Skip to content

Instantly share code, notes, and snippets.

View arshpreetsingh's full-sized avatar
💭
Get it Done! "Engineer"

Arshpreet Singh arshpreetsingh

💭
Get it Done! "Engineer"
View GitHub Profile
@arshpreetsingh
arshpreetsingh / nested_dict.py
Created November 9, 2021 02:18
nest dict algo
from collections import defaultdict
from itertools import chain
from operator import methodcaller
# dictionaries with non-equal keys, values all lists for simplicity
one = {'a': {1, 2}, 'c': [5, 6], 'b': [3, 4], 'e': [6.2]}
two = {'a': {2.4, 3.4}, 'c': [5.6, 7.6], 'b': [3.5, 4.5], 'f': [1.3]}
three = {'a': [1.2], 'c': [3.4], 'b': [2.3], 'e': [3.1],'f':[1,2,3,4,5]}
dict_list = [one,two,three]
@arshpreetsingh
arshpreetsingh / Dockerfile
Created March 22, 2019 03:45
Minimal TimScale
############################
# Build tools binaries in separate image
############################
FROM golang:alpine AS tools
ENV TOOLS_VERSION 0.4.1
RUN apk update && apk add --no-cache git \
&& mkdir -p ${GOPATH}/src/github.com/timescale/ \
&& cd ${GOPATH}/src/github.com/timescale/ \
@arshpreetsingh
arshpreetsingh / Dockerfile
Created March 22, 2019 03:44
Db with PGBouncer
FROM gliderlabs/alpine:3.3
RUN \
apk --update add autoconf autoconf-doc automake c-ares c-ares-dev curl gcc libc-dev libevent libevent-dev libtool make man openssl-dev pkgconfig && \
curl -o /tmp/pgbouncer-1.9.0.tar.gz -L https://pgbouncer.github.io/downloads/files/1.9.0/pgbouncer-1.9.0.tar.gz && \
cd /tmp && \
tar xvfz /tmp/pgbouncer-1.9.0.tar.gz && \
cd pgbouncer-1.9.0 && \
./configure --prefix=/usr && \
@arshpreetsingh
arshpreetsingh / script.sh
Created April 8, 2018 19:02
HyperLedger pre-req installtion script
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@arshpreetsingh
arshpreetsingh / flask_parallel.py
Created October 3, 2017 12:52
run flask in parallel using thread pool executor
from flask import Flask
from time import sleep
from concurrent.futures import ThreadPoolExecutor
# DOCS https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor
executor = ThreadPoolExecutor(2)
app = Flask(__name__)
@arshpreetsingh
arshpreetsingh / ama.py
Created September 26, 2017 09:54
amazon_uploader using boto3
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import boto3
class AmazonTask(object):
def __init__(self,amazon_key,secret_key,bucket_name):
self.amazon_key=amazon_key
self.bucket_name=bucket_name
self.aws_secret=secret_key
from amadeus import Flights
flights = Flights('QMrAAoM8koigSU9t1FCfWVALLoFT1DKv')
resp = flights.extensive_search(
origin='NCE',
destination='LAS',
departure_date='2017-11-25--2017-11-30',
duration='4--10')
print resp
@arshpreetsingh
arshpreetsingh / coucg_db.py
Created July 10, 2017 08:29
CouchBD_Python-Operations
import couchbase.subdocument as SD
from couchbase.bucket import Bucket
# Connecting to DB
cb = Bucket('couchbase:///www', username = 'user_arsh',password='Amber252556!@')
# Creating DB
cb.upsert('55',{'55':[{'text':'text','user_id':'user_id','created_at':'created_at','time':'time'}]}) # only run once
#!/usr/bin/python
# required imports
import requests
class TradeClient(object):
""" Client for tradidng through WebAPI
"""
"""
Important notes about model
Training Machine-Learning model is trained every Monday (I found that if I train my model every-day it shows less returns)
Trading is happening after each 10 minutes
Machine_learning Model:
I am using two independent Features: '5 minutes price change' and '15 minutes price change'