Skip to content

Instantly share code, notes, and snippets.

class A
attr_accessor :foo
def initialize
@mutex = Mutex.new
end
def perform
t1 = Thread.new do
@foo ||= 10
.demo {
position: static;
display: block;
float: left;
clear: both;
box-sizing: border-box;
left: 0;
@Ptico
Ptico / bench.txt
Last active August 29, 2015 14:10
Before:
user system total real
camelize 1.090000 0.120000 1.210000 ( 1.209177)
underscore 1.280000 0.130000 1.410000 ( 1.421322)
dasherize 0.540000 0.070000 0.610000 ( 0.605857)
demodulize 0.370000 0.050000 0.420000 ( 0.420292)
foreign_key 1.020000 0.080000 1.100000 ( 1.103289)
ordinalize 3.570000 0.230000 3.800000 ( 3.809217)
pluralize 5.000000 0.110000 5.110000 ( 5.113936)
require 'benchmark'
require 'tsort'
def TSort.tsort_each_enum(each_node, each_child) # :yields: node
return to_enum(__method__, each_node, each_child) unless block_given?
TSort.each_strongly_connected_component(each_node, each_child) {|component|
if component.size == 1
yield component.first
else
@Ptico
Ptico / ramfs
Last active August 29, 2015 14:07 — forked from raggi/ramfs
#!/bin/bash
ramfs_size_mb=1024
mount_point=~/volatile
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'Volatile' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
echo "remove with:"
/Users/ptico/.gem/ruby/2.1.0/gems/adamantium-0.2.0/lib/adamantium/class_methods.rb:17: [BUG] Segmentation fault at 0x00000000000018
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
#!/usr/bin/env ruby
require 'yaml'
require 'uri'
require 'socket'
require 'timeout'
def knock(host, ports)
ports.each do |port|
puts "Knocking port #{port}"
describe Sequelize::Migrator::Naming do
subject { described_class.new(name) }
describe 'Table create/delete' do
context 'create' do
let(:name) { 'create_user_profiles' }
end
context 'drop' do
let(:name) { 'drop_user_profiles' }
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten

URI templates

URI template syntax

But we have RFC6570, why another one?

Current implementation have more questions than answers:

  1. It describes only template expansion, not matching. While URI matching is more common task (routing) - any template standard which doesn't describe matching will fail
  2. The RFC6570 modifiers sometimes is pointless and create more pain than gain for developers