Fortran function example

This is an example in Fortran how to make a function:

program hello
    implicit none
    integer:: square
    integer:: i
    Print  *,"write your number:"
    read   *, i
    print  *,"your number:",i
    i= square(i)
    print  *,"your result:",i
end program Hello

integer function square( a )
  implicit none
  integer  :: a
  square   = a*a
end function square

Result:

 write your number: 
4   
 your number:           4  
 your result:          16

C# input output example

This is a little Program written in C sharp with Mono, It reads a number from the Terminal multiplies with itself and then print back:

using System.IO;
using System;

class Program
{
    static void Main()
    {
        Console.Write("write your number: ");//Info text 
        String str = Console.ReadLine();//read input
        Console.WriteLine("your number: "+str);//print input
        int i = Convert.ToInt32(str);//convert to intager
        i = i*i;//calculate
        Console.WriteLine("your result: "+i);//print result
    }
}

To compile run this:

mcs *.cs -out:main.exe

And then start with Mono :

mono main.exe

our result looks like this:

write your number: 4   
your number: 4     
your result: 16

The same Programm in Java is here : Java input output example

Java try/catch

This is a little example about try and catch in Java:

public class HelloWorld{
     public static void main(String []args){
        System.out.print("write your number: ");//Info text 
        String str = System.console().readLine();//read input
        int res = 0;
        try{
           res = Integer.parseInt(str); 
           res *= 2;
        }catch (Exception e){
            System.out.println("Error:"+e);
        }
        System.out.println("result:"+res);
     }
}

Output looks like:

sh-4.3# java -Xmx128M -Xms16M test                     
write your number: 2                                         
result:4  

                                                
sh-4.3# java -Xmx128M -Xms16M test                     
write your number: a                                         
Error:java.lang.NumberFormatException: For input string: "a" 
result:0

Java calculate the sum of the given numbers

This program calculates the sum from 10 numbers, you could hit “stop” to break and calculate less than 10 numbers:

public class HelloWorld{
     public static void main(String []args){
        int[] values = new int[10];
        int i = 0;
        int sum = 0;
        System.out.print("write up to 10 numbers !\n");//Info text
        for(i = 0; i <= values.length-1;++i){
           System.out.print("write your number: ");//Info text
           String str = System.console().readLine();
           if(!str.equals("stop")){
           values[i] = Integer.parseInt(str);//read input
           }else{--i;break;}
        }
        System.out.print("your input:\n");//Info text
        for(int x = 0; x <= i;++x){
           System.out.print("your number: "+values[x]+"\n");//Info text
           sum += values[x];
        }
        System.out.println("your result: "+sum);//print result
     }
}

Output looks like this:

write up to 10 numbers !
write your number: 1 
write your number: 2 
write your number: 3 
write your number: stop 
your input:        
your number: 1 
your number: 2 
your number: 3 
your result: 6

perl shuffle String and Array

I wrote a little script in Perl to shuffle Arrays or strings:

sub myshuffle {
    my @str = ($#_ == 0)?split(//o, $_[0]):@_;
    my $r1 = 0;
    my $r2 = 0;
    
    for(0..($#str*2)){
        $r1 = int(rand($#str+1));
        $r2 = int(rand($#str+1))while($r1 == $r2 && $#str>4);
        ($str[$r1],$str[$r2]) = ($str[$r2],$str[$r1]);
    }
    return join '', @str;
}

This are my examples:

print myshuffle("abcdefghijklmonopqrs").$/;
print myshuffle(1,2,3,4).$/;
print myshuffle(1,2,3).$/;
print myshuffle(1,2).$/;

and we got his as result:

obrdekohnlicgsfqapjm  
2431 
231 
21

Java input output example

This is a little example in Java how to print an info text and then read a number from the terminal, calculate the square and then print the result:

public class HelloWorld{
     public static void main(String []args){
        System.out.print("write your number: ");//Info text 
        String str = System.console().readLine();//read input
        System.out.println("your number: "+str);//print input
        int i = Integer.parseInt(str);//convert to intager
        i = i*i;//calculate
        System.out.println("your result: "+i);//print result
     }
}

To compile your test.java file run this in your terminal:

javac test.java

now we have the file test, to execute run this:

java -Xmx128M -Xms16M test

This is the output:

write your number: 4                                                       
your number: 4                                                               
your result: 16

The same Program in C# is here : C# input output example

Backtrack How to

This is an collection of problems and bugs I had with Backtrack 5 R2 (Linux based Distribution).

To download Backtrack look at http://www.backtrack-linux.org/downloads/

 

Ubuntu software centre and update manager

For more Software, I installed the ubuntu software centre with this command:

sudo apt-get install software-center

then run a update:

sudo apt-get update && apt-get dist-upgrade

now you could choose your software sources at:

System > Administration > Software Sources

If you want the Update manager, run this:

sudo apt-get install update-manager

Or you could add the ubuntu repository to your system, just open the “/etc/apt/sources.list” file and generate a list from http://repogen.simplylinux.ch/generate.php, now you could add what you want.

 

NVIDIA or ATI/AMD driver

NVIDIA: http://www.nvidia.de/Download/indexsg.aspx?lang=de

just run it from your download folder.

ATI/AMD: http://support.amd.com/us/gpudownload/Pages/index.aspx 

Code:

sudo sh amd-driver.run --buildpkg Ubuntu/lucid
sudo dpkg -i fglrx*.deb
sudo aticonfig --initial -f

After a reboot you could check your driver status with:

fglrxinfo

 

Network

If you need more features at your network just install what you need:

network-manager-openvpn – network management framework (OpenVPN plugin core)
network-manager-openvpn-gnome – Network Management framework (OpenVPN plugin GNOME GUI)
network-manager-pptp – network management framework (PPTP plugin)
network-manager-pptp-gnome – network management framework (PPTP plugin)
network-manager-vpnc – network management framework (VPNC plugin core)
network-manager-vpnc-gnome – network management framework (VPNC plugin GNOME GUI)
network-manager – network management framework daemon
network-manager-dev – network management framework (development files)
network-manager-gnome – network management framework (GNOME frontend)

sudo apt-get install network-manager-openvpn
sudo apt-get install network-manager-openvpn-gnome
sudo apt-get install network-manager-pptp
sudo apt-get install network-manager-pptp-gnome
sudo apt-get install network-manager-vpnc
sudo apt-get install network-manager-vpnc-gnome
sudo apt-get install network-manager
sudo apt-get install network-manager-dev
sudo apt-get install network-manager-gnome

 

Add the Network icon to the panel:

echo auto lo > /etc/network/interfaces
echo iface lo inet loopback >> /etc/network/interfaces
service network-manager start
nm-applet &

 

network is blocked

To solved this run this:

sudo rfkill unblock all

 

Disable bell in terminal

open the file “/etc/inputrc” and add this:

set bell-style none

 

Mint backup

run this:

sudo add-apt-repository ppa:webupd8team/mintbackup && sudo apt-get update
sudo apt-get install mintbackup

 

BUG : wait for sound system to respond

System > Preferences > Startup Applications add this:

/usr/bin/pulseaudio

 

BUG : Couldn’t execute command: xscreensaver-command -lock

run this command:

apt-get install xlockmore gconf-editor

System > Preferences > Keyboard Shortcuts
Lock Screen disable.
Add new “Ctrl+Alt+L” with “xlock” ,apply done!

 

BUG : Chrome wont start as root

Menue>Internet>Chrome>Properties>Comand and add this:

/usr/bin/chromium-browser %U --user-data-dir www.google.at

 

BUG : run a *.deb

sudo dpkg -i name.deb

 

BUG : E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Limit. Current value: 25165824. (man 5 apt.conf)

Solution A:

open “/etc/apt/apt.conf.d/70debconf” and add this:

APT::Cache-Limit "100000000";

then run this:

sudo apt-get clean && sudo apt-get update --fix-missing

Solution B:

open “/etc/apt/apt.conf.d/90user” and add this:

APT::Cache-Limit "100000000";

 

BUG : GRUB2 error: out of disk

sudo mount /dev/sda1 /mnt
sudo grub-install --root-directory=/mnt /dev/sda

 

BUG : VLC is not supposed to be run as root. Sorry.

sudo apt-get install ghex
ghex2 /usr/bin/vlc

In line 7F8, replace “geteuid” with “getppid”.

Calculator in C++

This is my calculator in C++ with in-line assembler:

#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main( void )
{
	int nZahl1 = 0, nZahl2 = 0, nVar3 = 0;string strOp="";
do{
	
   	cout << "calculate (+,-,*,/) :" ;
   	cin >> strOp;

   	cout << "number  1: " ;
   	cin >> nZahl1;
	
   	cout << "number  2: " ;
   	cin >> nZahl2;

	if("+"==strOp){
	asm("ADD %%edx, %%eax \n":"=a"(nZahl1):"d"(nZahl2),"a"(nZahl1));
	cout <<" = "<<(nZahl1)<<endl;
	}else if("-"==strOp){
	asm("SUB %%edx, %%eax \n":"=a"(nZahl1):"d"(nZahl2),"a"(nZahl1));
	cout <<" = "<<(nZahl1)<<endl;
	}else if("*"==strOp){
	asm("MOV %%edx, %%eax \n":"=a"(nVar3):"d"(nZahl1),"a"(nVar3));
	for(int i = 2 ;i<=nZahl2;i++)
	asm("ADD %%edx, %%eax \n":"=a"(nZahl1):"d"(nVar3),"a"(nZahl1));
	cout <<" = "<<(nZahl1)<<endl;
	}else if("/"==strOp){
	asm("MOV %%edx, %%eax \n XOR  %%edx,%%edx \n":"=a"(nVar3),"=d"(nZahl1):"d"(nZahl1),"a"(nVar3));
	for(int i = nZahl2 ;nVar3>=i;nZahl1++)
	asm("SUB %%edx, %%eax \n":"=a"(nVar3):"d"(nZahl2),"a"(nVar3));
	cout <<" = "<<(nZahl1)<<",";
	for(int i = 0 ;i<=10;i++){
	nVar3*=10;nZahl1=0;
	for(int i = nZahl2 ;nVar3>=i;nZahl1++)
	asm("SUB %%edx, %%eax \n":"=a"(nVar3):"d"(nZahl2),"a"(nVar3));
	cout <<(nZahl1);
	}
	cout << endl;
	}

}while(1);

return(0);
}

Compile the code:

g++ -o main test.cpp
./main

output:

calculate (+,-,*,/) :+ 
number  1: 4           
number  2: 5           
 = 9                   
calculate (+,-,*,/) :- 
number  1: 9           
number  2:             
4                      
 = 5                   
calculate (+,-,*,/) :^C
sh-4.3# main           
calculate (+,-,*,/) :+ 
number  1: 4           
number  2: 5           
 = 9                   
calculate (+,-,*,/) :- 
number  1: 9           
number  2: 4           
 = 5                   
calculate (+,-,*,/) :* 
number  1: 4           
number  2: 5           
 = 20                  
calculate (+,-,*,/) :/ 
number  1: 20          
number  2: 4           
 = 5,00000000000

new Hompage design

I made a new design for my scheinast.software domain, it looks like this:

scheinast-software

I tryed to make the Page as light weight as possible and use less code as possible

 

Html code:

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<title>Scheinast Software</title>
<link rel="stylesheet" href="/software/style.css" type="text/css">
</head>
<body>
<div id="PosDiv">
	<div id="HeadDiv">
		<h1>Scheinast Software</h1>
	</div>
	<div id="ContentDiv">
		<br>
		<h2>Title</h2>
		<h3>Wir arbeiten noch ....</h3>
		<br>
	</div>
	<div id="FootDiv">
		<a href="http://scheinast.eu/">Our Sponsor scheinast.eu</a>
	</div>
</div>
</body>
</html>

CSS code:

@font-face {
    font-family: "hu";
    src: url("/software/holyuni.ttf");
}
body  {
    background-image: url("/software/bg.jpg");
    background-size: 100% auto;
    width: 100%;
    margin: 0;
}
h1, h2, h3, h4, h5, h6,a {
    font-family: "hu",sans-serif;
    color: rgba(99, 9, 9, 1);;
    font-weight: normal;
    text-shadow: 1px 1px 1px rgba(99, 9, 9, 1);
    padding: 0;
}
h1 {
    font-size: 3.2em;
}
h2 {
    font-size: 3.0em;
}
h3,a {
    font-size: 2.6em;
}
h4 {
    font-size: 2.4em;
}
h5 {
    font-size: 2.2em;
}
h6 {
    font-size: 2.0em;
}
#PosDiv {
    margin: 0 auto;
    width: 800px;
    text-align:center;
    height: 100vh;
}
#HeadDiv,#ContentDiv,#FootDiv {
    background: rgba(0, 0, 0, 0.86);
    width: 100%;
    margin: 20px 0px;
    border: 1px solid rgba(118, 14, 14, 0.4);
    border-radius: 4px;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 1), 0 1px 10px rgba(0, 0, 0, 1) inset;
}
#HeadDiv {
    height:auto;
}
#ContentDiv {
    min-height: 100%;
    height: 100%;
    margin: 0 auto;
}
#FootDiv {
    height:auto;
}

Background image:

scheinast software background