Skip to content

Instantly share code, notes, and snippets.

View sshh12's full-sized avatar
πŸ‘¨β€πŸ’»
Where there is code, there is code.

Shrivu Shankar sshh12

πŸ‘¨β€πŸ’»
Where there is code, there is code.
View GitHub Profile
@sshh12
sshh12 / pwi-mc-restore.py
Created July 21, 2019 01:27
The PerWorldInventory plugin deleted a bunch of items from players, this script manually spawns in the items from the server's config/backup files.
import json
USERNAME = '<adminname>'
BACKUP = '<backup_file>.json'
def parse_item_json(item_json):
name = item_json['item']['type']
amt = item_json['item'].get('amount', 1)
return name, amt
@sshh12
sshh12 / im2gitfiti.py
Created July 15, 2019 23:42
Convert an image into a json array.
from PIL import Image
im = Image.open('banner.png').convert('RGB')
width, height = im.size
col_start = -1
for c in range(width):
content = False
for r in range(height):
color = im.getpixel((c, r))
if color != (255, 255, 255):
@sshh12
sshh12 / store.js
Last active July 30, 2019 22:24
Shridux - A superior global state management library.
// Shridux - A superior global state management library
class GlobalStore {
_initState = {};
_bindings = {};
setStore(newState) {
for(let key in newState) {
if(!(key in this._bindings)) {
@sshh12
sshh12 / SaitekFlightMultiPanel.py
Created April 25, 2019 23:14
A snippet for controlling a "Saitek Flight Multi Panel" with Python via HID.
# http://www.saitek.com/uk/prod-bak/multi.html
from pynput.keyboard import Key, Controller
import hid
import time
keyboard = Controller()
name = 'Pro Flight Multi Panel'
vend_id, product_id = None, None
@sshh12
sshh12 / PeopleMatching.py
Created March 5, 2019 23:26
Take rankings from 2 csv files and use them to compute the best pairings.
from matching import Player, HospitalResident
from collections import defaultdict
import csv
def read_csv_ranks_v1(fn, other_fields=2):
users = {}
items = []
@sshh12
sshh12 / MelSpec4Mic.py
Created February 17, 2019 19:34
Live mic -> live melspectrogram plot
import cv2
import numpy as np
import pyaudio
import librosa
import librosa.display
import matplotlib.pyplot as plt
import time
rate = 16000
chunk_size = rate // 4
import numpy as np
import cv2
class CellularAutomaton:
def __init__(self, size=1000, rule=0):
self.size = size
self.rule = rule
@sshh12
sshh12 / ArrayMaker.java
Created September 4, 2018 18:40
Array Runtime Tests
public class ArrayMaker {
public static void main(String[] args) {
int N = 150000;
for(int n = 500; n < N; n += 100) {
long sumInt = 0, sumLong = 0, sumObject = 0;
from textblob.classifiers import DecisionTreeClassifier as TextClassifier
from datetime import datetime
import matplotlib.pyplot as plt
import csv
num_months = 13
with open('train.csv', 'r') as fp:
clf = TextClassifier(fp, format="csv")
@sshh12
sshh12 / CS UIL.ipynb
Created March 22, 2018 00:38
Messing w/CS UIL Data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.