Skip to content

Instantly share code, notes, and snippets.

View FGRibreau's full-sized avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile
//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 July 30, 2010 16:18
The Inception code :)
function dream(lvl){
return lvl == -4 ? 'Inception done' : dream(--lvl);
}
dream(0);
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 July 30, 2010 17:01
How to detect if $ == jQuery
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
if(!function_exists('apc_exists')){
function apc_exists($keys){
$r;
apc_fetch($keys,$r);
return $r;
}
}
$('#el').AttributeObserver(attr, callback, [delay]);
@FGRibreau
FGRibreau / jQuery iFrame.js
Created November 30, 2010 07:18
jQuery iFrame
//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')
@FGRibreau
FGRibreau / The simple way.js
Created November 30, 2010 07:31
The simple way
$('#myIframe').contents().find('body #myElement').data('test', 'hello world');
//Will return {}
$('#myIframe').contents().find('body #myElement').data();
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 March 2, 2011 11:20
Faire fonctionner PeerGuardian2 sur Mac
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