Skip to content

Instantly share code, notes, and snippets.

View nplusp's full-sized avatar

Mikita Pridorozhko nplusp

View GitHub Profile
@nplusp
nplusp / gist:e665cadec807f3bfcd88b5a75b1df1b8
Created June 10, 2024 09:03
Create gifs from video in terminal
// install dependencies
brew install ffmpeg
brew install gifsicle
// add alias
alias gify='function _gify(){ ffmpeg -i "$1" -pix_fmt rgb8 -r 10 /tmp/{1%.*}_tmp.gif && gifsicle -O3 /tmp/{1%.*}_tmp.gif -o "${1%.*}.gif"; rm /tmp/{1%.*}_tmp.gif; unset -f _gify; }; _gify'
// run it
gify /path/to/file.mp4
@nplusp
nplusp / application.rb
Created June 6, 2024 11:56 — forked from fractaledmind/application.rb
Create a simple, beautiful Rails-integrated multi-file input that behaves like: https://codepen.io/smargh/pen/mdGLpEz. Uses TailwindCSS, StimulusJS, and ActiveStorage.
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# ensure that `update(files: [uploaded_file])` will append, not replace
config.active_storage.replace_on_assign_to_many = false
end

How to deploy a Rails 7.1 app with Postgres and Kamal on a single server

I think you have looked at the tutorial from Mr. Heinemeier Hansson at least once or twice and have a similar setup.

rails new kamal_pg --css tailwind --skip-test --database=postgresql

cd kamal_pg
@nplusp
nplusp / git-tag-delete-local-and-remote.sh
Created July 24, 2019 18:36 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@nplusp
nplusp / gist:5f55595ef9bb309bafb603a41bda0094
Created June 10, 2019 13:56
Install PG gem without locally installed Postgres
brew install libpq
gem install pg -- --with-opt-dir="/usr/local/opt/libpq"
bundle config --local build.pg --with-opt-dir="/usr/local/opt/libpq"
bundle install

Keybase proof

I hereby claim:

  • I am nplusp on github.
  • I am nplusp (https://keybase.io/nplusp) on keybase.
  • I have a public key whose fingerprint is 15FB 8132 60B8 3D73 44BC B9CF 5869 568A B841 34B0

To claim this, I am signing this object:

@nplusp
nplusp / gist:5c2a579f14283063743d0b8701171d3f
Created April 12, 2019 12:45
fix mysql max index length of 767
ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
@nplusp
nplusp / ssl_puma.sh
Created July 12, 2018 16:16 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@nplusp
nplusp / gist:b6ebd6998e03d9cee83e46f174faab31
Created August 9, 2017 13:59
Catch slow queries in Postgres
cat /etc/postgresql/9.6/main/postgresql.conf | grep log_min_duration_statement
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
log_min_duration_statement = 100
sudo tail -f /var/log/postgresql/postgresql-9.6-main.log
@nplusp
nplusp / gist:34aad8df58974eb2b15162a5d26b0776
Last active March 13, 2017 13:31
using SSH over HTTPS for CircleCI to fix authentication issues
checkout:
post:
# Work around some silly configuration added by Circle that doesn't actually even do what they want it to.
- git config --global --unset url.ssh://git@github.com:.insteadof