Skip to content

Instantly share code, notes, and snippets.

View matthewjberger's full-sized avatar
🦀
Writing something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Writing something in Rust, probably
  • Hyphen
View GitHub Profile
#include <MainState.h>
#include "ShaderProgram.h"
/* Created by following the example from the excellent OpenGL Superbible 7 book */
GLuint MainState::compile_shaders()
{
ShaderProgram program;
// Source code for vertex shader
@matthewjberger
matthewjberger / python3kflag.md
Created October 1, 2016 17:31 — forked from rowillia/python3kflag.md
The Magic of the -3 Flag in Python 2

The Magic of the -3 Flag in Python 2

Porting code from Python 2 to Python 3 can be a daunting task. Tools like Futureize or Modernize can do most of the mechanical work for you, and Pylint can find obvious problems with code that's meant to be 2and3 compatible. You should absolutely be using these tools as they identify the lion's share of compatibility problems. Thanks to this work, it's really never been easier to port a large codebase to Python 3.

Even with these tools, however, porting code in a way that ensures identical behavior in Python 2 and Python 3 is tough. Python is a highly dynamic language and there is a huge breadth of changes between Python 2 and Python 3. Also, while we'd all love to work in code bases with 100% unit test coverage, the reality is unfortunately often very different. Given this, it's hard if not impossible for a static analysis tool t

@matthewjberger
matthewjberger / .bashrc
Created October 2, 2016 01:51 — forked from mystor/.bashrc
Spacemacs configuration for rust
# You could also do this in emacs probably, but this is easier.
export RUST_SRC_PATH=/path/to/rust/checkout/src
export PATH="$PATH:/path/to/racer/binary/"
@matthewjberger
matthewjberger / .spacemacs.el
Last active April 4, 2018 19:24
Windows Spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@matthewjberger
matthewjberger / alternate.py
Last active October 17, 2016 17:30
npm dotbot plugin (wip)
import os, subprocess, dotbot
from enum import Enum
class PkgStatus(Enum):
UPDATED = 'Updated (npm)'
OUTDATED = 'Not up to date (npm)'
UP_TO_DATE = 'Already up to date (npm)'
INSTALLED = 'Newly installed (npm)'
NOT_FOUND = 'Not found (npm)'
@matthewjberger
matthewjberger / BlobExplanation.ps1
Last active August 16, 2017 16:43
A collection of various powershell scripts
# Load security dll
[Reflection.Assembly]::LoadWithPartialName("System.Security");
# Clear the screen
cls;
# Salt. Added to make a common password uncommon, even though ours is a jumbled mess of letters on purpose.
$salt="SaltCrypto";
# Password to use
@matthewjberger
matthewjberger / fizzbuzz.rs
Last active October 31, 2016 03:55
Rusty Fizzbuzz
fn main() {
for i in 1..101 {
match (i % 5, i % 3) {
(0, 0) => println!("FizzBuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
(_, _) => println!("{}", i),
}
}
}
@matthewjberger
matthewjberger / jsontest.rs
Last active October 31, 2016 14:17
Example of parsing some nested json from a file using a command line argument in Rust
extern crate rustc_serialize;
use rustc_serialize::json::Json;
use std::fs::File;
use std::io::Read;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
println!("I got {:?} arguments: {:?}.", args.len() - 1, &args[1..]);
@matthewjberger
matthewjberger / DisplayAllFonts.ps1
Last active January 5, 2021 14:29
Lists all installed TrueType fonts on Windows
# Displays all installed truetype font names in their corresponding font in a browser
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$objFonts = New-Object System.Drawing.Text.InstalledFontCollection
$colFonts = $objFonts.Families
foreach ($objFont in $colFonts)
{
$strHTML = $strHTML + "<font size='5' face='" + $objFont.Name + "'>" + $objFont.Name + "</font><br>"
}
;; Put in dotspacemacs/user-config
(defun my/use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
(lambda (dir) (file-executable-p
(expand-file-name "node_modules/.bin/eslint"
dir)))))
(eslint (and root
(expand-file-name "node_modules/.bin/eslint"
root))))