Skip to content

Instantly share code, notes, and snippets.

View syneart's full-sized avatar

Jed Hong syneart

View GitHub Profile
@syneart
syneart / PHPDeBugOnOff.sh
Created May 17, 2016 13:04
Turn On or Off php display_errors parameter on Ubuntu (to quick turn on display PHP error messages or not).
#!/bin/bash
DISPLAY_ERRORS_VAL=`grep display_errors.*=.* '/etc/php5/apache2/php.ini'`
clear
echo "Info: 目前 ${DISPLAY_ERRORS_VAL}";
echo "Info: 修改檔案需要權限, 請先輸入密碼 .."
sudo -v
if [ $? -eq 1 ]; then
clear
echo "Error: 未輸入正確密碼, 無法繼續執行"
sleep 3
@syneart
syneart / xargs_kill.sh
Last active November 7, 2020 09:53
with grep result, kill process
# if you want to kill all process with name "inetsim"
ps -aux | grep inetsim | grep -v grep | awk '{print $2}' | sudo xargs kill -9
@syneart
syneart / Shuffle.java
Created February 6, 2015 06:15
小數值打亂程式碼片段 (Android/Java)
int MaxVal = 5; // Max
ArrayList<Integer> list=new ArrayList<Integer>();
for (int i = 1; i <= MaxVal; i++) {
list.add(i);
}
Collections.shuffle(list);
for(Integer result:list) {
Log.e("ValOut", result+""); // Result
}
@syneart
syneart / editTextBox.vb
Created November 16, 2014 12:19
設定指定名稱 TextBox 的屬性
Const n As Integer = 7 'edit this
For i As Integer = 0 To n
DirectCast(Me.Controls("TextBox" & n), System.Windows.Forms.TextBox).Text = 0
Next
@syneart
syneart / Constellation_main.java
Last active March 31, 2016 17:28
星座判斷
public class Constellation_main {
public static void main(String[] args) {
System.out.println(getConstellationFromDate("10/01"));
}
private static String getConstellationFromDate(String strBirthday) {
int intBirthday = Integer.valueOf(strBirthday.replace("/",""));
if (intBirthday < 11 | intBirthday > 1231) {