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 'async' | |
require 'async/http/endpoint' | |
require 'async/websocket/adapters/rack' | |
require 'falcon' | |
websocket_endpoint = Async::HTTP::Endpoint.parse('http://127.0.0.1:3000') | |
module WebSocketApp | |
def self.call(env) |
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 'benchmark' | |
Benchmark.bm do |bm| | |
repeat = 10000000 | |
bm.report('send') { repeat.times { 5.send(:>, 2) } } | |
bm.report('method.call') { repeat.times { 5.method(:>).call(2) } } | |
end | |
# user system total real |
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
extern crate mio; | |
use std::error::Error; | |
use mio::*; | |
use mio::tcp::{TcpListener, TcpStream}; | |
// Setup some tokens to allow us to identify which event is | |
// for which socket. | |
const SERVER: Token = Token(0); |
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 String | |
def substrings | |
((0...length).to_a.combination(2).map do |from,to| | |
# Extract substrings | |
self[from, to] | |
end + self.chars).map do |s| | |
# Trim off any unwanted characters | |
s.sub(/\A\W+/, '').sub(/\W+\z/, '') | |
end.sort.uniq.reject do |s| | |
# Remove empty strings |
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 'nokogiri' | |
doc = Nokogiri::HTML(DATA) | |
doc.css('head').remove | |
puts doc.to_s | |
__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
module.exports = { | |
stringifyPart: function(part) { | |
switch(typeof part) { | |
case 'boolean': | |
case 'number': | |
return String(part) | |
case 'string': | |
return '"' + part.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' | |
case 'undefined': | |
return 'NULL' |
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 'benchmark' | |
LETTERS = ('a'..'z').to_a.freeze | |
def random_customer_name | |
name = [ ] | |
(rand(10) + 1).times do |
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
diff --git a/Manifest.txt b/Manifest.txt | |
index 6e79ebd..6a2f480 100644 | |
--- a/Manifest.txt | |
+++ b/Manifest.txt | |
@@ -121,6 +121,7 @@ test/rubygems/rubygems_plugin.rb | |
test/rubygems/sff/discover.rb | |
test/rubygems/simple_gem.rb | |
test/rubygems/test_config.rb | |
+test/rubygems/test_deprecate.rb | |
test/rubygems/test_gem.rb |
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
module ActiveRecord | |
class Base | |
def self.sqlserver_connection(config) #:nodoc: | |
config = config.dup.symbolize_keys! | |
config.reverse_merge! :mode => :dblib, :host => 'localhost', :username => 'sa', :password => '' | |
mode = config[:mode].to_s.downcase.underscore.to_sym | |
case mode | |
when :dblib | |
# <monkeypatch> | |
# raise ArgumentError, 'Missing :dataserver configuration.' unless config.has_key?(:dataserver) |
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 | |
MYSQL_USER=root | |
MYSQL_PASSWORD=<PASSWORD> | |
MYSQL_OPTS= | |
RETAIN_PERIOD=5 | |
DUMP_DIRECTORY="$HOME/dumps" |
NewerOlder