Skip to content

Instantly share code, notes, and snippets.

View johnknott's full-sized avatar
🎯
Focusing

John Knott johnknott

🎯
Focusing
View GitHub Profile
@qertoip
qertoip / sliding_session_timeout.ex
Last active July 18, 2023 15:33
Elixir / Phoenix Sliding Session Timeout Plug
# How to use it:
#
# Plug it at the end of your :browser pipeline in your Phoenix app router.ex
# Make sure it is plugged before your session-based authentication and authorization Plugs.
#
# pipeline :browser do
# plug :accepts, ["html"]
# plug :fetch_session
# plug :fetch_flash
# plug :put_secure_browser_headers
@dragolabs
dragolabs / proxmox-cli-and-tips.md
Last active November 28, 2024 23:07
Useful proxmox commands

Find next free VM ID

pvesh get /cluster/nextid

Create containter with external and internal nets

pct create 100 \
    local:vztmpl/ubuntu-16.04-standard_16.04-1_amd64.tar.gz \
    --cores 2 --cpuunits 1024 \
@jpbecotte
jpbecotte / Vue-cli-3-Phoenix-1.3-HOWTO.md
Last active March 28, 2025 04:04
Vue-cli 3, Phoenix 1.3, a complete how-to

Introduction

I have been struggling to start a new project with Phoenix 1.3 and the new vue-cli 3 for Vue.js. There are tons of example already but none of them suited my needs, because:

  • I want to use the new Vue-cli to select the features that I want,
  • I do NOT want to setup Webpack (I know, what a shame!). The new Vue-cli includes the new vue-cli-service, which uses an instance of webpack-dev-server, so you don't have to import it manually in your project.
  • I do not want to use Brunch.

Create your Phoenix App

Assuming that you have Elixir and Phoenix 1.3 are both installed, let's build our new App.

@posilva
posilva / context.ex
Created March 31, 2018 23:07 — forked from ericstumper/context.ex
Guardian Authentication with Absinthe GraphQL in Elixir
defmodule Languafy.Web.Context do
@behaviour Plug
import Plug.Conn
alias Languafy.User
def init(opts), do: opts
def call(conn, _) do
case build_context(conn) do
{:ok, context} ->
@TimJones
TimJones / proxmox-cloudinit-custom-userdata.pm
Created November 24, 2018 16:52
Proxmox helper script to load custom cloudinit user-data
#!/usr/bin/perl
use strict;
use warnings;
use PVE::Tools qw(file_get_contents);
use PVE::QemuConfig;
use PVE::QemuServer;
use PVE::QemuServer::Cloudinit;
@ks2211
ks2211 / Phoenix esbuild with Tailwind and Fontawesome
Last active July 30, 2024 01:50
Phoenix with esbuild, fortawesome, and tailwindcss
Phoenix esbuild with Tailwind+Fontawesome
@karlseguin
karlseguin / db.ex
Created February 5, 2022 03:39
Elixir without Ecto, A thin Postgrex wrapper
# see https://www.openmymind.net/Elixir-Without-Ecto/
defmodule A.DB do
defmacro __using__(_) do
quote location: :keep do
@name __MODULE__
def child_spec(opts) do
%{
id: __MODULE__,
@johnknott
johnknott / elixir-gen-server.code-snippets
Last active March 12, 2022 11:39
VSCode snippet to help with creation of Elixir GenServers and addition of handle_call and handle_cast and related client API functions
{
"GenServer Template": {
"scope": "elixir",
"prefix": "gs",
"body": [
"defmodule ${1}.${2} do",
"\tuse GenServer",
"",
"\t# Client",
"",