Skip to content

Instantly share code, notes, and snippets.

View rehrumesh's full-sized avatar
:octocat:
👍

Rumesh Eranga Hapuarachchi rehrumesh

:octocat:
👍
View GitHub Profile
@rehrumesh
rehrumesh / mosh.c
Created December 20, 2014 07:55
MyOwnShell
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
char *PATH="PATH=/bin:/usr/bin"; //System PATH variable.
void process(char *msg); //function to execute a command without a pipe
void processWithPipe(char *msg); //function to execute commands with a pipe
@rehrumesh
rehrumesh / makeAlphaFreqDist.py
Last active August 29, 2015 14:19
SCS4011 Lab1 Optional task
def makeAlphaFreqDist(words):
adist = FreqDist()
pattern = re.compile('.*[^a-z].*')
for word in words:
if not pattern.match(word):
adist[word] += 1
return adist
@rehrumesh
rehrumesh / bigramDist.py
Created April 14, 2015 07:10
SCS4011 Lab2 bigramDist
def bigramDist(words,stoplist):
biDist = FreqDist()
uniDist = alphaStopFreqDist(words,stoplist)
for i in range(1, len(words)):
if words[i-1] in uniDist and words[i] in uniDist:
biWord = words[i-1] + ' ' + words[i]
biDist[biWord] += 1
return biDist
@rehrumesh
rehrumesh / stem.py
Created April 14, 2015 07:27
SCS4011 Lab3 Stemmer
def stem(word):
for suffix in ['ing','ly','ed','ious','ies','ive','es','s']:
if word.endswith(suffix):
return word[:-len(suffix)]
return word
public static void quickSort(int array[]) {
quickSort(array, 0, array.length - 1);
}
public static void quickSort(int array[], int start, int end) {
int i = start;
int k = end;
if (end - start >= 1) {
int pivot = array[start];
CONTIKI_PROJECT=P3
all:$(CONTIKI_PROJECT)
CONTIKI=../..
include $(CONTIKI)/Makefile.include
#include "contiki.h"
#include "dev/button-sensor.h"
#include <stdio.h>
PROCESS(blink_process, "Blink");
AUTOSTART_PROCESSES(&blink_process);
PROCESS_THREAD(blink_process,ev,data){
PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);
#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
PROCESS(blink_process, "Blink");
AUTOSTART_PROCESSES(&blink_process);
PROCESS_THREAD(blink_process,ev,data){
PROCESS_BEGIN();
@rehrumesh
rehrumesh / Stack.py
Created May 2, 2015 05:04
Simple Python stack
class Stack:
def __init__(self):
self.items=[]
def isEmpty(self):
return self.items==[]
def push(self,item):
self.items.append(item)