Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Disable the below message in gitlab if your are annoyed with it like me:
remote:
remote: To create a merge request for dev, visit:
remote: https://repo.alohi.ch/alohi/backend/affogato/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote:
Go to your project settings and uncheck:
Display link to create/view merge request on push

#gitlab #merge_request #push
You can add title to iOS push notification as of iOS 8.2:
A short string describing the purpose of the notification. Apple Watch displays this string as part of the notification interface. This string is displayed only briefly and should be crafted so that it can be understood quickly. This key was added in iOS 8.2.

#push #notification #ios
OneSignal - free multiplatform push notification service

Send 100% FREE push notifications to Android, iOS, Web by their completely free SDKs on OneSignal. #OneSignal is multiplatform push notification service that you just interact with it using API calls in JSON format. It has a thorough documentation for SDKs and Server API.

* BE AWARE THAT use OneSignal in case your user's privacy does not matter to you! They have mentioned in their privacy policy that they sell this information!!! All device locations, user email addresses and all the other sensetive data will be collected by OneSignal.

#push_notification #push #ios #android #web #notification #one_signal
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
For enabling push notification on pushd server, you need to get a file with .p12 extension and .cer certificate file. For pushd to work you need to generate a .pem file and give its path in push configuration(`/etc/pushd/pushd.conf`).

We need to generate 2 pem files one called apns-cert.pem (generated from .cer file) and the other called apns-key.pem (generated from .p12 file).

To generate .pem file use openssl command, with the format below:
openssl pkcs12 -in YOUR_KEY.p12 -out apns-key.pem -nodes
NOTE: it may ask you for the password, enter the given password by whom that gave you the p12 file.

-in set your input file name and -out sets your output file name which will be generated.

And now generate the key pem file:
openssl x509 -in cert.cer -inform DER -outform PEM -out apns-cert.pem

Restart the pushd and check for any error in /var/log/pushd.

#pushd #openssl #p12 #cer #pem #push
Check if you can connect to APNS SERVER using openssl:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert /etc/pushd/apns-cert.pem -key /etc/pushd/apns-key.pem

At the end if you can connect to the APNS server you would see Verify return code: 0 (ok). Finally press CTRL+C to go outside of
response.

#pushd #openssl #apns #push
What is LPUSH in REDIS:

Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned.

It is possible to push multiple elements using a single command call just specifying multiple arguments at the end of the command. Elements are inserted one after the other to the head of the list, from the leftmost element to the rightmost element. So for instance the command LPUSH mylist a b c will result into a list containing c as first element, b as second element and a as third element.

Return value:
Integer reply: the length of the list after the push operations.

For instance:
redis> LPUSH mylist "world"
(integer) 1
redis> LPUSH mylist "hello"
(integer) 2
redis> LRANGE mylist 0 -1
1) "hello"
2) "world"

NOTE1: time complexity of LPUSH command is O(1). So it is the best from performance point of view.

NOTE2: `LRANGE is used to get list members, if you use 0 to -1 it will return all list elements.

#redis #list #lpush #push
Have you had a chance to work with Git? If so, did you know that you can work with your git repository from within python script?

GitPython python library does exactly this job:

http://gitpython.readthedocs.io/en/stable/

#python #git #push #pull #GitPython
Few days ago we talk about gitPython to work with git inside of python. The code below is a sample that would do all routine tasks like pulling and pushing or commit.

1- Initiate git object in python by providing path:

from git import Repo
repo = Repo(repo_path)


2- If you want to pull results from git repo:

repo.git.pull('origin', 'refs/heads/dev')


3- Let's say you want to set username and email for git author:

config = repo.config_writer()
config.set_value("user", "email", author_email)
config.set_value("user", "name", author_name)


4- Now to add a specific file to staged:

index = repo.index
index.add([file_path])


5- Commit the staged file with a message:

index.commit(commit_message)


6- The final step is to push to a remote repo:

repo.git.push('origin', 'refs/heads/dev')

#python #git #gitPython #pull #push #author