Skip to content

Instantly share code, notes, and snippets.

View bluetooth_chat_server.py
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()
View daveDemo.py
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.
View index.html
<!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>
View qpython_kivy_sl4a.py
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)
@dvas0004
dvas0004 / raspiCC_flask.py
Last active Aug 29, 2015
web interface for raspi CC
View raspiCC_flask.py
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 Aug 29, 2015
raspi CC PIR and cam script
View raspiCC_pir.py
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"
View raspiCC_LiveSecurityCam.sh
#!/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 Apr 17, 2014
progress dialog nugget
View progressDialog.java
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() {
View stuctArray.go
/*
Start Webserver Section
*/
type Page struct {
Title string
Body string
Alerts []string
}
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
View golangRepetition.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container well">
<h2>Alerts</h2>
<hr>
{{range $element := .Alerts}}