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
Should be added to /etc/network/if-pre-up.d/iptable_rules | |
Don't forget to run | |
chmod +x /etc/network/if-pre-up.d/iptable_rules |
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/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
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
#!/usr/bin/env ruby | |
Dir["*"].each do |f| | |
if File.directory?(f) and File.directory?(File.join(f, ".git")) | |
command = "cd #{f}; git #{ARGV.collect{|a| a.include?(" ") ? "\"#{a}\"" : a }.join(" ")}" | |
puts "Command: #{command}" | |
result = `#{command}` | |
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
named_scope :victims_for, Proc.new{|attacker| | |
{ | |
:conditions => [ | |
%{ | |
(level BETWEEN :low_level AND :high_level) AND | |
characters.id NOT IN ( | |
SELECT fights.victim_id FROM fights WHERE attacker_id = :attacker_id AND winner_id = :attacker_id AND fights.created_at > :time_limit | |
) AND | |
characters.id != :attacker_id | |
}, |
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
VTM = { | |
:dice => 10, | |
:critical_failure => 1, | |
:critical_success => 10, | |
:success => 5 | |
} | |
def calculate_dices(attacker, victim) | |
attack_points = attacker.attack_points | |
defence_points = victim.defence_points |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
require 'optparse' | |
require 'ostruct' | |
# Daemons sets pwd to /, so we have to explicitly set RAILS_ROOT | |
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) |
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
class Character < ActiveRecord::Base | |
extend SerializeWithPreload | |
LEVELS = [0] | |
200.times do |i| | |
LEVELS[i + 1] = LEVELS[i].to_i + (i + 1) * 10 | |
end | |
UPGRADES = { |
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
config.action_controller.asset_host = Proc.new do |source, request| | |
if source =~ %r{^/(pictures|brands|users)}i | |
"http://img.24video-test.net" | |
else | |
"" | |
end | |
end |
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
require "yaml" | |
require "benchmark" | |
class SomeClass | |
def initialize(value) | |
@value = value | |
end | |
end | |
hash = { |
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
ruby serialize_bench.rb | |
user system total real | |
Marshal dump 0.350000 0.010000 0.360000 ( 0.355897) | |
Marshal load 0.310000 0.000000 0.310000 ( 0.312442) | |
YAML dump 15.900000 0.030000 15.930000 ( 16.127431) | |
YAML load 3.810000 0.010000 3.820000 ( 3.878175) |
OlderNewer