Skip to content

Instantly share code, notes, and snippets.

🤒
Out sick

Chenny Du duchenpaul

Block or report user

Report or block duchenpaul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@duchenpaul
duchenpaul / file_split.py
Created Apr 2, 2019
Split csv into X line, with or without header
View file_split.py
import os
def split(filehandler, delimiter=',', row_limit=1000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
import csv
reader = csv.reader(filehandler, delimiter=delimiter)
current_piece = 1
current_out_path = os.path.join(
output_path,
View nwqs_data_extract.py
import json
import sqlparse
import xmltodict
from pprint import pprint
def xml2dict(xmlString):
'''Return json object'''
jsonString = json.dumps(xmltodict.parse(xmlString), indent=4)
xml_in_dict = json.loads(jsonString)
@duchenpaul
duchenpaul / robot_click.py
Created Jan 6, 2019
A very simple program which clicks back forward
View robot_click.py
import time
import pyautogui
print('ready')
time.sleep(3)
print('start')
for i in range(30):
pyautogui.click(1689,444)
time.sleep(.5)
View vim_powerline.sh
sudo pip install git+git://github.com/powerline/powerline
wget https://github.com/powerline/powerline/blob/develop/font/PowerlineSymbols.otf?raw=true -O PowerlineSymbols.otf
sudo mv PowerlineSymbols.otf /usr/share/fonts/
fc-cache -vf /usr/share/fonts/
wget https://raw.githubusercontent.com/powerline/powerline/develop/font/10-powerline-symbols.conf
sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/
echo "set rtp+=/usr/lib/python2.7/site-packages/powerline/bindings/vim/" >> ~/.vimrc
echo "set laststatus=2" >> ~/.vimrc
echo "set t_Co=256" >> ~/.vimrc
View port_forward_using_SSH.md
  1. Open putty
  2. Set host name: hostname.onedumb.com, port: 203
  3. In category, go to Connection->SSH->Tunnels, set Source port: 1433, Destination: sqlhost:1433
  4. Click Add button
  5. Click open, login as: pi password: 1qazxsw2
  6. It should be connected to the server, keep it in hte background
  7. Open SQLServer client
  8. Servername: 127.0.0.1
  9. Login: SA
  10. Password: passWORD
View initialize_unix_profile.md
  • Add sudoer
# Config editor
sudo update-alternatives --config editor

#add user to sudoer
vi /etc/sudoers (visudo)

## Allow root to run any commands anywhere
@duchenpaul
duchenpaul / win_path2wsl_path.py
Created Nov 5, 2018
Convert windows path to wsl path
View win_path2wsl_path.py
'''Convert windows path to wsl path'''
windows_path = r'''C:\Users\chdu\Desktop\Portal\Management\Google Cloud Training'''
MOUNT_PATH = '/mnt'
windows_path_split = windows_path.split(':\\')
diskLabel, path = windows_path_split[0].lower(), windows_path_split[1].replace('\\', r'''/''').replace(' ', r'''\ ''')
wsl_path = '/'.join((MOUNT_PATH, diskLabel, path))
View data_group.py
def cluster(data, maxgap):
'''Arrange data into groups where successive elements
differ by no more than *maxgap*
>>> cluster([1, 6, 9, 100, 102, 105, 109, 134, 139], maxgap=10)
[[1, 6, 9], [100, 102, 105, 109], [134, 139]]
>>> cluster([1, 6, 9, 99, 100, 102, 105, 134, 139, 141], maxgap=10)
[[1, 6, 9], [99, 100, 102, 105], [134, 139, 141]]
@duchenpaul
duchenpaul / caffeine.vbs
Last active Aug 1, 2018
A simple vbs to prevent your PC from policy screen lock
View caffeine.vbs
Dim objResult
Set objShell = WScript.CreateObject("WScript.Shell")
Do While True
Wscript.Sleep(3000)
objResult = objShell.sendkeys("{SCROLLLOCK}")
Wscript.Sleep(100)
objResult = objShell.sendkeys("{SCROLLLOCK}")
Wscript.Sleep(100)
@duchenpaul
duchenpaul / VDI Recovery checklist.md
Last active Mar 18, 2019
VDI Recovery checklist
View VDI Recovery checklist.md

Suggest print with scale 150% - 200%

  • DB tools:

    • DBeaver
      • Import projects
        • Carters
  • Software:

    • Chrome
      • config
You can’t perform that action at this time.