This file contains hidden or 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
knob_radius = 24; | |
knob(); | |
module knob() { | |
union() { | |
difference() { | |
sphere(r=knob_radius); | |
translate([0, 0, 0-(knob_radius)]) { | |
cylinder(r1=knob_radius, r2=knob_radius, h=knob_radius); |
This file contains hidden or 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
... | |
var makeScriptBundler = function(options) { | |
var cache = {}; | |
// load the cache from disk | |
if (fs.existsSync(options.cache)) { cache = require(options.cache); } | |
var mainScriptPackageCache = {}; | |
var bundler = browserify({ | |
entries: options.entries, | |
extensions: ['.coffee'], |
This file contains hidden or 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
var knox = require("knox"); | |
var mpu = require("knox-mpu"); | |
var s3lister = require("s3-lister"); | |
var async = require("async"); | |
var fs = require("fs"); | |
var archiver = require("archiver"); | |
var client = knox.createClient({ | |
key: process.env.S3_ACCESS_KEY_ID, | |
secret: process.env.S3_SECRET_KEY, |
This file contains hidden or 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
events.js:72 | |
throw er; // Unhandled 'error' event | |
^ | |
Error: write after end | |
at writeAfterEnd (_stream_writable.js:133:12) | |
at WriteStream.Writable.write (_stream_writable.js:181:5) | |
at Pack.<anonymous> (/Users/jordan/Code/nuts.com/image-archiver/node_modules/knox-mpu/lib/multipartupload.js:246:28) | |
at Pack.EventEmitter.emit (events.js:95:17) | |
at EntryWriter.<anonymous> (/Users/jordan/Code/nuts.com/image-archiver/node_modules/tar/lib/pack.js:191:8) | |
at EntryWriter.EventEmitter.emit (events.js:95:17) |
This file contains hidden or 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
# I first implemented a solution in a naive style to feel out an algorithm. | |
# While sketching the first solution I realized that a version with much less | |
# complexity is easily written. The second version avoids exponential run-times | |
# by doing simple arithmetic on each iteration to avoid the call to | |
# Enumerable#reduce. I left both versions here so that you might get a feel for | |
# my thought process. | |
def pivot_index_v1 integers | |
pivot = -1 | |
return pivot if integers.empty? |
This file contains hidden or 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
# Here is a sketch of some ActiveRecord models which could be used to support the features | |
# requested. I didn't code the implementation of the state machine as that isn't crucial | |
# to the question, but I think it would suit the system well and help in designing further | |
# features. | |
# | |
# The instance methods on the Seller model allow for flexibility of the rolling settlement | |
# window dates. | |
# | |
# As for indexing the tables, the most important one for the models below is: | |
# [:created_at, :seller_id] on the Transactions table. This makes the rolling settlement window |
This file contains hidden or 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 'open-uri' | |
require 'nokogiri' | |
base_uri = "http://www.thefremontproject.com" | |
path = "/rabbithole" | |
loop do | |
html = open(base_uri + path).read | |
link = Nokogiri::HTML(html).at_css("#next-link") | |
open("rabbithole.html", "wb") { |file| file.write(html) } |
This file contains hidden or 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 'net/http' | |
require 'json' | |
require 'uri' | |
uri = URI.parse "http://www.letsrevolutionizetesting.com/challenge.json" | |
loop do | |
response = JSON.parse(Net::HTTP.get_response(uri).body) | |
puts response | |
break unless response["follow"] |
This file contains hidden or 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
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
html = %(<div class="error">#{html_tag}) | |
html += %(<small>#{instance.error_message.to_a.to_sentence}</small>).html_safe unless html_tag =~ /^<label/ | |
html += %(</div>) | |
html.html_safe | |
end |
This file contains hidden or 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
@threads = [] | |
@num_of_threads = 8 | |
@queue = Queue.new | |
# fill queue with items ... | |
@num_of_threads.times do | |
@threads << Thread.new { | |
loop do | |
break if @queue.length == 0 | |
do_something @queue.deq |