Skip to content

Instantly share code, notes, and snippets.

@guy-a
guy-a / detect-private-browsing.js
Created March 22, 2016 00:16 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@guy-a
guy-a / Canary_CORS.bat
Last active January 14, 2016 21:15
Windows batch to open a separate session of CANARY where the same-origin-policy is disabled. Great for testing.
start "" "c:\Users\%USERNAME%\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --user-data-dir="c:/_canary_dev" --disable-web-security
@guy-a
guy-a / Chrome_CORS.bat
Last active September 19, 2022 06:30
Windows batch to open a separate session of chrome where the same-origin-policy is disabled. Great for testing.
start "" "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="c:/_chrome_dev" --disable-web-security
@guy-a
guy-a / leacher.py
Created May 3, 2015 22:22
A python script for leeching a folder on an FTP. run$ python supervisor.py leacher.py
import os
import logging
import ftplib
from ftplib import FTP
class Leacher:
def __init__(self, host, account, passwd, ftp_folder='', local_folder_path='', delete_files='False', file_match=''):
logging.basicConfig(filename='leacher.log', format='%(asctime)s - %(levelname)s: %(message)s', level=logging.DEBUG)
@guy-a
guy-a / toFixed.js
Last active May 2, 2018 07:34
To Fix Javascript toFixed
/* https://blog.guya.net/2012/08/18/to-fix-javascript-tofixed/
https://stackoverflow.com/a/11818658/275333 */
function toFixed(num, fixed) {
var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
return num.toString().match(re)[0];
}