Skip to content

Instantly share code, notes, and snippets.

View diewland's full-sized avatar
🧩
Jigsaw Fam

diewland.eth diewland

🧩
Jigsaw Fam
View GitHub Profile
@diewland
diewland / preview_random_5_items.py
Last active May 4, 2019 03:51
Preview random 5 items from list
import random
rows = [ 1, 2, 3, ... ] # your list
print([ random.choice(rows) for i in range(5) ])
@diewland
diewland / basic-gmail-accounts.csv
Created April 19, 2019 22:18
Basically Gmail Accounts
Gmail Account Google Drive Space
Main Small
Secondary Very Large
@diewland
diewland / cv2_imread_win.py
Last active March 19, 2019 07:33
cv2 for windows cannot read Thai/unicode image filename, this function resolved this issue.
# https://stackoverflow.com/a/43185606
def cv2_imread_win(img_filepath, np):
stream = open(img_filepath, "rb")
bytes = bytearray(stream.read())
numpyarray = np.asarray(bytes, dtype=np.uint8)
return cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED)
@diewland
diewland / political_party_th.js
Created February 5, 2019 14:36
Javascript Array of พรรคการเมืองไทย 2562
var political_party_th = [
'พรรคประชาธิปัตย์',
'พรรคประชากรไทย',
'พรรคมหาชน',
'พรรคกสิกรไทย',
'พรรคเพื่อฟ้าดิน',
'พรรคความหวังใหม่',
'พรรคเครือข่ายชาวนาแห่งประเทศไทย',
'พรรคเพื่อไทย',
'พรรคเพื่อแผ่นดิน',
@diewland
diewland / to_grayscale.py
Created January 16, 2019 10:30
Convert image to grayscale
from PIL import Image
def to_grayscale(source, dest):
img = Image.open(source)
img = img.convert('L') # grayscale
img.save(dest, quality=100)
@diewland
diewland / months_th.js
Last active August 2, 2023 07:39
Thai Month Array in Javascript
var months_th = [ "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม", ];
var months_th_mini = [ "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.", ];
// done
@diewland
diewland / user_profile.cmd
Created December 26, 2018 17:30
Cmder, set default working dir ( ./config/user_profile.cmd )
:: use this file to run your own startup commands
:: use in front of the command to prevent printing the command
:: uncomment this to have the ssh agent load when cmder starts
:: call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd" /k exit
:: uncomment the next two lines to use pageant as the ssh authentication agent
:: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
:: call "%GIT_INSTALL_ROOT%/cmd/start-ssh-pageant.cmd"
@diewland
diewland / my_for_each.js
Created November 12, 2018 08:57
Custom forEach by yourself
// https://stackoverflow.com/a/52501856/466693
Array.prototype.myForEach = function(callback){
this.forEach(function(r, i){
console.log('>>>', arguments);
callback(r, i);
});
};
@diewland
diewland / default
Last active April 29, 2020 18:12 — forked from ColeMurray/default
my nginx config example
server {
listen 80;
server_name YOUR_SERVERS_IP_ADDRESS;
location ~ ^/(js/|img/|css/) {
root /path/to/public/static/;
access_log off;
expires 24h;
}
location / {
@diewland
diewland / MainActivity.java
Created August 30, 2018 02:56
Eddystone URL Demo
/*
https://github.com/adriancretu/beacons-android
*/
package com.diewland.fake_beacons;
import android.app.Activity;
import android.os.Bundle;
import com.uriio.beacons.Beacons;
import com.uriio.beacons.model.EddystoneURL;
public class MainActivity extends Activity {