Skip to content

Instantly share code, notes, and snippets.

Genesis Guerrero Martinez gengue

Block or report user

Report or block gengue

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Aug 1, 2019
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:
@gengue
gengue / .babelrc
Created Feb 23, 2017 — forked from thejmazz/.babelrc
async/await with webpack+babel
View .babelrc
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@gengue
gengue / base.by
Last active Feb 11, 2017
Unescape special chars in Django VersatileImage
View base.by
#python3.5/versatileimagefield/datastructures/base.py
# -*- coding: utf-8 -*-
def retrieve_image(self, path_to_image):
"""Return a PIL Image instance stored at `path_to_image`."""
from urllib.parse import unquote
image = self.storage.open(unquote(path_to_image), 'rb')
file_ext = path_to_image.rsplit('.')[-1]
image_format, mime_type = get_image_metadata_from_file_ext(file_ext)
@gengue
gengue / rename.sh
Created Nov 15, 2016
Rename all files in a directory (BASH)
View rename.sh
for file in *_p.png
do
mv "$file" "${file/_p.png/_prueba.png}"
done
You can’t perform that action at this time.