Skip to content

Instantly share code, notes, and snippets.

View sairion's full-sized avatar
⚛️

Jaeho Lee (Jay) sairion

⚛️
View GitHub Profile
@sairion
sairion / html_mail_wordpress.php
Created June 25, 2013 14:05
How to send HTML mail via Wordpress.
<?php
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
$headers[] = 'From: Sender of Mail <mail@yourblog.com>';
wp_mail(
$guest_info['guest_email'],
'Title of The Mail',
'<html><body><p>This is the content of the mail<br />
This is the content of the mail. <br /><br />
<strong>another html strong tag test.</strong><br /><br />
@sairion
sairion / remove trailing slashes.php
Created June 27, 2013 03:39
How to remove trailing slashes in WordPress (or PHP)
from
http://fearlessflyer.com/2009/08/getting-rid-of-unwanted-backslashes-in-wordpress-form-input/
<?php
//by using stripslashes_deep, you can dodge trailing slash problems in wp_mail or any kind of form-provided contents
//before PHP 5.3.
if ( get_magic_quotes_gpc() ) {
$_POST = array_map( 'stripslashes_deep', $_POST );
@sairion
sairion / adduser .sh
Created August 17, 2013 10:39
Add existing user into a group using usermod command and -a (append) -G (group) option
usermod -a -G www-data invvvvent
id invvvvent
@sairion
sairion / drop all tables in a database.sh
Created August 18, 2013 13:07
drop all tables in a database (MySql)
#from http://lowendtalk.com/discussion/8203/quick-trick-drop-all-tables-in-mysql-database-in-one-step
mysqldump -u${user} -p${pass} -h ${host} --add-drop-table --no-data ${database} | grep ^DROP | mysql -u${user} -p${pass} -h ${host} ${database}
/*
Magic absolute centering recipe
http://jsfiddle.net/sairion/XhtwU/
*/
div{
background: red;
bottom: 0;
height: 100px;
@sairion
sairion / js_comprehension.js
Last active December 24, 2015 09:09
JavaScript OO concept / using Closures
/**
* Reference: http://pivotallabs.com/javascript-constructors-prototypes-and-the-new-keyword/
* Description: Java-like OO concept implemented in JavaScript.
*/
//init __superclass @Animal as form of JavaScript function.
var Animal = function(){};
//function works as __constructor either. (**has to have same-named function!)
var Animal = function Animal( color ){ this.color = color };
@sairion
sairion / Test Basics
Created October 1, 2013 12:35
Test Basics
Type of testing:
Static testing / Regression testing
"The intent of regression testing is to provide a general assurance that no additional errors were introduced in the process of fixing other problems."
"Regression test is a test that is performed to make sure that previously working functionality still works, after changes elsewhere in the system. Wikipedia article is pretty good at explaining what it is."
@sairion
sairion / SQL Basics.txt
Last active December 24, 2015 09:29
SQL Basics
/* SQL Basics by topics */
*Keys
-Foreign Key, Primary Key,
*Transation
-ACID (Atomicity, Consistency, Isolation, Durability) == "set of properties that guarantee that database transactions are processed reliably." (Wikipedia)
-Commit / Rollback after process
*Concurrency Control (Controlling Concurrent Transaction, interleaving excution of transaction)
@sairion
sairion / curl_in_php.php
Created October 1, 2013 14:39
Using curl in PHP
<?php
$c = curl_init('http://google.com');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
//curl_setopt(... other options you want...)
$html = curl_exec($c);
if (curl_error($c)){ die(curl_error($c)); }
// Get the status code
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
@sairion
sairion / Javascript_good_parts.js
Last active December 24, 2015 09:49
Javascript_good_parts.js
/*
* default function param value
*/
var getOuterWidth = function(Elem, Width, Padding){
//assigning default value
Width = Width || 0;
Padding = Padding || 0;
//...
}