Skip to content

Instantly share code, notes, and snippets.

@midu
midu / gist:948939
Created April 29, 2011 20:06
JavaScript Tip of the Day
var counter = 0;
var n_calls = function () {
console.log("This function was called ", ++counter, " times");
};
n_calls(); // This function was called 1 times
n_calls(); // This function was called 2 times
n_calls(); // This function was called 3 times
@midu
midu / lol.html
Created May 3, 2011 17:47
Browsers Randomness
<!-- Embedding flash -->
<!--
Let's say you want to include a youtube video.
The classic code is something like that:
-->
<object width="560" height="349">
<param name="movie" value="https://www.youtube-nocookie.com/v/QFCSXr6qnv4?fs=1&hl=en_US&rel=0"></param>
<param name="allowFullScreen" value="true"></param>
@midu
midu / lol.js
Created May 12, 2011 19:28
Best bookmarklet
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){nb_lols=0;midu=null;
$(document).ready(function(){$.fn.makeColor=function(){colors=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];color="#";for(i=0;i<6;)j=Math.floor(Math.random()*15),color+=colors[j],i+=1;return color};$.fn.makeP=function(){return p=$("<p></p>").css("color",$.fn.makeColor()).css("display","inline-block").css("font-weight","bold").css("padding","3px").css("position","fixed").css("z-index","1500")};$.fn.makeLol=function(){lol=$.fn.makeP();lol.html("lol").css("font-size",Math.floor(Math.random()*
20)+30+"px").css("left","-5%");return lol};$.fn.
@midu
midu / LICENSE.txt
Created June 9, 2011 21:18 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
127.0.0.1 home.dev
127.0.0.1 platform.dev
127.0.0.1 challenges.dev
127.0.0.1 challengepostcom.platform.dev
127.0.0.1 challengegov.platform.dev
127.0.0.1 freethetvchallengecom.platform.dev
127.0.0.1 bigappideas.challenges.dev
127.0.0.1 lollacom.challenges.dev
127.0.0.1 presidentcom.challenges.dev
@midu
midu / gist:1242766
Created September 26, 2011 17:15
youtube iframe embed code, IE9 error
<iframe width="615" height="375" src="http://www.youtube.com/embed/QH2-TGUlwu4?rel=0&amp;wmode=opaque" frameborder="0" allowfullscreen></iframe>
<!-- throws:
SCRIPT16385: Not implemented
www-embed_core_module-vfl_M4tJV.js, line 115 character 248
!>
(function($){
var current,
rnamespaces = /\.(.*)$/,
returnFalse = function(){return false},
returnTrue = function(){return true};
/**
* @function
@midu
midu / no-console.log.sh
Created November 8, 2011 21:05
pre-commit git hook to prevent console.log in javascript files
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='console.log'
git diff --cached --name-only | grep -E $FILES_PATTERN | GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo 'COMMIT REJECTED Found "console.log" references in your javascript. Please remove them before commiting';
# my zsh does annoying things with !
[ $? -ne 0 ]
@midu
midu / platform.access.log
Created November 22, 2011 00:09
nginx access logs
127.0.0.1 - - [21/Nov/2011:17:36:13 -0500] "DELETE /manage/groups/110/tags/130 HTTP/1.1" 302 140 "http://platform.dev/manage/groups/110" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.938.0 Safari/535.8" "-"
127.0.0.1 - - [21/Nov/2011:17:36:14 -0500] "DELETE /manage/groups/110 HTTP/1.1" 302 140 "http://platform.dev/manage/groups/110" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.938.0 Safari/535.8" "-"
127.0.0.1 - - [21/Nov/2011:17:36:15 -0500] "DELETE /manage/groups/109 HTTP/1.1" 503 5 "http://platform.dev/manage/groups/110" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.938.0 Safari/535.8" "-"
if (window.location.hash.match(/#notes/)) {
$('#tb-note span.ir').click();
}