Skip to content

Instantly share code, notes, and snippets.

View jcmartins's full-sized avatar

João Carlos Martins jcmartins

View GitHub Profile
@jcmartins
jcmartins / config.json
Created December 29, 2017 14:49
powerline config
cat ~/.config/powerline/config.json
{
"ext": {
"shell": {
"colorscheme": "solarized",
"theme": "default_leftonly"
}
}
}
@jcmartins
jcmartins / ifName
Created July 12, 2017 14:21
prometheus select pppoe
ifName{ifDescr="ether1",ifName="ether1",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="ether2",ifName="ether2",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="ether3",ifName="ether3",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="ether4",ifName="ether4",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="ether5",ifName="ether5",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="bridge1",ifName="bridge1",instance="192.168.12.1",job="snmp"} 1
ifName{ifDescr="<pppoe-honda>",ifName="<pppoe-honda>",instance="192.168.12.1",job="snmp"}
ifName{ifDescr="<pppoe-jmartins>",ifName="<pppoe-honda>",instance="192.168.12.1",job="snmp"}
import { FormControl } from '@angular/forms';
import { Component, EventEmitter, OnInit, Input, Output } from '@angular/core';
/*
Generated class for the NumberPicker component.
See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html
for more info on Angular 2 Components.
*/
@Component({
@jcmartins
jcmartins / ssh.go
Created December 27, 2016 18:56
ssh client
package main
import (
"bufio"
"fmt"
"golang.org/x/crypto/ssh"
"log"
"os"
"time"
)
set nocompatible " be iMproved, required
filetype off " required
filetype plugin indent on
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternat
@jcmartins
jcmartins / embaralha.go
Created March 8, 2016 18:37
embaralha.go
func main() {
names := []string{"joao", "alex", "ze", "gleicon", "mane", "maria"}
fmt.Printf("names : %v\n", names)
shuffleList := names
shuffle(shuffleList)
fmt.Printf("Shuffled : %v\n", shuffleList)
}
func shuffle(arr []string) {
rand.Seed(int64(time.Now().Nanosecond())) // no shuffling without this line
@jcmartins
jcmartins / gist:9e71c895d99090fb40cf
Created February 5, 2016 16:13
Work with Duplicate lines inside a text file
awk '!seen[$0]++' filename
or
sort -u -o filename1.txt filename2.txt
write dup files into text file
sort file1.txt file2.txt | uniq -d > duplicity.txt
@jcmartins
jcmartins / compare files
Created January 19, 2016 18:19
Compare CSR, KEY and CRT to ensure that matches:
Compare CSR, KEY and CRT to ensure that matches:
openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5
@jcmartins
jcmartins / bash
Created January 5, 2016 19:41
List all running containers’ sizes and volumes:
for d in `docker ps | awk '{print $1}' | tail -n +2`; do
d_name=`docker inspect -f {{.Name}} $d`
echo "========================================================="
echo "$d_name ($d) container size:"
sudo du -d 2 -h /var/lib/docker/devicemapper | grep `docker inspect -f "{{.Id}}" $d`
echo "$d_name ($d) volumes:"
docker inspect -f "{{.Volumes}}" $d | sed 's/map\[//' | sed 's/]//' | tr ' ' '\n' | sed 's/.*://' | xargs sudo du -d 1 -h
done
@jcmartins
jcmartins / gem install nokogiri
Last active January 14, 2016 14:12
gem install nokogiri
Using system library
gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2/