Skip to content

Instantly share code, notes, and snippets.

@JamesChevalier
JamesChevalier / poly_to_osm.rb
Created February 8, 2014 00:35
This is my script to generate OSMs out of all of a country's POLY files.
#!/usr/bin/env ruby
Dir.glob('poly/*.poly').each_slice(50) do |group|
bp_wx = ''
group.each do |poly_file|
file = File.basename(poly_file, '.poly')
city, region = file.split('_')
bp_wx << "--buffer bufferCapacity=50000"\
" --bp file='poly/#{city}_#{region}.poly'"\
@EdwardDiehl
EdwardDiehl / Bracket Terminology.md
Created May 28, 2018 13:16 — forked from Integralist/Bracket Terminology.md
[Bracket Terminology] #bracket #terminology
parentheses:     ( ) 
braces:          { } 
brackets:        < > 
square-brackets: [ ]
@danielpclark
danielpclark / rps-blackbytes.rb
Created April 24, 2017 18:45
Rock Paper Scissors Black Bytes blog version
module BlackBytesExample
class Game
def self.play(move1, move2)
return :tie if move1.class == move2.class
move2.wins_against?(move1)
end
end
class Rock
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pg'
gem 'activerecord', '5.2.0'
gem 'memory_profiler'
gem 'benchmark-ips'
end
@joejag
joejag / peach.rb
Created August 14, 2014 13:06
Parallel each method for ruby
class Array
def peach(&block)
threads = []
self.each do |item|
threads << Thread.new do
block.call(item)
end
end
threads.each {|t| t.join }
end
@mockdeep
mockdeep / bulk_updateable.rb
Created October 29, 2015 17:13
module to add ActiveRecord bulk update functionality for postgres
module BulkUpdatable
def bulk_update(objects, attribute)
return unless objects.any?
query = build_query_for(objects, attribute)
connection.execute(query)
end
private
@hartator
hartator / benchmark-deep-vs-flat-directories.rb
Last active December 28, 2018 10:28
Source code for Benchmark: Deep directory structure vs. flat directory structure to store millions of files on ext4 article (https://medium.com/@hartator/benchmark-deep-directory-structure-vs-flat-directory-structure-to-store-millions-of-files-on-ext4-cac1000ca28)
require 'digest'
require 'benchmark'
hash = {}
10_000_000.times do
key = Digest::MD5.hexdigest(rand.to_s)
value = Digest::MD5.hexdigest(rand.to_s)
hash[key] = value
end
@danielchappell
danielchappell / computed_properties.md
Last active October 21, 2019 11:51
Computed Properties Best Practices

Computed Property Theory & Best Practices or Functional Programming in Ember or How I learned to stop worrying and love the Tomster.

In a nutshell, computed properties let you declare functions as properties. You create one by defining a computed property as a function, which Ember will automatically call when you ask for the property. You can then use it the same way you would any normal, static property. -- The Ember Guides

The Ember Object Model is the corner stone of Ember, and at the heart of the Object Model are computed properties.

The guides do a fine job giving need to know information on how to create and use computed properties and what to expect from the cacheing system they provide. However, I feel so much of the beauty that computed properties provide is lost in terse (but wonderful) documentation.

Quick..the basics!

@wbotelhos
wbotelhos / phantomjs_intaller.sh
Last active December 12, 2019 12:08
Installing PhantomJS 1.9 on Ubuntu 12/14.xx x64/x86
#!/bin/bash
sudo apt-get remove phantomjs
sudo unlink /usr/local/bin/phantomjs
sudo unlink /usr/local/share/phantomjs
sudo unlink /usr/bin/phantomjs
cd /usr/local/share
@twolfson
twolfson / README.md
Last active December 28, 2019 22:38
Node.js ORM evaluation

We are planning on building a Node.js service. Here's our evaluation of the current ORM landscape:

Last updated: May 2 2016