Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile
View Firebug chained methods - Usage.js
//Do this only one time !
makeChainable(console, 'assert clear count debug dir dirxml error exception group groupCollapsed groupEnd info log profile profileEnd time timeEnd warn'.split(' '));
//Usage:
console
.profile()
.time('testTime')
.group('GroupTest')
.debug('test', 1, 2, 3)
.warn('warniiing!')
@FGRibreau
FGRibreau / Inception Code.js
Created Jul 30, 2010
The Inception code :)
View Inception Code.js
function dream(lvl){
return lvl == -4 ? 'Inception done' : dream(--lvl);
}
dream(0);
View Non-blocking-error.js
function toBeProfiled(){
console.log(new Error('Show me the stack!'));
//Do something here
}
function launchApp(){
function doThing(){
console.debug(toBeProfiled);
toBeProfiled();
@FGRibreau
FGRibreau / Detect_jQuery.js
Created Jul 30, 2010
How to detect if $ == jQuery
View Detect_jQuery.js
var isjQuery = function($){
return 'fn' in $ && !!$.fn.jquery;
}($);
//My original code: http://twitter.com/FGRibreau/status/19641898644
//piouPioum 2 cents: http://twitter.com/piouPiouM/status/19642960179
View APC_exists.php
if(!function_exists('apc_exists')){
function apc_exists($keys){
$r;
apc_fetch($keys,$r);
return $r;
}
}
View AttributeObserver.Proto.js
$('#el').AttributeObserver(attr, callback, [delay]);
View jQuery iFrame.js
//Find the iframe in the current document
var doc = $('#myIframe').contents()[0];
//Get the iframe's window context
var iFrameWindow = 'defaultView' in doc? doc.defaultView : doc.parentWindow;
//Now we can get jQuery by doing iFrameWindow.$ or iFrameWindow.jQuery
iFrameWindow.$('selector').data('key')
View The simple way.js
$('#myIframe').contents().find('body #myElement').data('test', 'hello world');
//Will return {}
$('#myIframe').contents().find('body #myElement').data();
View strophe.xdomainrequest.js
Strophe.addConnectionPlugin("xdomainrequest", {
init: function() {
if (window.XDomainRequest) {
Strophe.debug("using XdomainRequest for IE");
// override thee send method to fire readystate 2
XDomainRequest.prototype.send = (function(oldSend) {
return function() {
oldsend.apply(this, arguments);
this.readyState = 2;
@FGRibreau
FGRibreau / peerguardian_macos.sh
Created Mar 2, 2011
Faire fonctionner PeerGuardian2 sur Mac
View peerguardian_macos.sh
cd /Applications/
sudo ln -s /Applications/PeerGuardian.app/Contents/Resources/pploader.app PeerGuardian_loader.app
sudo ln -s /Applications/PeerGuardian.app/Contents/Resources/pplogger.app PeerGuardian_logger.app
open PeerGuardian_loader.app
open PeerGuardian_logger.app