Skip to content

Instantly share code, notes, and snippets.

View mlabrum's full-sized avatar

Matthew Labrum mlabrum

  • Lynkz Pty Ltd
  • Adelaide
  • 22:20 (UTC +10:30)
View GitHub Profile
@mlabrum
mlabrum / vagrant_rsync
Created March 17, 2015 02:36
vagrant rsync windows
rsync on windows working correctly with vagrant:
install and add this to the PATH https://www.itefix.net/dl/cwRsync_5.4.1_x86_Free.zip (make sure that this is before git on the path, otherwise ssh wont work correctly)
You'll also have to patch vagrant to run this correctly (https://github.com/mitchellh/vagrant/issues/3230 ):
find
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
and change it to
hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath)
@mlabrum
mlabrum / saveimageclipboardfusionmacro.cs
Created July 3, 2014 01:37
Image saving Clipboard Fusion Macro + Save Dialog
using System;
using System.Windows.Forms;
public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
string name = "ClipboardFusion Saved Picture";
if (Clipboard.ContainsImage())
@mlabrum
mlabrum / outgoing
Created December 19, 2011 23:13
git outgoing
#!/bin/sh
# From: http://weblog.latte.ca/blake/employment/mozilla/thunderbird/gitOutgoing.html
git push --dry-run $1 2>&1 | awk '/^ / {print $1}' | xargs git log --graph --abbrev-commit --date=relative --pretty='format:%Cred%h%Creset - %s %Cgreen(%cr) %C(yellow)<%an>%C(reset)%C(white).'
@mlabrum
mlabrum / gist:1266505
Created October 6, 2011 04:08
show open sockets
netstat -an |find /i "listening"
@mlabrum
mlabrum / gitpush.txt
Created September 18, 2011 06:13
Setting up GIT push to live website on a windows server
------------------
How to setup git based push to live webserver on windows with apache
------------------
1) Install http://code.google.com/p/msysgit/
2) Setup your git directories
# Setup a base git directory
mkdir c:/server/git
git init --bare www.git
# How to install wkhtmltopdf on centos 64bit
yum install xz urw-fonts libXext openssl-devel libXrender
wget http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0.10.0_rc1-static-amd64.tar.lzma&can=2&q=
xz -d wkhtmltopdf-0.10.0_rc1-static-amd64.tar.lzma
tar -xvf wkhtmltopdf-0.10.0_rc1-static-amd64.tar
cp wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf
#to test
This is a simple custom button ( http://xsms.nm.ru/custombuttons/en/ ) it requires sendtophone to be installed (https://addons.mozilla.org/en-US/firefox/addon/161941/)
This button simply allows you to click the button, then it will display a prompt for text, then it will copy it to your phones clipboard (the function in sendtophone only allows selected text, not custom text)
custombutton://%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Ccustombutton%20xmlns%3Acb%3D%22http%3A//xsms.nm.ru/custombuttons/%22%3E%0A%20%20%3Cname%3Esendtoclip%3C/name%3E%0A%20%20%3Cimage%3E%3C%21%5BCDATA%5Bdata%3Aimage/png%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAYAAADgKtSgAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAn
# quick powershell script to find songs added in the last 20days and add them into winamp
cd "c:/music/folder"
foreach( $song in Get-Childitem –recurse | where-object {$_.lastwritetime –gt (Get-date).AddDays(-20) -and $_.extension -eq ".mp3"}){
&'C:/Program Files (x86)/Winamp/winamp.exe' $song.fullname
}
#splits a string into parts, and returns them, this uses a workaround to handle wide unicode characters
function unicode_split($str, $length){
if(preg_match_all("/./u", $str, $results)){
$splits = Array_chunk($results[0], $length);
$str_splits = Array();
foreach($splits as $split){
$str_splits[] = implode("", $split);
}
#!/usr/bin/ruby
# Matt Labrum
# quick and dirty ruby script to neaten grep input by grouping by filename + some formatting
# Example Usage: grep -r -n "TODO:" . | neatgrep.rb
# must be called with -n, script doesn't handle other cases
#
# Handy when using a bash alias, for example
# alias todo='grep -r -n "TODO:" . | neatgrep.rb'
#