Skip to content

Instantly share code, notes, and snippets.

View leo-bianchi's full-sized avatar

Leo Bianchi leo-bianchi

  • Alpar Service
  • São Paulo, SP
View GitHub Profile
@leo-bianchi
leo-bianchi / migrate_to_gogs.sh
Last active May 21, 2019 20:31
Bash script to migrate repositories on GitHub to Gogs
# vim: syntax=bash
#!/usr/bin/env bash
## You will need a .csv with comma-separated values (you can change the separator on awk -F 'separator' line) file with the repo name to Gogs, the GitHub url and a description to your new Gogs repo
## Example: repo,https://github.com/gogs/go-gogs-client.git,My description
## To find your Gogs token (if you already created one on your Gogs cliente) you can run this command on Terminal:
## curl -u 'myuser' mygogsurl/api/v1/users/myuser/tokens
## You will receive a json output, and then, copy the token and paste on 'GOGS_TOKEN' variable replancing '#' symbol
@leo-bianchi
leo-bianchi / gogs
Created December 12, 2018 14:28 — forked from erlhermit/gogs
#! /bin/sh
### BEGIN INIT INFO
# Provides: gogs
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Git repository manager Gogs
# Description: Starts and stops the self-hosted git repository manager Gogs
### END INIT INFO
@leo-bianchi
leo-bianchi / fill.py
Created May 21, 2019 20:33
Pandas fill NaN values on csv file#python #pandas
# Preenche as linhas NaN com 0 para fazer a converão de tipos
final[['fone1', 'ddd']] = final[['fone1', 'ddd']].fillna(
'0').astype(float).astype(int).astype(str)
# Substitui as linhas com 0 por None(nulo)
final['fone1'] = final['fone1'].replace({'0': None})
@leo-bianchi
leo-bianchi / create_repo.sh
Last active May 23, 2019 15:18
Consuming Github API to create remote REPO #bash #github
#!/bin/bash
# Create a remote repository using github API
read -p "Type the repo name, and press [ENTER]:" repo_name
read -p "Type repo description, and press [ENTER]:" repo_desc
printf "REPOSITORY NAME: $repo_name\nREPOSITORY DESCRIPTION: $repo_desc\n"
# Confirmation
@leo-bianchi
leo-bianchi / client.js
Created June 4, 2019 18:27
Catalog Client Script and Script Include
function onLoad() {
var ga = new GlideAjax('GetUserData');
ga.addParam('sysparm_name', 'getData');
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
@leo-bianchi
leo-bianchi / README-Template.md
Created June 6, 2019 19:07 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@leo-bianchi
leo-bianchi / buildJsonTemplate.js
Created November 4, 2019 17:24
Build a custom object from another object.
/**
* Build a custom json template from another json.
*
* @param {Object} myObject - Object to be build
* @returns {Object} Builded JSON
* @module buildJson
*/
function buildJson(myObject) {
myObject = Object.keys(myObject).map(function(key, index) {
let newObject = {
@leo-bianchi
leo-bianchi / fixStr.js
Created November 4, 2019 17:36
Javascript function to remove accents, broken characters, special characters and blank spaces.
/**
* Normalize strings to a custom pattern, tempplate
*
* @param {string} myStr - String to be normalized
* @returns {string} Normalized string
*/
function fixStr(myStr) {
return myStr.normalize('NFD')
.replace(/\uFFFD/g, '')
.replace(/[\u0300-\u036f]/g, '')
@leo-bianchi
leo-bianchi / arrayToObject.js
Last active November 4, 2019 18:32
Constructs an object from a array, using even indexes as key and odd indexes as value
/**
* Constructs an object from a array, using even indexes as key and odd indixes as value
*
* @param {Array} myArray - Array to be transformed
* @returns {Object}
*/
function toObject(myArray) {
let r = {};
for (let i = 0; i < myArray.length; i += 2) {
let key = (myArray[i]),
@leo-bianchi
leo-bianchi / index.js
Last active November 21, 2019 17:34
Javascript ES6 (ES0215) .map(), .reduce(), .filter() usage examples.
// FILTER
/*
If i already have an array but i only want to have items in the array that match certain criteria, use the filter.
Quando eu já tenho um array e quero apenas itens no novo array que correspondem a uma condição, use filter.
*/
// GET JUST EVEN NUMBERS
let arr = [-200, -163, -26, -4, 0, 7, 76];