Skip to content

Instantly share code, notes, and snippets.

View tadjik1's full-sized avatar
:octocat:
🐛 🔫 🤠

Sergey Zelenov tadjik1

:octocat:
🐛 🔫 🤠
View GitHub Profile
var server = require('../server');
var supertest = require('supertest');
describe("server", function () {
var request,
UserId;
before(function (done) {
request = supertest(server.listen(done));
export default class Tracks extends React.Component {
static loadTracks() {
let user = await UserActions.getUser();
let playlists = await PlaylistsActions.getPlaylists(user);
let tracks = await TracksActions.getTracksByPlaylists(playlists);
};
componentWillMount() {
//check if we already have some data
@tadjik1
tadjik1 / reducers.js
Last active August 29, 2015 14:25
reducers
const state = {
users: {
list: {id1: user1, id2: user2},
followers: {id1: [id2], id2: [id1]},
following: {id1: [id2], id2: [id1]},
interestingPersons: {id1: [id2], id2: [id1]},
...
}
}
@tadjik1
tadjik1 / example.js
Created July 22, 2015 12:55
implement custom subscription on redux store
const initialTodosState = [];
const initialCounterState = 0;
function todos(state = initialTodosState, action) {
return state;
}
function counter(state = initialCounterState, action) {
return state;
}
@tadjik1
tadjik1 / moviesReducer.js
Created July 24, 2015 08:28
example of reducer
import {
RECEIVED_NEW_RELEASES,
RECEIVED_FREE_MOVIES
} from '../constants/ActionTypes';
import selectn from 'selectn';
import { merge, union } from 'lodash';
const initialState = {
allMovies: {},
@tadjik1
tadjik1 / server.js
Created August 15, 2015 20:14
server rendering redux
import 'babel/polyfill';
import 'isomorphic-fetch';
import koa from 'koa';
import favicon from 'koa-favicon';
import serve from 'koa-static';
import logger from 'koa-logger';
import fs from 'fs';
import path from 'path';
import _ from 'lodash';
import selectn from 'selectn';
import { union } from 'lodash';
/**
* list of default fields for all of our lists
* @type {{items: Array, isFetching: boolean, lastUpdated: null, didInvalidate: boolean, pagination: {}}}
*/
export const defaultFields = {
items: [],
isFetching: false,
import calculateQuantity from '../calculateQuantity';
const quantity = {
1920: 10,
1366: 8,
1024: 4,
1280: 6
};
describe('calculateQuantity function', () => {
@tadjik1
tadjik1 / gist:5b52176de35eecdb3e28
Last active November 2, 2015 10:08
Dockerfile
# Dockerfile for %example% project
FROM centos:centos7
MAINTAINER Sergey Zelenov <mail@example.com>
RUN yum update -y
# Install EPEL
RUN yum install -y epel-release
it('should return response', async () => {
const result = await API.get('/test', {});
expect(result).to.deep.equal({hello: 'world', meta: {status: 200}});
});