Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.playngo.com/2007/06" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header><Operator xmlns="http://www.playngo.com/2007/06"><Login>rsp</Login><Password>xxx</Password></Operator></env:Header>
<env:Body>
<GetCasinoHistoryRequest xmlns="http://www.playngo.com/2007/06">
<Session>4f23....e145</Session>
<Product>PlaynGOCasino</Product>
<From>2016-04-30</From>
<To>2016-05-01</To>
</GetCasinoHistoryRequest>
def stubs(f)
f.post '/v1/oauth2/token?grant_type=client_credentials' do |env|
expect(apicalls.shift).to eq env.url.path
respond_to_auth_call env
end
f.post '/v1/transferOut' do |env|
expect(apicalls.shift).to eq env.url.path
validate_transfer_out_call env
respond_to_transfer_out_call env
end
@morhekil
morhekil / anonsplat.rb
Created June 23, 2015 23:20
Destructuring Ruby hashes with named parameters and anonymous splat
def stuff
yield action: 'Boom', schedule: '7PM', color: :red, debug: true
end
# When a hash is yielded to a block, we can used named arguments to
# capture the keys we want, and an anonymous splat to ignore
# everything else
stuff { |action:, schedule:, **| p "Doing #{action} at #{schedule}" }
#
@morhekil
morhekil / extend_include.rb
Created May 28, 2015 23:48
ruby extend vs include
#
# <<<--- helpers to explore lookup chain
#
def method_lookup_chain(obj, result = [obj.singleton_class])
if obj.instance_of? Class
return add_modules(result) if result.last == BasicObject.singleton_class
r = result.last.superclass
method_lookup_chain(obj, result << r)
else
return result + obj.class.ancestors
@morhekil
morhekil / Makefile
Created February 24, 2015 09:09
Example of using httest (http://htt.sourceforge.net) to test availability and configuration of a set of domains
all:
./poker.htt
./casino.htt
./sports.htt
@morhekil
morhekil / build.sh
Created November 24, 2014 10:55
guilder - build.sh for go build service
#!/bin/bash
set -e # exit on first error
set -x
BUILD_DIR=/build/go
DIST_DIR=/dist
SRC_DIR=$BUILD_DIR/src/$PKG
source /etc/profile
# Substitute path/version of hadoop files below
HADOOP_CLASSPATH=/usr/local/Cellar/hadoop/2.4.0/libexec/share/hadoop/yarn/test/hadoop-yarn-server-tests-2.4.0-tests.jar hadoop jar /usr/local/Cellar/hadoop/2.4.0/libexec/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.4.0-tests.jar minicluster --nnport=8020
@morhekil
morhekil / guerrilla_fetch.md
Created November 2, 2014 05:32
How to fetch, download and save locally Guerrilla Mail inbox

Guerrilla Mail keeps all incoming emails for only an hour, so if you can't check in on your inbox for a while - the emails will be lost. A way around would be, of course, to periodically fetch and store emails locally.

There's a python client that automates low level operations for GM (list emails, get an email), so it's easy to add another command to it to combine list and get commands together, to get all emails and save them into files.

Here is a patch that adds the command, using it is easy:

$ mkdir inbox
$ while true; do python guerrillamail.py getall inbox && sleep 60; done
@morhekil
morhekil / Dockerfile
Last active August 29, 2015 14:05
Docker container for Go builds
FROM ubuntu
# Download and unpack golang archive
RUN apt-get update
RUN apt-get install -y wget git
RUN wget https://storage.googleapis.com/golang/go1.3.1.linux-amd64.tar.gz -O /tmp/golang.tar.gz
RUN tar -C /usr/local -xzf /tmp/golang.tar.gz
# Configure the environment
RUN echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile.d/go.sh
@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '