Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@alessioalex
alessioalex / debug-events.js
Last active June 2, 2023 17:08
intercept *.addEventListener for debugging
// http://stackoverflow.com/questions/4787698/failure-to-override-elements-addeventlistener-in-firefox
(function() {
Error.stackTraceLimit = Infinity;
var _interfaces = Object.getOwnPropertyNames(window).filter(function(i) {
return /^HTML/.test(i);
}).map(function(i) {
return window[i];
});
@alessioalex
alessioalex / domtokenlist.js
Created October 22, 2021 19:17 — forked from ShirtlessKirk/domtokenlist.js
DOMTokenList polyfill for IE < 9; implements element.classList
/**
* Polyfill of DOMTokenList for IE < 9
* Monkey patch of .add, .remove for IE 10 / 11, Firefox < 26 to support multiple arguments
* Monkey patch of .toggle for IE 10 / 11, Firefox < 24 to support second argument
*/
/*global define: false, module: false */
/*jslint nomen: true */
(function domTokenListModule(global, definition) { // non-exporting module magic dance
'use strict';
@alessioalex
alessioalex / index.html
Created August 22, 2021 22:10
Multiple docs opened in parallel // source https://jsbin.com/xogirokofe
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Multiple docs opened in parallel</title>
<style id="jsbin-css">
html, body, .container {
height: 100%;
}
@alessioalex
alessioalex / htmldiff.js
Created January 31, 2021 16:11 — forked from bcks/htmldiff.js
htmldiff
(function() {
var Match, calculate_operations, consecutive_where, create_index, diff, find_match, find_matching_blocks, html_to_tokens, is_end_of_tag, is_start_of_tag, is_tag, is_whitespace, isnt_tag, op_map, recursively_find_matching_blocks, render_operations, wrap;
is_end_of_tag = function(char) {
return char === '>';
};
is_start_of_tag = function(char) {
return char === '<';
};
@alessioalex
alessioalex / heavy-computation.js
Created November 22, 2014 09:04
heavy-computation.js
// TODO: in a single threaded JavaScript world (both in the browser and Node)
// how would you make the displaySum non-blocking?
var displaySum = function outputSumOfEvenNumbers(stopAt) {
var sum = 0;
for (var i = 0; i < stopAt; i++) {
if (i % 2 === 0) {
sum += i;
}
@alessioalex
alessioalex / gist:1339202
Created November 4, 2011 12:11
PHP get real IP
function get_real_ip()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
@alessioalex
alessioalex / request post node.js
Created November 12, 2011 19:19
request post node.js
var request = require('request'), default_headers, site_root = 'http://localhost:3000';;
default_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
// 'Connection': 'keep-alive',
'Cache-Control': 'max-age=0'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<pre id='display-panel'></pre>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<h3>Check your console to see the output, press F12 and go to the console tab.</h3>
@alessioalex
alessioalex / index.html
Created February 7, 2019 11:51
JS Bin example1 // source https://jsbin.com/kuhukal
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="example1">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<h3>Check your console to see the output, press F12 and go to the console tab.</h3>