Skip to content

Instantly share code, notes, and snippets.

View johnniehard's full-sized avatar
🚀
Making it happen!

Johnnie Hård johnniehard

🚀
Making it happen!
View GitHub Profile
@johnniehard
johnniehard / wham.sh
Last active December 10, 2022 07:45
I wanted to copy all of the .wav files from a wierdly nested directory structure into a flat folder. The filenames unfortunately had lots of spaces and single quotes in them. This is what ended up working.
#! /bin/bash
find . -name '*.wav' -print0 | xargs -I{} --null cp -u {} ../target_folder
@johnniehard
johnniehard / findByList.sh
Created April 26, 2022 10:27
Hittar rekursivt filer från en textfil i en mapp och kopierar dem till /targetdir.
find . | grep -F -f filelist.txt | xargs cp -t /targetdir
@johnniehard
johnniehard / parseCsv.ts
Created October 9, 2021 12:29
Async wrapper for csv-parse
import parse, { Options } from "csv-parse";
export function parseAsync(csv: string, options: Options) {
return new Promise<any[]>((resolve, reject) => {
parse(csv, options, (err, output) => {
if (err) {
return reject(err)
}
resolve(output)
### Keybase proof
I hereby claim:
* I am johnniehard on github.
* I am johnniehard (https://keybase.io/johnniehard) on keybase.
* I have a public key ASDjD47Af3YTeb84-b-55Ft4ssJjeXpP7641KEAAJUaXkAo
To claim this, I am signing this object:
@johnniehard
johnniehard / jq.sh
Last active February 25, 2021 09:34
Get strings longer than x with jq
cat popular_searches.json | jq '[.[] | {search} | map(select(length >= 4)) | .[0] | select(. != null)]' > popular_searches_len_gte_4.json
@johnniehard
johnniehard / food-color-names.csv
Created October 3, 2020 04:53
Tasty CSS color names
color comment
salmon
tomato
orange
peachpuff Questionable? It has peach, but wat's a puff?
lime
olive
lavender Questionable.
plum
honeydew
@johnniehard
johnniehard / getradius.sql
Created July 1, 2020 08:38
Getting the centroid and radius of (circle) polygons with postgis.
create table "magnus-etuna".trees as
select fid, center as geom, radius as crownRadius from "magnus-etuna"."tree-polygons", ST_MinimumBoundingRadius(geom) as geom;
dokku apps:create hasura
dokku domains:add hasura hasura.my.domain.com
dokku postgres:create hasura-db
dokku postgres:link hasura-db hasura
dokku config:set hasura HASURA_GRAPHQL_DATABASE_URL="<info from above command>" HASURA_GRAPHQL_ADMIN_SECRET="blahblah" HASURA_GRAPHQL_ENABLE_CONSOLE="true"
dokku proxy:ports-set hasura http:80:8080
docker pull hasura/graphql-engine
docker tag hasura/graphql-engine dokku/hasura
dokku tags:deploy hasura
dokku letsencrypt hasura
@johnniehard
johnniehard / TestSketch.js
Last active April 3, 2020 19:34
Using p5.js with React using custom hook.
import useSketch from ".";
export default function TestSketch() {
const sketch = useSketch(s => {
s.setup = () => {
s.createCanvas(800, 600)
}
@johnniehard
johnniehard / eebatch.js
Created March 20, 2020 12:20
kör alla tasks i EE webbklienten
function runTaskList() {
//1. task local type-EXPORT_FEATURES awaiting-user-config
//2. task local type-EXPORT_IMAGE awaiting-user-config
var tasklist = document.getElementsByClassName('awaiting-user-config');
for (var i = 0; i < tasklist.length; i++)
tasklist[i].children[2].click();
}
// confirmAll();
function confirmAll() {
var ok = document.getElementsByClassName('goog-buttonset-default goog-buttonset-action');