Q: How high can fish get? In Ridiculous Fishing, once the fish reach the water's surface on the way up, they fly into the air at high speeds. The background changes as they go, in that the clouds disappear, the sky gets darker, stars and the moon become visible. That's as far as I've seen, though, and I was wondering how high the fish can reach and what is the highest 'feature' (e.g. clouds, the moon, etc) visible.
There is also, as far as I can tell, no way to see the maximum height your fish have reached.

A: I currently have a fish that is rising rapidly and at 21km.  I'm just going to let it keep going and see how high it will go.
I'm assuming this is some kind of bug because it doesn't seem to be slowing down at all, After the moon are stars, after that the stars get less and less dense and at this point there are no stars I'm just in black space.
...
I let it run over night and it was up to 800km before I shot the fish.


Q: Pass all uncaught errors from the framework to Crashlytics with custom parameter I got uncaught errors form the framework to Crashlytics. But it is difficult to fix the issue because I don't know which screen or record caused the error.
For example below error, I only know that it is invalid image from CacheNetworkImage package. But It is very difficult to find out which screen or which record.
Is there any way to pass screen name or custom parameter. I can't find the way to record.

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError:
Exception: Invalid image data. Error thrown Instance of
'ErrorDescription'.
at .instantiateImageCodec(dart:ui)
at ImageLoader.loadAsync(_image_loader.dart:59)
at new MultiImageStreamCompleter.(multi_image_stream_completer.dart:25)

Below code pass all uncaught errors from the framework to Crashlytics.
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;

A: Use setCustomKey to add values to reports.
FirebaseCrashlytics.instance.setCustomKey('str_key', 'hello');

See Customize your Firebase Crashlytics crash reports for details.


Q: EclipseFP on Indigo, issues with Maven? I'm trying to install EclipseFP, using the usual Eclipse "Install new software" approach. However, at the "Installation Details" window, it says "This operation cannot be completed", giving me the following details:
Cannot complete the install because one or more required items could not be found.
  Software currently installed: Shared profile 1.0.0.1316138547364
      (SharedProfile_epp.package.java 1.0.0.1316138547364)
  Missing requirement: Shared profile 1.0.0.1316138547364
      (SharedProfile_epp.package.java 1.0.0.1316138547364)
    requires 'org.maven.ide.eclipse [1.0.100.20110804-1717]'
    but it could not be found

I just barely downloaded a fresh Eclipse:
Eclipse IDE for Java Developers
Version: Indigo Service Release 1
Build id: 20110916-0149

Does EclipseFP actually work on Indigo? Do I need to download an older Eclipse? Or perhaps there are additional steps I need to take to install Maven? (I don't want to download/install Maven if I don't have to.)

A: Since Kane neglected to turn his comment into an answer, I may as well state it plainly here:
This issue arises when you put the Eclipse folder in a location where Windows will have issues with access control (e.g. the Program Files folder). By moving the folder to my personal user's folder, I was able to use Eclipse normally without this issue.


Q: audio html5 with jquery to play next track I have html5 like this
<audio controls class="audioPlayer" >
     <source class="iSong" src="1.mp3" type="audio/mpeg">
     <source class="iSong" src="2.mp3" type="audio/mpeg">
     <source class="iSong" src="3.mp3" type="audio/mpeg">
     Your browser does not support the audio element.
</audio>

I want add jquery for button nextSong because my song always play only last one.

A: Adding multiple sources to an audio element does not create a playlist, it is to support different audio formats and your browser will simply play the first one it can, which is why you say only the last one is playing.
To have multiple songs you choose between you will have to write some javascript. Here is some information on audio in javascript.
It sounds like you will have to create a separate button for playing the next song, add a click event that changes the source of the audio element and plays it.


Q: Issue querying a materialized view redshift I've created a materialized view in redshift as follows:
create materialized view stats as
select *
from t1

however when i try to query it:
select * from stats

I get this error:
[2022-06-26 15:09:35] [XX000] ERROR: Failed assertion at rewriteHandler.c:883 - CheckMvInternalTables(mv_id). invalid MV internal tables.
I can't find anything on the internet about this so I'm a bit at a loss. Any clues on where i can go with this?

A: Solution:
Set AutoRefresh to ON on the mv (as it defaults to off). Or manually trigger the refresh.


Q: Code is working properly but if data is empty that time validation is not working i have made a code generated random number and save all number in database(that part of code is working) but i have problem in validation without enter any no on view page redirect this url admin_manage_epin.ctp, validation not working
admin_create_epin.ctp(view)

Add E-pin:(No of E-Pin)
<?php echo $this->Form->input('e_pin',array('label'=>false));?>

epins_controllers.php(controller)
public function admin_create_epin(){
 if(!empty($this->data)){
   $limit = $this->data['Epin']['e_pin'];

   for($i=0;$i<$limit;$i++)
     {
     $random = substr(number_format(time() * rand(),0,'',''),0,11)."
";
     $this->data['Epin']['e_pin'] = $random;
     $this->Epin->id =null;
     $this->Epin->save($this->data);
   }

      $this->Session->setFlash("Epin has been added");
      $this->Redirect(array('action'=>'admin_manage_epin'));
   }
 }

epin.php(model)
<?php class Epin extends appModel{
var $name ="Epin";
var $validate = array(
                      'e_pin'=>array(
                        'rule'=>'notEmpty',
                        'message'=>'Please type No of epin'
                      ));
  }
 ?>

i think i have problem in my controller function admin_create_epin
thanks

A: You should probably check if the actual field is empty - since submitting a form will still have an array:
if(!empty($this->data['Epin']['e_pin'])) {

Within your for() loop, you should be using create() and don't set id:
for($i=0;$i<$limit;$i++) {
    $this->Epin->create();
    $random = substr(number_format(time() * rand(),0,'',''),0,11)."
";
    $this->data['Epin']['e_pin'] = $random;
    //...

Your redirect should be lowercase:
$this->redirect(...

It's quite difficult to understand what you're actually asking, but if you're trying to redirect if the form was submitted empty, the redirect should be one more level out:
    }
    $this->Session->setFlash("Epin has been added");
    $this->Redirect(array('action'=>'admin_manage_epin'));
}


Q: Choose a number from a a given pmf in theano Say I have an array p = [ 0.27, 0.23, 0.1, 0.15, 0.2 ,0.05]. Let p be a probability mass function for a Random Variable X.  Now, I am writing a theano code, where I have a p generated at each iteration and  I also have n weight matrices. (Here[n = 6].)
Now, in each iteration I would want to select one of these weight matrices for further propagation. Could someone help out regarding how to write this piece of code. I am not sure I can write the exact code required to enable backpropagation(i.e. have the gradients corrected properly)
Note that all the W_is as well as the enter p are model parameters.

Edit

 W1,W2,W3,W4,W5,W6,x,eps = T.dmatrices("W1","W2","W3","W4","W5","W6","x","eps")

    b1,b2,b3,b4,b5,b6,pi = T.dcols("b1","b2","b3","b4","b5","b6","pi")

   h_encoder = T.tanh(T.dot(W1,x) + b1)

    rng = T.shared_randomstreams.RandomStreams(seed=124)

    i = rng.choice(size=(1,), a=self.num_model, p=T.nnet.softmax(pi))

    mu_encoder = T.dot(W2[i[0]*self.dimZ:(1+i[0])*self.dimZ].nonzero(),h_encoder) + b2[i[0]*self.dimZ:(1+i[0])*self.dimZ].nonzero()

    log_sigma_encoder = (0.5*(T.dot(W3[i[0]*self.dimZ:(1+i[0])*self.dimZ].nonzero(),h_encoder)))+ b3[i[0]*self.dimZ:(1+i[0])*self.dimZ].nonzero()

    z = mu_encoder + T.exp(log_sigma_encoder)*eps`

and my grad vaiables are gradvariables = [W1,W2,W3,W4,W5,b1,b2,b3,b4,b5,pi] Ignore the other variables as they are defined somewhere else. Now, I get the following error

  Traceback (most recent call last):
    File "trainmnist_mixture.py", line 55, in
      encoder.createGradientFunctions()
File "/home/amartya/Variational-Autoencoder/Theano/VariationalAutoencoder_mixture.py", line 118, in createGradientFunctions
      derivatives = T.grad(logp,gradvariables)
File "/usr/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gradient.py", line 543, in grad
      grad_dict, wrt, cost_name)
File "/usr/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gradient.py", line 1273, in _populate_grad_dict
      rval = [access_grad_cache(elem) for elem in wrt]
File "/usr/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gradient.py", line 1233, in access_grad_cache
      term = access_term_cache(node)[idx]
File "/usr/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gradient.py", line 944, in access_term_cache
      output_grads = [access_grad_cache(var) for var in node.outputs]
File "/usr/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gradient.py", line 1243, in access_grad_cache
      term.type.why_null)
theano.gradient.NullTypeGradError: tensor.grad encountered a NaN. This variable is Null because the grad method for input 0 (Subtensor{int64:int64:}.0) of the Nonzero op is mathematically undefined

A: You can use the choice method of a RandomStreams instance. More on random numbers in Theano can be found in the documentation here and here.
Here's an example:
import numpy
import theano
import theano.tensor as tt
import theano.tensor.shared_randomstreams

n = 6
alpha = [1] * n
seed = 1
w = theano.shared(numpy.random.randn(n, 2, 2).astype(theano.config.floatX))
p = theano.shared(numpy.random.dirichlet(alpha).astype(theano.config.floatX))
rng = tt.shared_randomstreams.RandomStreams(seed=seed)
i = rng.choice(size=(1,), a=n, p=p)
f = theano.function([], [p, i, w[i]])
print f()
print f()
print f()
print f()


Q: SSRS-what is the syntax for the Target Server URL in SSRS2008R2 can anyone help me out with the syntax and example for the target server URL in SSRS 2008R2 inorder to deploy my reports??

A: are you deploying to sharepoint or a standalone (native-mode) report server?
http://msdn.microsoft.com/en-us/library/ms155802(v=sql.105).aspx

10.In the TargetServerURL text box, type the URL of the target report server. Before you publish a report, you must set this property to a
  valid report server URL. When publishing to a report server running in
  native mode, use the URL of the virtual directory of the report server
  (for example, http://server/reportserver or
  https://server/reportserver). This is the virtual directory of the
  report server, not Report Manager.
When publishing to a report server running in SharePoint integrated
  mode, use a URL to a SharePoint top-level site or subsite. If you do
  not specify a site, the default top-level site is used (for example,
  http://servername, http://servername/site or
  http://servername/site/subsite).


Q: Mailbox unavailable. The server response was: 5.7.1 Invalid credentials for relay At our office others can use the .NET SMTP client to send email via our Google Apps account.  Using the exact same settings and credentials this does not work on a particular machine.  It seems to be just this one machine with this issue.  I get:
Mailbox unavailable. The server response was: 5.7.1 Invalid credentials for relay

We are all on the same external IP, so it's not

A: Aha!  We found the smoking gun.  Here is what the message actually says:

SmtpException: Mailbox unavailable. The server response was: 5.7.1
  Invalid credentials for relay [ffff:fff:ffff:ffff:ffff:ffff:ffff:ffff]

I've obfuscated the last part, but note that the IP address this appears to come from is an IPV6 address.  Out relay whitelist only includes IPV4 addresses.  So I turned IPV6 off on that machine - because honestly, what is that good for anyway?


Q: Record SSH commands sent to a Mac from Windows I've got a bit of a puzzler - I am an administrator on both a Windows 10 and a Mac Catalina machine.
The Windows machine is currently running software that has a known bug - SSH commands are sent to a Mac by a large piece of .NET Software that is difficult to RE (due more to its size than complexity)  over SSH. The 2 PCs are on the same network.
The SSH commands fail, but I don't know what they are. I would like to record these actions, or at least view them in some way, so I can change the behavior of the receiving end (Mac) to take the correct action (bug workaround).
Here is what I've tried to view the SSH commands:

*

*Run Wireshark (on both sides), try to decode the Diffie-Hellman exchange via SSH keys (I don't know how this works exactly, so I'm fumbling my way through - e.g. I don't know how to use RSA keys to decode the conversation)

*Try Strace - doesn't exist on Mac machines. Alternative option dtruss may work but I don't know the commands and have to bypass SIP.

*Try to log SSH commands by using .bashrc auto-logging - this has now been replaced by .zprofile and .zshrc - this doesn't appear to work, and no history is left in z_history or bash_history. It works when I run interactive Terminal commands though. This may be due to commands being chained to the initial SSH command, e.g. ssh user@host SOMECOMMAND.

*Run ProcMon, see if the commands are in some secret config file. Can't seem to find it.

*Decompile using Reflector and dnSpy - I find some logic on how to transmit SSH commands, but no hard-coded actual commands.

What am I missing? Is there some obvious way to do this that I've overlooked?
I am relatively versed in making things work, so if I have an idea of the best path forward, then I'll focus my attention there. There just seem to be too many options in a large space to know how to proceed..
I've read there are maybe ways to do this via the sshd_config on the SSH host (Mac), but I have no idea which settings would actually work, and apparently Mac does things in a special way.
[Please feel free to move the appropriate StackExchange site, not sure which is best for this]

A: This looks like a typical case for auditing. I've no experience configuring it on Mac OS, therefore the references to some documentation and examples:
https://opensource.apple.com/source/OpenBSM/OpenBSM-21/openbsm/man/
https://krypted.com/mac-os-x/quick-dirty-openbsm-auditing-macos/
It looks like a type of auditd is also available:
https://opensource.apple.com/source/system_cmds/system_cmds-336.10/auditd.tproj/auditd.8.auto.html
Enabling auditing, and parsing logs should work and contain all commands that had been executed on the destination system.
E.g knowing the ssh user you can start with audit_user and configure ex syscalls to be logged for this specific user. In case the user is changed during the session it might not capture all, but at least up to the user switch command.
/etc/security/audit_user
yoursshuser:ad,ex:no
For a quick start try something like auditreduce -u <userid> -c ex /dev/auditpipe | praudit
This should provide live logs from the users exec syscalls.
Suggest to forget any approaches through shell histories and the like, as you don't know if a shell is used. E.g. a script is copied over and shell is just switched. Interesting are ex syscalls, these contain all executions, no matter how these are triggered.

EDIT FOR MAC: Specifically for Mac (with System Integrity Protection [SIP] on, e.g. Catalina/El Capitan/etc), OpenBSM will not record bash commands that don't result in actual execution of a program.
If you would like to record incorrect commands (e.g. ASDFASDFASDF), then the best option appears to be using dtruss - dtrace may also work, but the difficulty in getting it to work properly appears to be higher.
First, disable SIP, then run the following to record all system calls for bash processes:
sudo dtruss -n bash

Incorrect commands will be "searched for" in various environment locations, in the stat64 calls. E.g. stat64("/usr/bin/ASDFASDFASDF",...)

A: If you have access to the shell where the commands are executed you could try to redirect the file descriptors in the shell's profile to a logfile. Or turn on history. Or use sysdig.


Q: How to draw a Polygon on MapView, fill it, and put a onTouch Event on it Is it possible to set an EventListener in a drawn Polygon in a osmdroid MapView Overlay ? I would like to print on a Overlay and after touching it I would like to change its color or handle data behind a Polygon.
For Example:
Poly1: ID = 1337, P1(0,0),P2(1,0),......,Pn(0,0)
Poly2: ID = 42 , P1(10,7),P2(18,39),......,Pn(10,7)
After touching in Poly1 I want to know aha ID 1337 is pressed. An want to change its color.
How could I implement such a behavior ?

A: Use this documentation to draw the polygons
Use this to listen for map clicks
Use this to determine if a touch is inside one of the polygons
I'm not sure that geometry library can run on android, so feel free to replace the third component.
EDIT:
Misread the question and associated it with google maps, sorry.

A: Here is how to draw and fill a polygon (rectangle example):
ArrayList bgRectPoints = new ArrayList<>();
    GeoPoint pt1 = new GeoPoint(-15.953548, 126.036911);
    bgRectPoints.add(pt1);
    GeoPoint pt2 = pt1.destinationPoint(10000, 0);
    bgRectPoints.add(pt2);
    GeoPoint pt3 = pt2.destinationPoint(10000, 90);
    bgRectPoints.add(pt3);
    GeoPoint pt4 = pt3.destinationPoint(10000, 180);
    bgRectPoints.add(pt4);
    bgRectPoints.add(pt1);

    Polygon polygon = new Polygon();
    polygon.setPoints(bgRectPoints);
    polygon.setFillColor(Color.BLACK);

    mapView.getOverlays().add(polygon);

To receive touch/Tap initialize polygon like this:
    Polygon polygon = new Polygon(){
        @Override
        public boolean onSingleTapConfirmed(MotionEvent event, MapView mapView) {
            Toast.makeText(context, "Polygon clicked!",Toast.LENGTH_SHORT).show();
            return super.onSingleTapConfirmed(event, mapView);
        }
    };

More can be found here


Q: Why does my div dont go fullscreen? why does my button expand down in height and not equally to the top and bottom so it would cover the fullscreen?
And the Border lines should stop at the size of the parent div... I cant make it work.. do you have any ideas? (to make the doggies disappear :DD)

var main = function(){
    $('#Music').click(function(){
        $('#soundcloud').animate({
            bottom:'0px'
        },200);

        $('body').animate({
            bottom:'285px'
        }, 200);

    });

    $('#Home').click(function(){
        $('#title').css("-webkit-text-fill-color", "transparent")
        $('.dick').css("background-image", "url(RegenBack.jpg)")
        $('#soundcloud').animate({
            bottom:'-285px'
        },200);

        $('body').animate({
            bottom:'0px'
            },200);
    });

    $('#button').mouseup(function () {
        var d = {};
        $('#button').removeClass('shadow')
        $('#button').find('p').removeClass('textshadow')
        $('#button').find('p').css("visibility", "hidden")
        $('#button').css("z-index", "999")
        $('#button').removeClass('shadow')
        $('#button').animate({
            width: '100%'
        },500,function() {
            $('#button').animate({
                height: '100%'
            }, 500);
        });

    });

    $('#button').mousedown(function() {
        $('#button').find('p').addClass('textshadow')
        $('#button').addClass('shadow')

    });

};

$(document).ready(main);
.menu{
    overflow: hidden;
    margin-top: 50px;
}

#button p{
    margin-left: auto;
    margin-right: auto;
    margin-top: -15px;
    font-size: 100px;
    font-family: mySecondFont;
    -webkit-user-select: none; /* Chrome/Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+ */
}
#button{
    background: url(https://pbs.twimg.com/profile_images/378800000532546226/dbe5f0727b69487016ffd67a6689e75a.jpeg) fixed;
    width: 622px;
    height: 148px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 200px;
    margin-bottom: auto;
    cursor: pointer;
    border-style: solid;
    border-width: 10px 10px 10px 10px;
    border-color: white black black white;
    border-radius: 10px;
    -webkit-box-shadow: inset -3px -3px 0px 0px rgba(255,255,255,1);
}

.textshadow{
    background-color: #000000;
    color: transparent;
    text-shadow: 0px 2px 3px rgba(255,255,255,0.5);
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
}

.shadow {
    -webkit-box-shadow: inset 9px 9px 15px 0px rgba(0,0,0,0.75).inset -2px -2px 15px 0px rgba(255,255,255,1) !important;
    -moz-box-shadow: inset 9px 9px 15px 0px rgba(0,0,0,0.75), inset -2px -2px 15px 0px rgba(255,255,255,1) !important;
    box-shadow: inset 9px 9px 15px 0px rgba(0,0,0,0.75), inset -2px -2px 15px 0px rgba(255,255,255,1) !important;
}

#soundcloud{
    bottom: -200px;  /* start off behind the scenes */
    height: 200px;
    position: fixed;
    width: 100%;
    background-color: #ffffff;
}

div div div div  p{
    border: 5px solid white;
    text-align: center;
    color: #ffffff;
    font-size: 70px;
    font-family: myFirstFont;
    text-decoration: none;
}

div div div div p:hover{
    cursor: pointer;
    border-color: grey;
    text-decoration: none;
    color: grey;
}

#Music {
    margin-left: auto;
    margin-right: auto;
    width: 70%;
}

#Home {
    margin-left: auto;
    margin-right: auto;
    width: 70%;
}

#About {
    margin-left: auto;
    margin-right: auto;
    width: 70%;
}

#Media {
    margin-left: auto;
    margin-right: auto;
    width: 70%;
}

.dick {
    position: absolute;
    height: 100%;
    width: 100%;
    background-image: url(http://www.prevention.com/sites/default/files/imagecache/slideshow_display/dog-dogue-de-bordeaux-puppy-410x290.jpg);
}

#title {
    -webkit-user-select: none; /* Chrome/Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+ */
    cursor: default;
    overflow: hidden;
    float: inherit;
    background: url(Textur1.jpg) no-repeat fixed;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: mySecondFont;
    font-size: 200px;
    margin-top: 50px;
}

div p{
    text-align: center;
    font-size: 70px;
    color: #ffffff;
}

@font-face {
    font-family: myFirstFont;
    src: url(/Fonts/Bask/BaskOldFace.woff);
}
@font-face {
    font-family: mySecondFont;
    src: url(Fonts/Script/ScriptMTBold.woff);
}

body, hmtl{
    height: 100%;
    width: 100%;
}

<!DOCTYPE html>

        <meta charset="UTF-8">
        <title>Bolle | Music</title>
        <link href="bootstrap-3.3.2-dist/css/bootstrap.css" rel="stylesheet">
        <link href="Bolle%20Music.css" rel="stylesheet">

Get Happy

Im thankful for any tips :)
Greetings
Bolle

A: You have a margin-top property set to 200px on the button. That property stays after the button expands.


Q: combined coffee and js development with Gulp Using Gulp to streamline my build process on a per-save basis, while eliminating the need for "temp" files is my goal (and why I chose to use Gulp over Grunt)
I've recently discovered that, apparently, the coffeescript compiler cannot handle dealing with basic Javascript as a source
So this, errors out:
gulp.task('scripts', function() {

    var stream =
            gulp.src([
                "bower_components/d3/d3.js",
                "bower_components/angular/angular.js",
                "bower_components/foundation/js/foundation.js",
                "public-dev/scripts/app.js",
                "public-dev/scripts/**/*.js",
                "public-dev/scripts/**/*.coffee"
            ])
                .pipe(coffee())
                .pipe(concat('compiled.js'))
                .pipe(gulp.dest('./public/scripts'))
        ;

    return stream;
});

This produces the output/errpr:
[11:58:51] Starting 'scripts'...

events.js:72
        throw er; // Unhandled 'error' event
              ^
/var/www/node.fortiguard.dev/bower_components/d3/d3.js:1:2: error: reserved word "function"
!function() {
 ^

How should I set this up, without again creating any temp files?
What I liked about the LESS compiler, is that it can still be fed straight CSS files and it'd be fine. I was kind of hoping the Coffee compiler would react the same way

A: I use gulp-add-src to do that.
var gulp = require('gulp'),
    coffee = require('gulp-coffee'),
    concat = require('gulp-concat'),
    addsrc = require('gulp-add-src');

// Scripts
gulp.task('coffee', function () {
  return gulp.src('src/coffee/**/*.coffee')
    .pipe(coffee())
    .pipe(addsrc('src/coffee/lib/*.js'))
    .pipe(concat('compiled.js'))
    .pipe(gulp.dest('dist'));
});

A: Sadly, it doesn't. What you can do, is using the underlying event-stream's merge method. Then you'll have one pipeline for the coffee files that gets compiled and one for the javascript side.
Here is an example Gulpfile.coffee:
coffee = require 'gulp-coffee'
es     = require 'event-stream'

gulp.task 'scripts', () ->
  es.merge(
    gulp.src(["public-dev/app.js", "public-dev/scripts/**/*.js"]) # ...
    gulp.src("public-dev/**/*.coffee").pipe coffee()
    )
  .pipe concat 'all.js'
  .pipe gulp.dest "build"

A: I marked Patrick J. S.'s answer as "Correct" becuase in reality, this is exactly what I needed to do.
That said, "event-stream" isn't what I ended up going with, simply because I needed to preserve my dependency structure of files, and event-stream's merge() method does not preserver order nor does it have options to.
Instead I opted for a package called streamqueue, which does preserve order of glob. Probably slower, but order matters in my app unfortunately.  In the future I will try to be as modular as possible.


Q: No rational solutions of a system of equations
Please show that there does not exist $(a,b,c)\in\mathbb{Q}^3$ such that
  \begin{matrix}
a^2b+2b^2c+2ac^2=0\\
a^2c+ab^2+2bc^2=0\\
a^3+2b^3+4c^3+12abc=3.
\end{matrix}

I'm able to show that this is true iff $[\mathbb{Q}(\sqrt[3]2,\sqrt[3]3):\mathbb{Q}]=9$.

A: In order to prove that there is no $(a,b,c)\in\mathbb{Q}^3$ satisfying the three equations, assume that one of $a,b,c$ is non-zero. Let's say that $a\neq 0$. Set $x=b/a$ and $y=c/a$ and divide the first two equations by $a^3$. Then we get $x+2x^2y+2y^2=0$ and $y+x^2+2xy^2=0$. Multiply the first equation by $x$ and substract from the second gives us that $2x^3y=y$ $\Leftrightarrow$ $y(2x^3-1)=0$. Since $x\in\mathbb Q$ we can not have $2x^3-1=0$, so $y=0$. It follows that $c=0$, and so on.

A: Just to add about why $|\mathbb{Q}(\sqrt[3]{2},\sqrt[3]{3}):\mathbb{Q}|=9$, there are at least a couple of ways to go about approaching it.
Showing that a basis consists of $9$ elements.
You can make an intuitive guess about what a possible basis would be. Starting with $1,\sqrt[3]{2},\sqrt[3]{3},\sqrt[3]{2}^2,\sqrt[3]{3}^2$, a guess for the other $4$ basis elements would be $\sqrt[3]{2}\sqrt[3]{3}=\sqrt[3]{6}$, $\sqrt[3]{2}\sqrt[3]{3}^2$, $\sqrt[3]{2}^2\sqrt[3]{3}$, and $\sqrt[3]{2}^2\sqrt[3]{3}^2=\sqrt[3]{6}^2$. It's then just a case of showing that these are linearly independent and spanning.
Showing that $\mathbb{Q}(\sqrt[3]{2},\sqrt[3]{3})=\mathbb{Q}(\alpha)$, where the minimal polynomial of $\alpha$ has degree $9$.
You might be familiar with the fact that $\mathbb{Q}(\sqrt{2},\sqrt{3})=\mathbb{Q}(\sqrt{2}+\sqrt{3})$. In this case, it also happens that $\mathbb{Q}(\sqrt[3]{2},\sqrt[3]{3})=\mathbb{Q}(\sqrt[3]{2}+\sqrt[3]{3})$, with minimal polynomial $x^9-15x^6-87x^3-125$.


Q: Move list paging buttons Is there a way to relocate the page navigation buttons from the bottom of the list to the top?  It is a hassle to scroll through 30+ items just to get to the buttons.
I read related posts that suggested using jQuery and JS code in a CEWP OR doing something with the XSLT.
I'm looking to place the page navigator buttons next to the search bar.  The imgur link shows the exact location I'm trying to put the buttons in.
http://imgur.com/a/BaoZY
How could I get the paging buttons there?  And is there a way to still keep buttons at the bottom of the list while placing new buttons at the top?

A: Using jQuery you can clone the Navigation Bar as below. Just run the code after page load
jQuery('#scriptPagingWPQ1').clone().appendTo('.ms-csrlistview-controldiv');

The problem with this is it stops asynchronous pagination and uses a full page refresh as it moves between pages.
Another option is to use JSLink and attach it to the list view webpart. Then create your own navigation.


Q: oracle apex tabular form validation How to add validation to a newly created row in tabular form ?. in normal method when I add validation to a tabular form column it applies to the existing records but not for newly created rows which are added after page load.


Q: PHP - How Can I make this array work? So I've got an array, which gets random images and display them with certain text. Unfortunately, the text won't appear and the if it does, the hyperlink doesn't appear UNDER  the image. Please someone help!!
<?php
define('RANDOM_IMAGES_COUNT', 3);
define('RANDOM_IMAGES_FORMAT', ' alt="%s" title="%3$s"   style="margin-right:10px">');

#------------------------------------------------------------------------------

$images = array (
    array ( 'title' => 'Test 2', 'src' => 'pic2.jpg', 'href' => 'Click Me' ),
    array ( 'title' => 'Test 3', 'src' => 'pic3.jpg', 'href' => 'Click Me' ),
    array ( 'title' => 'Test 4', 'src' => 'pic4.jpg', 'href' => 'Click Me' )
);

#------------------------------------------------------------------------------

if ( count($images) < RANDOM_IMAGES_COUNT ) {
    trigger_error('Not enough images given', E_USER_WARNING);
    exit;
}

#------------------------------------------------------------------------------

for ($i = 0; $i < RANDOM_IMAGES_COUNT; $i++) {
    shuffle($images);

    $tmp = array_shift($images);
    printf( RANDOM_IMAGES_FORMAT, $tmp['src'],$tmp['href'], $tmp['title'] );
}
?>

A: For the positioning of your link under the image, you'd have to work on your CSS. For proper working of the code sample, make following changes:

*

*Update RANDOM_IMAGES_FORMAT to
define('RANDOM_IMAGES_FORMAT', 'Click Me');

*Change the array to:
$images = array (
    array ( 'title' => 'Test 2', 'src' => 'pic2.jpg', 'href' => 'http://mylink.com/path/' ),
    array ( 'title' => 'Test 3', 'src' => 'pic3.jpg', 'href' => 'http://mylink.com/path/' ),
    array ( 'title' => 'Test 4', 'src' => 'pic4.jpg', 'href' => 'http://mylink.com/path/' )
);

*Use printf like this:
printf( RANDOM_IMAGES_FORMAT, $tmp['src'], $tmp['href'], $tmp['title'], $tmp['title'] );

A: Your code have multiple issues:
Constant RANDOM_IMAGES_FORMAT is poorly formatted as HTML it should look like:
define('RANDOM_IMAGES_FORMAT', '');

As for that, the order of printf arguments should be reordered, because we have modified displaying them in RANDOM_IMAGES_FORMAT:
printf( RANDOM_IMAGES_FORMAT, $tmp['src'],$tmp['href'], $tmp['title'] );

In your $images array, links should be only URL, not full links, as you defined then already in RANDOM_IMAGES_FORMAT.
Full code you presented should look like this:
define('RANDOM_IMAGES_COUNT', 3);
define('RANDOM_IMAGES_FORMAT', '');

$images = array (
    array ( 'title' => 'Test 2', 'src' => 'pic2.jpg', 'href' => 'http://mylink.com/path/' ),
    array ( 'title' => 'Test 3', 'src' => 'pic3.jpg', 'href' => 'http://mylink.com/path/' ),
    array ( 'title' => 'Test 4', 'src' => 'pic4.jpg', 'href' => 'http://mylink.com/path/' )
);

if ( count($images) < RANDOM_IMAGES_COUNT ) {
    trigger_error('Not enough images given', E_USER_WARNING);
    exit;
}

for ($i = 0; $i < RANDOM_IMAGES_COUNT; $i++) {
    shuffle($images);

    $tmp = array_shift($images);
    printf( RANDOM_IMAGES_FORMAT, $tmp['src'],$tmp['href'], $tmp['title'] );
}

A:  alt="%s" title="%3$s"   style="margin-right:10px">

do not close the tag a after href="%s"
and put img inside of a tag, like this:

A: Check
 define('RANDOM_IMAGES_FORMAT', ' alt="%s" title="%3$s"   style="margin-right:10px">');

and
 array ( 'title' => 'Test 2', 'src' => 'pic2.jpg', 'href' => 'Click Me' ),

their is a problem with href try to give only link in href


Q: Angular 14 mat date picker won't work and display properly I have trouble with material date picker.
I've imported this modules:
MatFormFieldModule,
MatInputModule,
MatDatepickerModule,
MatNativeDateModule
but no luck.
Only code that i have is in html template:
<div>
<mat-form-field appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput >
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>

Any suggestion is welcome. Thank you!
My ng version:
Angular CLI: 14.2.8
Node: 18.12.1 (Unsupported)
Package Manager: npm 8.19.2
OS: darwin x64

Angular: 14.2.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.8
@angular-devkit/build-angular   14.2.8
@angular-devkit/core            14.2.8
@angular-devkit/schematics      14.2.8
@angular/cli                    14.2.8
@angular/material               7.0.0
@schematics/angular             14.2.8
rxjs                            7.5.7
typescript                      4.7.4


Q: What is the most efficient/elegant way to parse a flat table into a tree? Assume you have a flat table that stores an ordered tree hierarchy:
Id   Name         ParentId   Order
 1   'Node 1'            0      10
 2   'Node 1.1'          1      10
 3   'Node 2'            0      20
 4   'Node 1.1.1'        2      10
 5   'Node 2.1'          3      10
 6   'Node 1.2'          1      20

Here's a diagram, where we have [id] Name.  Root node 0 is fictional.

                       [0] ROOT
                          /    \
              [1] Node 1          [3] Node 2
              /       \                   \
    [2] Node 1.1     [6] Node 1.2      [5] Node 2.1
          /
 [4] Node 1.1.1

What minimalistic approach would you use to output that to HTML (or text, for that matter) as a correctly ordered, correctly indented tree?
Assume further you only have basic data structures (arrays and hashmaps), no fancy objects with parent/children references, no ORM, no framework, just your two hands. The table is represented as a result set, which can be accessed randomly.
Pseudo code or plain English is okay, this is purely a conceptional question.
Bonus question: Is there a fundamentally better way to store a tree structure like this in a RDBMS?

EDITS AND ADDITIONS
To answer one commenter's (Mark Bessey's) question: A root node is not necessary, because it is never going to be displayed anyway. ParentId = 0 is the convention to express "these are top level". The Order column defines how nodes with the same parent are going to be sorted.
The "result set" I spoke of can be pictured as an array of hashmaps (to stay in that terminology). For my example was meant to be already there. Some answers go the extra mile and construct it first, but thats okay.
The tree can be arbitrarily deep. Each node can have N children. I did not exactly have a "millions of entries" tree in mind, though.
Don't mistake my choice of node naming ('Node 1.1.1') for something to rely on. The nodes could equally well be called 'Frank' or 'Bob', no naming structure is implied, this was merely to make it readable.
I have posted my own solution so you guys can pull it to pieces.

A: There are really good solutions which exploit the internal btree representation of sql indices. This is based on some great research done back around 1998.
Here is an example table (in mysql).
CREATE TABLE `node` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `tw` int(10) unsigned NOT NULL,
  `pa` int(10) unsigned DEFAULT NULL,
  `sz` int(10) unsigned DEFAULT NULL,
  `nc` int(11) GENERATED ALWAYS AS (tw+sz) STORED,
  PRIMARY KEY (`id`),
  KEY `node_tw_index` (`tw`),
  KEY `node_pa_index` (`pa`),
  KEY `node_nc_index` (`nc`),
  CONSTRAINT `node_pa_fk` FOREIGN KEY (`pa`) REFERENCES `node` (`tw`) ON DELETE CASCADE
)

The only fields necessary for the tree representation are:

*

*tw: The Left to Right DFS Pre-order index, where root = 1.

*pa: The reference (using tw) to the parent node, root has null.

*sz: The size of the node's branch including itself.

*nc: is used as syntactic sugar. it is tw+sz and represents the tw of the node's "next child".

Here is an example 24 node population, ordered by tw:
+-----+---------+----+------+------+------+
| id  | name    | tw | pa   | sz   | nc   |
+-----+---------+----+------+------+------+
|   1 | Root    |  1 | NULL |   24 |   25 |
|   2 | A       |  2 |    1 |   14 |   16 |
|   3 | AA      |  3 |    2 |    1 |    4 |
|   4 | AB      |  4 |    2 |    7 |   11 |
|   5 | ABA     |  5 |    4 |    1 |    6 |
|   6 | ABB     |  6 |    4 |    3 |    9 |
|   7 | ABBA    |  7 |    6 |    1 |    8 |
|   8 | ABBB    |  8 |    6 |    1 |    9 |
|   9 | ABC     |  9 |    4 |    2 |   11 |
|  10 | ABCD    | 10 |    9 |    1 |   11 |
|  11 | AC      | 11 |    2 |    4 |   15 |
|  12 | ACA     | 12 |   11 |    2 |   14 |
|  13 | ACAA    | 13 |   12 |    1 |   14 |
|  14 | ACB     | 14 |   11 |    1 |   15 |
|  15 | AD      | 15 |    2 |    1 |   16 |
|  16 | B       | 16 |    1 |    1 |   17 |
|  17 | C       | 17 |    1 |    6 |   23 |
| 359 | C0      | 18 |   17 |    5 |   23 |
| 360 | C1      | 19 |   18 |    4 |   23 |
| 361 | C2(res) | 20 |   19 |    3 |   23 |
| 362 | C3      | 21 |   20 |    2 |   23 |
| 363 | C4      | 22 |   21 |    1 |   23 |
|  18 | D       | 23 |    1 |    1 |   24 |
|  19 | E       | 24 |    1 |    1 |   25 |
+-----+---------+----+------+------+------+

Every tree result can be done non-recursively.
For instance, to get a list of ancestors of node at tw='22'
Ancestors
select anc.* from node me,node anc
where me.tw=22 and anc.nc >= me.tw and anc.tw <= me.tw
order by anc.tw;
+-----+---------+----+------+------+------+
| id  | name    | tw | pa   | sz   | nc   |
+-----+---------+----+------+------+------+
|   1 | Root    |  1 | NULL |   24 |   25 |
|  17 | C       | 17 |    1 |    6 |   23 |
| 359 | C0      | 18 |   17 |    5 |   23 |
| 360 | C1      | 19 |   18 |    4 |   23 |
| 361 | C2(res) | 20 |   19 |    3 |   23 |
| 362 | C3      | 21 |   20 |    2 |   23 |
| 363 | C4      | 22 |   21 |    1 |   23 |
+-----+---------+----+------+------+------+

Siblings and children are trivial - just use pa field ordering by tw.
Descendants
For example the set (branch) of nodes that are rooted at tw = 17.
select des.* from node me,node des
where me.tw=17 and des.tw < me.nc and des.tw >= me.tw
order by des.tw;
+-----+---------+----+------+------+------+
| id  | name    | tw | pa   | sz   | nc   |
+-----+---------+----+------+------+------+
|  17 | C       | 17 |    1 |    6 |   23 |
| 359 | C0      | 18 |   17 |    5 |   23 |
| 360 | C1      | 19 |   18 |    4 |   23 |
| 361 | C2(res) | 20 |   19 |    3 |   23 |
| 362 | C3      | 21 |   20 |    2 |   23 |
| 363 | C4      | 22 |   21 |    1 |   23 |
+-----+---------+----+------+------+------+

Additional Notes
This methodology is extremely useful for when there are a far greater number of reads than there are inserts or updates.
Because the insertion, movement, or updating of a node in the tree requires the tree to be adjusted, it is necessary to lock the table before commencing with the action.
The insertion/deletion cost is high because the tw index and sz (branch size) values will need to be updated on all the nodes after the insertion point, and for all ancestors respectively.
Branch moving involves moving the tw value of the branch out of range, so it is also necessary to disable foreign key constraints when moving a branch.  There are, essentially four queries required to move a branch:

*

*Move the branch out of range.

*Close the gap that it left. (the remaining tree is now normalised).

*Open the gap where it will go to.

*Move the branch into it's new position.

Adjust Tree Queries
The opening/closing of gaps in the tree is an important sub-function used by create/update/delete methods, so I include it here.
We need two parameters - a flag representing whether or not we are downsizing or upsizing, and the node's tw index. So, for example tw=18 (which has a branch size of 5). Let's assume that we are downsizing (removing tw) - this means that we are using '-' instead of '+' in the updates of the following example.
We first use a (slightly altered) ancestor function to update the sz value.
update node me, node anc set anc.sz = anc.sz - me.sz from
node me, node anc where me.tw=18
and ((anc.nc >= me.tw and anc.tw < me.pa) or (anc.tw=me.pa));

Then we need to adjust the tw for those whose tw is higher than the branch to be removed.
update node me, node anc set anc.tw = anc.tw - me.sz from
node me, node anc where me.tw=18 and anc.tw >= me.tw;

Then we need to adjust the parent for those whose pa's tw is higher than the branch to be removed.
update node me, node anc set anc.pa = anc.pa - me.sz from
node me, node anc where me.tw=18 and anc.pa >= me.tw;

A: Well given the choice, I'd be using objects. I'd create an object for each record where each object has a children collection and store them all in an assoc array (/hashtable) where the Id is the key. And blitz through the collection once, adding the children to the relevant children fields. Simple.
But because you're being no fun by restricting use of some good OOP, I'd probably iterate based on:
function PrintLine(int pID, int level)
    foreach record where ParentID == pID
        print level*tabs + record-data
        PrintLine(record.ID, level + 1)

PrintLine(0, 0)

Edit: this is similar to a couple of other entries, but I think it's slightly cleaner. One thing I'll add: this is extremely SQL-intensive. It's nasty. If you have the choice, go the OOP route.

A: If you use nested sets (sometimes referred to as Modified Pre-order Tree Traversal) you can extract the entire tree structure or any subtree within it in tree order with a single query, at the cost of inserts being more expensive, as you need to manage columns which describe an in-order path through thee tree structure.
For django-mptt, I used a structure like this:

id  parent_id  tree_id  level  lft  rght
--  ---------  -------  -----  ---  ----
 1       null        1      0    1    14
 2          1        1      1    2     7
 3          2        1      2    3     4
 4          2        1      2    5     6
 5          1        1      1    8    13
 6          5        1      2    9    10
 7          5        1      2    11   12

Which describes a tree which looks like this (with id representing each item):

 1
 +-- 2
 |   +-- 3
 |   +-- 4
 |
 +-- 5
     +-- 6
     +-- 7

Or, as a nested set diagram which makes it more obvious how the lft and rght values work:

 __________________________________________________________________________
|  Root 1                                                                  |
|   ________________________________    ________________________________   |
|  |  Child 1.1                     |  |  Child 1.2                     |  |
|  |   ___________    ___________   |  |   ___________    ___________   |  |
|  |  |  C 1.1.1  |  |  C 1.1.2  |  |  |  |  C 1.2.1  |  |  C 1.2.2  |  |  |
1  2  3___________4  5___________6  7  8  9___________10 11__________12 13 14
|  |________________________________|  |________________________________|  |
|__________________________________________________________________________|

As you can see, to get the entire subtree for a given node, in tree order, you simply have to select all rows which have lft and rght values between its lft and rght values. It's also simple to retrieve the tree of ancestors for a given node.
The level column is a bit of denormalisation for convenience more than anything and the tree_id column allows you to restart the lft and rght numbering for each top-level node, which reduces the number of columns affected by inserts, moves and deletions, as the lft and rght columns have to be adjusted accordingly when these operations take place in order to create or close gaps. I made some development notes at the time when I was trying to wrap my head around the queries required for each operation.
In terms of actually working with this data to display a tree, I created a tree_item_iterator utility function which, for each node, should give you sufficient information to generate whatever kind of display you want.
More info about MPTT:

*

*Trees in SQL

*Storing Hierarchical Data in a Database

*Managing Hierarchical Data in MySQL

A: Now that MySQL 8.0 supports recursive queries, we can say that all popular SQL databases support recursive queries in standard syntax.
WITH RECURSIVE MyTree AS (
    SELECT * FROM MyTable WHERE ParentId IS NULL
    UNION ALL
    SELECT m.* FROM MyTABLE AS m JOIN MyTree AS t ON m.ParentId = t.Id
)
SELECT * FROM MyTree;

I tested recursive queries in MySQL 8.0 in my presentation Recursive Query Throwdown in 2017.
Below is my original answer from 2008:

There are several ways to store tree-structured data in a relational database.  What you show in your example uses two methods:

*

*Adjacency List (the "parent" column) and

*Path Enumeration (the dotted-numbers in your name column).

Another solution is called Nested Sets, and it can be stored in the same table too.  Read "Trees and Hierarchies in SQL for Smarties" by Joe Celko for a lot more information on these designs.
I usually prefer a design called Closure Table (aka "Adjacency Relation") for storing tree-structured data.  It requires another table, but then querying trees is pretty easy.
I cover Closure Table in my presentation Models for Hierarchical Data with SQL and PHP and in my book SQL Antipatterns Volume 1: Avoiding the Pitfalls of Database Programming.
CREATE TABLE ClosureTable (
  ancestor_id   INT NOT NULL REFERENCES FlatTable(id),
  descendant_id INT NOT NULL REFERENCES FlatTable(id),
  PRIMARY KEY (ancestor_id, descendant_id)
);

Store all paths in the Closure Table, where there is a direct ancestry from one node to another.  Include a row for each node to reference itself.  For example, using the data set you showed in your question:
INSERT INTO ClosureTable (ancestor_id, descendant_id) VALUES
  (1,1), (1,2), (1,4), (1,6),
  (2,2), (2,4),
  (3,3), (3,5),
  (4,4),
  (5,5),
  (6,6);

Now you can get a tree starting at node 1 like this:
SELECT f.*
FROM FlatTable f
  JOIN ClosureTable a ON (f.id = a.descendant_id)
WHERE a.ancestor_id = 1;

The output (in MySQL client) looks like the following:
+----+
| id |
+----+
|  1 |
|  2 |
|  4 |
|  6 |
+----+

In other words, nodes 3 and 5 are excluded, because they're part of a separate hierarchy, not descending from node 1.

Re: comment from e-satis about immediate children (or immediate parent).  You can add a "path_length" column to the ClosureTable to make it easier to query specifically for an immediate child or parent (or any other distance).
INSERT INTO ClosureTable (ancestor_id, descendant_id, path_length) VALUES
  (1,1,0), (1,2,1), (1,4,2), (1,6,1),
  (2,2,0), (2,4,1),
  (3,3,0), (3,5,1),
  (4,4,0),
  (5,5,0),
  (6,6,0);

Then you can add a term in your search for querying the immediate children of a given node.  These are descendants whose path_length is 1.
SELECT f.*
FROM FlatTable f
  JOIN ClosureTable a ON (f.id = a.descendant_id)
WHERE a.ancestor_id = 1
  AND path_length = 1;

+----+
| id |
+----+
|  2 |
|  6 |
+----+

Re comment from @ashraf: "How about sorting the whole tree [by name]?"
Here's an example query to return all nodes that are descendants of node 1, join them to the FlatTable that contains other node attributes such as name, and sort by the name.
SELECT f.name
FROM FlatTable f
JOIN ClosureTable a ON (f.id = a.descendant_id)
WHERE a.ancestor_id = 1
ORDER BY f.name;

Re comment from @Nate:
SELECT f.name, GROUP_CONCAT(b.ancestor_id order by b.path_length desc) AS breadcrumbs
FROM FlatTable f
JOIN ClosureTable a ON (f.id = a.descendant_id)
JOIN ClosureTable b ON (b.descendant_id = a.descendant_id)
WHERE a.ancestor_id = 1
GROUP BY a.descendant_id
ORDER BY f.name

+------------+-------------+
| name       | breadcrumbs |
+------------+-------------+
| Node 1     | 1           |
| Node 1.1   | 1,2         |
| Node 1.1.1 | 1,2,4       |
| Node 1.2   | 1,6         |
+------------+-------------+

A user suggested an edit today. SO moderators approved the edit, but I am reversing it.
The edit suggested that the ORDER BY in the last query above should be ORDER BY b.path_length, f.name, presumably to make sure the ordering matches the hierarchy. But this doesn't work, because it would order "Node 1.1.1" after "Node 1.2".
If you want the ordering to match the hierarchy in a sensible way, that is possible, but not simply by ordering by the path length. For example, see my answer to MySQL Closure Table hierarchical database - How to pull information out in the correct order.

A: This was written quickly, and is neither pretty nor efficient (plus it autoboxes alot, converting between int and Integer is annoying!), but it works.
It probably breaks the rules since I'm creating my own objects but hey I'm doing this as a diversion from real work :)
This also assumes that the resultSet/table is completely read into some sort of structure before you start building Nodes, which wouldn't be the best solution if you have hundreds of thousands of rows.
public class Node {

    private Node parent = null;

    private List<Node> children;

    private String name;

    private int id = -1;

    public Node(Node parent, int id, String name) {
        this.parent = parent;
        this.children = new ArrayList<Node>();
        this.name = name;
        this.id = id;
    }

    public int getId() {
        return this.id;
    }

    public String getName() {
        return this.name;
    }

    public void addChild(Node child) {
        children.add(child);
    }

    public List<Node> getChildren() {
        return children;
    }

    public boolean isRoot() {
        return (this.parent == null);
    }

    @Override
    public String toString() {
        return "id=" + id + ", name=" + name + ", parent=" + parent;
    }
}

public class NodeBuilder {

    public static Node build(List<Map<String, String>> input) {

        // maps id of a node to it's Node object
        Map<Integer, Node> nodeMap = new HashMap<Integer, Node>();

        // maps id of a node to the id of it's parent
        Map<Integer, Integer> childParentMap = new HashMap<Integer, Integer>();

        // create special 'root' Node with id=0
        Node root = new Node(null, 0, "root");
        nodeMap.put(root.getId(), root);

        // iterate thru the input
        for (Map<String, String> map : input) {

            // expect each Map to have keys for "id", "name", "parent" ... a
            // real implementation would read from a SQL object or resultset
            int id = Integer.parseInt(map.get("id"));
            String name = map.get("name");
            int parent = Integer.parseInt(map.get("parent"));

            Node node = new Node(null, id, name);
            nodeMap.put(id, node);

            childParentMap.put(id, parent);
        }

        // now that each Node is created, setup the child-parent relationships
        for (Map.Entry<Integer, Integer> entry : childParentMap.entrySet()) {
            int nodeId = entry.getKey();
            int parentId = entry.getValue();

            Node child = nodeMap.get(nodeId);
            Node parent = nodeMap.get(parentId);
            parent.addChild(child);
        }

        return root;
    }
}

public class NodePrinter {

    static void printRootNode(Node root) {
        printNodes(root, 0);
    }

    static void printNodes(Node node, int indentLevel) {

        printNode(node, indentLevel);
        // recurse
        for (Node child : node.getChildren()) {
            printNodes(child, indentLevel + 1);
        }
    }

    static void printNode(Node node, int indentLevel) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < indentLevel; i++) {
            sb.append("\t");
        }
        sb.append(node);

        System.out.println(sb.toString());
    }

    public static void main(String[] args) {

        // setup dummy data
        List<Map<String, String>> resultSet = new ArrayList<Map<String, String>>();
        resultSet.add(newMap("1", "Node 1", "0"));
        resultSet.add(newMap("2", "Node 1.1", "1"));
        resultSet.add(newMap("3", "Node 2", "0"));
        resultSet.add(newMap("4", "Node 1.1.1", "2"));
        resultSet.add(newMap("5", "Node 2.1", "3"));
        resultSet.add(newMap("6", "Node 1.2", "1"));

        Node root = NodeBuilder.build(resultSet);
        printRootNode(root);

    }

    //convenience method for creating our dummy data
    private static Map<String, String> newMap(String id, String name, String parentId) {
        Map<String, String> row = new HashMap<String, String>();
        row.put("id", id);
        row.put("name", name);
        row.put("parent", parentId);
        return row;
    }
}

A: Assuming that you know that the root elements are zero, here's the pseudocode to output to text:
function PrintLevel (int curr, int level)
    //print the indents
    for (i=1; i<=level; i++)
        print a tab
    print curr \n;
    for each child in the table with a parent of curr
        PrintLevel (child, level+1)

for each elementID where the parentid is zero
    PrintLevel(elementID, 0)

A: It's a quite old question, but as it's got many views I think it's worth to present an alternative, and in my opinion very elegant, solution.
In order to read a tree structure you can use recursive Common Table Expressions (CTEs). It gives a possibility to fetch whole tree structure at once, have the information about the level of the node, its parent node and order within children of the parent node.
Let me show you how this would work in PostgreSQL 9.1.

*

*Create a structure
CREATE TABLE tree (
    id int  NOT NULL,
    name varchar(32)  NOT NULL,
    parent_id int  NULL,
    node_order int  NOT NULL,
    CONSTRAINT tree_pk PRIMARY KEY (id),
    CONSTRAINT tree_tree_fk FOREIGN KEY (parent_id)
      REFERENCES tree (id) NOT DEFERRABLE
);

insert into tree values
  (0, 'ROOT', NULL, 0),
  (1, 'Node 1', 0, 10),
  (2, 'Node 1.1', 1, 10),
  (3, 'Node 2', 0, 20),
  (4, 'Node 1.1.1', 2, 10),
  (5, 'Node 2.1', 3, 10),
  (6, 'Node 1.2', 1, 20);

*Write a query
WITH RECURSIVE
tree_search (id, name, level, parent_id, node_order) AS (
  SELECT
    id,
    name,
    0,
    parent_id,
    1
  FROM tree
  WHERE parent_id is NULL

  UNION ALL
  SELECT
    t.id,
    t.name,
    ts.level + 1,
    ts.id,
    t.node_order
  FROM tree t, tree_search ts
  WHERE t.parent_id = ts.id
)
SELECT * FROM tree_search
WHERE level > 0
ORDER BY level, parent_id, node_order;

Here are the results:
     id |    name    | level | parent_id | node_order
    ----+------------+-------+-----------+------------
      1 | Node 1     |     1 |         0 |         10
      3 | Node 2     |     1 |         0 |         20
      2 | Node 1.1   |     2 |         1 |         10
      6 | Node 1.2   |     2 |         1 |         20
      5 | Node 2.1   |     2 |         3 |         10
      4 | Node 1.1.1 |     3 |         2 |         10
    (6 rows)

The tree nodes are ordered by a level of depth. In the final output we would present them in the subsequent lines.
For each level, they are ordered by parent_id and node_order within the parent. This tells us how to present them in the output - link node to the parent in this order.
Having such a structure it wouldn't be difficult to make a really nice presentation in HTML.
Recursive CTEs are available in PostgreSQL, IBM DB2, MS SQL Server, Oracle and SQLite.
If you'd like to read more on recursive SQL queries, you can either check the documentation of your favourite DBMS or read my two articles covering this topic:

*

*Do It In SQL: Recursive Tree Traversal

*Get to know the power of SQL recursive queries

A: You can emulate any other data structure with a hashmap, so that's not a terrible limitation.  Scanning from the top to the bottom, you create a hashmap for each row of the database, with an entry for each column. Add each of these hashmaps to a "master" hashmap, keyed on the id. If any node has a "parent" that you haven't seen yet, create an placeholder entry for it in the master hashmap, and fill it in when you see the actual node.
To print it out, do a simple depth-first pass through the data, keeping track of indent level along the way. You can make this easier by keeping a "children" entry for each row, and populating it as you scan the data.
As for whether there's a "better" way to store a tree in a database, that depends on how you're going to use the data. I've seen systems that had a known maximum depth that used a different table for each level in the hierarchy. That makes a lot of sense if the levels in the tree aren't quite equivalent after all (top level categories being different than the leaves).

A: As of Oracle 9i, you can use CONNECT BY.
SELECT LPAD(' ', (LEVEL - 1) * 4) || "Name" AS "Name"
FROM (SELECT * FROM TMP_NODE ORDER BY "Order")
CONNECT BY PRIOR "Id" = "ParentId"
START WITH "Id" IN (SELECT "Id" FROM TMP_NODE WHERE "ParentId" = 0)

As of SQL Server 2005, you can use a recursive common table expression (CTE).
WITH [NodeList] (
  [Id]
  , [ParentId]
  , [Level]
  , [Order]
) AS (
  SELECT [Node].[Id]
    , [Node].[ParentId]
    , 0 AS [Level]
    , CONVERT([varchar](MAX), [Node].[Order]) AS [Order]
  FROM [Node]
  WHERE [Node].[ParentId] = 0
  UNION ALL
  SELECT [Node].[Id]
    , [Node].[ParentId]
    , [NodeList].[Level] + 1 AS [Level]
    , [NodeList].[Order] + '|'
      + CONVERT([varchar](MAX), [Node].[Order]) AS [Order]
  FROM [Node]
    INNER JOIN [NodeList] ON [NodeList].[Id] = [Node].[ParentId]
) SELECT REPLICATE(' ', [NodeList].[Level] * 4) + [Node].[Name] AS [Name]
FROM [Node]
  INNER JOIN [NodeList] ON [NodeList].[Id] = [Node].[Id]
ORDER BY [NodeList].[Order]

Both will output the following results.

Name
'Node 1'
'    Node 1.1'
'        Node 1.1.1'
'    Node 1.2'
'Node 2'
'    Node 2.1'

A: Bill's answer is pretty gosh-darned good, this answer adds some things to it which makes me wish SO supported threaded answers.
Anyway I wanted to support the tree structure and the Order property.  I included a single property in each Node called leftSibling that does the same thing Order is meant to do in the original question (maintain left-to-right order).

mysql> desc nodes ;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| name        | varchar(255) | YES  |     | NULL    |                |
| leftSibling | int(11)      | NO   |     | 0       |                |
+-------------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

mysql> desc adjacencies;
+------------+---------+------+-----+---------+----------------+
| Field      | Type    | Null | Key | Default | Extra          |
+------------+---------+------+-----+---------+----------------+
| relationId | int(11) | NO   | PRI | NULL    | auto_increment |
| parent     | int(11) | NO   |     | NULL    |                |
| child      | int(11) | NO   |     | NULL    |                |
| pathLen    | int(11) | NO   |     | NULL    |                |
+------------+---------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

More detail and SQL code on my blog.
Thanks Bill your answer was helpful in getting started!

A: If nested hash maps or arrays can be created, then I can simply go down the table from the beginning and add each item to the nested array. I must trace each line to the root node in order to know which level in the nested array to insert into. I can employ memoization so that I do not need to look up the same parent over and over again.
Edit: I would read the entire table into an array first, so it will not query the DB repeatedly. Of course this won't be practical if your table is very large.
After the structure is built, I must do a depth first traverse through it and print out the HTML.
There's no better fundamental way to store this information using one table (I could be wrong though ;), and would love to see a better solution ). However, if you create a scheme to employ dynamically created db tables, then you opened up a whole new world at the sacrifice of simplicity, and the risk of SQL hell ;).

A: To Extend Bill's SQL solution you can basically do the same using a flat array.  Further more if your strings all have the same lenght and your maximum number of children are known (say in a binary tree) you can do it using a single string (character array).  If you have arbitrary number of children this complicates things a bit...  I would have to check my old notes to see what can be done.
Then, sacrificing a bit of memory, especially if your tree is sparse and/or unballanced, you can, with a bit of index math, access all the strings randomly by storing your tree, width first in the array like so (for a binary tree):
String[] nodeArray = [L0root, L1child1, L1child2, L2Child1, L2Child2, L2Child3, L2Child4] ...

yo know your string length, you know it

I'm at work now so cannot spend much time on it but with interest I can fetch a bit of code to do this.
We use to do it to search in binary trees made of DNA codons, a process built the tree, then we flattened it to search text patterns and when found, though index math (revers from above) we get the node back...  very fast and efficient, tough our tree rarely had empty nodes, but we could searh gigabytes of data in a jiffy.

A: Pre-order transversal with on-the-fly path enumeration on adjacency representation
Nested sets from:

*

*Konchog https://stackoverflow.com/a/42781302/895245

*Jonny Buchanan https://stackoverflow.com/a/194031/895245
is the only efficient way I've seen of traversing, at the cost of slower updates. That's likely what most people will want for pre-order.
Closure table from https://stackoverflow.com/a/192462/895245 is interesting, but I don't see how to enforce pre-order there: MySQL Closure Table hierarchical database - How to pull information out in the correct order
Mostly for fun, here's a method that recursively calculates the 1.3.2.5. prefixes on the fly and sorts by them at the end, based only on the parent ID/child index representation.
Upsides:

*

*updates only need to update the indexes of each sibling

Downsides:

*

*n^2 memory usage worst case for a super deep tree. This could be quite serious, which is why I say this method is likely mostly for fun only. But maybe there is some ultra high update case where someone would want to use it? Who knows

*recursive queries, so reads are going to be less efficient than nested sets

Create and populate table:
CREATE TABLE "ParentIndexTree" (
  "id" INTEGER PRIMARY KEY,
  "parentId" INTEGER,
  "childIndex" INTEGER NOT NULL,
  "value" INTEGER NOT NULL,
  "name" TEXT NOT NULL,
  FOREIGN KEY ("parentId") REFERENCES "ParentIndexTree"(id)
)
;
INSERT INTO "ParentIndexTree" VALUES
  (0, NULL, 0, 1, 'one'  ),
  (1, 0,    0, 2, 'two'  ),
  (2, 0,    1, 3, 'three'),
  (3, 1,    0, 4, 'four' ),
  (4, 1,    1, 5, 'five' )
;

Represented tree:
    1
   / \
  2   3
 / \
4   5

Then for a DBMS with arrays like PostgreSQL](https://www.postgresql.org/docs/14/arrays.html):
WITH RECURSIVE "TreeSearch" (
  "id",
  "parentId",
  "childIndex",
  "value",
  "name",
  "prefix"
) AS (
  SELECT
    "id",
    "parentId",
    "childIndex",
    "value",
    "name",
    array[0]
  FROM "ParentIndexTree"
  WHERE "parentId" IS NULL

  UNION ALL

  SELECT
    "child"."id",
    "child"."parentId",
    "child"."childIndex",
    "child"."value",
    "child"."name",
    array_append("parent"."prefix", "child"."childIndex")
  FROM "ParentIndexTree" AS "child"
  JOIN "TreeSearch" AS "parent"
    ON "child"."parentId" = "parent"."id"
)
SELECT * FROM "TreeSearch"
ORDER BY "prefix"
;

This creates on the fly prefixes of form:
1 -> 0
2 -> 0, 0
3 -> 0, 1
4 -> 0, 0, 0
5 -> 0, 0, 1

and then PostgreSQL then sorts by the arrays alphabetically as:
1 -> 0
2 -> 0, 0
4 -> 0, 0, 0
5 -> 0, 0, 1
3 -> 0, 1

which is the pre-order result that we want.
For a DBMS without arrays like SQLite, you can hack by encoding the prefix with a string of fixed width integers. Binary would be ideal, but I couldn't find out how, so hex would work. This of course means you will have to select a maximum depth that will fit in the number of bytes selected, e.g. below I choose 6 allowing for a maximum of 16^6 children per node.
WITH RECURSIVE "TreeSearch" (
  "id",
  "parentId",
  "childIndex",
  "value",
  "name",
  "prefix"
) AS (
  SELECT
    "id",
    "parentId",
    "childIndex",
    "value",
    "name",
    '000000'
  FROM "ParentIndexTree"
  WHERE "parentId" IS NULL

  UNION ALL

  SELECT
    "child"."id",
    "child"."parentId",
    "child"."childIndex",
    "child"."value",
    "child"."name",
    "parent"."prefix" || printf('%06x', "child"."childIndex")
  FROM "ParentIndexTree" AS "child"
  JOIN "TreeSearch" AS "parent"
    ON "child"."parentId" = "parent"."id"
)
SELECT * FROM "TreeSearch"
ORDER BY "prefix"
;

Some nested set notes
Here are a few points which confused me a bit after looking at the other nested set answers.
Jonny Buchanan shows his nested set setup as:
__________________________________________________________________________
|  Root 1                                                                  |
|   ________________________________    ________________________________   |
|  |  Child 1.1                     |  |  Child 1.2                     |  |
|  |   ___________    ___________   |  |   ___________    ___________   |  |
|  |  |  C 1.1.1  |  |  C 1.1.2  |  |  |  |  C 1.2.1  |  |  C 1.2.2  |  |  |
1  2  3___________4  5___________6  7  8  9___________10 11__________12 13 14
|  |________________________________|  |________________________________|  |
|__________________________________________________________________________|

which made me wonder why not just use the simpler looking:
__________________________________________________________________________
|  Root 1                                                                 |
|   ________________________________    _______________________________   |
|  |  Child 1.1                     |  |  Child 1.2                    |  |
|  |   ___________    ___________   |  |   ___________   ___________   |  |
|  |  |  C 1.1.1  |  |  C 1.1.2  |  |  |  |  C 1.2.1  | |  C 1.2.2  |  |  |
1  2  3___________|  4___________|  |  5  6___________| 7___________|  |  |
|  |________________________________|  |_______________________________|  |
|_________________________________________________________________________|

which does not have an extra number for each endpoint.
But then when I actually tried to implement it, I noticed that it was hard/impossible to implement the update queries like that, unless I had parent information as used by Konchog. The problem is that it was hard/impossible to distinguish between a sibling and a parent in one case while the tree was being moved around, and I needed that to decide if I was going to reduce the right hand side or not while closing a gap.
Left/size vs left/right: you could store it either way in the database, but I think left/right can be more efficient as you can index the DB with a multicolumn index (left, right) which can then be used to speed up ancestor queries, which are of type:
left < curLeft AND right > curLeft

Tested on Ubuntu 22.04, PostgreSQL 14.5, SQLite 3.34.0.

A: If elements are in tree order, as shown in your example, you can use something like the following Python example:
delimiter = '.'
stack = []
for item in items:
  while stack and not item.startswith(stack[-1]+delimiter):
    print "</div>"
    stack.pop()
  print "<div>"
  print item
  stack.append(item)

What this does is maintain a stack representing the current position in the tree. For each element in the table, it pops stack elements (closing the matching divs) until it finds the parent of the current item. Then it outputs the start of that node and pushes it to the stack.
If you want to output the tree using indenting rather than nested elements, you can simply skip the print statements to print the divs, and print a number of spaces equal to some multiple of the size of the stack before each item. For example, in Python:
print "  " * len(stack)

You could also easily use this method to construct a set of nested lists or dictionaries.
Edit: I see from your clarification that the names were not intended to be node paths. That suggests an alternate approach:
idx = {}
idx[0] = []
for node in results:
  child_list = []
  idx[node.Id] = child_list
  idx[node.ParentId].append((node, child_list))

This constructs a tree of arrays of tuples(!). idx[0] represents the root(s) of the tree. Each element in an array is a 2-tuple consisting of the node itself and a list of all its children. Once constructed, you can hold on to idx[0] and discard idx, unless you want to access nodes by their ID.

A: Think about using nosql tools like neo4j for hierarchial structures.
e.g a networked application like linkedin uses couchbase (another nosql solution)
But use nosql only for data-mart level queries and not to store / maintain transactions


Q: Can we use dagger only in some parts of an android app? Until now we have not used dagger in our android app. We want to use dagger for whatever new code that we write in our app from now on. Is this possible ? I just started exploring dagger and i have a doubt if this is possible.

A: Yes , It is possible. You can add dagger for ongoing project and use it.


Q: GridGain Error : java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/JobContext I have configured gridgain-hadoop-os-6.6.2.zip, and followed steps as mentioned in docs/hadoop_readme.pdf . started gridgain using bin/ggstart.sh command, now am running a simple wordcount code in gridgain with hadoop-2.2.0. using command
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/*-mapreduce-examples-*.jar wordcount /input /output

Steps I tried:
Step 1:
Extracted hadoop-2.2.0 and gridgain-hadoop-os-6.6.2.zip file in usr/local folder and changed name for gridgain folder as "gridgain".
Step 2:
 Set the path for export GRIDGAIN_HOME=/usr/local/gridgain.. and path for hadoop-2.2.0 with JAVA_HOME as
    # Set Hadoop-related environment variables
export HADOOP_PREFIX=/usr/local/hadoop-2.2.0
export HADOOP_HOME=/usr/local/hadoop-2.2.0
export HADOOP_MAPRED_HOME=/usr/local/hadoop-2.2.0
export HADOOP_COMMON_HOME=/usr/local/hadoop-2.2.0
export HADOOP_HDFS_HOME=/usr/local/hadoop-2.2.0
export YARN_HOME=/usr/local/hadoop-2.2.0
export HADOOP_CONF_DIR=/usr/local/hadoop-2.2.0/etc/hadoop
export GRIDGAIN_HADOOP_CLASSPATH='/usr/local/hadoop-2.2.0/lib/*:/usr/local/hadoop-2.2.0/lib/*:/usr/local/hadoop-2.2.0/lib/*'

Step 3:
now i run command as bin/setup-hadoop.sh ... answer Y to every prompt.
Step 4:
started gridgain using command
bin/ggstart.sh
Step 5:
now i created dir and uploaded file using :
hadoop fs -mkdir /input

hadoop fs -copyFromLocal $HADOOP_HOME/README.txt /input/WORD_COUNT_ME.
txt

Step 6:
Running this command gives me error:
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/*-mapreduce-examples-*.
jar wordcount /input /output

Getting following error:
15/02/22 12:49:13 INFO Configuration.deprecation: mapred.working.dir is deprecated. Instead, use mapreduce.job.working.dir
15/02/22 12:49:13 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_091ebfbd-2993-475f-a506-28280dbbf891_0002
15/02/22 12:49:13 INFO mapreduce.JobSubmitter: Cleaning up the staging area /tmp/hadoop-yarn/staging/hduser/.staging/job_091ebfbd-2993-475f-a506-28280dbbf891_0002
java.lang.NullPointerException
    at org.gridgain.client.hadoop.GridHadoopClientProtocol.processStatus(GridHadoopClientProtocol.java:329)
    at org.gridgain.client.hadoop.GridHadoopClientProtocol.submitJob(GridHadoopClientProtocol.java:115)
    at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:430)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1268)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1265)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1265)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1286)
    at org.apache.hadoop.examples.WordCount.main(WordCount.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:72)
    at org.apache.hadoop.util.ProgramDriver.run(ProgramDriver.java:144)
    at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

and gridgain console error as:
sLdrId=a0b8610bb41-091ebfbd-2993-475f-a506-28280dbbf891, userVer=0, loc=true, sampleClsName=java.lang.String, pendingUndeploy=false, undeployed=false, usage=0]], taskClsName=o.g.g.kernal.processors.hadoop.proto.GridHadoopProtocolSubmitJobTask, sesId=e129610bb41-091ebfbd-2993-475f-a506-28280dbbf891, startTime=1424589553332, endTime=9223372036854775807, taskNodeId=091ebfbd-2993-475f-a506-28280dbbf891, clsLdr=sun.misc.Launcher$AppClassLoader@1bdcbb2, closed=false, cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false, subjId=091ebfbd-2993-475f-a506-28280dbbf891], jobId=f129610bb41-091ebfbd-2993-475f-a506-28280dbbf891]]
java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/JobContext
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
    at java.lang.Class.getConstructor0(Class.java:2885)
    at java.lang.Class.getConstructor(Class.java:1723)
    at org.gridgain.grid.hadoop.GridHadoopDefaultJobInfo.createJob(GridHadoopDefaultJobInfo.java:107)
    at org.gridgain.grid.kernal.processors.hadoop.jobtracker.GridHadoopJobTracker.job(GridHadoopJobTracker.java:959)
    at org.gridgain.grid.kernal.processors.hadoop.jobtracker.GridHadoopJobTracker.submit(GridHadoopJobTracker.java:222)
    at org.gridgain.grid.kernal.processors.hadoop.GridHadoopProcessor.submit(GridHadoopProcessor.java:188)
    at org.gridgain.grid.kernal.processors.hadoop.GridHadoopImpl.submit(GridHadoopImpl.java:73)
    at org.gridgain.grid.kernal.processors.hadoop.proto.GridHadoopProtocolSubmitJobTask.run(GridHadoopProtocolSubmitJobTask.java:54)
    at org.gridgain.grid.kernal.processors.hadoop.proto.GridHadoopProtocolSubmitJobTask.run(GridHadoopProtocolSubmitJobTask.java:37)
    at org.gridgain.grid.kernal.processors.hadoop.proto.GridHadoopProtocolTaskAdapter$Job.execute(GridHadoopProtocolTaskAdapter.java:95)
    at org.gridgain.grid.kernal.processors.job.GridJobWorker$2.call(GridJobWorker.java:484)
    at org.gridgain.grid.util.GridUtils.wrapThreadLoader(GridUtils.java:6136)
    at org.gridgain.grid.kernal.processors.job.GridJobWorker.execute0(GridJobWorker.java:478)
    at org.gridgain.grid.kernal.processors.job.GridJobWorker.body(GridJobWorker.java:429)
    at org.gridgain.grid.util.worker.GridWorker.run(GridWorker.java:151)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: Failed to load class: org.apache.hadoop.mapreduce.JobContext
    at org.gridgain.grid.kernal.processors.hadoop.GridHadoopClassLoader.loadClass(GridHadoopClassLoader.java:125)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.JobContext
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at org.gridgain.grid.kernal.processors.hadoop.GridHadoopClassLoader.loadClassExplicitly(GridHadoopClassLoader.java:196)
    at org.gridgain.grid.kernal.processors.hadoop.GridHadoopClassLoader.loadClass(GridHadoopClassLoader.java:106)
    ... 21 more
^[[B

Help here....
Edited Here :
raj@ubuntu:~$ hadoop classpath
/usr/local/hadoop-2.2.0/etc/hadoop:/usr/local/hadoop-2.2.0/share/hadoop/common/lib/*:/usr/local/hadoop-2.2.0/share/hadoop/common/*:/usr/local/hadoop-2.2.0/share/hadoop/hdfs:/usr/local/hadoop-2.2.0/share/hadoop/hdfs/lib/*:/usr/local/hadoop-2.2.0/share/hadoop/hdfs/*:/usr/local/hadoop-2.2.0/share/hadoop/yarn/lib/*:/usr/local/hadoop-2.2.0/share/hadoop/yarn/*:/usr/local/hadoop-2.2.0/share/hadoop/mapreduce/lib/*:/usr/local/hadoop-2.2.0/share/hadoop/mapreduce/*:/usr/local/hadoop-2.2.0/contrib/capacity-scheduler/*.jar
raj@ubuntu:~$ jps
3529 GridCommandLineStartup
3646 Jps
raj@ubuntu:~$ echo $GRIDGAIN_HOME
/usr/local/gridgain
raj@ubuntu:~$ echo $HADOOP_HOME
/usr/local/hadoop-2.2.0
raj@ubuntu:~$ hadoop version
Hadoop 2.2.0
Subversion https://svn.apache.org/repos/asf/hadoop/common -r 1529768
Compiled by hortonmu on 2013-10-07T06:28Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
This command was run using /usr/local/hadoop-2.2.0/share/hadoop/common/hadoop-common-2.2.0.jar
raj@ubuntu:~$ cd /usr/local/hadoop-2.2.0/share/hadoop/mapreduce
raj@ubuntu:/usr/local/hadoop-2.2.0/share/hadoop/mapreduce$ ls
hadoop-mapreduce-client-app-2.2.0.jar     hadoop-mapreduce-client-hs-2.2.0.jar          hadoop-mapreduce-client-jobclient-2.2.0-tests.jar  lib
hadoop-mapreduce-client-common-2.2.0.jar  hadoop-mapreduce-client-hs-plugins-2.2.0.jar  hadoop-mapreduce-client-shuffle-2.2.0.jar          lib-examples
hadoop-mapreduce-client-core-2.2.0.jar    hadoop-mapreduce-client-jobclient-2.2.0.jar   hadoop-mapreduce-examples-2.2.0.jar                sources
raj@ubuntu:/usr/local/hadoop-2.2.0/share/hadoop/mapreduce$

A: I configured exactly the versions you mentioned (gridgain-hadoop-os-6.6.2.zip + hadoop-2.2.0) -- the "wordcount" sample works fine.

[UPD after question's author log analysis:]
Raju, thanks for the detailed logs.
The cause of the problem are incorrectly set env variables
export HADOOP_MAPRED_HOME=${HADOOP_HOME}
export HADOOP_COMMON_HOME=${HADOOP_HOME}
export HADOOP_HDFS_HOME=${HADOOP_HOME}

You explicitly set all these variables to ${HADOOP_HOME} value, what is wrong. This causes GG to compose incorrect hadoop classpath, as seen from the below GG Node log:
+++ HADOOP_PREFIX=/usr/local/hadoop-2.2.0
+++ [[ -z /usr/local/hadoop-2.2.0 ]]
+++ '[' -z /usr/local/hadoop-2.2.0 ']'
+++ HADOOP_COMMON_HOME=/usr/local/hadoop-2.2.0
+++ HADOOP_HDFS_HOME=/usr/local/hadoop-2.2.0
+++ HADOOP_MAPRED_HOME=/usr/local/hadoop-2.2.0
+++ GRIDGAIN_HADOOP_CLASSPATH='/usr/local/hadoop-2.2.0/lib/*:/usr/local/hadoop-2.2.0/lib/*:/usr/local/hadoop-2.2.0/lib/*'

So, to fix the issue please don't set unnecessary env variables. JAVA_HOME  and HADOOP_HOME is quite enough, nothing else is needed.

A: many thnaks to Ivan, thanks for your help and support, the solution you gave was good to get me out of the problem.
The issue was not to set other hadoop related environment variables. this is enough to set.
JAVA_HOME , HADOOP_HOME and GRIDGAIN_HOME


Q: How to change a predeterminate underline color in an Input with Materialize w/Ruby on Rails I really try so hard to change the underline color but I can't, I don't know where do that, please help me!

          <%= form_for(:session, url: login_path) do |f| %>

          <%= f.label :email %>
          <%= f.email_field :email, class: 'form-control white-text' %>

          <%= f.label :password %>
          <%= f.password_field :password, class: 'form-control white-text' %>

          <%= f.submit "Log in", class: "btn" ,style:"color:white;background-color: #EEB756;" %>
          <% end %>

A: You can change the class .input-field, and add more specific selector, for example:
.input-field input

or to email type of input
.input-field input[type=email]

or to focused field:
.input-field input[type=text]:focus

And set the border style:
.input-field input[type=text]:focus{
     border-bottom: 1px solid #aaa;
}

You can read more in Materialize documentation: http://materializecss.com/forms.html
EDIT: edited as suggested by @Toby1Kenobi

A: According to the docs you can change the underline colour in CSS by modifying the colour of border-bottom and box-shadow of the element containing the input element (that is the one with the class input-field)
so maybe it would be something like this:
.input-field input[type=email] {
   border-bottom: 1px solid red;
   box-shadow: 0 1px 0 0 red;
}


Q: How to delete a pointer belonging to an object stored in a vector? I have a Containing class, a Contained class, and a Data class. That Containing class holds a vector of Contained objects. The Contained class holds a pointer to a data object, allocated on the heap in Contained's constructor. However, I can't deallocate it in the destructor, since the vector will create copies of Contained and then destroy them, thus destroying the data pointer even in the copy we're using.
TL;DR Here's some code to explain:
class Data {
    public:
        Data();
};

class Contained {
    private:
        Data* data;
    public:
        Contained();
        // what should I add ? a copy constructor ? an assignement operator ? and how
};

class Container {
    private:
        vector<Contained> rooms;
    public:
        //some member functions
};

Contained::Contained() {
    data = new Data();
}

Where do I delete data ?

A: Using RAII(Resource Acquisition is Initialization)
Add a destructor to the Contained class:
Contained::~Contained() {
    delete data;
}

This will ensure whenever your contained object goes out of scope, it will automatically delete the data pointer it has. So if you do
//delete first element
rooms.erase(rooms.begin());

data ptr of that object will automatically be deleted.
Using smart pointers
Use std::unique_ptr<T>.
class Contained {
    private:
        std::unique_ptr<Data> data;
    public:
        Contained();
        // what should I add ? a copy constructor ? an assignement operator ? and how
};

and in the constructor:
Contained::Contained() {
    data = std::make_unique<Data>();
}

Using smart pointers i.e., (unique_ptr, shared_ptr) ensures your pointer will automatically delete when no one is owning it. Since you can not copy unique_ptr but only move it, you should define a move constructor and move assignment operator on the Contained class.
Contained::Contained(Contained&& other)
    : data(std::move(other.data))
{}

Contained& operator=(Contained&& rhs) {
    if (this != &other) {
        data = std::move(rhs.data);
    }
    return *this;
}


Q: Finding if file exists ANYWHERE c# For starters, I'm quite new to C#.
How would I go about checking if a (.exe) file exists anywhere on a pc's memory?
I tried to google an answer, but only ones I came across required you to specify a directory where to look from.
I'm building an application that launches certain apps which the user selects, hence why I can't know the directory where the file is in. Is there a way of checking it without a directory, aka check if the file exists anywhere on the pc?
Alternatively, is there a way to handle an error where the selected file is not found?


Q: Help review this calculation of Torsion of a space curve I am working on a practice set and this is given as a guide to solving for torsion of a space curve.

$\color{red}{\textrm{My issue is this following part}}$

I have that $( r'(t) \times r''(t)) \cdot r'''(t) ) = 46080$ , $\color{red}{\textrm{not 92160}}$
Can someone check this and share what I am missing?


Q: Elementary question on pointwise convergence and norm continuity
Let $\;a_n \in \mathbb R\;$ be a bounded sequence, then by
  Bolzano-Weierstrass Theorem it follows there exists a subsequence
  $\;a_{n_k}\subset a_n\;$ such that $\;a_{n_k} \to a \in \mathbb R\;$.
  If $\;f:\mathbb R \to \mathbb R^m\;$ a continuous function, then
  $\;f(x-a_{n_k}) \to f(x-a)\;$ pointwise.
In addition, $\;\forall g \in C(\mathbb R;\mathbb R^m)\;$ it holds:
  $\;{\vert g(x)-f(x-a_{n_k}) \vert}^2 \to {\vert g(x)-f(x-a) \vert}^2\;$ also
  pointwise.

NOTE: $\; \vert \cdot \vert \;$ stands above for the Euclidean norm
As I was studying, the above part of my notes confused me a little bit.
QUESTIONS:

*

*Why is $\;f(x-a_{n_k}) \to f(x-a)\;$ pointwise? I know that uniform convergence is much stronger than pointwise but why is that the case here?

*Why does the second convergence hold? Is it because $\;\vert \cdot \vert\;$ is also continuous?

Any help would be valuable. Thanks in advance!

A: *

*Since $\lim_{k\to\infty}a_{n_k}=a$ and since $f$ is continuous, $\lim_{k\to\infty}f(x-a_{n_k})=f(x-a)$.

*Since $\lim_{k\to\infty}a_{n_k}=a$ and since $f$ and $g$ are continuous, $\lim_{k\to\infty}\bigl|g(x)-f(x-a_{n_k})\bigr|^2=\bigl|g(x)-f(x-a)\bigr|^2$.

I didn't understand your reference to uniform continuity. It is not relevant here.

A: For fixed $x$, then $\{x-a_{n_{k}}\}_{k}$ is a sequence such that $x-a_{n_{k}}\rightarrow x-a$. Then by sequential characterisation of the continuity of $f$, we have $f(x-a_{n_{k}})\rightarrow f(x-a)$.
For the second one, appeal to the composition with the continuous map $|\cdot|^{2}$.

A: Consider $y_{n_k}=x-a_{n_k}$ and $y =x-a $ for any fixed $x\in \mathbb{R}$, then $y_{n_k} \rightarrow y $ in $\mathbb{R}$. Now as both $f$ and $g$ is continuous in $\mathbb{R},$ you can have both the convergence. Also you have to use the fact $||$ is continuous and composition of two continuous maps is continuous  to get the last result.


Q: apt-get fails on i386/debian docker image I have a 32-bit Ubuntu server, running 17.10 Artful & with docker.io installed (my understanding is this is the only version available for 32-bit)
jonny@grizzly ~ $ lsb_release -cs
artful
jonny@grizzly ~ $ apt list | grep docker.io

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

4384:docker.io/artful,now 1.13.1-0ubuntu6 i386 [installed]

I am attempting to use i386/debian image (I have also tried 32bit/Ubuntu with similar results), and having issues with apt-get. Sources appear to be configured sensibly, but apt-get update gets 404 errors. Hitting the same URLs (with .gz appended) from browser works fine. ping works within Docker image, wget & curl aren't available so haven't been able to further diagnose possible network issues.
jonny@grizzly ~ $ docker run -it i386/debian /bin/bash
root@1023ad95222c:/# more /etc/apt/sources.list
deb http://deb.debian.org/debian stretch main
deb http://security.debian.org/debian-security stretch/updates main
deb http://deb.debian.org/debian stretch-updates main
root@1023ad95222c:/# apt-get update
Ign:1 http://security.debian.org/debian-security stretch/updates InRelease
Ign:2 http://security.debian.org/debian-security stretch/updates Release
Ign:3 http://deb.debian.org/debian stretch InRelease
Ign:4 http://deb.debian.org/debian stretch-updates InRelease
Ign:5 http://deb.debian.org/debian stretch Release
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
Ign:8 http://deb.debian.org/debian stretch-updates Release
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main i386 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main i386 Packages
Ign:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Err:7 http://security.debian.org/debian-security stretch/updates/main i386 Packages
  404   [IP: 212.211.132.250 80]
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main i386 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main i386 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Ign:10 http://deb.debian.org/debian stretch/main i386 Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main all Packages
Err:10 http://deb.debian.org/debian stretch/main i386 Packages
  404   [IP: 130.89.148.14 80]
Err:11 http://deb.debian.org/debian stretch-updates/main i386 Packages
  404   [IP: 130.89.148.14 80]
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Reading package lists... Done
W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-i386/Packages  404   [IP: 212.211.132.250 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-i386/Packages  404   [IP: 130.89.148.14 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-i386/Packages  404   [IP: 130.89.148.14 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

I've tried various different mirrors I've found online with no difference. I've also tried a few different versions/tags of the i386/debian docker image. No proxy used to access internet on this server. Are there any other steps I may be missing here?


Q: Why is my User Group Information Do as not passing my keytab token to my HDFS access method When I attempt to list the files in a HDFS directory I am receiving the following error:
main] ERROR com.pr.hdfs.common.hadooputils.HdfsUtil - Failed to connect to hdfs directory /HDFS/Datastore/DB
org.apache.hadoop.security.AccessControlException: SIMPLE authentication is not enabled.  Available:[TOKEN, KERBEROS]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.java:106)
at org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.java:73)

The code I am using although being accessed as scala is the following Java:
public static List<Path> listHdfsFilePaths(final FileSystem hdfs, final String directory) throws IOException
 {
  final List<Path> result = new ArrayList<>();
  final FileStatus[] fileStatuses;
  try
  {
     fileStatuses = hdfs.listStatus(new Path(directory));
     for (final FileStatus fileStatus : fileStatuses)
     {
        result.add(fileStatus.getPath());
     }
  }
  catch (final IOException e)
  {
     LOGGER.error("Failed to connect to hdfs directory " + directory, e);
     throw e;
  }
  return result;
}

The scala code wraps a User Group Information doas to access the folder:
val auctions = ugiDoAs(ugi){
  val hdfs = FileSystem.get(hadoopConf)
  HdfsUtils.listHdfsFilePaths(hdfs, "/HDFS/Datastore/DB/")
}

The ugiDoAs method is specified as:
def ugiDoAs[T](ugi: Option[UserGroupInformation])(code: => T) = ugi match {
   case None => code
   case Some(u) => u.doAs(new PrivilegedExceptionAction[T] {
     override def run(): T = code
   })
 }

The ugiDoAs wrapper works for reading from Zookeeper, reading from Hbase but just not accessing HDFS in this case.
Also, my ugi variable contains the keytab and the principal needed.