Skip to content

Instantly share code, notes, and snippets.

@ricardoriogo
ricardoriogo / convertPolyToPath.js
Created April 14, 2014 16:13
Convert SVG polygon element to path element.
var polys = document.querySelectorAll('polygon,polyline');
[].forEach.call(polys,convertPolyToPath);
function convertPolyToPath(poly){
var svgNS = poly.ownerSVGElement.namespaceURI;
var path = document.createElementNS(svgNS,'path');
var points = poly.getAttribute('points').split(/\s+|,/);
var x0=points.shift(), y0=points.shift();
var pathdata = 'M'+x0+','+y0+'L'+points.join(' ');
if (poly.tagName=='polygon') pathdata+='z';
@tommysundstrom
tommysundstrom / sitemap.xml.builder
Last active September 5, 2025 05:28
Middleman xml sitemap (to aid Google and other search engines)
# encoding: utf-8
xml.instruct!
# Drop this file in your source directory
#
# Uses the builder gem.
# Add
# gem 'builder', '~> 2.0'
# to the Gemfile, and run builder install
#
@bluefuton
bluefuton / .bash_profile
Last active October 8, 2015 14:48
Include current Git or Subversion branch name in terminal prompt
parse_git_branch () {
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then git branch | sed -n '/\* /s///p'; fi | awk '{print " ["$1"]" }'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk '{print " ["$1"]" }'
}
parse_svn_url() {
svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
parse_svn_repository_root() {
@bluefuton
bluefuton / gist:2916321
Last active October 6, 2015 01:58
Start Sublime Text from the terminal
# Add to your .bash_profile
# Check the name of your Sublime app in /Applications (can include version number)
alias sub='open -a "Sublime Text"'
# Source: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=1450
@lg0
lg0 / markdown.xml
Created April 10, 2012 19:58
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
@bluefuton
bluefuton / gist:2204364
Created March 26, 2012 10:35
Create an archive of the changed files between two Subversion revisions, preserving directory structure
# Based upon http://serverfault.com/a/49324
tar -cf archive.tar `svn diff -r 542:HEAD --summarize | grep -v "^D" | awk '{print $2}' | grep -vw "."`
@jambu
jambu / gmail-scrollbars.css
Created March 9, 2012 02:17 — forked from Cifro/gmail-scrollbars.css
New Gmail like scrollbars for webkit browsers
/* Gmail style scrollbar */
::-webkit-scrollbar {
width: 12px
}
::-webkit-scrollbar-thumb {
border-width: 1px 1px 1px 2px
}
::-webkit-scrollbar-track {
border-width: 0
}
@siffring
siffring / .htaccess
Created March 4, 2012 17:33
htaccess to password protect a specific server
# ----------------------------------------------------------------------
# Password protect staging server
# Use one .htaccess file across multiple environments
# (e.g. local, dev, staging, production)
# but only password protect a specific environment.
# ----------------------------------------------------------------------
SetEnvIf Host staging.domain.com passreq
AuthType Basic
AuthName "Password Required"
@bluefuton
bluefuton / gist:1468061
Created December 12, 2011 16:15
OS X: replace tabs with spaces in all files using expand
find . -name "*.php" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done
@artero
artero / launch_sublime_from_terminal.markdown
Last active March 10, 2026 11:29 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation