Pages

Labels

Sample (14) Intent (5) Media (5) Location (4) Funny (3) HTTP (3) Sleep as Android (3) WiFi (3) Alarm (2) Recording (2) Regexp (2) Array (1) Basic (1) Battery (1) Browser (1) Calculator (1) Contacts (1) Content Provider (1) Cron (1) Dialog (1) Dictionary (1) Export (1) Function (1) GUI (1) Game (1) Loop (1) Random (1) SD Card (1) Social (1) Temperature (1) Text to Speech (1) Weather (1)

Search Scripts

Loading...

2015-04-08

Turn wifi on when home or work and off when out

// Turn wifi on when home or work and off when out

loc = location();
log("Current location lat: " ~ loc["lat"] ~ " lon: " ~ loc["lon"]);

while(true) {

  // put your work location here
  iAmWork = near(10, 20, 700);
// put your home location here
iAmHome = near(10, 30, 100);
  if (iAmWork) {
    log("At work");
    enableWifi(true);
  } else if (iAmHome) {
    log("At home");
    enableWifi(true);
    } else {
    log("Out");
    enableWifi(false);

  }  
  // wait 2 minutes till next check
  sleep(120000);

}

  

2013-10-30

Hello World by Dan

// the obligatory Hello World example

log("Hello World!");
alert("Hello World!");
// notify("Hello World!");
// speak("Hello World!");


2013-05-19

Weather forecast by Taha

// timeout
r = waitForConnectivity(0);

beep(2000);

response = httpGet("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D1540935&format=json&callback=cbfunc");

speak("Attention : flash météo","french");

temp = find('"temp":"([0-9]+)"', response[1]);
tempC = round((number(temp[0])-32)*0.555);
humidity = find('"humidity":"([0-9]+)"', response[1]);

speed = find('"speed":"([0-9]+)"', response[1]);
speedKph = round(number(speed[0])/1.6);

windDirection = find('"direction":"([0-9]+)"', response[1]);

windL = "";
if(number(windDirection) > 285){
windL = "Nord ";
}
if(number(windDirection) < 75) {
windL = "Nord ";
} 
if(number(windDirection) < 255){
if(number(windDirection) > 105) {
windL = "Sud ";
}}
if(number(windDirection) > 45 ){
if(number(windDirection) < 135) {
windL = windL ~ "Est ";
}}
if(number(windDirection) < 325){
if(number(windDirection) > 225 ) {
windL = windL ~ "Ouest ";
}}

visibility = find('"visibility":"([0-9]+.[0-9]+)"', response[1]); 
visibilityKm = round( number(visibility[0])*1.6);
speak("La température à Tanger est "~tempC~" °C","french");
speak("L'humidité est de "~humidity[0]~"%","french");
speak("La vitesse du vent  est "~ speedKph~" Km/h en direction "~windL,"french");
speak("La visibilité est de "~ visibilityKm~" Km","french");

beep(2000);

2013-02-26

Turn wifi on when coming home (by Jaromir)

// Turn wifi on when coming home 

loc = location(); 
log("Current location lat: " ~ loc["lat"] ~ " lon: " ~ loc["lon"]); 

while(true) { 

  //if airplane mode ON, don't turn wifi ON 
  if(setting("airplane_mode_on") == 0){ 

    // put your home location here 
    iAmHome = near(50.00, 14.00, 1000); 

    if (iAmHome) { 
      log("At home"); 
      enableWifi(true); 
    } 
  } 

  // wait 2 minutes till next check 
  sleep(120000); 
}

2012-12-28

Drop the bomb (by Jeremy)

r = rand(5, 60);

while (r > 0)
{
beep();
r = r - 1;
sleep(1000);
}

noise = play("/sdcard/download/bomb.mp3", "");

2012-10-10

View image

startIntent("android.intent.action.VIEW", "file:///sdcard/urbandroid.png", "image/png");

2012-06-28

Sample: Address from Facebook


here = location(false, 2);
result = httpGet("http://maps.googleapis.com/maps/api/geocode/json?latlng="~here["lat"]~","~here["lon"]~"&sensor=true");

log(""~result[1]);

place = find("formatted_address. : (.*)", result[1]);

post("Currently I'm at "  ~ place[0], "facebook");
post("Currently I'm at " ~  place[0], "twitter");