Skip to content

Instantly share code, notes, and snippets.

View phamquocbuu's full-sized avatar
💻

Buu Pham phamquocbuu

💻
View GitHub Profile
@phamquocbuu
phamquocbuu / gist:15c54796846b18cd1e30de9478d56a70
Created July 2, 2020 02:00 — forked from viktorkelemen/gist:2575598
Reload the active tab in Chrome with AppleScript
tell application "Google Chrome"
reload active tab of window 1
end tell
@phamquocbuu
phamquocbuu / README.js
Created May 13, 2020 14:47
Getting all query string values from a URL with vanilla JavaScript - https://gomakethings.com/getting-all-query-string-values-from-a-url-with-vanilla-js/
// Get parameters from the current URL
getParams(window.location.href);
// Get parameters from a URL string
var url = 'https://gomakethings.com?sandwhich=chicken%20salad&bread=wheat';
getParams(url);
@phamquocbuu
phamquocbuu / short-number-format.php
Created May 12, 2020 08:10 — forked from RadGH/short-number-format.php
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@phamquocbuu
phamquocbuu / massInsertOrUpdate.php
Created May 9, 2020 03:55 — forked from RuGa/massInsertOrUpdate.php
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@phamquocbuu
phamquocbuu / space-tab.txt
Created May 8, 2020 07:43
tìm các khoảng trắng, tab liên tục
(\(\'.*)([\ \t]+)(.*\'\))
@phamquocbuu
phamquocbuu / fcm.token-info.tugo-web.demo.php
Created April 25, 2020 14:04
Xem token này đã subscribe những topic nào
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://iid.googleapis.com/iid/info/DEVICE_TOKEN?details=true",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://iid.googleapis.com/iid/v1/DEVICE_TOKEN/rel/topics/TOPIC_NAME",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
@phamquocbuu
phamquocbuu / fcm.send.tugo-web.demo.php
Created April 25, 2020 13:52
Gửi Notification qua FCM (Firebase Cloud Message) - tới topic TUGO_ALL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://fcm.googleapis.com/fcm/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
@phamquocbuu
phamquocbuu / add-custom-field.md
Created November 19, 2019 07:43
Case when then for custom field in Google Data Studio
CASE 
    WHEN age_pax<20 then "<19"
        WHEN age_pax<30 then "20-30"
WHEN age_pax<35 then "30-34"
WHEN age_pax<40 then "35-39"
WHEN age_pax<45 then "40-44"
WHEN age_pax<50 then "45-49"
WHEN age_pax<55 then "50-54"
 ELSE "&gt;=55" 
$("select :selected").map(function (i, element) { return jQuery(element).text(); }).get();