Skip to content

Instantly share code, notes, and snippets.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@catawbasam
catawbasam / pandas_dbms.py
Last active May 26, 2024 05:32
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,
@cristobal
cristobal / LUA unserialize
Created September 5, 2012 23:39
Lua php unserialize port
--[[
LUA variant of the php unserialize function
Port of http://phpjs.org/functions/unserialize
]]--
local function unserialize (data)
local function utf8Overhead (chr)
local code = chr:byte()
if (code < 0x0080) then
return 0
@malarkey
malarkey / Contract Killer 3.md
Last active May 24, 2024 23:38
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@neerolyte
neerolyte / vssh
Last active November 16, 2016 23:24
vssh - significantly faster ssh for vagrant
#!/bin/bash -e
# vssh - significantly faster Vagrant SSHing
# Usage: vssh [vagrant host] [regular ssh arguments]
# find the .vagrant directory scanning up from $PWD
find_vagrant_dir() {
cdir="$PWD"
while ! [[ -d "$cdir/.vagrant" ]] && [[ "$cdir" != "/" ]]; do
cdir="$(dirname "$cdir")"
@whodidthis
whodidthis / queries.sql
Last active August 18, 2021 03:25
YES for pgmoon too, because YeSQL
-- name: get_cools
SELECT *
FROM cools
-- name: insert_a_cool
INSERT INTO cools
(name, why)
VALUES
(?, ?)
RETURNING level
@josephspurrier
josephspurrier / values_pointers.go
Last active June 20, 2024 14:06
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@mickhansen
mickhansen / gist:966a67648c45dd5c25ee
Last active April 13, 2019 11:31
Sequelize JSONB indexing
indexes: [
{
using: 'GIN',
fields: ['field']
}
]
// CREATE INDEX field ON $modelTable USING gin (field);
indexes: [