Skip to content

Instantly share code, notes, and snippets.

View powerslacker's full-sized avatar

powerslacker

View GitHub Profile
type Query{
// ...
findPaymentRequests(
offset: Int
limit: Int
locationId: String
isPaid: Bool
isRefunded: Bool
isPartiallyRefunded: Bool
isRecorded: Bool
@powerslacker
powerslacker / main.go
Created November 20, 2018 19:22
golang scan from stdin in a loop
package main
import (
"bufio"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
for {
@powerslacker
powerslacker / interfaces.go
Created March 17, 2018 16:40
interfaces FTW
// https://www.reddit.com/r/golang/comments/852i6m/about_to_switch_to_python_because_ive_hit_a_brick/?ref=share&ref_source=link
package main
import "errors"
const (
MonsterType = iota
CookingRecipeType
InventoryItemType
)
@powerslacker
powerslacker / download-workaround.html
Last active December 20, 2019 15:01
html5 download attribute workaround
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<a href="video/small.mp4" download="new-filename">click me!</a>
// flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]
function flatten (arr) {
let result = arr
// check if arr contains an array
while(result.find(item => Array.isArray(item))) {
// merge arr w/ top level arr
result = [].concat.apply([], result)
}
// when complete return flattened arr