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
fn ui<B: Backend>(f: &mut Frame<B>, app: &App) { | |
let size = f.size(); | |
let chunks = Layout::default() | |
.direction(Direction::Vertical) | |
.margin(5) | |
.constraints( | |
[ | |
Constraint::Percentage(25), | |
Constraint::Percentage(25), | |
Constraint::Percentage(25), |
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
[package] | |
name = "nested_blocks" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
ratatui = "0.20.1" | |
crossterm = "0.23.2" |
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 invoke | |
import invoke.cli | |
from invoke import run, ctask as task, Collection | |
import sys | |
def redo_args(coll, baseargs=[]): | |
import our_tasks | |
root = our_tasks.__path__[0] | |
print "root is:", root | |
args = sys.argv[1:] |
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 csv | |
from calendar import monthrange | |
def get_n_days(year, month): | |
return monthrange(year, month)[1] | |
def due_month(year, month): | |
due_month = ((month + 6) % 12) | |
if due_month == 0: due_month = 12 | |
due_year = year + ((month + 6) // 12) |
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
void blockwrite(struct SR *sr, unsigned long long data, int bits) { | |
if (!SR_WRITEABLE(sr, bits)) { | |
wait = (bits + sr->pos) - 32; | |
LED_OUT &= ~LED1; | |
} | |
while (wait) { | |
//loop till something else makes wait go to 0 | |
} | |
if (1) LED_OUT |= LED1; |
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
# Make a forkpty wrapper that works nicely with gevent. | |
# This only wraps the process properly, the same way gevent.os.fork() does, | |
# and doesn't do anything special for dealing with the pty file descriptor. | |
# | |
# This was originally intended to work with pexpect, and does so nicely, since the | |
# head version of pexpect uses select.select and time.sleep in many places, effectively | |
# "geventifying" the expect interactions. | |
# | |
# Other things using forkpty and doing reads and writes via the pty will need to | |
# take a look at doing proper gevent wrapping of operations on the fd for now. |
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
class N(object): # analogous to a Task class | |
def __init__(self, func): | |
self.run = func | |
self.a = ":(" | |
self.b = ":(" | |
self.c = ":(" | |
self.d = ":(" | |
def __call__(self, *args, **kw): | |
print 'N WRAPPED a:', self.a, 'b:', self.b, 'c:', self.c, 'd:', self.d |
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
# Now you can do this from the command line: | |
$ commandname --list | |
--list | |
Available tasks: | |
foo |