thaicosmic.com

หนัง

วันอังคารที่ 28 มกราคม พ.ศ. 2557

Function แยกบ้านเลขที่ออกจาก บ้านเลขที่และข้อความ


Public Function FormatAdr(Adr) As String

    For i = Len(Adr) To 1 Step -1
            If IsNumeric(Mid(Adr, i, 1)) Then
                    FormatAdr = Left(Adr, i)
                    Exit For
            Else
                    FormatAdr = Adr
            End If
    Next

End Function

Public Function numAdr(Adr) As String

    For i = 1 To Len(Adr)
            If (Not (IsNumeric(Mid(Adr, i, 1))) And Mid(Adr, i, 1) <> "/" And Mid(Adr, i, 1) <> "-") Then
                    numAdr = Left(Adr, i - 1)
                    Exit For
            Else
                    numAdr = Adr
            End If
    Next

End Function

วันพฤหัสบดีที่ 23 มกราคม พ.ศ. 2557

run notepad from internet explorer

 function RunFile() {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
  }
   

วันพุธที่ 22 มกราคม พ.ศ. 2557

วันจันทร์ที่ 13 มกราคม พ.ศ. 2557

How do I set up automatic login? Ubuntu



You can find this option under System > Administration > Login Screen.
You'll need to "unlock" the window as this requires administrative privileges.
alt text
You can then select the user and session you would like logged in automatically.
alt text

วันอาทิตย์ที่ 12 มกราคม พ.ศ. 2557

Repair GRUB Windows 7

เครดิต http://nongtokung.blogspot.com/2012/06/repair-grub-windows-7.html
ลอกมาไว้ก่อน กันหน้านี้หายไป

Repair GRUB Windows 7

ขอจดกันลืมไวซะหน่อย พอดีเมื่อวาน(19/06/2012) น้องออกัส  ลง Ubuntu แล้วลบออก ทำให้ Grub Windows 7 หายไป มันเลยเตือนว่า
?
1
2
error: unknown filesystem.
grub rescue>

เลยหาวิธีแก้ให้น้องอยู่พักนึง ก็เจอวิธีแก้ไขง่ายๆ โดยใช้ แผ่นวินโดวส์ธรรมดา ซึ่งมีวิธีแก้ไขดังนี้
  • ใส่แผ่นวินโดวส์ (Windows 7 นะ) เข้าไปแล้วรอสักแปป
  • ตอนถึงหน้าจอ Install ให้เลือก “Repair Your Computer” ดังรูป
  •  จากนั้นให้เลือก “Command Prompt” ก็จะมีหน้าต่าง DOS เด้งขึ้นมา
  •  แล้วก็พิมพ์คำสั่งตามนี้ลงไปครับ
?
1
2
3
4
5
6
7
C:
cd windows\System32
 
bootrec /fixboot
bootrec /fixmbr
 
exit
  • หน้าจอ CMD DOS จะหายไป ก็ให้กด Restart ครับ

เท่านี้ก็แก้ไข GRUB ให้สามารถเข้า Windows 7 ได้แล้ว เย้เย้เย้
ขอบคุณภาพประกอบจากเว็บ theitbros.com ครับ

วันศุกร์ที่ 3 มกราคม พ.ศ. 2557

Installing hamachi VPN in Ubuntu as a service

เครดิต http://the-ubuntu-linux.blogspot.com/2010/09/installing-hamachi-as-service-in-ubuntu.html


Hamachi is a free vpn service, useful to create a private LAN over the internet. For more details of hamachi, go to www.hamachi.cc

The following covers installing hamachi in Ubuntu as a service.

  • We start with installing the 'tun' module to enable IP tunneling in linux
sudo modprob tun
(If that gives an error tun module failed try installing faketun as given in the blog post Installing faketun)
  • Open the modules file and add ‘tun’ to the list
sudo nano /etc/modules
Your file should look similar to the example below.
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
lp
rtc
tun
(Incase 'tun' is not on that file, write 'tun' in a new line)
  • Save the file and exit out of nano (Ctrl-O to save & Ctrl-X to exit), lets move on and verify that a tunneling node has been created. (*If you have compiled your own kernel you likely need to recompile it with IP Tunneling support if you receive an error with modprobe. This is not covered in this guide. And if you are unsure, you most likely did not compile yourself and you would definitely remember doing so.)
ls /dev/net/tun
You should recieve a response like the example below
/dev/net/tun
  • If you received something along the lines of “No Such File or Directory” you may need to manually create the node (run the commands below).  If you received the response (/dev/net/tun), jump to the next step.
sudo mkdir /dev/net
sudo mknod /dev/net/tun c 10 200
Run ls /dev/net/tun again and you should now receive the correct response.
  • With our IP Tunnel node created, it is time to install Hamachi itself.  First download the latest version.  As of writing this guide, the latest version is 0.9.9.9-20
wget http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
Expected output below
--2010-09-19 18:40:55--  http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
Resolving files.hamachi.cc... 74.201.74.16
Connecting to files.hamachi.cc|74.201.74.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 344866 (337K) [text/plain]
Saving to: `hamachi-0.9.9.9-20-lnx.tar.gz'
100%[======================================>] 3,44,866    --.-K/s   in 0.002s  
2010-09-19 18:41:19 (149 MB/s) - `hamachi-0.9.9.9-20-lnx.tar.gz' saved [344866/344866]
  • Extract our newly downloaded archive
tar zxvf hamachi-0.9.9.9-20-lnx.tar.gz
Expected output below
hamachi-0.9.9.9-20-lnx/
hamachi-0.9.9.9-20-lnx/Makefile
hamachi-0.9.9.9-20-lnx/LICENSE
hamachi-0.9.9.9-20-lnx/README
hamachi-0.9.9.9-20-lnx/LICENSE.tuncfg
hamachi-0.9.9.9-20-lnx/LICENSE.openssh
hamachi-0.9.9.9-20-lnx/LICENSE.openssl
hamachi-0.9.9.9-20-lnx/hamachi
hamachi-0.9.9.9-20-lnx/tuncfg/
hamachi-0.9.9.9-20-lnx/tuncfg/Makefile
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg.c
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg
hamachi-0.9.9.9-20-lnx/CHANGES
  • Navigate into the extracted directory
cd hamachi-0.9.9.9-20-lnx/
  • Start the installation
sudo make install
Expected output below
Copying hamachi into /usr/bin ..
Creating hamachi-init symlink ..
Compiling tuncfg ..
Copying tuncfg into /sbin ..
Hamachi is installed. See README for what to do next.
  • Run the tunnel
sudo tuncfg
This should complete the install, we will now configure the user permission in order for it to run correctly.  Create a ‘hamachi’ user group
sudo groupadd hamachi
Add youself as a user to the ‘hamachi’ group.  Be sure to replace your user name where appropriate.
sudo gpasswd -a YOURUSERNAME hamachi
Add the root user to the ‘hamachi’ group
sudo gpasswd -a root hamachi
Set the correct permissions for the tuncfg socket
sudo chmod 760 /var/run/tuncfg.sock
Change the ownership of the socket file
sudo chgrp hamachi /var/run/tuncfg.sock
That should do it for the permissions, Now onto setting Hamachi up & configuring it to start as a system service.
sudo hamachi-init -c /etc/hamachi
Expected output
Initializing Hamachi configuration (/etc/hamachi). Please wait ..
   generating 2048-bit RSA keypair .. ok
   making /etc/hamachi directory .. ok
   saving /etc/hamachi/client.pub .. ok
   saving /etc/hamachi/client.pri .. ok
   saving /etc/hamachi/state .. ok
 Authentication information has been created. Hamachi can now be started with
'hamachi start' command and then brought online with 'hamachi login'.
Start hamachi
sudo hamachi -c /etc/hamachi start
              ( sudo service logmein-hamachi start )
              ( sudo  /etc/init.d/logmein-hamachi restart)
Expected output
Starting Hamachi hamachi-lnx-0.9.9.9-20 .. ok
Set your computer’s nickname
sudo hamachi -c /etc/hamachi set-nick "COMPUTERNICKNAME"
Login to the Hamachi network
sudo hamachi -c /etc/hamachi login
To join an existing network (optional)  “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
sudo hamachi -c /etc/hamachi join NETWORKNAME PASSKEY
To create a new network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
sudo hamachi -c /etc/hamachi create NETWORKNAME PASSKEY
If you joined an existing network you must tell hamachi to then “go-online”. Be sure to replace NETWORKNAME with your relevant network name.
sudo hamachi -c /etc/hamachi go-online NETWORKNAME
Check your hamachi status to verify everything is as it should be
sudo hamachi -c /etc/hamachi
Expected output

Hamachi, a zero-config virtual private networking utility, ver 0.9.9.9-20

  version  : hamachi-lnx-0.9.9.9-20
  pid      : 5754
  status   : logged in
  nickname : NICKNAME(assigned nickname)

  • Now to configure to startup and login automatically when the computer starts:
  • Create the startup script file:
sudo touch /etc/init.d/hamachi
(Else you can download the file directly from here. Place it in the /etc/init.d folder.)

  • Open the startup script file for editing (Incase you have downloaded the file and placed in the /etc/init.d folder, you need not do this step)
sudo nano /etc/init.d/hamachi
Paste the following contents in the file:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          hamachi
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start hamachi at boot time
# Description:       Starts up hamachi daemon. Networking is required.
### END INIT INFO

hamachi_start() {
  echo "Starting hamachi..."
  /sbin/tuncfg
  /usr/bin/hamachi -c /etc/hamachi start
  /bin/chmod 760 /var/run/tuncfg.sock
  /bin/chgrp hamachi /var/run/tuncfg.sock
}

hamachi_stop() {
  echo "Stopping hamachi..."
  killall tuncfg
  /usr/bin/hamachi -c /etc/hamachi stop
}

hamachi_restart() {
  hamachi_stop
  sleep 1
  hamachi_start
}

case "$1" in
'start')
  hamachi_start
  ;;
'stop')
  hamachi_stop
  ;;
'restart')
  hamachi_restart
  ;;
*)
  hamachi_start
esac
Save the file Ctrl+O and exit nano Ctrl+X

  • Make the file executable and configure it to run it at startup:
sudo chmod +x /etc/init.d/hamachi
sudo update-rc.d hamachi defaults

Expected output
                 Adding system startup for /etc/init.d/hamachi ...
                   /etc/rc0.d/K20hamachi -> ../init.d/hamachi
                   /etc/rc1.d/K20hamachi -> ../init.d/hamachi
                   /etc/rc6.d/K20hamachi -> ../init.d/hamachi
                  /etc/rc2.d/S20hamachi -> ../init.d/hamachi
                  /etc/rc3.d/S20hamachi -> ../init.d/hamachi
                  /etc/rc4.d/S20hamachi -> ../init.d/hamachi
                  /etc/rc5.d/S20hamachi -> ../init.d/hamachi