Skip to content

Instantly share code, notes, and snippets.

View dafi's full-sized avatar

Davide Ficano dafi

View GitHub Profile
function getToolbar() {
return document.getElementById('nav-bar') ||
document.getElementById('mail-bar3') || // TB3 must be checked before TB2
document.getElementById('mail-bar2') || // TB2
document.getElementById('mail-bar');
}
// remove empty lines and multiple carriage return/newline
var lines = "1\r\n\n\n\n2\n3\n\n \n\n"
.replace(/^\s*$/mg, '') // remove empty lines
.replace(/[\r\n]+/g, '\n') // all carriage return/newline
.replace(/\n$/, '') // remove newline at end
.split('\n');
@dafi
dafi / GReaderAutoTagger.js
Created January 30, 2011 07:03
Press F2 to add the current google reader entry title to tags
/**
* Author: Davide Ficano https://github.com/dafi
* Greader Auto Tagger from current entry title
* While you are on google reader press F2, the tag input box will open containing the
* current tags for current entry plus the title
*/
javascript:window.addEventListener('keydown', function(event) {
// F2 key
var isValidKey = event.keyCode == 113;
if (!isValidKey) {
@dafi
dafi / miniUrlBlocker.js
Created February 9, 2011 18:05
Firefox mini blocker
var miniUrlBlocker = {
// Lista delle regular expression contenenti le URL da bloccare
blackList : [/http:\/\/www\.badurl\.com/],
observe:function(subject, topic, data) {
if (topic != "http-on-modify-request") {
return;
}
try {
var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
@dafi
dafi / g+barOnTop.js
Created July 13, 2011 06:08
Bookmarklet to put google bar on G+ always visible on top
javascript:(function(){var el=document.querySelector('.a-Eo-T');el.style.position='fixed';el.style.width='100%';})()
@dafi
dafi / extractLiks.js
Created September 13, 2011 06:06
Bookmarklet to extract links from page
var n = document.querySelectorAll('a[href*=fileserve]');
var s = '';
for (var i = 0; i < n.length; i++) {
s += n[i].getAttribute('href') + '\n';
}
var ta = document.createElement('textarea');
ta.setAttribute('rows', '20');
ta.setAttribute('cols', '100');
ta.value = s;
document.body.appendChild(ta);
@dafi
dafi / NSComparisonPredicate+HumanDescriptions.h
Created February 23, 2012 07:04
Category to get the string description for a NSComparisonPredicate
//
// NSComparisonPredicate+HumanDescriptions.h
// VisualDiffer
//
// Created by davide ficano on 13/02/12.
// Copyright (c) 2012 visualdiffer.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@dafi
dafi / RegExpUtils.h
Created May 5, 2012 08:46
Convert a glob string to a valid regular expression string
#import <Foundation/Foundation.h>
@interface RegExpUtils
/**
* Convert a glob string to a valid regular expression string
* strings like "*m" are converted to ".*m"
* Available on OSX 10.7 or above
*/
+ (NSString*)convertGlobMetaCharsToRegexpMetaChars:(NSString*)glob;
@dafi
dafi / crappost.js
Created May 29, 2012 11:51
Remove posts from g+ containing specific words
// ==UserScript==
// @name gplus
// @namespace http://dafi.plus
// @include plus.google.com
// @version 1
// ==/UserScript==
[].forEach.call(document.querySelectorAll('div.jn.gu'), function(e) {
var text = e.firstChild
&& e.firstChild.textContent.toLowerCase();
if (text && (text.indexOf('terremot') != -1)) {
@dafi
dafi / Default.idekeybindings
Created June 17, 2012 15:49
Custom XCode 4.3.x key bindings (Library/Developer/Xcode/UserData/KeyBindings/Default.idekeybindings)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Menu Key Bindings</key>
<dict>
<key>Key Bindings</key>
<array>
<dict>
<key>Action</key>