Skip to content

Instantly share code, notes, and snippets.

View congzhangzh's full-sized avatar
🎯
Focusing

Cong Zhang congzhangzh

🎯
Focusing
View GitHub Profile
# -*- 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 / CMakeLists.txt
Created July 24, 2018 14:46 — forked from DavidHamburg/CMakeLists.txt
cmake c++/cli
cmake_minimum_required(VERSION 3.5)
project(myproject)
set(SOURCE_FILES src/main.cpp)
add_executable(myproject ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6")
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DOTNET_REFERENCES "System")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/clr /EHa")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
@congzhangzh
congzhangzh / set_ipsec_tun.sh
Last active November 9, 2019 12:53 — forked from vishvananda/tunnel.sh
A script setup an ip sec tunnel to a server and use server as default route, this in fact create a security vpn which is very fast and NAT friendly which work for both NAT behind host. All the input parameter need be set in file which mark as input section!!!
#!/bin/bash
#
# the basic idea from https://gist.github.com/vishvananda/7094676
#
# if [ "$4" == "" ]; then
# echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
# echo "creates an ipsec tunnel between two machines"
# exit 1
@richkilmer
richkilmer / vmrun
Created November 5, 2010 17:30
vmrun is a command you can execute to externally script vmware fusion VMs
/Library/Application\ Support/VMware\ Fusion/vmrun
vmrun version 3.1.1 build-282344
Usage: vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]
AUTHENTICATION-FLAGS
--------------------
@ihciah
ihciah / set_route.py
Last active February 13, 2020 12:53
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")
@cdroulers
cdroulers / trx-to-junit.xslt
Last active February 28, 2020 14:52
Transform dotnet test output (TRX) to jUnit format for CI purposes.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a ="http://microsoft.com/schemas/VisualStudio/TeamTest/2006" xmlns:b ="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" >
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<testsuites>
<xsl:variable name="buildName" select="//a:TestRun/@name"/>
<xsl:variable name="numberOfTests" select="count(//a:UnitTestResult/@testId) + count(//b:UnitTestResult/@testId)"/>
<xsl:variable name="numberOfFailures" select="count(//a:UnitTestResult/@outcome[.='Failed']) + count(//b:UnitTestResult/@outcome[.='Failed'])" />
<xsl:variable name="numberOfErrors" select="count(//a:UnitTestResult[not(@outcome)]) + count(//b:UnitTestResult[not(@outcome)])" />
<xsl:variable name="numberSkipped" select="count(//a:UnitTestResult/@outcome[.!='Passed' and .!='Failed']) + count(//b:UnitTestResult/@outcome[.!='Passed' and .!='Failed'])" />
@mottosso
mottosso / README.md
Last active May 27, 2020 07:16
QObject list-model with factory function
@rdempsey
rdempsey / python_3_email_with_attachment.py
Created December 6, 2014 21:30
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
@PonyMaLoveJackMa
PonyMaLoveJackMa / netboot.sh
Last active October 30, 2020 01:57 — forked from AndersonIncorp/netboot.xyz.md
Install netboot.xyz.lkrn into grub
apt install wget -y
wget https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn -O /netboot.xyz.lkrn
cat >> /etc/grub.d/40_custom <<EOF
#/etc/grub.d/40_custom
menuentry "netboot.xyz.lkrn" {
linux16 (hd0,msdos1)/netboot.xyz.lkrn # /boot is (hd0,msdos1) drive
}
EOF
grub2-mkconfig -o /boot/grub2/grub.cfg
grub-mkconfig -o /boot/grub/grub.cfg