Skip to content

Instantly share code, notes, and snippets.

View sidravic's full-sized avatar

Siddharth sidravic

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / factory-shared.es5.js
Created December 12, 2015 18:25 — forked from PatrickJS/factory-shared.es5.js
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@sidravic
sidravic / torquebox_init_script.rb
Created March 19, 2015 08:47
A basic init script to start and stop torquebox. Copy this script to the /etc/init.d/ folder
#!/usr/bin/env ruby
require "fileutils"
puts "Using system RVM"
#system("/bin/bash --login && rvm use system")
puts "Initializing PID and Log files"
PIDFOLDER = "/opt/pids"
PIDFILE = "/opt/pids/torquebox.pid"
LOGFILE = "/var/log/torquebox/torquebox.log"
FileUtils.mkdir_p(PIDFOLDER) unless Dir.exists?(PIDFILE)
Kaminari.paginate_array([{:a => 1}, {:b => 2}, {:c => 3}, {:d => 4}]).page(1).per(1)
=> [{:a=>1}]
[10] pry(main)> Kaminari.paginate_array([{:a => [1,2,3,4]}, {:b => [123,123,1231,231]}, {:c => [123123]}, {:d => [:asd, :asdasd]}]).page(1).per(1)
=> [{:a=>[1, 2, 3, 4]}]
[11] pry(main)> Kaminari.paginate_array([{:a => [1,2,3,4]}, {:b => [123,123,1231,231]}, {:c => [123123]}, {:d => [:asd, :asdasd]}]).page(1).per(2)
=> [{:a=>[1, 2, 3, 4]}, {:b=>[123, 123, 1231, 231]}]
[12] pry(main)> Kaminari.paginate_array([{:a => [1,2,3,4]}, {:b => [123,123,1231,231]}, {:c => [123123]}, {:d => [:asd, :asdasd]}]).page(1).per(3)
=> [{:a=>[1, 2, 3, 4]}, {:b=>[123, 123, 1231, 231]}, {:c=>[123123]}]
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment: