Skip to content

Instantly share code, notes, and snippets.

View damncabbage's full-sized avatar
🙅‍♀️
permanent omnishambles

Robin Howard damncabbage

🙅‍♀️
permanent omnishambles
View GitHub Profile
#ruby
[1,2,3,4].select{ |x| x.even? }
#python
[x for x in [1,2,3,4] if not x%2]
#or, more norvingly
filter(lambda x: not x%2, [1,2,3,4])
#clojure
(filter #(even? % ) [1 2 3 4])
# Consider the following
class ApplicationController < ActionController::Base
helper_method :current_filter
private
def current_filter
ActiveSupport::StringInquirer.new(params[:filter] || '')
end
end

This is the code that powers the parallax effect on codetunes.com.

I think it’s quite chaotic at the moment and waits for being released as open source when it’s cleaned up.

@damncabbage
damncabbage / gist:6077544
Last active December 20, 2015 05:19 — forked from mwotton/gist:6077238
<?php
header("Content-Disposition: binary/data");
preg_match('/([^\/]+)\/favicon.ico/', $_SERVER['REQUEST_URI'], $matches);
echo (file_exists(getenv('cachedir').'/'.$matches[1]) ? file_put_contents(getenv('cachedir').'/'.$matches[1], file_get_contents('http://'.$matches[1].'/favicon.ico')) : file_get_contents(getenv('cachedir').'/'.$matches[1]));
// see that. thats fucking magestic is what it is.
@damncabbage
damncabbage / deploy.rb
Last active December 20, 2015 17:49 — forked from pyrmont/deploy.rb
default_run_options[:pty] = true # Must be set for the password prompt from git to work
set :ssh_options, { :forward_agent => true }
set :user, "smash"
set :application, "SMASH! Join Us"
set :domain, "linode.smash.org.au"
set :deploy_to, "/var/www/smash.org.au/2014-staff-call"
set :shared_path, "#{deploy_to}/shared"
set :use_sudo, false
@damncabbage
damncabbage / Main.hs
Last active August 29, 2015 14:03 — forked from christian-marie/gist:475858353961828655f8
Prisoner's Dilemma: Game Server
--
-- Copyright © 2013-2014 Anchor Systems, Pty Ltd and Others
--
-- The code in this file, and the program it is a part of, is
-- made available to you by its authors as open source software:
-- you can redistribute it and/or modify it under the terms of
-- the 3-clause BSD licence.
--
module Main where
@damncabbage
damncabbage / Strictness.hs
Created March 2, 2015 11:30 — forked from tonymorris/Person.hs
Haskell Strictness
data Person = Person {
firstName :: String
, lastName :: String
}
data Person' = Person' {
firstName' :: !String
, lastName' :: String
}
func coalesceMaps(args ...map[string]interface{}) map[string]interface{} {
var m map[string]interface{}
if len(args) > 1 {
m = make(map[string]interface{})
for _, arg := range args {
m = clobberMerge(m, arg)
}
} else {
@damncabbage
damncabbage / foo.rb
Last active August 29, 2015 14:19 — forked from radar/foo.rb
require 'rspec'
require 'rspec/autorun'
module Foo
end
RSpec.describe Foo do
it "tests" do
expect(subject.class).to eq(Foo)
end
@damncabbage
damncabbage / sql.rb
Last active August 29, 2015 14:21 — forked from zerowidth/sql.md
# GitHub::SQL - a helping hand for SQL in a rails app.
#
# Built for MySQL, adaptations and updates welcome.
#
# Authors/maintainers: @jbarnette, @zerowidth, et. al.
#
# The MIT License (MIT)
#
# Copyright (c) 2014 GitHub, Inc.
#