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 / 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";
}'
@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 / 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 / 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 / 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 / .gitignore
Last active August 29, 2015 14:11
NSDate experiment
main
*.o
@HomerJSimpson
HomerJSimpson / readme.markdown
Last active August 29, 2015 14:12
Convert avi to mp4 copying video and re-encoding the audio as aac

Convert avi to mp4 copying video and re-encoding the audio as aac

        ffmpeg \
                -fflags +genpts `# http://superuser.com/a/710087` \
                -i Hawaii.Five-0.2010.S01E01.avi \
                -vcodec copy `# copy the video` \
                -acodec aac -strict -2 `# re-encode the audio as aac` \
                Hawaii.Five-0.2010.S01E01.mp4
@HomerJSimpson
HomerJSimpson / gist:b5b83977ad5b667baf75
Created January 6, 2015 18:03
Scrape envato author page for sales and revenue
/*jslint white:true, unparam:true, browser:true */
/*global $, casper, console, jQuery */
(function() {
"use strict";
var casper = require('casper').create();
console.log("Starting...");
casper.start('http://themeforest.net/user/oxygenna/portfolio?direction=desc&order_by=sortable_at&view=grid', function() {
console.log('scraping');
var rv = this.evaluate(function() {
@HomerJSimpson
HomerJSimpson / .html5.html
Created April 21, 2015 21:02
Bootstrap 3.3.4 empty template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
@HomerJSimpson
HomerJSimpson / test.js
Last active August 29, 2015 14:20
walk iframes
var myFrames = [];
function mkLog(name) {
return function() {
console.log('unloading ' + name);
};
}
(function walk(d) {
var doc = d.contentDocument || d, i, iframes = doc.getElementsByTagName('iframe');
console.log('found ' + iframes.length + ' iframes');
myFrames.push({ doc :doc, frame : d.contentDocument, node : d, id : d.id, name:d.name });