Skip to content

Instantly share code, notes, and snippets.

View sowcow's full-sized avatar

Alexander K sowcow

  • Serbia
View GitHub Profile
@sowcow
sowcow / make.rb
Created August 26, 2023 15:43
generates grid for samsung notes background template
$size = (1600 / 6) * 6 # 1600 is tablet height resolution
END {
draw 'green', 'green'
draw 'silver', 'silver'
draw 'gray', 'gray'
draw 'black', 'black'
draw 'navy', 'navy'
}
@sowcow
sowcow / server.rb
Last active May 17, 2023 12:15
Unique identifiers: Requests can be made idempotent by including a unique identifier with each request. This identifier can be used by the system to recognize duplicate requests and handle them appropriately. For example, using a unique transaction ID or a request-specific token.
require 'sinatra'
require 'pg'
require 'connection_pool'
require 'dotenv/load'
configure {
set :server, :puma
set :port, 3000
}
@sowcow
sowcow / devenv.fish
Created February 7, 2020 05:39
how to automate creating simple tmux layout for development environment
#!/bin/fish
set TOP1 'ruby -e "p :TOP1; loop { sleep 1 }"'
set TOP2 'ruby -e "p :TOP2; loop { sleep 1 }"'
set BOT1 'ruby -e "p :BOT1; loop { sleep 1 }"'
set BOT2 'ruby -e "p :BOT2; loop { sleep 1 }"'
tmux new-session -d
tmux send-keys $TOP1 ENTER
tmux split-window -v
@sowcow
sowcow / 1_run.rb
Last active January 2, 2020 05:31
make a graph of d3.js dependencies
# D3 DEPS
# -------
#
# Nice graph of d3 organization packages
# to help to start and to assist in reading the code.
#
# - outputs only packages from d3 organization excluding `IRRELEVANT`
# - arrows show packages dependencies
# - blue nodes are directly used by 'd3' package
# - adding names to `DONE` array marks packages with green color
@sowcow
sowcow / 0_somafm.m3u
Created December 4, 2019 02:14
Soma.fm playlist
#EXTM3U
#EXTINF:-1,Groove Salad
http://ice2.somafm.com/groovesalad-128-aac
#EXTINF:-1,Drone Zone
http://ice2.somafm.com/dronezone-128-aac
#EXTINF:-1,Christmas Lounge
http://ice2.somafm.com/christmas-128-aac
#EXTINF:-1,Indie Pop Rocks!
http://ice2.somafm.com/indiepop-128-aac
#EXTINF:-1,Space Station Soma
@sowcow
sowcow / 1_alacritty_all_themes.md
Last active December 1, 2019 10:31
alacritty all themes from it's wiki (yml)
  1. Open the config (probably .config/alacritty/alacritty.yml)
  2. Comment or delete old colors: ... section
  3. Copy given excerpt at the beginning or at the end of the config
  4. Uncomment one theme in the excerpt (colors: *ABC) and save the file
  5. You should see the theme applied immediately
# NOTE: no optimisations
#
module Util
module_function
def group_by_sums_of_pairs array, sum = 5
result = []
array = array.clone
loop do
found = array.permutation(2).find { |a, b| a + b == sum }
@sowcow
sowcow / Rakefile
Created October 21, 2019 09:30
add shadow to screenshots
# input/ directory - create a directory with your images
# output/ directory - create empty one for resulting files
task :default do
files = Dir['input/*']
files.each { |x|
output = 'output/' + File.basename(x)
create_shadow x, output
}
end
# remap wacom to preserve the ratio of drawings
def main
reset_to_defaults
my_custom_setup
# comment my setup and uncomment to try one of these:
#
# reduce_the_drawing_area_height
# reduce_the_screen_area_width
xinput set-prop "Logitech Gaming Mouse G502" 148 3.000000, 0.000000, 0.000000, 0.000000, 3.000000, 0.000000, 0.000000, 0.000000, 1.000000