Skip to content

Instantly share code, notes, and snippets.

@gengue
gengue / .babelrc
Created February 23, 2017 22:19 — forked from thejmazz/.babelrc
async/await with webpack+babel
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@gengue
gengue / focus.directive.js
Last active September 12, 2017 20:28
Focus directive angularjs
angular.module('app.layouts').directive('focusMe',
function($timeout, $parse) {
return {
link: function(scope, element, attrs) {
var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
@gengue
gengue / instagramPhotoDownloader.js
Last active September 18, 2017 13:23
How download all your photos from instagram
/*
* 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);
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 / ClickOutside.js
Last active April 11, 2019 16:25
React component: detect when focus has been lost
import React, { useRef, useEffect } from 'react';
/**
* Example:
* const [open, setOpen] = useState(false);
* ...
* <ClickOutside onBlur={() => setOpen(false)}>
* <MyDropdown open={open}/>
* </ClickOutsie>
*/
@gengue
gengue / init.vim
Created May 2, 2020 03:06
My Neovim config
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 / index.js
Created July 3, 2020 23:20
Import trello list to wikijs
/*
* 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 / cookie-manager.html
Created October 26, 2020 15:58
Set cross domain cookies with Single Page Applications
@gengue
gengue / FuzzySearchDemo.js
Last active October 29, 2021 22:31
React hook to filter a list using local state and Fuse.js Demo: https://codesandbox.io/s/tender-stallman-qi1gl?fontsize=14
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 / setup_keyboard_for_vim.sh
Last active December 1, 2021 21:28
Keyboard settings for vim in Mac OS X + Iterm2
defaults write org.vim.ITerm ApplePressAndHoldEnabled -bool false
defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
# restart