Skip to content

Instantly share code, notes, and snippets.

View mambocab's full-sized avatar

Jim Witschey mambocab

  • Rapid7
  • Reston, VA
  • 10:16 (UTC -04:00)
View GitHub Profile
function __pdfsize {
if [ -n "$1" ] ; then
identify -verbose $1 | grep "Print size"
else
echo "no arguments!"
fi
}
alias pdfsize=__pdfsize
<snippet>
<content><![CDATA[
1. View > Show Console (^`)
2. ${1:print(view.syntax_name(view.sel()[0].begin()))}
]]></content>
<description>Display console command for showing scope name of current document</description>
<tabTrigger>showscope</tabTrigger>
</snippet>
@mambocab
mambocab / test.sh
Created October 10, 2013 23:22
bash test harness
#!/bin/bash
FILES=./test/*.in
failures=0
for f in $FILES
do
bn=`basename "$f" .in`
if cmp -s <(./ush <"$f") ./test/"$bn".out; then
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
<string>text.tex, sources.bib</string>
<key>settings</key>
<dict>
@mambocab
mambocab / Crock Pot Chili
Created December 30, 2013 23:30
chili recipe
# Ingredients
1 (15 ounce) cans black beans
1 (15 ounce) cans kidney beans
1 (15 ounce) cans chickpeas
1 (15 ounce) cans pinto beans
1 (26 ounce) boxes pomi tomatoes
(2 cans chopped tomatoes can be substituted)
1 (15 ounce) cans corn
1 1/2 cups green peppers, chopped
1 jalapeno pepper, sliced
greek_alphabet = {
u'\u0391': 'Alpha',
u'\u0392': 'Beta',
u'\u0393': 'Gamma',
u'\u0394': 'Delta',
u'\u0395': 'Epsilon',
u'\u0396': 'Zeta',
u'\u0397': 'Eta',
u'\u0398': 'Theta',
u'\u0399': 'Iota',
@mambocab
mambocab / test.js
Last active July 20, 2016 13:16
intro to selenium tests with the intern
define([
'intern!object',
'intern/assert',
'require'
], function (registerSuite, assert, require) {
appUrl = 'http://mithril-test.cos.io/basic/';
var getBrowser = function(remote) {
return remote.environmentType.browserName;
};
  • set up sauce labs/browserstack account (remote tests)
  • download selenium server (not selenium IDE) & install Java (for local tests)
  • install phantomjs (brew install phantomjs) (probably doesn't work with intern-geezer)
  • to structure a directory: git clone https://github.com/theintern/intern-tutorial
    • we don't care about the application, so you can
      • rm -r app
      • rm index.html
  • step through steps 1 and 2 of the intern tutorial
    • but! don't install the main intern package on npm. you'll use npm install intern-geezer --save-dev. the geezer branch is capable of driving
    • you also don't need to worry about changing the packages attribute in loader (that's for dealing with the local app)
@mambocab
mambocab / speedtest.py
Last active August 29, 2015 14:06
memoizing object speed demo
class memo():
'''adapted from https://github.com/timm/sbse14/wiki/basepy'''
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def test_memo():
m = memo(stats=memo(mean=3.5, median=3),
author=memo(name='Jim Witschey', twitter='mambocab', github='mambocab'))
m.author.age = 25
@mambocab
mambocab / output
Last active August 29, 2015 14:06
iteration speed tests
❯ ./speedtest.sh
2 ** 10 items
2 slices: 10000 loops, best of 3: 106 usec per loop
0 slices: 10000 loops, best of 3: 151 usec per loop
2 ** 15 items
2 slices: 100 loops, best of 3: 4.23 msec per loop
0 slices: 100 loops, best of 3: 5.68 msec per loop