Skip to content

Instantly share code, notes, and snippets.

🖥
C64/Amiga Scener/Coder

Uğur Özyılmazel vigo

View GitHub Profile
@vigo
vigo / admin.py
Created Mar 14, 2019 — forked from hakib/admin.py
How to Turn Django Admin Into a Lightweight Dashboard
View admin.py
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard
from django.contrib import admin
from django.db.models import Count, Sum, Min, Max, DateTimeField)
from django.db.models.functions import Trunc
from . import models
def get_next_in_date_hierarchy(request, date_hierarchy):
View workflows-in-django.md

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@vigo
vigo / json_server.py
Last active Apr 4, 2018
Basic JSON webserver
View json_server.py
#!/usr/bin/env python
import sys
import time
import argparse
import os
import json
import socketserver
from http.server import BaseHTTPRequestHandler
View pubsub.py
class PubSub(object):
"""
Very simple Pub/Sub pattern wrapper
using simplified Redis Pub/Sub functionality.
Usage (publisher)::
import redis
r = redis.Redis()
@vigo
vigo / tree.md
Created Nov 12, 2017 — forked from hrldcpr/tree.md
one-line tree in python
View tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@vigo
vigo / env.sh
Last active Jan 25, 2017
Dotfiles Fever - Linux setup
View env.sh
export PS1=$PS1_ADVANCED
@vigo
vigo / style.css
Last active Feb 21, 2017
GitHub - Stylish
View style.css
body {
font-family: 'Helvetica';
}
.markdown-body {
font-family: 'Helvetica';
}
.octotree_views {
font-family: 'FiraCode-retina';
font-size: .75rem;
}
@vigo
vigo / show_opened_tab_count_of_safari.applescript
Last active Jul 19, 2016
Show opened tab count of Safari
View show_opened_tab_count_of_safari.applescript
tell application "Safari"
set total_tab_count to 0
set number_of_windows to number of windows
repeat with x from 1 to number_of_windows
try
set current_windows_tab_count to number of tabs in window x
set total_tab_count to total_tab_count + current_windows_tab_count
on error error_message
log error_message
end try
@vigo
vigo / README.md
Last active Feb 1, 2016
Akademik Bilişim 2016 - Rails 101 - Linkler
@vigo
vigo / resources.md
Created Aug 27, 2015
Resources, libs etc.
You can’t perform that action at this time.