This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.
Please make sure that your Gemfile in your rails application includes unicorn.
# create the template | |
template = PageOfflineTemplate.new | |
template.quote = quote | |
template.pages = quote.build_pages | |
# Here I render a template with layout to a string then a PDF | |
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml") | |
# /home/elvuel/.rvm/gems/ruby-2.0.0-p0@rails/gems/cequel-0.5.6/lib/cequel/keyspace.rb | |
def configure(configuration = {}) | |
@configuration = configuration | |
@hosts = configuration[:host] || configuration[:hosts] | |
@thrift_options = configuration[:thrift].try(:symbolize_keys) || {} | |
@keyspace = configuration[:keyspace] | |
@username = configuration[:username] # ++ | |
@password = configuration[:password] # ++ | |
# reset the connections |
~/projects/jruby ➔ cat my_java_thing.rb | |
require 'java' | |
java_package 'foo.bar' | |
class SomeJavaThing | |
java_signature 'void main(String[] args)' | |
def self.main(args) | |
puts args.to_a | |
end |
#! /bin/ruby1.8.7 -Ku | |
require 'socket' | |
require 'open-uri' | |
require 'time' | |
require 'json' | |
require 'base64' | |
def cut str, len=100 | |
a = str.scan /./u |
# | |
# A basic, synthetic benchmark of the impact HTTP client has | |
# on the speed of talking to ElasticSearch in the Tire gem. | |
# | |
# In general, Curb seems to be more then two times faster the RestClient, in some cases it's three | |
# to five times faster. I wonder if keep-alive has anything to do with it, but it probably does. | |
# | |
# Run me with: | |
# $ git clone git://github.com/karmi/tire.git | |
# $ cd tire |
# encoding: utf-8 | |
# code from: http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 | |
# and also: https://gist.github.com/1976864 | |
# Serialized columns in AR don't support UTF-8 well, so set the encoding on those | |
class ActiveRecord::Base | |
def unserialize_attribute_with_utf8(attr_name) | |
traverse = lambda do |object, block| | |
if object.kind_of?(Hash) |
# Example of .jrubyrc | |
# Set compilation mode. JIT = at runtime; FORCE = before execution. (JIT, FORCE, OFF, OFFIR) | |
# compile.mode = FORCE | |
# Dump to console all bytecode generated at runtime. | |
# compile.dump = true | |
# Enable verbose JIT logging (reports failed compilation) | |
# jit.logging.verbose = true |
# encoding: utf-8 | |
# investigation | |
require 'massive_record' | |
require 'active_model' | |
require 'json' | |
require 'tire' | |
require 'rest_client' | |
MassiveRecord::ORM::Base.connection_configuration = { | |
:host => 'localhost', |
hadoop fs -mkdir /invest | |
echo 'hello world' >> /tmp/invest1.txt | |
echo 'hello hadoop' >> /tmp/invest2.txt | |
hadoop fs -copyFromLocal /tmp/invest2.txt /invest | |
hadoop fs -ls /invest | |
cd /usr/local/hadoop//share/hadoop/mapreduce | |
hadoop jar hadoop-mapreduce-examples-2.0.3-alpha.jar wordcount /invest /invest-output | |
... |