Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
var wrappers = require("pouchdb-wrappers");
var noops = {};
// also add all the other methods
"get allDocs getAttachment info revsDiff put post".split(" ")).forEach(function (name) {
noops[name] = function (orig) {return orig(); };
});
wrappers.installWrapperMethods(db, noops);
@cicorias
cicorias / appify
Created March 3, 2016 13:10 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@cicorias
cicorias / regex-string-whitelist.js
Created March 6, 2016 18:14 — forked from steveosoule/regex-string-whitelist.js
JavaScript Regular Expression Whitelist for String
// in the regex, the carrot(^) negates the match, so if the stringToReplace contains something that is not a-z or 0-9 it will be replaced
// In this case the desired string will only be alpha numeric characters, stripping out spaces and symbols
// Help from: http://stackoverflow.com/questions/4374822/javascript-regexp-remove-all-special-characters
var desired = stringToReplace.replace(/[^a-zA-Z0-9]/gi, '')
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
@cicorias
cicorias / pr.md
Created March 12, 2016 15:40 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@cicorias
cicorias / gist:9ad133060b13149d7d1b
Last active March 17, 2016 15:38 — forked from burakerdem/gist:d8195e6e343aa55ff578
Installing wget on Mac OS X El Capitan 10.11
ln -s /usr/local/opt/openssl /usr/local/ssl
curl -O http://ftp.gnu.org/gnu/wget/wget-1.17.tar.gz
tar -xzf wget-1.17.tar.gz
cd wget-1.17
./configure --with-ssl=openssl
./configure --with-ssl=openssl --with-libssl-prefix=/usr/local/ssl
make
sudo make install
wget --help
cd .. && rm -rf wget*
@cicorias
cicorias / ngrok-selfhosting-setup.md
Created April 24, 2016 03:27 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@cicorias
cicorias / Generators.fsx
Created April 26, 2016 00:55 — forked from shwars/Generators.fsx
Demonstration of creating generators in F#
// Simple counter
type cell = { mutable content : int }
let new_counter n =
let x :cell = { content = n }
fun () ->
(x.content <- x.content+1; x.content)
// The same, using F# refs
let new_counter' n =