Skip to content

Instantly share code, notes, and snippets.

Avatar

Luke Rodgers lukeasrodgers

View GitHub Profile
@lukeasrodgers
lukeasrodgers / gnuplot commands
Last active Sep 27, 2016
Hacky shell script and gnuplot commands to plot the size of a file across a number of git commits, where the name of the file changes but is pattern-matcheable. y-axis data is unique by date.
View gnuplot commands
set xdata time
set timefmt "%Y%m%d"
set offset graph 0.1, graph 0.1, graph 0.1, graph 0.1
plot "temp.data" using 2:1 with lines
@lukeasrodgers
lukeasrodgers / DOMSubtreeModified_logger.js
Last active Dec 12, 2015
log dom subtree modifications to the console (works in Chrome, not sure of other browsers)
View DOMSubtreeModified_logger.js
document.body.addEventListener('DOMSubtreeModified', function(e) { console.log(e.target); });
@lukeasrodgers
lukeasrodgers / mysql_export_import.sh
Last active Dec 12, 2015
mysql dumping and importing
View mysql_export_import.sh
mysqldump DB -hHOST > OUTFILE.sql
# copy to local
rsync -avPz --progress USER@HOST:/PATH/TO/OUTFILE.sql .
# import to local db
mysql -uroot -p -DDATABASE < OUTFILE.sql
@lukeasrodgers
lukeasrodgers / deep-detect.js
Last active Dec 14, 2015
recursive deep detection in javascript with underscore and try/catch statements, inspired by ruby's throw/catch. jsperfs http://jsperf.com/deep-detect and http://jsperf.com/deep-detect-last-success
View deep-detect.js
var deepDetect = function(list, iterator, context) {
var _deepDetect = function(list, iterator, context) {
if (_.isArray(list[0])) {
_.each(list, function(sublist) {
return _deepDetect(sublist, iterator, context);
});
}
else {
var res = _.detect(list, iterator, context);
if (!_.isUndefined(res)) {
@lukeasrodgers
lukeasrodgers / commands
Last active Mar 8, 2021
commands I forget
View commands
tmux
move window
:move-window -t INDEX
swap window
:swap-window -t INDEX
kill session
tmux kill-session -t mynames
cycle sessions
C-a (
save scrollback text into a file:
View load_script.js
load_script = function (url, callback) {
var oDOC = document;
var head = oDOC.head || oDOC.getElementsByTagName("head");
// loading code borrowed directly from LABjs itself
setTimeout(function () {
if ("item" in head) { // check if ref is still a live node list
if (!head[0]) { // append_to node not yet ready
setTimeout(arguments.callee, 25);
return;
@lukeasrodgers
lukeasrodgers / spec.js.coffee
Created Apr 7, 2013
sample of jasminerice spec manifest
View spec.js.coffee
#= require ./before_src/sinon-1.4.2
#= require application
#= require backbone_base
#= require buckets_dashboard
#= require racking
#= require service_order
#= require dashboard
#= require matters
#= require_tree ./
@lukeasrodgers
lukeasrodgers / constructor_getter.js
Last active Dec 16, 2015
Helper to determine the constructor for an instance, given a namesapce
View constructor_getter.js
var constructor_getter = (function() {
var parser = function(ns, instance) {
for (var key in ns) {
try {
if (instance instanceof ns[key]) {
return key;
}
} catch (err) {}
}
};
@lukeasrodgers
lukeasrodgers / GridFilteringExtensions.js
Created Apr 24, 2013
Extensions to Ext.grid.GridPanel to make it easier to do programmatically hook into grid filtering.
View GridFilteringExtensions.js
Ext.grid.GridPanel.prototype.getFeatures = function() {
return this.view.featuresMC;
};
Ext.grid.GridPanel.prototype.getFilters = function() {
var features = this.getFeatures();
if (features && features.items) {
for (var i = 0; i < features.items.length; i++) {
if (features.items[i].ftype === 'filters') {
return features.items[i];
@lukeasrodgers
lukeasrodgers / vagrant_ssh.log
Created Jan 9, 2014
Vagrant ssh issues log output
View vagrant_ssh.log
VAGRANT_LOG=debug vagrant ssh
INFO global: Vagrant version: 1.3.5
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/box/plugin.rb
INFO manager: Registered plugin: box command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/destroy/plugin.rb
INFO manager: Registered plugin: destroy command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/halt/plugin.rb
INFO manager: Registered plugin: halt command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/help/plugin.rb
INFO manager: Registered plugin: help command