Skip to content

Instantly share code, notes, and snippets.

View rjcorwin's full-sized avatar

R.J. (Steinert) Corwin rjcorwin

View GitHub Profile
#!/bin/sh
MYVERSION="0.2.0e"
#
# Sakis3G All-in-one script
# Copyright (c) 2009, 2010 Sakis Dimopoulos (sakis3g @domain sakis3g.org)
# Under GNU GPL v2.
#
# URL: http://www.sakis3g.org/
# License: http://www.gnu.org/licenses/gpl.txt
#
ssh root@192.168.0.111
apt-get install ppp
mkdir /root/umtskeeper
cd /root/umtskeeper
wget https://gist.github.com/rjsteinert/6273133/raw/988fa477f9f6a1c2fd5ea24dbd6001ff1b413b96/sakis3G
chmod +x sakis3g
wget "http://mintakaconciencia.net/squares/umtskeeper1/src/umtskeeper.tar.gz"
tar -xzvf umtskeeper.tar.gz
chmod +x umtskeeper
mkdir /home/pi/umtskeeper
@rjcorwin
rjcorwin / set-channel-in-form-for-qwebirc.js
Created August 22, 2013 21:58
Changes the channels text box to your channel of your choosing.
document.getElementsByTagName('input')[1].value = "#treehouse";

#vim shortcuts I use.md

0 - home

$ - end

k - up

j - down

working with hexadecimals in #javascript.md

back and forth

(parseInt(1373487419, 16)).toString(16)

convert hexadecimal to integer

var s = "1f"; alert(parseInt(s, 16)); // 31

@rjcorwin
rjcorwin / OpenFileIntoBrowser-TransformText-SaveFileToCouchDB.html
Created September 24, 2013 18:04
This file assumes it's living in a CouchDB doc and will find and save the file to be transformed to the CouchDB Doc that it is sitting in.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Find and Replace</title>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
</head>
@rjcorwin
rjcorwin / node-js-debug-in-google-chrome.md
Last active January 2, 2016 21:08
Fastest and most lightweight method for starting a GUI based debugger I've ever seen. For node.js, this debugs your code using the Developer Tools in Google Chrome.

install

npm install -g node-inspector;

run debugger

node-inspector & ;
node --debug your/node/program.js;

Callback Hell

Callbacks are rampant in Javascript, this can cause what's known as "Callback Hell", or as I like to call. Rat nests. In the following example the "rat nest" is not that hard to follow along with, and that will be the case when your program is simple. But imagine when your program grows to have many rat nests, perhaps even the rat nests become intertwined. Messy.

/*
 * Callback hell example
 */

function yell(text, callback) {
@rjcorwin
rjcorwin / proxy-a-couchdb-with-another-service.js
Created February 7, 2014 17:09
Combine the CouchDB API with another HTTP API using Node.js http-proxy module.
var httpProxy = require('http-proxy')
var options = {
router: {
'mydomain.com/api': '127.0.0.1:8800', // -> Additional API possibly from an Express App
'mydomain.com/*': '127.0.0.1:5984', // -> CouchDB binded to the base so it behaves just like a CouchDB
}
}