原文地址: http://www.cnblogs.com/yangyxd/articles/5993764.html YxdIocp: https://github.com/yangyxd/YxdIOCP 最近为 YxdIocp 开源库增加了这个轻量级的 MVC 支持。其实说是 MVC ,但由于现在还没
作者: 爱音乐的孩子是小白
[FMX] FMX UI 开源库
【简介】 FMXUI的开发忠旨是发掘FMX界面设计的优点,再整合进入Android界面设计的优点。使用过Java搞Android界面设计朋友看到后应该会有一定的熟悉感。 【类介绍】 TView 基本视图 TViewGroup 视图组 TLinearLayout 线性布局 TRelativeLayout 相对布局 TT
[Java] 图说 注解
在 Java 1.5 开始,可以使用“注解”更方便的实现一些功能。
[Delphi] FMXUI布局组件简介
终于熬过了今年的最后一天班,哥们怀着兴奋,下班了赶紧去放松了一下,再吃碗热呼呼的牛肉面,回来洗个热水澡,感觉太舒服了。 当然了,这么重要的日了,不能忘了写篇文章,介绍下最近整的这个基础UI库,不能顾着自个儿舒服了,要让大家也开开心心才对吧?哈,顺便各位走过路过的满天神佛拜个早年,祝大家新春快乐,恭喜发财!(好吧,我还想
[QWorker] 制作多线程日志输出查看Demo
要解决的问题: 有多个线程输出日志,日志内容需要在列表框中显示出来,不管日志输出的频率快慢,界面不能卡,不能闪烁。超过10万行日志时,自动删除最开始的1万行日志。 此问题涉及多线程编程,多线程输出时要更新界面的显示。 多线程的东西,当然不能忘了QWorker这样的神器,下面我们就来使用QWorker解决问题,哦,不对,
[FMX] Android APP 启动黑屏优化补丁
使用说明 *************************************************** Android APP 启动黑屏优化补丁 作者: Swish, YangYxd 2016.01.16 Version: 1.0.0 QDAC官方群: 250530692 ******************
[Delphi] 进制转换之10进制与34进制互转
嗯,今天阳光明媚,空气清新,心情愉快,还不忙。正好有人说到进制转换,就试着做了一下。 此处省略一千字的废话。。。。 先上图: 下面直接上代码,希望大家能看明白。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Button1: TButton; Button2: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} const Convert: array[0..255] of Integer = ( -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,-1,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ); Convert2: array[0..33] of AnsiChar = ( '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 'w','x'); function IntToHEX34(const V: Int64; const Digits: Integer = -1): string; const CSTR = '0000000000000000'; var P, P1: PAnsiChar; I: Int64; NewLen: Integer; begin GetMem(P, 16); Move(CSTR, P^, 16); P1 := P + 16 - 1; I := V; while True do begin P1^ := Convert2[I mod 34]; I := I div 34; if I = 0 then Break else Dec(P1); end; NewLen := 16 - (P1 - P); if NewLen > Digits then SetString(Result, P1, NewLen) else begin P1 := P + 16 - Digits; SetString(Result, P1, Digits); end; end; function HEX34ToInt(const S: string; const Default: Int64): Int64; var I: Integer; v: Int64; begin Result := 0; for I := 1 to length(s) do begin V := Convert[ord(s[i])]; if V < 0 then begin Result := Default; Exit; end; result := (result * 34) + V; end; end; procedure TForm1.Button1Click(Sender: TObject); begin Edit2.Text := IntToHEX34(StrToInt64Def(Edit1.Text, 0)); end; procedure TForm1.Button2Click(Sender: TObject); begin Edit1.Text := IntToStr(HEX34ToInt(Edit2.Text, 0)); end; end. |
34进制,不好优化。要是32进制,除法的地方和乘法地方,应该可以换成移位操作。
[技巧] Pg2MSSQL数据同步工具简介
Pg2MSSQL是swish群主开发的一个可以同步PostgreSQL、MSSQL的工具软件,使用了我们熟悉的QWorker作为引擎,可以高效的并发执行数据库同步任务。 您可以到QDAC官方群或者本站下载页面找到Pg2MSSQL的下载地址,并免费使用部分功能。如果您觉得好用,可以和swish联系购买注册码。详细的注册信
[Java] 在JSP中读取POST的JSON数据
jsp是开发bs的利器。在jsp中我们可以很方便的使用JSON来开发一个数据接口。 今天我想实现的例子是: 接收客户端(浏览器、APP)通过POST方式提交的JSON数据。 解析接收到数据,如果存在”username”则返回用户名,否则返回一个错误。 我使用java-ee作为开发环境,项目结构如
[数据库] 取指定表中某字段的累加和不超过总和80%的行
有表 Table_1, 字段 Value int, P float 。5 要取出以 Value 字段倒序的 P 字段累加和 不超过 整个表中P字段总和的 80%的行。 并在返回列表中 加入字段 SUM ,存放当前行与前面所有行的累加和。 折腾了半天, 写了下面的查询sql: [crayon-62f914fece87
【随笔】什么是函数?
在数学中,函数通常用式子 y=f(x) 来表示。f 是英语单词 function中的f , 是“功能”或者“作用”的意思。 说白了就是使用f给x施加某种规则或关系,进而推导出y。 函数可以用来表示“因果”,表示“变化”规则。 比如把 x 当作母鸡,f(x)可能出来的就是小鸡鸡了。当然了,不同的f会有不同的结果,说不定结
[原创] 常用字符集简介
字符集 ANSI (ASCII) 美国信息互换标准编码 GB 2312 信息交换用汉字编码字符集 GBK Chinese Internal Code Specification GB18030 信息交换用汉字编码字符集基本集的扩充 UTF-8 万国码 UTF-16 (ISO/IEC 10646-1、UCS-2) 通用字
GIF 动画建立
1 2 3 4 5 6 7 8 9 10 11 |
var Gif:TGifImage; begin //Setting the delay for each frame TGIFGraphicControlExtension.Create(Gif.Add(image1.Picture.Bitmap)).Delay := 300; TGIFGraphicControlExtension.Create(Gif.Add(image2.Picture.Bitmap)).Delay := 300; TGIFGraphicControlExtension.Create(Gif.Add(image3.Picture.Bitmap)).Delay := 300; //Adding loop extension in the first frame (0 = forever) TGIFAppExtNSLoop.Create(Gif.Images.Frames[0]).Loops := 0; Gif.SaveToFile('gif.gif'); end; |
【Delphi】玩转浮点数转整数
Delphi中提供了三个函数: Trunc: 将浮点数的整数部分返回。 Round: 将浮点数四舍五入后返回整数部分。 Int: 将浮点数的小数部分去掉,返回只保留了整数部分的Extended型。 在D2007 + Win7 + Intel平台下测试, 由于Int返回的并非整型,我们把它排除掉。测试结果是 Round
【Delphi】GMT时间与TDateTime转换
说到GMT时间,人们天天都在用,但一般人不会被注意到。 在Http的世界里面,GMT无处不在,不信你抓包看看各种Header里面。 GMT是世界时间,在处理的时候需要处理当前的时区。 算了,我懒得多说,直接贴代码吧。吹吹牛,我这个可以高性能的哦~~~~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
const Convert: array[0..255] of Integer = ( -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 ); function PCharToIntDef(const S: PAnsichar; Len: Integer; def: Integer = 0): Integer; var I: Integer; v: Integer; begin Result := 0; for I := 0 to len-1 do begin V := Convert[ord(s[i])]; if V<0 then begin Result := def; Exit; end; result := (result * 10) + V; end; end; function LocalTimeZoneBias: Integer; {$IFDEF LINUX} var TV: TTimeval; TZ: TTimezone; begin gettimeofday(TV, TZ); Result := TZ.tz_minuteswest; end; {$ELSE} var TimeZoneInformation: TTimeZoneInformation; Bias: Longint; begin case GetTimeZoneInformation(TimeZoneInformation) of TIME_ZONE_ID_STANDARD: Bias := TimeZoneInformation.Bias + TimeZoneInformation.StandardBias; TIME_ZONE_ID_DAYLIGHT: Bias := TimeZoneInformation.Bias + ((TimeZoneInformation.DaylightBias div 60) * -100); else Bias := TimeZoneInformation.Bias; end; Result := Bias; end; {$ENDIF} var DLocalTimeZoneBias: Double = 0; function DateTimeToGMT(const DT: TDateTime): TDateTime; inline; begin Result := DT + DLocalTimeZoneBias; end; function GMTToDateTime(const DT: TDateTime): TDateTime; inline; begin Result := DT - DLocalTimeZoneBias; end; function DateTimeToGMTRFC822(const DateTime: TDateTime): string; const WEEK: array[1..7] of string = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); STR_ENGLISH_M: array[1..12] of string = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); var wWeek, wYear, wMonth, wDay, wHour, wMin, wSec, wMilliSec: Word; begin DecodeDateTime(DateTimeToGMT(DateTime), wYear, wMonth, wDay, wHour, wMin, wSec, wMilliSec); wWeek := DayOfWeek(DateTimeToGMT(DateTime)); Result := Format('%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT', [WEEK[wWeek], wDay, STR_ENGLISH_M[wMonth], wYear, wHour, wMin, wSec]); end; function GMTRFC822ToDateTime(const pSour: AnsiString): TDateTime; function GetMonthDig(const Value: PAnsiChar): Integer; const STR_ENGLISH_M: array[1..12] of PAnsiChar = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); begin for Result := Low(STR_ENGLISH_M) to High(STR_ENGLISH_M) do begin if StrLIComp(Value, STR_ENGLISH_M[Result], 3) = 0 then Exit; end; Result := 0; end; var P1, P2, PMax: PAnsiChar; wDay, wMonth, wYear, wHour, wMinute, wSec: SmallInt; begin Result := 0; if Length(pSour) < 25 then Exit; P1 := Pointer(pSour); P2 := P1; PMax := P1 + Length(pSour); while (P1 < PMax) and (P1^ <> ',') do Inc(P1); Inc(P1); if (P1^ <> #32) and (P1 - P2 < 4) then Exit; Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> #32) do Inc(P1); if (P1^ <> #32) then Exit; wDay := PCharToIntDef(P2, P1 - P2); if wDay = 0 then Exit; Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> #32) do Inc(P1); if (P1^ <> #32) and (P1 - P2 < 3) then Exit; wMonth := GetMonthDig(P2); Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> #32) do Inc(P1); if (P1^ <> #32) then Exit; wYear := PCharToIntDef(P2, P1 - P2); if wYear = 0 then Exit; Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> ':') do Inc(P1); if (P1^ <> ':') then Exit; wHour := PCharToIntDef(P2, P1 - P2); if wHour = 0 then Exit; Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> ':') do Inc(P1); if (P1^ <> ':') then Exit; wMinute := PCharToIntDef(P2, P1 - P2); if wMinute = 0 then Exit; Inc(P1); P2 := P1; while (P1 < PMax) and (P1^ <> #32) do Inc(P1); if (P1^ <> #32) then Exit; wSec := PCharToIntDef(P2, P1 - P2); if wSec = 0 then Exit; Result := GMTToDateTime(EnCodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSec, 0)); end; initialization DLocalTimeZoneBias := LocalTimeZoneBias / 1440; |
【原创分享】LookImage 图像查看器
从很早以前开始,我就用自己编写的图像查看器浏览图片了。至于为什么要这样,可能当初是为了煅炼技术,也可能是作为程序员的一点点自娱自乐的习惯,还有可能就是感觉用自己的亲手开发的工具有成就感。LookImage很多年前就存在了,从最开始的VB版本,到至今的Delphi重新编码版,从最开始的仅仅能查看bmp、jpg,到现在能支
DIOCP 小白精简版(YxdIOCP)
YxdIocp (DIOCP修改版) SVN: https://github.com/yangyxd/YxdIOCP 【特别说明】 本源码由YangYxd(音儿小白)以网友天地弦的DIOCP为基础修改优化而来。YxdIocp与DIOCP使用方式略有不同,不完全兼容!! 我会接收大家提交的B
DIOCP 运作核心探密
来自网友天地弦的DIOCP早已经广为人知了,有很多的同学都用上了它,甚至各种变异、修改版本也出了不少。我最近也在学习DIOCP,打算将它用于自己的服务端,今天让我们来一起探密它(DIOCP)的运作核心吧。 DIOCP作为对Windows的IOCP完成端口封装,拥有了很高的性能,经过对ECHO示例的测试,它
Android 反编译工具
想必玩安卓的童鞋大多都知道,安卓的APK安装包是可以反编译出源代码的,如果开发人员发布时没有对其混淆等加密处理,反编译出来的代码几乎与真实的源代码一模一样。 想要反编译apk,需要用到apktool.jar,目前它已经更新了到了apktool_2.0.0rc6了。apktool.jar通过命令行即可反编译apk,而且网
【Delphi】AXMLPrinter (Android XML)
找这个的人肯定知道这是干什么的。没错,我花了半天时间将Java代码改写成了Delphi,在D2007下调试通过。 用法很简单,将APK文件改名成.zip,就可以解压缩了。解压以后可以看到很多文件,其中有很多是.xml后缀的。打开发现全是乱码。是的,你现在需要AXMLPrinter了。 比如我们知道,其中的Android