Skip to content

Instantly share code, notes, and snippets.

View chakrit's full-sized avatar

Chakrit Wichian chakrit

View GitHub Profile
@chakrit
chakrit / elmgroupof.elm
Created June 11, 2019 15:28
Elm groupOf function
groupOf : Int -> List a -> List (List a)
groupOf count list =
let
len =
List.length list
in
if len >= count then
List.take count list :: (groupOf count <| List.drop count list)
else if len > 0 then
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"
@chakrit
chakrit / text.md
Last active July 18, 2018 20:34
On Go binary deploys.

Talked with @anthonybouch and @scomma the other day and told them that I don't do source-deploys with Go programs. It was sort of a gut reaction and also because I havn't quite worked out all the details at that time as I was not at the stage to be thinking about deployments just yet.

Cons

@scomma made note that you could still do git deploys with source and compile on the server and that's right that you can do that but there are some complications:

@chakrit
chakrit / main.go
Last active March 23, 2018 14:57
Testing golang's map behavior when the map is nil. Map is defined in the spec as being a reference type (i.e. you can assign maps to multiple variables but they would share the underlying storage). In this case, you can actually index a nil map, but not add values to it. This is nice but could a bit surprising when you are testing for your code'…
package main
import "fmt"
type Values map[string]string
func main() {
var v Values = nil
fmt.Printf("%-15s\t%-15s\t%-15s\n", "nil", "result", "ok")
using System;
namespace TCastr.Models
{
/// <summary>
/// An implicitly-convertible buffer that automatically converts between
/// a compact string representation and a Guid.
/// </summary>
/// <remarks>

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
}