飞线拯救不能充电的Nexus 7一代,测试电池可以充电并且7的U口插上电源但在电池排插测不到电压,所以用两条飞线直接将U口的正负极接过来。目前充电正常,只是没有充电状态显示,可以安装应用显示电量百分比,可以看到比较明显的变化。直接用2A的充电器给电池充电时,电池的电压每秒增加约0.001V。
分类: IT小常识
__MigrationHistory
MVC5+MySql
尽管有了这篇文章的指引,但我还是不知道为什么__MigrationHistory这个表还是无法被创建,所以在初始化数据库连接的时候总是报错。所以手工建立了这个表:
CREATE TABLE `__migrationhistory` (
`MigrationId` varchar(255) NOT NULL,
`Model` varchar(2048) DEFAULT NULL,
`ProductVersion` varchar(32) DEFAULT NULL,
PRIMARY KEY (`MigrationId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Change/Upgrade from Linux to Windows host in Godaddy Shared Hosting service
直到找到这篇博客我才敢放心的转移,当然全面的备份是不可少的。目前我的Filezilla正在辛勤的下载文件。
Godaddy网站自己并没有说清楚windows的hosting支持哪些语言,只是简单的说如果想支持asp.net就只能选择这个,其实他也支持php啊,这多么重要啊。而从Linux迁移到Windows也只要在后台相应的hosting项目的option中做一个简单操作。对于我所有的wordpress来说,应该不会有太大意外发生。
因为工作的关系,两年以来一直用ASP.NET MVC3/4+Mysql组合开发,所以自己的一些定制开发的小项目也基本上都采用这个模式,其他的全部用wordpress解决了。最近想做一个出版经纪人的项目,以检验自己关于这个角色的一些设想。
创维VT-E03安装泰捷视频电视版应用App方法
主流云主机非标准测试
因为是个人用途,所以选择的都是最低端的配置,这里介绍一下大致的体验,不是标准测试,仅供参考。
测试环境是Windows 2008 R2+MySQL5.5+IIS+MVC4 继续阅读“主流云主机非标准测试”
获取汉字的十六进制编码
public static string Str2Hex(string s)
{
string result = string.Empty;
byte[] arrByte = System.Text.Encoding.GetEncoding(“GB2312”).GetBytes(s);
for (int i = 0; i < arrByte.Length; i++)
{
result += “0x” + System.Convert.ToString(arrByte[i], 16).ToUpper() + “,”; //Convert.ToString(byte, 16)把byte转化成十六进制string
}
return result;
}
防水 超声波测距模块 一体化超声波DYP-ME007Y-TX串口输出
在淘宝“高校基地”店买了一个http://item.taobao.com/item.htm?spm=a1z0k.6846101.1130973605.d4915209.SAObbz&id=36884805726,还有一种是PWM输出,这个代码比较多,就是最普遍的发送命令,然后等待信号,再计时,用声速推算距离,但是TX输出把我搞乱了。
终于在http://forum.arduino.cc/index.php?topic=88388.5;wap2找到了答案:
#include <SoftwareSerial.h>
// TX_PIN is not used by the sensor, since that the it only transmits!
#define PING_RX_PIN 6
#define PING_TX_PIN 7SoftwareSerial mySerial(PING_RX_PIN, PING_TX_PIN);
long inches = 0, mili = 0;
byte mybuffer[4] = {0};
byte bitpos = 0;void setup() {
Serial.begin(9600);mySerial.begin(9600);
}void loop() {
bitpos = 0;
while (mySerial.available()) {
// the first byte is ALWAYS 0xFF and I’m not using the checksum (last byte)
// if your print the mySerial.read() data as HEX until it is not available, you will get several measures for the distance (FF-XX-XX-XX-FF-YY-YY-YY-FF-…). I think that is some kind of internal buffer, so I’m only considering the first 4 bytes in the sequence (which I hope that are the most recent! 😀 )
if (bitpos < 4) {
mybuffer[bitpos++] = mySerial.read();
} else break;
}
mySerial.flush(); // discard older values in the next readmili = mybuffer[1]<<8 | mybuffer[2]; // 0x– : 0xb3b2 : 0xb1b0 : 0x–
inches = 0.0393700787 * mili;
Serial.print(“PING: “);
Serial.print(inches);
Serial.print(“in, “);
Serial.print(mili);
Serial.print(“mili”);delay(100);
}
说明:模块每次输出一帧,含4个8位数据,帧格式为:0XFF+H_DATA+L_DATA+SUM
1、0XFF: 为一帧开始数据,用于判断。
2、H_DARA:距离数据的高8位。
3、L_DATA:距离数据的低8位。
4、SUM: 数据和用于交验。其0XFF+H_DATA+L_DATA=SUM(仅低8位)
5、H_DATA与L_DATA合成16位数据,即以毫米为单位的距离值。
注意:模块检测最小距离为30cm,在30cm内有物体,将获得不准确信号。
以上代码中没有做SUM校验
Arduino Yún与DFR0265(IO Expansion Shield for Arduino V7)不兼容解决办法
如图,因为Yun的网线口比之前的板子挨着引脚近,所以V7插不上去,研究一番,决定加一层排母,垫高一些再插扩展板。最终选择
1.http://item.taobao.com/item.htm?id=20747855300 1个;
2.http://item.taobao.com/item.htm?id=20747511841 2个;
3.http://item.taobao.com/item.htm?id=20747903210 1个;
4.http://item.taobao.com/item.htm?id=20802935165 1个。
另外还想把这些排母焊到一层板子上,不过单买一个洞洞板运费不划算,回头想好了再说。
BugNet Issue Tracker域帐号配置说明
网站安装时只需要修改web.config中的数据库连接,其他不变,主要是<authentication mode=”Forms”>保持不变。
1. 用默认的admin账号登录,初始密码是password,界面上有说明,登录后可以在系统设置中修改;
2. 添加一个域帐号作为切换到域帐号登录模式后的管理员账号,新建用户,Admin->User Accounts->Create New User->User Name的格式为domain\username,具体如ccppg\mengfanyong,其他随便填,密码勾选Random Password; 继续阅读“BugNet Issue Tracker域帐号配置说明”
Asp.net mvc + .net EF database first 或 model first 时如何添加验证特性
在使用Entity Framework 的Database frist或model first时,怎么在model上添加验证的特性?
因为此时的Model是是VS 工具怎么生成的,直接加attribute到modle类上是太现实也不合理。一个比较合理做法,就是用 buddy class的方式来实现。
比如有一个Model类: Movie。那我们就可以添加一个局部类文件,局部类的内容如下:
using System.ComponentModel.DataAnnotations;
namespace Movies.Models
{
[MetadataType(typeof(MovieMetadata))]
public partial class Movie
{
private class MovieMetadata //这个类名随便起,相当于把这个类里面的东西追加给Movie,这个追加是用[MetadataType]实现的
{
[Required(ErrorMessage="Titles are required")]
public string Title { get; set; }
[Required(ErrorMessage="The Price is required.")]
[Range(5,100,ErrorMessage ="Movies cost between $5 and $100.")]
public decimal Price { get; set; }
}
}
}
通过在这个局部类文件中添加需要的验证属性就可以了。
以上内容来自http://www.cnblogs.com/ITHelper/archive/2013/01/08/2851442.html
另外,对于有文件上传的时候,还可以写一个扩展的model,比如:
public class MovieViewModel
{
[FileExtensions(Extensions = “jpg,gif,png”, ErrorMessage = “jpg,gif,png”)]
public HttpPostedFileBase CoverImageFile { get; set; }
public Movie movie { get; set; }
}
这样,在给control生成强类型view的时候就用MovieViewModel。

