Saturday, 7 September 2013

Function arguments in add_action() to init

Function arguments in add_action() to init

I am looking to pass arguments in my function to add_action(), but
apparently I need to do this through do_action. My problem is the
add_action tag is 'init', which I think will cause issues if I run it
again/prematurely. Any ideas?
function taxonomy_equipment( ) {
$name = "Equipment";
$labels = array(
'name' => _x( $name, 'taxonomy general name' ),
'singular_name' => _x( $name, 'taxonomy singular name' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( str_replace(' ', '', strtolower($name)),
'exercise', $args );
}
add_action( 'init', 'taxonomy_equipment', 0 );
I want to pass $name as an argument.

most repeated int in a 2D array

most repeated int in a 2D array

i am working on a java Method to take in a 2 dimesional array and return
the most repeated Int in the 2D array. if 2 or more numbers are tied for
the most repeating int then the int the appears the least amount of times
in the array will be returned. if the array is empty the method will
return -1. I was reading through some posts and have seen using a Map
mentioned as the best way to accomplish something like this. does anyone
have any ideas were to start i was thinking the below code as a start with
each letter representing a number 0-9 then adding to the value to keep
track of how many times each is encountered.
public static int getMostRepeatedNumber(int[][] array)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
int i = 0;
int j = 0;
}

Simple java socket client, what throws this ConnectException?

Simple java socket client, what throws this ConnectException?

I'm writing a very simple client for my very simple server. Line 17 throws
a ConnectException at runtime if the server isn't running, I don't know
why. I have looked through the docs for Socket's constructor and
getInputStream(), but neither of them throw the ConnectException. I looked
at the docs for the CE, and it says "Signals that an error occurred while
attempting to connect a socket to a remote address and port. Typically,
the connection was refused remotely (e.g., no process is listening on the
remote address/port)." That is exactly true, the server isn't running, but
I don't know how to know this other than trial and error, why isn't it in
the docs for Socket?
import java.net.*;
import java.io.*;
public class ClientLesson {
//declare vars
static Socket socket;
static BufferedReader inputReader;
public static void main(String[] args) throws IOException {
try {
socket = new Socket("Lithium", 55555);
} catch (IOException ioe) {
System.out.println(ioe.toString());
}
try {
this is the problem --> inputReader = new BufferedReader(new
InputStreamReader(socket.getInputStream())); } catch (IOException ioe) {
System.out.print("couldn't get I/O stream"); ioe.printStackTrace(); }
String fromServer; while ((fromServer = inputReader.readLine()) != null) {
System.out.println(fromServer); } inputReader.close(); socket.close();
}
}
Simply put: Which docs explain the connection between Socket and
ConnectException? I think ConnectException is a subtype of IOException, so
I would handle that first, then IOException after that, right?

wrong memory allocation new char [n]

wrong memory allocation new char [n]

What is wrong with this program?
#include<iostream>
using namespace std;
void main()
{
int n = 5;
char* p = new char [n];
int i;
for(i=0;i<n;i++)
{
p[i] = 'A'+i;
}
cout<<p<<endl;
}
Why do I get "ABCDExxxx" instead of "ABCDE" ? What is wrong with memory
allocation?

How to track each individual click through data in an e-commerce website through google analytics.

How to track each individual click through data in an e-commerce website
through google analytics.

I want to track each individual user click through data on an e-commerce
website using google analytics.
Suppose user A arrives on the website then what he clicks next, what time
he spends on each page, whether he opens a related product or opens up a
new unrelated product, or add a product to his wishlist, or he put a
comment on a product, or he shares it on social media, or simply buy a
product or search for a product in the search bar. In all, the page flow
of each individual and user session has to be tracked.
I was trying this using custom variables. Is this a correct way of
approaching it. Or there could be some other better techniques. Also
provide me proper references for both.

Friday, 6 September 2013

Once a week animation on website enter

Once a week animation on website enter

So, On my website, I want to do something kind of fancy. I want to set it
up so once a week it will do a little animation. I feel like its very
similar to how http://apple.com/mac-pro/ works when you connect, however,
I would like to set it up so a cookie is used to make it only do it once a
week. This link is exactly what I want it to do:
http://www.youtube.com/watch?v=_P51GKcpkQc If this is possible to set up,
please tell me how. I am not very good with java script yet and I am
trying to learn. Also, please let me know what you think of this idea,
cause I won't do it if you guys dont think its a good idea.
Thank You!

LAMP: Can't get PHP errors to go to a log file (other than the Apache log)

LAMP: Can't get PHP errors to go to a log file (other than the Apache log)

On a Ubuntu web server [LAMP], I'm trying to get PHP errors to write into
a php_error file, but no matter what I do, they keep going to the apache
log.
Here's what I have tried/done:
Edited the php.ini file:
error_reporting = E_ALL | E_STRICT
display_error = Off
log_errors = On
error_log = /var/log/php_errors.log
Restarted apache
Checked the phpinfo() output to verify that the changes I made to the
php.ini file took -- they did.
After verifying that the errors were still going to the apache log, I
physically created the php_errors.log and tried again. Still going to the
apache log!!
Rebooted the web server! Still ...!!!
Anybody have a solution?