Skip to content

Instantly share code, notes, and snippets.

@xeago
xeago / android-dev-sample.xml
Created September 18, 2011 14:19
#android-dev
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.infosupport.com/Modules/Geneesmiddelen" xmlns:types="http://www.infosupport.com/Modules/Geneesmiddelen" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><types:GetMedicinesByCriteriumResponse><GetMedicinesByCriteriumResult href="#id1" /></types:GetMedicinesByCriteriumResponse><soapenc:Array id="id1" soapenc:arrayType="types:GeneesmiddelSlimItem[31]"><Item href="#id2" /><Item href="#id3" /><Item href="#id4" /><Item href="#id5" /><Item href="#id6" /><Item href="#id7" /><Item href="#id8" /><Item href="#id9" /><Item href="#id10" /><Item href="#id11" /><Item href="#id12" /><Item href="#id13" /><Item href="#id14" /><Item href="#id15" /><Item href="#id16" /><Item href="#id17" /><Item href="#id18" /><Item href=
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://www.infosupport.com/Modules/Geneesmiddelen" xmlns:types="http://www.infosupport.com/Modules/Geneesmiddelen" xmlns:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<types:GetMedicinesByCriteriumResponse>
<rpc:result xmlns="">GetMedicinesByCriteriumResult</rpc:result>
<GetMedicinesByCriteriumResult soapenc:id="id1" soapenc:itemType="types:GeneesmiddelSlimItem" soapenc:arraySize="31">
<Item soapenc:id="id2">
<GeneesmiddelId xsi:type="xsd:int">658</GeneesmiddelId>
<WerkzameStof xsi:type="xsd:string">Acebutolol</WerkzameStof>
</Item>
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "xsi:type=\"xsd:string\"><![CDATA[");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></WerkzameStof>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Herzieningsdatum>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Markt>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Intro>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Bijwerking>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Wisselwerking>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Verboden>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Zwangerschap>");
retrievedXML= retrievedXML.replaceAll("xsi:type=\"xsd:string\">", "]]></Gebruik>");
@xeago
xeago / subset_sum_dynamic.rb
Created May 1, 2012 17:21 — forked from skorks/subset_sum_dynamic.rb
Solving the subset sum problem via dynamic programming
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
require 'rubygems'
require 'Tire'
search = Tire.search('videos')
search.filter :term, "status" => "REMOVED"
# search.size 100
p search.results.map.all? {|v| v.status == "REMOVED" }
search.results.map.each { |v| puts v.status }
puts search.to_curl
@xeago
xeago / gist:3793895
Created September 27, 2012 13:09
opinion, belief, conviction, persuasion, sentiment, view, what to choose?

CHOOSE THE RIGHT WORD

When you give your opinion on something, you offer a conclusion or a judgment that, although it may be open to question, seems true or probable to you at the time (she was known for her strong opinions on women in the workplace). A view is an opinion that is affected by your personal feelings or biases (his views on life were essentially optimistic), while a sentiment is a more or less settled opinion that may still be colored by emotion (her sentiments on aging were shared by many other women approaching fifty). A belief differs from an opinion or a view in that it is not necessarily the creation of the person who holds it; the emphasis here is on the mental acceptance of an idea, a proposition, or a doctrine and on the assurance of its truth (religious beliefs; his belief in the power of the body to heal itself). A conviction is a firmly-held and unshakable belief whose truth is not doubted (she could not be swayed in her convictions), while a persuasion (in this sense) is a strong

import sys
def strxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)])
else:
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])])
def encrypt(key, msg):
c = strxor(key, msg)

Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.

To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.

Our setup:

  • elasticsearch

We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.

# [Tue Jun 21 12:05:39 2011] Protocol: http, Server: 192.168.5.103:9200
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"contact" : {
"properties" : {
"twitter" : {
"type" : "object",
"properties" : {
"profile" : {
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"number_of_shards" : 1
}
}
'
curl -XPUT 'http://127.0.0.1:9200/test/foo/1?pretty=1' -d '
{
"bar" : 5,