Skip to content

Instantly share code, notes, and snippets.

View adiog's full-sized avatar

Aleksander Gajewski adiog

View GitHub Profile
$MARKS_DIR = "$HOME/.powermarks"
$MARKS_CWD = ".cwd"
New-Item -ItemType Director -Force -Path $MARKS_DIR
function _l() {
Get-ChildItem -Path $MARKS_DIR
}
function _m($MARK_LABEL) {
Get-Location | Set-Content "$MARKS_DIR/$MARK_LABEL"
// https://github.com/CppCon/CppCon2018/tree/master/Presentations/named_arguements_from_scratch
#include <string>
#include <boost/hana.hpp>
namespace hana = boost::hana;
using namespace hana::literals;
static int foo(int a, float b, std::string const& c) {
return (c.size() + a) / b;
@adiog
adiog / sleepsort.sh
Created March 12, 2018 20:28
sleepsort
#!/bin/bash
function f() {
sleep "$1"
echo -n "$1 "
}
while [ -n "$1" ]
do
f "$1" &
shift
done
@adiog
adiog / access_point.sh
Created February 17, 2018 23:09
Create Access Point on Debian/Ubuntu
#!/bin/bash
### CONFIG ###
ETH=enp4s0 # interface connected to the Internet
WLAN=wlp5s0 # interface serving as an Access Point
ACCESS_POINT_SSID=thinkpad
ACCESS_POINT_PASS=password
SERVER_IP=192.168.42.1
SERVER_SUBNET=192.168.42.0
@adiog
adiog / gist:232c725018b052110b10e8343e2411f9
Last active February 7, 2018 13:28
mock with logging
#!/bin/bash
MOCK=$1
# moves MOCK (ed) to MOCK.real and creates MOCK with logging to MOCK.log and calling MOCK.real
REALMOCK=$(realpath ${MOCK})
REAL=${REALMOCK}.real
LOG=${REALMOCK}.log
@adiog
adiog / copy-based-history.hh
Created November 8, 2017 03:12
copy-based-history
#include <cassert>
template <typename T>
using history_t = std::vector<T>;
template <typename T>
void commit(history_t<T>& h) { assert(h.size()); h.push_back(h.back()); }
template <typename T>
void undo(history_t<T>& h) { assert(h.size()); h.pop_back(); }
@adiog
adiog / memdump64.c
Last active November 7, 2017 06:41
memdump64
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
void dump_memory_region(FILE* pMemFile, unsigned long start_address, long length)
{
unsigned long address;
int pageLength = 4096;
@adiog
adiog / sfinae.h
Created November 7, 2017 00:03
sfinae_class
#include <type_traits>
template <typename T, typename Enable = void>
class foo;
template <typename T>
class foo<T, typename std::enable_if<std::is_integral<T>::value>::type>
{ };
template <typename T>
@adiog
adiog / constexpr-fnv1a.h
Created November 6, 2017 20:44
hash-constexpr-fnv1a
#include <cstdint>
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
constexpr uint32_t val_32_const = 0x811c9dc5;
constexpr uint32_t prime_32_const = 0x1000193;
constexpr uint64_t val_64_const = 0xcbf29ce484222325;
constexpr uint64_t prime_64_const = 0x100000001b3;
inline constexpr uint32_t hash_32_fnv1a_const(const char* const str, const uint32_t value = val_32_const) noexcept {
@adiog
adiog / make_move_iterator.cc
Created November 5, 2017 19:27
make_move_iterator
#include <algorithm>
#include <iostream>
#include <iterator>
#include <ostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> dst;