Skip to content

Instantly share code, notes, and snippets.

View maxkandler's full-sized avatar
👨‍💻

Max Kandler maxkandler

👨‍💻
View GitHub Profile
@maxkandler
maxkandler / logstash.conf
Last active October 8, 2021 07:31
Grok filter for Cloudfront Logs to be used with Logstash & ElasticSearch
filter {
grok {
match => ["message", "%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day}[ \t]%{TIME:time}[ \t]%{DATA:x_edge_location}[ \t](?:%{NUMBER:sc_bytes}|-)[ \t]%{IP:c_ip}[ \t]%{WORD:cs_method}[ \t]%{HOSTNAME:cs_host}[ \t]%{NOTSPACE:cs_uri_stem}[ \t]%{NUMBER:sc_status}[ \t]%{GREEDYDATA:referrer}[ \t]%{NOTSPACE:user_agent}[ \t]%{GREEDYDATA:cs_uri_query}[ \t]%{NOTSPACE:cookie}[ \t]%{WORD:x_edge_result_type}[ \t]%{NOTSPACE:x_edge_request_id}[ \t]%{HOSTNAME:x_host_header}[ \t]%{URIPROTO:cs_protocol}[ \t]%{INT:cs_bytes}[ \t]%{NUMBER:time_taken}[ \t]%{NOTSPACE:x_forwarded_for}[ \t]%{NOTSPACE:ssl_protocol}[ \t]%{NOTSPACE:ssl_cipher}[ \t]%{NOTSPACE:x_edge_response_result_type}([ \t])?(%{NOTSPACE:cs_protocol_version})?"]
}
geoip {
source => "c_ip"
}
mutate {
add_field => ["listener_timestamp", "%{year}-%{month}-%{day} %{time}"]
convert => {
@maxkandler
maxkandler / issues.sh
Last active January 12, 2016 12:42
One liner to get a coma-separated list of all JIRA-issues between to two commits / branches / tags.
# Replace `v1` and `v2` with the correct SHAs or tags.
# Replace `PROJ` with your Jira-Project identifier.
git log --pretty=oneline v1..v2 | pcregrep -o --regexp="(PROJ-\d+)" | sort -n | uniq | tr '\n' ','
@maxkandler
maxkandler / ffmpeg.md
Last active August 29, 2015 13:56
Simple video conversion to create videos compatible with various browser and devices. Uses ffmpeg on a Mac. Source material is supposed to be a higher quality h.264 video.

Resize a video to 480p w/ max. bitrate of 750k

ffmpeg -i video-raw.mp4 -codec:v libx264 -profile:v main -preset slow -b:v 750k -maxrate 750k -bufsize 1000k -vf scale=720:480 -threads 0 -codec:a libfaac -acodec libfaac -ac 2 -ar 44100 -ab 128k video.mp4

Change only the quality of a video

ffmpeg -i video-raw.mp4 -codec:v libx264 -profile:v main -preset slow -b:v 1000k -maxrate 1000k -bufsize 2000k -threads 0 -codec:a libfaac -acodec libfaac -ac 2 -ar 44100 -ab 128k video.mp4
@maxkandler
maxkandler / mobileVisits.js
Last active December 23, 2015 02:49
Script to extract all mobile vitsits from your (synced) Chrome history. Run this script in the dev-tools of chrome://history-frame.
// Script to extract the mobile visits from the the synced Chrome history.
//
// INSTRUCTIONS:
// 1. Open chrome://history-frame
// 2. Copy & Paste the code below into the console
// 3. Run and wait (it will evaluate all visits dating back to 12. September 2013)
// 4. Success
var mobileVisits;
var endDate = new Date('2013','08', '12');
@maxkandler
maxkandler / automounter.sh
Created August 20, 2013 00:23
Mounts and unmounts a USB drive based on the presence of another machine in the network. A little more explanation on what it does: http://justcurious.is/2013/raspberry-pi-and-external-drives/
#!/bin/bash
host="island1.local"
mountPoint="/media/KRETA"
drive="/dev/sda1"
device="/dev/sda"
hostIsUp=-1
checkHostIsUp()
@maxkandler
maxkandler / is.justcurious.photostreamsync.plist
Last active December 20, 2015 02:19
Syncing photostream to Dropbox. Find a full explanation over at my blog: http://justcurious.is/2013/sync-ios-photostream-to-dropbox/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>is.justcurious.photostreamsync</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/utils/photostream</string>
</array>
@maxkandler
maxkandler / MainWindow.xaml.cs
Created April 9, 2013 09:42
Serializing Kinect-Skeletons and transmitting them via MemoryMappedFiles to another process. These are just snippets and won't run without further Code.
// This process uses the data comming from the kinect processes.
// Read from the MemoryMappedFile
MemoryMappedViewAccessor accessor = memoryMappedFile.createViewAccessor();
// Read to Array
accessor.ReadArray<byte>(0, mmf_result, 0, mmf_result.Length);
// Use a local Array for further instructions
byte[] temp = new byte[mmf_result.Length];
@maxkandler
maxkandler / gist:5233150
Created March 24, 2013 19:25
Hide the iTerm2 Dock icon.
/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
@maxkandler
maxkandler / context-reset.sh
Created December 13, 2012 21:42
Reset the "Open With..." entries on a Mac
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
@maxkandler
maxkandler / VPN.scpt
Created March 9, 2012 11:49
Connects / Disconnects to a VPN and pushes its action to Growl
-- config: change the VPN name here (as listed under the network preferences)
set VPNname to "LRZ VPN"
tell application "System Events"
set isGrowlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isGrowlRunning then
tell application id "com.Growl.GrowlHelperApp"
set the allNotificationsList to ¬