Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Programming something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Programming something in Rust, probably
View GitHub Profile
@matthewjberger
matthewjberger / EventDispatcher.cpp
Created May 6, 2016 — forked from sansumbrella/EventDispatcher.cpp
C++ observer pattern for event handling.
View EventDispatcher.cpp
#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() );
View .gitconfig
[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
View .gitconfig
[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 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted
View git-recover-branch.md

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 Jun 16, 2016 — forked from jongalloway/RecursiveReplace.ps
Recursive replace in files (PowerShell)
View RecursiveReplace.ps
$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 Jun 21, 2016
message boxes in powershell
View ShowMessage.ps1
<# types
"ok",
"error",
"warning",
"question",
"info",
"okcancel",
"abortretryignore",
"yesnocancel",
"yesno",
View GuessingGame.rs
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 Mar 14, 2018
Extract Image from pdf
View Extract.cs
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 Jul 20, 2016 — forked from planbnet/gnome-terminal-zenburn.sh
Zenburn color scheme for gnome-terminal
View gnome-terminal-zenburn.sh
#!/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 Jul 22, 2016
Prompt for folder selection with a dialog.
View BrowseForFolder.ps1
$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