View silent-night-omega2.py
#!/usr/bin/env python | |
# Plays "silent night" on a piezo buzzer attached to pin 18 of the Onion Omega2 | |
# Things required: python lite, pwm needs to be enabled via: | |
# omega2-ctrl gpiomux set pwm0 pwm | |
from time import sleep | |
exportStr="/sys/class/pwm/pwmchip0/export" | |
periodStr="/sys/class/pwm/pwmchip0/pwm%s/period" | |
dutyStr="/sys/class/pwm/pwmchip0/pwm%s/duty_cycle" |
View Example.java
import org.easymock.EasyMock; | |
import org.easymock.IAnswer; | |
import org.junit.Assert; | |
import org.junit.Test; | |
/* | |
* Demonstrate using EasyMock to mock a method argument modification. | |
*/ | |
// Dependency to mock... |
View decodeFloat.js
// Derived from http://stackoverflow.com/a/8545403/106786 | |
function decodeFloat(bytes, signBits, exponentBits, fractionBits, eMin, eMax, littleEndian) { | |
var totalBits = (signBits + exponentBits + fractionBits); | |
var binary = ""; | |
for (var i = 0, l = bytes.length; i < l; i++) { | |
var bits = bytes[i].toString(2); | |
while (bits.length < 8) | |
bits = "0" + bits; |
View Int64.js
// Int64.js | |
// | |
// Copyright (c) 2012 Robert Kieffer | |
// MIT License - http://opensource.org/licenses/mit-license.php | |
/** | |
* Support for handling 64-bit int numbers in Javascript (node.js) | |
* | |
* JS Numbers are IEEE-754 binary double-precision floats, which limits the | |
* range of values that can be represented with integer precision to: |