Skip to content

Instantly share code, notes, and snippets.

@cocowalla
cocowalla / ExponentialWeightedMovingAverage.cs
Created May 7, 2021 10:23
Exponential Weighted Moving Average
public class ExponentialWeightedMovingAverage
{
private bool isInitialized;
// Smoothing/damping coefficient
private double alpha;
public double Average { get; private set; }
public ExponentialWeightedMovingAverage(int samplesPerWindow)
@ellaismer
ellaismer / README.md
Last active April 3, 2019 18:10
Ellaismer AMA

About Ellaismer

So, have to ask.. Who is Ellaismer? Who are you?

I am a software engineer who works on protocol-level development in the cryptocurrency field. In my free time, I also contribute to many other non-cryptocurrency-related open source projects.

Are you a girl?

@kadukf
kadukf / ParalellizedTasks.Sempaphore.cs
Created August 31, 2018 10:29
Tasks paralellization using Semaphore
static async Task<(IReadOnlyCollection<int>, TimeSpan)> RunComputationsAsync(int maxDegreeOfParallelism, int messageCount)
{
SemaphoreSlim semaphore = new SemaphoreSlim(maxDegreeOfParallelism);
List<Task<int>> tasks = new List<Task<int>>();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i < messageCount; i++)
{
@kevinjpetersen
kevinjpetersen / KJPOpenALPRBuildAndroid.sh
Created April 18, 2018 21:59
Shell file which handles everything related to building OpenALPR for Android (armeabi, armeabi-v7a, etc..). It installs Android SDK, NDK, CMAKE, JDK and wraps it into a single .sh file. Only tested on a specific Ubuntu version right now, but probably works on others aswell. Tested on Ubuntu 17.10 x64
#!/bin/bash
# Only tested on Ubuntu 17.10 x64 (This is because CMAKE Package 3.6 is required for Build OpenALPR Android Script)
########################################################################################################
# Script pieced together and tested by Kevin J. Petersen (Github: https://github.com/kevinjpetersen) ###
########################################################################################################
## Scripts used ##
# ubuntu-cli-install-android-sdk.sh by zhy0 (Github: https://github.com/zhy0)
@jav974
jav974 / build_openalpr_android.sh
Last active January 4, 2023 13:11
This bash script compiles openalpr for android. You just need to provide the path to Android SDK and Android NDK in the first lines of this code and execute it. Tested on ubuntu 17.04 64bit
#!/bin/bash
# You should tweak this section to adapt the paths to your need
export ANDROID_HOME=/home/jeremy/Android/Sdk
export NDK_ROOT=/home/jeremy/Android/Sdk/ndk-bundle
ANDROID_PLATFORM="android-21"
# In my case, FindJNI.cmake does not find java, so i had to manually specify these
# You could try without it and remove the cmake variable specification at the bottom of this file
@BretFisher
BretFisher / docker-swarm-ports.md
Last active August 12, 2024 16:10
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

@jrmadsen67
jrmadsen67 / gist:bd0f9ad0ef1ed6bb594e
Last active August 19, 2024 10:37
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@carols10cents
carols10cents / c#-to-rust.md
Last active March 3, 2026 07:21
C# to Rust Cheat Sheet

Thanks to @seejee for making this for me!!!

C# to Rust Cheat Sheet

The goal of this is to have an easily-scannable reference for the most common syntax idioms in C# and Rust so that programmers most comfortable with C# can quickly get through the syntax differences and feel like they could read and write basic Rust programs.

What do you think? Does this meet its goal? If not, why not?

Variables

@davidfowl
davidfowl / dotnetlayout.md
Last active February 28, 2026 18:13
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@venkateshshukla
venkateshshukla / AndroidDevLinux
Last active September 19, 2023 04:20
Setting up your Linux for Android Application Development
Step 1. Preparation
--------------------
First take care of the dependencies for Android Application Development.
Dependencies are -
1. Java
2. ant
3. Eclipse and Android Development tools (IDE)
4. Android SDK and NDK
5. adb