Skip to content

Instantly share code, notes, and snippets.

View chakrit's full-sized avatar

Chakrit Wichian chakrit

View GitHub Profile
package main
import (
"fmt"
"io/ioutil"
"os"
)
const Shift = 254
import uuid
OMISE_FEE = 0.0365
THAILAND_VAT = 0.07
class Transaction:
def __init__(self, balance, direction, amount, description):
self.balance = balance
self.direction = direction
self.amount = amount
package sql
import (
"bytes"
"github.com/gobuffalo/packr"
"github.com/golang-migrate/migrate"
"github.com/golang-migrate/migrate/source"
"io"
"io/ioutil"
"os"

Keybase proof

I hereby claim:

  • I am chakrit on github.
  • I am chakrit (https://keybase.io/chakrit) on keybase.
  • I have a public key ASBrshhm9oCYpRbPKix9k2qb8WSIgPcSydL70DOxQ_Ccpwo

To claim this, I am signing this object:

{
"object": "charge",
"id": "chrg_test_5086xlsx4lghk9bpb75",
"livemode": false,
"location": "/charges/chrg_test_5086xlsx4lghk9bpb75",
"amount": 100000,
"currency": "thb",
"description": null,
"capture": true,
"authorized": true,
import Foundation
import RxSwift
// HACK: Since the built-in Optional<T> is a generic type, not a protocol we cannot apply
// constraints on it. This protocol allows us to constraint our Rx operators onto
// optional types
protocol OptionalType {
associatedtype WrappedType
}
@chakrit
chakrit / test.swift
Last active May 30, 2016 04:47
In some circumstances where a lot of generics are involved, `make1` can returns a `Parent` instance instead of a `Child` instance.
import Foundation
protocol StringContainer {
var string: String { get }
init(string: String)
}
class Parent: NSObject, StringContainer {
var string: String
required init(string: String) {
@chakrit
chakrit / brew
Last active March 31, 2016 06:02
brew tap homebrew/versions
postgresql
mysql
sqlite
openssl
git
svn
hg
tmux
@chakrit
chakrit / Actor.swift
Last active February 17, 2016 11:45
A single-file drop-in GCD-based strongly-typed Actor implementation in Swift.
import Foundation
protocol Actable {
typealias MessageType
func act(cue: MessageType, replyTo channel: Channel<MessageType, Self>)
}
class Channel<TMessage, TActable: Actable where TActable.MessageType == TMessage> {
typealias CallbackType = (TMessage) -> Void
@chakrit
chakrit / .gitignore
Last active December 23, 2015 11:00
*.so
*.h
main