This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyModule do | |
@moduledoc false | |
if Mix.env() == :prod do | |
@foo Application.fetch_env!(:myapp, :foo) | |
def foo, do: @foo | |
else | |
def foo, do: Application.fetch_env!(:myapp, :foo) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Type your phrase then ^D | |
perl -pe 'chop;s/([a-z]+)/lc($1)/ige' | perl -lpe 's/[^a-z0-9]+/-/ig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#replace_selected | |
echo -n "$2" | /usr/local/bin/jq . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp docs_before_closing_head_tag(:html) do | |
~s{<link rel="stylesheet" href="assets/doc.css">} | |
end | |
defp docs_before_closing_head_tag(_), do: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def project do | |
[ | |
apps_path: "apps", | |
build_embedded: Mix.env() == :prod, | |
start_permanent: Mix.env() == :prod, | |
aliases: aliases(), | |
deps: deps(), | |
# Docs | |
name: "MyProject", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+++ | |
date = {{ .Date }} | |
title = "{{ $t := now }}{{ $t.Format "1月2日"}}{{ if eq ($t.Weekday) 0 }}(日){{ end }}{{ if eq ($t.Weekday) 1 }}(月){{ end }}{{ if eq ($t.Weekday) 2 }}(火){{ end }}{{ if eq ($t.Weekday) 3 }}(水){{ end }}{{ if eq ($t.Weekday) 4 }}(木){{ end }}{{ if eq ($t.Weekday) 5 }}(金){{ end }}{{ if eq ($t.Weekday) 6 }}(土){{ end }}" | |
+++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a private key | |
$ openssl genrsa -out private-key.pem 2048 | |
# and public key | |
$ openssl rsa -in private-key.pem -pubout -out public-key.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch | grep -v -e 'master' -e 'deployment/' -e 'develop' -e '*' | xargs git branch -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Checkout theirs unmerged files and continue rebase | |
git ls-files --unmerged | awk '{ print $4 }' | uniq | xargs git checkout --theirs -- | |
git ls-files --unmerged | awk '{ print $4 }' | uniq | xargs git add -- | |
git rebase --continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyTypespec do | |
defmacro union_type({:"::", _, [name, types]}) when is_list(types) do | |
union = | |
types | |
|> Enum.reverse | |
|> Enum.reduce(fn x, acc -> | |
{:|, [], [x, acc]} | |
end) | |
quote do |