Skip to content

Instantly share code, notes, and snippets.

@gavinheavyside
gavinheavyside / trivial_file_upload_service.rb
Created November 3, 2009 20:09
Trivial file upload service using Sinatra
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])
@fnhipster
fnhipster / html5.haml
Created April 9, 2011 01:19
HTML5 HAML Template
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
@koriroys
koriroys / doccsv.rb
Created January 19, 2012 01:43
Tom
# encoding: utf-8
require 'csv'
def is_suffix? name
case name
when "Jr"
true
when "JR"
true
@scottwb
scottwb / Rakefile
Created February 24, 2012 17:21
Rakefile for Middleman with an rsync deploy task.
SSH_USER = 'root'
SSH_HOST = 'www.example.com'
SSH_DIR = '/var/www/html/www.example.com'
desc "Build the website from source"
task :build do
puts "## Building website"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end
@runemadsen
runemadsen / fileupload.rb
Created May 23, 2012 18:35
How to read an uploaded file in sinatra
post '/process' do
file = params[:fileupload][:tempfile]
json = JSON.parse(open(file).read)
# do something with your json here
end

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
  • NBC
@Bodacious
Bodacious / REAME.md
Created July 6, 2012 13:05
Transposing An Existing XCode Project to Rubymotion

For the last two weeks I've been working flat out with Rubymotion, a new toolchain that allows developers to build native iOS applications using the beautiful, elegant Ruby programming language instead of the verbose and somewhat fussy Objective-C programming language.

The app I've been working on is an existing client app we've been developing for several months. The app was about 80% ready for a pilot launch but still had quite a bit of development to go before being shipped. After discussing Rubymotion with the client, we agreed that it would save us both time and money in future development if we move over to Rubymotion. I was tasked with doing the migration; transposing the entire application to Rubymotion.

Timescale

For those of you looking to do the same, here are some stats that might help you estimate the time required and the costs

@ParkinT
ParkinT / Rakefile
Last active October 7, 2015 07:18
RubyMotion Rakefile - improved workflow
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
# custom rake tasks
require '../raketasks/gemerator.rb'
desc "Open latest crash log"
task :log do
app = Motion::Project::App.config
@georgy-martirosov
georgy-martirosov / post-commit
Created August 14, 2012 13:23
Take webcam shot after each commit via post-commit hook
#!/usr/bin/env ruby
# take photo after commit ; )
file="~/.gitshots/#{Time.now.to_i}.jpg"
puts "Taking capture into #{file}!"
system "imagesnap -q -w 3 #{file}"
exit 0
@rafaelrinaldi
rafaelrinaldi / README.md
Created October 20, 2012 04:45
Command for the native Markdown bundle of TextMate which allows you to preview the current document on Marked.

This is a simple TextMate command that allows you to preview the current document you're editing right on Marked editor.

Installation

  • Go to BundlesBundle EditorShow Bundle Editor (or simply ⌃⌥⌘B):
  • Locate the Markdown bundle then click on it:
  • On the bottom of the window you'll find a plus icon. Click on it then select New Command: