Skip to content

Instantly share code, notes, and snippets.

@ala747
ala747 / detect-private-browsing.js
Last active February 12, 2016 00:33 — 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);
@ala747
ala747 / example.php
Last active August 29, 2015 14:14 — forked from dphiffer/example.php
<?php
// 1. The class name must match the filename (i.e., "foo.php" for JSON_API_Foo_Controller)
// 2. Save this in your themes folder
// 3. Activate your controller under Settings > JSON API
class JSON_API_Example_Controller {
public function get_posts_by_meta_query() {
global $json_api;
function graph(data, w, h, color) {
var canvas = document.createElement('canvas');
var max = 0;
// normalize
var len = data.length, i;
for(i = 0; i < len; ++i) {
max = Math.max(data[i], max);
}
for(i = 0; i < len; ++i) {
# Custom Stopwatch Scope
## As Simple Stopwatch
* Show total session time and lap count
* Show current lap time
* Show last lap time and time diff with previous
* Show best lap, time diff between last and best lap, and average lap time
* Log every session related data locally
* Transmit every session related data to remote server [^2]
* Share live session web page on FB, Twitter [^2]
function format(ms) {
//console.log(t[5])
var d = new Date(ms + t[5]).toString()
.replace(/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/, '$1');
var x = ms % 1000;
d += '.' + addZeros(Math.round(x), 3);
return d;
}
function addZeros(number, digits, place) {
@ala747
ala747 / build.sh
Created December 13, 2012 12:21 — forked from badsyntax/build.sh
#! /usr/bin/env bash
#clone the repo
git clone -q "${1}" "clones/${2}"
cd "clones/${2}"
#update the submodules (how do we handle errors here?)
git submodule --quiet update --init --recursive
#!/bin/bash
#
# Script that checks GitHub's status API before continuing. If GitHub does not return "good" then
# you will be prompted whether you want to continue.
#
# Information messages are echoed to stderr so it is still possible to pipe the results of stdout to
# a file.
#
# Example Usage:
# $ if-github-up make clean
@ala747
ala747 / gist:3832676
Created October 4, 2012 10:01
Creación programática de usuario en WP made simple!
<?php
// Disclaimer: no está probado en las últimas versiones de WP, pero antes se hacía así.
// Para el registro del user volviendo desde Paypal.
require_once( ABSPATH . WPINC . '/registration.php' );
$user_pass = wp_generate_password();
$userdata = array(
@ala747
ala747 / gist:1382103
Created November 21, 2011 09:07
Algoritmo político de España, versión Sinclair Spectrum BASIC
5 OVER 1
10 REM Primero los POKEs, por lo que pudiera pasar
20 REM Vidas infinitas
30 POKE 50437,1
40 REM Dinero infinito
50 POKE 51181,24
60 REM No morir de hambre
70 POKE 60298,201
80 REM Ahora, al tajo
90 LET VIDAS=3
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
<!--
#argh {
margin:20px;
padding:20px;
-moz-border-radius: 10px;