Skip to content

Instantly share code, notes, and snippets.

@AliYmn
AliYmn / docker-compose.yml
Last active December 14, 2020 06:39
django docker-compose.yml
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
volumes:
- /usr/src/app
@AliYmn
AliYmn / Docker.sh
Created August 4, 2017 21:52
Docker all Remove ps and images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@AliYmn
AliYmn / python_ogretici.py
Created June 27, 2017 21:21 — forked from cptangry/python_ogretici.py
Python 3 için Tek bir betik dosyasında ayrıntılı yorumlarla Python dilinin temel kavram ve uygulamaları ile açıklamaları. Dosya çalıştırılabilir.
#!/usr/bin/env python3.6
# coding: utf-8
"""
Çok Satırlı yorum:
Python Guido Van Rossum tarafından 90'ların başında geliştirilmeye
başlanmıştır.
"""
# Bu da bir tek satırlık yorum örneğidir.
@AliYmn
AliYmn / client.py
Created March 5, 2017 01:15
Python3x socket example
import socket
import sys
def get_constants(prefix):
"""Create a dictionary mapping socket module constants to their names."""
return dict((getattr(socket, n), n)
for n in dir(socket)
if n.startswith(prefix)
)
import paho.mqtt.client as mqtt
# This is the Publisher
client = mqtt.Client()
client.connect("ip_Adress",1883,60)
client.publish("temp/random", 5)
client.disconnect()
class SimpleMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
print('USER: {}'.format(request.user))
return response
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class SimpleMiddleware(MiddlewareMixin):
def process_request(self, request):
pass
@AliYmn
AliYmn / decorator_with_arguments.py
Created February 12, 2017 13:15
decorator_with_arguments
class decorator_with_arguments():
def __init__(self, arg1, arg2, arg3):
"""
__init__ kısmı bizim constructor bölümüdür.
@decerator_with_arguments(arg1,arg2,arg3) parametrelerini alır.
"""
print("__init__() Çalıştı ...")
# Değişken atamaları yapılır.
{% load mptt_tags %}
<ul>
{% recursetree nodes %}
<li>
{{ node.title }}
<br>
{{ node.image.url }}
{% if not node.is_leaf_node %}
<ul class="children">
{{ children }}
@AliYmn
AliYmn / func_wrap.py
Last active February 1, 2017 01:15
python @dekoratör fonksiyonlar
def arguman(arg):
def wrap(func):
def func_wrapper(name):
return "{} {}".format(arg, func(name))
return func_wrapper
return wrap
@arguman("Merhaba")
def get_text(name):