Skip to content

Instantly share code, notes, and snippets.

View windhooked's full-sized avatar

H windhooked

View GitHub Profile
@windhooked
windhooked / main.go
Created July 4, 2022 08:34 — forked from denisbrodbeck/main.go
How to generate secure random strings in golang with crypto/rand.
// License: MIT
package main
import (
"crypto/rand"
"fmt"
"math/big"
)
// GenerateRandomASCIIString returns a securely generated random ASCII string.

Run go install and

  • gogitlocalstats -add /path/to/folder will scan that folder and its subdirectories for repositories to scan
  • gogitlocalstats -email your@email.com will generate a CLI stats graph representing the last 6 months of activity for the passed email. You can configure the default in main.go, so you can run gogitlocalstats without parameters.

Being able to pass an email as param makes it possible to scan repos for collaborators activity as well.

License: CC BY-SA 4.0

@windhooked
windhooked / batch_worker_test.go
Last active June 2, 2022 14:16
Batching request, then split merge pattern
package pool
import (
"log"
"testing"
"time"
)
var testData = []string{
"vBnvjMTw6jIQ",
@windhooked
windhooked / sshd.go
Last active October 7, 2020 06:21 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@windhooked
windhooked / fsevents_windows.go
Created September 19, 2020 07:01 — forked from pkrnjevic/fsevents_windows.go
Windows USN Journal sample in Go based on Jeffrey Richter's superb MSDN Journal article. A work in progress, intended to provide similar API to go.fsevents.
//
// File: fsevents_windows.go
// Date: October 29, 2013
// Author: Peter Krnjevic <pkrnjevic@gmail.com>, on the shoulders of many others
//
// This code sample is released into the Public Domain.
//
package fsevents
import (
@windhooked
windhooked / cgo.md
Created September 11, 2020 10:55 — forked from zchee/cgo.md
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@windhooked
windhooked / touchscreen-debian-fix.sh
Created August 15, 2020 05:54 — forked from Chocksy/touchscreen-debian-fix.sh
Fix for Elo Touchscreen on debian
# Some interesting python script:
# https://raw.githubusercontent.com/adafruit/PiTFT_Extras/master/pitft_touch_cal.py
# > sudo add-apt-repository ppa:tias/xinput-calibrator-ppa
> sudo apt-get update && sudo apt-get install xinput-calibrator
> apt-get install xinput
> export DISPLAY=:0.0
> xinput list-props "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface"
> xinput set-prop "EloTouchSystems,Inc Elo TouchSystems 2216 AccuTouch® USB Touchmonitor Interface" "Evdev Axis Inversion" 0 1
# here touch the points on the screen in the corners
> xinput_calibrator --output-type xinput
@windhooked
windhooked / string.md
Created July 8, 2020 06:18 — forked from helinwang/string.md
How to call go from c with string (char *) as the parameter without making a copy

Here is the gist for showing how to send string from c to go without a copy, for sending an float32 array from c to go without copy, please see here

Below is the documentation for converting between a c string and a go string:

// From https://golang.org/cmd/cgo/
// A few special functions convert between Go and C types by making copies of the data. 
// Go string to C string
// The C string is allocated in the C heap using malloc.
// It is the caller's responsibility to arrange for it to be
// freed, such as by calling C.free (be sure to include stdlib.h
@windhooked
windhooked / soap-EandD.go
Created July 2, 2020 17:08 — forked from kn9ts/soap-EandD.go
Decoding and encoding SOAP using Go (Awesomeness!!!)
package main
import (
"bytes"
"encoding/xml"
"fmt"
"github.com/webconnex/xmlutil"
"log"
//"net/http"
)
@windhooked
windhooked / README.md
Created June 1, 2020 13:34 — forked from crypticmind/README.md
Setup lambda + API Gateway using localstack