Skip to content

Instantly share code, notes, and snippets.

View dideler's full-sized avatar

Dennis Ideler dideler

View GitHub Profile
@jboner
jboner / latency.txt
Last active June 7, 2024 11:40
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
@nebiros
nebiros / unicorn.rake
Created June 5, 2012 17:26
rails rake tasks for managing unicorn server instances + rbenv
ENV["RAILS_ENV"] ||= "production"
module UnicornServer
# http://unicorn.bogomips.org/Unicorn/Configurator.html
CONFIG_PATH = File.join(Rails.root, "config", "unicorn.rb")
PID_PATH = File.join(Rails.root, "tmp", "pids", "unicorn.pid")
RBENV = %x[which rbenv].strip
DAEMON = "bundle exec unicorn_rails"
DAEMON_OPTS = "-c #{CONFIG_PATH} -E #{ENV["RAILS_ENV"]} -D"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
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 = git@github.com: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:

@mrdoob
mrdoob / gist:3504305
Created August 28, 2012 20:58
Renaming files in a folder consecutively.
import os
for i, filename in enumerate(sorted(os.listdir("."))):
os.rename(filename, "{0}.png".format(i))
@uhziel
uhziel / unameh.sh
Created September 6, 2012 05:08
human version of uname
unameh()
{
echo "kernel-name: $(uname --kernel-name)"
echo "nodename: $(uname --nodename)"
echo "kernel-release: $(uname --kernel-release)"
echo "kernel-version: $(uname --kernel-version)"
echo "machine: $(uname --machine)"
echo "processor: $(uname --processor)"
echo "hardware-platform: $(uname --hardware-platform)"
echo "operating-system: $(uname --operating-system)"
@jlfwong
jlfwong / progdiff.sh
Created October 3, 2012 20:07
Diff the stdout, stderr and return code of two programs with piped input and arguments
#!/bin/bash
sandbox="$(mktemp -d)"
hasstdin=false
if [ ! -t 0 ]; then
cat <&0 > "$sandbox/stdin.txt"
hasstdin=true
fi
@nhoizey
nhoizey / screenshots.js
Created November 12, 2012 17:07
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@minitech
minitech / web-checklist.md
Last active January 4, 2020 11:59
minitech’s Web Checklist

minitech’s Web Checklist

Here are some guidelines that will make me actually like your amazing new web application!

  1. Make sure encoding is handled properly every step of the way. If comes out as ’, you’ve got a problem on your hands. 😊

  2. Make it accessible. Turn off images, JavaScript, and CSS. If your website is still legible and usable (it’s okay if it’s just barely usable, or not particularly interactive) then you are already in the top 0.01%.

  3. Check your grammar. One of the fastest ways to lose respect in a blog post (or worse — in body copy) is to make basic orthographical or grammatical mistakes. These include, but are not limited to:

  • Missing apostrophes — [Bitbucket even did that][bitbucket-apostrophe-catastrophe].
@fosslc
fosslc / Freeseer.md
Created November 30, 2012 23:21
Freeseer project

Overview

The Freeseer project is a powerful software suite for capturing video. It enables you to capture great presentations, demos, training material, and other videos. It handles desktop screen-casting with ease. It is one of a few such tools that can also record vga output. It is particularly good at handling large conferences with hundreds of talks. Freeseer can run on a laptop with commodity hardware such as a web cam, camcorder, or vga capture device. The resulting system fits easily into a laptop and can be assembled in under 10 minutes to record any number of presentations/demos/talks.

Freeseer is implemented in Python, uses Qt for its GUI, and quite approachable and easy to learn the code base given it's clear structure and reasonable size (17K lines of code). One can make a significant contribution to Freeseer, perhaps more than many other open source projects.

Freeseer is the best software available for recording large conferences. We have put a lot of thought and automation into work flow to

@SumuduF
SumuduF / card_game.py
Created February 3, 2013 21:30
Solutions for Facebook Hacker Cup 2013 / Round 1 No explanations for now...
import sys
MOD = 1000000007
def main():
for (i, (n, k, cards)) in enumerate(testcases()):
print "Case #{0}: {1}".format(i+1, subsum(n, k, cards))
def testcases(cin=sys.stdin):
m = int(cin.next())