Skip to content

Instantly share code, notes, and snippets.

@salekh
salekh / MediaOperations.ts
Created September 30, 2019 15:26
Typescript version of lukechilds/merge-images that works with canvas2.6.0
import * as Canvas from 'canvas';
import { Image } from 'canvas';
import axios from 'axios';
export class MediaOperations {
// Defaults
public defaultOptions: any = {
format: 'image/png',
quality: 0.92,
width: 100,
@salekh
salekh / gcs-copyblob.py
Last active May 21, 2019 09:04
Copy blob from one GCS bucket to another
def copy_blob(bucket_name, blob_name, new_bucket_name, new_blob_name):
"""Copies a blob from one bucket to another with a new name."""
storage_client = storage.Client()
source_bucket = storage_client.get_bucket(bucket_name)
source_blob = source_bucket.blob(blob_name)
destination_bucket = storage_client.get_bucket(new_bucket_name)
new_blob = source_bucket.copy_blob(
source_blob, destination_bucket, new_blob_name)
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@salekh
salekh / DFSTraverseOntology.java
Created May 21, 2017 01:02
Code to traverse an ontology via DFS
public static OWLClass getUnvisitedChild(OWLClass owl, OWLOntology pOnt){
Set<OWLClassExpression> children = owl.getSubClasses(pOnt);
Iterator<OWLClassExpression> childIt = children.iterator();
while(childIt.hasNext()){
OWLClass currentChild = childIt.next().asOWLClass();
if(!visited.contains(currentChild)){
return currentChild;
}
}
return owl;
@salekh
salekh / LRWithBoldDriver.java
Created May 7, 2017 20:59
Part of a module to perform Logistic Regression for Author Disambiguation using a hybrid approach: Patent text + Metadata
package preprocessing;
import Evaluation.trainingDataMatrix;
import base.pair;
import base.patent;
import clustering.distancefunction.AbstractDistance;
import clustering.distancefunction.CosDistance;
import org.carrot2.core.LanguageCode;
import org.jblas.DoubleMatrix;
import org.jblas.MatrixFunctions;
@salekh
salekh / HierAggloClustering.java
Created May 7, 2017 20:33
Part of a module that performs Hierarchical Clustering to cluster patents for which we have a high confidence that they are authored by the same person Raw
package algorithms;
import base.PatentCluster;
import base.PatstatPatent;
import java.util.ArrayList;
/**
* Created by sanchitalekh on 14/03/2017.
*/
@salekh
salekh / sqlconn.class
Last active March 12, 2017 19:41
Connecting to MySQL Database from Java
package base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* Created by sanchitalekh on 12/03/2017.
*/