Skip to content

Instantly share code, notes, and snippets.

@robmoore
robmoore / modin_index_issue.py
Last active October 23, 2021 03:59
Results in "ValueError: Invalid integer data type 'f'."
import modin.pandas as pd
# import pandas as pd
import pandas_market_calendars as mcal
import ray
ENTITIES = ['037833100', '594918104', '023135106', '30231G102', '478160104', '30303M102', '369604103', '00206R102',
'46625H100', '742718109', '02079K305', '949746101', '931142103', '92343V104', '717081103', '084670702',
'166764100', '191216100', '458140100', '58933Y105', '68389X105', '060505104', '20030N101', '437076102',
'92826C839', '17275R102', '718172109', '713448108', '254687106', '459200101', '172967424', '91324P102',
'031162100', '02209S103', '57636Q104', '88579Y101', '500754106', '806857108', '375558103', '00287Y109',
@robmoore
robmoore / change.py
Created December 11, 2018 01:04
Change using 5s and 7s
def change(amount):
assert(24 <= amount <= 1000)
if amount == 24:
return [5, 5, 7, 7]
if amount == 25:
return [5, 5, 5, 5, 5]
if amount == 26:
return [5, 7, 7, 7]
if amount == 27:
import requests
from urllib.parse import quote_plus
url_base = 'https://rxnav.nlm.nih.gov/REST'
def lookup_bn(rxcui):
brand_names = {}
url = f'{url_base}/rxcui/{rxcui}/related.json?tty=BN'
@robmoore
robmoore / PartitionCounter.java
Created October 9, 2018 21:42
Can calculate count of odd integer partitions
public class PartitionCounter {
public static void main(String[] args) {
// System.out.print("[");
// for (int k = 0; k < 201; k++) {
// System.out.print(count(k) + (k != 200 ? ", " : ""));
// }
// System.out.print("]");
System.out.println("11: " + count(11));
}
@robmoore
robmoore / gist:4424bd5bf7e7b05d168bcd7ede9a587a
Created December 18, 2017 20:51
Another case where we see infinite retries on ClassCastExceptions
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info Caused by: org.springframework.messaging.MessageHandlingException: nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to com.epf.vault.domain.ArchiverSummary
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info at org.springframework.integration.dsl.LambdaMessageProcessor.processMessage(LambdaMessageProcessor.java:130)
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:89)
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109)
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
Dec 18 10:19:46 b436016615eb epf-vault-prd-cmd info at org.springframework.
@robmoore
robmoore / gist:3c5a0ee29f677925b78bc0585f4d9970
Created December 18, 2017 17:24
Infinite retry on ClassCastException
2017-12-18T16:58:12.466Z [epf-vault-prd-cmd da6a59732735]: [org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#4-2] WARN o.s.a.r.l.ConditionalRejectingErrorHandler - Execution of Rabbit message listener failed.
2017-12-18T16:58:12.466Z [epf-vault-prd-cmd da6a59732735]: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
2017-12-18T16:58:12.466Z [epf-vault-prd-cmd da6a59732735]: at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:941)
2017-12-18T16:58:12.466Z [epf-vault-prd-cmd da6a59732735]: at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:851)
2017-12-18T16:58:12.466Z [epf-vault-prd-cmd da6a59732735]: at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:771)
201
@robmoore
robmoore / forwarded-request-customizer.xml
Created December 17, 2015 22:13
Can be used in ${jetty.base}/etc to add forwarded support rather than editing jetty.xml.
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Ref refid="httpConfig">
<Call name="addCustomizer">
<Arg>
<New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/>
</Arg>
</Call>
</Ref>
@robmoore
robmoore / TrampolineExample
Last active August 29, 2015 14:16
Trampoline example.
Code from slides 41 - 44 of [Laziness, trampolines, monoids and other functional amenities: this is not your father's Java]
(http://www.slideshare.net/mariofusco/lazine).
"A trampoline is an iteration applying a list of functions. Each function returns the next function for the loop to run."
(define (safe-string-head s start) ; gives 'up to' 6 or remaining
(let ((sl (string-length s)))
(if (>= sl start)
(string-head s start)
(string-head s sl))))
(define (safe-string-tail s end) ; gives 'up to' 6 and remaining
(let ((sl (string-length s)))
(if (>= sl end)
(string-tail s end)
@robmoore
robmoore / 0_reuse_code.js
Created January 31, 2014 14:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console