Skip to content

Instantly share code, notes, and snippets.

View olibre's full-sized avatar
🦆
Empowering self-governance

O. Libre olibre

🦆
Empowering self-governance
View GitHub Profile
@dscharrer
dscharrer / infix_operator.cpp
Created June 7, 2012 07:38
The proper way to call std::swap
#include <type_traits>
namespace detail {
// No need to give up constexpr for std::forward
template <class T>
constexpr T && forward(typename std::remove_reference<T>::type & t) noexcept {
return static_cast<T &&>(t);
}
@hutorny
hutorny / enumnames.hpp
Created January 21, 2017 18:05
Zero-dependency allocation-free mapping enum values to names for C++11
/** zero-dependency allocation-free mapping enum values to names */
namespace enumnames {
typedef const char* (*name)();
bool match(const char*, const char*) noexcept; /* to be provided by the user */
template<typename T, T K, name V>
struct tuple {
typedef T key_t;
static constexpr T key = K;
@olibre
olibre / smart_dtor.cpp
Last active October 7, 2018 21:10 — forked from odeblic/smart_dtor.cpp
Smart destructor
/*
* Original work: https://gist.github.com/odeblic/fa54037bf4d764a5dc02735cb4bd79f3
* Inspired from: https://youtu.be/ZiNGWHg5Z-o
*
* Compile
*
* $ g++ -Wall -Wextra smart_dtor.cpp
*
* Run
*
@odeblic
odeblic / smart_dtor.cpp
Last active October 7, 2018 21:10
Smart destructor
#include <iostream>
#include <memory>
struct Base
{
~Base()
{
std::cout << "~Base()" << std::endl;
}
};
@olibre
olibre / 60-jetbrains.conf
Last active September 9, 2019 14:18 — forked from bittner/60-jetbrains.conf
Inotify configuration for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm). Create this file with e.g. `sudo vim /etc/sysctl.d/60-jetbrains.conf`
# Set inotify watch limit high enough for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm).
# 1. Check current value in use: `cat /proc/sys/fs/inotify/max_user_watches`
# 2. Create this file as /etc/sysctl.d/60-jetbrains.conf (Debian, Ubuntu, Fedora...)
# 3. Apply new configuration: `sudo sysctl -p --system` or `sudo service procps start` or reboot
# 4. Check new value in use: `cat /proc/sys/fs/inotify/max_user_watches`
#
# References:
# * https://gist.github.com/olibre/a0219529a6cc347494f40780e7e539eb
# * https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
#
@bittner
bittner / 60-jetbrains.conf
Created September 25, 2015 07:57
Inotify configuration for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm). Create this file with e.g. `sudo vim /etc/sysctl.d/60-jetbrains.conf`
# Set inotify watch limit high enough for IntelliJ IDEA (PhpStorm, PyCharm, RubyMine, WebStorm).
# Create this file as /etc/sysctl.d/60-jetbrains.conf (Debian, Ubuntu), and
# run `sudo service procps start` or reboot.
# Source: https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
#
# More information resources:
# -$ man inotify # manpage
# -$ man sysctl.conf # manpage
# -$ cat /proc/sys/fs/inotify/max_user_watches # print current value in use
@subfuzion
subfuzion / http-status-codes.md
Last active September 3, 2023 09:15
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@olibre
olibre / cpp_legacy_inheritance_vs_std_variant.md
Last active February 11, 2024 10:41 — forked from GuillaumeDua/cpp_legacy_inheritance_vs_std_variant.md
C++ legacy inheritance vs CRTP + std::variant
@marioBonales
marioBonales / .bashrc
Created January 19, 2012 03:56
Default .bashrc for ubuntu
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@emiller
emiller / git-mv-with-history
Last active April 17, 2024 21:06
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.