干杯,我正试图通过Android获得当前的GPS位置.我也遵循了本教程和Vogellas的文章.虽然它不起作用.当使用LocationManager.NETWORK_PROVIDER时,无论我站在哪里,我总是得到51的纬度和9的经度.使用LocationManager.GPS_PROVIDER时,我什么都没得到.
虽然使用GMaps时一切正常:S不知道为什么.如何像GMaps一样获得当前的GPS位置?
这是我的代码:
package com.example.gpslocation;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.Menu;
public class GPS_Location extends Activity implements LocationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gps__location);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gps__location, menu);
return true;
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) 所以,在这里,我再次遇到另一个问题 - .-'
我编写了自己的php/html脚本来输入并将数据从表单传递到数据库.一开始它起作用了.不知何故,几天后它开始将我重定向到XAMPP localhost主页(http:// localhost/xampp /).我不明白为什么:/
这是我的网站的样子:
这是我的"addguestbook.php"的样子:
<?php
...database stuff...
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$comment = $_POST['comment'];
$datetime = date("l, jS M Y, g:i a"); //date time
// Connect to server and select database.
mysql_connect($host, $username, $password)or die("cannot connect server: ".mysql_error());
mysql_select_db($db_name)or die("cannot select DB: ".mysql_error());
$sql="INSERT INTO ".$tbl_name."(id, name, email, website, comment, datetime)VALUES('".$post_id."', '".$name."', '".$email."', '".$website."', '".$comment."', '".$datetime."')";
$result=mysql_query($sql);
mysql_close();
header('Location: http://'.$hostname.$path.'/index.php' . …Run Code Online (Sandbox Code Playgroud) 我知道扩展对象是通过
_.extend(parent, child);
Run Code Online (Sandbox Code Playgroud)
方法.
我在网上看到过不同的地方,人们在underscore.js中以特殊的方式扩展对象
_.extend({}, this, child);
Run Code Online (Sandbox Code Playgroud)
他们为什么这样做?
我有以下文件夹结构:
- .git
- services
- service-a
- .devcontainer
- src
- service-b
- .devcontainer
- src
- service-c
- .devcontainer
- src
- many more services...
Run Code Online (Sandbox Code Playgroud)
我在根文件夹中定义了 git 存储库。我为每个服务使用 VS-Code devcontainer,在其中安装子文件夹 ( service-a/、service-b/、service-c/)。在容器内部,我想使用git命令,即pull、add、commit、push等等。
这是不可能的,因为一旦我将子文件夹挂载到容器中,它就不知道根目录中有一个 .git 文件夹,因为该文件夹没有挂载进去。只有子文件夹挂载在.VS-Code 然后认为它不是 git 存储库。
我知道这个问题有几种解决方案/解决方法:
一种解决方案显然是将整个根文件夹挂载到容器中,但我的项目非常大。我在这个存储库中有几十个服务。仅安装相应服务的文件夹可以让我更好地了解其源代码。另外,我有多个具有相似或相同模块名称的 Python 项目。因此,在容器中使用自动完成功能时,还会发现其他服务的Python模块,这不是我想要的。
另一个解决方案是整理每个服务并将其放入其自己的 git 存储库中。这是我喜欢的解决方案,但遗憾的是,我没有时间这样做。
另一种解决方法是使用在主机上而不是在容器中运行的本地控制台。这让我可以访问 git。但是,VS-Code 将失去 git 的所有功能,因为 VS-Code 不知道安装的文件夹实际上是 git 存储库。
这个问题还有其他解决方案吗?
git containers docker visual-studio-code vscode-devcontainer
所以,这根本不起作用.
CheckBox chck_bluetooth = (CheckBox) findViewById(R.id.chck_bluetooth);
if (mProperties.getProperty("bluetooth") == "true") {
chck_bluetooth.setChecked(true);
Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
} else {
chck_bluetooth.setChecked(false);
Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
}
Run Code Online (Sandbox Code Playgroud)
好吧,日志告诉我蓝牙设置为"true",所以我想复选框一定有问题.
我很难理解教师的多线程方法.好吧,在展示我们的两个例子之前,我必须说他正在教一些新手(包括我,我猜^.^)所以他可能选择了一种易于理解的多线程方法.另外,我没有参观他的课程,但是我的脚本上写着以下内容:
他正在做这样的多线程:
class MyThread implements Runnable {
Thread t;
MyThread() {
t = new Thread(this, "Demo");
t.start();
}
public void run() {
try {
for (int i = 5; i > 0; i--) {
System.out.println("Child-Thread:" + i);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
System.out.println("Child interrupted");
}
System.out.println("Child finished");
}
}
Run Code Online (Sandbox Code Playgroud)
我觉得这样做比较干净:
public class Aufg1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyThread t1 = new MyThread(1);
ScheduledExecutorService executor = …Run Code Online (Sandbox Code Playgroud) Authenticity Token我刚刚注意到,通过 提交请求时将我的放在哪里并不重要AJAX。我可以将其附加到表单中POST data,或者将其放入Header.
有什么区别吗?特别是在安全方面?
此外:
我没有对 Token 进行编码Javascript。我现在接触过什么吗?
提前致谢。
编辑:
form.on("sending", function(file, xhr, formData) {
xhr.setRequestHeader('X-CSRF-Token', AUTH_TOKEN);
// formData.append('authenticity_token', AUTH_TOKEN);
});
Run Code Online (Sandbox Code Playgroud)
这是我Javascript将令牌添加到Header或(注释掉)到POST data. AUTH_TOKEN是原始密钥。我没有以任何方式对其进行编码。
在这个网站上找到它.
holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
Run Code Online (Sandbox Code Playgroud)
我要求"位置和1 ......"我已经多次看过这个陈述,但从来不知道这意味着什么:/虽然我觉得它很方便知道:P
谢谢!
我试图通过PHP上传图像.在上传时,应调整大小,使其'尺寸与我在config [] - 数组中定义的尺寸一样大,并且其'filesize也小于或等于我的config [] - 数组中的预定义值.但不知何故,方法getFileSize()总是返回相同的大小,即使在调整图像大小后也是如此.
这是我的代码.说明如下.
$tries = 0;
while ( $image->getFileSize() > $config['image_max_file_size'] && $tries < 10 ) {
$factor = 1 - (0.1 * $tries);
echo $image->getFileSize().PHP_EOL;
if ( !$image->resize($config['image_max_width'], $config['image_max_height'], $factor) ) {
return false;
}
$tries++;
}
Run Code Online (Sandbox Code Playgroud)
$ image是Picture类型的对象,它只是我需要修改图片所需的所有函数的包装类.
$ config是我的配置数组,包含所有类型的预定义值.
$ attempts包含允许的尝试次数.允许程序调整图像大小不超过10次.
getFileSize()通过返回文件大小(路径)返回image-filesize
resize(maxWidth,maxHeight,factor)将图像大小调整为参数中提到的大小.在调整图片大小后,它会将结果保存到同一路径,从中读取文件大小.
我将发布resize()和getFileSize()方法,因为它可能会让您感兴趣:
function resize($neededwidth, $neededheight, $factor) {
$oldwidth = $this->getWidth($this->file_path);
$oldheight = $this->getHeight($this->file_path);
$neededwidth = $neededwidth * $factor;
$neededheight = $neededheight …Run Code Online (Sandbox Code Playgroud) 为什么这个正则表达式
/^[^-_]*([A-Za-z0-9]{3,})+[-_]?[^-_]*$/i
Run Code Online (Sandbox Code Playgroud)
匹配这个字符串?
,abc,,.
Run Code Online (Sandbox Code Playgroud)
它清楚地说String应该只包含
正则表达式不应该允许任何其他字符比A-z,0-9和- or _,不过不失,这使他们.
提前致谢
我正在尝试同时收听不同类型的多个输入元素的更改事件.
这不起作用
$(function(){
$(".update_search").change( function() {
alert("do some");
});
});
<input class="update_search" id="car_type_ids_" name="car_type_ids[]" type="checkbox" value="1">
<select id="size" name="search[size]">
<option value="1">1</option>
<option selected="selected" value="2">2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
select和input标签工作正常,但我只在复选框上收到更改事件.
编辑: 我在渲染dom后调用JQuery.因此所有事件都应该受到约束