This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refactoring of https://github.com/Sebmaster/racer-example/blob/master/app.js | |
var racer = require('racer'); | |
var express = require('express'); | |
var app = express(); | |
var http = require('http'); | |
var server = http.createServer(app); | |
var store = racer.createStore({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pdfkit' | |
require 'nokogiri' | |
require 'haml' | |
# config/initializers/pdfkit.rb | |
PDFKit.configure do |config| | |
# Note: Often required for Windows OS configuration | |
# config.wkhtmltopdf = '/path/to/wkhtmltopdf' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Originally written by http://redartisan.com/tags/csv | |
# Added and minor changes by Gavin Laking | |
# Rewritten by Andrew Bennett for Ruby 1.9 | |
# | |
# Usage: rake csv_to_fixture[file.csv] | |
# Usage (format): rake csv_to_fixture[file.csv,json] | |
# | |
# "id","name","mime_type","extensions","icon_url" | |
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gemfile | |
<pre> | |
gem 'resque_mailer', '2.0.0', :path => '/Users/kmandrup/private/repos/resque_mailer' # , :git => 'git://github.com/kristianmandrup/resque_mailer.git' | |
</pre> | |
My own debugging... (resque_mailer.rb) | |
<pre> | |
def method_missing(method_name, *args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload_modules [:a, :b, :c, ...,], 'base' | |
=> | |
autoload :A, 'base/a' | |
... | |
in sugar-high | |
isolate all file operations into SugarHigh::File, SugarHigh::FileMutate etc | |
then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GeoVector | |
module Math | |
# Add Vector v1 to a GeoPoint | |
# This module should be included in the GeoPoint class !!! | |
module PointAdd | |
def apply! vector | |
raise ArgumentError, "Argument must be a GeoVector" if !vector.kind_of?(GeoVector) | |
@lat = lat + vector.lat | |
@lng = lng + vector.lng |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inline Rails 3 templating solution : for ActionView RSpec testing etc. | |
require 'action_view' | |
require 'action_view/context' | |
class TestERBTemplate | |
ERBHandler = ActionView::Template::Handlers::ERB | |
attr_accessor :output_buffer, :rendered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functioning RSpec 2 spec for ActiveView helper | |
require 'spec_helper' | |
require 'action_view/template/handlers/erb' | |
module MyViewHelper | |
def tab_for(clazz, &block) | |
content = with_output_buffer(&block) | |
content_tag :li, content, :class => clazz | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minimal TDD for extending Rails components | |
require 'active_support/railtie' | |
module Minimal | |
class Application < Rails::Application | |
config.active_support.deprecation | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please me | |
*Note: The following is planned functionality only. I have not really started to implement it yet!* | |
This is a project that tries to please you in any way possible. This is done by executing a number of steps (kinda scripts) based on one or more configured profiles. | |
Each 'please-me request' can be customized to override the defaults as per defined in the profile(s). | |
## COMMANDS | |
- please [command] [name] [options...] |