Skip to content

Instantly share code, notes, and snippets.

View kuncevic's full-sized avatar
🎯
Focusing

Aliaksei Kuncevič kuncevic

🎯
Focusing
View GitHub Profile
@kuncevic
kuncevic / CookieManager.ts
Created September 27, 2017 04:06
aspnet core cooke manager, cookie helper
public class CookieManager
{
private readonly IHttpContextAccessor httpContextAccessor;
private readonly IDataProtector protecotr;
public CookieManager(IHttpContextAccessor httpContextAccessor, IDataProtectionProvider provider)
{
this.httpContextAccessor = httpContextAccessor;
this.protecotr = provider.CreateProtector(GetType().FullName);
}
@kuncevic
kuncevic / sample.html
Created January 22, 2018 22:28 — forked from guillaumegarcia13/sample.html
Angular 4 ng-template & ng-container with parameters
<ng-template #followingpost let-author="author" let-age="age" let-text="text" let-badge="badge">
<div class="container-fluid">
<div class="card">
<div class="header">
<h4 class="title">{{ author }}</h4>
<p class="category">il y a {{ age }} jours</p>
</div>
<div class="content" [innerHTML]="text">
</div>
import { Input } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export function InputObservable<T>(inputName?: string) {
return (target: object, name: string): void => {
const subject = new BehaviorSubject(this[name]);
if (delete target[name]) {
Object.defineProperty(target, name, {
set(value: T): void {
@kuncevic
kuncevic / jQuery API Call Utility
Created March 12, 2018 08:57
jQuery API Call Utility
var Service = (function () {
Service.prototype.Call = function (input) {
var output = new dataOut(42);
if (!input.url) output.status = "url is undefined";
if (!input.data) output.status = "data is undefined";
if (output.status != 42)
return output;
import { BehaviorSubject, of } from 'rxjs';
import { distinctUntilChanged, concatMap, map, take } from 'rxjs/operators';
export class StateDef<T> extends BehaviorSubject<T> {
setState(setter: (state: T) => T) {
this.pipe(take(1)).subscribe(state => {
super.next(setter(state));
});
}
@kuncevic
kuncevic / git_cheat_sheet.txt
Last active May 22, 2018 06:33
git cheat sheet
git config --get remote.origin.url
git remote show origin
git ls-remote --get-url
git add -A //stages All
git add . //stages new and modified, without deleted
git add -u //stages modified and deleted, without new
git reset -- main/dontcheckmein.txt
@kuncevic
kuncevic / osx_wifi_strenght_command_line.sh
Created March 4, 2019 01:22 — forked from miglen/osx_wifi_strenght_command_line.sh
Mac OS X Wifi Signal strength meter command line
#!/bin/bash
# Simple command to display the wireless strenght signal
#
clear
while x=1
do /System/Library/PrivateFrameworks/Apple*.framework/Versions/Current/Resources/airport -I \
| grep CtlRSSI \
| sed -e 's/^.*://g' \
| xargs -I SIGNAL printf "\rWifi dBm: SIGNAL"
sleep 0.5
@kuncevic
kuncevic / terminal-gif.md
Created June 18, 2019 07:37 — forked from protrolium/terminal-gif.md
convert images to GIF in Terminal

Install ImageMagick

brew install ImageMagick

Pull specific region of frames from video file w/ ffmpeg

ffmpeg -ss 14:55 -i video.mkv -t 5 -s 480x270 -f image2 %04d.png

  • -ss 14:55 gives the timestamp where I want FFmpeg to start, as a duration string.
  • -t 5 says how much I want FFmpeg to decode, using the same duration syntax as for -ss.
  • -s 480x270 tells FFmpeg to resize the video output to 480 by 270 pixels.
  • -f image2 selects the output format, a series of still images — make sure there are leading zeros in filename.
@kuncevic
kuncevic / reactive-services-1.ts
Last active September 6, 2020 10:00
Reactive Services with BehaviourSubject
export class CounterService {
private data$ = new BehaviorSubject<Counter>(initialState);
state$ = this.data$.asObservable();
constructor() {}
public setValue1(value1): void {
const currentData = this.data$.getValue();
this.data$.next({ ...currentData, value1: currentData.value1 + value1 });
}