Skip to content

Instantly share code, notes, and snippets.

View ProximaB's full-sized avatar
🍀
Focusing

Bartek ProximaB

🍀
Focusing
View GitHub Profile
@ProximaB
ProximaB / QuadEncoder.cpp
Created November 19, 2015 13:22 — forked from adamzaninovich/QuadEncoder.cpp
Code used on demo project shown at (http://www.youtube.com/watch?v=a1M5kirA2_8) and (http://www.youtube.com/watch?v=epJ3aSzrsXQ) Includes climate sensing, logging to SD card, HTTP server with JSON output, LCD display with settings menus.
/**
* QuadEncoder.cpp - Library for reading moves from a quadrature rotary encoder
* Created by Pedro Rodrigues ([email protected]) 9, January of 2010
* Released into the public domain.
*/
#include "Arduino.h"
#include "QuadEncoder.h"
QuadEncoder::QuadEncoder(int pin1, int pin2)
@ProximaB
ProximaB / Canselation Token
Created January 21, 2018 23:00
Canselation Token
public void Stop()
{
this.Status = ServerStatus.Stopping;
this.listener.Stop();
this.cancellationTokenSource.Cancel();
this.Status = ServerStatus.Stopped;
}

1. Sessions State

Consisting of a dictionary or hash table on the server, session persist data across requests from a browser.
The sessoin data is backed by a cache. ASP.NET Core maintains session state by giing the client cookie that contains the session ID, which is sent to the server with each request. Session state is ideal for storing user data that's specific to a particular session but doesn't need to be persisted permanently. The server doesn't know when the browser is closed or when the session cookie is deleted. You can either set the session timeout or use the default value of 20 minutes. Data is deleted from the backing store either when you call Session.Clear or when the session expires in the data store.

2. TempData, temp Cookie

public class NaturalSortComparer<T> : IComparer<string>, IDisposable
{
private bool _isAscending;
private Dictionary<string, string[]> _table = new Dictionary<string, string[]>();
public NaturalSortComparer(bool inAscendingOrder = true)
{
this._isAscending = inAscendingOrder;
}
var tmpRes = query.List<object[]>().Select(a => new {
EmployeeId = a[0].ToInt32(),
StudiesModeId = a[1].ToInt32Nullable(),
FormId = a[2].ToInt32Nullable()
}).ToArray();
if (tmpRes != null && tmpRes.Count() > 0)
{
var tmpGroupedRes = tmpRes.GroupBy(a => a.EmployeeId);
//all types or forms for each employee must have value or all of them must not have it - otherwise we throw an exception
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PinP.Service
{
public delegate bool Validation();
public class ValidatorDtos
using System;
using System.Collections.Generic;
using System.Linq;
namespace ValidatorDekorator
{
class Program
{
static void Main(string[] args)
{

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';