b0nfire.xyz is a Fediverse instance that uses the ActivityPub protocol. In other words, users at this host can communicate with people that use software like Mastodon, Pleroma, Friendica, etc. all around the world.
This server runs the snac software and there is no automatic sign-up process.
I'd like to do some "graphics" programming, but a specific type.
I want to display white dots on a black backround. Calculate a new set of dots, and spit them to the screen. Don't mind if I have to turn off old dots myself.
SBCL would be optimal, Python OK, C/C++ no thanks city.
Do any GUI toolkits support such a widget???
Any recommendations/experience doing this sort of thing???
Tell #Python to recite the powers of two in English
$ seq 1 16|while read n;do echo $((2**n));done|python3 -c "import sys,inflect;p=inflect.engine();[print(p.number_to_words(int(x.strip()))) for x in sys.stdin if x.strip()]"
Calculate pi to n digits with #python
#!/usr/bin/python3
from decimal import Decimal, getcontext
import sys
digits = int(sys.argv[1]) if len(sys.argv) > 1 else 50
getcontext().prec = digits + 5
def arctan(x):
x = Decimal(x)
x2 = x * x
term = Decimal(1) / x
total = term
n = 1
sign = -1
while True:
term = term / x2
delta = term / (2 * n + 1)
if delta == 0:
break
total += sign * delta
sign *= -1
n += 1
return total
pi = 16 * arctan(5) - 4 * arctan(239)
pi = +pi
print(f"Pi to {digits} digits:\n{str(pi)[:digits+2]}")
Build a random maze with #Python
#!/usr/bin/python3
from random import shuffle, randrange
def makemaze(w=20,h=12):
vis = [[0] * w + [1] for _ in range(h)] + [[1] * (w + 1)]
ver = [["| "] * w + ['|'] for _ in range(h)] + [[]]
hor = [["+--"] * w + ['+'] for _ in range(h + 1)]
def walk(x, y):
vis[y][x] = 1
d = [(x - 1, y), (x, y + 1), (x + 1, y), (x, y - 1)]
shuffle(d)
for (xx, yy) in d:
if vis[yy][xx]: continue
if xx == x: hor[max(y, yy)][x] = "+ "
if yy == y: ver[y][max(x, xx)] = " "
walk(xx, yy)
walk(randrange(w), randrange(h))
s = ""
for (a, b) in zip(hor, ver):
s += ''.join(a + ['\n'] + b + ['\n'])
return s
print(makemaze())
Find the intersection of two lines from four points with #linearalgebra under #Python
#!/usr/bin/env python3
import sys,numpy as n
p,q,r,s=map(n.array,((float(sys.argv[i]),float(sys.argv[i+1])) for i in (1,3,5,7)))
M=n.c_[q-p,s-r]
d=n.linalg.det(M)
if abs(d)<1e-10:
print("Coincident" if abs(n.cross(q-p,r-p))<1e-10 else "Parallel")
else:
t,_=n.linalg.solve(M,r-p)
print(p+t*(q-p))
Logical truth tables in #Python
#!/usr/bin/env python3
import sys
from itertools import product
bexp=" ".join(sys.argv[1:])
code=compile(bexp,"<string>","eval")
names=code.co_names
print("\n" + " ".join(names),":",bexp)
for values in product(range(2), repeat=len(names)):
env=dict(zip(names,values))
print(" ".join(map(str,values)),":",int(eval(code,env)))
#!/usr/bin/env python3
from datetime import*
t=datetime.today()
print("Only",(datetime(t.year,12,25)-t).days,"shopping days until Christmas.")
Plot a 3D sphere with #Python
#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
theta, phi = np.linspace(0, 2 * np.pi, 50), np.linspace(0, np.pi, 20)
THETA, PHI = np.meshgrid(theta, phi)
R = 1.0
X = R * np.sin(PHI) * np.cos(THETA)
Y = R * np.sin(PHI) * np.sin(THETA)
Z = R * np.cos(PHI)
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='3d')
plot = ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1, linewidth=.1, color='red', antialiased=False, alpha=1)
plt.show()
Convert time in seconds to larger units with #Python:
#!/usr/bin/env python3
import sys
sec=int(sys.argv[1])
def dur(sec):
t=[]
for dm in (60,60,24,7):
sec, m=divmod(sec,dm)
t.append(m)
t.append(sec)
return ', '.join('%d %s' % (num,unit)
for num, unit in zip(t[::-1], 'wk d hr min sec'.split())
if num)
print ("%7d seconds = %s" % (sec,dur(sec)))
Invoke the Dark Lord with #Python using turtle graphics:
#!/usr/bin/env python3
import turtle
turtle.bgcolor("green")
t = turtle.Turtle()
t.color("red", "blue")
t.begin_fill()
for _ in range(5):
t.forward(200)
t.right(144)
t.end_fill()
t.hideturtle()
turtle.exitonclick()
Calculate the complete elliptic integral of the second kind with #Python (in this case the perimeter of the orbit of Mercury in AU):
#! /usr/bin/python3
import math
import sys
a = float(sys.argv[1])
b = float(sys.argv[2])
h = ((a - b) / (a + b))**2
eps = sys.float_info.epsilon
def binom_half(n):
coef = 1.0
for k in range(n):
coef *= (0.5 - k) / (k + 1)
return coef
perimeter = 0.0
n = 0
term = 1.0
while abs(term) > eps:
coef = binom_half(n)
term = (coef**2) * h**(2*n)
perimeter += term
n += 1
perimeter *= math.pi * (a + b)
print(f"Ellipse perimeter: {perimeter:.17f}")
print(f"Series converged after {n} terms")
Factors with #Python
#! /usr/bin/python3
from sys import*
from sympy.ntheory import factorint as f
for i in range(int(argv[1]),int(argv[2])+1):print(i,f(i,multiple=1))
Plot an ellipsoid with #Python
#! /usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
r = 10
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = r * np.outer(np.cos(u), np.sin(v))
y = r * np.outer(np.sin(u), np.sin(v))
z = r * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, color='linen', alpha=0.5)
theta = np.linspace(0, 2 * np.pi, 100)
z = np.zeros(100)
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, color='black', alpha=0.75)
ax.plot(z, x, y, color='black', alpha=0.75)
zeros = np.zeros(1000)
line = np.linspace(-10,10,1000)
ax.plot(line, zeros, zeros, color='black', alpha=0.75)
ax.plot(zeros, line, zeros, color='black', alpha=0.75)
ax.plot(zeros, zeros, line, color='black', alpha=0.75)
plt.show()
I am looking forward to seeing so many of you at #EuroPython, please come to the #PyCharm booth and talk about #Python and maybe #Rust? We have something cool to show you 😉
Check out the scheulde and register ticket here: https://ep2026.europython.eu/ also make sure you come to the #RustSummit
Python Quick Ref for JS Devs: A Side-by-Side ES6 & TypeScript to Python Reference by Samir Solanki is a new release on Leanpub!
Stop translating Python in your head. Compare ES6/TypeScript and Python side by side and start writing Python with confidence.
Link: https://leanpub.com/pythonquickref
#books #ebooks #newreleases #leanpublishing #selfpublishing #python #es6
heise+ | Die eigenen Lieblingsfilme durch paarweises Vergleichen herausfinden
Gefällt Ihnen Memento oder Heat besser? Unsere kleine Webanwendung findet durch paarweises Vergleichen statistisch Ihre Lieblingsfilme.
#Filme #IT #JavaScript #Python #Softwareentwicklung #Statistik #news
Area of any valid triangle with #Python
#!/usr/bin/python3
import sys, math
a, b, c = map(float, sys.argv[1:])
if a + b <= c or a + c <= b or b + c <= a:
print("Error: not a valid triangle")
sys.exit(1)
peri = a + b + c
area = math.sqrt((a + b + c) *
(a + b - c) *
(a - b + c) *
(-a + b + c)) / 4
print("Perimeter =", peri)
print("Area =", area)
Put text in an ASCII art box with #Python
#!/usr/bin/env python3
import sys
print("+" + "-" * 62 + "+")
for line in sys.stdin:
print(f"| {line.rstrip():<60} |")
print("+" + "-" * 62 + "+")
#Apollo and #Python. Ovide moralisé en prose, Bruges ca. 1470-1480. BnF, Français 137, fol. 8r.
#medieval #MedievalArt
Print all primes less than 5000 with #Python
python3 -c 'print([i for i in range(2,5000) if all(i%j for j in range(2,int(i**0.5)+1))])'
Reformat standard input to any width with #Python
#!/usr/bin/python3
import sys
import textwrap
w=int(sys.argv[1])
for line in sys.stdin:
print(textwrap.fill(line,width=w))
#Python script to show top 20 #bash commands:
#!/usr/bin/env python3
from collections import Counter
import matplotlib.pyplot as plt
import os
history_file = os.path.expanduser("~/.bash_history")
counter = Counter()
with open(history_file, "r", errors="ignore") as f:
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
cmdline = line.split("|", 1)[0].strip()
parts = cmdline.split()
if not parts:
continue
cmd = parts[1] if parts[0] == "sudo" and len(parts) > 1 else parts[0]
counter[cmd] += 1
top = counter.most_common(20)
commands, counts = zip(*top)
commands = commands[::-1]
counts = counts[::-1]
plt.figure(figsize=(10, 6))
plt.barh(commands, counts)
plt.title("Top 20 Bash Commands (frequency)")
plt.xlabel("Usage count")
plt.tight_layout()
plt.show()
I programmed python for a living in the late 1990's, as I got into data analysis I switched to R in the very late 1990's and early 2000's, then in 2019 or so switched almost entirely to Julia. I also have experience in C, C++, Common Lisp and lots of other languages.
I need to write *modern* python for micropython for my project with my kid. What's like the 3 page zine refresher on modern python I should read? #python #programming #micropython
So i managed to load micropython on to one of my ESP32 devices. I am not clear how I load python code onto the board though. The docs weren't super clear on this. Any hints?
#HIRING! Senior Engineer, #python based full stack but leaning to devops/infra. 70/30 would be my ideal split. Fully remote UK only, £63,000 non negotiable sadly, but ~20% pension on top. Closing date: WEDS NOON! So get in touch (thayer@team-prime.com) asap if this might be you.
Org: healthcare, data, ~30 person team. Zero AI currently in place, but some may be implemented very gently/ethically/thoughtfully over the next year, or not!
Would esp suit someone who prefers chill vs rocket ship.
I'm looking for work, please boost!
I'm a senior software engineer with 35 years of experience. I've worked across an unusually wide range of domains: mobile game backends, privacy-preserving data platforms, high-throughput COVID testing infrastructure, email and account systems, e-payment processing, job marketplace systems, and bioinformatics. I pick up new domains quickly and have a track record of doing it repeatedly. I understand how to turn business needs into engineering requirements.
I've worked remotely since the 1990s and can operate with minimal supervision. I don't need hand-holding to find the right problem to solve. Several of my most valued projects were self-directed: I identified the need, built the thing, and shipped it.
Some of the technologies I'm familiar with include: Python, Perl, TypeScript/JavaScript, Haskell, Go, C, Java. Postgres, MySQL, SQLite. Flask, SQLAlchemy. AWS (Lambda, S3, RDS, SQS, EC2). Docker, Git. Github and Gitlab.
I've also repeatedly picked up new languages and stacks as needed: Haskell for differential privacy research, TypeScript for a 24/7 AWS Lambda system, Flask for my most recent employer. I've become productive with new systems over and over, and I can do it quickly.
I'm also a published author (Higher-Order Perl, Morgan Kaufmann), longtime blogger, and conference speaker with a reputation for making complex ideas clear.
My résumé is at https://plover.com/~mjd/cv/Mark%20Jason%20Dominus.pdf
mjd@pobox.com
Thanks for your attention!
#OpenToWork #remoteWork #softwareEngineering #Python #backend #hiring
J. R. DePriest
:EA DATA. SF: [She / Her / Goddess] » 🌐
@jrdepriest@infosec.exchange
Since there has been a huge influx of new users, I decided to write a new #Introduction and actually pin it to my profile.
I'm pushing 50 years old and I live in a Red State that is trying to make me illegal. I'm a #pansexual / #bisexual #transgender woman married to a heterosexual cisgender woman who frequently talks about the current hellscape for people like me in my Toots.
I'm #NeuroDivergent / #ND which is probably why all of these sentences start with "I".
I've worked in #InfoSec for a little over 20 years. I've had lots of roles in #SecEng, #SecOps, and #ThreatManagement. I taught myself #Perl, #Bash, #SQL, and #PowerShell. I'm decent at #JavaScript. I can read #Python and #Ruby. I enjoy automating things and turning manual processes into scripts.
I've been the primary #CareGiver to my wife for 8 years since she developed a chronic condition and went on disability.
My hobbies including #writing #paranormal short fiction, journaling my #dreams, and playing #PCGames on my laptop and #SteamDeck.
I prefer #StarGate over #StarTrek over #StarWars. Still waiting for Amazon to do something, anything with the Stargate property.
While we loved the #ArrowVerse including #Stargirl and #SwampThing, in general we prefer #Marvel over #DC.
I'm a fan of #Horror / #HorrorFam, #HorrorMovies and #HorrorBooks, especially the existential dread of #CosmicHorror or #LovecraftianHorror. I tend to sympathize with the nameless terrors. I am not a fan of mindless slashers, unrelenting gore, or torture porn. Over-the-top, egregious gore that crosses into the absurd is fine, though, so I am a Sam Raimi fan, obvs. Also, #HorrorComedies are underappreciated.
I'm slowly reconnecting with my #Pagan roots. I knew some stuff about #Tarot and had a friend who as a tree a lifetime ago and I'm trying to rekindle that.
We've got #Cats and they are our kids. I also happen to love #Frogs, but we don't have any of those.
#BLM #BlackLivesMatter
#TransgenderRightsAreHumanRights
#LGBT #LGBTQ #LGBTQIA
#ThePandemicIsNotOver
#ClimateChangeIsReal
#SexWorkIsWork
aw ye whats up my bozos it's static type checking for array shape and dtype constraints so you no longer have to toil in the mines of infinity incomprehensible (ndarray)->ndarray functions like bunch of clowns face smacking in a field of rakes
https://numpydantic.readthedocs.io/en/latest/typecheckers.html