Skip to content

Instantly share code, notes, and snippets.

View ssergio198's full-sized avatar
🌴
On vacation

Sergio Sanguanini ssergio198

🌴
On vacation
View GitHub Profile
@ssergio198
ssergio198 / work-with-multiple-github-accounts.md
Created December 11, 2022 15:53 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@ssergio198
ssergio198 / emulator-install-using-avdmanager.md
Created July 25, 2021 07:36 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For generic skin emulator with default apis (without google apis):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-29;default;x86"

@ssergio198
ssergio198 / RSAKeyExtensions.cs
Created September 27, 2020 13:52 — forked from ffantasy/RSAKeyExtensions.cs
export/import rsa
internal static class RSAKeyExtensions
{
#region JSON
internal static void FromJsonString(this RSA rsa, string jsonString)
{
Check.Argument.IsNotEmpty(jsonString, nameof(jsonString));
try
{
var paramsJson = JsonConvert.DeserializeObject<RSAParametersJson>(jsonString);
@ssergio198
ssergio198 / AngularRxJs5DateHttpInterceptor.ts
Created August 15, 2020 20:03 — forked from martinobordin/AngularRxJs5DateHttpInterceptor.ts
An Angular interceptor to parse string dates (ISO8601 format) from server response to JS Date Object. There are both RxJs 5 and RxJs 6 versions
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
@Injectable()
export class AngularDateHttpInterceptor implements HttpInterceptor {
// Migrated from AngularJS https://raw.githubusercontent.com/Ins87/angular-date-interceptor/master/src/angular-date-interceptor.js
iso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/;
@ssergio198
ssergio198 / ExcludeFilesWhenZipping.md
Created November 4, 2019 20:52 — forked from ddieppa/How to zip dotnet projects.md
Excludes Files when zipping Visual Studio project using 7zip

Excludes Files when zipping Visual Studio project using 7zip

Visual Studio project folders contains a lot of files that it generates each time you compile your project, so you dont need them when zipping the folder, it is kind of a .gitignore for 7zip in order to decrease the size of the file.

To accomplish this follow this steps:

  • Open a command prompt
  • Copy this into the console:
7z.exe a -t7z "C:\Destination\Path\%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% BackupName.7z" "C:\Source\Path\FolderToBeBackup" -bd  -mx9 -xr@"C:\Path\To\ExcludeListName"
  • Press Enter
@ssergio198
ssergio198 / ng-signalr.md
Created April 29, 2019 20:30 — forked from jehugaleahsa/ng-signalr.md
Consume SignalR Using Angular 2+

Consume SignalR Using Angular 2+

The beautiful thing about the web was that this article is outdated before I even started writing it. I am going to show how I was able to encapsulate SignalR functionality behind a simple service that works nicely in an Angular 2+ environment. I find myself frequently ruminating about the fact that Angular 2+ is more of an "environment" than a framework. It's not just a handful of libraries strewn together - it literally drives your development process - pretty much forcing you to introduce Node.js, TypeScript and a build tool (eg., Webpack) into your daily activities. It also strongly reinforces how you organize your files and what you name them. It's so painfully opinionated and I love it!

Services

If you are working on an Angular 2+ application and you don't have a lot of services, you are doing something woefully wrong. One of the biggest parts of getting your head wrapped around Angular 2+ is familiarizing yourself with their new approach to dependency injection an

@ssergio198
ssergio198 / Startup.cs
Created October 6, 2018 09:47
Automatic registering of generic repositories in ASP.NET Core
var assemblyToScan = typeof(IRepository<>).Assembly;
var types = assemblyToScan
.GetTypes()
.Where(t => t.IsClass && !t.IsAbstract && !t.IsNested && !t.IsNotPublic);
foreach (var type in types)
{
var interfaces = type.GetInterfaces();
@ssergio198
ssergio198 / index.js
Created October 15, 2016 20:57
node v7 async await
// An example class which generates a hello world greeting
class Demo {
async greeting() {
const h = await this.world();
return h;
}
world() {
return Promise.resolve('hello world');
}
}
@ssergio198
ssergio198 / is-prime.js
Created September 4, 2016 09:25
Filter Prime Numbers
function isPrime(number) {
if (number === 3 || number === 2) {
return true;
}
if (number === 1) {
return false;
}
for (let divisor = 2; divisor <= Math.sqrt(number); divisor++) {
@ssergio198
ssergio198 / permutations.js
Created July 9, 2016 16:00
The following very efficient algorithm uses Heap's method to generate all permutations of N elements with runtime complexity in O(N!)
// http://stackoverflow.com/questions/9960908/permutations-in-javascript
function permute(permutation) {
var length = permutation.length,
result = new Array([0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600][length]),
c = new Array(length).fill(0),
i = 1,
j = 1;
result[0] = permutation.slice();