Skip to content

Instantly share code, notes, and snippets.

@Otteri
Otteri / .env
Last active July 27, 2022 06:21
Azure DevOps Pipeline: load variables from .env file
PYTHON=/home/usr/anaconda3/bin/python
CACHEDIR=~/.cache
@Otteri
Otteri / install.bash
Created December 8, 2020 20:33
Pytorch+cuda installation script for Ubuntu 20.04 LTS WSL
#!/bin/bash
# Installs Pytorch development environment
# on Ubuntu 20.04 LTS (WSL2) host machine
# First make sure that Windows GPU driver and WSL2 installations are ok,
# then launch WSL, create a new user and execute commands.
# Reference: https://docs.nvidia.com/cuda/wsl-user-guide/index.html
# 1) Install cuda stuff
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
@Otteri
Otteri / integral.py
Last active March 1, 2020 16:26
Forward Euler example
import matplotlib.pyplot as plt
import numpy as np
PI = np.pi
PI2 = (2*PI)
# Calculus says:
# 1) integral of sin(x) from 0 to pi equals 2,
# 2) integral of sin(x) from pi to 2pi equals -2,
# 3) integral of cos(x) from 0 to pi/2 equals 1,
@Otteri
Otteri / MLX90363_Rotary_program.c
Last active August 5, 2022 14:13
Minimalistic MLX90363 interfacing example with Adruino board
// Arduino port for MLX90363 Example rotary program
// Purpose: Demonstrate getting angular data from
// MLX90363 via GET1a message
//
// Adapts code example given on:
// MLX90363 Getting Started Guide (Rev 002)
// Tested with Arduino Nano V3 and IDE ver. 1.8.5
// Date: 09.03.2019
#include <stdio.h>
@Otteri
Otteri / prettyPrint.m
Created October 25, 2018 12:46
[Matlab] prettyPrint function for matrices and vectors
% Function pretty prints given matrix / vector
% @param M: a matrix or a vector to be printed
% @param M_name: name which is displayed in the print (optionl)
% @param precision: specify the amount of decimals to be shown (optional)
function prettyPrint(M, M_name, precision)
[rows_n, cols_n] = size(M);
% Check optional arguments
if ~exist('M_name','var'), M_name = 'PrettyPrint'; end
if ~exist('precision','var'), precision = 3; end
@Otteri
Otteri / example.cpp
Created September 3, 2018 16:01
C++ basics
#include "examples.h"
#include <vector>
bool changeAge(std::vector<Person>& people) {
// Create people
for (int i = 0; i < 50; i++) {
Person new_person;
new_person.gender = Gender::Male;
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+m", "command": "editor.action.jumpToBracket" },
{ "key": "ctrl+l", "command": "expandLineSelection" },
{ "key": "ctrl+n", "command": "" },
{ "key": "ctrl+i", "command": "" },
{ "key":"ctrl+alt+2", "command": "workbench.action.splitEditor" },
{ "key": "ctrl+alt+right", "command": "cursorWordPartRight" },
#pragma once
#include <SDL_ttf.h>
#include <map>
#include <string>
#include <vector>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GOOD TO KNOW ABOUT THE CLASS. +--------------------------+ //
// | TextService | //
// How to use: |--------------------------| //
// Note: static renderer must be defined when creating the service class.
class TextService {
public:
// Colors has to be defined as an enum, because otherwise
// they cant be accessed outside class. ('Has to be specific for some object').
enum class Colors { red = 1, green = 2, blue = 3, yellow = 4, white = 5, gray = 6, black = 7 };
class TextProperties; // forward declaration;
enum class FontNames { ostrich = 1, blabalb = 2 };
@Otteri
Otteri / Git cheatsheet.txt
Created July 21, 2018 10:41
Some often needed git commands
###########################
# GENERAL #
###########################
# Show filenames that have changed in the last <n> commits:
git diff --name-only HEAD HEAD~<n>
# Git copy current branch status to master w/o doing merge
git checkout master
git checkout other_branch .