Instantly share code, notes, and snippets.

View start-pi-hole.sh
IP_LOOKUP="$(ip route get 8.8.8.8 | 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="192.168.1.125" # 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_"
endfunction
function! InsertEmptyLines()
silent g/.\n\n\@!/norm o
endfunction
function! FormatComicListEntries()
execute "normal! gg^VG:sort\<CR>"
View decode.md

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 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
View copy-and-rename.sh
for file in crushed-*; do cp "$file" "${file/crushed-/}"; done
View test-layout.sh
#!/bin/bash
# Clear rbenv variables before starting tmux
unset RBENV_VERSION
unset RBENV_DIR
tmux start-server;
cd .
View test-layout.yml
# /home/peter/.config/tmuxinator/test-layout.yml
name: test-layout
windows:
- email:
panes:
- echo zero
- echo one
- echo two
- echo three
View layout.md
  • 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]}
View yield_self_demo.rb
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!