Skip to content

Instantly share code, notes, and snippets.

View fael's full-sized avatar

Rafael Santos Sá fael

  • OLX
  • Lisbon, Portugal
View GitHub Profile
@fael
fael / custom-storage-exchange.ts
Last active October 7, 2021 14:53
If I ever need to make an exchange to let urql have a custom cache storage
/* eslint-disable no-return-assign */
import type {
StorageAdapter,
SerializedEntries,
SerializedRequest,
} from "@urql/exchange-graphStorage";
// OR redis?
let cache = {};
@fael
fael / osx-setup.sh
Last active February 5, 2019 03:13
OSX setup
# operation system
brew install wget zsh xcv exa ccat lua
# xcv = copy/cut/paste tool
# exa = better ls
# ccat = better cat
touch ~/.rafaelrc
echo 'source ~/.rafaelrc' >> .zshrc
@fael
fael / post-checkout
Last active November 14, 2018 14:45 — forked from flesler/post-checkout
git hook to run a command after `git pull` and `git checkout` if a specified file was change for example, package.json
#!/usr/bin/env bash
# fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run package.json "npm prune && npm install"
@fael
fael / list.md
Last active November 14, 2018 11:42
Awesome NPX
@fael
fael / README.md
Created September 24, 2017 01:38
Fat arrow / ligature in Fira Code font for Visual Studio
  1. Install this VSCode Extension https://marketplace.visualstudio.com/items?itemName=be5invis.vscode-custom-css

  2. Create a CSS in a place like so ~/Users/you/vscode.css

  3. Paste the lines of file below

  4. Go to Settings to change some settings like so:

    "editor.fontLigatures": true, "editor.fontFamily": "Operator Mono", "editor.fontSize": 13, "vscode_custom_css.imports": [ "file:///Users/rafael/vscode.css"

@fael
fael / App.js
Created September 22, 2017 16:28
Async Component Loading for React
// @flow
import React, { Component } from 'react'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import asyncComponent from './asyncComponent'
const MyAwesomePage = asyncComponent(() => import('./MyAwesomePage'))
/**
* Main Component, displays App Shell UI, setup routes which are dynamically loaded
*/
// bling.js
var $ = window.$ = document.querySelector.bind(document);
var $$ = window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = NodeList.prototype.addEventListener = (function(name, fn) {
this.forEach(function(elem) {
elem.on(name, fn);
@fael
fael / functions.php
Created August 14, 2013 05:16
Get adjacent posts from a term of a custom taxonomy
<?php
function next_prev_portfolio($post, $current_term){
//echo '<pre>';
$postlist_args = array(
'posts_per_page' => -1,
//'orderby' => 'menu_order title',
//'order' => 'ASC',
'post_type' => 'portfolio',
'portfolio_category' => $current_term
);
@fael
fael / crontab
Created March 13, 2013 14:21
Auto-deployment.
*/15 * * * * sh /home/rafael/projects/deployment/deploy-projects