Skip to content

Instantly share code, notes, and snippets.

View schettino's full-sized avatar

Matheus Schettino schettino

View GitHub Profile
@schettino
schettino / golang_job_queue.md
Created May 9, 2016 11:06 — forked from harlow/golang_job_queue.md
Job queues in Golang
@schettino
schettino / update-dokku-stack.sh
Created June 7, 2016 17:44 — forked from egerlach/update-dokku-stack.sh
Update stack underlying apps running on dokku
#!/bin/bash
# before you can use this, you need to run (as root):
# git clone https://github.com/tt/stack-images.git /root/stack-images
# git clone https://github.com/gliderlabs/herokuish.git /root/herokuish
# First, we need to get our base ubuntu images up to date
docker pull ubuntu-debootstrap:14.04
docker pull ubuntu:trusty # for postgresql
@schettino
schettino / dfs-bfs-non-recursive.js
Created August 23, 2016 17:53 — forked from DmitrySoshnikov/dfs-bfs-non-recursive.js
Non-recursive DFS and BFS algorithms
/**
* Depth-first and Breadth-first graph traversals.
*
* In this diff we implement non-recursive algorithms for DFS,
* and BFS maintaining an explicit stack and a queue.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style license
*/
@schettino
schettino / prim.py
Created September 21, 2016 15:54 — forked from siddMahen/prim.py
Prim's algorithm, in Python.
from sys import argv
import re
# open the file and get read to read data
file = open(argv[1], "r");
p = re.compile("\d+");
# initialize the graph
vertices, edges = map(int, p.findall(file.readline()))
graph = [[0]*vertices for _ in range(vertices)]
@schettino
schettino / prims.js
Created September 26, 2016 13:26 — forked from methodin/prims.js
Prim's Algorithm
// Represents an edge from source to sink with capacity
var Edge = function(source, sink, capacity) {
this.source = source;
this.sink = sink;
this.capacity = capacity;
};
// Main class to manage the network
var Graph = function() {
this.edges = {};
@schettino
schettino / introrx.md
Created November 30, 2016 11:40 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@schettino
schettino / .bash_profile
Created July 26, 2017 12:59 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@schettino
schettino / flask skeleton folder tree
Created October 26, 2017 21:29 — forked from efazati/Py Flask Skeleton
flask folders and files structure
.
├── deploy.py
├── project
│   ├── application.py
│   ├── apps
│   │   ├── articles
│   │   │   ├── forms.py
│   │   │   ├── __init__.py
│   │   │   ├── models.py
│   │   │   └── views.py
@schettino
schettino / api.py
Created October 27, 2017 14:25 — forked from alanhamlett/api.py
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort
@schettino
schettino / useUserReducer.ts
Created March 30, 2019 20:23
Better Reducers with React and Typescript 3.4
import { useReducer } from 'react'
export function updateName(name: string) {
return <const>{
type: 'UPDATE_NAME',
name
}
}
export function addPoints(points: number) {