我正在尝试按照Google在此处提供的示例将我的Google Play服务依赖项升级到8.4.0 ,但是我收到以下错误('com.example.exampleapp'是我的应用包名称的替代品):
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.exampleapp'
Run Code Online (Sandbox Code Playgroud)
项目build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
模块app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.exampleapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName …Run Code Online (Sandbox Code Playgroud) android google-play-services android-studio build.gradle android-gradle-plugin
我有问题在Android片段上膨胀Mapbox MapView.当我在Activity上使用相同的代码时(除了Activity和Fragment之间的标准差异),我可以正确加载MapView,但不能在Fragment上加载.
Mapbox 在这里也有一个MapFragment类,但我不确定如何在Fragment中正确使用它(该示例仍然在Activity中); 使用Google Maps API,我可以在片段上使用MapView而不会出现问题.
下面的logcat行:
at com.example.exampleapp.FragmentMap.onCreateView(FragmentMap.java:133)
Run Code Online (Sandbox Code Playgroud)
是指Java行:
fragmentLayout = inflater.inflate(R.layout.fragment_map, container, false);
Run Code Online (Sandbox Code Playgroud)
以下是此问题的相关代码以及日志:
fragment_map.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:access_token="@string/access_token"/>
<android.support.v7.widget.CardView
android:id="@+id/map_card"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp">
<com.mapbox.mapboxsdk.views.MapView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/mini_map"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
mapbox:access_token="@string/access_token"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
FragmentMap.java:
public class FragmentMap extends Fragment {
private MapView mv, miniMap;
View fragmentLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentLayout = inflater.inflate(R.layout.fragment_map, container, false);
mv = (MapView) fragmentLayout.findViewById(R.id.mapview);
mv.onCreate(savedInstanceState);
miniMap …Run Code Online (Sandbox Code Playgroud) 我想我不理解python的argparse基本知识.
我正在尝试将Google YouTube API用于python脚本,但我不了解如何在不使用命令行的情况下将值传递给脚本.
例如,这里是对API的例子.github和其他地方的示例将此示例显示为从命令行调用,在调用脚本时从该命令行传递argparse值.
我不想使用命令行.我正在构建一个使用装饰器获取用户登录凭据的应用程序,当该用户想要上传到他们的YouTube帐户时,他们会提交一个表单,然后调用此脚本并将argparse值传递给它.
如何从另一个python脚本将值传递给argparser(请参阅下面的YouTube上传API脚本中的部分代码)?
if __name__ == '__main__':
argparser.add_argument("--file", required=True, help="Video file to upload")
argparser.add_argument("--title", help="Video title", default="Test Title")
argparser.add_argument("--description", help="Video description",
default="Test Description")
argparser.add_argument("--category", default="22",
help="Numeric video category. " +
"See https://developers.google.com/youtube/v3/docs/videoCategories/list")
argparser.add_argument("--keywords", help="Video keywords, comma separated",
default="")
argparser.add_argument("--privacyStatus", choices=VALID_PRIVACY_STATUSES,
default=VALID_PRIVACY_STATUSES[0], help="Video privacy status.")
args = argparser.parse_args()
if not os.path.exists(args.file):
exit("Please specify a valid file using the --file= parameter.")
youtube = get_authenticated_service(args)
try:
initialize_upload(youtube, args)
except HttpError, e:
print "An HTTP error %d occurred:\n%s" …Run Code Online (Sandbox Code Playgroud) 我使用带有Python的Google App Engine来托管一些后端脚本并将数据存储在数据存储区中,我需要利用openCV进行更高级的媒体操作.
我正在尝试切换到Google Cloud VM平台,我无法理解如何安装openCV.
今天早些时候,在VM Cloud Shell上我尝试过:
sudo apt-get install python-opencv
Run Code Online (Sandbox Code Playgroud)
这似乎工作,并在列出我的python模块后,我得到:
help> modules
Please wait a moment while I gather a list of all available modules...
/usr/local/lib/python2.7/dist-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
BaseHTTPServer audiodev importlib setuptools
Bastion audioop imputil sgmllib
CDROM autoreload inspect sha
CGIHTTPServer base64 io shelve
Canvas bdb ipython_genutils shlex
ConfigParser binascii itertools shutil
Cookie binhex …Run Code Online (Sandbox Code Playgroud) python google-app-engine opencv google-cloud-platform dockerfile
我正在使用Lambda(Python)来查询我的DynamoDB数据库.我正在使用boto3库,我能够创建一个"等效"查询:
这个脚本有效:
import boto3
from boto3.dynamodb.conditions import Key, Attr
import json
def create_list(event, context):
resource = boto3.resource('dynamodb')
table = resource.Table('Table_Name')
response = table.query(
TableName='Table_Name',
IndexName='Custom-Index-Name',
KeyConditionExpression=Key('Number_Attribute').eq(0)
)
return response
Run Code Online (Sandbox Code Playgroud)
但是,当我将查询表达式更改为:
KeyConditionExpression=Key('Number_Attribute').gt(0)
Run Code Online (Sandbox Code Playgroud)
我收到错误:
"errorType": "ClientError",
"errorMessage": "An error occurred (ValidationException) when calling the Query operation: Query key condition not supported"
Run Code Online (Sandbox Code Playgroud)
根据这[1]资源,"gt"是Key()的方法.有没有人知道这个库是否已经更新,或者除了"eq"之外还有哪些其他方法?
[1] http://boto3.readthedocs.io/en/latest/reference/customizations/dynamodb.html#ref-dynamodb-conditions
- - - - -编辑 - - - - -
我也尝试使用旧方法:
response = client.query(
TableName = 'Table_Name',
IndexName='Custom_Index',
KeyConditions = {
'Custom_Number_Attribute':{
'ComparisonOperator':'EQ',
'AttributeValueList': [{'N': '0'}]
}
} …Run Code Online (Sandbox Code Playgroud) 我已经查看了许多 SO 答案,但似乎找不到这个问题。我有一种感觉,我只是错过了一些明显的东西。
我有一个基本的 Flask api,并且我已经实现了 flask_cors 扩展和自定义 Flask 装饰器[@crossdomain from Armin Ronacher]。1 ( http://flask.pocoo.org/snippets/56/ ) 两者都显示相同的问题。
这是我的示例应用程序:
application = Flask(__name__,
static_url_path='',
static_folder='static')
CORS(application)
application.config['CORS_HEADERS'] = 'Content-Type'
@application.route('/api/v1.0/example')
@cross_origin(origins=['http://example.com'])
# @crossdomain(origin='http://example.com')
def api_example():
print(request.headers)
response = jsonify({'key': 'value'})
print(response.headers)
return response
Run Code Online (Sandbox Code Playgroud)
(插入编辑 3):
当我在浏览器中(从 127.0.0.1 开始)从 JS 向该端点发出 GET 请求时,它总是返回 200,我希望看到:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:5000' is therefore not allowed access. The …Run Code Online (Sandbox Code Playgroud) 我有一个带有一些令人困惑的Git克隆统计信息的Github存储库。如下所示,该存储库没有大量的访问者或星级,但在9月29日显示了相对大量的克隆。
Github 的流量帮助页面不是很有帮助,但是我假设“克隆”统计信息将对发出的每个单独的克隆命令进行计数。似乎不可能有3个克隆程序在一天之内将这个仓库克隆近400次。
这个统计数据还能代表什么?
我有一个[AVAsset]数组,我正在尝试将所有这些资产组合成一个资产,以便我可以无缝播放视频(我尝试使用AVQueuePlayer,但不能无缝播放资产).
下面是我到目前为止所做的,但当我尝试播放最终乐曲时,它只播放第一首曲目,即使它表明它具有所有曲目且总持续时间等于所有曲目.
我是否错过了一个步骤,即使看起来所有曲目都在合成中?如果AVPlayerItem有多个轨道,也许我需要以不同的方式处理AVPlayer?
let playerLayer: AVPlayerLayer = AVPlayerLayer()
lazy var videoPlayer: AVPlayer = AVPlayer()
var videoClips = [AVAsset]()
let videoComposition = AVMutableComposition()
var playerItem: AVPlayerItem!
var lastTime: CMTime = kCMTimeZero
for clipIndex in videoClips {
let videoCompositionTrack = videoComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
do {
try videoCompositionTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, clipIndex.duration),
ofTrack: clipIndex.tracksWithMediaType(AVMediaTypeVideo)[0] ,
atTime: lastTime)
lastTime = CMTimeAdd(lastTime, clipIndex.duration)
} catch {
print("Failed to insert track")
}
}
print("VideoComposition Tracks: \(videoComposition.tracks.count)") // Shows multiple tracks
playerItem = AVPlayerItem(asset: videoComposition)
print("PlayerItem Duration: \(playerItem.duration.seconds)") // Shows …Run Code Online (Sandbox Code Playgroud) 我知道这个 html 很草率,有一些不必要的额外 div,但无论如何,我无法理解为什么 ID 为“info_box_right”的 div 与父 div 的底部对齐(您可以看到“文本”对齐到下面的 jsfiddle 示例的底部)。
有什么想法可以让它与其父级的顶部对齐吗?
http://jsfiddle.net/taddme0y/1/
HTML:
<div id="info_container" >
<div id="info_box">
<hr class="info_box_hr" noshade>
<a id="info_box_title"></a>
<hr class="info_box_hr" noshade>
<div id="info_box_wrapper">
<div id="info_box_left">
<div class="info_box_sub_wrapper">
<a id="info_box_logo">
<img class="info_img" id="info_img_logo" alt="logo">
</a>
<a id="info_box_screenshot">
<img class="info_img" id="info_img_screenshot" alt="screenshot">
</a>
</div>
</div>
<div id="info_box_right">
<div class="info_box_sub_wrapper">
<a id="info_box_right_text">
Text
</a>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#info_container {
z-index: 500;
position: relative;
top: 0;
left: 0;
width: 80%;
height: 0;
margin: 0 …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装Postgres以使用Heroku。
我按照Heroku教程中的说明进行操作,并且在安装Postgres之后(成功),它说要配置.bash_profile以允许Postgres命令行功能。
我正在按照此处的说明进行操作,但是无法成功添加以下行:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Run Code Online (Sandbox Code Playgroud)
该文件夹实际上在我的计算机上确实包含“ psql”,因此它应该可以工作。这是我当前的.bash_profile:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# The next line updates PATH for the Google Cloud SDK.
source '/Users/user/google-cloud-sdk/path.bash.inc'
# The next line enables shell command completion for gcloud.
source '/Users/user/google-cloud-sdk/completion.bash.inc'
Run Code Online (Sandbox Code Playgroud)
我试图将Postgres行添加到该文件的末尾,但是它不起作用。在线搜索之后,关于如何向.bash_profile中添加PATH似乎尚未达成共识。我尝试了列出的许多版本,但没有一个起作用。
如果我做错了,请告诉我!
目录树:
.
??? main.go
??? web
??? app.go
??? views
??? index.html
??? js
??? app.jsx
Run Code Online (Sandbox Code Playgroud)
这有效:
package main
import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("./web/views")))
http.ListenAndServe(":3000", nil)
}
Run Code Online (Sandbox Code Playgroud)
但这回归404 page not found:
main.go:
package main
import (
"{dir with main.go}/web"
)
func main() {
web.StartHttp()
}
Run Code Online (Sandbox Code Playgroud)
app.go:
package web
import (
"fmt"
"net/http"
)
func StartHttp() {
fmt.Println("STARTHTTP - CHECK 01")
http.Handle("/", http.FileServer(http.Dir("./views")))
http.ListenAndServe(":3000", nil)
}
Run Code Online (Sandbox Code Playgroud)
终端打印STARTHTTP - CHECK 01,因此StartHttp()调用该功能,并且终端要求允许传入的网络连接,因此http服务器似乎正在侦听端口.
是否有某种类型的上下文未传递给其他包?
python ×4
android ×2
alignment ×1
argparse ×1
avasset ×1
avplayer ×1
aws-lambda ×1
bash ×1
boto3 ×1
build.gradle ×1
cors ×1
css ×1
dockerfile ×1
flask ×1
flask-cors ×1
git ×1
github ×1
go ×1
go-http ×1
google-api ×1
heroku ×1
html ×1
ios ×1
java ×1
mapbox ×1
opencv ×1
position ×1
postgresql ×1
psql ×1
swift ×1
xml ×1
youtube-api ×1