View tut.erl
run() ->
Pid = spawn(fun ping/0),
Pid ! self(),
receive
pong -> ok
end.
ping() ->
receive
From -> From ! pong
end.
View yaml generator
require 'rubygems'
require 'bcrypt'
require 'digest/md5'
require 'yaml'
#todo
# load schema.rb
# t.string "username", :limit => 30
# t.string "email"
View sample
---
990:
:updated_at: 2011-02-03 15:17:10.704334 +00:00
:email: archpresbytery@gmail.com
:karma: 5
:password_salt: $2a$10$31sLwM64th6X07yLN5nw/e
:sign_in_count: 2
:password_hash: $2a$10$31sLwM64th6X07yLN5nw/eK8rzfBn8ofFEbrve8dU9OiwKmmaxbd2
:sign_in_failed: 2
:reset_password_token: asd
View gist:814186
WITHOUT_PTHREADS= yes
.if defined(WITHOUT_PTHREADS)
CONFIGURE_ARGS+=--disable-pthread
PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+nopthreads
.else
LDFLAGS+= ${PTHREAD_LIBS}
CONFIGURE_ARGS+=--disable-pthread
.endif
View rails.rb
Nohup::Application.routes.draw do
namespace "admin" do
get "users/:id/edit" => "users#edit"
get "users/:id" => "users#show"
get "users" => "users#index"
put "users" => "users#index"
#resources :comments, :only => [:create, :destroy]
end
View nested_hashes.rb
#/usr/bin/env ruby
silicates = Hash.new {
|h, k| h[k] = Hash.new
}
silicates[:mineral0]["ruby"] = "String + red"
silicates[:mineral1]["ruby"] = "String + blue"
silicates[:mineral2][:ruby] = "Symbol + green"
silicates[:mineral3][:ruby] = "Symbol + black"
View inet.hrl
-type hostname() :: atom() | string().
-type ip4_address() :: {0..255,0..255,0..255,0..255}.
-type ip6_address() :: {0..65535,0..65535,0..65535,0..65535,
0..65535,0..65535,0..65535,0..65535}.
-type ip_address() :: ip4_address() | ip6_address().
-type ip_port() :: 0..65535.
-record(hostent,
{
h_name :: hostname(), %% offical name of host
View lists.erl
-spec map(fun((D) -> R), [D]) -> [R].
map(F, [H|T]) ->
[F(H)|map(F, T)];
map(F, []) when is_function(F, 1) -> [].
View mnesia:transaction.erl
{atomic, Result} = mnesia:transaction(Fun)
case Result of [] -> undefined [Rec] -> Rec#rec.prop end.
%% http://www.erlang.org/doc/man/mnesia.html#transaction-2
add_family({family, F, M, Children}) ->
ChildOids = lists:map(fun oid/1, Children),
Trans = fun() ->
mnesia:write(F#person{children = ChildOids},
mnesia:write(M#person{children = ChildOids},
Write = fun(Child) -> mnesia:write(Child) end,
View gist:866032
class X
def initialize
begin
@yaml_hash = YAML::load(File.read("xyz.yml"))
rescue => e
puts "An error generated during opening the xyz.yml"
puts e
end
end
end