Skip to content

Instantly share code, notes, and snippets.

@arikfr
arikfr / .monitrc
Created December 13, 2010 14:35
Setting Monit to work with Gmail as mail server
set mailserver smtp.gmail.com port 587 username "[email protected]" password "password" using tlsv1 with timeout 30 seconds
@temoto
temoto / datetime.py
Created March 9, 2011 13:15
Python datetime timezone utils.
# coding: utf-8
from __future__ import absolute_import
"""Datetime utils.
To store time use `naive_to_utc(dt, tz_name)`.
To display time use `utc_to_local(dt, tz_name)`.
"""
import datetime as stdlib_datetime
import pytz
@jclulow
jclulow / awk.js
Created November 10, 2011 05:18
Awk in Javascript?
/*
* map predicate to code...
* /regex/ --> function (groups, next)
* ^ ^ function to call if we should
* | \---skip remaining predicates for this line
* \- e.g. groups[1] is first regex group, etc
*/
function line(predicate, codeblock) {
return ({ predicate: predicate, codeblock: codeblock });
@dupuy
dupuy / README.rst
Last active October 21, 2024 22:20
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@turtlesoupy
turtlesoupy / pg_pool.coffee
Created June 10, 2012 23:34
node-postgres pooled function decorator
pg = require 'pg'
module.exports = pooler =
#Get a connection from the pool
acquire: (callback) -> pg.connect "tcp://postgres:postgres@localhost/dummy_db", callback
#Decorate a function to use the de-pooled connection as a first argument
pooled: (fn) -> ->
callerCallback = arguments[arguments.length - 1]
callerHasCallback = typeof callerCallback == 'function'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 17, 2024 01:28
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@youcandanch
youcandanch / gist:3952746
Created October 25, 2012 14:06
Quick console app to get VS2010 product key
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace RegCheck
{
class Program
{
@wolever
wolever / example.sql
Created January 4, 2013 23:00
A simple Postgres aggregate function for calculating a trimmed mean, excluding values outside N standard deviations from the mean: `tmean(v, standard_deviations)` (for example: `tmean(rating, 1.75)`).
DROP TABLE IF EXISTS foo;
CREATE TEMPORARY TABLE foo (x FLOAT);
INSERT INTO foo VALUES (1);
INSERT INTO foo VALUES (2);
INSERT INTO foo VALUES (3);
INSERT INTO foo VALUES (4);
INSERT INTO foo VALUES (100);
SELECT avg(x), tmean(x, 2.0), tmean(x, 1.5) FROM foo;
@jpillora
jpillora / di.coffee
Last active April 30, 2018 01:21
Micro JavaScript Dependancy Injection.Written in CoffeeScript / JS.This is *approximately* how AngularJS works.
# Micro JavaScript Dependancy Injection
define = (name, val) ->
#init modules map if missing
define.mods = define.mods or {}
#store 'name'
define.mods[name] = val
inject = (fn) ->
#regex match on function.toString()
@emersonf
emersonf / s3etag.sh
Last active August 14, 2024 13:56
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then