android 获取存储空间大小

摘要: #获取External Storage 上的存储空间/可用存储空间大小StatFs state = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());long blockSize = state.getBlockSize(); long blockCount = state.getBlockCount();long availableCount = state.getAvailableBlocks();long totalSpace = blockCount * blockSize / 1024; . 阅读全文
posted @ 2011-12-12 16:13 John Smith 阅读(1082) 评论(0) 推荐(0) 编辑

android 获取和设置屏幕亮度

摘要: # 获取屏幕亮度public static int getScreenBrightness(Activity activity) { int value = 0; ContentResolver cr = activity.getContentResolver(); try { value = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { } return value;}#... 阅读全文
posted @ 2011-12-12 16:02 John Smith 阅读(2522) 评论(0) 推荐(0) 编辑

android 调节媒体音量

摘要: 引用 AudioManager 对象AudioManager audio = (AudioManager) getSystemService(Service.AUDIO_SERVICE);重写 Activity 的 onKeyDown 方法@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: audio.adjustStreamVolume( AudioManager.... 阅读全文
posted @ 2011-11-02 10:09 John Smith 阅读(3281) 评论(0) 推荐(0) 编辑

android 根据分辨率对图像进行缩放

摘要: mDDpi = 0xF0;mDpi = 0xA0;if (mDDpi != mDpi) { float perc = (float) mDpi / (float) mDDpi; int width = (int) (org.getWidth() * perc); int height = (int) (org.getHeight() * perc); org = Bitmap.createScaledBitmap(org, width, height, true);}Drawable draw = new BitmapDrawable(getResources(), org); 阅读全文
posted @ 2011-11-02 10:05 John Smith 阅读(385) 评论(0) 推荐(0) 编辑

在IE键中添加菜单并调用外部程序

摘要: 1. 打开注册表编辑器regedit.exe;2. 定位到HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt ,在MenuExt节点上新建子项,如IELINK,如果要设置快捷键访问方式,可以用(&+字母)的方式;3. 设置默认值为一个地址,如:C:\startup.htm,当IE的菜单中点击菜单项时,就会调用该文件并执行里面的脚本;4.添加一个名为Contexts的DWORD值,并赋值,可以使用预定义的值或组合,定义如下:缺省 0x1图片 0x2控件 0x4表单域 0x8选择文本 0x10锚点(链接) 0x20如 阅读全文
posted @ 2011-03-05 18:11 John Smith 阅读(538) 评论(0) 推荐(0) 编辑

让ListBox自动滚动到底部

摘要: 在ListBox中添加一条记录(ListBox.Items.Add方法)后,滚动条会自动回到顶部。我们可能更希望它自动滚动到底部,本文简要介绍几种方法。方法1:在添加记录后,先选择最后一条记录,滚动条会自动到底部,再取消选择。缺点是需两次设置选中条目,中间可能会出现反色的动画,影响美观。this.listBox1.Items.Add("new line");this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;this.listBox1.SelectedIndex = -1;方法2:通过计算ListBox显示 阅读全文
posted @ 2011-03-05 17:51 John Smith 阅读(3562) 评论(0) 推荐(0) 编辑

Python - 批量文件重命名

摘要: 两个目标两个:1. 输入一组文件名,进行批量重命名;2. 输入一组目录名,批量重命名各个目录下的文件。附加功能:1. 可根据文件的创建日期对文件重新排序;2. 重命名方式为递增数列,可带前后缀;3. 可以指定输出目录,如果不指定输出目录,则在原文件夹中重命名,默认为在原文件夹中进行重命名;4. 可指定在重命名后删除原文件(只有输出目录不同时有效),默认为不删除。代码:[代码]说明fs_rename方法对一组文件进行批量重命名。参数说明:files: 文件列表;resort: 是否重新排列文件(按创文件建时间),默认为False;ngen: 一个gen类型的对象,用于产生文件名;delsrc: 阅读全文
posted @ 2011-01-27 00:43 John Smith 阅读(3334) 评论(0) 推荐(0) 编辑

网络与信息安全——知识整理(2)

摘要: The Traditional Symmetric-Key CiphersDefine P as the plaintext, C as theciphertext, and K is the key, than:Encryption: C=Ek(P)Decryption: P=Dk(C)In which: Dk(Ek(x))=Ek(Dk(x))=xThe Kerckhoff’s Pr... 阅读全文
posted @ 2010-11-23 22:42 John Smith 阅读(364) 评论(0) 推荐(0) 编辑

网络与信息安全——知识整理(1)

摘要: 1. The Security Goalsa. Confidentiality: to protect theconfidential information and to guard against the malicious actions that will endangerthe confidentiality of information.b. Integrity: changes of... 阅读全文
posted @ 2010-11-22 23:48 John Smith 阅读(486) 评论(0) 推荐(0) 编辑

在Visual Studio 2008中搭建GTK+开发环境

摘要: 1.在http://www.gtk.org/download-windows.html上下载All-in-one bundles包,目前有2.16和2.22。下载完后解压到一个任意的目录中,如“D:\Environment\gtk”。2.系统环境变量配置:我的电脑 ->属性->高级属性->环境变量->系统变量->Path,在Path值的最后添加... 阅读全文
posted @ 2010-11-06 15:46 John Smith 阅读(3111) 评论(3) 推荐(0) 编辑