brew install python swig zmq
class Forwardable(object): | |
def __init__(self, *args, **kwargs): | |
self._delegates = [] | |
return super().__init__(*args, **kwargs) | |
@property | |
def delegates(self): | |
return self._delegates | |
@delegates.setter |
import collections | |
def sample(): | |
# point 1. 属性はデコレータに文字列で与える。 | |
@immutable( | |
'x1', 'y1', 'x2', 'y2', | |
'is_rectangle', 'is_line', 'is_dot') | |
class Region(object): | |
# point 2. __init__ ではなく、__new__ を使う。 |
provider "aws" { | |
region = "us-west-2" | |
access_key = "anaccesskey" | |
secret_key = "asecretkey" | |
skip_credentials_validation = true | |
skip_metadata_api_check = true | |
s3_force_path_style = true | |
endpoints { | |
s3 = "http://119.18.0.101:4572" | |
} |
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work. | |
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0." | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default | |
brew unlink postgresql | |
brew install [email protected] | |
brew unlink [email protected] | |
brew link postgresql |
When calling a Lambda Function via Boto3, the returned object is something like:
{u'Payload': <botocore.response.StreamingBody object at 0x7f8d5b62ac50>,
'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '5bdbb3ca-3b35-11e7-9816-397b140c3bac', 'HTTPHeaders': {'x-amzn-requestid': '5bdbb3ca-3b35-11e7-9816-397b140c3bac', 'content-length': '1636', 'x-amzn-trace-id': 'root=1-591ca199-00d34d5474d16275ec2c8d10;sampled=0', 'x-amzn-remapped-content-length': '0', 'connection': 'keep-alive', 'date': 'Wed, 17 May 2017 19:16:41 GMT', 'content-type': 'application/json'}}, u'StatusCode': 200}
The Payload
parameter is <botocore.response.StreamingBody>
which is a data streaming object.
import sys | |
import random | |
import time | |
from threading import * | |
class Producer(Thread): | |
def __init__(self, items, can_produce, can_consume): | |
Thread.__init__(self) | |
self.items = items | |
self.can_produce = can_produce |
import UIKit | |
import PlaygroundSupport | |
let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | |
scrollView.backgroundColor = .red | |
let stackView = UIStackView(frame: CGRect(x: 0, y: 0, width: 1000, height: 100)) | |
stackView.backgroundColor = .gray | |
stackView.axis = .horizontal | |
stackView.spacing = 10 |
Squid is available in the Ubuntu repositories. To ensure your system is up to date and then to install Squid, run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install squid
Copy the original configuration file to keep as a backup:
Question: Given a sequence of positive integers A and an integer T, return whether there is a continuous sequence of A that sums up to exactly T Example [23, 5, 4, 7, 2, 11], 20. Return True because 7 + 2 + 11 = 20 [1, 3, 5, 23, 2], 8. Return True because 3 + 5 = 8 [1, 3, 5, 23, 2], 7 Return False because no sequence in this array adds up to 7
Note: We are looking for an O(N) solution. There is an obvious O(N^2) solution which is a good starting point but is not the final solution we are looking for.