Skip to content

Instantly share code, notes, and snippets.

View micahbrich's full-sized avatar

Micah Rich micahbrich

View GitHub Profile
@micahbrich
micahbrich / Gemfile
Created September 19, 2014 23:06
The default rails server when you run it on your local computer is WEBrick, which is great for developing, but awful once a bunch of people start using it at once. Instead, let's add a new, more production-ready server in on Heroku, and add a file that tells Heroku to use it.
source 'https://rubygems.org'
group :production do
gem "thin"
end
@micahbrich
micahbrich / git-grab
Created August 6, 2015 19:54
git-grab – snagging a specific piece of a git repo using SVN, of all things
#!/bin/bash
#######################################
# List the contents, or download a
# folder from a GitHub repo.
# Argument:
# HTTPS URI to folder
#######################################
echo ${1} | sed 's/tree\/master/trunk/g' | { read uri; (svn export $uri); }
require 'fleakr'
class Fetchr < ActiveRecord::Base
# This script fetches flickr photos
@flickr ||= Fleakr.api_key = < my key >
@user ||= Fleakr.user('info@micahrich.com')
@photos ||= @user.sets.first.photos
@photos.each do |photo|
class ImagesController < ApplicationController
session :cookie_only => false, :only => :upload_image_block
def upload_image_block
@image = Image.new(:file => swf_upload_data) # here you can use your favourite plugin to work with attachments
if @image.save
render :partial => 'image', :object => @image
else
render :text => "error"
end
@micahbrich
micahbrich / amgleft.js
Created August 16, 2009 17:39
anthony's imageswapping js
function swapPhoto(photoSRC,theCaption,theLink) {
var displayedImage = document.getElementById("thephoto");
var displayedCaption = document.getElementById("caption");
// to make the link go to a new window, i just added 'target="_blank"' to both links below.
// target is just an attribute of the a tag in html
//
// however, i added a conditional to the image & link replacers.
// it says that if there is no third variable, there won't be any links. it's written as follows:
@micahbrich
micahbrich / codemirror.js
Created October 29, 2009 21:23
this junk is doing nothing at all
<script src="javascripts/codemirror/js/codemirror.js" type="text/javascript"></script>
<script type="text/javascript">
var textarea = document.getElementById('user_about');
var editor = CodeMirror.fromTextArea(textarea, {
content: textarea.value,
parserfile: ["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js"],
stylesheet: ["javascripts/codemirror/css/xmlcolors.css", "javascripts/codemirror/css/jscolors.css", "javascripts/codemirror/css/csscolors.css"],
path: "javascripts/codemirror/js/",
lineNumbers: true,
@micahbrich
micahbrich / error on heroku db:pull
Created November 25, 2009 15:22
error on heroku db:pull
Auto-detected local database: mysql://root@127.0.0.1/agoodportfolio_development?encoding=utf8
Receiving schema
Receiving data
6 tables, 4,650 records
groups: 100% |==========================================| Time: 00:00:01
schema_migrat: 100% |==========================================| Time: 00:00:00
/Library/Ruby/Gems/1.8/gems/sequel-3.0.0/lib/sequel/adapters/mysql.rb:147:in `query': MySQL server has gone away (Mysql::Error)
from /Library/Ruby/Gems/1.8/gems/sequel-3.0.0/lib/sequel/adapters/mysql.rb:147:in `transaction'
from /Library/Ruby/Gems/1.8/gems/sequel-3.0.0/lib/sequel/connection_pool.rb:108:in `hold'
from /Library/Ruby/Gems/1.8/gems/sequel-3.0.0/lib/sequel/database.rb:461:in `synchronize'

Typekit Font Events

Web fonts may be the best thing to happen to web design in years, but that doesn't mean there aren't some tricky issues to overcome. One of the most annoying things is dealing with what's become known as the FOUT or 'Flash of Unstyled Text'. It's what happens in some browsers while waiting for fonts to download.

Typekit is introducing Font Events to put you back in control when using web

{block:Post1}
<div class="featured">
{/block:Post1}
your post type blocks...
{block:Post1}
</div>
{/block:Post1}
@micahbrich
micahbrich / flac-to-mp3.rb
Created May 21, 2011 23:40
Batch convert flac to mp3, with metadata, using ffmpeg
Dir.glob("*.flac").each do |f|
flac = "./#{f.gsub(' ', '\ ')}"
mp3 = "./#{f.gsub(' ', '\ ').chomp('.flac')}.mp3"
system("ffmpeg -i #{flac} -map_meta_data #{mp3}:#{flac} #{mp3}")
end