XMMS2

XMMS2 just a Music Player you can use It with write a command line in terminal. Lets get started.

  1. Install, my OS is Manjaro Linux, It’s about 1 MB. So small.
    [marwa@aspan-pc Downloads]$ sudo pacman -S xmms2
    [sudo] password for marwa:
    resolving dependencies…
    looking for conflicting packages…

    Packages (1) xmms2-0.8DrO_o.949.gca15e830-15

    Total Download Size: 1,39 MiB
    Total Installed Size: 5,03 MiB

    :: Proceed with installation? [Y/n] y

  2. Your Music File Directory, get in. In this case I’ll using my Music file in Download Directory.
    [marwa@aspan-pc Downloads]$ pwd
    /home/marwa/Downloads
  3. Add your Files, I’ll use all files with mp3 extension and put It on Default Playlist.
    [marwa@aspan-pc Downloads]$ xmms2 add *.mp3 -p Default
  4. List, was It already in your playlist.
    [marwa@aspan-pc Downloads]$ xmms2 list
    ->[1/77] Gita Gutawa – GITA GUTAWA feat DAFI – Dua Hati Menjadi Satu.mp3 (03:56)
    [2/78] Gita Gutawa – Gita Gutawa – Sempurna.mp3 (04:01)
    [3/93] – Peterpan – Kukatakan Dengan Indah (Official Music Video).mp3 (05:34)

    Total playtime: 0:13:30

  5. Play It
    [marwa@aspan-pc Downloads]$ xmms2 play
  6. That’s It.

    Not too important thing, just write down something that I have already did. When I forgot It, just open my blog to get It back. Second thing just hope this give a benefit for who search same case.

Advertisements

php, OOP-Inheritance

Original link : https://stackoverflow.com/questions/11237511/multiple-ways-of-calling-parent-method-in-php

When U trying make a class and then make a child class u can access a function usually called methode of parent class.

try this code :

<?php

abstract class Animal {

function get_species() {

echo “I am an animal.”;

}

}

class Dog extends Animal {

function __construct(){

$this->get_species();
}

function get_species(){

parent::get_species();
echo “More specifically, I am a dog.”;
}

}
$nico = new Dog;

Use different Python version with virtualenv

the ori : https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv

in some case in python development we need older version than a new one. in my system the latest python installed this :

aspan@aspan-thinkpad ~ $ python –version
Python 3.6.2

First I’ll make new folder for python 2 environment :

$ mkdir ~/python2

Come in to folder :

$ cd ~/python2

make a virtual environment using virtualenv command :

$ virtualenv venv

It’ll make a new folder named venv.

aspan@aspan-thinkpad ~/python2 $ virtualenv venv
Using base prefix ‘/usr’
New python executable in /home/aspan/python2/venv/bin/python3
Also creating executable in /home/aspan/python2/venv/bin/python
Installing setuptools, pip, wheel…done.

Setup python 2.7 to this environment :

aspan@aspan-thinkpad ~/python2 $ virtualenv –python=/usr/bin/python2.7 venv/

UPDATE : virtualenv -p /usr/bin/python2.7 venv/

Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /home/aspan/python2/venv/bin/python2.7
Not overwriting existing python script /home/aspan/python2/venv/bin/python (you must use /home/aspan/python2/venv/bin/python2.7)
Installing setuptools, pip, wheel…done.

Activate the environment :

$ . venv/bin/activate

Remember, starting with dot. and check the python version on virtual environment :

(venv) aspan@aspan-thinkpad ~/python2 $ python –version
Python 2.7.13

Ok, That’s It, Happy to share

ebook reader on Linux Manjaro, Arch derivatives.

If U found a file using an extension .epub like this Screenshot_2015-10-21_16-25-02

u can install an application on Manjaro to read this ebook/file named FBReader. If u have an internet connection u can install It w/ easy way :

  1. update UR pacman : $ sudo pacman -Syy
  2. search the package : [aspan@aspan-netbook ~]$ sudo pacman -Ss fbreader
    community/fbreader 0.99.4-5
    An e-book reader for Linux
  3. Install It : [aspan@aspan-netbook ~]$ sudo pacman -S fbreader
    resolving dependencies…
    looking for conflicting packages…Packages (2) libunibreak-3.0-2  fbreader-0.99.4-5

    Total Download Size:   1.96 MiB
    Total Installed Size:  7.59 MiB

    :: Proceed with installation? [Y/n] y
    :: Retrieving packages …
    libunibreak-3.0-2-i686    16.2 KiB  22.0K/s 00:01 [######################] 100%
    fbreader-0.99.4-5-i686  1990.9 KiB  43.9K/s 00:45 [######################] 100%
    (2/2) checking keys in keyring                     [######################] 100%
    (2/2) checking package integrity                   [######################] 100%
    (2/2) loading package files                        [######################] 100%
    (2/2) checking for file conflicts                  [######################] 100%
    (1/2) installing libunibreak                       [######################] 100%
    (2/2) installing fbreader                          [######################] 100%

  4. Just right click on file an choose open with : Screenshot_2015-10-21_16-36-26
  5. Done, Enjoy the book.

Linux Demilitarized Zone (DMZ) Ethernet Interface Requirements and Configuration

the ori : http://www.cyberciti.biz/faq/linux-demilitarized-zone-howto/

Q. Can you tell me more about Linux Demilitarized Zone and Ethernet Interface Card Requirements for typical DMZ implementation? How can a rule be set to route traffic to certain machines on a DMZ for HTTP or SMTP?

A. Demilitarized zone, used to secure an internal network from external access. You can use Linux firewall to create DMZ easily. There are many different ways to design a network with a DMZ. The basic method is to use a single Linux firewall with 3 Ethernet cards. The following simple example discusses DMZ setup and forwarding public traffic to internal servers.

Sample Example DMZ Setup

Consider the following DMZ host with 3 NIC:
[a] eth0 with 192.168.1.1 private IP address – Internal LAN ~ Desktop system
[b] eth1 with 202.54.1.1 public IP address – WAN connected to ISP router
[c] eth2 with 192.168.2.1 private IP address – DMZ connected to Mail / Web / DNS and other private servers

linux-dmz-network-diagram-firewall

 

 

 

 

 

 

 

 

(Fig 01: A typical Linux based DMZ setup [ Image modified from Wikipedia article] )

Routing traffic between public and DMZ server

To set a rule for routing all incoming SMTP requests to a dedicated Mail server at IP address 192.168.2.2 and port 25, network address translation (NAT) calls a PREROUTING table to forward the packets to the proper destination.

This can be done with appropriate IPTABLES firewall rule to route traffic between LAN to DMZ and public interface to DMZ. For example, all incoming mail traffic from internet (202.54.1.1) can be send to DMZ mail server (192.168.2.2) with the following iptables prerouting rule (assuming default DROP all firewall policy):

### end init firewall .. Start DMZ stuff ####
# forward traffic between DMZ and LAN
iptables -A FORWARD -i eth0 -o eth2 -m state –state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth2 -o eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT
# forward traffic between DMZ and WAN servers SMTP, Mail etc
iptables -A FORWARD -i eth2 -o eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth2 -m state –state NEW,ESTABLISHED,RELATED -j ACCEPT
# Route incoming SMTP (port 25 ) traffic to DMZ server 192.168.2.2
iptables -t nat -A PREROUTING -p tcp -i eth1 -d 202.54.1.1 –dport 25 -j DNAT –to-destination 192.168.2.2
# Route incoming HTTP (port 80 ) traffic to DMZ server load balancer IP 192.168.2.3
iptables -t nat -A PREROUTING -p tcp -i eth1 -d 202.54.1.1 –dport 80 -j DNAT –to-destination 192.168.2.3
# Route incoming HTTPS (port 443 ) traffic to DMZ server reverse load balancer IP 192.168.2.4
iptables -t nat -A PREROUTING -p tcp -i eth1 -d 202.54.1.1 –dport 443 -j DNAT –to-destination 192.168.2.4
### End DMZ .. Add other rules ###
Where,

-i eth1 : Wan network interface
-d 202.54.1.1 : Wan public IP address
–dport 25 : SMTP Traffic
-j DNAT : DNAT target used set the destination address of the packet with –to-destination
–to-destination 192.168.2.2: Mail server ip address (private IP)
Multi port redirection

You can also use multiport iptables module to matches a set of source or destination ports. Up to 15 ports can be specified. For example, route incoming HTTP (port 80 ) and HTTPS ( port 443) traffic to WAN server load balancer IP 192.168.2.3:

iptables -t nat -A PREROUTING -p tcp -i eth1 -d 202.54.1.1 -m multiport –dport 80,443 -j DNAT –to-destination 192.168.2.3
Pitfalls

Above design has few pitfalls:

Single point of failure – The firewall becomes a single point of failure for the network.
Hardware – The firewall Host must be able to handle all of the traffic going to the DMZ as well as the internal network.
Linux / BSD Firewall Distros

If you find above discussion little hard to digest, I suggest getting a Linux / BSD distribution which aims to provide a simple-to-manage firewall appliance based on PC hardware to setup DMZ and gateways:

IPCop
Shorewall
PfSense (FreeBSD based)