{{ message }}

Instantly share code, notes, and snippets.

# Heather harthur

• New York, NY
Last active Aug 1, 2021
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View understanding-word-vectors.ipynb
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Created Oct 26, 2016
Utility Methods to Transpose a org.apache.spark.mllib.linalg.distributed.RowMatrix
View Transpose.scala
 def transposeRowMatrix(m: RowMatrix): RowMatrix = { val transposedRowsRDD = m.rows.zipWithIndex.map{case (row, rowIndex) => rowToTransposedTriplet(row, rowIndex)} .flatMap(x => x) // now we have triplets (newRowIndex, (newColIndex, value)) .groupByKey .sortByKey().map(_._2) // sort rows and remove row indexes .map(buildRow) // restore order of elements in each row and remove column indexes new RowMatrix(transposedRowsRDD) } def rowToTransposedTriplet(row: Vector, rowIndex: Long): Array[(Long, (Long, Double))] = {
anonymous / index.html
Created Mar 7, 2015
qExGJZ
View index.html

Black scale:
lightest
lighter
light
normal
dark
darker
darkest
Created Apr 27, 2013
View fractals.asm.js
 fractalModule =function(stdlib){ "use asm"; var pow = stdlib.Math.pow; var abs = stdlib.Math.abs; var atan2 = stdlib.Math.atan2; var cos = stdlib.Math.cos; var sin = stdlib.Math.sin; function mandlebrot(cx, cy, maxIter) { cx = +cx; cy = +cy;
anonymous / debug-toolbox.js
Created Dec 22, 2012
Developer tools window to debug toolbox open in current tab.
View debug-toolbox.js
 /* * Running this scratchpad will open a Developer Tools window that's debugging * the currently selected tab's toolbox. */ Cu.import("resource:///modules/devtools/Target.jsm"); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolboxToDebug = gDevTools.getToolbox(target); let tbTarget = TargetFactory.forWindow(toolboxToDebug.frame.contentWindow);
Last active Jul 27, 2021
The Langoliers, a tweet deletion script
View langoliers.rb
 require "rubygems" require "twitter" require "json" # things you must configure TWITTER_USER = "your_username" MAX_AGE_IN_DAYS = 1 # anything older than this is deleted # get these from dev.twitter.com CONSUMER_KEY = "your_consumer_key"
Created Mar 21, 2012
Firefox Magnifier
 /* TODO: - zoom level menu - need to find a way to re-start the update - add color tools - integrate better in Firefox - crosshair has a 1px offset */
Created Jul 25, 2011
Javascript module for color quantization, based on Leptonica
View quantize.js