Skip to content

Instantly share code, notes, and snippets.

View aravindbaskaran's full-sized avatar

Aravind aravindbaskaran

View GitHub Profile
@vitalyrotari
vitalyrotari / device.js
Created August 2, 2012 12:41
Detect Mobile Devices
var Device = {
ENV_DESKTOP: 'desktop',
ENV_PHONE: 'phone',
ENV_TABLET: 'tablet',
ENV_PORTRAIT: 'portrait',
ENV_LANDSCAPE: 'landscape',
agent: {
mobile: (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(window.navigator.userAgent.toLowerCase())),
tablet: (/ipad|android|android\s3\.0|xoom|sch-i800|playbook|tablet|kindle/i.test(window.navigator.userAgent.toLowerCase()))
},
@fliphess
fliphess / tornado basic auth
Last active February 22, 2020 22:35
basic auth with "htpasswd" file - auth example for tornado webserver
#!/usr/bin/env python
# also check https://gist.github.com/fliphess/7836479
import tornado.ioloop
import tornado.web
import base64
import netaddr
import bcrypt
def require_basic_auth(handler_class):
@cou929
cou929 / detect-private-browsing.js
Last active May 1, 2024 21:07
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);