Skip to content

Instantly share code, notes, and snippets.

View sidravic's full-sized avatar

Siddharth sidravic

View GitHub Profile
@sidravic
sidravic / error_codes
Created January 2, 2017 07:48
A list of error codes
{
unauthorized: 'unauthorized',
token_based_subscription_create_service: {
create_error: 'create_error',
user_not_found: 'user_not_found',
merchant_not_found: 'merchant_not_found'
},
subscription_charge_service: {
@sidravic
sidravic / postgres_queries_and_commands.sql
Created August 1, 2017 09:48 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@sidravic
sidravic / Ubuntu1604py36Dockerfile
Created March 26, 2018 10:04 — forked from monkut/Ubuntu1604py36Dockerfile
Base Docker image for ubuntu-16.04 & Python3.6
# docker build -t ubuntu1604py36
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git
@sidravic
sidravic / gist:bbe2fa7a8a49af65e16ef281bf2143fa
Created April 23, 2018 08:29 — forked from rkuzsma/gist:b9a0e342c56479f5e58d654b1341f01e
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@sidravic
sidravic / dht-walkthrough.md
Created July 17, 2018 08:21 — forked from gubatron/dht-walkthrough.md
DHT walkthrough notes

DHT Walkthrough Notes

I've put together these notes as I read about DHT's in depth and then learned how the libtorrent implementation based on the Kademlia paper actually works.

What problem does this solve?

400,000,000,000 (400 billion stars), that's a 4 followed by 11 zeros. The number of atoms in the universe is estimated to be around 10^82. A DHT with keys of 160 bits, can have 2^160 possible numbers, which is around 10^48

@sidravic
sidravic / config2.json
Created May 30, 2020 06:48 — forked from pmav99/config2.json
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
@sidravic
sidravic / config2.json
Created May 30, 2020 06:48 — forked from pmav99/config2.json
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
@sidravic
sidravic / install-gcc-4.9.3.sh
Created June 7, 2020 06:07 — forked from jtilly/install-gcc-4.9.3.sh
Install GCC 4.9.3
#!/bin/bash
# this script installs GCC 4.9.3
# to use it navigate to your home directory and type:
# sh install-gcc-4.9.3.sh
# download and install gcc 4.9.3
wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.gz
tar xzf gcc-4.9.3.tar.gz
cd gcc-4.9.3
@sidravic
sidravic / fit_dump_model_to_s3fs.py
Created July 18, 2020 09:11 — forked from sbalnojan/fit_dump_model_to_s3fs.py
Fit model, dump to S3 via s3fs
import s3fs
import pickle
import json
import numpy as np
BUCKET_NAME = "my-bucket"
# definitions, keras/tf/... imports...
if __name__ == "__main__":
@sidravic
sidravic / how-to-copy-aws-rds-to-local.md
Created February 2, 2021 05:26 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored