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
View GitHub Profile
@matthewjberger
matthewjberger / SamL.ps1
Last active December 8, 2015 02:57
aamsay atinlay
function SamL ($a) {$a = $a -replace "[^\w\s]",""; $b = $a.split(" ") | %{"a" + $_.substring(1) + $_[0].ToString().tolower() + "ay" }; [string]::Join(" ", $b) | Out-String }
function DecryptSamL ($a) {$b = $a.split(" ") | %{$_[$_.Length-3] + $_.Substring(1, $_.Length-4) }; [string]::Join(" ", $b) | Out-String }
@matthewjberger
matthewjberger / Meme.ps1
Created December 8, 2015 02:57
Meme spacer
Function ToMeme($a){$b=""; foreach($c in $a.tochararray()){$b="$b $c"}; return $b.Trim(' ');}
@matthewjberger
matthewjberger / Converters.py
Last active December 10, 2015 23:26
Simple python converters for binary, hexadecimal, and decimal
# Converters
def hexToBin(h):
return bin(int(h,16))[2:]
def binToHex(b):
return '{:0{}X}'.format(int(b,2), len(b) // 4)
def decToBin(i):
s = ""
while i:
finda = "!grepalias() { git config --global --get-regexp alias | grep -i \"$1\" | awk -v nr=2 '{sub(/^alias\\./,\"\")};{printf \"\\033[31m%_10s\\033[1;37m\", $1};{sep=FS};{for (x=nr; x<=NF; x++) {printf \"%s%s\", sep, $x; }; print \"\\033[0;39m\"}'; }; grepalias"
######################
### DESIGN CHANGES ###
######################
# panes
set -g pane-border-fg black
set -g pane-active-border-fg brightred
## Status bar design
# status line
@matthewjberger
matthewjberger / Default (windows).sublime-keymap
Created March 25, 2016 22:06
Sublime Vintage mode keymappings
[
// jk to exit insert mode
{ "keys": ["j", "k"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
@matthewjberger
matthewjberger / SDL_MessageBox.cpp
Created April 4, 2016 00:38
SDL_MessageBox Example
const SDL_MessageBoxButtonData buttons[] = {
{ /* .flags, .buttonid, .text */ 0, 0, "no" },
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "ok" },
};
const SDL_MessageBoxColorScheme colorScheme = {
{ /* .colors (.r, .g, .b) */
/* [SDL_MESSAGEBOX_COLOR_BACKGROUND] */
{ 255, 0, 0 },
/* [SDL_MESSAGEBOX_COLOR_TEXT] */
{ 0, 255, 0 },
/*
"Seascape" by Alexander Alekseev aka TDM - 2014
License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Contact: [email protected]
*/
const int NUM_STEPS = 8;
const float PI = 3.1415;
const float EPSILON = 1e-3;
float EPSILON_NRM = 0.1 / iResolution.x;
@matthewjberger
matthewjberger / ReadAllBytes.cpp
Last active April 26, 2016 06:04
Reads a file into a vector of unsigned char
typedef unsigned char BYTE;
std::vector<BYTE> ReadAllBytes(const std::string& filename)
{
using namespace std;
ifstream file(filename.c_str(), ios::binary | ios::ate);
file >> noskipws;
streampos fileSize = file.tellg();
file.seekg(0, ios::beg);
@matthewjberger
matthewjberger / TextureSetup.cpp
Last active April 27, 2016 07:31
Text Rendering with OpenGL
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h"
typedef unsigned char BYTE;
std::vector<BYTE> ReadAllBytes(const std::string& filename)
{
using namespace std;
ifstream file(filename.c_str(), ios::binary | ios::ate);
file >> noskipws;