Skip to content

Instantly share code, notes, and snippets.

View kodekracker's full-sized avatar
🎯
Focusing

Akshay Pratap Singh kodekracker

🎯
Focusing
View GitHub Profile
@kodekracker
kodekracker / after_fetch_queryset_mixin.py
Created October 17, 2022 16:02 — forked from spookylukey/after_fetch_queryset_mixin.py
AfterFetchQuerySetMixin for Django
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 / 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

How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers.

@kodekracker
kodekracker / network-tuning.conf
Created December 1, 2021 06:22 — forked from pensierinmusica/network-tuning.conf
Linux sysctl configuration file for NginX
## 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
# -*- coding: utf-8 -*-
# /var/runtime/awslambda/bootstrap.py
"""
aws_lambda.bootstrap.py
Amazon Lambda
Copyright (c) 2013 Amazon. All rights reserved.
Lambda runtime implemention
"""

Libuv and libev, two I/O libraries with similar names, recently had the privilege to use both libraries to write something. Now let's talk about my own subjective expression of common and different points.

The topic of high-performance network programming has been discussed. Asynchronous, asynchronous, or asynchronous. Whether it is epoll or kqueue, it is always indispensable to the asynchronous topic.

Libuv is asynchronous, and libev is synchronous multiplexing IO multiplexing.

Libev is a simple encapsulation of system I/O reuse. Basically, it solves the problem of different APIs between epoll and kqueuq. Ensure that programs written using livev's API can run on most *nix platforms. However, the disadvantages of libev are also obvious. Because it basically just encapsulates the Event Library, it is inconvenient to use. For example, accept(3) requires manual setnonblocking after connection. EAGAIN, EWOULDBLOCK, and EINTER need to be detected when reading from a socket. This is a

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
Param(
[Parameter(Mandatory = $true)]
[string] $ResourceGroupName,
[Parameter(Mandatory = $true)]
[string] $AppServiceName,
[Parameter(Mandatory = $true)]
[string] $SubscriptionId,
[Parameter(Mandatory = $true)]
[string] $RulePriority
)
@kodekracker
kodekracker / nginx-tuning.md
Created November 11, 2020 18:43 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

OpenSSL Playground

Certificates

Print Certificate ( crt file )

openssl x509 -in stackexchangecom.crt -text -noout

Print Certificate ( pem file )

openssl x509 -in cert.pem -text -noout

Print Certificate ( cer file )

openssl x509 -inform der -in foobar.cer -noout -text

Read part of Certificate
@kodekracker
kodekracker / ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Created October 5, 2020 16:47 — forked from ntamvl/ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

If you are setting up nginx,chances are you will discover your worker_connections is at some low number, such as 1024. You can’t increase this number unless you increase kernel limit as well. First of all run cat /proc/sys/fs/file-max to discover your maximum limit.

abc@ubuntu:~$ cat /proc/sys/fs/file-max
1048576
abc@ubuntu:~$ ulimit -n
1024