Skip to content

Instantly share code, notes, and snippets.

View hieuhuynh93's full-sized avatar
💭
I may be slow to respond.

Hieu Huynh hieuhuynh93

💭
I may be slow to respond.
View GitHub Profile
<?php
function check_isMobile() {
$is_mobile = '0';
if(preg_match('/(android|iphone|ipad|up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT'])))
$is_mobile=1;
if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']))))
$is_mobile=1;
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
$mobile_agents = array('w3c ','acs-','alav','alca','amoi','andr','audi','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno','ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-','maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','oper','palm','pana','pant','phil','play','port','prox','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','up
@hieuhuynh93
hieuhuynh93 / openssl_encrypt_decrypt.php
Created June 21, 2018 07:17 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@hieuhuynh93
hieuhuynh93 / anti.js
Created October 4, 2018 03:06
Anti ctrl+u, viewsource, f12
checkCtrl=false $(&#39;*&#39;).keydown(function(e){
if(e.keyCode==&#39;17&#39;){ checkCtrl=false } }).keyup(function(ev){
if(ev.keyCode==&#39;17&#39;){ checkCtrl=false } }).keydown(function(event){
if(checkCtrl){
if(event.keyCode==&#39;85&#39;){ return false; } } })
@hieuhuynh93
hieuhuynh93 / medium-unclap.js
Created January 8, 2019 16:11
Unclap everything on Medium
/**
* Unclaps everything on Medium
* @author Jane Manchun Wong
*/
(async () => {
if ( window.location.host !== 'medium.com' ) {
console.error(`This script won't work unless you go to Medium:\nhttps://medium.com/me`)
return
}
/**
@hieuhuynh93
hieuhuynh93 / function.php
Created May 23, 2019 06:40 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@hieuhuynh93
hieuhuynh93 / class.envato2.php
Created May 30, 2019 10:23 — forked from dtbaker/class.envato2.php
Using the verify-purchase endpoint of the new Envato API to validate a purchase code.
<?php
// NOTE: verify-purchase has been deprecated and it's best to use the new /author/sale endpoint as documented on http://build.envato.com/
// created by Envato user wpdreams https://forums.envato.com/t/verify-purchase-class/3526
// usage example:
$o = EnvatoApi2::verifyPurchase( $purchase_code );
@hieuhuynh93
hieuhuynh93 / media-query.css
Created July 25, 2019 07:48 — 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
### Keybase proof
I hereby claim:
* I am hieuhuynh93 on github.
* I am hieuhuynh (https://keybase.io/hieuhuynh) on keybase.
* I have a public key ASC7XfUn0kcEARAzaNeh-1wh9yyAhrXsN7jutAhoJEaOAgo
To claim this, I am signing this object:
@hieuhuynh93
hieuhuynh93 / VnMobilePhoneRegEx.md
Created December 28, 2019 10:38 — forked from yetanotherdev267/VnMobilePhoneRegEx.md
Vietnamese Mobile Phone Regex Test

Vietnamese Mobile Phone Regex Test

JavaScript

var regEx = /^0(1\d{9}|9\d{8})$/;
var phone = '0912345678';
var match = regEx.test(phone);
@hieuhuynh93
hieuhuynh93 / Common-Currency.json
Created January 20, 2020 04:28 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},