Skip to content

Instantly share code, notes, and snippets.

View chiehting's full-sized avatar

Chiehting chiehting

View GitHub Profile
#!/bin/sh
echo $1
patt="^-?[0-9]+$"
if [[ "$1" =~ $patt ]]
then
echo "true"
else
echo "false"
import smtplib
smtp = smtplib.SMTP('smtp.gmail.com', 587)
smtp.ehlo()
smtp.starttls()
smtp.login('login_account','login_password')
smtp.sendmail('no-reply@gmail.com',
'ting911111@gmail.com',
'Subject: Hello World Email!\n\nHi there~')
smtp.quit()
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>st-nexus</id>
<username>${ACCOUNT}</username>
<password>${PASSWORD}</password>
</server>
@chiehting
chiehting / oom-score.sh
Created September 18, 2019 02:55
show high oom_score top 10
#!/bin/bash
for proc in $(find /proc -maxdepth 1 -regex '/proc/[0-9]+'); do
printf "%2d %5d %s\n" \
"$(cat $proc/oom_score)" \
"$(basename $proc)" \
"$(cat $proc/cmdline | tr '\0' ' ' | head -c 50)"
done 2>/dev/null | sort -nr | head -n 10
<?php
// execute command: php insertion-sorting.php 5 0 2 --detail
echo 'selection sorting'.PHP_EOL;
$sort_array = array();
for ($i = 1; $i <= count($argv); $i++){
$value = $argv[$i];
if (preg_match('/^(--)/', $value)) {
$value = substr($value, 2);
$$value = true;
<?php
// execute command: php selection-sorting.php 5 0 2 --detail
echo 'selection sorting'.PHP_EOL;
$sort_array = array();
for ($i = 1; $i <= count($argv); $i++){
$value = $argv[$i];
if (preg_match('/^(--)/', $value)) {
$value = substr($value, 2);
$$value = true;
<?php
// execute command: php bubble-sorting.php 5 0 2
echo 'bubble sorting'.PHP_EOL;
$sort_array = array();
for ($i = 1; $i <= count($argv); $i++){
$value = $argv[$i];
if (preg_match('/^(--)/', $value)) {
$value = substr($value, 2);
$$value = true;
@chiehting
chiehting / img2base64
Created February 24, 2019 15:45
使用python轉換圖片成base64
#!/usr/bin/env python3
from PIL import Image
import base64,io
scale = 0.3
def tobase64(img):
return base64.b64encode(img).decode('ascii')
def imgResize(img, scale=1):