Skip to content

Instantly share code, notes, and snippets.

View nqthqn's full-sized avatar
🍐
pear programming

Nate nqthqn

🍐
pear programming
View GitHub Profile
@nqthqn
nqthqn / main.go
Created July 11, 2020 17:04
Convert XML file to JSON file
package main
import (
"bufio"
"io/ioutil"
"os"
xj "github.com/basgys/goxml2json"
)
@nqthqn
nqthqn / secret.go
Created May 26, 2020 21:43
Generate random passwords
package main
import (
"flag"
"fmt"
"math/rand"
"os"
"strings"
"time"
)
@nqthqn
nqthqn / spotube.js
Created March 28, 2020 05:49
Spotify to YouTube Music
// Open dev tools on a spotify playlist and run this script
// You will get a list of links that will take you to searches for the songs
let tracks = [...document.querySelectorAll(".track-name-wrapper")]
.map(t => ({
name: t.querySelector(".tracklist-name").innerText,
artist: t.querySelector(".TrackListRow__artists").innerText,
album: t.querySelector(".TrackListRow__album").innerText
}))
.map(({ name, artist, album }) => {
const q = encodeURIComponent(`${name} ${artist} ${album}`);
0. index of available content
1. user request access to some content
a. form submission with email, hidden content_key
2. check redis - email registered already?
3. generate hash + content_key entry
4. email user link example.com/secret/:hash
5. user clicks link
6. remove hash + content_key entry
7. deliver bytes corresponding to content_key (look in hugo /public)
8. if user refreshes the /secret:hash page and no entry is found, redirect to index
@nqthqn
nqthqn / cheat.ts
Last active October 10, 2019 15:30
Typescript Cheats
// Typescript type cheatsheet
// TypeScript is a structural type system (not a nominal one)
// quacks like a duck it is a duck — if the props are the same, the types are considered the same
// interfaces are automatically implemented if thing has matching properties
enum Bar { Red, Green, Blue }
enum Bar2 { Red = 2, Green, Blue }
interface Foo {
@nqthqn
nqthqn / day1.elm
Last active December 13, 2018 03:33
AOC — copy paste to Ellie-App.com to play around
module Main exposing (main)
import Html exposing (Html, text)
import Set exposing (Set)
ints =
data
|> String.split "\n"
|> List.filterMap String.toInt
@nqthqn
nqthqn / presentation.cst
Last active October 18, 2018 02:18
code step throughs — a format for presenting lines of code in a beautiful way
repo: https://github.com/elm-eug/live-polls
show: /blob/master/src/Poll.elm#L18-L20
emph: L18
emph: L19
show: /blob/master/src/Poll.elm#L29-L43
emph: L29-L32
emph: L41,L43
show: /blob/develop/src/Main.elm#L23-L26
emph: L24
emph: L25
@nqthqn
nqthqn / dbuser.sql
Created September 10, 2018 17:26
Create database with user, postgresql
-- after running psql
CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
Name = "Hello"
Testing = ["1", "2", "3"]
@nqthqn
nqthqn / nginx.conf
Created June 1, 2018 21:09
2 php servers
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;