Skip to content

Instantly share code, notes, and snippets.

@inodb
inodb / string-format.js
Created February 25, 2016 23:13 — forked from poxip/string-format.js
Python-like string format in JavaScript
/**
* Python-like string format function
* @param {String} str - Template string.
* @param {Object} data - Data to insert strings from.
* @returns {String}
*/
var format = function(str, data) {
var re = /{([^{}]+)}/g;
return str.replace(/{([^{}]+)}/g, function(match, val) {
@inodb
inodb / gbgrep
Created November 5, 2015 23:14 — forked from nas/gbgrep
git blame with grep
#!/usr/bin/env ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
puts "\n-----------------------------------------------------------"
puts "GREP RESULT"
puts '-----------------------------------------------------------'
puts grep
files = grep.scan /.*\:\d+/