Posts

Showing posts from October, 2010

Axapta : Execute SQL command

Axapta มีคำสั่ง SQL รวมอยู่ใน X++ อยู่แล้ว แต่ถ้าอยากใช้คำสั่ง SQL อื่น ๆ เช่น ใช้ประโยชน์จาก NewID() ของ MS SQL Server เพื่อ random ก็ทำได้ ดังตัวอย่าง static void Job3(Args _args) { LogInProperty Lp = new LogInProperty(); OdbcConnection myConnection; Statement myStatement; ResultSet myResult; str sqlQuery; ; sqlQuery = 'SELECT TOP 10 * FROM CustTable ORDER BY NewID()'; LP.setServer("Server"); LP.setDatabase("db"); Lp.setUsername("user"); Lp.setPassword("password"); try{ myConnection = new OdbcConnection(LP); } catch{ info("Check username/password."); return; } myStatement = myConnection.createStatement(); myResult = myStatement.executeQuery(sqlQuery); while (myResult.next()){ box::info(myResult.getString(1)); } }

Axapta : Find user group of current userid

กันลืม UserGroupList userGroupList; ; WHILE SELECT userGroupList WHERE userGroupList.userId == curuserid() // && userGroupList.groupId == 'searchGroup'; { print userGroupList.groupId; } pause;

Ubuntu : Shutter add-ons

Image
อ้าว Shutter (โปรแกรมสำหรับ capture screen) ทำไม capture แล้ว edit ไม่ได้หว่า search ดูถึงได้รู้ว่า ขาด add-ons บางอย่างไปนี่เอง ว่าแล้วก็ติดตั้งซะเลย apt-get install libgoo-canvas-perl apt-get install gnome-web-photo อันแรกเอาไว้ capture แล้ว edit ได้ อันที่สองเอาไว้ capture หน้า web page ยาว ๆ มันจะ scroll ให้อัตโนมัติ

Ubuntu : Backup & Restore

คำสั่ง mt (Magnatic Tape) ปกติระบบจะ mount ไว้ให้ที่ /dev/st0 mt -f /dev/st0 status # ตรวจสอบสถานะ mt -f /dev/st0 rewind # สั่งหมุน tape กลับ mt -f /dev/st0 erase # ลบข้อมูล (นานมาก) mt -f /dev/st0 offline #สั่งเด้ง tape ออก Cleaning Cartridge # บางรุ่นอาจไม่เหมือนกัน ใส่เข้าไป พอมัน load เข้าไปแล้วทำความสะอาดเสร็จจะเด้งออกมาเอง (Cleaning Cartridge เป็นแบบใช้แล้วใช้เลย rewind กลับมาใช้อีกไม่ได้) คำสั่ง Backup & Restore Backup ใช้ -c tar -cvf backup_filename data_to_backup เช่น tar -cvf backup.tar /home/nikom กรณีต้องการให้บีบอัดไฟล์ด้วย เพิ่ม parameter -z tar -cvzf backup.tar.gz /home/nikom Restore เปลี่ยน -c เป็น -x (เข้าไปใน directory ที่จะ restore ก่อน เพราะสั่งตรงไหน restore มาตรงนั้น) tar -xvf backup_filename เช่น tar -xvf backup.tar restore ไฟล์ที่บีบไว้ ใช้ -z เหมือนกัน tar -xvzf backup.tar.gz Tape backup ลง tape tar -cvf /dev/st0 data_to_backup ดูรายการใน tape tar -tvf /dev/st0 restore จาก tape tar -tvf /dev/st0 backup_filename backup & restore กับ tape ก็ใช้ -z สำห

Ubuntu : Automount NTFS partition when login

ติดตั้ง ubuntu ใหม่ทีไร ลืมทุกที 1.แก้ fstab 1.1 mkdir /media/Data1 #สร้าง mount point 1.2 sudo apt-get install ntfs-3g 1.3 sudo nano /etc/fstab 1.4 เพิ่มบรรทัดดังนี้ /dev/sda1 /media/Data1 ntfs-3g defaults 0 0 2.ใช้ script 2.1 nano /etc/automount.sh 2.2 ดังนี้ #!/bin/bash mount /dev/sda1 /media/Data -t ntfs -o rw mount /dev/sda2 /media/Data2 -t ntfs -o rw