Skip to content

Instantly share code, notes, and snippets.

View mebaysan's full-sized avatar
🏠
Working from home

Baysan mebaysan

🏠
Working from home
View GitHub Profile
@mebaysan
mebaysan / form.html
Created May 30, 2020 17:58
Django Türkiye İl-İlçe Modeli ve Data Generator
<!-- bu blok ilgili formun bulunduğu sayfadan alınmıştır -->
<div class="form-group col-md-6 space-30" id="il_div">
<label class="control-label" for="inputemail">İl *</label>
<select name="il" id="il_secim" class="form-control" style="color: black;">
{% for il in iller %}
<option value="{{ il.ad }}" data-id="{{ il.pk }}">{{ il.ad }}</option>
{% endfor %}
</select>
</div>
@mebaysan
mebaysan / README.md
Created May 31, 2020 00:32
Django Deployment Ubuntu

Django Deployment to Ubuntu 18.04

Yeni kullanıcı oluşturuyoruz

Uzak sunucumuzua bağlanmak için kendimize bir kullanıcı oluşturuyoruz. Şifresini güçlü oluşturmalıyız.

# adduser yeni_kullanici
@mebaysan
mebaysan / dosya.txt
Created May 31, 2020 00:33
pythonanywhere.com Deployment
dashboardımızdan web sekmesine tıklıyoruz ve yeni bir app oluşturuyoruz custom seçeneğini seçiyoruz
ardından bash console açıyoruz
/home/kullanici_adiniz/.virtualenvs -> bu dizin altında virtualenvlerimiz bulunur
mkvirtualenv --python=/usr/bin/python3.8 venv -> /home/kullanici_adiniz/.virtualenvs altına venv adında bir virtualenv kurar
git repomuzu /home altına klonluyoruz
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
@mebaysan
mebaysan / python.py
Created July 16, 2020 07:47
Python3 ile TLS versiyonu öğrenmek
# Python3 - requests package
import requests
print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])
# Python3 - urllib package
import json
import urllib.request
@mebaysan
mebaysan / intro_callback.py
Last active September 21, 2020 19:19
Intro Plotly Dash Callback
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
my_input = dcc.Input(id='my-input', # component id'si
type='text', # input tipi
placeholder='Aramak İstediğiniz Metni Girin...', # input box boş ise ne yazacak
@mebaysan
mebaysan / intro_callback_tips.py
Created September 21, 2020 22:19
Introduction to Plotly Dash Callback Funcs
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import seaborn as sns
import pandas as pd
def get_fig(df):
return px.scatter(df, x="total_bill", # x eksenindeki değişken
@mebaysan
mebaysan / cart.py
Created September 23, 2020 20:26
Django Alışveriş Sepeti
from decimal import Decimal
from django.conf import settings
from cart.models import Product
class Cart:
def __init__(self, request):
"""
Cart objesi oluşturulurken.
"""
@mebaysan
mebaysan / file-structure-dash-project.md
Last active October 3, 2020 15:58
Dash klasör yapısı (Medium için markdown )
  • project_name/
    • apps/ # dashboard'larımızı bu klasör altında oluşturacağız
      • __init__.py
      • covid19/ # covid19 dashboard'ının klasörü
        • app.py # covid19 dashboard'ı
        • data.py # covid19 dashboard'ının data dosyası
    • assets/ # static dosyalar için bu klasörü kullanacağız, Dash otomatik olarak bu klasör altına bakar
      • favicon.ico # favicon.ico adında bir icon dosyası koyarsanız otomatik olarak set edilir
    • components/ # ben kendi component'lerimi (örn: footer, sidebar vb.) bu klasör altında tutmayı tercih ettim
  • __init__.py
@mebaysan
mebaysan / README.md
Last active November 17, 2020 11:59
Plotly Dash Bootstrap Component Tablo Oluşturmak için Snippet

Tablomuzu oluşturacak fonksiyon

import dash_html_components as html
import dash_bootstrap_components as dbc


def get_basic_table(headers, rows, style):
    table_header = [
 html.Thead(html.Tr([html.Th(f"{header}") for header in headers]))