Skip to content

Instantly share code, notes, and snippets.

View lenards's full-sized avatar

Andrew Lenards lenards

  • Tucson, AZ
View GitHub Profile
@ChillyBwoy
ChillyBwoy / cookie.js
Created May 26, 2011 00:35
Cookie functions for underscore.js
@myano
myano / cs.py
Created June 30, 2011 01:25
Quick example of ncurses in Python!
#!/usr/bin/env python
import curses
import curses.textpad
import time
stdscr = curses.initscr()
#curses.noecho()
#curses.echo()
@wrunk
wrunk / jinja2_file_less.py
Last active November 8, 2024 20:53
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@artgillespie
artgillespie / rmws
Created November 24, 2011 20:52
Remove trailing whitespace from all source files under the current dir
#!/bin/sh
#
# Removes trailing whitespace from all source files in the current directory and its children.
# Note the `-i .bak` switch to sed. This will create a backup copy alongside any modified files
# like `Somefile.cpp.bak` Simply remove the `.bak` argument to `-i` to prevent the backup
# files from being generated
#
/usr/bin/find . -type f -and \( -name '*.m' -or -name '*.h' -or -name '*.mm' -or -name '*.cpp' -or -name '*.c' \) -and -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]+$//"
@jboner
jboner / latency.txt
Last active December 2, 2024 16:39
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@ferd
ferd / app_deps.erl
Created September 23, 2012 05:33
Quick escript to generate a visualization of app dependencies in Erlang/OTP.
%%% Run with 'escript app_deps.erl'
%%% Change the path in filelib:wildcard/1 as required to capture all
%%% your dependencies.
%%%
%%% Rectangular nodes will represent library apps (no processes involved)
%%% and the circular nodes will represent regular apps. An arrow going from
%%% 'A -> B' means 'A depends on B'.
%%%
%%% This script depends on graphviz being present on the system.
-module(app_deps).
@lenards
lenards / gist:7340034
Last active December 27, 2015 14:19 — forked from bhardin/gist:7339955
How @ messages in Hipchat should be used

The @ Symbol in Hipchat

At KISSmetrics our team is distributed around the global in 5 different timezones. When we interview candidates a common question asked is how do we like working remotely from one another. We love it. We use Hipchat as our water cooler, breakroom, and discussion area.

However, there is one thing in Hipchat that needs to be explained. By default, Hipchat will make a noise and bounce in your dock anytime a message is sent. This can become annoying during the work day since Hipchat is used as a water cooler and most of the stuff discussed is not mission critical. You are able to turn this functionality off, and most of us do. But this brings up the notification when someone is @ mentioned.

The dreaded @ symbol. In Hipchat, anytime someone mentions you with your defined @ handle the dock bounces and a sound goes off. This means that someone is attempting to bring something to your attention (and this is likely to be an urgent matter). There is also an @all that will ping ever

@clay-whitley
clay-whitley / export_processor.md
Last active April 5, 2017 04:53
km-export-processor Documentation

km-export-processor gem

The purpose of this gem is to consume the JSON that KISSmetrics exports to an S3 bucket, and transform it in a variety of useful ways.

The core features are:

  • JSON compiler : Aggregates all KISSmetrics JSON files in a directory, into a single (nonstandard) file.
  • JSON to JSON converter : Converts a nonstandard JSON file into standard format.
  • JSON to CSV converter : Converts a nonstandard JSON file into a CSV file, where each row is an event/property/alias.
  • Reimporter : Takes a nonstandard JSON file, and an API key, and sends the data in the JSON file to the product using the KMTS gem.
@sokratisg
sokratisg / pdns-pipebackend.py
Created April 7, 2014 22:38
PowerDNS PipeBackend python example
#!/usr/bin/python -u
import sys, os, time
import random
class DNSLookup(object):
"""Handle PowerDNS pipe-backend domain name lookups."""
ttl = 30
FIELDS = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr']
def human_log(res):
if type(res) == type(dict()):
for field in FIELDS:
if field in res.keys():
encoded_field = res[field].encode('utf-8')
print '\n{0}:\n{1}'.format(field, encoded_field)