Skip to content

Instantly share code, notes, and snippets.

View natevw's full-sized avatar

Nathan Vander Wilt natevw

View GitHub Profile
@kabturek
kabturek / pins_arduino.c
Created July 14, 2011 10:37
Arduino port mapping with additional pins PB6 & PB7
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
PD, /* 0 */
PD,
PD,
PD,
PD,
PD,
PD,
PD,
PB, /* 8 */
@stolsma
stolsma / example.js
Created September 20, 2011 14:47
Downgrade process after connecting to port 80
app.listen(process.env.NODE_ENV === 'production' ? 80 : 8000, function() {
console.log('Ready');
// if run as root, downgrade to the owner of this file
if (process.getuid() === 0)
require('fs').stat(__filename, function(err, stats) {
if (err) return console.log(err)
process.setuid(stats.uid);
});
});
@creationix
creationix / jsonparse.js
Created February 13, 2012 23:20
event-only version of jsonparse
// Named constants with unique integer values
var C = {};
// Tokenizer States
var START = C.START = 0x11;
var TRUE1 = C.TRUE1 = 0x21;
var TRUE2 = C.TRUE2 = 0x22;
var TRUE3 = C.TRUE3 = 0x23;
var FALSE1 = C.FALSE1 = 0x31;
var FALSE2 = C.FALSE2 = 0x32;
var FALSE3 = C.FALSE3 = 0x33;

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@rodw
rodw / pid-file-daemon.sh
Created August 14, 2012 01:53
Bash script that uses a PID file to add daemon-like start/stop/status behavior to an arbitrary program.
#!/bin/bash
# Uses a PID file to add daemon-like behavior to an arbitrary program.
################################################################################
usage() {
echo "Usage: `basename $0` PROGRAM {start|stop|restart|force-stop|force-restart|status} [PIDFILE|PID]" >&2
echo "Where: PROGRAM is an executable file." >&2
echo " PIDFILE is the file that contains (or will contain) the PID." >&2
echo " PID is a process id to use in place of a PIDFILE." >&2
}
@max-mapper
max-mapper / readme.md
Last active June 3, 2020 00:31
automatically scan for and join open internet enabled wifi networks on linux using node.js (tested on raspberry pi raspbian)
@johnjohndoe
johnjohndoe / delicious.js
Last active July 25, 2017 13:49
Bookmarklet of del.icio.us. Latest version available at https://del.icio.us/tools. This Gist tracks the changes made to the script. Javascript is formatted via http://jsbeautifier.org. - The authors of the script are the guys from del.icio.us.
javascript: (function($) {
var bookmarklet = document.getElementById(
'DELI_save_link_slidedown');
if (bookmarklet) {
$('#DELI_mist').show();
$('#DELI_save_link_slidedown').slideDown('normal');
return
};
if (!window.jQuery) {
node = document.createElement('SCRIPT');
@natevw
natevw / psc↔pdx|sea transportation schedules.md
Last active August 30, 2018 21:24
Direct connections available between the Tri-Cities and Portland or Seattle, with approximate prices as of 2013 April.

All price estimates are for one-way. Car and train and bus return doubles price, air has significant discount for round trip.

TODO: For longer trips it can be a little cheaper to ride Amtrak by signing up for rewards, buying miles, then booking tickets; haven't calculated cost for Portland yet.

PSC ↔ PDX

Car $26

Downtown Portland is about 215 miles from the Tri-Cities and takes about 3h30m. Cost calculated with gas at $3.69/gal and fuel economy averaging 30mpg (i.e. 12.3¢/mile).

@landonf
landonf / watchdog.c
Last active October 4, 2020 17:44
Enables OS X's hardware watchdog.
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <dispatch/dispatch.h>
// 5 minutes
#define TIMEOUT (5*60)
bool reset_watchdog (int timeout) {
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOWatchDogTimer"));
if (service == IO_OBJECT_NULL) {
@tmcw
tmcw / jargon.md
Last active October 5, 2016 14:39
Startup English
This team is growing We're hiring lots of people
"Hunger" Enthusiasm
"Fire" Enthusiasm
"Spark" Enthusiasm
Commander's intent Goals
Onboarding Training
The best Pretty good
Burn Money-losing