Skip to content

Instantly share code, notes, and snippets.

View lunaroyster's full-sized avatar

Arnav Bansal lunaroyster

View GitHub Profile
var toTree = function(comments) {
comments.sort(function(x, y) {return -(x.degree-y.degree)}) //Sorts by degree, descending.
var treeDegree = comments[0].degree; //Max degree
var commentsByDegree = {};
for(var comment of comments) {
//Separates comments by degree.
comment.comments = [];
if(commentsByDegree.hasOwnProperty(comment.degree)) {
commentsByDegree[comment.degree].push(comment);
}
#!/usr/bin/python
# Python 2.7.6
# Authors: [thel3l, lunaroyster]
def binarySearch(sortedList, item, start=None, end=None):
#This happens when the item is not present in the array
if(start>end):
return(False)
#If start and end aren't defined, assume it's the entire array
print sorted(input("Enter your Strings: "), key=lambda string: len(string))
class ITEMINFO:
def __init__(self, ICode, Item, Price, Qty, Discount):
self.ICode = ICode
self.Item = Item
self.Price = Price
self.Qty = Qty
self.Discount = Discount
# self.Netprice =
def FindDisc(self):
pass;
def multiply(m1, m2):
x1 = len(m1[0])
y1 = len(m1)
x2 = len(m2[0])
y2 = len(m2)
if(x1!=y2):
return("Error. Bad Matrix")
x3 = x2
@lunaroyster
lunaroyster / donor.py
Created August 26, 2017 18:08
Schoolwork
class Donor:
donors = []
def Input(self, Name, DateOfBirth, Address, Phone, BloodGroup):
self.__Name = Name
self.__DateOfBirth = DateOfBirth
self.__Address = Address
self.__Phone = Phone
self.__BloodGroup = BloodGroup
@staticmethod
def Append(donor):
@lunaroyster
lunaroyster / TickGenerator.js
Created August 30, 2017 15:59
Generates ticks. Adjust tick length. Start and stop generator.
var on = function(name, handler) {
if(this._events.hasOwnProperty(name)) {
this._events[name].push(handler);
}
else {
this._events[name] = [handler];
}
};
var invoke = function(name, args) {
var res = [];
class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
const fse = require('fs-extra');
const path = require('path');
const less = require('less');
function toCSS(lessFileName) {
return lessFileName.replace(".less", ".css");
}
module.exports = (async (lessFolder, outFolder)=> {
await fse.ensureDir(outFolder);
const fse = require('fs-extra');
const path = require('path');
const sass = require('node-sass');
function toCSS(scssFileName) {
return scssFileName.replace(".scss", ".css");
}
module.exports = (async (scssFolder, outFolder)=> {
await fse.ensureDir(outFolder);