Skip to content

Instantly share code, notes, and snippets.

:octocat:
On the way

soroush safari coci

:octocat:
On the way
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am coci on github.
  • I am coci (https://keybase.io/coci) on keybase.
  • I have a public key ASDVQo88kttH7Pxmtt9NFlJBgnjQ2fAzTXQOjgQ7ZJFDMQo

To claim this, I am signing this object:

View reverse_number.py
import math
def reverse_int_without_string(number):
"""
reverse without change number into string
"""
number_copy = abs(number)
digits_number = [] # split number by their digits
while number_copy > 0 :
digits_number.append(number_copy%10)
View fixtures django
to create initial data for models in django :
1- create "fixtures" dir inside app
2- add fx.json file init
3- add data like :
[
{
"model": "activity.Todo",
"pk": 1,
"fields": {
"name": "buy food"
View custom_response_serializer.py
# in this seriliazer : 'user' is forignkey to customuser
# i need add user name and pk instead of pk only
class LandSerializer(serializers.ModelSerializer):
points = PointSerializer(many=True, read_only=True)
class Meta:
model = Land
fields = ('pk', 'user', 'name', 'create_time', 'points')
View decimal_to_binary.py
class Stack:
def __ini__(self):
self.array = []
def push(self,item):
self.array.append(itme)
def pop(self):
return self.array.pop()
def isEmpty(self):
return True if len(array) > 0 else False
View parenthesis_checker.py
class Stack:
def __ini__(self):
self.array = []
def push(self,item):
self.array.append(itme)
def pop(self):
return self.array.pop()
def isEmpty(self):
return True if len(array) > 0 else False
@coci
coci / threading.py
Created Mar 18, 2020
access value from thread
View threading.py
import threading
import Queue
import timeit
q = Queue.Queue()
number = 5
t1 = timeit.default_timer()
# Step1: For example, we are running multiple functions normally
result = []
@coci
coci / BaseThreading
Created Mar 18, 2020 — forked from amirasaran/BaseThreading
Python threading with callback function (callback function run after thread is finished)
View BaseThreading
import time
import threading
class BaseThread(threading.Thread):
def __init__(self, callback=None, callback_args=None, *args, **kwargs):
target = kwargs.pop('target')
super(BaseThread, self).__init__(target=self.target_with_callback, *args, **kwargs)
self.callback = callback
self.method = target
View django-api-for-sms-auth.py
import random
import string
from random import randrange
from rest_framework import status
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.authtoken.models import Token
from users.models import CustomUser
View keybase.md

Keybase proof

I hereby claim:

  • I am coci on github.
  • I am coci (https://keybase.io/coci) on keybase.
  • I have a public key whose fingerprint is 4682 0230 73A8 5CCE E642 BC4A 3E75 4224 961D D916

To claim this, I am signing this object:

You can’t perform that action at this time.