Skip to content

Instantly share code, notes, and snippets.

View mcbrwr's full-sized avatar

Matthijs Brouwer mcbrwr

View GitHub Profile
@mcbrwr
mcbrwr / zwift_test_keystrokes.applescript
Last active February 13, 2016 21:34
applescript to test keystrokes - eventually trying to get keystrokes into Zwift
on run {input, parameters}
tell application "System Events" to set frontmost of process "ZwiftApp" to true
tell application "System Events"
keystroke "M"
keystroke "Ride on!!"
keystroke return
end tell
return input
@mcbrwr
mcbrwr / say_open_windows.applescript
Created February 13, 2016 21:07
name all open applications and count their open windows
tell application "System Events"
repeat with theProcess in processes
if not background only of theProcess then
tell theProcess
set processName to name
set theWindows to windows
end tell
set windowsCount to count of theWindows
if processName is not "Finder" and processName is not "Automator" then
@mcbrwr
mcbrwr / parseMediaString.php
Last active March 4, 2016 08:12
throw in a string, returns embed code. Some use vimeo, others youtube, some insert the full URL, others just the key.. This returns the right embed code. If all fails it just returns the string (let's hope it's an embed code then ;-)
/**
* parse a string and return the appropriate embed code
* @return string
*/
public function parseMedia($string)
{
if (empty($string)) return false;
$rgx = '/^https*:\/\/(?:.*?)\.?(youtube|vimeo)\.com\/(watch\?[^#]*v=(\w+)|(\d+))/';
@mcbrwr
mcbrwr / Pretty Git Log
Created July 8, 2016 08:01
nice git log
# run once
git log --graph --pretty=format:'%C(yellow)%cD%Creset - %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# OR: set config:
git config --global alias.lg "log --graph --pretty=format:'%C(yellow)%cD%Creset - %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"