Skip to content

Instantly share code, notes, and snippets.

View leyafo's full-sized avatar
😈
I may be slow to respond.

Wick leyafo

😈
I may be slow to respond.
View GitHub Profile
@leyafo
leyafo / schema.sql
Last active April 3, 2024 02:08
slippod sql schema
CREATE TABLE IF NOT EXISTS cards (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
entry TEXT NOT NULL,
created_at TIMESTAMP DEFAULT (strftime('%s', 'now')) NOT NULL,
updated_at TIMESTAMP DEFAULT (strftime('%s', 'now')) NOT NULL
);
CREATE VIRTUAL TABLE IF NOT EXISTS cards_fts USING fts5(
entry,
content='cards',
@leyafo
leyafo / main.go
Last active October 21, 2023 11:06
ed25519 between golang and nodejs.
package main
import (
"crypto/ed25519"
"crypto/rand"
"encoding/base64"
"fmt"
)
func main() {
@leyafo
leyafo / linux configuration
Last active January 17, 2022 10:16
Remapping Capslock to control on Linux console
#change capslock to ctrl though gnome-tweak-tool
#set manjaro mirros
sudo pacman-mirrors -i -c China -m rank #choose the sources that you want
sudo pacman -Syy
#set http over socks5 in shell
export http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080
#set git socks5
@leyafo
leyafo / IEEE754
Last active March 24, 2021 09:22
IEEE754 presenting
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
void printIEEE754(size_t const size, void const * const ptr){
unsigned char *b = (unsigned char*) ptr;
unsigned char byte;
int i, j, c=0;
if(size == 4){
@leyafo
leyafo / report_goroutine_progress.go
Last active May 22, 2019 13:52
Report mutiple go routine progress. If you wang report async goroutine schedule, you can use a channel to report the progress sequentially. Especilly if you want design a progressing bar.
package main
import (
"fmt"
"sync"
"time"
)
func main() {
c := make(chan struct{})
@leyafo
leyafo / gen_models.go
Created September 7, 2017 09:28
generate go CRUD code by robots.
package main
import (
"fmt"
"os"
"path"
"text/template"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
@leyafo
leyafo / awesom-go count
Last active November 29, 2019 11:08
awesome-go count stars
Count By 2017-07-04
Repo Stars
https://github.com/kubernetes/kubernetes 24538
https://github.com/bayandin/awesome-awesomeness 19182
https://github.com/astaxie/build-web-application-with-golang 16645
https://github.com/coreos/etcd 13933
https://github.com/mholt/caddy 12840
https://github.com/astaxie/beego 11438
https://github.com/influxdb/influxdb 10952
https://github.com/github/hub 10903
@leyafo
leyafo / subtitles_parse.py
Created June 12, 2015 15:03
srt subtitles parse
import os, sys;
import distutils.file_util as file_util
def iterate_path(source):
#list all files
files = os.listdir(source)
for f in files:
if(os.path.isfile(os.path.join(source,f))):
#check hide file
if(f[0] == "." or f == 'tmp.py'):
@leyafo
leyafo / time_ago_in_words
Last active August 9, 2017 18:43
A simple ruby time ago convert
MINUTE = 60
HOUR = MINUTE*60
DAY = HOUR*24
WEEK = DAY*7
MONTH = DAY*30
YEAR = MONTH*12
def time_ago_in_words(near_time, far_time)
diff = near_time.to_i - far_time.to_i