Skip to content

Instantly share code, notes, and snippets.

View hassansw's full-sized avatar
🎯
Focusing

Hassan Saleem hassansw

🎯
Focusing
View GitHub Profile
@hassansw
hassansw / cookies.injectable.ts
Created July 4, 2018 09:05
Cookies Injectable
import { Injectable } from '@angular/core';
@Injectable()
export class CookieService {
constructor() { }
public getCookie(name: string): any | null {
let ca: Array<string> = document.cookie.split(';');
let caLen: number = ca.length;
@hassansw
hassansw / app.component.ts
Last active July 3, 2018 07:34
Angular Asynch ngFor
import { Component, OnInit, AfterViewInit } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Title } from "@angular/platform-browser";
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/delay';
@Component({
@hassansw
hassansw / filter.js
Last active May 10, 2018 13:10
Javascript Filter
listOfObjects.filter(x => x.obj > 1); //or any other condition to filter the list
listOfObjects.filter(x => anotherList.includes(x.anyObject));
@hassansw
hassansw / filter.pipe.ts
Created May 4, 2018 06:53
Angular Filter Pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filter'
})
export class FilterPipe implements PipeTransform {
transform(items: any[], searchText: string): any[] {
if (!items) return [];
if (!searchText) return items;
searchText = searchText.toLowerCase();
return items.filter(it => {
@hassansw
hassansw / customDate.js
Last active April 25, 2018 09:50
modify and get Date format of your choice :)
//A special thanks to Sabih Siddiqui : https://github.com/siddiquisabih
changeDateToCurrentTimezone(date) {
let splitDate = date.split('-')
let year = parseInt(splitDate[0])
let month = parseInt(splitDate[1])
let splitCurrentDate = splitDate[2]
let newDate = splitCurrentDate.split('T')
let day = parseInt(newDate[0])
@hassansw
hassansw / react-native-maps-enable-google-maps-instructions.md
Created April 15, 2018 16:14 — forked from heron2014/react-native-maps-enable-google-maps-instructions.md
Visual instructions how to enable Google Maps on IOS using react-native-maps

Visual instructions how to enable Google Maps on IOS using react-native-maps

This is for my personal use, things might not be correctly explained here. For the official docs please check https://github.com/airbnb/react-native-maps

Steps from scratch:

1.react-native init GoogleMapPlayground

2. cd GoogleMapPlayground

@hassansw
hassansw / FragmentHome.kt
Created October 4, 2017 14:22
Creating a Fragment with Kotlin
class FragmentHome : Fragment() {
//Any other widgets such as Button, Layouts and etc be declared also like this
var tvHomeLabel:TextView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}