Skip to content

Instantly share code, notes, and snippets.

@scratchyone
scratchyone / midi.rs
Created March 18, 2020 16:32
Midi -> Scratch
use midly::Smf;
use std::env;
use std::fs;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::path::Path;
#[derive(Eq, PartialEq)]
struct Note {
tick: i32,
pub fn prime(amount: i32) -> Vec<i64> {
let amount: usize = amount as usize;
let mut out: Vec<usize> = (0..amount)
.map(|n| {
if n % 2 == 1 && n % 5 != 0 && n % 3 != 0 && n % 7 != 0 {
n
} else {
0
}
})
pub fn prime(amount: i32) -> Vec<i64> {
let amount: usize = amount as usize;
let mut out: Vec<usize> = (0..amount).collect::<Vec<usize>>();
for x in 2..amount {
for i in (x * x..amount).step_by(x) {
out[i] = 0;
}
if out[x] == 0 {
continue;
}
pub fn prime(amount: i32) -> Vec<i64> {
let mut out: Vec<i64> = Vec::with_capacity(amount as usize / 3);
let mut allowed: Vec<bool> = vec![false; amount as usize];
for i in
(0_usize..amount as usize).filter(|n| n % 2 == 1 && n % 5 != 0 && n % 3 != 0 && n % 7 != 0)
{
allowed[i] = true;
}
out.push(2_i64);
out.push(3_i64);
@scratchyone
scratchyone / scratchusernamehash.user.js
Last active September 18, 2020 05:26 — forked from nathanprocks/scratchusernamehash.user.js
Scratch Username Hash Userscript
// ==UserScript==
// @name Scratch Username Hash
// @namespace nathanprocks.scratchusernamehash
// @version 0.1
// @description Kaj was here
// @author nathanprocks and scratchyone
// @match https://scratch.mit.edu/*
// @grant none
// @require https://cdn.rawgit.com/jupiterio/466bbd644eb3d4b680326da15520071a/raw/be552d004ab21ab8b3bb04e687bb85d231c20554/4096mostFrequentEnglishWords.js
// @require https://cdn.rawgit.com/emn178/js-sha3/master/build/sha3.min.js