Install Spark IM client on Linux


Make sure you should install JAVA before proceeding Spark installation because it’s mandatory to run Spark.

# Checking JAVA Version #
$ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

# Download Spark Archive file # 
$ sudo wget http://download.igniterealtime.org/spark/spark_2_7_6.tar.gz

# Extract Spark Archive file #
$ sudo tar -zxvf spark_2_7_6.tar.gz
$ sudo mkdir /opt/spark
$ sudo mv Spark/.[!.]* /opt/spark/
# Download Spark Icon # 
$ sudo wget https://dl.dropbox.com/u/50880014/spark.png 
$ sudo mv spark.png /opt/spark/

# Prerequiest library # 
$ sudo apt-get install libxtst6:i386 libxi6:i386

# if you want to create a Ubuntu Unity Desktop Launcher, create a desktop launcher file with 
$ sudo gedit /usr/share/applications/spark.desktop
   
# Then add the following information and save :
[Desktop Entry]
Name=Spark
Version=2.6.3
GenericName=Spark
X-GNOME-FullName=Spark
Comment=ignite realtime Spark IM client
Type=Application
Categories=Application;Utility;
Path=/opt/spark
Exec=/bin/bash Spark
Terminal=false
StartupNotify=true
Icon=/opt/spark/spark.png
TargetEnvironment=Unity

You will then be able to search for Spark in you unity dash and launch Spark.

spark-01

Finally log in with a valid Spark user and enter the server details.

spark-02

Add recurring task php


<?php

$startDate = $postData[‘start_date’];
$endDate = $postData[‘end_date’];
$endDate = date(“Y-m-d”, strtotime($endDate . ” +1 day”));

/* For weekly schedule
* frequency_id:
*      ‘1’ => ‘Daily’,
*      ‘2’ => ‘alternative day’,
*      —-Every——–
*      ‘3’ => ‘Monday’,
*      ‘4’ => ‘Tuesday’,
*      ‘5’ => ‘Wednesday’,
*      ‘6’ => ‘Thursday’,
*      ‘7’ => ‘Friday’,
*      ‘8’ => ‘Saturday’,
*      ‘9’ => ‘Sunday’
*  */
if (in_array ($postData[‘frequency_id’], array(3,4,5,6,7,8,9))) {
$beginDate = new DateTime($startDate);
$endDate1 = new DateTime($endDate);

$interval = DateInterval::createFromDateString(‘1 day’);
$period = new DatePeriod($beginDate, $interval, $endDate1);

$arrDay = array(‘3’ => ‘Monday’, ‘4’ => ‘Tuesday’, ‘5’ => ‘Wednesday’, ‘6’ => ‘Thursday’, ‘7’ => ‘Friday’, ‘8’ => ‘Saturday’, ‘9’ => ‘Sunday’);

foreach ($period as $dt)
if ($dt->format(“l”) == $arrDay[$postData[‘frequency_id’]]) {
$startDate = $dt->format(“Y-m-d”);
break;
}
}

$begin = new DateTime($startDate);
$end = new DateTime($endDate);

if ($postData[‘frequency_id’] == ‘1’) { // daily
$interval = DateInterval::createFromDateString(‘1 day’);
} elseif ($postData[‘frequency_id’] == ‘2’) { // alternative day
$interval = DateInterval::createFromDateString(‘2 day’);
} elseif (in_array ($postData[‘frequency_id’], array(3,4,5,6,7,8,9))) {
$interval = DateInterval::createFromDateString(‘7 day’);
}

$period = new DatePeriod($begin, $interval, $end);

foreach ($period as $dt) {
$postData[‘frequency_post_id’] = $frequencyPostAdd;
$postData[‘post_date’] = $dt->format(“Y-m-d”);

/********** Your Logik *************/
}

phpmyadmin not working after updating php


Create a link in /var/www like this:

sudo ln -s /usr/share/phpmyadmin /var/www/

Note: since 14.04 you may want to use /var/www/html/ instead of /var/www/ (same for php 5)

If thats not working for you, you need to include phpmyadmin inside apache configuration.

Open apache.conf using your favorite editor, mine is vim 🙂

sudo vim /etc/apache2/apache2.conf

Then add the following line:

Include /etc/phpmyadmin/apache.conf

Increment date by any number using js


This is the function to do so:

function increment_date(date,increment)
{
var dateString = date;
var myDate = new Date(dateString);
myDate.setDate(myDate.getDate() + increment);
var y = myDate.getFullYear(),
m = myDate.getMonth() + 1, // january is month 0 in javascript
d = myDate.getDate();
var pad = function(val) { var str = val.toString(); return (str.length < 2) ? “0” + str : str};
dateString = [y, pad(m), pad(d)].join(“/”);
return dateString;
}

 

and here is the example for that:

date_val = increment_date(‘2014/05/29’,parseInt(1));