Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

wangrenjun

🎯
Focusing
View GitHub Profile
@wangrenjun
wangrenjun / main.go
Created Feb 5, 2021
Go loading data and coordinates from GeoJson file to PostgreSQL using Gorm.
View main.go
package main
import (
"flag"
"fmt"
"io/ioutil"
"strconv"
"time"
geojson "github.com/paulmach/go.geojson"
@wangrenjun
wangrenjun / gormjoin.go
Last active Feb 5, 2021
Example of GORM using join
View gormjoin.go
package main
import (
"encoding/json"
"fmt"
"time"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
View gist:4a817c777d2dbd31232b8112d34a0a62
#! /bin/bash
cat << EOD
Format/result | Command | Output
--------------------------------+-------------------------------+------------------------------
YYYY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T)
YYYYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S)
YYYYMMDD_hhmmss (UTC version) | date --utc +%Y%m%d_%H%M%SZ | $(date --utc +%Y%m%d_%H%M%SZ)
YYYYMMDD_hhmmss (with local TZ) | date +%Y%m%d_%H%M%S%Z | $(date +%Y%m%d_%H%M%S%Z)
YYYYMMSShhmmss | date +%Y%m%d%H%M%S | $(date +%Y%m%d%H%M%S)
@wangrenjun
wangrenjun / goredis_pipeline.go
Created Dec 15, 2019
Redis pipeline example with Go
View goredis_pipeline.go
package main
import (
"fmt"
"strconv"
"github.com/go-redis/redis/v7"
)
func main() {
client := redis.NewClient(&redis.Options{
@wangrenjun
wangrenjun / gjson_foreach_example.go
Last active Dec 10, 2019
GJSON example of ForEach()
View gjson_foreach_example.go
package main
import "github.com/tidwall/gjson"
import "fmt"
import "strings"
func main() {
jsonstring := `
{
    "status":"ok",
@wangrenjun
wangrenjun / libev-client.c
Last active Oct 17, 2019
another libev example
View libev-client.c
/*
* Licensed under the Apache License, Version 2.0.
*
* simple libev client example
* based on multi-process and ring buffer
* wangrj1981@gmail.com
*/
/*
gcc ./libev-client.c -c -o ./libev-client.o -I/usr/local/include/
@wangrenjun
wangrenjun / gist:9803449
Last active Aug 29, 2015
linux splice simple test
View gist:9803449
/*
* No license provided.
*/
#define _GNU_SOURCE
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
View gist:9798915
#include <stdio.h>
int main()
{
printf("hello world\n");
return 0;
}