Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcin Kulik sickill

View GitHub Profile
@sickill
sickill / asciinema-upload.sh
Last active Jun 1, 2021
Upload local recording to asciinema.org with curl
View asciinema-upload.sh
curl -v -u $USER:$(cat ~/.config/asciinema/install-id) https://asciinema.org/api/asciicasts -F asciicast=@/path/to/demo.cast
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
@sickill
sickill / script-template.sh
Created Dec 27, 2020 — forked from m-radzikowski/script-template.sh
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 warden.rb
Rails.configuration.middleware.use Rack::OpenID
Rails.configuration.middleware.use RailsWarden::Manager do |manager|
manager.default_strategies :remember_me_token, :password_form, :api_token, :openid
manager.failure_app = ExceptionsController
end
# Setup Session Serialization
class Warden::SessionSerializer
def serialize(record)
View collatz.md

I implemented simple (dumb) algorithm for finding the largest Collatz trajectory (see Collatz conjecture) for all numbers < 100,000,000 in Python, Rust and Elixir.

I benchmarked them with time command, assuming boot time is negligible (Python and Elixir need ~1 sec to boot before the calculation loop starts but their runtime is in hundreds of seconds anyway. Rust program boots in couple of milliseconds.)

@sickill
sickill / gist:3930651
Created Oct 22, 2012
You don't need bundle exec, rbenv-bundler and other bundler integration scripts
View gist:3930651

You don't need bundle exec, rbenv-bundler or other bundler integration scripts

You just need 2 things

Just prepend $PATH with .bundle/bin:

$ cat ~/.bashrc
...
export PATH=".bundle/bin:$PATH"
...
@sickill
sickill / line_break1.rb
Created Mar 8, 2012
Line breaking in Ruby
View line_break1.rb
# Example 1
# Lets assume following line is longer than 80 cols and I want it to break it
Foobar.some_method.another_on(:with_some => :arg, :and_another => "one")
# Variant 1
Foobar.some_method.another_on(
:with_some => :arg, :and_another => "one"
)
@sickill
sickill / rw_ro_access.sql
Last active Oct 16, 2018 — forked from checco/rw_ro_access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
View rw_ro_access.sql
--
-- Read only
--
-- Create a group
CREATE ROLE ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ro_group;
@sickill
sickill / asciicast-transformations.py
Created Mar 6, 2018
Experiments with asciicast transformations
View asciicast-transformations.py
import sys
import asciinema.asciicast as asciicast
import asciinema.asciicast.events as ev
# predicates
def _(actual):
return True
View edit-asciicast.py
import sys
import os
import json
import asciinema.asciicast as asciicast
import asciinema.asciicast.frames as frames
# run me with:
# python3 edit-asciicast.py original.cast edited.cast