Skip to content

Instantly share code, notes, and snippets.

View johnknott's full-sized avatar
🎯
Focusing

John Knott johnknott

🎯
Focusing
View GitHub Profile
@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",
"",
@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__,
@ks2211
ks2211 / Phoenix esbuild with Tailwind and Fontawesome
Last active January 31, 2024 05:08
Phoenix with esbuild, fortawesome, and tailwindcss
Phoenix esbuild with Tailwind+Fontawesome
@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;
@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} ->
@jpbecotte
jpbecotte / Vue-cli-3-Phoenix-1.3-HOWTO.md
Last active August 23, 2020 05:32
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.

@dragolabs
dragolabs / proxmox-cli-and-tips.md
Last active January 4, 2024 10:21
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 \
@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
@roadrunner2
roadrunner2 / 0 Linux-On-MBP-Late-2016.md
Last active May 13, 2024 12:14
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@bglusman
bglusman / elixir_decrypt.exs
Last active March 26, 2017 16:58
simple working ruby-encryption to elixir-decryption (DO NOT USE a zero IV for real)
defmodule Decrypt do
@iv String.duplicate("0", 16)
def unpad(data) do
to_remove = :binary.last(data)
:binary.part(data, 0, byte_size(data) - to_remove)
end
def decrypt(data, key) do