This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function time_to_seconds($time = 0) | |
{ | |
list($secs, $mins, $hours) = array_pad(array_reverse(explode(':', $time)), 3, 0); | |
return ($hours * 3600) + ($mins * 60) + $secs; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$storagePath = './img'; | |
$cachePath = $storagePath.'/cache'; | |
// Maximum requestable dimensions | |
$maxWidth = 1000; | |
$maxHeight = 1000; | |
$forceJpeg = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_splice_assoc($array, $key, $replacement = array()) | |
{ | |
// Get numeric offset of the key to remove | |
$offset = array_search($key, array_keys($array)); | |
if (!is_int($offset)) return $array; | |
unset($array[$key]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run | |
tell application "Numbers" to tell front document | |
set tPath to (POSIX file (get path)) as string | |
tell tPath to if it ends with ".numbers" then set tPath to text 1 thru -9 -- remove extension | |
save as "LSDocumentTypeCSV" in file tPath -- Numbers automatically adds the ".csv" | |
end tell | |
return tPath as alias -- return the path of the CSV file to the next action | |
end run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "ScreenSaverEngine" to activate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Takes a list of images as arguments and slices them in half | |
# All images should be in the same directory | |
require 'rubygems' | |
require 'RMagick' | |
include Magick | |
# Check to make sure at least one file was given |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get the currently selected item | |
tell application "Finder" | |
set currentFile to selection as text | |
end tell | |
set container to GetParentPath(currentFile) | |
display dialog "File name and extension" default answer "New File.txt" | |
set fileName to text returned of result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on open (filelist) | |
tell application "Image Events" | |
launch | |
repeat with i in filelist | |
set this_image to open i | |
copy dimensions of this_image to {current_width, current_height} | |
-- do stuff | |
end repeat | |
end tell | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thumb_width = 117 | |
thumb_height = 141 | |
raise ArgumentError, 'No images given. You must supply at least one image to process' if ARGV.empty? | |
ARGV.each do |image| | |
if File.file?(image) | |
width = `sips -g pixelWidth "#{image}"`.match(/pixelWidth: \d+$/im).to_s.match(/\d+/).to_s.to_i | |
height = `sips -g pixelHeight "#{image}"`.match(/pixelHeight: \d+$/im).to_s.match(/\d+/).to_s.to_i | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export COPYFILE_DISABLE=true && tar -czvf tarball.tar.gz --exclude='.DS_Store' --exclude='._*' --exclude='Thumbs.db' /path/to/archive |