Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alican Toprak alican

🎯
Focusing
  • adesso SE
  • Frankfurt a. M.
  • 19:58 (UTC +02:00)
View GitHub Profile
@alican
alican / friendly_id.py
Created October 24, 2017 09:17
friendly ID
View friendly_id.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
""" Generates and decodes an unique invoice id, which can use characters
to shorten its length.
Author: Will Hardy
Date: December 2008
Usage: >>> encode(1)
"488KR"
Description: Invoice numbers like "0000004" are unprofessional in that they
@alican
alican / django_field_update_checker.txt
Last active January 6, 2023 15:58
check if django model fields changed after save
View django_field_update_checker.txt
class DjangoModel(models.Model):
@classmethod
def from_db(cls, db, field_names, values):
instance = super().from_db(db, field_names, values)
instance._state.adding = False
instance._state.db = db
instance._old_values = dict(zip(field_names, values))
return instance
@alican
alican / crossover.cpp
Last active May 23, 2016 20:06
Crossover einer doppelt verketten Liste (std::list) in c++.
View crossover.cpp
std::ostream& operator<<(std::ostream& ostr, const std::list<std::string>& list) {
for (auto &i : list) {
ostr << " " << i;
}
return ostr;
}
////////
int position = 4;
@alican
alican / .bashrc
Last active August 29, 2015 14:10
My personal .bashrc
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
#PS1="[\[\e[35m\]\u\[\e[m\]: \[\e[36m\]\w\[\e[m\]\[\e[37m\]]\[\e[m\]\[\e[33m\]\\$\[\e[m\] "
#PS2="$HC$FYEL&gt; $RS"
# If not running interactively, don't do anything
case $- in
*i*) ;;
View supervisord.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
View gist:5451502
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|