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 <algorithm> | |
template<typename T> | |
bool all_equal(const T& c) | |
{ | |
return c.empty() or std::equal(++c.begin(), c.end(), c.begin()); | |
} | |
// Example: | |
// std::vector<int> v{42, 42, 42}; |
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
#ifndef base62_h | |
#define base62_h | |
#include <string> | |
/** Returns base 62 encoded unsigend integral value. | |
* base62(1234567890) // -> s"1ly7vk" | |
*/ | |
std::string base62(unsigned long long value) | |
{ |
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
/* | |
* ap_array - array container for Xilinx Vivado HLS | |
* Copyright (C) 2018 Bernhard Arnold <[email protected]> | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, |
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
/* | |
* hex2bytes - hex string of unlimited length to a continous block of bytes | |
* Copyright (C) 2018 Bernhard Arnold <[email protected]> | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, |
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
<?php namespace TextSearch; | |
/* Fallback if multibyte string plugin is not available. */ | |
if (!extension_loaded('mbstring')) { | |
function mb_strlen(...$args) { return strlen(...$args); } | |
function mb_strpos(...$args) { return strpos(...$args); } | |
function mb_stripos(...$args) { return stripos(...$args); } | |
function mb_substr(...$args) { return substr(...$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
#include <iostream> | |
#include <string> | |
#include <vector> | |
// sample container | |
struct jet | |
{ | |
typedef size_t pt_type; | |
pt_type pt; | |
}; |
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 | |
# | |
# Requires manylinux1 docker image | |
# | |
# Run 'init' on local host machine, then 'build', 'install' and 'wheel' from docher image. | |
# Note: wget will not work from manylinux1 docker image due to dreadful outdated OpenSSL! | |
# | |
# Docker instructions | |
# | |
# $ docker pull quay.io/pypa/manylinux1_x86_64 |
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
# Fractional prescales | |
from collections import OrderedDict | |
class Prescale: | |
def __init__(self, prescale, prec=2): | |
self.prescale = prescale | |
self.prec = 10**prec | |
self.count_max = self.prescale * self.prec | |
self.count = 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
# Fractional prescale patterns | |
# | |
# A = base | |
# B = base-1 | |
# | |
# .0: 1B, | |
# .1: 1A, 9B | |
# .2: 1A, 4B | |
# .3: 1A, 2B, 1A, 2B, 1A, 3B | |
# .4: 1A, 1B, 1A, 2B |
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 argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--orbits', type=int, default=1) | |
parser.add_argument('--precision', type=int, default=1) | |
parser.add_argument('--prescale', type=float, default=2.0) | |
parser.add_argument('--show-ticks', action='store_true') | |
args = parser.parse_args() |
OlderNewer