Skip to content

Instantly share code, notes, and snippets.

Avatar
♨️
Missing Zsófia 👧🏼🇭🇺

Glenn Dwiyatcita dwiyatci

♨️
Missing Zsófia 👧🏼🇭🇺
View GitHub Profile
@dwiyatci
dwiyatci / kfc.de-face.js
Created Apr 24, 2014
A monkey script for halal-ing chickens in KFC Deutschland. Just for fun! No offense to the muslim brotherhood. :'p
View kfc.de-face.js
// ==UserScript==
// @name kfc.de-face
// @creator Glenn Dwiyatcita
// @namespace https://gist.github.com/dwiyatci
// @description A monkey script for halal-ing chickens in KFC Deutschland. Just for fun! No offense to the muslim brotherhood. :'p
// @include http://www.kfc.de/faq
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
@dwiyatci
dwiyatci / anticollision-kletternmonkey-2.x.js
Created Jul 8, 2015
An anti-collision Kletternmonkey 🙈
View anticollision-kletternmonkey-2.x.js
// ==UserScript==
// @name anticollision-kletternmonkey
// @namespace localhost
// @description My take on "#MoneyTree - das Kletterduell" campaign by O2 (May-July 2015).
// Just for fun (topping myself in the top ten), and not for
// intentionally winning the contest and/or the "Hauptpreis" -
// Schwedenreise für zwei im Design-Baumhaus (Gesamtwert 3.000 €).
//
// This should also be a case study showing how bad it is when a JS
// programmer carelessly pollutes the global namespace. =)
View Do Harlem Shake
javascript:void function()%7B(function()%7Bfunction e()%7Bvar e%3Ddocument.createElement("link")%3Be.setAttribute("type","text/css"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",T),e.setAttribute("class",A),document.body.appendChild(e)%7Dfunction t()%7Bfor(var e%3Ddocument.getElementsByClassName(A),t%3D0%3Bt<e.length%3Bt%2B%2B)document.body.removeChild(e%5Bt%5D)%7Dfunction n()%7Bvar e%3Ddocument.createElement("div")%3Be.setAttribute("class",C),document.body.appendChild(e),setTimeout(function()%7Bdocument.body.removeChild(e)%7D,100)%7Dfunction o(e)%7Breturn%7Bheight:e.offsetHeight,width:e.offsetWidth%7D%7Dfunction a(e)%7Bvar t%3Do(e)%3Breturn t.height>p%26%26t.height<b%26%26t.width>w%26%26t.width<v%7Dfunction r(e)%7Bfor(var t%3De,n%3D0%3Bt%3B)n%2B%3Dt.offsetTop,t%3Dt.offsetParent%3Breturn n%7Dfunction i()%7Bvar e%3Ddocument.documentElement%3Breturn window.innerWidth%3Fwindow.innerHeight:e%26%26!isNaN(e.clientHeight)%3Fe.clientHeight:0%7Dfunction s()%7Breturn window.pageYOffset%3Fwindow.pageYOffset:
@dwiyatci
dwiyatci / favor-factory.js
Last active Nov 10, 2016
Favoring factory pattern over constructor pattern in JavaScript
View favor-factory.js
//////////// constructor pattern
function Employee() {
this.name = '';
this.salary = 0; // no real encapsulation of private property
}
// too much code noises and bugs-prone from `prototype` and `this`
Employee.prototype.getSalary = function () {
@dwiyatci
dwiyatci / xgen-and-gen.js
Last active Apr 17, 2020
function* is not a gen.
View xgen-and-gen.js
function* xcounter() {
let index = 0;
while (true) {
index += 1;
const x = yield index;
console.log(x);
}
}
const xgen = xcounter();
@dwiyatci
dwiyatci / faketimers-polling-workaround.js
Last active Nov 30, 2020
Jest Timers and Promises in polling.
View faketimers-polling-workaround.js
jest.useFakeTimers();
const pollingPromise = poll();
const cancelAdvance = advanceTimersContinuously();
const status = await pollingPromise;
cancelAdvance();
expect(status).toEqual('COMPLETE');
function advanceTimersContinuously() {
You can’t perform that action at this time.