This file contains 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
import sys, os, glob | |
from datetime import datetime | |
sys.path.append(os.environ.get("MAHOUT_CORE")) | |
for jar in glob.glob(os.environ.get("MAHOUT_JAR_DIR") + "/*.jar"): | |
sys.path.append(jar) | |
from org.apache.mahout.common import RandomUtils | |
from org.apache.mahout.cf.taste.common import TasteException | |
from org.apache.mahout.cf.taste.eval import * |
This file contains 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
#redundancy is the max number of survivable failures, so eg 1 for RAID5 | |
#mtbf_array is an array of either actual mean-time-between-failures, or a nested RAID array | |
# RAID([100]*7,2) #7 disk RAID 6 | |
# RAID([RAID([100]*3,1),RAID([1000]*3,1)],0) # RAID 50, 2 arrays of 3 | |
# RAID([100,100,50,50],1) #RAID 5 with varying reliabilities | |
from random import random | |
class RAID(object): |
This file contains 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
from multiprocessing import Pool | |
from functools import partial | |
def _pickle_method(method): | |
func_name = method.im_func.__name__ | |
obj = method.im_self | |
cls = method.im_class | |
if func_name.startswith('__') and not func_name.endswith('__'): #deal with mangled names | |
cls_name = cls.__name__.lstrip('_') | |
func_name = '_' + cls_name + func_name |
This file contains 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
import urllib | |
import re | |
import time | |
data = urllib.urlopen('http://bitly.measuredvoice.com/bitly_archive/?C=M;O=D').read() | |
#print data | |
#datafiles name pattern - usagov_bitly_data2011-07-29-1311919454 |
This file contains 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
import sys | |
import numpy | |
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance | |
import nltk.corpus | |
from nltk import decorators | |
import nltk.stem | |
stemmer_func = nltk.stem.EnglishStemmer().stem | |
stopwords = set(nltk.corpus.stopwords.words('english')) |
This file contains 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
# Description: Consume a DataSift stream and save Twitter interactions to a Google Fusion Table | |
# Author: Paul M. Watson <[email protected]> | |
# Date: 2011/11/28 | |
# Usage: | |
# ruby ds_to_gft.rb <DataSift stream id hash> | |
# config.yml should contain; | |
# datasift: | |
# username: datasift username | |
# api_key: datasift api key | |
# googlefusiontables: |
This file contains 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
#include <sys/xattr.h> | |
/// Set a flag that the files shouldn't be backuped to iCloud. | |
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath { | |
u_int8_t b = 1; | |
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0); | |
} | |
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available. | |
+ (NSString *)legacyStoragePath { |
This file contains 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
// | |
// MNDocumentConflictResolutionViewController.h | |
// MindNodeTouch | |
// | |
// Created by Markus Müller on 15.12.11. | |
// Copyright (c) 2011 __MyCompanyName__. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@class MNDocumentReference; |
This file contains 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
var donutVal = 85; | |
var donutFull = 100 - donutVal; | |
var d3_category_socialmedia = ["#0054a6", "#dbdbdb"]; | |
if(donutVal < 50) { | |
donutVal = -donutVal; | |
donutFull = -donutFull; |
This file contains 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 python | |
"""Split large file into multiple pieces for upload to S3. | |
S3 only supports 5Gb files for uploading directly, so for larger CloudBioLinux | |
box images we need to use boto's multipart file support. | |
This parallelizes the task over available cores using multiprocessing. | |
Usage: | |
s3_multipart_upload.py <file_to_transfer> <bucket_name> [<s3_key_name>] |
OlderNewer