Skip to content

Instantly share code, notes, and snippets.

View dews's full-sized avatar

Calvin Zheng dews

  • Taichung, Taiwan
View GitHub Profile
@dews
dews / vim.md
Last active June 13, 2016 11:08
vim
$vim ~/.vimrc
set number
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
@dews
dews / Limit mac bandwidth.md
Last active February 14, 2025 18:43
Limit mac bandwidth

Mac limit bandwidth

Enable firewall

Apple menu -> System Preferences -> Security & Privacy -> Firewall

sudo pfctl -e

Example

sudo dnctl pipe 1 config bw 10Kbit/s

@dews
dews / git.md
Last active February 1, 2018 03:47
Git remove merged branch
@dews
dews / fillDB.py
Created February 9, 2018 03:04
Fill the SQLite
import sqlite3
conn = sqlite3.connect('testDB.db')
cursor = conn.cursor()
# cursor.execute('''CREATE TABLE test5
# (ID INT PRIMARY KEY NOT NULL,
# NAME TEXT NOT NULL);''')
with open('1mb.img') as f:
readFile = f.read()
i = 11
@dews
dews / openssl.bash
Last active July 16, 2018 10:06
Verify the Signature of a X.509 Certificate
#!/bin/bash
openssl req -newkey rsa:2048 -nodes -keyout server.key \
-subj '/CN=example.com/C=AU/O=Widgits Pty' -outform d -sha256 -out server.crt
openssl req -inform d -in server.crt -text -noout
# Certificate Request:
# Data:
# Version: 0 (0x0)
# Subject: CN=example.com, C=AU, O=Widgits Pty
@dews
dews / inheritance_demo.py
Last active October 30, 2018 08:17
python inheritance share variable
class Parent():
i = 123
def assign(self, n):
self.i = n
class ChildA(Parent):
def f1(self):
Parent.assign(self, 1)
import queue
import time
from threading import Event, Thread
class mo(Thread):
def __init__(self, num, q):
Thread.__init__(self, name='mo' + str(num))
self.num = num
self.q = q
@dews
dews / netflix.js
Last active February 2, 2019 04:13
speedup netflix play rate
document.querySelector('video').playbackRate = 1.5
@dews
dews / ModbusClient
Created April 9, 2019 06:38
ModbusClient.py
#!/usr/bin/env python
"""
Pymodbus Synchronous Client Examples
--------------------------------------------------------------------------
The following is an example of how to use the synchronous modbus client
implementation from pymodbus.
It should be noted that the client can also be used with
the guard construct that is available in python 2.5 and up::
[device]
murano_host = https://jrxncdkk2ls00000.m2.exosite.io/
murano_id = test
debug = INFO
murano_token = 7504c0bff8e9b9fe73214e0a113bc57a49e7bb14
murano_port = 443
watchlist = config_io,data_out
[edged]
config_io_file = config_io.json