Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1></h1>
</body>
/*
* 判斷按下的按鈕是哪一個
* @param (event) e keypress event.
* @param (mix) targetKeyChar 按鍵的編號或名稱,如果是這個按鍵,就執行 callback
* @param (function) callBack 送入callback的function,不用加()括號
*
*/
var detectKeyPress = function(e, targetKeyChar, callBack){
var keynum
@cesarkohl
cesarkohl / mysqli_connect.php
Created February 25, 2015 00:39
mysqli connect
$mysqli = new mysqli('localhost', 'root', 'root', 'register');
if ($mysqli->connect_error) {
die('Connect Error ('.$mysqli->connect_errno.')'.$mysqli->connect_error);
}else{
//printf ( 'Connect succeeded: %s', $mysqli->host_info );
}
@cesarkohl
cesarkohl / php_show_errors.php
Created February 25, 2015 23:03
php show errors
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
@cesarkohl
cesarkohl / codeigniter-pagination-with-get
Created March 16, 2015 16:21
CodeIgniter Pagination URL with GET Parameters
// http://subhra.me/codeigniter-pagination-url-get-parameters/
if (count($_GET) > 0) $config['suffix'] = '?' . http_build_query($_GET, '', "&");
$config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
@cesarkohl
cesarkohl / mysql-myisam-to-innodb
Last active August 29, 2015 14:21
MySQL - MyISAM to InnoDB
// Run this SQL statement (in the mysql client, phpMyAdmin, or wherever) to retrieve all the MyISAM tables in your database.
// Replace value of the name_of_your_db variable with your database name.
// Then, copy the output and run as a new SQL query.
SET @DATABASE_NAME = 'name_of_your_db';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
@cesarkohl
cesarkohl / current-url
Created June 7, 2015 20:13
Raw PHP to get current URL
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$actual_page = $_SERVER[REQUEST_URI];
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
@cesarkohl
cesarkohl / youtube-pause.js
Last active January 17, 2018 19:06 — forked from cferdinandi/stop-video.js
Youtube Pause Video
var youtube_video = $('iframe');
var url = youtube_video.attr('src'); // 1. First get the iframe URL
youtube_video.attr('src', ''); // 2. Then assign the src to null, this then stops the video been playing
youtube_video.attr('src', url); // If you need to reassign the URL back to your iframe, so when you hide and load it again you still have the link
@cesarkohl
cesarkohl / html-center-items
Last active September 11, 2015 12:51
HTML center items
.center-items { overflow: auto; list-style-type: none; text-align: center; }
.center-items .item { display: inline-block; vertical-align: top; }
<div class="center-items">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>