Skip to content

Instantly share code, notes, and snippets.

View jaikoo's full-sized avatar
🗻
Working

Jonathan Conway jaikoo

🗻
Working
View GitHub Profile
@jaikoo
jaikoo / gist:2576036
Created May 2, 2012 11:49 — forked from anarchivist/gist:1724852
Installing clamav gem on Mac OS X with Homebrew-installed clamav
$ env ARCHFLAGS='-arch x86_64' gem install clamav
Building native extensions. This could take a while...
ERROR: Error installing clamav:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for clamav.h... yes
checking for cl_engine_compile() in -lclamav... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
@jaikoo
jaikoo / underscoreR.coffee
Created May 7, 2012 08:40 — forked from jimtla/underscoreR.coffee
Add CoffeeScript friendly argument order to Underscore.js
# Five lines of code that will make your underscore + CoffeeScript use cleaner.
# Creates an underscore function for each function in to_reverse with R (short for Reversed) appended to the name.
# The R version moves the function argument (first argument in normal underscore) to the end,
# so you can write:
$(window).scroll _.throttleR 500, ->
console.log "This print's at most every 500ms"
# Instead of:
$(window).scroll _.throttle ->
console.log "This prints at most every 500ms too"
@jaikoo
jaikoo / Gemfile
Created May 28, 2012 22:12
Rails 3.2.3 with Postgresql DB pool using JNDI
source 'https://rubygems.org'
gem 'rails', '3.2.3'
platforms :jruby do
gem 'trinidad'
gem 'trinidad_postgresql_dbpool_extension'
gem 'jruby-openssl'
gem 'activerecord-jdbcpostgresql-adapter'
@jaikoo
jaikoo / miniskirt.rb
Created June 3, 2012 13:39 — forked from stephencelis/minifacture.rb
Factory girl, relaxed.
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
@jaikoo
jaikoo / gist:4754975
Last active December 12, 2015 09:49
Answer to a recent LRUG question about downloading of images in parallel. I noticed everyone seemed to shy away from threads, but with j.u.c you get a lot for free including battle hardened concurrency semantics.
#!/usr/bin/env jruby
java_import java.util.concurrent.Executors
require 'net/http'
class ThreadedDownloader
def initialize(poolsize = 50)
@executor = Executors.new_fixed_thread_pool(poolsize)
end
# Tested on Ubuntu 13.04 x64
# You need to set those environment variables
#```
# export DATABASE_USER=username_here
# export DATABASE_PASSWORD=password_here
# export DATABASE_NAME=database_name_here
# export DATABASE_ROOT_PASSWORD=database_root_password
# ```
# ON SERVER
@jaikoo
jaikoo / gist:6658963
Last active December 23, 2015 15:59
This is a rant. It's totally unscientific and emotional and should be taken as an old programmer blowing off steam.
  • Getting projects that rely on a particular version of X, Y or Z external software being installed to even boot up
  • Gems that rely on n number of other gems that are locked to a particular version - how many of us have had to fork an open source lib just to mess with the locked versions
  • Gems that rely on C extensions that are built against specific system installed libs
  • Running bundle update always seems to take way longer(1) on a non trivial project than in other ecosystems dependency management systems such as Clojure/Leningen or Node/npm etc

I'm not saying things are perfect in other languages. Heck, although I can just about use SBT I refuse use Scala because it seriously grates me in so many ways. And Go, which I love as a language has only recently started seeing some decent attempts with projects trying to deal with the difficult problem of dependency management.

I know some of my points above can be rectified by engineers just using a bit of common sense in their projects. I love writing apps

@jaikoo
jaikoo / gist:daf88024b8de1cf9339b
Created August 6, 2014 10:48
Force SSL for all request/feature tests in RSpec
config.before(:each) do
(request.env["rack.url_scheme"] = "https") if defined?(request) && request
end
Returns the internal DNS entries
--------------------------------
nodes=$(kubectl --kubeconfig=deploy/kubeconfig get nodes -o jsonpath='{range.items[*].metadata}{.name} {end}'); echo $nodes
Returns the public IP addresses
------------------------
nodes=$(kubectl --kubeconfig=deploy/kubeconfig get nodes -o jsonpath='{range .items[*].status.addresses[?(@.type=="ExternalIP")]}{.address} {end}'); echo $nodes
Mining parts
Motherboard either: https://www.amazon.co.uk/ASRock-H81-PRO-BTC-R2-0/dp/B01M5FQZYE/ref=sr_1_1?ie=UTF8&qid=1498643442&sr=8-1&keywords=btc+pro+motherboard
or
https://www.amazon.co.uk/Biostar-TB85-Intel-Socket-Motherboard/dp/B06VS94ZSF
CPU
https://www.amazon.co.uk/Intel-Celeron-G1840-Processor-LGA1150/dp/B00K5OJ0TS/ref=pd_lpo_vtph_107_lp_t_4?_encoding=UTF8&psc=1&refRID=QMZTF1YX8CMTS643V6PQ