Skip to content

Instantly share code, notes, and snippets.

View ethagnawl's full-sized avatar
🐢

Pete Doherty ethagnawl

🐢
View GitHub Profile
@ethagnawl
ethagnawl / decode.md
Created September 7, 2018 03:27 — forked from yang-wei/decode.md
Elm Json.Decode tutorial and cheatsheet

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
@ethagnawl
ethagnawl / JacksonKotlinModuleExample.kt
Created August 23, 2018 04:49 — forked from hansenji/JacksonKotlinModuleExample.kt
Jackson Kotlin Module Example
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"))
ffmpeg -y -t 10 -i tmuxinator-edited-4.mov -vf fps=10,scale=900:-1:flags=lanczos,palettegen palette.png;
ffmpeg -t 10 -i tmuxinator-edited-4.mov -i palette.png -filter_complex "fps=10,scale=900:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
@ethagnawl
ethagnawl / copy-and-rename.sh
Created August 17, 2018 02:21
copy multiple files and rename using regex
for file in crushed-*; do cp "$file" "${file/crushed-/}"; done
@ethagnawl
ethagnawl / test-layout.sh
Created July 2, 2018 21:53
test layout tmuxinator script
#!/bin/bash
# Clear rbenv variables before starting tmux
unset RBENV_VERSION
unset RBENV_DIR
tmux start-server;
cd .
@ethagnawl
ethagnawl / test-layout.yml
Created June 21, 2018 13:53
tmuxinator test layout
# /home/peter/.config/tmuxinator/test-layout.yml
name: test-layout
windows:
- email:
panes:
- echo zero
- echo one
- echo two
- echo three
@ethagnawl
ethagnawl / layout.md
Last active June 21, 2018 13:11
custom tmuxinator layout
  • manually create your layout
  • run either tmux list-windows outside of your session or run list-windows from inside your session in the (tmux) command prompt
  • the output will contain a substring like: [layout e1ce,158x43,0,0{79x43,0,0,1,78x43,80,0[78x10,80,0,2,78x10,80,11,5,78x10,80,22,3,78x10,80,33,4]}]
  • copy/massage the substring to look like the following and you should be set:
windows:
  - editor:
      layout: e1ce,158x43,0,0{79x43,0,0,1,78x43,80,0[78x10,80,0,2,78x10,80,11,5,78x10,80,22,3,78x10,80,33,4]}
modified_str = "foo"
.yield_self { |str| str.split('') }
.yield_self { |str| str.join('-') }
.yield_self(&:upcase)
.yield_self { |str| "#{str}!" }
puts modified_str # F-O-O!
@ethagnawl
ethagnawl / default.html
Last active June 8, 2018 14:18
hakyll post css
<!doctype html>
<html lang="en">
<head>
<title>$title$ - peterdohertys.website</title>
$if(css)$
<link rel="stylesheet" href="/css/$css$.css" />
$endif$
</head>
@ethagnawl
ethagnawl / console
Created May 23, 2018 18:40
tmuxinator console
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "tmuxinator"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)