Skip to content

Instantly share code, notes, and snippets.

@lucaslugao
lucaslugao / binarysearch.js
Last active June 5, 2021 14:48
Binary Search script for MPV
this.states = [{ left: 0, cur: 50, right: 100 }];
function printState(state) {
var line = "";
var width = 79;
var round = function (v) {
return Math.floor((v * width) / 100);
};
var visMap = {};
visMap[round(state.left)] = "[";
const assert = require("assert");
c0 = (s, z) => z;
succ = n => (s, z) => s(n(s, z));
add = (x, y) => (s, z) => x(s, y(s, z));
mul = (x, y) => (s, z) => x(z => y(s, z), z);
T = (x, y) => x;
F = (x, y) => y;
and = (a, b) => a(b, F);
or = (a, b) => a(T, b);
@lucaslugao
lucaslugao / gitlab-force-checkout.sh
Last active April 25, 2019 19:25
Simulate a checkout of a detached commit in the gitlab upstream
#!/bin/bash
#
# Simulate a checkout of a detached commit in the gitlab upstream
#
# Usage
# $ gitlab-force-checkout COMMIT_HASH
set -e
if [ ! -z "$(git status --porcelain)" ]; then
template<typename T>
auto DummyFirstArgument(T&& f)
{
return [&](auto dummy, auto ...x){ return f(x...); };
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucaslugao
lucaslugao / jl.sh
Last active November 27, 2017 12:41
JupyerLab Launch Script
#!/bin/bash
original_path=$(pwd)
cd "$(dirname "$0")"
##PARAMETERS
port=5656
user=lucas.lugao-guimaraes
host=cuboide.polytechnique.fr
##CONFIG AUTODETECTION
hostname=$(hostname)
#!/usr/bin/env python
from functools import partial
def main():
"""
Main function
"""
A = list(range(10))
@lucaslugao
lucaslugao / .mintty
Created August 27, 2017 17:36
Mintty vscode theme
BoldAsFont=-1
Font=Consolas
FontHeight=11
ForegroundColour=204,204,204
BackgroundColour=30,30,30
CursorColour=204,204,204
Black=30,30,30
BoldBlack=102,102,102
Gray=255,0,0
BoldGray=0,0,255
@lucaslugao
lucaslugao / reverse_list.cpp
Created February 13, 2017 16:13
reverse_list
void reverse_list(Node* head) {
//Make sure we are not trying to reverse an empty list or a singleton
if (head != NULL && head->next != NULL) {
Node* curr = head;
Node* next = head->next;
Node* nextNext = NULL;
//Initial state
//[0] -> [1] -> [2] -> ... -> [n] -> NULL
//head next