Skip to content

Instantly share code, notes, and snippets.

function countSubarrays(arr) {
var result = [];
for (var index = 0; index < arr.length; index++) {
var count = 1; // always include the index itself
// look forward
var subIndex = index + 1;
while(arr[subIndex] < arr[index] && subIndex < arr.length) {
count++;
// This example shows that deep-diff reports arrays of objects with different sort order as "edit" diffs:
var diff = require('deep-diff').diff;
var lhs = {
name: 'my object',
details: {
it: 'has',
an: 'array',
with: [{'a': 1}, {'a': 2}, {'a': 3}]
'use strict';
function fib(maxLength=10, series=[1,1]) {
const l = series.length;
if (l >= maxLength) {
return series;
}
series.push(series[l-2] + series[l-1]);
return fib(maxLength, series);
}
@mpelzsherman
mpelzsherman / gist:f3e729d4eeb870fa486e4f6f985fdaed
Created January 10, 2018 19:16
changes to support Optimizely POC
diff --git a/src/apps/shared/Layout/Html.js b/src/apps/shared/Layout/Html.js
index dc2444d32..cfb75ba89 100644
--- a/src/apps/shared/Layout/Html.js
+++ b/src/apps/shared/Layout/Html.js
@@ -36,6 +36,9 @@ export default class HTML extends Component {
}
const optimizelySrcPath = OPTIMIZELY_SRC_PATHS[view]
+
+ const loadOptVariation = optimizelyClient.activate('fullstack_poc', userId) // TODO - make a utility function that knows how to get userId
for i in {1..30};
do curl --globoff -s -w "%{time_total}\n" -o /dev/null "http://m.api.ci.apartmentguide.com/listings/photos.json?ids[]=191140&ids[]=83822&ids[]=192121&ids[]=189625&ids[]=191881&ids[]=188320&cb_mps4=$i"
done
require 'oj'
Oj.default_options = { mode: :compat }
test_json = '{"a":"Alpha","b":true,"c":12345,"d":[true,[false,[-123456789,null],3.9676,["Something else.",false],null]],"e":{"zero":null,"one":1,"two":2,"three":[3],"four":[0,1,2,3,4]},"f":null,"h":{"a":{"b":{"c":{"d":{"e":{"f":{"g":null}}}}}}},"i":[[[[[[[null]]]]]]]}'
start_time = Time.now
1000000.times do
Oj.load(test_json)
end
@mpelzsherman
mpelzsherman / gist:99abd023beabe84c059d
Last active January 15, 2016 20:48
transformers to-do list
- merge leads_ui PR:https://github.com/rentpath/leads_ui/pull/28/ -> see Caleb's comment
- decide if/when to merge the React work
- need swiping (or do we? who makes the call?)
- existing 3rd-party options aren't working
- revisit resizing logic - seems complicated?
- create epic, start adding stories to convert to React (Ocean's team has already started this)
- get clarity from Stu on product decisions during product transition
- ge a ruling about which tracking system to use
- add Redux to Gallery?
- Caleb suggests waiting
@mpelzsherman
mpelzsherman / gist:174e8bfdd758562414d0
Last active November 30, 2015 14:28
ag mobile api performance metrics for including photos with SRP
WITH PHOTOS: siege -b -c10 -t1 "http://m.api.ci.apartmentguide.com/search?query=Atlanta,GA&include_photos=true"
=================
Transactions: 979 hits
Availability: 100.00 %
Elapsed time: 60.24 secs
Data transferred: 53.63 MB
Response time: 0.61 secs
Transaction rate: 16.25 trans/sec
Throughput: 0.89 MB/sec
Concurrency: 9.86
@mpelzsherman
mpelzsherman / gist:d614f423ea5a67ced976
Created November 30, 2015 14:25
ag mobile api performance metrics for including photos with SRP
WITH PHOTOS: siege -b -c10 -t1 "http://m.api.ci.apartmentguide.com/search?query=Atlanta,GA&include_photos=true"
=================
Transactions: 979 hits
Availability: 100.00 %
Elapsed time: 60.24 secs
Data transferred: 53.63 MB
Response time: 0.61 secs
Transaction rate: 16.25 trans/sec
Throughput: 0.89 MB/sec
Concurrency: 9.86
@mpelzsherman
mpelzsherman / gist:7f47619e5c9d7e4d7787
Created November 30, 2015 14:25
ag mobile api performance metrics for including photos with SRP
WITH PHOTOS: siege -b -c10 -t1 "http://m.api.ci.apartmentguide.com/search?query=Atlanta,GA&include_photos=true"
=================
Transactions: 979 hits
Availability: 100.00 %
Elapsed time: 60.24 secs
Data transferred: 53.63 MB
Response time: 0.61 secs
Transaction rate: 16.25 trans/sec
Throughput: 0.89 MB/sec
Concurrency: 9.86