Skip to content

Instantly share code, notes, and snippets.

View taiypeo's full-sized avatar

Ivan Lysenko taiypeo

View GitHub Profile
@taiypeo
taiypeo / spaapsshell.lua
Created December 22, 2019 06:29
A shell I made years ago for ComputerCraft
path = ""
sel = 1
function init()
term.clear()
term.setCursorPos(1,1)
dir = fs.list("")
for a, i in ipairs(dir) do
if a == 1 then
@taiypeo
taiypeo / pi.go
Last active March 14, 2023 11:27
Concurrent π calculation with Golang!
package main
import (
"fmt"
"math"
)
func partialSum(c chan<- float64, kStart int, kOffset int, amount int) {
// Using the Bailey–Borwein–Plouffe formula
@taiypeo
taiypeo / permutation.py
Created November 10, 2019 22:21
Permutation class for my linear algebra course
class Permutation:
def __init__(self, perm_list):
self.perm_list = perm_list
self.n = len(perm_list)
def __repr__(self):
return (
' '.join([str(i) for i in range(1, self.n + 1)]) +
'\n' +
' '.join([str(i) for i in self.perm_list])
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++;
});
});
// 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)
@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>
@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 / 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 / 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 / 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,