Skip to content

Instantly share code, notes, and snippets.

View chathurawidanage's full-sized avatar
🏠
Working from home

Chathura Widanage chathurawidanage

🏠
Working from home
View GitHub Profile
import IPython
import numpy as np
from IPython.display import display, HTML, Javascript
import time
import random
def configure_browser_state():
display(IPython.core.display.HTML('''
<canvas id="myChart"></canvas>
'''))
@chathurawidanage
chathurawidanage / gahw1.py
Last active February 3, 2021 05:12
Graph Analytics HW1 Sample Codes
import networkx as nx
# Degree distribution
# Input: A graph
# Output: find degrees and plot their distribution
def Degree_Distribution(G):
degree = G.degree()
degree = [ deg for (v,deg) in degree ]
plot_distribution(degree, xlabel='Degree ($k$)',
<div>
<h1>Your module title here</h1>
<div style="display: grid; grid-template-columns: 100px auto">
<img
width="100%"
src="https://www.cs.cornell.edu/courses/cs1110/2020fa/lessons/lesson30/thumb.png"
/>
<div>
<p>
Your descriotion here. Your descriotion here. Your descriotion here.
@chathurawidanage
chathurawidanage / demo.py
Created January 5, 2021 21:37
My Demo Python
def x():
return 129
x = 90
@chathurawidanage
chathurawidanage / sgx-pod.yaml
Created December 18, 2020 22:06
Running SGX enabled pod
apiVersion: v1
kind: Pod
metadata:
name: shell-demo2
namespace: default
spec:
containers:
- image: tozd/sgx:ubuntu-xenial
imagePullPolicy: IfNotPresent
name: sgx-ubuntu2
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.IntVector;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.ipc.ArrowFileReader;
import org.apache.arrow.vector.ipc.SeekableReadChannel;
import org.apache.arrow.vector.ipc.message.ArrowBlock;
import org.apache.arrow.vector.types.pojo.Schema;
import java.io.File;
@chathurawidanage
chathurawidanage / tei.js
Created March 17, 2020 15:03
TEI fetch
const axios = require('axios');
const headers = {Authorization: "Basic YWRtaW46ZGlzdHJpY3Q="};
const baseURL = "https://play.dhis2.org/2.33.2/api/";
function getTEIs() {
return axios.get(baseURL + "trackedEntityInstances.json?ouMode=ACCESSIBLE&fields=[trackedEntityInstance,relationships]", {headers});
}
function getTEIInfo(teiId) {
{
totalMapTaskSpecs: 29,
completedMapTaskSpecs: 29,
totalReduceTaskSpecs: 8,
completedReduceTaskSpecs: 0,
jobConfig: {
name: "Word Count",
id: "37f40245-de47-4d43-bd6c-9c896e780e37",
mapperClass: "com.cwidanage.mapred.examples.WordCount$WordMapper",
#include <arrow/compute/api.h>
#include <arrow/array/builder_base.h>
#include "arrow_utils.h"
namespace twisterx::util {
void copy_int64_by_index(int64_t index,
std::shared_ptr<arrow::Array> data_column,
std::shared_ptr<arrow::ArrayBuilder> array_builder) {
auto casted_builder = std::static_pointer_cast<arrow::Int64Builder>(array_builder);
@chathurawidanage
chathurawidanage / rtmp_client.py
Last active January 16, 2020 19:11
RTMP Client with Video Analysis
# https://github.com/log0/video_streaming_with_flask_example
import os
import numpy as np
import cv2
from flask import Flask, render_template, Response
import time
import cv2
import core.utils as utils