Skip to content

Instantly share code, notes, and snippets.

@jg
jg / freemonads.scala
Created October 21, 2015 07:04 — forked from kciesielski/freemonads.scala
Free Monads example
package com.softwaremill.freemonads
import cats.free.Free
import cats.~>
import cats._, cats.std.all._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
sealed trait External[A]
case class Tickets(count: Int) extends AnyVal
@jg
jg / MessageStore_FluxBone.js
Last active August 29, 2015 14:27 — forked from rattrayalex/MessageStore_FluxBone.js
Flux and Backbone
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
var ChatConstants = require('../constants/ChatConstants');
var ChatMessageUtils = require('../utils/ChatMessageUtils');
var EventEmitter = require('events').EventEmitter;
var ThreadStore = require('../stores/ThreadStore');
var merge = require('react/lib/merge');
var ActionTypes = ChatConstants.ActionTypes;
var CHANGE_EVENT = 'change';

#Container Resource Allocation Options in docker-run You have various options for controlling resources (cpu, memory, disk) in docker. These are principally via the docker-run command options.

##Dynamic CPU Allocation -c, --cpu-shares=0
CPU shares (relative weight, specify some numeric value which is used to allocate relative cpu share)

##Reserved CPU Allocation

# Clone rbenv into ~/.rbenv
git clone [email protected]:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
@jg
jg / build.sbt
Created March 10, 2013 08:01 — forked from Swind/build.sbt
// Set the project name to the string 'My Project'
name := "SBTProject"
// The := method used in Name and Version is one of two fundamental methods.
// The other method is <<=
// All other initialization methods are implemented in terms of these.
version := "1.0"
//Add Repository Path
resolvers += "db4o-repo" at "http://source.db4o.com/maven"
@jg
jg / gist:4207915
Created December 4, 2012 19:43 — forked from dwins/gist:4207894
def fetch[R : Fetchable](s: SQLCursor): R = implicitly[Fetchable[R]].fetch(s)
trait Fetchable[R] {
def fetch(s: SQLCursor): R
}
implicit object IntIsFetchable extends Fetchable[Int] {
def fetch(s: SQLCursor): Int = s.getInt
}
@jg
jg / .ctags
Created November 18, 2012 10:41 — forked from anonymous/.ctags
Scala ctags conf, Vim tagbar integration
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/\1/o,objects/
--regex-Scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/r,cclasses/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,aclasses/
--regex-Scala=/^[ \t]*def[ \t]*([a-zA-Z0-9_=]+)[ \t]*.*[:=]/\1/m,methods/
--regex-Scala=/[ \t]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/
--regex-Scala=/[ \t]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/
@jg
jg / gist:1234449
Created September 22, 2011 09:59 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111