Skip to content

Instantly share code, notes, and snippets.

@adamvduke
adamvduke / ig_downloader.rb
Created October 3, 2012 17:59
Download all the photos you've liked on instagram
require 'restclient'
require 'json'
require 'digest'
class IGDownloader
def initialize(output_path)
@base_output_path = output_path
end
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user forge;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
@adamvduke
adamvduke / build.sh
Created September 29, 2011 21:21 — forked from jonah-williams/build.sh
Command line iOS project builds and over-the-air distribution
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
@adamvduke
adamvduke / BitwiseMagic.c
Created August 29, 2012 00:17
A C function to compute an average without the risk of integer overflow
#include <stdio.h>
/* https://twitter.com/mikeash/status/240471662422810624
* Compute average with no possibility of integer overflow.
* Note: patented in 1996, so you can't use it!
*/
int patentedAverage(int a, int b)
{
int av = (a/2) + (b/2) + (a&b&1);
return av;
@adamvduke
adamvduke / encrypt_openssl.txt
Created September 13, 2018 21:23 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.
@adamvduke
adamvduke / de_dup.rb
Created January 2, 2013 12:51
Find and remove duplicate images from a directory by shelling out to imagemagick for comparisons
require 'open3'
require 'fileutils'
if ARGV[0].nil?
puts "This script requires a directory to operate on"
exit 1
end
def file_names(path)
Dir.glob("#{path}/**/*").map do |file|
@adamvduke
adamvduke / gen_manifest.rb
Created December 12, 2013 20:02
A minimal ruby script to generate a manifest.json for Safari push notification push packages.
require 'digest'
require 'json'
REQUIRED_ICONSET_FILES = ["icon_16x16.png", "icon_16x16@2x.png", "icon_32x32.png", "icon_32x32@2x.png", "icon_128x128.png", "icon_128x128@2x.png" ]
manifest_keys = REQUIRED_ICONSET_FILES.map{|f| 'icon.iconset/' + f }
manifest_keys << 'website.json'
manifest_values = manifest_keys.map {|file| Digest::SHA1.file(file).hexdigest }
manifest_data = Hash[manifest_keys.zip(manifest_values)].to_json
@adamvduke
adamvduke / service-checklist.md
Last active May 8, 2017 05:11 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@adamvduke
adamvduke / Git Cheat Sheet
Created March 12, 2011 15:01
Corey Floyd's git cheat sheet
via: http://groups.google.com/group/phillycocoa/browse_thread/thread/2d05f3eac5a7d260?hl=en
revert file:
git checkout HEAD path/to/file
OR
git checkout filename
pluck one file from another branch
git checkout Branch path/to/file
@adamvduke
adamvduke / .zshrc
Last active November 22, 2016 19:01 — forked from bmhatfield/.zshrc
OSX Keychain Environment Variables
# If you use bash, this technique isn't really zsh specific. Adapt as needed.
source ~/keychain-environment-variables.sh
# AWS configuration example, after doing:
# $ set-keychain-environment-variable AWS_ACCESS_KEY_ID
# provide: "AKIAYOURACCESSKEY"
# $ set-keychain-environment-variable AWS_SECRET_ACCESS_KEY
# provide: "j1/yoursupersecret/password"
export AWS_ACCESS_KEY_ID=$(keychain-environment-variable AWS_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(keychain-environment-variable AWS_SECRET_ACCESS_KEY);