Skip to content

Instantly share code, notes, and snippets.

View RichardJohnn's full-sized avatar

Richard RichardJohnn

  • HackerNoon
  • Michigan
  • 08:20 (UTC -05:00)
View GitHub Profile
@RichardJohnn
RichardJohnn / Euler No. 125
Created February 22, 2014 15:07
J for Project Euler 125.
+/(#~(100000000)&>) (#~(=|.&.":)"0)x:(~.,(2+i.700)(+/@:*:)\>:i.7090)
@RichardJohnn
RichardJohnn / removeOrigs.sh
Created June 25, 2014 16:16
auto remove .orig files on os x
#brew install fswatch
#replace ~/shit with directory to watch, -r for recursively
fswatch -r0 ~/shit | while read -d "" event
do
regex='\.orig$'
if [[ ${event} =~ $regex && -e ${event} ]]
then
rm ${event}
@RichardJohnn
RichardJohnn / heapsAlgorithmForPermutationGeneration.rs
Created September 25, 2015 01:37
Heap's Algorithm for Permutation Generation in Rust
//https://en.wikipedia.org/wiki/Heap%27s_algorithm
fn main(){
let mut array = vec![1,2,3,4];
generate(4, &mut array);
}
fn generate(n : usize, a : &mut Vec<usize>) {
if n == 1 {
println!("{:?}", a);
}
@RichardJohnn
RichardJohnn / use.coffee
Last active April 10, 2020 09:50
universal sentence encoder - percent similarity
tf = require('@tensorflow/tfjs-node')
use = require('@tensorflow-models/universal-sentence-encoder')
use.load().then (model) ->
sentences = [
'Hello.'
'Hi.'
'Greetings.'
'Sup?'
"It's nice to meet you."
'How are you?'
@RichardJohnn
RichardJohnn / chaos.js
Last active April 16, 2020 19:20
Chaos Game
//chaos game (https://en.wikipedia.org/wiki/Chaos_game)
//parameters: n = 5, r = 2 & cannot pick same vertex twice
//demo: https://editor.p5js.org/RichardJohnn/sketches/VxFo5o_Yv
//image: https://i.imgur.com/iBFEZDO.png
let w ;
let h ;
let x = 0;
let y = 0;
let anchors = [];
@RichardJohnn
RichardJohnn / superPrettyUrl.js
Created February 11, 2021 14:06
post pretty URLs to super
const fs = require("fs");
const cheerio = require("cheerio");
const fetch = require("node-fetch");
const path = require( 'path' );
// Make an async function that gets executed immediately
(async ()=> {
const files = await fs.promises.readdir("./");
const prettyUrls = new Set()
@RichardJohnn
RichardJohnn / story.json
Created March 9, 2021 20:25
Example HN Story
{
"id": "lFthoYgwXZzfpNWyr5FD",
"tags": [
"react",
"reactjs",
"javascript",
"web-development",
"website-development",
"loading-screen",
"reactjs-loading",
@RichardJohnn
RichardJohnn / split-transients.py
Created February 9, 2023 23:01 — forked from kylemcdonald/split-transients.py
Split an audio file into multiple files based on detected onsets from librosa.
#!/usr/bin/env python
import argparse
import soundfile
import librosa
import numpy as np
import os
from progressbar import ProgressBar, Percentage, Bar
parser = argparse.ArgumentParser(