Skip to content

Instantly share code, notes, and snippets.

Avatar

Chakrit Wichian chakrit

View GitHub Profile
View keybase.md

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:

View input.json
{
"object": "charge",
"id": "chrg_test_5086xlsx4lghk9bpb75",
"livemode": false,
"location": "/charges/chrg_test_5086xlsx4lghk9bpb75",
"amount": 100000,
"currency": "thb",
"description": null,
"capture": true,
"authorized": true,
View optional-operator.swift
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
In some circumstances where a lot of generics are involved, `make1` can returns a `Parent` instance instead of a `Child` instance.
View test.swift
import Foundation
protocol StringContainer {
var string: String { get }
init(string: String)
}
class Parent: NSObject, StringContainer {
var string: String
required init(string: String) {
View brew
brew tap homebrew/versions
postgresql
mysql
sqlite
openssl
git
svn
hg
tmux
@chakrit
chakrit / Actor.swift
Last active Feb 17, 2016
A single-file drop-in GCD-based strongly-typed Actor implementation in Swift.
View Actor.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
View gist:f704a48644864d9465bc
var _ = require('underscore');
function dud() { }
var result = _.wrap(dud, function(wrapped) {
console.log(arguments);
return 'result';
})('one', 'two', 'three');
console.log(result);
View horses.md

5th round (5x5x5x5x5)

If we split the 25 hourses into groups of 5 and have each group race among themselves, we'd be able to establish the ranking inside each group:

group:        1 2 3 4 5
1st finisher: a b c d e
2nd finisher: f g h i j
3rd finisher: k l m n o
View BrandsAdapter.java
package com.example.adapters;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewGroup;
import com.example.R;
import com.example.models.Brand;
import com.example.models.ImageKind;