Skip to content

Instantly share code, notes, and snippets.

@jyotendra
jyotendra / actionExample.js
Last active Jan 25, 2017
React-redux action creator
View actionExample.js
// Example 1 with no payload
export function incrementCounter(){
return {type:"INCREMENT_COUNTER"};
}
/*
The action is only the object that is being return
that is: {type:"INCREMENT_COUNTER"}
Rest of the function is called Action creator - which creates the action
*/
View exampleRootReducer.js
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.
});
View Main.my.js
/*
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'
@jyotendra
jyotendra / Image.cs
Created Feb 7, 2018
This describes usage of delegates in C#
View Image.cs
namespace Data.Model
{
class Image
{
public string Title { get; set; }
public bool IsBlurred { get; set; } = false;
}
}
@jyotendra
jyotendra / appuser.ts
Created Feb 22, 2018
sequelize-model-importer.ts is used to connect all models with main model, in sequelize.
View appuser.ts
import * as Sequelize from 'sequelize'
export interface AppUserAttributes {
id?: string
active?: boolean,
avatar?: string,
email?: string,
firstName?: string,
@jyotendra
jyotendra / _index.ts
Last active Feb 22, 2018
'sequelize-model-importer.ts' is used to connect all models with main model, in sequelize.
View _index.ts
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 / index.html
Last active Mar 23, 2018
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.
View index.html
<!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 / express.conf
Created Mar 24, 2018
sample configuration files for nginx setup
View express.conf
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 / dashboard.component.ts
Last active Mar 27, 2018
Using web-workers in Angular to off-load data intensive calculations. Considering a trivial addition here.
View dashboard.component.ts
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-dashboard",
templateUrl: "dashboard.component.html"
})
export class DashboardComponent implements OnInit {
constructor() {}
ngOnInit() {
@jyotendra
jyotendra / jSummer.js
Created Apr 7, 2018
Gist to demonstrate web workers
View jSummer.js
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);
}