Skip to content

Instantly share code, notes, and snippets.

@higuoxing
higuoxing / quicksort.hs
Last active January 10, 2018 05:23
quick sort in Haskell
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x : xs) =
let smallerSorted = quicksort (filter (<= x) xs)
biggerSorted = quicksort (filter (> x) xs)
in smallerSorted ++ [x] ++ biggerSorted
@higuoxing
higuoxing / Automata.hs
Last active March 1, 2018 04:43
Automata implemented in Haskell
{-# LANGUAGE GADTs #-}
module Regex.Automata (
Automata (..) , -- Automata states transitions (initial state) (final states)
Transition (..) , -- Transitions
subsetConstruct , -- Subset construction
isEpsilon , -- Indicates epsilon edge
getStates , -- Get two states of an edge
getEdgeChar , -- Get Char of an edge
epsilonClosure_T , -- Get the epsilon closure of a set of state
@higuoxing
higuoxing / ngspice-wrapper.js
Last active May 9, 2018 06:21
node binding for ngspice-shared-lib
const ffi = require('ffi');
const ref = require('ref');
const ref_struct = require('ref-struct');
const struct = require('./wrapper/struct');
const sendChar = ffi.Callback('int', ['string', 'int', 'pointer'],
// callback: SendChar
// return type: int
// args: ['string', 'int', 'void*']
(res, id, user_data) => {
@higuoxing
higuoxing / .block
Last active August 17, 2018 10:12
Expanding Binary Tree
license: gpl-3.0
height: 500
scrolling: no
border: yes
@higuoxing
higuoxing / transform.cc
Created October 6, 2018 15:50
Image Processing in C++/Go
//===--------------------------------------------
// File: transform.cc
// Usage: display a given image from a specific
// rgb color space and simulate the image
// from another color rgb space.
// Author: Xing GUO <[email protected]>
//===-------------------------------------------
#include <iostream>
#include <cmath>
@higuoxing
higuoxing / README.md
Created November 26, 2018 04:07
OS X disk merging failed

Some commands

sudo diskutil apfs deleteContainer disk0s3
sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3
sudo diskutil apfs resizeContainer disk0s2 0

Reference

stackexchange

1、安装arcanist,clone源代码到安装目录somewhere/,arcanist依赖于libphutil,所以两个都要clone
somewhere/ git clone git://github.com/facebook/arcanist.git
somewhere/ git clone git://github.com/facebook/libphutil.git
2、配置arc,将arc加入到PATH,或在/usr/sbin里面建一个到arc的软链接
export PATH=$PATH:/somewhere/arcanist/bin/
或者:cd /usr/sbin; ln -sf /somewhere/arcanist/bin/arc
* 在系统的~/.bashrc或~/.bash_profile中加上该export语句。
* 运行命令"arc help",来检测安装是否成功。
3、配置arc的编辑器,不然会报错,提示EDITOR环境变量没配置
arc set-config editor "vim"
package main
import (
"fmt"
"runtime"
"time"
"math/rand"
)
type semaphore chan int
@higuoxing
higuoxing / constraints.xdc
Created October 9, 2019 06:13
AX7020 管脚绑定的约束文件
## CLK
#set_property IOSTANDARD LVCMOS33 [get_ports clk_50M]
#set_property PACKAGE_PIN U18 [get_ports clk_50M]
## HDMI
#set_property IOSTANDARD TMDS_33 [get_ports TMDS_clk_n]
#set_property PACKAGE_PIN N18 [get_ports TMDS_clk_p]
#set_property IOSTANDARD TMDS_33 [get_ports TMDS_clk_p]
#set_property IOSTANDARD TMDS_33 [get_ports TMDS_data_n0]
#set_property PACKAGE_PIN V20 [get_ports TMDS_data_p0]