Skip to content

Instantly share code, notes, and snippets.

@ma11hew28
ma11hew28 / find-duplicate-files.rb
Last active January 25, 2022 18:48
Ruby script that finds identical (md5) files in all subdirectories (recursive)
# This Ruby script (regardless of where it's located on the file system) recur-
# sively lists all duplicate files in the direcotry in which it's executed.
require 'digest/md5'
hash = {}
Dir.glob('**/*', File::FNM_DOTMATCH).each do |f|
next if File.directory?(f)
key = Digest::MD5.hexdigest(IO.read(f)).to_sym
require 'rubygems'
require 'ruby-debug'
require 'gdata'
require 'pp'
SPREADSHEET_FEED = 'https://spreadsheets.google.com/feeds/spreadsheets/private/full'
client = GData::Client::DocList.new
email = ARGV[0]
@ma11hew28
ma11hew28 / gist:641363
Created October 22, 2010 21:00
Address standardization via USPS Webtools API
require 'rubygems'
require 'nokogiri'
require 'open-uri'
module USPS
SERVER = "http://production.shippingapis.com/ShippingAPITest.dll"
USERNAME = 'username-here' # username from http://www.usps.com/webtools/
class Address
# requres ruby-1.9, which keeps hashes ordered
@ma11hew28
ma11hew28 / Tile Images.jsx
Created November 21, 2010 16:47
Photoshop script to tile images for iPhone Photo Scroller
// Photoshop Script to Resize & Tile Images
//
// WARNING!!! This script will overwrite (delete perminently) files in the
// selected output folder in the rare case that there are name collisions.
// Therefore, to be safe, it's best to choose an empty output folder.
//
// Copyright (c) 2010 Matt Di Pasquale
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ma11hew28
ma11hew28 / Create Icons.jsx
Created November 23, 2010 03:50
Photoshop Script to Create iPhone Icons from iTunesArtwork
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
//
@ma11hew28
ma11hew28 / string-additions.rb
Created April 2, 2011 14:17
String#reverse_words & #longest_run
require 'rspec'
class String
if method_defined? :reverse_words
raise "String#reverse_words is already defined"
end
def reverse_words
split(' ').reverse!.join(' ')
end
@ma11hew28
ma11hew28 / NSDecimalNumber+Additions.h
Created May 29, 2011 08:43
Kiwi specs for NSDecimalNumber+Additions (iPhone & iPad)
@interface NSDecimalNumber (Additions)
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)string scale:(short)scale;
- (NSDecimalNumber *)decimalNumberByRoundingByScale:(short)scale;
@end
@ma11hew28
ma11hew28 / README.md
Last active August 18, 2016 05:40
Homebrew Meteor Formula

Homebrew Meteor Formula

Note: This formula is outdated.

To install [Meteor][1] with the [Homebrew][2] formula [below][3], run:

brew install https://raw.github.com/gist/3072321/meteor.rb

This Homebrew Meteor Formula is based on https://install.meteor.com.

@ma11hew28
ma11hew28 / 1.rvm_ruby_install.log
Last active September 16, 2019 07:49
How to Install RVM, Ruby, and Gems without Xcode Command Line Tools
# How to Install RVM, Ruby, and Gems without Xcode Command Line Tools
# ===================================================================
#
# Mac OS X 10.8.2 (12C60) (Mountain Lion)
# Xcode 4.5 (4G182)
#
# While attempting to `rvm pkg install openssl`, I had encountered the error:
# > cryptlib.h:62:20: error: stdlib.h: No such file or directory
# But, the commands & ouput below show how I worked around the issue.
#
@ma11hew28
ma11hew28 / reverse.c
Last active December 12, 2015 09:29
Reverse a singly linked list in C.
// http://stackoverflow.com/questions/1801549/reverse-a-singly-linked-list
#include <stdio.h>
#include <assert.h>
typedef struct node Node;
struct node {
int data;
Node *next;
};