Skip to content

Instantly share code, notes, and snippets.

View trhura's full-sized avatar

Thura Hlaing trhura

View GitHub Profile
@trhura
trhura / ooredoo-topupcard-reader.py
Created October 4, 2014 21:11
Python script which scan ooredoo topup cards and extract the topup code using opencv+tesseract
#! /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
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;
}
(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
@trhura
trhura / combinations.clj
Created December 26, 2013 09:06
Combinations generator in Clojure
(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)
@trhura
trhura / startup-crawler.py
Created November 8, 2013 05:42
script to parse startup infos from https://angel.co and save it into a csv file.
# Author: Thura Hlaing <trhura@gmail.com>
# 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 <trhura@gmail.com>"
import csv
import requests
#! /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 <trhura@gmail.com>"
import sys
from collections import namedtuple
from scanner import Scanner
from pprint import pprint
@trhura
trhura / importcsv.py
Last active October 28, 2023 19:31
Django Management Command to import csv data into Model. The first line of the csv file must be model field names.
# -*- coding: utf-8 -*-
# Author: Thura Hlaing <trhura@gmail.com>
# Time-stamp: <2013-08-29 16:13:36 (trhura)>
import os
import csv
from django.core.management.base import BaseCommand, CommandError
from django.db.models.loading import get_model
@trhura
trhura / discover.py
Created July 15, 2013 09:17
python script that can discover ubiquiti airOS devices on the network. Equivalence of "Device Discovery Tool".
#! /usr/bin/env python
# script for ubnt device discovery
# Usage: python discover.py or ./discover.py
import socket
from contextlib import closing
PORT=40860
@trhura
trhura / cdp.py
Created July 12, 2013 05:02
A small python script for cdp device discovery
#! /usr/bin/env python
# A small script for cdp devices discovery
import sys
import pcapy
import socket
from dpkt import ethernet
from dpkt import cdp
from docopt import docopt
@trhura
trhura / greed-dice-game.rb
Last active December 19, 2015 00:09
my greed dice-game solution for ruby koans (http://rubykoans.com/)
require File.expand_path(File.dirname(__FILE__) + '/neo')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#