mirror of
https://github.com/flancian/garden.git
synced 2026-08-08 07:26:21 +00:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 341c4a3edb | |||
| d9b13d8976 | |||
| 363818436a | |||
| 3e8e22e0e2 | |||
| 61f5724101 | |||
| 31fbecfba8 | |||
| 2a82de3a9d | |||
| 252361433d | |||
| e1b989680d | |||
| 953d9da069 | |||
| 32f525ff34 | |||
| bbf20dc60a | |||
| ec27c51dec | |||
| 0e8365e442 | |||
| cd42f3c692 | |||
| bb43d6eb13 | |||
| 193775f994 | |||
| 40022b71cd | |||
| dac90d8562 | |||
| 017039c012 | |||
| f9e64e007a | |||
| 3b8a0094de | |||
| 32009ab2ab | |||
| 935e444492 | |||
| e3e575a9f2 | |||
| 0dafd7ebaa | |||
| cb6419c982 | |||
| 88e7e2e252 | |||
| 3542718e9f | |||
| 1a2d2d48b3 | |||
| 10bab69801 | |||
| e7719a03f2 | |||
| cb39621e97 | |||
| d3b674a2e0 | |||
| e1985bd945 | |||
| a4cd9dc251 | |||
| 35ec6381d0 | |||
| 0fa80d61b9 | |||
| 6a3d32748f | |||
| a5eab0b0cb | |||
| 72d3e90b9a | |||
| 62f3323892 | |||
| fd9343eadd | |||
| 012412a30e | |||
| f0369bec56 |
Executable
+53
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# https://click.palletsprojects.com/en/8.1.x/arguments/
|
||||||
|
# https://click.palletsprojects.com/en/8.1.x/options/
|
||||||
|
#
|
||||||
|
# boilerplate shamelessly cloned from prime.py :).
|
||||||
|
|
||||||
|
import click
|
||||||
|
import math
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class AgoraCmd(click.Command):
|
||||||
|
def format_help(self, ctx, formatter):
|
||||||
|
click.echo("""Usage:
|
||||||
|
- Visit anagora.org/dice to execute this file in the Agora of Flancia.
|
||||||
|
- Visit e.g. anagora.org/dice/17 to throw a 17-sided die, and others :)
|
||||||
|
- In general visit anagora.org/foo, anagora.org/foo/bar to execute e.g. <bin/foo.py bar> from your garden.
|
||||||
|
""")
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
return super(AgoraCmd, self).__call__(
|
||||||
|
*args, standalone_mode=False, **kwargs)
|
||||||
|
except click.MissingParameter as exc:
|
||||||
|
exc.ctx = None
|
||||||
|
exc.show(file=sys.stdout)
|
||||||
|
click.echo()
|
||||||
|
try:
|
||||||
|
super(AgoraCmd, self).__call__(['--help'])
|
||||||
|
except SystemExit:
|
||||||
|
sys.exit(exc.exit_code)
|
||||||
|
|
||||||
|
def rand(n):
|
||||||
|
proof = []
|
||||||
|
for i in range(2, n+1):
|
||||||
|
r = random.randint(1, i)
|
||||||
|
if i == 2:
|
||||||
|
proof.append(f"You throw a fair coin and it lands [[{bool(r-1) and 'heads' or 'tails'}]].")
|
||||||
|
else:
|
||||||
|
proof.append(f"You throw a die of [[{i}]] sides and it comes up [[{r}]].")
|
||||||
|
|
||||||
|
return "\n".join(reversed(proof))
|
||||||
|
|
||||||
|
@click.command(cls=AgoraCmd)
|
||||||
|
@click.argument('n', type=click.INT)
|
||||||
|
def dice(n):
|
||||||
|
"""A simple randomness generator, imitating those we know and love from R^4 :)."""
|
||||||
|
proof = rand(n)
|
||||||
|
click.echo(proof)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
dice()
|
||||||
+18
-9
@@ -14,10 +14,17 @@ def factor(n):
|
|||||||
for i in range(2, n+1):
|
for i in range(2, n+1):
|
||||||
click.echo(f"Is {i} a factor of {n}, I wonder?")
|
click.echo(f"Is {i} a factor of {n}, I wonder?")
|
||||||
|
|
||||||
|
def print_sieve(sieve):
|
||||||
|
primes = []
|
||||||
|
for n, prime in enumerate(sieve):
|
||||||
|
if n >= 2 and prime:
|
||||||
|
primes.append(str(n))
|
||||||
|
return ", ".join(primes)
|
||||||
|
|
||||||
def is_prime(n):
|
def is_prime(n):
|
||||||
is_prime = [True for n in range(0, n+1)]
|
sieve = [True for n in range(0, n+1)]
|
||||||
upto = math.ceil(math.sqrt(n))
|
upto = math.ceil(math.sqrt(n))
|
||||||
for i, _ in enumerate(is_prime):
|
for i, _ in enumerate(sieve):
|
||||||
# click.echo(f"i: {i}")
|
# click.echo(f"i: {i}")
|
||||||
if i < 2:
|
if i < 2:
|
||||||
continue
|
continue
|
||||||
@@ -25,7 +32,7 @@ def is_prime(n):
|
|||||||
if i > upto:
|
if i > upto:
|
||||||
break
|
break
|
||||||
# If this is a known composite, then we've already crossed off its multiples when we iterated over its primes.
|
# If this is a known composite, then we've already crossed off its multiples when we iterated over its primes.
|
||||||
if not is_prime[i]:
|
if not sieve[i]:
|
||||||
continue
|
continue
|
||||||
# for j in range(2, math.ceil(math.sqrt(n) + 1)):
|
# for j in range(2, math.ceil(math.sqrt(n) + 1)):
|
||||||
for j in range(2, n):
|
for j in range(2, n):
|
||||||
@@ -34,11 +41,10 @@ def is_prime(n):
|
|||||||
break
|
break
|
||||||
PROOF.append(f"[[{i*j}]] is composite: {i} * {j}.")
|
PROOF.append(f"[[{i*j}]] is composite: {i} * {j}.")
|
||||||
try:
|
try:
|
||||||
is_prime[i*j] = False
|
sieve[i*j] = False
|
||||||
except IndexError:
|
except IndexError:
|
||||||
continue
|
continue
|
||||||
# click.echo(f"Sieve: {is_prime}.")
|
return (n >= 2 and sieve[n], sieve)
|
||||||
return is_prime[n]
|
|
||||||
|
|
||||||
class AgoraCmd(click.Command):
|
class AgoraCmd(click.Command):
|
||||||
def format_help(self, ctx, formatter):
|
def format_help(self, ctx, formatter):
|
||||||
@@ -65,11 +71,14 @@ class AgoraCmd(click.Command):
|
|||||||
@click.argument('n', type=click.INT)
|
@click.argument('n', type=click.INT)
|
||||||
def prime(n):
|
def prime(n):
|
||||||
"""Simple program that factors a number using a [[Sieve of Eratosthenes]]."""
|
"""Simple program that factors a number using a [[Sieve of Eratosthenes]]."""
|
||||||
if is_prime(n):
|
p, sieve = is_prime(n)
|
||||||
click.echo(f"[[{n}]] is prime.")
|
if p:
|
||||||
|
click.echo(f"*{n}* is *prime*.")
|
||||||
else:
|
else:
|
||||||
click.echo(f"{n} is not prime. Want proof? :)")
|
click.echo(f"*{n}* is *not prime*. Want proof? :)")
|
||||||
click.echo("\n".join([line for line in PROOF if f'[[{n}]]' in line]))
|
click.echo("\n".join([line for line in PROOF if f'[[{n}]]' in line]))
|
||||||
|
|
||||||
|
click.echo(f"\nPrimes up to {n}: {print_sieve(sieve)}.")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
prime()
|
prime()
|
||||||
|
|||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
prime.py
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# https://click.palletsprojects.com/en/8.1.x/arguments/
|
||||||
|
# https://click.palletsprojects.com/en/8.1.x/options/
|
||||||
|
#
|
||||||
|
# boilerplate shamelessly cloned from prime.py :).
|
||||||
|
|
||||||
|
import click
|
||||||
|
import math
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class AgoraCmd(click.Command):
|
||||||
|
def format_help(self, ctx, formatter):
|
||||||
|
click.echo("""Usage:
|
||||||
|
- Visit anagora.org/prompt to execute this file in the Agora of Flancia.
|
||||||
|
- Visit e.g. anagora.org/prompt/foo to prompt known models with 'foo'.
|
||||||
|
- In general visit anagora.org/foo, anagora.org/foo/bar to execute e.g. <bin/foo.py bar> from your garden.
|
||||||
|
""")
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
return super(AgoraCmd, self).__call__(
|
||||||
|
*args, standalone_mode=False, **kwargs)
|
||||||
|
except click.MissingParameter as exc:
|
||||||
|
exc.ctx = None
|
||||||
|
exc.show(file=sys.stdout)
|
||||||
|
click.echo()
|
||||||
|
try:
|
||||||
|
super(AgoraCmd, self).__call__(['--help'])
|
||||||
|
except SystemExit:
|
||||||
|
sys.exit(exc.exit_code)
|
||||||
|
|
||||||
|
@click.command(cls=AgoraCmd)
|
||||||
|
@click.argument('s', type=click.STRING)
|
||||||
|
def prompt(s):
|
||||||
|
"""A simple utility to redirect to generation providers."""
|
||||||
|
gen = f"https://anagora.org/{s}"
|
||||||
|
click.echo(gen)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
prompt()
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
- Mi idioma materno.
|
||||||
|
|
||||||
|
Hola! Gracias por estar acá. Si encontraste este video en youtube o en otro repositorio de videos: bienenide! Espero que en este día (en el día en que encontrás esto) te esté yendo bien :)
|
||||||
|
|
||||||
|
Escribo esto en [[2023-10-03]]. Qué fecha es por allá?
|
||||||
|
|
||||||
|
Para contestar, podés visitar https://anagora.org/2023-10-03 y leer ese nodo, o visitar una [[Stoa]].
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
- [[work]]
|
||||||
|
- meetings with [[er-ch]]
|
||||||
|
- [[consultation doc]]
|
||||||
|
- [[proposal]]
|
||||||
|
- [[flancia]]!
|
||||||
|
- I've been thinking of [[flancia home]] in the context of [[mohammed]]
|
||||||
|
- [[37]]
|
||||||
|
- [[bodhi]]
|
||||||
|
|
||||||
|
[[Imaginate un mundo sin latencia]] me dije, habiendo solucionado los problemas de conectividad bluetooth en [[nostromo]] :)
|
||||||
|
|
||||||
|
A veces extraño el [[español]] como idioma.
|
||||||
|
|
||||||
|
|
||||||
|
- #push [[youtube]]
|
||||||
|
- the uploading experience even on studio.youtube.com leaves me unsatisfied :)
|
||||||
|
- it is slow, you need to perform a multitude of clicks to get to publish something
|
||||||
|
- friction should be much lower than this!
|
||||||
|
|
||||||
|
Mientras escribo esto, estoy escuchando [[hola frank]] de [[sumo]] :)
|
||||||
|
|
||||||
|
- Next I will work on a [[proposal]] within the context of my work in the [[er-ch]].
|
||||||
|
- And on my personal computer I will start work on [[x]] as the evening progresses :)
|
||||||
|
|
||||||
|
Let us pray, dice Luca Prodan :)
|
||||||
|
|
||||||
|
- Four hours later, I'm back here after three hours of work and then dinner+yoga.
|
||||||
|
- [[janet]] made me laugh: https://www.youtube.com/watch?v=LXbYeJKcRf4
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- [[flancia]]!
|
||||||
|
- [[work]]
|
||||||
|
- [[er-ch]] gets intense sometimes
|
||||||
|
- still it's a privilege to represent [[zooglers]] and to some extent [[googlers]], meaning my fellow employees
|
||||||
|
- [[aldhari]]
|
||||||
@@ -5,4 +5,20 @@ Today is [[14 October 2023]] and I am glad you are here with me.
|
|||||||
|
|
||||||
It has been ages since I've in Flancia, sometimes it feels, even as time is varying.
|
It has been ages since I've in Flancia, sometimes it feels, even as time is varying.
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
Here is what I call a poem: [[trees]].
|
Here is what I call a poem: [[trees]].
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
This weekend I intend to advance what I call [[open letters]]: documents addressed to groups, openly published even as they are being written.
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
As of 21:45 CET I did some 'day job' stuff (having chosen it) and started a proposal (open letter, as per the above) that I had on my todo list.
|
||||||
|
|
||||||
|
Now switching to [[paramita]], planning to continue on related topics but in the [[commons]].
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
Today we bought the tickets to and from [[Sri Lanka]], happy about it!
|
||||||
|
|||||||
Reference in New Issue
Block a user