Skip to content

Instantly share code, notes, and snippets.

class AsyncCommand : ICommand
{
private readonly Func<Task> asyncAction;
private bool isRunning = false;
public bool IsRunning
{
get { return isRunning; }
set
{
@derofim
derofim / Readme.md
Created April 1, 2017 18:07
OpenCV 3.2.0 Features2D + Homography to find a known object

Description

Features2D + Homography to find a known object http://docs.opencv.org/3.2.0/d9/d97/tutorial_table_of_content_features2d.html ported to OpenCV 3.2.0

Setup

  1. git clone -b 3.2.0 --depth 1 --recursive https://github.com/opencv/opencv_contrib.git
  2. git clone -b 3.2.0 --depth 1 --recursive https://github.com/opencv/opencv.git
  3. Create bat script (Windows):
@echo off
REM git clone -b 3.2.0 --depth 1 --recursive https://github.com/opencv/opencv_contrib.git
REM OR Download https://github.com/opencv/opencv_contrib/archive/3.2.0.zip
@darach
darach / fony.sh
Last active February 15, 2021 20:36
Example showing how to compile pony executables via LLVM and clang from LLVM IR produced by 'ponyc -rir ...'
#!/bin/sh
LLVM_HOME=/usr/local/Cellar/llvm/3.6.2/bin
PONY_HOME=/path/to/pony/repo
PONY_LIBS=${PONY_HOME}/build/debug
TARGET_ARCH=x86-64
OUT_LL="$1.ll"
OUT_BC="$1.bc"
OUT_S="$1.s"
@KvanTTT
KvanTTT / CSharpAntlrParser.cs
Last active May 13, 2021 18:31
ANTLR C# runtime code fragment for correct C# code parsing with preprocessor directives (for CSharp grammar in oficial repository: https://github.com/antlr/grammars-v4/tree/master/csharp).
List<IToken> codeTokens = new List<IToken>();
List<IToken> commentTokens = new List<IToken>();
Lexer preprocessorLexer = new CSharpLexer(new AntlrInputStream(sourceCode));
// Collect all tokens with lexer (CSharpLexer.g4).
var tokens = preprocessorLexer.GetAllTokens();
var directiveTokens = new List<IToken>();
var directiveTokenSource = new ListTokenSource(directiveTokens);
var directiveTokenStream = new CommonTokenStream(directiveTokenSource, CSharpLexer.DIRECTIVE);
CSharpPreprocessorParser preprocessorParser = new CSharpPreprocessorParser(directiveTokenStream);
@julianxhokaxhiu
julianxhokaxhiu / README.md
Last active April 19, 2022 20:09
How to install OSX 10.11 El Capitan on VMWare

How to install OSX 10.11 El Capitan on VMWare

To accomplish this tutorial you already need a previous copy of OSX installed on VMWare Player or Workstation.

0) Acquire a copy of OSX 10.11 El Capitan

First of all you need to acquire a legal copy of OSX El Capitan from the App Store. This tutorial will not cover this part. Sorry :)

1) Unlock OSX option on VMWare

Download the latest version of VMWare Unlocker and use the relative binary to unlock it ( based on your Host OS ).

@LordJZ
LordJZ / SpanSplitExtensions.cs
Created August 9, 2018 18:04
Split for Span
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
public static class SpanSplitExtensions
{
public ref struct Enumerable1<T> where T : IEquatable<T>
{
public Enumerable1(ReadOnlySpan<T> span, T separator)
{
@jammycakes
jammycakes / LazyDisposable.cs
Last active December 26, 2022 22:31
A subclass of System.Lazy<T> that implements IDisposable and forwards calls to the Dispose method on to the lazily created instance if it exists.
/// <summary>
/// A <see cref="Lazy"/> object that implements <see cref="IDisposable"/>.
/// </summary>
/// <typeparam name="T">
/// The object being lazily created.
/// </typeparam>
public class LazyDisposable<T> : Lazy<T>, IDisposable where T: IDisposable
{
/// <summary>
@ToruNiina
ToruNiina / branchless_ReLU.c
Created July 9, 2018 12:35
branchless ReLU implementation (with bitwise operations)
// copyright Toru Niina 2018. distributed under the Boost Software License v1.0.
// it provides an implementation of ReLU without branching.
// the core idea of branchless-ReLU is the following.
// 1. first, bitwise-and with 0 bits everytime returns 0 bits. but bitwise-and
// with 1 bits returns the original argument kept intact.
// 0000 & 1010 == 0000, 1111 & 1010 == 1010
// 2. second, we can make 0 bits or 1 bits depending on the sign bit by applying
// right arithmetic shift 31 times.
// 1000 >> 31 == 1111, 0110 >> 31 == 0000

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@brianhassel
brianhassel / PreventSleep.cs
Last active December 19, 2023 09:16
Prevent Computer Sleep in C#
internal static class NativeMethods {
public static void PreventSleep() {
SetThreadExecutionState(ExecutionState.EsContinuous | ExecutionState.EsSystemRequired);
}
public static void AllowSleep() {
SetThreadExecutionState(ExecutionState.EsContinuous);
}