Skip to content

Instantly share code, notes, and snippets.

View Mardiniii's full-sized avatar

Sebastian Zapata Mardini Mardiniii

View GitHub Profile
@Mardiniii
Mardiniii / finance_script_tools.md
Last active December 26, 2017 14:35
In this gist you will find the main scripts used by the finance team in its daily workflow. Feel free to add any comment or question.

Why we are doing this?

We want to have a centralized source where any person from the finance team or the product department can find easy and fast the scripts and code related to the tasks from our team.

What do you need?

You will need access to the staging and production consoles, if you are not available to got into this enviroments talk to the Systems Team in #dev-systems Slack channel.

Invoice Generation

If you want to see the current implementation for this process you can check this Flow Diagram any comment about this process ask in #dev-finance Slack channel.

For global - All agencies

@Mardiniii
Mardiniii / sudoku_solver.go
Last active April 15, 2018 16:44
Snippet for medium post
// Solve algorithm
func (s *Sudoku) Solve() bool {
// Find the next pending position in the board
pending, row, col := s.pendingPositions()
// If there aren't more pending positions we did
// and the problem is solved
if !pending {
return true
}
// If not, let's try to find a solution for the pending position
@Mardiniii
Mardiniii / concurrent_factorial.go
Last active April 15, 2018 16:46
Snippet for medium post
package main
import "fmt"
// Factorial recursive function to find the factorial result
// using go routines and the channel passed as parameter
func Factorial(number int, product int, ch chan int) {
// Calculate the product until this point
product = product * number
@Mardiniii
Mardiniii / concurrent_sudoku_solve.go
Last active April 15, 2018 16:50
Code snippet for medium post
// Solve algorithm
func Solve(grid [N][N]int) (bool, [N][N]int) {
ch := make(chan [N][N]int)
pending, row, col := pendingPositions(grid)
if !pending {
fmt.Println("Solve calls:", count)
return false, grid
}
@Mardiniii
Mardiniii / concurrent_sudoku_recursiveSolution.go
Last active April 15, 2018 16:51
Code snippet for medium post
func recursiveSolution(grid [N][N]int, ch chan [N][N]int) {
pending, row, col := pendingPositions(grid)
if !pending && CheckBoard(grid) {
ch <- grid
close(ch)
return
}
for i := 1; i <= 9; i++ {
@Mardiniii
Mardiniii / tcp_server.go
Created April 16, 2018 15:51
TCP server with HTTP protocol using Golang
package main
import (
"fmt"
"net"
"os"
)
const (
CONN_HOST = "localhost"
@Mardiniii
Mardiniii / channels_solution.go
Created April 17, 2018 20:48
Fix race data races and race conditions with mutex and channels in Go
package main
import (
"fmt"
"sync"
)
// ChannelsSolution uses a buffered channel with capacity of one
// in order to avoid data races from the go routines trying to increase
// the counter
@Mardiniii
Mardiniii / searchFormHandler.js
Last active April 30, 2018 05:39
Code snippet for medium post
$(document).ready(function() {
function parseResponse(resultsContainer, data) {
console.log(data);
const resultsAmount = data.pages.length
$(resultsContainer).html('');
if (resultsAmount > 0) {
$.each(data.pages, function(index, page) {
appendToResults(resultsContainer, page)
setResultsTitle(resultsAmount + " results found it for: " + data.input, 'green')
@Mardiniii
Mardiniii / data_replication_problem.rb
Last active May 24, 2018 18:56
1st approach to solve data replication problem using Ruby.
require 'minitest/autorun'
# Problem
# https://softwareengineering.stackexchange.com/questions/153806/conflict-resolution-for-two-way-sync
# interface DB {
# String Get(String)
# void Set(String, String)
# []String Keys()
#
@Mardiniii
Mardiniii / srp.rb
Created May 28, 2018 20:38
Single Responsability Principle: A class should have one and only one reason to change, meaning that a class should have only one job.
# Violates SRP
class Invoice
def initialize(items, client)
@items = items
@client = client
@total = 0
end
def generate