Skip to content

Instantly share code, notes, and snippets.

@ken47
ken47 / gist:5723232
Created June 6, 2013 17:21
Ken's testem.json
{
"framework": "mocha",
"src_files": [
"assets/javascripts/**/*.js",
"spec/js/**/*.js"
],
"serve_files": [
"testem/setup.js",
"spec/js/deps/sinon.js",
"node_modules/expect.js/expect.js",
@ken47
ken47 / coursera-courses-js
Created October 12, 2012 05:14
copy and paste this into dev console while on the course listings page for performance gains
// #1 I do not have access to the 'added' timestamp (for the purposes of sorting), so I just used the first class date as a substitute.
// #2 I disabled the image loading (inView()) functionality, because using $(element).hide() caused significant lag when scrolling.
// This issue could probably be corrected by adding an additional filter on the $('img') search triggered by inView()
jQuery.ajax({
url: 'https://www.coursera.org/maestro/api/topic/list?full=1',
success: function(catalog) {
var compressed = [],
course_names = [],
instructors = [];
@ken47
ken47 / gist:3870213
Created October 11, 2012 04:41
single-layer perceptron in Octave / Matlab
function perceptron0 = perceptron(numPoints, runs)
iters = 0;
for i = 1:runs
errors = 2;
points = genPoints(numPoints);
gWeights = [0 0 0];
[fWeights,a,b] = genTarget;
while errors > 0
errors = 0;
@ken47
ken47 / gist:3734083
Created September 16, 2012 19:46
string parsing w ruby
text = File.read(filepath)
if text.include? "console.log"
puts '########'
puts "console.log statements detected in " + filepath.split('/').last
puts '########'
next_console_log = 0
while true do
next_console_log = text.index('console.log', next_console_log)
if next_console_log.nil?