Skip to content

Instantly share code, notes, and snippets.

View salsferrazza's full-sized avatar
💭
I can't wait to meet the code

Salvatore Sferrazza salsferrazza

💭
I can't wait to meet the code
  • NYC
  • 10:28 (UTC -04:00)
View GitHub Profile
@salsferrazza
salsferrazza / gist:6884ecf29214289baea8af585eafadc0
Created December 21, 2025 04:25
CQ inventory file unsequenced, fire-and-forget blast
cat data/inventory.txt| while read -r line;
do echo $line |tr -d "\n" |nc -c localhost 3001 ; echo ; done < data/inventory.txt/
@salsferrazza
salsferrazza / LengthPrefixedUnframer.java
Last active November 20, 2024 14:28
Streams experiment
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class LengthPrefixedUnframer implements Supplier<Message> {
private final InputStream in;
private Message msg = new Message(new byte[0]);
private int counter = 0;
@salsferrazza
salsferrazza / ExercisePriceLevels.java
Last active November 19, 2024 04:35
Using a LinkedHashMap to facilitate price-time priority iteration
import java.io.*;
import java.util.*;
import java.util.concurrent.atomic.*;
// Options for NOOP collector:
// -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
public class ExercisePriceLevels {
class Order {
@salsferrazza
salsferrazza / forecast.sh
Last active August 12, 2023 15:29
NWS forecast data by coordinates
#!/bin/bash
[ -z ${2} ] && echo "Usage: ${0} <longitude> <latitude>" && exit 1
http -F $(http -F "https://api.weather.gov/points/${1},${2}" \
| json .properties.forecastHourly) \
| json -a .properties.periods \
| json -a .endTime .temperature .temperatureUnit .windSpeed .windDirection .shortForecast
@salsferrazza
salsferrazza / sppint.sh
Last active May 10, 2023 15:32
ERCOT SPP interval generator
#!/bin/bash
for HOUR in $(seq -w 0 23)
do
for MINUTE in 00 15 30 45
do
SLICE=$(date +%Y%m%d_${HOUR}${MINUTE})
echo SPPHLXNP6905_${SLICE}
done
done
@salsferrazza
salsferrazza / mapSlots.js
Last active April 12, 2023 17:40
Populate the slots of an HTML template at runtime
// elem: DOM element housing the template
// obj: object containing values corresponding to template slots
function mapSlots(elem, obj) {
if (obj) {
Object.keys(obj).forEach(function(key) {
let slot = elem.querySelectorAll(`slot[name='${key}']`);
if (slot[0]) {
slot[0].innerHTML = obj[key];
}
@salsferrazza
salsferrazza / totalview-itch-50.xml
Last active April 3, 2023 23:54
SBE XML template definition for Nasdaq TotalView ITCH 5.0 feed
<?xml version="1.0" encoding="UTF-8"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="baseline"
id="1"
version="0"
semanticVersion="5.2"
description="Example base schema which can be extended."
byteOrder="bigEndian">
<types>
<type name="timestamp_nanos_midnight" primitiveType="uint32" length="6"/>
@salsferrazza
salsferrazza / mapToDom.js
Last active May 8, 2025 14:41
The anti-framework
const formatter = {};
export const mapToDom = function (index, object) {
const keys = Object.keys(object);
keys.forEach(function (key) {
const element = index !== undefined
? `${index}-${key}`
: `${key}`;
const domElem = document.getElementById(element);
if (domElem) {
@salsferrazza
salsferrazza / uom.sh
Created November 22, 2022 23:35
Split lines by first instance of a space
while read -r line
do
export UOM=$(echo ${line} | cut -f1 -d" ")
export s=" "
export DESC=${line#*$s}
echo "<value enum='${UOM}' description='${DESC}'/>"
done < /var/tmp/uom.txt
@salsferrazza
salsferrazza / bytes.sh
Created November 3, 2022 17:21
Pull out the first two bytes of b64 encoded messages stored in a file and write to console
export LINE_COUNT=$(wc -l ${1} | cut -f1 -d" ")
for i in $(seq ${LINE_COUNT})
do head -$i ${1} | tail -1 | base64 -d | head -c2 | od -xL | head -2 | tail -1
done