Skip to content

Instantly share code, notes, and snippets.

@mushtat
mushtat / index.js
Created April 25, 2016 08:38
Worker-timer
function factory(root){
if (root === root.window && root.URL && root.Blob && root.Worker) {
return (function() {
var TIMER_WORKER_SOURCE = [
"var timerIds = {}, _ = {};",
"_.setInterval = function(args) {",
" timerIds[args.timerId] = setInterval(function() { postMessage(args.timerId); }, args.delay);",
"};",
"_.clearInterval = function(args) {",
" clearInterval(timerIds[args.timerId]);",
@mushtat
mushtat / quotes.json
Created October 16, 2015 14:27
Top 100 Forbes quotation list in json
["Life is about making an impact, not making an income. \n–Kevin Kruse", "Whatever the mind of man can conceive and believe, it can achieve. \n–Napoleon Hill", "Strive not to be a success, but rather to be of value. \n–Albert Einstein", "Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference. \n–Robert Frost", "I attribute my success to this: I never gave or took any excuse. \n–Florence Nightingale", "You miss 100% of the shots you don’t take. \n–Wayne Gretzky", "I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed. \n–Michael Jordan", "The most difficult thing is the decision to act, the rest is merely tenacity. \n–Amelia Earhart", "Every strike brings me closer to the next home run. \n–Babe Ruth", "Definiteness of purpose is the starting point of all achievement. \n–W. Clement Stone", "Lif
@mushtat
mushtat / des.js
Last active August 27, 2015 09:49
DES module for Google's Crypto JS
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
module.exports = exports = factory(require("crypto-js/core"), require("crypto-js/enc-base64"), require("crypto-js/md5"), require("crypto-js/evpkdf"), require("crypto-js/cipher-core"));
}
else if (typeof define === "function" && define.amd) {
// AMD
define(["crypto-js/core", "crypto-js/enc-base64", "crypto-js/md5", "crypto-js/evpkdf", "crypto-js/cipher-core"], factory);
}
else {
@mushtat
mushtat / gist:dc0f8923e99d304d2777
Last active August 29, 2015 14:23
Detect all window properties that was added after script run
'use strict';
// ES6 Object.assign
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
if (!Object.assign) {
Object.defineProperty(Object, 'assign', {
enumerable: false,
configurable: true,
writable: true,
value: function(target) {
@mushtat
mushtat / gist:35589ff98987481384ad
Last active March 24, 2016 13:29
Ruby simple web-server with webrick
require 'webrick'
config = {
'port' => 3002
}
server = WEBrick::HTTPServer.new({:Port => config['port']})
server.mount_proc '/' do |request, response|