Mac OSX – perfect Terminal Settings

TerminalSeveral years I used the Terminals as it is. Some months ago I started configuring the Terminal settings and now it’s perfect.
To get the settings enabled for your terminal just download and install the free font and my terminal settings:

 

 

  1. SourceCodePro
  2. Settings.terminal
  3. To get the perfect font colors follow my article from 2010: ls –color unter Mac OSX / BSD Unix

Features:

  • Perfect font …
    • to get the differences between chars like l and I or O and 0
    • not to fat or thin
    • monospaced
  • Terminal windows in the background are translucent
  • Cursor is high visible
  • special window title
  • background color is a very eye friendly light grey (very close to white)

 

perfect Terminal

Install GlassFish 4 with Oracle JDK RedHat / CentOS

glassfishDie Installation von GlassFish 4.0 schlägt auf Linux-Systemen welche nicht in englisch installiert sind fehlt. Die folgenden Schritte funktionieren:

 

# uninstall openJDK
   0   yum remove java-1.6.0-openjdk      

# download Oracle JDK
   0   http://www.oracle.com/technetwork/java/javase/downloads/index.html
# install Oracle JAVA
   0   yum reinstall '/tmp/jdk-7u45-linux-x64.rpm' 
   1   java
   2   java -version
   3   alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_45/jre/bin/java 20000
   4   alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_45/bin/jar 20000
   5   alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_45/bin/javac 20000
   6   alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_45/jre/bin/javaws 20000
   7   java -version
   8   ls -lA /etc/alternatives/
   9   alternatives --set java /usr/java/jdk1.7.0_45/jre/bin/java
   10  alternatives --set javaws /usr/java/jdk1.7.0_45/jre/bin/javaws
   11  alternatives --set javac /usr/java/jdk1.7.0_45/bin/javac
   12  alternatives --set jar /usr/java/jdk1.7.0_45/bin/jar
   13  update-alternatives --install "/usr/bin/jar" "jar" "/usr/java/jdk1.7.0_45/bin/jar" 1
   14  java -version
   15  export JAVA_HOME=/usr/java/jdk1.7.0_45/bin/java

# install GlassFisht 4.0
   0   wget http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip
   1   unzip -d /opt/oracle/ glassfish-4.0.zip
       # Full edition:
   2a wget http://download.java.net/glassfish/4.0/release/glassfish-4.0-unix.sh
./glassfish-4.0-unix.sh
       # Webedition:
   2b wget http://download.java.net/glassfish/4.0/release/glassfish-4.0-web-unix.sh
./glassfish-4.0-web-unix.sh
       # Avoid error: Fehler beim Rendern von SWIXML Frame=content area Verursacht durch: Invalid SwiXML Descriptor.
   3   LANG=EN sh ./glassfish-4.0-unix.sh
   4   Follow this perfect instructions: https://blog.hazrulnizam.com/?p=207

iPhone / iOS get device model

Mit diesem kleine Code sniped kann die aktuelle Version des genutzten iPhone / iPod / iPad bestimmt werden.

#import <sys/utsname.h>

struct utsname u;
uname(&u);

NSString *name =  [NSString stringWithCString:u.machine encoding:NSUTF8StringEncoding];

NSArray *oldDevices = @[@"iPhone1,1", @"iPhone1,2", @"iPhone2,1", @"iPhone3,1", @"iPhone3,2", @"iPhone3,3", @"iPod1,1", @"iPod2,1", @"iPod2,2", @"iPod3,1"];

if ([oldDevices containsObject:name])
{
    // Workaround for old devices
}
else
{

}

Script to create Public/Private-key SSH login without password (UPDATE: added port settings)

SSH_Communications_Security_logo.svgTo increment your servers security one position might by to disable ssh login with password and use certificated login instead. But if you are not familiar withe the given tools, creating the requested certificates and how to install them on the server and your client the following script will help you. Just run it on your Mac or *nix system.  Continue reading “Script to create Public/Private-key SSH login without password (UPDATE: added port settings)”

Check if device is mobile (iOS, iPhone iPad, iPod, Android, WebOS, Windows Mobile, Blackberry) inside PHP

<?php
$isAndroid 			= (bool) stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$isiPad 			= (bool) stripos($_SERVER['HTTP_USER_AGENT'],'iPad');
$isiPhone 			= (bool) stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$isiPod 			= (bool) stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iswebOS 			= (bool) stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
$isBlackBerry 		= (bool) stristr($_SERVER['HTTP_USER_AGENT'],'blackberry');
$isWindowsMobile 	= (bool) stristr($_SERVER['HTTP_USER_AGENT'],"Windows Mobile");
$isMobile 	= ($isAndroid || $isiPad || $isiPhone || $isiPod || $iswebOS || $isBlackBerry || $isWindowsMobile)
?>

How to set dd (disc dump) verbose (mac / bsd / linux)

Because of the missing verbose mode in GNU dd there is an other application with verbose mode by default. It’s dcfldd.

dcfldd is an enhanced version of GNU dd written by Nicholas Harbour

I especially used it for duplicating Raspberry Pi SD Cards. Without dcfldd you don’t know what time it will take to create the backup or SD Card.

Running Example:

Mac:Downloads andreas$ sudo dcfldd if=RaspberryPi.img of=/dev/disk1 bs=512
1798144 blocks (878Mb) written.

How to install dcfldd:

  1. Download dcfldd-1.3.4-1 :
    (wget http://andreasprang.de/?attachment_id=534)
  2. tar -xvf dcfldd-1.3.4-1.tar
  3. cd dcfldd-1.3.4-1
  4. ./configure
  5. sudo make install clean

Raspberry Pi – set sound interface shell script

Raspberry Pi
Raspberry Pi B © GijsbertPeijs/Flickr (CC BY 2.0)

 

For selecting the audio output I wrote a little script.

 

 

 

 

#!/bin/bash

if test $1  #check if parameter 1 / 0=auto, 1=analog, 2=hdmi is set
then

        echo "Try to select sound Interface:" $1
        sudo amixer cset numid=3  $1

else
        echo " select interface :" 
        echo "0=auto"
        echo "1=analog"
        echo "2=hdmi"
        read -p "Which interface should be used? " interfaceID
        echo "Try to select sound Interface:"  $interfaceID
        sudo amixer cset numid=3 interfaceID
fi