Category Archives: action

Time for an apache spark script: Actions

I have an Apache Spark script that does a series of transformations and eventually "transforms" into a sparse coordinate matrix. If I were to compute, the time it takes for my script to run, I would need to perform some "action" at the end.

The question is, which action should I be transforming to compute run time of the script?

1) matrix.collect() would make me run in to memory issues. 2) I could save the final matrix to a file. Would this be more preferred choice than .collect()?

thank you so much for your help.

yii theme won’t load in index action of every controller

I'm using Yii for my website. I created an addon domain and uploaded the website there. Below is the website's config:

return array(
    'theme' => 'frontend',
    'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>false,
        'rules'=>array(
            '/'                                             => 'site/index',
            'login'                                         => 'site/login',
            'forgotpass'                                    => 'site/forgotpass',
            'logout'                                        => 'site/logout',
            'page/<slug:[a-zA-Z0-9-]+>'                     => 'site/page',
            'verification/<code:[a-zA-Z0-9-]+>'             => 'site/verification',
            'gii'                                           => 'gii/default',
            'gii/<controller:\w+>/<id:\d+>'                 => 'gii/<controller>/view',
            'gii/<controller:\w+>/<action:\w+>/<id:\d+>'    => 'gii/<controller>/<action>',
            'gii/<controller:\w+>/<action:\w+>'             => 'gii/<controller>/<action>',
            'gii/<controller:\w+>/<action:\w+>/id/<id:\w->' => 'gii/<controller>/<action>/id/<id>',
        ),
    ),
);

Here is my htaccess:

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

The weird thing is, the theme won't load when I access home page which goes to SiteController and index action. But it loads okay when I access other action. The same goes to other Controller.

What could possibly go wrong?

This is the website I'm building: www.professorwriting.com. It will access SiteController actionIndex.

and this is the place to access SiteController actionLogin: www.professorwriting.com/login

Make Subdomain Post Request

How would I make it so that a subdomain of a website acts as a get/post action and request. For example, all subdomains would work as a form action and visiting subdomain.mywebsite.com would be the same as visiting mywebsite.com/?id=subdomain.

I've seen similar things like this done before but have never seen anything on how this can be done.

Thank you in advance for any help or information.

Is there any way with Apache Spark to reduce number of elements in rdd [take as transformation]

I am working with Apache Spark for a query processing engine. The problem I recently faced is that I want to limit the number of elements in the rdd.

I know there is take function in rdd which can be used to retrieve only the given number of elements from rdd. However, after applying this function the result won't be rdd.

It is essential that even if we apply this functionality, the rdd has to be remain (as transformation)

So for now what I did is following

public JavaRDD<Map<String,Object>> limitRDD(JavaRDD<Map<String,Object>> rdd, JavaSparkContext context, int number){
context.parallelize(rdd.take(number));
return rdd;

I think this is massive waste of time. However I can't think of any way using transformations such as map, filter to implement this functionality.

Is there anyway to achieve this without what I did here?

Thanks

$_SERVER['PHP_SELF'] Issue with .htaccess mode_rewrite

I created clean url with .htaccess,

     RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
     RewriteRule ^ %1 [R,L]


     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME}\.php -f
     RewriteRule ^(.*)$ $1.php

.php is removed, but wherever I have a form where

     action = somepage.php 

I am forced to change it to

      action = somepage

these are old websites I am fixing, luckily one has all

     action =$_SERVER['PHP_SELF'] 

is there someway to resolve so action takes the posted values no matter if

action = somepage.php or

action somepage or

action = $_SERVER['PHP_SELF']

So Instead of

   form enctype="multipart/form-data" method="post" action="actionfr.php"

I am forced to change it to:

     form  method="post" action="actionfr"

Same goes for

      form method="post" action="<?php echo   $_SERVER['PHP_SELF']?>"

Many Thanks

P.S I learned how to make clean url .htaccess here on this forum (y) :)