Loess.ru

having fun

Git clone branch from one remote to another by webhook call

quick and (very) dirty:

1.

git clone repo.git
cd repo
git status
git remote -v
git remote set-url --push origin git@github.com:User/repo.git

this should set your remote.origin.pushurl to another path, check it with

git remote -v

2. check it with

git pull origin master && git push

3. make sure you set your private and public ssh keys for pulling and pushing seamlessly

4. write bash script for this, for example:

cd /home/lol/repo/
echo $(date +%Y-%m-%d-%H:%M) >> /home/lol/copy-repo.log
git pull origin master >> /home/lol/copy-repo.log 2>&1
git push >> /home/lol/copy-repo.log 2>&1

You can skip and do this directly from within Python flask server with https://gitpython.readthedocs.io/en/stable/tutorial.html

5. Set up webhook @ first webservice to call @ push event. Write flask-server for getting webhooks, open incoming port, for example:

from flask import Flask
from flask import request
from bitbucket_webhooks import event_schemas
from bitbucket_webhooks import hooks
from bitbucket_webhooks import router
import subprocess

app = Flask(__name__)

@app.route("/hooks", methods=["POST"])
def bb_webhooks_handler():
    router.route(request.headers["X-Event-Key"], request.json)
    return ("", 204)

@hooks.repo_push
def _handle_repo_push(event: event_schemas.RepoPush):
    print(f"One or more commits pushed to: {event.repository.name}")
    subprocess.call("/home/lol/copy-repo.sh")

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=617, debug=False)

or if you prefer bash+netcat-like way, consider trying this https://gist.github.com/orangeblock/15ee8e3cb304a4046082b422adaaf5fb

6. wrap it into waitress call (i don’t know why but flask says it sufficient 😀 ):

if __name__ == '__main__':
    from waitress import serve
    serve(app,host="0.0.0.0",port=617)

7. wrap it into Systemd unit (https://blog.miguelgrinberg.com/post/running-a-flask-application-as-a-service-with-systemd):

[Unit]
Description=Webhook monitor for copying repo from BB to GitHub
After=network.target

[Service]
User=lol
WorkingDirectory=/home/lol
ExecStart=/usr/bin/python3 /home/lol/clone-repo-webhook-server.py
Restart=always

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start clone-repo-webhook-server
systemctl enable clone-repo-webhook-server

p.s. and you could combine this with git full-mirroring capabilities as you like
p.s. heres bb man https://support.atlassian.com/bitbucket-cloud/docs/create-and-trigger-a-webhook-tutorial/ and webhook listener repo https://bitbucket.org/atlassianlabs/webhook-listener which I haven’t read

FreeCad quick intro

SVG to FreeCAD:

quickest intro ever:

И ещё немножко мануалов по сборке сложных деталей:
https://wiki.freecadweb.org/Sketcher_Workbench


Канал с примерами:
https://www.youtube.com/channel/UC5nqtWv3094XLubtxzvK8zg

Current stable version 18.4 содержит неприятнейшую особенность — https://wiki.freecadweb.org/Topological_naming_problem

В последней 19 версии — она не исправлена, (хоть и неоднократно обещали), посему можно пользоваться продвинутым няшным форком:
https://github.com/realthunder/FreeCAD_assembly3/releases

Вот такую красоту (Himoto hi823402) можно сделать с нуля за пару вечеров:

Windows-tools и автозапуск SSHD в WSL2

Список плюшек для упрощения жизни windows-рабов:

https://vas3k.club/post/6238/
https://www.hanselman.com/blog/scott-hanselmans-2021-ultimate-developer-and-power-users-tool-list-for-windows

Включить цветную рамку текущего окна в win10 (https://habr.com/ru/post/544214/):
HKCU\Software\Microsoft\Windows\DWM\
EnableWindowColorization:REG_DWORD:1
ColorPrevalence:REG_DWORD:1

Включить все иконки в system tray (https://winaero.com/always-show-tray-icons-windows-10/):
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\
EnableAutoTray:REG_DWORD:0
или cmd -> shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}

WSL2:

Дабы SSHD был запущен при старте windows 10 (не входя в bash), надо его перезапустить из-под root:

wsl sudo service ssh --full-restart

можно даже такой батник в автозапуск засунуть

Далее кратко описан процесс установки WSL2 на Win10 home:
Read More

Git tools: diff docx/pdf, git server

Using git diff for doc, xls, pdf, ppt, odt:

https://gist.github.com/mbrehin/634f46aeacb0a9a6da5e (pdf)
for docx use pandoc as following (https://blog.martinfenner.org/posts/using-microsoft-word-with-git):

[diff "docx"]
textconv=pandoc --to=markdown
prompt = false

Git personal server

(Gitolite, Cgit, fcgiwrap, and Nginx)

https://bryanbrattlof.com/cgit-nginx-gitolite-a-personal-git-server/ (pdf)

and more of freshly-baked gitlab alternatives: https://www.cyberciti.biz/open-source/github-alternatives-open-source-seflt-hosted/

Правило 20 секунд

Здесь было видео «Use Laziness To Your Advantage — The 20 Second Rule», но «Видео недоступно, Автор ограничил доступ к видео.», поэтому теперь версия на русском:

Кратко: Избавляйтесь от плохих привычек, делая их на 20 секунд сложнее, и приобретайте хорошие — делая их на 20 секунд проще
(от себя: и закрепляя их в течение ~40 дней)

Each neuron is two-layer computational network. And it strives for living

«… Yet, it is fascinating that, while surviving, a neuron makes computation.»

https://medium.com/the-spike/neuron-core-computational-principles-ed0fe9cfb711

https://medium.com/the-spike/your-cortex-contains-17-billion-computers-9034e42d34f2

Ася Казанцева. Как сдать любой экзамен, выучить иностранный язык и почему алкоголь меняет память?

44:44 — про организацию внешних ситуаций для того, чтобы жить правильно (правило 20 секунд)
49:25 — про дневники и историю в чятиках

Backing up your git repos

git clone --mirror path/to/original path/to/dest/.git
cd path/to/dest
git config --bool core.bare false
git checkout anybranch

https://stackoverflow.com/questions/67699/how-to-clone-all-remote-branches-in-git

p.s. можно просто git clone --mirror path/to/original,
затем — mv original.git .git и далее — по инструкции git config..., git checkout...

Современный гейминг

Ажиотажный спрос на новые карты Nvidia — заслуга не производителя, а косоруких разработчиков игр — что доказано c выходом Cyberpunk 2077.
Несмотря на то, что разработки lcd-панелей перешли рубеж в 480Hz, культура software-разработки, далёкой от железа, катится в пропасть, а гейминг — за ней.

Шиза грядёт! 😀

Online 2d graphing tool

http://memorystomp.com/graphtoy/#draw1%3Dtrue%26formula1%3Dsin(4*x)%252Fx%26draw2%3Dtrue%26formula2%3Dfloor(x-frac(t))%252Bfrac(t)%26draw3%3Dtrue%26formula3%3Dnoise(x)*x%26draw4%3Dtrue%26formula4%3D2%2B*%2Babs(%2Bfloor(x*0.5%252B0.5)%2B-%2B0.5*x%2B)%26draw5%3Dtrue%26formula5%3Dlog(x)%26draw6%3Dtrue%26formula6%3D-x%252Bsin(x)%26draw7%3Dtrue%26formula7%3Dtri(0.3%252Cx-t*b)%26draw8%3Dtrue%26formula8%3Df7(x)%2B%252B%2Bf7(x*(2%252Ba))*0.5%2B%252B%2Bf7(x*(4%252Ba))*0.25%2B%252B%2Bf7(x*(8%252Ba))*0.125%26mShowAxes%3Dtrue%26mShowGuides%3Dtrue%26mShowGrid%3Dfalse%26paused%3Dfalse%26lightTheme%3Dfalse%26mXres%3D960%26mYres%3D720%26mCx%3D-0.7874999999999996%26mCy%3D-1.4625000000000006%26mRx%3D12%26mRy%3D9%26backgroundCol%3D%26A%3D0.271%26B%3D0.254%26C%3D0.130%26mySize%3D1%26myPresets%3D0