Skip to content

Instantly share code, notes, and snippets.

View AnthonyNystrom's full-sized avatar

Anthony Nyström AnthonyNystrom

View GitHub Profile
package mapreduce
func MapReduce(mapper func(interface{}, chan interface{}),
reducer func(chan interface{}, chan interface{}),
input chan interface{},
pool_size int) interface{}
{
reduce_input := make(chan interface{});
reduce_output := make(chan interface{});
worker_output := make(chan chan interface{}, pool_size);
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
total = 0
N = 300
start_time = time()
for a in 0:(N - 1)
for b in 0:(N - 1)
for c in 0:(N - 1)
if a^2 + b^2 == c^2
total = total + 1
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
import os
def split(filehandler, delimiter=',', row_limit=10000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
"""
Splits a CSV file into multiple pieces.
A quick bastardization of the Python CSV library.
Arguments:

#Map Reduce is Simple (in Javascript)

##The Implementation

var mf = function (item){return item;};//Sample MAP FUNCTION -- this one does nothings to the initial values of the DATA array 
    //For more information, check out https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
 
var rf = function (iv,current) {iv.push(current);return iv;};//Sample REDUCE FUNCTION -- this one simply adds mapped values to the INITIAL VALUE array
 //For more information, check out https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reduce

Python Number Conversion Chart

From To Expression
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
# Copyright (c) 2011, Xabier (slok) Larrakoetxea
# Copyright (c) 2011, Iraide (Sharem) Diaz
#
# 3 clause/New BSD license:
# opensource: http://www.opensource.org/licenses/BSD-3-Clause
# wikipedia: http://en.wikipedia.org/wiki/BSD_licenses
#
#-----------------------------------------------------------------------
# This script allows to upload to Fileserve with FTP various files at the same time
#
@AnthonyNystrom
AnthonyNystrom / es.sh
Created June 13, 2012 06:17 — forked from KazW/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
wget https://raw.github.com/flexiondotorg/oab-java6/master/oab-java6.sh -O oab-java6.sh
chmod +x oab-java6.sh
sudo ./oab-java6.sh
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz