Skip to content

Instantly share code, notes, and snippets.

⚡️
Hello World!

Hi girvan

⚡️
Hello World!
  • US
Block or report user

Report or block girvan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@girvan
girvan / cloudflare.html
Created Jun 27, 2019
track cloudflare's edge location by using GA event
View cloudflare.html
<script>
(function(){
var request = new XMLHttpRequest();
request.open('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
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)
return;
var id = li.querySelector('a').href.split('#')[1];
var block = document.querySelector('a[name=' + id + ']').nextElementSibling;
block.parentNode.removeChild(block);
li.parentNode.removeChild(li);
});
View testing.sh
cd ~/tmp/
url1=https://...
url2=https://...
url3=https://...
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
girvan / ga_patch.js
Created Dec 7, 2016
Fix Google Analytics tracking
View ga_patch.js
/*
setup: paste before ga('send', 'pageview');
features:
- fix *.search.yahoo.com to Organic
- fix Line and WeChat Apps to Social
*/
(function(r, M, S){
if(r.match(/^https?:\/\/\w+\.search\.yahoo\.com\//))
{ga('set',M,'Organic');ga('set',S,'Yahoo!');return}
@girvan
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 https://gist.github.com/304261 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
View Country Currency Code Mappings
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
View restore-ulimit.sh
if grep -q 32768 /etc/security/limits.conf; then
sudo sed -i -e "/^.*nofile 32768$/d" /etc/security/limits.conf
sudo sed -i -e "/^.*nofile 65536$/d" /etc/security/limits.conf
else
echo skip /etc/security/limits.conf;
fi
if grep -q net.core.somaxconn /etc/sysctl.conf; then
sudo sed -i -e "/^net.core.somaxconn.*$/d" /etc/sysctl.conf
View modify-ulimit.sh
if grep -q 32768 /etc/security/limits.conf; then
echo skip /etc/security/limits.conf;
else
echo "* hard nofile 32768" | sudo tee -a /etc/security/limits.conf
echo "* soft nofile 32768" | sudo tee -a /etc/security/limits.conf
echo "root hard nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "root soft nofile 65536" | sudo tee -a /etc/security/limits.conf
fi
@girvan
girvan / Common-Currency.json
Created Jun 22, 2016 — forked from Fluidbyte/Common-Currency.json
Common Currency Codes in JSON
View Common-Currency.json
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
View gist:645bfc9ab5e00a8bb37c4112fc908c09
240=>'240x320',
480=>'480x800',
540=>'540x960',
720=>'720x1280',
1080=>'1080x1920',
1440=>'1440x2560',
1536=>'1536x2048',
800=>'800x1280',
'wvga'=>'480x640',
'wxga'=>'800x1280',
You can’t perform that action at this time.