Skip to content

Instantly share code, notes, and snippets.

View jessedc's full-sized avatar

Jesse Collis jessedc

View GitHub Profile
$cacheDir = './cache/';
$curl_setopt_array = array( CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true);
if (file_exists($cacheDir.$filename)) {
$timetable_view_file = file_get_contents($cacheDir.$filename);
}else{
$curlR = curl_init($request_url);
if (curl_setopt_array($curlR, $curl_setopt_array)){
$timetable_view_file = curl_exec($curlR);
int equi(int A[], int n){
int left = 0;
int right = 0;
int index = -1;
// Sum the array
int i = 0;
for (i = 0; i < n; i++) {
left += A[i];
@jessedc
jessedc / iOS Icon.png bash script
Last active February 25, 2018 03:02
A simple bash script using OSX command line tool sips to resample a 1024x1024 image
#!/bin/bash
f=$(pwd)
sips --resampleWidth 512 "${f}/${1}" --out "${f}/iTunesArtwork"
sips --resampleWidth 1024 "${f}/${1}" --out "${f}/iTunesArtwork@2x"
sips --resampleWidth 57 "${f}/${1}" --out "${f}/Icon.png"
sips --resampleWidth 114 "${f}/${1}" --out "${f}/Icon@2x.png"
sips --resampleWidth 29 "${f}/${1}" --out "${f}/Icon-Small.png"
sips --resampleWidth 58 "${f}/${1}" --out "${f}/Icon-Small@2x.png"
sips --resampleWidth 50 "${f}/${1}" --out "${f}/Icon-Small-50.png"
@jessedc
jessedc / express-stylus.html
Created April 25, 2011 05:57 — forked from bentruyman/express-stylus.html
Using Stylus Middleware with Express
<!doctype html>
<html lang="en">
<head>
<title>My Web Page</title>
<meta charset="utf-8">
<link href="/stylesheets/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
@jessedc
jessedc / compiled.html
Created April 25, 2011 12:19
Jade Example for Steve
<html lang="en">
<head>
<title>
title of the page
</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css">
</head>
<body>
<h1>
title of the post
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@jessedc
jessedc / cityrail.rb
Created January 5, 2012 11:02
Sydney City Rail service updates to JSON
require 'nokogiri'
require 'open-uri'
require 'json'
METRO_URL = 'http://www.cityrail.info/service_updates'
doc = Nokogiri::HTML(open(METRO_URL).read)
lines = []
line_row2 = doc.xpath("//tbody[@id='serviceStatusLines:j_id631:tbody_element']/tr").each do |line_row|
@jessedc
jessedc / UIDeviceHardware.h
Created April 26, 2012 04:35 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@jessedc
jessedc / ObsidianCode.dvtcolortheme
Last active April 20, 2016 09:22 — forked from subdigital/ObsidianCode.dvtcolortheme
Obsidian Code Theme for Xcode 4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@jessedc
jessedc / dateformatterstuffs.m
Created June 7, 2012 08:04
DateFormatter stuffs
NSDateFormatter *timeOfArrival = [[NSDateFormatter alloc] init];
[timeOfArrival setTimeStyle:NSDateFormatterLongStyle];
[timeOfArrival setDateStyle:NSDateFormatterNoStyle];
[timeOfArrival setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSString *etaStr = [attributeDict objectForKey:@"cumulativeTime"];
NSLog(@"%@", etaStr);
checkpoint.eta = [timeOfArrival dateFromString:etaStr];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];