Skip to content

Instantly share code, notes, and snippets.

@nomatteus
nomatteus / postgres-centos-6.sh
Last active Aug 29, 2015
CentOS 6 Postgres Install
View postgres-centos-6.sh
sudo vi /etc/yum.repos.d/CentOS-Base.repo
# At the bottom of the [base] section, add a line that excludes the postgres packages:
exclude=postgresql*
# Add the same line to the bottom of the [updates]
exclude=postgresql*
# Use URL for your version of CentOS: http://yum.postgresql.org/repopackages.php
cd ~
curl -O http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm
sudo rpm -ivh pgdg*
View ocmock-cheatsheet.m
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
@nomatteus
nomatteus / json.php
Created Jun 28, 2011
Sample using very basic XML feed file caching
View json.php
<?php
/*
* File to convert NextBus' XML Feeds to JSON format
* that our script will use.
*/
// Get route from $_GET['r'] variable, or set to default
// TODO: Add in check for valid route
$route = (isset($_GET['r']) && (int) $_GET['r'] != 0) ? (int) $_GET['r'] : '501';
@nomatteus
nomatteus / gist:1093518
Created Jul 19, 2011
Really simple task (i.e. Rake) timing in Bash
View gist:1093518
# Just copy this line into your terminal
# Replace "clear ; rake" with whatever command(s) you want to time.
start=`date +'%s'` ; clear ; rake ; end=`date +'%s'`; echo \*\*\* Task took `expr $end - $start` seconds to run.
# Even better, add this to your ~/.bash_profile (or similar) file:
function timer() {
start=`date +'%s'`;
$@
end=`date +'%s'`;
echo \*\*\* Task took `expr $end - $start` seconds to run.;
@nomatteus
nomatteus / prettyTweetDateForTumblr.js
Created Jul 25, 2011 — forked from chrismendis/prettyTweetDateForTumblr.js
Change the dates returned by Tumblr's tweet.js callback to something like 12:00 PM Oct. 27th
View prettyTweetDateForTumblr.js
var prettyTweetDate = function(tweetDateFromJSON) {
var tweetDate = new Date(Date.parse(tweetDateFromJSON)),
tweetHours = tweetDate.getHours();
tweetHours = (tweetHours < 13) ? tweetHours : tweetHours - 12;
var tweetDateSuffix = function(day) {
switch (day) {
case 1: case 21: case 31:
return "st"; break;
@nomatteus
nomatteus / .rvmrc
Created Aug 12, 2011
My .rvmrc file for rails
View .rvmrc
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.2-p290@pc-black-label"
#
# First we attempt to load the desired environment directly from the environment
@nomatteus
nomatteus / gist:2776574
Created May 23, 2012
David Foster Wallace - Transcription of the 2005 Kenyon Commencement Address - May 21, 2005
View gist:2776574

David Foster Wallace - Transcription of the 2005 Kenyon Commencement Address - May 21, 2005

(If anybody feels like perspiring [cough], I'd advise you to go ahead, because I'm sure going to. In fact I'm gonna [mumbles while pulling up his gown and taking out a handkerchief from his pocket].) Greetings ["parents"?] and congratulations to Kenyon's graduating class of 2005. There are these two young fish swimming along and they happen to meet an older fish swimming the other way, who nods at them and says "Morning, boys. How's the water?" And the two young fish swim on for a bit, and then eventually one of them looks over at the other and goes "What the hell is water?"

This is a standard requirement of US commencement speeches, the deployment of didactic little parable-ish stories. The story ["thing"] turns out to be one of the better, less bullshitty conventions of the genre, but if you're worried that I plan to present myself here as the wise, older fish explaining what water is to you younger fish, please do

@nomatteus
nomatteus / gist:4444799
Created Jan 3, 2013
get_distance_km function for postgres
View gist:4444799
CREATE FUNCTION get_distance_km(alat double precision, alon double precision, lat double precision, lon double precision) RETURNS double precision
LANGUAGE plpgsql
AS $$
DECLARE
radius_earth FLOAT;
radian_lat FLOAT;
radian_lon FLOAT;
distance_v FLOAT;
distance_h FLOAT;
distance FLOAT;
@nomatteus
nomatteus / gist:4546816
Last active Dec 11, 2015
List all font names (useful for finding the font name of custom fonts added to project).
View gist:4546816
// TTF or OTF fonts are supported.
// Drag font into project, and copy into target.
// Add this to [App]-Info.plist: "Fonts provided by application"
// Add all font filenames to this property (i.e. "my_font.ttf" or "fontName.otf")
// Use font in your code! (Get the name using the code below; it won't always be the same as the filename.)
// Lists all font names
for ( NSString *familyName in [UIFont familyNames] ) {
NSLog(@"Family %@", familyName);
NSLog(@"Names = %@", [UIFont fontNamesForFamilyName:familyName]);
View PressReleaseBoilerplate.md
FOR IMMEDIATE RELEASE

## AppName vX.X does something interesting

AppName vX.X is on the App Store now, and features the following very interesting feature. This is a summary, so I'm focusing on the lead. Just something to make me want to read the rest. Done.

City, State/Country - [Company/Developer] has released AppName vX.X, available in the Mac App Store. AppName is/does [broad, general strokes]. [A few more specific points about who it's for and why it's of benefit to them].

New features!