Skip to content

Instantly share code, notes, and snippets.

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

Oscar E. Oceguera Bibriesca oscaroceguera

🏠
Working from home
View GitHub Profile
@oscaroceguera
oscaroceguera / index.js
Created July 3, 2020 02:35
models index sequelize
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const { DB } = require('../../config/config');
const config = DB;
const db = {};
const sequelize = new Sequelize(
config.database,
import React, { useState, useEffect } from 'react';
import axios from 'axios';
// https://www.robinwieruch.de/react-hooks-fetch-data
const useDataApi = () => {
const [items, setData] = useState();
const [url, setUrl] = useState();
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(false);
import React, { useState } from 'react';
import {
Button,
DialogContainer,
TextField,
Toolbar,
SelectField,
} from 'react-md';
import axios from 'axios';
@oscaroceguera
oscaroceguera / auxFuncAutocomplete.js
Created September 1, 2019 07:47
funciones para autocomplete
// instalar => npm install --save keycode
const getFoodUuid = (data, item) => data.find(i => i.label === item).uuid
// AUTOCOMPLETE
handleInputChange = event => {
this.setState({ inputValue: event.target.value })
}
// AUTOCOMPLETE
@oscaroceguera
oscaroceguera / Autocomplete.js
Last active September 1, 2019 07:45
Autocomplete material-ui component
import React from 'react'
import PropTypes from 'prop-types'
import deburr from 'lodash/deburr'
import Downshift from 'downshift'
import { withStyles } from '@material-ui/core/styles'
import { TextField, Paper, MenuItem, Chip } from '@material-ui/core'
function renderInput(inputProps) {
const { InputProps, classes, ref, ...other } = inputProps
return (
@oscaroceguera
oscaroceguera / .eslintrc.js
Created March 21, 2019 19:10
my eslintrc
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
@oscaroceguera
oscaroceguera / timestampHashing.js
Created November 14, 2018 23:06
Hashids timestamp
const Hashids = require('hashids');
const hashids = new Hashids()
const dateTime = Date.now('1985-14-05')
const timestamp = Math.floor(dateTime / 1000)
console.log('DateTime ===>', dateTime)
console.log('Timestamp ===>', timestamp)
const encrypted = hashids.encodeHex(timestamp)
import React, { createContext } from 'react'
export const TableContext = createContext()
export const Row = ({ row }) => (
<TableContext.Consumer>
{({ columns }) => (
columns.map((field, i) => <td key={i}>{row[field.name]}</td>)
)}
</TableContext.Consumer>
body {
margin: 0;
padding: 0;
font-size: 16px;
font-family: sans-serif;
}
table {
margin: 2em auto;
width: 80%;
import React, { Component } from 'react'
import {Table, Header, Body, TableContext} from './table.component'
import './App.css';
class App extends Component {
state = {
activeRow: null,
data: [
{ Id: "1", Year: "1961", Make: "Jaguar", Model: "E-Type" },
{ Id: "2", Year: "1969", Make: "Ferrari", Model: "365 GT 2 + 2" },