Skip to content

Instantly share code, notes, and snippets.

@jyotendra
jyotendra / apiHandler.ts
Created June 21, 2018 13:10
This function can be used to get files from angular observable
import { HttpClient, HttpHeaders, HttpParams } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { TokenManager } from "@app/shared/services/token-manager.service";
@Injectable()
export class ApiHandler {
constructor(private http: HttpClient) {}
apiGet(url, params?, extras?: Extras) {
let options = this.renderHeaders(extras);
@jyotendra
jyotendra / jSummer.js
Created April 7, 2018 09:06
Gist to demonstrate web workers
onmessage = function(e) {
console.log('Message received from main script');
var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
console.log('Posting message back to main script');
postMessage(workerResult);
}
@jyotendra
jyotendra / dashboard.component.ts
Last active March 27, 2018 10:51
Using web-workers in Angular to off-load data intensive calculations. Considering a trivial addition here.
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-dashboard",
templateUrl: "dashboard.component.html"
})
export class DashboardComponent implements OnInit {
constructor() {}
ngOnInit() {
@jyotendra
jyotendra / express.conf
Created March 24, 2018 14:12
sample configuration files for nginx setup
server {
listen 80;
server_name www.js-server.com js-server.com;
root /home/jyotendra/files/projects/express-sequelize/;
location ~
^/(assets/|public/|images/|img/|javascript/|js/|css/|stylesheets/|media/|static){
@jyotendra
jyotendra / index.html
Last active March 23, 2018 11:58
This gist explains how to setup express to serve multiple angular apps from its public folder while also serving apis and other functions. It demonstrates how routing conflict between angular and express can be resolved.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>NgApp</title>
<!-- Need to change this base href to proper folder hierarchy -->
<base href="/ng/">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
@jyotendra
jyotendra / _index.ts
Last active February 22, 2018 07:31
'sequelize-model-importer.ts' is used to connect all models with main model, in sequelize.
import * as fs from 'fs'
import * as path from 'path'
import * as Sequelize from 'sequelize'
// configuration to connect to db are getted
const config = require('../config/config.json')
// Import model specification from its own definition file.
import { LanguageInstance, LanguageAttributes } from './language'
import { AppUserInstance, AppUserAttributes } from './appuser'
@jyotendra
jyotendra / appuser.ts
Created February 22, 2018 06:57
sequelize-model-importer.ts is used to connect all models with main model, in sequelize.
import * as Sequelize from 'sequelize'
export interface AppUserAttributes {
id?: string
active?: boolean,
avatar?: string,
email?: string,
firstName?: string,
@jyotendra
jyotendra / Image.cs
Created February 7, 2018 09:20
This describes usage of delegates in C#
namespace Data.Model
{
class Image
{
public string Title { get; set; }
public bool IsBlurred { get; set; } = false;
}
}
/*
This is my test implementation
*/
import React from 'react'
import { Switch, Route } from 'react-router-dom'
import Home from './Home'
import Roster from './Roster'
import Schedule from './Schedule'
import {combineReducer} from "redux";
import counter from "./reducerExample";
/*
The idea is to
*/
export default const rootReducer = combineReducer({
counter
//, other reducers goes here with this object.
});