working on it ...

Filters

Explore InChannel Snippets

Sort by

Found 500 snippets

    public by dawidkolonski modified Thursday at 10:50:11 AM  52  0  2  0

    ZXasdad

    ECHO Off
    @%WINDIR%\Microsoft.NET\Framework\v3.5\MSBuild.exe "c:\a\copy.proj"
    set BUILD_STATUS=%ERRORLEVEL% 
    IF NOT %BUILD_STATUS%==0 GOTO ERROR
    GOTO DONE
    
    :ERROR
    ECHO %ERRORLEVEL%
    ECHO --------------------------------------------------
    ECHO ERROR HAS OCCURED
    ECHO --------------------------------------------------
    pause
    GOTO END
    
    :DONE
    ECHO %ERRORLEVEL%
    ECHO "AllOK"
    pause
    :END

    public by Hlinh modified Monday at 8:29:22 AM  40  0  3  0

    Product Tabs For Magento 2

    Magento 2 Product Tabs extension allow admin to edit and add unlimited tabs for product details page.Default of magento v2, product details page just showing 3 tabs are: Details, More Information and Reviews. With this extension admin can add unlimited tabs. The tab can be use static blocks or attributes. View more: https://www.magesolution.com/pro
    View more: https://www.magesolution.com/product-tabs-for-magento-2.html						

    public by gwarah modified Feb 9, 2018  87  0  3  0

    mysnaps.sh

    Choose one snap app and run it. syntax: ./mysnaps.sh
    #!/bin/bash
    # program     : mysnaps.sh
    # description : choose one snap app and run it
    # author      : lp (Luís Pessoa)
    # version     : 0.1.0b
    # dependences : 
    #   1) shell: bash 
    #   2) packages awk, snap and zenity installed
    #   3) at least one snap app instaled
    # history     :
    #   lp; 07/02/2018; begin of development
    #   lp; 09/02/2018; first release
    
    ###############
    # functions
    ###############
    
    
    ###############
    # end functions
    ###############
    
    # building snap list header 
    snap_cols="$(snap list | \
    awk '{ if (NR == 1) { for (i = 1; i <= NF; i++)  printf "--column " $i " " }} ')"
    snap_cols="--column check ${snap_cols}"
    
    # building snap list options
    snap_ops=$(snap list | \
    awk '
    BEGIN { }
    {
    if (NR >= 2 ) {
        for (i = 1; i <= NF; i++) {
            
            if ( i == 1 ) {
                if ( $i == "core"  ) break;
                if (NR == 2) {printf "TRUE ";} 
                else {printf "FALSE ";}
            }
            printf $i;
            if ( i == NF ) { print "";}
            else { printf " "; }
       }
    }}')
    
    # snap app selection
    opc=$(zenity  --list  --text "Apps snaped " --radiolist  ${snap_cols} ${snap_ops})
    case $? in
             1)
                    echo "No snap app selected"
                    exit 1
                    ;;
            -1)
                    echo "Error!"
                    exit 1
                    ;;
    esac
    
    # run app selected
    app_opc=`echo $opc | awk '{print $1}'`
    ${app_opc}
    exit $?
    

    public by Hlinh modified Feb 9, 2018  47  0  3  0

    Page Builder for Magento 2 by Magesolution

    Page Builder for Magento 2 allows you to get rid of complicated steps to configure your site with minimal coding experiences required. Instead of login in the back-end, the fabulous feature allows you to build and configure Homepage, Category page, Product page, CMS pages straightly and visually at front-end. Also, it allows you to select header &
    https://www.magesolution.com/mgs-frontend-builder-theme-for-magento2.html						

    public by Hlinh modified Feb 5, 2018  66  0  2  0

    Popup for Magento 2

    Popup for Magento 2 is a great solution for those who want their visitors to be aware of all the latest and hot stuff on your store. This is a universal extension to create popups with any HTML content, image or form when pages load for grab customer attention. Promote your products, news, ads and events or collect information from users by any ki
    https://www.magesolution.com/popup-for-magento.html

    public by tomsim modified Jan 21, 2018  125  1  4  0

    Simple RPC call

    Simple function to call RPC (only 1k uncompressed). Use this instead of JQuery. Alternatively, use zepto.min.js from zeptojs.com if you have 26K to spare.
    /* 
    Addapted from Paolo Manna git pmanna/mongoose_os_playground browser_rpc_service.js
    */
    
    var platform = '';
    var host = '';
    
    var defCallBack = function(response) {
      if ((response) && (response.error)) {
    	  alert(response.message);
      }
    };
    
    // Common call to RPC services on the board
    function callRPCService(cmd, params, callback) {
      if (!callback) {
    	  callback = defCallBack;
      }
      var xhttp = new XMLHttpRequest();
      
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          callback(this.response);
        }
      };
      
      xhttp.open('POST', 'rpc/' + cmd + '?' + new Date().getTime(), true);
      xhttp.responseType = 'json';
      xhttp.send(JSON.stringify(params));
    }
    
    // Discover which platform we're using, to enable/disable features
    function startup() {
      callRPCService('Config.Get',{}, function(response) {
        if (response) {
          platform = response.device.id;
          console.log('Platform is: ' + platform);
    
          var mac_id = (response.device.id.split("_"))[1];
    
          host = mac_id + '.local';
          document.getElementById("hostname").innerHTML = host;
        }
      });
    }
    
    // Reboots the microcontroller
    function rebootDevice() {
      callRPCService('Sys.Reboot',{delay_ms:500});
    }
    
    						

    public by tomsim modified Jan 21, 2018  91  1  2  0

    Using simple RPC service

    Use simple rpc script to call RPC service on small IOT devices
    <html>
    <head>
    	<script src="simple_rpc_service.js"></script>
    </head>
    <body onLoad='startup();'>
    <h4 id="hostname"> </h4>
    <p>Hello, see <a target="_blank" href="/rpc/Config.Get">rpc</a>
    <br><a target="_blank" href="/rpc/clearAll">clear strip</a>
    
    <p><table>
      <tr><td>Pin</td> <td><input type="number" id="GPIO.pin" value='2'/></td></tr>
      <tr><td>Red</td><td><input type="range" id="rval" name="rval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr>
      <tr><td>Green</td><td><input type="range" id="gval" name="gval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr>
      <tr><td>Blue</td><td><input type="range" id="bval" name="bval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr>
    </table>
    <p><button href="#" id="setPixel" onclick="setPixel()">Set Pixel</button>
    <button href="#" id="clearAll" onclick="callRPCService('clearAll')">Clear All Pixel</button>
    <p><button href="#" id="setPixel" onclick="rebootDevice()">Reboot</button>
    
    <script>
    
      var log = function(msg) {
        console.log(msg);
      };
      log('Starting ...');
      function setPixel() {
        log("setPixel...");
      	var pin = parseInt(document.getElementById("GPIO.pin").value);
      	var rv = parseInt(document.getElementById("rval").value);
      	var gv = parseInt(document.getElementById("gval").value);
      	var bv = parseInt(document.getElementById("bval").value);
    	callRPCService('setPixel',{px:pin, r:rv, g:gv, b:bv});
      };
    </script>
    
    </body>
    </html>
    

    public by tomsim modified Jan 21, 2018  125  2  4  0

    ESP8266 wifi web server setup

    Lambda style Wifi web server with DHT22 data upload to ThingSpeak
    /* DHTServer - ESP8266 Webserver with a DHT sensor as an input
    
       Based on ESP8266Webserver, DHTexample, and BlinkWithoutDelay (thank you)
    
       Version 1.0  5/3/2014  Version 1.0 Mike Barela for Adafruit Industries
    */
    #include <ESP8266WiFi.h>
    #include <WiFiClient.h>
    #include <ESP8266WebServer.h>
    #include <DHT.h>
    #include <TimeLib.h>
    #include "ThingSpeak.h"
    
    #define DHTTYPE DHT22
    
    const int DHTPIN = D4;
    
    const char* ssid     = "mySSID";
    const char* password = "myPassword";
    
    ESP8266WebServer server(80);
    
    /*============ ThingSpeak setup ==================*/
    // Note:  Each channel has its own number and write API key
    // API key is what get used - wrong channel number doesn't matter
    
    // Temperature Humidity Channel
    static unsigned long myChannelNumber = 123456;
    static const char 	*myWriteAPIKey = "AB1CDEF6HIJKLMNO";
    static WiFiClient  client;
    
    /*============ End ThingSpeak setup ==============*/
    
    
    // Initialize DHT sensor 
    // NOTE: For working with a faster than ATmega328p 16 MHz Arduino chip, like an ESP8266,
    // you need to increase the threshold for cycle counts considered a 1 or 0.
    // You can do this by passing a 3rd parameter for this threshold.  It's a bit
    // of fiddling to find the right value, but in general the faster the CPU the
    // higher the value.  The default for a 16mhz AVR is a value of 6.  For an
    // Arduino Due that runs at 84mhz a value of 30 works.
    // This is for the ESP8266 processor on ESP-01 
    DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266
     
    float lastHumdty, lastTempF;  // Values read from sensor
    static int nextSampleMinute = 15;
    static int minuteSampleInterval = 15;
    
    // Generally, you should use "unsigned long" for variables that hold time
    unsigned long previousMillis = 0;        // will store last temp was read
    const long interval = 2000;              // interval at which to read sensor
    
    void getTemperature() {
      // Wait at least 2 seconds seconds between measurements.
      // if the difference between the current time and last time you read
      // the sensor is bigger than the interval you set, read the sensor
      // Works better than delay for things happening elsewhere also
      unsigned long currentMillis = millis();
     
      if(currentMillis - previousMillis >= interval) {
        // save the last time you read the sensor 
        previousMillis = currentMillis;   
    
        // Reading temperature for humidity takes about 250 milliseconds!
        // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
        lastHumdty = dht.readHumidity();          // Read humidity (percent)
        lastTempF = dht.readTemperature(true);     // Read temperature as Fahrenheit
        // Check if any reads failed and exit early (to try again).
        if (isnan(lastHumdty) || isnan(lastTempF)) {
          Serial.println("Failed to read from DHT sensor!");
          return;
        }
      }
    }
    
    static int uploadData(void)
    {
    	ThingSpeak.setField( 1, lastTempF);
    	ThingSpeak.setField( 2, lastHumdty);
    	int rc = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    //	Serial.println(String("Post rc=")+rc);
    	return rc;
    }
    
     
    const String HTML_TYPE = "text/html";
    
    void handle_null() {
        Serial.println("Handle null");
    	server.send(200,HTML_TYPE,"");
    	delay(100);
    }
    void handleRoot()
    {
    	String wstr = 
    	"<p>Hello from the weather esp8266, read from /temp or /humidity"
    	"<br>set <a href=/set?minuteSampleInterval=5>5 minute</a> sample interval"
    	", <a href=/set?nextSampleMinute=15>sample at 15 </a> minute"
    	"<br>Take <a href=/sample>sample Data</a> and upload to ThingSpeak"
    	"<br><a href=/temp>Get Temperature</a>"
    	"<br><a href=/humidity>Get Humidity</a>";
    	wstr += "<br>Last temperature: " + String(lastTempF)+"F";
    	wstr += " humidity: " + String(lastHumdty)+"%";
    	wstr += "<br>Current minute: " + String(minute(now()));
    	wstr += " next sample time: " + String(nextSampleMinute)+" min.";
    	wstr += " sample interval: " + String(minuteSampleInterval)+" min.";
    	server.send(200,HTML_TYPE, wstr);
    	delay(100);
    }
    void doSample()
    {
    	Serial.println("DoSample");
    	getTemperature();
    	int rc = uploadData();
    	String wstr = "<p>Take sample data:  ";
    	wstr += "<br>Temperature " + String(lastTempF);
    	wstr += "<br>Humidity " + String(lastHumdty);
    	wstr += "<br>Upload thingspeak rc=" + String(rc);
    	server.send(200,HTML_TYPE, wstr);
    }
     
    // Web Server Service Definition structure
    // =======================================
    typedef struct s_WebServiceDef
    {
    	const char *urlName;
    	void (*doit)(void);
    } WebServiceDef;
    
    /* =======================================================================
    	Define web service definition here
    	Each entry has a URL name and a lambda function to service the request
       =======================================================================
    */
    static WebServiceDef wsd[] = {
    	{ "/", handleRoot },
    	{ "/favicon", handle_null },
    	{ "/temp",			// url name
    		[] ()				// lambda function
    		{
    			getTemperature();       // read sensor
    			String wstr="Temperature: "+String((int)lastTempF)+" F";
    			server.send(200, "text/plain", wstr);   // send to someones browser when asked
    		}
    	},
    	{ "/humidity", []()
    		{ 
    			getTemperature();
    			String wstr="Humidity: "+String((int)lastHumdty)+"%";
    			server.send(200, "text/plain", wstr);
    		}
    	},
    	{ "/sample", doSample },
    	{ "/set", []()
    		{
    			String n = String("minuteSampleInterval");
    			if (server.hasArg(n))
    			{
    				int v = server.arg(n).toInt();
    				if (v)
    					minuteSampleInterval = v;
    			}
    			n = String("nextSampleMinute");
    			if (server.hasArg(n))
    			{
    				int v = server.arg(n).toInt();
    				if (v)
    					nextSampleMinute = v;
    			}
    			server.send(200, "text/plain", "ok");
    		}
    	},
     	{0,0}
    };
    
    static void setupServerHandler(void)
    {
    	for (int i; wsd[i].urlName; i++)
    	{
    		server.on( wsd[i].urlName, wsd[i].doit);
    	}
    	server.onNotFound(handleRoot);
    }
    
    static int nextAlarmMin(int sampleInterval)
    {
    	int nextMin = minute(now());
    	nextMin = ((nextMin + sampleInterval) % 60);	// alarm every 5 min
    	return nextMin;
    }
    
    
    
    void setup(void)
    {
    	// You can open the Arduino IDE Serial Monitor window to see what the code is doing
    	Serial.begin(115200);  // Serial connection from ESP-01 via 3.3v console cable
    	dht.begin();           // initialize temperature sensor
    
    	// Connect to WiFi network
    	WiFi.begin(ssid, password);
    	Serial.print("\n\r \n\rWorking to connect");
    
    	// Wait for connection
    	while (WiFi.status() != WL_CONNECTED) {
    	delay(500);
    	Serial.print(".");
    	}
    	Serial.println("");
    	Serial.println("DHT Weather Reading Server");
    	Serial.print("Connected to ");
    	Serial.println(ssid);
    	Serial.print("IP address: ");
    	Serial.println(WiFi.localIP());
    
    	ThingSpeak.begin(client);
    
    	setupServerHandler();
    
    	server.begin();
    	Serial.println("HTTP server started");
    }
     
    void loop(void)
    {
    	int currentMinute = minute(now());
    
    	if (currentMinute == nextSampleMinute)
    	{
    		// trigger sample at set interval
    		Serial.println("Regular sample");
    		getTemperature();
    		int rc = uploadData();
    		Serial.println("rc=" + String(rc));
    
    		nextSampleMinute = nextAlarmMin(minuteSampleInterval);
    		delay(1000);
    	}
    
    	server.handleClient();
    } 
    
    
    • Public Snippets
    • Channels Snippets