Skip to content

Instantly share code, notes, and snippets.

View berkerpeksag's full-sized avatar

Berker Peksag berkerpeksag

  • Helsinki, Finland
View GitHub Profile
@bewithdhanu
bewithdhanu / upgrade_python_3.10_to_3.11.md
Last active April 7, 2025 07:41
Upgrade Python 3.10 to 3.11 on Ubuntu 22.04

Check python version use python and python3

The first comman will Not show version info.

The second one show 3.10 as version as it is provided by ubuntu as default

python --version
python3 --version

Add additional repository to download python 3.11

#include <AK/DistinctNumeric.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/Vector.h>
#include <LibMain/Main.h>
#include <sys/mman.h>
// JS::Bytecode::Executable (jitme)
// 1:
//[ 0] Store $5
//[ 20] LoadImmediate 0
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@rcoh
rcoh / otp.py
Last active August 17, 2023 08:03
An implementation of Google Authenticator Compatible 2-factor Codes
"""
An implementation of TOTP as described in https://tools.ietf.org/html/rfc6238#section-4 aka Google Authenticator Style 2-factor Auth
"""
import base64
import datetime
import hashlib
import hmac
import sys
import struct
import time
@benschwarz
benschwarz / pg.md
Last active October 16, 2024 23:15
Awesome postgres
@brettcannon
brettcannon / hglookup.py
Last active November 28, 2017 22:14
hg.python.org/lookup
# hglookup.py
#
# Lookup a revision hash in a bunch of different hgwebdir repos.
# Also includes special treatment for subversion revisions from
# the CPython repo.
#
# Written by Georg Brandl, 2010.
import io
import json
@kyle-eshares
kyle-eshares / models.py
Created October 15, 2016 18:01
Strict ForeignKeys
from __future__ import unicode_literals
from django.db import models
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa
class RelationNotLoaded(Exception):
pass
@vaibhav-jain
vaibhav-jain / UniqueTogetherValidator.py
Created July 2, 2016 12:45
Django Rest Framework (DRF) Custom Unique Together Message
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
class SomeSerializer(serializers.ModelSerializer):
"""
Demostrating How to Override DRF UniqueTogetherValidator Message
"""
class Meta:
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdio.h>
#include <windows.h>
#pragma warning (disable: 4146)
#include <stdint.h>
#ifdef _DEBUG
#define Assert(x) \
if (!(x)) { MessageBoxA(0, #x, "Assertion Failure", MB_OK); __debugbreak(); }
@pervognsen
pervognsen / x64_emitter.cpp
Created May 14, 2016 20:31
x64 machine code emitter
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
#include <stdint.h>
#define Assert(x) \
if (!(x)) { MessageBoxA(0, #x, "Assertion Failure", MB_OK); __debugbreak(); }
enum Register {
RAX = 0,