Skip to content

Instantly share code, notes, and snippets.

View ttsvetko's full-sized avatar
:octocat:
Working from home

Tsvetan Tsvetkov ttsvetko

:octocat:
Working from home
View GitHub Profile
@ttsvetko
ttsvetko / translate.js
Last active December 15, 2015 08:59 — forked from mgechev/translate.js
var translate = (function () {
var symbols = {
a: '([]+![])[+!+[]]',
b: '([]+{})[+!+[]+!+[]]',
c: '([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]',
d: '([]+[][+[]])[+!+[]+!+[]]',
e: '([]+[][+[]])[+!+[]+!+[]+!+[]]',
f: '([]+[][+[]])[+!+[]+!+[]+!+[]+!+[]]',
g: '([]+([]+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+[][+!+[]])[+!+[]]+([]+![])[+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+!![])[+!+[]]+([]+!![])[+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+!![])[+!+[]]])[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]',
h: '(+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+([]+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+[][+!+[]])[+!+[]]+([]+![])[+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+!![])[+!+[]]+([]+!![])[+!+[]+!+[]]
@ttsvetko
ttsvetko / onbeforeunload
Created June 9, 2013 07:22
Simple 'onbeforeunload' multiple handler. It assigned a basic function to 'onbeforeunload' method of window object and provide ability to attache multiple functions to be called when 'onbeforeunload' event is called.
(function (win) {
var funcArr = [],
isFunction = function (value) { return (value && (value).constructor === Function); },
isString = function (value) {return (value && (value).constructor === String); };
win.onbeforeunload = function() {
var func,
result;
while (func = funcArr.shift()) {
if (func && isFunction(func)) {
result = func();
@ttsvetko
ttsvetko / chrome_extension_test.js
Created March 21, 2014 15:27
Code running inside chrome extension check
(function () {
var isChrome = (function () {
var contentWindow,
iframe = document.createElement("iframe"),
isChrome;
if ("sandbox" in iframe) {
try {
iframe.sandbox = "allow-same-origin";
iframe.src='/';
iframe.style="display: none";
@ttsvetko
ttsvetko / disable_js_console.js
Created April 26, 2014 11:48
Disable the User’s JavaScript Console
// It appears Netflix is following (Facebook's lead)[https://news.ycombinator.com/item?id=7222129].
(function() {
try {
var $_console$$ = console;
Object.defineProperty(window, "console", {
get: function() {
if ($_console$$._commandLineAPI)
throw "Sorry, for security reasons, the script console is deactivated on netflix.com";
return $_console$$
@ttsvetko
ttsvetko / index.html
Created November 19, 2015 15:54 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/kepemu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.progressbar {
height: 20px;
line-height: 20px;
width: 100px;
function setWeatherIcon(condid) {
var icon = '';
switch(condid) {
case '0': icon = 'wi-tornado';
break;
case '1': icon = 'wi-storm-showers';
break;
case '2': icon = 'wi-tornado';
break;
case '3': icon = 'wi-thunderstorm';
@ttsvetko
ttsvetko / gist:e4da6abb8ae2b81b5e4a
Created February 5, 2016 12:39 — forked from ericchen/gist:1000225
Yahoo Weather Condition Codes
<?xml version="1.0" encoding="UTF-8"?>
<yahoo-weather-codes>
<code number="0" description="tornado"/>
<code number="1" description="tropical storm"/>
<code number="2" description="hurricane"/>
<code number="3" description="severe thunderstorms"/>
<code number="4" description="thunderstorms"/>
<code number="5" description="mixed rain and snow"/>
<code number="6" description="mixed rain and sleet"/>
<code number="7" description="mixed snow and sleet"/>
@ttsvetko
ttsvetko / console_wrapper1.js
Created November 21, 2016 18:49 — forked from edmore/console_wrapper1.js
Paul Irish
// usage: log('inside coolFunc',this,arguments);
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
@ttsvetko
ttsvetko / index.html
Created November 22, 2016 09:21
Inline Web Worker
<html>
<head>
<script type="javascript/worker">
postMessage('Worker is ready...');
onmessage = function(e) {
if (e.data === 'start') {
//simulate heavy work..
var max = 500000000;
for (var i = 0; i < max; i++) {
function setWeatherIcon(condid) {
var icon = '';
switch(condid) {
case '0': icon = 'wi-tornado';
break;
case '1': icon = 'wi-storm-showers';
break;
case '2': icon = 'wi-tornado';
break;
case '3': icon = 'wi-thunderstorm';