Skip to content

Instantly share code, notes, and snippets.

View athulmurali's full-sized avatar
🎯

Athul Muralidharan athulmurali

🎯
View GitHub Profile
@athulmurali
athulmurali / ReduxFix.md
Last active June 6, 2019 20:56
ReduxFix.md

There are some issues in redux fundamentals here.

A store should be created once. Whenever, you select a topic , you will have to update the store but not re-create them. Move the createStore code accordingly.

Since you are using only one reducer, the following should be code to create a redux store. You were passing an object as a second argument which is a place for a redux middleware but not any other argument or parameter

@athulmurali
athulmurali / meetingRooms2.py
Last active June 6, 2019 04:57
Meeting Rooms ||
# Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
def minMeetingRooms(self, intervals: List[Interval]) -> int:
import heapq
heap = []
@athulmurali
athulmurali / MinMaxHeap.py
Last active June 6, 2019 04:47
MinMaxHeap in Python
import heapq
class MaxInt(int):
def __init__(self,val):
self.val = val
def __lt__(self,other): return self.val > other.val
class heap:
def __init__(self, arr =[], num_type = int):
self.arr = arr
1. React dev tools
2. anchor tag issues
@athulmurali
athulmurali / selection.js
Last active June 3, 2019 15:37
Selection fix
//Note: some may have selectedWidget, some may not , ignore it if it is not yours.
// while selecting a module, set topic and selectedWidget to null so that you don't retain the existing selection
// while selecting a lesson, set widget and selectedWidget to null
// This is just a sample code
this.state={
// ...
selectedModule: course.modules[0],
selectedLesson: course.modules[0].lessons[0],
@athulmurali
athulmurali / WidgetListEditor.js
Last active June 1, 2019 03:39
Sample redux code
import React from 'react';
import WidgetListContainer from './WidgetListContainer'
import {applyMiddleware, createStore} from 'redux'
import logger from 'redux-logger'
import {Provider} from 'react-redux'
import {widgetReducer} from "../reducers/widgetReducer"
let store = createStore(widgetReducer);
@athulmurali
athulmurali / Closure.js
Last active May 26, 2019 16:41
Singleton Pattern
import coursesData from './courses'
function CourseService() {
let courses = coursesData;
return {
addCourse: (newCourse) => {
courses.push(newCourse);
},
deleteCourse: (id) => {
courses = courses.filter(course => course.id !== id)
},
#!/usr/bin/env bash
#sh
export DB_URL='mongodb://rfid:[email protected]:23756/crappy-logger'
node server.js
@athulmurali
athulmurali / Connection.java
Last active October 21, 2018 21:01 — forked from jasoet/gist:3843797
Database Connection Singleton
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.secondstack.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@athulmurali
athulmurali / server.js
Created July 31, 2018 10:07
express-code-angular
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(`${__dirname}/front-end/dist/`));
app.get('/*', function(req,res) {