Skip to content

Instantly share code, notes, and snippets.

View lilianmoraru's full-sized avatar

Lilian Anatolie Moraru lilianmoraru

View GitHub Profile
@lilianmoraru
lilianmoraru / main.cpp
Last active August 29, 2015 14:05
C++11 Example
//For demonstration purposes we move reverse into a separate function
// In C++98 - this would make a deep copy then throw the original
// In C++11 - It will detect that a temporary is passed. It uses move semantics automatically.
// Copies the pointer and takes ownership of the buffer.
// Doesn't do a shallow copy or deep copy.
// There is no need to implicitly tell the compiler what to do with a temporary data,
// it's error prone while the compiler knows
// better and the case is very simple for the compiler to detect.
// If the user wants, he can tell it explicitly with "string&& s"
string reverse_string(string s) {
@lilianmoraru
lilianmoraru / setup_vagga.sh
Last active May 20, 2019 22:26
Script to setup vagga on Debian based systems
#! /bin/sh
red_color="\033[1;31m"
green_color="\033[1;32m"
no_color="\033[0m"
throw_error() {
if [ ! -z "$1" ]; then
printf "${red_color}$1${no_color}\n"
fi
#! /bin/sh
## Warning: Please don't source this script from within' another script(note the use of "exit")
red_color="\033[1;31m"
green_color="\033[1;32m"
no_color="\033[0m"
throw_error() {
if [ ! -z "$1" ]; then
printf "${red_color}$1${no_color}\n"
containers:
ubuntu:
setup:
- !Ubuntu trusty
- !UbuntuUniverse
- !Env
HOME: /root
- !Install [git, ca-certificates, curl, gcc, g++, cmake,
build-essential, autoconf2.13, libcap-dev,
linux-vdso.so.1 => (0x00007ffcf2f6d000)
libreadline.so.6 => /hab/pkgs/core/readline/6.3.8/20160729192706/lib/libreadline.so.6 (0x00007fe3a4584000)
libz.so.1 => /hab/pkgs/core/zlib/1.2.8/20160612064520/lib/libz.so.1 (0x00007fe3a4369000)
libdl.so.2 => /hab/pkgs/core/glibc/2.22/20160612063629/lib/libdl.so.2 (0x00007fe3a4165000)
libncursesw.so.6 => /hab/pkgs/core/ncurses/6.0/20160612075116/lib/libncursesw.so.6 (0x00007fe3a3f27000)
libm.so.6 => /hab/pkgs/core/glibc/2.22/20160612063629/lib/libm.so.6 (0x00007fe3a3c29000)
libguile-2.0.so.22 => /hab/pkgs/core/guile/2.0.12/20160729224832/lib/libguile-2.0.so.22 (0x00007fe3a383b000)
libgc.so.1 => not found
libpthread.so.0 => /hab/pkgs/core/glibc/2.22/20160612063629/lib/libpthread.so.0 (0x00007fe3a3601000)
libutil.so.1 => /hab/pkgs/core/glibc/2.22/20160612063629/lib/libutil.so.1 (0x00007fe3a33fe000)
Dynamic section at offset 0x655d48 contains 38 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libreadline.so.6]
0x0000000000000001 (NEEDED) Shared library: [libz.so.1]
0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED) Shared library: [libncursesw.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libguile-2.0.so.22]
0x0000000000000001 (NEEDED) Shared library: [libgc.so.1]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]

Prerequisites

You'll need to have a system running that is accessible through a DNS record. It should have access to the public Habitat depot, https://app.habitat.sh so it can download the required packages.

You'll need to register an OAuth application for GitHub. You need the client ID and client secret that are created for the application later in this guide. Your system needs to have access to https://github.com so that it can authenticate.

Your system also needs to have an FQDN that can be resolved, for example depot.example.com. This will be used in your OAuth application's "Authorization Callback URL." For this example, use http://depot.example.com/#/sign-in. The /#/sign-in is required.

Operating System

Looking into the Future

futures-rs is the library which will hopefully become a shared foundation for everything async in Rust. However it's already become renowned for having a steep learning curve, even for experienced Rustaceans.

I think one of the best ways to get comfortable with using a library is to look at how it works internally: often API design can seem bizarre or impenetrable and it's only when you put yourself in the shoes of the library author that you can really understand why it was designed that way.

In this post I'll try to put down on "paper" my understanding of how futures work and I'll aim to do it in a visual way. I'm going to assume you're already somewhat familiar with Rust and why futures are a useful tool to have at one's disposal.

For most of this post I'll be talking about how things work today (as of September 2017). At the end I'll touch on what's being proposed next and also make a case for some of the changes I'd like to see.

If you're interested in learning more ab

@lilianmoraru
lilianmoraru / UpdateLLVM.bash
Last active April 5, 2018 08:01
Build locally your own optimized version of LLVM/Clang
#! /bin/bash
source_dir="" # Define this, example(this usually should be the device with the fastest Read perf): ${HOME:?}/git/llvm
build_dir="" # Define this, example(preferably a different device which can be slower): /ssd/llvm-build
install_prefix="" # Define this, example: /usr/local/llvm
release_branch="release_60"
update_project() {
local -r dir="${1:?}"
local -r branch="${2:?}"
@lilianmoraru
lilianmoraru / update_linux.bash
Last active March 3, 2019 11:37
pop_os self-compiling the Linux Kernel and installing inside EFI(also installs as backup the distro-provided kernel)
#! /bin/bash
set -euo pipefail
IFS=$'\n\t'
sudo update-alternatives --auto gcc
mtune_patch_path="${mtune_patch_path:-${HOME:?}/HelperScripts/enable_additional_cpu_optimizations_for_gcc_v8.1+_kernel_v4.13+.patch}"
kernel_config_path="${kernel_config_path:-${HOME:?}/HelperScripts/MyKernelConfig}"
extract_location="${extract_location:-/dev/shm/linux-source}"
CFLAGS="-O3 -DNDEBUG -D_GNU_SOURCE -fomit-frame-pointer -fno-asynchronous-unwind-tables -ftree-vectorize -floop-strip-mine -floop-block -fgraphite-identity -m64 -mavx -march=native -mtune=native"
CXXFLAGS="-O3 -DNDEBUG -D_GNU_SOURCE -fomit-frame-pointer -fno-asynchronous-unwind-tables -ftree-vectorize -floop-strip-mine -floop-block -fgraphite-identity -m64 -mavx -march=native -mtune=native"