Skip to content

Instantly share code, notes, and snippets.

View userimack's full-sized avatar

Mahendra Yadav userimack

View GitHub Profile
@userimack
userimack / Dockerfile
Created December 21, 2020 15:36
Dockerfile suse/tumbleweed with Python 3.6.7 installed
from opensuse/tumbleweed:latest
LABEL maintainer="Mahendra"
RUN zypper --non-interactive --quiet install --type pattern devel_C_C++
RUN zypper --non-interactive --quiet install libopenssl-devel libffi-devel bluez-devel tk-devel valgrind-devel libexpat-devel sqlite3-devel readline-devel readline-devel-32bit libbz2-devel libexpat-devel libbz2-devel readline-devel sqlite3-devel wget patterns-devel-python-devel_python3 tar gcc make
ENV VERSION="3.6.7"
RUN wget -P /usr/src https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tar.xz && tar -xf /usr/src/Python-${VERSION}.tar.xz -C /usr/src/ && rm -rf /usr/src/Python-${VERSION}.tar.xz
Date Status DH
4/3/20 Confirmed 1
4/4/20 Confirmed 1
4/5/20 Confirmed 3
4/6/20 Confirmed 4
4/7/20 Confirmed 4
4/8/20 Confirmed 6
4/9/20 Confirmed 11
4/10/20 Confirmed 14
4/11/20 Confirmed 25
@userimack
userimack / postgresql_db_dump_command.sh
Created March 21, 2020 13:45
postgresql db dump command - it will dump the database and gzip it before saving it
#!/bin/bash
echo "Starting database backup.."
pg_dump -Fc --no-acl --no-owner \
<Database Name> \
| gzip > "<dump name>-$(date +%Y%m%d%H%M%S).pgdump.gz"
echo "Backup completed.."
@userimack
userimack / sum_of_powers_of_2.py
Created March 11, 2020 07:12
Different solutions for sum of powers of 2
#!/usr/bin/env python3
# example 1: brute force solution
def sum_of_powers_of_2_brute_force(power):
# time complexity: O(n)
return sum([pow(2, i) for i in range(power+1)])
def sum_of_powers_of_2(power):
# time complexity: O(1)
return pow(2, power+1) - 1
@userimack
userimack / nginx.conf
Created February 23, 2020 09:14
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This demonstrates split_clients based routing on an argument named token
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
default_type text/html;
log_format main '$remote_addr -> $request $status $body_bytes_sent bytes -> $upstream_addr';
access_log /var/log/nginx/access.log main;
@userimack
userimack / System Design.md
Created January 25, 2020 17:41 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@userimack
userimack / br.sh
Created January 25, 2020 10:00 — forked from dmkash/br.sh
Shell Script for tmux setup
#!/bin/sh
SESSION_NAME="big_red"
cd ~/Sites/within3/big_red
tmux has-session -t ${SESSION_NAME}
if [ $? != 0 ]
then

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@userimack
userimack / .iex.exs
Created May 31, 2019 06:18
To make your iex console look Fancy 🆒
Application.put_env(:elixir, :ansi_enabled, true)
IEx.configure(
colors: [
eval_result: [:cyan, :bright] ,
eval_error: [[:red, :bright, "\n▶▶▶\n"]],
eval_info: [:yellow, :bright ],
],
default_prompt: [
"\e[G", # cursor ⇒ column 1
:blue, "%prefix", :yellow, "|", :blue, "%counter", " ", :yellow, "▶", :reset