You are not logged in.
Pages: 1
I'm currently translating a semi-fictional novel about Bitcoin (on a Bunsenlabs machine, of course). In one scene a hacker is looking at "code" that's flowing up the screen. Now, from my very little scripting experience, the flowing lines ought to be output, not code. Am I right? Or is there any situation where looking at a stream of code would be helpful.
I'd hate to embarrass myself in front of more competent readers, so any clarification is appreciated.
Offline
Code is inside the program neo.
Try this in a terminal.
COL=$(( $(tput cols) / 2 )); clear; tput setaf 2; while :; do tput cup $((RANDOM%COL)) $((RANDOM%COL)); printf "%$((RANDOM%COL))s" $((RANDOM%2)); done
Offline
Try this in a terminal.
Haha, I'll leave it running to freak out my coworkers.
Offline
$ sudo apt install cmatrix
8bit
A mind is a terrible thing not to change.
The problem lies not with new ideas, but in escaping the old ones.
Offline
(@OP sorry about the thread drift)
And there is this python script for a matrix-like effect...
#!/usr/bin/env python
#Create "The Matrix" of binary numbers scrolling vertically in your terminal.
#original code adapted from juancarlospaco:
#- http://ubuntuforums.org/showpost.php?p=10306676
#Inspired by the movie: The Matrix
#- Corey Goldberg (2013)
import fcntl
import time
import random
import struct
import sys
import termios
class message(str):
def __new__(cls, text, speed):
self = super(message, cls).__new__(cls, text)
self.speed = speed
self.y = -1 * len(text)
self.x = random.randint(0, display().width)
self.skip = 0
return self
def move(self):
if self.speed > self.skip:
self.skip += 1
else:
self.skip = 0
self.y += 1
class display(list):
def __init__(self):
self.height, self.width = struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
self[:] = [' ' for y in range(self.height) for x in range(self.width)]
def set_vertical(self, x, y, string):
string = string[::-1]
if x < 0:
x = 80 + x
if x >= self.width:
x = self.width - 1
if y < 0:
string = string[abs(y):]
y = 0
if y + len(string) > self.height:
string = string[0:self.height - y]
if y >= self.height:
return
start = y * self.width + x
length = self.width * (y + len(string))
step = self.width
self[start:length:step] = string
def __str__(self):
return ''.join(self)
def matrix(iterations, sleep_time=.08):
messages = []
d = display()
for _ in range(iterations):
messages.append(message('10' * 16, random.randint(1, 5)))
for text in messages:
d.set_vertical(text.x, text.y, text)
text.move()
sys.stdout.write('\033[1m\033[32m%s\033[0m\r' % d)
# sys.stdout.write('xyz')
sys.stdout.flush()
time.sleep(sleep_time)
if __name__ == '__main__':
while True:
try:
matrix(150)
except KeyboardInterrupt:
sys.stdout.write('\n\033[1m\033[32m=== Matrix Stopped ====\033[0m\n')
sys.exit()
Be Excellent to Each Other...
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
There is also hollywood in the repos, for a "Hollywood" output in the terminal!
Be Excellent to Each Other...
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
from my very little scripting experience, the flowing lines ought to be output, not code. Am I right? Or is there any situation where looking at a stream of code would be helpful.
I have wondered that myself, posting to forums etc.
IMO code is something that needs to be executable one way or another (even HTML is code), and output is something that is produced by software.
But in my experience even IT specialists & native English speakers tend to call output code - but not the other way round.
BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
Offline
Some output is code, no?
Are config files code? Maybe anything that's written to be read by a computer is code?
John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.
Offline
Are config files code?
Yes, I did not consider config files. I'd say they count as code.
Maybe anything that's written to be read by a computer is code?
Exactly.
Terminal output is not primarily written to be read by a computer!
BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
Offline
Having recently looked into the spectrwm window manager i believe they really struck a good balance in regards to the config file to run the code, that being the window manager written in C and shell scripts. This probably delves into programming language as not all programs need a config file to execute.
Offline
^ I guess you talk about human readable code there.
Yeah, it's important.
Just compare fluxbox' config file syntax to openbox'!
BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
Offline
Pages: 1