Skip to content

Instantly share code, notes, and snippets.

View stravid's full-sized avatar

David Strauß stravid

View GitHub Profile
@stravid
stravid / task.thor
Created November 13, 2012 12:18
Thor FTP deploy task
desc "deploy", "deploys the site via LFTP to the location specified in the environment"
def deploy
load_ftp_configuration
start_timestamp = Time.now.to_i
if system("lftp -e 'mirror -R -v #{ENV['PUBLIC_DIRECTORY']} #{ENV['FTP_TARGET_DIRECTORY']}; bye' -u #{ENV['FTP_USER']},#{ENV['FTP_PASSWORD']} #{ENV['FTP_SERVER']}")
puts "Deploy finished. (Duration: #{Time.now.to_i - start_timestamp} seconds)"
else
puts 'Deploy aborted, something went wrong.'
#!/bin/sh
set -e
function download() {
url=$1
base=$(basename $1)
if [[ ! -e $base ]]; then
echo "curling $url"
curl -O -L $url
@stravid
stravid / gist:2024450
Created March 12, 2012 20:23
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (OS X)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
#= require helpers/namespace
#= require embient/ember-routemanager
namespace 'slotcars'
slotcars.RouteManager = Ember.RouteManager.extend
wantsHistory: true # use html5 push state
delegate: null
Slotcars::Application.routes.draw do
root :to => 'tracks#index'
get '/tracks/:id' => 'tracks#index'
get '/tracks/new' => 'tracks#index'
end
canvas = document.getElementById 'canvas'
canvas.width = 1024
canvas.height = 700
context = canvas.getContext '2d'
points = []
isMoving = false
$('canvas').on 'touchstart', (event) -> onTouchStart event
$('canvas').on 'touchmove', (event) -> onTouchMove event
@stravid
stravid / coffeescript.html
Created January 24, 2012 11:00
Starterkit for CoffeeScript
<html>
<head>
<title>CoffeeScript</title>
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
</head>
<body>
<h1>Hello CoffeeScript!</h1>
class User < ActiveRecord::Base
include Clearance::User
before_create :generate_api_key
attr_accessible :time_zone, :email, :password
validates_uniqueness_of :api_key
private
def generate_api_key
self.api_key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..24]
# test.coffee
Test =
print: ->
console.log("Test.print called")
if module.exports?
module.exports = Test
else
@Test = Test
# RVM bootstrap
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, '1.9.2@shuffler'
set :rvm_type, :user
# bundler bootstrap
require 'bundler/capistrano'
unless Capistrano::CLI.ui.agree("Are you sure you want to redeploy? (yes/no): ")