Skip to content

Instantly share code, notes, and snippets.

View congzhangzh's full-sized avatar
🎯
Focusing

Cong Zhang congzhangzh

🎯
Focusing
View GitHub Profile
extern "C" int self_main(int argc, char**argv)
{
//char cmdline[1024]={};
std::string cmdLine;
//std::getline(std::fstream("/proc/self/cmdline", std::ios::binary|std::ios::in), cmdLine);
std::getline(std::fstream("/proc/self/cmdline", std::ios::in), cmdLine);
std::string::size_type pos=0;
std::string oldStr;
@congzhangzh
congzhangzh / tun-ping-win.py
Created December 25, 2016 00:30 — forked from glacjay/tun-ping-win.py
Reading/Writing OpenVPN's TUN/TAP Device under Windows using Python.
import _winreg as reg
import win32file
adapter_key = r'SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}'
def get_device_guid():
with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters:
try:
@congzhangzh
congzhangzh / 0build-bitcoin.sh
Created January 1, 2017 18:37 — forked from devrandom/00README.md
Building bitcoin with gitian-builder
# First run:
apt-get install apt-cacher python-vm-builder
vi /etc/default/apt-cacher # ensure autostart is enabled
sudo service apt-cacher start
git clone git://github.com/bitcoin/bitcoin.git
git clone git://github.com/devrandom/gitian-builder.git
mkdir gitian-builder/inputs
wget 'http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.5.tar.gz' -O gitian-builder/inputs/miniupnpc-1.5.tar.gz
wget 'http://downloads.sourceforge.net/project/wxwindows/2.9.1/wxWidgets-2.9.1.tar.bz2' -O gitian-builder/inputs/wxWidgets-2.9.1.tar.bz2
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'design.ui'
#
# Created: Wed May 27 16:39:17 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
@congzhangzh
congzhangzh / grab_all_pages.sh
Created February 12, 2017 11:59 — forked from rjshade/grab_all_pages.sh
wget with https and cookie login
#!/bin/bash
# first login and store the cookie
wget --post-data='name=USERNAME&pass=PASSWORD&op=Log%20in' --save-cookies=my-cookies.txt --keep-session-cookies "https://private.site.com" > /dev/null 2>&1
# now we can scrape the site (353 pages)
for i in {0..353}
do
echo "grabbing page $i..."
wget --cookies=on --keep-session-cookies --load-cookies=my-cookies.txt "https://private.site.com/people?page=$i" > /dev/null 2>&1
@congzhangzh
congzhangzh / generate.sh
Created August 20, 2017 13:32 — forked from fyears/generate.sh
pyside+qml+pyinstaller
pyinstaller -F -w --noupx main.spec
@congzhangzh
congzhangzh / README.md
Created January 31, 2018 14:40 — forked from mottosso/README.md
QObject list-model with factory function
@congzhangzh
congzhangzh / gmail_actions_example.html
Created February 9, 2018 00:16
Python script to send HTML email from command line
<!--
This is a sample email taken from https://developers.google.com/gmail/schemas/apps-script-tutorial
and used to test the GMail actions support.
-->
<html>
<head>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
@congzhangzh
congzhangzh / python_3_email_with_attachment.py
Created February 9, 2018 00:26 — forked from rdempsey/python_3_email_with_attachment.py
Use Python 3 to send an email with an attachment using Gmail
#!/usr/bin/env python
# encoding: utf-8
"""
python_3_email_with_attachment.py
Created by Robert Dempsey on 12/6/14.
Copyright (c) 2014 Robert Dempsey. Use at your own peril.
This script works with Python 3.x
NOTE: replace values in ALL CAPS with your own values
@congzhangzh
congzhangzh / set_route.py
Created March 3, 2018 04:44 — forked from ihciah/set_route.py
Set route script for tinc on windows
#!/bin/python
# -*- coding: utf-8 -*-
# I found the interface id is not a fixed value...
import subprocess
INTERFACE = "tincvpn"
ROUTE = "route add 10.0.0.0 mask 255.0.0.0 192.168.102.199 metric 1 if %s"
def get_interface_id():
interfaces = subprocess.check_output("netsh int ipv4 show interfaces")