Skip to content

Instantly share code, notes, and snippets.

Gpio interrupt callbacks in Node.js

When using the C++ Gpio method isr or the C function mraa_gpio_isr it's important to know that the passed in function will be called in the context of a low level interrupt.

As such it should be coded very carefully, and typically do as little as possible, in order not to interfere with the environment that has been interrupted.

When using the isr method in Javascript do we have to worry about this kind of thing?

The answer is no, as the logic for the Javascript wrappers ensures that the callback function passed to isr is invoked from the normal Node.js event loop.

Cable making service?

Hi all --

Does anyone know someone who can make high quality cables?

I need to make an adapter from a JST-PH 2-pin male connector to a two pin 0.1" female header connector.

To hack up something like this would be trivial, but I need them for a situation where they should look near perfect - for this I came up with:

BLE Nano and the nRF51822 SDK

If you've tried using the nRF51822 SDK with the BLE Nano (after following the RedBearLab guide) you may have come to a dead end.

Even the simplest examples didn't work for me. I assumed I had a dead Nano (despite the upload process seeming to work fine).

The reason turned out to be that the latest SDK versions assume you have a nRF51822 chip with 32KB of RAM rather than the 16KB that the nRF51822 on the Nano has.

James Willcox explains this in a post to the RedBearLab BLE Nano support forum.

'use strict';
var globalFoo;
function Foo(name) {
this.name = name;
}
function captureGlobalFoo(name) {
globalFoo = new Foo(name);
package hello;
import com.stormpath.sdk.servlet.config.CookieConfig;
public class DelegatingCookieConfig implements CookieConfig {
private final CookieConfig delegate;
public DelegatingCookieConfig(CookieConfig config) {
this.delegate = config;
}
@george-hawkins
george-hawkins / hcidump.out
Last active November 25, 2015 17:00
Noble #269
@george-hawkins
george-hawkins / SpringPropertiesTest.java
Last active June 9, 2016 10:07
Accessing Spring properties in a non-Spring application. This test demonstrates creating an application context that doesn't create beans but does setup the environment.
package com.example;
import java.util.Arrays;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.boot.ApplicationArguments;
def union(that: TweetSet): TweetSet = {
(left union (right union that)) incl elem
// If we have two trees x={{{.a.}b.}c{.d{.e.}}} and y={{{.f.}g.}h{.i{.j.}}} the number of calls to union varies dramatically according to how we order things:
//
// (left union (right union that)) incl elem // calls=5
// (right union (left union that)) incl elem // calls=5
// (right union (that union left)) incl elem // calls=36
// (left union (that union right)) incl elem // calls=33
// (that union (left union right)) incl elem // calls=26
// (that union (right union left)) incl elem // calls=26
package mytests
import org.scalatest.FunSuite
class MonadLawSuite extends FunSuite {
// 1. Remind ourselves about associativity.
test("addition is associative") {
val rtl = (1 + 2) + 3
val ltr = 1 + (2 + 3)
@george-hawkins
george-hawkins / StreamCost.java
Created August 27, 2016 10:44
Do streams involve upfront calculation in Java?
package net.betaengine;
import java.util.stream.IntStream;
public class StreamCost {
private boolean isPrime(int n) {
System.out.println("Checking if " + n + " is a prime.");
return IntStream.range(2, n).allMatch(x -> n % x != 0);
}