Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Tech C**P
Photo
Adding, deleting, and cloning carets in 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
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 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 PHP programmer and are using Yii2 for your project, I would suggest using the Twig template engine renderer rather
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, first add "yiisoft/yii2-twig": "~2.0.0" to composer.json file:
composer install

#php #composer #twig #yii2 #template #template_engine
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 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 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 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 Inside
di stands for Delete Inside

#vim #tricks #commands #change #delete #ci #di
A quick way to comment/uncomment lines in 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 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
In ls you can list files by using regex pattern as below:
ls data.subtitle_*

* is gready and list all the files that start with data.subtitle_.

Now lets say you want to get count of files which is listed by ls command. For that you can use wc -l as follow:
ls data.subtitle_* | wc -l

Now you shoud the count of files listed by the first command. This method of using 2 commands is piping commands, which is in fact separated by | (pipe)

#linux #sysadmin #ls #wc #command #bash #terminal
tr command in Linux can be used to trim special characters from a string in bash script. Let's say we want to remove underscore (_) from the string _hello_:
$ echo "_hello_" | tr -d "_"
hello
As you can see the output is hello.

-d flag causes to delete _ from the whole string.

In case you want to delete multiple special characters, that's easy as pie:
$ echo "_sal-am_" | tr -d "_-"
salam

We have removed - and _ from the string above.

Making lower case to uppercase:
tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
asdasd
ASDASD

OR:
tr [:lower:] [:upper:]
asdasd
ASDASD

Turn {} into ():
$ echo '{hello}' | tr '{}' '()'
(hello)

#linux #tr #translate #trim #bash #sysadmin
Preventing installation of devDependencies node modules:

npm install in the package directory installs the dependencies in the local node_modules folder.

In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.

By default, npm install will install all modules listed as dependencies in package.json.

With the --production flag (or when the NODE_ENV environment variable is set to production`), `npm will not install modules listed in devDependencies.

#node #npm #package_json #devDependencies #NODE_ENV