Skip to content

Instantly share code, notes, and snippets.

@bwiggs
bwiggs / array_like_objects.js
Last active December 24, 2015 05:19
This shows how one can use Array's prototype methods on any object by using `call`.
var CarLot = {
name: 'We-Buy-Cars',
length: 0,
buy: function(num) {
return Array.prototype.push.call(this, num);
},
sell: function() {
return Array.prototype.pop.call(this);
},
report: function() {
@bwiggs
bwiggs / profanities.json
Created February 20, 2014 22:51
epic profanity list
[
"$hit",
"$hit$",
"$hits",
"$hitted",
"$hitter",
"$hitting",
"3some",
"53x",
"60 nine",
function BaseballGame(home_team_name, away_team_name) {
var home_goals = 0;
var away_goals = 0;
function home_team_run_scored() {
home_goals++;
}
function away_team_run_scored() {
@bwiggs
bwiggs / after.js
Last active August 29, 2015 13:57
before and after global namespace pollution cleanup
function findURLValue(q) {
var p = document.location.search.substring(1).split('&'),
i = 0;
for (; i < p.length; i = i + 1) {
if (p[i].split('=')[0] == q) return p[i].split('=')[1];
}
return '';
}
var Application = (function () {
function TimeDurationDirective() {
var tpl = "<div> \
<input type='text' ng-model='num' size='80' /> \
<select ng-model='unit'> \
<option value='secs'>Seconds</option> \
<option value='mins'>Minutes</option> \
<option value='hours'>Hours</option> \
<option value='days'>Days</option> \
</select> \
</div>";
@bwiggs
bwiggs / genpasswd.sh
Created June 4, 2014 17:46
CLI Password Generator with openssl
function genpasswd() {
let passwordLength=${1:-48}
openssl rand -base64 $passwordLength | cut -c 1-$passwordLength
}
# $ genpasswd 24
# qPE5rpQOF74k8SoibCFzhlwp
@bwiggs
bwiggs / ConstructorProxy.js
Created July 15, 2014 14:22
ConstructorProxy.js
function Person() {
this.name = 'Bob'
}
constructorProxy = (constructorFn, args) ->
Proxy = ->
constructorFn.apply(this, args)
this.name = 'Dave'
Proxy:: = Object.create constructorFn::
Proxy
@bwiggs
bwiggs / keybase.md
Last active March 12, 2017 18:04
keybase.md

Keybase proof

I hereby claim:

  • I am bwiggs on github.
  • I am bwigginton (https://keybase.io/bwigginton) on keybase.
  • I have a public key ASDUuJfyp5_3y5dZK7UHwIU5997em3uXsuZdAcfFxf5qoAo

To claim this, I am signing this object:

params := url.Values{
"Condition": []string{"New"},
"Operation": []string{"ItemSearch"},
"SearchIndex": []string{"Books"},
"Title": []string{"ruby microscope"},
}
@bwiggs
bwiggs / new_engine_refactor.go
Created February 25, 2015 04:16
limetext refactor snippet
// newQmlEngine creates a new qml engine. Destroys the old one if set.
//
// This is needed to re-load qml files to get the new file contents from disc as
// otherwise the old file would still be what is referenced.
func (t *qmlfrontend) newQmlEngine() (err error) {
if t.engine != nil {
// TODO(.): calling this appears to make the editor *very* crash-prone, just let it leak for now
// engine.Destroy()
t.engine = nil
}