Skip to content

Instantly share code, notes, and snippets.

View supershabam's full-sized avatar
📴

Ian Hansen supershabam

📴
View GitHub Profile
@supershabam
supershabam / gist:5c415683f5bd4c0afe9b
Created December 3, 2014 23:19
dynamic iptables rules using updating groups
# Accept packets from trusted IP addresses
iptables -A INPUT -s group:web_workers -j ACCEPT # change the IP address as appropriate
# enumerates group to create several rule lines
# iptables -A INPUT -s 123.1.1.2 -j ACCEPT # change the IP address as appropriate
# iptables -A INPUT -s 123.1.1.3 -j ACCEPT # change the IP address as appropriate
# as the web_workers group is updated, the rules are recreated and iptables flushed

yank could be a tool to pull source code into your own project

philosophy

  • no new package manager
  • dependencies should be committed in code
  • dependencies should be easily updated
  • dependencies should easily be checked for out-of-dateness

similar to go get for getting code, except specify where to insert the code and write a file to describe what you've yanked.

# editing nodeifyme settings for $EMAILADDRESS
#
# {module}@{majorTimer}.{minorTimer}.{patchTimer}
#
# timers
# i - immediately
# d - daily
# w - weekly
# n - never
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
set nocompatible " be iMproved
filetype on
filetype off
filetype plugin indent off
set runtimepath+=~/.vim/bundle/vundle/
set runtimepath+=$GOROOT/misc/vim
call vundle#rc()
@supershabam
supershabam / gist:8800304
Last active August 29, 2015 13:56
promised stream
// backpressure is better modeled with a promised event
var stream
// our data listeners are functions that *may* return a promise
// when the promise resolves, the data has been consumed and the stream may continue
stream.on('data', function(data) {
// simulate being busy by returning a promise that resolves in 150ms
return new Promise(function(resolve, reject) {
setTimeout(function() {
console.log('laggy-stream: ', data)
{
listings: [
"[email protected]:supershabam/slchouse",
"[email protected]:supershabam/condo"
]
}
@supershabam
supershabam / index.js
Created December 4, 2013 05:49
requirebin sketch
// require something
var URL = require('websocket-url')
console.log(URL.parse('ws://test.com'))
@supershabam
supershabam / WorkEmitter.js
Created December 3, 2013 00:46
WorkEmitter
// problem: you need to emit an event and then do something AFTER the handlers have completed
// EventEmitter works ONLY if your event handlers are not async. If you're working in the browser and you
// emit an event and then change page, or submit a form, you run the risk of your async handlers not completing
// before you change pages
// WorkEmitter has the same interface as EventEmitter, except it expects that the handlers will return a promise.
var Q = require('q')
emitter.on('submit', function(form) {
var deferred = Q.defer()
@supershabam
supershabam / client.html
Last active December 27, 2015 20:09
A browser using PolySocket
<!DOCTYPE html>
<html>
<head>
<script src='//polysocket.io/polysocket.js'></script>
<script>
// PolySocket behaves exactly like a WebSocket
// http://www.html5rocks.com/en/tutorials/websockets/basics/
var ps = new PolySocket('ws://node.remysharp.com:8001/')
ps.onmessage = function(data) {
console.log(data)