Skip to content

Instantly share code, notes, and snippets.

@MaxHalford
MaxHalford / ogd-in-sql.ipynb
Created March 7, 2023 12:32
Online gradient descent written in SQL
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MichalBrylka
MichalBrylka / Consumer.cs
Last active September 25, 2023 17:52
Creating and using C# 9.0 records
using System;
using RecordsProducer;
var lizard1 = new Reptile(Habitat.Terrestrial) { Name = "Agama" };
var lizard2 = new Reptile(Habitat.Terrestrial) { Name = "Agama" };
//use <LangVersion>latest</LangVersion>
var lizard3 = lizard1 with { Name = "Komodo dragon", Habitat = Habitat.Terrestrial };
@mementum
mementum / ported-pinescript-right.py
Created September 4, 2019 12:15
Ported Pinescript-Backtrader right
def __init__(self):
self.donchian = DonchianChannels()
def next(self):
if self.data[0] > self.donchian.dch[0]:
self.sell()
elif self.data[0] < self.donchian.dcl[0]:
self.buy()
@ceshine
ceshine / bactrader_sample.py
Last active July 22, 2024 07:35
A Simple Strategy Trading Two Stocks (back trader)
"""A Simple Strategy Trading Two Stocks
Original code: https://blog.csdn.net/qq_26948675/article/details/80016633
Modified based on: https://www.backtrader.com/blog/posts/2018-04-22-improving-code/improving-code.html
Replaced the local CSV files with online data from IEX.
Unfortunately, this strategy is not profitable for the two stocks picked.
"""
@0xced
0xced / ForEachAsync.cs
Created May 26, 2018 17:57
Parallel foreach async enumeration with maximum degree of parallelism
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Parallel
{
public static class EnumerableExtensions
{
@femtotrader
femtotrader / alphavantage.py
Last active December 23, 2019 00:55
Download data from Alphavantage http://www.alphavantage.co/ using Python, Requests and Pandas
import requests
from pandas.io.common import urlencode
from pandas.tseries.frequencies import to_offset
ALPHAVANTAGE_API_URL = "http://www.alphavantage.co/query"
ALPHAVANTAGE_API_KEY_DEFAULT = "demo"
def _init_session(session):
@aopell
aopell / SettingsManager.cs
Last active May 7, 2021 13:30
C# JSON Settings Manager
using System;
using System.IO;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace DiscordBotNew.Settings
{
public class SettingsManager
@Dev-Dipesh
Dev-Dipesh / rabbitmq_notes.md
Last active September 28, 2024 19:36
Why RabbitMQ is better over Redis and notes on RabbitMq.

Redis is Database whereas RabbitMQ was designed as a message router or message-orientated-middleware (mom), so I'm sure if you look for benchmarks, you'll find that RabbitMQ will outperform Redis when it comes to message routing.

RabbitMQ is written in Erlang which was specifically designed by the telecom industry to route messages, you get clustering out of the box due to it being written in Erlang which means in a clustered environment, RabbitMQ will outperform Redis even further.

Furthermore, you get guaranteed delivery of messages due to the AMQP protocol, in other words, if the network drops while consuming the message, the consumer won't be able to say thanks for the message, so the consumer will drop the message and Rabbit will requeue the message, if you publish a message and the queue didn't say thanks to the publisher due to network problems or timeouts, Rabbit will drop the message and the publisher will keep on trying to publish the message. You can have publish retries with backoff policies, so

@vasanthk
vasanthk / System Design.md
Last active April 21, 2025 02:58
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?