Skip to content

Instantly share code, notes, and snippets.

View Apmyp's full-sized avatar

Artur Bordeniuc Apmyp

  • Moldova, Chisinau
View GitHub Profile
@Apmyp
Apmyp / psql-with-gzip-cheatsheet.sh
Created February 12, 2021 09:04 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@Apmyp
Apmyp / readme.md
Last active June 29, 2020 10:08
Migrate sessions from DB to Redis

How to migrate Laravel sessions from Database to Redis

Declare new Redis database

config/database.php

'redis' => [
  // ...
  'sessions' => [
    'host' => env('REDIS_HOST', '127.0.0.1'),
@Apmyp
Apmyp / shortener.md
Created April 11, 2020 08:17
Shorten your ids by converting them to base n number system

How shortener feature works

I have to make a system which can give us short version of URL and a way to track clicks.

This gist is about how I solved the first part of problem: as short as possible URL.

First things first. If we talk about system which handle URLs then we should have a table in database.

Example table of URLs:

@Apmyp
Apmyp / money-value-of-time.js
Created August 20, 2019 07:34
Annuity and linear payments
const principal = 100000;
const interestRate = 0.12 / 12;
const instalments = 24;
function annuityFactor(interestRate, instalments) {
return (interestRate + ( interestRate / ( Math.pow(1 + interestRate, instalments) - 1 ) ) );
}
function annuityPayment(principal, interestRate, instalments) {
return principal * annuityFactor(interestRate, instalments);
@Apmyp
Apmyp / nginx--rails-application.conf
Last active November 9, 2018 14:32
Example of nginx configuration for proxing to a rails application. Don't forget to change <template_strings>
server {
listen <ip>:<port>;
server_name <domain>;
charset off;
set $root_path <path_to_rails_application>/public;
disable_symlinks if_not_owner from=$root_path;
root $root_path;
access_log <path_to_logs_dir>/<domain>-access.log;
error_log <path_to_logs_dir>/<domain>-error.log notice;