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> | |
struct point2d : public std::pair<int, int> | |
{ | |
int& x() { return first; } | |
int& y() { return second; } | |
template <typename ... Args> | |
point2d(Args&& ... args) : pair<int, int>(std::forward<Args>(args)...) {} | |
}; |
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
import matplotlib.pyplot as plt | |
import statistics | |
import collections | |
d = collections.defaultdict(lambda: 0) | |
x = statistics.mean(data1) | |
sys.argv; | |
"{0: <5}".format("abc") | |
"{:.2f}".format(0.001) |
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
# screen start and detach | |
screen -S sleepy -dm cmd | |
screen -XS sleepy quit | |
# mutex | |
waiter() | |
{ | |
local max=$1; | |
while (( $(jobs -l | wc -l) >= $max )); do | |
sleep 1; | |
done |
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
#pragma once | |
#ifndef SCOPE_EXIT_HPP__ | |
#define SCOPE_EXIT_HPP__ | |
#include <functional> | |
#define BASIC_SCOPE_EXIT_CONCAT_IMPL(x, y) x##y | |
#define BASIC_SCOPE_EXIT_CONCAT(x, y) BASIC_SCOPE_EXIT_CONCAT_IMPL(x, y) | |
#define SCOPE_DEFER ::basic_scope_exit::scope_exit BASIC_SCOPE_EXIT_CONCAT(SCOPE_EXIT_UNIQUE_VAR_, __LINE__) = \ |
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
CURL_REQUEST_CMD=...; | |
XCODE_DL_LOCATION="/Volumes/Card512"; | |
XCODE_TMP_EXTRACT_LOCATION="/Volumes/Card512/xcode"; | |
XCODE_FINAL_EXTRACT_LOCATION="/Volumes/Card512" | |
# download xcode | |
cd "${XCODE_DL_LOCATION}" || \ | |
{ echo "cd ${XCODE_DL_LOCATION} failed"; exit 1; } | |
while ! ${CURL_REQUEST_CMD} -o xcode.xip --continue -; do |
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 <vector> | |
bool sum_of(std::vector<int> const & list, int const target, int const maxdep) | |
{ | |
if (maxdep < 0 or target < 0) | |
return false; | |
if (target == 0) | |
return true; |
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
INTERNET_INTERFACE=wlp13s0 | |
LOCAL_INTERFACE=enp15s0 | |
LOCAL_INTERFACE_IP_BASE=192.168.155 | |
LOCAL_INTERFACE_IP="${LOCAL_INTERFACE_IP_BASE}.1" | |
LOCAL_INTERFACE_MAC=$(cat /sys/class/net/${LOCAL_INTERFACE}/address) | |
ip link set up dev ${LOCAL_INTERFACE} | |
ip addr add "${LOCAL_INTERFACE_IP}"/24 dev ${LOCAL_INTERFACE} |
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 <png++/png.hpp> | |
#include <iostream> | |
#include <memory> | |
#include <type_traits> | |
int constexpr bitmask = 0b00000011; | |
constexpr inline auto hash(char const * str, int h = 0) -> long long int { | |
return (!str[h] ? 5381 : (hash(str, h+1)*33) ^ str[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
#include <ArduinoSTL.h> | |
#include <vector> | |
#include <functional> | |
using arduino_time_t = unsigned long; | |
using function_ptr = void (*)(); | |
class dispatcher | |
{ |
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 <vector> | |
#include <sstream> | |
#include <limits> | |
#include <unordered_set> | |
class tetris | |
{ | |
protected: | |
enum class ele { empty, occupied }; |
NewerOlder