Skip to content

Instantly share code, notes, and snippets.

@druska
druska / engine.c
Created September 17, 2018 15:18
Quant Cup 1's winning order book implementation
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@thomwolf
thomwolf / top-k-top-p.py
Last active May 9, 2024 08:34
Sample the next token from a probability distribution using top-k and/or nucleus (top-p) sampling
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (vocabulary size)
top_k >0: keep only top k tokens with highest probability (top-k filtering).
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering).
Nucleus filtering is described in Holtzman et al. (http://arxiv.org/abs/1904.09751)
"""
assert logits.dim() == 1 # batch size 1 for now - could be updated for more but the code would be less clear
top_k = min(top_k, logits.size(-1)) # Safety check
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active May 9, 2024 08:24
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

Perfetto for upstream kernel development

Perfetto is super useful for understanding interactions between the kernel and applications. Outside of Android and ChromeOS, though it's use isn't as common. This doc tries to provide a basic walk through to get started using perfetto for upstream kernel development with classic linux distros, potentially running under qemu.

Install perfetto

Grab the latest linux- tarball: https://github.com/google/perfetto/releases

Often the tests I’m tracing need to run as root, so because of this, I copied the binaries in the tarball to /usr/local/bin/ and chmod +x the binaries to make

@chrisidakwo
chrisidakwo / nigerian-states.json
Last active May 9, 2024 07:54
All 36 states in Nigeria, and their local government areas - including the Federal Capital Territory and its area councils
{
"Abia": [
"Aba North",
"Aba South",
"Arochukwu",
"Bende",
"Ikwuano",
"Isiala-Ngwa North",
"Isiala-Ngwa South",
"Isuikwato",
@ababilinski
ababilinski / PlayParticlesInEditorExtension.cs
Last active May 9, 2024 07:49
Play particles in editor without having the simulation selected.
/* LICENSE
Copyright (c) 2021 Adrian Babilinski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@HugsLibRecordKeeper
HugsLibRecordKeeper / output_log.txt
Created May 9, 2024 07:19
Rimworld output log published using HugsLib
Log uploaded on Thursday, May 9, 2024, 3:19:54 PM
Loaded mods:
Harmony(brrainz.harmony)[mv:2.3.1.0]: 0Harmony(2.3.3), HarmonyMod(2.3.1)
Core(Ludeon.RimWorld): (no assemblies)
Royalty(Ludeon.RimWorld.Royalty): (no assemblies)
Biotech(Ludeon.RimWorld.Biotech): (no assemblies)
HugsLib(UnlimitedHugs.HugsLib)[ov:11.0.3]: 0Harmony(av:2.3.3,fv:1.2.0.1), HugsLib(av:1.0.0,fv:11.0.3)
MinifyEverything(erdelf.MinifyEverything): 0Harmony(av:2.3.3,fv:2.3.1.1), MinifyEverything(1.0.8838.32721)
Ruined Is Unfertilized(Mlie.RuinedIsUnfertilized)[mv:1.5.0]: RuinedIsUnfertilized(av:1.0.0,fv:1.5.0)
RimSearch(valcrafto.RimSearch): RimSearch(1.0.0)
@Gustorvo
Gustorvo / ArtBodyExtensions.cs
Last active May 9, 2024 07:18
Extension methods for working with ArticulationBody component for Unity
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Extension methods for working with ArticulationBody component for Unity
/// </summary>
public static class ArtBodyExtensions
{
/// <summary>
/// Sets an articulation body drive target rotation to match a given targetLocalRotation.
@sbyx
sbyx / notify-or-do-something-when-an-appliance-like-a-dishwasher-or-washing-machine-finishes.yaml
Last active May 9, 2024 07:15
Home Assistant Blueprint: Notify or do something when an appliance like a dishwasher or washing machine finishes
blueprint:
name: Appliance has finished
description: Do something when an appliance (like a washing machine or dishwasher)
has finished as detected by a power sensor.
domain: automation
input:
power_sensor:
name: Power Sensor
description: Power sensor entity (e.g. from a smart plug device).
selector: