Skip to content

Instantly share code, notes, and snippets.

View mohamedaboelmagd's full-sized avatar
🎯
Focusing

Mohamed Aboelmagd mohamedaboelmagd

🎯
Focusing
View GitHub Profile
@mohamedaboelmagd
mohamedaboelmagd / effect.spec.ts
Created May 16, 2019 06:40
This testing doesn't work
import { environment } from 'environments/environment';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import * as fromModels from '@models';
import { Actions } from '@ngrx/effects';
import { cold, hot } from 'jasmine-marbles';
import { empty, Observable, of, BehaviorSubject } from 'rxjs';
import * as fromActions from '../actions/trending.actions';
import * as fromEffects from './trending.effects';
@mohamedaboelmagd
mohamedaboelmagd / ts
Created March 26, 2019 12:58
Check user has internet connection or not using Angular 2
export class ExtendedHttpService extends Http {
constructor(backend: XHRBackend, defaultOptions: RequestOptions) {
super(backend, defaultOptions);
}
request(url: string, options?: RequestOptionsArgs): Observable<Response> {
return super.request(url, options).catch((error: Response) => {
if (error.status === 0) {
this._router.navigateByUrl('/no-internet', { skipLocationChange: true });
let timer = 1000; // in milliseconds
Observable.interval(timer * 2).subscribe(x => {
@mohamedaboelmagd
mohamedaboelmagd / gist1.txt
Created October 11, 2017 08:46
Generating a new SSH key and adding it to the ssh-agent
Generating a new SSH key
Open Terminal.
Paste the text below, substituting in your GitHub email address.
> ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This creates a new ssh key, using the provided email as a label.
Generating public/private rsa key pair.
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.