Skip to content

Instantly share code, notes, and snippets.

nbro

Block or report user

Report or block nbro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS.md

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

Steps:

  1. Open VirtualBox
  2. Right-click your VM, then click Settings
  3. Go to Shared Folders section
  4. Add a new shared folder
  5. On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
@nbro
nbro / mnist_example.py
Last active Jan 5, 2019
PyTorch example to train a CNN on MNIST using VisualDL for logging
View mnist_example.py
# It takes about 8 minutes to train this model and obtain 99% accuracy.
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import time
import datetime
import argparse
@nbro
nbro / game-tree.tex
Created Oct 21, 2018
Game tree template to be included in main.tex
View game-tree.tex
\def\alphabetadiagram{
\begin{tikzpicture}[-, >=stealth', level/.style={sibling distance = 8cm/#1, level distance = 2cm}]
\node [circle_node] (A) {$+$}
child { node [square_node] (B) {-}
child { node [circle_node] (E) {+}
child { node [square_node] (L) {-}
child [sibling distance = 1cm] { node [circle_node] (V) {$7$} }
child [sibling distance = 1cm] { node [circle_node] (W) {$4$} }
}
@nbro
nbro / main.tex
Created Oct 21, 2018
Main file which imports the template in the file game-tree.tex
View main.tex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[margin=0.6in]{geometry}
% Define a few styles for the nodes
\tikzset{
tree_node/.style = {align=center, inner sep=0pt, text centered, font=\sffamily},
square_node/.style = {tree_node, rectangle, draw=black, minimum width=1.5em, minimum height=1.5em, very thick},
@nbro
nbro / template.tex
Created Oct 21, 2018
Code to be made a template
View template.tex
\begin{tikzpicture}[-, >=stealth', level/.style={sibling distance = 8cm/#1, level distance = 2cm}]
\node [circle_node] (A) {$+$}
child { node [square_node] (B) {-}
child { node [circle_node] (E) {+}
child { node [square_node] (L) {-}
child [sibling distance = 1cm] { node [circle_node] (V) {$7$} }
child [sibling distance = 1cm] { node [circle_node] (W) {$4$} }
}
child { node [square_node] (M) {-}
child [sibling distance = 1cm] { node [circle_node] (X) {$2$} }
View channel-op-cheatsheet.md

channel operator quick reference

direct discussion about administrative action away from the main channel and into #reddit-diabetes-ops to minimise disruption. our -ops channel is the place where users should come to ask for our help. examples:

  • any sort of operator request or discussion of channel administration in the main channel
  • PMs asking why a ban was set
  • reports of harassment (unless the user is confiding in you)
  • any request for operator action

changing channel access permissions

@nbro
nbro / policy_iteration.py
Created Dec 16, 2017
Simple example of policy iteration on a grid/maze world (using Python/NumPy)
View policy_iteration.py
import numpy as np
E = EMPTY = 0
B = BLOCKED = 1
G = GOAL = 2
# The maze from the assignment
MAZE = np.array(
[[0, 0, 0, 0, 0, 0, 0],
[0, 0, B, 0, 0, 0, 0],
@nbro
nbro / double_bridge.md
Last active Mar 12, 2017
In-place double-bridge or 4-opt move
View double_bridge.md

I've implemented a double-bridge (or 4-opt) move in place, i.e. without any additional containers than the original. I'm sharing it with you first because I would like to know if it's correct or if I can improve it and second because I thought it could be helpful to someone else (since I have not found anything on the web).

/*
 * DOUBLE-BRIDGE-COMPUTE-GAIN
 *
 * Computes and returns the gain of a random double-bridge move.
 * The indices of the vertices used are also returnd as 2nd, 3rd and 4th parametrs of the array returned.
 * */
std::array<int, 4> double_bridge_in_place_compute_gain(const MatrixGraph &m, const VectorTour &t) {
You can’t perform that action at this time.