Skip to content

Instantly share code, notes, and snippets.

View zorab47's full-sized avatar
⌨️

Charles Maresh zorab47

⌨️
View GitHub Profile
# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
@tswicegood
tswicegood / sync_things.rb
Created October 1, 2009 20:13
Simple Ruby script to sync Basecamp and Things to-dos.
#!/usr/bin/env ruby
#
# Biggest problem with this is that it checks everything. Needs
# to be adjusted to only check N days and/or N tasks on Basecamp.
#
# Also has a problem in that Completed always wins. If you have a
# task marked at completed, then mark it as open again on just one
# side, it'll mark the other as completed if you run the sync again.
#
# All that said, it provides a basic, very rudimentary sync.
public class InMemoryDbSet<T> : IDbSet<T> where T : class
{
readonly HashSet<T> _set;
readonly IQueryable<T> _queryableSet;
public InMemoryDbSet() : this(Enumerable.Empty<T>()) { }
public InMemoryDbSet(IEnumerable<T> entities) {
@durran
durran / unicorn
Created December 1, 2011 14:07
Unicorn Config Rackspace (init.d)
#! /bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Unicorn server"
NAME=unicorn
RVM=/usr/local/rvm/bin/rvm
RVM_EXEC_ARGS="1.9.3@application exec"
RAILS_DIR=/data/application
DAEMON=$RVM
DAEMON_ARGS="$RVM_EXEC_ARGS $RAILS_DIR/bin/unicorn -c $RAILS_DIR/config/unicorn.rb -E staging -D"
@britg
britg / jquery.touch.js
Created January 5, 2012 16:29
jQuery touch events
/**
* touch for jQuery
*
* Copyright (c) 2008 Peter Schmalfeldt (ManifestInteractive.com) <manifestinteractive@gmail.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@betamatt
betamatt / Procfile
Created January 26, 2012 23:29
Running delayed_job with foreman
queue: ./queue.sh
#!/bin/sh
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
usage=$(
cat <<EOF
$0 [OPTIONS] start/stop
-s set speed default 256Kbit/s
-p set port default 3000
-d set delay default 350ms
@OllyHodgson
OllyHodgson / sparkline.svg
Created January 7, 2013 09:50
Stuart Langridge's Simple SVG sparklines — http://kryogenix.org/days/2012/12/30/simple-svg-sparklines — but using an object element instead of an embed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mislav
mislav / tmux-session.sh
Last active January 27, 2016 01:00
Get current tmux session name
tmux list-pane -F '#S' | head -1
@bigsur0
bigsur0 / parallel_find_in_batches_start_end
Created September 23, 2011 16:53
Parallel gem and find_in_batches with start, end
num_processes = 2
batch_size = 1000
threads_per_process = 10
Parallel.map(0...num_processes, :in_processes => num_processes) do |i|·
User.connection.reconnect!
User.find_in_batches(:batch_size => batch_size,·
:start => (User.count/num_processes) * i,·
:conditions => ["id <= ?", (User.count/num_processes)*(i+1)]) do |batch|·
Parallel.map(batch, :in_threads => threads_per_process) do |record|