Skip to content

Instantly share code, notes, and snippets.

@trvsdnn
trvsdnn / static.rake
Created December 17, 2013 00:43
Rails static pages generation/compilation with no extra routing or controllers.
namespace :static do
desc "Compile static pages and save them in /public"
task compile: :environment do
class StaticController < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::AssetPaths
include Rails.application.routes.url_helpers
@trvsdnn
trvsdnn / gist:2992801
Created June 26, 2012 02:17
extract attachments from a folder of .eml
#! /usr/bin/env ruby
require 'mail'
MAIL_PATH = "#{ARGV.first}/*.eml"
ATTACHMENTS_PATH = File.join(ENV['HOME'], 'found-attachments')
Dir[MAIL_PATH].each do |email|
mail = Mail.read(email)
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
page_number = 1
print "Where you wanna put it? "
folder = gets.chomp
Dir.mkdir(folder)
@trvsdnn
trvsdnn / gist:1321710
Created October 28, 2011 05:48
twitter_link
def twitter_link(handle)
avatars_path = 'public/img/avatars/'
avatar = handle + '.jpg'
avatar_path = avatars_path + avatar
img_tag = "<img src='#{avatar_path.sub(/^public/, '')}' />"
# Check and see if there's already an avatar.
unless File.exists?(avatar_path)
# We don't have it. Let's try to get it from Twitter.
begin
#!/bin/sh -
if [ $# -ne 1 ]; then
NEWPATH=$PWD
else
NEWPATH=$1
fi
/usr/bin/osascript <<-EOF
activate application "Terminal"