Skip to content

Instantly share code, notes, and snippets.

View codfish's full-sized avatar

Chris O'Donnell codfish

View GitHub Profile
codfish / textRendering.css
Last active December 20, 2015 18:29
Improve text legibility for webkit browsers
View textRendering.css
text-rendering: optimizeLegibility;
codfish /
Last active December 21, 2015 00:08
Compare Git Branches, Compare Two Files in Different Branches
# diff two branches
$ git diff --name-status branch1..branch2
# diff of a specific file between two commits/branchs
$ git diff feature-branch master -- myfile.css
$ git diff eaa241d 4d49814 -- myfile.css
codfish / gist:6624919
Last active December 23, 2015 10:59
Browser caching your scripts and styles intelligently
View gist:6624919
<link rel="stylesheet" type="text/css" href="/css/main.<?php echo filemtime('/path/to/css/main.css'); ?>.css" />
<script language="javascript" src="/js/common.<?php echo filemtime('/path/to/js/common.js'); ?>.js">
# Add a rewrite in apache
RewriteRule ^(css|js)/(.*)\.[0-9]+\.(.*)$ /$1/$2.$3 [L]
# nginx
rewrite ^(css|js)/(.*)\.[0-9]+\.(.*)$ /$1/$2.$3 last;
codfish / gist:6993840
Created October 15, 2013 15:56
Flush DNS on mac
View gist:6993840
sudo killall -HUP mDNSResponder
codfish / webkit-line-clamp.css
Created October 24, 2013 01:21
"-webkit-line-clamp is an unsupported WebKit property that limits the number of lines of text displayed in a block element. In order to achieve the effect, it needs to be combo-ed with a couple of other exotic WebKit properties."
View webkit-line-clamp.css
* Truncate paragraph with an ellipsis, while specifying exactly how many lines you want
* source:
#content-body {
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
View dotallRegex.js
// You are looking for the /.../s modifier, also known as the dotall modifier. It forces the dot . to also match newlines, which it does not do by default.
// The bad news is that it does not exist in Javascript. The good news is that you can work around it by using a character class (e.g. \s) and its negation (\S) together, like this:
var htmlStringWithScriptTags = "sdf <script>test fsajkdfn</script> a sdasda <script> sdfsdfsdf \n \
sdfsdfsd </script> sjkndfjkasnd <script> sdfsdfsdf \n \
sdfsdfsd </script>sjkndfjkasnd <script> sdfsdfsdf \n \
sdfsdfsd </script>";
// incorrect
htmlStringWithScriptTags.replace(/<script.*?<\/script>/g, '');
codfish /
Last active December 28, 2015 17:59
Symlink every file in one directory into another directory
# for instance, if you want to link all of your nginx config files
# from sites-available/ to sites-enabled/ in one fell swoop
# the trick here is to go into the target directory before issuing the ln command
cd /etc/nginx/sites-enabled
sudo ln -sfnv /etc/nginx/sites-available/* .
codfish /
Last active June 25, 2022 13:34
Helpful bash commands & reference. Some commands specific to Debian-based distros.

Bash Notebook


  • mkdir -p /path/to/dir/to/create - Recursively create directories if necessary
  • scp -r <host>:</source/path> <host>:</destination/path> - Recursively copy files & directories over ssh
  • printenv - List all environment variables
  • lsof -i :<port> - Find out which process is listening upon a port

Conditional Logic

codfish /
Last active August 29, 2015 14:04
Remove an auto-complete URL from Chrome

How to remove an auto-complete URL from Chrome

Mac: highlight the entry and then press Fn + Shift + Del

PC: highlight the entry and press Shift + Delete

  • Update, 7/29/14 - From my own personal trial and error, this is only working for me on items specifically in my history, either URL's or previous Omnibox google searches, but not google's auto suggestions. To delete an item from the omnibox on mac, arrow over it and hit Fn + Shift + Del or just Shift + Del for some people it seems (not me).

Original Source

codfish /
Created July 29, 2014 17:12
Delete all local gems with this one liner. Source:
# In Ruby 2.0 there are protected default gems that wont get uninstalled by this.
$ for i in `gem list --no-versions`; do gem uninstall -aIx $i; done