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 / README.md
Last active August 7, 2016 10:30
Testing ES6 features in io.js

node --harmony --harmony_classes --harmony_proxies --harmony_arrow_functions --harmony_object_literals io1

@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];
@Comandeer
Comandeer / document_write.js
Last active July 23, 2016 19:38
Better document.write
( function( doc ) {
'use strict';
var createFragment = ( function( template ) {
// http://stackoverflow.com/a/25214113
if ( template ) {
return function( html ) {
var elem = document.createElement( 'template' );
elem.innerHTML = html;
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;