Skip to content

Instantly share code, notes, and snippets.

View dhruvaray's full-sized avatar

Dhruva Ray dhruvaray

View GitHub Profile
@dhruvaray
dhruvaray / chatgpt_macros_bundle.md
Created April 30, 2024 15:05
Macros (for ChatGPT Memory)

command /bundle bundles the working code as a zip file for download. Users will fill in the value of the programming-language. Default value of programming-language is python. Do the following 0. create a project directory structure 1. Add context sensitive logging 2. Add exception handling 3. Follow language style standards 4. Provide a dependency file 5. Provide a build file 6. Provide detailed README.md 7. Provide a blank LICENSE file.

@dhruvaray
dhruvaray / sharedmem.py
Last active January 23, 2022 03:19
Use torch multiprocessing & share_memory APIs
import torch.multiprocessing as mp
from transformers import BertModel
import torch
import time
import click
def load_model(model_name):
model = BertModel.from_pretrained(model_name)
#device = torch.device(f"cuda:0")
#model.to(device)
@dhruvaray
dhruvaray / dummymodelserving.py
Last active September 9, 2020 09:41
dummymodelserving
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
import time
import threading
import os
import click
def predict_pipeline(compute_unit, model_name, framework):
#todo -- force cuda usage
from transformers import pipeline
unmasker = pipeline('fill-mask', model=model_name, framework=framework)
@dhruvaray
dhruvaray / README.md
Created March 17, 2017 13:09 — forked from jun9/README.md
Bullet Charts

Designed by Stephen Few, a bullet chart “provides a rich display of data in a small space.” A variation on a bar chart, bullet charts compare a given quantitative measure (such as profit or revenue) against qualitative ranges (e.g., poor, satisfactory, good) and related markers (e.g., the same measure a year ago). Layout inspired by Stephen Few. Implementation based on work by Clint Ivy, Jamie Love of N-Squared Software and Jason Davies. The "update" button randomizes the values slightly to demonstrate transitions.

{
"configurations": [
{
"nagios-env": {
"nagios_contact": "admin@localhost"
}
}
],
"host_groups": [
{
@dhruvaray
dhruvaray / assoc_options.js
Created October 18, 2013 09:55
Pass options to relations
var Employee = Backbone.AssociatedModel.extend({
parse:function (obj) {
if (obj.sex === "M") {
obj.prefix = "Mr.";
}
return obj;
}
});
var Company = Backbone.AssociatedModel.extend({
relations:[
@dhruvaray
dhruvaray / poly_1:M.js
Created October 18, 2013 09:44
Use Polymorphic models in 1:M relations
var Club = Backbone.AssociatedModel.extend({
relations:[{
type:Backbone.Many,
key:'members',
relatedModel:function (relation, attributes) {
return function (attrs, options) {
if (_.isArray(attrs.dependents)) {
return new Employee(attrs);
}
@dhruvaray
dhruvaray / reverseRelationTest_js_House.js
Last active December 25, 2015 06:09 — forked from mattcroberts/reverseRelationTest_index.html
Specify circular associations in an AMD context like require.js
define([
"backbone.associations",
"Person"
], function(Associations, Person){
var House = Backbone.AssociatedModel.extend({
relations:[{
key:"person",
type:Backbone.One,
relatedModel: function(){ return require("Person");}
@dhruvaray
dhruvaray / map_polymorphic_assoc.js
Last active December 22, 2015 03:38
System-wide map function (to convert an id or array of ids to the appropriate model instance from model stores). Also demonstrates polymorphic associations.
var Fruit = Backbone.AssociatedModel.extend();
var Banana = Fruit.extend();
var Tomato = Fruit.extend();
var fruitStore = {};
fruitStore['Banana'] = [
new Banana({species:"Robusta", id:3}),
new Banana({species:"Yallaki", id:4}),
new Banana({species:"Genetic Modification", id:5}),
@dhruvaray
dhruvaray / explicit_reverse_relations.js
Last active December 22, 2015 03:29
Setup Explicit Reverse Relationships
var MyApp = {
Models:{}
};
var Models = MyApp.Models;
Models.Zoo = Backbone.AssociatedModel.extend({
relations: [{
type: Backbone.Many,
key: 'animals',