Skip to content

Instantly share code, notes, and snippets.

View oquirozm's full-sized avatar
🦕
Front End Dev

Omar Quiroz oquirozm

🦕
Front End Dev
View GitHub Profile
import { useState } from 'react';
function usePagination() {
const [page, setPage] = useState(1);
const nextPage = () => setPage(page + 1);
const prevPage = () => setPage(page - 1);
return { page, setters: { prevPage, nextPage } };
}
@oquirozm
oquirozm / CharacterForm.jsx
Last active November 9, 2019 23:39
CharacterForm/index.jsx
import React, { useState } from 'react';
import Loader from 'react-spinners/PacmanLoader';
import useCharacterForm from './hooks/useGetCharacters';
import usePagination from './hooks/usePagination';
const CharacterForm = () => {
const [selectedCharacter, setSelectedCharater] = useState(null);
const { characters, loading, error } = useCharacterForm();
import axios from 'axios';
import { useState, useEffect } from 'react';
function useCharacterForm() {
const [loading, setLoading] = useState(false);
const [characters, setCharacters] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
@oquirozm
oquirozm / .gitlab-ci.yml
Created May 18, 2017 10:27
This is a .yml file to setup up ftp deployment in GitLab. Super awesome. Remember to set up the environmental variables.
deploy:
script:
- apt-get update -qq && apt-get install -y -qq lftp
- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnev --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
only:
- master
@oquirozm
oquirozm / include.js
Created March 31, 2018 23:06
Include scripts into Google Chrome console
(function () {
if (typeof window.R === 'undefined') {
var s = document.createElement('script');
s.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/ramda/0.17.1/ramda.min.js');
document.body.appendChild(s);
}
}());
@oquirozm
oquirozm / wait-for-element-in-dom.js
Created March 17, 2018 01:28
How to wait for an item to appear in the DOM
function try() {
if (!$("#element").size()) {
window.requestAnimationFrame(try);
}else {
$("#element").do_some_stuff();
}
};
@oquirozm
oquirozm / media_queries.scss
Created February 8, 2018 22:29
Sass Media Queries
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 15,
// font family with optional fallbacks
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
@oquirozm
oquirozm / gulpfile.js
Last active October 10, 2017 22:06
Gulp setup for WordPress Theme Development
// Gulp.js configuration
'use strict';
const
// source and build folders
gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
deporder = require('gulp-deporder'),