Skip to content

Instantly share code, notes, and snippets.

View abel0b's full-sized avatar
🐉
Compiling

Abel Calluaud abel0b

🐉
Compiling
  • Voie lactée
View GitHub Profile
@abel0b
abel0b / bash_prompt.sh
Created April 25, 2020 11:34
Prompt bash git branch + previous command exit code
export PS1='$(if [[ ! "$?" = "0" ]]; then echo "\[\e[1;31m\]($?)\[\e[0m\] "; fi)\h:\[\e[1;31m\]$(basename $PWD)\[\e[0m\]\[\e[1;33m\]$(__git_ps1 " [%s]")\[\e[0m\]> '
@abel0b
abel0b / uninstall-all.ps1
Created April 20, 2020 09:14
Uninstall all built-in Windows 10 app with powershell script
Get-AppxPackage -AllUsers | Remove-AppxPackage
@abel0b
abel0b / debug.h
Created April 15, 2020 17:31
Debug C++ macro stl containers
#ifndef DEBUG_H
#define DEBUG_H
#include <bits/stdc++.h>
#define yo cout << "YO[" << __FILE__ << ":" << __LINE__ << "]" << std::endl;std::cerr.flush();std::cout.flush();exit(0)
#define check(x) std::cerr.flush();std::cout.flush();std::assert(x)
template<typename Arg, typename... Args>
void print_debug(const char * filename, int line, Arg&& arg, Args&&... args) {
@abel0b
abel0b / install-linux-perf-on-wsl2.sh
Last active May 27, 2024 13:44
Install perf on WSL 2
apt install flex bison
git clone https://github.com/microsoft/WSL2-Linux-Kernel --depth 1
cd WSL2-Linux-Kernel/tools/perf
make -j8
sudo cp perf /usr/local/bin
@abel0b
abel0b / glfw-starter.c
Created April 1, 2020 13:27
glfw stater template
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
@abel0b
abel0b / ufw-docker-swarm.conf
Created February 24, 2020 10:25
UFW Application Profile for Docker Swarm
[Docker Swarm]
title=Docker Swarm
description=Docker Swarm
ports=2377/udp|7946/tcp|7946/udp|4789/udp
@abel0b
abel0b / ufw-glusterfs.conf
Last active February 21, 2020 12:34 — forked from Diftraku/ufw-glusterfs.conf
UFW Application Profile for GlusterFS
[GlusterFS Daemon]
title=GlusterFS (Daemon)
description=GlusterFS Daemon
ports=24007/tcp
[GlusterFS Management]
title=GlusterFS (Management)
description=GlusterFS Management
ports=24008/tcp
@abel0b
abel0b / main.c
Created February 1, 2020 16:10
calculcate power 3/2
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <omp.h>
#define N 1000000
// Compare 3/2 power calculation
@abel0b
abel0b / main.cpp
Created January 20, 2020 12:25
C++ pre-increment vs post-increment
#include <vector>
#include <chrono>
#include <iostream>
using namespace std;
int main() {
int n = 1000000;
int value = 42;
vector<int> vec(n, value);
@abel0b
abel0b / slug.sh
Created January 19, 2020 09:16
Create human-readable url slug in bash
function slug() {
echo "$1" | sed "s/\s/-/g" | tr "[:upper:]" "[:lower:]"
}
slug "Hello World!"