format() is way better than % in many different ways. One of those is:>>> names = ['ali', 'reza', 'alireza', 'mohsen']
>>> print map('Hello Mr. {}'.format, names)
['Hello Mr. ali', 'Hello Mr. reza', 'Hello Mr. alireza', 'Hello Mr. mohsen']
#python #format #string_formatter #map
Tech C**P
format() is way better than % in many different ways. One of those is: >>> names = ['ali', 'reza', 'alireza', 'mohsen'] >>> print map('Hello Mr. {}'.format, names) ['Hello Mr. ali', 'Hello Mr. reza', 'Hello Mr. alireza', 'Hello Mr. mohsen'] #python #format…
format() is way better than %:>>> a = {'name': 'ali', 'credit': '$2.0', 'status': 'active'}
>>> 'User {name} is {status} and has balance equal to {credit}'.format(**a)
'User ali is active and has balance equal to $2.0'A design tool which writes
https://builderx.io/
#reactjs #react_native #builderx #react
React Native code for you:https://builderx.io/
#reactjs #react_native #builderx #react
Rapidnative
RapidNative | AI-Powered Code Generator for React Native & Expo
RapidNative is an AI-powered code generator that instantly converts your ideas into production-ready React Native and Expo apps. Perfect for developers, designers, and teams who want to accelerate mobile app development.
Tech C**P
Photo
Adding, deleting, and cloning carets in
To add carets, do one of the following:
- Press Alt (Windows or UNIX)/Cmd (macOS) and click the left mouse button at the location of the caret.
- Press Ctrl (Windows or UNIX)/Alt(macOS) twice, and then without releasing it, press up or down arrow keys.
The new carets are added to the specified locations, according to setting of the Allow placement of caret after end of line check box.
To delete carets, do one of the following:
- Press Esc to delete all the existing carets, except the primary one.
- Press Shift+Alt and click the left mouse button on a caret to be deleted.
#pycharm #caret #multi_selection #carets
pyCharm:To add carets, do one of the following:
- Press Alt (Windows or UNIX)/Cmd (macOS) and click the left mouse button at the location of the caret.
- Press Ctrl (Windows or UNIX)/Alt(macOS) twice, and then without releasing it, press up or down arrow keys.
The new carets are added to the specified locations, according to setting of the Allow placement of caret after end of line check box.
To delete carets, do one of the following:
- Press Esc to delete all the existing carets, except the primary one.
- Press Shift+Alt and click the left mouse button on a caret to be deleted.
#pycharm #caret #multi_selection #carets
https://electron.atom.io/
Build cross platform desktop apps with JavaScript, HTML, and CSS
#multi_platform #cross_platform #css #js #electron #osx #windows #linux #desktop #application
Build cross platform desktop apps with JavaScript, HTML, and CSS
#multi_platform #cross_platform #css #js #electron #osx #windows #linux #desktop #application
Tech C**P
Photo
Except the first video, all the videos are totally non-sense and after a lot of results there some related video clips. This is where
#aparat #machine_learning #startup
MACHINE LEARNING could save the project and enhance the UX (user experience).Aparat needs to take this matter seriously.#aparat #machine_learning #startup
If you are a
than the default one. No more php coding inside of templates plus the readability and much more:
https://github.com/yiisoft/yii2-twig
Install it using
#php #composer #twig #yii2 #template #template_engine
PHP programmer and are using Yii2 for your project, I would suggest using the Twig template engine renderer ratherthan the default one. No more php coding inside of templates plus the readability and much more:
https://github.com/yiisoft/yii2-twig
Install it using
php composer, first add "yiisoft/yii2-twig": "~2.0.0" to composer.json file:composer install
#php #composer #twig #yii2 #template #template_engine
GitHub
GitHub - yiisoft/yii2-twig: Yii 2 Twig extension.
Yii 2 Twig extension. Contribute to yiisoft/yii2-twig development by creating an account on GitHub.
with python compound statement in depth [ADVANCE]:with is ported into python in version 2.5.with is used to wrap the execution of a code block using methods defined by a context manager.The process of
with statement:- The expression given in front of with statement is evaluated to obtain a context manager.
- The context manager’s __exit__() is loaded (it is not executed, it is just loaded for later use).
- The context manager’s __enter__() method is invoked.
- If a target was included in the with statement, the return value from __enter__() is assigned to it (like opening a file)
- The suite is executed (your code block)
- The context manager’s __exit__() method is invoked.
Now consider the example below:
with VAR = EXPR:
BLOCK
Would roughly translates to:
VAR = EXPR
VAR.__enter__()
try:
BLOCK
finally:
VAR.__exit__()
The moral of the story is that when you open a file it will close the file automatically at the end:
@contextmanager
def opening(filename):
f = open(filename)
try:
yield f
finally:
f.close()
At the
finally stage, the file will always be closed, and you don't need to manage it.Another example:
f = open(filename)
with f:
BLOCK1
with f:
BLOCK2
NOTE: The above code does not do what one might think (f is closed before BLOCK2 is entered!).List of types which can be as a context manager (can be used in `with`):
- file
- thread.LockType
- threading.Lock
- threading.RLock
- threading.Condition
- threading.Semaphore
- threading.BoundedSemaphore
What is a
context manager: it is an object that consists of __enter__() and __exit__() methods.What is a
context expression: the expression immediately following the with keyword in the statement is a context expression.There is more about
with to talk about, but I think it is more advanced and not needed for the time being :)#python #with #context_manager #with_statement #advance
Shift time in
To get your new date in
To turn
#python #epoch #datetime #time #timedelta #strftime
python using datetime & timedelta:import datetime
from datetime import timedelta
date1 = datetime.datetime.utcnow()
# output of date1: datetime.datetime(2017, 11, 8, 10, 24, 25, 19492)
date2 = date1 + timedelta(days=1)
# output of date2: datetime.datetime(2017, 11, 9, 10, 24, 25, 19492)
To get your new date in
EPOCH:at_epoch = (date2 - datetime.datetime(1970, 1, 1)).total_seconds()
# output of subtract: 1510223065.019492
To turn
EPOCH to datetime:import time
from_epoch = time.localtime(1510223065.019492)
# output: time.struct_time(tm_year=2017, tm_mon=11, tm_mday=9, tm_hour=13, tm_min=54, tm_sec=25, tm_wday=3, tm_yday=313, tm_isdst=0)
formatted_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1510223065.019492))
# output: 2017-11-09 13:54:25
#python #epoch #datetime #time #timedelta #strftime
Customize
- open
- add
- add
- add the below function to line 51:
Ok done in payload. Push now accept subtitle for
Open
OK DONE :)
Restart your
#pushd #ios #title #subtitle #coffee_script #push #notification
pushd server to add a new field like subtitle or title for iOS push notification payload. As you may know ios payload is like below:{
"aps":{
"alert":{
"body":"New flight is booked",
"title":"Boarding at 20:05",
"subtitle": ""Yay!
},
"category":"openFlightCategory"
},
}pushd by default does not support subtitle in the payload, to add this do the following:- open
/usr/local/pushdcustomized/lib/payload.coffee file- add
@subtitle = {} to line 14- add
when 'subtitle' then @subtitle.default = value to line 28- add the below function to line 51:
localizedMessage: (lang) ->
@localized('subtitle', lang)
Ok done in payload. Push now accept subtitle for
iOS, but there is one step left. You need to send subtitle to iOS device.Open
/usr/local/pushdcustomized/lib/pushservices/apns.coffee file and go to line note.alert = alert (line 44), and change it to:note.alert = {'title':payload.title.default, 'body':payload.msg.default, 'subtitle': payload.subtitle.default}OK DONE :)
Restart your
pushd server and enjoy title and subtitle in your iOS push notifications.#pushd #ios #title #subtitle #coffee_script #push #notification
One the most useful commands in
In case you want to just delete inside of something and you don't want to go into
Let's give an example. Suppose we have lines like below and we have opened it in vim:
Place the cursor between double quotes somewhere in the
Now let's assume we have a block of code like below:
Go inside of the block of curly braces (`{}`) and put your cursor inside of the block. Now press
You can do the same with every block of code and every character like
#vim #tricks #commands #change #delete #ci #di
vim is to delete or change inside of a block like {} or inside of a charater like "SOME THING".In case you want to just delete inside of something and you don't want to go into
INSERT mode just press di keyboard buttons in order, otherwise press ci keyboard buttons to go in INSERT mode and change something.Let's give an example. Suppose we have lines like below and we have opened it in vim:
user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = "SECRET :)"
Place the cursor between double quotes somewhere in the
SECRET :) and press d then press c keys and finally press double quote ("). The vim will search for the surrounding double quotes and will remove everything inside of it. Our output is:user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = ""
Now let's assume we have a block of code like below:
users_data = {
}Go inside of the block of curly braces (`{}`) and put your cursor inside of the block. Now press
c on your keyboard then press i afterward, and at the end press { on your keyboard. It will delete everything inside of {} for you and put your vim mode in INSERT mode. So you would have the following output:users_data = {
}You can do the same with every block of code and every character like
(), [], '', etc.ci stands for Change Insidedi stands for Delete Inside#vim #tricks #commands #change #delete #ci #di
A quick way to comment/uncomment lines in
Put your cursor on the first # character, press
For commenting a block of text is almost the same:
- First, go to the first line you want to comment, press
- Then using the arrow key and select until the last line.
- Now press
- Then press
#vim #comment #comment_out #visual_block
vim:Put your cursor on the first # character, press
Ctrl+V, and go down until the last commented line and press x, that will delete all the # characters vertically.For commenting a block of text is almost the same:
- First, go to the first line you want to comment, press
Ctrl+V. This will put the editor in the VISUAL BLOCK mode.- Then using the arrow key and select until the last line.
- Now press
Shift+I, which will put the editor in INSERT mode and then press #. This will add a hash to the first line.- Then press
Esc (give it a second), and it will insert a # character on all other selected lines.#vim #comment #comment_out #visual_block
Stay tuned for the
Happy coding ✌💥💫
Django video tutorials for the weekend. Yay!!!Happy coding ✌💥💫
این رازِ پُر از عذاب پیشت باشد
تصویر من خراب پیشت باشد
شاید که اربعینت نبودم آقا !
این اشک علی الحساب پیشت باشد
😭😭😭😭
تصویر من خراب پیشت باشد
شاید که اربعینت نبودم آقا !
این اشک علی الحساب پیشت باشد
😭😭😭😭
سائلم ؛ آب و دانه میخواهم
رحمت" مادرانه" میخواهم
آی "بی بی" گدا نمیخواهی!؟
پسر بی وفا نمیخواهی!؟😭😭😭
کاش میشد ز من سوال کنی
پسرم کربلا نمیخواهی!؟
پسر بی وفا نمیخواهی 😭😭😭
رحمت" مادرانه" میخواهم
آی "بی بی" گدا نمیخواهی!؟
پسر بی وفا نمیخواهی!؟😭😭😭
کاش میشد ز من سوال کنی
پسرم کربلا نمیخواهی!؟
پسر بی وفا نمیخواهی 😭😭😭
Media is too big
VIEW IN TELEGRAM
Routes implementation in `Django` and how to wire routes & views
#python #django #route #view #django_part8
#python #django #route #view #django_part8