This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@state = :sad | |
class TrueClass | |
def stop | |
@state = :neutral | |
end | |
end | |
def sad | |
@state == :sad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -XPUT 'http://localhost:9200/test/offer/1' -d '{ | |
"arrival": "2015-01-01", | |
"price": 100, | |
"hotel_id": "H1", | |
"offer_code": "O1" | |
}' | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
attr_accessor :prop | |
def set_prop(value) | |
prop = value | |
end | |
end | |
t = Test.new | |
t.set_prop 'a' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
def initialize | |
@atts = Hash.new | |
end | |
def prop=(value) | |
@atts[:prop] = value | |
end | |
def prop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'datamapper' | |
DataMapper.setup(:default, 'sqlite::memory:') | |
class Test | |
include DataMapper::Resource | |
property :id, Serial | |
property :prop, String |