Sladrekort Manual

http://www.soyogroup.com/dl/manuals/peripherals/techaid_manual_v10.pdf

Udgivet i Knowledge Base, Links, Old Base | Skriv en kommentar

C Pointer Crash Course

#include <stdio.h>

int main(void)
{
        int buffer;                                     // An integer are declare
        int *pointer;                                   // A pointer to an integer are declared


        buffer=512;                                     // The buffer are set to 512

        pointer=&buffer;                                // Pointer gets assigned the _adress_ that buffer points at


        printf("Pointer points at [%i]\n",*pointer);    // Print the content of whatever pointer points at
        printf("Pointer contains  [%i]\n",pointer);     // Print the adress that pointer points at
        printf("Buffer  contains  [%i]\n",buffer);      // Print the content of the buffer

        printf("Changing values\n");                    // To demonstrate i change the value of buffer
                                                        // and reprint the values
        buffer=1024;

        printf("Pointer points at [%i]\n",*pointer);    // Print the content of whatever pointer points at
        printf("Pointer contains  [%i]\n",pointer);     // Print the adress that pointer points at
        printf("Buffer  contains  [%i]\n",buffer);      // Print the content of the buffer

        printf("Changing values\n");                    // To demonstrate once again
        *pointer=2048;                                  // We now want to change buffer by using the pointer

        printf("Pointer points at [%i]\n",*pointer);    // Print the content of whatever pointer points at
        printf("Pointer contains  [%i]\n",pointer);     // Print the adress that pointer points at
        printf("Buffer  contains  [%i]\n",buffer);      // Print the content of the buffer


}


Generates following output:

bash-2.05b$ ./a.out 
Pointer points at [512]
Pointer contains  [-1073745188]
Buffer  contains  [512]
Changing values
Pointer points at [1024]
Pointer contains  [-1073745188]
Buffer  contains  [1024]
Changing values
Pointer points at [2048]
Pointer contains  [-1073745188]
Buffer  contains  [2048]


  Whats it good for? Give me some examples!

Very simple example would be a sub-routine that does work on several values and returns more than one result, as follow:
#include <stdio.h>


int multi(ap,bp,cp)   // Function that works on 3 pointers
        int *ap,*bp,*cp;
{
        int temp;

        *ap=*bp + *cp; // add the values of c and b and store the result in a

        temp=*bp;       // Swap bp and bc
        *bp=*cp;
        *cp=temp;


}

int main(void)
{
        // Practical exampel on use of pointers

        int a,b,c;

        a=b=c=0;
        printf("Initated values\n");
        printf("A:[%i] B:[%i] C:[%i]\n",a,b,c);

        a=3;b=2;c=1;                                    // Random test values


        printf("\nRandom test values\n");
        printf("A:[%i] B:[%i] C:[%i]\n",a,b,c);

        multi(&a,&b,&c);                                // Calling function, passing on addresses for a,b and c

        printf("\nAfter multi values\n");
        printf("A:[%i] B:[%i] C:[%i]\n",a,b,c);



}

Generates following output:
bash-2.05b$ ./a.out 
Initated values
A:[0] B:[0] C:[0]

Random test values
A:[3] B:[2] C:[1]

After multi values
A:[3] B:[1] C:[2]

 

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

High Availablitiy Clusters in Linux

Forskellinge links jeg har fundet på min jagt om emnet:

LinuxHA , Failover, heartbeat o.l. snask:
http://linux-ha.org/download/GettingStarted.html

Network Block Device + Raid
http://www2.linuxjournal.com/article/3778

Distributed Remote Block Device
http://www.drbd.org/

Udgivet i Knowledge Base, Linux, Networking, Old Base | Skriv en kommentar

Pastasalat alá Mike og Midnight

I går lavede Mikkel og jeg den bedste pastasalat, så her kommer lige opskriften 😉

Opskrift på “Verdens bedste pastasalat”, eller
Pastasalat alá Mike og Midnight

Til 25 sultne hanløver skal der bruges:

Ingredienser:
En masse pasta!
4-5 store gulerødder
1 bakke friske ærter
3/4 dåse majs
1 salathoved
1 bakke stenfri vindruer
Cherrytomater
1 pakke croutoner med provence krydderi
Evt. Thousand Island dressing

Gør sådan her:
Den ene af jer (I skal helst være mindst 2 personer, så smager det bedst) sætter sig til at pille ærter, et helvedes arbejde, som tager temmelig lang tid, men det er det værd 😉
Den anden: koger pasta, snitter salat, åbner dåsen med majs, skærer cherrytomaterne i kvarte, skærer gulerødderne i tern, åbner pakken med croutoner og hælder dem i en skål.

Alle frugter og grøntsager blandes i en kæmpestor skål. Og så er det bare om at tage for sig 🙂

NAM! :D:D

Kilde: http://www.midnightshadow.dk

Udgivet i Knowledge Base, Links, Old Base | Skriv en kommentar

Slideshow , autorotation of all files in directory. Written in PHP

<?

# read .jpg files into array
$dir=opendir(".");
while ($dat = readdir($dir)) { if (substr($dat,strlen($dat)-4)==".jpg") { $pics[]=$dat; }}
closedir($dir);

# Increment the image value
if ($_REQUEST['image'])
{ $img=$_REQUEST['image']; $img++;
} else {$img=1;}
if ( $img >= count($pics))  {$img=0;}

# Automatic reload
print '<meta http-equiv="refresh" content="5, url=?image='.$img.'">';

# Show picture #img in pics array
print "<img src=".$pics[$img+1].">";
?>
~

 

Udgivet i Knowledge Base, Old Base, Workstation | Skriv en kommentar

BOFH-Mobning

IT Udvalget + Mike og Niko i Seriøs samtale.

BlackThorne_DK: fuck det her! nu sletter jeg sq lortet
cybermike: Nooh ik slet mig
cybermike: slet Hampuz
Hampuz: HEY!
cybermike: :p
* Hampuz sætter mode: write-protected
* cybermike sets mode: imuteable
* BlackThorne_DK sets mode: BOFH!
Hampuz: Pis
Hampuz: cybermike.. Vi har tabt..
* cybermike flytter sine filer
* Hampuz hiver netkabel ud
* BlackThorne_DK nuker dalgas
* BlackThorne_DK has quit (Quit: Leaving)
cybermike: Godt klaret han ramte sig selv :p
Hampuz: hehe
Niko: pudsigt nok ramte han det største mål i nærheden

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

Create a screencast

Ever tried creating one of these 🙂 ?

http://cs1ajb.staff.shef.ac.uk/blog/?q=node/12

Udgivet i Knowledge Base, Links, Old Base, Uncategorized | Skriv en kommentar

Elektronik Links

http://www.epanorama.net/index.php
http://www.ethernut.de/
http://www.beyondlogic.org

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

Tjekkisk hacking

http://1.im.cz/n/photo/00/26/86whxdp-original.jpg

Udgivet i Knowledge Base, Links, Old Base | Skriv en kommentar

mysql from java

Courtesy from http://www.javacoding.net/articles/technical/java-mysql.html

=== Introduction

Many people requested a tutorial on how to access MySQL from Java.

The standard way of working against a relational database from Java is by using the JDBC API.
(the Java Database Connectivity API). This API allows you to access any relational database from Java, no matter whether you’re on Linux, Solaris or Windows. As long as there’s a JDBC driver for the database, you can use the same standard API to access it.

To give you a kickstart in using MySQL from your applications, we decided to provide a little tutorial on this subject.

enjoy!
=== Prerequisites

When you’re going to access a relational db from Java, you’ll need the following:

* JDBC API (part of the JDK)
* JDBC Driver for your database
(or the JDBC-ODBC bridge driver from Sun that comes with the JDK)

The JDBC driver for MySQL can be found at MySQL download page …
=== Using the JDBC Driver

In order to use the JDBC driver, you just need to put it on your classpath, or installing it as a Java extension library.

to put it on the classpath:

WINDOWS:
set classpath=c:\path\to\jar\mysql-connector-java-2.0.14-bin.jar;%classpath%
UNIX:
export CLASSPATH=/path/to/jar/mysql-connector-java-2.0.14-bin.jar:$CLASSPATH

(of course, you’ll need to change the folders to the folder you put the JAR into)

if you put it in your jre/lib/ext folder of your JDK/JRE, it will also be found automatically.
=== Preparing the test database

In order to let our little demo program do it’s job, you’ll need to create a database on the MySQL instance.

Startup the mySQL console (mysql.exe on windows, mysql.sh on unix).
use:
create database test;

you can use any other name you like for your database.
=== The demo program

/* import needed for JDBC access */
import java.sql.*;

/**
* MySQL Demo Program
* this program is just a little demonstration of the usage
* of MySQL in combination with Java JDBC
*
* http://www.javacoding.net
*/
public class TestMySQL {

public void test ( String host, String database ) throws Exception {

/* first, we’ll test whether the MySQL driver is installed */
testDriver ( );

/* then, we’ll get a connection to the database */
Connection con = getConnection ( host, database );

/* we create a table */
executeUpdate ( con, “create table test (id int not null,text varchar(20))” );

/* we insert some data */
executeUpdate(con,”insert into test (id,text) values (1,’first entry’)”);
executeUpdate(con,”insert into test (id,text) values (2,’second entry’)”);
executeUpdate(con,”insert into test (id,text) values (3,’third entry’)”);

/* then we’ll fetch this data */
executeQuery ( con, “select * from test” );

/* and we’ll destroy the table … */
executeUpdate ( con, “drop table test” );

/* finally, we close the database */
con.close ( );
}

/**
* Checks whether the MySQL JDBC Driver is installed
*/
protected void testDriver ( ) throws Exception {

try {
Class.forName ( “org.gjt.mm.mysql.Driver” );
System.out.println ( “MySQL Driver Found” );
} catch ( java.lang.ClassNotFoundException e ) {
System.out.println(“MySQL JDBC Driver not found … “);
throw ( e );
}
}

/**
* Returns a connection to the MySQL database
*
*/
protected Connection getConnection ( String host, String database )
throws Exception {

String url = “”;
try {
url = “jdbc:mysql://” + host + “/” + database;
Connection con = DriverManager.getConnection(url);
System.out.println(“Connection established to ” + url + “…”);

return con;
} catch ( java.sql.SQLException e ) {
System.out.println(“Connection couldn’t be established to ” + url);
throw ( e );
}
}

/**
* This method executes an update statement
* @param con database connection
* @param sqlStatement SQL DDL or DML statement to execute
*/
protected void executeUpdate ( Connection con, String sqlStatement )
throws Exception {

try {
Statement s = con.createStatement ( );
s.execute ( sqlStatement );
s.close ( );
} catch ( SQLException e ) {
System.out.println ( “Error executing sql statement” );
throw ( e );
}
}

/**
* This method executes a select statement and displays the result
* @param con database connection
* @param sqlStatement SQL SELECT statement to execute
*/
protected void executeQuery( Connection con, String sqlStatement )
throws Exception {

try {
Statement s = con.createStatement ( );
ResultSet rs = s.executeQuery( sqlStatement );

while ( rs.next ( ) ) {
String id = ( rs.getObject (“id”).toString() );
String text = ( rs.getObject (“text”).toString() );

System.out.println ( “found record : ” + id + ” ” + text );
}

rs.close ( );

} catch ( SQLException e ) {
System.out.println ( “Error executing sql statement” );
throw ( e );
}
}

/**
* This one is used to start the program.
*/
public static void main ( String args[] ) throws Exception {
if ( args.length == 2 ) {
new TestMySQL ( ).test ( args[0], args[1] );
} else {
System.out.println ( “usage: java TestMySQL host database” );
}
}

}

=== Compiling and running the test program

Compile the test program:
javac TestMySQL.java

Run it by the following command:
java TestMySQL localhost test

(the first argument is the host with the MySQL server, the second argument is the name of the database you created for our test program).

If an error occurs, the most probable reason is that the MySQL JDBC driver is not on your classpath, so it can’t be found. Refer to our prior explanation for details on how to fix this.

=== Where to go next

Now that you have a little JDBC-MySQL example working with this tutorial, you can explore further by:

* Reading the MySQL and Java Developer’s Guide written by Mark Matthews
* Playing with the example (change it a bit, see what happens…)
* Read through the JDBC specs to learn the API (can be found at java.sun.com

enjoy !

if you have some questions/remarks regarding this article, please feel free to post them at our forums…

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar