Skip to content

Instantly share code, notes, and snippets.

@sasha-id
sasha-id / codedeploy-install.sh
Created February 27, 2023 23:15
Installs CodeDeploy agent and its prerequisites on Ubuntu 22.04 given AWS CodeDeploy team doesn't exist
#!/bin/bash
# Installs CodeDeploy agent and its prerequisites on Ubuntu 22.04 given AWS CodeDeploy team doesn't exist
# https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html#codedeploy-agent-version-history
CODEDEPLOY_VERSION=1.4.1-2244
sudo apt update
sudo apt install ruby-full ruby-webrick wget -y
cd /tmp
@sasha-id
sasha-id / vscode-snippets.rb
Created September 10, 2022 16:36
VScode snippets shortcuts for typescript/react, dash docset
cheatsheet do
title 'VSCode snippets' # Will be displayed by Dash in the docset list
docset_file_name 'VSCode-snippets' # Used for the filename of the docset
keyword 'typescript' # Used as the initial search keyword (listed in Preferences > Docsets)
# resources 'resources_dir' # An optional resources folder which can contain images or anything else
introduction 'Snippet shortcuts for vscode' # Optional, can contain Markdown or HTML
# https://github.com/accierro/react-typescript-snippets
category do
@sasha-id
sasha-id / query.sql
Created August 2, 2022 19:35
Query to find locking pids
select pid,
usename,
pg_blocking_pids(pid) as blocked_by,
query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
@sasha-id
sasha-id / __init__.py
Created July 20, 2022 05:15
jinja2 webpack extension for flask/quart: add this to __init__.py
# Webpack loader: manifest.json map generated by webpacker
manifest = orjson.loads(open(f'{app.static_folder}/dist/manifest.json').read())
def webpack(pack):
filename = 'bundle.js' if app.config['ENV'] == 'development' else manifest.get(pack)
return f'{app.static_url_path}/dist/{filename}'
app.jinja_env.globals.update(webpack=webpack)
# Use in template <script src="{{ webpack('main.js') }}"></script>
@sasha-id
sasha-id / decode-django-session.py
Created June 11, 2022 02:03
Decode django (version 4) session outside django
from django.core import signing
from django.conf import settings
from django.utils.module_loading import import_string
session_data = 'xxxxxxx'
settings.configure(SECRET_KEY = 'XXXX')
signing.loads(
session_data,
salt="django.contrib.sessions.SessionStore",
@sasha-id
sasha-id / aws-s3-copy-with-versions.rb
Created November 30, 2021 13:08
Copy S3 bucket from one account to another with versions
require 'aws-sdk-s3'
require 'concurrent'
source_bucket = 'xxx'
dest_bucket = 'xxx'
acl = 'public-read'
client = Aws::S3::Client.new(
region: 'ap-southeast-2',
@sasha-id
sasha-id / export.sh
Created November 10, 2021 09:19
EB export env variables
export $(cat /opt/elasticbeanstalk/deployment/env | xargs)
@sasha-id
sasha-id / gist:2df77ec7c3b27b965f3b7ac0a997ce36
Created January 21, 2021 05:45 — forked from den-crane/gist:6eff375752a236a456e1b3dc2ca7db62
Clickhouse example AggregatingMergeTree, (max, min, avg ) State / Merge
DROP TABLE IF EXISTS requests;
CREATE TABLE requests (
request_date Date,
request_time DateTime,
response_time Int,
request_uri String)
ENGINE = MergeTree(request_date, (request_time, request_uri), 8192);
@sasha-id
sasha-id / install.sh
Last active October 29, 2021 19:11
Linux Mint to mimic MacOS keys
pip3 install xkeysnail
sudo xkeysnail linux-map-key-remap.py
ln -s ~/xkeysnail.service /etc/systemd/system/xkeysnail.service
sudo systemctl enable xkeysnail
@sasha-id
sasha-id / Chart.js
Last active May 20, 2020 04:43
react-stockcharts Zone component
<Zone zones={[
{
id: 'pre',
start: { hours: 4, minutes: 0, seconds: 0 },
end: { hours: 9, minutes: 30, seconds: 0 },
fill: "#999999",
opacity: 0.1,
startLine: {
stroke: '#3d7cd4',
strokeWidth: 1,