Skip to content

Instantly share code, notes, and snippets.

View matthewjberger's full-sized avatar

Matthew J. Berger matthewjberger

View GitHub Profile
@matthewjberger
matthewjberger / DisplayFonts.ps1
Created July 29, 2016 16:20
PowerShell Font Listing
# From https://technet.microsoft.com/en-us/library/ff730944.aspx
# This will open an internet explorer window that will display all installed windows font names in their corresponding font.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$objFonts = New-Object System.Drawing.Text.InstalledFontCollection
$colFonts = $objFonts.Families
$objIE = New-Object -com "InternetExplorer.Application"
$objIE.Navigate("about:blank")
$objIE.ToolBar = 0
@matthewjberger
matthewjberger / auto-deploy.md
Created August 8, 2016 04:16 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.

@matthewjberger
matthewjberger / AvailableComPorts.ps1
Last active October 21, 2016 22:18
This will generate an html table that lists available COM ports on windows. It can be styled with css.
# Multi-Line
$style = @"
<style type="text/css">
th {
background: lightblue
}
tr {
text-align:left
}
table, th, td{
@matthewjberger
matthewjberger / OxyplotBitmap.cs
Last active August 25, 2016 15:15
This will make a bitmap out of an oxyplot plot model.
using System;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Wpf;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
namespace OxyPlot2
@matthewjberger
matthewjberger / ExecuteOnSTAThread.cs
Last active September 2, 2016 19:46
Executes code from a wpf app on an STA thread synchronously and sets the cursor to busy.
void ExecuteOnSTAThread(ThreadStart t)
{
Mouse.OverrideCursor = Cursors.Wait; // Make the mouse cursor a busy spinner
Thread thread = new Thread(t);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
Mouse.OverrideCursor = null;
}
// Create an XML Document from a string
XmlDocument doc = new XmlDocument();
doc.LoadXml(reply);
// Get a node from the XML as an XML object
XmlNode root = doc.SelectSingleNode("//TimeLeft");
// Access specific attributes from the dictionary of attributes on the node
XmlAttribute timeLeft = root?.Attributes["value"];
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
solution "SDL2_Test"
configurations { "debug", "release" }
location("make/" .. os.get() .. "/")
targetdir("bin/" .. os.get() .. "/%{cfg.buildcfg}/")
objdir("obj/" .. os.get() .. "/%{cfg.buildcfg}/")
project "sdl2_test"
kind "WindowedApp"
language "C"
@matthewjberger
matthewjberger / vsvimrc.vim
Last active November 18, 2016 16:46
Visual Studio Vim config
" Set the leader key to the spacebar
let mapleader = "\<SPACE>"
" Save the file
nnoremap <leader>fs :w<CR>
" Save all open files
nnoremap <leader>fS :w<CR>
" Jump to far left or right of line
#include <iostream>
#include "gtest/gtest.h"
int GetPositionOfMaxInteger(int* arr, int start, int end);
void RearrangeArray(int* arr, int size);
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);