Skip to content

Instantly share code, notes, and snippets.

View mithi's full-sized avatar

Mithi Sevilla mithi

View GitHub Profile
@mithi
mithi / sql_tests.md
Last active September 30, 2020 14:53

Test data

CREATE TABLE nodes (
    id SERIAL PRIMARY KEY,
    parent VARCHAR(2) NOT NULL,
    child VARCHAR(2) NOT NULL
);

INSERT INTO nodes (parent, child) VALUES  ('B1', 'C1');
from itertools import combinations
number_of_items = 8
number_of_draws = 6
iter_sets = combinations([i for i in range(number_of_items)], number_of_draws)
sets = list(iter_sets)
for s in sets:
print(s)
len(sets)
@mithi
mithi / pipeline.py
Last active August 28, 2020 00:48
matrix = calibration_data['camera_matrix']
distortion_coef = calibration_data['distortion_coefficient']
source_points = [(580, 460), (205, 720), (1110, 720), (703, 460)]
destination_points = [(320, 0), (320, 720), (960, 720), (960, 0)]
p = { 'sat_thresh': 120, 'light_thresh': 40, 'light_thresh_agr': 205,
'grad_thresh': (0.7, 1.4), 'mag_thresh': 40, 'x_thresh': 20 }
birdsEye = BirdsEye(source_points, destination_points, matrix, distortion_coef)
curves = Curves(number_of_windows = 9, margin = 100, minimum_pixels = 50,
ym_per_pix = 30 / 720 , xm_per_pix = 3.7 / 700)
undistorted_image = birdsEye.undistort(image)
binary = laneFilter.apply(undistorted_image)
lane_pixels = np.logical_and(birdsEye.sky_view(binary), roi(binary)).astype(np.uint8)
result = curves.fit(lane_pixels)
print("[real world] left best-fit curve parameters:", result['real_left_best_fit_curve'])
const radians = thetaDegrees => (thetaDegrees * Math.PI) / 180
const getSinCos = theta => [Math.sin(radians(theta)), Math.cos(radians(theta))]
const dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z
const vectorLength = v => Math.sqrt(dot(v, v))
const vectorFromTo = (a, b) => new Vector(b.x - a.x, b.y - a.y, b.z - a.z)
const scaleVector = (v, d) => new Vector(d * v.x, d * v.y, d * v.z)
const cross = (a, b) => {
const x = a.y * b.z - a.z * b.y
require 'benchmark'
require 'test/unit'
include Test::Unit::Assertions
# Create values
# data: [{id, quantity }, {location_id, quantity }]
def test_values
data = []
require 'benchmark'
require 'test/unit'
include Test::Unit::Assertions
# Create values
# data: [{id, quantity }, {location_id, quantity }]
def test_values
data = []
@mithi
mithi / what-forces-layout.md
Created July 25, 2020 12:39 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@mithi
mithi / web-performance.md
Created July 25, 2020 09:24 — forked from stevekinney/web-performance.md
Web Performance Workshop

Web Performance

Requirements

Repositories

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
fig = plt.figure(figsize=(18, 16), dpi= 80)
ax = plt.axes(projection='3d')
ax.set_xlim3d(-100, 100)
ax.set_ylim3d(-100, 100)
ax.set_zlim3d(-100, 100)