Skip to content

Instantly share code, notes, and snippets.

View cocodrino's full-sized avatar
🏠
Working from home

carlos L cocodrino

🏠
Working from home
  • Venezuela
View GitHub Profile
@cocodrino
cocodrino / index.js
Last active February 20, 2020 14:53 — forked from reireynoso/index.js
redux dev tool extension
import {createStore} from 'redux'
import rootReducer from './reducers'
import {Provider} from 'react-redux'
const store = createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
@cocodrino
cocodrino / index.js
Created February 20, 2020 14:53 — forked from reireynoso/index.js
Index File
import {createStore} from 'redux'
import rootReducer from './reducers'
import {Provider} from 'react-redux'
const store = createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
@cocodrino
cocodrino / pyenv_python_version_manager.bash
Created February 11, 2020 13:23
pyenv python version manager
install curl https://pyenv.run | bash
add
export PATH="/Users/Admin/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
sudo micro ~/.zshrc
source ~/.zshrc
@cocodrino
cocodrino / remotedebug.js
Created January 5, 2020 23:09
remote debug
si se desea activar de manera segura el debugger de node se debe seguir los siguientes pasos
1. corra el script con el argumento inspect-brk
```
pm2 start ./server/server.js --node-args="--inspect-brk" --name api-test
```
luego, *NO* abra puertos, esto es inseguro y cualquiera con acceso a su ip y puerto tendría acceso al código, para conectar la máquina local lo mejor es usar un ssh tunneling
@cocodrino
cocodrino / calling children function from parent react.js
Created December 8, 2019 22:35
calling children function from parent react
const { forwardRef, useRef, useImperativeHandle } = React;
// We need to wrap component in `forwardRef` in order to gain
// access to the ref object that is assigned using the `ref` prop.
// This ref is passed as the second parameter to the function component.
const Child = forwardRef((props, ref) => {
// The component instance will be extended
// with whatever you return from the callback passed
// as the second argument
@cocodrino
cocodrino / sample.js
Created December 7, 2019 00:51
click outside event for react
import { useEffect } from "react";
const useOutsideClick = (ref, callback) => {
const handleClick = e => {
if (ref.current && !ref.current.contains(e.target)) {
callback();
}
};
useEffect(() => {
@cocodrino
cocodrino / sample.js
Created November 27, 2019 15:58
router with modal
/*
LA IDEA ES LA SIGUIENTE:
AL DARLE CLICK A UN MODAL SE DEBEN RENDERIZAR DOS RUTAS, LA RUTA DE LA PÁGINA DE ABAJO Y LA RUTA DEL MODAL
PARA SABER LA RUTA DE ABAJO SE CREA UN ESTADO backgroundPage QUE ES DE LA FORMA {pathname:<ruta>}
CUANDO LA PERSONA DA CLICK PARA ABRIR UN MODAL (LINEA 123,128) SE SETEA ESE ESTADO CON EL PATH ACTUAL...ESO LO HACE LinkToModal (114) QUE SETEA EL BACKGROUND
LLAMANDO A LA ACCIÓN setModalBackgroundPageAction (57) TIENES UN EXTRACTO DEL ESTADO EN LA LINEA 204
ES DECIR, SI backgroundPage ESTÁ SETEADO SE MUESTRA EL MODAL Y EL SWITCH RENDERIZA ESA RUTA (82,177)
@cocodrino
cocodrino / document.js
Created November 13, 2019 18:13
jquery document ready in plain js
Document Ready check
This snippet will covers all the browser to check if the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
console.log('Your document is ready!');
});
Document Ready check for IE8
Offcourse there is IE8, who wants a different way.
document.attachEvent("onreadystatechange", function(){
@cocodrino
cocodrino / crap.scss
Created November 6, 2019 15:22
add margin to horizontal menu
.your_nav_element:not(:last-child) {
-webkit-box-shadow: 10px 0px 0px -9px white;
-moz-box-shadow: 10px 0px 0px -9px white;
box-shadow: 10px 0px 0px -9px white;
}
@cocodrino
cocodrino / netdata disk alarms
Created August 16, 2019 15:15
netdata disk alarms
# -----------------------------------------------------------------------------
# low disk space
# checking the latest collected values
# raise an alarm if the disk is low on
# available disk space
template: disk_space_usage
on: disk.space
families: *