这些天,当我在设置页面上的GitHub上创建一个新的存储库时,我得到:
git remote add origin https://github.com/nikhilbhardwaj/abc.git
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
每当我必须提交提交时,我需要输入我的GitHub用户名和密码.
我可以手动将其更改为
git@github.com:nikhilbhardwaj/abc.git
Run Code Online (Sandbox Code Playgroud)
在.git/config.我觉得这很烦人 - 有什么办法可以配置git默认使用SSH吗?
我正在运行Mac OS 10.9.5,我已经按照https://docs.docker.com/installation/mac/来安装docker .即使boot2docker VM在后台运行,我运行docker时也会收到超时错误消息.
nikhil@macbook ~> boot2docker status
running
nikhil@macbook ~> boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103
nikhil@macbook ~> docker run hello-world
2014/11/01 01:01:31 Post https://192.168.59.103:2376/v1.15/containers/create: dial tcp 192.168.59.103:2376: i/o timeout
nikhil@macbook ~> docker search ubuntu
2014/11/01 01:02:40 Get https://192.168.59.103:2376/v1.15/images/search?term=ubuntu: dial tcp 192.168.59.103:2376: i/o timeout
Run Code Online (Sandbox Code Playgroud)
我已经验证了docker在boot2docker vm中运行并且我的端口是正确的.
nikhil@macbook ~> boot2docker ssh
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / …Run Code Online (Sandbox Code Playgroud) 我使用一个简单的代码从Java应用程序访问SQLite数据库.我的代码是
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectSQLite
{
public static void main(String[] args)
{
Connection connection = null;
ResultSet resultSet = null;
Statement statement = null;
try
{
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:D:\\testdb.db");
statement = connection.createStatement();
resultSet = statement
.executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");
while (resultSet.next())
{
System.out.println("EMPLOYEE NAME:"
+ resultSet.getString("EMPNAME"));
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
resultSet.close();
statement.close();
connection.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码给出了一个例外 …
我正在解析一些文本并根据一些规则计算权重.所有角色都具有相同的重量.这会使switch语句真的很长,我可以在case语句中使用范围.
我看到了一个提倡关联数组的答案.
$weights = array(
[a-z][A-Z] => 10,
[0-9] => 100,
['+','-','/','*'] => 250
);
//there are more rules which have been left out for the sake of clarity and brevity
$total_weight = 0;
foreach ($text as $character)
{
$total_weight += $weight[$character];
}
echo $weight;
Run Code Online (Sandbox Code Playgroud)
实现这样的目标的最佳方法是什么?是否有类似于PHP中的bash case语句?当然,在关联数组或switch语句中写下每个字符都不是最优雅的解决方案,还是唯一的替代方案?
我正在学习jQuery并且正在学习一个教程,一个非常奇怪的错误困扰着我.这是我的HTML:
<!doctype html>
<html>
<head>
<title> Simple Task List </title>
<script src="jquery.js"></script>
<script src="task-list.js"></script>
</head>
<body>
<ul id="tasks">
</ul>
<input type="text" id="task-text" />
<input type="submit" id="add-task" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和jQuery:
$(document).ready(function(){
//To add a task when the user hits the return key
$('#task-text').keydown(function(evt){
if(evt.keyCode == 13)
{
add_task(this, evt);
}
});
//To add a task when the user clicks on the submit button
$("#add-task").click(function(evt){
add_task(document.getElementByID("task-text"),evt);
});
});
function add_task(textBox, evt){
evt.preventDefault();
var taskText = textBox.value;
$("<li>").text(taskText).appendTo("#tasks");
textBox.value = "";
}; …Run Code Online (Sandbox Code Playgroud) 我在代码库中遇到了一个错误,我已经缩小到导致这种行为的原因.第一个测试用例失败,而后两个失败.
@Test
public void testBooleanNull1() {
Boolean nullB = null;
assertFalse(Boolean.valueOf(nullB));
}
@Test
public void testBooleanNull2() {
String nullS = null;
assertFalse(Boolean.valueOf(nullS));
}
@Test
public void testBooleanNull3() {
assertFalse(Boolean.valueOf(null));
}
Run Code Online (Sandbox Code Playgroud)
我知道这Boolean.valueOf是一个重载方法,有两个变量,一个采用a String,另一个采用类型的原语boolean.
我怀疑这是因为自动装箱而发生,但我不确定是否是这种情况,而且我不知道为什么null被转换为a Boolean,据我所知null不是有效primitive类型.
我已经转而使用BooleanUtils了Apache Commons,我在这里问这个更好地理解为什么这种行为是这样的.
我想调试我的Android应用程序,我使用USB线将Android设备连接到我的PC.在我的应用程序中有一个用于连接localhost的按钮,用于localhost的ip是10.0.2.2端口8080,我已经读过在移动设备上调试时,ip 10.0.2.2是android设备的本地主机而不是我的PC,所以应该做什么改变到ip而不是10.0.2.2?还是我必须做出另一个改变?在这种情况下,我的Android设备是sony ericsson xperia arc s.
我正在尝试创建一个2D数组来存储一些不会像这样改变的值.
const int[,] hiveIndices = new int[,] {
{200,362},{250,370},{213,410} ,
{400,330} , {380,282} , {437, 295} ,
{325, 405} , {379,413} ,{343,453} ,
{450,382},{510,395},{468,430} ,
{585,330} , {645,340} , {603,375}
};
Run Code Online (Sandbox Code Playgroud)
但是在编译时我得到了这个错误
hiveIndices is of type 'int[*,*]'.
A const field of a reference type other than string can only be initialized with null.
Run Code Online (Sandbox Code Playgroud)
如果我改变const to static,它会编译.我不明白添加const量词应该如何引发这种行为.
我试图将图像存储在DataBase中,由于某种原因它似乎不起作用.这是我桌子的结构.
mysql> describe ImageStore;
+---------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+----------+------+-----+---------+-------+
| ImageId | int(11) | NO | PRI | NULL | |
| Image | longblob | NO | | NULL | |
+---------+----------+------+-----+---------+-------+
2 rows in set (0.01 sec)
Run Code Online (Sandbox Code Playgroud)
这是我的查询插入图像或至少这应该是什么:
//Store the binary image into the database
$tmp_img = $this->image['tmp_name'];
$sql = "INSERT INTO ImageStore(ImageId,Image)
VALUES('$this->image_id','file_get_contents($tmp_image)')";
mysql_query($sql);
Run Code Online (Sandbox Code Playgroud)
如果我打印file_get_contents($ tmp_image)的值,那么屏幕上会有大量数据.但是这个值并没有存储在数据库中,这就是我所面临的问题.
我只是在Channel9上观看了一些视频.我发现像lambdas这样的东西真的很酷.当我试图复制该示例时,它失败了.auto也没用.
我正在使用配备gcc-4.4.0的诺基亚qtcreator.
我想知道哪个编译器具有实现的有趣功能,所以我可以玩游戏并学习.我不是反MS或者任何人,所以我不介意尝试Visual Studio,如果它有这些功能.