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 / SamL.ps1
Last active Dec 8, 2015
aamsay atinlay
View SamL.ps1
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 }
View Meme.ps1
Function ToMeme($a){$b=""; foreach($c in $a.tochararray()){$b="$b $c"}; return $b.Trim(' ');}
@matthewjberger
matthewjberger / Converters.py
Last active Dec 10, 2015
Simple python converters for binary, hexadecimal, and decimal
View Converters.py
# 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:
View one_git_alias_to_rule_them_all
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"
View Tmux Style
######################
### DESIGN CHANGES ###
######################
# panes
set -g pane-border-fg black
set -g pane-active-border-fg brightred
## Status bar design
# status line
View Default (windows).sublime-keymap
[
// 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 }
]
},
View SDL_MessageBox.cpp
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 },
View seascape.glsl
/*
"Seascape" by Alexander Alekseev aka TDM - 2014
License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Contact: tdmaav@gmail.com
*/
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 Apr 26, 2016
Reads a file into a vector of unsigned char
View ReadAllBytes.cpp
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 Apr 27, 2016
Text Rendering with OpenGL
View TextureSetup.cpp
#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;