Wednesday, 4 July 2012

Could not load file or assembly 'cli_cppuhelper, Version=1.0.14.0, Culture=neutral, PublicKeyToken=ce2cb7e279207b9e' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Could not load file or assembly 'cli_cppuhelper, Version=1.0.14.0, Culture=neutral, PublicKeyToken=ce2cb7e279207b9e' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Fix by changing the properties of project solution to Debug as figure below


Saturday, 19 May 2012

disable enable constrain mssql

I copied this from http://stackoverflow.com/questions/159038/can-foreign-key-constraints-be-temporarily-disabled-using-t-sql 
 
-- disable all constraints
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
 
-- enable all constraints
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
 

delete all tables and stored procedures on SQL2005

I copy this from http://weblogs.asp.net/rchartier/archive/2010/08/20/sql-scripts-delete-all-tables-procedures-views-and-functions.aspx?CommentPosted=true#commentmessage 

Delete All Tables

--Delete All Keys

DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR
SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME
OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql
WHILE (@@FETCH_STATUS = 0)
BEGIN
Exec SP_EXECUTESQL @Sql
FETCH NEXT FROM @Cursor INTO @Sql
END
CLOSE @Cursor DEALLOCATE @Cursor
GO
EXEC sp_MSForEachTable 'DROP TABLE ?'
GO
 

Delete All Stored Procedures

declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'p'
open cur

fetch next from cur into @procName
while @@fetch_status = 0
begin
if @procName <> 'DeleteAllProcedures'
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end

close cur
deallocate cur
 

Tuesday, 27 March 2012

Disk Usage - du

to check how much disk usage in each directory on Linux box, we use

#du /home


Monday, 26 March 2012

How to setup SVN on Ubuntu for personal use

This will show you how to set up svn for personal use on Ubuntu

*install relevant software 
#sudo apt-get install subversion    //this is subversion command line tools
#sudo apt-get install apache2        //this is apache2 webserver
#sudo apt-get install libapache2-svn  //this is sub-version extension for apache2

*Then
#sudo service apache2 restart       //restart apache webserver


*Configure apache config file
1.edit file in /etc/apache2/mods-enable/dav_svn.conf

#sudo nano /etc/apache2/mods-enable/dav_svn.conf


2.create directory for svn as we use in above configuration file

#sudo svnadmin create /home/svn

*Then restart apache2 again
#sudo service apache2 restart


Test, just open web-browser and type
 http://localhost/svn


That is.






Monday, 19 March 2012

Linux Add NIC and Gateway command

# Adding new network interface command

ifconfig eth0 192.168.1.112 netmask 255.255.255.0 up

# Adding new virtual network interface command

ifconfig eth0:0 192.168.10.112 netmask 255.255.255.0 up

# Adding Default Gateway

route add default gw 192.168.1.1

Monday, 12 March 2012

I2C Bus ( ไอ กำลังสอง ซี) [ Inter-IC protocol aka Two Wire Interface] ถูกพัฒนาโดย Philips Semiconductors

เป็นหนึ่งในระบบบัส ที่ใช้สื้อสาร (ส่งข้อมูล) ระหว่าง ไอซี ต่างๆใน วงจร อิเล็กทรอนิกส์

โดยจะใช้สายสัญญานเพียงสองเส้น
เส้นแรกจะเป็น Clock เพื่อ synchronise เวลา ในการส่งข้อมูล เรียกว่า Serial Clock Line (SCL)
เส้นที่สองจะเป็น Data เพื่อใช้ในการรับส่ง data เรียกว่า Serial Data Line (SDA)

ในกรณที่ใช้กับ Arduino
จะต่อ
SDA ที่ Analog Pin4
SCL ที่ Analog Pin5

และต่อ Pull-up resistor ในแต่ละ bus line.

เราสามารถพ่วง i2c devices ได้มากถึง 128 ในหนึ่งระบบ two wires

ในแต่ละ device จะมี address เป็นของตัวเอง เพื่อที่เราจะใช้อ้างถึง device หรือ node นั้น

ด่านล่างจะเป็นรูปแบบของ code ที่ เอาไว้ใช้ อ่าน/เขียน (สื่อสาร) กับ I2C IC


#include "Wire.h"

void setup()
{

}

void loop()
{
//Write something into IC
Wire.beginTransmission(/*I2C_Device_Address*/);
Wire.write(/*byteToWriteHere*/);  //consult your datasheet
Wire.endTransmission();

//Read something from IC
Wire.beginTransmission(/*I2C_Device_Address*/);
Wire.write();  //consult your datasheet
Wire.endTransmission();

Wire.requestFrom(/*I2C_Device_Address*/);

Wire.read();  //this will return as byte

}

หมายเหตุ
ผู้เขียนใช้ Arduino 1.0 กับ board Arduino UNO

Friday, 9 March 2012

How to search specific directory name in Linux

find / -type d -name gnuradio-examp* 2> /dev/null

which the text in yellow highlighted is the directory name that you wanna find.

Wednesday, 29 February 2012

Please update the firmware and FPGA images for your device.

See the application notes for USRP2/N-Series for instructions.

Expected FPGA compatibility number 8, but got 7:

The FPGA build is not compatible with the host code build.
Segment fault
This has been fixed by update firmware which can be downloaded from ettus website.

Tuesday, 28 February 2012

Microsoft SQL server collation issue.

To chech which collation is used.

SELECT DATABASEPROPERTYEX('pipe1', 'Collation') SQLCollation;
//pipe1 equals to the database name

SELECT name, collation_name
FROM sys.databases
WHERE name = 'pipe1'
//pipe1 equals to the database name

These two commands give the same output.

To check the collation which are supported in server.
SELECT * FROM ::fn_helpcollations()


To change database collation
ALTER DATABASE databasename
COLLATE SQL_Latin1_General_CP1_CI_AS

Thursday, 16 February 2012

Arduino Serial Communication

Arduino will automatically restart itself when we start the serial communication.

There are some websites recommend hardware solution to prevent this as below,

www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1204641836

Tuesday, 24 January 2012

Arduino - DS1307

Today I did DS1307 with I2C communication

DS1307 is the IC which it will create Real-Time-Clock and send that clock via I2C bus to the microcontroller.

You can write the function to read the time which has been sent via I2C bus.

As well as you can write the function to set the time via I2C bus.