Skip to content

Instantly share code, notes, and snippets.

View graup's full-sized avatar

Paul Grau graup

View GitHub Profile
@graup
graup / rx-elf-gcc-guide-mac.md
Last active March 9, 2022 10:44
Instructions on building rx-elf toolchain on Mac OS

Building rx-elf toolchain on Mac OS

If you google around, there are some guides on building gcc for RX, but none of them is really concise. So here you go.

With this method I was able to compile a toolchain for RX on Mac OS 10.8.2.

Credits

This post for Linux on the Renesas forums basically includes everything mentioned here, but with a lot of overhead and not very well formatted, however head there if you want some more explanations on the options used. Also thanks to Andy K. who helped me troubleshooting.

import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});

Keybase proof

I hereby claim:

  • I am graup on github.
  • I am grau (https://keybase.io/grau) on keybase.
  • I have a public key whose fingerprint is 6D57 7918 F01C 3B85 6A61 23AA AFE6 8F55 6DED DABB

To claim this, I am signing this object:

@graup
graup / lambda.js
Last active November 1, 2016 05:13
console.log('Lambda calculus with ES6 syntax');
console.log(
// (\(x,y).x+y)(1,2) => 1+2 => 3
((x, y) => x + y) (1, 2)
);
console.log(
// ((\x.\y.x+y) 1) 2 => (\y.1+y) 2 => 3
(x => y => x + y) (1) (2)
@graup
graup / decimal.py
Created January 10, 2017 16:56
The reason why you should be careful with currency amount calculation
>>> from decimal import *
>>> VAT_RATE = Decimal('0.19')
>>> amount = Decimal('12.12')
>>> ((amount / (VAT_RATE + 1)).quantize(Decimal('1.00')) * (1+VAT_RATE)).quantize(Decimal('1.00'))
Decimal('12.11')
>>> ((amount / (VAT_RATE + 1)).quantize(Decimal('1.0000')) * (1+VAT_RATE)).quantize(Decimal('1.00'))
Decimal('12.12')
def balanced_latin_squares(n):
l = [[((j//2+1 if j%2 else n-j//2) + i) % n + 1 for j in range(n)] for i in range(n)]
if n % 2: # Repeat reversed for odd n
l += [seq[::-1] for seq in l]
return l
from itertools import permutations
# Generate permutations
p = list(permutations('1234', 4))
# Flip table for display in columns
flipped = [[p[j][i] for j in range(4*3*2)] for i in range(4)]
# Print table
print("\n".join([" ".join(row) for row in flipped]))
import JSBI from 'jsbi';
const useNativeBigIntsIfAvailable = true;
if (useNativeBigIntsIfAvailable) JSBI.useNativeBigIntsIfAvailable();
const BigInt = JSBI.BigInt
DataView.prototype._setBigUint64 = DataView.prototype.setBigUint64;
DataView.prototype.setBigUint64 = function(byteOffset, value, littleEndian) {
if (typeof value === 'bigint' && typeof this._setBigUint64 !== 'undefined') {
// the original native implementation for bigint
this._setBigUint64(byteOffset, value, littleEndian);
const FAST_LOAD_TIME = 500;
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
function loadAndWait(minimumLoadTime = FAST_LOAD_TIME) {
const startedLoading = + new Date();
return function waitMinimum() {
return new Promise(resolve => {
const loadDuration = new Date() - startedLoading;
const SLOW_LOAD_TIME = 1500;
function waitOrLoad(callbackIfSlow, maximumLoadTime = SLOW_LOAD_TIME) {
const timeout = setTimeout(callbackIfSlow, maximumLoadTime);
return function loadingFinished() {
clearTimeout(timeout);
}
}
async function doSomething() {