用AI(Claude - sonnet4.6)寫個小遊戲,雖然很快但是Debug起來有點費力!
遊戲結束
遊戲玩法
- 方塊往你選擇的方向移動,數字相同的相鄰方塊會合併成兩倍。
- 每次移動後,棋盤隨機出現一個新的 2 或 4。
- 合併出 2048 即達成目標,仍可繼續刷新分數。
- 棋盤填滿且無法再移動時,遊戲結束。
- 每日午夜自動重置今日最高分紀錄。
操作方式
- 電腦:鍵盤 ↑ ↓ ← → 方向鍵。
- 手機:在棋盤上上下左右滑動。
用AI(Claude - sonnet4.6)寫個小遊戲,雖然很快但是Debug起來有點費力!
可能是用到沒電造成,重新充飽電後可以開機但桌球APP卻一直停在未安裝狀態,連續點選安裝幾次都沒有成功,對於不熟悉的裝置一時之間還真無助。最後真沒辦法想到曾經重新啟用quest2成功拿到被推薦獎金,這次再重置quest2看看沒想到問題竟然解決了。所幸只有安裝3-4個APP,重新安裝完連紀錄都在。
前幾天舊手機HTC One X9突然一直不斷重新開機,本來以為電池是該掛了,上網查到低階重置的方法,重置了手機,死馬當活馬醫竟然可以開機了。
確定不是硬體或是電池的問題後,花了一些時間重新登入帳號安裝完該裝的軟體,還來不及高興又開始不斷重新開機⋯
再來一次低階重置問題仍然存在,不過一切問題的發生好像是在上網之後,經過一些嘗試發現在不斷重開機的秒差之間,點選飛航模式就可以阻止重開機。
在飛航模式下終於發現原兇是Google Play 服務,對就是你,在沒有經過我同意的情形下把我從快樂如天堂的版本12.6.85改成死機的地獄版本22.02.21!(有圖有真相)
Android App 多如過江之鯽, 而自己真正用得到的卻是屈指可數, 但是就缺那麼一個. 為了能使用現役手機能完成這個簡單需求, 費了九牛二虎之力, 從零開始, 蹣跚學步, 終於在過完農曆年後得以啼聲初試:
1. autocomplete.aspx
2. handler1.ashx
Sample Code:
1. autocomplete.aspx:
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - ASP.NET ASHX datasource</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<style type="text/css">
body {
font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
font-size: 62.5%;
}
.ui-autocomplete-loading {
background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
}
</style>
<script type ="text/javascript" >
$(function () {
$("#txtInput").autocomplete({
source: "handler1.ashx",
minLength: 1,
select: function (event, ui) {
alert(ui.item.value);
},
change: function(event, ui) {
alert("changed!");
}
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="Sample">Your list: </label>
<input id="txtInput">
</div>
‘-----------------------------------------------------
2. handler1.ashx:
Public Class Handler1
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
'context.Response.ContentType = "text/plain"
'context.Response.Write("Hello World!")
'query string
Dim prefixText As String = context.Request.QueryString("term")
'suggestion list
Dim v_ret As String = "[]"
'TODO: SQL data searching...
'Sample list:
v_ret = "[{""id"":""A"",""label"":""AAA"",""value"":""AA""},
{""id"":""B"",""label"":""BBB"",""value"":""BB""}]"
context.Response.ContentType = "text/plain"
context.Response.Write(v_ret)
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
‘---------------------------------------------------------
Ref: www.jqueryui.com
用notepad++(MS notepad 會自動轉碼)開啟
C:\ProgramData\MySQLMySQL Server 5.7\my.ini
找到 [client] 區塊
加入
default-character-set=utf8
找到 [mysqld] 區塊
加入
character-set-server=utf8
collation-server=utf8_general_ci
原來除了MySQL本身資料編碼設定外
在ASP.NET中ODBC版本也有絕對的影響:
MySQL ODBC 3.51 Driver 只能顯示big5繁體中文
MySQL ODBC 5.1 Driver 能同時顯示utf8簡體繁體中文
web.config中連結字串差別:
<add name="MySQLConnStr" connectionString="DRIVER={MySQL ODBC 5.1 Driver};Database=[strDatabaseName];Server=[strServerName];UID=[strUserName];PWD=[strPassword];charset=utf8"/>
dotNetFramework1.1:
<add key="MySQLConnStr" value="DRIVER={MySQL ODBC 3.51 Driver};Database=[strDatabaseName];Server=[strServerName];UID=[strUserName];PWD=[strPassword];OPTION=3;CharSet=big5;"/>
很久沒有用PC(Win7, 64bit)連接手機Nexus 4,
記得之前一接上去充電, 手機有時會一直被喚醒,
但至少我的電腦內有顯示Nexus 4而且可讀取內容檔案.
如今卻只在右下方顯示MTP USB裝置 X失敗,
而裝置管理員也出現MTP USB (黃色三角型),
用了很多方法, 最後只有改註冊表這招有效:
unplug phone
open up the registry editor
regedit
navigate to
HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Control > Class > {EEC5AD98-8080-425F-922A-DABF3DE3F69A}
if you see a string called Upperfilters
right click on {EEC5AD98-8080-425F-922A-DABF3DE3F69A} on the left side and export if (so you have a backup)
delete the Upperfilters string
plug phone back in
重新掃描硬體變更. 解決!
Imports ThoughtWorks.QRCode.Codec
Imports ThoughtWorks.QRCode.Codec.Data
Imports ThoughtWorks.QRCode.Codec.Util
......
Private Sub print_qr()
Dim reportDoc As New ReportDocument
Dim rpt_ds As DataSet = GetDS("")
If rpt_ds.Tables(0) Is Nothing Then
lblDBErrorMessage.Text = "No Data!"
Exit Sub
End If
If rpt_ds.Tables(0).Rows.Count <= 0 Then
lblDBErrorMessage.Text = "No Data!"
Exit Sub
End If
reportDoc.Load(Server.MapPath("./rpt/QRC_print.rpt"))
reportDoc.SetDataSource(rpt_ds)
'印到PDF -------------
Dim objFile As New DiskFileDestinationOptions
reportDoc.ExportOptions.DestinationOptions = objFile
objFile.DiskFileName = Server.MapPath("./printemp/QRC_print.pdf")
With reportDoc.ExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = objFile
End With
reportDoc.Export()
Dim xlsurl As String = "./printemp/QRC_print.pdf"
Response.Redirect(xlsurl)
Exit Sub
'OR 直接列印 ---------------
Try
reportDoc.PrintOptions.PrinterName = strpath
reportDoc.PrintToPrinter(1, True, 0, 0)
'Response.Redirect(strRturnTo)
Catch
lblDBErrorMessage.Text = "找不到指定的印表機!"
End Try
End Sub
Function GetDS(ByVal vd_no) As DataSet
Dim strSQL As String
Dim ds As DS_QRC = New DS_QRC
......
Dim data As String = "Your TEXT here"
Dim v_copy As Integer = 1 ' 列印份數
Dim qrCodeEncoder As QRCodeEncoder = New QRCodeEncoder
qrCodeEncoder.QRCodeEncodeMode = qrCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC
qrCodeEncoder.QRCodeScale = 6
qrCodeEncoder.QRCodeVersion = 2
qrCodeEncoder.QRCodeErrorCorrect = qrCodeEncoder.ERROR_CORRECTION.L
Dim image As Image
image = qrCodeEncoder.Encode(data)
Dim ms As MemoryStream = New MemoryStream
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim ImageSize As Integer = ms.Length
Dim ImageContent() As Byte = ms.GetBuffer
ms.Close()
image.Dispose()
Dim j As Integer
For j = 1 To v_copy
MyNewRow = ds.Tables("T_QRCode").NewRow
MyNewRow("QR_pno") = v_sname
MyNewRow("QR_sno1") = v_ss
MyNewRow("QR_sno2") = v_ee
MyNewRow("QR_img") = ImageContent
MyNewRow("QR_supname") = v_supname
MyNewRow("QR_mno") = v_mno
If ii = v_boxs Then
MyNewRow("QR_qty") = v_pqtyp
Else
MyNewRow("QR_qty") = v_pqty
End If
ds.Tables("T_QRCode").Rows.Add(MyNewRow)
Next
......
Return ds
End Function
註:
ThoughtWorks.QRCode.dll - ThoughtWorks QRCode .NET Library is download available from CodeProject.com.
1. 下載Slide Helper for N95 軟體:
http://s60soft.ru/eng/slide-helper.html
2. 在手機鍵盤上輸入*#06#,IMEI號碼就會顯示在手機螢幕.
3. 到NOKIA Developer 網站註冊一個帳號.
https://www.symbiansigned.com/signedui/welcome
並在下面畫面加入手機IMEI碼:
在右方上傳sis檔案後即可下載PrivateKey_And_Certificate二個檔案.
4. 到下面網站下載 SignSIS-GUI_v1.1.exe執行檔
http://www.gosymbian.com/SSIS_download.html
並如該網站所示執行並選取cer,key及sis檔, 並按SignSiS!鈕.
5. 將Output產生的sis檔copy到手機或用Nokia電腦端套件安裝.
Private Function GetOnlyDirectories(ByVal v_server As String, ByVal v_user As String, ByVal v_pw As String) As String
Dim TheShortList As String = FTPListDirectory(v_server, v_user, v_pw, True)
Dim theDirectories As String = ""
If TheShortList <> "" Then
Dim TheLists() As String = Split(TheShortList.Trim, vbCrLf)
For Each thelist As String In TheLists
If thelist.Trim.ToLower.EndsWith(".xml") Then
Dim v_ffile As String = v_server + thelist.Trim.ToLower
Dim v_tfile As String = "../temp.xml"
If ftpDownload(v_ffile, v_tfile, v_user, v_pw) Then
ftpDelete(v_ffile, v_user, v_pw)
End If
End If
theDirectories &= vbCrLf & thelist.Trim
theDirectories = theDirectories.Trim
Next
End If
Return theDirectories
End Function
Public Shared Function ftpDownload(ByVal source As String, ByVal target As String, ByVal v_fuser As String, ByVal v_fpw As String) As Boolean
Dim v_ret As Boolean = True
Dim credential As New NetworkCredential(v_fuser, v_fpw)
Dim clsrequest As FtpWebRequest = _
DirectCast(WebRequest.Create(source), FtpWebRequest)
clsrequest.Method = WebRequestMethods.Ftp.DownloadFile
clsrequest.Credentials = credential
Dim response As FtpWebResponse = _
DirectCast(clsrequest.GetResponse, FtpWebResponse)
Dim stream As Stream = response.GetResponseStream
Dim reader As New StreamReader(stream)
Dim v_cont As String = reader.ReadToEnd()
If (File.Exists(target)) Then
File.Delete(target)
End If
Dim FS As FileStream = New FileStream(target, FileMode.CreateNew, FileAccess.Write)
Dim SW As StreamWriter = New StreamWriter(FS, Encoding.GetEncoding("utf-8"))
SW.WriteLine(v_cont)
SW.Flush()
FS.Close()
reader.Close()
response.Close()
'Read to dataset
Dim ds As DataSet = New DataSet
Dim FSr As FileStream
FSr = New FileStream(target, FileMode.Open)
Dim XmlRead As New XmlTextReader(FSr)
ds.ReadXml(XmlRead)
FSr.Close()
XmlRead.Close()
'do process of dataset ……
ds.Dispose()
Return v_ret
End Function
Function FTPListDirectory(ByVal Target As String, ByVal UID As String, _
ByVal Pass As String, Optional ByVal Shortlist As Boolean = False) As String
Try
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(Target), _
System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(UID, Pass)
If Shortlist Then
clsRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectory
Else
clsRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails
End If
Dim str As String = GetStringResponse(clsRequest)
clsRequest.Abort()
Return str
Catch ex As Exception
Throw New Exception("Connection Problem – Error:" & vbCrLf & vbCrLf & ex.Message)
Return ""
End Try
End Function
Private Function GetStringResponse(ByVal ftp As FtpWebRequest) As String
Dim result As String = ""
Using response As FtpWebResponse = CType(ftp.GetResponse, FtpWebResponse)
Dim size As Long = response.ContentLength
Using datastream As Stream = response.GetResponseStream
Using sr As New StreamReader(datastream)
result = sr.ReadToEnd()
sr.Close()
End Using
datastream.Close()
End Using
response.Close()
End Using
Return result
End Function
Public Shared Function ftpDelete(ByVal source As String, ByVal v_fuser As String, ByVal v_fpw As String) As Boolean
Dim v_ret As Boolean = True
Dim credential As New NetworkCredential(v_fuser, v_fpw)
Dim clsrequest As FtpWebRequest = _
DirectCast(WebRequest.Create(source), FtpWebRequest)
clsrequest.Method = WebRequestMethods.Ftp.DeleteFile
clsrequest.Credentials = credential
Dim response As FtpWebResponse = _
DirectCast(clsrequest.GetResponse, FtpWebResponse)
Dim v_mmm As String = response.StatusDescription
response.Close()
Return v_ret
End Function
自從換Windows7 64bit 每次執行Crystal Report
轉PDF檔 總是出現一個空白訊息視窗Adobe Reader
裡面只顯示一個?圖示其他都空白一片, Adobe Reader 9
重新安裝, IE8 更新成 IE9結果都一樣, Google了很久發現
可能是字元集不全的問題,到Adobe的官方網站下載
字元集包
http://www.adobe.com/support/products/enterprise/knowledgecenter/c4230.pdf
執行AsianFontPackYes.reg安裝後到目前為止都可以
正常開啟PDF檔了.
function FormatNumber(n) {
n += "";
var arr = n.split(".");
var re = /(\d{1,3})(?=(\d{3})+$)/g;
return arr[0].replace(re,"$1,") + (arr.length == 2 ? "."+arr[1] : "");
}
//取消千分位:
nn = parseInt(v_p.replace(",",""),10);
//test
document.write("1234567 -> " + FormatNumber(1234567) + "<br>");
document.write("12345678.12 -> " + FormatNumber("12345678.12") + "<br>");
document.write("123456789.1234 -> " + FormatNumber(123456789.1234) + "<br>");
document.write("-123456.123 ->" + FormatNumber(-123456.123) + "<br>");
Public Shared Function file_checksum(ByVal file_path As String) As String
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim fs As FileStream = New FileStream(file_path, FileMode.Open, FileAccess.Read, FileShare.Read)
md5.ComputeHash(fs)
Dim hash As Byte() = md5.Hash
Dim buff As StringBuilder = New StringBuilder
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X2}", hashByte))
Next
fs.Close()
Return buff.ToString.Trim
End Function