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 / gist:02eb0156571818981f7e
Created July 17, 2014 16:34
Echo Message in Web Site.
<div id="msg"></div>
<?php
set_time_limit(0);
if (ob_get_level() == 0) ob_start();
for($i=0;$i<=500;$i++) {
//echo 'I = '.$i."<br>";
//echo str_pad('',4096)."\n";
@yehchge
yehchge / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yehchge
yehchge / example.js
Last active August 29, 2015 14:07 — forked from lukemorton/example.js
// In this example we detect if a user clicks a link to travel elsewhere
// but has made changes to a form. If they have changed the form it prompts
// them to confirm before continuing.
jQuery(function ($) {
var $form = $('form').watchChanges();
$('a').click(function (e) {
if ($form.hasChanged() and ! confirm('Continue without saving changes?')) {
e.preventDefault();
}
@yehchge
yehchge / progress_bar.htm
Last active February 29, 2016 06:51
Javascript 進度條
<html>
<head>
<script type="text/javascript">
var bar_width = 200;
function progress() {
var node = document.getElementById('progress');
var w = node.style.width.match(/\d+/);
if (w == bar_width) {
@yehchge
yehchge / alert.htm
Created February 29, 2016 06:56
自訂Alert視窗
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
#dialogoverlay{
display: none;
opacity: .8;
position: fixed;
top: 0px;
@yehchge
yehchge / htmltobbcode.php
Last active May 4, 2016 09:14
PHP HTML to BBCode
//20160429 HTML To BBCode
public function sHtmlToBbcode($html, $bbcode_uid = 0){
$tags = array(
'#<strong>(.*?)</strong>#si' => '[b]\\1[/b]',
'#<b>(.*?)</b>#si' => '[b]\\1[/b]',
'#<em>(.*?)</em>#si' => '[i]\\1[/i]',
'#<i>(.*?)</i>#si' => '[i]\\1[/i]',
'#<u>(.*?)</u>#si' => '[u]\\1[/u]',
'#<s>(.*?)</s>#si' => '[s]\\1[/s]',
'#<h2>(.*?)</h2>#si' => '[h1]\\1[/h1]',
# status line を更新する間隔を 1 秒にする
set-option -g status-interval 1
# window-status を中央揃えで配置する
set-option -g status-justify "centre"
# status line の背景色を指定する。
set-option -g status-bg "colour238"
# status line の文字色を指定する。
set-window-option -g status-left " #S "
set-window-option -g status-left-fg black
set-window-option -g status-left-bg white
set-window-option -g status-right " %H:%M %d-%b-%y "
set-window-option -g status-right-fg black
set-window-option -g status-right-bg white
set-window-option -g window-status-format " #I: #W "
{
"auto_close_tags": true,
"auto_complete": false,
"auto_indent": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/All Hallow's Eve.tmTheme",
"default_encoding": "UTF-8",
"font_size": 12,
"gutter": true,
@yehchge
yehchge / my_replace.php
Last active November 10, 2016 07:35
重複的關鍵字只替換一次
<?php
// 重複的關鍵字只替換一次
$str = "http://www.school.com/asdf2m/asdf/dd1234acfgesger/asdf/asdf/屁屁";
$a = array('/(AC)/i','/(ac)/i','/(dd1234)/i','/(dd12)/i','/(er)/i','/(屁屁)/i');
echo my_replace($a, $str);
function my_replace($aKeyword, $sString){
$aTmp = preg_replace($aKeyword, "[indent]$1[/indent]" , $sString);
return parseTagsRec($aTmp);