Skip to content

Instantly share code, notes, and snippets.

import android
import time
droid = android.Android()
droid.toggleBluetoothState(True)
droid.dialogCreateAlert('Be a server?')
droid.dialogSetPositiveButtonText('Yes')
droid.dialogSetNegativeButtonText('No')
droid.dialogShow()
result = droid.dialogGetResponse()
from android import Android
import time,sys
# Prepare the python for android API
droid = Android()
# Instruct Py4A which HTML file to use for the webview (we’ll explore this later)
droid.webViewShow('file:///sdcard/sl4a/scripts/daveTest/index.html')
# SL4A uses the concept of events, like javascript does.
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="file:///sdcard/sl4a/scripts/daveTest/css/bootstrap.min.css" />
<script src="file:///sdcard/sl4a/scripts/daveTest/js/bootstrap.min.js"></script>
<script>
import androidhelper
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def buttonPress(self,instance):
droid = androidhelper.Android()
line = droid.dialogGetInput()
s = 'Hello %s' % line.result
droid.makeToast(s)
from bluetooth import *
import sys
from subprocess import call
if sys.version < '3':
input = raw_input
addr = None
@dvas0004
dvas0004 / daveOLED.py
Created March 9, 2014 16:49
raspi pi OLED code showing IP and temperature + humidity
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Meant for use with the Raspberry Pi and an Adafruit monochrome OLED display!
# This was coded by David Vassallo, modified from code by The Raspberry Pi Guy
# Imports all of the necessary modules
import gaugette.ssd1306
import time
@dvas0004
dvas0004 / raspiCC_flask.py
Last active August 29, 2015 13:57
web interface for raspi CC
from flask import Flask
from flask import render_template
from flask import redirect, url_for
import dhtreader
import cPickle as pickle
from subprocess import call
app = Flask(__name__)
@app.route('/toggle')
def toggle():
@dvas0004
dvas0004 / raspiCC_pir.py
Last active August 29, 2015 13:57
raspi CC PIR and cam script
from subprocess import call
import time, datetime
import smtplib, ftplib
import RPi.GPIO as io
import multiprocessing
io.setmode(io.BCM)
pir_pin = 24
GMAIL_USERNAME = "YOUR_EMAIL_ADDRESS_HERE"
#!/bin/bash
mkdir /tmp/mjpg
raspistill -tl 500 -t 0 -vf -w 640 -h 480 -o /tmp/mjpg/test.jpg -n -q 50 & > /dev/null 2>&1
LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "input_file.so -f /tmp/mjpg -n test.jpg" -o "output_http.so -w /usr/local/www" -b
@dvas0004
dvas0004 / progressDialog.java
Created April 17, 2014 15:44
progress dialog nugget
uploadButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
//perform upload action
Thread thread = new Thread()
{
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {