This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.tobilehman.benchmarks; | |
| import java.util.LinkedList; | |
| import java.util.List; | |
| import java.util.Random; | |
| public class StreamMax { | |
| public static void main(String args[]) { | |
| StreamMax sm = new StreamMax(10_000_000); | |
| Long then,now; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.concurrent.atomic.AtomicInteger; | |
| public class AtomicIntegerExample { | |
| public static void main(String args[]) throws InterruptedException { | |
| AtomicInteger a = new AtomicInteger(); | |
| NonAtomicInteger n = new NonAtomicInteger(); | |
| Runnable r = () -> { | |
| for(int j = 0; j < 100_000; j++) { | |
| a.getAndIncrement(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # This is used in bitbar to display the time in the two main timezones I work in: | |
| TZ=America/Los_Angeles date +"%Y-%h-%d %r (%Z)" | sed 's/:[0-9][0-9] / /g' | |
| TZ=UTC date +"%Y-%h-%d %r (%Z)" | sed 's/:[0-9][0-9] / /g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://www.evanmiller.org/bayesian-ab-testing.html implemented in ruby | |
| # requires the distribution gem from https://github.com/clbustos/distribution (gem 'distribution', require: false) | |
| def probability_b_beats_a(completed_a, total_a, completed_b, total_b) | |
| require 'distribution/math_extension' | |
| total = 0.0 | |
| alpha_a = completed_a + 1 | |
| beta_a = total_a - completed_a + 1 | |
| alpha_b = completed_b + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Response> | |
| <Say voice="alice" language="en-US">Hello, the number you're calling is for existing and potential clients only. | |
| If this is a sales call of any kind , including business to business please add this number to your do not call list and hang up now, otherwise, please press one to continue.</Say> | |
| </Response> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Response> | |
| <Say voice="alice" language="en">Hello, the number you're calling is for existing and potential clients only. | |
| If this is a sales call of any kind , including business to business please add this number to your do not call list and hang up now, otherwise, please press one to continue.</Say> | |
| </Response> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <Response> | |
| <Gather timeout="30" finishOnKey="1" | |
| action="https://gist.githubusercontent.com/tlehman/6a01547faa90a790387f5bdc93d7cbfb/raw/ef8940e17a4560c9625c849706c019a9c7865893/forwards1.xml"> | |
| <Say>If you are a cold caller, please hang up. Otherwise, press 1 to continue.</Say> | |
| </Gather> | |
| </Response> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Response> | |
| <Dial record="false"> | |
| +15038164076 | |
| </Dial> | |
| </Response> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Generate a sparse decision matrix using backtracking to solve the | |
| multiple knapsack problem. In the code I use the term "bin" instead | |
| of knapsack because I think "knapsack" is a dumb word. And sacks are | |
| too flexible, bins are sturdier. | |
| by @tlehman | |
| Problem: There are N items and M bins. For each of the items, there is | |
| a size, and for each bin, there is a capacity. We see an | |
| assignment of each of the N items to at least one bin so that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Generate a sparse decision matrix using backtracking to solve the | |
| multiple knapsack problem. In the code I use the term "bin" instead | |
| of knapsack because I think "knapsack" is a dumb word. And sacks are | |
| too flexible, bins are sturdier. | |
| by @tlehman | |
| Problem: There are N items and M bins. For each of the items, there is | |
| a size, and for each bin, there is a capacity. We see an | |
| assignment of each of the N items to at least one bin so that |