Skip to content

Instantly share code, notes, and snippets.

View bertrandom's full-sized avatar

Bertrand Fan bertrandom

View GitHub Profile
@bertrandom
bertrandom / private.xml
Created November 14, 2013 19:32
KeyRemap4Macbook config to remap Caps Lock to Ctrl-Shift-Eject (Lock computer), after setting Caps Lock to PC Application Key with PCKeyboardHacks
<?xml version="1.0"?>
<root>
<item>
<name>CAPSLOCKTOLOCK</name>
<appendix>this is to remap caps lock to CtrlShiftEject</appendix>
<identifier>private.swap_capslock</identifier>
<autogen>
--KeyToKey--
KeyCode::PC_APPLICATION,
KeyCode::VK_CONSUMERKEY_EJECT, ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
@bertrandom
bertrandom / storedata.sh
Created April 12, 2013 20:31
tourbillion performance testing
#!/bin/bash
i=0
while true
do
i=$(($i+1))
status=$(curl -H 'Content-Type: application/json' --request POST --data '{"data":"Goodbye world!"}' --write-out %{http_code} --silent https://tourbillon.herokuapp.com/dev/null)
if [ "$status" -eq 200 ]
then
echo "$i Discarded successfully."
else
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
@bertrandom
bertrandom / gist:5017613
Created February 23, 2013 00:20
Trip Advisor venue URL -> ID regex
(.*)(d[0-9]+)(.*)
$2
Read permissions:
email
read_friendlists
read_insights
read_mailbox
read_requests
read_stream
user_online_presence
friends_online_presence
@bertrandom
bertrandom / gist:4262137
Created December 11, 2012 21:05
Recursive square thumbnail generation (destructive)
find . -type f -name '*.jpg' | xargs mogrify -define jpeg:size=640x640 -thumbnail 320x320^ -gravity center -extent 320x320
@bertrandom
bertrandom / gist:2961106
Created June 20, 2012 17:39
Removes the Bing logo from Satellite Eyes wallpapers
#!/bin/bash
#
# Removes the Bing logo from Satellite Eyes wallpapers
#
# Delete the Bing logo image
rm -f /Applications/Satellite\ Eyes.app/Contents/Resources/bing-logo.png
# Clear the map cache
rm -f ~/Library/Application\ Support/Satellite\ Eyes/map-*.png
@bertrandom
bertrandom / gist:2393966
Created April 15, 2012 17:19
Script for displaying all the available 256 colors in the terminal, for prompt customization wankery
#!/bin/bash
function fgcolor {
echo "\033[38;5;"$1"m"
}
for i in `seq 1 256`
do
echo -e "$(fgcolor $i)color-$i"
done
@bertrandom
bertrandom / InstagramShortUrl.php
Created April 11, 2012 15:14
InstagramShortUrl encoding/decoding service
<?php
namespace Smittn\InstagramBundle\Services;
class InstagramShortUrl {
private $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
public function __construct() {
@bertrandom
bertrandom / ephemswap
Created March 20, 2012 04:56
Creates a 4 gig swap file and mounts it as swap space, used for EC2 small instances for on-boot ephemeral swap space, put it somewhere in boot init
#!/bin/bash
if swapon -s | grep -q /mnt/swapfile
then
echo "Swapfile already mounted"
else
if [ -e /mnt/swapfile ]
then
echo "Mounting swapfile"
swapon /mnt/swapfile