Skip to content

Instantly share code, notes, and snippets.

View EvanLovely's full-sized avatar

Evan Lovely EvanLovely

View GitHub Profile
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html
@EvanLovely
EvanLovely / config.rb
Created August 22, 2013 02:42
SASS/Compass Simple Compile Error Beep for Mac. To hear a sample, run this in Terminal: `afplay /System/Library/Sounds/Basso.aiff`
# Play sound Basso upon error
on_stylesheet_error do
system('afplay /System/Library/Sounds/Basso.aiff')
end
@EvanLovely
EvanLovely / Mixin:-Arrow.markdown
Created August 29, 2013 07:06
A Pen by Evan Lovely.
@EvanLovely
EvanLovely / search-bash-aliases.sh
Created September 4, 2013 18:36
Bash Function to search through your Bash Aliases and Functions and display helpful text in the prompt.
# search bash aliases
sba() {
cat ~/.bash_aliases | grep -i -A 1 "^#.*$*"
cat ~/.bash_aliases | grep -i -B 1 "^alias.*$*"
cat ~/.bash_functions | grep -i -A 1 "^#.*$*"
}
// Make elements align in a grid, regardless of height
// Apply to elements you want as grid items
// $cols = how many columns you want
// $margin-right = margin-right, should be in percent
// $ie8-height = an explicit height for all the elements, "off" by default, only applied to IE
@mixin gridify($cols, $margin-right: 5%, $ie8-height: auto) {
// Math for widths, margins, and clears
$width: (100% / $cols) - $margin-right + ($margin-right / $cols);
$ie-width: (100% / $cols) - $margin-right;
$clearnum: $cols + 1;
@EvanLovely
EvanLovely / no-drush-on-server.aliases.drushrc.php
Created September 25, 2013 02:01
Drush alias for a server that doesn't have drush installed. Helps considerably when pushing and pulling databases and files for a Drupal site as it uses mysqldump, ssh, and rsync instead of drush (which is usually required for parsing the settings.php file and finding out what is set below.
$aliases['prod'] = array(
'root' => '',
'uri' => '',
'remote-user' => '',
'remote-host' => '',
'ssh-options' => '-o PasswordAuthentication=yes',
'path-aliases' => array(
'%files' => 'sites/default/files',
),
'databases' =>
@EvanLovely
EvanLovely / sql-sync-with-no-remote-drush.sh
Created September 27, 2013 23:49
It's like drush sql-sync for a Drupal site, but there's no drush installed on the remote server.
# Author: Evan Lovely
# Syncs the database and files from the live production site to here. Run it anywhere with `sh sync--prod->stage.sh`
# Needs to be an absolute path
LOCAL_PATH=""
SSH="user@server.com"
DB_USER=""
DB_PASS=""
DB=""
REMOTE_PATH=""
@EvanLovely
EvanLovely / Double-Negative-Borders.markdown
Created February 20, 2014 01:51
A Pen by Evan Lovely.
@EvanLovely
EvanLovely / bash_functions.sh
Created April 16, 2014 19:23
Git Checkout Helper
# Git Checkout Helper
gitco() {
git branch
echo "Branch to checkout? (Fuzzy searching from left to right with space support)"
read branch
branches=$(git branch | egrep -i "${branch// /.*}" | tr -d ' ')
count=$(echo "$branches" | egrep -c ".")
if [ "$count" = "1" ]; then
git checkout $(echo $branches | tr -d '\n' | tr -d '*')
elif [[ "$count" = "0" ]]; then
@EvanLovely
EvanLovely / img-sizes.sh
Created April 26, 2014 01:29
Display image sizes in the command line for either a single image or a whole directory
# Run on an image to see it's width & height in pixels, then copy the CSS syntax for it.
imgsize () {
width=$(mdls -name kMDItemPixelWidth -raw "$1")
height=$(mdls -name kMDItemPixelHeight -raw "$1")
echo "width: "$width"px;
height: "$height"px;" | pbcopy
echo "$width"x"$height"
}
# Displays all images in a directory with image sizes. Either pass in a folder or run as-is to list the current directory