Skip to content

Instantly share code, notes, and snippets.

View yehchge's full-sized avatar
:octocat:
Working from office

yehchge yehchge

:octocat:
Working from office
View GitHub Profile
@yehchge
yehchge / php_log.php
Created August 7, 2023 03:01
php simple log
<?php
$sLogPath = dirname(__FILE__) ."/mylog.log";
$rFile = fopen( $sLogPath, "a" );
$sErrorMsg = "Error Message:".$msg." @at ".date("Y-m-d H:i:s")."\n";
fwrite($rFile, $sErrorMsg);
fclose($rFile);
@yehchge
yehchge / dynamicDisplay.html
Created July 21, 2023 07:46
動態在網頁上顯示數字
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Number Display</title>
</head>
<body>
<div id="numberDisplay"></div>
<script>
var count = 1;
@yehchge
yehchge / wordforword.html
Created July 21, 2023 07:44
逐字顯示
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
window.onload=function(){
var story = document.getElementById('word');
var s = document.getElementById('show');
var i = 0;
@yehchge
yehchge / array_merge.php
Created July 20, 2023 08:21
array merge
<?php
/**
* 將陣列合併, 如果有相同的值, 後面的值會覆蓋前面的值
* @param array &$array1 [description]
* @param array &$array2 [description]
* @return [type] [description]
*/
function array_merge_recursive_distinct (array &$array1, array &$array2){
$merged = $array1;
@yehchge
yehchge / .bash_prompt
Created July 22, 2022 02:44 — forked from diegodurs/.bash_prompt
Bash Prompt
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@yehchge
yehchge / .bashrc
Created July 22, 2022 02:37 — forked from duese/.bashrc
Colored prompt with git-prompt enabled
# to get a git prompt:
source /usr/share/git/completion/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
#GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWCOLORHINTS=true
# colorize bash prompt
# see also http://misc.flogisoft.com/bash/tip_colors_and_formatting
#PS1='[\u@\h \W]\$ ' # To leave the default one
@yehchge
yehchge / .prompt
Created July 22, 2022 02:32 — forked from heyitsolivia/.prompt
.prompt
# git prompt
# from http://gist.github.com/47364
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "⚡"
}
function git_prompt {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\e[1;33m\]\W\[\e[1;36m\]$(git_prompt)\[\e[1;33m\]$\[\e[m\] '
@yehchge
yehchge / linux prompt bashrc 2
Created July 22, 2022 02:24
linux prompt bashrc 2
function __repository_name() {
toplevel="$(git rev-parse --show-toplevel 2> /dev/null)"
if [ -n "$toplevel" ]; then
printf "$(basename $toplevel)"
fi
}
function __branch_name() {
name="$(git symbolic-ref --short HEAD 2> /dev/null)"
if [ "$name" = 'master' -o "$name" = 'main' -o "$name" = 'develop' ]; then
@yehchge
yehchge / Linux Prompt bashrc
Created July 22, 2022 02:18
Linux Prompt bashrc
# Color schema for prompt
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35
@yehchge
yehchge / is_json.php
Created February 8, 2022 07:34
php is_json value
<?php
function is_json($json_string = "")
{
return is_string($json_string) &&
is_array(json_decode($json_string, true)) &&
(json_last_error() == JSON_ERROR_NONE) ? true : false;
}