Skip to content

Instantly share code, notes, and snippets.

View blasten's full-sized avatar

Emmanuel Garcia blasten

  • c.ai
  • Palo Alto, CA
View GitHub Profile
# OAPI Specification for the annotation tool service
openapi: 3.0.0
info:
title: Annotation Service
version: 1.0.0
paths:
/tasks/{taskId}:
get:
summary: Get information about a task
@blasten
blasten / KMP.js
Last active February 11, 2024 04:04
String matching based on the KMP algorithm. This how `String.prototype.indexOf` is generally implemented.
// Construct a table with table[i] as the length of the longest prefix of the substring 0..i
function longestPrefix(str) {
// create a table of size equal to the length of `str`
// table[i] will store the prefix of the longest prefix of the substring str[0..i]
var table = new Array(str.length);
var maxPrefix = 0;
// the longest prefix of the substring str[0] has length
table[0] = 0;
@blasten
blasten / group-intervals.js
Created January 6, 2015 05:57
Group all overlapping intervals.
// Group all overlaping intervals
// * * * * * * *
// This is an approach to a problem the engineers at Google Calandar/ Outlook probably faced.
// You have events that may overlap and you want to display them in such a way that
// they don't overlap with each other. One approach is to distribute them into columns.
// Each column has events that don't overlap with each other.
// Cost: O(n*log n) if the interval aren't sorted by the starting time,
// O(n) otherwise.
// Sample run: groupOverlapingIntervals([ [2, 5], [5, 6],[3, 4] ])
@blasten
blasten / build.gradle
Last active July 8, 2022 15:34
Add lifecycle dependency in build.gradle
afterEvaluate {
def containsEmbeddingDependencies = false
for (def configuration : configurations.all) {
for (def dependency : configuration.dependencies) {
if (dependency.group == 'io.flutter' &&
dependency.name.startsWith('flutter_embedding') &&
dependency.isTransitive())
{
containsEmbeddingDependencies = true
break
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<hierarchy rotation="0">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="io.flutter.plugins.webviewflutterexample" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2236]">
<node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="io.flutter.plugins.webviewflutterexample" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2236]">
<node index="0" text="" resource-id="android:id/content" class="android.widget.FrameLayout" package="io.flutter.plugins.webviewflutterexample" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" fo
@blasten
blasten / bisect-flutter-sdk.md
Last active January 13, 2022 21:08
Bisect the Flutter SDK

Bisect the Flutter SDK

  1. Start
cd <flutter-sdk-install-location>
git bisect start
  1. Ensure you can reproduce the issue at this point.
1c1
< P d 43608 51116 5282752 <TOTAL>
---
> P d 43606 51114 5282644 <TOTAL>
62098,62099c62098,62099
< P d 2672 2821 344704 io
< P d 2672 2821 344704 io.flutter
---
> P d 2670 2819 344596 io
> P d 2670 2819 344596 io.flutter
@blasten
blasten / object-fit-edge.css
Last active August 28, 2020 20:12
Adds support to object-fit in Edge.
.fit {
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
width: 100%;
height: 100%;
object-fit: cover;
}
function throttle(task, ms, context) {
let started = false;
let lastCall = -Infinity;
let taskScheduled = false;
let lastArguments = [];
return function() {
if (!started) {
started = true;
lastCall = Date.now();
function parse(pattern, query) {
const patternWords = pattern.split(' ');
const queryWords = query.split(' ');
const sol = {};
if (!match(patternWords, 0, queryWords, 0, sol)) {
return null;
}
return sol;