Skip to content

Instantly share code, notes, and snippets.

View weird-coon's full-sized avatar
🦝
Surprise!

Quyen Luu weird-coon

🦝
Surprise!
View GitHub Profile
@weird-coon
weird-coon / strip_tags.sql
Last active June 14, 2018 08:11
[MySQL] Reproduces PHP strip_tags () with Mysql and search keywords from the result of excluding HTML tags.
DELIMITER //
DROP FUNCTION IF EXISTS `STRIP_TAGS`//
CREATE FUNCTION STRIP_TAGS( x text) RETURNS text
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA
BEGIN
DECLARE sstart INT;
DECLARE ends INT;
IF x IS NOT NULL THEN
SET sstart = LOCATE('<', x, 1);
@weird-coon
weird-coon / japan_pref.php
Last active June 8, 2018 03:46
[PHP] Japanese pref ids and names
<?php
$pref_ids = array(
'01' => '北海道', '02' => '青森県', '03' => '岩手県', '04' => '宮城県', '05' => '秋田県',
'06' => '山形県', '07' => '福島県', '08' => '茨城県', '09' => '栃木県', '10' => '群馬県',
'11' => '埼玉県', '12' => '千葉県', '13' => '東京都', '14' => '神奈川県', '15' => '新潟県',
'16' => '富山県', '17' => '石川県', '18' => '福井県', '19' => '山梨県', '20' => '長野県',
'21' => '岐阜県', '22' => '静岡県', '23' => '愛知県', '24' => '三重県', '25' => '滋賀県',
'26' => '京都府', '27' => '大阪府', '28' => '兵庫県', '29' => '奈良県', '30' => '和歌山県',
'31' => '鳥取県', '32' => '島根県', '33' => '岡山県', '34' => '広島県', '35' => '山口県',
'36' => '徳島県', '37' => '香川県', '38' => '愛媛県', '39' => '高知県', '40' => '福岡県',
@weird-coon
weird-coon / padNumber.php
Last active June 8, 2018 03:46
[PHP] Add zero before number
<?php
/**
* Padding a time on the left format time 1 -> 01
*
* @access private
* @param string $num 時間
* @return string time after format
*/
public function addZeroBeforeNumber($num) {
return sprintf('%02d', $num);
@weird-coon
weird-coon / validateDate.php
Last active June 8, 2018 03:46
[PHP] Validate date PHP function with date format. Return true if valid date and other side.
<?php
/**
* Valid datetime format
*
* @param string $date
* @param string $format
* @return bool
*/
private function validate_date($date, $format = 'Y/m/d')
{
@weird-coon
weird-coon / http_statuses.php
Last active June 8, 2018 03:45
[PHP] Array of HTTP response status codes and messages
<?php
/**
* @var array An array of status codes and messages
*
* See http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
* for the complete and approved list, and links to the RFC's that define them
*/
public static $statuses = array(
100 => 'Continue',
101 => 'Switching Protocols',
@weird-coon
weird-coon / redirect_back.js
Created June 8, 2018 03:45
[JS] Redirect to previous page
/**
* Redirect to previous page
*
* @returns {boolean}
*/
function redirect_back() {
// From other domain or from direct
if (document.referrer.split('/')[2] != location.hostname) {
location.href = '/';
} else {

Here there are some examples of git commands that I use often.

Not all commands written here are git commands, but all of them are related to git. Please refer to the documentation for more details.

Set your details

git config --global user.name "John Doe"
git config --global user.email "john@example.com"

Use --global to set the configuration for all projects. If git config is used without --global and run inside a project directory, the settings are set for the specific project.

@weird-coon
weird-coon / backToTop.js
Created June 26, 2018 03:22
Simple Jquery smoothie back to top button
// Back to top function
$('#top').click(function() {
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
@weird-coon
weird-coon / media-query.css
Created August 7, 2018 04:57 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@weird-coon
weird-coon / url.md
Created August 16, 2018 02:28
Japanese character bug

Notes

Khi làm việc với URL có chứa kí tự tiếng Nhật Để tránh lỗi trên IE

  1. Encode URL
  2. Decode tại server