Skip to content

Instantly share code, notes, and snippets.

@foobarfighter
foobarfighter / ip_range_calculator.rb
Created April 4, 2014 05:57
IP Range Calculator
#!/usr/bin/env ruby
def valid?(range)
range.split("/").size == 2 && range.split(".").size == 4
end
print "Enter IP address range in CIDR notation. Example [192.168.1.0/24]: "
while true do
range = gets
@foobarfighter
foobarfighter / underscore_bug.js
Created December 18, 2011 06:44
is this an underscore bug in _.wrap?
var _ = require('underscore')
, a = require('assert');
var firstArg;
var handler = function (){};
var wrapped = _.wrap(handler, function (func){
console.log('--> arguments is wrong or unexpected', arguments);
a.strictEqual(arguments[0], func);
@foobarfighter
foobarfighter / mintest.coffee
Created July 27, 2011 06:42
foounit mintest in coffeescript
require('foounit').globalize()
describe 'this is a test group', ->
x = null
before ->
x = 1
it 'has a failing test', ->
expect(x).to beTrue
@foobarfighter
foobarfighter / minimalist-test.js
Created June 30, 2011 19:05
minimalist-test.js
var a = require('assert')
, fu = require('foounit').globalize();
it('test some timeout stuff', function (){
var x;
setTimeout(function (){
x = true;
}, 1000);
@foobarfighter
foobarfighter / test.html
Created March 21, 2011 01:30
basic html page
<!DOCTYPE html>
<html>
<head>
<title>TestApp</title>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
@foobarfighter
foobarfighter / test-app.xml
Created March 21, 2011 01:28
basic html air app file
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/2.0">
<id>TestApp</id>
<version>001</version>
<filename>TestApp</filename>
<initialWindow>
<content>test.html</content>
<visible>true</visible>
<width>553</width>
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[color]
branch = auto
diff = auto
status = auto
# Git/SVN/PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git::\1)/'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk -F / '{print "(svn::"$1 "/" $2 ")"}'
}
parse_svn_url() {
svn info 2>/dev/null | grep -e '^URL*' | sed -e 's#^URL: *\(.*\)#\1#g '
}
dojo.publish = function(topic, args) {
var f = dojo._topics[topic];
for (var t in dojo._topics) {
var re = new RegExp("^" + t)
if (topic.match(t)) {
var argArray = [];
if (args) {
dojo.forEach(args, function(arg) {
argArray.push(arg)
var events = new Object();
util.mixin(events, {
_channels: {},
_regExpChannels: [],
publish: function(name, args) {
var handles = this._channels[name] && this._channels[name].handles;
if (handles) {
this._applyHandles(handles, name, args);
}