View bb-python-gpio-test.py
#!/usr/bin/python | |
import time | |
# Open up the pins and set mode in/out | |
# TODO: Error handling | |
outPin = file("/sys/class/gpio/export", "w") | |
outPin.write("%d" % (38)) | |
outPin.close() | |
outPin = file("/sys/class/gpio/gpio38/direction", "w") |
View gist:8195325
// Taken from: http://net.tutsplus.com/tutorials/javascript-ajax/managing-the-asynchronous-nature-of-node-js/ | |
// STANDARD | |
app.get('/login', function (req, res) { | |
sql.query('SELECT 1 FROM users WHERE name = ?;', [ req.param('username') ], function (error, rows) { | |
if (error) { | |
res.writeHead(500); | |
return res.end(); | |
} | |
if (rows.length < 1) { |
View template.c
/******************************************************************************* | |
* Title : System Initialization | |
* Filename : sys_init.c | |
* Author : JWB | |
* Origin Date : 04/23/2012 | |
* Version : 1.0.0 | |
* Compiler : Microchip C30 v3.30c | |
* Target : PIC24FJ64GB004 | |
* Notes : None | |
*******************************************************************************/ |
View debounce.c
#define CHECK_MSEC 5 // Read hardware every 5 msec | |
#define PRESS_MSEC 10 // Stable time before registering pressed | |
#define RELEASE_MSEC 100 // Stable time before registering released | |
// This function reads the key state from the hardware. | |
extern bool_t RawKeyPressed(); | |
// This holds the debounced state of the key. | |
bool_t DebouncedKeyPress = false; | |
// Service routine called every CHECK_MSEC to | |
// debounce both edges | |
void DebounceSwitch1(bool_t *Key_changed, bool_t *Key_pressed) |
View ga_error.js
// Track basic JavaScript errors | |
window.addEventListener('error', function(e) { | |
_gaq.push([ | |
'_trackEvent', | |
'JavaScript Error', | |
e.message, | |
e.filename + ': ' + e.lineno, | |
true | |
]); | |
}); |
View angular-socket-io.js
factory('socket', ['$rootScope', 'io', function($rootScope, io) { | |
var socket = io.connect(), | |
events = {}, | |
that = {}; | |
var addCallback = function(name, callback) { | |
var event = events[name], | |
wrappedCallback = wrapCallback(callback); | |
if (!event) { |
View socket.js
appServices.factory('socket', function ($rootScope) { | |
var socket = io.connect('http://localhost:3000'); | |
return { | |
on: function (eventName, callback) { | |
socket.on(eventName, function () { | |
var args = arguments; | |
$rootScope.$apply(function () { | |
callback.apply(socket, args); | |
}); | |
}); |
View split_bootimg.pl
#!/usr/bin/perl | |
###################################################################### | |
# | |
# File : split_bootimg.pl | |
# Author(s) : William Enck <enck@cse.psu.edu> | |
# Description : Split appart an Android boot image created | |
# with mkbootimg. The format can be found in | |
# android-src/system/core/mkbootimg/bootimg.h | |
# | |
# Thanks to alansj on xda-developers.com for |
View getopts.sh
#!/bin/bash | |
###################################################################### | |
#This is an example of using getopts in Bash. It also contains some | |
#other bits of code I find useful. | |
#Author: Linerd | |
#Website: http://tuxtweaks.com/ | |
#Copyright 2014 | |
#License: Creative Commons Attribution-ShareAlike 4.0 | |
#http://creativecommons.org/licenses/by-sa/4.0/legalcode |
View androidVersion.java
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { | |
AlertDialog.Builder dialog = new AlertDialog.Builder(BlueBand.this); | |
dialog.setTitle("Error"); | |
dialog.setMessage("Support Android 4.3 or above only."); | |
dialog.setNegativeButton("OK", | |
new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
System.exit(0); |
OlderNewer