Skip to content

Instantly share code, notes, and snippets.

View indieisaconcept's full-sized avatar

Jonathan Barnett indieisaconcept

View GitHub Profile
@mlafeldt
mlafeldt / parse_cheffile.rb
Created October 23, 2012 15:08
Parse Cheffile in Ruby
#!/usr/bin/env ruby
class CookbookSource
attr_reader :name, :options
def initialize(name, options = {})
@name = name
@options = options
end
end
@miohtama
miohtama / gist:4062655
Created November 12, 2012 23:04
Migrate several SVN projects to Github using a shell script
#!/bin/zsh
#
# Install svn2git https://github.com/nirvdrum/svn2git
# Install curl: sudo apt-get install curl
#
# Create API token Github on command line before running this script
#
# curl -u 'miohtama' -d '{"scopes":["repo"],"note":"migrate.sh"}' https://api.github.com/authorizations
#
# More info https://help.github.com/articles/creating-an-oauth-token-for-command-line-use
@jrburke
jrburke / builder.js
Created December 1, 2011 19:07
Multiple single file builds using one "build script" for requirejs optimizer
//Load the requirejs optimizer
var requirejs = require('./path/to/r.js'),
//Set up basic config, include config that is
//common to all the optimize() calls.
basConfig = {
baseUrl: './some/path',
paths: {
//whatever is neded globally.
}
};
#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A
@passcod
passcod / dom-loaded-test.html
Created May 26, 2012 08:29
onload, readyState, and DOMContentLoaded
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function () {
console.log(''+(+new Date)+': Onload fired');
};
document.onreadystatechange = function () {
console.log(''+(+new Date)+': Ready state changed');
@durango
durango / app.js
Created December 3, 2012 15:41 — forked from katanacrimson/app.js
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@brasic
brasic / clear_redis_script.rb
Last active October 13, 2020 19:52
Clear a large number of redis keys by pattern using SCAN and pipelining
#!/usr/bin/env ruby
require 'redis'
# Clear a large number of keys matching a pattern using SCAN and
# pipelining to avoid killing the server.
class ClearKeys
def initialize(pattern, host='localhost', postprocess_pattern=nil)
@redis = Redis.new(host: host)
@pattern = pattern
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@MattiSG
MattiSG / brewv
Created July 9, 2012 14:05
Install a previous version of a formula with Homebrew
#!/bin/bash
#
# Installs the previous version of a Homebrew formula
#
# Usage: brewv formula_name desired_version
#
# Based on http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula#9832084
#
# Author: Matti Schneider <hi@mattischneider.fr> (http://mattischneider.fr)