Skip to content

Instantly share code, notes, and snippets.

View aalmada's full-sized avatar
🏠
Working from home

Antão Almada aalmada

🏠
Working from home
View GitHub Profile
@aalmada
aalmada / Rx.NET Gate
Last active July 8, 2016 16:37
A Gate operator that outputs the latest input value when triggered by another observable. This example shows two consumers (faster and slower than producer) trigger the gate when done with the previous value.
// This example is based on the Gate operator from https://bitbucket.org/horizongir/bonsai
using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
namespace ConsoleApplication1
{
@aalmada
aalmada / StereoCamera.cs
Created September 23, 2016 16:43
Unity script for a stereoscopic camera rig
using UnityEngine;
public class StereoCamera
: MonoBehaviour
{
public const float DefaultSeparation = 0.067f;
public const float MinSeparation = 0.01f;
public const float MaxSeparation = 0.10f;
public const float DefaultConvergence = 5.0f;
public const float MinConvergence = 0.01f;
public IObservable<float> GetSignalStrength()
{
return Observable.Create<float>(observer =>
{
var centralManager = new CBCentralManager(DispatchQueue.CurrentQueue);
centralManager.DiscoveredPeripheral += (object sender, CBDiscoveredPeripheralEventArgs e) =>
{
observer.OnNext(e.RSSI.FloatValue);
};
@aalmada
aalmada / IterationTest
Created December 14, 2016 22:22
For loop benchmarking in Unity
using UnityEngine;
public class IterationTest : MonoBehaviour {
// Use this for initialization
void Start () {
const int count = 100000000;
int[] a = new int[count];
int total;
var watch = new System.Diagnostics.Stopwatch();
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
cinst -y f.lux
cinst -y 7zip.install
cinst -y adobereader
cinst -y googlechrome
cinst -y notepadplusplus.install
cinst -y tailblazer
cinst -y vlc
cinst -y greenshot
@aalmada
aalmada / karabiner.json
Last active June 26, 2019 09:04
Karabiner configuration for Portuguese Microsoft Sculpt Ergonomic Desktop keyboard
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@aalmada
aalmada / FilesystemWatchCache.cs
Last active November 22, 2018 11:43 — forked from anaisbetts/FilesystemWatchCache.cs
An Rx-friendly Filesystem Watcher
using Splat;
using System;
using System.IO;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
namespace SaveAllTheTime.Models
{
interface IFilesystemWatchCache
MySmartEnum.First.Equals(MySmartEnum.First); // = true
MySmartEnum.First.Equals(MySmartEnum.Third); // = false
MySmartEnum.Third.Equals(MySmartEnum.AnotherThird); // = true
firewall {
all-ping enable
broadcast-ping disable
group {
network-group UDP_MULTICAST {
description ""
network 232.0.0.0/8
network 235.0.0.0/8
network 239.0.0.0/8
}
@aalmada
aalmada / TypeExtensions.GetFriendlyName.cs
Created January 4, 2019 14:14
An extension-method for System.Type that returns its human-readable name.
public static partial class TypeExtensions
{
public static string GetFriendlyName(this Type type)
{
if (!type.IsGenericType)
return type.FullName;
var name = type.FullName.Substring(0, type.FullName.IndexOf('`'));
var fullName = new StringBuilder(name);
fullName.Append("<");