This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# How to run this program: python3 twittersort.py tweet1.py tweet2.py | |
# Implementation for CS150 project 2 (http://troll.cs.ua.edu/cs150/projects/index.html) | |
__author__ = "Thura Hlaing <[email protected]>" | |
import sys | |
from collections import namedtuple | |
from scanner import Scanner | |
from pprint import pprint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Thura Hlaing <[email protected]> | |
# Time-stamp: <2013-11-08 12:11:30 (trhura)> | |
# script to parse startup infos from https://api.angel.co/1/startups?filter=raising and | |
# save it into a csv file. | |
__author__ = "Thura Hlaing <[email protected]>" | |
import csv | |
import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn combinations [lst k] | |
(letfn [(combinator [x xs] | |
(if (= (count x) k) | |
[x] | |
(when (not (empty? xs)) | |
(concat (combinator (concat x [(first xs)]) (rest xs)) | |
(combinator x (rest xs))))))] | |
(combinator nil lst))) | |
;; user> (combinations (range 1 6) 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn palindrome? [string] | |
"Check whether a given string is a palindrome." | |
(loop [string string | |
start 0 | |
end (dec (count string))] | |
(cond | |
;;compare string's start and string's end | |
(not (= (get string start) (get string end))) false | |
;; return true after checking middle char | |
(<= end start) true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
private static boolean isPalindrome (String string) { | |
String reversedString = new StringBuilder(string).reverse().toString(); | |
for (int i =0; i < string.length() / 2; i++) { | |
if (string.charAt(i) != reversedString.charAt(i)) | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2 | |
import cv2 | |
import numpy as np | |
from collections import deque | |
orig_image = None | |
gray_image = None | |
threshold_image = None | |
edge_image = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2 | |
import cv2 | |
import numpy as np | |
colors = [] | |
def on_mouse_click (event, x, y, flags, frame): | |
if event == cv2.EVENT_LBUTTONUP: | |
colors.append(frame[y,x].tolist()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Assuming a and b are not negative | |
multiply a 0 = 0 | |
multiply a 1 = a | |
multiply a b = a + multiply a (b-1) | |
-- Assuming e is not negative | |
power b 0 = 1 | |
power b 1 = b | |
power b e = multiply b $ power b (e-1) -- aka multiply b (power b e-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiply(a, b): | |
# Assuming a and b are not negative | |
if b == 0: return 0 | |
if b == 1: return a | |
return a + multiply(a, b-1) | |
def power(b, e): | |
# Assuming e is not negative | |
if e == 0: return 1 | |
if e == 1: return b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module (calculator). | |
-export ([exponential/2, multiply/2]). | |
multiply(_, 0) -> 1; | |
multiply(Num, 1) -> Num; | |
multiply(Num, Exp) -> Num + multiply(Num, Exp-1). | |
exponential(_, 0) -> 1; | |
exponential(Base, 1) -> Base; | |
exponential(_, Exp) when(Exp < 0) -> throw("Bad argument"); |