Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View shamod's full-sized avatar

Shamod Lacoul shamod

View GitHub Profile
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
def findPath(root, x, res):
if not root: return False
res.append(root.val)
if root.val == x:
return True
class Solution(object):
def insert(self, intervals, newInterval):
"""
:type intervals: List[List[int]]
:type newInterval: List[int]
:rtype: List[List[int]]
"""
'''
Test cases
i) [], [2,5] => [[2,5]]
@shamod
shamod / wordcount.nonfunctional.js
Created April 24, 2015 00:42
WordCount - Non-funcational
var para = 'How much wood would a woodchuck chuck\nIf a woodchuck could chuck wood?\nHe would chuck, he would, as much as he could,\nAnd chuck as much as a woodchuck would\nIf a woodchuck could chuck wood.';
function Words(paragraph) {
this.paragraph = paragraph;
};
Words.prototype.countWords = function() {
var mapWords = {},
arrWords = this.createArrayOfWords(this.paragraph);
@shamod
shamod / wordcount.functional.js
Last active August 29, 2015 14:19
WordCount - Functional
var paragraph = 'How much wood would a woodchuck chuck\nIf a woodchuck could chuck wood?\nHe would chuck, he would, as much as he could,\nAnd chuck as much as a woodchuck would\nIf a woodchuck could chuck wood.';
var paraCount = paragraph.split('\n')
.reduce(joinArray)
.replace(/[^\w\s]/g, '')
.split(/\s+/)
.reduce(wordCount, {});
function joinArray(last, now) {
return last.toLowerCase().concat(' ' + now.toLowerCase());
20:49:27,543 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "project2.clj"
20:49:27,553 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."project2.clj".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."project2.clj".STRUCTURE: Failed to process phase STRUCTURE of deployment "project2.clj"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run
@shamod
shamod / everyauth.js
Created May 26, 2011 01:06
everyauth steps incomplete
var express = require('express')
, everyauth = require('everyauth')
, conf = require('./conf');
everyauth.debug = true;
var usersByTwitId = {};
everyauth
.twitter