Skip to content

Instantly share code, notes, and snippets.

@yortz
yortz / gist:1140103
Created August 11, 2011 16:32 — forked from rweald/gist:969981
Multi-threaded Non blocking file uploads using EventMachine and EM-Http-Request
#!/usr/bin/env ruby
require 'em-http-request'
require 'fiber'
require "ruby-debug"
class AsynUploader
@successes = []
@failures = []
@yortz
yortz / test_server.rb
Created August 13, 2011 15:21 — forked from vincentchu/test_server.rb
Test sinatra + EventMachine
require 'rubygems'
require 'sinatra/base'
require 'eventmachine'
require 'logger'
$logger = Logger.new(File.join(File.dirname(__FILE__), "development.log"))
module TestEM
def self.start
if defined?(PhusionPassenger)
@yortz
yortz / resize_and_crop.rb
Created August 13, 2011 22:14 — forked from soutaro/resize_and_crop.rb
resize and crop using using MiniMagick
def resize_and_crop(blob, w0, h0, w1, h1)
image = MiniMagick::Image.read(blob)
rw = w1.to_f / w0
rh = h1.to_f / h0
unless rw > 1 or rh > 1
w,h = w1, h1
sx, sy = 0, 0
@yortz
yortz / gist:1394699
Created November 25, 2011 23:51 — forked from metaskills/gist:756111
Rails 3 Models To Export Mephisto To Jekyll & Disqus
require 'builder'
require 'digest/md5'
class Content < ActiveRecord::Base
belongs_to :user
end
class Section < ActiveRecord::Base
has_many :assigned_sections
has_many :articles, :order => 'position', :through => :assigned_sections
@yortz
yortz / gist:3314799
Created August 10, 2012 15:01
StoreLocator
class mm.StoreLocator extends mm.Module
constructor: ->
@canvas = $('#map-canvas')
@center = new google.maps.LatLng(51.512054, -0.103855)
@mapOpts =
zoom: 11
zoomControl: true #seems that 320-up is breaking zoomcontrol???? though it seems from the mockups that they just want an empy map
disableDefaultUI: true
mapTypeId: google.maps.MapTypeId.ROADMAP
center: @center
" .vimrc File
" Procured from: Jeffrey Way
" jeffrey@jeffrey-way.com
"
" Improved by: Garrett Dawson
" killtheliterate@gmail.com
"
"Forget compatibility with Vi. Who cares.
set nocompatible
@yortz
yortz / gist:5225415
Created March 22, 2013 23:03
jekyll-assets Rakefile for octopress
require "rubygems"
require "bundler/setup"
require "stringex"
## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ssh_user = "user@domain.com"
ssh_port = "22"
document_root = "~/website.com/"
rsync_delete = false
@yortz
yortz / gist:5225462
Created March 22, 2013 23:12
jekyll-assets octopress theme.scss
$noise-bg: image-url("{% asset_path images/noise.png %}") top left !default;
$img-border: inline-image("{% asset_path images/straight-border.png %}");
// Main Link Colors
$link-color: #e11e30 !default;
$link-color-hover: adjust-color($link-color, $lightness: 20, $saturation: 45) !default;
$link-color-visited: adjust-color($link-color, $hue: 80, $lightness: -4) !default;
$link-color-active: adjust-color($link-color-hover, $lightness: -15) !default;
// Main Section Colors
# Generating Site with Jekyll
WARNING: 'noise.png %}' was not found (or cannot be read) in /Users/yortz/code/projects/website.com/source/_assets/images/{% asset_path images
File not found or cannot be read: /Users/yortz/code/projects/website.com/source/_assets/images/{% asset_path images/straight-border.png %}
Configuration from /Users/yortz/code/projects/website.com/_config.yml
Building site: source -> public
Successfully generated site: source -> public
" Screen settings
map <F5> :ScreenShellVertical<CR>
command! -nargs=? -complete=shellcmd W :w | :call ScreenShellSend("load '".@%."';")
map <Leader>c :ScreenShellVertical bundle exec rails c<CR>
map <Leader>r :w<CR> :call ScreenShellSend("rspec ".@% . ':' . line('.'))<CR>
map <Leader>e :w<CR> :call ScreenShellSend("cucumber --format=pretty ".@% . ':' . line('.'))<CR>
map <Leader>b :w<CR> :call ScreenShellSend("break ".@% . ':' . line('.'))<CR>