Skip to content

Instantly share code, notes, and snippets.

@jingzhehu
jingzhehu / gist:2550eb4efd665fe548582629128121d4
Created February 20, 2017 15:36
ubuntu-llvm-update-sym-links
#!/usr/bin/env sh
# adapted from https://gist.github.com/jc00ke/b55cf7d16d584fbb2b92
sudo update-alternatives --install \
/usr/bin/llvm-config llvm-config /usr/bin/llvm-config-3.9 200 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-3.9 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.9 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-3.9 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-3.9 \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-3.9 \
@jingzhehu
jingzhehu / gist:4ba59054e3eac0705ccd6eda24536ca0
Last active February 20, 2017 16:11
regex-not-match-a-word
# https://regex101.com/r/Serx4o/1
# do not match the string if "someword" occurs anywhere in the string
# https://docs.python.org/3/howto/regex.html
^(?:(?!someword).)*$
@jingzhehu
jingzhehu / CMakeLists.txt
Created February 26, 2017 15:36
Clion meets bitcoin.
cmake_minimum_required(VERSION 3.3)
project(bitcoin)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_custom_target(build-bitcoin ALL
COMMAND ./autogen.sh
COMMAND ./configure
COMMAND $(MAKE) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# tf quick test
# CUDA_VISIBLE_DEVICES=0 python
import os
# os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"
import tensorflow as tf
# gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)
@jingzhehu
jingzhehu / CMakeLists.txt
Created March 3, 2017 12:46
Clion meets bitcoin - macOS.
cmake_minimum_required(VERSION 3.3)
project(bitcoin)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_custom_target(build-bitcoin ALL
COMMAND ./autogen.sh
COMMAND ./configure
COMMAND $(MAKE) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@jingzhehu
jingzhehu / go_tour_ex_maps.go
Created April 23, 2017 23:06
A Tour of Go: Exercise: Maps
package main
import (
"fmt"
"strings"
"golang.org/x/tour/wc"
)
func WordCount(s string) map[string]int {
@jingzhehu
jingzhehu / go_tour_ex_slices.go
Created April 23, 2017 23:10
A Tour of Go - Exercise Slices
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for x := range pic {
pic[x] = make([]uint8, dx)
for y := range pic[x] {
@jingzhehu
jingzhehu / go_tour_ex_loops_fns.go
Created April 23, 2017 23:11
A Tour of Go: Exercise Loops and Functions
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(1)
@jingzhehu
jingzhehu / go_tour_ex_fibonacci_closure.go
Created April 24, 2017 01:50
A Tour of Go: Exercise Fibonacci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a := 1
b := 1
c := 0
@jingzhehu
jingzhehu / go_tour_ex_stringers.go
Created April 24, 2017 13:57
A Tour of Go: Exercise Stringers
package main
import "fmt"
type IPAddr [4]byte
// TODO: Add a "String() string" method to IPAddr.
func (ip IPAddr) String() string {
return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3])
}