This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* 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 | |
*******************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Track basic JavaScript errors | |
window.addEventListener('error', function(e) { | |
_gaq.push([ | |
'_trackEvent', | |
'JavaScript Error', | |
e.message, | |
e.filename + ': ' + e.lineno, | |
true | |
]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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