Skip to content

Instantly share code, notes, and snippets.

View yepitschunked's full-sized avatar

Victor Lin yepitschunked

  • Airbnb
  • San Francisco
View GitHub Profile
This file has been truncated, but you can view the full file.
[{"args":{"name":"swapper"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24322,"tid":0,"ts":0},
{"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24291,"tid":775,"ts":0},
{"args":{"name":"Chrome_IOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24291,"tid":35075,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":88158,"tid":775,"ts":0},
{"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":88143,"tid":18691,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":88140,"tid":775,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":88143,"tid":775,"ts":0},
{"args":{"name":"VizCompositorThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24322,"tid":85251,"ts":0},
{"args":{"name":"CrGpuMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24322,"tid":7
This file has been truncated, but you can view the full file.
[{"args":{"name":"swapper"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24352,"tid":0,"ts":0},
{"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24291,"tid":775,"ts":0},
{"args":{"name":"Chrome_IOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24291,"tid":35075,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24352,"tid":775,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":36618,"tid":775,"ts":0},
{"args":{"name":"ThreadPoolServiceThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24291,"tid":38667,"ts":0},
{"args":{"name":"CrGpuMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24322,"tid":775,"ts":0},
{"args":{"name":"VizCompositorThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":24322,"tid":85251,"ts":0},
{"args":{"name":"Chrome_ChildIOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":36618,"tid
@yepitschunked
yepitschunked / multi-consumer.ts
Created December 17, 2019 02:24
consume multiple contexts
type ContextValueType<T extends React.Context<unknown>[]> =
| {
[K in keyof T]: T[K] extends React.Context<infer U> ? U : never;
}
| [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function consumerWrapper<T extends React.Context<any>[]>(...contexts: T) {
return ({
children,
var resolve = require('../resolve');
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;
suite.add('uncached', () => {
delete process.env.CACHE;
resolve.sync('./frontend/homes-pdp-marketplace/components/Policies.jsx');
});
suite.add('cached', () => {
var resolve = require('../resolve');
var performance = require('perf_hooks').performance;
for(var i = 0; i < 10000; i++) {
resolve.sync('./frontend/homes-pdp-marketplace/components/Policies.jsx');
}
console.log(performance.getEntriesByName('parsePkg').reduce((sum, e) => sum + e.duration, 0));
@yepitschunked
yepitschunked / test.xml
Last active August 14, 2018 23:08
test
<?xml version="1.0"?>
<listing xmlns="http://www.airbnb.com/schemas/airbnb-listing/v1" schemaVersion="1.0">
<lastUpdated>2017-11-13T02:43:18Z</lastUpdated>
<published>true</published>
<basicDetails>
<bathrooms>3</bathrooms>
<bedrooms>4</bedrooms>
<propertyType>house</propertyType>
<listingType>entire_home</listingType>
<amenities>
@yepitschunked
yepitschunked / extractOrientation.js
Created October 19, 2016 22:25
extract image orientation from exif
export function extractOrientation(imgBlob) {
// written based on https://www.media.mit.edu/pia/Research/deepview/exif.html
// the exif orientation values are pretty nonsensical.
const orientationValueToRotateDegrees = {
1: 0,
3: 180,
6: 90,
8: 270,
};
@yepitschunked
yepitschunked / gist:5810785
Created June 19, 2013 00:34
Autovivifying hash - accessing a key automatically creates a hash at that key
autovivifying = proc {|x| proc { Hash.new {|h,k| h[k] = x.call(x).call } } }.call(proc {|x| proc { Hash.new {|h,k| h[k] = x.call(x).call } } }).call
[53] pry(main)> autovivifying[:foo]
=> {}
[54] pry(main)> autovivifying[:foo][:bar]
=> {}
[55] pry(main)> autovivifying[:foo][:bar][:baz]
=> {}
[56] pry(main)> autovivifying
=> {:foo=>{:bar=>{:baz=>{}}}}
@yepitschunked
yepitschunked / finder_methods.rb
Created July 6, 2011 18:11
limited eager loading patch
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index c6e8762..56985fa 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -226,16 +226,42 @@ module ActiveRecord
end
def apply_join_dependency(relation, join_dependency)
- join_dependency.join_associations.each do |association|
- relation = association.join_relation(relation)