Skip to content

Instantly share code, notes, and snippets.

running this url:
$ curl http://localhost:3000/projects/2
<html><body>You are being <a href="http://localhost:3000/users/sign_in">redirected</a>.</body></html>
# with puma
# $ siege -c 20 -r 100 -b http://localhost:3000/projects/2
** SIEGE 2.72
** Preparing 20 concurrent users for battle.
@framallo
framallo / unicorn.rb
Created October 9, 2012 19:47
init upstart script for ubuntu 12.04 and Rails 3 app
app_dir = "/home/public_forums/unstable/"
worker_processes 5
pid "#{app_dir}/tmp/pids/unicorn.pid"
# listen "#{app_dir}/tmp/sockets/public_forum.socket"
listen 5000, :tcp_nopush => true
stderr_path "#{app_dir}/log/unicorn.stderr.log"
stdout_path "#{app_dir}/log/unicorn.stdout.log"
@framallo
framallo / makefile
Last active June 8, 2023 07:49
This is a makefile to deploy a rails application using puma, runit and apache
# This is the deployment recipe
# You require to install runit on the server.
# First you need to declare on which port the application will run
#
# echo 3000 > port
#
# Then you can setup a new runit service with
#
# make setup_service
#
@framallo
framallo / makefile
Created August 21, 2013 15:51
node js deployment
# This is the deployment recipe
# You require to install runit on the server.
# Then you can setup a new runit service with
#
# make setup_service
#
# Also you need to install the git hooks, so you can push and update this repo
#
# make setup_git_hook
#
@framallo
framallo / scoring_help.rb
Created June 6, 2014 19:19
scoring_peredictions
Write a method that accepts two arguments: an Array of five guesses for
finalists in a race and an Array of the five actual finalists. Each
position in the lists matches a finishing position in the race, so first
place corresponds to index 0. Return an Integer score of the predictions:
0 or more points. Correctly guessing first place is worth 15 points,
second is worth 10, and so on down with 5, 3, and 1 point for fifth
place. It's also worth 1 point to correctly guess a racer that finishes
in the top five but to have that racer in the wrong position.
class Image
attr_accessor :array
def initialize(array)
@array = array
@new_array = @array.map {|e| Array.new(e.size) }
end
def blur
@array.each_with_index do |row,x|
@framallo
framallo / linked_list_mutation.rb
Created September 4, 2015 16:37 — forked from vincentchin/linked_list_mutation.rb
Reverse a linked list using mutation
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
end
def print_values(list_node)
@framallo
framallo / dfs.rb
Created September 17, 2015 19:16 — forked from vincentchin/dfs.rb
# In the above example it will check to see if the payload is 11 in the following order: 2, 7, 6, 5 when
# it gets to 5 and 5 has no children, it will return to the 6 and go to any children 6 has. 6 has a
# remaining child, which is 11 so that node is checked and since that value is the correct value it
# will be returned and searching will stop.
class Tree
attr_accessor :payload, :children
def initialize(payload, children)
@payload = payload
@framallo
framallo / card.rb
Last active October 14, 2015 23:37 — forked from arightious/card.rb
Firehose Card Challenge
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
self.rank = rank
self.suit = suit
end
def output_card
puts "#{self.rank} of #{self.suit}"
@framallo
framallo / deck.rb
Last active October 19, 2015 18:13
class Deck
attr_accessor :size
def size
cards.size
end
def cards
cards = []
52.times { cards << 1 }