Skip to content

Instantly share code, notes, and snippets.

View ralexandr's full-sized avatar
💭
You're never wrong to do the right thing

Alexander Radyushin ralexandr

💭
You're never wrong to do the right thing
View GitHub Profile
@ralexandr
ralexandr / SASS: Media queries + breakpoints
Last active December 29, 2023 05:33
SASS: Media queries + breakpoints
// Usage:
// .site-header {
// padding: 2rem;
// font-size: 1.8rem;
// @include mq('tablet-wide') {
// padding-top: 4rem;
// font-size: 2.4rem;
// }
// }
@ralexandr
ralexandr / alpine_install_nvm.md
Last active September 19, 2023 18:56
Installing nvm on Alpine Linux

Installing nvm on Alpine Linux

Alpine Linux, unlike mainstream/traditional Linux distributions, is based on BusyBox, a very compact (~5MB) Linux distribution. BusyBox (and thus Alpine Linux) uses a different C/C++ stack to most mainstream/traditional Linux distributions - musl. There currently is no musl based binary published in the nodejs official builds but they do publish a musl based binary in the nodejs unofficial builds which they use in the node:alpine docker image. The node:alpine docker image is a potential alternative to nvm for using node on alpine linux.

For now you can override the nvm_get_arch function to return x64-musl on x64 Alpine Distributions. Currently the Node project only has unofficial builds for x64-musl. Sorry no ARM-musl/x86-musl,etc builds for now. The N

@ralexandr
ralexandr / Jenkinsfile
Created December 17, 2020 23:55 — forked from merikan/Jenkinsfile
Some Jenkinsfile examples
Some Jenkinsfile examples
@ralexandr
ralexandr / .bashrc
Created October 27, 2020 03:13
Git shell aliases
# Copy-paste following code to your .bashrc/.zshrc file and restart your terminal session (or run 'source ~/.bashrc' command)
# git
alias gs="git status"
alias gp="git pull"
alias gpo="git push origin $1"
alias gb="git branch"
alias ga="git add ."
alias gc="git pull && git commit -m $1"
function git_checkout_branch() {
@ralexandr
ralexandr / non_blocking_alter_table.sql
Last active September 2, 2020 06:00
Non-blocking ALTER TABLE for mySQL
ALTER TABLE `my_awesome_database`.`user_transaction`
ADD FOREIGN KEY (`userId`) REFERENCES `my_awesome_database`.`user` (`id`),
ALGORITHM=INPLACE, LOCK=NONE;
@ralexandr
ralexandr / sequelize-wrap-in-transaction.ts
Last active June 30, 2020 12:43
Simple wrapper to wrap multiple db-queries in db-transaction
import { Transaction } from 'sequelize';
type DatabaseTransactionProps = {
transaction?: Transaction;
isolationLevel?: string;
autocommit?: boolean;
};
type TransactionActionCallback = (transaction: Transaction) => Promise<any>;
@ralexandr
ralexandr / nginx.cors.settings.conf
Last active June 20, 2020 23:55
nginx.cors.settings.conf
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Frappe-Site-Name erp.example.pro;
proxy_set_header Origin $scheme://$http_host;
proxy_set_header Host $host;
proxy_pass http://frappe-bench-socketio-server;
add_header 'Access-Control-Allow-Origin' '*' always;
@ralexandr
ralexandr / logger.ts
Created June 5, 2020 21:56
Logger with custom formatting
import pino, { Logger } from 'pino';
function logMethod(args: any, method: any) {
if (args.length === 2) {
let interpolationValue;
switch (typeof args[1]) {
case 'object':
interpolationValue = ' %j';
break;
case 'string':
@ralexandr
ralexandr / ip4
Created June 9, 2019 01:12 — forked from DeadAlready/ip4
IPv4 firewall setup
*filter
# Default policy is to drop all traffic
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT DROP
# Allow all loopback traffic
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
@ralexandr
ralexandr / mmmmCookies.hbs
Created May 28, 2019 10:30 — forked from kevana/mmmmCookies.hbs
Part of Nginx config for cookie-based routing.
if ($http_cookie ~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}
{{~/each~}}
)=Y) {
rewrite ^{{ ocpUrl }}$ {{ bcpUrl }} redirect;
}
if ($http_cookie !~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}