Skip to content

Instantly share code, notes, and snippets.

View rich-97's full-sized avatar

Ricardo Moreno rich-97

View GitHub Profile
@rich-97
rich-97 / deploy_to_surge.yaml
Created April 29, 2021 13:27
Gh Action for Next.js App Deploy to surge
name: Deploy To Surge
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@rich-97
rich-97 / Padding.tsx
Last active October 28, 2020 19:17
React - Padding component
import styled from "styled-components";
interface Props {
top?: string;
right?: string;
left?: string;
bottom?: string;
all?: string;
}
@rich-97
rich-97 / Margin.js
Last active October 28, 2020 19:12
React - Margin Component
import PropTypes from 'prop-types';
import styled from "styled-components";
const Margin = styled.div`
${props => {
const { top, right, left, bottom } = props;
return `
margin: ${top} ${right} ${left} ${bottom};
`;
@rich-97
rich-97 / AvatarUpload.tsx
Created July 19, 2020 20:04
React - Avatar Upload with Ant Design
import React, { useState, useCallback } from 'react';
import { Avatar, Button, Upload } from 'antd';
import { DownloadOutlined, UserOutlined } from '@ant-design/icons';
import { fileToBase64 } from "../../utils";
interface Props {
label: string,
buttonText: string,
action: string,
avatarIcon?: React.ReactElement,
@rich-97
rich-97 / validators.js
Created July 19, 2020 07:39
Javascript - Validators
import moment from 'moment';
/**
* Validate if a string is valid or not.
*
* @param {string} stringToTest - The string to validate.
* @param {boolean} [allowEmpty=false] - If a empty string should be valid or not.
* @param {boolean} allowNull - Returns true if the value is null
* @returns {boolean} If the string is valid or not.
*/
@rich-97
rich-97 / git_alias.sh
Last active March 3, 2018 12:09
Common alias for Git.
alias gits='git status -s'
alias gitl='git log --oneline'
alias gitc='git commit -m'
alias gita='git add --all'
alias gitp='git push -u origin master'
alias gitd='git diff'
alias gitpl='git pull'
alias gitpb='git push origin'
@rich-97
rich-97 / data_upload.js
Created August 20, 2017 23:13
Data upload and print to the stdout with nodejs.
const http = require('http')
const server = http.createServer()
server.on('request', function (req, res) {
res.writeHead(200)
req.on('data', function (chunk) {
console.log(chunk.toString())
})
res.end()
@rich-97
rich-97 / echo.js
Created August 20, 2017 23:03
Echo server in nodejs.
const http = require('http')
const server = http.createServer()
server.on('request', function (req, res) {
req.pipe(res)
})
server.listen(8000)
@rich-97
rich-97 / file.js
Created August 20, 2017 06:49
Liltle snippets for webpack export single object.
module.exports = {}
// Resolve the problem with the context (is by webpack).
Object.keys(module.exports).forEach(function (key) {
if (typeof module.exports[key] === 'function') {
module.exports[key] = module.exports[key].bind(module.exports)
}
})