Skip to content

Instantly share code, notes, and snippets.

View nandakishorkoka's full-sized avatar

Nandakishor Koka nandakishorkoka

View GitHub Profile
@nandakishorkoka
nandakishorkoka / gpu_usage.py
Created August 11, 2022 13:44 — forked from 99991/gpu_usage.py
Get NVIDIA GPU memory usage and find free GPUs using nvidia-smi
import subprocess, getpass
def get_gpu_usage():
"""
Returns a dict which contains information about memory usage for each GPU.
In the following output, the GPU with id "0" uses 5774 MB of 16280 MB.
253 MB are used by other users, which means that we are using 5774 - 253 MB.
{
@nandakishorkoka
nandakishorkoka / truncate_dynamodb_table.py
Last active January 31, 2019 15:27
Truncate DynamoDB Table
import boto3
import sys
access_key = "..."
secret_key = "..."
session = boto3.Session(
aws_access_key_id=access_key,
aws_secret_access_key=secret_key
)
@nandakishorkoka
nandakishorkoka / gist:2505cf346d0f0f97a10b5c107922f85d
Created January 25, 2019 17:46 — forked from griggheo/gist:2698152
dynamodb batchwriteitem in boto
import os
import sys
import subprocess
import re
import optparse
import boto
dynamodb_conn = boto.connect_dynamodb(aws_access_key_id='MY_ACCESS_KEY_ID', aws_secret_access_key='MY_SECRET_ACCESS_KEY')
table_name = 'mytable'
dynamodb_table = dynamodb_conn.get_table(table_name)
@nandakishorkoka
nandakishorkoka / duplicate_dynamodb_table.py
Created January 23, 2019 20:51 — forked from iomz/duplicate_dynamodb_table.py
Duplicate a table in AWS DynamoDB (for renaming or manual fix)
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
print 'Usage: %s <source_table_name> <destination_table_name>' % sys.argv[0]
@nandakishorkoka
nandakishorkoka / designer.html
Last active August 29, 2015 14:19
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@nandakishorkoka
nandakishorkoka / 0_reuse_code.js
Created July 31, 2014 12:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console