start new:
tmux
start new with session name:
tmux new -s myname
| from flask import Flask | |
| from flask_caching import Cache | |
| import random | |
| app = Flask(__name__) | |
| cache = Cache(app, config={'CACHE_TYPE': 'redis', 'CACHE_REDIS_URL': 'redis://localhost:6379/0'}) | |
| @app.route("/route1") | |
| @cache.cached(timeout=10) | |
| def route1(): |
| #!/usr/bin/python3 | |
| import argparse | |
| import logging | |
| import subprocess | |
| import os | |
| import tempfile | |
| from tempfile import mkstemp | |
| import configparser | |
| import gzip |
| 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) |
| 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: |
| 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 |
| 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() |
| <?php | |
| /** | |
| * Created by PhpStorm. | |
| * User: Computer Source | |
| * Date: 12/12/14 | |
| * Time: 3:56 PM | |
| */ | |
| $array = array( | |
| array(554 => "a"), |
| #!/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: |