Skip to content

Instantly share code, notes, and snippets.

@techwhizbang
techwhizbang / selenium-grid.sh
Created October 28, 2011 17:34
Selenium Grid service script
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium-grid.pid
then
echo "Selenium Grid is already running."
else
java -jar /home/bkr/selenium/selenium-server-standalone-2.9.0.jar -port 5555 -role hub > /var/log/selenium/selenium-grid.log 2> /var/log/selenium/selenium-grid-error.log & echo $! > /tmp/selenium-grid.pid
echo "Starting Selenium Grid..."
@techwhizbang
techwhizbang / injectable.rb
Created July 21, 2011 06:38
Ruby inject method implementation
require 'rubygems'
require 'rspec'
module Enumerable
def inject(*args, &block)
if(args.size == 2)
inject_binary_operation(args[0], args[1], self)
elsif(args.size == 1 && !block_given?)
inject_binary_operation(self.first, args[0], self.drop(1))
else
@techwhizbang
techwhizbang / README.md
Created January 22, 2019 22:50 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@techwhizbang
techwhizbang / env_var_lein_project.clj
Created February 8, 2014 18:30
Difficulty reading environment variables in Leiningen project.clj
; consider this example
(let [_ (prn (System/getenv))]
(defproject your-clojure-app "1.0.0-SNAPSHOT"
:mirrors {#".+" {:url "https://internal.artifactory.repo.com/repo"
:username :env/artifactory_username
:password :env/artifactory_password}}))
; in the above example I confirm that the environment variables that I want
@techwhizbang
techwhizbang / gist:2008998
Created March 9, 2012 22:14
lobos alter :modify not working
(defmigration alter-ip-address-column-for-ipv6-20120125
(up []
(alter :modify
(table :notifications
(column :ip_address (data-type :varchar 45) :not-null))))
(down []
(alter :modify
(table :notifications
(column :ip_address (data-type :varchar 15))))))
@techwhizbang
techwhizbang / prepare.clj
Created January 18, 2012 21:33
Super long running Clojure shell commands
(ns my-app.db.prepare
(:use [clojure.java.shell :only [sh]]))
(defn -main []
"Will create the database if it does not exist yet for the specified environment"
(let [db-name "my_db"
db-user "root"
db-pass ""]
@techwhizbang
techwhizbang / selenium-grid.sh
Created October 28, 2011 17:34
Selenium Grid service script
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium-grid.pid
then
echo "Selenium Grid is already running."
else
java -jar /home/bkr/selenium/selenium-server-standalone-2.9.0.jar -port 5555 -role hub > /var/log/selenium/selenium-grid.log 2> /var/log/selenium/selenium-grid-error.log & echo $! > /tmp/selenium-grid.pid
echo "Starting Selenium Grid..."
override def calculate(cartItem: CartItem): DiscountResult = {
val saleDao = saleDao.findSale
if (shopKeeperSale != None) {
if (isThis(cartItem.getProductData) ||
isThat(cartItem.getProductData)) {
new DiscountResult(DiscountType.SOME_TYPE_A, percentageOff)
} else {
new DiscountResult(DiscountType.SOME_TYPE_B, percentageOff)
@techwhizbang
techwhizbang / rspec2_mongoid_activerecord_rails3.rb
Created October 19, 2010 22:34
RSpec 2 with ActiveRecord and Mongoid together (temporary hack)
#put this in your spec_helper.rb if you're using Rails 3, Rspec2, Mongoid, and #ActiveRecord together until the "real" fix comes along
class RSpec::Core::Configuration
attr_accessor :fixture_path, :use_transactional_fixtures
def fixture_path=(path)
@fixture_path = path
end
def use_transactional_fixtures=(bool)
@use_transactional_fixtures = bool
module API
module ServiceCall
protected
def service_call(&block)
begin
puts "in begin block"
raise "exception occurred here"
parse_response(yield) if block_given?