This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ipaddr' | |
module Rack | |
# | |
# BanHammer is a Rack middleware app that restricts access to your server | |
# using a black-list of IPv4/IPv6 addresses and ranges. | |
# | |
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com) | |
# | |
# Needlessly modified by Mike Frawley |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a `module` is about == to a namespace | |
`@name` is an instance variable in a class | |
self == this | |
puts == console.printLn | |
initialize == constructor | |
`def method(*args)` takes an arbitrary number of arguments, and 'splats' them in to an array in the `args` variable. so we can call: `method(1,2,3,4,7775,5) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://roo.rubyforge.org/ | |
# http://code.joejag.com/2009/using-ruby-to-parse-an-excel-document/ | |
class Spreadsheet | |
def initialize(path, path_to_results='c:/tmp/resultz') | |
@path = path | |
@path_to_results = | |
end | |
def id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've got some experimental stuff in unpublished branches / projects I use underscore in. Let me know if | |
you like any of these: | |
1.) Too many simple things take two lines to do in javascript, like: | |
_.reduce(list, {}, function (memo, value) { | |
memo[value] = true; | |
return memo; | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function that builds both min and max functions since they use the same logic, | |
// the only thing difference being: | |
// - which Math function we use (min or max) | |
// - what the starting value is (Infinity or -Infinity) | |
// - what the comparison is (< or >) for the transform case. | |
// We can't curry this away without evaling or calling a function, so just pass in | |
// true if we want to use a greater than comparison, false to use less than. | |
// | |
// For the cases where no transform function is given we fast path out this trick: | |
// http://ejohn.org/blog/fast-javascript-maxmin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* toggleAttr() jQuery plugin | |
* @link http://github.com/mathiasbynens/toggleAttr-jQuery-Plugin | |
* @description Used to toggle selected="selected", disabled="disabled", checked="checked" etc… | |
* @author Mathias Bynens <http://mathiasbynens.be/> | |
*/ | |
;(function($) { | |
$.fn.toggleAttr = function(attr) { | |
return this.each(function() { | |
$(this).attr(attr) ? $(this).removeAttr(attr) : $(this).attr(attr, attr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assuming running script from home dir, with local.rb inside the backup folder, load it: | |
require 'Backup/local' | |
Backup::Model.new(:my_backup, 'My Backup') do | |
archive :vim do |archive| | |
archive.add '/Users/mike.frawley/.vim' | |
end | |
store_with ::Backup::Storage::Local do |local| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="/stylesheets/news/detail.css" /> | |
<section> | |
<div class="module central content"> | |
<div class="post"> | |
<h2><%= article.title %></h2> | |
<%= article.content %> | |
</div> | |
</div> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I thought of a good analogy to 'no ;' are bad argument: | |
~~~ | |
I can recall getting bitten by 'no ;' once, but LOTS of times I've | |
gotten the dangling ',' in object literal bug: | |
this.options = { a:1, b:2, } | |
Modern browsers allow it so you typically don't spot it late in the game when ie7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After('@screenshot') do |scenario| | |
filename = scenario.name.parameterize + ".png" | |
filename = "FAILED-#{filename}" if scenario.failed? | |
path = File.join("doc", "screenshots", filename) | |
page.driver.save_screenshot(path) | |
end |