您好我在javascript中使用类来散列字符串:https: //ssl.bsk.com.pl/mobi/js/sha1.js
hex_hmac_sha1("927545161", "asdasdasdasd?") ;
Run Code Online (Sandbox Code Playgroud)
结果是:5db0194c834d419fc5d68b72c88af1ac8ee749d6
在PHP中我是哈希:
echo hash_hmac('sha1', "asdasdasdasd?", '927545161');
Run Code Online (Sandbox Code Playgroud)
但结果是:0b115775a20bed9922b6a9cc934cb5328fe71ade
错误在哪里?5db0194c834d419fc5d68b72c88af1ac8ee749d6!= 0b115775a20bed9922b6a9cc934cb5328fe71ade
我的Web应用程序中的视图有一个可能非常长的表,因此我将其包装在div中,overflow: auto; max-height: 400px;以便用户可以滚动浏览它,同时保持页面上的其他控件可见.
我想使用一些JavaScript动态调整max-heightCSS属性,以便div延伸到浏览器窗口的底部.我该如何确定这个值?jQuery解决方案很好.
该表不会从页面顶部开始,因此我不能将高度设置为100%.
我创建了一个这样的用户:
create user blog with password 'blog';
Run Code Online (Sandbox Code Playgroud)
然后我把它作为数据库的所有者:
alter database blog_development owner to blog;
Run Code Online (Sandbox Code Playgroud)
然后我尝试登录,它不起作用:
$ psql -d blog_development -U blog -W
Password for user blog:
psql: FATAL: Ident authentication failed for user "blog"
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
我尝试过的一件事就是编辑 pg_hba.conf
76 # Database administrative login by UNIX sockets
77 local all postgres ident
78
79 # TYPE DATABASE USER CIDR-ADDRESS METHOD
80
81 # "local" is for Unix domain socket connections only
82 local all all ident
83 # IPv4 local connections:
84 …Run Code Online (Sandbox Code Playgroud) 我知道有很多方法可以在现有的ruby数组中创建新元素.
例如
myArray = []
myArray + other_array
myArray << obj
myArray[index] = obj
Run Code Online (Sandbox Code Playgroud)
我也敢肯定,我可以使用.collect,.map,.concat,.fill,.replace,.insert,.join,.pack和.push以及加入或修改的内容myArray.
但是,我想确保myArray只包含有效的HTTP/HTTPS URL.
任何人都可以解释我是如何强制执行这种行为的吗?
可能已经问过但我找不到..这里有两种常见的情况(对我而言编程rails ..)在ruby中写的很令人沮丧:
"a string".match(/abc(.+)abc/)[1]
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我得到一个错误,因为字符串不匹配,因此调用[]运算符为零.我想要找到的是一个更好的替代方案:
temp="a string".match(/abc(.+)abc/); temp.nil? ? nil : temp[1]
Run Code Online (Sandbox Code Playgroud)
简而言之,如果它不匹配则只返回nil而没有错误
第二种情况是这样的:
var = something.very.long.and.tedious.to.write
var = something.other if var.nil?
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我想只在不是nil的情况下为var分配一些东西,如果它是零,我将分配something.other ..
有什么建议吗?谢谢!
我一直试图将相机图像从iPhone上传到我的网络服务器,但有些图像是如何在病房后改变它的方向.这只发生在相机图像上,而不是从我的机器上传到设备的简单图像.
以下是代码:
NSData *imgdataRepresentation = UIImageJPEGRepresentation(imgTemp, 0.5);
///////**********************************************
// setting up the URL to post to
NSString *addPhotoURL = [NSString stringWithFormat:@"%@%@%@",HTTP_HOST,ADD_PHOTO_URL,[userInfo.userDetail objectForKey:@"id"]];
// setting up the request object now
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:addPhotoURL]];
[request setHTTPMethod:@"POST"];
/*
add some header info now
we always need a boundary when we post a file
also we need to set the content type
You might want to generate a random boundary.. this is just the same
as my …Run Code Online (Sandbox Code Playgroud) 为什么php的字符串是值类型?每次将参数传递给函数时,它都会被复制到每个位置,每次进行赋值时,每个连接都会导致复制字符串.我的.NET经验告诉我,它似乎效率低下,迫使我几乎无处不在地使用引用.考虑以下备选方案:
备选方案1
// This implementation hurts performance
class X {
public $str;
function __construct($str) { // string copied during argument pass
$this->$str = $str; // string copied here during assignment
}
}
Run Code Online (Sandbox Code Playgroud)
备选方案2
// This implementation hurts security
class Y {
public $str;
function __construct(&$str) {
$this->$str = &$str;
}
}
// because
$var = 'var';
$y = new Y($var);
$var[0] = 'Y';
echo $y->var; // shows 'Yar'
Run Code Online (Sandbox Code Playgroud)
备选方案3
// This implementation is a potential solution, the callee decides
// …Run Code Online (Sandbox Code Playgroud) 我需要更改项目的工作目录,以便输出文件转到某个文件夹,而不是所有项目文件.
我正在使用
system("cd secretdir/");
system("ls");
Run Code Online (Sandbox Code Playgroud)
但是,我得到的是当前项目目录中的文件列表,而不是"secretdir"文件.
我使用的是Mac OS X 10.6/Qt Creator 4.7 64位
谢谢!
作为一个非英语的人,我经常会遇到某些编程结构和缩写的问题.我一直在观看一些视频教程和收听播客,虽然我无法抓住它们.
我的问题是以下代码片段的常见或正确发音是什么?
泛型,像
IEnumerable<int> 或者在一种方法中 void Swap<T>(T lhs, T rhs)
集合索引和索引器访问例如
garage[i],矩形阵列myArray[2,1]或jagged[1][2][3]
Lambda运算符=>,例如在where扩展方法中
.Where(animal => animal.Color == Color.Brown)
或者以匿名方式
() => { return false;}
遗产
class Derived : Base (延伸?)
class SomeClass : IDisposable (实现?)
Arithemtic运营商
+= -= *= /= %= !
是+=和-=发音相同的事件?
集合初始化器
new int[] { 4, 5, 8, 9, 12, 13, 16, 17 };
铸件
MyEnum foo = (MyEnum)(int)yourFloat; (如?)
Nullables
DateTime? dt = new DateTime?(); …
这是一个非常奇怪的错误.我不知道为什么会发生这种情况.我知道在这里发布它有点长,但我没有其他想法.
我有两个ListBoxs作为菜单.
<ListBox Margin="56,8,15,0" FontSize="64"
ItemsSource="{Binding FavoriteSections}"
SelectionChanged="MenuList_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Remove" Click="FavoritesContextMenuItem_Click" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="sectionList" Margin="56,8,15,0" FontSize="64"
SelectionChanged="MenuList_SelectionChanged"
ItemsSource="{Binding SectionViewModels}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Add to favorites" Click="SectionContextMenuItem_Click" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
这两个错误都存在.
当任一菜单上的选择发生变化时,会调用此方法:
void MenuList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count == 0)
{
return;
}
Uri page = null;
object selected = e.AddedItems[0]; …Run Code Online (Sandbox Code Playgroud) c# ×2
javascript ×2
php ×2
ruby ×2
c++ ×1
dimensions ×1
directory ×1
idioms ×1
image ×1
iphone ×1
jquery ×1
orientation ×1
performance ×1
positioning ×1
postgresql ×1
security ×1
sha1 ×1
silverlight ×1
upload ×1
xaml ×1