Skip to content

Instantly share code, notes, and snippets.

Avatar

Chakrit Wichian chakrit

View GitHub Profile
View install-docker.sh
#!/bin/sh
apt-get remove -y docker docker-engine docker.io containerd runc
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
@chakrit
chakrit / api.go
Created May 4, 2021 — forked from narze/gov-project-generator.rb
gov-project-generator
View api.go
package main
import (
"crypto/rand"
"encoding/binary"
"encoding/json"
"io/ioutil"
"log"
"net/http"
"strings"
@chakrit
chakrit / PageStreamer.java
Created Feb 23, 2021
Converting Spring Page<T> to Stream<T>
View PageStreamer.java
package com.github.chakrit;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.util.function.Function;
import java.util.stream.Stream;
/**
View Main.elm
module Main exposing (..)
import Browser
import Html exposing (div, input, p, span, strong, text)
import Html.Attributes exposing (value)
import Html.Events exposing (onInput)
type alias Model =
String
@chakrit
chakrit / gendiff.go
Last active Jul 5, 2019
Generic Diff algorithm in Go.
View gendiff.go
package gendiff
type Op int
const (
noOp = Op(iota)
Match
Delete
Insert
)
@chakrit
chakrit / Base64.elm
Last active Jun 11, 2019
Base64 URL encoding
View Base64.elm
module Base64 exposing
( base64FromBytes
, base64ToBytes
, fromBase64String
, toBase64String
)
import Bitwise as Bits
import Bytes exposing (Bytes)
import Bytes.Decode as D
@chakrit
chakrit / elmgroupof.elm
Created Jun 11, 2019
Elm groupOf function
View elmgroupof.elm
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
View main.go
package main
import (
"fmt"
"io/ioutil"
"os"
)
const Shift = 254
View challenge_py.py
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
View packr_source.go
package sql
import (
"bytes"
"github.com/gobuffalo/packr"
"github.com/golang-migrate/migrate"
"github.com/golang-migrate/migrate/source"
"io"
"io/ioutil"
"os"