Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / multiple-url-paths.lua
Created June 15, 2015 11:45
Benchmark multiple url paths with wrk
-- Resource: https://github.com/timotta/wrk-scripts/blob/master/multiplepaths.lua
-- Initialize the pseudo random number generator
-- Resource: http://lua-users.org/wiki/MathLibraryTutorial
math.randomseed(os.time())
math.random(); math.random(); math.random()
-- Shuffle array
-- Returns a randomly shuffled array
function shuffle(paths)
@romabelka
romabelka / gist:642dd8a68c58c008bbc6
Last active August 29, 2015 14:17
Private object attributes using ES6 WeakMap
var My = (function() {
var privates = new WeakMap;
return function(a) {
privates.set(this, a);
this.setter = function(a) {
privates.set(this, a)
};
this.getter = function() {
return privates.get(this)
};
@davegurnell
davegurnell / anorm.scala
Last active April 10, 2025 06:37
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@entaroadun
entaroadun / gist:1653794
Created January 21, 2012 20:10
Recommendation and Ratings Public Data Sets For Machine Learning

Movies Recommendation:

Music Recommendation:

@berngp
berngp / Measurable.scala
Created January 4, 2012 01:32
Trait with NewRelic and Scala Metrics.
import com.newrelic.api.agent.NewRelic
import collection.mutable.{HashMap, SynchronizedMap}
import com.yammer.metrics.{Timer, MetricsGroup}
trait Measurable {
protected lazy val metricsGroup = new MetricsGroup(this.getClass)
private val timers = new HashMap[String, Timer] with SynchronizedMap[String, Timer]
@nicerobot
nicerobot / jstatd.sh
Created November 18, 2011 00:01
Run jstatd w/o error 'access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)'
#!/bin/sh
policy=${HOME}/.jstatd.all.policy
[ -r ${policy} ] || cat >${policy} <<'POLICY'
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
POLICY
jstatd -J-Djava.security.policy=${policy} &
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@retronym
retronym / type-bounds.scala
Created December 16, 2009 11:17
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x