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 / 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.
@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 / 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 / custom last months.ts
Created May 30, 2019 07:53
analytics on timestamp
cleanPerMonth(
data: {
counter: number;
month: number;
year: number;
}[],
numberOfMonths: number
) {
const result = [];
const everyMonth = [];
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:muport:QmYnGmzou2bvhXAr4TpdXdW9uJe5K2671x6jHE7p4cwZsp ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:muport:QmeqQETUT587avA6JXiBTiTpgif8PzcLwsoVDyqDr2krqx ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@mohamedaboelmagd
mohamedaboelmagd / vmdxToIso.txt
Created September 10, 2020 08:51
convert vmdk to iso
This was easy because I’d installed QEMU earlier on my system via Homebrew, so it was easy to convert the VMDK (the VMware disk image) to a RAW image image:
> qemu-img convert -f vmdk puredarwinxmas.vmdk pd.raw
This captures the contents of the VMware image into a raw image in some (unbeknownst to me) format. You can then write this to an ISO file:
> dd if=pd.raw of=pd.iso
That’s it. You can then mount this ISO, put it up for download, or whatever. This shouldn’t be limited to PureDarwin, and should work for most VMware disk images as long as it is stored as a VMDK file.
export function dirtyCheck<U>(source: Observable<U>) {
let subscription: Subscription;
let isDirty = false;
return function <T>(valueChanges: Observable<T>): Observable<boolean> {
const isDirty$ = combineLatest(
source,
valueChanges,
).pipe(
debounceTime(300),
export function dirtyCheck<U>(source: Observable<U>) {
return function<T>(valueChanges: Observable<T>): Observable<boolean> {
const isDirty$ = combineLatest(
source,
valueChanges,
).pipe(
debounceTime(300),
map(([a, b]) => isEqual(a, b) === false),
startWith(false),
@Component({
template: `
<form>
...
<button (click)="submit()" *ngIf="isDirty$ | async">Save</button>
</form>
`
})
export class SettingsComponent {
settings = new FormGroup({...});