This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
# It's simpler version of the example posted at: | |
# https://www.geeksforgeeks.org/union-find/ | |
class Graph: | |
edges = set() | |
def add_edge(self, src, dst): | |
'''Each edge has 2 vertices: source and destination.''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python3 program which calculates final mark based on previous and potential future marks. | |
# How to use this program: | |
# - modify "previous_marks" list (line 18) | |
# - run the program | |
# If the program fails to run because of missing libraries, you can run the following command: | |
# python3 -m pip install matplotlib tk numpy | |
import matplotlib | |
matplotlib.use('TkAgg') | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##from nltk.corpus import brown | |
## | |
###tw = brown.tagged_words(tagset='universal') | |
##tw = brown.tagged_words() | |
## | |
##vbz = [t for t in tw if t[1] == "VBZ"] | |
##print('Total number of VBZ tokens:', len(vbz)) | |
## | |
##is_ = [t for t in tw if t[0] == "is"] | |
##print('Total number of "is" words:', len(is_)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $# -eq 0 ]; then | |
PATH_DU="." | |
else | |
PATH_DU="$1" | |
fi | |
sudo du -ah --max-depth=1 $PATH_DU | sort -rh | head -n 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def reg_index(reg_name): | |
return [ | |
'zero', # always zero (x0) | |
'ra', # return address | |
'sp', # stack pointer | |
'gp', # global pointer | |
'tp', # thread pointer | |
't0', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!py -3 | |
''' | |
After using Vivado block design, creating a HDL wrapper for it, | |
and generating bitstream, this script can be used to move the | |
"_wrapper.bit" and ".hwh" files to pynq. | |
Tested on Windows only. | |
''' | |
import shutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Example usage with dma.sendchannel supplying the data: | |
import os, subprocess, sys, re, time | |
from pathlib import Path | |
from pynq import Overlay | |
from pynq import allocate | |
from threading import Thread | |
from dma_receiver import DmaReceiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
''' | |
This script can be replaced by simply using: | |
python3 -m serial.tools.list_ports -v | |
''' | |
import serial # pip install pyserial | |
import serial.tools.list_ports as list_ports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbed.h" | |
// mosi, miso (unused really), sclk | |
SPI sw(p5, p6, p7); | |
// lat (latch) pin of TLC59281 as shown in extension board schematic | |
DigitalOut lat(p8); | |
/* The extension board wiring from TLC59281 to 3 LEDs pairs are not consistent with | |
remaining 5 LEDs pairs (green is wired as red, red is wired as green). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbed.h" | |
Serial pc(USBTX, USBRX); // tx, rx | |
BusOut cols_out(p26, p25, p24); | |
// Checking extension board with multimeter shows that p14,p13,p12,p11 are connected | |
// to row indicating pins of the keypad. The extension board schematic is incorrect. | |
BusIn rows_in(p14, p13, p12, p11); |
OlderNewer