Skip to content

Instantly share code, notes, and snippets.

View junaid1460's full-sized avatar
🙃
I may be slow to respond.

J junaid1460

🙃
I may be slow to respond.
View GitHub Profile
export const hapiServer = new Server({
host: env.APP_HOST,
port: env.APP_PORT,
routes: { cors: true },
});
(async () => {
await hapiServer.route(new ApiModule().getRoutes());
await hapiServer.route(new ApiModuleForAdmin().getRoutes());
await hapiServer.route(new AdminModule().getRoutes());
@junaid1460
junaid1460 / extended.hapiest.ts
Last active August 17, 2019 11:16
Extended api
// Now I want user api to be available for admin
// may be I want to show in dashboard
export class ApiModuleForAdmin extends ApiModule {
public auth = "simple";
public baseUrl = `${baseUrl}/admin/user-apis${baseUrl}`;
}
export class ApiModule extends Hapiest.HapiestModule {
public routeSets = [UserApiRoutes];
public baseUrl = baseUrl;
}
export class AdminModule extends Hapiest.HapiestModule {
public routeSets = [AdminRoutes];
public auth = "simple"; // Overrides auth for all routes under this.
public baseUrl = `${baseUrl}/admin`;
}
@junaid1460
junaid1460 / asyncBatchMap.ts
Last active August 16, 2019 11:30
typescript snippets
// Create batches out of big array
// Map those batches to a lambda
export async function asyncBatchMap<T, F>(
items: ReadonlyArray<T>,
predicate: (input: T[]) => Promise<F>,
batchSize: number = 10,
): Promise<F[]> {
const newContainer = items.map((e) => e);
const result: F[] = [];
while (newContainer.length > 0) {
.blue_grace_preview_button {
box-shadow: 0 3px 2px #e0e0e0;
margin-left: 11px !important;
}
.blue_grace_toolbar_buttons {
color: #3F51B5 !important;
margin-right: 5px !important;
div(class="overflow-fix")
app-inputs(
#myCustomInput
appTheme
)
app-inputs(
#myCustomInput
appTheme="myCustomThemeKey"
)
import { Directive, Input, OnInit, ElementRef, Renderer2 } from '@angular/core';
import { ThemeService } from './theme.service';
@Directive({
selector: '[appTheme]'
})
export class ThemeDirective implements OnInit {
@Input('appTheme') appTheme: string; // appTheme="customClassKey"
constructor(
private themeService: ThemeService,
export const blueGrace = {
appSidebarClass: 'blue_grace_sidebar',
sidebarSectionClass: 'blue_grace_sidebar_section',
'app-inputs': 'blue_grace_app_inputs',
'app-tags': 'blue_grace_app_inputs',
'app-sources': 'blue_grace_app_inputs',
'myCustomThemeKey': 'myCustomClass',
};
@junaid1460
junaid1460 / thmeservice.ts
Last active January 6, 2019 10:23
theme service
import { Injectable } from '@angular/core';
import { blueGrace } from './themes';
const themeKey = 'app:theme';
export const themeStore = {
'Blue Grace': blueGrace,
'Default': null
};
@junaid1460
junaid1460 / slider-css.html
Created August 15, 2018 10:44
Simple slider with no javascript and animation
<html>
<style>
.begin {
background: #f1f1f1;
width : 100%;
}
.anim {
background: red;
width: 0%;