Skip to content

Instantly share code, notes, and snippets.

Avatar

Mithi Sevilla mithi

View GitHub Profile
View combination_problem.py
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)
View box.js
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
View ruby_benchmark.rb
require 'benchmark'
require 'test/unit'
include Test::Unit::Assertions
# Create values
# data: [{id, quantity }, {location_id, quantity }]
def test_values
data = []
View ruby_benchmark.rb
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 Jul 25, 2020 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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 Jul 25, 2020 — forked from stevekinney/web-performance.md
Web Performance Workshop
View web-performance.md

Web Performance

Requirements

Repositories

View plot3d.py
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)
View matplot_lib_examples.py
# -*- coding: utf-8 -*-
"""matplot3d_examples
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1Zy_tYU5LXxJuc44AG_4GO9-2ZfVhFMnK
"""
from mpl_toolkits.mplot3d import axes3d
View geometry.js
import {
sin,
cos,
unit,
matrix,
multiply,
transpose,
identity,
concat,
dotMultiply,
View simple.css
/* Table of contents
––––––––––––––––––––––––––––––––––––––––––––––––––
- Plotly.js
- Grid
- Base Styles
- Typography
- Links
- Buttons
- Forms
- Lists