Skip to content

Instantly share code, notes, and snippets.

{
"bb": 2.0,
"committed_eur": 140.571633,
"committed_usd": 183.0,
"created_at": "2013-08-08 20:03:22.916840",
"ended_at": "2013-06-26 16:55:49",
"game_server": "PokerStars",
"game_type": "omaha",
"id": 1273,
"started_at": "2013-06-26 16:11:08",
@maliqq
maliqq / gist:9895985
Created March 31, 2014 16:16
Annual tourists to total population, World Bank data
Andorra: 2485.96%
Macao SAR China: 2321.37%
Turks and Caicos Islands: 1091.68%
Sint Maarten (Dutch part): 1084.73%
Aruba: 849.74%
Monaco: 785.01%
Guam: 711.87%
Northern Mariana Islands: 630.33%
Cayman Islands: 536.74%
Palau: 525.20%
### Usage example
Publisher = Struct.new(:name)
Book = Struct.new(:publisher)
Review = Struct.new(:book)
def Review.publisher
book.publisher
end
final val TypeField = "$type"
final val ObjectField = "$object"
def encode[T <: Message](msg: T): Array[Byte] = {
val schema: protostuff.Schema[T] = msg.schema.asInstanceOf[protostuff.Schema[T]]
val out = new java.io.ByteArrayOutputStream
val context = new org.codehaus.jackson.io.IOContext(protostuff.JsonIOUtil.DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false);
val generator = protostuff.JsonIOUtil.newJsonGenerator(out, context.allocWriteEncodingBuffer)
group java_bean_model_schema : java_bean_model_base;
message_block(message, module, options, nested) ::= <<
<if(!nested)>
<message:message_header(message=it, module=module, options=options)>
<endif>
public <if(nested)>static <endif>class <remote_model_schema_name(message=message, name=message.name)>
<options.(message.name + ".extends_schema_declaration"); format=" ">
<message:message_impl_declaration(message=it, options=options)> {
import (
"math"
)
type Currency struct {
Name string // "US Dollar"
IsoCode string // "USD"
Precision int // 2
}
@maliqq
maliqq / broker.go
Last active November 22, 2018 08:53
Golang message broker
package protocol
import (
"fmt"
"log"
)
// pubsub
type Broker struct {
Send map[string]*chan *Message
a = [1,2,3,5,6,7,10,11,12,14,15]
def split_gaps(a)
gaps = []
buffer = a.inject([]) { |buffer, item|
prev = buffer[buffer.size - 1]
if prev && item - prev > 1
gaps << buffer
[]
@maliqq
maliqq / gist:5244932
Created March 26, 2013 12:11
github languages (full)
JavaScript 1
Ruby 2
Java 3
Python 4
Shell 5
PHP 6
C 7
C++ 8
Perl 9
Objective-C 10
@maliqq
maliqq / sberbank.rb
Last active December 23, 2016 23:41
текстовая выписка сбербанка -> csv
# encoding: utf-8
def parse_date(s)
map = {'ЯНВ' => 1, 'ФЕВ' => 2, 'МАР' => 3, 'АПР' => 4, 'МАЙ' => 5, 'ИЮН' => 6, 'ИЮЛ' => 7, 'АВГ' => 8, 'СЕН' => 9, 'ОКТ' => 10, 'НОЯ' => 11, 'ДЕК' => 12}
s =~ /^(\d+)(.+?)(\d+)$/
Date.new($3.to_i + 2000, map[$2], $1.to_i)
end
require 'csv'
str = CSV.generate do |csv|
while line = gets