Skip to content

Instantly share code, notes, and snippets.

import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
/*Navigation stuff*/
import { addNavigationHelpers, StackNavigator } from 'react-navigation';
/*Custom components*/
import Login from '../components/Login/Login';
import WeeksPage from '../components/WeeksPage/WeeksPage';
import clientThumbnailModule from './clientThumbnail'
import clientThumbnailController from './clientThumbnail.controller';
import clientThumbnailComponent from './clientThumbnail.component';
import clientThumbnailTemplate from './clientThumbnail.html';
describe('clientThumbnail', () => {
let $rootScope, $q, makeController;
beforeEach(window.module(clientThumbnailModule));
class ClientThumbnailController {
constructor(ClientFactory, $mdDialog, $state) {
"ngInject";
this.ClientFactory = ClientFactory;
this.sortOptions = {
"Sort by": '',
"name": 'data.commercialName',
"country": 'data.country.label',
}
@erick2014
erick2014 / Hoc.js
Last active April 20, 2018 16:42
HOC in react, simple demo
/***define the Home component here***/
import React, { Component } from 'react'
class Home extends Component {
componentDidMount () {
// dispatch action to fetch users
this.props.fetchUsers()
}
@erick2014
erick2014 / Provider.js
Last active June 3, 2018 22:16
React Context Api - Provider implementation
import { SESSION_SET_USER_INFO } from '../constants'
const sessionData = {
userName:'',
userId
}
const orders = {
orders: false
}
@erick2014
erick2014 / ConsumerComp.js
Last active June 3, 2018 22:21
React Context api Consumer implementation
// Session Actions
export const setSessionInfo = data => {
return {
payload: data,
type: SESSION_SET_USER_INFO
}
}
// Login Comp
onClickLoginBtn = dispatch => {
@erick2014
erick2014 / countDuplicatedElements.js
Created June 17, 2018 20:52
Count duplicated elements using Array.prototype.reduce
var arr = ['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a'];
return arr.reduce(function(acc, cur) {
acc[cur] = (acc[cur] || 0) + 1;
return acc;
},{});
// prints { a: 3, b: 2, c: 2, d: 2, e: 2, f: 1, g: 1, h: 3 }
@erick2014
erick2014 / media-query.css
Created October 29, 2018 13:31 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
/* Binary search algorithm implementation */
function binarySearch(items,valueToFind){
let start = 0
let stop = items.length-1
let middle = Math.floor( (start+stop) / 2 )
let itemFoundAtPos = -1
while( start < stop ){
let itemInMiddlePos = items[middle]
@erick2014
erick2014 / BubbleSortAlgorithm.py
Created May 14, 2019 21:38
Bubble Sort algorithm
sorted = True
numbers = [3, 5, 4, 2]
numbersLength = len(numbers)
while sorted:
sorted = False
for number in range(len(numbers)):
nextNumber = number + 1
if nextNumber == numbersLength:
break