Skip to content

Instantly share code, notes, and snippets.

View redbar0n's full-sized avatar

redbar0n

View GitHub Profile
;variants of the code from point #2 of:
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses
;original
(apply merge-with +
(pmap count-lines
(partition-all *batch-size*
(line-seq (reader filename)))))
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@mike-burns
mike-burns / io.rb
Created November 29, 2011 01:55
The IO data type, functor, and monad ... in Ruby
class InputOutput
def initialize(&action)
@action = action
end
private_class_method :new
# return :: (Monad m) => a -> m a
def self.unit(x)
new { x }
end
@sidane
sidane / capybara_selenium_resize_window.rb
Last active June 3, 2022 13:27
Resize browser window with Capybara Selenium
# Resize selenium browser window to avoid Selenium::WebDriver::Error::MoveTargetOutOfBoundsError errors
#
# Example usage with Rspec (in spec/support/spec_helper.rb):
#
# config.before(:each) do
# set_selenium_window_size(1250, 800) if Capybara.current_driver == :selenium
# end
#
def set_selenium_window_size(width, height)
window = Capybara.current_session.current_window.resize_to
@shakefu
shakefu / example.sh
Last active August 30, 2022 01:22
Bash Script with Short and Long Options
# Option defaults
OPT="value"
# getopts string
# This string needs to be updated with the single character options (e.g. -f)
opts="fvo:"
# Gets the command name without path
cmd(){ echo `basename $0`; }
@dsamarin
dsamarin / UndoStack.js
Created July 5, 2012 00:37
Easy undo-redo in JavaScript.
function UndoItem (perform, data) {
this.perform = perform;
this.data = data;
}
/**
* UndoStack:
* Easy undo-redo in JavaScript.
**/
@Tassandar
Tassandar / ruby
Created September 29, 2012 10:30
How to parse CSV data with Ruby
#Ruby alternatives for parsing CSV files
# Ruby String#split (slow)
# Ruby CSV (slow)
# FasterCSV (ok, recommended)
# ccsv (fast & recommended if you have control over CSV format)
# CSVScan (fast & recommended if you have control over CSV format)
# Excelsior (fast & recommended if you have control over CSV format)
#CSV library benchmarks can be found here and here
@nicholasjhenry
nicholasjhenry / gist:4070557
Created November 14, 2012 05:56
Deconstructing the Framework (Gary Bernhardt)

Design in the Small

  • Don't design a Model to be coupled to an API
  • Create a Service that talks to both your Model and the API

Service Wrapper Record

  • You have services, stateless objects that talk to the application
  • You have records, objects that talk to the database
  • And you have Wrappers, a thin class for a narrow interface to an API
@vishaltelangre
vishaltelangre / savon.rb
Last active September 16, 2019 14:41
Logging Savon SOAP requests/responses in Rails
# initializers/savon.rb
# Savon Global configuration
Savon.configure do |config|
config.log = true
config.log_level = :debug
config.logger = Rails.logger
config.env_namespace = :soapenv
end
@thelibrarian
thelibrarian / Fixing XCode Command Line Tools.md
Last active November 6, 2017 03:28
How to fix compile errors with the XCode command line tools on Mac OS X. Solves problems such as failing to find Framework header files (e.g. ruby.h).

The Problem

If you have installed the standalone Command Line Tools for XCode on your Mac (i.e. without having XCode.app installed), some of these tools can get a bit confused due to a couple of oversights on Apple's part in finalising the setup.

Note: all commands below will need to be run from an Administrator account, or by an account with appropriate permission in /etc/sudoers.

The Solution

1. Failing to Find Frameworks

Sometime when compiling against the preinstalled Frameworks (e.g. Ruby or Python), various tools will inexplicable fail to find header files that are quite clearly there. This is caused by the fact that no XCode has been selected for the command-line tools. Wait, I hear you cry, I don't have XCode installed! Indeed, but you nonetheless need to select one, and point it somewhere where the command line tools exist, like so