Skip to content

Instantly share code, notes, and snippets.

View jonsherrard's full-sized avatar
💭
Working

Jon Sherrard jonsherrard

💭
Working
View GitHub Profile
@engelfrost
engelfrost / LICENSE
Last active September 2, 2020 11:15
Fake localStorage. Useful for Safari Private Browsing and browsers that don't implement localStorage.
The MIT License (MIT)
Copyright (c) 2015 Textalk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@brianc
brianc / gist:f906bacc17409203aee0
Last active December 22, 2023 00:47
Some thoughts on node-postgres in web applications

Some thoughts on using node-postgres in a web application

This is the approach I've been using for the past year or so. I'm sure I'll change and it will change as I grow & am exposed to more ideas, but it's worked alright for me so far.

Pooling:

I would definitely use a single pool of clients throughout the application. node-postgres ships with a pool implementation that has always met my needs, but it's also fine to just use the require('pg').Client prototype and implement your own pool if you know what you're doing & have some custom requirements on the pool.

@shantanuo
shantanuo / mysql_to_big_query.sh
Last active September 14, 2022 07:12
Copy MySQL table to big query. If you need to copy all tables, use the loop given at the end. Exit with error code 3 if blob or text columns are found. The csv files are first copied to google cloud before being imported to big query.
#!/bin/sh
TABLE_SCHEMA=$1
TABLE_NAME=$2
mytime=`date '+%y%m%d%H%M'`
hostname=`hostname | tr 'A-Z' 'a-z'`
file_prefix="trimax$TABLE_NAME$mytime$TABLE_SCHEMA"
bucket_name=$file_prefix
splitat="4000000000"
bulkfiles=200
@adammw
adammw / README.md
Created August 3, 2012 06:30
Node.js for Raspberry Pi

Node.js for Raspberry Pi

Pre-built binaries

Recent releases have been pre-built using cross-compilers and this script and are downloadable below.

If you have found these packages useful, give me a shout out on twitter: @adammw

@FigmentEngine
FigmentEngine / TMUXonEC2.sh
Created April 27, 2012 15:54
Install TMUX on Amazon Linux (EC2)
wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
tar zxf libevent-2.0.18-stable.tar.gz
cd libevent-2.0.18-stable
sudo ./configure
sudo ./make
DIR="/home/ec2-user/downloads/libevent-2.0.18-stable"
wget http://downloads.sourceforge.net/tmux/tmux-1.6.tar.gz
tar zxf tmux-1.6.tar.gz
cd tmux-1.6
@jzazove
jzazove / gist:1479763
Created December 15, 2011 03:54
URL Friendly Javascript Regex
/* function to urlify a string */
var urlify = function(a){return a.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '')};
/* usage example */
var str_a = "* The Best Wallpaper Magazine in the . ? & world! : Rjer9238131 & ";
urlify(str_a)
/* returns */
"the-best-wallpaper-magazine-in-the-world-rjer9238131"
@christopherdebeer
christopherdebeer / snippet.js
Created September 7, 2011 09:22
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@aronwoost
aronwoost / README.md
Created July 25, 2011 19:46
How to install LAMP on a EC2 Amazon AMI

Launch the instance and connect with ssh.

##Update the server

sudo yum update

##Install php and MySQL packages

@twilson63
twilson63 / ask.coffee
Created May 12, 2011 11:04
Ask Method for your Cakefile
ask = (question, format, callback) ->
stdin = process.stdin
stdout = process.stdout
stdin.resume()
stdout.write "#{question}:"
stdin.once 'data', (data) ->
data = data.toString().trim()
if format.test(data)