Skip to content

Instantly share code, notes, and snippets.

Hello World!

Hi girvan

Hello World!
  • US
View GitHub Profile
girvan / disable_adsense.php
Created Apr 30, 2020
disable adsense on 404 pages in wordpress
View disable_adsense.php
add_filter('widget_text', function( $content ) {
$adsense = 'src="//"';
if ( is_404() ) {
$content = str_replace( $adsense, '', $content );
return $content;
}, 1 );
girvan / promise-sequence.js
Created Jan 10, 2020
run promise / task in sequence
View promise-sequence.js
var tasks = [
function(resolve) {
return setTimeout(function() {
}, 300);
function(resolve) {
return setTimeout(function() {
View workers_proxy.js
addEventListener('fetch', event => {
async function handleRequest(request) {
const url = request.url + (request.url.indexOf('?')===-1 ? '?' : '&')
const hook1Response = await fetch(url + 'workers_proxy_get=1', request)
girvan / detect-browser.js
Created Oct 25, 2019
detect browser and append classname on html element
View detect-browser.js
var m = ua.match(/(msie|firefox|edge)/);
if(m) document.documentElement.className += m[1];
girvan / bs4-navbar-toggler.js
Last active Oct 24, 2019
[bootstrap-4] pure js for burger icon of navbar toggler
View bs4-navbar-toggler.js
document.querySelector('.navbar-toggler').addEventListener('click', function(){
girvan / cloudflare.html
Created Jun 27, 2019
track cloudflare's edge location by using GA event
View cloudflare.html
var request = new XMLHttpRequest();'GET', '/cdn-cgi/trace', true);
request.onload = function() {
if (request.status != 200) return;
var match = request.responseText.match(/(colo|loc)=(\w+)/g),
colo = match[0].split('=')[1], loc = match[1].split('=')[1];
ga('send', 'event', 'cloudflare', loc, colo);
girvan / gist:f2c1755abc7f5409eb3bd756611cb2e5
Last active Mar 27, 2019
Exclude some file paths in git file changes
View gist:f2c1755abc7f5409eb3bd756611cb2e5
document.querySelectorAll("#toc li").forEach(function(li, idx){
if(li.innerText.indexOf('/SOME-PATH-YOU-WANT-TO-EXCLUDE/') === -1)
var id = li.querySelector('a').href.split('#')[1];
var block = document.querySelector('a[name=' + id + ']').nextElementSibling;
cd ~/tmp/
for i in {1..500000}; do
time1=$(curl -o /dev/null -s -w %{time_total} $url1)
time2=$(curl -o /dev/null -s -w %{time_total} $url2)
girvan / ga_patch.js
Created Dec 7, 2016
Fix Google Analytics tracking
View ga_patch.js
setup: paste before ga('send', 'pageview');
- fix * to Organic
- fix Line and WeChat Apps to Social
(function(r, M, S){
girvan / country-code-to-currency-code-mapping.csv
Last active Aug 31, 2016 — forked from HarishChaudhari/country-code-to-currency-code-mapping.csv
Country, Country Code, Currency code mapping in CSV format Taken from Contains 249 countries.
View country-code-to-currency-code-mapping.csv
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
You can’t perform that action at this time.