This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return a promise, limiting the number of concurrent accesses to a shared | |
// resources to |max_concurrent_access|. | |
const concurrencyLimiter = (max_concurrency) => { | |
let pending = 0; | |
let waiting = []; | |
return async (task) => { | |
pending++; | |
// Wait our turn, if needed. | |
if (pending > max_concurrency) | |
await new Promise(resolve => waiting.push(resolve)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let locked = []; | |
const lock = async (promise) => { | |
if (locked.length == 0) { | |
locked.push(undefined) | |
} else { | |
await new Promise(resolve => { | |
locked.push(resolve); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CaptureStdout { | |
public: | |
CaptureStdout() { old = std::cout.rdbuf(ss.rdbuf()); } | |
~CaptureStdout() { std::cout.rdbuf(old); } | |
std::string Value() { return ss.str(); } | |
private: | |
std::stringstream ss; | |
std::streambuf* old; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// ---------------------------------------------------------- | |
/// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date +"%y_%m_%d_%Hh%Mmin%Ssec" |
NewerOlder