Skip to content

Instantly share code, notes, and snippets.

View Echooff3's full-sized avatar

Echooff3 Echooff3

  • South of heaven
View GitHub Profile
@Echooff3
Echooff3 / CircularBuffer.cs
Created November 21, 2023 20:19
c# circular buffer
namespace Utils
{
public class CircularList<T> : List<T>
{
private int Index;
public CircularList() : this(0) { }
public CircularList(int index)
{
@Echooff3
Echooff3 / creds.ps1
Created August 9, 2023 22:14
Update AWS Creds from Powershell
# Make sure you have a creds object in your clipboard
function creds () {
Import-Module "Microsoft.PowerShell.Management"
Import-Module "PsIni" # Make sure you have this installed
$pth = "~\.aws\credentials" # Update to your path
$creds = Get-IniContent $pth
$cb = Get-Clipboard
try {
$first, $rest = $cb
@Echooff3
Echooff3 / App.js
Created January 19, 2023 21:33
Very simple link expiration for React Aps
if(window.location.search.indexOf('key') > -1 )
{
try {
// Could probably do this better but I'm being lazy
const linkKey = window.location.href.toString().split('=')[1]
// Side effect of being lazy means I have to add back the 2 == at the end of the string I just split
var bytes = CryptoJS.AES.decrypt(linkKey + '==', KEY);
var originalText = bytes.toString(CryptoJS.enc.Utf8);
passUser = moment(originalText).valueOf() > moment().valueOf()
} catch (error) {
@Echooff3
Echooff3 / package.json
Created June 9, 2015 19:07
Batch Resize & Append with node
{
"name": "resizer",
"version": "1.0.0",
"description": "",
"main": "resizer.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@Echooff3
Echooff3 / convert.py
Created November 24, 2021 22:10
Python - Change midi channel 1 to 10 (converting midi drum samples)
from mido import MidiFile
from pathlib import Path
for name in Path('./ConvertThis').rglob('*.mid'):
print(name)
mid = MidiFile(name, clip=True)
for message in mid.tracks[0]:
if message.type in ('note_on','note_off'):
message.copy(channel=9)
mid.save(name)
@Echooff3
Echooff3 / index.js
Created January 15, 2021 00:10
Palindrome
const isPalindrome = str => [...str].reverse().join('') === str
const canBePalindrome = str => {
const res = [...str].reduce((a,c) => {
a[c] = !a[c] ? 1 : a[c]+1
return a
}, {})
//there needs to be 1 odd number letter and the reset even
const check = Object.entries(res).map(x => {
return x[1] % 2
@Echooff3
Echooff3 / loadfont.js
Created December 7, 2020 07:14
Dynamic Font Loading
window.loadFont = async(base64) => {
const byteArray = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
// Add font face 'customFont' to an element. It will fallback until a font gets loaded
const font = new FontFace('customFont', byteArray);
// wait for font to be loaded
await font.load();
// add font to document
document.fonts.add(font);
};
@Echooff3
Echooff3 / Gradient.js
Last active November 21, 2020 23:30
Moving Gradient in React
import React, { useRef, useEffect } from 'react'
const Gradient = ({ className }) => {
const refContainer = useRef()
const refCanvas = useRef()
const refAnimationFrame = useRef()
useEffect(() => {
const colors = [
@Echooff3
Echooff3 / README.md
Last active August 10, 2020 23:44
Scikit-Learn - Gaussian Naive Bayes (File or Binary)

Scikit-Learn - Gaussian Naive Bayes (File or Binary)

I wanted to create a quick tool to determine if a file is a text file or binary file. I'm not 100% sure this was right approach. However, early testing is showing that it's working.

My assumption is that from the first 128 bytes of a file that you can dermine its type.

I'm going to throw more files at it and train it up some more.

@Echooff3
Echooff3 / Dockerfile
Created November 20, 2019 18:04
Docker Maven Build and Run Java 11
FROM maven:slim as builder
COPY . /opt/app
WORKDIR /opt/app
RUN mvn package -DskipTests
FROM openjdk:11-jdk-slim as runtime
ARG properties_file=dockerConfigs/dev.application.properties
EXPOSE 8080
WORKDIR /opt/app
COPY --from=builder /opt/app/target/app-0.0.1-SNAPSHOT.jar ./