Skip to content

Instantly share code, notes, and snippets.

View pjambet's full-sized avatar

Pierre Jambet pjambet

View GitHub Profile
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
@sirupsen
sirupsen / README.md
Created October 15, 2010 15:23
Simple evented ChatServer in pure Ruby using network I/O with select(2).

Dependencies

Colored for chat colors

gem install colored

It has many comments since I tried to explain what is going on for less-experienced Ruby people.

@kyleturner
kyleturner / Remove Submodule
Created January 5, 2012 01:07
How to remove a submodule from a Github project
To remove a submodule you need to:
Delete the relevant line from the .gitmodules file.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit and delete the now untracked submodule files.
@weilu
weilu / spec_helper.rb
Created November 10, 2012 08:12
Configure database_cleaner for a test suite that contains Capybara js specs.
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
@oivoodoo
oivoodoo / vim-scripts
Created April 16, 2013 12:10
Replace old rspec style with expect using vim regexp
%s/\(\S\+\).should\(\s\+\)==\s*\(.\+\)/expect(\1).to\2eq(\3)/
Example:
row.day.should == 'value'
expect(row.day).to eq('value')
@werkshy
werkshy / cr
Created October 22, 2013 18:49
Asana code review CLI
#!/usr/bin/env ruby
# cr: send an Asana ticket for code review
# It will add (or re-open) a sub-task called 'Code Review' owned
# by the specified user.
# Usage:
# cr [-a ASANA_ID] [-g GIT_COMMIT] username
#
# - If the Asana ticket ID is given, use that.
@werkshy
werkshy / init.rb
Last active January 11, 2017 16:18
Heroku plugin that installs busybox onto a dynos before dropping you into a bash shell.
#!/usr/bin/env ruby
# Put this file at ~/.heroku/plugins/busybox/init.rb
# Call it with 'heroku busybox'
require 'heroku/helpers'
require 'heroku/command'
require 'heroku/command/run'
class Heroku::Command::Busybox < Heroku::Command::Run
@henrik
henrik / deploying_phoenix_on_dokku.md
Last active April 14, 2024 00:32
Deploying Elixir's Phoenix Framework on Dokku.

Deploying Phoenix on Dokku

Worked 2015-09-08 for Phoenix 1.0.1 on Dokku 0.3.25.

These instructions assume you've set up Dokku. If not, go find a tutorial for that part. My notes for setting it up on Digital Ocean.

On your local machine, in the app's repo

Create a Dokku app:

@mmrko
mmrko / git-zsh-checkout-autocomplete-local-only.md
Last active July 20, 2023 08:48
List only local branches when autocompleting git checkout (Zsh)
git config --global alias.checkoutr checkout
$EDITOR /usr/local/share/zsh/site-functions/git-completion.bash

...and then modify the file as follows...

-__gitcomp_nl "$(__git_refs '' $track)"
+if [ "$command" = "checkoutr" ]; then
+    __gitcomp_nl "$(__git_refs '' $track)"
+else
@AGWA
AGWA / select.rs
Created April 14, 2017 03:34
Very simple Rust wrapper around pselect
/* Copyright (C) 2017 Andrew Ayer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included