Skip to content

Instantly share code, notes, and snippets.

View roryokane's full-sized avatar

Rory O’Kane roryokane

View GitHub Profile
@roryokane
roryokane / code.coffee
Created November 14, 2012 01:25
assistant for “Maximum of the difference” puzzle on Mathematics Stack Exchange, copied from JS Bin
# environment setup
# this is CoffeeScript (http://coffeescript.org/)
# and I'm using the Underscore.js library (http://underscorejs.org/)
log = console.log
testFunctionUsingTestCases = (fun, funName, testCases) ->
for testCase in testCases
expectedResult = _(testCase).first()
@roryokane
roryokane / Sass_snippets.sass
Created October 26, 2012 03:43
Sass snippets – useful mixins that Compass doesn't already define
@mixin all-but-first($property, $normal-value, $value-for-first: 0)
#{$property}: $normal-value
&:first-child
#{$property}: $value-for-first
@mixin all-but-last($property, $normal-value, $value-for-last: 0)
// won't work in IE8 or below; :last-child not supported
#{$property}: $normal-value
&:last-child
#{$property}: $value-for-last
@roryokane
roryokane / Hide_GitHub_Project_Page_Latest_Commit.user.js
Created September 11, 2012 19:44
UserScript: Hide GitHub Project Page Latest Commit
// ==UserScript==
// @name Hide GitHub Project Page Latest Commit
// @namespace roryokane
// @include /^https?://github\.com/[^/]+/[^/]+/?$/
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
// ==/UserScript==
// GreaseMonkey doesn't fire on pushState and popState right now,
// so the box is reshown and not rehidden when going forward and back to the page again
// TODO work around – at least make toggle link recognize when it’s been thwarted

I had a pretty elaborate vim setup https://github.com/mbriggs/dotvim, and now I am using emacs with evil. I’ll go through the reasons why, with a giant caveat being I actually don’t care what editor anyone who reads this uses, so long as they learn it and it works for them. As someone who has used both, vim shines for people who aren’t in to heavy customization. You can heavily customize vim, but it is so easy to make it dog slow, and even with a ton of work you won’t hit what you can accomplish in emacs. Here are some examples, and also essentially why I am no longer using vim, YMMV

If I want to run a command and have it pipe to another buffer AND not completely lock up the editor, I can do that with a few lines and compilation-mode. This is next to impossible in vim. I can split my editor window and have a shell running on the other side, that i can use all the keys and tools on that I use to edit code, again, not possible in vim. I can have a repl connected to my editor that the editor uses for auto-compl

@roryokane
roryokane / Blank page with single-color background.html
Created September 7, 2012 18:50
Blank page with single-color background
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Blank page with single-color background</title>
<style>
body {
color: black;
background-color: black;
@roryokane
roryokane / .rbenv-version
Created September 4, 2012 12:31
editing Wikipedia ISBN calculation code
1.9.3-p194
html {zoom:1.32;}
img, a[href=news] {zoom:.76;}
/* choose one: */
body * {font-family:'Helvetica Neue', Helvetica, 'Liberation Sans', sans-serif !important;}
/* body * {font-family:Palatino, 'Liberation Serif', Georgia, serif !important;} */
a[href=news] {font-family:Palatino, 'Liberation Serif', Georgia, serif !important;}
code {font:10px/1.5 Menlo, monospace !important;}
@roryokane
roryokane / original_with_test_harness.rb
Created August 3, 2012 17:57 — forked from jcasimir/gist:3247167
test harness for posted code wanting refactoring
class LocaleChooser
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
def self.set_by(inputs)
locale = nil
LOOKUP_CHAIN.each do |lookup|
locale = send("by_#{lookup}", inputs[lookup])
break if locale
@roryokane
roryokane / implementation_in_class.rb
Created August 3, 2012 17:51 — forked from jcasimir/gist:3247167
refactoring posted code by creating Enumerable#find_mapped
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
def self.set_by(inputs)
LOOKUP_CHAIN.find_mapped do |lookup|
locale = send("by_#{lookup}", inputs[lookup])
end
end
@roryokane
roryokane / examples.rb
Created August 1, 2012 18:32
Object#apply_repeatedly and #send_repeatedly for Ruby
# encoding: utf-8
3 * 2 * 2 * 2 * 2 #=> 48
3 * (2 ** 4) #=> 48
3.send_repeatedly(4, :*, 2) #=> 48
3.apply_repeatedly(4) { |obj| obj * 2 } #=> 48
BasicObject.singleton_class.superclass # => Class
BasicObject.singleton_class.superclass.superclass.superclass.superclass #=> BasicObject
BasicObject.singleton_class.send_repeatedly(4, :superclass) #=> BasicObject