Skip to content

Instantly share code, notes, and snippets.

View mesuutt's full-sized avatar

Mesut Taşçı mesuutt

View GitHub Profile
@mesuutt
mesuutt / city.json
Last active January 21, 2018 01:20
Django projeleri için il-ilçe fixtureları ve modeli (İl id'leri plaka kodlarıdır)
[
{
"model": "other.city",
"pk": 1,
"fields": {
"name": "ADANA"
}
},
{
"model": "other.city",
DELETE = "delete"
UPDATE = "update"
SELECT = "select"
INSERT = "insert"
QUOTE = "'"
def format_parameter(parameter, value):
return "%s = %s" % (parameter, determine_quote(value))
@mesuutt
mesuutt / form_widgets.py
Last active August 23, 2017 13:02
Custom form widget for add additional attributes to option tags of select on Django forms.
from django import forms
from django.utils.encoding import force_text
from django.utils.html import format_html
from django.utils.safestring import mark_safe
class SelectOptionsWithAttrs(forms.widgets.Select):
def render_options(self, selected_choices):
# Normalize to strings.
selected_choices = set(force_text(v) for v in selected_choices)
@mesuutt
mesuutt / System Design.md
Created July 6, 2016 23:08 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@mesuutt
mesuutt / convert-timestamp.js
Created November 10, 2016 02:05
Convert a timestamp to user's local time via JavaScript
function convertToLocalTimestamp(timestamp) {
var offset = new Date().getTimezoneOffset();
return timestamp + (60 * offset * 1000);
}
// convertToLocalTimestamp(1479168000000);
@mesuutt
mesuutt / aras_kargo_soap.py
Last active February 25, 2016 12:36
ArasKargo Soap API call example with Python suds library.
import logging
from suds.xsd.doctor import ImportDoctor, Import
from suds.client import Client, WebFault
logger = logging.getLogger(__name__)
wsdl_url = 'http://appls-srv.araskargo.com.tr/arascargoservice/arascargoservice.asmx?WSDL'
client = None
@mesuutt
mesuutt / middleware.py
Last active January 2, 2016 20:19 — forked from strogonoff/middleware.py
Django middleware for cross-domain XHR. WARNING: Defaults are unsafe here. Make sure to set proper restrictions in production!
from django import http
class XsSharing(object):
"""
This middleware allows cross-domain XHR using the html5 postMessage API.
Access-Control-Allow-Origin: http://foo.example
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
@mesuutt
mesuutt / tmux.md
Last active December 30, 2015 03:09

Not: Bu kısayollar benim tmux.conf'umda ayarlanan kısa yollardır. Default bir tmux.conf konfigürasyonunda bu kısayollar farklık gösterebilir.

Kendi .tmux.conf dosyam

CK Kontrol key anlamına gelir.Default'ta Ctrl+b'dir.


Pencere ve Paneler

@mesuutt
mesuutt / Flake8Lint.sublime-settings
Last active December 15, 2015 10:38
Sublime text 2 Settings
{
"pep8_max_line_length": 120,
"ignore": ["E128"]
}
@mesuutt
mesuutt / iller.sql
Last active December 14, 2015 20:29
Türkiye iller - 01.06.2012
CREATE TABLE IF NOT EXISTS `tr_city` (
`id` int(3) NOT NULL,
`name` varchar(50) NOT NULL,
UNIQUE KEY `id_town` (`id`)
);
INSERT INTO `tr_city` (`id`, `name`) VALUES
(1, 'Adana'),