Skip to content

Instantly share code, notes, and snippets.

View mangar's full-sized avatar
:octocat:
Working from home

Marcio Mangar mangar

:octocat:
Working from home
View GitHub Profile
@mangar
mangar / ubuntu_change_date
Created January 10, 2018 11:56
How to change date and time on Ubuntu - The best way
ntpdate -s ntp.ubuntu.com
dpkg-reconfigure tzdata
@mangar
mangar / docker_time_sync.sh
Created April 28, 2017 14:27
Docker - Problems with Time sync - Americas/Sao_Paulo
# Define America/Sao_Paulo
echo America/Sao_Paulo >/etc/timezone; dpkg-reconfigure -f noninteractive tzdata
# Sync clock
docker run --rm --privileged mangar/rails-pg:5.0.2.1 hwclock -s
echo "Enjoy!"
@mangar
mangar / codigo.gs
Created January 24, 2017 12:20
[Google Drive - Spreadsheet] Read spreadsheet (+ tabs) compose and send email...
/**
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 2; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 2)
// Fetch values for each row in the Range.
@mangar
mangar / pipes.truncate.ts
Created October 5, 2016 18:22
Truncate Pipe for Angular2
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'truncate'})
export class Truncate implements PipeTransform {
transform(value: string, args: string[]) : string {
let limit = args.length > 0 ? parseInt(args[0], 10) : 10;
let trail = args.length > 1 ? args[1] : '...';
return value.length > limit ? value.substring(0, limit) + trail : value;
}
}
@mangar
mangar / nginx.conf
Created May 11, 2016 20:24
Nginx config upstream. Reverse proxy for docker + ngrok
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@mangar
mangar / MyArray.swift
Created March 14, 2016 14:56
Shuffle an array - Swift
import Foundation
extension Array {
func shuffle() -> Array {
var result = Array(self)
result.shuffleInPlace()
return result
}
@mangar
mangar / action_controller.rb
Created December 31, 2015 14:50
Formatar numero (Rails) em valor monetário (R$) ... dentro de um controller, por exemplo
def formatar_valor_BRL(valor)
ActionController::Base.helpers.number_to_currency(valor, :unit => "R$ ", :separator => ",", :delimiter => ".")
end
@mangar
mangar / helper.rb
Created December 31, 2015 14:49
Formatar numero (Rails) em valor monetário (R$)
def number_to_currency_br(number)
number_to_currency(number, :unit => "R$ ", :separator => ",", :delimiter => ".")
end
@mangar
mangar / DAO.java.java
Created October 17, 2015 23:31
AbstractDAO
import java.util.List;
import java.util.Map;
public interface DAO {
public Boolean save(Map<?, ?> param);
public List<?> getAll();
}
#!/usr/bin/env ruby
#
require 'fileutils'
puts "Started @ #{Time.now}"
starting_point = "./output"
structure_count = 282344