Skip to content

Instantly share code, notes, and snippets.

View barata0's full-sized avatar

Daniel Ribeiro barata0

  • Rio de Janeiro
View GitHub Profile
@barata0
barata0 / ClipList.vue
Created August 29, 2017 02:53
default CRUD vuex store array with samples for creating the modules and how to map module on view
// components/ClipList.vue
<template>
<div>
<h1>{{ clientid }}</h1>
Add: <input v-model="newClip.title" placeholder="Enter a title, then hit [enter]" @keyup.enter="tryCreateClip">
<br />Search: <input v-model="q" placeholder="Enter a title for search, and hit [enter]" @keyup.enter="trySearchClip">
<br />Result: {{searchResult}}
<div class="client">
<ul>
<li v-for="clip in clips">
@barata0
barata0 / UrlQueryStringParser.groovy
Created July 16, 2017 15:51
Groovy Url Query String Parser. accepts multiple keys (every key has an array as value) and accept a equal sign = on the query value (
def parseQuery(query) {query.split('&').collect{it.split('\\=', 2)}.groupBy{it[0]}.collectEntries{k, v ->[k, v.collect{it.size() == 2 ? it[1] : ''}]}}
// USAGE EXAMPLE BELOW (uncomment lines below to test)
// def query = 'orange=price=10&orange=color=red&edit&separator==========='
// def queryParameters = parseQuery(query)
// assert queryParameters.toString() == '[orange:[price=10, color=red], edit:[], separator:[==========]]'
// assert queryParameters.orange[0] == 'price=10'
// assert queryParameters.orange[1] == 'color=red'
@barata0
barata0 / proxy-server.js
Created December 14, 2016 17:15
A nodejs proxy server e.g. https to http
// To start
// node proxy-server.js REMOTE_ADDR PORT
// REMOTE_ADDR the remote address. eg. https://my-secure-site
// PORT port number to listen
var http = require('http');
var request = require('request');
var url = require('url')
@barata0
barata0 / java_pack_to_jar.bat
Created December 13, 2016 20:41
Altera as extensões dos arquivos .pack para .jar no pacote de instalação JAVA.
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
@barata0
barata0 / allow-s3-bucket.json
Created December 5, 2016 13:44
Allow Access to s3 specific Bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
@barata0
barata0 / .profile
Created July 18, 2016 14:45
Ubuntu bash with colors and path and ll alias
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
@barata0
barata0 / elasticsearch-reindex.groovy
Created June 15, 2016 17:51
Elasticsearch reindex groovy script. Read from oldServer/oldIndex/oldType/ and saves it on newServer/newIndex/newType
/*
* Reindex elasticsearch
* Read all documents from oldServer/oldIndex/oldType and put them into newServer/newIndex/newtype
* If the newIndex raises an error script will print and stop
*/
/* Configuration START */
// OLD Server config - READ_ONLY
def oldServer = "http://localhost:9200"
@barata0
barata0 / sub-directories-size-linux
Created April 11, 2016 14:42
sub directories size in linux
du -h --max-depth=1
@barata0
barata0 / sha256base64.groovy
Created April 5, 2016 22:41
generate a SHA256 encoded as Base64
@Grapes(
@Grab(group='commons-codec', module='commons-codec', version='1.10')
)
import java.security.*
import java.util.Base64;
def file = new File('c:/users/danielr/Downloads/mortalkombat.mp4')
FileInputStream fis = new FileInputStream(file);
def md5 = org.apache.commons.codec.digest.DigestUtils.sha256(fis);
fis.close()
println md5
@barata0
barata0 / Dockerfile
Created November 6, 2013 16:49
lxc-docker ubuntu tomcat7 apt-get install with oracle-java7-jdk
#
# Apache Tomcat7 installation
#
FROM danieltribeiro/oracle-java7-jdk
MAINTAINER Daniel Ribeiro <danieltribeiro@gmail.com>
RUN apt-get update
RUN apt-get -y install tomcat7