This file contains 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
#!/bin/bash | |
rm -rf api.rubyonrails.org/ | |
wget -r -k -p http://api.rubyonrails.org/ | |
rm rails_api.rar | |
rar a -r rails_api.rar api.rubyonrails.org/ |
This file contains 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
# yes, sometimes you need to do this. you get pilloried in a forum if you | |
# ask about it, though! | |
# this code taken from | |
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/ | |
class MyModel < ActiveRecord::Base | |
# Use the my_models/_my_model.txt.erb view to render this object as a string | |
def to_s | |
ActionView::Base.new(Rails.configuration.paths.app.views.first).render( |
This file contains 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
namespace :routes do | |
desc 'Print out all defined routes in match order, with names, per constraint class. Target specific constraint class with CONSTRAINT=x. Target specific controller with CONTROLLER=x.' | |
task constrained: :environment do | |
Rails.application.reload_routes! | |
constraints_routes = Hash.new | |
Rails.application.routes.routes.each do |route| | |
group = (route.app.class == ActionDispatch::Routing::Mapper::Constraints ? route.app.send( :constraints ).first.to_s : 'No constraint class') | |
constraints_routes[group] ||= [] |
This file contains 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
// IDEA FROM: https://stackoverflow.com/questions/33929712/crypto-in-nodejs-and-ruby | |
var crypto = require('crypto'), | |
algorithm = 'aes-256-cbc', | |
key = 'SOME_RANDOM_KEY_32_CHR_123456789', // 32 Characters | |
iv = "0000000000000000"; // 16 Characters | |
function encrypt(text){ | |
var cipher = crypto.createCipheriv(algorithm,key,iv) | |
var crypted = cipher.update(text,'utf-8',"base64") |