text:
Q: Selecting overflowing elements Selecting overflowing elements with jQuery
I'm currently doing a project at my internship, and I have stumbled upon an issue which I can't solve myself. I have a horizontal navigation bar, which should support unlimited navigation items. What I want is that all the overflowing navigation items should be hidden in a view more button.
How do I target all the overflowing navigation items?
I tried to visualize my idea:
Link to visualization

.sidebar {
  position: fixed;
  z-index: 50;
  width: 25%;
  height: 100%;
  padding: 150px 0 50px;
  background: $secondary;
  overflow-y: scroll;
  @include break(1000px) {
    top: 100px;
    width: 100%;
    height: 50px;
    padding: 0;
    overflow: hidden;
  }
  nav {
    width: 100%;
    height: auto;
  }
  li {
    @include break(1000px) {
      display: inline-block;
    }
  }
  a {
    position: relative;
    display: block;
    width: 100%;
    height: 50px;
    padding: 17px 40px;
    background: none;
    -webkit-transition: background 0.4s;
    transition: background 0.4s;
    font-family: $font;
    font-size: 16px;
    text-decoration: none;
    line-height: 1;
    color: #fff;
    &: hover {
      background: lighten($secondary, 5%);
    }
  }
  .active {
    color: $primary;
    background: lighten($secondary, 5%);
    span {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      width: 5px;
      height: 50px;
      background: $primary;
      @include break(1000px) {
        top: -webkit-calc(100% - 5px);
        top: calc(100% - 5px);
        width: 100%;
        height: 5px;
      }
    }
  }
}

Item 1

Item 2

Item 3

Item 4

Item 5

Item 6

Item 7

Item 8

Item 9

Item 10

Item 11

Item 12

A: Or you could scroll the contents of the container on "View More...".  Although without code it is difficult to answer.


text:
Q: Pronunciation of "spring" I found this text on the internet:

We must polish the Polish furniture.
  He could lead if he would get the lead out.
  The farm was used to produce produce.
  ...
  There was a bow tied in the ropes on the bow of the ship.
  You should spring that on us next spring!

http://www.corsinet.com/braincandy/hlanguage2.html
Could you clarify the difference in pronunciation of the word spring in the last line?

A: There's no difference between how the two springs are pronounced. The meanings are different, though: the first spring means "surprise (us) with"; the second is the season.

A: First, there is no difference in pronunciation of the two instances of spring in the last sentence of your example. True, it is the exception to the pattern in the preceding lines. And the meaning is different in each usage of spring.
Two words with the same spelling and same pronunciation, with different meanings, such as spring in your example, are Homonyms, see chart below.
All the other examples had the same spelling, different pronunciation and different meanings. They are Heteronyms.
This is probably a bit of overkill, but I like this kind of thing, and was excited to find this cool Venn diagram just now, so posted what is mostly a repeat of fortunate1's fine answer.
See Venn diagram from Wikipedia of terms for words with similar pronunciation, meaning and spelling, or any combination http://i.stack.imgur.com/sMlIE.png
I couldn't insert the image because I am new on the English Stackexchange site, sorry!

A: The two words are not pronounced differently; they have a different meaning as spring (something) on means present or propose something suddenly or unexpectedly to someone, while spring (as noun) can mean the season (as in the example sentence) or have other meanings.
There are also two words that have a similar pronunciation (at least in American English): produce (verb) and produce (noun): The first is pronounced /prəˈd(j)us/, or /proʊˈd(j)us/; the second is pronounced /ˈprɑˌd(j)us/, or /ˈproʊˌd(j)us/. The difference between /proʊˈd(j)us/ and /ˈproʊˌd(j)us/ is where the primary accent is, and the presence of a secondary accent in place of the primary accent of the first word.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Comparing the contents of two recently created folders using Windows Batch file I'm writing a batch file to compare the contents of two folders on a network drive. A new folder is generated every night by a macro and I want to see what changed between today and yesterday. For example, if yesterday's folder is called "B" and today's folder is "A" and their structure looks like:
- Home
    - A
        - file1.txt
        - file2.txt
        - file4.txt
    - B
        - file1.txt
        - file2.txt
        - file3.txt

I would want to see something like
A: file4.txt added
A: file3.txt removed

But the format of the output doesn't really matter at the end of the day. I just need to see a comparison of the folder's contents.
What I have so far
Using my limited batch knowledge, I've smashed together this currently non-working solution:
@ECHO OFF
setlocal EnableDelayedExpansion
pushd "\\domain\path\to\Home"
set "j=0"
set "count=2"

:: get the names of the two most recently added folders
FOR /f "delims=" %%i IN ('dir /AD-H /B /O-D') DO (
    set /A j=j+1
    if !j! equ 1 (
        :: send contents of newest folder to file
        dir !i! /B > newest_folder.txt
    )
    if !j! equ 2 (
        :: send contents of second-newest folder to file
        dir !i! /B > older_folder.txt
    )
    if !j! geq !count! (
        :: break after two folders
        goto :end
    )
)
:end
fc newest_folder.txt oldest_folder.txt
PAUSE

I saw a similar solution here:
(for %%i in ("folder2\*") do if exist "folder1\%%~nxi" echo(%%~i)>file.csv

But it wouldn't work in my case because the folder names change every day.
Any help would be appreciated!

A: @ECHO OFF
setlocal EnableDelayedExpansion
set "later="
set "earlier="
pushd "\\domain\path\to\Home"
:: get the names of the two most recently added folders
FOR /f "delims=" %%i IN ('dir /AD-H /B /O-D') DO (
 if defined later set "earlier=%%i"&goto report
 set "later=%%i"
)
:report
if defined earlier (
 dir /b "%earlier%">older.txt
 dir /b "%later%">newer.txt
 fc older.txt newer.txt
) else echo too few directories found
pause
popd

would be my approach, setting later and earlier to the names of the first two directories found by the dir command.
---- afterthought
if the fc command is replaced by
 echo files added
 findstr /x /v /g:"older.txt" "newer.txt"
 echo files deleted
 findstr /x /v /g:"newer.txt" "older.txt"

then your report should be more easily interpreted.
findstr options /x does an exact match, /v reports NON-matches and /g:filename specifies a file containing strings against which to match.


text:
Q: highcharts are not rendering in grails views I am trying to execute a simple highcharts chart in grails. I have created a controller(Test) and also created index closure in the controller.
In the views , I have created index.gsp page in Test dir. I have copied the code given at http://www.highcharts.com/docs/getting-started/your-first-chart into index.gsp.I have tried the JQuery example. It works fine without any issues. But if I include grails metadata layout code <    meta name="layout" content="main"   /> in the index.gsp page, the chart never renders the chart.
Could you please some one can provide me a solution to resolve this issue.
Your help would be appreciated.
index.gsp :
<!DOCTYPE html>

<title>Test Chart</title>

<meta name="layout" content="main" />

main.gsp :
 <!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><g:layoutTitle default="Grails"/></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon">
    <link rel="apple-touch-icon" href="${resource(dir: 'images', file: 'apple-touch-icon.png')}">
    <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'mobile.css')}" type="text/css">
    <g:layoutHead/>
    <g:javascript library="application"/>
    <r:layoutResources />

    <g:layoutBody/>

<g:message code="spinner.alt" default="Loading…"/>

    <r:layoutResources />

Thanks.

A: The position of <g:layoutHead/> and <r:layoutResources/> in main.gsp in not correct. It must be
<r:layoutResources />
<g:layoutHead />

Change this and it will work. Thanks.

A: Highcharts are not working if I use   r:layoutResources
 in the main.gsp. It works if I remove the  r:layoutResources from the main.gsp.
I removed the below code from main.gsp. It solved my problem.
<r:layoutResources />


text:
Q: C# Xamarin - Binding data to UICollectionViewCell using SetValueForKey I am having significant problems using Xamarin.iOS.
I come from a MVC5 web background and would often bind data to DOM elements (for example with JS data- attributes). I want to achieve a similar pattern in Xamarin.iOS.
From what I gather in Xamarin's documentation (which always seems to be based on obsolete versions of the framework) I need to bind data (but not display it) to a UICollectionViewCell using the KVC pattern.
Is the best method calling SetValueForKey(NSObject object, NString key) within my UpdateCell method (NOTE: I have changed the params to be generic):
 public class MyClassCollectionViewCell : UICollectionViewCell
 {
     [Outlet]
     UILabel NameLabel { get; set; }

     public BaseCell (IntPtr handle) : base (handle)
     {
         this.NameLabel = new UILabel();
     }

     public virtual void UpdateCell(MyClass myClassObject)
     {
         // Display the "Name" within the UILabel outlet
         this.NameLabel.Text = myClassObject.Name;

         // This being my custom cell which inherits from UICollectionViewCell
         this.SetValueForKey(myClassObject, "BoundMyClassObject");

         // remainder omitted for brevity
     }
 }

And MyClass.cs (again, not it's real name but for illustration)
public class MyClass
{
     [JsonProperty("Id")]
     public int Id { get; set; }

     [JsonProperty("Name")]
     public string Name { get; set; }

     // more props omitted for brevity
}

Is the problem that the object I am trying to bind does not inherit from NSObject and therefore will not work with SetValueForKey.
I am hoping to bind the object to a cell, tap the cell, retrieve data bound to cell and finally make a REST call using the bound data.
The reason for this? Well I want the "Name" MyClass property to appear on the UICollectionViewCell's label and the "Id" to be accessible for the REST call but not displayed to the user. Currently the label appears the TapGesture works but I am unable to retrieve the value for myClassObject.Id and thus cannot make a web call!
The UITapGestureRecognizer is wired up to the UICollectionView within  my UICollectionViewController- code not required for scope of question) and corrently fires an event but requires the value for key "BoundMyClassObject" or myClassObject.Id to POST as JSON...
Make sense?
Please help me out as there is very little information within Xamarin documentation and forums.
All the best,
John
EDIT
As @AdamKemp points out in the post here SetValueForKey is meant for NSObjects.
So I refactored the code in MyClass.cs as follows
[Register("MyClass)]
    public class My Class : NSObject
    {
        public MyClass() { }
    public MyClass(int ID)
    {
        this.Id = ID;
    }

    private int _Id = 0;
    [Export("Id")]
    public int Id
    {
        get
        {
            return _Id;
        }
        set
        {
            WillChangeValue("Id");
            _Id = value;
            DidChangeValue("Id");
        }
    }

    // same for Name property
}

However when I call SetValueForKey within my UpdateCell method
 MyClass myClassObject = newMyClass(7); // int passed to constructor for illustration in my real code it's dynamic

    this.SetValueForKey(myClassObject, "MyClassObject");

I encounter the following error
Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSUnknownKeyException Reason: [<UICollectionViewCell 0x7e433a30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key MyClassObject.

A: Okay,
I added the following properties to my UICollectionViewCell class:
[Export("Id")]
NSNumber Id { get; set; }
[Export("Name")]
NSString Name { get; set; }

And also changes the arguments passed to SetValueForKey
this.SetValueForKey(new NSNumber(7),
                    new NSString("Id"));

Then it will correctly allocate the value 7 to the property of this UICollectionViewCell. Note that your properties must ALL be decorated with [Export].
In fact the MyClass.cs is no longer needed - if you place the properties within the custom UICollectionViewCell and call SetValueForKey to initialize them.
They can then be read out anywhere by using
NSNumber instanceID = (NSNumber)cell.ValueForKey(new NSString("Id"));

Then you can use the data retrieved from this call and pass to your data access layer as necessary.
As an aside, the SetValueForKey method expects an NSObject (or a child of this) as the first argument. Annoyingly NSDate can be a pain so I made an extension method for converting C# DateTime to NSDate for easy data binding:
public static NSDate DateTimeToNSDate(DateTime date)
{
    return NSDate.FromTimeIntervalSinceReferenceDate((date - (new DateTime(2001, 1, 1, 0, 0, 0))).TotalSeconds);
}

public static DateTime NSDateToDateTime(NSDate date)
{
    return (new DateTime(2001, 1, 1, 0, 0, 0)).AddSeconds(date.SecondsSinceReferenceDate);
}

Finally, see this Xamarin tutorial for more information on data binding.
I hope this helps people in the future! (Hi future people - has the singularity occurred yet?)


text:
Q: Playing MP3 files using pure Java Is it possible at all to play MP3 files using only the built-in libraries provided with JDK. I've heard of the javax.media library which is found is 1.7 I think. By the way I know of jlayer but I don't want to use it.

A: Yes you can play MP3 file, but you need to download MP3 plugin because java framework only supports WAV and AIFF files.
Check http://www.morgenstille.at/blog/how-to-play-a-mp3-file-in-java-simple-and-beautiful/


text:
Q: Mongo DB: How to enable authentication only on single database Assume, I have 3 databases AX,BX,CX
I want to enable authentication only on the DB CX.
My understanding is, we can enable authentication only on port (example-27017).
Can you pleas help me in setting up authentication only on CX DB


text:
Q: How can I check the current camera id in android api 8? I am trying let my camera in android switch from back to front. In order to do that I first need to check which direction it is facing. Therefore I did this:
CameraInfo cameraInfo = new Camera.CameraInfo();
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
    ...
}

This code just works with API 9 and higher. What can I do in lower api's?

A: You won't be able to use front camera in API 8 and below, because multiple camera support has been added in API 9. Check Platform highlights and this tutorial.


text:
Q: Simple formula for Adjusted Mutual Information for the two clusters Given two partitions of a dataset into clusters, we can evaluate their similarity via adjusted mutual information (AMI). However, the formula is rather complicated in the general case.
In the specific case where each partition splits the dataset into exactly two clusters with one much smaller than the other, is there a simple formula or approximate formula for AMI?
Concretely, suppose the dataset has $N$ discrete elements. Partition 1 splits the data into a cluster of size $a$ and $N-a$, with $a \ll N$. Partition 2 splits the data into a cluster of size $b$ and $N-b$, with $b \ll N$. The intersection between the smaller cluster of each partition has size $c \ll N$.
In terms of $[N, a, b, c]$, what is an approximate formula for the AMI between partitions 1 and 2?


text:
Q: Ruby reorganizing a hash I'm trying to reorganize a hash so that a specific key is at the beginning, and another key is at the end. For example:
x = {:a => 123, :b => 456, :c => 789, :d => 123}
# returns => {:a=>123, :b=>456, :c=>789, :d=>123}
x.sort.reverse!
# returns => [[:d, 123], [:c, 789], [:b, 456], [:a, 123]]

How can I make the hash start with c and end with b after the sort?
EDIT: I need to order the hash because of when I do "x.each |key, object| do..." I need the hash to start with a particular key

A: x = {:a => 123, :b => 456, :c => 789, :d => 123}

c, b = x.delete(:c), x.delete(:b)
Hash[[[:c, c], *x.sort.reverse, [:b, b]]]
# => {:c => 789, :d => 123, :a => 123, :b => 456}

or
c, b = x.delete(:c), x.delete(:b)
Hash[:c, c, *x.sort.reverse.flatten, :b, b]
# => {:c => 789, :d => 123, :a => 123, :b => 456}

A: Don't rely on hashes order. Get the keys, order them, and loop the hash:
keys = x.keys
#sort how you need it
keys.each do |key|
  object = x[key]
  #do what you want
end

A: Since Ruby 1.9 hashs keep their order (although this is ignored to the == operator). The problem is that most of these methods predate 1.9, they used to return an array. You can easily create a Hash from a pair-value Array this way:
x = {c: 1, d: 2, a: 3, b: 4}

x.sort.reverse
#=> [[:d, 2], [:c, 1], [:b, 4], [:a, 3]]

Hash[x.sort.reverse]
#=> {:d=>2, :c=>1, :b=>4, :a=>3}


text:
Q: Seg fault when using multiple levels of indirection When allocating and then attempting to access an array of pointers to pointers:
void tester(char ***p)
{
    int i;
    char **pp;

    pp = *p;
    pp = calloc(10, sizeof(*pp));

    for (i = 0; i < 10; i++)
        printf("%d = %p\n", i, pp[i]);

            *p = pp;
}

void tester_broken(char ***p)
{
    int i;

    *p = calloc(10, sizeof(**p));

    for (i = 0; i < 10; i++)
        printf("%d = %p\n", i, *p[i]);
}

int main(void)
{
    char **a;

    tester(&a);
    tester_broken(&a);

    return 0;
}

Can anyone explain why one of these works and the other seg faults?

A: It's a precedence problem.  Try:
void tester_fixed(char ***p)
{
    int i;

    *p = calloc(10, sizeof(**p));

    for (i = 0; i < 10; i++)
        printf("%d = %p\n", i, (*p)[i]);
}

The bracket operator (array subscripting) binds tighter than the asterisk operator (dereference).  The parentheses make your intent explict.


text:
Q: Correlated noise in Kalman filter Assume a standard state-space setting:
\begin{align}
x_{t+1} &= Ax_t + w_t\\
y_t &= Cx_t+v_t,
\end{align}
where the noise sequences are i.i.d. Gaussian with $w_i\sim N(0,W)$ and $v_i\sim N(0,V)$.
I am interested in the pre- and post- error covariance matrices recursions when there is a correlation $\mathbb{E}[w_tv_t^\top]= S$.
Specifically, using the notation
\begin{align}
\Sigma_{t|t} &= \mathbf{cov}(x_{t}|y^t)\\
\Sigma_{t+1|t} &= \mathbf{cov}(x_{t+1}|y^t),
\end{align}
how does the standard propagations:
\begin{align}
\Sigma_{t|t}&= \Sigma_{t|t-1} - \Sigma_{t|t-1} C^\top (C\Sigma_{t|t-1}C^\top+V)^{-1}C \Sigma_{t|t-1}\\
\Sigma_{t+1|t} &= A\Sigma_{t|t}A^\top+W
\end{align}
change. Thanks.

A: I will use your notation, and also define the conditional mean $\hat x_{t|s} = \mathbf{E}(x_t \mid y^{s})$.
The way you wrote the KF updates in your question have them split in two steps, the "measurement update" $(t|t-1) \to (t|t)$ and the "time update" $(t|t) \to (t+1|t)$.
In general, you can just combine the two updates into a single update $(t|t-1) \to (t+1|t)$. Here is what you get for the case $S\neq 0$ when you do that; these are the standard KF update equations.
$$
\begin{aligned}
\Sigma_{t+1|t} &= \left(A \Sigma_{t|t-1} A^\top + W\right) - \left( A \Sigma_{t|t-1} C^\top + S \right) \left( C \Sigma_{t|t-1} C^\top + V \right)^{-1} \left( C \Sigma_{t|t-1}A^\top + S^\top\right) \\
L_t &= \left( A \Sigma_{t|t-1} C^\top + S \right) \left( C \Sigma_{t|t-1} C^\top + V \right)^{-1} \\
\hat x_{t+1|t} &= A \hat x_{t|t-1} + L_t (y_t - C\hat x_{t|t-1})
\end{aligned}
$$
If you want to look at the measurement and time updates separately, that's also possible. The measurement update when $S\neq 0$ is the same as in the case $S=0$. For completeness sake, here is the measurement update:
\begin{align}
\hat x_{t|t} &= \hat x_{t|t-1} + \Sigma_{t|t-1} C^\top (C\Sigma_{t|t-1}C^\top +V)^{-1}(y_t - C \hat x_{t|t-1})\\
\Sigma_{t|t} &= \Sigma_{t|t-1} - \Sigma_{t|t-1} C^\top (C\Sigma_{t|t-1}C^\top+V)^{-1}C \Sigma_{t|t-1}
\end{align}
The time update is different when $S\neq 0$. Actually, you can't write $(t+1|t)$ neatly in terms of just $(t|t)$. I'll try to give some insight. When $S=0$, you can take the state update equation $x_{t+1} = Ax_t + w_t$ and take conditional expectations given $(y_0,\dots,y_t)$ and directly obtain $\hat x_{t+1|t} = A \hat x_{t|t}$ and $\Sigma_{t+1|t} = A\Sigma_{t|t}A^\top + W$. This works because $x_t$ and $w_t$ are independent. But when $S\neq 0$, although $x_t$ and $w_t$ are still independent by assumption, they become correlated when you condition given $(y_0,\dots,y_t)$, since $y_t$ depends on $x_t$ and $v_t$ (which is correlated with $w_t$), i.e. $y_t$ is correlated with both $x_t$ and $w_t$. Therefore, your terms involving $(w_t|y^t)$ will need to be expressed in terms of $(w_t|y^{t-1})$, which is simply $w_t$, but this introduces dependency on $(x_t|y^{t-1})$, which we were trying to avoid in the first place. Working through this, you get:
\begin{align}
\hat x_{t+1|t} &= A\hat x_{t|t} + S (C\Sigma_{t|t-1}C^\top +V)^{-1}(y_t - C \hat x_{t|t-1})\\
\Sigma_{t+1|t} &= A\Sigma_{t|t}A^\top + W - \left( A \Sigma_{t|t-1} C^\top + S \right) \left( C \Sigma_{t|t-1} C^\top + V \right)^{-1} \left( C \Sigma_{t|t-1}A^\top + S^\top\right)\\
&\hspace{1cm}+A\Sigma_{t|t-1} C^\top (C\Sigma_{t|t-1}C^\top+V)^{-1}C \Sigma_{t|t-1}A^\top
\end{align}
Note that combining the measurement and time updates recovers the standard KF update equations at the top of the post.


text:
Q: Css file is not being updated after clearing cache I did the following:
1. clearing cache (press Ctrl + F5).
2. remove css file and then upload again.
3. checked updated css file manually.
4. I remove browser data from chrome setting
From the above test it should load updated css. but it is being loaded old css.
Here is the old link: http://demo.voberhat.com/wp-content/themes/bootstraplight/style.css?ver=4.9.6
I can see update at : http://demo.voberhat.com/wp-content/themes/bootstraplight/style.css
Meaning version change may be the trick. But why should I change version just to add one line css? Any idea?

A: Force browser to refresh css, javascript, etc
Try this Stackoverflow thread. If it's not what your looking for then I can provide some PHP.


text:
Q: How to grant root privilages to an user in ubuntu 18.04 how do give full permissions to the normal user in Ubuntu 18.04

A: You can use the /etc/sudoers.tmp file to modify the user permissions
First with root user:
sudo -i

run the following command to lead you to the /etc/sudoers.tmp folder
visudo

in the nano screen navigate down to the section #User privilege specification
you can see that the root user have this privilege specifications
root ALL=(ALL:ALL) ALL

you can edit the admin user as the same format or add your user to the file
for example:
mehran ALL=(ALL:ALL) ALL

you can check if the user have permissions with the command
grep '^sudo' /etc/group

If the output was sudo:x:27:yourusername, then you granted the user root privileges.

A: It is very dangerous for system's stability to work as root in GUI mode as it was in Windows XP.

If you have a user you want to give all admin privileges to, the best
  method is to simply add that user to the admin group. You will notice
  this line, in the /etc/sudoers file:
%admin ALL=(ALL) ALL

This means all members of the admin group have full sudo privileges.
  To add your user to the admin group, you would issue the command (as a
  user who already has full sudo privileges):
sudo usermod -a -G sudo USERNAME

Where USERNAME is the name of the user to be added. Once the user logs
  out and logs back in, they will now enjoy full sudo privileges.

Reference
To run an app with full admin privileges, just type sudo before a command:
sudo app

You will need to enter your USERNAME's password. System remembers this password for some time, so consequent commands you'll run without password inputing for some time.
Note: password you'll be typing will not be visible in terminal


text:
Q: Printing content of XML in Twig I am trying to print some basic logs in Perl but I get stuck on a very simple issue: I cannot print the contents of XML tags.
my $twig=XML::Twig->new(pretty_print => "nice");
$twig->parse($xml);
my $root = $twig->root;

my @desc=$root->descendants_or_self('node');
my $nrofdesc=@desc;

my $sentence = $root->descendants('sentence')->print;
my $sentenceid = $root->{att}->{id};

if ($nrofdesc > $maxdescendants) {
  print "$sentence\t$nrofdesc\t$sentenceid\n";
}

I tried tthe code above but I receive the error

Can't call method "print" without a package or object reference at
  file.pl line 35,  line 15.

Which is this line:
my $sentence = $root->descendants('sentence')->print;

I also tried text as is often proposed, but I get the same error. What am I missing here?

A: This is not jQuery ;--( You have to iterate through the list of descendants.
Plus you can't use print to collect data in a variable, you use print to... print! Use sprint instead:
$sentence= join '', map { $_->sprint } $root->descendants('sentence');

If what you want is the text of the elements, and the contents of all sentence elements is pure text, you could also use $sentence= $root->findvalue( '//sentence')
Also, use $root->att( 'id'), or $root->id since $root->{att}->{id} is not part of the official API, and could potentially change in the future.


text:
Q: How to deal with r(123) in did_imputation command? I ran the did_imputation command in Stata and got  faced the ms_get_version error. I follow a discussion from Statalist to run the code below to fix:
ssc install ftools

However, after that, when running did_imputation, I faced the problem of r(123). I had a look around and they say it may be due to name encoding, number of variables .... however, none of them are my problem. I only have 1 milion observations, while my Stata package allows me up to 1 billion observations.
I am wondering if there is any guidance for helping me to sort it out.
did_imputation lnq_r id2 ndate nbanned_date, horizons(0/10) pretrend(10)

I have tried to look at the variables and I am sure all of them are numeric or already encoded to numeric by using encode.
Update:
After learning the code from @NickCox, I got the resultsa below and I am still not sure what happened causing my error, from what I saw, it seems that the errors coming from time dimension but it is clear that these two time dimensions in the equationm were written under date DMY format so should not be non-integer
  ----------------------------------------------------------------------------------------------------------------------------------------------------- begin did_imputation ---
  - version 13.0
  - syntax varlist(min=4 max=4) [if] [in] [aw iw] [, wtr(varlist) sum Horizons(numlist >=0) ALLHorizons HBALance minn(integer 30) shift(integer 0) AUTOSample SAVEestimates(name
> ) SAVEWeights LOADWeights(varlist) AVGEFFectsby(varlist) fe(string) Controls(varlist) UNITControls(varlist) TIMEControls(varlist) CLUSter(varname) leaveout tol(real 0.000001)
>  maxit(integer 100) verbose nose PREtrends(integer 0) delta(integer 0) alpha(real 0.05)]
  - qui {
  - if ("`verbose'"!="") noi di "Starting"
  = if (""!="") noi di "Starting"
  - ms_get_version reghdfe, min_version("5.7.3")
    ms_get_version ftools, min_version("2.37.0")
    marksample touse, novarlist
    if ("`controls'"!="") markout `touse' `controls'
    if ("`unitcontrols'"!="") markout `touse' `unitcontrols'
    if ("`timecontrols'"!="") markout `touse' `timecontrols'
    if ("`cluster'"!="") markout `touse' `cluster', strok
    if ("`saveestimates'"!="") confirm new variable `saveestimates'
    if ("`saveweights'"!="") confirm new variable `saveweights'
    if ("`verbose'"!="") noi di "#00"
    tempvar wei
    if ("`weight'"=="") {
    gen `wei' = 1
    local weiexp ""
    }
    else {
    gen `wei' `exp'
    replace `wei' = . if `wei'==0
    markout `touse' `wei'
    if ("`sum'"=="") {
    sum `wei' if `touse'
    replace `wei' = `wei' * r(N)/r(sum)
    }
    local weiexp "[`weight'=`wei']"
    }
    local debugging = ("`verbose'"=="verbose")
    tokenize `varlist'
    local Y `1'
    local i `2'
    local t `3'
    local ei `4'
    markout `touse' `Y' `t'
    markout `touse' `i', strok
    tempvar D K
    if ("`fe'"=="") local fe `i' `t'
    if ("`fe'"==".") {
    tempvar constant
    gen `constant' = 1
    local fe `constant'
    }
    local fecount = 0
    foreach fecurrent of local fe {
    if (("`fecurrent'"!="`i'" | "`unitcontrols'"=="") & ("`fecurrent'"!="`t'" | "`timecontrols'"=="")) {
    local ++fecount
    local fecopy `fecopy' `fecurrent'
    local fe`fecount' = subinstr("`fecurrent'","#"," ",.)
    markout `touse' `fe`fecount'', strok
    }
    }
    local fe `fecopy'
    if (`delta'==0) {
    cap tsset, noquery
    if (_rc==0) {
    if (r(timevar)=="`t'") {
    local delta = r(tdelta)
    if (`delta'!=1) noi di "Note: setting delta = `delta'"
    }
    }
    else local delta = 1
    }
    if (`delta'<=0 | mi(`delta')) {
    di as error "A problem has occured with determining delta. Please specify it explicitly."
    error 198
    }
    if (`debugging') noi di "#1"
    gen `K' = (`t'-`ei'+`shift')/`delta' if `touse'
    cap assert mi(`K') | mod(`K',1)==0
    if (_rc!=0) {
    di as error "There are non-integer values of the number of periods since treatment. Please check the time dimension of your data."
    error 198
    }
    gen `D' = (`K'>=0 & !mi(`K')) if `touse'
    if ("`avgeffectsby'"=="") local avgeffectsby = "`ei' `t'"
    if ("`cluster'"=="") local cluster = "`i'"
    if ("`autosample'"!="" & "`sum'"!="") {
    di as error "Autosample cannot be combined with sum. Please specify the sample explicitly"
    error 184
    }
    if ("`autosample'"!="" & "`hbalance'"!="") {
    di as error "Autosample cannot be combined with hbalance. Please specify the sample explicitly"
    error 184
    }
    if (`debugging') noi di "#2 `fe'"
    local wtr_count : word count `wtr'
    if (`wtr_count'==0) {
    tempvar wtr
    gen `wtr' = 1 if (`touse') & (`D'==1)
    local wtrnames tau
    local wtr_count = 1
    }
    else {
    if (`wtr_count'==1) local wtrnames tau
    else local wtrnames ""
    local wtr_new_list
    foreach v of local wtr {
    tempvar `v'_new
    gen ``v'_new' = `v' if `touse'
    local wtr_new_list `wtr_new_list' ``v'_new'
    if (`wtr_count'>1) local wtrnames `wtrnames' tau_`v'
    }
    local wtr `wtr_new_list'
    }
    if (("`horizons'"!="" | "`allhorizons'"!="") & `wtr_count'>1) {
    di as error "Options horizons and allhorizons cannot be combined with multiple wtr variables"
    error 184
    }
    if ("`allhorizons'"!="") {
    if ("`horizons'"!="") {
    di as error "Options horizons and allhorizons cannot be combined"
    error 184
    }
    if ("`hbalance'"!="") di as error "Warning: combining hbalance with allhorizons may lead to very restricted samples. Consider specifying a smaller subset of horizons."
    levelsof `K' if `touse' & `D'==1 & `wtr'!=0 & !mi(`wtr'), local(horizons)
    }
    if ("`horizons'"!="") {
    if ("`hbalance'"=="hbalance") {
    tempvar in_horizons num_horizons_by_i min_weight_by_i max_weight_by_i
    local n_horizons = 0
    gen `in_horizons'=0 if `touse'
    foreach h of numlist `horizons' {
    replace `in_horizons'=1 if (`K'==`h') & `touse'
    local ++n_horizons
    }
    egen `num_horizons_by_i' = sum(`in_horizons') if `in_horizons'==1, by(`i')
    replace `wtr' = 0 if `touse' & (`in_horizons'==0 | (`num_horizons_by_i'<`n_horizons'))
    egen `min_weight_by_i' = min(`wtr'*`wei') if `touse' & `in_horizons'==1 & (`num_horizons_by_i'==`n_horizons'), by(`i')
    egen `max_weight_by_i' = max(`wtr'*`wei') if `touse' & `in_horizons'==1 & (`num_horizons_by_i'==`n_horizons'), by(`i')
    cap assert `max_weight_by_i'<=1.000001*`min_weight_by_i' if `touse' & `in_horizons'==1 & (`num_horizons_by_i'==`n_horizons')
    if (_rc>0) {
    di as error "Weights must be identical across periods for units in the balanced sample"
    error 498
    }
    drop `in_horizons' `num_horizons_by_i' `min_weight_by_i' `max_weight_by_i'
    }
    foreach h of numlist `horizons' {
    tempvar wtr`h'
    gen `wtr`h'' = `wtr' * (`K'==`h')
    local horlist `horlist' `wtr`h''
    local hornameslist `hornameslist' tau`h'
    }
    local wtr `horlist'
    local wtrnames `hornameslist'
    }
    if (`debugging') noi di "List: `wtr'"
    if (`debugging') noi di "Namelist: `wtrnames'"
    if ("`sum'"=="") {
    foreach v of local wtr {
    cap assert `v'>=0 if (`touse') & (`D'==1)
    if (_rc!=0) {
    di as error "Negative wtr weights are only allowed if the sum option is specified"
    error 9
    }
    sum `v' `weiexp' if (`touse') & (`D'==1)
    replace `v' = `v'/r(sum)
    }
    }
    local tau_num : word count `wtr'
    local ctrl_num : word count `controls'
    if (`debugging') noi di `tau_num'
    if (`debugging') noi di `"`wtr' | `wtrnames' | `controls'"'
    tempname b Nt
    matrix `b' = J(1,`tau_num'+`pretrends'+`ctrl_num',.)
    matrix `Nt' = J(1,`tau_num',.)
    if (`debugging') noi di "#4.0"
    if ("`unitcontrols'"!="") local fe_i `i'##c.(`unitcontrols')
    if ("`timecontrols'"!="") local fe_t `t'##c.(`timecontrols')
    count if (`D'==0) & (`touse')
    if (r(N)==0) {
    if (`shift'==0) noi di as error "There are no untreated observations, i.e. those with `t'<`ei' or mi(`ei')."
    else noi di as error "There are no untreated observations, i.e. those with `t'<`ei'-`shift' or mi(`ei')."
    noi di as error "Please double-check the period & event time variables."
    noi di
    error 459
    }
    tempvar imput_resid
    if (`debugging') noi di "#4: reghdfe `Y' `controls' if (`D'==0) & (`touse') `weiexp', a(`fe_i' `fe_t' `fe', savefe) nocon keepsing resid(`imput_resid') cluster(`cluster')"
    if (`debugging') noi reghdfe `Y' `controls' if (`D'==0) & (`touse') `weiexp', a(`fe_i' `fe_t' `fe', savefe) nocon keepsing resid(`imput_resid') cluster(`cluster')
    else reghdfe `Y' `controls' if (`D'==0) & (`touse') `weiexp', a(`fe_i' `fe_t' `fe', savefe) nocon keepsing resid(`imput_resid') cluster(`cluster')verbose(-1)
    local dof_adj = (e(N)-1)/(e(N)-e(df_m)-e(df_a)) * (e(N_clust)/(e(N_clust)-1))
    if (`debugging') noi di "#5"
    tempvar Y0
    gen `Y0' = 0 if `touse'
    local feset = 1
    if ("`unitcontrols'"!="") {
    recover __hdfe`feset'__*, from(`i')
    replace `Y0' = `Y0' + __hdfe`feset'__ if `touse'
    local j=1
    foreach v of local unitcontrols {
    replace `Y0' = `Y0'+__hdfe`feset'__Slope`j'*`v' if `touse'
    local ++j
    }
    local ++feset
    }
    if ("`timecontrols'"!="") {
    recover __hdfe`feset'__*, from(`t')
    replace `Y0' = `Y0' + __hdfe`feset'__ if `touse'
    local j=1
    foreach v of local timecontrols {
    replace `Y0' = `Y0'+__hdfe`feset'__Slope`j'*`v' if `touse'
    local ++j
    }
    local ++feset
    }
    forvalues feindex = 1/`fecount' {
    recover __hdfe`feset'__, from(`fe`feindex'')
    replace `Y0' = `Y0' + __hdfe`feset'__ if `touse'
    local ++feset
    }
    foreach v of local controls {
    replace `Y0' = `Y0'+_b[`v']*`v' if `touse'
    }
    if (`debugging') noi di "#7"
    if ("`saveestimates'"=="") tempvar effect
    else {
    local effect `saveestimates'
    cap confirm var `effect', exact
    if (_rc==0) drop `effect'
    }
    gen `effect' = `Y' - `Y0' if (`D'==1) & (`touse')
    drop __hdfe*
    if (`debugging') noi di "#8"
    if (`ctrl_num'>0) {
    forvalues h = 1/`ctrl_num' {
    local ctrl_current : word `h' of `controls'
    matrix `b'[1,`tau_num'+`pretrends'+`h'] = _b[`ctrl_current']
    local ctrlb`h' = _b[`ctrl_current']
    local ctrlse`h' = _se[`ctrl_current']
    }
    local ctrl_df = e(df_r)
    if (`debugging') noi di "#4B"
    local list_ctrl_weps
    if ("`se'"!="nose") {
    if (`debugging') noi di "#4C3"
    local ctrlvars ""
    forvalues h = 1/`ctrl_num' {
    local ctrl_current : word `h' of `controls'
    if (`ctrlb`h''!=0 | `ctrlse`h''!=0) local ctrlvars `ctrlvars' `ctrl_current'
    }
    if (`debugging') noi di "#4C4 `ctrlvars'"
    tempvar ctrlweight ctrlweight_product
    forvalues h = 1/`ctrl_num' {
    if (`debugging') noi di "#4D `h'"
    tempvar ctrleps_w`h'
    if (`ctrlb`h''==0 & `ctrlse`h''==0) gen `ctrleps_w`h'' = 0
    else {
    local ctrl_current : word `h' of `controls'
    local rhsvars = subinstr(" `ctrlvars' "," `ctrl_current' "," ",.)
    reghdfe `ctrl_current' `rhsvars' `weiexp' if `touse' & `D'==0, a(`fe_i' `fe_t' `fe') cluster(`cluster') resid(`ctrlweight')
    replace `ctrlweight' = `ctrlweight' * `wei'
    gen `ctrlweight_product' = `ctrlweight' * `ctrl_current'
    sum `ctrlweight_product' if `touse' & `D'==0
    replace `ctrlweight' = `ctrlweight'/r(sum)
    egen `ctrleps_w`h'' = total(`ctrlweight' * `imput_resid') if `touse', by(`cluster')
    replace `ctrleps_w`h'' = `ctrleps_w`h'' * sqrt(`dof_adj')
    drop `ctrlweight' `ctrlweight_product'
    }
    local list_ctrl_weps `list_ctrl_weps' `ctrleps_w`h''
    }
    }
    if (`debugging') noi di "#4.75 `list_ctrl_weps'"
    }
    tempvar need_imputation
    gen byte `need_imputation' = 0
    foreach v of local wtr {
    replace `need_imputation'=1 if `touse' & `D'==1 & `v'!=0 & !mi(`v')
    }
    replace `touse' = (`touse') & (`D'==0 | `need_imputation')
    count if mi(`effect') & `need_imputation'
    if r(N)>0 {
    if (`debugging') noi di "#8b `wtr'"
    cap drop cannot_impute
    gen byte cannot_impute = mi(`effect') & `need_imputation'
    count if cannot_impute==1
    if ("`autosample'"=="") {
    noi di as error "Could not impute FE for " r(N) " observations. Those are saved in the cannot_impute variable. Use the autosample option if you would like those observation
> s to be dropped from the sample automatically."
    error 198
    }
    else {
    assert "`sum'"==""
    local j = 1
    qui foreach v of local wtr {
    if (`debugging') noi di "#8d sum `v' `weiexp' if `touse' & `D'==1"
    local outputname : word `j' of `wtrnames'
    sum `v' `weiexp' if `touse' & `D'==1
    if (`debugging') noi di "#8dd " r(sum)
    assert abs(r(sum)-1)<10^-5 | abs(r(sum))<10^-5
    count if `touse' & `D'==1 & cannot_impute==1 & `v'!=0 & !mi(`v')
    local n_cannot_impute = r(N)
    if (`n_cannot_impute'>0) {
    sum `v' `weiexp' if `touse' & `D'==1 & cannot_impute!=1 & `v'!=0 & !mi(`v')
    if (r(N)==0) {
    replace `v' = 0 if `touse' & `D'==1
    local autosample_drop `autosample_drop' `outputname'
    }
    else {
    replace `v' = `v'/r(sum) if `touse' & `D'==1 & cannot_impute!=1
    replace `v' = 0 if cannot_impute==1
    local autosample_trim `autosample_trim' `outputname'
    }
    }
    local ++j
    }
    if (`debugging') noi di "#8e"
    replace `touse' = `touse' & cannot_impute!=1
    if ("`autosample_drop'"!="") noi di "Warning: suppressing the following coefficients because FE could not be imputed for any units: `autosample_drop'."
    if ("`autosample_trim'"!="") noi di "Warning: part of the sample was dropped for the following coefficients because FE could not be imputed: `autosample_trim'."
    }
    }
    if (`debugging') noi di "#8c"
    tempvar tnorm
    gen `tnorm' = rnormal() if (`touse') & (`D'==0 | `need_imputation')
    reghdfe `tnorm' `controls' if (`D'==0) & (`touse'), a(`fe_i' `fe_t' `fe') nocon keepsing verbose(-1)
    local df_m_control = e(df_m)
    local df_a_control = e(df_a)
    reghdfe `tnorm' `controls' , a(`fe_i' `fe_t' `fe') nocon keepsing verbose(-1)
    local df_m_full = e(df_m)
    local df_a_full = e(df_a)
    if (`debugging') noi di "#9 `df_m_control' `df_m_full' `df_a_control' `df_a_full'"
    if (`df_m_control'<`df_m_full') {
    di as error "Could not run imputation for some observations because some controls are collinear in the D==0 subsample but not in the full sample"
    if ("`autosample'"!="") di as error "Please note that autosample does not know how to deal with this. Please correct the sample manually"
    error 481
    }
    if (`df_a_control'<`df_a_full') {
    di as error "Could not run imputation for some observations because some absorbed variables/FEs are collinear in the D==0 subsample but not in the full sample"
    if ("`autosample'"!="") di as error "Please note that autosample does not know how to deal with this. Please correct the sample manually"
    error 481
    }
    local droplist
    tempvar abswei
    gen `abswei' = .
    local j = 1
    foreach v of local wtr {
    local outputname : word `j' of `wtrnames'
    replace `abswei' = abs(`v') if (`touse') & (`D'==1)
    sum `abswei' `weiexp'
    if (r(sum)!=0) {
    replace `abswei' = (`v'*`wei'/r(sum))^2 if (`touse') & (`D'==1)
    sum `abswei'
    if (r(sum)>1/`minn') {
    local droplist `droplist' `outputname'
    replace `v' = 0 if `touse'
    }
    }
    else local droplist `droplist' `outputname'
    local ++j
    }
    if ("`droplist'"!="") noi di "WARNING: suppressing the following coefficients from estimation because of insufficient effective sample size: `droplist'. To report them neve
> rtheless, set the minn option to a smaller number or 0, but keep in mind that the estimates may be unreliable and their SE may be downward biased."
    if (`debugging') noi di "#9.5"
    if (`pretrends'>0) {
    tempname pretrendvar
    tempvar preresid
    forvalues h = 1/`pretrends' {
    gen `pretrendvar'`h' = (`K'==-`h') if `touse'
    local pretrendvars `pretrendvars' `pretrendvar'`h'
    local prenames `prenames' pre`h'
    }
    if (`debugging') noi di "#9A reghdfe `Y' `controls' `pretrendvars' `weiexp' if `touse' & `D'==0,  a(`fe_i' `fe_t' `fe') cluster(`cluster') resid(`preresid')"
    reghdfe `Y' `controls' `pretrendvars' `weiexp' if `touse' & `D'==0, a(`fe_i' `fe_t' `fe') cluster(`cluster') resid(`preresid')
    forvalues h = 1/`pretrends' {
    matrix `b'[1,`tau_num'+`h'] = _b[`pretrendvar'`h']
    local preb`h' = _b[`pretrendvar'`h']
    local prese`h' = _se[`pretrendvar'`h']
    }
    local pre_df = e(df_r)
    if (`debugging') noi di "#9B"
    local list_pre_weps
    if ("`se'"!="nose") {
    matrix pre_b = e(b)
    if (`debugging') noi di "#9C1"
    matrix pre_V = e(V)
    if (`debugging') noi di "#9C2"
    local dof_adj = (e(N)-1)/(e(N)-e(df_m)-e(df_a)) * (e(N_clust)/(e(N_clust)-1))
    if (`debugging') noi di "#9C3"
    local pretrendvars ""
    forvalues h = 1/`pretrends' {
    if (`preb`h''!=0 | `prese`h''!=0) local pretrendvars `pretrendvars' `pretrendvar'`h'
    }
    if (`debugging') noi di "#9C4 `pretrendvars'"
    tempvar preweight
    forvalues h = 1/`pretrends' {
    if (`debugging') noi di "#9D `h'"
    tempvar preeps_w`h'
    if (`preb`h''==0 & `prese`h''==0) gen `preeps_w`h'' = 0
    else {
    local rhsvars = subinstr(" `pretrendvars' "," `pretrendvar'`h' "," ",.)
    reghdfe `pretrendvar'`h' `controls' `rhsvars' `weiexp' if `touse' & `D'==0, a(`fe_i' `fe_t' `fe') cluster(`cluster') resid(`preweight')
    replace `preweight' = `preweight' * `wei'
    sum `preweight' if `touse' & `D'==0 & `pretrendvar'`h'==1
    replace `preweight' = `preweight'/r(sum)
    egen `preeps_w`h'' = total(`preweight' * `preresid') if `touse', by(`cluster')
    replace `preeps_w`h'' = `preeps_w`h'' * sqrt(`dof_adj')
    drop `preweight'
    }
    local list_pre_weps `list_pre_weps' `preeps_w`h''
    }
    }
    if (`debugging') noi di "#9.75"
    }
    count if `D'==0 & `touse'
    local Nc = r(N)
    count if `touse'
    local Nall = r(N)
    tempvar effectsum
    gen `effectsum' = .
    local j = 1
    foreach v of local wtr {
    local outputname : word `j' of `wtrnames'
    if (`debugging') noi di "Reporting `j' `v' `outputname'"
    replace `effectsum' = `effect'*`v'*`wei' if (`D'==1) & (`touse')
    sum `effectsum'
    matrix `b'[1,`j'] = r(sum)
    count if `D'==1 & `touse' & `v'!=0 & !mi(`v')
    matrix `Nt'[1,`j'] = r(N)
    local ++j
    }
    if (`debugging') noi di "#10"
    if ("`se'"!="nose") {
    cap drop __w_*
    tempvar tag_clus resid
    egen `tag_clus' = tag(`cluster') if `touse'
    gen `resid' = `Y' - `Y0' if (`touse') & (`D'==0)
    if ("`loadweights'"=="") {
    local weightvars = ""
    foreach vn of local wtrnames {
    local weightvars `weightvars' __w_`vn'
    }
    if (`debugging') noi di "#11a imputation_weights `i' `t' `D' , touse(`touse') wtr(`wtr') saveweights(`weightvars') wei(`wei') fe(`fe') controls(`controls') unitcontrols(`un
> itcontrols') timecontrols(`timecontrols') tol(`tol') maxit(`maxit')"
    noi imputation_weights `i' `t' `D', touse(`touse') wtr(`wtr') saveweights(`weightvars') wei(`wei') fe(`fe') controls(`controls') unitcontrols(`unitcontrols') timecontrols(`
> timecontrols') tol(`tol') maxit(`maxit') `verbose'
    local Niter = r(iter)
    }
    else {
    local weightvars `loadweights'
    }
    local list_weps = ""
    local j = 1
    foreach v of local wtr {
    if (`debugging') noi di "#11b `v'"
    local weightvar : word `j' of `weightvars'
    tempvar clusterweight smartweight smartdenom avgtau eps_w`j'
    egen `clusterweight' = total(`wei'*`v') if `touse' & (`D'==1), by(`cluster' `avgeffectsby')
    egen `smartdenom' = total(`clusterweight' * `wei' * `v') if `touse' & (`D'==1), by(`avgeffectsby')
    gen `smartweight' = `clusterweight' * `wei' * `v' / `smartdenom' if `touse' & (`D'==1)
    replace `smartweight' = 0 if mi(`smartweight') & `touse' & (`D'==1)
    egen `avgtau' = sum(`effect'*`smartweight') if (`touse') & (`D'==1), by(`avgeffectsby')
    replace `resid' = `effect'-`avgtau' if (`touse') & (`D'==1)
    if ("`leaveout'"!="") {
    if (`debugging') noi di "#11LO"
    count if `smartdenom'>0 & ((`clusterweight'^2)/`smartdenom'>0.99999) & (`touse') & (`D'==1)
    if (r(N)>0) {
    local outputname : word `j' of `wtrnames'
    di as error `"Cannot compute leave-out standard errors because of "' r(N) `" observations for coefficient "`outputname'""'
    di as error "This most likely happened because there are cohorts with only one unit or cluster (and the default value for avgeffectsby  is used)."
    di as error "Consider using the avgeffectsby option with broader observation groups. Do not address this problem by using non-leave-out standard errors, as they may be down
> ward biased for the same reason."
    error 498
    }
    replace `resid' = `resid' * `smartdenom' / (`smartdenom'-(`clusterweight'^2)) if (`touse') & (`D'==1)
    }
    egen `eps_w`j'' = sum(`wei'*`weightvar'*`resid') if `touse', by(`cluster')
    local list_weps `list_weps' `eps_w`j''
    drop `clusterweight' `smartweight' `smartdenom' `avgtau'
    local ++j
    }
    if (`debugging') noi di "11c"
    tempname V
    if (`debugging') noi di "11d `list_weps' | `list_pre_weps' | `list_ctrl_weps'"
    matrix accum `V' = `list_weps' `list_pre_weps' `list_ctrl_weps' if `tag_clus', nocon
    if (`debugging') noi di "11e `wtrnames' | `prenames' | `controls'"
    matrix rownames `V' = `wtrnames' `prenames' `controls'
    matrix colnames `V' = `wtrnames' `prenames' `controls'
    if ("`saveweights'"=="" & "`loadweights'"=="") drop __w_*
    }
    if (`debugging') noi di "#12"
    matrix colnames `b' = `wtrnames' `prenames' `controls'
    matrix colnames `Nt' = `wtrnames'
    ereturn post `b' `V', esample(`touse') depname(`Y') obs(`Nall')
    ereturn matrix Nt = `Nt'
    ereturn scalar Nc = `Nc'
    ereturn local depvar `Y'
    ereturn local cmd did_imputation
    ereturn local droplist `droplist'
    ereturn local autosample_drop `autosample_drop'
    ereturn local autosample_trim `autosample_trim'
    if ("`Niter'"!="") ereturn scalar Niter = `Niter'
    if (`pretrends'>0 & "`se'"!="nose") {
    test `prenames', df(`pre_df')
    ereturn scalar pre_F = r(F)
    ereturn scalar pre_p = r(p)
    ereturn scalar pre_df = `pre_df'
    }
    }
  ------------------------------------------------------------------------------------------------------------------------------------------------------- end did_imputation ---
r(123);

A: .   error 123
invalid numlist has too many elements
r(123);

hints that you may be asking too much. Not much else can be said helpfully without access to your data. But
set trace on
set tracedepth 1

before running your command may indicate where the error occurs. If necessary, bump up tracedepth to 2, 3, and so on.

A: The help file for did_imputation indicates this package has two dependencies: ftools and reghdfe. Have you confirmed you've installed both?
ssc install ftools
ssc install reghdfe


text:
Q: Small And Big Cell Size with Sequence in UICollectionView I would like to have 3 small cell, then 2 big cells, and then 3 small cells again, repeatedly, in my UICollectionView,
I know that it has something to do with this function, but I am confused as how to achieve the result
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

}

Please take a look at the screenshot.

A: You can calculate modulo of indexPath.row like this way.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
     if (indexPath.row % 5 == 3 || indexPath.row % 5 == 4) {
         //return big cell size
         let size = (collectionView.frame.size.width - minSpace) / 2
         return CGSize(width: size, height: size)
     }
     else {
         //return small cell size
         let size = (collectionView.frame.size.width - minSpace) / 3
         return CGSize(width: size, height: size)
     }
}

Note: Here minSpace is minimum space that you want between two cells.


text:
Q: get sales_quote model in sales/Ordercontroller magento backend How can I get sales_quote model in ordercontroller Magento backend? I need to get the quote details in the ordercontroller, so I'm using the following code.
$quote= Mage::getModel('sales/quote')->load($quoteid);

Above query returns empty data. which is below
  Mage_Sales_Model_Quote Object
(
    [_eventPrefix:protected] => sales_quote
    [_eventObject:protected] => quote
    [_customer:protected] =>
    [_addresses:protected] =>
    [_items:protected] =>
    [_payments:protected] =>
    [_errorInfoGroups:protected] => Array
        (
        )

    [_preventSaving:protected] =>
    [_resourceName:protected] => sales/quote
    [_resource:protected] =>
    [_resourceCollectionName:protected] => sales/quote_collection
    [_cacheTag:protected] =>
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] =>
    [_data:protected] => Array
        (
        )

    [_hasDataChanges:protected] =>
    [_origData:protected] =>
    [_idFieldName:protected] =>
    [_isDeleted:protected] =>
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)

Is there any way to get quote?

A: I was having the same problem. After looking through the code for a while I came across this function:
Mage_Sales_Model_Quote::loadByIdWithoutStore()

I guess the regular Mage_Sales_Model_Quote::load() function automatically attaches the current storeview to load the quote object. In this case the storeview is admin, which means no results will be found for the quote id and the returned object is empty.
In your case, this should work as expected:
$quote= Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteid);

A: i guess, your quote id is missing, check before loading the model ,
 try this code
if($quoteID)
{
    try {
        $quote = Mage::getModel("sales/quote")->load($quoteID);

    } catch(Exception $e) {
        return $e->getMessage();
    }
}else{
    return "no quote found";
}


text:
Q: Why are the fonts all screwy for remote X11 apps on one Mac client? I have two Mac OS X clients, both running XQuartz 2.1.6 (xorg-server 1.4.2-apple33). When I SSH into a remote linux system enabling X11 forwarding and launch gnome-terminal, on one Mac the terminal looks correct while on the other, the fonts are all screwy!
[jnet@Stan ~]$ ssh -X jnet@kyle.local gnome-terminal produces:

powerbook:~ hp$ ssh -X jnet@kyle.local gnome-terminal produces:

The problem goes away on the powerbook if I zoom in twice:

Edit: This affects a number of apps, not just gnome-terminal. It also affects Thunderbird, for example.


text:
Q: Koala SCSS - Errno::ENOENT: No such file or directory Here is a structure of my project:

*

*css dir

*

*style.css (there should be compiled and minified style.scss)

*font dir

*js dir

*sass dir

*

*components dir (files from materializecss)

*_main.css (my custom styles)

*_materialize.scss (import components from materializecss)

*style.scss (import materialize.scss and main.scss)

*index.html

When I try compile style.scss in Koala, I get error message:
C:\Users\Paweł\Desktop\tw2\sass\style.scss
Errno::ENOENT: No such file or directory - C:\Users\Pawe�\Desktop\tw2\sass\style.scss
  Use --trace for backtrace.

I'm Windows 7 32bit user, I don't have installed Ruby or something other stuff. How can I solve this problem?

A: Set Koala to use the system SASS compiler, maybe will fix this problem.

A: I think it`s usual problem with non latin symbols. I had same problems and the solution was to change the directory which shown as '?' on latin symbol and all compiled.


text:
Q: How to count factors frequency and organize in a new dataframe in R I have a dataframe like this:
test1 = data.frame("id" = c("FC01", "FC01", "FC22", "FC03", "FC01"),
                    "product" = c("p01", "p02", "p03", "p01", "p03"),
                    "year" = c("2018", "2017", "2015", "2018", "2016"))

I need to find the IDs that appear more than onc, bought between 2016 and 2018, and know which products they bought and which year.
Is it possible to create a new dataframe that showing the ids and how many times they appear and when did this happen? Something like this:
test2 = data.frame("times" = c(3, 1), "id" = c("FC01", "FC03"),
                   "year" = c("2018, 2017, 2016", "2018"))

I used dplyr and tried to group by id and filter every id that appears more than once, but I don't know how to continue to get something like this test2. I appreciate any tips in this regard.

A: test1$year <- as.numeric(as.character(test1$year))

test1 %>% filter(between(year,2016,2018))
      %>% group_by(id)
      %>% summarize(times = n(),
          year = toString(unique(year)))

  id    times year
  <fct> <int> <chr>
1 FC01      3 2018 2017 2016
2 FC03      1 2018

Notes:

*

*Getting the times column is easy, we just use the utility function dplyr::n().

*For the pasted list of (unique) string names of years, same approach as this answer. toString(...) is cleaner code than paste0(as.character(...), collapse=' ')

*Note we must use unique(year) as you might have multiple entries for same year.

*In order to be able to filter(between(year, 2016, 2018)), we must first fix up year to be numeric, not a factor (or at minimum, make sure the factor levels are also 2015..2018 so that directly doing as.numeric() works as intended, instead of giving 1..4


text:
Q: Why code "while (true) new Object()" will not cause OutOfMemoryException? why code
while(true)
  new Object();

will not cause OutOfMemoryException?

A: You are not assigning the new Object to any persistent variable, so you will not run out of memory because the Java Virtual Machine will garbage collect each Object before you have a chance to run out of memory.
On the other hand, if you said
List<Object> xs = new LinkedList<Object>();
while (true) {
    xs.add(new Object());
}

then they wouldn't get garbage collected automatically and you would eventually run out of memory.

A: Because you're not saving any references to the new objects you create, so the garbage-collector can simply remove them whenever it runs out of memory.

A: The JVM guarantees that, no matter what amount of garbage you create, you won't receive an OutOfMemoryError if there is reclaimable heap left. The only exception to this would be when the GC performance overhead exceeds a defined threshold. It your case, however, GC-ing is in fact utterly trivial and lightning fast: at each minor collection cycle all the Objects are collected as one huge block in the Thread-Local Area.

A: Because once each loop iteration is done, the object is eligible for GC (HEAP won't be fill because of this). When JVM needs more memory it can clean up the eligible objects.
I would suggest reading The Truth About Garbage Collection (I couldn't post the link here because it has IP, just google it).


text:
Q: Textbox border is dissappearing in windows phone mango c# i am not expert in desinging in windows phone mango UI. When I am changing the background of my layoutroot to white the text box borders dissapear when i try to edit any value in the text box...plase suggest
code
<phone:PhoneApplicationPage
    x:Class="WP7MangoSocketsTest.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBox Foreground="Black" Height="72" HorizontalAlignment="Left" Margin="127,23,0,0" Name="textBox1" Text="TextBox" VerticalAlignment="Top" Width="217" />
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>

A: That happens even when you don't set the background to white. That's because textBox has a style which makes it ignore border whenever it is selected/focused. To make it use border you'd have to define custom TextBox style (like in this post).


text:
Q: Is there a way to orderBy orOrderBy in laravel (8)? I have a scoped method on a laravel model:
public function scopeSort($query, array $params = []) {
    return $query->orderBy('read');
}

What I would like to do is say: if there are no items with read = true, then orderByDesc on id.
For example:
public function scopeSort($query, array $params = []) {
    return $query->orderBy('read')->orOrderByDesc('id');

    // Find all with a read of true or, if there is none, order the collection by id in descending order.
}

Does anything like this exist? Or is there some other way I can achieve this?

A: You can chain your sorts :
public function scopeSort($query, array $params = []) {
    return $query->orderBy('read')->orderBy('id','desc');
}

Example with :
ID      read
1       0
4       0
3       0

You'll get :
ID      read
4       0
3       0
1       0

Example with :
ID      read
1       0
4       1
3       1
5       0
6       1

You'll get :
ID      read
5       0
1       0
6       1
4       1
3       1

In the case where all read = 0, the query will sort by ID desc.
In the case where there are some read = 1, the query will sort by read, then ID.
EDIT: to be precise, the query will always sort by 'read' then 'ID', but I guess you'll have what you want


text:
Q: entity framework code first double many to many relationship I'm using Entity framwork 5 code first and i have 2 tables: Customer and Dossier. And i have 2 relationships of type many-to-many between them:
public class Customer {
    public int Id { get; set; }
    public string Name { get; set; }

    public List<Dossier> Debtors { get; set; }
    public List<Dossier> Creditors { get; set; }
}

public class Dossier {
    public int Id { get; set; }
    public string Name { get; set; }

    public List<Customer> Debtors { get; set; }
    public List<Customer> Creditors { get; set; }
}

How can i achieve this using code first?
Thanks

A: I think you can achieve that using two relation tables, one for the Debtors and one for the Creditors.
modelBuilder.Entity<Customer>().HasMany(c => c.Debtors).WithMany(d => d.Debtors).Map(m => m.MapLeftKey("CustomerId").MapRightKey("DossierId").ToTable("DebtorCustomerDossierRel"));

modelBuilder.Entity<Customer>().HasMany(c => c.Creditors).WithMany(d => d.Creditors).Map(m => m.MapLeftKey("CustomerId").MapRightKey("DossierId").ToTable("CreditorCustomerDossierRel"));

I haven't tried this code, but it should work pretty close to that.
This would be in your DbContext.OnModelCreating method (for that are new to Code First).


text:
Q: Is there a way to get the Database tab in IntelliJ? I am using IntelliJ and I use H2 database file (.mv.db) and I need to only view its contents whenever I add something in it. I thought I'd be able to file 'Database' tab in IntelliJ but I didn't find it.
This is what I want (image below)

When I click "View --> tool Windows" I don't see a database option (image below)

I am using Maven, is it possible that a certain plugin I downloaded somehow blocked/removed the database option?
I know there's 'Database Navigator' that I can download as a plugin, but its support for JDBC including H2 is experimental. So it's not a good choice for me. I can't seem to find the database plugin, is there any way to obtain it?

A: Database tools are a commercial feature, supported in Ultimate edition only.
See the comparison of Community versus Ultimate editions.
The database tools functionality is also available as a separate product, DataGrip.


text:
Q: How do you work with JSON with unique keys? I'm trying to run through JSON, but some of the keys are random numbers and have otherwise unique names. I understand that you can select keys and their values if the key is predictable, but I'm unsure how to work with keys that aren't predictable.
Here is an example of some JSON:
{
"10193939": {
    "3948493": {
        "predictable_key1": "value1",
        "predictable_key2": "value2",
        "predictable_key3": [{
            "inner_predictable_key1": "value1"
        }]
    },
    "9898483": {
        "predictable_key1": "value1",
        "predictable_key2": "value2",
        "predictable_key3": [{
             "inner_predictable_key1": "value1"
        }]
    }
}

Now, I had some ideas, such as using a for each loops and remapping the inner unique keys to a new variable to bypass the outmost key. Is there an easy way to do this?

A: You can iterate through the keys using the for...in clause.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
You can discover if the field belongs to the object direct, as opposed to part of the prototype using hasOwnProperty.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
If you're using a library like Lodash or underscore you can use the _.each function to iterate through the object keys and properties, or the _.keys to return all the keys in the object.
http://lodash.com/docs#keys
Beyond this, if you have a specific use case, you'd have to elaborate on your particular problem in greater detail.


text:
Q: Using an if statement to determine the highest value My code asks the user to enter a certain amount of students and to enter there name and score depends on how many students there are. My question is, how would I use an if statement to find out the student with the highest score. (C#)
class Class1
{

    public void studentCount()
    {
        int studentcount;
        int i;
        int x;
        string studentname = "";

        Console.WriteLine("Enter how many students there are: ");
        studentcount = Convert.ToInt32(Console.ReadLine());
        {
            for (i = 1; i <= studentcount; i++)
            {
                Console.WriteLine("Enter students name: ");
                studentname = Convert.ToString(Console.ReadLine());
                Console.WriteLine("Enter students score: ");
                x = Convert.ToInt32(Console.ReadLine());
            }
        }

A: Keep track of the current highest x (student's score) and if a new one that's entered is higher than the last highest, update the last highest score's variable and that student's name. You'll need to use one more variable for this to keep track of the current max score. You can always update the student's name to match the student with the max score. After the loop, you can output that student's score and name.

A: Respecting your actual code, probably this would suit you well.
int studentcount = 0, i = 0, x = 0, highestScore = 0;
string studentname = "", highestScoreStudentName = "";

Console.WriteLine("Enter how many students there are: ");

studentcount = Convert.ToInt32(Console.ReadLine());
{
    for (i = 1; i <= studentcount; i++)
    {
        Console.WriteLine("Enter students name: ");
        studentname = Convert.ToString(Console.ReadLine());
        Console.WriteLine("Enter students score: ");
        x = Convert.ToInt32(Console.ReadLine());

        if (x > highestScore)
        {
            highestScore = x;
            highestScoreStudentName = studentname;
        }
    }
}

A: There are many ways to accomplish this. Below are a few ways. Best would be the take advantage of OOP and create classes for what you need to do, but of course there are other ways to do what you want.
Sticking with your current method:
    public void studentCount()
    {
        string highestScoringStudent;
        int highestScore = 0;

        Console.WriteLine("Enter how many students there are: ");
        var studentCount = Convert.ToInt32(Console.ReadLine());

        for (var i = 0; i < studentCount; i++)
        {
            Console.WriteLine("Enter students name: ");
            var tempStudent = Convert.ToString(Console.ReadLine());
            Console.WriteLine("Enter students score: ");
            var tempScore = Convert.ToInt32(Console.ReadLine());
            if(tempScore > highestScore)
            {
                highestScore = tempScore;
                highestScoringStudent = tempStudent;
            }
        }
     }

With a dictionary to keep track of your students:
public void StudentCount()
{
    var students = new Dictionary<string, int>();
    var count = Convert.ToInt32(Console.ReadLine());
    for (var i = 0; i < count; i++)
    {
         Console.WriteLine("Enter Student's Name:");
         var name = Console.ReadLine();

         Console.WriteLine("Enter Student's Score:");
         var score = Convert.ToInt32(Console.ReadLine());

         students.Add(name, score);
    }
    var highestStudent = students.OrderByDescending(x => x.Value).FirstOrDefault()
    Console.WriteLine("{0} scored {1}", highestStudent.Key, highestStudent.Value);
}

Using OOP:
public class TestEntry
{
    public string StudentName { get; set; }
    public int Score { get; set; }
}

public class SomeClass
{
    readonly List<TestEntry> _testEntries = new List<TestEntry>();

    public void EnterTests()
    {
        _testEntries.Clear();
        var count = Convert.ToInt32(Console.ReadLine());
        for (var i = 0; i < count; i++)
        {
            Console.WriteLine("Enter Student's Name:");
            var testEntry = new TestEntry();

            testEntry.StudentName = Console.ReadLine();

            Console.WriteLine("Enter Student's Score:");
            testEntry.Score = Convert.ToInt32(Console.ReadLine());

            _testEntries.Add(testEntry);
        }
    }

    public void PrintHighestScoringStudent()
    {
        var highestTest = _testEntries.OrderByDescending(x => x.Score).FirstOrDefault();
        if (highestTest == null)
        {
            Console.WriteLine("No tests entered.");
            return;
        }

        Console.WriteLine("{0} scored {1}", highestTest.StudentName, highestTest.Score);
    }
}

A: use array [] and sort it then top most value is higher

A: Everton's solution will work, but I would think that you might be interested in keeping track of all scores.  In that case, you could use an Array as suggested, but a better solution is probably to use a SortedList.
SortedList<int> students = new SortedList<int>();
...
for (int i = 0; i < studentcount; i++)
{
    Console.WriteLine("Enter students name: ");
    studentname = Convert.ToString(Console.ReadLine());
    Console.WriteLine("Enter students score: ");
    x = Convert.ToInt32(Console.ReadLine());
    students.Add(x);
}
int max = students.Last; //Default sorting is low to high,
                         //though this could be changed if
                         //you want to look into it.

If you wanted to keep track of scores with respect to the student, you could use a List<Tuple<string, int>>, but without some finagling it would not be possible to sort it.  However, using Linq finding the max value is not difficult.
List<Tuple<string, int> >students = new List<Tuple<string, int> >();
...
for (int i = 0; i < studentcount; i++)
{
    Console.WriteLine("Enter students name: ");
    studentname = Convert.ToString(Console.ReadLine());
    Console.WriteLine("Enter students score: ");
    x = Convert.ToInt32(Console.ReadLine());
    students.Add(studentname, x);
}
int max = students.Max(a => a.Item2).FirstorDefault();


text:
Q: typeerror a bytes-like object is required not 'str' socket past day i try wrote a code for a UR (UNIVERSAL ROBOTS) but every time i start running the progam i gaves me the same mistake "typeerror a bytes-like object is required not 'str' socket", and i dont know what i to do/where is rhe error.
import socket
import time
from struct import pack

#Vars
sock = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
HOST = "192.168.1.6"
PORT = 5050

sock.bind((HOST, PORT))
sock.listen()
connection, client_address = sock.accept() #realizar a conexção entre o portatil-robo
print(client_address)
Connection = input('Do you want start? ')
print ("Ligação iniciada...")

if Connection == ('yes' or 'Y'):

    time.sleep(5)
    print("Iniciando o movimentos") #anuncia o inico do corrimento das coordenas

    #Varaveis que sock.send que mandam para o robo as coordenadas que o robo deve realizar e fazer o movimento
    #sendo que o movel vai obrigar a fazer movimentos lineares sem muita liberdade de movimento
    sock.send("movel(p[0.100, -0.100, 0.0, 0.0, 0.0, 0.0], acc_mss, vel_ms)" + "/n")
    time.sleep(2) #tempo de delay ate fazer a proxima açao
    sock.send("movel(p[-0.100, -0.100, 0.0, 0.0, 0.0, 0.0], acc_mss, vel_ms)" + "/n")
    time.sleep(2) #tempo de delay ate fazer a proxima açao
    sock.send("movel(p[-0.100, 0.100, 0.0, 0.0, 0.0, 0.0], acc_mss, vel_ms)" + "/n")
    time.sleep(2) #tempo de delay ate fazer a proxima açao
    sock.send("movel(p[0.100, 0.100, 0.0, 0.0, 0.0, 0.0], acc_mss, vel_ms)" + "/n")
    time.sleep(2) #tempo de delay ate fazer a proxima açao

elif Connection == ('no' or 'N'):
    connection.close()

else:
    print("tenta outra vez")
connection.close() #fechar ligação


text:
Q: How to encode possible state transitions in type? I am trying to replicate in Haskell this piece of Idris code, which enforces correct sequencing of actions through types:
 data DoorState = DoorClosed | DoorOpen
 data DoorCmd : Type ->
                DoorState ->
 DoorState ->
                Type where
      Open : DoorCmd     () DoorClosed DoorOpen
      Close : DoorCmd    () DoorOpen   DoorClosed
      RingBell : DoorCmd () DoorClosed DoorClosed
      Pure : ty -> DoorCmd ty state state
      (>>=) : DoorCmd a state1 state2 ->
              (a -> DoorCmd b state2 state3) ->
              DoorCmd b state1 state3

Thanks to overloading of (>>=) operator, one can write monadic code like:
do Ring
   Open
   Close

but compiler rejects incorrect transitions like:
do Ring
   Open
   Ring
   Open

I have tried to follow this pattern in the following Haskell fragment:
 data DoorState = Closed | Opened

 data DoorCommand (begin :: DoorState) (end :: DoorState) a where
   Open  :: DoorCommand 'Closed 'Opened ()
   Close :: DoorCommand 'Opened 'Closed ()
   Ring  :: DoorCommand 'Closed 'Closed ()

   Pure  :: x -> DoorCommand b e x
   Bind  :: DoorCommand b e x -> (x -> DoorCommand e f y) -> DoorCommand b f y

 instance Functor (DoorCommand b e) where
   f `fmap` c = Bind c (\ x -> Pure (f x))

 -- instance Applicative (DoorCommand b e) where
 --    pure    = Pure
 --    f <*> x = Bind f (\ f' -> Bind x (\ x' -> Pure (f' x')))

 -- instance Monad (DoorCommand b e) where
 --   return = Pure
 --   (>>=) = Bind

But of course this fails: The Applicative and Monad instances cannot be defined correctly as they require two different instances to properly sequence operations. The constructor Bind can be used to enforce proper sequencing but I cannot manage to use the "nicer" do-notation.
How could I write this code to be able to use do-notation, e.g. to prevent invalid sequences of Commands ?

A: What you're looking for is indeed Atkey's parameterised monad, now more commonly known as the indexed monad.
class IFunctor f where
    imap :: (a -> b) -> f i j a -> f i j b
class IFunctor m => IMonad m where
    ireturn :: a -> m i i a
    (>>>=) :: m i j a -> (a -> m j k b) -> m i k b

IMonad is the class of monad-like things m :: k -> k -> * -> * describing paths through a directed graph of types belonging to the kind k. >>>= binds a computation which takes the type-level state from i to j into a computation which takes it from j to k, returning a bigger computation from i to k. ireturn allows you to lift a pure value into a monadic computation which doesn't change the type-level state.
I'm going to use the indexed free monad to capture the structure of this sort of request-response action, largely because I don't want to have to figure out how to write the IMonad instance for your type myself:
data IFree f i j a where
    IReturn :: a -> IFree f i i a
    IFree :: f i j (IFree f j k a) -> IFree f i k a

instance IFunctor f => IFunctor (IFree f) where
    imap f (IReturn x) = IReturn (f x)
    imap f (IFree ff) = IFree $ imap (imap f) ff
instance IFunctor f => IMonad (IFree f) where
    ireturn = IReturn
    IReturn x >>>= f = f x
    IFree ff >>>= f = IFree $ imap (>>>= f) ff

We can build your Door monad for free from the following functor:
data DoorState = Opened | Closed
data DoorF i j next where
    Open :: next -> DoorF Closed Opened next
    Close :: next -> DoorF Opened Closed next
    Ring :: next -> DoorF Closed Closed next

instance IFunctor DoorF where
    imap f (Open x) = Open (f x)
    imap f (Close x) = Close (f x)
    imap f (Ring x) = Ring (f x)

type Door = IFree DoorF

open :: Door Closed Opened ()
open = IFree (Open (IReturn ()))
close :: Door Opened Closed ()
close = IFree (Close (IReturn ()))
ring :: Door Closed Closed ()
ring = IFree (Ring (IReturn ()))

You can open a door, which causes a currently-closed door to become open, close a currently-open door, or ring the bell of a door which remains closed, presumably because the house's occupant doesn't want to see you.
Finally, the RebindableSyntax language extension means we can replace the standard Monad class with our own custom IMonad.
(>>=) = (>>>=)
m >> n = m >>>= const n
return = ireturn
fail = undefined

door :: Door Open Open ()
door = do
    close
    ring
    open

However I notice that you're not really using the binding structure of your monad. None of your building blocks Open, Close or Ring return a value. So I think what you really need is the following, simpler type-aligned list type:
data Path g i j where
    Nil :: Path g i i
    Cons :: g i j -> Path g j k -> Path g i k

Operationally, Path :: (k -> k -> *) -> k -> k -> * is like a linked list, but it has some extra type-level structure, once again describing a path through a directed graph whose nodes are in k. The elements of the list are edges g. Nil says you can always find a path from a node i to itself and Cons reminds us that a journey of a thousand miles begins with a single step: if you have an edge from i to j and a path from j to k, you can combine them to make a path from i to k. It's called a type-aligned list because the ending type of one element must match the starting type of the next.
On the other side of Curry-Howard Street, if g is a binary logical relation then Path g constructs its reflexive transitive closure. Or, categorically, Path g is the type of morphisms in the free category of a graph g. Composing morphisms in the free category is just (flipped) appending type-aligned lists.
instance Category (Path g) where
    id = Nil
    xs . Nil = xs
    xs . Cons y ys = Cons y (xs . ys)

Then we can write Door in terms of Path:
data DoorAction i j where
    Open :: DoorAction Closed Opened
    Close :: DoorAction Opened Closed
    Ring :: DoorAction Closed Closed

type Door = Path DoorAction

open :: Door Closed Opened
open = Cons Open Nil
close :: Door Opened Closed
close = Cons Close Nil
ring :: Door Closed Closed
ring = Cons Ring Nil

door :: Door Open Open
door = open . ring . close

You don't get do notation (though I think RebindableSyntax does allow you to overload list literals), but building computations with (.) looks like sequencing of pure functions, which I think is a rather good analogy for what you're doing anyway. For me it requires extra brainpower - a rare and precious natural resource - to use indexed monads. It's better to avoid the complexity of monads when a simpler structure will do.


text:
Q: Single drive LVM to RAID6 LVM I cloned my entire LVM volume group from a single drive to a RAID5 array with 3 disks. The VG is formed by these logical volumes:

*

*root

*swap

*home

... and other volumes of some XEN virtual machines.
I tried to make the RAID5 array bootable using boot-repair from the UbuntuSecure disk. I get GRUB2 startup screen with the list of kernels, but the system doesn't start. It end up with some error message that tell me that it can't find LVM volumes:
Loading, please wait...
Volume group "lvm10" not found
Skipping volume group lvm10
Unable to find LVM volume lvm10/root
Volume group "lvm0" not found
Skipping volume group lvm0
Unable to find LVM volume lvm0/swap
Gave up waiting for root device [...]


text:
Q: Radio Propagation Modelling, from a GIS view point I've had a request from another department involved in telecommunications to revamp elevation data into GTOPO30, DTED or SRTM formats as input into a program called Radio Mobile. They are working on adding infill sites to low signal areas. Radio Mobile looks to be a program with history and a quick peruse of the message archives and tutorial sites shows there is active user community.
The reliance on somewhat dated elevation formats, e.g. they don't seem to have heard of geotiff and do everything in geographic lat/long, got me wondering about the overlap between GIS and radio signal analysis. What communities and/or software systems are there out there approach Radio Propagation Modelling from a GIS point of view? What's your assessment of their GIS "savvyness"?
EDIT: This could also be phrased as, where does someone who knows a something about GIS but nothing about radio signal propagation go to learn more?

A: I have encountered this while working on broadband communications and mobile telephony for the FCC (in the US).  For an introduction to this viewpoint, see Wagen & Risk, Radiowave propagation, building databases, and GIS: anything in common? A radio engineer's viewpoint.
The stuff I have seen ranges from calculations that are so simple they're stupid (create buffers, or use viewshed calculations) to ones that model electromagnetic propagation through the atmosphere around a cluttered environment (hills, trees, buildings, etc.).  The sophistication is there, but not all telcos have the knowledge, resources, or even the need to use it.

A:
From NOAA
I think frequency and the condition of the ionosphere will be factors.  Signals can bounce off the ionosphere, reducing the impact of terrain.  Several years back I looked into interfacing VOACAP with GIS.  I see now there is an online version.  In higher latitudes, as I recall, the ionosphere is not very predictable.
Update:
Also, the Review of HF propagation analysis & prediction programs looks at 54 different application.  Notice how each of them seems to have a global map associated with them.  From a GIS point of view, if you are siting a HF transmitter, you'd like to know statistically how well you will be received by your target audience, which is how the Voice of America used VOACAP.  All the source code I've seen is FORTRAN from the cold war era.

GIS can be used to evaluate alternative transmitter sites  This can be done by generating time of day maps (say, every hour) showing signal strength distribution for each proposed site. This video shows time of day maps.  Combine the time of day maps to create a map showing number of hours of where your reception is sufficent for a site. Some areas may only be able to hear you 2 hours a day while other areas 6, and so on.  You can then overlay that map with population to determine number of potential listener hours for a site.

A: Maybe you want to the also "The Radio Planning Tool for GRASS GIS" - Raplat. Citation: "It is especially designed for radio coverage calculation of GSM/UMTS systems, but can be applied also to other wireless systems in the frequency range 400 MHz – 2.4 GHz (e.g. TETRA, WiFi). Its structure is modular and characterized by high level of flexibility and adaptability."
See http://grass.osgeo.org/wiki/Addons#Raplat

A: This answer is a little bit off-base but it might help someone.... I tried to tackle this problem a few weeks ago (trying to get cell coverage data), but the questions I kept asking is why?
I found a quicker solution by using the interactive maps that are already provided by cell providers.  http://www.thadwester.com/1/post/2011/11/custom-cell-coverage-map-the-easy-way.html
Now, I know you want to plan, so you will need custom analysis, but the basemap will still be useful to plug into.
Interesting solution with radio mobile.  Going to give it a go.

A: I have been working on using RM to map out the current range of >30 towers in my work area (about 64,000km2) so that in a disaster inhabitants of remote properties can have a clear understanding of what communication pathways are available to them in areas which they can access at that time.
A major part of this process was converting the txt file created by the Cartesian Coordinate plot system of RM to a vector polygon shapefile and dealing with the large datasets (over 1 GB text files per tower and 30million lines) that were created. I am happy to share all the models and python scripts that we created for this, if any of you would like (simply email me a request).
I have attached a summary document of the process used and would really appreciate any feedback from the RM user group - I am a spatial and ecological scientist and so have had to rely heavily on advise from Ian D Brown (G3TVU) for the communication engineering aspects of the work.
Please see/edit/comment on https://docs.google.com/document/d/1WW9IKQWlrhc0-VBJqM79dNx3e4p6Xs89QlqV9wAoi6Q/edit
Cheers,
George Corea
GIS Specialist
Atherton, QLD, Australia

A: We have built a simple easy to use RF propagation mapping site with easy web integration for end user sign up and pre-qualification.  Roger Coudé has completely overhauled Radio Mobile for this site only with multi-threading in order to make it blazing fast on rendering coverage maps and link paths. It is basically Radio Mobile on steroids. We also have an android app for field techs with augmented reality, APIs to push end user submissions from your website into your third party billing system or CRM. We have worldwide topo data and have added 22 languages to the site.


text:
Q: How can I upgrade kernel to version 4.10 on Ubuntu 16.04? I have an installed Ubuntu version 16.04 running with Kernel version 4.4.0-64-generic
How can I upgrade the kernel to 4.10?

A: Always remember that might be an issue between a specific software and the latest Linux-kernel, for example the VirtualBox might not work like it should on the newest Linux-Kernel.
I suggest you to wait until the teams of the distros Ubuntu 16.04 include the Linux-kernel 4.10.x in the repositories or you can follow those two options:
OPTION 1: You can download the Debian packages of 4.10.1 Linux-Kernel from Ubuntu trusted sources and install them with the risk of some software that may not work like it should since the programmer did not make it to work on the newest Linux-Kernel yet.
OPTION 2: You can compiling it by yourself for using the latest of the latest version of Linux-Kernel for fun and learning.

Downloading and Installing the Debian Packages for 4.10.1 Linux-Kernel:

For 32bit ONLY.
In Terminal:
cd Desktop
mkdir linux_14.10.1
cd linux_14.10.1
wget kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_i386.deb
wget kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_i386.deb

Install the 4.10.1 Linux-Kernel:
sudo dpkg -i *.deb

Update GRUB:
sudo update-grub

Don't forget to install (to avoid any software error in the future) the "gcc" from synaptics according to the Linux-kernel x.xx version.
sudo reboot

Now choose to boot your 4.10.1 Linux-kernel from GRUB menu.
REMOVING THE 4.10.1 LINUX-KERNEL:
Reboot to GRUB.
Choose to boot from your previous Linux-Kernel.
Execute and choose to remove:
linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_i386.deb
linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_i386.deb

For 64bit ONLY.
In Terminal:
cd Desktop
mkdir linux_14.10.1
cd linux_14.10.1
wget kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
wget kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb

Install the 4.10.1 Linux-Kernel:
sudo dpkg -i *.deb

Update GRUB:
sudo update-grub

Don't forget to install (to avoid any software error in the future) the "gcc" from synaptics according to the Linux-kernel x.xx version
Sudo reboot

Now choose to boot your 4.10.1 Linux-kernel from GRUB menu.
REMOVING THE 4.10.1 LINUX-KERNEL:
Reboot to GRUB.
Choose to boot from your previous Linux-Kernel.
Execute and choose to remove:
linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
Open a Terminal:
sudo update-grub

Compiling the newest Linux-Kernel for X86 architecture:
0. Downloading the Free-Source-Code:
Go to  from https://www.kernel.org/ and choose the version of Linux-Kernel you wish
Move the downloaded ".tar.xz" Linux-Kernel to a optional named folder anywere you like.
Extract the ".tar.xz" Linux Kernel to the Desktop or anywhere you wish.
Open a Terminal by pressing Ctrl+Alt+T:
cd Desktop/Linux-x.x.x (Linux-x.x.xis an example of the name of the folder of the extracted Linux-Kernel)
1.INSTALLING THE NEEDED LIBRARIES:
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install libssl-dev build-essential kernel-package libncurses5-dev bzip2 fakeroot gdebi grub-customizer

2.KERNEL CONFIGURATION:
In terminal:
make menuconfig (Choose the Options OR leave it as it is you can always go back to your previous Linux-kernel)
Controls:
Use the arrows Up,Down for the options.
Use Enter OR Space to choose an option.
Use Left,Right to Exit, Save, Help etc.
Take your time to explore the options (or leave them as it is) and Save,Exit.
3.COMPILING THE LINUX-KERNEL:
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-its-a-test kernel_image kernel_headers

(its-a-test is an example you can name it anything-you-like)
Now wait until the compiling finish, it will take some time according to your cpu for example a core2quad will take around to 45 minutes.
4.INSTALLING THE NEW LINUX KERNEL:
Install the two DEB packages that has been created into the extracted kernel folder it should be named something like  linux-headers-x.xx.deb and linux-image-x.xx.deb.
DO NOT DELETED THOSE TWO DEB'S FILES IF YOU WANT TO INSTALL THEM ON ANOTHER PC OR IF YOU WANT TO REMOVE YOUR TEST LINUX-KERNEL LATER.
ls (see the compiled *.deb files)
sudo dpkg -i *.deb

5.UPDATING GRUB:
sudo update-grub

Don't forget to install (to avoid any software error in the future) the "gcc" from synaptics according to the kernel x.xx version.
Sudo reboot

Now choose to boot your test Linux-kernel from GRUB menu.
Open a Terminal:
uname -a (see the version and name of your test Linux-Kernel)
Congratulations!

REMOVING YOUR TEST LINUX-KERNEL:
Reboot to GRUB.
Choose to boot from your previous Linux-Kernel
Execute  linux-headers-x.xx.deb and then the linux-image-x.xx.deb and choose to remove.
Open a Terminal:
sudo update-grub


text:
Q: How to change Solr document id by SolrJ? I use the following code to change specific field value.
SolrInputDocument solrdoc=new SolrInputDocument();
solrdoc.addField("id","book001");
Map<String,Object> fieldModifier=new HashMap<>(1);
fieldModifier.put("set","book_new_name");
solrdoc.addField("name",fieldModifier);

But I cannot use the similar code to change Solr unique document id, exception is thrown.
solrdoc.addField("id",fieldModifier);

Is there any solution to change the Solr document id?

A: Changing the document id requires removing and re-adding the document, so delete the document (by id), then re-add the document with the new id. You can do this without committing between deleting and adding the document, so it will be seamless for any clients querying the collection.


text:
Q: If a url is redirected to another, is there a way to use the original domain in php Noob here! This is my first post - I apologise if it's been answered already.
I can't find anything in the search!
I have a number of sites in development and want to redirect them all to a single splash page for the company that owns them.
Is there a way to determine which url it was redirected from to allow different text and contact info to be called?
I can find lots of answers about using the current url - but not one that redirected to it.
Thanks for your help!

A: Like Kkinsey said in the comments - The first approach I would take is starting with $_SERVER['HTTP_REFERER']

A: Using Referer will work most of the time. Some browsers don't send it.
Instead, add a GET parameter to your redirection URL:
header("Location: http://main-company.net/splash?from=".$website_id);
exit;

Then retrieve it on the main website, if set it will be the variable $_GET['website_id'].


text:
Q: Rename file location AJAX PHP I am developing a sort of library in which a user is able to upload different files and then only post those desired.
When the user uploads a file or files, these will be stored in a temporary folder. Later, by filling a form the user can post a selected file. As soon as the user pushs the submit button I want to move the file from the temporary folder to another folder suggested by the user.
At the moment, I am able to create the suggested folder. Nevertheless, I am getting an "access denied (code 5)" error, and the files do not appear on the new folder. I've read other issues, and added "Read and Write" permissions to my all users for all folders inside htdocs(XAMPP folder). Still, the error continues to appear.
I am running this script in an AJAX file (shown below in the JS code).
Here is my code. Hope you can help me and this can help others! Than you

// When the form is submitted we want for the temp file to be moved to the directory chosen by the user
  $( "form" ).submit(function( event ) {
   $directory = $('#directory').val();
   $file = $('#fileid').val();
   $.ajax({

     url:'ajax/rename.php',
     type:"POST",
     data:({ directory:$directory,
       file:$file
      }),
     success:function(data){
     //window.location.href = 'home';//redirect to the homepage
     alert(data);
    },
     error: function(xhr, status, error) {
       var err = eval("(" + xhr.responseText + ")");
       alert(err.Message);
     }
   });event.preventDefault();
  });

AJAX CODE

<?php

 require_once '../../app/models/DB.php';
 require_once '../../app/models/Files.php';
 require_once '../../app/init.php';
  $db= DB::getInstance();
  $files= new Files();
  $directory = $_POST['directory'];
  $file = $_POST['file'];
  if (!file_exists('../' . $directory)) {
   mkdir('../' . $directory, 0744, true);
   chmod('../'. $directory, 0777);
  }
  $currentdirectory = $db->query("SELECT path FROM file WHERE id = '$file'")->first()->path;
  rename('../' . $currentdirectory,'../' . $directory);
  $data = $db->query("UPDATE file SET path = '$directory' WHERE id = '$file'");

  echo('../' . $currentdirectory);
  ?>
.secondaryContainer{
  margin:0 auto; width:86%;
  height:58px;
  background: linear-gradient(to bottom,#FBFBFB,#A7A6A6) #f3f3f3;
  border-radius: 5px 5px 5px 5px;
 }
 #HomesearchBar{
  float:right;
 }

 .boxHeader{
  padding:15px 15px 0px 15px ;
 }

 #headerTab{
  border-bottom:0px;
 }
 .filesBoxContent{
  background-color: #aeaeae !important;
     border-color: #818181 !important;
     border-radius: 5px 5px 5px 5px;
 }

 #MainPageThumbnails{
  margin-top: 15px;
 }

 #MainPageThumbnails{
  text-align:justify;
 }

 .clicked {
    border: 3px solid blue;
}
  #mainPage{
   max-width: 900px;
  }
  #mainPage h1, #mainPage h2 {
      font-size: 28px;
      color: #25A7DE;
      font-weight: lighter;
      text-align: left;
  }
  .postPage legend {
      text-align: center;
      background: #25A7DE;
      color: #fff;
      font-size: 18px;
      padding: 4px;
      -webkit-border-radius: 34px;
      -moz-border-radius: 34px;
      border-radius: 34px;
      width: 34px;
      height: 34px;
  }
  fieldset{
      border-top: 1px solid #ccc;
  }

  .fileUpload {
      position: relative;
      overflow: hidden;
      margin: 10px;
  }
  .fileUpload input.upload {
      position: absolute;
      top: 0;
      right: 0;
      margin: 0;
      padding: 0;
      font-size: 20px;
      cursor: pointer;
      opacity: 0;
      filter: alpha(opacity=0);
  }

  #banner_warning{
   float:left;
  }

  .form-actions {
      margin: 0;
      background-color: transparent;
      text-align: center;
  }
  /*---------Category CSS-------*/
  .subcategoryList,.categoryList {
      border-radius: 15px;
      background-color: white;
      border: 1px solid #ccc;
      padding: 5px;
      min-height:150px;
      max-height:150px;
      overflow-y: auto;
      overflow-x:hidden;
      margin-bottom:20px !important;
  }
  .categoryList{
   float: left;
   width:49%;

  }
  .subcategoryList{
   float: right;
   width:49%;
   visibility: hidden;
  }
  .subcategoryList ul,.categoryList ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
  }
  .subcategory,.category {
    text-decoration: none;
    color: #000;
    -webkit-transition: font-size 0.3s ease, background-color 0.3s ease;
    -moz-transition: font-size 0.3s ease, background-color 0.3s ease;
    -o-transition: font-size 0.3s ease, background-color 0.3s ease;
    -ms-transition: font-size 0.3s ease, background-color 0.3s ease;
    transition: font-size 0.3s ease, background-color 0.3s ease;
    display: block;
  }
  .subcategory:hover,.category:hover {
    font-size: 15px;
    background: #f6f6f6;
  }

  .input-group{
   z-index: 0;
  }

Add New Post

  <form action="" method="post">
     <fieldset class="form-group">
      <legend>1</legend>

        Title*
        <input type="text" class="form-control" name="title" id="title" aria-describedby="basic-addon1" placeholder="Enter the post title">

        Choose Banner
        <input type="file" name="banner" id="uploadBtn" class="upload" />

     Choose a banner for your post.

        Description*
        <textarea class="form-control" name="description" id="description" rows="10" placeholder="Type a short description for this file"></textarea>

     </fieldset>

     <fieldset class="form-group">
      <legend>2</legend>

       <?php foreach($category as $item):?>
         <li class="category" id="<?php echo $item->id;?>"><?php echo $item->name; ?>

        <?php endforeach; ?>

      <input type="hidden" name="category" id="category"/>

      <input type="hidden" name="subcategory" id="subcategory"/>

       <button type="button" id="myBtn" class="btn btn-default btn-lg">
        Add Media
     </button>

        Directory
        <input type="text" class="form-control" name="directory" id="directory" aria-describedby="basic-addon1">
        <input type="hidden" name="filename" id="filename"/>
        <input type="hidden" name="fileid" id="fileid"/>

   </fieldset>

   <fieldset class="form-group">
      <legend>3</legend>

Keywords

       <textarea class="form-control" name="keywords" id="keywords" rows="3"></textarea>
       Separate words by either '/' or ';'
     </fieldset>

   <input type="hidden" name = "token" value="<?php echo Token::generate(); ?>">
   <input type="submit" value="Post">
  </form>

A: Firstly i would suggest your sanitize the user input:
$directory = $_POST['directory'];
$file = $_POST['file'];

Later you use $directory in SQL query, could give SQL injection issue.
Secondly check all the file/folder permissions of the parent folder in which the mkdir command makes its new folder.