Skip to content

Instantly share code, notes, and snippets.

View manuelbrunner's full-sized avatar

Manuel Brunner manuelbrunner

View GitHub Profile
@manuelbrunner
manuelbrunner / gist:414f135eb6c292d13407
Created September 2, 2014 13:10
be awesome according to pic
@state = :sad
class TrueClass
def stop
@state = :neutral
end
end
def sad
@state == :sad
#!/bin/sh
curl -XPUT 'http://localhost:9200/test/offer/1' -d '{
"arrival": "2015-01-01",
"price": 100,
"hotel_id": "H1",
"offer_code": "O1"
}'
echo
// includes http://stackoverflow.com/questions/332079/in-java-how-do-i-convert-a-byte-array-to-a-string-of-hex-digits-while-keeping-l
public static void main(String[] args) throws Exception {
String stringToEncrypt = "foobar";
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(stringToEncrypt.getBytes("UTF-8"));
byte messageDigest[] = md.digest();
StringBuffer hexString = new StringBuffer();
for (int i=0;i<messageDigest.length;i++) {
String hex = Integer.toHexString(0xFF & messageDigest[i]);
if (hex.length() == 1) {
apt-get install tmux
gem install teamocil
# ~/.teamocil/test.yml
windows:
- name: "test"
root: "/home/user/projects/test"
splits:
- cmd: "vim"
- cmd: "bundle exec guard"
@manuelbrunner
manuelbrunner / gist:1626269
Created January 17, 2012 11:11
prevent memcached library to write to system out
// force memcached library to use log4j
Properties systemProperties = System.getProperties();
systemProperties.put("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.Log4JLogger");
System.setProperties(systemProperties);
// set log level in log4j.properties
// log4j.logger.net.spy.memcached = WARN
class Test
attr_accessor :prop
def set_prop(value)
prop = value
end
end
t = Test.new
t.set_prop 'a'
class Test
def initialize
@atts = Hash.new
end
def prop=(value)
@atts[:prop] = value
end
def prop
require 'rubygems'
require 'datamapper'
DataMapper.setup(:default, 'sqlite::memory:')
class Test
include DataMapper::Resource
property :id, Serial
property :prop, String