Skip to content

Instantly share code, notes, and snippets.

View maddouri's full-sized avatar

Yassine MADDOURI maddouri

View GitHub Profile
@maddouri
maddouri / build-static-python.sh
Created December 6, 2015 22:42
A simple script that builds static versions of Python and LibPython using musl-libc
#!/bin/bash
# set -eux
# This a simple script that builds static versions of Python and LibPython using musl-libc
# Find the associated article at: http://general-purpose.io/2015/12/06/compiling-python-and-libpython-statically-using-musl-libc/
WORKING_DIR="/code/static-python"
MUSL_PREFIX="/code/static-python/musl"
PY_PREFIX="/code/static-python/python"
@maddouri
maddouri / untar_url.sh
Last active February 25, 2018 16:20
Downloading and Decompressing an Archive in One Command
#!/usr/bin/env bash
set -eu
## untar_url <archive_url> <dest_dir> [<nb_components_to_strip>]
##
## Downloads an archive from <archive_url> and decompresses it in <dest_dir>
##
## @param archive_url archive url
## @param dest_dir directory in which to decompress the archive (created if not existing)
## @param nb_components_to_strip number of components to strip from file names on extraction. Default=1
@maddouri
maddouri / has_member.hpp
Last active January 5, 2024 01:38
Checking the Existence of a C++ Class Member at Compile Time
// A compile-time method for checking the existence of a class member
// @see https://general-purpose.io/2017/03/10/checking-the-existence-of-a-cpp-class-member-at-compile-time/
// This code uses "decltype" which, according to http://en.cppreference.com/w/cpp/compiler_support
// should be supported by Clang 2.9+, GCC 4.3+ and MSVC 2010+ (if you have an older compiler, please upgrade :)
// As of "constexpr", if not supported by your compiler, you could try "const"
// or use the value as an inner enum value e.g. enum { value = ... }
// check "test_has_member.cpp" for a usage example
@maddouri
maddouri / wget.vbs
Last active April 18, 2019 21:43 — forked from udawtr/wget.vbs
wget.vbs - similar to wget but written in vbscript
'wget.vbs - similar to wget but written in vbscript
'based on a script by Chrissy LeMaire
' alternatively https://stackoverflow.com/a/28143180/865719
' bitsadmin /transfer dl_job_name /download /priority normal <url> <absolute/path/to/file>
' Usage
if WScript.Arguments.Count < 1 then
MsgBox "Usage: wget.vbs <url> (file)"
WScript.Quit
@maddouri
maddouri / cmakeit.sh
Created November 19, 2017 15:47
Wrapper around CMake Config/Build
#!/usr/bin/env bash
set -eux
# Usage
# cmakeit source SOURCE_DIR build BUILD_DIR config CONFIG target TARGET1,TARGET2,... -- EXTRA_TOOL_ARGS
THIS_FILE_NAME="$(basename "$(readlink -f "$0")")"
THIS_DIR="$(dirname "$(readlink -f "$0")")"
@maddouri
maddouri / .clang-format
Last active March 15, 2024 06:58
Allman-style clang-format file initially generated using https://zed0.co.uk/clang-format-configurator/
---
BasedOnStyle: Mozilla
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlinesLeft: 'false'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
@maddouri
maddouri / Default.sublime-keymap
Last active September 14, 2019 20:56
Sublime Text 3 Settings
[
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["ctrl+space"], "command": "auto_complete" },
{ "keys": ["ctrl+alt+left"], "command": "jump_back" },
{ "keys": ["ctrl+alt+right"], "command": "jump_forward" },
{ "keys": ["ctrl+shift+o"], "command": "prompt_add_folder" },
{ "keys": ["ctrl+up"], "command": "scroll_lines", "args": {"amount": 1.0 } },
{ "keys": ["ctrl+down"], "command": "scroll_lines", "args": {"amount": -1.0 } },
{ "keys": ["ctrl+u"], "command": "soft_undo" }
@maddouri
maddouri / get-cling.sh
Last active July 27, 2019 20:30
Get the latest nightly build of Cling (LLVM-based, interactive C++ interpreter) https://root.cern.ch/cling
#!/usr/bin/env bash
set -eux
this_dir="$(dirname "$(readlink -f "$0")")"
# TODO replate 'ubuntu.*18' by a regex that matches your distro
# check https://root.cern.ch/download/cling to see what distros are supported
latest_archive="$(w3m https://root.cern.ch/download/cling | grep -u 'ubuntu.*18' | head -n1 | sed 's/\s\+/ /g' | awk '{print $3}')"
latest_url="https://root.cern.ch/download/cling/${latest_archive}"
#include <iostream>
// http://coliru.stacked-crooked.com/a/3d07f7711012d021
// https://stackoverflow.com/q/29661253/865719
// https://connect.microsoft.com/VisualStudio/feedback/details/990223/overloaded-lambda-pattern-fails-to-compile
template <typename L, typename... Ls>
struct overload_set : L, overload_set<Ls...>
{
@maddouri
maddouri / subl.sh
Created August 12, 2018 17:19
A better "subl" command: Allows piping to Sublime Text
# a better "subl" command:
# allows piping to sublime text:
# open sublime text:
# subl [arguments] [files]
# subl ~/.bashrc
# or
# pipe output to sublime text:
# some_command | subl
# echo "Hello sublime pipe" | subl
# adapted from https://gist.github.com/nathforge/7120225