Skip to content

Instantly share code, notes, and snippets.

View xlbruce's full-sized avatar
💭
Adena plz

Gilson de Paula xlbruce

💭
Adena plz
View GitHub Profile
@xlbruce
xlbruce / Post in Blogger.txt
Last active June 11, 2017 03:56
Simple workflow description describing how to insert a new post using Blogger API v3.
Create a post flow:
1- Generate an access token:
//TODO search how to do this programmatically
2- Send a request to blogger with post content
URI: https://www.googleapis.com/blogger/v3/blogs/$blogId/posts
Header:
@xlbruce
xlbruce / Git blame original author
Created April 20, 2017 14:11
Show the original author of lines using git log
git log -p -M --follow --stat -- path/to/your/file
@xlbruce
xlbruce / dump.sh
Created February 19, 2018 18:09
This script makes a dump from a given database ignoring unwanted content from certain tables, like histories and orders.
#!/bin/bash
tmpFile1=~/.tmp1$$
tmpFile2=~/.tmp2$$
database=$1
database_local=$2
function cleanFiles() {
rm $tmpFile1 $tmpFile2 > /dev/null 2>&1;
exit;
@xlbruce
xlbruce / last-pom.sh
Created February 19, 2018 18:45
Check pom latest version for a directory based project
#!/bin/bash
# set -x
SNAPSHOT_REPO="http://nexus.clickbus.net:8081/nexus/content/repositories/snapshots2/com/clickbus/platform"
RELEASE_REPO="http://nexus.clickbus.net:8081/nexus/content/repositories/releases/com/clickbus/platform"
function getCurrentDir() {
local dir=`pwd`;
echo `basename $dir`;
}
@xlbruce
xlbruce / test.txt
Last active July 6, 2018 15:40
Usage: python translate_words.py <input_file> <output_file>
{
"1": "Crate",
"2": "Cave Entrance",
"3": "Door",
"5": "Broken multicannon",
"6": "Dwarf multicannon",
"7": "Cannon base",
"8": "Cannon stand",
"9": "Cannon barrels",
"11": "Ladder",
@xlbruce
xlbruce / ansible.cfg
Last active July 16, 2018 23:21
Ansible initial config example
# vim: ft=ansible_hosts
[defaults]
ansible_python_interpreter = /usr/bin/env python
ansible_managed = Ansible Managed. Please refrain from making manual changes.
host_key_checking = False
accept_hostkeys = yes
remote_user = admin
hash_behaviour = merge
retry_files_enabled = False
roles_path = roles
@xlbruce
xlbruce / csv_to_json_post.py
Last active August 7, 2018 16:35
Convert reference prices in csv to json
import csv
import json
import sys
# Example csv file:
#originPlaceId;destinationPlaceId;travelCompanyId;serviceClassId;price;active;clientIds/0;clientIds/1;clientIds/2;clientIds/3;clientIds/4;clientIds/5
#3827;3022;35;1;416.55;VERDADEIRO;1;2;3;10013;10014;10015
try:
@xlbruce
xlbruce / app.service
Created August 14, 2018 13:36
Systemd service template
[Unit]
Description=My Service Name
After=network.target
[Service]
Type=simple
User=<user>
Group=<group>
WorkingDirectory=/opt/app
ExecStart=/bin/ls -lh
@xlbruce
xlbruce / async_playbook.yml
Created September 5, 2018 17:06
Run arbitrary async commands
---
- name: Run async tasks
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Sleep 2 times
shell: /bin/sleep 5
async: 10000
poll: 0
@xlbruce
xlbruce / pricing.py
Last active October 26, 2018 19:39
Save EC2, RDS and ElastiCache prices into csv files.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import boto3
import csv
import json
import locale
import os
locale.setlocale(locale.LC_ALL,'')