Skip to content

Instantly share code, notes, and snippets.

View Mhs-220's full-sized avatar
💻
Programming

MohammadHossein Shahmohammadi Mhs-220

💻
Programming
  • FashionCloud
  • Amsterdam
  • 01:31 (UTC +02:00)
View GitHub Profile
@adtac
adtac / Dockerfile
Last active April 13, 2024 22:33
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@jonashaag
jonashaag / celery_model_serializer.py
Last active March 28, 2022 23:14
Celery Django model serializer – pass Django model instances as arguments to Celery tasks
"""Our convenience Celery Task wrapper that allows us to conveniently pass
model instances as Task arguments.
It "serializes" model instances to IDs and "deserializes" these IDs to model
instances upon task execution.
Serialized representation of a model instance is (sentinel, app_name, model_name, pk).
"""
import celery
from django.apps import apps
@patrickelectric
patrickelectric / video_udp.py
Last active March 16, 2024 20:28
Get video from gstreamer udp with python and visualize with OpenCV
#!/usr/bin/env python
import cv2
import gi
import numpy as np
gi.require_version('Gst', '1.0')
from gi.repository import Gst
@MauricioMoraes
MauricioMoraes / access_postgresql_with_docker.md
Last active November 2, 2023 23:34
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@Francesco149
Francesco149 / osu_on_linux_overhaul.md
Last active April 12, 2024 21:56
Ultimate guide to low-latency osu on linux
@ebraminio
ebraminio / gist:5292017
Last active March 29, 2024 23:58
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, F#, Ruby, JavaScript, Dart, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir, PowerQuery M Language, VBA, R, Lua, Fortran, Pascal/Delphi, Excel, Stored Procedure / MySQL
// Check Iranian National Code Validity - Clojure, C#, F#, Ruby, JavaScript, Dart, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir, Power Query M Language, VBA, R, Lua, Fortran, Pascal/Delphi, Excel, Stored Procedure / MySQL
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، اف‌شارپ، روبی، جاوااسکریپت، دارت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی، راست، هسکل، ارلنگ، الکسیر، پاورکوئری ام، وی‌بی ای، آر، لوآ، فرترن، پاسکال/دلفی، اکسل، مای‌اس‌کیوال
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست https://web.archive.org/web/20170706081048/http://www.fardanews.com/fa/news/127747/رندترین-شماره-ملی-بلای-جان-صاحبش-شد
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 16, 2024 22:44
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'