Skip to content

Instantly share code, notes, and snippets.

View psodaz's full-sized avatar
🎯
Focusing

PORNCHAI SODA psodaz

🎯
Focusing
  • Thailand
  • 06:06 (UTC +07:00)
View GitHub Profile
@psodaz
psodaz / Android_CN.sh
Created September 6, 2021 07:26 — forked from chenyiping1995/Android_CN.sh
Changes the NTP server and Captive Portal Server for Chinese users.
# Settings to the NTP server since Android 4.0
adb -d shell settings put global ntp_server time.pool.aliyun.com
# Android 4.2 - 6.0.1
adb -d shell settings put global captive_portal_detection_enabled 1
adb -d shell settings put global captive_portal_server www.google.cn
# Android 7.0 - 7.1
adb -d shell settings put global captive_portal_detection_enabled 1
adb -d shell settings put global captive_portal_use_https 1
@psodaz
psodaz / osx_ramdisk.sh
Created August 12, 2020 11:04 — forked from jnschulze/osx_ramdisk.sh
Move Chrome, Safari and iTunes Cache to Ramdisk.
#!/bin/bash
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
CACHEDIR="/Volumes/RamDiskCache/$USER"
# GET VERSION
yarn -v (or --version)
# GET HELP
yarn help
# CREATE PACKAGE.JSON
yarn init
yarn init -y // Use defaults
@psodaz
psodaz / beautiful_idiomatic_python.md
Created May 9, 2019 05:48 — forked from 0x4D31/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@psodaz
psodaz / pkl_to_json.py
Created December 21, 2018 08:48 — forked from hailiang-wang/pkl_to_json.py
Convert python pickle file to json
#!/usr/local/bin/python3
'''
Convert a pkl file into json file
'''
import sys
import os
import _pickle as pickle
import json
@psodaz
psodaz / detect.py
Created October 22, 2018 07:13 — forked from Lukse/detect.py
Advanced OpenCV 3 python hole detection
import cv2
import sys
import numpy as np
camera = cv2.VideoCapture("video.avi")
# Setup BlobDetector
detector = cv2.SimpleBlobDetector_create()
params = cv2.SimpleBlobDetector_Params()
A partial list of these Vendor ID Codes:
0x014F - Transcend Information
0x2C00—Micron Technology, Inc.
0x802C—Micron Technology, Inc.
0x80AD—Hynix Semiconductor Inc.
0x80CE—Samsung Electronics, Inc.
0xAD00—Hynix Semiconductor Inc.
0xCE00—Samsung Electronics, Inc.
My system has memory made by 0x802C and 0x80CE. One came with the system, the other came from Crucial.
@psodaz
psodaz / check_shadowsocks.sh
Created August 18, 2018 19:39 — forked from meanevo/check_shadowsocks.sh
Scripts for OpenWrt to bypass the gfw in mainland china, using ipset for gfwlist and geoip for ips outside specified region. (two ss-redir instances)
# FILE_LOCATION: /usr/bin/check_shadowsocks.sh
# DESCRIPTION: Script for checking whether shadowsocks-libev is running, and if not, restart it.
# <!-- ORIGINAL_CONTENTS_BELOW -->
#!/bin/sh
ss_pid_path="/var/run/ss-redir.pid"
ss_port={SS1_PORT}
ss2_pid_path="/var/run/ss-redir-whitelist.pid"
ss2_port={SS2_PORT}
if [ -f $ss_pid_path ] && [ -f $ss2_pid_path ]; then
@psodaz
psodaz / add-remove-windows-path.ps1
Created May 10, 2018 02:47 — forked from drazul/add-remove-windows-path.ps1
Example to add and remove local-path to system-path-variable on Windows. Without the limitations of 1024 characters
#------------ Add path to system variable -------------------------------------
$path2add = ';C:\path;'
$systemPath = [Environment]::GetEnvironmentVariable('Path', 'machine');
If (!$systemPath.contains($path2add)) {
$systemPath += $path2add
$systemPath = $systemPath -join ';'
[Environment]::SetEnvironmentVariable('Path', $systemPath, 'Machine');
write-host "Added to path!"
@psodaz
psodaz / NoStockSearch.txt
Created April 23, 2018 05:29 — forked from jonkratz/NoStockSearch.txt
Google search images hack to avoid stock images. Paste after search term to see only valid results. Please feel free to add pull requests!
-fotolia.com -graphicleftovers.com -bigstockphoto.com -vectorstock.com -depositphotos.com -fotosearch.com -stockfresh.com -thinkstockphotos.com -istockphoto.com -123rf.com -dreamstime.com -shutterstock.com -canstockphoto.com -cutcaster.com -dondrup.com -colourbox.com