小编Mar*_* Ma的帖子

为什么在使用http gzip压缩后png大小不会改变

我使用以下.htaccess来设置gzip压缩:

AddOutputFilterByType DEFLATE text/html image/png image/jpeg text/css text/javascript
Run Code Online (Sandbox Code Playgroud)

请查看此网址:http://www.coinex.com/cn/silver_panda/proof/china_1984_27_gram_silver_panda_coin/

gzip压缩适用于html,css,js和jpg,但不适用于png(非常棒......)

apache .htaccess gzip http-compression deflate

20
推荐指数
4
解决办法
2万
查看次数

如何将SQL Server数据库迁移到MySQL?

我有一个SQL Server数据库,包含大量数据和一个空的MySQL数据库.现在我想将SQL Server数据库的所有数据(包括数据库模式)复制到MySQL数据库.

我考虑过使用原始SQL转储,但SQL Server的SQL语法与MySQL不同.

我用谷歌搜索了一些数据库迁移工具,比如南方(仅适用于django),简单数据库迁移(仅适用于一种类型的数据库,可能是PostreSQL?)和SQLAlchemy(我还没有完成学习,只是感觉有点笨重).

我可以使用什么工具来完成此迁移?

mysql sql-server database-migration

17
推荐指数
2
解决办法
8万
查看次数

由于其保护级别,ConfigurationProperty无法访问

我想在程序中读/写(并保存)应用程序的配置文件

app.config是这样的:

<configuration>
  <configSections>
    <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler" requirePermission="false"/>
  </configSections>
  <AdWordsApi>
    <add key="LogPath" value=".\Logs\"/>
    ...
  </AdWordsApi>
</configuration>
Run Code Online (Sandbox Code Playgroud)

当我使用ConfigurationManager.GetSection读取app.config时,它可以工作:

var adwords_section = (System.Collections.Hashtable) System.Configuration.ConfigurationManager.GetSection("AdWordsApi");
Console.WriteLine((string)adwords_section["LogPath"]);
Run Code Online (Sandbox Code Playgroud)

但是当我使用ConfigurationManager.OpenExeConfiguration时:

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ConfigurationSection section = config.GetSection("AdWordsApi");
Console.WriteLine(section["LogPath"]);
Run Code Online (Sandbox Code Playgroud)

我总是得到这个错误:

由于其保护级别,'System.Configuration.ConfigurationElement.this [System.Configuration.ConfigurationProperty]'无法访问

但据我所知,GetSection无法在程序运行时保存配置,就像我在开头说的那样:我想在程序运行时保存配置,所以我必须使用OpenExeConfiguration.

我已经google了很长时间,我发现使用AppSettings,但我使用的是自定义部分..

任何人都可以解释为什么会出现"ConfigurationProperty无法访问"错误?谢谢

编辑:

我已复制本地系统System.Configuration

.net c# configurationmanager app-config configurationsection

10
推荐指数
2
解决办法
3万
查看次数

无法为django中的forms.ChoiceField设置初始值

大家

我想为ChoiceField设置初始值,而该值不在ChoiceField的选项中

以下是ArticleForm定义:

def ArticleForm(forms.Form):
  choice = forms.ChoiceField(choices=[['a':'a'],['b':'b']])
Run Code Online (Sandbox Code Playgroud)

然后我通过传递初始参数来实例化表单:

form = ArticleForm(initial={'choice':'Portrush'})
Run Code Online (Sandbox Code Playgroud)

请注意,初始值('Portrush')不是ChoiceField('a'和'b')中定义的选项之一

我怎么能设定初始值?任何建议表示赞赏.

python django django-forms

8
推荐指数
1
解决办法
5070
查看次数

CURDATE()导致语法错误

大家

我想添加一个列start_date,其默认值是当前日期(),所以我使用以下命令:

alter table validation添加列start_date日期默认值CURDATE()

但它没有用,并告诉我它有语法错误.

使用以下命令时效果很好:

alter table validation添加列start_date日期默认值为0

任何建议表示赞赏.

mysql database

5
推荐指数
1
解决办法
5347
查看次数

python和c#中的字节字符串相同,但md5哈希码是不同的

我想从字符串生成哈希码,例如"咖啡",但我从python和c#得到的哈希码是不同的,python中的哈希码是我想要的

C#

String str = "??";
MD5 m = MD5.Create();
byte[] data = m.ComputeHash(Encoding.Default.GetBytes(str));
StringBuilder sbuilder = new StringBuilder();
for(int i=0;i<data.Length;i++){
  sbuilder.Append(data[i].ToString("x2"));
}
byte[] hex = Encoding.Default.GetBytes(str);
StringBuilder hex_builder = new StringBuilder();
foreach(byte a in hex){
  hex_builder.Append("{0:x2}",a);
}
//md5 hash code
Response.Write(sbuilder.ToString());
//binary string
Response.Write(hex_builder.ToString());
Run Code Online (Sandbox Code Playgroud)

蟒蛇

#coding:utf8
str = '??'
m = hashlib.md5()
m.update(str)
#md5 hashcode
print m.hexdigest()
#binary string
print ' '.join(["%02x"%ord(x) for x in str])
Run Code Online (Sandbox Code Playgroud)

二进制字符串是c#和python中的e5 92 96 e5 95 a1

md5哈希码:

(C#)a761914f9760af3c112e24f08dea1b16

(蟒)3b7daa58a1fecdf5ba4d94d539fbb4d5

c# python encoding md5

4
推荐指数
1
解决办法
2375
查看次数

动态追加html时,jquery选择器不起作用

我可以动态地将"选择"控件附加到DOM,在将它附加到DOM之后,我想要更改最后一个"选择"的html内容(动态添加的最新"选择"),但它失败了......

(我无法在param_html中设置选项值,因为我应该稍后使用ajax请求来设置它们.)

<script>
    $(function(){
      var param_html = '<select class="params"></select>';
      $("input[value='+']").click(function(){
        $('#parameters').append(param_html);
          $('.params :last').html('<option>aaa</option><option>keyword in profile</option><option>last tweet</option>');
      });

    });
  </script>
  <div id="parameters">
    <input type="button" value="+">
    <select class="params"><option>1</option><option>2</option></select>
  </div>
Run Code Online (Sandbox Code Playgroud)

任何建议表示赞赏.

html javascript jquery dom

3
推荐指数
1
解决办法
8094
查看次数

如何通过代码添加eventsetter

一个完整的例子

    public delegate void mouseup_delegate(object obj, MouseButtonEventArgs args);

    constructor()
    {
        TextBlock text_block = new TextBlock() { Text = "aa" };
        Style style = new Style();
        //style.Setters.Add(new EventSetter(){Event=TextBlock.MouseUpEvent, Handler=new mouseup_delegate(this.textblockClicked)});
        style.Setters.Add(new EventSetter(TextBlock.MouseUpEvent, new mouseup_delegate(this.textblockClicked)));
        text_block.Style = style;
    }

    public void textblockClicked(object sender, MouseButtonEventArgs args)
    {
        MessageBox.Show("mouse up");
    }
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,会出现异常:处理程序类型无效

这段代码有什么问题?

c# wpf delegates event-handling eventsetter

3
推荐指数
1
解决办法
5699
查看次数

如何在底部设置页脚?

以下是我的代码

HTML:

<div id="content">
<div id="A">
A
</div>
<div id="B">
B
</div>
</div>
<div id="footer">
  footer
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

#content{
  width:600px;
}
#A{
  position:relative;
  float:left;
  background:#0000ff;
  width:300px;
  height:600px;
}
#B{
  position:relative;
  float:right;
  background:#00ff00;
  width:300px;
  height:100px;
}
#footer{
  background:#ff0000;
}
Run Code Online (Sandbox Code Playgroud)

我想在底部设置页脚,但页脚位于div B.

当我使用float:left for footer,虽然页脚在底部,我必须设置页脚的宽度,但我想让页脚的宽度等于浏览器窗口的宽度.

那么如何在底部设置页脚并将页脚的宽度设置为等于浏览器窗口的宽度?任何建议表示赞赏.

css

0
推荐指数
1
解决办法
2675
查看次数