Skip to content

Instantly share code, notes, and snippets.

Matthew Di Pasquale ma11hew28

Block or report user

Report or block ma11hew28

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ma11hew28
ma11hew28 / app.rb
Created Jul 13, 2016
Rack::Test Issue: Body shouldn't be a string
View app.rb
class App
def call(env)
[200, {'Content-Type' => 'text/plain'}, "Hello, World!"]
end
end
@ma11hew28
ma11hew28 / delete-duplicate-pictures.rb
Created Aug 21, 2014
Delete duplicate pictures created by Image Capture's Import All feature.
View delete-duplicate-pictures.rb
require 'digest/md5'
def md5(filename)
Digest::MD5.hexdigest(IO.read(filename))
end
duplicate_files = []
Dir.glob('* 1.JPG').each do |duplicate_filename|
original_filename = duplicate_filename[0..7] + '.JPG'
@ma11hew28
ma11hew28 / terminal.txt
Last active Jul 17, 2018
Unique Unordered Pairing Function
View terminal.txt
$ ruby unique-unordered-pairing-function.rb
Cantor Pairing Function
-----------------------
<x, y> = (x + y) * (x + y + 1) / 2 + y
0 1 2 3 4 5 6 7 8 9 10 11 12 13
+ ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— +
0 | 0 | 1 | 3 | 6 | 10 | 15 | 21 | 28 | 36 | 45 | 55 | 66 | 78 | 91 |
@ma11hew28
ma11hew28 / census_birthdate_calculator.rb
Created Oct 23, 2013
Calculate birthdate range from dates & ages.
View census_birthdate_calculator.rb
# Census Birthdate Calculator
# http://sean.famthings.com/2009/03/04/the-census-birth-date-calculator/
# http://genealogy.eshea.us/anchestor_birthdate_calculator.html
# Calculate birthdate range from dates & ages.
# Usage: ruby census_birthdate_calculator.rb 2000-04-14 16 2013-03-21 28
require 'date'
@ma11hew28
ma11hew28 / reverse.c
Last active Dec 12, 2015
Reverse a singly linked list in C.
View reverse.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;
};
@ma11hew28
ma11hew28 / 1.rvm_ruby_install.log
Last active Sep 7, 2016
How to Install RVM, Ruby, and Gems without Xcode Command Line Tools
View 1.rvm_ruby_install.log
# 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 / README.md
Last active Aug 18, 2016
Homebrew Meteor Formula
View README.md

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 / NSDecimalNumber+Additions.h
Created May 29, 2011
Kiwi specs for NSDecimalNumber+Additions (iPhone & iPad)
View NSDecimalNumber+Additions.h
@interface NSDecimalNumber (Additions)
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)string scale:(short)scale;
- (NSDecimalNumber *)decimalNumberByRoundingByScale:(short)scale;
@end
@ma11hew28
ma11hew28 / string-additions.rb
Created Apr 2, 2011
String#reverse_words & #longest_run
View string-additions.rb
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 / Create Icons.jsx
Created Nov 23, 2010
Photoshop Script to Create iPhone Icons from iTunesArtwork
View Create Icons.jsx
// 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
//
You can’t perform that action at this time.