Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTWC0gUpIVksiKaWpJYY8LQJCSwN/x0rZm6nvk/lybV1b9PhHvo4z2293CsPTZYrYhaiQU37992hxY4dzVl8XZ9sposa91CyYjMSnZQEbriReP/63iyMOYHA9c3Dx07z1DHrnBnuKIoAWvpjoD1c6uKJdeZsuVjVvWB5dW7GDYmThkxcYWR1ZErJ0CjNcAZbrmkHHGARFB1D/vxRg5y0x28x0TPICBgh156B5v1EBGO96qwjXFhk2rJBUVJumXyOWvLDc28mAHUpJE5TiJ66Qs5KyB1rqTQN1Yjkw8e4KoGy2MwBNGNm7hq6EVP4eMkItQBrM7H56MSpDvPKkwcEq1Eq82OarxvP1hR/sOwo4OQN/uXh+Y7X2valMRZiZEnjAdN3NBdHoqoqttBr+LlSdr7/wH4la/gGLrGzw5awm/LoCvBx8KNkOnkOPd27NNwmoVVsfEcvaPFupkwEHpaxk5lXKrz8Ngd0/dxUaDZYtct65vPb46hSFoiUQf28XJggc= thomas@moon.localdomain
@sarfata
sarfata / esp32-crashdecoder.py
Created December 28, 2019 01:02
A Python version of the esp32 exception decoder
#!/usr/bin/env python
import argparse
import re
import os
import subprocess
import sys
class ESP32CrashParser(object):
@sarfata
sarfata / iamalive.sh
Created September 16, 2020 19:49
Script to run from crontab to debug CPU lockup issues on a Raspberry Pi
#!/bin/sh │
LOG=/home/pi/iamalive.log │
date >> $LOG │
uptime >> $LOG │
ping -c 1 192.168.1.1 |grep 'transmitted\|rtt' >> $LOG │
echo >> $LOG
@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;
}
@sarfata
sarfata / pebble_fonts.h
Created September 7, 2014 21:49
Pebble fonts
#define FONT_KEY_FONT_FALLBACK "RESOURCE_ID_FONT_FALLBACK"
#define FONT_KEY_GOTHIC_14 "RESOURCE_ID_GOTHIC_14"
#define FONT_KEY_GOTHIC_14_BOLD "RESOURCE_ID_GOTHIC_14_BOLD"
#define FONT_KEY_GOTHIC_18 "RESOURCE_ID_GOTHIC_18"
#define FONT_KEY_GOTHIC_18_BOLD "RESOURCE_ID_GOTHIC_18_BOLD"
#define FONT_KEY_GOTHIC_24 "RESOURCE_ID_GOTHIC_24"
#define FONT_KEY_GOTHIC_24_BOLD "RESOURCE_ID_GOTHIC_24_BOLD"
#define FONT_KEY_GOTHIC_28 "RESOURCE_ID_GOTHIC_28"
#define FONT_KEY_GOTHIC_28_BOLD "RESOURCE_ID_GOTHIC_28_BOLD"
#define FONT_KEY_BITHAM_30_BLACK "RESOURCE_ID_BITHAM_30_BLACK"
@sarfata
sarfata / gist:df39171bebee7766b816
Created May 29, 2014 03:25
JSConf'14 Scavenger Hunt app
var card = new Pebble.UI.Card({ title: "JSConf 2014", subtitle: "Scavenger Hunt", scrollable: true });
card.show();
var msg = "Contacting NSA to get your current position ";
var timer = setInterval(function() {
card.body(msg);
msg += ".";
}, 800);
function distanceBetweenCoordinates(pos1, pos2) {
@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 / app.js
Created June 6, 2014 02:13
AA Hackathon - Example pebblejs app
/*
* Example provided by Pebble for the American Airlines - Gogo in flight - Wearable World Hackathon
*
* To use this project, please go to cloudpebble.net and create a new Pebble.js project.
* Copy and paste this gist in the app.js file.
*
* You will need to update the gogoStatusURL to point to a valid Gogo Inflight test server.
* An example JSON file is provided too.
*/