Skip to content

Instantly share code, notes, and snippets.

View taiypeo's full-sized avatar

Ivan Lysenko taiypeo

View GitHub Profile
@taiypeo
taiypeo / BrainfuckInterpreter.cpp
Created August 21, 2015 19:26
Simple Brainfuck interpreter written in C++
#include <iostream>
#include <stack>
int main()
{
std::string program;
unsigned char tape[30000] = {0};
unsigned char* ptr = tape;
@taiypeo
taiypeo / BrainfuckInterpreter.c
Last active August 29, 2015 14:27
A Brainfuck interpreter written in C
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define STACK_MAX 100
#define TAPE_MAX 30000
#define ECHO_MESSAGES 1
enum MESSAGE
@taiypeo
taiypeo / pi.c
Last active December 19, 2016 00:17
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
char* calculatePi(unsigned long digits);
int main()
{
const unsigned long piDigits = 500;
char* pi = calculatePi(piDigits);
@taiypeo
taiypeo / png2ascii.cpp
Created December 19, 2016 00:17
A basic app that converts .png images to ASCII art
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <vector>
#include "lodepng/lodepng.h" // you have to have lodepng in this folder to compile
bool open_input(std::string filename, std::vector<unsigned char> &img, unsigned int &width,
@taiypeo
taiypeo / error_macro.html
Created February 22, 2018 12:18
A Jinja2 macro that prints all of the errors of a WTForms field
{% macro print_errors(field) -%}
{% for err in field.errors %}
<span style="color: red;">[{{ err }}]</span>
{% endfor %}
{%- endmacro %}
@taiypeo
taiypeo / phystools.py
Created February 25, 2018 12:36
A simple graphing program on Python for my experimental physics classes
import matplotlib.pyplot as plt
def get_input():
print('X label?')
xlabel = input()
print('Y label?')
ylabel = input()
@taiypeo
taiypeo / decorators.py
Created March 3, 2018 14:01
A bunch of Flask decorators that I used
def role_required(role=ROLE_USER):
def wrapper(f):
@wraps(f)
def role_checker(*args, **kwargs):
if not current_user.is_authenticated:
abort(403)
if role == ROLE_USER or current_user.role == role:
return f(*args, **kwargs)
else:
@taiypeo
taiypeo / centered.html
Created March 25, 2018 20:01
Semantic UI centered text
<div class="ui one column centered grid">
<h1 class="row">text</h1>
</div>
<div class="ui divider"></div>
// Based on Ben Eater's tutorial
#define SHIFT_DATA 2
#define SHIFT_CLOCK 3
#define SHIFT_LATCH 4
#define EEPROM_I0 5
#define EEPROM_I7 12
#define WE 13
void set_address(int addr, bool OE)
let last_index = 0; // TODO: check if last_index is in range of videos.length
sections.forEach(section => {
section.data.forEach(item => {
item['video'] = last_index;
last_index++;
});
});