Skip to content

Instantly share code, notes, and snippets.

@tosone
tosone / lagou-crawler.py
Last active July 21, 2019 13:10
[Lagou crawler] #Python
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import logging
import math
import random
import re
import sqlite3
import time
import uuid
@tosone
tosone / Makefile
Last active July 21, 2019 13:04 — forked from isaacs/Makefile
[Makefile] #Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@tosone
tosone / relect.go
Last active July 21, 2019 13:09
[Golang reflect struct] #Go
package main
import (
"fmt"
"reflect"
"time"
)
func main() {
type T struct {
@tosone
tosone / float32642byte.go
Last active July 21, 2019 13:07
[Byte to Float] #Go
import (
"encoding/binary"
"math"
)
func Float32ToByte(float float32) []byte {
bits := math.Float32bits(float)
bytes := make([]byte, 4)
binary.LittleEndian.PutUint32(bytes, bits)
@tosone
tosone / callback.c
Last active August 16, 2019 03:22
[Callback in C] #C
#include <stdio.h>
typedef void (*callback_t)(char *);
void callback_test(char *str) {
printf("%s\n", str);
return;
}
void callback_main(callback_t cb) {
@tosone
tosone / cgo.md
Last active July 21, 2019 13:11 — forked from zchee/cgo.md
[Golang CGO] #Go

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.

@tosone
tosone / objectid.go
Last active July 21, 2019 13:05
[Object ID] Generate MongoDB object id. #Go
package main
import (
"crypto/md5"
"crypto/rand"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"os"
@tosone
tosone / gen.sh
Last active July 21, 2019 13:40
[Mac Keys]
ssh-keygen -t rsa -b 4096 -C "i@tosone.cn" -P "" -f deploy-key
@tosone
tosone / git.sh
Created July 21, 2019 13:50
[Initialize Script] #Bash
git config user.signingkey B48CF8424DDA96E1
git config commit.gpgsign true
git config user.email "i@tosone.cn"
git config user.name "Tosone"
@tosone
tosone / bash.sh
Created August 29, 2019 02:40
[K8s]
kubectl get namespaces
kubectl get pods --namespace uaa
kubectl get pods --namespace scf
kubectl get pods --namespace stratos
kubectl describe pods uaa-0 --namespace uaa
kubectl describe pods router-0 --namespace scf
kubectl logs -f --namespace uaa uaa-0 uaa