Sabtu, 06 Agustus 2016

Build url shortening service on openshift

Openshift is platform as a service provided by Redhat and python is one of supported programming language on openshift.

This example project provide you ready to run source code for url shortening service build with python and Flask. Its required you to have mongodb cartridge setup on your openshift project. You can git clone from this repo https://github.com/vinhut/shurl
git clone https://github.com/vinhut/shurl

demo site : http://shurl-sasori.rhcloud.com/

Minggu, 14 Februari 2016

ssh offering wrong keys

the problem

somehow ssh trying offering keys to server before fallback to password authentication. If you run ssh command with -v option, you can see more verbose message :
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Received disconnect from 192.168.0.1: 2: Too many authentication failures
Disconnected from 192.168.0.1

Solution

I found solution for this issue in stackoverflow post. Summary :
root cause for this issue is because by default ssh agent will search for keys on default path : ~/.ssh/id_dsa, ~/.ssh/id_rsa, ~/.ssh/id_ecdsa. You can ovveride this behavior by add this on ~/.ssh/config or /etc/ssh/ssh_config :
Host *
IdentitiesOnly yes

Senin, 07 Mei 2012

Bandwidth Management with Squid






Squid is free and opensource proxy server/cache server software. Squid is normally run on the operating system GNU/Linux. Squid also has advantages regulate and restrict bandwidth based on the extension, for example, a server is configured to limit the client uses only 100kbps bandwidth to download files ending in .flv, .avi, and so forth.

Get to the stages of installation:

  • I recommend to install squid from source, so it can be configured at compile, because by default squid does not support delay pool as a regulator of bandwidth.
  • To obtain maximum performance, create a separate partition with a size of about 300MB, name the partition "/cache" (without the quotes).  
  • Add/create a user "squid" into the system:
    useradd -d /cache/ -r -s /dev/null squid >/dev/null 2>&1 
  • Download squid source using the link below (as of this writing, the latest release is version 1.3.11 squid) :
    http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.11.tar.gz
  • Extract the file .tar.gz :
    tar xzpf squid-3.1.11.tar.gz 
  • compile and install squid, installation folder is /opt
    ./configure --prefix=/opt/squid --exec-prefix=/opt/squid --enable-delay-pools --enable-cache-digests --enable-poll --disable-ident-lookups --enable-truncate --enable-removal-policies
    make all
    make install
  • edit squid.conf (located in /opt/squid/etc/squid.conf). Example : http://pastebin.com/WRNULTWX
  • configure squid folder :
    mkdir /var/log/squid/
    chown squid:squid /var/log/squid/
    chmod 770 /var/log/squid/
    chown -R squid:squid /opt/squid/
    chown -R squid:squid /opt/squid/
  • execute squid command to create the cache folder :
    /opt/squid/bin/squid -z
  • run squid :
    /opt/squid/bin/squid 
Squid will run on port 3128.

Changing the scanned pdf to text html

When looking for a source of reference, I get a pdf file that the content/text in the form of images. As a result I could not copy the text (Lol... bad habit). There is one way to change the scanned pdf into html, by using google. If you get a pdf file of search results, then Google will display an option to display it in html form. This method is only useful if the pdf file indexed all by google and only displays the first 20 pages alone.

There is one other way to convert pdf files into a set of images (.png, .jpg), and then scan the image with OCR, and then to output a HTML or text file. Since I (the author) using the operating system GNU / linux ubuntu, then the method below only applies to OS GNU/Linux only (for the windows version, ask someone else!). 

Just go ahead....
First install xpdf, imagemagick, and ocropus 
sudo apt-get install xpdf imagemagick ocropus
use this script to convert. Save with the name "pdf2txt" (without the quotes).
click here to view the code.

How to use:
Suppose you want convert "makalah.pdf" into the html file, use the command:
./txt2pdf makalah.pdf > makalah.html 
 the above command will convert "makalah.pdf" and output "makalah.html".

by: Alvin

Fix Linux Boot Loader

Problem often occurs when a user re-install Microsoft windows, after windows OS install was completed in linux previously installed boot loader is not detected by windows, in other words the grub loader (grub boot loader is often used popular linux distro) affected by the windows boot loader. It is very common among my friends which a newbie or still try to use linux. These problems are quite confusing to the point that one of my friends are willing to call me at midnight in order to overcome this problem. Actually solve the problem one is quite easy and simple, just capitalize the linux live cd. In this paper I use ubuntu live cd and live cd linux mint.

  1. First booting linux via live cd, restart / turn on the computer, insert the CD into the disk drive, and change the bios settings to boot first via cd / dvd rom.
  2. Having made it into the linux GUI display, open a terminal, and run the command: sudo mkdir /mnt/recover_grub ;sudo fdisk-l press enter, it will show information about the disk and its partitions installed in it  
  3.  based on the information shown, mount the root partition recover linux grub loader will in its. This stage is necessary for request help from people who proficient in linux. To check whether the partition is a linux partition, can be tried with mount partition one by one. Method for mounting a partition is to run the command: sudo mount [linux partition] [folder mount point] for example: sudo mount / dev/sda2 / mnt / recover_grub
  4. Start the installation process grub after the linux partition is mounted in a predetermined folder, run the command: sudo grub-install - root-directory = [folder mounnt point] [install device] for example: sudo grub-install - root-directory = / mnt / recover_grub / dev / sda
In addition to using the live cd, you can also use a flash disk that is installed live cd.
by: alvin