Skip to content

Instantly share code, notes, and snippets.

Being good to others

Evan Walsh evanwalsh

Being good to others
View GitHub Profile
evanwalsh / import.rb
Last active Jul 18, 2021
I imported my Jekyll from Squarespace's Wordpress XML with this
View import.rb
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'safe_yaml'
require 'time'
module JekyllImport
# This importer takes a wordpress.xml file, which can be exported from your
View mithril-query.d.ts
declare var MithrilQuery: (...options: any[]) => MithrilQueryInstance
interface KeyEventOptions {
target?: any
value?: any
altKey?: boolean
shiftKey?: boolean
ctrlKey?: boolean
silent?: boolean
evanwalsh / imgur.rb
Created Aug 21, 2012
Download an gallery with Ruby and Nokogiri
View imgur.rb
#!/usr/bin/env ruby
# Download galleries easily
# Requirements:
# gem install nokogiri
# Usage:
# ruby imgur.rb [url of gallery] [directory to download into] [namespace for files]
View gist:c9060b09adeefa1b3f59d90c3de1e402
• What does the app do?
• How to start a timer?
• How to stop a timer?
• How does idle time work?
• How does summary bar/time summary work?
• How to change preferences?
• Where do I get it?
evanwalsh / weather_geeklet.rb
Last active Dec 17, 2015 script for GeekTool
View weather_geeklet.rb
#!/usr/bin/env ruby
# Get an API key from
# Outputs something like this:
# Clear, 65°F
# Moderate chance of rain until tonight
View selector.rb
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
evanwalsh / meta_tag_helper.rb
Created Aug 12, 2012
Meta tag helper for Rails
View meta_tag_helper.rb
# Accepts arguments like:
# meta_tag :warning, "HC SVNT DRACONES"
# or
# meta_tag charset: "utf-8"
def meta_tag *options
if ( {|o| o.is_a?(String) || o.is_a?(Symbol) }.count == options.count) && (options.count == 2)
tag :meta, name: options.first, content: options.last
tag :meta, *options
evanwalsh / app--helpers--application_helper.rb
Created May 4, 2012 — forked from nickhoffman/app--helpers--application_helper.rb
pjax is awesome, but causes code within #content_for not to be rendered. Here's a solution.
View app--helpers--application_helper.rb
module ApplicationHelper
def content_for_or_pjax(name, &block)
request.headers['X-PJAX'] ? capture(&block) : content_for(name, &block)
evanwalsh / gist:2552100
Created Apr 29, 2012 — forked from joelmoss/gist:2470666
Capistrano recipe for Puma start/stop/restarts
View gist:2552100
set :shared_children, shared_children << 'tmp/sockets'
namespace :deploy do
desc "Start the application"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{stage} bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{stage}.log 2>&1 &", :pty => false
desc "Stop the application"
task :stop, :roles => :app, :except => { :no_release => true } do
evanwalsh / levenshtein.rb
Created Apr 20, 2012
Levenshtein distance
View levenshtein.rb
class String
def levenshtein(other, ins=2, del=2, sub=1)
# ins, del, sub are weighted costs
return nil if self.nil?
return nil if other.nil?
dm = [] # distance matrix