Skip to content

Instantly share code, notes, and snippets.

View berkerpeksag's full-sized avatar

Berker Peksag berkerpeksag

View GitHub Profile
// Xeno
enum Xeno_Kind {
XENO_POINTER,
XENO_AGGREGATE,
XENO_FIRST_PRIMITIVE_TYPE,
XENO_UINT8 = XENO_FIRST_PRIMITIVE_TYPE,
XENO_UINT16,
XENO_UINT32,
XENO_UINT64,
@pervognsen
pervognsen / BTree.cpp
Created April 24, 2016 20:40
A B+-tree implementation with find, insert and delete in 176 lines of code.
enum { BMAX = 32, BMIN = BMAX / 2, BHEIGHT = 6 };
struct BNode {
uint32_t length;
Key keys[BMAX];
union {
BNode *children[BMAX];
Value values[BMAX];
};
};
@joar
joar / gunicorn+werkzeug-behind-nginx.nginxconf
Last active August 29, 2015 14:00
How to get rid of 127.0.0.1 in your generated links
server {
# [...]
location / {
set $backend_url 'http://127.0.0.1:8000';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass $backend_url;
@Nagyman
Nagyman / workflows-in-django.md
Last active January 27, 2024 08:29
Workflows in Django

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)
from nonlocal_ import nonlocal_
def foo():
a = 1
def bar():
nonlocal_('a')
a = 2
bar()
return a
@tylerneylon
tylerneylon / learn.lua
Last active May 16, 2024 05:47
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------

wsgi.input_terminated Proposal

Problem Description

Currently WSGI servers or WSGI middlewares cannot accept chunked requests or perform request filtering because a WSGI application needs to depend on the content length as this is the only thing that the specification currently guarantees will work.

# Helpers for bytes handling
# For 3.2, we deliberately require applications that
# handle improperly quoted URLs to do their own
# decoding and encoding. If valid use cases are
# presented, we may relax this by using latin-1
# decoding internally for 3.3
_implicit_encoding = 'ascii'
_implicit_errors = 'strict'
def _noop(obj):
@emre
emre / south.bash
Created March 29, 2013 10:40
south için alias
function south_first() {
./manage.py schemamigration --initial "$@";
./manage.py migrate "$@";
}
function south_update() {
./manage.py schemamigration --auto "$@";
./manage.py migrate "$@";
}
@raulb
raulb / gist:5251844
Last active August 21, 2018 14:51
English is hard

ENGLISH IS FOGGING HARD

Let's face it. I'm not the Queen Elizabeth in what concerns to speak English. But ey! (hey!), just help me. I know you wanted to tell me: "Idiot, it's not like that", now you have your chance. Add your comments/pr/merges/forkes/... here and contribute to the cause of why I am paying a psychologist every month (also, can you recommend me someone?)

I wrote (it is)

  • It should works (It should work)
  • Looks fine for you (Looks fine to you)
  • Dial you (Dial you in)
  • Oyster egss (Easter eggs)