Skip to content

Instantly share code, notes, and snippets.

View codfish's full-sized avatar

Chris O'Donnell codfish

View GitHub Profile
@codfish
codfish / textRendering.css
Last active December 20, 2015 18:29
Improve text legibility for webkit browsers
text-rendering: optimizeLegibility;
@codfish
codfish / gitDiffBranches.sh
Last active December 21, 2015 00:08
Compare Git Branches, Compare Two Files in Different Branches
# http://blog.firsthand.ca/2011/05/compare-git-branches-compare-two-files.html
# 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
codfish / gist:6624919
Last active December 23, 2015 10:59
Browser caching your scripts and styles intelligently
<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">
</script>
# 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
codfish / gist:6993840
Created October 15, 2013 15:56
Flush DNS on mac
sudo killall -HUP mDNSResponder
@codfish
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."
/**
* Truncate paragraph with an ellipsis, while specifying exactly how many lines you want
* source: http://dropshado.ws/post/1015351370/webkit-line-clamp
*/
#content-body {
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
// 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
codfish / symlinkAll.sh
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
codfish / bash_notebook.md
Last active June 25, 2022 13:34
Helpful bash commands & reference. Some commands specific to Debian-based distros.

Bash Notebook

Popular

  • 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
codfish / rm_autocomplete_chrome.md
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
codfish / rm_local_gems.sh
Created July 29, 2014 17:12
Delete all local gems with this one liner. Source: http://stackoverflow.com/a/8095234
# 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