Skip to content

Instantly share code, notes, and snippets.

View HomerJSimpson's full-sized avatar

Homer Simpson HomerJSimpson

  • New Jersey, USA
View GitHub Profile
@HomerJSimpson
HomerJSimpson / main.m
Last active August 29, 2015 14:10
Waiting on a gcd task in a command line app
#import <Foundation/Foundation.h>
NSString *const retirementUrl = @"https://query.yahooapis.com/v1/public/yql/homerj/retirement?format=json";
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSURLSession *session = [NSURLSession sharedSession];
@HomerJSimpson
HomerJSimpson / src.js
Created July 27, 2013 18:59
calculate last friday in month in javascript
/*jslint white:true */
/*global console */
function lastFridayOfMonth(year, month) { "use strict";
var lastDay = new Date(year, month+1, 0);
if(lastDay.getDay() < 5) {
lastDay.setDate(lastDay.getDate() - 7);
}
lastDay.setDate(lastDay.getDate() - (lastDay.getDay() -5));
return lastDay;
@HomerJSimpson
HomerJSimpson / gist:6093931
Last active September 28, 2022 22:14
Calculate Second Monday of the month in javascript (not quite done)
/*jslint plusplus:true, white:true */
/*global console:false */
function secondMonday(year, month) { "use strict";
var firstDay = new Date(year, month, 1);
if(firstDay.getDay() !== 1) {
firstDay.setDate(
firstDay.getDay() === 0 ? 2 : 9 - firstDay.getDay()
);
}
@HomerJSimpson
HomerJSimpson / lock-screen.sh
Created July 25, 2013 03:27
Lock Mac OS X screen from command line
#!/bin/bash
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
@HomerJSimpson
HomerJSimpson / listBBRepos.sh
Last active December 20, 2015 05:08
List my bitbucket repositories from the command line
#!/bin/bash
# Usage:
# listBBRepos.sh [bitbucket username]
curl -su "$1" https://api.bitbucket.org/1.0/users/"$1" | perl -MJSON -MData::Dumper -ne'
my $data = from_json($_);
foreach my $repo (@{$data->{repositories}}) {
print $repo->{slug}, "\n";
}'