Skip to content

Instantly share code, notes, and snippets.

View andrezsanchez's full-sized avatar

Andre Z. Sanchez andrezsanchez

View GitHub Profile
@andrezsanchez
andrezsanchez / distribute.ts
Created December 5, 2022 00:19
TypeScript distribute intersection
type X = { a: number; z: string };
type Y = { a: 6; b: number };
// TS shows:
// X & Y
type XY1 = X & Y;
type DistributeIntersection<A, B> = Pick<A & B, keyof A | keyof B>;
// TS shows:
@andrezsanchez
andrezsanchez / spherical-cartesian-jacobian.py
Created July 31, 2022 23:32
Calculating an inverse jacobian matrix
from sympy import Matrix, symbols, sin, cos, pi
r, lat, lng = symbols('r lat lng')
sphericalToCartesian = Matrix([r*sin(lat)*cos(lng), r*sin(lat)*sin(lng), r*cos(lat)])
jacobian = sphericalToCartesian.jacobian(Matrix([r, lat, lng]))
print(jacobian)
inverseJacobian = jacobian.inv()
@andrezsanchez
andrezsanchez / flatten.js
Last active December 30, 2016 22:35
Flattens an array using a stack
function flatten(a) {
if (!Array.isArray(a)) throw new TypeError('argument must be array');
let stack = [a];
let stackIndex = [0];
let rv = [];
while (stack.length > 0) {
const i = stack.length - 1;

Keybase proof

I hereby claim:

  • I am andrezsanchez on github.
  • I am andrezsanchez (https://keybase.io/andrezsanchez) on keybase.
  • I have a public key whose fingerprint is 6983 23F2 B08B DEB0 D5B4 CF2E 757B 021E 997F 3C60

To claim this, I am signing this object:

@andrezsanchez
andrezsanchez / gist:8030686
Created December 18, 2013 22:07
dirty gulp jsx compile
module.exports = jsxGulp
var jsx = require('react-tools')
var es = require('event-stream')
function jsxGulp() {
function compile(file, cb) {
var err = null
try {
file.contents = new Buffer(jsx.transform(String(file.contents)))