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 / gist:7508762
Created November 17, 2013 03:38
Resize a bunch of images to exactly 640x480 with black borders if they don't fit the dimensions
ls *.jpg | xargs -n1 sh -c 'convert $0 -resize 640x480 -background "#000000" -gravity center -extent 640x480 fixed/$0'
1
00:00:01,266 --> 00:00:03,366
Do you know what this is all
about? Why we're here?
2
00:00:03,400 --> 00:00:06,366
To be out. This is out.
[AUDIENCE LAUGHS]
#!/bin/bash
start_time=$3
duration=$4
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -ss $start_time -t $duration -i $1 -vf "$filters,palettegen" -y $palette
var moment = require('moment');
module.exports = {
convertTimeToTimestamp: function (time) {
return moment.utc(time, "HH:mm:ss,SSS").set({'year':1970, 'month':0, 'date':1}).valueOf();
},
var timestampMs = transform.convertTimeToTimestamp(line.endTime) - transform.convertTimeToTimestamp(line.startTime);
line.duration = transform.convertTimestampToTime(timestampMs);
convert data/frames/S03E11/270.gif -gravity south -font Helvetica -pointsize 14 -stroke '#000C' -strokewidth 3 -annotate 0 '"These pretzels are\nmaking me thirsty"\n' -stroke none -fill white -annotate 0 '"These pretzels are\nmaking me thirsty"\n' data/annotate/S03E11/270.gif
$ mkvinfo Seinfeld.S01E01.The.Seinfeld.Chronicles.mkv
...
|+ Segment tracks
...
| + A track
| + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
| + Track UID: 17434673961305370787
| + Track type: subtitles
| + Lacing flag: 0
| + Codec ID: S_TEXT/UTF8
$ mkvinfo Seinfeld.S01E01.The.Seinfeld.Chronicles.mkv
...
|+ Segment tracks
...
| + A track
| + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
| + Track UID: 17434673961305370787
| + Track type: subtitles
| + Lacing flag: 0
| + Codec ID: S_TEXT/UTF8
#!/bin/bash
for i in `seq 1 7306`;
do
frame=$(printf '%06d' "$i")
echo $frame
curl "https://slack.com/api/chat.postMessage?token=SLACK_API_TOKEN&channel=CHANNEL_ID&username=Star%20Wars&text=http://starwars.toomanycooks.kitchen/out$frame.jpg&as_user=starwarsbot"
sleep 10
done