Skip to content

Instantly share code, notes, and snippets.

View ralph-tice's full-sized avatar

Ralph Tice ralph-tice

  • Kentik
  • Texas
View GitHub Profile
@coderanger
coderanger / README.md
Last active August 29, 2015 13:56
Command to run depsolver

To use this snippet first replace the _default in the URL with your environment name if you are using somethign other than the global default. Next in the run list, replace ... with your cookbook names. Unlike other run lists, you cannot have roles here, and you don't use the 'recipe[foo]' syntax, just 'foo'.

@Jacoby6000
Jacoby6000 / gist:3b24d8397491c0f92cb4
Last active August 29, 2015 14:16
Scala extension methods
object Implicits {
implicit class PimpedString(str: String) {
def everyNthChar(skipNum: Int) = (for (i <- 0 until str.length if i%skipNum==0) yield str(i)).mkString
//Other methods I want strings to have go here
}
implicit class PimpedInt(int: Int){
//Other methods I want ints to have do here
}
}
@stonegao
stonegao / AkkaKafkaMailboxTest.scala
Created May 1, 2012 07:24 — forked from mardambey/AkkaKafkaMailboxTest.scala
Akka 2.0 actors with Kafka backed durable mailboxes.
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.agent.Agent
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.actor.Props
import kafka.utils.Utils
import java.nio.ByteBuffer
@Irio
Irio / fake_parser.rb
Created July 8, 2012 01:23
Skip parse on HTTParty
class FakeParser
def self.call(body, format)
body
end
end
@willf
willf / inverted_index.scala
Created December 23, 2011 16:54
Create an inverted index from a file
/**
* From a file that contains
* doc_id w1 w2 w3 ... lines, separated by tabs
* return an inverted index Map of w -> Set(doc_id)
*
* @param filename well isn't it obvious
* @return Map[String,Set[String]]
*/
import scala.collection.immutable.Map
@philwinkle
philwinkle / compare-core-mods.sh
Last active December 12, 2015 05:49
MD5 Comparison snapshot of current Magento release files. Works and tested on OSX, CentOS; though OSX requires md5 instead of md5sum
#!/bin/bash
find app/code/core/Mage app/code/core/Enterprise app/code/core/Zend lib/Varien lib/Mage lib/Zend -type f | grep -v '\.svn' | sort -d -f -k1 | xargs md5sum | awk {'print $2, $1'} > 1.11.2.0.local.md5
diff 1.11.2.0.base.md5 1.11.2.0.local.md5
@nanliu
nanliu / homebrew::tap.pp
Last active December 14, 2015 16:08
Homebrew::Tap for boxen PoC
define homebrew::tap (
$ensure = present,
) {
if $ensure == 'present' {
exec { "homebrew_tap_${name}":
command => "brew tap ${name}",
unless => "brew tap | grep ${name}",
}
} else {
exec { "homebrew_untap_${name}":
@simonvc
simonvc / stats-to-hosted-graphite.py
Last active December 16, 2015 03:39
This little recipe will pump your riak stats into hosted graphite. For more information see hostedgraphite.com @simonvc
import json
from urllib2 import urlopen
import socket
from time import sleep
UDP_ADDRESS = "carbon.hostedgraphite.com"
UDP_PORT = 2003
RIAK_STATS_URL='http://localhost:11098/stats'
HG_API_KEY='Your Api Key from HostedGraphite.com'
@danveloper
danveloper / MemoizedLambdaFib.java
Last active December 16, 2015 08:19
Memoized Fibonacci calculation using lambdas in Java 8
public class MemoizedLambdaFib {
interface MemoizedFunction<T, R> {
enum Cache {
_;
Map<Object, Object> vals = new HashMap<>();
}
R calc(T t);
@dhoss
dhoss / gist:5484465
Created April 29, 2013 20:19
error: play test [info] Loading project definition from /Users/daustin/web-dev/lumos-pottery/project [info] Set current project to lumos (in build file:/Users/daustin/web-dev/lumos-pottery/) [info] Compiling 10 Scala sources and 1 Java source to /Users/daustin/web-dev/lumos-pottery/target/scala-2.10/classes... [error] /Users/daustin/web-dev/lumo…
/** GenerateThumbnail
* generate a thumbnail of an image
*
* ==Overview==
* {{{
* val thumbnail = new Thumbnailer(.25, "image.jpg", "image-thumbnail.jpg")
* val resized = thumbnail.resize()
* thumbnail.save()
* }}}
*/