Skip to content

Instantly share code, notes, and snippets.

View nuxlli's full-sized avatar
🎯
Focusing

Everton Ribeiro nuxlli

🎯
Focusing
View GitHub Profile
defmodule Web.Graphql.Types.Scalars.JSON do
@moduledoc """
The Json scalar type allows arbitrary JSON values to be passed in and out.
Requires `{ :jason, "~> 1.1" }` package: https://github.com/michalmuskala/jason
"""
use Absinthe.Schema.Notation
scalar :json_text, name: "Json" do
description("""
The `Json` scalar type represents arbitrary json string data, represented as UTF-8
@nuxlli
nuxlli / tags.gotemplate.yml
Last active April 3, 2019 20:24
Generate tags from a lista without create new lists
{{- define "tags" }}
{{- tmpl.Exec "tags_with_pt" (slice "" 0 .) }}
{{- end }}
{{- define "tags_with_pt" }}
{{- $prefix := (index . 0)}}
{{- $pt := (index . 1) }}
{{- $items := (index . 2)}}
{{- range $i, $item := $items }}
{{- if ge $i $pt }}
{{- if (eq (printf "%T" $item) "string") }}
@nuxlli
nuxlli / README.md
Last active February 5, 2019 18:07

EnvTools

Atenção: Este projeto não é uma ferramenta de configuração com base em variáveis de ambiente para [Elixir][elixir] por si só. Em geral este não é o caminho para configuração de aplicações [Elixir][elixir].

Este projeto reuni algumas ferramentas uteis para lidar com variáveis de ambiente:

  • Um suporte a carregamento e parse de arquivos [dotenv][dotenv]: EnvTools.load!
  • Um parse para formatos [dotenv][dotenv]: EnvTools.decode!
@nuxlli
nuxlli / index.js
Created December 5, 2017 19:19
requirebin sketch
const pathToRegexp = require('path-to-regexp');
const re = pathToRegexp('/:locale?', [], { end: false });
const pathname = "/pt-BR";
//const pathname = "/en/about";
const match = re.exec(pathname);
const [, locale] = match;
console.log({ pathname, match, locale });
@nuxlli
nuxlli / index.js
Last active November 25, 2017 19:16
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const languageCultures = require('language-cultures');
const _ = require('lodash');
function selectLanguage(availables, accepts, defaultLang = null) {
let common = _.intersection(accepts, availables);
@nuxlli
nuxlli / Butto.jsx
Created November 17, 2017 16:01
Extend material Button with Typescript
import * as React from 'react';
import { withStyles, WithStyles, StandardProps } from 'material-ui';
import MButton, { ButtonProps, ButtonClassKey } from 'material-ui/Button';
// import { compose } from 'recompose';
let styles = {
small: {
minWidth: 64,
minHeight: 32,
}
@nuxlli
nuxlli / rails_postgres_enum.rb
Last active July 30, 2020 15:48 — forked from fizz/rails_postgres_enum.rb
Support for PostgreSQL enum types in Rails 5 (including schema dump)
module ActiveRecord
class SchemaDumper
def dump(stream)
header(stream)
extensions(stream)
enums(stream)
tables(stream)
trailer(stream)
stream
end
@nuxlli
nuxlli / README.md
Created July 14, 2016 18:19
Testing `react-native` applications

Sobre

Não é simples fazer testes de aplicações react-native no device, por isso a maior parte das pessoas preferem testar separadamente os componentes (test unitários) usando o node.js e usar outras ferramentas para test de integração.

Dessa forma os testes unitários são como qualquer outro teste node.js. Você é livre para usar qualquer framework de testes, apesar da documentação oficial recomendar o uso do jest.

Pontos chave

  • Referências: Por se tratar de uma tecnologia em franca fase de desenvolvimento, muitas das referências para react-native estão desatualizadas ou imprecisas. Tome bastante cuidado principalmente no que se refere a syntax de ES5 e ES6;
import React, { PropTypes, Component } from 'react';
import KeyboardSpacer from 'react-native-keyboard-spacer';
import {
Animated,
Dimensions,
Image,
ListView,
Platform,
StyleSheet,
@nuxlli
nuxlli / replace_envs.js
Created May 13, 2016 03:47
Replace shell envs
// https://regex101.com/r/rK1eJ0/6
var regex_envs = /(\\*)(\$(?:(?:[=|-]?([A-Z0-9_]*[A-Z_]+[A-Z0-9_]*)|(?:{[=|-]?([A-Z0-9_]*[A-Z_]+[A-Z0-9_]*)}))))/g
function replaceEnvs(str, replace_for = "$1") {
return str.replace(regex_envs, (_match, slashs, v1, v2, v3) => {
if (slashs.length == 0 || slashs.length % 2 == 0) {
var value = v2 === undefined ? v3 : v2;
return `${slashs}${replace_for.replace("$1", value)}`;
} else if (slashs.length > 0) {
return `${slashs.slice(0,slashs.length-1)}${v1}`;