Skip to content

Instantly share code, notes, and snippets.

View chsami's full-sized avatar

chsami chsami

View GitHub Profile
//Use the InjectionToken for the mapsConfig, this can be later used to inject it with DI
export const MapsConfig = new InjectionToken<IMapsConfig>('MAPS_CONFIG');
@Injectable({
providedIn: MapModule
})
export class MapService {
private _key: string;
constructor(
export class MapModule {
//create a static function with the mapConfig as a parameter
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders {
return {
ngModule: MapModule,
//We provide a MapsConfig InjectionToken, which we later can use in our service to use
providers: [ {provide: MapsConfig, useValue: mapConfig} ]
};
}
}
export class MapModule {
//create a static function with the mapConfig as a parameter
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders {
return {
ngModule: MapModule,
//We provide a MapsConfig InjectionToken, which we later can use in our service to use
providers: [ {provide: MapsConfig, useValue: mapConfig} ]
};
}
}
<input type="text" />
<div tabindex="0"></div>
<div tabindex="0"></div>
<input type="text" />
@chsami
chsami / AuthenticationHelper.cs
Last active January 14, 2019 21:14
Pagination Class
public class AuthenticationHelper : IAuthenticationHelper
{
static string ApplicationName = "APPLICATIONNAME";
static string RefreshToken = "YOURREFRESHTOKEN";
public DriveService Authenticate()
{
var token = new TokenResponse
{
RefreshToken = RefreshToken
@chsami
chsami / strip.typename.property.ts
Created January 16, 2019 20:15
strip javascript property
this.blogs.forEach((blog: any) => { delete blog.__typename; });
// delegate to your own implementation
spyOn(MoviesComponent, 'getMovies').and.callFake(() => {});
//delegate to your own implementation with an argument
spyOn(MoviesComponent, 'getMovies').withArgs('').and.callFake(() => {});
//return a specific value 'false'
spyon(MoviesComponent, 'getMovies').and.returnValue({movies: ['terminator', 'titanic', 'avatar']}});
//delegate to the actual implementation
@chsami
chsami / fetch.ts
Last active February 2, 2019 11:41
export class MoviesComponent {
constructor() {}
getMovies(): void {
this.http.get('http://example.com/movies.json').toPromise().then((response) => {
console.log(response);
});
}
<label for="my-lovely-checkbox">Some label text</label>
<input type="checkbox" id="my-lovely-checkbox" />
var parents = await _context.Set<Parent>()
.Include(m => (m as Child1).Property1)
Include(m => (m as Child2).Property1)
.ToListAsync();