Skip to content

Instantly share code, notes, and snippets.

View lastlegion's full-sized avatar
🎯
Focusing

Ganesh Iyer lastlegion

🎯
Focusing
View GitHub Profile
import pinject
import os
class Repository:
def __init__(self, db: str):
self.db = db
def get_data(self):
return 'Hello World'
class RepositoryBindingSpec(pinject.BindingSpec):
def provide_repository(self):
return Repository(db=os.getenv('dbname'))
@lastlegion
lastlegion / di_2.py
Last active September 1, 2020 00:11
class Repository:
def __init__(self, db: str):
self.db = db
def get_data(self):
return 'Hello World'
class Service:
def __init__(self, repsoitory: Repository):
self.repsoitory = repsoitory
def process(self):
return self.repsoitory.get_data()
@lastlegion
lastlegion / di_1.py
Created August 31, 2020 23:57
Dependency injection example 1
class Repository:
def __init__(self):
self.db = os.getenv('dbname')
def get_data(self):
return 'Hello World'
class Service:
def __init__(self):
self.repository = Repository()
def process(self):
return self.dal.get_data()
@lastlegion
lastlegion / .block
Last active March 7, 2018 21:01
Heartrate heatmap
license: mit
@lastlegion
lastlegion / .block
Created March 7, 2018 20:56
Heartrate heatmap
license: mit
@lastlegion
lastlegion / metadataextractor.py
Last active May 1, 2017 18:35
metadataextractor.py
import hashlib
import time
import openslide
class MetadataExtractor:
PROPERTIES = [
"objective",
"mpp-x",
"mpp-y",
"vendor",
{
_id: '{{objectId()}}',
index: '{{index()}}',
guid: '{{guid()}}',
isActive: '{{bool()}}',
balance: '{{floating(1000, 4000, 2, "$0,0.00")}}',
picture: 'http://placehold.it/32x32',
age: '{{integer(20, 40)}}',
eyeColor: '{{random("blue", "brown", "green")}}',
company: '{{company().toUpperCase()}}',
@lastlegion
lastlegion / output.json
Created November 4, 2016 03:33
Output of druid query
[ {
"timestamp" : "2014-01-03T06:35:22.255Z",
"result" : [ {
"count" : 337,
"eyeColor" : "brown"
}, {
"count" : 328,
"eyeColor" : "blue"
}, {
"count" : 298,
@lastlegion
lastlegion / query.json
Created November 4, 2016 03:31
Sample Druid query
{
"queryType" : "topN",
"dataSource" : "dummyx",
"intervals" : ["2014-01-01/2016-10-13"],
"granularity" : "all",
"dimension" : "eyeColor",
"metric" : "count",
"threshold" : 25,
"aggregations" :[
{
@lastlegion
lastlegion / index.json
Created November 4, 2016 03:25
Druid dummy data ingestion spec
{
"type" : "index_hadoop",
"spec" : {
"ioConfig" : {
"type" : "hadoop",
"inputSpec" : {
"type" : "static",
"paths" : "quickstart/dummy.json"
}
},