- Qualsiasi cella viva con meno di due celle vive adiacenti muore, come per effetto d'isolamento;
- Qualsiasi cella viva con due o tre celle vive adiacenti sopravvive alla generazione successiva;
- Qualsiasi cella viva con più di tre celle vive adiacenti muore, come per effetto di sovrappopolazione;
- Qualsiasi cella morta con esattamente tre celle vive adiacenti diventa una cella viva, come per effetto di riproduzione.
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
#include <cassert> | |
#include <iostream> | |
#include <memory> | |
#include <mutex> | |
#include <string> | |
#include <unordered_map> | |
template <typename T> | |
std::shared_ptr<T> get_global(int id) { | |
using Map = std::unordered_map<int, std::weak_ptr<T>>; |
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
add_custom_target(demos) | |
find_package(Qt5Core REQUIRED) | |
find_package(Qt5Gui REQUIRED) | |
find_package(Qt5OpenGL REQUIRED) | |
find_package(OpenGL) | |
find_package(Eigen3) | |
set(CMAKE_AUTOMOC ON) |
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
template <typename T> | |
T fix_modular_sequence(T&& seq, const typename T::value_type modulus) { | |
const auto threshold = modulus / 2.0; | |
auto it = seq.begin(); | |
auto prev = *it; | |
while (it != seq.end()) { | |
++it; | |
auto& curr = *it; | |
auto diff = curr - prev; | |
if (std::abs(diff) > threshold) curr -= (diff < 0 ? -1 : 1) * modulus; |
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
#include <iostream> | |
#include <sys/resource.h> | |
int main() { | |
rlimit core_limits; | |
core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY; | |
setrlimit(RLIMIT_CORE, &core_limits); | |
std::cout << "begin\n"; | |
int* x = 0; |
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/sh | |
output="" | |
xrandr | while read line; do | |
if echo "${line}" | grep 'connected' > /dev/null; then | |
if echo "${line}" | grep ' connected' > /dev/null; then | |
output="$( echo "${line}" | sed 's/\(.*\) connected.*/\1/' )" | |
fi | |
elif ! echo "${line}" | grep '^Screen' > /dev/null; then |
In Linux, my Brother MFC-J480DW cuts off top margin when used with A4 paper, even if all settings are set to A4.
To make it work, I had to edit /opt/brother/Printers/mfcj480dw/inf/brmfcj480dwrc
file (that's the path in Gentoo, it could be different in other distributions).
And change:
PaperType=Letter
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/sh | |
FAKE_SERVER_ADDRESS='127.8.8.8' | |
URL='http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext' | |
FILENAME='/etc/NetworkManager/dnsmasq.d/adblock' | |
## do not update if fresh (24h) | |
if test -e "${FILENAME}"; then | |
echo 'file exists' | |
if ! test "$( find "${FILENAME}" -mmin +1440 )"; then |
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
SUMMARY = "xbindkeys - Tool for launching commands on keystrokes" | |
HOMEPAGE = "http://www.nongnu.org/xbindkeys/xbindkeys.html" | |
LICENSE = "GPL" | |
LIC_FILES_CHKSUM = "file://COPYING;md5=24396300012ca5a98ff24b08179852a0" | |
SECTION = "x11" | |
DEPENDS = "virtual/libx11" | |
PR = "r0" | |
inherit distro_features_check autotools |
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
#include <cassert> | |
#include <iostream> | |
#include <stdio.h> | |
#include <string> | |
#include <vector> | |
std::vector<int> toVector(const std::string& str) { | |
std::vector<int> result; | |
for (auto c : str) { | |
result.push_back(c - '0'); |