Linux / CentOS xsel 1.2 install script(.sh)

If yum can't find xsel package by using 'yum install xsel'. You can install it via script:

  1. cd /tmp/
  2. #download
  3. wget http://dl.fedoraproject.org/pub/epel/6/i386/xsel-1.2.0-8.el6.i686.rpm
  4. yum -y install xsel-1.2.0-8.el6.i686.rpm
  5. #remove backup
  6. rm -f xsel-1.2.0-8.el6.i686.rpm
  7. #check installation and see:
  8. #xsel version 1.2.0 by Conrad Parker <conrad@vergenet.net>
  9. xsel --version
Download script Install xsel 1.2.sh

sparkjava : problems passing urls as parameter to routes

With sparkjava you can build a helloworld website within lessthan a minute like Node Express (http://expressjs.com/).

Passing url parameters :
Consider creating a route like: http://host:port/url ( e.g. http://localhost:4567/https://finance.yahoo.com/q/ks?s=VNJTX+Key+Statistics )
whereas the black url portion you want to pass as parameter.
This can be done very easily using splats (http://sparkjava.com/documentation.html).
With the following code in your route:
  1. port(8081);//lets start our server on port 8081
  2. get("/", (request, response) -> "Welcome to HelloWorld Server! :)");
  3. get("/*", (request, response) -> {
  4.     String url = request.splat()[0];//take the first splat param value
  5.     return "Requested url : " + url;
  6.     });
And here the problem comes:
It prints:
  1. Requested url : https:/finance.yahoo.com/q/ks
The first thing is that it has removed the query string.
On top of that https:/finance.yahoo.com/q/ks
is not a valid url.

To solve this:

We can simply do some manipulate on the urls ourselves:
Corrected codes:
  1. get("/*", (request, response) -> {
  2.     String url = request.splat()[0];//take the first splat param value
  3.     url = manipulateUrl(url, request.queryString());
  4.     return "Requested url : " + url;
  5.     });
  6. //let's modify url param
  7. public static String manipulateUrl(String urlStr, String queryStr) throws URISyntaxException, MalformedURLException, UnsupportedEncodingException {
  8.     urlStr = urlStr.replaceFirst("/", "//");
  9.     if (queryStr.length() >= 0) {
  10.         urlStr = urlStr + "?" + queryStr;
  11.     }
  12.     return urlStr;
  13.     }

java exception : Expected org.codehaus.plexus.components.io.resources.PlexusIoArchivedResourceCollection, got org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection

Running maven command with maven assembly plugin
  1. mvn clean compile assembly:single
may some times throw:

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (default-cli) on project : Failed to create assembly: Error adding file-set for to archive: Expected org.codehaus.plexus.components.io.resources.PlexusIoArchivedResourceCollection, got org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection -> [Help 1]

This may happen if by any chances maven project structure is not standard.For example: if it misses src/main/java

Non-standard structure:
src->com->company->package->files
Standard structure:
src->main->java->com->company->package->files

Solution:

  1. #navigate to project dir where pom.xml exists
  2. cd PROJECT_DIR
  3. cd src
  4. #create directories
  5. mkdir main/
  6. mkdir main/java/
  7. #move source packages & files into src/main/java directory.
  8. mv com/ main/java/

Laravel 4 : UnexpectedValueException (The stream or file LOG_FILE could not be opened: failed to open stream: No such file or directory)


The stream or file "PROJECT_ROOT/app/storage/logs/LARALVEL_LOG_FILE" could not be opened: failed to open stream: No such file or directory

This may happen when laravel can' find log file.
One solution is to create logs dir manually :


  1. #Goto your laravel project dir. Do the following on terminal:
  2. mkdir app/storage/logs

  3. #incase you forgot file permissions
  4. chmod -R 777 app/

Update git 1.7 to most recent version 2.0.4 on centos 6 script



  • #install dependencies
  • yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel && yum -y install gcc perl-ExtUtils-MakeMaker
  • #remove old version
  • yum -y remove git
  • #install git 2 most recent src
  • cd /usr/src
  • wget https://www.kernel.org/pub/software/scm/git/git-2.0.4.tar.gz
  • tar xzf git-2.0.4.tar.gz
  • #remove backup
  • rm -f git-2.0.4.tar.gz
  • #build git
  • cd git-2.0.4
  • make prefix=/usr/local/git all
  • make prefix=/usr/local/git install
  • #add to path
  • echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
  • source /etc/bashrc
  • #verify successful installation
  • git --version
  • Parsing xml response data with Nodejs

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ns2:urlset xmlns:ns2="http://www.sitemaps.org/schemas/sitemap/0.9" hc="a3">
    3. <url>
    4. <loc>http://www.flipclub.com/</loc>
    5. <lastmod>2015-06-09</lastmod>
    6. <changefreq>daily</changefreq>
    7. <priority>1.0</priority>
    8. </url>
    9. <url>
    10. <loc>http://www.flipclub.com/flashcard/46/3rd-Grade:-Ancient-Rome-Flashcards</loc>
    11. <lastmod>2015-06-09</lastmod>
    12. <changefreq>daily</changefreq>
    13. <priority>1.0</priority>
    14. </url>
    15. <url>
    16. <loc>http://www.flipclub.com/flashcard/47/7th-Grade:-Social-Studies-Flashcards</loc>
    17. <lastmod>2015-06-09</lastmod>
    18. <changefreq>daily</changefreq>
    19. <priority>1.0</priority>
    20. </url>
    21. <url>
    22. <loc>http://www.flipclub.com/flashcard/1068/ACT-English-Game-Set-2-Flashcards</loc>
    23. <lastmod>2015-06-09</lastmod>
    24. <changefreq>daily</changefreq>
    25. <priority>1.0</priority>
    26. </url>
    27. <url>
    28. <loc>http://www.flipclub.com/flashcard/1070/ACT-Exam-Math-Game-Set-1-Flashcards</loc>
    29. <lastmod>2015-06-09</lastmod>
    30. <changefreq>daily</changefreq>
    31. <priority>1.0</priority>
    32. </url>
    33. <url>
    34. <loc>http://www.flipclub.com/flashcard/1069/ACT-Exam-Science-Game-Set-1-Flashcards</loc>
    35. <lastmod>2015-06-09</lastmod>
    36. <changefreq>daily</changefreq>
    37. <priority>1.0</priority>
    38. </url>
    39. </ns2:urlset>
    Sample Parsed Output:-

    http://flipclub.com/
    http://flipclub.com/flashcard/46/3rd-Grade:-Ancient-Rome-Flashcards
    http://flipclub.com/flashcard/47/7th-Grade:-Social-Studies-Flashcards
    http://flipclub.com/flashcard/1068/ACT-English-Game-Set-2-Flashcards
    http://flipclub.com/flashcard/1070/ACT-Exam-Math-Game-Set-1-Flashcards
    http://flipclub.com/flashcard/1069/ACT-Exam-Science-Game-Set-1-Flashcards

    Codes:-
    1. var url = "http://flipclub.com/sitemap.xml";//get xml from sample sitemap.xml
    2. var http = require("http");
    3. var parseString = require('xml2js').parseString;//make sure you have installed xml2js with "npm install xml2js"
    4. var req = http.get(url, function(res) {
    5. // save the data
    6. var xml = '';
    7. res.on('data', function(chunk) {
    8. xml += chunk;
    9. });
    10. res.on('end', function() {
    11. parseString(xml, function(err, result) {
    12. var items = result['ns2:urlset']['url'];
    13. items.forEach(function(entry) {
    14. console.log(entry['loc'][0]);
    15. });
    16. });
    17. });
    18. });
    19. req.on('error', function(err) {
    20. // debug
    21. console.log(err);
    22. });

    Install I2P server 0.9.20 on CentOS Script(*.sh)

    Download & install I2p:
    1. mkdir /usr/local/i2p/
    2. cd /usr/local/i2p/
    3. wget --no-check-certificate https://download.i2p2.de/releases/0.9.20/i2pinstall_0.9.20.jar
    4. java -jar i2pinstall_0.9.20.jar -console
    5. #press 1
    6. /usr/share/i2p/
    7. #press 1
    Configure for running server as root:
    1. vim /usr/share/i2p/i2prouter
    uncomment the line containing:
    1. ALLOW_ROOT=true
    Start I2p service:
    1. sh /usr/share/i2p/i2prouter start
    A browser window should open pointing at

    see logs:
    1. tail -f /root/.i2p/logs/log-router-0.txt
    2. tail -f /root/.i2p/wrapper.log

    stopping service:
    1. sh /usr/share/i2p/i2prouter stop

    Uninstall i2p server:

    1. sh /usr/share/i2p/i2prouter stop
    2. rm -rf /root/.i2p/
    3. rm -rf /usr/local/i2p/
    4. rm -rf /usr/share/i2p/
    References: