Skip to content

Instantly share code, notes, and snippets.

View matthewjberger's full-sized avatar

Matthew J. Berger matthewjberger

View GitHub Profile
@matthewjberger
matthewjberger / EventDispatcher.cpp
Created May 6, 2016 20:01 — forked from sansumbrella/EventDispatcher.cpp
C++ observer pattern for event handling.
#include "EventDispatcher.h"
void EventDispatcher::addListener( Listener *l )
{
mListeners.push_back(l);
}
void EventDispatcher::removeListener( Listener *l )
{
mListeners.erase( std::remove( mListeners.begin(), mListeners.end(), l ), mListeners.end() );
[user]
name = Matthew J. Berger
email = matthewberger@nevada.unr.edu
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@matthewjberger
matthewjberger / .gitconfig
Created May 18, 2016 02:20 — forked from putermancer/.gitconfig
git aliases
[alias]
man = help
unadd = reset HEAD
#co = checkout
co = "!f(){ git checkout \"$@\" && git sup; }; f"
feature = "!git reset HEAD && git checkout -b feature/\"$1\" && git commit --allow-empty -m \"Created feature branch $1\" && git push --set-upstream origin feature/\"$1\" && echo Branch feature/$1 published to origin"
cp = cherry-pick
sma = submodule add
st = status
br = branch
@matthewjberger
matthewjberger / git-recover-branch.md
Created May 19, 2016 05:29 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@matthewjberger
matthewjberger / RecursiveReplace.ps
Created June 16, 2016 14:22 — forked from jongalloway/RecursiveReplace.ps
Recursive replace in files (PowerShell)
$find = 'jquery-1\.4\.4'
$replace = 'jquery-1\.5\.1'
$match = '*.cshtml' , '*.vbhtml'
$preview = $true
foreach ($sc in dir -recurse -include $match | where { test-path $_.fullname -pathtype leaf} ) {
select-string -path $sc -pattern $find
if (!$preview) {
(get-content $sc) | foreach-object { $_ -replace $find, $replace } | set-content $sc
}
@matthewjberger
matthewjberger / ShowMessage.ps1
Last active June 21, 2016 17:48
message boxes in powershell
<# types
"ok",
"error",
"warning",
"question",
"info",
"okcancel",
"abortretryignore",
"yesnocancel",
"yesno",
extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
let secret_number = rand::thread_rng().gen_range(1, 101);
let mut guesses = 0;
loop {
@matthewjberger
matthewjberger / Extract.cs
Last active March 14, 2018 00:29
Extract Image from pdf
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using Tesseract;
using System.Drawing.Imaging;
namespace ExtractInvoice
@matthewjberger
matthewjberger / gnome-terminal-zenburn.sh
Created July 20, 2016 06:17 — forked from planbnet/gnome-terminal-zenburn.sh
Zenburn color scheme for gnome-terminal
#!/usr/bin/env bash
dir=$(dirname $0)
gconfdir=/apps/gnome-terminal/profiles
echo # This makes the prompts easier to follow (as do other random echos below)
########################
### Select a profile ###
########################
@matthewjberger
matthewjberger / BrowseForFolder.ps1
Created July 22, 2016 15:00
Prompt for folder selection with a dialog.
$path = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path)
$objShell = new-object -com shell.application
$objFolder = $objShell.NameSpace($path)
$namedfolder = $objShell.BrowseForFolder(0,"Select the root of the driver.",0,$path)
$namedfolder.self.path