Skip to content

Instantly share code, notes, and snippets.

View hash_test.go
//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.
# Uncomment the following line to use case-sensitive completion.
huydx / nvim.conf
Created Jan 12, 2018
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

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 / simple_regex.go
Last active Aug 30, 2016
View simple_regex.go
package main
import (
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
View gist:cf1b647db7bdab07404c
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)
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]
huydx / lifx.scala
Last active Nov 10, 2015
View lifx.scala
import{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