Skip to content

Instantly share code, notes, and snippets.

View janderudder's full-sized avatar

Jan janderudder

  • France
View GitHub Profile
@janderudder
janderudder / lth.sh
Last active October 4, 2020 12:00
lth : list a bunch of most recently modified files
#!/bin/bash
declare -ir Entry_max=15
declare -ir Max_count=$((Entry_max+1))
show_listing()
{
declare -a Entries
for Entry in $(\ls "$1" -1tF --color=always | head -n $Max_count)
@janderudder
janderudder / command-queue-sample.cpp
Last active March 16, 2020 15:04
Simple command & command queue in C++17
#include <any>
#include <functional>
#include <iostream>
#include <map>
#include <string_view>
#include <tuple>
#include <queue>
int main()
@janderudder
janderudder / unique_ptr_example.cpp
Last active March 14, 2020 12:32
unique_ptr as parameter : difference between taking by value or by rvalue reference
#include <iostream>
#include <memory>
/**
* Sample types with loud destructors
*/
struct By_value
{
int i;
@janderudder
janderudder / main.cpp
Created July 27, 2019 21:43
SFML main.cpp - blank project snippet
#if __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#elif __has_include(<filesystem>)
#include <filesystem>
namespace filesystem = std::filesystem;
#else
#error "Couldn't find a standard 'filesystem' header."
#endif
@janderudder
janderudder / vsc.sh
Last active August 16, 2021 11:33
VSC : script for booting up new dev project : it copies a template folder and launches Visual Studio Code
#!/bin/bash
##
## Create dev project and launch Visual Studio Code
##
if [[ $1 == '-h' || $1 == '--help' || $1 == '-?' ]]
then
Base_name="$(basename -s '.sh' $0)"
cat <<-EOD
Create a dev project based on a template and launch Visual Studio Code.
@janderudder
janderudder / clear-vsc-ipch.sh
Created June 28, 2019 20:53
bash script: delete .vscode/ipch folders
#!/bin/bash
help() {
cat <<- EOF
Usage: $(basename $0) PATH...
Erase '.vscode/ipch' folders from VSCode projects in
the sub-directories of the supplied path.
PATH must be a valid folder.
EOF
@janderudder
janderudder / typeUniqueId.hpp
Last active March 11, 2019 18:31
Get a unique numeric identifier for a type, without RTTI.
#pragma once
#include <cstdint>
#include <type_traits>
using TypeUniqueId = std::uintptr_t;
template <typename T>
constexpr TypeUniqueId typeUniqueId()
{
return reinterpret_cast<TypeUniqueId>(&typeUniqueId<T>);
@janderudder
janderudder / deletenode.js
Created August 1, 2018 17:50
Bookmarklet : delete a DOM node on click
(function (arg) {
if (!arg)
window.activeDeleteNodeBookmarklet = true
else
window.activeDeleteNodeBookmarklet = !window.activeDeleteNodeBookmarklet
if ( window.activeDeleteNodeBookmarklet )
console.log('DeleteNode bookmarklet activated')
else
console.log('DeleteNode bookmarklet deactivated')