Skip to content

Instantly share code, notes, and snippets.

@YannickFricke
Created August 20, 2024 10:00
Show Gist options
  • Save YannickFricke/9c2507f664276129e5bf7884b997304f to your computer and use it in GitHub Desktop.
Save YannickFricke/9c2507f664276129e5bf7884b997304f to your computer and use it in GitHub Desktop.
My VSCode Elixir snippets
{
"Inspect a value": {
"prefix": "ins",
"description": "Inspect a value with a label",
"body": [
"IO.inspect($1, label: \"$1\")"
]
},
"Pipe inspect": {
"prefix": "insp",
"description": "Inspect a value with a pipe operator",
"body": [
"|> IO.inspect(label: \"$1\")"
]
},
"Pipe operator": {
"prefix": "p",
"body": "|> "
},
"String type": {
"prefix": "string",
"body": "String.t()"
},
"t Type": {
"prefix": "tt",
"body": [
"@type t() :: %__MODULE__{",
" id: $1,",
" $2",
"}"
]
},
"t Type with timestamps": {
"prefix": "ttwts",
"body": [
"@type t() :: %__MODULE__{",
" id: $1,",
" $2",
" inserted_at: DateTime.t(),",
" updated_at: DateTime.t()",
"}"
]
},
"ecto fields": {
"prefix": "ef",
"body": [
"@required_fields ~w($1)a",
"",
" @optional_fields ~w($2)a"
]
},
"ecto migration uuid table": {
"prefix": "emut",
"body": [
"create table(:$1, primary_key: false) do",
" add :id, :uuid, null: false",
" $2",
"end"
]
},
"ecto migration uuid table with timestamps": {
"prefix": "emutwts",
"body": [
"create table(:$1, primary_key: false) do",
" add :id, :uuid, null: false",
" $2",
" add :inserted_at, :utc_datetime, null: false",
" add :updated_at, :utc_datetime, null: false",
"end"
]
},
"module": {
"prefix": "m",
"body": "__MODULE__"
},
"module struct": {
"prefix": "ms",
"body": "%__MODULE__{$0}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment