Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar
🎯
Focusing

Akshay Pratap Singh kodekracker

🎯
Focusing
View GitHub Profile
@kodekracker
kodekracker / settings.json
Created July 25, 2023 09:00
VS Code settings
View settings.json
{
"workbench.productIconTheme": "material-product-icons",
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Material Theme Ocean",
"telemetry.telemetryLevel": "off",
"files.associations": {
"*.env.staging": "env",
"*.env.development": "env",
"*.env.production": "env",
"*.env.example": "env",
@kodekracker
kodekracker / after_fetch_queryset_mixin.py
Created October 17, 2022 16:02 — forked from spookylukey/after_fetch_queryset_mixin.py
AfterFetchQuerySetMixin for Django
View after_fetch_queryset_mixin.py
class AfterFetchQuerySetMixin:
"""
QuerySet mixin to enable functions to run immediately
after records have been fetched from the DB.
"""
# This is most useful for registering 'prefetch_related' like operations
# or complex aggregations that need to be run after fetching, but while
# still allowing chaining of other QuerySet methods.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@kodekracker
kodekracker / debug_requests.py
Created July 19, 2022 17:40
Enable debugging in python requests package
View debug_requests.py
# source: https://stackoverflow.com/a/57325050/10504918
import requests
import logging
from http.client import HTTPConnection # py3
log = logging.getLogger('urllib3')
log.setLevel(logging.DEBUG)
# logging from urllib3 to console
@kodekracker
kodekracker / amazon-cloudwatch-agent-config-schema.json
Created June 2, 2022 08:37
Amazon Cloudwatch Agent Config JSON Schema
View amazon-cloudwatch-agent-config-schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Amazon CloudWatch Agent JSON Schema",
"properties": {
"agent": {
"$ref": "#/definitions/agentDefinition"
},
"metrics": {
"$ref": "#/definitions/metricsDefinition"
@kodekracker
kodekracker / install_python_source_build_system_dependencies.sh
Created May 14, 2022 19:04
Python source build system dependencies
View install_python_source_build_system_dependencies.sh
sudo apt install libffi-dev libgdbm-dev libsqlite3-dev libssl-dev zlib1g-dev libncurses-dev libz-dev tk-dev libreadline-dev liblzma-dev
@kodekracker
kodekracker / pseudo_encrypt.sql
Last active April 27, 2022 19:00
A pseudo_encrypt function implementation for int and bigint
View pseudo_encrypt.sql
CREATE OR REPLACE FUNCTION pseudo_encrypt(value int) returns int AS $$
DECLARE
l1 int;
l2 int;
r1 int;
r2 int;
i int:=0;
BEGIN
l1:= (value >> 16) & 65535;
r1:= value & 65535;
@kodekracker
kodekracker / bounded_prng.sql
Last active April 27, 2022 18:02
A bounded pseudo-random generator of unique values in postgres database inspired from pseudo_encrypt
View bounded_prng.sql
CREATE FUNCTION pseudo_encrypt_24(VALUE int) returns int AS $$
DECLARE
l1 int;
l2 int;
r1 int;
r2 int;
i int:=0;
BEGIN
l1:= (VALUE >> 12) & (4096-1);
r1:= VALUE & (4096-1);
@kodekracker
kodekracker / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent
View multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
@kodekracker
kodekracker / network-tuning.conf
Created December 1, 2021 06:22 — forked from pensierinmusica/network-tuning.conf
Linux sysctl configuration file for NginX
View network-tuning.conf
## Place this file in "/etc/sysctl.d/network-tuning.conf" and
## run "sysctl -p" to have the kernel pick the new settings up
# Avoid a smurf attack
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Turn on protection for bad icmp error messages
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Turn on syncookies for SYN flood attack protection
@kodekracker
kodekracker / awslambda.bootstrap.py
Created October 26, 2021 12:06 — forked from lucasrcosta/awslambda.bootstrap.py
AWS Lambda Python Runtime
View awslambda.bootstrap.py
# -*- coding: utf-8 -*-
# /var/runtime/awslambda/bootstrap.py
"""
aws_lambda.bootstrap.py
Amazon Lambda
Copyright (c) 2013 Amazon. All rights reserved.
Lambda runtime implemention
"""