wayland...
h
🩵 avery cochrane 🩵
cherry valley forever
ojovivo

ellievsbear
we're not kids anymore.
𓃗

PR's Tumblrdome
Xuebing Du
wallacepolsom

❣ Chile in a Photography ❣
d e v o n
macklin celebrini has autism
todays bird
"I'm Dorothy Gale from Kansas"

No title available
sheepfilms
occasionally subtle

No title available
Monterey Bay Aquarium
seen from United States

seen from United States

seen from Türkiye
seen from Hungary

seen from United Kingdom

seen from Malaysia
seen from United States

seen from United States
seen from Poland

seen from Malaysia

seen from United States
seen from United States

seen from South Africa

seen from Canada

seen from Italy

seen from United States
seen from Spain

seen from Malaysia
seen from United States
seen from Netherlands
@tlaziuk
wayland...
joining paths in PHP
PHP is missing in some important functions available in other languages, eg. Python's os.path.join. Well, there's a replacement:
function joinPaths() { return preg_replace('|'.DIRECTORY_SEPARATOR.'+|', DIRECTORY_SEPARATOR, join(DIRECTORY_SEPARATOR, array_filter(func_get_args(), function ($var) { return is_string($var); }))); }
Filtering django models by now datetime
There might be a case where you might need to filter django objects by current time. Well, at least I did, and the things gets complicated when you want to filter a queryset for django-rest-framework.
This case seems to be easy, just use django.utils.timezone and it should be working. Well - not at all.
Due to how python works, values are assigned to class properties at the time of initialization of the script, it doesn't matter for methods, but when you need to do such thing as queryset = Date.objects.filter(time__lte=timezone.now()) it becomes a pain.
The solution is easy and fits most of your needs (at least if your database works in same timezone as your django) - django.db.models.functions.Now. The Now function filters the database by the CURRENT_TIMESTAMP query, which is great even for our queryset case.
Maybe that's not a genius conclusion, but I couldn't find answer elsewhere :)
restart process on low memory
Recently one of my client asked me to take a closer look on his server.
There was an issue where the php-fpm process caused the server to run out of memory after some time of execution. I couldn't get more details, so all what I did was to create this dead-simple script.
#!/usr/bin/env bash # get first arg, 512 is default value m=${1:-512} # get free memory amount in mb r=`free -m |awk 'NR==2' |awk '{ print$4 }'` if [ $r -lt $m ]; then service php-fpm restart fi
Tthis script is executing a command when free memory is lower than provided (or default) value. Actually you can place any command into that conditional block.
Hello World
Tomek: Hi! :)