Skip to content

Instantly share code, notes, and snippets.

View mh-github's full-sized avatar

Mahboob Hussain mh-github

View GitHub Profile
@Controller
public class LoginLogoutController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public void login() {
}
........
}
@mh-github
mh-github / word_pe.rb
Created March 31, 2013 18:30
Ruby program to find if a word is made up of periodic table elements' symbols.
#!/usr/bin/ruby
periodic_elements = ["h", "he", "li", "be", "b", "c", "n", "o", "f", "ne", "na", "mg", "al", "si", "p", "s", "cl", "ar", "k", "ca", "sc", "ti", "v", "cr", "mn", "fe", "co", "ni", "cu", "zn", "ga", "ge", "as", "se", "br", "kr", "rb", "sr", "y", "zr", "nb", "mo", "tc", "ru", "rh", "pd", "ag", "cd", "in", "sn", "sb", "te", "i", "xe", "cs", "ba", "la", "ce", "pr", "nd", "pm", "sm", "eu", "gd", "tb", "dy", "ho", "er", "tm", "yb", "lu", "hf", "ta", "w", "re", "os", "ir", "pt", "au", "hg", "tl", "pb", "bi", "po", "at", "rn", "fr", "ra", "ac", "th", "pa", "u", "np", "pu", "am", "cm", "bk", "cf", "es", "fm", "md", "no", "lr", "unq", "unp", "unh", "uns", "uno", "une", "unn"]
$found_array = []
$solution_array = []
headless_word_arr = []
$word = ARGV[0]
@mh-github
mh-github / docdist8.py
Last active December 16, 2015 04:09
Erik D. Demaine (MIT)'s Python program to compute the "distance" between two text files as the angle between their word frequency vectors (in radians).
#!/usr/bin/python
# docdist8.py - treat whole file as a single "line"
#
# Original version by Erik D. Demaine on January 31, 2011,
# based on code by Ronald L. Rivest (see docdist[1-7].py).
#
# Usage:
# docdist8.py filename1 filename2
#
# This program computes the "distance" between two text files
@mh-github
mh-github / docdist-v3.rb
Created April 12, 2013 22:02
Ruby program that computes the "distance" between two text files as the angle between their word frequency vectors (in radians). This is Ruby version of Erik Demaine's (MIT) docdist8.py
#!/usr/bin/ruby
def read_file(filename)
"""
Read the text file with the given filename;
return a list of the lines of text in the file.
"""
begin
f = File.open(filename, "r")
return f.read()
@mh-github
mh-github / docdist-v0.rb
Created April 12, 2013 22:05
Ruby program that computes the "distance" between two text files as the angle between their word frequency vectors (in radians). This is Ruby version of Erik Demaine's (MIT) docdist8.py
#!/usr/bin/ruby
def read_file(filename)
"""
Read the text file with the given filename;
return a list of the lines of text in the file.
"""
begin
f = File.open(filename, "r")
return f.read()
@mh-github
mh-github / docdist-v5.rb
Created April 13, 2013 20:28
Ruby program that computes the "distance" between two text files as the angle between their word frequency vectors (in radians). This is Ruby version of Erik Demaine's (MIT) docdist8.py
#!/usr/bin/ruby
def read_file(filename)
=begin
Read the text file with the given filename;
return a list of the lines of text in the file.
=end
begin
f = File.open(filename, "r")
return f.read()
@mh-github
mh-github / brew-install-graphviz-failed.log
Created May 19, 2013 00:14
brew install graphviz failed on OS X 10.8.3
mh-iMac:Russel mahboob$ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install graphviz 2>&1
==> Downloading http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.30.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/graphviz-2.30.1.tar.gz
tar xf /Library/Caches/Homebrew/graphviz-2.30.1.tar.gz
==> Downloading patches
/usr/bin/curl -f#LA Homebrew 0.9.4 (Ruby 1.8.7-358; Mac OS X 10.8.3) https://trac.macports.org/export/103168/trunk/dports/graphics/graphviz/files/patch-project.pbxproj.diff -o 000-homebrew.diff
######################################################################## 100.0%
==> Patching
/usr/bin/patch -f -p0 -i 000-homebrew.diff
patching file macosx/graphviz.xcodeproj/project.pbxproj
@mh-github
mh-github / mh-get-blogger-posts.py
Created July 27, 2013 13:16
Fetch blogger posts with Python
#!/usr/bin/python
import urllib2
from BeautifulSoup import BeautifulSoup
from BeautifulSoup import BeautifulStoneSoup
from nltk import clean_html
from HTMLParser import HTMLParser
import feedparser
import os
@mh-github
mh-github / Mongo_Insert_Collection.java
Created July 13, 2014 08:56
Inserting a million records into MongoDB
import java.net.UnknownHostException;
import com.mongodb.Mongo;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.mongodb.MongoException;
public class Mongo_Insert_Collection