Skip to content

Instantly share code, notes, and snippets.

View zhanglongqi's full-sized avatar

Zhang LongQi zhanglongqi

View GitHub Profile
@zhanglongqi
zhanglongqi / unique-val-col-calc
Created September 5, 2017 15:12 — forked from arthurleon/unique-val-col-calc
Get unique values of a column in Libre Office Calc
Select the whole column
Data > Filter > Standard Filter
Change 'Field Name' to -none- , click on 'More options' and check on 'No duplication' box
Source: http://superuser.com/questions/238656/openoffice-get-distinct-values-from-column

Keybase proof

I hereby claim:

  • I am zhanglongqi on github.
  • I am longqi (https://keybase.io/longqi) on keybase.
  • I have a public key whose fingerprint is EAD9 C1AE C3CE 48E3 5F1B D0AC 17C6 A1D4 DEA0 8339

To claim this, I am signing this object:

@zhanglongqi
zhanglongqi / center.html
Created July 9, 2017 10:43
show the element in the absolute center vertically and horizontally.
<h1 style="position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%)"> Loading...</h1>
@zhanglongqi
zhanglongqi / http_server.py
Created July 9, 2017 10:21
change the root path of Python http.server
from os import chdir
from os.path import join, dirname
from http.server import SimpleHTTPRequestHandler, test
chdir(join(dirname(__file__), 'YOUR_WEB_ROOT_PATH'))
test(SimpleHTTPRequestHandler, port=8080, bind='0.0.0.0')
@zhanglongqi
zhanglongqi / broadcast_receiving.py
Last active June 30, 2017 10:32
broadcast a message in the local network
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
longqi 30/Jun/17 16:36
Description:
"""
from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_BROADCAST, SO_REUSEADDR
@zhanglongqi
zhanglongqi / wechat.js
Last active June 19, 2017 14:29
wechat article
// ==UserScript==
// @name wechat
// @namespace http://tampermonkey.net/
// @version 0.2
// @description expand the width of wechat article to 100%, hide the QR code div
// @author LongQi
// @match https://mp.weixin.qq.com/*
// @grant none
// @updateURL https://gist.github.com/zhanglongqi/24d3410126cb706b2307173c6e0a8b64
// ==UserScript==
// @name NTU WebMail
// @namespace https://github.com/zhanglongqi
// @version 0.2
// @description keep NTU webmail cookies
// @author Zhang LongQi
// @match https://webmail.ntu.edu.sg/owa/auth/logon.aspx*
// @grant none
// @updateURL https://gist.github.com/zhanglongqi/ae244a0cd16ac8b76abbf6ce755be40b
@zhanglongqi
zhanglongqi / cal.sh
Created April 20, 2017 01:18
calculate the rate of some files in a folder
echo $(( `ls -l brief | grep -e ".*json.old$" | wc -l` / `ls -l brief | wc -l`.0 ))
# 0.71987643734567586
@zhanglongqi
zhanglongqi / pickle_python.py
Created January 25, 2017 07:14
Pickle example of python
import pickle
data1 = {'foo': [1, 2, 3],
'bar': ('Hello', 'world!'),
'baz': True}
# write the pickled data to the file jar
with open('data.pkl', mode='wb') as jar:
pickle.dump(data1, jar, fix_imports=True)
@zhanglongqi
zhanglongqi / check_network_connection.py
Last active January 24, 2017 06:43
Check network connection
import socket
def check_internet(host="8.8.8.8", port=53, timeout=3):
"""
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
"""
try:
socket.setdefaulttimeout(timeout)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)