I hereby claim:
- I am davidgarsan on github.
- I am davidgarsan (https://keybase.io/davidgarsan) on keybase.
- I have a public key whose fingerprint is DD0B 6620 AB30 D2CB 1E47 7206 F7B7 2F6E 08CC 0955
To claim this, I am signing this object:
var time = new Date().getTime(); | |
var interval = 1000; | |
(function update() { | |
requestAnimationFrame(update); | |
var now = new Date().getTime(), | |
delta = now - (time || now); | |
if(delta>=interval) { | |
// Update a "time ago"|"time left" or do something... | |
console.log((new Date(now)).getSeconds()); |
package com.emil.android.util; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.telephony.TelephonyManager; | |
/** | |
* Check device's network connectivity and speed | |
* @author emil http://stackoverflow.com/users/220710/emil |
I hereby claim:
To claim this, I am signing this object:
image: node:argon | |
before_script: | |
- apt-get -qq update | |
- apt-get -qq install -y python2.7 python2.7-dev build-essential make gcc g++ libicu-dev | |
- npm -g install npm --silent | |
- "echo -e \"export default {CLIENT_ID: '$CLIENT_ID'}\" > app/scripts/settings.js" | |
- npm set progress=false | |
- npm install --silent |
<head> | |
<base href="/"> | |
<!--[if IE]><script type="text/javascript"> | |
// Fix for IE ignoring relative base tags. | |
// See http://stackoverflow.com/questions/3926197/html-base-tag-and-local-folder-path-with-internet-explorer | |
(function() { | |
var baseTag = document.getElementsByTagName('base')[0]; | |
baseTag.href = baseTag.href; | |
})(); | |
</script><![endif]--> |
/** | |
* @desc Returns a template function builder. | |
* @param template - template string. | |
* @param params - Substitution params. | |
* @return {function} - Template function. | |
* | |
* @example | |
* var template = buildTemplate("Hello, my name is ${params}"); | |
* template('David'); // Hello, my name is David | |
* |
var xhr = function() { | |
var xhr = new XMLHttpRequest(); | |
var mapper = function(data) { | |
return Object.keys(data).map(function(k) { | |
return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) | |
}).join('&'); | |
}; | |
return function(method, url, data, success, error, isJSON, headers) { | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === 4) { |
function spyObjectProperty(obj, key) { | |
var val = obj[key]; | |
Object.defineProperty(obj, key, { | |
get() { | |
return val; | |
}, | |
set(newVal) { | |
val = newVal; | |
console.log(key + ' is now ' + val); |
function attributeChangeDetector(element, callback) { | |
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (mutation.type == 'attributes') { | |
console.log('Attribute ' + mutation.attributeName + ' changed'); | |
!!callback && callback(mutation); | |
} | |
}); |
var memoizeNewValue = function() { | |
var old = null; | |
return function(newVal){ | |
if(newVal === old) { | |
return false; | |
} else { | |
old = newVal; | |
return true; | |
} | |
} |