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 "memprof" | |
Memprof.start | |
"Test Value" =~ /\s/i | |
puts "-----------------" | |
Memprof.stats | |
GC.start | |
Regexp.new(/\s/i).match("Test Value") | |
puts "-----------------" | |
Memprof.stats |
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
def lift[A, B](f: Function1[A, B]): Function1[Option[A], Option[B]] = { | |
(oa: Option[A]) => for(a <- oa) yield f(a) | |
} | |
def doSomething(s:String) = { s.toUpperCase } | |
val f = lift(doSomething) | |
f(None).getOrElse("if nothing was available") |
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
#include <ruby.h> | |
#include <vector> | |
#include <iostream> | |
typedef VALUE (ruby_method)(...); | |
extern "C" VALUE t_init(VALUE self) | |
{ | |
return self; | |
} |
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 "eventmachine" | |
require "mysql2/em" | |
EM.run do | |
opts = {} | |
opts[:username] = "username" | |
opts[:password] = "password" | |
opts[:database] = "local_dev_db" | |
client = Mysql2::EM::Client.new(opts) |
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 "eventmachine" | |
EM.run do | |
1.upto 100 do |i| #this could be database records | |
email = EM::Protocols::SmtpClient.send( | |
:auth => {:type => :plain, :username => "username@domain.com", :password => ""}, | |
:domain => "domain.com", | |
:host => "smtp.gmail.com", | |
:port => 587, | |
:starttls => true, |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <zmq.h> | |
int main(void) | |
{ | |
int rc; | |
void *ctx, *s; | |
zmq_msg_t message; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <zmq.h> | |
int main(void) | |
{ | |
int rc; | |
void *ctx, *s; | |
char message[32]; |
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
# Because Unicorn is such a brilliant piece of software, it wraps older, | |
# non-Rack versions of Rails in a Rack handler. That way Unicorn | |
# itself can target Rack and not have to worry about monkey patching | |
# Rails' dispatcher. | |
# | |
# This means we can do the same, and even more. | |
# | |
# Starting Rackhub locally: | |
# | |
# Thin: |
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 | |
# Usage: gemspec [-s] GEMNAME | |
# | |
# Prints a basic gemspec for GEMNAME based on your git-config info. | |
# If -s is passed, saves it as a GEMNAME.gemspec in the current | |
# directory. Otherwise prints to standard output. | |
# | |
# Once you check this gemspec into your project, releasing a new gem | |
# is dead simple: | |
# |
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 Packaging Standard | |
The aim of this document is two-fold. First, to specify a common | |
structure of how a Ruby package distributed as source (that is, but | |
not limited to, development directories, version-controlled | |
repositories, .tar.gz, Gems, ...) should conform to. | |
Second, to document common and proven ways to structure Ruby packages, | |
and to point out certain anti-patterns that sneaked into common use. | |
It is by intent not to innovate. |