Skip to content

Instantly share code, notes, and snippets.

View hash_test.go
//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
View gist:33e916ae721dc422e7b98e16e503ad6e
# 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 Jan 12, 2018
~/.config/nvim/init.vim
View nvim.conf
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
View Advanced-FP-with-Scala.md

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
View 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 Aug 30, 2016
simple_regex.go
View simple_regex.go
package main
import (
"fmt"
)
func match(regex string, text string) bool {
if string(regex[0]) == "^" {
return matchhere(regex[1:], text)
}
View perceptron.rb
module TacosMachineLearning
class TrainDat
attr_accessor :features, :label
def initialize(features, label)
@features = features
@label = label
end
end
View gist:cf1b647db7bdab07404c
////////////////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]
View Scala2.11.md
@huydx
huydx / lifx.scala
Last active Nov 10, 2015
lifx.scala
View lifx.scala
import java.net.{NetworkInterface, InetAddress, DatagramPacket, DatagramSocket}
object Command {
case class Header(frame: Frame, frameAdress: FrameAddress, protocolHeader: ProtocolHeader, payload: Array[Byte])
case class Frame(size: Short, protocol: Short, addressable: Byte, tagged: Byte, origin: Byte, source: Int) {
val length = 64 //64 bit
}
case class FrameAddress(target: Byte, reserved: Byte, resRequired: Byte, ackRequired: Byte, blank: Byte, sequence: Byte) {
val length = 128 //128 bit