Programming

You are currently browsing the articles from KomKid.Net matching the category Programming.

Set homepage by code

วันก่อนมีรุ่นน้องที่เคารพ โทรมาหาถามว่า

พี่ เซ็ต homepage ทำยังไงอ่ะ พอดีไปเผลอกดตอบรับเซ็ต homepage ของเว็บนึงเข้า

คิดในใจ “โห โง่ว่ะ” แต่ตอบไปว่า

เข้าไปที่ Tools -> Internet option …

สวนกลับมาก่อนจะบอกจบว่า

ไม่ได้พี่ IT บล็อก

ค่อยเริ่มน่าสนใจหน่อย จะบอกให้ไปแก้จาก registry ก็คงจะโดนบล็อกอีก ก็เลยหาวิธีอื่นให้ สรุปได้ว่าใช้ code ข้างล่าง

1
2
3
4
5
6
7
8
9
10
11
12
<html>
<head>
<title>Set homepage</title>
</head>
<body>
<form name="HomepageForm">
<input type="text" name="urlbox">
<input type="button" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(document.HomepageForm.urlbox.value);" value="Set">
</form>

</body>
</html>

upload ให้ด้วยที่ http://tools.komkid.net/homepage.html เผื่อใครจะเจอสถานการณ์แบบนี้บ้าง (ใช้ได้เฉพาะ IE เท่านั้นเด้อ)

——————————————
อันนี้แปะไว้กันลืม Registry สำหรับ IE

1
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page

Written by Komkid on April 27th, 2010 with no comments.
Read more articles on Internet and JavaScript and Programming.

Axapta : Posting journal by code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static void InventJournalCheckPost(Args _args)
{
InventJournalTable      inventJournalTable;
InventJournalCheckPost  journalCheckPost;    
;
ttsbegin;
inventJournalTable =  InventJournalTable::find("xxx",true);
//Remove Journal "xxx" has not been locked by system
inventJournalTable.SystemBlocked = true;
inventJournalTable.update();

journalCheckPost   =  InventJournalCheckPost::newJournalCheckPost  (JournalCheckPostType::Post,inventJournalTable);
journalCheckPost.run();

inventJournalTable.SystemBlocked = false;
inventJournalTable.update();
ttscommit;
}

Written by Komkid on February 11th, 2010 with no comments.
Read more articles on Axapta and Programming.

Squid : Custom error page

blocked
หน้าตาสำหรับแสดงผลกรณีมี error ของ squid เช่น กรณีถูกบล็อก(ERR_ACCESS_DENIED) แก้ไขได้ที่ /usr/share/squod/errors/
โดยสามารถใช้ Variable ได้ด้วย ดังนี้

%B URL with FTP %2f hack
%c Squid error code
%d seconds elapsed since request received (not yet implemented)
%e errno
%E strerror()
%f FTP request line
%F FTP reply line
%g FTP server message
%h cache hostname
%H server host name
%i client IP address
%I server IP address
%L contents of err_html_text config option
%M Request Method
%m Error message returned by external auth helper
%p URL port
%P Protocol
%R Full HTTP Request
%S squid default signature
%s caching proxy software with version
%t local time
%T UTC
%U URL without password
%u URL with password (Squid-2.5 and later only)
%w cachemgr email address
%z dns server error message

ตัวอย่าง ERR_ACCESS_DENIED

1
2
3
4
5
6
7
8
9
10
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF8">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY bgcolor="#000000">
 <div align="center">
  <img src="http://intranet.sci.com/sci/blocked.jpg" border="0" alt="Access dinied">
  </div>
<br>
<div align="center">Web นี้ถูก block ในช่วงเวลา 8:00-12:00 น. และ 13:00-17:40 น. หากมีความจำเป็นต้องใช้งาน กรุณาแจ้ง งทส.</div>

Written by Komkid on January 28th, 2010 with no comments.
Read more articles on Admin and Networking and Programming and Ubuntu.

JavaScript : 1 Form 2 Target

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        <script type="text/javascript">
         <!--
         function submitView()
         {
           myform = document.form1;
           myform.target="_blank";
           myform.action="view.php";
           myform.submit();
           return false;
         }
         
        function submitEdit()
         {
           myform = document.form1;
           myform.target="_blank";
           myform.action="edit.php";
           myform.submit();
           return false;
         }
 
         //-->
         </script>
1
2
3
4
<form name="form1" method="post">
<input type="submit" name="SubmitV" value="- View -" onclick="submitView();">
<input type="submit" name="SubmitE" value="- Edit -" onclick="submitEdit();">
</form>

Written by Komkid on January 27th, 2010 with no comments.
Read more articles on JavaScript and Programming.

Logon Script : Map Network Drive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
' MapNetworkDrive.vbs
' VBScript to map a network drive to a UNC Path.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - September 2005
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath
strDriveLetter = "P:"
strRemotePath = "\\server2\public_data"
 
' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method.  Result J: drive
Set objNetwork = CreateObject("WScript.Network")
 
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
WScript.Quit
 
' End of Example VBScript.

Written by Komkid on January 27th, 2010 with no comments.
Read more articles on Admin and Networking and Programming.

« Older articles

No newer articles