Skip to content

Instantly share code, notes, and snippets.

View oneshubh's full-sized avatar

Shubham Meshram oneshubh

View GitHub Profile
@oneshubh
oneshubh / gist:ea62b1d53adbe5f9a54b1c02b2e539c7
Created August 9, 2021 15:43
run docker container with localhost access
docker run --network=host -d <image name>
@oneshubh
oneshubh / gpumon.py
Created June 28, 2021 16:18
gpumon for monitoring aws gpu instances
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
#copy from local to server
scp <file-path> <username>@<hostname or ip>:<path-to-store-the-file>
@oneshubh
oneshubh / docker-commands
Last active April 27, 2020 21:57
useful docker commands
Author: oneshubh
#add current user to docker group, so you dont need to use sudo in ubuntu
$ sudo usermod -aG docker $USER
#check running containers
$ docker ps
#stop running container
$ docker stop <container-name>
cat file-dump.sql | sudo docker exec -i container-name psql -U db-user-name -d db-name
pg_dump -U username -p 5432 dbname > filename-to-backup-to.sql
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@oneshubh
oneshubh / retryAPI.js
Last active December 9, 2019 10:16
Higher order function for multiple number of tries to get result, Here instead of 'math.Random' you can put an API call, and retry multiple times until successful response is received.
// author: oneshubh
function retry(api,numberOfTries){
var counter = numberOfTries;
console.log("counter initially is",counter);
var getRandom = function(){
counter--;
console.log("counter is",counter);
var num = parseInt(Math.random()*10);
@oneshubh
oneshubh / mutliAPICallSynchronously.js
Last active December 9, 2019 10:17
Call multiple API synchronously and get all results or failure
// author : oneshubh
function retry(api,numberOfTries){
var counter = numberOfTries;
console.log("counter initially is",counter);
var results = []
var getRandom = function(){
counter--;
console.log("counter is",counter);