Skip to content

Instantly share code, notes, and snippets.

@ammmze
ammmze / getNearestPages.js
Created March 22, 2013 19:15
Gets the nearest x pages. Useful for pagination where there may be many results, but you only want to display a max of X pages. It will always put the current page in the middle, except if num_to_show is odd, if its even, it will be in the middle, with the one extra on left.
/**
* Gets the nearest x pages.
*
* Useful for pagination where there may be many results, but you only want to display a max of X pages.
* It will always put the current page in the middle, except if num_to_show is odd, if its even, it will be in the
* middle, with the one extra on left.
*/
function getNearestPages(current_page, total_pages, num_to_show) {
var near_pages = [];
var num_to_show = 3;
@ammmze
ammmze / gist:6380290
Last active December 21, 2015 23:09

In my experience with Font Awesome, you don't have to use <i>. You can add the icon class to a <div> and it works just the same.

<div class="icon-github"></div>

You can also still put contents within the div like so:

@ammmze
ammmze / 0_reuse_code.js
Created June 5, 2014 21:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ammmze
ammmze / gist:cb854b56f6b1efe82f1f
Last active August 29, 2015 14:06
Alias docker to start boot2docker
# Alias `docker` command to start boot2docker if its not already running
alias b2d-running="boot2docker ip 2>/dev/null | grep -Eq '([0-9]{1,3}\.){3}[0-9]{1,3}'"
alias adddockerhost='export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 '
alias docker="if ! b2d-running > 0 ; then boot2docker start; fi; adddockerhost; /usr/local/bin/docker"
#! /bin/bash
#######################################################################
# this is a helper script that keeps SnapRAID parity info in sync with
# your data. Here's how it works:
# 1) it first calls diff to figure out if the parity info is out of sync
# 2) if there are changed files (i.e. new, changed, moved or removed),
# it then checks how many files were removed.
# 3) if the deleted files exceed X (configurable), it triggers an
# alert email and stops. (in case of accidental deletions)
# 4) otherwise, it will call sync.
@ammmze
ammmze / .gitignore
Last active August 29, 2015 14:08
FlexRaid Transparent RAID Test
*.vdi
.vagrant
@ammmze
ammmze / install-netatalk
Created February 11, 2015 14:46
Install Netatalk (Ubuntu) (Work in Progress)
#!/bin/bash
VERSION=3.1.7
TRACKER_VERSION=`apt-cache search libtracker-miner | grep dev | grep -oE '[0-9\.]+'`
sudo apt-get install build-essential \
libevent-dev \
libssl-dev \
libgcrypt11-dev \
@ammmze
ammmze / ofs-user.sh
Created April 12, 2015 21:35
Changing odrive file server (ofs) run user.
#!/bin/bash
# Usage: sudo ./ofs-user.sh some-new-user
# New username to use for ofs
NEW_USER=${1:-media}
OFS_HOME=/etc/ofs
# Set up home directory for ofs
// Example usage: http://codepen.io/ammmze/pen/xGmRWz
// {{#compare unicorns '==' ponies}}
// I knew it, unicorns are just low-quality ponies!
// {{/compare}}
//
// (based from http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/)
Handlebars.registerHelper('compare', function(val1, val2, val3, options) {
if (arguments.length < 3)
@ammmze
ammmze / com.mashupmill.screenshot-watcher.plist
Last active January 21, 2020 04:32
Open OS X default screenshots in monosnap (or can be customized to open in a different application)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mashupmill.screenshot-watcher</string>