Skip to content

Instantly share code, notes, and snippets.

if (currentRange > stopRange) {
forward();
currentRoutine = 'd';
actionDelay = 50;
}else {
if (currentRoutine != 'e') {
engine_stop();
delay(400);
back();
@DzikuVx
DzikuVx / gist:5693478
Last active December 17, 2015 23:59
JavaScript Local Storage with item expire
/**
* localStorage with expire wrapper
*/
var myStorage = (function() {
var self = {};
/**
* Method unsets value in localStorage
*/
self.unset = function(key) {
self.getCurrent = function(onSuccess, onFailure) {
var cache = myStorage.get('current-json');
if (cache === null) {
$.ajax({
url : "http://api.openweathermap.org/data/2.5/weather?id=3083829&mode=json&units=metric",
dataType : 'jsonp',
success : function(json) {
function myFunction(foo) {
bar = 'foo';
console.log(bar);
console.log(foo);
}
var bar = 'bar',
baz = 'baz';
console.log(bar);
#!/bin/sh
tries=0
while [[ $tries -lt 5 ]]
do
if /bin/ping -c 1 8.8.8.8 >/dev/null
then
exit 0
fi
tries=$((tries+1))
package pl.spychalski.WeatherStation;
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
public class PogodaApplication extends Application {
private Tracker appTracker = null;
<application
android:logo="@drawable/ab_icon"
android:label="@string/app_name"
android:name=".PogodaApplication"
android:icon="@drawable/ic_launcher">
@Override
public void onResume() {
super.onResume();
Tracker t = ((PogodaApplication) getApplication()).getTracker();
t.setScreenName("ForecastActivity");
t.send(new HitBuilders.AppViewBuilder().build());
}
import RPi.GPIO as GPIO
import time
def main():
# GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, GPIO.HIGH)
time.sleep(5);
void enterSleep(void) {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();
sleep_disable();
}