Skip to content

Instantly share code, notes, and snippets.

@nvg
nvg / article_page.dart
Created August 25, 2023 21:59
Buggy Flutter Page
import 'package:flutter/material.dart';
import 'package:widgets/model/article.dart';
class ArticlePage extends StatelessWidget {
final Article? article;
const ArticlePage({Key? key, this.article}) : super(key: key);
@override
Widget build(BuildContext context) {
@nvg
nvg / classification_with_BERT.py
Created September 14, 2022 01:50
Binary classification with BERT
import tensorflow as tf
import tensorflow_addons as tfa
import tensorflow_hub as hub
import tensorflow_text as text
import pandas as pd
## Dataset is obtained from https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset
df=pd.read_csv('spam.csv', encoding_errors='ignore')
df.drop(df.columns[2:5], axis=1, inplace=True)
df.rename(columns = {'v1':'Category', 'v2':'Message'}, inplace = True)
@nvg
nvg / sentiment_with_bert.py
Created September 8, 2022 00:45
Sentiment analysis with transformers
from transformers import BertForSequenceClassification, BertTokenizer
## Step 1 - Pre-processing
MODEL = 'YOUR MODEL'
TEXT = ("YOUR INPUTS")
tokenizer = BertTokenizer.from_pretrained(MODEL)
tokens = tokenizer.encode_plus(TEXT, max_length=512, # max number of tokens in each sample
truncation=True, # what to do with extra token over max_length
padding='max_length', # for shorter sequences, pad with 0's
add_special_tokens=True, # add special tokens by default
@nvg
nvg / app.js
Last active June 6, 2021 16:45
Credentials Authority
const express = require('express')
const bodyParser = require('body-parser')
const zlib = require('zlib')
const jose = require('node-jose');
const fs = require('fs');
const qrcode = require('qrcode')
const nodemailer = require('nodemailer');
let signingKey;
let keystore = jose.JWK.asKeyStore(JSON.parse(fs.readFileSync('keys.json'))).then(function (result) {
@nvg
nvg / ImmunizationInterceptor.java
Last active June 6, 2021 16:48
Immunization Interceptor Example
package ca.onfhir.interceptor;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.Interceptor;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
@nvg
nvg / ImagingStudy_annotated.json
Last active May 22, 2021 16:03
Annotated ImagingStudy
{
"resourceType": "ImagingStudy",
"text": {
"status": "generated",
"div": "<div xmlns='http://www.w3.org/1999/xhtml'>Chest Frontal View X-Ray. John Smith (MRN: 109236). Accession: W12342398. Performed: 2017-01-01. 1 series, 1 image.</div>" },
"identifier": [ {
"use": "official",
"system": "urn:dicom:uid",
"value": "urn:oid:2.16.124.113543.6003.1154777499.30246.19789.3503430046" } ],
@nvg
nvg / Predictions.json
Created May 22, 2021 15:01
Sample Predictions
{
"predictions": [
{ "label": "Atelectasis", "probability": 0.065 },
{ "label": "Cardiomegaly", "probability": 0.009 },
{ "label": "Effusion", "probability": 0.43 },
{ "label": "Infiltration", "probability": 0.397 },
{ "label": "Mass", "probability": 0.0652 },
{ "label": "Nodule", "probability": 0.052 },
{ "label": "Pneumonia", "probability": 0.049 },
{ "label": "Pneumothorax", "probability": 0.037 },
@nvg
nvg / server.py
Created May 21, 2021 02:40
Sample Python Server
import io
import flask
import keras.applications
import numpy as np
from PIL import Image
from keras.layers import Input
from keras.layers.core import Dense
from keras.models import Model
from skimage.transform import resize
@nvg
nvg / ImagingStudy.json
Last active May 20, 2021 23:34
Sample Imaging Study
{
"resourceType": "ImagingStudy",
"text": {
"status": "generated",
"div": "<div xmlns='http://www.w3.org/1999/xhtml'>Chest Frontal View X-Ray. John Smith (MRN: 109236). Accession: W12342398. Performed: 2017-01-01. 1 series, 1 image.</div>" },
"identifier": [ {
"use": "official",
"system": "urn:dicom:uid",
"value": "urn:oid:2.16.124.113543.6003.1154777499.30246.19789.3503430046" } ],
"status": "available",
@nvg
nvg / ImagingStudyInterceptor.java
Created May 20, 2021 02:21
Interceptor for ImagingStudy FHIR resource
package ca.onfhir.interceptor;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.fhirpath.IFhirPath;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.Interceptor;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.rest.api.server.RequestDetails;