Skip to content

Instantly share code, notes, and snippets.

View Comandeer's full-sized avatar
:octocat:
JavaScripting

Tomasz Jakut Comandeer

:octocat:
JavaScripting
View GitHub Profile
@Comandeer
Comandeer / popup.js
Created July 11, 2014 20:37
Gemius style popup
(function()
{
var fn = function fn()
{
window.open('test.php', 'intruder', 'menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=400,height=500');
document.removeEventListener('click',fn);
};
document.addEventListener('click',fn);
@Comandeer
Comandeer / test.html
Last active August 29, 2015 14:04
rAF makeEqual
<!DOCTYPE html>
<html lang="pl" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Ehhhh</title>
<style>
html, body
{
margin: 0;
padding: 0;
@Comandeer
Comandeer / gist:e97b18e34b58e4a2645e
Created January 8, 2015 22:22
Dead simple fireEvent function
function fireEvent(elem, type, data)
{
elem = elem || window;
type = type || 'custom';
data = data || {};
var event = new CustomEvent(type, {detail: data});
elem.dispatchEvent(event);
}
@Comandeer
Comandeer / inception.php
Created February 1, 2015 16:31
Rule of inception
<?php
eval('
eval(\'
eval(\\\'
eval(\\\\\\\'
eval(\\\\\\\\\\\\\\\'
eval(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
eval(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
eval(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
echo "2n + 1";
@Comandeer
Comandeer / polyfill
Created February 26, 2015 20:45
Polymer's polyfill for lacking support for arrays in form.elements. It really sucks.
//it's one of the ugliest hacks I've ever created…
for(var x in this.$)
{
if(!this.$.hasOwnProperty(x) ||x.indexOf('chars') !== 0)
continue;
var tmp = this.$[x];
if(tmp.checked)
range += chars[tmp.value];
var getStyle = function(elem)
{
var output = ''
,getSelector = function(elem)
{
var parent = elem.parentNode
,selector = '';
if(elem.id)
return '#' + elem.id
@Comandeer
Comandeer / inheritance.js
Created July 6, 2015 17:41
Multi inheritance in JS
var A = function()
{
}
,B = function()
{
}
,C = function()
{
/**
* Multiple accordion
* It extends jQuery UI Accordion 1.11.x (Copyright 2015 jQuery Foundation and other contributors)
* Shamely created by Comandeer, released under MIT license
*/
(function($)
{
var _create = $.ui.accordion.prototype._create
,_toggle = $.ui.accordion.prototype._toggle;
@Comandeer
Comandeer / iife.js
Created November 16, 2015 22:55
IIFE example
var isLocalStorageSupported = (function()
{
try
{
localStorage.setItem('test', 'test');
localStorage.removeItem('test');
return true;
}
catch(e)
{
@Comandeer
Comandeer / basicFeatures.md
Created December 6, 2015 19:23
Basic features in various WYSIWYGs