Skip to content

Instantly share code, notes, and snippets.

View chathuranga94's full-sized avatar

Udara Bibile chathuranga94

  • AmnesiaTech
  • Colombo, Sri Lanka
View GitHub Profile
@chathuranga94
chathuranga94 / client.html
Last active September 10, 2017 08:24
SocketIO-v2-Chat
<html>
<body>
<form action="">
<input id="m" autocomplete="off" /><button>Send</button>
</form>
<ul id="messages"></ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.0/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script>
@chathuranga94
chathuranga94 / spark.py
Created November 15, 2017 17:40
SPARK AvgById
sc.textFile("/home/bibi/Desktop/distributed.csv") \
.map(lambda line: line.split(",")) \
.map(lambda line: (int(line[0]),float(line[2]))) \
.combineByKey( lambda value: (value, 1),
lambda x, value: (x[0] + value, x[1] + 1),
lambda x, y: (x[0] + y[0], x[1] + y[1])) \
.map(lambda (label, (value_sum, count)): (label, value_sum / count)) \
.collectAsMap()
@chathuranga94
chathuranga94 / readme.txt
Created January 24, 2018 02:51
SAMPLE JSON
USE https://jsoneditoronline.org/ TO VISUALIZE THESE DATA!
USER.JSON
WRITE LOGIC TO COMPARE ALL VIDEOS WITHING ALL PLAYLISTS -> KEEP COUNT OF ALL VIDEOS COUNT -> COMPARE WITH WATCHED VIDEOS
WRITE LOGIC TO COMPARE QUIZES WITH COMPLETED WATCHED VIDEOS
@chathuranga94
chathuranga94 / basics.js
Last active January 21, 2019 10:24
GraphQL gists for article
const { ApolloServer, gql } = require('apollo-server');
// The GraphQL schema
const typeDefs = gql`
type Query {
"A simple type for getting started!"
book: Book
}
type Book {
const typeDefs = gql`
type Query {
Posts: [Post],
}
type Mutation {
addPost(title: String!, content: String!): [Post]
}
type Post {
title: String
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql');
const schema = buildSchema(`
input MessageInput {
content: String
author: String
}
FROM node:8
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace efcore
{
public class AppDBContext : DbContext
{
public DbSet<Student> Students { get; set; }
public DbSet<Course> Courses { get; set; }
import React from 'react';
const App = () => {
return <Menu colour="blue" language="en" />;
}
function Menu(props) {
return(
<MenuItem
colour={props.colour}
import React from 'react';
const AppContext = React.createContext({ colour: 'blue', lang: 'en' });
const App = () =>
<AppContext.Provider value={{ colour: 'blue', lang: 'fr' }}>
<Menu />
</AppContext.Provider>;
function Menu() {