This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted.
All the relevant code is in https://github.com/ruby/ruby/blob/trunk/gc.c
default: 10000
The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps).
(todo: figure out how big a slot is. i think the answer can be infered from this code.)
* Only the releases of the stable versions are enumerated in principle. The releases of the unstable versions especially considered to be important are indicated as "not stable." | |
* The branches used as the source of each releases are specified, and the branching timing of them are also shown. BTW, before subversionizing of the repository, the term called "trunk" was not used, but this list uses it in order to avoid confusion. | |
* In order to show a historical backdrop, big conferences (RubyKaigi, RubyConf and Euruko) are also emurated. About the venues of such conferences, general English notations are adopted, in my hope. | |
* ruby_1_8_7 branch was recut from v1_8_7 tag after the 1.8.7 release becaouse of an accident. | |
* 1.2.1 release was canceled once, and the 2nd release called "repack" was performed. Although there were other examples similar to this, since the re-releases were performed during the same day, it does not write clearly in particular. | |
* Since 1.0 was released with the date in large quantities, |
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
require 'mongoid' | |
require 'minitest/autorun' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('basket_test') | |
end | |
class Basket | |
include Mongoid::Document |
source "https://rubygems.org" | |
gem 'eventmachine' | |
gem 'rubysl-stringio' | |
gem 'sinatra' | |
gem 'yajl-ruby', require: 'yajl' | |
gem 'thin' | |
gem 'em-websocket', :git=>'https://github.com/igrigorik/em-websocket.git' |
Encrypting text fields in Mongoose is easy using Node's built-in crypto module. You might want to do this if you're using MongoDB as a service (see the recent MongoHQ security breach); or, if you're storing OAuth tokens that could, in the wrong hands, screw with somebody's account on a 3rd party service. (Of course, you should never encrypt passwords: those should be hashed.)
Imagine you have a Mongoose model like that shown below, which is modified only slighly from the example on the MongooseJS homepage.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var User = mongoose.model('User', {
name: String,
function computeDistance(startCoords, destCoords) { | |
var startLatRads = degreesToRadians(startCoords.latitude); | |
var startLongRads = degreesToRadians(startCoords.longitude); | |
var destLatRads = degreesToRadians(destCoords.latitude); | |
var destLongRads = degreesToRadians(destCoords.longitude); | |
var Radius = 6371; // radius of the Earth in km | |
var distance = | |
Math.acos(Math.sin(startLatRads) * Math.sin(destLatRads) + |
require 'active_record' | |
require 'sqlite3' | |
require 'logger' | |
ActiveRecord::Base.logger = Logger.new('debug.log') | |
ActiveRecord::Base.configurations = YAML::load(IO.read('database.yml')) | |
ActiveRecord::Base.establish_connection('development') | |
class Schema < ActiveRecord::Migration | |
def change |
# changes from http://www.cyberciti.biz/faq/linux-kernel-etcsysctl-conf-security-hardening/ | |
# Protect ICMP attacks | |
net.ipv4.icmp_echo_ignore_broadcasts = 1 | |
# Turn on protection for bad icmp error messages | |
net.ipv4.icmp_ignore_bogus_error_responses = 1 | |
# Turn on syncookies for SYN flood attack protection | |
net.ipv4.tcp_syncookies = 1 |