Skip to content

Instantly share code, notes, and snippets.

Working from home

carlos L cocodrino

Working from home
  • Venezuela
View GitHub Profile
cocodrino / code.jsx
Created Sep 1, 2022
same ReactJS incremental counter in functional style using HOC,render props and Hooks
View code.jsx
import React,{useEffect,useState} from "react";
const useCounter=()=>{
const [count,setCount] = useState(0)
let timer = setInterval(()=>{setCount(v=>v+10)},2000)
return ()=>{clearInterval(timer)}
cocodrino / gist:f6298e5e593c7615f74687a5823ac1d6
Created Aug 5, 2022
remove unused imports automatically from typescript files
View gist:f6298e5e593c7615f74687a5823ac1d6
1) install eslint-plugin-unused-imports
`yarn add -D eslint-plugin-unused-imports`
2) add "unused-imports" to your "plugins"section under .eslitrc.json file
"plugins": [
cocodrino / download
Created Nov 1, 2018
download subfolder github
View download
For other users who just want to download a file/folder from github, simply use:
svn export <repo>/trunk/<folder>
svn export
(yes, that's svn here. apparently in 2016 you still need svn to simply download some github files)
Courtesy: Download a single folder or directory from a GitHub repo
cocodrino / wrapper.tsx
Created Jul 14, 2021
wrapper for react testing library and redux
View wrapper.tsx
import { configureStore, Store } from '@reduxjs/toolkit';
import React, { ComponentType, ReactElement } from 'react';
import { Provider } from 'react-redux';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router';
import { reducer } from '../state/store';
export const makeStore = (): Store => configureStore({ reducer });
const history = createMemoryHistory();
cocodrino / factory.ts
Created Apr 16, 2021
factory typescript
View factory.ts
class Person {
firstName = 'John';
lastName = 'Doe';
class Factory {
create<T>(type: (new () => T)): T {
return new type();
View gist:3c3513fa6b36022a22c9b732822b44c4
git grep "string/regexp" $(git rev-list --all)
or filtering every commit and only show branches
git grep "your-search" `git show-ref --heads` or git show-ref --heads | xargs git grep "your-search"
View docker-compose.yaml
version: "3.2"
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
cocodrino / partition.js
Last active Nov 6, 2020
javascript partition similar to clojure partition
View partition.js
function partition(input, step,pad){
const output = [];
for (let i = 0; i < input.length; i += pad){
const part = input.slice(i, i + step)
if(part.length >=step )
output[output.length] = part
return output;
cocodrino /
Last active Jun 27, 2020
Moving Averages helper for detect Elliot Waves
//@Author: cocodrino
//This indicator was made to allow three moving averages to be displayed without needing to use up 3 charting indicators individually
// based on
study(title="MA Elliot Helpers", shorttitle="Melliot", overlay=true)
cocodrino / hook.php
Created Mar 13, 2020
wordpress and woocommerce hooks
View hook.php
add_filter( 'wp_nav_menu_items', 'ia_custom_menu_item', 10, 2 );
function ia_custom_menu_item ( $items, $args ) {
if (is_user_logged_in()) {
$items .= '<li id="menu-item-logout" class="menu-item menu-item-type-custom menu-item-object-custom aiv_sign_button"><a href="/mi-cuenta/salir/">Salir</a></li>';