Skip to content

Instantly share code, notes, and snippets.

View victorhqc's full-sized avatar
💭
🦀 ⭐

Victor Quiroz victorhqc

💭
🦀 ⭐
View GitHub Profile
@victorhqc
victorhqc / DynamicRenderImplementation.jsx
Created September 27, 2017 08:43
Dynamic render implementation
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Translate from './highOrderComponents/WithTranslate';
import ClickOutside from './highOrderComponents/ClickOutside';
import WithUser from './highOrderComponents/WithUser';
import {
configureUser,
} from './store/actions';
@victorhqc
victorhqc / build-atom.sh
Created July 13, 2019 19:04
Bash script for atom in circleci
#!/bin/sh
ATOM_CHANNEL="${ATOM_CHANNEL:=stable}"
echo "Downloading latest Atom release on the ${ATOM_CHANNEL} channel..."
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
curl -s -L "https://atom.io/download/mac?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom.zip"
mkdir atom
@victorhqc
victorhqc / emojis.js
Created March 13, 2018 13:11
Get slack Emojis
// Go to "Customize Slack" in settings. It'll redirect you to https://[organization].slack.com/customize/emoji
// Then run this code in the web terminal.
{
let total = 0;
const contributors = Object.entries([].slice.call(document.querySelectorAll('#custom_emoji a')).reduce((prev, link) => {
total += 1;
if (!prev[link.innerText]) {
return {
...prev,
@victorhqc
victorhqc / controller.js
Created December 15, 2017 12:52
Angular 1.X Redux-Controller
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function($scope, TodoService) {
function addTodo($scope, TodoService) {
return function curriedAddTodo(title, description) {
$scope.title = '';
$scope.description = '';
$scope.todos = TodoService.todosReducer(
$scope.todos,
@victorhqc
victorhqc / factory.js
Last active December 15, 2017 12:48
Angular 1.X Redux-Factory
(function(app) {
function TodoServiceFactory() {
var ADD_TODO = 'ADD_TODO';
var REMOVE_TODO = 'REMOVE_TODO';
var ID = -1;
function findIndex(haystack, needle) {
var isFound = false;
var index = -1;
haystack.some(function mapHaystack(data) {
@victorhqc
victorhqc / build-package.sh
Last active October 24, 2017 15:30
atom build
#!/bin/sh
ATOM_CHANNEL="${ATOM_CHANNEL:=stable}"
echo "Downloading latest Atom release on the ${ATOM_CHANNEL} channel..."
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
curl -s -L "https://atom.io/download/mac?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom.zip"
mkdir atom
@victorhqc
victorhqc / TranslateHighOrderComponent.jsx
Last active September 27, 2017 09:06
High Order Component Implementation example
import React, { Component } from 'react';
import {
translateFromCountry,
} from './translate';
// High order Component translate
const translate = (WrappedComponent) => {
return class extends Component {
translate = (key, params) => {
@victorhqc
victorhqc / TranslateDynamicRenderComponent.jsx
Last active September 27, 2017 09:04
Dynamic render example
import React, { Component } from 'react';
import reduce from 'lodash/reduce';
const TRANSLATIONS = {
US: {
welcome: 'Welcome {{user}}',
},
MX: {
welcome: 'Bienvenido {{user}}',
},
@victorhqc
victorhqc / HighOrderComponentsProblemsExample.jsx
Created September 26, 2017 19:25
HighOrderComponents Problems Example
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { recompose } from 'recompose';
import translate from './highOrderComponents/withTranslate';
import clickOutside from './highOrderComponents/clickOutside';
import withUser from './highOrderComponents/withUser';
import {
configureUser,
} from './store/actions';