Skip to content

Instantly share code, notes, and snippets.

@jc00ke
jc00ke / advanced_nonce_plug_and_router.ex
Created November 12, 2024 22:03
CSP Nonce example for Fun With Flags UI
defmofule MyAppWeb.NoncePlug do
import Plug.Conn
def init(opts \\ []), do: opts
def call(conn, _opts) do
style_nonce = :crypto.strong_random_bytes(16) |> Base.encode64(padding: false)
script_nonce = :crypto.strong_random_bytes(16) |> Base.encode64(padding: false)
conn
|> assign(:my_app_style_nonce, style_nonce)
@jc00ke
jc00ke / install-instructions.md
Created August 7, 2023 17:51 — forked from crispyricepc/install-instructions.md
wlprop - An xprop clone for wlroots based compositors

Dependencies

Make sure you have installed the following commands:

  • swaymsg
  • jq
  • slurp
  • awk

Installation

" from https://github.com/aduros/dotfiles/blob/eab476fc62e74e46cb41bb5c094cede7a28a014f/home/.config/nvim/options.vim#L27
autocmd BufNewFile,BufRead *.hx set filetype=haxe
autocmd BufNewFile,BufRead *.jsfl set filetype=javascript
autocmd BufNewFile,BufRead ~/.config/dunst/dunstrc set filetype=dosini
autocmd BufNewFile,BufRead ~/.config/polybar/config set filetype=dosini
autocmd BufNewFile,BufRead ~/.config/tridactyl/tridactylrc set filetype=vim
autocmd BufNewFile,BufRead ~/.config/zathura/zathurarc set filetype=config
autocmd BufNewFile,BufRead ~/.lesskey set filetype=config
@jc00ke
jc00ke / nginx-config-auth-cert-ssl.md
Created July 14, 2022 20:04 — forked from alexishida/nginx-config-auth-cert-ssl.md
Tutorial to configure Nginx client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Original: https://gist.github.com/mtigas/952344

Convert SSL certificate from CRT format to PEM

openssl x509 -in server.crt -out server.der -outform DER
openssl x509 -in server.der -inform DER -out server.pem -outform PEM
@jc00ke
jc00ke / Convert PostgreSQL to SQLite
Created July 5, 2022 16:17 — forked from fiftin/Convert PostgreSQL to SQLite
Convert PostgreSQL to SQLite
1. Dump the data only sql to file
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql
2. scp to local
3. Remove the SET statements at the top
such as:
SET statement_timeout = 0;
SET client_encoding = 'SQL_ASCII';
4. Remove the setval sequence queries
#!/usr/bin/env bash
set -ex
trap 'handleError' ERR
handleError() {
echo ""
echo "If you encountered an error, please consider fixing"
echo "the script for your environment and creating a pull"
@jc00ke
jc00ke / firefox-snap-to-deb.sh
Last active July 14, 2023 06:24
Migrate Firefox from snap back to deb on Ubuntu Jammy+
#!/bin/env bash
sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
@jc00ke
jc00ke / gist:078cbe23ac56e76ee0a8ee64523b62dc
Created May 25, 2022 19:34
Migrate apt-key to keyrings file
> sudo apt-key list
# find last 8 of public signature, for example ABCD EFGH for jc00ke
> sudo apt-key export ABCDEFGH | sudo gpg --dearmour -o /usr/share/keyrings/jc00ke.gpg
> sudo -H gedit /etc/apt/sources.list.d/jc00ke.list
# add [arch=amd64 signed-by=/usr/share/keyrings/jc00ke.gpg] after deb
> sudo apt update
> sudo apt-key del ABCDEFGH
# summarized from https://askubuntu.com/a/1403964
#!/usr/bin/env bash
# https://discourse.elm-lang.org/t/simple-watcher-for-elm-make/3694
# https://twitter.com/evancz/status/1131650856024125440
# nice colors
COLOR_OFF="\e[0m";
DIM="\e[2m";
# random filename for the lock; see below
@jc00ke
jc00ke / Ubuntu default sound input and output.md
Created November 18, 2021 19:22 — forked from ChriRas/readme.md
Set up default audio device on Ubuntu 20.04 LTS

Problem

I have a notebook connected to a port replicator. I want to use the build-in speakers and microfone and not the external ones. If I boot my notebook in my port replicator Ubuntu changes the devices to external.

Solution

  1. Find your internal speaker
pactl list short sinks