Skip to content

Instantly share code, notes, and snippets.

a = [1,2,3,4,5]
# 2 new arrays
left,right = a.each_slice( (a.size/2.0).round ).to_a
# left == [1, 2, 3]
# right == [4, 5]
# make array 2-dimensional
a.each_slice( (a.size/2.0).round ).to_a
# a == [[1, 2, 3], [4, 5]]
@chris-79
chris-79 / gist:8421355
Created January 14, 2014 16:41
Facebook statuses in JSON
https://www.facebook.com/feeds/page.php?id=266818906680257&format=json
@chris-79
chris-79 / README.md
Last active November 20, 2015 15:51
Screen Shot Prettifier

Screen Shot Prettifier

This is a short shell script (inspired by Dr. Drang) that makes Mac screen shots a bit nicer than normal.

Why?

I find OS X's screen shots to be a bit annoying in a few ways:

  • The large drop shadow on whole-window screen shots is way too large.
  • Having zero drop shadows on all other screen shots is boring.
@chris-79
chris-79 / gist:ac8d347d4da4433d6714
Created April 27, 2015 17:06
Re-enable Safari Backspace navigation
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool YES
@chris-79
chris-79 / set-date-time-formats.sh
Created August 6, 2015 14:30
Set my preferred date and time formats on OS X
# declare my US locale
defaults write NSGlobalDomain AppleLocale -string "en_US@currency=USD"
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add "AppleIntlCustomLocale" "en_US"
# date string formats
defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "1" "yyyy/MM/dd"
defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "2" "dd MMM y"
defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "3" "dd MMMM y"
defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "4" "EEEE, dd MMMM y"
@chris-79
chris-79 / wp-to-md.php
Created May 3, 2016 15:23
Wordpress exported xml to markdown entries
<?php
// USAGE: php magic.php
// Edit the details below to your needs
$wp_file = 'wordpress-export.2015-11-23.xml';
$export_folder = 'test/'; // existing files will be over-written, use with care
print "Exporting contents from $wp_file to folder\"$export_folder\"...\n";
if (file_exists($wp_file)) {
@chris-79
chris-79 / arch-linux-on-raspberry-pi.md
Last active June 8, 2018 11:56
Installing Arch Linux on Raspberry Pi
<div class="youtube-section" id="video-{{ youtube_id }}">
<div class="youtube-container">
<div class="youtube-watermark">
{{ theme:output src="svg/uga-college-logo-white.svg" }}
</div>
<div class="youtube-player" data-id="{{ youtube_id }}"></div>
{{ if video_title || video_description }}
<div class="row padd-top-default">
<article>
{{ if video_title }}
@chris-79
chris-79 / image.html
Created February 4, 2019 16:10
Hugo shortcode for Imgix
{{/* Assemble imgix URL without the query bit */}}
{{ $path := ((.Get "url") | default (.Get 0)) }}
{{/* Handle public shared images from Google Drive */}}
{{ if (in $path "drive.google.com") }}
{{ $path = ($path | replaceRE "([^=\\s]+id=)([\\w_-]+)" "https://drive.google.com/uc?id=$2") }}
{{ end }}
{{/* Encode paths that are full URLs or contain a "?" */}}
{{ if ((in $path "?") | or (findRE "^https?:\\/\\/" $path 1)) }}
{{ $path = (delimit (slice "/" (strings.TrimPrefix "=" (querify "" $path))) "") }}
{{ end }}
property includeSkippedSlides : false
set the defaultDestinationFolder to (path to downloads folder)
tell application "Keynote"
activate
try
if playing is true then tell the front document to stop
if not (exists document 1) then error number -128