Skip to content

Instantly share code, notes, and snippets.

View Kobzol's full-sized avatar

Jakub Beránek Kobzol

View GitHub Profile
@Kobzol
Kobzol / recursion.cpp
Created September 15, 2016 17:12
Recursion
int n = 0;
void foo() {
void* x = nullptr;
printf("%d\n", ++n);
if (n >= 100) {
exit(0);
}
@Kobzol
Kobzol / bia.cpp
Created September 15, 2016 17:57
#include <iostream>
#include <vector>
#include <stdio.h>
#include <random>
#include <chrono>
class Point {
public:
double x, y;
@Kobzol
Kobzol / du1.hs
Created September 16, 2016 19:49
module Du1 where
import Prelude hiding (length, zip, zipWith, reverse, min)
-- 1. length of a list
length :: [t] -> Int
length [] = 0
length (x:xs) = 1 + length xs
@Kobzol
Kobzol / main.java
Last active September 28, 2016 12:14
String[][] tabulka = new String[15][5];
try (BufferedReader br = new BufferedReader(new FileReader("pocasi.csv")))
{
String s;
int radek = 0;
while ((s = br.readLine()) != null)
{
tabulka[radek++] = s.split(";");
}
@Kobzol
Kobzol / for.cpp
Created September 29, 2016 07:04
Loop unrolling
#include <iostream>
void for1(int x)
{
int* arr = new int[x];
for (int i = 0; i < x; i++)
{
arr[i] = i;
}
template <typename T, unsigned int S>
void convolution(cv::Mat& original, cv::Mat& resultImg, T kernel[S][S])
{
original.copyTo(resultImg);
int offset = S / 2;
T scale = 0;
for (int i = 0; i < S; i++)
{
for (int j = 0; j < S; j++)
@Kobzol
Kobzol / wtf.cpp
Created October 10, 2016 21:57
wtf
#include <iostream>
class A
{
public:
void fn() & {
std::cout << "A" << std::endl;
}
void fn() && {
std::cout << "B" << std::endl;
@Kobzol
Kobzol / words.c
Created October 20, 2016 14:57
Generate word at a given index
void generate(int index, int wordSize, int alphabetSize, char* result, char base = 0)
{
for (int i = wordSize - 1; i >= 0; i--)
{
int toSkip = std::pow(alphabetSize, i);
char c = index / toSkip;
result[wordSize - i - 1] = base + c;
index = index % toSkip;
}
}
@Kobzol
Kobzol / nahodna_velicina.R
Last active March 1, 2017 22:21
PS - nahodna velicina
str_hodnota = function(v, p)
{
sum(v * p);
}
rozptyl = function(v, p)
{
str_hodnota(v ** 2, p) - str_hodnota(v, p) ** 2
}
var_koeficient = function(v, p)
{
str_hodnota = function(v, p)
{
sum(v * p);
}
rozptyl = function(v, p)
{
str_hodnota(v ** 2, p) - str_hodnota(v, p) ** 2
}
var_koeficient = function(v, p)
{