Skip to content

Instantly share code, notes, and snippets.

@sarfata
sarfata / jshint-pebble
Created January 13, 2014 02:50
A sample [JSHint](http://www.jshint.com) configuration file for Pebble development and a modified `wscript` build file to call jshint on every build.
/*
* Example jshint configuration file for Pebble development.
*
* Read: http://developer.getpebble.com/blog/2014/01/12/Using-JSHint-For-Pebble-Development/
* And check out the full documentation at http://www.jshint.com/docs/options/
*/
{
// Declares the existence of a global 'Pebble' object
"globals": { "Pebble" : true },
@sarfata
sarfata / hn-watch.py
Created June 10, 2013 10:48
Parses hn homepage and counts article with small scores so you can have a better idea of when is a good time to post.
# -*- coding: utf-8 -*-
import sys
import codecs
import re
from bs4 import BeautifulSoup
import requests
reload(sys)
sys.setdefaultencoding("utf-8")
@sarfata
sarfata / gist:5549732
Created May 9, 2013 19:06
First test pass but the second one fails - I do not understand why. The only difference is that the second test ticks 200ms (which is more than needed), while the first one only ticks 100ms.
var assert = require('assert'),
sinon = require('sinon');
describe("Testing sinon useFakeTimers", function() {
it('sinon faking timer should work with small intervals', function() {
var clock = sinon.useFakeTimers();
var spy = sinon.spy();
setInterval(spy, 100);
assert(! spy.calledOnce);
@sarfata
sarfata / gist:5068200
Created March 1, 2013 21:58
Google Script example on how to get the total number of comments for a disus forum
function disqusComments(cursor) {
var api_key = "YOUR_API_KEY";
var forum = "YOUR_FORUM";
var url = "https://disqus.com/api/3.0/forums/listThreads.json?api_key=" + api_key + "&forum=" + forum; //+ "&limit=100";
if (cursor) {
url = url + "&cursor=" + cursor;
}