Skip to content

Instantly share code, notes, and snippets.

def preprocess(A):
return A
def solution(mat, i, j, m, n):
# write your solution here
sum1 = 0
for ix in range(len(mat)):
row = mat[ix]
for jx in range(len(mat)):
column = row[jx]
@onedayitwillmake
onedayitwillmake / git.txt
Last active June 25, 2021 02:49
basic git commands
git init # create a git repo
* git status # show me status of all my stuff
* git add . # Add all the files in this folder to my change list
* git commit -m "First commit!" #
git log # shows you your commits
clear # TERMINAL: clear the terminal so you can think
git checkout file # reset the file
onInputUp(cursor: CursorController) {
if(this.points.length > 2) {
let newStrokes = Array.from(this.strokes);
newStrokes.push(this.points);
this.setStrokes(newStrokes);
}
this.points = [];
}
setStrokes(arr:Array<Array<vec2>>) {
@onedayitwillmake
onedayitwillmake / scaled-rotated-image.js
Created February 28, 2018 00:01
Draw rotated, scaled image at position
let scale = 0.5;
let ox = deg;
let oy = 0;
let radians = deg * DEG_TO_RAD;
let xx = this.canvas.width * 0.5 + imageWidth * 0.5 * scale + ox;
let yy = this.canvas.height * 0.5 + imageHeight * 0.5 * scale + oy;
ctx.translate(xx,yy);
ctx.rotate(radians);
ctx.drawImage(image, 0, 0, imageWidth, imageHeight, -imageWidth * 0.5 * scale, -imageHeight * 0.5 * scale, imageWidth * scale, imageHeight * scale);
@onedayitwillmake
onedayitwillmake / compare-gemini-gdax.js
Created December 12, 2017 23:19
compare-gemini-gdax.js
(function loop(){
window.gem = window.gem || $(".header-market-link[href*=gem] .price-right").get()[0]
window.gdax = window.gdax || $(".header-market-link[href*=gdax] .price-right").get()[0]
let gemPrice = parseFloat(gem.innerText);
let gdaxPrice = parseFloat(gdax.innerText);
console.log(Math.round(gdaxPrice - gemPrice), Math.round(gemPrice/gdaxPrice * 1000) / 1000)
setTimeout(loop, 200)
})()
@onedayitwillmake
onedayitwillmake / blur.glsl
Created December 1, 2017 11:33
gaussian blur
#define pow2(x) (x * x)
const float pi = atan(1.0) * 4.0;
const int samples = 25;
float gaussian(vec2 i, float sigma) {
return 1.0 / (2.0 * pi * pow2(sigma)) * exp(-((pow2(i.x) + pow2(i.y)) / (2.0 * pow2(sigma))));
}
vec3 blur(sampler2D sp, vec2 uv, vec2 scale) {
@onedayitwillmake
onedayitwillmake / getParameterByNameUsingDefaultValue.js
Created December 8, 2016 20:33
getParameterByNameUsingDefaultValue.js
/**
* @copyright 2015 Apple Inc. All rights reserved.
* @author supermario@apple.com
*/
'use strict';
var cachedValues = {};
/**
* Returns URL parameter if available, if not returns `defaultValue`
* @param {String} name Name of URL parameter to look for

Question

Write a function to detect if correct order of parentheses in a string. Let's assume the string will only ever contain parentheses.

(()) = good
(())) = bad
(()(())) = good
)() = bad
/**
* A simple "event" emitter for
* Dart inspired by the classical
* stuff used in JavaScript/ActionScript.
*/
library dart_events;
class EventEmitter {
Map<String, List<Function>> _listeners = new Map<String, List<Function>>();
Array.prototype.slice.call(document.querySelectorAll("canvas")).forEach(function(e){ e.parentNode.removeChild(e)})