Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcin Kulik sickill

View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active May 1, 2021
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
View proxmox_resize_pve-root
# Check disk space before
df -h
# Delete local-lvm storage in gui
lvremove /dev/pve/data
lvresize -l +100%FREE /dev/pve/root
resize2fs /dev/mapper/pve-root
View renaming.clj
;; Step 1) Produce a build with :advanced optimizations. Tell me the size of the .js file.
;; Step 2) Run `gzip` on your output .js file and tell me the size of the .js.gz file.
;; Step 3) Apply this monkey patch:
(in-ns 'cljs.closure)
(import '[com.google.javascript.jscomp VariableRenamingPolicy PropertyRenamingPolicy])
(def wrapped-set-options set-options)
(defn set-options [opts ^CompilerOptions compiler-options]
@jstepien
jstepien / reduce-and-gc.clj
Last active Mar 6, 2017
reduce-and-gc.clj
View reduce-and-gc.clj
;; Let's experiment with Clojure 1.8.0 running with a relatively small heap
;; of 10MB. To avoid any extra dependencies, we'll start it as follows:
;;
;; java -Xmx10m -jar clojure-1.8.0.jar
;;
;; Copy following expressions into your REPL one by one.
;;
;; Let's take a small number, for instance one million.
(def small-num (* 1000 1000))
@mjnaderi
mjnaderi / install-arch.md
Last active May 4, 2021 — forked from mattiaslundberg/arch-linux-install
Install Arch Linux with Full Disk Encryption (LVM on LUKS)
View install-arch.md
@oinopion
oinopion / read-access.sql
Created Oct 5, 2016
How to create read only user in PostgreSQL
View read-access.sql
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@brianleroux
brianleroux / wtf-sns-apns.js
Created Aug 5, 2016
Send a silent push notification to APNS with AWS SNS.
View wtf-sns-apns.js
sns.publish({
TargetArn: device.arn,
MessageStructure: 'json',
Message: JSON.stringify({
default: 'you will never see this muah!',
APNS_SANDBOX: JSON.stringify({
aps: {
'alert': '',
'content-available': 1
},
@bastman
bastman / docker-cleanup-resources.md
Created Mar 31, 2016
docker cleanup guide: containers, images, volumes, networks
View docker-cleanup-resources.md

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
@jamonholmgren
jamonholmgren / plug.conn.ex
Created Mar 9, 2016
Typical Elixir Phoenix Plug.Conn struct contents, in an easy-to-read format. By Jamon Holmgren.
View plug.conn.ex
%Plug.Conn{
adapter: {Plug.Adapters.Cowboy.Conn, :...},
assigns: %{
my_assigns: "here"
},
before_send: [
#Function<7.125546534/1 in Phoenix.Controller.fetch_flash/2>,
#Function<1.127904613/1 in Plug.Session.before_send/2>,
#Function<1.43511252/1 in Plug.Logger.call/2>,
#Function<0.70322810/1 in Phoenix.LiveReloader.before_send_inject_reloader/1>
@ulve
ulve / remoteobserver.sh
Created Feb 2, 2016
Connect to remote phoenix node with observer
View remoteobserver.sh
# On the phoenix node
# if production mode
MIX_ENV=prod PORT=4001 elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -pa _build/prod/consolidated -S mix phoenix.server
# if debug mode
elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -S mix phoenix.server
# On the observing node
# Terminal 1, start SSH tunnel
ssh -N -L 9001:localhost:9001 -L 4369:localhost:4369 pi@192.168.1.31