Skip to content

Instantly share code, notes, and snippets.

View fellipecaetano's full-sized avatar

Fellipe S. Scarpa Caetano fellipecaetano

  • Software Engineer @uber
  • Campinas, São Paulo, Brazil
View GitHub Profile
@objc protocol Migration {}
func printMigrations() {
var classCount: UInt32 = 0
let classList = objc_copyClassList(&classCount)!
for index in 0 ..< Int(classCount) {
if class_conformsToProtocol(classList[index], Migration.self) {
print(classList[index])
}
@fellipecaetano
fellipecaetano / Redux.swift
Last active January 15, 2018 20:08
Extending Redux with an effect system
/* Credits to @gsampaio for coming up with the Effect<S, A> type.
* Even though this flavor of reducer also describes side-effects,
* testing is still trivial since it's sufficient to check if the
* side-effects are of the right type. The actual execution of the
* effect can be tested separately using integration tests. */
import RxSwift
class Effect<S: Equatable, A: Action> {
open func execute(state: () -> S) -> Observable<A> {
@fellipecaetano
fellipecaetano / fact.mips
Last active March 22, 2018 02:57
Procedure that calculates the factorial of a number recursively, written in MIPS assembly
.text
.globl main
main:
add $a0, $zero, 8
jal fact
j exit
# int fact(int n) {
# if (n < 1) {
.text
.globl main
main:
addi $a0, $zero, 7
jal rot
j exit
rot:
# Check if $a0 < 2
#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "gurobi_c++.h"
using namespace std;
vector<vector<int>> read_input_file(char *input_file_name, int &number_of_employees, int &min_employees_per_group,
{
"experiment": "experiment_1",
"generations": {
"baseline": {
"mean": 280.1,
"stdev": 118.93337365273489
},
"variation": {
"mean": 275.15,
"stdev": 96.98251334512238
a = 0
for i from 1 to 3 // loop three times
{
a = a + i // add the current value of i to a
}
print a // the number 6 is printed (0 + 1; 1 + 2; 3 + 3)