Skip to content

Instantly share code, notes, and snippets.

View matthijsgroen's full-sized avatar
🚀
Computering

Matthijs Groen matthijsgroen

🚀
Computering
View GitHub Profile
@matthijsgroen
matthijsgroen / exporter.rb
Created February 28, 2011 09:52
Set up database backup scripts
#!/usr/bin/ruby
u = "root"
p = "password"
Dir.chdir "/root/database_backups"
`git reset --hard`
`git checkout backups`
`git merge master`
@matthijsgroen
matthijsgroen / move-repos.rb
Created March 3, 2011 13:28
Move repositories from one git repo to another
#!/usr/bin/ruby
require "yaml"
module Git
class RepoMover
CONFIG_ROOT = "repo_movement"
@matthijsgroen
matthijsgroen / scss-watch.rake
Created March 28, 2011 06:31
Rake task to watch all scss files
namespace :scss do
task :watch do
files = `find . -iname *.scss`
destination = "public/stylesheets/"
pairs = []
files.each_line do |file|
file.strip!
pairs << "#{file}:#{destination}#{File.basename(file, ".scss")}.css"
end
command = "sass --watch #{pairs.join " "}"
@matthijsgroen
matthijsgroen / 0_README.md
Created July 5, 2011 06:27 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@matthijsgroen
matthijsgroen / prepare.rake
Created July 8, 2011 11:51
Rake file for executing guard to prepare your environment
desc "compiles all coffeescripts and scss stylesheets in the project"
task :prepare => 'prepare:all'.to_sym
namespace :prepare do
desc "compiles all coffeescripts in the project"
task :coffeescript do
run_guards "Guard::CoffeeScript"
end
@matthijsgroen
matthijsgroen / wrapper.rb
Created October 27, 2011 10:28
Wraps text. using Transformation Priority Premise
def find_positions_for_split(text, width)
if space = text[0..width].rindex(" ")
[space-1, space+1]
else
[width-1, width]
end
end
def wrap(text, width)
@matthijsgroen
matthijsgroen / jasmine.yml
Created November 29, 2011 10:35
Rails 3.1 Jasmine testing
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
@matthijsgroen
matthijsgroen / gist:1558986
Created January 4, 2012 07:38
Convert javascript to coffeescript (ideal for jasmine specs)
" convert javascript to coffeescript
command! ConvertJs :call ConvertJs()
function! ConvertJs()
:norm =G
:silent :%s/;$//e
:silent :%s/var //ge
:silent :g/^\s\+})$/d
:silent :%s/function() {/->/ge
@matthijsgroen
matthijsgroen / application.js.coffee
Created February 14, 2012 21:35
Backbone.contextmanager
window.App =
Models: {}
Collections: {}
Routers: {}
Views: {}
DebugInstances: {}
context_manager: null
init: ->
@context_manager = new App.Views.ContextManager
@matthijsgroen
matthijsgroen / fapi
Created February 29, 2012 14:52
Fapi
#!/usr/bin/ruby
require 'net/http'
require 'net/https'
require 'base64'
require 'uri'
require 'yaml'
require 'cgi'
class Net::HTTP
alias_method :old_initialize, :initialize