Skip to content

Instantly share code, notes, and snippets.

View janjongboom's full-sized avatar

Jan Jongboom janjongboom

View GitHub Profile
@janjongboom
janjongboom / loraCS.js
Created September 8, 2015 07:12
LoRa Customer Server in node
var net = require('net');
var server = net.createServer(function(socket) {
console.log('Listening yo');
socket.on('data', function(data) {
if (data.length === 1 && data[0] === 0x00) {
return; // some sort of ping?
}
// so all messages end with 0x00 so skip that
var obj = data.toString('utf8', 0, data.length - 1);
@janjongboom
janjongboom / uribeacon.js
Created August 10, 2015 12:20
Scan Uri Beacons with Web Bluetooth
navigator.mozBluetooth.defaultAdapter.startLeScan([]).then(handle => {
console.log('Start scanning', handle);
handle.ondevicefound = e=> {
var uri = parseUriBeacon(e.scanRecord);
if (uri) {
return console.log('Found UriBeacon', uri);
}
}
@janjongboom
janjongboom / README.md
Created June 4, 2015 10:04
Building LoRaMac-node on OS/X and Linux without IDE

This applies to building the software from LoRaMac-node for LoRaMote Class A with MCU STM32L151CB on an OS/X or Linux system.

  1. Acquire the GNU Tools for ARM Embedded Processors
  2. Put it under ~/toolchains/arm-embedded-4_9 (or change the paths in the .sh file)
  3. Place the build-loramote-class-a.sh file in your LoRaMac-node directory, and chmod +x it
  4. Run ./build-loramote-class-a.sh
  5. LoRaMacClassA.elf will be in your out/ directory
  6. ???
  7. PROFIT!
@janjongboom
janjongboom / ibeacon.js
Created May 18, 2015 12:42
iBeacon scanning Firefox OS
navigator.mozBluetooth.defaultAdapter.startLeScan([]).then(handle => {
console.log('Start scanning', handle);
handle.ondevicefound = e=> {
var record = parseScanRecord(e.scanRecord);
if (record) {
console.log('Found an iBeacon', record.uuid, record.major, record.minor, e.rssi);
}
}
setTimeout(() => {
diff --git a/dom/apps/AppsUtils.jsm b/dom/apps/AppsUtils.jsm
index b44c11e..edc5caa 100644
--- a/dom/apps/AppsUtils.jsm
+++ b/dom/apps/AppsUtils.jsm
@@ -33,7 +33,7 @@ this.EXPORTED_SYMBOLS =
["AppsUtils", "ManifestHelper", "isAbsoluteURI", "mozIApplication"];
function debug(s) {
- //dump("-*- AppsUtils.jsm: " + s + "\n");
+ dump("-*- AppsUtils.jsm: " + s + "\n");
@janjongboom
janjongboom / emscripten_mmap.h
Last active September 23, 2015 04:33
emscripten_mmap.h
#ifndef EMSCRIPTEN_MMAP_H_
#define EMSCRIPTEN_MMAP_H_
#ifndef EMSCRIPTEN
#define define_mmap_write(T, name) \
void mmap_write_##name(void* map, size_t index, T value) { \
((T*)map)[index] = value; \
}
#define define_mmap_read(T, name) \
@janjongboom
janjongboom / gist:94d575526a689687a6b8
Last active February 24, 2023 14:40
Firefox OS / JanOS on Raspberry Pi with GPIO support

This does NOT work on Raspberry Pi 2!

  1. Obtain a 8GB (or bigger) SD Card
  2. Download disk image from http://janos.io/builds/fxos-pi-gpio.img.zip and unzip
  3. Put SD card in your computer
  4. Find out where your SD card is mounted (BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!), f.e. /dev/disk5 on OSX
  5. On Linux, run: sudo dd bs=4M if=fxos-pi-gpio.img of=/path/to/your/disk
  6. On OSX, run: sudo dd bs=4m if=fxos-pi-gpio.img of=/dev/rdisk5 (do rdisk, not disk here!)
  7. When it's done put it in your Pi and start up
  8. The demo's are wired like this: yellow LED on GPIO2, red LED on GPIO3, button (wire it as pulldown) on GPIO26.
@janjongboom
janjongboom / gist:8faddcbfc361acab4ec4
Created February 23, 2015 12:02
Flash Jan's experimental build for rpi
  1. Follow instructions to install the prebuilt version for rpi from here: https://wiki.mozilla.org/Hacking_b2g_on_Raspberry_Pi
  2. Boot rpi and connect to wired network. Find the IP it's registered via nmap --open -p 5555 192.168.2.*
  3. Connect over adb: (f.e.) adb connect 192.168.2.100
  4. Checkout jan-os/gecko-dev, rpi branch; and use it as your GECKO_PATH
  5. Think this only works on Ubuntu by the way, but:
  6. In B2G, ./config.sh rpi && ./build.sh gecko && ./flash.sh gecko
  7. Checkout jan-os/janos, gpio branch
  8. Run make reset-phone
  9. adb logcat to see if flashing succeeded
@janjongboom
janjongboom / gist:88cb698cdd475d2591dd
Created February 3, 2015 09:04
Remove pin on FFOS
var pin = '0000';
var icc = navigator.mozIccManager.getIccById(navigator.mozIccManager.iccIds[0]);
if (icc.cardState === 'pinRequired') {
var req = icc.unlockCardLock({ lockType: 'pin', pin: pin });
req.onsuccess = function() {
console.log('pin unlocked');
var r2 = icc.setCardLock({ lockType: 'pin', pin: pin, enabled: false });
r2.onsuccess = function() {
@janjongboom
janjongboom / a.css
Created July 3, 2014 06:23
Weird animations
div {
border-radius: 50%;
position: absolute;
width: 100px;
height: 100px;
background: linear-gradient(90deg, orange, blue)
}
div.move-out {
animation: 10s weird-move-out infinite;