Skip to content

Instantly share code, notes, and snippets.

View daryasary's full-sized avatar

Hossein Ramezanpour daryasary

  • Shell EV Solutions
  • Amsterdam, Netherlands
View GitHub Profile
@daryasary
daryasary / get_products_dict.py
Created February 7, 2020 06:20
Dubizzle refactoring challenge
"""
Assumptions:
We use Django ORM
get_language() method returns the locale string
products is a list of dictionaries
"""
# All other previous imports come here
# ...
from django.db.models import Value, IntegerField, F
@daryasary
daryasary / flower command line
Created February 7, 2019 09:41 — forked from hlawrenz/flower command line
Serve celery flower behind Django authentication.
celery flower --address=127.0.0.1 --url_prefix=flower --broker=<broker url>
@daryasary
daryasary / smart_swap_utils_sample.py
Last active December 4, 2018 12:19
This is a sample code of MTN-Irancell pishvaz service, which swap different tones for users during month. This code also used for academic courses to describe Factory() and Builder() design patterns
from datetime import timedelta
from django.utils import timezone
from transaction.models import PurchaseBaseModel, PurchaseSmartTone
from users.utils import check_charkhune_subscription
from utils.USDP_handler import user_inbox, active_deactive_tones, order_tone, \
set_tone
from utils.formats import clean_phone_number, extract_person_ids, get_tone_id
from utils.irancell import safe_call, hide_tone_file
@daryasary
daryasary / Database debugger
Created October 24, 2018 13:22
Log databse hits (+query) in django projects, DO NOT USE IN PRODUCTION
LOGGING = {
'version': 1,
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
}
},
'handlers': {
'console': {
'level': 'DEBUG',
@daryasary
daryasary / main.py
Created August 7, 2018 05:23
BingWallpaper-Python-i3 veriosn
#!/usr/bin/python
# -*- coding: utf-8 -*-
import locale
import os
import re
import sys
# replace with the actual path to the bing-desktop-wallpaper-changer folder
path_to_Bing_Wallpapers="/home/hosein/Downloads/bing-desktop-wallpaper-changer-master/bin"
@daryasary
daryasary / config
Last active May 7, 2017 12:28
custom_i3_config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.app import App
#from kivy.uix.popup import Popup
#from kivy.uix.label import Label
from kivy.core.audio import SoundLoader
Builder.load_string('''
<MenuPage>:
BoxLayout:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.audio import SoundLoader,Sound
from kivy.lang import Builder
Builder.load_string('''
<MenuPage>:
BoxLayout:
orientation:'vertical'
Button:
text:'play'