sudo apt-get install python3-pip
sudo pip3 install virtualenv
| # http://docs.python-requests.org/en/master/api/ | |
| import requests | |
| class RequestsApi: | |
| def __init__(self, base_url, **kwargs): | |
| self.base_url = base_url | |
| self.session = requests.Session() | |
| for arg in kwargs: | |
| if isinstance(kwargs[arg], dict): | |
| kwargs[arg] = self.__deep_merge(getattr(self.session, arg), kwargs[arg]) |
| #!/usr/bin/env python | |
| import json | |
| import sys | |
| try: | |
| dotenv = sys.argv[1] | |
| except IndexError as e: | |
| dotenv = '.env' | |
| with open(dotenv, 'r') as f: |
| <?php | |
| /** | |
| * Created by PhpStorm. | |
| * User: Computer Source | |
| * Date: 12/12/14 | |
| * Time: 3:56 PM | |
| */ | |
| $array = array( | |
| array(554 => "a"), |
| import grpc | |
| import helloworld_pb2 | |
| import helloworld_pb2_grpc | |
| # you need to use secure port, | |
| # otherwise call credentials won't be transmitted | |
| def run(): | |
| with open('server.crt', 'rb') as f: | |
| trusted_certs = f.read() |
| Authorization Code Grant Flow | |
| ============================= | |
| Step 1 : Created a Live SDK application at https://apps.dev.microsoft.com/, and login with your Microsoft Account credentials when prompted. | |
| Got client_id e.g XXXXXXXXXXXXXXXXX | |
| Step 2 : Request for CODE with response_type=code at https://login.live.com/oauth20_authorize.srf?client_id=XXXXXXXXXXXXXXXXX&scope=bingads.manage&response_type=code&redirect_uri=https://login.live.com/oauth20_desktop.srf&state=ClientStateGoesHere |
| from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | |
| # First we create a little helper function, becase we will potentially have many PaginatedTypes | |
| # and we will potentially want to turn many querysets into paginated results: | |
| def get_paginator(qs, page_size, page, paginated_type, **kwargs): | |
| p = Paginator(qs, page_size) | |
| try: | |
| page_obj = p.page(page) | |
| except PageNotAnInteger: |
| from PIL import Image, ImageSequence | |
| # Output (max) size | |
| size = 320, 240 | |
| # Open source | |
| im = Image.open("in.gif") | |
| # Get sequence iterator | |
| frames = ImageSequence.Iterator(im) |
| #!/usr/bin/python3 | |
| import argparse | |
| import logging | |
| import subprocess | |
| import os | |
| import tempfile | |
| from tempfile import mkstemp | |
| import configparser | |
| import gzip |