Instantly share code, notes, and snippets.

Pete Doherty ethagnawl

View GitHub Profile
View decode.elm
-- adding example here for posterity's sake
-- original example can be found at:
-- source material can be found at:
module Main exposing (main)
import Html exposing (Html, text, programWithFlags)
import Json.Decode
View input.rc
set completion-ignore-case On
#TAB: menu-complete
Tab: complete
set editing-mode vi
# operate-and-get-next allows you to navigagte to history
# and then keep executing commands successively from
# that point onwards
#!/usr/bin/env bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
echo "DIR: $DIR"
echo "SRC: $SRC"
echo "DEST: $DEST"
View index.html
<!DOCTYPE html>
<meta charSet="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="generator" content="Gatsby 2.0.68" />
<link as="script" rel="preload" href="/component---src-pages-index-js-ac2364b3c7ba3836ce1f.js" />
<link as="script" rel="preload" href="/app-b7a4b847d9bcda823daf.js" />
View SceneComponentElm.js
const Elm = require("react-elm-components");
const React = require("react");
const ElmApplication = require("./src/Main.elm");
const ScenesComponentElm = ({scenes}) => (
flags={{ scenes: scenes }}
IP_LOOKUP="$(ip route get | awk '{ print $NF; exit }')" # May not work for VPN / tun0
IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}')" # May not work for VPN / tun0
#IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
IP="" # use $IP, if set, otherwise IP_LOOKUP
IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP
DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever.
echo "### Make sure your IPs are correct, hard code ServerIP ENV VARs if necessary\nIP: ${IP}\nIPv6: ${IPv6}"
docker run -d \
--name pihole \
View format-comic-list-entries.viml
function! InsertHyphensAndUnderscores()
execute "normal! i- wi_f#gea_"
function! InsertEmptyLines()
silent g/.\n\n\@!/norm o
function! FormatComicListEntries()
execute "normal! gg^VG:sort\<CR>"

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
View JacksonKotlinModuleExample.kt
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
fun main(args: Array<String>) {
// val mapper = ObjectMapper().registerModule(KotlinModule())
// val mapper = ObjectMapper().registerKotlinModule()
val mapper = jacksonObjectMapper()
val writer = mapper.writerWithDefaultPrettyPrinter()
val json1 = writer.writeValueAsString(Data1(1, "Foo", "Bar"))
View gist:4fea9016fee7300211a986d9fb68ee46
ffmpeg -y -t 10 -i -vf fps=10,scale=900:-1:flags=lanczos,palettegen palette.png;
ffmpeg -t 10 -i -i palette.png -filter_complex "fps=10,scale=900:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif