Skip to content

Instantly share code, notes, and snippets.

Avatar

Arthur Sonzogni ArthurSonzogni

View GitHub Profile
View i3-lock-blur.sh
#!/bin/bash
# bindsym $mod+l exec ~/lock.sh
lock_image=/tmp/screen.png
RES=$(xrandr | grep 'current' | sed -E 's/.*current\s([0-9]+)\sx\s([0-9]+).*/\1x\2/')
ffmpeg \
-f x11grab \
-video_size $RES \
-y \
-i $DISPLAY \
@ArthurSonzogni
ArthurSonzogni / finally_delete.hpp
Created Jul 14, 2017
finally_delete -- Adapt old C object to RAII.
View finally_delete.hpp
// adapt old C object to RAII
// Example:
// ```
// Object* object_pointer = nullptr;
// finally_delete(object_pointer, delete_function)
// auto* object_pointer = allocate_some_object();
// throw exception/return;
// ```
template <typename objectPointer, typename delete_function>
@ArthurSonzogni
ArthurSonzogni / CP1252_to_UTF8.hpp
Last active Aug 2, 2020
Convert Windows-1252 (aka CP1252) to UTF8
View CP1252_to_UTF8.hpp
/*
MIT License
Copyright (c) 2017 Arthur Sonzogni
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
View git-vim
#!/bin/bash
# +---------------------------------------+
# | Open commit's files as buffers in vim |
# +---------------------------------------+
if [ -z $1 ]
then
# No argument provided => use the latest commit's files.
commit=HEAD
View buildScrollableWidgetList.hpp
/// ----------------------------------------------------------
/// Author : ArthurSonzogni
/// License : MIT
/// Description : wrap a QVboxLayout into a QScrollArea
/// if the QVBoxLayout is to big, a scroll bar
/// appear and let the user scroll
/// ----------------------------------------------------------
#ifndef BUILDSCROLLABLEWIDGETLIST_H
#define BUILDSCROLLABLEWIDGETLIST_H
@ArthurSonzogni
ArthurSonzogni / todo.cpp
Created Mar 14, 2016
TODO written in TODO
View todo.cpp
// TODO TODO TODO TODO TODO TODO TODO
// TODO TODO TODO TODO TODO TODO TODO
// TODO TODO TODO TODO TODO TODO TODO
// TODO TODO TODO TODO TODO TODO TODO
// TODO TODO TODO TODO TODO TODO TODO
// TODO TODO TODO TODO TODO
@ArthurSonzogni
ArthurSonzogni / date.sh
Created Mar 9, 2016
bash date command to display date in a compatible format for filename (in french)
View date.sh
date +"%y_%m_%d_%Hh%Mmin%Ssec"
@ArthurSonzogni
ArthurSonzogni / create_bitbucket_repositories.sh
Created Mar 8, 2016
Use bitbucket REST api to create and update all git repository in the directory. ( push into bitbucket team )
View create_bitbucket_repositories.sh
#!/bin/bash
echo -n "username in lowercase : "
read username
echo -n "password : "
read password
echo -n "team : "
read team
for r in $(echo */)
do
repo=${r%%/}
View saturate_cast.hpp
#ifndef SATURATE_CAST_HPP
#define SATURATE_CAST_HPP
#include <cmath>
// because C++ doesn't allow partial function
// specialization, we must use static method
// from specialized class
//-----------
@ArthurSonzogni
ArthurSonzogni / Print.hpp
Last active Mar 3, 2016
qdebug() like object that avoid interleaving issues in a multiprocess / multithread environment.
View Print.hpp
/* ---------------------------------------------------------------------------
* ** This software is in the public domain, furnished "as is", without technical
* ** support, and with no warranty, express or implied, as to its usefulness for
* ** any purpose.
* **
* ** The file provide a way to avoid interleaved printing in a multithreaded
* ** environment. It works like qDebug() for the Qt framework
* **
* ** Usage :
* ** Print() << " The debug value = " << 42;
You can’t perform that action at this time.