Skip to content

Instantly share code, notes, and snippets.

View lukehedger's full-sized avatar
🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active April 18, 2024 21:00
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@lukehedger
lukehedger / gc.js
Last active August 29, 2015 14:17
Monitor JS garbage collection
// run this in Chrome with the --enable-precise-memory-info flag
// $ open -a "Google Chrome" --args --enable-precise-memory-info
timer = function() {
requestAnimationFrame(timer)
var heapBefore = window.performance.memory.usedJSHeapSize
// run processes here
// eg. console.log allocates 2216 bytes, new Object() 56 bytes
@lukehedger
lukehedger / ffmpeg-trim
Created February 16, 2015 14:48
Trim video using FFMPEG
$ ffmpeg -i movie.mp4 -ss 00:00:05 -t 00:01:00 -async 1 cut.mp4
# -ss = start time
# -t = duration, not end time
@lukehedger
lukehedger / ffmpeg-60fps
Created February 9, 2015 14:20
ffmpeg - extract 60fps
ffmpeg -i file.mp4 -r 60 $filename%03d.jpg
@lukehedger
lukehedger / gitdays.sh
Created December 16, 2014 10:53
Git today, git yesterday
# get a log of today's commits
$ git config --global alias.today '!git log --since=midnight --author="$(git config user.name)" --oneline'
$ git today
# get a log of yesterday's commits
$ git config --global alias.yday '!git log --graph --since=day.before.yesterday.midnight --until=midnight --author="$(git config user.name)" --oneline'
$ git yday
@lukehedger
lukehedger / cmd_alias.bash
Created November 21, 2014 11:07
Command aliases
nano ~/.bash_profile
# or subl ~/.bash_profile
# add the following to your bash_profile and any other commands you use regularly
# command aliases
# git
alias gs='git status'
alias gpom='git push origin master'
# cd
@lukehedger
lukehedger / rbenv.bash
Created October 27, 2014 12:16
Setup rbenv to replace OSX system version of Ruby
$ brew install rbenv ruby-build
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# restart terminal
$ type rbenv
#=> "rbenv is a function"
$ rbenv install --list
#=> list of all available installations
$ rbenv install 2.1.3
#=> install specified version
$ rbenv global 2.1.3
@lukehedger
lukehedger / directives.js
Created September 24, 2014 11:18
Simple Angular directive
'use strict';
// declare app-level module
var app = angular.module('app', []);
// register directive
app.directive('partial', function () {
return {
templateUrl: "partial.html", // url to template
restrict: "AE" // restrict directive trigger to attribute (A) and element (E), not classname (C)
@lukehedger
lukehedger / nonpmsudo.bash
Last active August 29, 2015 14:05
Kill sudo for npm
$ npm config set prefix ~/npm
$ echo prefix = ~/.node >> ~/.npmrc
# append this to .bashrc or .bash_profile: export PATH="$PATH:$HOME/.node/bin"
@lukehedger
lukehedger / UKPostcode.md
Created August 13, 2014 15:11
UK Postcode RegExp

Official Gov UK postcode regular expression:

^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([AZa-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$