Skip to content

Instantly share code, notes, and snippets.

Avatar

Genesis Guerrero Martinez gengue

View GitHub Profile
@gengue
gengue / Caddyfile
Created Aug 1, 2020
Caddy server automatic HTTPS for localhost - API + frontend using reverse proxy
View Caddyfile
# https://medium.com/@devahmedshendy/traditional-setup-run-local-development-over-https-using-caddy-964884e75232
# 1. sudo pacman -S mkcert
# 2. mkdir ./certs && cd ./certs
# 3. mkcert "*.sqila.local"
# 4. new line /etc/hosts/ -> 127.0.0.1 backend.sqila.local app.sqila.local
backend.sqila.local {
tls ./certs/_wildcard.sqila.local.pem ./certs/_wildcard.sqila.local-key.pem
reverse_proxy localhost:1337 {
header_up Host {host}
@gengue
gengue / index.js
Created Jul 3, 2020
Import trello list to wikijs
View index.js
/*
* Get started
* 1. create a folder and run `npm init`
* 2. run `npm install graphql-request slugify`
* 3. copy this file inside the folder
* 4. edit config (trello json, API_KEY, SOURCE_LIST, TARGET_PATH, etc...)
* 5. run `node index.js`
*/
const { GraphQLClient } = require("graphql-request");
const slugify = require("slugify");
@gengue
gengue / init.vim
Created May 2, 2020
My Neovim config
View init.vim
set path+=**
set nocompatible " be iMproved, required
filetype off " required
let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3.8'
" -----------------------------------------------------------------------------
"
" Plugins list
@gengue
gengue / FuzzySearchDemo.js
Last active Sep 20, 2019
React hook to filter a list using local state and Fuse.js Demo: https://codesandbox.io/s/tender-stallman-qi1gl?fontsize=14
View FuzzySearchDemo.js
import React, { useState } from "react";
import ReactDOM from "react-dom";
import useFuzzySearch from "./useFuzzySearch";
const persons = [
{ id: 1, name: "genesis" },
{ id: 2, name: "jose" },
{ id: 3, name: "mauro" },
{ id: 4, name: "fredo" },
{ id: 5, name: "meggie" },
@gengue
gengue / ClickOutside.js
Last active Apr 11, 2019
React component: detect when focus has been lost
View ClickOutside.js
import React, { useRef, useEffect } from 'react';
/**
* Example:
* const [open, setOpen] = useState(false);
* ...
* <ClickOutside onBlur={() => setOpen(false)}>
* <MyDropdown open={open}/>
* </ClickOutsie>
*/
View deferComponentRender.js
import hoistStatics from 'hoist-non-react-statics';
import React from 'react';
/**
* Allows two animation frames to complete to allow other components to update
* and re-render before mounting and rendering an expensive `WrappedComponent`.
*/
export default function deferComponentRender(WrappedComponent) {
class DeferredRenderWrapper extends React.Component {
constructor(props, context) {
@gengue
gengue / instagramPhotoDownloader.js
Last active Sep 18, 2017
How download all your photos from instagram
View instagramPhotoDownloader.js
/*
* Download as plain file
* @param {String} filename
* @param {String} text data
*/
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
@gengue
gengue / index.html
Last active Apr 28, 2017
Facebook page autolike
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>AutoLike Test</title>
<style type="text/css" media="screen">
#iframe-wrapper {
overflow: hidden;
width: 10px;
@gengue
gengue / serializers.py
Last active Jul 13, 2020
Django Rest Framework user endpoint with change password
View serializers.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from rest_framework import serializers
from .models import User
class UserSerializer(serializers.ModelSerializer):
"""
User accounts serializer
@gengue
gengue / ordering.py
Created Mar 16, 2017
Performance benchmark Bubble vs Quicksort
View ordering.py
import random
import time
def quicksort(items):
lowest = []
equal = []
greater = []
if len(items) > 0:
You can’t perform that action at this time.