This tutorial uses the "Sample hapi.js REST API" project.
Take a look at: https://github.com/agendor/sample-hapi-rest-api/
##Topics
- Introduction
- Installing Node.js
- Installing MySQL
- Setting-up the project
namespace :database do | |
task fat_tables: :environment do | |
c = ActiveRecord::Base.connection | |
max_table_name_width = 0 | |
tables = c.tables.sort_by do |t| | |
max_table_name_width = t.length if t.length > max_table_name_width |
# each_with_index, each_with_object and inject({}) are all %50 slower then #each | |
# simple each with an addition noop | |
[4] pry(main)> puts Benchmark.measure { (1..10_000_000).each { |i| i + 1 } } | |
0.450000 0.000000 0.450000 ( 0.448808) | |
# each_with_index | |
[5] pry(main)> puts Benchmark.measure { (1..10_000_000).each_with_index { |i, index| i + 1 } } | |
0.650000 0.000000 0.650000 ( 0.645812) |
#!/usr/bin/env ruby | |
require 'rocketamf' | |
require 'stringio' | |
# Monkey patch for RocketAMF (0.2.1 gem) that handles IExrternalizable types | |
# in the input, storing their type as "__as3_type" parameter: | |
module RocketAMF | |
module Values #:nodoc: | |
class TypedHash |
@echo Off | |
set config=%1 | |
if "%config%" == "" ( | |
set config=Release | |
) | |
set version=1.0.0 | |
if not "%PackageVersion%" == "" ( | |
set version=%PackageVersion% | |
) |
# Temporarily redirects STDOUT and STDERR to /dev/null | |
# but does print exceptions should there occur any. | |
# Call as: | |
# suppress_output { puts 'never printed' } | |
# | |
def suppress_output | |
original_stderr = $stderr.clone | |
original_stdout = $stdout.clone | |
$stderr.reopen(File.new('/dev/null', 'w')) | |
$stdout.reopen(File.new('/dev/null', 'w')) |
This tutorial uses the "Sample hapi.js REST API" project.
Take a look at: https://github.com/agendor/sample-hapi-rest-api/
##Topics
#Heroku, Ruby on Rails and PhantomJS
In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).
Let’s get started. This is a high-level overview of the required steps:
As part of this verification process, I am signing this object and posting as a gist as github user tacoplusplus
{
"body": {
"key": {
"fingerprint": "a3a9e2afba2c7edeea6d2552a603027ff4523ba5",
"host": "keybase.io",
require 'benchmark' | |
N = 1000000 | |
nums = N.times.map{ rand(N) } | |
enum = [1, 2, 'string', {}, [], false, true, nil] | |
def process(v) | |
v | |
end |
# http://37signals.com/svn/posts/3176-three-quick-rails-console-tips | |
>> helper.truncate("Testing", length: 4) | |
=> "T..." | |
>> helper.link_to "Home", app.root_path | |
=> "<a href=\"/\">Home</a>" |