Skip to content

Instantly share code, notes, and snippets.

View codearmorygists's full-sized avatar

codearmorygists

View GitHub Profile
@codearmorygists
codearmorygists / index.html
Created September 20, 2012 19:22
CSS loading spinner
<div id="wrapper">
<span class="spinner"></span>
<span class="pulser"></span>
<span class="doublespinner"></span>
<span class="ball"></span>
</div>
<style type="text/css">
body {
background: #333;
@codearmorygists
codearmorygists / tooltip.html
Created September 19, 2012 23:23
Tooltip with CSS3
<a href="#" data-tooltop="This is a tooltip!">a link</a>
<style type="text/css">
a:hover:after {
content: attr(data-tooltip);
position: absolute;
top: 20px;
left: 0;
}
</style>
@codearmorygists
codearmorygists / gitdrop.sh
Created September 19, 2012 23:20
Gitdrop: add file to Github Page, push to web, and put URL into clipboard
#!/bin/bash
DIR="/Path/to/gh-pages/repo" # Path to gh-pages repo
URL="http://website.com" # Domain and path to where the GitHub Page lives on the web
BASE=`basename $1`
cp $1 $DIR
cd $DIR
git add $BASE
git commit -m "$BASE added"
@codearmorygists
codearmorygists / dirlist.php
Created September 19, 2012 23:18
PHP list all files in directory
<?php
function getDirectoryList ($directory) {
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// open directory and walk through the filenames
while ($file = readdir($handler)) {
@codearmorygists
codearmorygists / rm_dst.sh
Created September 19, 2012 23:17
Recursively delete all .DS_Store files
find . -name *.DS_Store -type f -exec rm {} ;
@codearmorygists
codearmorygists / substr.sh
Created September 19, 2012 23:16
Check for substring in shell script
string='My string';
if [[ $string == *My* ]]; then
echo "It's there!";
fi
@codearmorygists
codearmorygists / beautify.php
Created September 19, 2012 23:12
Phone number beautifier
function format_phone($phone) {
$prefix = null;
//Check if number has international prefix
switch(true){
case substr($phone, 0, 1) == '+':
$phone = substr($phone, 1);
$prefix = '+';
break;
case substr($phone, 0, 2) == '00':
@codearmorygists
codearmorygists / resize.sh
Created September 19, 2012 23:09
Resize images in directory
find SOURCE_DIR -print -name "*.jpg" -execdir convert -resize 800x800 -quality 80 '{}' 'TARGET_DIR/{}' ;
find Pictures/ -print -name "*.jpg" -execdir convert -resize 800x800 -quality 80 '{}' '/tmp/test/{}' ;
@codearmorygists
codearmorygists / page_count.rb
Created September 19, 2012 23:05
Recurse directory and count all pages in pdf files
require 'rubygems'
require 'pdf/reader'
class TotalPages
def count(dir)
@conv_directory = dir
## I output the directory argument as a test with the below line -
## mostly to make sure that passing '.' gets current dir
# puts @conv_directory
@codearmorygists
codearmorygists / geolocate.rb
Created September 19, 2012 22:50
Find City and State from Zipcode
require 'net/http'
require 'uri'
require "rexml/document"
# Retrieves US Location data based on a passed in Zipcode. Uses
# Google Maps geocoding service to retrieve a Hash of city, state, and zip
# For more info on the service see: <a href="http://code.google.com/apis/maps/documentation/geocoding/" >http://code.google.com/apis/maps/documentation/geocoding/</a>
#
# example:
# puts get_location_data(97030).inspect