Skip to content

Instantly share code, notes, and snippets.

View bitkidd's full-sized avatar
🎯
Focusing

Chirill Ceban bitkidd

🎯
Focusing
View GitHub Profile
@bitkidd
bitkidd / aws-vesta-s3.md
Last active October 17, 2023 18:58
AWS S3 backup for Vesta

Before doing all this you have to create a bucket in your AWS console. Or just use AWS cli tool in order to create one.

  • Install pip (if not installed already):
$ curl -O https://bootstrap.pypa.io/get-pip.py
  • Install AWS cli tool:
$ sudo pip install awscli
@bitkidd
bitkidd / generateToken.ts
Last active February 7, 2022 14:21
KeyCDN Secure Token
const domain = 'domain'
const secret = 'supersecret'
const expire = Math.round(Date.now() / 1000) + 120
const links: { original?: string } = {}
const path = `/${this.filetype}/${this.uid}.${this.fileext}`
const generateToken = ({ path, query = '' }: { path: string; query?: string }): string => {
// generate md5 token
const md5String = crypto
@bitkidd
bitkidd / routes.rb
Created January 27, 2016 13:36 — forked from kryzhovnik/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail
@bitkidd
bitkidd / example.js
Created July 12, 2019 14:22
Adonis.js v4 example exception handler
const BaseExceptionHandler = use('BaseExceptionHandler');
const Logger = use('Logger');
class ExceptionHandler extends BaseExceptionHandler {
async handle(error, { request, response, session, view }) {
const isJSON = request.accepts(['html', 'json']) === 'json';
const production = process.env.NODE_ENV === 'production';
if (error.code === 'E_INVALID_SESSION') {
session.flash({
@bitkidd
bitkidd / force-https-wp.stpl
Created March 29, 2019 12:55
VestaCP (Nginx + Php-fpm) force WordPress HTTPS
server {
listen %ip%:%web_ssl_port% http2;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
ssl on;
@bitkidd
bitkidd / facebook_key_hash.md
Last active February 12, 2019 16:42
Create key hash for Facebook

You can convert SHA-1 hash in hex format (as found in Play console) into base64 hash using next command:

echo 33:4E:48:84:19:50:3A:1F:63:A6:0F:F6:A1:C2:31:E5:01:38:55:2E | xxd -r -p | openssl base64

Output:

M05IhBlQOh9jpg/2ocIx5QE4VS4=
@bitkidd
bitkidd / deleting_tons_of_files_in_linux.md
Last active August 14, 2018 13:59
Deleting tons of files in Linux (Argument list too long)

If you’re trying to delete a very large number of files at one time (I deleted a directory with 485,000+ today), you will probably run into this error:

/bin/rm: Argument list too long.

The problem is that when you type something like “rm -rf ”, the “” is replaced with a list of every matching file, like “rm -rf file1 file2 file3 file4” and so on. There is a reletively small buffer of memory allocated to storing this list of arguments and if it is filled up, the shell will not execute the program. To get around this problem, a lot of people will use the find command to find every file and pass them one-by-one to the “rm” command like this:

find . -type f -exec rm -v {} \;

My problem is that I needed to delete 500,000 files and it was taking way too long.

@bitkidd
bitkidd / uri.js
Last active January 18, 2018 21:01 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a')
parser.href = "http://example.com:3000/pathname/?search=test#hash"
parser.protocol // => "http:"
parser.host // => "example.com:3000"
parser.hostname // => "example.com"
parser.port // => "3000"
parser.pathname // => "/pathname/"
parser.hash // => "#hash"
parser.search // => "?search=test"
@bitkidd
bitkidd / script.sh
Created December 7, 2017 20:28 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@bitkidd
bitkidd / logger.js
Last active December 1, 2017 13:44
adonis logger
'use strict'
const colors = use('colors/safe')
const Env = use('Env')
const colorStatus = function (status) {
let colorFn = status >= 500 ? colors.red // red
: status >= 400 ? colors.yellow // yellow
: status >= 300 ? colors.cyan // cyan