Skip to content

Instantly share code, notes, and snippets.

View wilhelmjung's full-sized avatar
🎯
Focusing

YangWeiliang_DeepNova@Deepexi wilhelmjung

🎯
Focusing
View GitHub Profile
#string hash functions
def bkdr(str):
seed = 13131 # 31,131,13131,...
hash = 0
for ch in str:
hash = hash * seed + ord(ch) # char to int
return hash & 0xFFFFFFFF # unit32
def english_words_hash_test(wtxt):
// compile with: /EHsc
#include <windows.h>
#include <ppl.h>
#include <concurrent_vector.h>
#include <array>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iostream>
@wilhelmjung
wilhelmjung / SerialPortToTcpPort.sh
Created July 12, 2013 03:37
Serial port and TCP port forwarding script.
#!/bin/sh
# serial port and TCP port forwarding script
# use under linux and busybox shell.
PORT=12345
COM=/dev/ttyS1
echo Start to setup serial.
echo Set serial port as 9600-8-e-1
(require :usocket)
(defvar server-socket)
(defvar client-socket)
(defun default-udp-handler (buffer) ; echo
(declare (type (simple-array (unsigned-byte 8) *) buffer))
(format t "recv: ~A~%" buffer) ; no show in new thread.
buffer)
;;(setq w32-pass-apps-to-system nil)
(setq w32-apps-modifier 'hyper)
(setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'hyper)
;; editing
(global-set-key (kbd "H-c") 'kill-ring-save) ;; copy
(global-set-key (kbd "H-x") 'kill-region) ;; cut
@wilhelmjung
wilhelmjung / countWordsAsync
Created June 13, 2013 08:54
Words frequency statistic by async syntax in F#
open System
open System.IO
open System.Text.RegularExpressions
open Microsoft.FSharp.Control.CommonExtensions
let path = @"C:\Users\William\Desktop\log\txt"
let readFileAsync filePath =
async { // open and read file
let fileStream = File.OpenText(filePath)