Skip to content

Instantly share code, notes, and snippets.

View mcbrwr's full-sized avatar

Matthijs Brouwer mcbrwr

View GitHub Profile
@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"
@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 / 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 / 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 / clear-columns.less
Created January 27, 2016 19:38
Bootstrap 3 - clear columns
.row {
> .col-sm-4 {
@media screen and (min-width: @screen-sm-min){
&:nth-child(3n + 1) {
clear: left;
}
}
}
> .col-sm-3 {
@media screen and (min-width: @screen-sm-min){
@mcbrwr
mcbrwr / chrome_console_filter.regex
Created January 6, 2016 13:30
regex to filter out XHR & Security messages from the Chrome JS console
^((?!Security|XHR).)*$
@mcbrwr
mcbrwr / no-ad-no-suggested-no-sidebar-facebook.css
Created September 2, 2015 05:21
Use stylebot or any other CSS replacement plugin in your browser with this bit of CSS to clean up Facebook timeline. It removes sidebars, ads & suggested posts and some "people you know liked this company" posts.
#contentArea {
float: none;
margin: 0 auto;
max-width: 700px;
width: 100%;
}
#contentCol {
margin-left: 0;
padding-left: 0;
@mcbrwr
mcbrwr / jquery.smooth.js
Last active August 29, 2016 14:44
jquery smooth scroll on all <a> tags
// smooth scroll
$('a[href*="#"]:not([href="#"])').on("click", function() {
if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
var toppie = target.offset().top - 50;
$('html,body').animate({
scrollTop: toppie
}, 600);
@mcbrwr
mcbrwr / popupLink-alt.js
Last active May 31, 2016 14:05
vanilla JS to open href of a link in popup window (ie for custom share buttons)
@mcbrwr
mcbrwr / nav.less
Last active August 29, 2015 14:04
CSS logic to show/hide a wrapper with navigation on small screens using the target selector instead of Javascript.
// --------------------------------- */
// menu logic
// --------------------------------- */
#siteheader {
.menu-wrapper {
max-height: 0;
overflow: hidden;
}
.hidemenu {