Skip to content

Instantly share code, notes, and snippets.

View tedshd's full-sized avatar

Ted tedshd

View GitHub Profile
@tedshd
tedshd / escape.js
Created September 12, 2013 01:39
escape
util.htmlspecialchars = function (str) {
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
};
util.htmlspecialchars_decode = function (str) {
return str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"");
};
util.nl2br = function (str) {
return str.replace(/\n/g, "<br>");
};
@tedshd
tedshd / vimrc_by_mba
Created January 30, 2014 05:15
vimrc
filetype on
if &diff
filetype plugin off
else
filetype plugin on
endif
set bs=2
set cindent
set history=50
[
{
"keys": ["ctrl+w"],
"command": "run_multiple",
"args": {
"commands": [
{"command": "find_under_expand", "args": null, "context": "window"},
{"command": "show_panel", "args": {"panel": "find"}, "context": "window"}
]
}
# General configuration.
# $ tmux show-options -g
set -g base-index 1
set -g display-time 5000
set -g repeat-time 1000
set -g status-keys vi
set -g status-utf8 on
set -g status-bg black
set -g status-fg white
set -g status-justify left
@tedshd
tedshd / httpd.conf
Created December 17, 2014 06:57
apache config
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
@tedshd
tedshd / ajax.js
Last active August 29, 2015 14:13
Ajax method with javascript
/*global $, jQuery, alert, console, angular*/
/**
*
* @authors Ted Shiu (tedshd@gmail.com)
* @date 2015-01-09 01:23:09
* @version $Id$
*/
/**
* [Ajax basic]
@tedshd
tedshd / 0_reuse_code.js
Last active August 29, 2015 14:14
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
@tedshd
tedshd / polling.js
Last active August 29, 2015 14:17
polling with jquery
var polling,
pollingResponse = true;
polling = setInterval(
function () {
if (pollingResponse) {
console.log('polling');
pollingResponse = false;
$.ajax({
url: 'test.php',
type: 'POST',
@tedshd
tedshd / trim
Last active August 29, 2015 14:19
Trim html
function trimHTMLTagContent(string) {
string = string.replace(/\n/g, '');
string = string.replace(/\s\s/g, '');
// remove two space
string = string.replace(/<font color.*?<\/font>/mig, '');
// remove color font content
string = string.replace(/<[^>]*>/g, '');
// remove html tag
console.log(string);
}
@tedshd
tedshd / Hestia_Google_search
Last active August 29, 2015 14:20
Hestia Google search