Skip to content

Instantly share code, notes, and snippets.

View kamirr's full-sized avatar
🐴
horse

Kamil Koczurek kamirr

🐴
horse
  • Golem Factory
  • Poland
View GitHub Profile
import socket
import base64
import cv2
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
cap = cv2.VideoCapture(0)
while True:
//use "path:/src/main/lib"
actor Main
new create(env: Env) =>
env.out.print("Stuff")
@kamirr
kamirr / aaron.cpp
Last active August 8, 2017 00:22
Aaron Numbers
// Compile with -std=c++1z and -ftemplate-depth=1025, may contain non–standard code, so GCC is preferred.
#include <iostream>
template<size_t n, int cnt = 3>
constexpr bool is_prime_impl() {
if constexpr(cnt >= n - 1) {
return true;
} else if constexpr(n % cnt == 0) {
return false;
} else {
/* SIMD */
#include <boost/simd/function/store.hpp>
#include <boost/simd/function/load.hpp>
#include <boost/simd/function/sum.hpp>
#include <boost/simd/memory.hpp>
#include <boost/simd/pack.hpp>
/* SFML */
#include <SFML/System/Vector2.hpp>
#include <boost/simd/function/load.hpp>
#include <boost/simd/function/sum.hpp>
#include <boost/simd/memory.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
#include <vector>
#include <chrono>
/*Żeby było mniej pisania*/
namespace bs = boost::simd;
@kamirr
kamirr / test.cpp
Last active January 18, 2017 14:31
int main() {
std::cout << "cardinal: " << cardinal << std::endl;
constexpr auto size = 512;
std::vector<float, bs::allocator<float>> vec1(size);
std::vector<float, bs::allocator<float>> vec2(size);
std::generate(vec1.begin(), vec1.end(), [](){return 5.f;});
std::generate(vec2.begin(), vec2.end(), [](){return .5f;});
@kamirr
kamirr / simd.cpp
Last active January 18, 2017 15:02
template <class allocator_t>
float simd(std::vector<float, allocator_t>& a, std::vector<float, allocator_t>& b) {
float sum = 0.f;
/* Deklarujemy paczki */
pack_t pack1;
pack_t pack2;
auto i = 0u;
/*Żeby było mniej pisania*/
namespace bs = boost::simd;
/* Będziemy używać paczek trzymających zmienne typu float */
typedef bs::pack<float> pack_t;
/* Stała (właściwie wyrażenie) cardinal będzie informować
o tym ile zmiennych mieści się w jednej paczce */
constexpr auto cardinal = bs::cardinal_of<pack_t>();
@kamirr
kamirr / naive.cpp
Last active January 18, 2017 15:01
/* Dowolny alokator */
template <class allocator_t>
/* Funkcja przyjmuje referencję na dwa wektory (z tym samym alokatorem) */
float linear(std::vector<float, allocator_t>& a, std::vector<float, allocator_t>& b) {
float sum = 0.f;
/* Jeśli jeden vector ma więcej elemntów niż drugi to je pomijamy */
for(auto i = 0u; i < std::min(a.size(), b.size()); ++i) {
sum += a[i] * b[i];
}
#include <iostream>
#include <cstdlib>
#include <chrono>
/* Measure time of function execution */
template<class Func>
std::chrono::duration<double> measure(Func f) {
auto point = std::chrono::high_resolution_clock::now();
f();