Skip to content

Instantly share code, notes, and snippets.

View mnem's full-sized avatar

Dave Clayton-Wagner mnem

View GitHub Profile
@mnem
mnem / ebook_select_ipad_versions.rb
Created December 26, 2011 15:43
Script to look in each subfolder containing ebook files and select the 'best' candidates for chucking on an iPad
#!/usr/bin/env ruby
require "fileutils"
output_folder_name = "_ipad_selection"
output = File.expand_path File.join(Dir.pwd, output_folder_name)
selected = []
# Gather folders to look at
folders = Dir.glob(%w{*/*.epub */*.pdf}).map {|file| File.dirname file}
folders.delete_if { | item | item.match(/^#{output_folder_name}/)}
@mnem
mnem / pwgen_a.sh
Created January 5, 2012 20:07
Quick 'n' dirty password generation commands for *nix/mac
# Will generate passwords up to 76 characters long.
#
# Change the 20 at the end to change the length.
dd if=/dev/urandom count=1 2> /dev/null | base64 | sed -ne 2p | cut -c-20
@mnem
mnem / nah_vpn_add_user.sh
Created January 17, 2012 13:32
Simple script to add VPN users to your chap-secrets file. For details on setting up a VPN on EC2, see http://noiseandheat.com/blog/2012/01/vpn-with-amazon-ec2-or-saving-your-iphone-from-promiscuity/
#!/bin/bash
#######################################
# Simple script to add VPN users to your chap-secrets file. For details
# on setting up a VPN on EC2, see:
#
# http://noiseandheat.com/blog/2012/01/vpn-with-amazon-ec2-or-saving-your-phone-from-promiscuity/
#
#
# (c) Copyright 2011 David Wagner.
#
@mnem
mnem / nah_xcode_uncrustify.rb
Last active February 1, 2020 20:12
Script file to be run as an Xcode 4 behaviour which uncrustifies the project source using reasonable Objective-C formatting defaults. Alternatively, you can run it and pass a path to uncrustify.
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
@mnem
mnem / .nah_xcode_uncrustify.cfg
Created January 20, 2012 09:38
My uncrustify script which has an eye towards making Objective-C code sane. See also https://gist.github.com/1641451
# Uncrustify 0.59
###########################################################################
# nah_xcode_uncrustify.rb default
# configuration
#
# config_version: 1.1.0
#
# Default uncrustify config to use for
# the nah_xcode_uncrustify.rb script
@jboner
jboner / latency.txt
Last active May 17, 2025 02:27
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
@mnem
mnem / tools_osx_edition.md
Last active October 5, 2015 17:17
Tools and setup for doing stuff, for my future reference when I accidentally destroy my computer. Again.

OS X Edition

Stuff I install to make creating magic rubbish easier.

General tools

  • OSX Terminal: Good enough when combined with tmux.
  • tmux: Terminals done proper; tmuxinator: handy tmux session templates.
  • Homebrew: The only package manager that matters.
  • git: Source control that works.
  • The Silver Searcher: A faster, better ack.
@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 = [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:

@ccgus
ccgus / Xcode crash report
Created February 23, 2013 19:02
Xcode crash report whoa
Application Specific Information:
ProductBuildVersion: 4H127
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilder/IDEInterfaceBuilder-3084/Framework/Connections/Interface/IBConnectionPopUpMenu.m:388
Details: Need a menu.
Function: NSMenuItem *IBPopUpConnectionMenuWithMenuItems(NSArray *, NSMenuItem *, NSEvent *, NSRect, BOOL, NSSet *, CGFloat, NSWindow *, NSColor *, NSColor *, NSColor *, NSColor *, id<IBConnectionPopUpMenuDelegate>)
Thread: <NSThread: 0x40030a1e0>{name = (null), num = 1}
Hints: None
Backtrace:
0 0x000000010c77b249 -[IDEAssertionHandler handleFailureInFunction:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
1 0x000000010ba2ec65 _DVTAssertionHandler (in DVTFoundation)
@aras-p
aras-p / preprocessor_fun.h
Last active May 16, 2025 11:21
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,