Skip to content

Instantly share code, notes, and snippets.

@michaelwills
michaelwills / jquery-lodash-injector.js
Last active August 29, 2015 14:23 — forked from spalger/gist:6417923
Inject jQuery and loads into current webpage
// convert to bookmarklet here:
// http://mrcoles.com/bookmarklet/
javascript: (function () {
var jv = '2.1.4';
var lv = '3.9.3';
var el = document.createElement('pre'),
b = document.getElementsByTagName('body')[0],
otherjQuery = false,
msg = '',
@michaelwills
michaelwills / intern.snippet.js
Last active August 29, 2015 14:21
Use intern.io to iterate and click elements sequentially
// uses when
// reduce and when suggested https://gist.github.com/michaelwills/f362e2368422f80ea831#comment-1454585
var when = require('intern/dojo/promise/when');
// snippet from previous this.remote sequence
this.remote
.findAllByCssSelector('.tile')
.then(function onTileImages(tiles) {
return tiles.reduce(function iterTiles(prev, tile) {
return when(prev)
@michaelwills
michaelwills / bzr-to-github.sh
Last active August 29, 2015 14:17
Pulling a bzr repo for use in git
#from http://paste.ubuntu.com/10621984/
# [10:01] <marcoceppi> my_chiguai: we kind of abandonded keeping them in sync as we work towards a better charm store model
# [10:02] <marcoceppi> my_chiguai: you can follow these instructions to convert a bzr repo a git one if that better suites your workflow
# [10:03] <marcoceppi> my_chiguai: http://paste.ubuntu.com/10621984/
# [10:03] <marcoceppi> my_chiguai: you may also need to run "git reset --hard" at the end
git init
bzr fast-export --plain . | git fast-import
git checkout -f master
rm -rf .bzr/
@michaelwills
michaelwills / socat-2b.rb
Last active August 29, 2015 14:10
homebrew patched install for socat 2b5
require "formula"
class Socat2b < Formula
homepage "http://www.dest-unreach.org/socat/socat-version2.html"
url "http://www.dest-unreach.org/socat/download/socat-2.0.0-b5.tar.gz"
sha256 "b936a6ce67d89b5ada382a093a1aabd093534773b4997c1b211bdae40e8b60b0"
## Patch
# https://gist.github.com/michaelwills/1534146cfdd97ee28fc0
# based on http://www.xappsoftware.com/wordpress/2013/10/10/how-to-run-socat-on-mac-os-x/
--- xio-ip6.c
+++ xio-ip6.c
@@ -4,6 +4,8 @@
/* this file contains the source for IP6 related functions */
+#define __APPLE_USE_RFC_2292
+
#include "xiosysincludes.h"
@michaelwills
michaelwills / netsed.rb
Created November 21, 2014 23:08 — forked from g3d/netsed.rb
require "formula"
class Netsed < Formula
homepage "http://silicone.homelinux.org/projects/netsed/"
url "http://silicone.homelinux.org/release/netsed/netsed-1.2.tar.gz"
sha256 "0a7f12bac83d02c6fc837055bf4ff02c1bdfc8ea478227afcc762e92d1661c80"
def install
system "make"
@michaelwills
michaelwills / Inno DB ibdata resizing
Last active August 29, 2015 14:04
Inno DB ibdata resizing to reclaim data
# Reducing InnoDB ibdata file, converting from monolithic file to individual files per database. See:
# http://dba.stackexchange.com/questions/8982/what-is-the-best-way-to-reduce-the-size-of-ibdata-in-mysql
# http://stackoverflow.com/questions/3456159/how-to-shrink-purge-ibdata1-file-in-mysql
# http://vitobotta.com/smarter-faster-backups-restores-mysql-databases-with-mysqldump/#sthash.VCU3nJHa.SldueNKm.dpbs
# user, password, host, port opts stored in ~/.my.cnf
# dump databases to one file, streamed compression
/Applications/MAMP/Library/bin/mysqldump --all-databases --routines --opt --verbose | gzip > backup.sql.gz
source 'https://rubygems.org'
gem 'rake'
gem 'motion-kit'
@michaelwills
michaelwills / pandas-row-timestamp.py
Last active August 29, 2015 14:01
Get the timestamp of a sliced row in a pandas dataframe
from pandas import *
from numpy import *
from numpy.matlib import randn
dates = date_range('1/1/2000', periods=8)
df = DataFrame(randn(8, 4), index=dates, columns=['A', 'B', 'C', 'D'])
i = df.loc['20000101']
In [157]:i.name
Out[157]: Timestamp('2000-01-01 00:00:00', tz=None)