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
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)
{
"experiment": "experiment_1",
"generations": {
"baseline": {
"mean": 280.1,
"stdev": 118.93337365273489
},
"variation": {
"mean": 275.15,
"stdev": 96.98251334512238
#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,
.text
.globl main
main:
addi $a0, $zero, 7
jal rot
j exit
rot:
# Check if $a0 < 2
@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) {
@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> {
@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 / PHImageAssetLoader.swift
Created October 27, 2017 18:10
A loader for asset images
import Photos
import RxSwift
final class PHAssetImageLoader: ImageLoader {
func loadImage(with url: URL) -> Single<UIImage> {
return Single<UIImage>.create { observer in
let imageManager = PHImageManager.default()
var requestIdentifier: PHImageRequestID?
DispatchQueue.global(qos: .userInitiated).async {
@fellipecaetano
fellipecaetano / Networking.swift
Last active October 12, 2017 23:02
At attempt at solving networking. Just paste it inside an Xcode Playground and start from there.
import Foundation
struct HTTPRequest<T> {
let method: HTTPMethod
let path: String
let parameters: [String: Any]
let headers: [String: String]
let response: ExpectedHTTPResponse<T>
}
@fellipecaetano
fellipecaetano / duplicate_snapshots.py
Created September 21, 2017 17:15
Duplicate current set of snapshots, changing the versions on the copies
#!/usr/bin/env python3
import argparse
import glob
import shutil
import re
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--reference-image-folder',
dest='reference_image_folder')