ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
#JSON
Map keys are always strings.
Unification
#characters #ASCII
Whitespace
9 character tabulation
10 line feed*
11 line tabulation
12 form feed
13 carriage return*
32 space

*line endings

MS Windows files use CR+LF as line ending.
#Nile
Terminology

Cloudnile, the cloud:
The website where authors hang out.

NILEPATH:
The directory that stores files downloaded from the cloud for offline use.

Author:
Any developer from beginner to expert.
Authors have XP levels.

App:
A bundle with a i.txt, a version history, and corresponding modules and resources mentioned in them.

Bundle:
Folders that include some modules and resources like databases, documentation, screenshots, etc.

Module:
.nile files, comprised of Nile code.
#Python
How to install a module

python -m pip install SomePackage

Normally, if a suitable module is already installed, attempting to install it again will have no effect. Upgrading existing modules must be requested explicitly:

python -m pip install --upgrade SomePackage
#toRead

📚 Controlling the Keyboard and Mouse with GUI Automation
#Python

https://automatetheboringstuff.com/chapter18/
Channel photo updated
#Python
The Zen of Python

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
#Python
Syntax

Definition:
def f(args):

Conditional
if expression:
⚠️ Use == to check for equality, not is.

Iteration:
for i in iterable:

Inside a function definition, use the following syntax to include the global variables in its scope:
def f(args):
global names
stuff
#Python
How to send GET or POST requests

import requests
r = requests.get(url)
r = requests.post(url, data=data)

r = r.json()
Exceptions
Events that occur during the execution of a program and disrupt the normal flow. An exception is an object that represents an error.

When raised, exceptions must be handled immediately, otherwise they would terminate the execution. If you have some suspicious code that may raise an exception, you can defend your program by placing it in a try block, followed by a except block which handles the problem as elegantly as possible.

try:
You do your operations here;
......................
except ExceptionI:
If there is ExceptionI, then execute this block.
except ExceptionII:
If there is ExceptionII, then execute this block.
......................
else:
If there is no exception then execute this block.


The list of all #Python exceptions:
https://docs.python.org/3/library/exceptions.html
“Desktop environment is something you normally don't think much about, once it's setup anyway, but finding an old screenshot while trying to clean up the drive can be oddly nostalgic.”
#Daniil_Baturin
“A language that makes it hard to write elegant code makes it hard to write good code.”
#Eric_Raymond, Why Python?
“All OO languages show some tendency to suck programmers into the trap of excessive layering. Object frameworks and object browsers are not a substitute for good design or documentation, but they often get treated as one. Too many layers destroy transparency: It becomes too difficult to see down through them and mentally model what the code is actually doing. The Rules of Simplicity, Clarity, and Transparency get violated wholesale, and the result is code full of obscure bugs and continuing maintenance problems.”
#Eric_Raymond, The Art of Unix Programming: Unix and Object-Oriented Languages
#characters
Therefore
“Computer science is a restless infant and its progress depends as much on shifts in point of view as on the orderly development of our current concepts.”
#Alan_Perlis
XML
data
<emptyTag/>
<tag> data </tag>
<tag attribute="value"> data </tag>

Lisp
(data)
(emptyTag)
(tag data)
(tag ((attribute value)) data)

JSON
"data"
{}
{"tag": "data"}
{"tag": [{"attribute": "value"}, "data"]}

NON
"data"
{}
{tag = "data"}
{tag = {{attribute = "value"}, "data"}}

#XML #Lisp #JSON #Nile
JSON to NON

Replacements:
[{
]
}
nullnone
"(.*)":$1 =

#JSON #Nile
#Nile
Vision
An app should be able to start executing as it is being downloaded similar to how audio or video files are able to start streaming while being downloaded.

This is achievable by storing outer layers of GUI in the beginning of the app file.