Skip to content

Instantly share code, notes, and snippets.

View Ripley6811's full-sized avatar

Jay W Johnson Ripley6811

View GitHub Profile
@Ripley6811
Ripley6811 / trifocal_tensor_class.py
Created August 28, 2015 08:55
A class that creates a trifocal tensor from either a pair of camera matrices or three corresponding point sets. (Trifocal( Pi, Pii ) or Trifocal( x0, x1, x2 )) Includes methods for testing constraints, retrieving epipoles and fundamental matrices.
from numpy import *
import cv2
"""
A class that creates a trifocal tensor from either a pair of camera matrices
or three corresponding point sets. "Trifocal( Pi, Pii )" or "Trifocal( x0, x1, x2 )"
Includes methods for testing constraints, retrieving epipoles and fundamental matrices.
The estimation of the tensor from points uses equation 16.2 in Hartley/Zimmerman.
The version only covers algorithm 15.1 (i and ii) and 16.2 up to (iii).
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState !== 4) return;
var res = JSON.parse(xmlhttp.response);
};
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader('Content-type', 'application/json');
xmlhttp.send(params);
@Ripley6811
Ripley6811 / pdfDesignGrid.js
Created August 7, 2015 01:39
Light grey grid to help align items in jsPDF
/**
* Display a light grey grid for designing layout
*/
if (false) {
doc.setDrawColor(200);
doc.setTextColor(200,200,200);
for (var i=0; i<50; i++) {
doc.rect(0,i*10,300,10);
doc.text(0,i*10, (i*10).toString());
doc.rect(i*10,0,10,300);
@Ripley6811
Ripley6811 / nonASCIItext.js
Last active August 9, 2022 08:27
Add non-ASCII text as images to jsPDF. Use for Chinese characters and more. If canvas can draw it, then it can be added to jsPDF.
/**
* Prints a line of non-ASCII text as a series of images.
* All doc.text methods can be replaced with this method.
* Works like doc.text but requires a fontsize (default is 10).
*
* Add function to jsPDF instance (do not overwrite doc.text):
* var doc = new jsPDF();
* doc.alttext = nonASCIItext;
*
* @param {Number} x Horizontal placement
@Ripley6811
Ripley6811 / ko_extend_numeric.js
Last active August 29, 2015 14:14
KnockoutJS numeric validation function modified to allow a single period.
// Modified version of code at http://knockoutjs.com/documentation/extenders.html
// Allow a single period to pass when using "textInput" data-binding.
ko.extenders.numeric = function(target, precision) {
//create a writable computed observable to intercept writes to our observable
var result = ko.pureComputed({
read: target, //always return the original observables value
write: function(newValue) {
console.log(typeof newValue, newValue);
var current = target(),

This is a personalized reference for functions I have used. Any excluded parameters or simplifications are intentional.


##Function Summary

function param1 param2 response
.find PK or {} NA [{}]
.findOrCreate PK or {} {} {}
.destroy PK or {} NA [{}]
@Ripley6811
Ripley6811 / BurningPlain.js
Last active December 23, 2015 23:19
Demo of using a animated canvas element as a texture on a webgl (Three.js) object surface.
"use strict";
// Create a class that draws to a canvas.
function BurningPlain(canvas) {
this.w = canvas.width;
this.h = canvas.height;
this.ctx = canvas.getContext("2d");
// Draw buffer
var buffer = this.buffer = document.createElement('canvas');
@Ripley6811
Ripley6811 / Grue.js
Last active December 20, 2015 16:59
Basic HTML5/Canvas setup with CreateJS. Full page canvas for games, demos, or other effects.
"use strict";
// Create a `Player` class that inherits from `createjs.Shape`.
function Grue() {
// This example object will display a circle with a transparency gradient
// The center is transparent and becomes solid blue at edges.
this.graphics.beginStroke("#F0F") // Purple edge.
.beginRadialGradientFill(
["rgba(0,0,0,0.2)","rgba(0,0,255,1)"], // colors: [center, edge]
[0,1], // gradient: [begin, end]
@Ripley6811
Ripley6811 / index.html
Created August 6, 2013 07:04
A CodePen by Jay W Johnson. Boy in the rain - CreateJS and Box2DWeb example. Raindrops are small circular dynamic bodies. Umbrella is a kinematic body (ignores gravity).
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="text/javascript" src="https://dl.dropboxusercontent.com/u/49722688/packages/Box2dWeb-2.1.a.3.min.js"></script>
</body>
</html>
@Ripley6811
Ripley6811 / IDL_crop_ASCAT_location
Created July 18, 2013 03:52
IDL code for reducing ASCAT data to a bounded area
function crop_ASCAT_location, data, lon_bounds=lon_bounds, lat_bounds=lat_bounds
n = N_ELEMENTS(data.lon)
c = 0 ; count
for i=0l, n-1 do begin
print, data.lon[i]
if data.lon[i] ge lon_bounds[0] and data.lon[i] le lon_bounds[1] $
and data.lat[i] ge lat_bounds[0] and data.lat[i] le lat_bounds[1] $