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 / blp.py
Last active June 3, 2024 06:38
Beta Transformed Linear Opinion Pool (Python)
blp_N = len(sources)
blp_X = np.array(blp_X) # (examples, sources)
blp_y = np.array(blp_y) # (examples as 1/0,)
def log_llh_blp(params, x, y):
a, b, w = params[0], params[1], params[2:]
hswp = st.beta.cdf(np.dot(x, w), a, b)
llh = scipy.special.xlogy(y, hswp) + scipy.special.xlogy(1.0 - y, 1.0 - hswp)
return -np.mean(llh)
from sklearn.base import BaseEstimator, ClassifierMixin
import numpy as np
class DelphiClassifier(BaseEstimator, ClassifierMixin):
def __init__(self, base_clfs, output_model=None, rounds=3):
self.base_clfs = base_clfs
self.output_model = output_model
self.rounds = rounds
self.round_clfs = {}
@sshh12
sshh12 / new-box.sh
Last active January 23, 2021 19:36
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y python3-pip python3-dev tmux nodejs npm nano net-tools htop ufw git curl less build-essential
sudo pip3 --upgrade pip install black requests
sudo npm install -g pm2
"""
Use this script to migrate notes from Samsung Notes to Google Keep.
1. Export notes from Samsung Notes as .pdf files
2. Copy those into the same folder as this script.
3. Open Google Keep in your browser
4. $ python samsungnotes2keep.py
You may need to ($ pip install keyboard pdfplumber)
"""
import pdfplumber
(function(console){
console.save = function(data{
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4);
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a');
a.download = 'console.json'
a.href = window.URL.createObjectURL(blob);
sudo apt update
sudo apt-get upgrade -y
sudo apt install openjdk-8-jre-headless tmux
sudo ufw allow 25565
sudo ufw allow 22
sudo ufw enable
java -Xmx1024M -Xms1024M -jar minecraft_server.1.16.2.jar nogui
https://launcher.mojang.com/v1/objects/c5f6fb23c3876461d46ec380421e42b289789530/server.jar
\u00A73\u00A7l\u25BC\u00A73\u00A7l Convergent \u00A7rMinecraft
import React from 'react';
import { ResponsiveLine } from '@nivo/line'
import logo from './logo.svg';
import './App.css';
let data = require('./data.json')
function App() {
return (
<div className="App">
import json
import sys
import csv
def main(fn):
with open(fn, 'r', newline='') as csvfile:
reader = csv.DictReader(csvfile)
rows = [dict(row) for row in reader]
with open('data.json', 'w') as jsonfile:
@sshh12
sshh12 / crop_imgs.py
Last active January 23, 2020 22:09
Simple image data utilities.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import glob
import os
import time
import smartcrop
from PIL import Image
from multiprocessing import Pool
import pickle
@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