Skip to content

Instantly share code, notes, and snippets.

@dashaw92
dashaw92 / mahjong_board.rs
Last active February 1, 2017 17:27 — forked from anonymous/playground.rs
My mahjong board implementation prototype
use std::collections::HashMap;
use std::fmt;
/*
Hello, this is my prototype for storing boards in my mahjong project.
I defined the Board as a struct, and TileType as an enum with both an Empty option and a Used struct option
The entire game board is stored in a HashMap<i32, Vec<TileType>>
^-layer ^-Allows me to easily see if a tile is empty or not (empty spot on board)
The layer refers to what level of the game board the Vec<TileType> is on.

Keybase proof

I hereby claim:

  • I am dashaw92 on github.
  • I am dashaw92 (https://keybase.io/dashaw92) on keybase.
  • I have a public key whose fingerprint is 58C9 5C0C 1EAE 983A 4F23 D158 90D0 BC31 EE31 1C75

To claim this, I am signing this object:

@dashaw92
dashaw92 / pad.java
Created August 6, 2017 13:08
Create a byte array where every value is followed by a 0x00
//this is for https://github.com/dashaw92/500IQIdea
private static byte[] construct(String msg) {
byte[] packet = new byte[(2 + msg.length()) * 2];
packet[0] = 0x03;
packet[2] = (byte)msg.length();
for(int i = 0; i < msg.length(); i++) {
packet[4 + (i * 2)] = (byte)msg.charAt(i);
}
return packet;
}
@dashaw92
dashaw92 / init.vim
Last active September 28, 2017 04:34
My Nvimrc, based off @jad340's
set nocompatible
" Use a sane encoding
set encoding=utf-8
scriptencoding utf-8
" Autoinstall vim-plug
if empty(glob('C:\Users\Daniel\AppData\local\nvim\autoload\plug.vim'))
silent !curl -fLo C:\Users\Daniel\AppData\local\nvim\autoload\plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
@dashaw92
dashaw92 / caesar-cipher.rs
Last active October 23, 2017 19:45 — forked from Xinayder/caesar-cipher.rs
Caesar's cipher implemented in Rust
// Caesar's cipher implemented in Rust
// Made by Xinayder with the help of folks from #rust at irc.mozilla.org
//
fn encrypt(msg: &str, shift: u32) -> String {
let alphabet_upper: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let alphabet_lower: &str = "abcdefghijklmnopqrstuvwxyz";
let mut result: String = String::new();
if msg.trim().is_empty() {
return msg.to_owned()
@dashaw92
dashaw92 / SwitchFunction.bas
Last active April 5, 2018 19:05
Emulates the SWITCH function introduced in Excel 2016.
' Author: Daniel Shaw (dashaw92) - April 1, 2018
' This function emulates the behavior of SWITCH,
' a convenience function introduced in Excel 2016.
'
' To add this function to Excel, follow the steps listed on:
' https://support.office.com/en-us/article/create-custom-functions-in-excel-2f06c10b-3622-40d6-a1b2-b6748ae8231f
'
' Note: The 2016 version has a limit of 126
' conditions and results, whereas this version is
' only limited by memory. Otherwise, this should be
@dashaw92
dashaw92 / Microsoft.PowerShell_profile.ps1
Last active March 26, 2023 15:27
My PowerShell Profile
Import-Module PSConsoleTheme
# Custom prompt to show nested prompt level
#
Function Prompt {
Write-Host "PS" -NoNewLine
Write-Host -Fore DarkGreen "[$NestedPromptLevel]" -NoNewLine
Write-Host " $(Get-Location)>" -NoNewLine
return " "
}
@dashaw92
dashaw92 / Wallpaper.java
Created March 4, 2019 22:54
Program that generates a w95-esque tileable wallpaper
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.util.Random;
import javax.imageio.ImageIO;
public class Wallpaper {
public static void main(String[] args) throws Exception {
BufferedImage ig = new BufferedImage(255, 255, BufferedImage.TYPE_INT_ARGB);
Graphics g = ig.createGraphics();
@dashaw92
dashaw92 / Commandsell.patch
Created March 9, 2019 16:18
Modification to EssentialsX Commandsell.java to provide hooking into when people sell items to the server
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index e6c41a98..8897b6b5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -11,6 +11,9 @@ import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
@dashaw92
dashaw92 / build.gradle
Created March 23, 2019 07:02
Skeleton Kotlin/Spigot build.gradle
plugins {
id 'idea'
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
group 'me.daniel'
version '1.0'
//vars (CHANGE ME)