Skip to content

Instantly share code, notes, and snippets.

@js2854
js2854 / jsoniter_ext.go
Last active June 28, 2022 12:00
jsoniter ignore omitempty
import jsoniter "github.com/json-iterator/go"
type NotOmitemptyValEncoder struct {
encoder jsoniter.ValEncoder
}
func (codec *NotOmitemptyValEncoder) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream) {
codec.encoder.Encode(ptr, stream)
}
@js2854
js2854 / compress_test.go
Last active January 5, 2022 06:34
compress/uncompress protobuf benchmark test
package main
import (
"bytes"
"compress/flate"
"compress/gzip"
"compress/zlib"
"io/ioutil"
"math/rand"
"testing"
@js2854
js2854 / binlog.txt
Last active April 7, 2021 07:27
查看mysql是否开启binlog,log_bin为ON表示开启了binlog,binlog_format为ROW表示是ROW模式,binlog_row_image为FULL
MariaDB [phone_property]> show variables like '%log_bin%';
+----------------------------------+-------+
| Variable_name | Value |
+----------------------------------+-------+
| forbid_remote_change_sql_log_bin | ON |
| log_bin | ON |
| log_bin_trust_function_creators | ON |
| sql_log_bin | ON |
+----------------------------------+-------+
4 rows in set (0.00 sec)
@js2854
js2854 / update-vscode-server.sh
Last active December 20, 2019 01:34
Manually download updates to resolve stuck problem on the step of downloading vscode-server-linux-x64.tar.gz with wget
#!/bin/bash
# Reference https://github.com/microsoft/vscode-remote-release/issues/680
if [ $# -lt 1 ]; then
echo "Usage: $0 sha"
echo "Demo: $0 26076a4de974ead31f97692a0d32f90d735645c0"
exit 0
fi
sha=$1
@js2854
js2854 / SyncDir.go
Last active January 27, 2022 11:16
// watches the source directory for changes and synchronize to destination directory
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"strings"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from functools import wraps
from bottle import request
def login():
def decorator(func):
@wraps(func)
class RepeatingTimer(_Timer):
def __init__(self, init_delay, interval, function, args=[], kwargs={}):
_Timer.__init__(self, interval, function, *args, **kwargs)
self.init_delay = init_delay
def run(self):
self.finished.wait(self.init_delay)
self.function(*self.args, **self.kwargs)
while not self.finished.is_set():
@js2854
js2854 / login_required
Created September 28, 2018 01:34 — forked from vsergeyev/login_required
@login_required decorator to use with bottle.py
from bottle import *
from bottlepy_user_auth import User
def validate_login():
return User().loggedin
def login_required(view, check_func=validate_login):
'''
#ifndef __RESULT_CODE__
#define __RESULT_CODE__
#include <string>
#include <iostream>
using std::string;
using std::ostream;
namespace Result
{
@js2854
js2854 / .gitignore
Last active August 29, 2015 14:13 — forked from reagent/.gitignore
Curses Windowing Example
demo
*.swp