Skip to content

Instantly share code, notes, and snippets.

View rares's full-sized avatar
🌑

(╯°□°)╯︵ ┻━┻ rares

🌑
View GitHub Profile
require "memprof"
Memprof.start
"Test Value" =~ /\s/i
puts "-----------------"
Memprof.stats
GC.start
Regexp.new(/\s/i).match("Test Value")
puts "-----------------"
Memprof.stats
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")
#include <ruby.h>
#include <vector>
#include <iostream>
typedef VALUE (ruby_method)(...);
extern "C" VALUE t_init(VALUE self)
{
return self;
}
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)
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,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zmq.h>
int main(void)
{
int rc;
void *ctx, *s;
zmq_msg_t message;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zmq.h>
int main(void)
{
int rc;
void *ctx, *s;
char message[32];
# 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:
@rares
rares / gemspec
Created May 13, 2010 16:51 — forked from defunkt/gemspec
#!/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:
#
= 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.