Skip to content

Instantly share code, notes, and snippets.

View abner's full-sized avatar

Ábner Silva de Oliveira abner

View GitHub Profile
@abner
abner / http-file-upload.js
Created January 12, 2018 13:42
Node Http File Upload
var multiparty = require('multiparty');
var http = require('http');
var util = require('util');
http
.createServer(function(req, res) {
if (req.url === '/upload' && req.method === 'POST') {
// parse a file upload
var form = new multiparty.Form();
@abner
abner / vim.rc
Created October 21, 2017 11:23
vim.rc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@abner
abner / .tmux.conf
Created October 17, 2017 15:31 — forked from gblmarquez/.tmux.conf
.tmux.conf with fish as default shell
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# support logging out and back in
set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
# pbcopy support
set-option -g default-command "reattach-to-user-namespace -l bash"
# vi mode
@abner
abner / generate.js
Created September 29, 2017 00:57 — forked from mlynch/generate.js
Stencil component generator
/*
To setup, place in scripts/generate.js and add
"st:generate": "node scripts/generate.js"
To your npm scripts.
To generate a component in src/components/ run
npm run st:generate component my-component
@abner
abner / StateMachine
Created September 21, 2017 08:45 — forked from elandau/StateMachine
Rx based state machine
package com.netflix.experiments.rx;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.Observable.OnSubscribe;
@abner
abner / UUIDTest.java
Last active August 25, 2017 10:22
UUID GENERATION
package io.abner.vertx.errors;
import java.util.UUID;
import org.junit.Test;
import com.fasterxml.jackson.annotation.ObjectIdGenerators.UUIDGenerator;
import io.vertx.core.json.JsonObject;
@abner
abner / postgres_queries_and_commands.sql
Last active October 13, 2017 13:05 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@abner
abner / JSONB_POSTGRESQL_PARTIAL_UPDATE.sql
Created August 24, 2017 04:38
Postgresql - JSONB Operations
select * from tabela
/* UPDATE */
SELECT CONTEUDO->'ficha' from tabela WHERE ID=? FOR UPDATE /* BLOQUEIA A LINHA PARA ATUALIZACAO */;
/* OBTEM O INDICE * DO ITEM DA FICHA */
/* FAZ O JSON_B_SET */
UPDATE tabela SET CONTEUDO = JSONB_SET(CONTEUDO, '{ficha,?}'::text, ?::jsonb), ULTIMA_ATUALIZACAO_CONTEUDO=NOW() WHERE ID=? and (conteudo->'ULTIMA_ATUALIZACAO_CONTEUDO' IS NULL OR conteudo->'ULTIMA_ATUALIZACAO_CONTEUDO'=?);
@abner
abner / angular2-replace.ts
Created July 6, 2017 06:24 — forked from bhavik07/angular2-replace.ts
Another approach that can be used to create components that can replace there host elements, based on my SO question(http://stackoverflow.com/questions/34280475/remove-the-host-html-element-selectors-created-by-angular-component). Consider checking this http://plnkr.co/edit/LFKN5doI9Y9wKwPxBbcJ?p=preview
/// <reference path="../node_modules/angular2/core.d.ts" />
/// <reference path="../node_modules/angular2/platform/browser.d.ts" />
/// <reference path="../node_modules/angular2/common.d.ts" />
import { Component, View, Directive, Input, ElementRef, Output, EventEmitter } from 'angular2/core';
import { bootstrap } from 'angular2/platform/browser';
//remove the host of avatar to be rendered as svg
@Directive({
@abner
abner / mdeditor.html
Created May 18, 2017 16:02 — forked from DerekTBrown/mdeditor.html
Simple Markdown Editor with Angular2
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<textarea #simplemde></textarea>