Skip to content

Instantly share code, notes, and snippets.

View hamzakc's full-sized avatar

Hamza Khan-Cheema hamzakc

View GitHub Profile
; vi: ft=clojure
; THIS IS A Fennel SOURCE FILE (.fnl) !NOT! clojure!
; you need to use luajit to run this, after using fennel --compile
; install lapis and turbo from luarocks
; When running with Fennel directly, you need to --globals all used HTML tags
(local turbo (require "turbo"))
(local render_html (. (assert (require "lapis.html")) :render_html))
;; org-gcal wrappers to only sync with a timeout
(defvar org-gcal-fetch-last-run (current-time)
"Timestamp of the last time org-gcal-fetch-store-time was run")
(defun org-gcal-fetch-with-timeout (timeout)
(interactive)
"Runs org-gcal-fetch only if the last time this function was called is > the timeout"
(let ((time-since-last-run
(float-time (time-subtract (current-time) org-gcal-fetch-last-run))))
(when (> time-since-last-run timeout) ;; was the last run longer than our timeout
(org-gcal-fetch)
@davidstump
davidstump / touch.coffee
Created May 1, 2013 23:42
Simple class to handle touch events and emit them to your application. Utilizes EventEmitter.
@Touch=
horizontal_sensitivity: 22
vertical_sensitivity: 6
touchDX: 0
touchDY: 0
touchStartX: 0
touchStartY: 0
bind: (elements...) ->
@McRipper
McRipper / payments_controller.rb
Created December 3, 2012 21:01
Rails PayPal recurring monthly payment
class PaymentsController < ActionController::Base
skip_before_filter :verify_authenticity_token, :only => :notification
before_filter :load_subscription
def checkout
redirect_to @subscription.paypal.checkout_url(
return_url: "http://www.example.com" + "/paypal/review/#{@subscription.id}",
cancel_url: "http://www.example.com" + "/paypal/cancel/#{@subscription.id}"
@geuis
geuis / remote-typeahead.js
Created February 16, 2012 22:58
Remote data querying for Twitter Bootstrap 2.0 Typeahead without modifications
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
@brentkirby
brentkirby / service
Created June 22, 2011 08:50
Unicorn + Runit + RVM
#!/bin/bash -e
#
# Since unicorn creates a new pid on restart/reload, it needs a little extra love to
# manage with runit. Instead of managing unicorn directly, we simply trap signal calls
# to the service and redirect them to unicorn directly.
#
# To make this work properly with RVM, you should create a wrapper for the app's gemset unicorn.
#
function is_unicorn_alive {
@cajun-code
cajun-code / migration.rb
Created May 18, 2011 18:28 — forked from serek/migration.rb
Migration from attachment_fu to paperclip.
class ConvertImagesToPaperclip < ActiveRecord::Migration
include PaperclipMigrations
def self.up
# Paperclip
add_column :images, :data_file_name, :string
add_column :images, :data_content_type, :string
add_column :images, :data_file_size, :integer
add_column :images, :data_updated_at, :datetime
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
if defined?(RSpec)
namespace :rcov do
RSpec::Core::RakeTask.new(:rspec_aggregate) do |task|
task.pattern = 'spec/**/*_spec.rb'
task.rspec_opts = "--format progress"
task.rcov = true
task.rcov_opts = "--rails --exclude osx\/objc,spec,gems\/ " +
"--aggregate tmp/coverage.data"
end
@bryanl
bryanl / 37singals REE GC environment
Created October 27, 2010 15:54
37signals ree settings
RUBY_HEAP_MIN_SLOTS=600000
RUBY_GC_MALLOC_LIMIT=59000000
RUBY_HEAP_FREE_MIN=100000