Skip to content

Instantly share code, notes, and snippets.

@ZJONSSON
ZJONSSON / force_labels.js
Last active May 18, 2023 08:52
Automatic floating labels using d3 force-layout
(function() {
d3.force_labels = function force_labels() {
var labels = d3.layout.force();
// Update the position of the anchor based on the center of bounding box
function updateAnchor() {
if (!labels.selection) return;
labels.selection.each(function(d) {
var bbox = this.getBBox(),
x = bbox.x + bbox.width / 2,
@nas
nas / gbgrep
Created May 20, 2011 18:19
git blame with grep
#!/usr/local/bin/ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
puts "\n-----------------------------------------------------------"
puts "GREP RESULT"
puts '-----------------------------------------------------------'
puts grep
files = grep.scan /.*\:\d+/
@teramako
teramako / bartab-integration.js
Created April 26, 2010 13:32
BarTab integration - Vimperator Plugin
/*
* BarTab integration - Vimperator Plugin
*
* Commands:
* :tap tap the current tab
* :tap # tap the previous seleced tab
* :tap {num}:? tap the {num}-th tab
* :tap! tap all tabs without the current tab
*
* Tab Completion is available !!