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 / no-cache.md
Created November 13, 2018 04:29
Set header no cache

As porneL stated, what you want is not to deactivate the cache, but to deactivate the history buffer. Different browsers have their own subtle ways to disable the history buffer.

In Chrome (v28.0.1500.95 m) we can do this only by Cache-Control: no-store.

In FireFox (v23.0.1) any one of these will work:

  1. Cache-Control: no-store

  2. Cache-Control: no-cache (https only)

  3. Pragma: no-cache (https only)
@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
@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 / 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;
});

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 "[email protected]"

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 / 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 {
@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 / 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 / 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);