Skip to content

Instantly share code, notes, and snippets.

@huydx
huydx / wordle_solver.go
Created January 28, 2022 14:23
wordle_solver.go
package main
import (
"bufio"
"fmt"
"github.com/umpc/go-sortedmap/desc"
"log"
"math/rand"
"os"
"strconv"
//go:noescape
//go:linkname memhash runtime.memhash
func memhash(p unsafe.Pointer, h, s uintptr) uintptr
type stringStruct struct {
str unsafe.Pointer
len int
}
// MemHash is the hash function used by go map, it utilizes available hardware instructions(behaves
# Path to your oh-my-zsh installation.
export ZSH=/Users/jp20992/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="jnrowe"
# Uncomment the following line to use case-sensitive completion.
@huydx
huydx / nvim.conf
Created January 12, 2018 13:47
~/.config/nvim/init.vim
call plug#begin('~/.vim/bundle')
" must
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let b:commandDepends = ['Unite', 'UniteWithBufferDir',
\ 'VimFilerCurrentDir', 'VimFilerBufferDir']
Plug 'Shougo/unite.vim', {'on': b:commandDepends, 'for': ['unite']}
\ | Plug 'Shougo/vimfiler', {'on': b:commandDepends}
Plug 'tpope/vim-commentary' " use gcc to comment line, gc to comment capture

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@huydx
huydx / descent_parser.go
Created September 3, 2016 13:22
descent_parser.go
package main
import "fmt"
// <regex> ::= <term> '|' <regex> | <term>
// <term> ::= { <factor> }
// <factor> ::= <base> { '*' }
// <base> ::= <char>
// | '\' <char>
// | '(' <regex> ')'
@huydx
huydx / simple_regex.go
Last active August 30, 2016 01:18
simple_regex.go
package main
import (
"fmt"
)
func match(regex string, text string) bool {
if string(regex[0]) == "^" {
return matchhere(regex[1:], text)
}
module TacosMachineLearning
class TrainDat
attr_accessor :features, :label
def initialize(features, label)
@features = features
@label = label
end
end
@huydx
huydx / gist:cf1b647db7bdab07404c
Created December 14, 2015 02:38
OffHeap Experiment
////////////////OnHeapGC
Java HotSpot(TM) 64-Bit Server VM (25.45-b02) for bsd-amd64 JRE (1.8.0_45-b14), built on Apr 10 2015 10:46:38 by "java_re" with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Memory: 4k page, physical 16777216k(1141424k free)
/proc/meminfo:
CommandLine flags: -XX:InitialHeapSize=734003200 -XX:MaxHeapSize=734003200 -XX:MaxNewSize=734003200 -XX:NewSize=734003200 -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
0.991: [GC (Allocation Failure) [PSYoungGen: 538112K->9320K(627200K)] 538112K->9328K(627712K), 0.0064314 secs] [Times: user=0.01 sys=0.01, real=0.01 secs]
1.481: [GC (Allocation Failure) [PSYoungGen: 547432K->13644K(627200K)] 547440K->13660K(627712K), 0.0068257 secs] [Times: user=0.01 sys=0.03, real=0.01 secs]