Skip to content

Instantly share code, notes, and snippets.

Avatar

Echooff3 Echooff3

  • South of heaven
View GitHub Profile
@Echooff3
Echooff3 / convert.py
Created Nov 24, 2021
Python - Change midi channel 1 to 10 (converting midi drum samples)
View convert.py
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)
View index.js
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 Dec 7, 2020
Dynamic Font Loading
View loadfont.js
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 Nov 21, 2020
Moving Gradient in React
View Gradient.js
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 Aug 10, 2020
Scikit-Learn - Gaussian Naive Bayes (File or Binary)
View README.md

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 Nov 20, 2019
Docker Maven Build and Run Java 11
View Dockerfile
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 ./
View twoPlueFour.cpp
// sequence template
#include <iostream>
using namespace std;
/* OMG awesome void_t metafunction will change your life */
template <typename...>
using void_t = void;
typedef std::integral_constant<int, 2> two_t;
typedef std::integral_constant<int, 4> four_t;
@Echooff3
Echooff3 / sample.py
Last active Jan 3, 2018
Contrived tf.estimator.DNNClassifier
View sample.py
import tensorflow as tf
import numpy as np
import sys
from tensorflow.python import debug as tf_debug
hooks = [tf_debug.LocalCLIDebugHook()]
tf.logging.set_verbosity(tf.logging.INFO)
trainX = np.array([[1,1,0,1],[0,0,1,0],[1,0,1,1],[0,0,1,1]])
labelX = np.array([[1],[0],[1],[0]])
num_classes = 2
feature_names = ['f1','f2','f3','f4']
View gist:e149ac7e24f65a54339f5b3a9aafb3a5
head -200 /dev/urandom | cksum | cut -f1 -d " "
find ./ -name "*.zip" -type f -print0 | xargs -0 -I {} sh -c 'unzip {} -d ./$(head -200 /dev/urandom | cksum | cut -f1 -d " ")'
@Echooff3
Echooff3 / index.js
Last active Sep 8, 2017
Copy GloVe to redis db
View index.js
const path = require('path')
const redis = require("redis")
var client = redis.createClient()
const LineByLineReader = require('line-by-line')
const lr = new LineByLineReader(process.argv[2]);
var lineCount = 0
var currentWord = ""
var filename = path.basename(process.argv[2]).replace('.', '')
var status = require('node-status')
var pizzas = status.addItem('pizza', {