我不知道如何解决这个错误。
bash:/home/dery/.bashrc:第 168 行:语法错误:文件意外结束
这是我的.bashrc:
case $- in
*i*) ;;
*) return;;
esac
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; …Run Code Online (Sandbox Code Playgroud) 我正在我的gradle构建中设置jvm args并且它给了我这个温和烦人的消息:
Note: in order to honour the org.gradle.jvmargs and/or org.gradle.java.home values specified for this build, it is necessary to fork a new JVM.
To avoid the slowdown associated with this extra process, you might want to consider running Gradle with the daemon enabled.
Please see the user guide chapter on the daemon at /Users/gus/tools/gradle-1.4/docs/userguide/gradle_daemon.html.
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
Run Code Online (Sandbox Code Playgroud)
所以我想尝试让消息消失gradle --daemon.然后我遇到了一大堆垃圾邮件,看起来像这样:(小摘录)
14:33:35.248 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Build
14:33:35.287 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: received class …Run Code Online (Sandbox Code Playgroud) 许多架构师和工程师推荐使用依赖注入和其他控制反转模式来提高代码的可测试性。不可否认,依赖注入使代码更具可测试性,但是,一般来说,它不也是抽象的一个完整目标吗?
我觉得很矛盾!我写了一个例子来说明这一点;它不是超现实的,我不会这样设计,但我需要一个具有多个依赖项的类结构的快速而简单的示例。第一个例子没有依赖注入,第二个例子使用注入依赖。
非 DI 示例
package com.stackoverflow.di;
public class EmployeeInventoryAnswerer()
{
/* In reality, at least the store name and product name would be
* passed in, but this example can't be 8 pages long or the point
* may be lost.
*/
public void myEntryPoint()
{
Store oaklandStore = new Store('Oakland, CA');
StoreInventoryManager inventoryManager = new StoreInventoryManager(oaklandStore);
Product fancyNewProduct = new Product('My Awesome Product');
if (inventoryManager.isProductInStock(fancyNewProduct))
{
System.out.println("Product is …Run Code Online (Sandbox Code Playgroud) java language-agnostic oop design-patterns dependency-injection
我想在 PHP5.6$min和$maxPHP5.6之间生成一个安全的随机整数。双方rand()并mt_rand()在PHP被认为不是密码安全。
从文档:
警告
此函数不生成加密安全值,不应用于加密目的。如果您需要加密安全值,请考虑改用 random_int()、random_bytes() 或 openssl_random_pseudo_bytes()。
PHP 7 添加了random_int()( docs ),它非常适合我的用例:
random_int — 生成加密安全的伪随机整数
但是如何在 PHP 5.6 中实现这个功能呢?
我天真的尝试是这样的:
<?php
function secure_rand($min, $max)
{
return (unpack("N", openssl_random_pseudo_bytes(4)) % ($max - $min)) + $min;
}
Run Code Online (Sandbox Code Playgroud)
但我似乎总是在调用时得到“2” secure_rand(1, 100)。我还读到,以这种方式使用模数运算会产生偏差。如何random_int()在 PHP 5.6 中进行模拟?
我可以使用sha1(md5($password))更好的密码哈希,并且它会更难破解吗?或者哈希的安全性是否相同?
在 的session部分中php.ini有一个名为 的指令session.entropy_length。
我知道它用于使会话 ID 的生成“更加随机”。
它如何使 Session ID 更加随机?
最大长度是多少?
如果它的长度超过hash正在使用的位怎么办?
我的问题是,当我们grep在终端输入命令时,我们得到输出以及标题:
例如:
lscpu | grep MHz
Run Code Online (Sandbox Code Playgroud)
将输出:
CPU MHz: 1216.851
Run Code Online (Sandbox Code Playgroud)
但是,如果我只想要:
1216.851
Run Code Online (Sandbox Code Playgroud)
作为输出?还有其他命令来执行此任务吗?
传入以下JSON字符串json_decode(),它正在返回NULL.
{"total_goals":26,"total_games":17,"average_goals":"1.53"}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
$homeJSON = file_get_contents("http://strategy-bets.com/archive/archive.php?baseurl=http://www.totalcorner.com".$Home_Team_Link);
$homeJSON = str_replace("\xEF\xBB\xBF",'',$homeJSON);
$homeJSON = rtrim($homeJSON);
$homeJSON = html_entity_decode($homeJSON);
$homeJSON = preg_replace('/\s+/', '', $homeJSON);
$clean = rtrim($homeJSON, "\x00..\x1F");
$home_decoded = json_decode($clean);
Run Code Online (Sandbox Code Playgroud)
$home_decoded还在NULL.
我正在学习PHP开发作为初学者的过程我想问一下关于if与isset一起使用的问题.这里有两个代码:
这两段代码之间有什么区别:
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) )
Run Code Online (Sandbox Code Playgroud)
和:
if (isset($_GET['s']) && is_numeric($_GET['s']))
Run Code Online (Sandbox Code Playgroud)
在第一部分中,isset()并且is_numeric()在另一组括号内.
但是在第二次它们位于if()括号内.
第一个和第二个片段之间有什么区别吗?
提前感谢任何解释和澄清.
我有一个字典,其中包含我想要排序的字符串键和int值.我希望它首先按减少数值排序,然后按字母顺序排序.
例如,如果你有一个字典包含:
my_dict = {'zebra':1, 'the':201, 'apple':1, 'chicken':58}
Run Code Online (Sandbox Code Playgroud)
生成的排序列表将包含:
{('the', 201), ('chicken', 58), ('apple', 1), ('zebra', 1)
Run Code Online (Sandbox Code Playgroud)
目前我正在使用以下内容:
my_list = sorted(my_dict.items(), key=lambda x: (x[1],x[0])
Run Code Online (Sandbox Code Playgroud)
我得到一个列表,先按升序排序,然后按字母顺序排序.
如何反转值而不是键?我知道你可以将第三个参数传递reverse=[boolean]给sorted()方法,但它要么反转BOTH键和值,要么反转.怎么可以只通过一次逆转排序?谢谢你的帮助!