Skip to content

Instantly share code, notes, and snippets.

View nplusp's full-sized avatar

Mikita Pridorozhko nplusp

View GitHub Profile
@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 / 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 / nginx.conf
Created May 6, 2016 13:08 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@nplusp
nplusp / workaround.php
Created December 29, 2015 06:39 — forked from aspyct/workaround.php
The most undebuggable PHP snippet ever
<?php
define("true ", false);
function doIt() {
define(" false", true);
define("maybe", rand() & 1);
}
function  ($stupid="clever") {
if (assert_value($stupid)) {
@nplusp
nplusp / gist:0520094210667a120dd0
Created November 11, 2015 12:07 — forked from yuri-zubov/gist:91bf6e4d5a75a63c5790
template for init.d
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO