Skip to content

Instantly share code, notes, and snippets.

View andrejnano's full-sized avatar
🤹‍♂️
everything everywhere all at once

Andrej Nano andrejnano

🤹‍♂️
everything everywhere all at once
View GitHub Profile
@andrejnano
andrejnano / fizzbuzz.cpp
Last active August 29, 2017 18:08
[Fizzbuzz] example way of doing fizz-buzz problem
#include <iostream>
#include <string>
int main()
{
using namespace std;
for (int i = 0; i < 100; ++i)
{
string output;
@andrejnano
andrejnano / isprime.cpp
Created August 30, 2017 10:55
[Prime checker] checks if the number is a prime number, returns boolean #primes #c++
bool isPrime(int &n) {
if (n < 2) { return false; }
if (n == 2) { return true; }
// this can be optimized, no need to check for multiples of 2
// condition in for loop can be a sqrt of n
for (int i=2; i <= n / 2; ++i)
if (n % i == 0)
return false;
@andrejnano
andrejnano / bubblesort.cpp
Created September 25, 2017 13:10
[BubbleSort] c++, sorting, algorithm
void bubble_sort(std::vector<int> &v)
{
while(1)
{
bool swapped = false;
for(int i = 0; i < v.size() - 1; ++i)
{
if (v[i] > v[i + 1])
{
std::swap(v[i], v[i + 1]);
@andrejnano
andrejnano / pgrep.cpp
Created October 12, 2017 10:38
IPS uloha 1 [paralel grep] [c++]
/*
* IPS domaca uloha 1.
* Paralelni GREP
* 2016/17
* xmarko15
* xnanoa00
*
* @TODO osetrit chyby
* @TODO vycistit kod
* @TODO otestovat
@andrejnano
andrejnano / errorcodes.h
Created October 13, 2017 15:49
[IFJ ErrorCodes] Definicia chybovych kodov pre pouzitie v prekladaci
#ifndef ERRORCODES_H
#define ERRORCODES_H
/*
+ ---------------------------- +
| temporary macro error codes |
+ --------------------------- +
as defined in ifj2017.pdf
@andrejnano
andrejnano / token.h
Created October 13, 2017 16:03
[TOKEN DATA TYPE] definicia datoveho typu Token_t
#ifndef TOKEN_H
#define TOKEN_H
/*
+ ---------------------------- +
| TOKEN DATA STRUCTURE def. |
+ --------------------------- +
*/
/*
* \brief Checks if the current token is the expected one.
* If it is. It either frees the token and its memory
* or just moves on. In case of EOF, the function gets
* blocked for futher token getting. Just prints the error message.
* \param expected_token_type The expected token by syntax
* \return bool value, wether the token was found or not
*
* @TODO refactor a bit
*/
@andrejnano
andrejnano / add-separator.sh
Created December 25, 2017 01:44
[Mac OS | Dock Separator] adds blank icon to dock
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock
@andrejnano
andrejnano / dns_export-dns.pcap.out
Created November 10, 2018 16:26
example output from DNS-EXPORT of dns.pcap file
news.bbc.co.uk. CNAME newswww.bbc.net.uk. 2
newswww.bbc.net.uk. A 212.58.244.56 1
newswww.bbc.net.uk. A 212.58.246.80 1
www.bbc.co.uk. CNAME www.bbc.net.uk. 2
www.bbc.net.uk. A 212.58.246.95 2
www.bbc.net.uk. A 212.58.244.71 2
static.bbci.co.uk. CNAME static-bbci.bbc.net.uk. 2
static-bbci.bbc.net.uk. CNAME static.bbci.co.uk.edgekey.net. 2
static.bbci.co.uk.edgekey.net. CNAME e3891.g.akamaiedge.net. 2
e3891.g.akamaiedge.net. A 104.123.225.99 18
@andrejnano
andrejnano / fitkit_demo.c
Created December 18, 2018 14:39
fitkit_demo_imp
/* Header file with all the essential definitions for a given type of MCU */
#include "MK60D10.h"
/* Macros for bit-level registers manipulation */
#define GPIO_PIN_MASK 0x1Fu
#define GPIO_PIN(x) (((1)<<(x & GPIO_PIN_MASK)))
/* Constants specifying delay loop duration */
#define DELAY_T 200000