Skip to content

Instantly share code, notes, and snippets.

View lucasmelin's full-sized avatar
🥽
Poking at stuff

Lucas Melin lucasmelin

🥽
Poking at stuff
View GitHub Profile
@lucasmelin
lucasmelin / watch_run.sh
Last active March 3, 2023 21:40
Find and watch in-progress GitHub Actions workflow runs
workflow=$(gh workflow list | fzf | cut -f1) &&
gh api user \
| jq -r '.login' \
| xargs -I {} gh run list -u {} -w $workflow -b main --json name,number,status,displayTitle,databaseId \
--template '{{tablerow "ID" "Title" "Run number"}}{{range .}}{{if eq .status "in_progress"}}{{tablerow .databaseId .displayTitle (printf "#%v" .number)}}{{end}}{{end}}' \
| fzf --header-lines=1 \
| cut -w -f1 \
| xargs -I {} gh run watch {} --exit-status
@lucasmelin
lucasmelin / raytracer.png
Last active January 6, 2023 02:16
Raytracer - Final World
raytracer.png
@lucasmelin
lucasmelin / .golangci.yaml
Last active July 19, 2022 20:15
Personal golangci-lint config
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
enable:
- asciicheck
- bidichk
- containedctx
- cyclop
- decorder
- depguard
@lucasmelin
lucasmelin / README.md
Created April 16, 2021 22:30 — forked from sandys/Fastapi-sqlalchemy-pydantic-dataclasses-reloadable-logging.md
fastapi with python 3.7 dataclasses - used to create both sqlalchemy and pydantic models simultaneously

cmdline

poetry run gunicorn testpg:app -p 8080 --preload --reload --reload-engine inotify -w 10 -k uvicorn.workers.UvicornWorker --log-level debug --access-logfile - --error-logfile - --access-logformat "SSSS - %(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s"

How to quickly run postgres (using docker)

docker run --network="host" -it --rm --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -e PGDATA=/var/lib/postgresql/data/pgdata -v /tmp/pgdata2:/var/lib/postgresql/data -e POSTGRES_USER=test postgres

This command will quickly start postgres on port 5432 and create a database test with user test and password mysecretpassword

@lucasmelin
lucasmelin / disabledusers.ps1
Created February 21, 2018 05:00
Powershell script to get all disabled Active Directory users
Get-ADUser -Filter * -SearchBase "ou=Disabled Accounts" -Searchscope "onelevel" | select givenname,surname,samaccountname,whenchanged | Out-File "disabled_users.txt"
@lucasmelin
lucasmelin / extract.py
Created February 21, 2018 04:35
Python script to extract unique rows from a csv
with open('input.csv','r') as in_file, open ('output.csv','w') as out_file:
seen = set()
for line in in_file:
if line in seen: continue
seen.add(line)
out_file.write(line)

Keybase proof

I hereby claim:

  • I am lucasmelin on github.
  • I am lucasmelin (https://keybase.io/lucasmelin) on keybase.
  • I have a public key whose fingerprint is 2E63 0DD5 92C5 5200 81E2 37AD 7A75 CC9E 065D D11A

To claim this, I am signing this object:

@lucasmelin
lucasmelin / guess.py
Created May 9, 2016 14:06
Simple number guessing game
import random
secret = random.randint(0, 100)
guess = 0
tries = 0
print ("Try to guess the number between 1 and 100!")
print ("You have 7 tries.")
while guess != secret and tries < 7:
guess = int(input("What is your guess? "))
if guess < secret:
print ("Too low, try again")
@lucasmelin
lucasmelin / bubblesort.py
Created May 9, 2016 14:05
BubbleSort Python Implementaton
for i in xrange(len(1)):
for j in xrange(len(1)):
if 1[i]>1[j]:
l[i], l[j] = l[j], l[i]
print (1[i])
@lucasmelin
lucasmelin / SaveTasks.java
Last active February 19, 2018 16:49
Save tasks to a file using FileWriter and an enhanced for-loop.
/**
* Saves tasks found in the ArrayList to a file.
* <p>
* Each task is separated by a newline,
* and the tasks are formatted using the createTabRecord method, which separates the values
* of the task with tab characters. This method also overwrites any previous files of the
* same name.
*/
private void saveTasks(){
if (tasks.isEmpty()){ // Make sure tasks ArrayList isn't empty