Skip to content

Instantly share code, notes, and snippets.

View SRatna's full-sized avatar

Sushanta Ratna Adhikari SRatna

  • Virtual Retail GmbH
  • Siegen, Germany
View GitHub Profile
@SRatna
SRatna / gunicorn-flask.txt
Created June 27, 2017 05:47
Steps I followed to set up gunicorn service in ubuntu for flask restless
I used anaconda as my python vendor.
So first install anaconda.
Then set path in .profile in home directory.
--> PATH="$HOME/bin:$HOME/.local/bin:$HOME/anaconda3/bin:$PATH"
then create a virtual environment using conda as
: conda create --name your_name_for_env python=3.4
this will create named env directory inside anaconda3/envs
do source activate your_name_for_env
now go to your project directory and install dependencies using pip as:
--> pip install -r requirements.txt
@SRatna
SRatna / scrapySetup.txt
Last active August 16, 2017 11:39
Set up for scrapy
I used anaconda as my python vendor.
So first install anaconda.
Then set path in .profile in home directory.
--> PATH="$HOME/bin:$HOME/.local/bin:$HOME/anaconda3/bin:$PATH"
then create a virtual environment using conda as
: conda create --name your_name_for_env
this will create named env directory inside anaconda3/envs
do source activate your_name_for_env
then pip install scrapy

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
/**
* Create valid redux reducer with action types as object keys and values as
* functions, instead of using Switch Statement
*
* Use it like this:
*
* `createReducer({
* // optional if you set a initial state as the second argument
* initialState: {},
*
import snakeCase from 'lodash/snakeCase'
/**
* Convert a object with action creators created with
* redux-actions createAction to a object with these
* functions names as action types
*
* "someAction" becomes "SOME_ACTION"
*
* @param {Object} actions Object with action creators
@SRatna
SRatna / Top 50 Universities List.md
Created April 29, 2018 03:27
Top 50 Computer Science Universities

Universities

Massachusetts Institute of Technology (MIT)

###phd###

  • MIT Graduate Admissions link
  • PhD Program - MIT Sloan School of Management link
  • MIT - Massachusetts Institute of Technology link
  • to view contact information for all departments. - MIT link
@SRatna
SRatna / Random-string
Created May 4, 2018 04:41 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@SRatna
SRatna / crud-saga.js
Created June 21, 2018 06:26 — forked from cbilgili/crud-saga.js
Redux CRUD Saga (redux-saga)
import { takeLatest } from 'redux-saga'
import { call, put } from 'redux-saga/effects'
import fetch from 'isomorphic-fetch'
import * as actions from './modules/grid'
import * as api from '../lib/api'
export function* fetchGrids(action) {
try {
const grids = yield call(api.GET, 'grids')
yield put(actions.fetchGridsSuccess(grids))
@SRatna
SRatna / reduxObjectLiteral.js
Created June 22, 2018 04:16 — forked from sebjwallace/reduxObjectLiteral.js
Redux reducer using object literal instead of a switch statement
import {createStore} from 'redux';
const counter = (state = 0, action) => {
const index = {
'INCREMENT': () => {
return state+1;
},
'DECREMENT': () => {
return state-1;
},
@SRatna
SRatna / multiFilter.js
Last active July 17, 2018 08:43 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple criteria.
/**
* Filters an array of objects with multiple criteria.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria as the property names
* @return {Array}
*/
function multiFilter(array, filters) {
const filterKeys = Object.keys(filters);
// filters all elements passing the criteria