Skip to content

Instantly share code, notes, and snippets.

View Ivanca's full-sized avatar
💭
Why does github has statuses? Microsoft what the hell is wrong with you?🤦‍♂️

Ivan Ivanca

💭
Why does github has statuses? Microsoft what the hell is wrong with you?🤦‍♂️
View GitHub Profile
@Ivanca
Ivanca / function.sexy_comment.php
Last active October 29, 2023 21:21
A PHP function to generate pretty comments for PHP and Javascript.
<?php
/*----------------------------------------------------------------------
|: :|
|: Sexy comments in your code! :|
|: =========================== :|
|: Hi, my name is Ivan I care about programming, music and women. :|
|: Follow me on twitter: @ivanca :|
|: :|
----------------------------------------------------------------------*/
@Ivanca
Ivanca / gist:4586071
Created January 21, 2013 13:33
Fixing console.log in Twitter.com
console.log = function(){ return console.__proto__.log.apply(console, arguments) } ;
/**************
* Con promesas
**************/
var promise = foo().then(function(){
var promise = new Promise();
asyncFunction(function(){
// It has to know there is no need to merge it to a received object in order to
// do this;
var data = {key1:0x111};
var url = document.location.href;
var cdnFallback = /\bcdn=2/.test(url);
setTimeout(function(){
if( !window.jQuery && !cdnFallback )
document.location += (/\?/.test(url) ? "&" : "?") + "cdn=2";
},400);
if( cdnFallback ){
document.write('<script src="js/jquery-1.8.3.min.js"></scr'+'ipt>');
@Ivanca
Ivanca / IE_detection.js
Created December 17, 2012 00:36
Get Internet Explorer version; or return undefined if it is NOT internet explorer. Modded from james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/ Unfortunately IE10 doesn't accept HTML conditional statements, so we have to use a JS conditional statement.
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
do {
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->';
} while(all[0]);
@Ivanca
Ivanca / New_Bind.js
Created December 16, 2012 04:47
Bind that can be override with other arguments; can be used with call and apply too (mixcall & mixapply)
// New methods for all functions: mixapply, mixcall, and mixbind
// Allows you to force arguments and context even after using .bind
// To skip any argument you can use NULL
// License: Public Domain
(function () {
var __bind = Function.prototype.bind;
var toArray = function (a) {
return Array.prototype.slice.call(a);
};
@Ivanca
Ivanca / gist:4264971
Created December 12, 2012 04:57
Drag and drop functionality for "requirements.txt" files for http://python3wos.appspot.com/ Tested in latest Google Chrome and Firefox-
(function(){
document.addEventListener("drop", function( e ) {
e.preventDefault();
var blob = e.dataTransfer.files[0].slice();
var binaryReader = new FileReader();
$('.req').removeClass('.req');
binaryReader.addEventListener("load", function( file ) {
var notFound = '';
file.target.result.trim().replace(/==.*/g,'').split(/\n/).forEach(function(pack){