Skip to content

Instantly share code, notes, and snippets.

/**
* @desc ConfigService will be used to deal with loading and saving config files that is needed to init the app
*/
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
@Injectable()
@mansour-ahmed
mansour-ahmed / tslint.json
Created January 7, 2018 10:18
up-to-date tslint configuration file for TS & angular development
{
"rulesDirectory": ["node_modules/codelyzer"],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [true, "check-space"],
"curly": true,
"eofline": true,
"forin": true,
@mansour-ahmed
mansour-ahmed / animate-scroll-class.ts
Created January 7, 2019 05:31
animate-scroll-class
export class AnimateScroll {
constructor() {}
/**
* @desc scrollToItem Fn scrolls to an items by utilising the animated scroll fn (scrollTo)
* and calculating the height of the header to accurately find the item's position.
* @param elementID: element's ID that will be scrolled to.
* @param duration: duration in milliseconds, default is 750.
*/
scrollToElement(elementID: string, duration: number = 750) {
@mansour-ahmed
mansour-ahmed / breakpoint-mixin.scss
Created October 28, 2019 12:28
Mobile first scss mixin to handle responsive layouts using media queries
@mixin breakpoint($point) {
/*========== Mobile First Method ==========*/
@if $point==xs {
@media only screen and (min-width: 0px) {
@content;
}
} @else if $point==sm {
@media only screen and (min-width: 600px) {
@content;
}
@mansour-ahmed
mansour-ahmed / chessKnightMoves.ts
Last active February 24, 2024 20:30
A function to calculate possible coordinates for a knight on a chess board.
type Coordinate = [number, number];
/**
* @desc gets all possible coordinates for a knight given its current position
* @param x knight's current x position
* @param y knight's current y position
*
* @example possibleDestinations(4, 3) => [[3, 1], [3, 5], [5, 5], [5, 1], [2, 2], [2, 4], [6, 2], [6, 4]]
*
* @returns all possible coordinates for the knight