Skip to content

Instantly share code, notes, and snippets.

View evanwalsh's full-sized avatar
❤️‍🔥
You make me feel almost human

Evan Walsh evanwalsh

❤️‍🔥
You make me feel almost human
View GitHub Profile
@vito
vito / gist:728346
Created December 4, 2010 17:38
session garbage collector
Timer do: {
Session all each: { s |
when: (Timer now - s created-at > 1 month) do: {
"Cleaning up expired session " (.. s id) print
s delete!
}
}
} every: 1 day
@malkia
malkia / dotkey.lua
Created June 6, 2012 23:04
Returns the value of a dot encoded key from the table t
local dotkey = {}
----------------------------------------------------------
-- Returns the value of a dot encoded key from the table t
-- Returns nil if the key is not found.
-- Example: local t = { one = { two = 12 } }
-- print( dotkey.get( t, "one.two" ) ) -- prints 12
function dotkey.get(t, key)
local b, s, p = string.byte, string.sub, 1
for i=1, key:len()+1 do
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@inertialbit
inertialbit / ansible-ubuntu-ruby-playbook.yml
Created January 21, 2013 18:10
installs rbenv via rbenv-installer, ruby matching $ruby_version and passenger + apache2 module to $user home and updates $user/.bash_profile w/ rbenv env vars
---
- name: install rb-installer
action: shell curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
- name: update PATH in ~/.bash_profile for rb-env
action: lineinfile dest=/home/$user/.bash_profile line=export\ PATH="$HOME/.rbenv/bin:$PATH" regexp=PATH.*rbenv
- name: add rb-env init to ~/.bash_profile
action: lineinfile dest=/home/$user/.bash_profile line='eval "$(rbenv init -)"' regexp=eval.*rbenv
@mebens
mebens / gist:3929259
Created October 22, 2012 02:07
Generate a linear radial gradient in Love2D
local function scale(x, min1, max1, min2, max2)
return min2 + ((x - min1) / (max1 - min1)) * (max2 - min2)
end
local function distance(x1, y1, x2, y2)
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
end
function radialGradient(radius)
local data = love.image.newImageData(radius * 2, radius * 2)
@mebens
mebens / postfx.lua
Created December 6, 2012 02:30
A post-processing effects manager for Love2D
postfx = {}
postfx.all = {}
postfx.active = true
local PixelEffect = class("PixelEffect")
function PixelEffect:initialize(effect)
self.effect = effect
self.active = true
end
@PatrickTulskie
PatrickTulskie / resque_retry.rb
Created July 25, 2011 19:15 — forked from clemens/resque_retry.rb
Retry failed Resque jobs in Ruby
# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
using UnityEngine;
using System;
public class ScreenshotCamera
{
static Vector3 FocusPoint;
static float Aperture = 20.0f;
RealTimeSince timeSinceMessage;
string MessageText;
@mebens
mebens / example.lua
Created November 16, 2012 04:24
Doubly linked list in Lua
require("list")
local a = { 3 }
local b = { 4 }
local l = list({ 2 }, a, b, { 5 })
l:pop()
l:shift()
l:push({ 6 })
l:unshift({ 7 })
Hi David,
I came across your profile online and wanted to reach out about Development
Opportunities here at Groupon. The company is growing, and we're always
looking for folks with solid skills that can make positive contribution to
our continued success. Any chance you'd be open to a quick conversation
about opportunities, or for any possible networking potential? If so, let me
know when you're free and we can set up a time to chat. Also, if you are
interested, it would be great if you could forward a current resume over
that I can take a look at. I look forward to hearing back from you! Please
let me know if you have any questions.