How to install and configure grunt on mac Osx
This post is intended to assist folks who are trying to install and work with grunt on mac osx
Install Node.js and npm with Homebrew First, install Homebrew by typing in the following command ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Then, type in brew update to ensure your Homebrew is up to date.
brew update Run
brew doctor to make sure your system is all good.
Follow any other recommendations from brew doctor.
Normalizing Ranges of Numbers
Range Normalization is a normalization technique that allows you to map a number to a specific range.
Lets say that we have a data set where the values are in a range of 1 to 10, however we wish to normalise it to a range between 0 and 5
Mathematically speaking the equation comes down to
translated to Python
class Normaliser: def __init__(self,dH,dL,nH,nL): self.dH = dH self.dL = dL self.nH = nH self.
Install tile-stache on OsX Mavericks
This is quick tutorial about installing Tilestache library in OSX Mavericks.
Step 1 Make sure Developer tools are installed xcode-select –install
Then add these flags to tell xcode to use python like rest of the world does
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
Finally type in sudo easy_install tilestache
Thats it all done, you might see some warnings but thats fine ignore them .
Read the introduction here to get started
Hope it helps.
how to make a web crawler in python
Here is a very simple web crawler in python
import sys, thread, Queue, re, urllib, urlparse, time, os, sys dupcheck = set() q = Queue.Queue(100) q.put("http://www.varunpant.com") def queueURLs(html, origLink): for url in re.findall(''']+href="'["']''', html, re.I): link = url.split("#", 1)[0] if url.startswith("http") else '{uri.scheme}://{uri.netloc}'.format(uri=urlparse.urlparse(origLink)) + url.split("#", 1)[0] if link in dupcheck: continue dupcheck.add(link) if len(dupcheck) > 99999: dupcheck.clear() q.put(link) def getHTML(link): try: html = urllib.urlopen(link).read() print link # open(str(time.time()) + ".html", "w").
Ternary search tree
In computer science, a ternary search tree is a type of prefix tree where nodes are arranged as a binary search tree. Like other prefix trees, a ternary search tree can be used as an associative map structure with the ability for incremental string search. However, ternary search trees are more space efficient compared to standard prefix trees, at the cost of speed. Common applications for ternary search trees include spell-checking and auto-completion.