Skip to content

Instantly share code, notes, and snippets.

jQuery(".entry-meta>a:eq(1)").before('<span class="show-conversation"> + </span>');
jQuery("span.show-conversation").live('click', function(){var show=jQuery(this),status=show.parents('.status').eq(0),target=show.next('a').attr('href');
jQuery.get(target, function(data){var body=jQuery(data);var author=body.find('a.screen-name');body=body.find('span.status-body');body.find('span.status-content').prepend(']').prepend(author).prepend('[');body.css({borderTop: "1px solid #EEEEEE", padding: "5px"});body.find(".entry-meta>a:eq(1)").before('<span class="show-conversation"> + </span>');status.prepend(body.parent().html());});});
@clochix
clochix / fortunes.txt
Created December 1, 2010 23:50
Misc sentences that should go to a fortune file
Source: http://theoks.net/blog/2008/04/25/funny-quips/
* BSD is for people who love UNIX. Linux is for those who hate Microsoft.
* “XML is like violence: if it doesn’t solve your problem, you aren’t using enough of it.” – Chris Maden
* UNIX is user friendly, it just picks its friends carefully.
* Our OS who art in CPU, UNIX be thy name. Thy programs run, thy syscalls done, In kernel as it is in user!
* UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. – Dennis Ritchie
* “Black holes are where God divided by zero.”
* How to make COBOL a great language? Remove “OBOL”.
* How to make COBOL a great language? Select “COBO” then Type “Per”.
@clochix
clochix / spelledit.sh
Created August 9, 2011 23:03
Detect spelllang when answering a message with mutt
# I usually get french and english emails, and would like to auto-detect the language
# to set the spellchecker when answering.
# (I use mutt and vim)
# In .muttrc:
set editor = 'bash ~/bin/spelledit.sh'
# and my ~/bin/spelledit.sh
vim + -c "setlocal spell spelllang=$([ `cat $1 | aspell -l en list | sort -u | wc -l` -lt `cat $1 | aspell -l fr list | sort -u | wc -l` ] && echo "en" || echo "fr") encoding=utf-8" $1
# Yes, this is dirty: I call aspell twice on the file,
# counting the number of bad words in french and english,
# and set spelllang to the lang with the less bad words
@clochix
clochix / gist:2818840
Created May 28, 2012 12:15
Bookmarklet to display proposed short links for a page
javascript:Array.prototype.forEach.call(document.querySelectorAll('link[rel=shortlink]'),function(e){window.alert(e.getAttribute('href'));})
@clochix
clochix / gist:2867857
Created June 4, 2012 11:32
Customize responsive mode presets in Firefox devtools
/**
* USE AT YOUR OWN RISK !!!
*
* In about:config set devtools.chrome.enabled to true;
* Open the Scratchpad, select Environment / Browser and run this script
*
* DON'T forget to then switch back Environment to Content and devtools.chrome.enabled to false
*
* @see http://mxr.mozilla.org/mozilla-central/source/browser/devtools/responsivedesign/responsivedesign.jsm#39
*/
@clochix
clochix / gist:2895977
Created June 8, 2012 14:42
Microdata exploration
var items = document.getItems();
if (items.length > 0) {
Array.prototype.forEach.call(items, function (elmt) {
console.log(elmt);
console.log(elmt.itemId, elmt.itemProp.value, elmt.itemRef.value, elmt.itemType.value, elmt.itemValue);
Array.prototype.forEach.call(elmt.properties, function (prop) {
console.log(' ⇒ ' + prop.itemProp.value + ' : ' + (prop.content || prop.itemValue), prop);
})
})
}
@clochix
clochix / RDFa in header's meta
Created June 18, 2012 16:13
Sample semantic markup to add the url of a bugtracker to a Web page
<html lang="fr" >
<head prefix="doap: http://usefulinc.com/ns/doap#">
<title>Saisis un ticket ! Oussa ???</title>
<meta charset="utf-8" />
<meta name="description" content="Esquisses, brouillons et notes en vrac d'un apprenti geek intéressé par la liberté" />
<meta name="author" content="Clochix" />
<meta property="doap:bug-database" content="https://github.com/clochix/esquisses/issues">
</head>
<body>
(…)
@clochix
clochix / gist:2959831
Created June 20, 2012 13:12
Commit in the past
# commit file toto 12 hours ago
GIT_COMMITTER_DATE="`date -R --date='12 hours ago'`" bash -c 'git commit --date "$GIT_COMMITTER_DATE" foo'
@clochix
clochix / sandbox.js
Created October 10, 2012 08:27
JavaScript Sandbox
// Clone an object
// @see https://developer.mozilla.org/en-US/docs/Differential_inheritance_in_JavaScript
Object.prototype.clone = function(){
// Extract the prototype from the "this" object
var p = Object.getPrototypeOf(this);
// Create a new object with p as its prototype
return Object.create(p);
};
@clochix
clochix / xpath.js
Created October 12, 2012 12:17
Sample XPath to get node by it's content
// Get a node whose content starts with (optional spaces) "Doing"
// Available functions : https://developer.mozilla.org/en-US/docs/XPath/Functions
// (regex with matches are not available, XPath 2.0, only normalized still 2007 :S )
evaluation = document.evaluate("//*[starts-with(normalize-space(.), 'Doing')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
evaluation = document.evaluate("//h2[contains(., 'part')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue