Drupal 8 live preview question

Question: I'm a designer who is doing a design review on a Drupal 8 website. I'm having trouble doing the design review because 'admin objects' are getting in the way of the full page design:

Admin bar at top of screen

View, Edit, Up-Publish etc buttons below the header

Sticky provide feedback bar

(Sorry can't show the full page due to NDA)
Usually I would just log out and preview live site, but the staging server for this project is hidden behind multiple logins and trying to access the website when not being logged in just redirects to the currently live (old) Drupal 7 website.
Any idea for how to remove these items and just preview the normal page?
Thanks
Comment: Run it locally?
Comment: Unfortunately running it locally isn't an option unfortunately, as we're working with a 3rd party development company who is only sharing staging site access.
Answer: You could create a user without any special admin privileges.  Then you can either view it from another browser as the normal user or use the Masquerade module to swap in and out of that user from the same session.
Comment: That's the easiest approach. Keep in mind that if this is a site that users/editors are actively working with, they should be able to get a meaningful view of their result as well. The local tasks for example are a block. You can put them wherever you want and you can also override that template to render them for example outside of the active content (e.g. top-right corner). There is also an issue in admin_toolbar to support moving them into the toolbar.
Comment: Hi CG Monroe & Berdir, thanks for your responses, we'll try giving this approach a shot. Cheers

Drupal 8 live preview question


Como interromper um ciclo de "whiles"?

Question: Bom, vou dar um exemplo muito abstrato de forma a conseguir expressar a minha dúvida de maneira mais simples
Eu tenho seguinte codigo:
while(a>b){ // Meu while principal

while(c>d){

while(e>f){

}
}
}

Existe algum comando, de forma a que eu deia dentro de um dos meus whiles, e ele volte para o while principal? Se sim, qual seria o comando?
Answer: O código não é muito claro do que quer, mas seria mais ou menos isto:
loop@ while (a > b){ // Meu while principal
    while (c > d) {
        while (e > f) {
            break@loop
        }
    }
}

Coloquei no GitHub para referência futura.

Como interromper um ciclo de "whiles"?


Accessing inner HTML elements and delete them

Question: I have an image in a div:

and I'm going to delete this image when it's selected. I detect selecting by listening to an onclick() of each element:
function updateSelectedElement(id) {
  // select the clicked element
  SelectedElement = "#elem-" + id;
}

Note: IDs are created dynamically (I simplify my problem in this example)
My problem is that when I click on an image to select it, updateSelectedElement() of image is called first and then updateSelectedElement() of div. The final value of SelectedElement will be "0" and I can't select that inner element (to modify or delete it, for example)
I have tried to save the max number of IDs, but it doesn't work, because if I have some other elements with lower IDs, I can't select them anymore.
Comment: Possible duplicate of [How to stop event propagation with inline onclick attribute?](http://stackoverflow.com/questions/387736/how-to-stop-event-propagation-with-inline-onclick-attribute)
Answer: Stop the click event from bubbling up the DOM by adding event.stopPropagation();:
function updateSelectedElement(id) {
    console.log(id)
    if (event.stopPropagation) {
        event.stopPropagation();
    } else {
        window.event.cancelBubble = true // For IE
    }
}

jsFiddle example
Comment: For IE: `window.event.cancelBubble = true`
Comment: it does't work , I have the same problem after I add this line to my function
Comment: Did you try the fiddle I posted? It works fine. Are you getting any errors in your page when changing the code?
Comment: yes fiddle works fine ... I don't why it doesn't work on my codes !
Comment: It's not working because the event object wasn't passed in the function parameters. I think in Chrome it will still work sometimes even without passing it, but in Firefox it certainly would break. You'd have to pass event both in the onclick() in the html, then accept it as a parameter in updateSelectedElement()
Answer: Do you need to pass the ID around like that, i.e. with updateSelectedElement?
Or can you just pass in the this to the selected element, and delete like in this example (I used buttons instead of images, but same concept):
HTML:

    <button onclick="addToCache(this)">Do Delete 1</button>

    <button onclick="addToCache(this)">Do Delete 2</button>

...

JAVASCRIPT:
var deletionCache = []; //keep a cache of things to be deleted

function doDeleteCache() {
    for (var i = 0; i < deletionCache.length; i++) {
        elem = deletionCache[i];
        elem.parentNode.removeChild(elem);
    }
    deletionCache = [];
}

function addToCache(elem) {
    deletionCache.push(elem);
    elem.style.color = "red";
}

http://jsfiddle.net/3exn763w/2/
Comment: I need it's ID actually , since I'm going to delete it by another button (outside of the div)
Comment: I updated so you can delete with a separate button.  Just a thought.  Might not be what you need though.
Comment: such a creative idea :)
Answer: If I understand correctly, you are saying that when you click on the image, it ends up registering the click on the div (because, the image is after all a part of the parent div).
The way to solve this is:

And:
function updateSelectedElement(event,id) {
 SelectedElement = "#elem-" + id;
 event.stopPropagation();
}

This will stop the click from propagating up the DOM tree to the parent elements of whatever you're trying to access.
However, I really recommend you don't use the "onclick" inline here... It gets so messy and tough to manage. Instead, just make a class "removable" or something for any of the elements you want, then pop in some jQuery:

and
$(function(){
  $('.removable').click(updateSelectedElement);
});

function updateSelectedElement(event) {
   $(event.target).remove();
   event.stopPropagation();
}

Answer: You need to stop propagation like so:

function updateSelectedElement(e) {
 e.stopPropagation();
 document.body.appendChild(document.createTextNode(e.target.id));
}
Click a label

  outside div

inside div


Formatando data e hora com Javascript?

Question: Estou consumindo dados de uma API e gostaria de saber como faço para passar o seguinte valor de data e hora, para o padrão brasileiro.
O formato retornado é esse:
2017-01-05T14:35:17.437

mas eu gostaria que fosse exibido
05-01-2017

Comment: Nesse específico formato, você vai ter que pegar o resultado, transformar um objeto Date do javascript, pegar os valores que deseja (dia, mês e ano) e formar uma nova _string_. Caso queira um jeito mais fácil, é só pegar esse valor, transformar em um objeto Date do javascript e posteriormente utilizar o método `toLocaleString()`, que irá retornar nesse formato: dd/mm/aaaa hh:mm:ss
Answer: Pode utilizar o momentjs que faz todo trabalho de formatação de data, cálculos, etc:

moment.locale('pt-br');
console.log(moment('2017-01-05T14:35:17.437').format('DD-MM-YYYY'));

mas, também pode ser feito com o puro javascript:

var data = '2017-01-05T14:35:17.437';
var parte = data.substring(0,10).split('-').reverse().join('-');
console.log(parte);

Referencias:

momentjs - Parse, validate, manipulate, and display dates in JavaScript.
JavaScript String substring() Method
JavaScript String split() Method
JavaScript Array reverse() Method
JavaScript Array join() Method
Comment: Obrigado a ajuda de todos : )
Answer: Só veja como transformar em string essa sua data e teste isso:
Ex:
var formatoCompleto = "2017-01-05T14:35:17.437";
var dataFormatada = formatoCompleto.substring(0,formatoCompleto.indexOf("T"));
var dadosData = dataFormatada.split("-");

var dataFinal = dadosData[2]+"-"+dadosData[1]+"-"+dadosData[0];
console.log(dataFinal);

Comment: Obrigado pela ajuda : )

Formatando data e hora com Javascript?


How to create a rule to assign roles to users based on some checkbox items in their profile?

Question: I am pretty new to Drupal. I am using Profile2 so that the user can select there own user role. So say I have a profile page with some checkbox items like

Automotive
Computer
Garden
etc

How would I add a condition or data comparison in Rules to say, If Automotive is selected/checked, set user role to that role? I also need to be able to select multiple checkboxes to get multiple roles.
Any suggestions?
Answer: Part 1 - Make it work for a single selection and related role
Create a rule which looks like so:

Rules Event: After saving user profile.
Rules Conditions (both conditions must be satisfied):

entity has field (with the field corresponding to (eg) "Automotive".
data comparison to check if "Automotive is selected/checked".

Rules Action: : Assign role to user (for the role related to "Automotive").

You could create a similar rule for each possible combination of checkboxes and roles to be assigned. Or continue as detailed in Part 2 to further enhance your rule from Part 1 so that you end up with a single rule for all possible combinations.
Part 2 - Make it work for other possible combinations
To also make it work for other possible combinations, and because of the fact that a Rules action cannot contain "conditions", you basically have 2 possible approaches:

Create a similar rule (as in Part 1) for each possible combination.
Use the Conditional Rules module to enhance the Rules Action in the above rule to alter the flow, using either Conditional (if/else) of Switch logic. Be aware: this module only has a beta release for D7, though it's used in over 8K sites (which makes it seem like a pretty robust module though).
Comment: Wow, thank-you so much. This information is very helpful!


Uniform Convergence of $\sum_{n=1}^{\infty} \frac{z^n}{n} $

Question: I can easily prove that $$\sum_{n=1}^{\infty} \frac{z^n}{n^2} $$ uniformly converges when $|z|<1$ simply by applying the M-Test. But, I cannot figure out how to prove that  $$\sum_{n=1}^{\infty} \frac{z^n}{n}$$ does not uniformly converge when $|z|<1$. Hope someone could help me out this is simple I know but just can't figure out a way. Thanks
Comment: Oh I see my mistake; there is a squared term in the first statement. Pardon my beety eyes!
Comment: @graydad Nope $|z|<1$
Comment: @graydad I just added the other summation to show that I find it easier to prove that a sum is uniformly convergent but find it difficult to prove that it is not when required
Comment: @graydad I those are two DIFFERENT summations
Comment: @graydad No worries could happen to anyone
Answer: It suffices to show $$\sum_{n=1}^{\infty} \frac{z^n}{n}$$ does not uniformly converge when $0<z<1$
Now consider
$\sum_{k=n}^{2n} \frac{z^k}{k}>(n+1)\frac{z^{2n}}{2n}>\frac{z^{2n}}{2}>\frac{1}{4}$, if $(\frac{1}{2})^\frac{1}{2n}<z<1$.
Hence, let $\epsilon=\frac{1}{4}$, for all $n\in\mathbb{N}$,let $(\frac{1}{2})^\frac{1}{2n}<z_0<1$, then $$\sum_{k=n}^{2n} \frac{z_0^k}{k}>(n+1)\frac{z_0^{2n}}{2n}>\frac{z_0^{2n}}{2}>\frac{1}{4}$$
Hence the series is not uniformly convergent on $(0,1)$.


How to connect instances in CloudFormation

Question: We would like to create a template for a fairly standard stack in AWS. We need three layers.

Layer: Elastic Load Balancer
Layer: several web servers which are created / destroyed according to alarms triggered by the demand on the site
Layer: a database server

Instances on Layer 2 should know the host name of the database instance. Ideally I would like to get hold of the private IP of the database instance and pass it through user-data to the web servers.
Fn::GetAtt does not support the private ip (only the public)
I suppose an alternative would be to build the stack and afterwards to set manually the db private ip. It does though make our setup a bit less clean. We would ideally like everything to be described in the template. (even if this involves running a script through user-data)
Any suggestions?
Comment: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html is the correct link to the doc for GetAtt - and it _does_ in fact support the Private IP (nowadays at least)
Answer: I do this now to add new nodes to my puppet master. For example, I grab the private IP of the puppet master instance in the UserData section of my new node:
<code>"echo ", { "Fn::GetAtt" : [ "MasterOfPuppets", "PrivateIp" ] }, " ",
         { "Fn::GetAtt" : [ "MasterOfPuppets", "PrivateDnsName" ] } ," puppet
    >> /etc/hosts\n","\n",
</code>
See page 119 of the CloudFormation User guide.
Alternatively you could use the instance MetaData:
<code>curl http://169.254.169.254/latest/meta-data/local-ipv4/
</code>


How to transform multi-columns to rows

Question: I have a excel file with multi-columns as below (Sorry but I don't know how to recreate it with pandas):

Below is my expected Output:
import pandas as pd
import numpy as np

df = pd.DataFrame({'Code': ['11000000000', '11200100000', '11710000000', '11000000000', '11200100000', '11710000000', '11000000000', '11200100000', '11710000000'],
                   'Code Name': ['Car', 'Motorbike', 'Bike', 'Car', 'Motorbike', 'Bike', 'Car', 'Motorbike', 'Bike'],
                   'Date': ['19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024', '19-02-2024'],
                   'Customer': ['Customer A', 'Customer A', 'Customer A', 'Customer B', 'Customer B', 'Customer B', 'Customer ...', 'Customer ...', 'Customer ...'],
                   'Point_1': [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
                   'Point_2': [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]})
df

    Code        Code Name   Date        Customer      Point_1   Point_2
0   11000000000 Car         19-02-2024  Customer A    NaN       NaN
1   11200100000 Motorbike   19-02-2024  Customer A    NaN       NaN
2   11710000000 Bike        19-02-2024  Customer A    NaN       NaN
3   11000000000 Car         19-02-2024  Customer B    NaN       NaN
4   11200100000 Motorbike   19-02-2024  Customer B    NaN       NaN
5   11710000000 Bike        19-02-2024  Customer B    NaN       NaN
6   11000000000 Car         19-02-2024  Customer ...  NaN       NaN
7   11200100000 Motorbike   19-02-2024  Customer ...  NaN       NaN
8   11710000000 Bike        19-02-2024  Customer ...  NaN       NaN

What should I do to get this result. Thank you
Answer: Create DataFrame with MultiIndex first in index and columns by parameters index_col and header and then use DataFrame.stack with first level and dropna parameter for avoid remove rows with missing values:
df = pd.read_excel(file, index_col=[0,1,2], header=[0,1])

#test MultiIndex in columns
print (df.columns)
MultiIndex([('Customer A', 'Point_1'),
            ('Customer A', 'Point_2'),
            ('Customer B', 'Point_1'),
            ('Customer B', 'Point_2'),
            ('Customer ...', 'Point_1'),
            ('Customer ...', 'Point_2')],
           names=['Customer', None])

#test MultiIndex in index
print (df.index)
MultiIndex([('11000000000',       'Car', '19-02-2024'),
            ('11200100000', 'Motorbike', '19-02-2024'),
            ('11710000000',      'Bike', '19-02-2024')],
           names=['Code', 'Code Name', 'Date'])

EDIT: There is problem with missing values in headers, so is possible use alternative solution - create MultiIndex first in columns and use DataFrame.set_index with DataFrame.rename_axis:
df = pd.read_excel('file.xls', header=[0,1])

df = df.set_index(df.columns[:3].tolist()).rename_axis(df.columns[:3].get_level_values(0))
print (df)
                                 Customer A         Customer B          \
                                    Point_1 Point_2    Point_1 Point_2
Code        Code Name Date
11000000000 Car       19-02-2024        NaN     NaN        NaN     NaN
11200100000 Motorbike 19-02-2024        NaN     NaN        NaN     NaN
11710000000 Bike      19-02-2024        NaN     NaN        NaN     NaN

                                 Customer …
                                    Point_1 Point_2
Code        Code Name Date
11000000000 Car       19-02-2024        NaN     NaN
11200100000 Motorbike 19-02-2024        NaN     NaN
11710000000 Bike      19-02-2024        NaN     NaN

out = df.stack(0, dropna=False).reset_index()
print (out)
          Code  Code Name        Date      Customer  Point_1  Point_2
0  11000000000        Car  19-02-2024  Customer ...      NaN      NaN
1  11000000000        Car  19-02-2024    Customer A      NaN      NaN
2  11000000000        Car  19-02-2024    Customer B      NaN      NaN
3  11200100000  Motorbike  19-02-2024  Customer ...      NaN      NaN
4  11200100000  Motorbike  19-02-2024    Customer A      NaN      NaN
5  11200100000  Motorbike  19-02-2024    Customer B      NaN      NaN
6  11710000000       Bike  19-02-2024  Customer ...      NaN      NaN
7  11710000000       Bike  19-02-2024    Customer A      NaN      NaN
8  11710000000       Bike  19-02-2024    Customer B      NaN      NaN

Comment: Sorry but it not worked as expect. Please check screenshot in my updated question.
Comment: @hoatran - Is possible share sample excel file? Hard test without file.
Comment: Sure, you can check it here: https://docs.google.com/spreadsheets/d/16zL43tOKpz8srQo0WOG99umwqKDr6Kbv/edit#gid=863247321
Comment: @hoatran - request sent
Comment: @hoatran - Can you check EDIT in answer?

How to transform multi-columns to rows


ClassNotFoundException with Jemmy Examples

Question: I m trying to launch the jemmy examples from https://jemmy.java.net/tutorial.html and keep getting the ClassNotFoundExeption about the test- class, what is given in  org.netbeans.jemmy.Test.main(String params).
For example, with
enter code here

import org.netbeans.jemmy.*;
import org.netbeans.jemmy.explorer.*;
import org.netbeans.jemmy.operators.*;

public class WaitWindowSample implements Scenario {

    public int runIt(Object param) {
        try { //start application
            new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser").startApplication();
            //wait frame
            new JFrameOperator("GUI Browser");
        } catch (Exception e) {
            e.printStackTrace();
            return (1);
        }
        return (0);
    }

    public static void main(String[] argv) {
        String[] params = {"WaitWindowSample"};
        org.netbeans.jemmy.Test.main(params);
    }
}

i get:
> Class WaitWindowSample does not exist!
java.lang.ClassNotFoundException: WaitWindowSample
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

I have a normal Netbeans (ant) project and added jemmy2.jar to project libraries.
What can be wrong?
Answer: you should use classname with full package info.
Try to use following code:
public static void main(String[] argv) {
    String[] params = {WaitWindowSample.class.getName()};
    org.netbeans.jemmy.Test.main(params);
}

I hope that it was worth to wait 9 months for this anwser :D
Comment: It won't help. The class is declared by the user as outlined in the question. Probably declaring the class in a package, rather than the default package, will help.
Comment: I can agree with you only partially. Yes, it is true that author of this post could use other package than default, and it could be the main cause of this error. On the other hand, we do not know if he made it intentionally. Using WaitWindowSample.class.getName() instead of "WaitWindowSample" would avoid problems with packages, becouse it would return full name of class with packages
Comment: In the case of default package, `WaitWindowSample.class.getName()` would return `"WaitWindowSample"` just as the question states.
Comment: Yes, in case of default package `WaitWindowSample.class.getName()` would return `WaitWindowSample`. For non default package f.eg. `package org.sample` it would return class with full package name, so it would be `org.sample.WaitWindowSample` .This would be solution for problem above, becouse developer doesn't have to put classpath as plain String. Have you tried to launch this code before commenting?
Comment: No, I haven't actually. Now I tried, it works perfectly with the String. However, I used command line to compile and run rather than NetBeans IDE. It's enough to add `-cp jemmy.jar` when compiling with `javac`; but you have to include the location of `WaitWindowSample.class` to cp when running with `java`, otherwise it does not find the class: `java -cp .;jemmy.jar WaitWindowSample`. But still, it does not answer the original question.
Comment: I agree, *using `WaitWindowSample.class.getName()` is better*: if the class moves between packages, the code will continue to work without modifications.


Best solution for public shop

Question: I want to create a site where users can sell their products.
How best to do this kind of system?
Is it a good idea to use Ubercart or it may be better to use something else?
Comment: Sorry, but any question asking for the 'best' of something is never likely to last long on a Stack Exchange site - it's just too opinion-based, and we need questions to be answerable objectively. The two e-commerce solutions currently are Ubercart and Drupal Commerce, to find out which is best for your own needs you need to do some reading about their features, install them, and actually use them to see if they're what you want
Comment: To add to what @Clive said, this question is also too broad: Whenever it is better to use the Ubercart module or another one depends from your requirements, but you didn't listed them. If you were to ask if it is possible to do something with Ubercart, that would be a better question, after you looked for an answer yourself, and reports what you found out.
Answer: You have got two options. Ubercart or Drupal commerce With Ubercart you have to do some bits of configuration to get your store ready.
With commerce, you have a basic store setup for you if you use the Commerce kickstart distribution.

Commerce Kickstart is the quickest way to get up and running with
  Drupal Commerce. It includes the latest versions of Drupal core,
  Drupal Commerce, and the other modules it depends on. It also gives
  you a set of options to create a fully-featured demo store out of the
  box complete with an attractive theme, catalog and search
  configuration, and a custom back office interface.
Who should use Commerce Kickstart? Anyone who wants to skip weeks of
  configuration to build a commerce site on the Drupal Commerce
  framework.

Best solution for public shop


TMX map not starting at x = 0. Android studio,

Question: Im trying to move the map to x = 0. the player is spawning correctly at x = 0, and the camera as well but the map is not.
this is the map tmx (untitled.tmx):
<code><?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="128" height="32" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="1">
 <editorsettings>
  <export target="untitled.tmx" format="tmx"/>
 </editorsettings>
 <tileset firstgid="1" name="tileset" tilewidth="32" tileheight="32" tilecount="180" columns="18">
  <image source="tileset.png" width="576" height="320"/>
 </tileset>
 <layer id="1" name="sky" width="128" height="32" offsetx="2.30303" offsety="1.09091">
  <data encoding="csv">
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112
</data>
 </layer>
 <layer id="2" name="ground" width="128" height="32" offsetx="2.30303" offsety="1.09091">
  <data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,3,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,21,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,38,38,38,38,38,38,38,38,38,39,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20
</data>
 </layer>
</map>

</code>
This is the MapGame class:
<code>
public class MapGame extends ApplicationAdapter {
    private TiledMap tiledMap;
    private OrthographicCamera camera;
    private OrthogonalTiledMapRenderer tiledMapRenderer;
    private SpriteBatch batch;
    private Player player;

    @Override
    public void create() {

        AssetManager assetManager = new AssetManager();
        assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
        assetManager.load("tilemap/untitled.tmx", TiledMap.class);
        assetManager.finishLoading();
        tiledMap = assetManager.get("tilemap/untitled.tmx", TiledMap.class);

        int screenWidth = Gdx.graphics.getWidth();
        int screenHeight = Gdx.graphics.getHeight();

        camera = new OrthographicCamera();
        camera.setToOrtho(false, screenWidth, screenHeight);
        camera.position.set(0, camera.viewportHeight / 2, 0);

        tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, 1);

        MapVar mapVar = new MapVar(tiledMap);

        batch = new SpriteBatch();

        player = new Player(0, screenHeight / 2);

        Gdx.input.setInputProcessor(new InputAdapter() {
            @Override
            public boolean touchDown(int screenX, int screenY, int pointer, int button){
                player.jump();
                return true;
            }

            @Override
            public boolean touchUp(int screenX, int screenY, int pointer, int button) {
                return true;
            }
        });

    }

    public void update() {
        updateCamera();
        player.checkGroundCollision();
    }

    private void updateCamera() {
        if(camera.position.x < MapVar.getMapWidthInPixels() - camera.viewportWidth / 2)
            camera.position.x +=2;

        camera.update();
    }

    @Override
    public void render() {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        player.update(Gdx.graphics.getDeltaTime());

        update();

        tiledMapRenderer.setView(camera);

        tiledMapRenderer.render();

        batch.begin();
        batch.draw(player.getPlayerTextureRegion(), player.getPosition().x, player.getPosition().y);
        batch.end();
    }

    @Override
    public void dispose() {
        tiledMap.dispose();
        batch.dispose();
    }
}

</code>
This is the Player class:
<code>
public class Player {
    private final Vector2 position;
    private final Vector2 velocity;
    private boolean canMove;
    private final Animation<TextureRegion> playerAnimation;
    private float stateTime;
    private static final float JUMP_VELOCITY = 10 * 50; // Adjust the jump velocity as needed
    private static final float JUMP_DURATION = 0.5f; // Duration of the jump in seconds
    private static final float GRAVITY = -5500; // Adjust the gravity value as needed
    private boolean isJumping;
    private float jumpTime;
    public Player(int x, int y) {

        Texture playerSheet = new Texture(Gdx.files.internal("spritesheet/run2.png"));

        int spriteColumns = 8;
        int spriteRows = 1;

        TextureRegion[][] playerFrames = TextureRegion.split(playerSheet, playerSheet.getWidth() / spriteColumns, playerSheet.getHeight() / spriteRows);

        Array<TextureRegion> frames = new Array<>();
        for (int i = 0; i < spriteRows; i++) {
            for (int j = 0; j < spriteColumns; j++) {
                frames.add(playerFrames[i][j]);
            }
        }

        playerAnimation = new Animation<>(0.1F, frames);
        playerAnimation.setPlayMode(Animation.PlayMode.LOOP);

        position = new Vector2(x, y);
        velocity = new Vector2();
        canMove = true;
        stateTime = 0;
        isJumping = false;
        jumpTime = 0;
    }

    public TextureRegion getPlayerTextureRegion() {
        return playerAnimation.getKeyFrame(stateTime);
    }

    public void jump() {
        if (!isJumping) {
            velocity.y = JUMP_VELOCITY;
            isJumping = true;
            jumpTime = 0;
        }
    }

    public void applyGravity(float deltaTime) {
        velocity.y += GRAVITY * deltaTime;
    }

    public void update(float deltaTime) {

        if (isJumping) {
            jumpTime += deltaTime;
            if (jumpTime >= JUMP_DURATION) {
                isJumping = false;
                velocity.y = 0;
            }
        }
        if (canMove && position.x <= MapVar.getMapWidthInPixels()) {
            float tileSize = MapVar.getTileWidthInPixels();
            float tilesPerSecondX = 5;

            velocity.x = tileSize * tilesPerSecondX;

            position.x += velocity.x * deltaTime;
            position.y += velocity.y * deltaTime;
        }
        stateTime += deltaTime;
    }

    public void checkGroundCollision() {
        int playerTileX = (int) (Math.ceil(position.x) / MapVar.getTileWidthInPixels());
        int playerTileY = (int)Math.ceil(position.y / MapVar.getTileHeightInPixels());

        int tileBelowValue = MapVar.getTileValue(playerTileX -2, playerTileY, "ground");

        if (tileBelowValue == 2) {
            position.y = (playerTileY + 1) * MapVar.getTileHeightInPixels();
            setJumping(false);
        }
        else if (tileBelowValue == 20) {
            position.y = (playerTileY + 2) * MapVar.getTileHeightInPixels();
            setJumping(false);
        }
        else if(tileBelowValue == 0){
            applyGravity(Gdx.graphics.getDeltaTime());
        }
    }

    public void move(float deltaX, float deltaY) {
        if(canMove){
            position.x += deltaX;
            position.y += deltaY;
        }
    }

    public Vector2 getPosition() {
        return position;
    }
    public void setPosition(int x, int y) {
        position.x = x;
        position.y = y;
    }

    public void setVelocity(float x, float y) {
        velocity.set(x, y);
    }

    public boolean canMove() {
        return canMove;
    }

    public void setCanMove(boolean canMove) {
        this.canMove = canMove;
    }

    public boolean isJumping() {
        return isJumping;
    }

    public void setJumping(boolean jumping) {
        isJumping = jumping;
    }
}

</code>
Image of the map in tiled
Image of the map in the game (The problem)
I dont know what to do anymore. please help me fix it, i would be so grateful!.
Answer: Your initial camera position x is this
<code>camera.position.set(0, camera.viewportHeight / 2, 0);
</code>
and you update the tileMapRenderer with
<code>tiledMapRenderer.setView(camera);
</code>
As far as the OrthogonalTileMapRenderer is concerned this sets the -center- of the camera (i.e. the center of the screen as you look at it) to x=0 of the tileMap coordinate system. So the position x=0 of the tileMap, the left of the map, renders at the center of the screen. The camera looks at x=0. What I mean is that the camera look at coordinates are centered, you are not specifying camera coordinates in terms of the lower left point of the viewport.


David Brubeck's "Take Five" in 4/4 Time

Question: Dave Brubeck's famous hit "Take Five" is traditionally arranged in performed in 5/4 time. My jazz ensemble instructor, however, said he once witnessed a performance of "Take Five" in a "funky 4/4 time." I was wondering how it is possible to manipulate a time signature to yield such an effect…how would the beats be adjusted to create the new rhythm?
Moreover, is there any purpose of doing this rather than for fun and for sake of variation? (not that those aren't great reasons to play with the elements of jazz)
Comment: Tito Puente's version https://www.youtube.com/watch?v=KB4iVzf10lY
Comment: I've reworked 4/4 songs into 5/4 - the first two crotchets in the bar became dotted crotchets.
Comment: Lullaby of Birdland translates into 5 time well
Comment: Here is a very funky 4/4 arrangement: https://www.youtube.com/watch?v=ouEmiXtIxHc
Comment: Not surprisingly, NReilingh's proposed mechanism for the funky variant of Take Five exactly matches what I hear in the drums on the Tito Puente video.
Answer: You can't do this algorithmically -- or I really mean to say you shouldn't. But as a musician and arranger, there are infinite possibilities to take some material and rework it into a different format.
To the specific example of "Take Five", consider the 5/4 rhythm groove:
5 | 1   2   3   4   5   |
4 | e e - e e - q   q   |
For me, I answer the question of "how would I play this groove in 4/4?" with the following:
4 | 1   2   3   4   |
4 | e e - e q   q   |
... which could easily be made to have a reggae feel.
I've left out some notes to accomplish this -- since a groove effectively is the rhythm, you can't really avoid that. But for the melody you don't have to leave out any notes at all -- the rhythms can be compressed and modified to "economize out" the missing beat.
Again, not algorithmically; putting the entire melody into 5:4 tuplets would be pretty uninspired. But you can get creative, shortening held notes and compressing rhythms, but mostly trying to retain the points of emphasis that exist in the original melody and rhythm/articulation.
A simple but good guide to this would be to try to retain the placement of beat 1 of each bar after translating. (In other words, make the note that occurs on beat 1 of every bar in 5/4 translate to the first beat of every bar in 4/4.)
As to the question of why? Well, it's fun, it's memorable (as evidenced by your jazz ensemble instructor), and of course making your ears and internal rhythmic clock do "weird" stuff can only benefit you as a musician.
Comment: I indeed have heard reggae versions of Take Five in bars. A quick Youtube search brings several results.
Comment: I think this is very helpful for analyzing "Take Five." What's more, this advice can be generalized to other pieces as well. Since my major concert just ended, I have some time to play around with it and some other pieces just to see what I can concoct.
Answer: Listen to the trailer of the 1990 BBC 4 program The Secret Life of Machines, the episode on radio, and you'll hear it done.

David Brubeck's "Take Five" in 4/4 Time


Problems with java app and remote dbase

Question: I'm having trouble with my java app on the database side of things. It uses connectorJ to communicate with a mysql dbase and works perfectly fine locally.  When communicating with a remote dbase, it performs dismally.  It's takes ages to start and windows that are supposed to open to display dbase data just say 'Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException' and prints a stack showing problems in places that work perfectly fine locally.  On top of that, features like search and uploads(based on xml-rpc) do not work at all but are fine  locally.  Am I missing something big? Please help me out.
Comment: Have you tried to connect to the remote database manually?
Comment: Yes I've done that and its working fine
Comment: I would start looking at the network, how many hops does a `tracert` show? Are any of the network cards set to auto-negotiate? etc.
Comment: Also, is the version of your local db the same as the remote db? You could look at an incompatibility issue Driver vs. DB
Comment: Does it "perform dismally" and give you meaningful results, or are you sometimes able to interact with the database and read/write stuff?
Comment: Sounds like sympthoms of nasty race conditions and non-thread safe code.
Answer: Have you investigated very carefully that you are not accidentially ignoring an error result or exception?
In other words, the code has told you something is wrong, but you keep continuing and you get lots of errors afterwards?

Problems with java app and remote dbase


Unitary in the Orthocomplement of a Matrix

Question:
Given a matrix $A \in M_n(\Bbb{C})$, does there exist a unitary $U \in M_n(\Bbb{C})$ such that $tr(AU)=0$?

Geometrically it seems true: thinking of $A$ as a vector in the plane, and unitaries as points on the unit-circle, then I should be able to rotate the line defined by $A$ through a $90$ deg. angle and intersect the circle at some point $U$, which means $A$ and $U$ are orthogonal. I just can't figure out how to put this geometric intuition into a proof...But perhaps this intuition is misguided
The condition $tr(AU)=0$ basically says that $A$ and $U$ are orthogonal. In fact, I'm really trying to show that the unitary group intersects the orthocomplement of $A$. With this in mind, I tried arguing by contradiction using a Hahn-Banach separation theorem, but I couldn't see how to finish the proof...
Another idea was to take the linearly independent columns of $A$, then use the Gram-Schmidt process to form an orthonormal basis for $\Bbb{C}^n$, and then use the vectors as the column of $U$. But I'm not sure this would work...In fact, it won't. If $A \in M_2(\Bbb{C})$ is the matrix whose first column is $(1,0)^T$ and second column is $(-1,1)^T$, the orthonormal basis formed from these is $(1,0)^T$ and $(0,1)^T$, meaning that the identity is the associated unitary. But clearly it doesn't satisfy the condition $Tr(AU)=0$.

Here is my attempt using Hahn-Banach. Since $\{A\}^\perp$ is closed and $U(n)$, the $n \times n$ unitary group, is compact, there exists a linear functional $\phi : M_n(\Bbb{C}) \to \Bbb{C}$ and $s,t \in \Bbb{R}$ such that
$$Re \phi (U) < t < s < Re \phi (X)$$
for all $U \in U(n)$ and $X \in \{A\}^\perp$. Alternatively, it says $Re \phi(U(n)) \subseteq (-\infty, t)$ and $Re \phi (\{A\}^\perp) \subseteq (s, \infty)$. Since $-U(n) \subseteq U(n)$, this implies $Re \phi(-U(n)) \subseteq (-\infty, t)$ or $Re \phi (U(n)) \subseteq (-t, \infty)$. Also $iU(n) \subseteq U(n)$, so $Re \phi(iU(n)) \subseteq (-\infty, t)$ or $Im \phi (U(n)) \subseteq (-t, \infty)$. Similarly, $-iU(n) \subseteq U(n)$ shows that $Im(\phi(U(n)) \subseteq (-\infty, t)$. Hence
$$\phi U(n) \subseteq (-t,t) \times (-t,t) \subseteq \Bbb{C}$$
Doing the same for $\{A\}^\perp$, we get
$$\phi (\{A\}^\perp) \subseteq (-s,s) \times (-s,s) \subseteq \Bbb{C}$$
By Riesz Representation theorem, there is some $C \in M_n(\Bbb{C})$ such that $\phi( \cdot) = Tr(C \cdot )$...
This is basically as far as I can get. I can't figure out what the contradiction is going to look like. I'll continue to think about it, however.
Answer: Suppose $A$ has the SVD $A = U_0\Sigma V_0^{\mathrm{H}}$, then $\mathrm{tr}(AU) = 0$ is equivalent to $\mathrm{tr}(\Sigma V_0^{\mathrm{H}}UU_0) = 0$. Let $P$ be the circular shift matrix defined as
$$
P_{ij} =
\begin{cases}
1,& \text{if}~j = (i~\text{mod}~n) + 1,\\
0,& \text{otherwise},
\end{cases}
$$
then $P$ is unitary and $\text{tr}(\Sigma P) = 0$.
Hence, we have $\mathrm{tr}(AU) = 0$ if we choose $U = V_0PU_0^{\mathrm{H}}$.
Answer: Yes, this is true. Because every matrix can be written as a linear
combination of unitary matrices. So if $tr\left(AU\right)=0$ for
all unitary $U\in M_{n}\left(\mathbb{C}\right)$, then $tr\left(AB\right)=0$
for all $B\in M_{n}\left(\mathbb{C}\right)$. Thus $tr\left(A^{*}A\right)=0$,
which holds iff $A=0$.
Comment: I think you might be proving a different theorem. I am not assuming that $tr(AU)=0$ holds for every unitary $U \in M_n(\Bbb{C})$. I am trying to find a unitary $U$ such that $tr(AU)=0$.


No such module Swift package manager for 'purchases' module

Question: I've quite literally tried everything and read every article/done hours of research. I cannot build my Xcode Project due to the fact it cannot find the module 'purchases' from: RevenueCat/purchases.
Everything was working well before I upgrade my Mac to the latest Ventura beta with the newest version of Xcode, where the issue started happening, I downgraded both my OS and Xcode thinking this issue would subside, but it hasn't.
I've tried resetting the package cache, deleting derived data, gone through each SO post and tried their answers, still nothing.
Yes the module and it's packages/frameworks are apart of my target
Answer: I had the issue this morning, and most of the issue was that I tried to upgrade from 3.x.x to 4.x.x at once, and swift compiler wanted to kill itself.
If you still use import Purchases ; then it's still 3.x.x and I solved it using:
products: [
  ...
  .library(name: "Premium", targets: ["Premium"]),
  ...
],
dependencies: [
  ...
  .package(url: "https://github.com/RevenueCat/purchases-ios.git", from: "3.0.0"),
  ...
],
targets: [
  ...
  .target(name: "Premium", dependencies: [
    .product(name: "Purchases", package: "purchases-ios"),
  ]),
  ...
]

Upgrading to 4.x.x wasn't that hard once I got 3.x.x compiling again.
This is what my Package.swift file looks like now:
products: [
  ...
  .library(name: "Premium", targets: ["Premium"]),
  ...
],
dependencies: [
  ...
  .package(url: "https://github.com/RevenueCat/purchases-ios.git", from: "4.0.0"),
  ...
],
targets: [
  ...
  .target(name: "Premium", dependencies: [
    .product(name: "RevenueCat", package: "purchases-ios"),
  ]),
  ...
]

And now, I need to use import RevenueCat as explained in the migration guide


Achieve single node field edit to have different values for each user?

Question: I am trying to create lets say and activity node which allow each user to insert a different value without having to create a node. for example:
I created activity1 node, and then I will allow user a to edit activity1 and insert value "a", and user b can also edit activity1 and insert value "b", and both can see their own activity1(the same node) but with different values for each user.
is this achieveable? as I tried using uniquefields module and that is the one I want for this case.
look forward for some response!
thank you
Answer: As you described it, it is not possible with core Drupal's field system. While you can create a node editable by many users with a multivalue field, the field (and its values) do not have property of ownership. Thus, your requirement to see different values for different users would not work.
There are alternative ways to achieve this. One path is to add 2 fields to the user profile.

Activity: an entity reference to your activity node.
Value: the user's field value you want to capture.

If the values are inherent single property of a user, you can add them directly to the user profile and use a Field Group to present it as combination of fields for the user to enter.
If the user can have many different Activity & Value combinations, you could use either use something like Field Collection or ECK/Inline Entity Form to present an embedded form in the user profile where users can add many different Activity/Value combinations.


Magnification based on touch location

Question: I'm having an issue developing a magnification based on touch location in Android. The result I want is similar to the older mac book application bar magnification; the icon where the mouse is hovered over is the largest magnified and the icons surround it slow scale down back to their original size.
I've included an image of what it should like if the user touch an icon in the center of the icons bar.

Currently I have code that somewhat works. I'm using a cos equation to create the scale factor but when you touch near the yellow icons, it causes the last green icon to magnify. Also the sloping affect isn't coming out properly. I've attached a photo with sample touches and the code.
Thank you for any help you can provide.

Java class preforming the scaling
public class Layout extends RelativeLayout implements View.OnTouchListener{
    private Camera mCamera = new Camera();
    private Matrix mMatrix = new Matrix();
    private ArrayList<Layer> layers = new ArrayList<Layer>();
    private final String TAG = this.getClass().getSimpleName();
    private int xTouch = 0;
    private int yTouch = 0;
    private boolean isUserInput = false;

    private int childHeight = 1;
    private Context context;

    public TrackerLayout(Context context) {
        super(context);
        setupView(context);
    }

    public TrackerLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        setupView(context);
    }

    public TrackerLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setupView(context);
    }

    private void setupView(Context context){
        this.context = context;
        setOnTouchListener(this);
        setWillNotDraw(false);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        if (layers.size() != getChildCount()) {
            getChildrenViews();
        }
        //getChild's order
        sortChildrenByDist();
        super.onDraw(canvas);

    }
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        childHeight = h / 8;
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
        if(isUserInput && yTouch >= 0) {
            Bitmap bitmap = child.getDrawingCache();

            if (bitmap == null) {
                child.setDrawingCacheEnabled(true);
                child.buildDrawingCache();
                bitmap = child.getDrawingCache();
            }

            //Get a reference for the child layer that's being modified
            Layer layer = null;
            for (Layer tempLayer : layers) {
                if (tempLayer.child.getId() == child.getId()) {
                    layer = tempLayer;
                    break;
                }
            }

            canvas.save();
            if(layer.coordinates.scale < 1){
                layer.coordinates.scale = 1;
            }
            canvas.scale(layer.coordinates.scale, layer.coordinates.scale, layer.coordinates.pivotX, layer.coordinates.pivotY);

            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setFilterBitmap(true);

            if (mCamera == null) {
                mCamera = new Camera();
            }

            mCamera.save();
            mCamera.rotateY(layer.coordinates.rotation);

            if (mMatrix == null) {
                mMatrix = new Matrix();
            }

            mCamera.getMatrix(mMatrix);
            mCamera.restore();

            mMatrix.preTranslate(-layer.coordinates.centerX, -layer.coordinates.centerY);
            mMatrix.postScale(layer.coordinates.scale, layer.coordinates.scale);
            mMatrix.postTranslate(layer.coordinates.pivotX, layer.coordinates.pivotY);
            canvas.drawBitmap(bitmap, layer.coordinates.left, layer.coordinates.top, paint);

            canvas.restore();
            return false;
        }
        return super.drawChild(canvas, child, drawingTime);

    }

    private void getChildrenViews() {
        int childrenCount = this.getChildCount();

        for (int i = 0; i < childrenCount; i++) {
            if (getChildAt(i) instanceof ImageView) {
                Layer layer = new Layer();
                ImageView child = (ImageView) getChildAt(i);
                int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, context.getResources().getDisplayMetrics());
                RelativeLayout.LayoutParams params = (LayoutParams) child.getLayoutParams();
                params.height = childHeight;
                child.setLayoutParams(params );
                layer.child = (child);

                layers.add(layer);
            }
        }
    }

    private void sortChildrenByDist() {
        ArrayList<Layer> negDistLayers = new ArrayList<Layer>();
        ArrayList<Layer> postDistLayers = new ArrayList<Layer>();

        for (Layer layer : layers) {
            layer.coordinates = calculateCoordinates(layer.child);
            if(layer.coordinates.distFromCenter >= 0 ){
                postDistLayers.add(layer);
            }else{
                negDistLayers.add(layer);
            }
        }

        Collections.sort(negDistLayers);
        Collections.sort(postDistLayers);

        layers.clear();
        layers.addAll(postDistLayers);
        layers.addAll(negDistLayers);

        drawOrderedLayers();
    }

    private synchronized void drawOrderedLayers() {
        for (int i = (layers.size() - 1); i > -1; i--) {
            this.bringChildToFront(layers.get(i).child);

        }
    }

    /**
     * This method calculates the coordinates used to create the rotates, camera, and scaling on each child view
     *
     * @param child - the view the coordinates will be calculated from
     * @return
     */

    private Coordinates calculateCoordinates(View child) {
        Coordinates coordinates = new Coordinates();

        coordinates.left = child.getLeft();
        coordinates.top = child.getTop();

        coordinates.centerX = child.getWidth() / 2;
        coordinates.centerY = child.getHeight() / 2;

        coordinates.pivotX = coordinates.left + coordinates.centerX;
        coordinates.pivotY = coordinates.top + coordinates.centerY;

        coordinates.userYInput = yTouch;
        coordinates.distFromCenter = (yTouch == 0) ? coordinates.pivotY : ((coordinates.pivotY - coordinates.userYInput) / coordinates.userYInput);

        double cosValue = (Math.cos(coordinates.distFromCenter));
        coordinates.scale = (float) (2 * cosValue);

        coordinates.rotation = coordinates.distFromCenter;
        return coordinates;

    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        final int action = event.getAction();
        Log.i(TAG, " on touch detected");
        switch (action & MotionEvent.ACTION_MASK) {

            case MotionEvent.ACTION_DOWN: {
                xTouch = (int) event.getX();
                yTouch = (int) event.getY();
                isUserInput = true;
                return true;
            }

            case MotionEvent.ACTION_MOVE: {

                xTouch = (int) event.getX();
                yTouch = (int) event.getY();
                isUserInput = true;
                return true;
            }

            default:
                isUserInput = false;
                return false;
        }

    }

    private class Coordinates {
        int left;
        int top;
        int centerX;
        int centerY;
        float pivotX;
        float pivotY;
        float userYInput;
        float distFromCenter;
        float scale;
        float rotation;

    }

    //This class will hold a reference to the child and it's coordinates to
    //help imitate layers
    private class Layer implements Comparable<Layer> {
        View child;
        Coordinates coordinates;

        //All values need to be sort towards ) so there's an if case to determine if the input is
        //comparing the list of positive values or negative values
        public int compareTo(Layer compareItem) {
            if(coordinates.distFromCenter >= 0) {
                return Float.compare(coordinates.distFromCenter, compareItem.coordinates.distFromCenter);
            }else{
                return Float.compare(compareItem.coordinates.distFromCenter, coordinates.distFromCenter);
            }
        }

    }

}

xml layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color">

    <com.layouts.Layout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/icon_level_1"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:layout_alignParentRight="true"
            android:background="#FFF66C"
            android:layout_alignParentTop="true"/>

        <ImageView
            android:id="@+id/icon_level_2"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#E7EE6C"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/ticon_level_1"/>

        <ImageView
            android:id="@+id/icon_level_3"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#CCE46D"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_2"/>

        <ImageView
            android:id="@+id/icon_level_4"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#B2E07B"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_3"/>

        <ImageView
            android:id="@+id/icon_level_5"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#8BDB91"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_4"/>

        <ImageView
            android:id="@+id/icon_level_6"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#65BE91"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_5"/>

        <ImageView
            android:id="@+id/icon_level_7"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#4E8F77"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_6"/>

        <ImageView
            android:id="@+id/icon_level_8"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#3A655F"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/icon_level_7"/>

    </com.layouts.Layout>

Answer: My fix for this was a much simpler equation.
I used the center pivot of each square to get their distance for the center and then divided the distance from the center by the layout height.
 distFromCenter = (yTouch == 0) ? pivotY : Math.abs((pivotY - userYInput));
 scale = (distFromCenter / layoutHieght);
 scale = scale == 0 ? 2 : 2 - scale.

The close the center, the larger the scale, other wise its reduced but never goes below 1.

Magnification based on touch location


One-to-one mapping from $\mathbb{R}^4$ to $\mathbb{R}^3$

Question: I'm trying to define a mapping from $\mathbb{R}^4$ into $\mathbb{R}^3$ that takes the flat torus to a torus of revolution.
Where the flat torus is defined by $x(u,v) = (\cos u, \sin u, \cos v, \sin v)$.
And the torus of revolution by $x(u,v) = ( (R + r \cos u)\cos v, (R + r \cos u)\sin v, r \sin u)$.
I think an appropriate map would be:
$f(x,y,z,w) = ((R + r x)z, (R + r x)w, r y)$ where $R$, $r$ are constants greater than $0$.
But now I'm having trouble showing this is one-to-one.
Comment: Presumably the mapping is only going to be one-to-one when restricted to the torus?
Answer: Compute the Jacobians of the two mappings.  I'll call your first mapping $X(u, v)$ so as not to re-use the variable $x$.  Let $R > r > 0$.
$$\frac{\partial X}{\partial(u, v)} = \left[ \begin{array}{cc}
-\sin u & 0 \\ \cos u & 0 \\ 0 & -\sin v \\ 0 & \cos v \end{array} \right] $$
$$\frac{\partial f}{\partial(x, y, z, w)} = \left[ \begin{array}{cccc}
rz & 0 & R + rx & 0 \\ rw & 0 & 0 & R + rx \\ 0 & r & 0 & 0 \end{array} \right] $$
The embedding in $\mathbb{R}^3$ is the composite $f \circ X$, whose Jacobian is the product of the Jacobians:
$$ \frac{\partial f}{\partial(x,y,z,w)}\frac{\partial X}{\partial(u,v)}
= \left[ \begin{array}{cc}
-rz\sin u & -(R + rx)\sin v \\ -rw\sin u & (R+rx)\cos v \\ r\cos u & 0  \end{array} \right]
= \left[ \begin{array}{cc}
-r\cos v\sin u & -(R + r\cos u)\sin v \\ -r\sin v\sin u & (R+r\cos u)\cos v \\ r\cos u & 0  \end{array} \right]

$$
(I used sage notebook www.sagenb.org for my computations.)
Now all of the questions concerning 1-to-1 can be phrased in terms of rank and nullity of these matrices.  For example, it easy to see the first and third matrices have rank 2 (so nullity=0) for all choices of $u, v$, (which shows both representations of the torus are immersive, meaning an appropriate restriction of domain will make those maps 1-to-1).
Now $f$ is 1-to-1 when restricted to $\mathrm{im} X$ (the flat torus) because $f \circ X$ is immersive and by restricting to $u, v \in [0, 2\pi)$, both $f$ and $f \circ X$ become 1-to-1.  In other words, if $f( X(u,v) ) = f(X(u', v'))$, then $X(u,v) = X(u', v')$.
Hope this helps!
Answer: Shaun's answer is insufficient since there are immersions which are not 1-1. For example, the figure 8 is an immersed circle. Also, the torus covers itself and all covering maps are immersions. http://en.wikipedia.org/wiki/Immersion_(mathematics)
Your parametrization of the torus of rotation is the the same as in http://en.wikipedia.org/wiki/Torus You just have to notice that the minimal period in both coordinates of the $uv$ plane is the same $2\pi$ in the case of both the flat and rotated tori.
Answer: Do you need to explicitly give the map or are you asked to prove both sets have the same cardinilty?
If not, it is a good exercise to prove $\mathbb{R}$ and $\mathbb{R}^2$ are both the same size (Schroeder-Bernstein theorem - consider decimal expansions to show a surjection) then via induction and the fact both sets are subsets of $\mathbb{R}^n$ we see there is a bijection between them. Explicitly finding a bijection is not clear to me, perhaps it is to someone else.
Comment: It doesn't look like you read the question very carefully...
Comment: It's possible that he only read the title of the question.


Orbeon Forms: Split Text into Control Fields

Question: We are pasting the following text into a Plain Text Area control:
{
"FIELD1":VALUE1,
"FIELD2":VALUE2,
"FIELD3":VALUE3,
"FIELD4":VALUE4
}
Then we need to unpack this data into separate fields within the form.
How can we achieve this?
Many thanks in advance.
PeteA
Comment: We found the answer using a Calculated Value within the controls using:

translate(substring-before(substring-after($vc_test, 'FIELD1":'), ','), '"', '') or
translate(substring-before(substring-after($vc_test, 'FIELD2":'), ','), '"', '')
Answer: If the user-entered value is in JSON format, you can also use the xxf:json-to-xml() function, which makes this both easier and more robust.

For reference:

The two fields to the right of the text area use the expressions xxf:json-to-xml($json)/json/author and xxf:json-to-xml($json)/json/date.
The source for this form is available here.
Comment: Many thanks Alex
Answer: See last explanation above using a Calculated Value formula.


Columns hidden/missing inside phpmyadmin

Question: When I click on the "explore" tab it would normally show me the data inside my table, but for some reason it wont show me all the columns. It only shows me 5 columns and the rest are hidden. The exact same thing happens when I use this query:
SELECT * FROM `tabs`

However, I do find the column and the data inside it when I specifically search for it:
SELECT `prevpage` FROM `tabs`

When I click on the dropdown arrow on the < T > column above the edit options I can choose which columns I want to show. There are two empty column names inside the list (exactly like two columns are missing), and when I choose to view them all the content inside them says NULL while its not.
Any idea's on how to solve this?
Comment: Are you running the "SELECT * FROM `tabs`" from phpmyadmin or from the terminal?
Comment: phpmyadmin, when I click on "SQL" I can insert my own SQL and run it.
Answer: I had a similar issue. However, the resolution was a lot different and EASIER to apply.
The issue was actually caused by 'Storage Engine'. All you need to do to clear this error is to:
     - Go to the table that is having the trouble of hidden column->
     - Got to 'Operation' Tab->
     - Under 'Table Options' ->
     - For 'Storage Engine' Option, select the one that is consistent with
       the one that you are   using throughout the table.
     - Refresh the table-> Wala! The missing column reappear in browse tab!

In the case for myself, I am using 'MyISAM' as default but was using 'InnoDB' for that specific troubled table.
It has took my an hour to figure out what happened and NOTHING was available online for this situation. Hope it helps one who has the same problem.
Comment: this solution works. go home phpmyadmin your drunk !
Answer: if u still interested in how to solve this..
just recently i got the same problem..
first of all, you must exporting your troublesome table..
and then, drop the table..
finally, importing the file to your database..
Comment: Thanks for your answer. I never solved this problem, I just quited with whatever I was doing (I forgot what it was), but I'm sure it might be useful to others.
Comment: I just encountered this problem, I can easily drop the table and rebuild it which will hopefully solve the issue but it's not knowing what is happening that is most troublesome..
Answer: My issue was with an indexed foreign key.  I reset my indexes and that resolved my issue, since the previous answers didn't work for me.
I've been leaching here for years...nice to HOPEFULLY give back for once!
Answer: Clear browser cache. Worked for me.
Answer: I ran into this problem. Logging out and in again solved it for me. Might help someone ending up here.


How to install FFMPEG encoders on Linux CentOS 5 Server

Question: I need to install

LAME MP3 Encoder
Libogg + Libvorbis
Mencoder and also Mplayer
FFMpeg-PHP

For a script called PHPmotion. I do have root access so please does anyone have a step by step. I am fairly comfortable with linux commands, but I am not a pro by any means.
Answer: Install the rpmforge release for RHEL (CentOS) 5.
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Then install ffmpeg package
yum -y install ffmpeg

The rest of the packages should also be in the rpmforge release.
Answer: Our internal wiki page at work on doing this references http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-–-the-easy-way/ (you'll have to fix up the URL manually, I have NFI what they've put in the middle of it) -- I haven't tried it myself, and the page is looking a bit old now, but it should at least get you on the right track.
Answer: I don't generally need media/codecs stuff for my Centos boxes, but I definitely do on my Fedora desktops.  For the latter case, I get them from RPMFusion, which just happens to have repositories for RHEL5-compatible releases so I would suggest looking there first.
Answer: The automated installer over @ http://ffmpeginstaller.com/ will have everything you need. Although if you don't have root access that would be an issue. Try and bubble this up to your host, should be an easy addition for them as long as you're not on shared hosting. I'd imagine PHPMotion will be utilizing shell_exec as well to execute ffmpeg commands so be sure to clarify that with them as well.


Retorno de ponteiro que apontam para um vetor de caractere local?

Question: #include <stdio.h>

char *local(void);

void main(void) {
    char *ponteiro = local();
    printf("%s\n", ponteiro); /*Saida = - (*/
}

char *local(void) {
    char nome[12] = "programador";
    char *ponteiro = nome;
    return ponteiro;
}

No exemplo acima tenho a seguinte saída comentada no código "- (" creio eu que seja algum lixo na região da memoria, porem se eu acesso o ponteiro por meio de índice ele me imprime o caractere, por exemplo ponteiro[0] imprimirá "p", agora se eu uso o modificador de tipo de classe de armazenamento static na variável nome a saída ocorre como esperado.
Por que ocorre isso nas três ocasiões citadas?
Comment: A resposta resolveu sua dúvida? Acha que pode aceitá-la? Veja o [tour] se não souber como faz. Isso ajudaria muito indicar que a solução foi útil para você. Também pode votar em qualquer pergunta ou resposta que achar útil no site todo
Answer: Vamos entender oque está fazendo cada linha:
char nome[12] = "programador";

Criou um espaço na pilha de dados para um ponteiro para caracteres que ficarão alocados em uma área estática da aplicação. Lá são 12 caracteres (11 úteis por causa do terminador). Este ponteiro é chamado de nome.
char *ponteiro = nome;

Criou um espaço na pilha de dados para um ponteiro (4 ou 8 bytes dependendo da arquitetura) e colocou o ponteiro para o espaço anterior referenciado como nome.
return ponteiro;

Encerrou a execução da função retornando (copiando) o valor desse ponteiro, "destruindo" toda área alocada nesse função (na verdade é só indisponibilizado)
Agora voltamos para a função principal. ponteiro aqui tem o mesmo valor de `ponteiro da função chamada, houve uma cópia.
printf("%s\n", ponteiro); /*Saida = - (*/

O ponteiro aí está apontando e portando acessando a área de memória que foi destruída. Qualquer coisa pode acontecer. Isto chama-se comportamento indefinido.
Quando você coloca um static na variável está dizendo que deseja alocar o conteúdo na área estática da sua aplicação, uma área que nunca é destruída (e diferente do stack), então o dado está lá como deseja.
Este código demonstra melhor o que deseja:
#include <stdio.h>
#include <string.h>

char *local(void) {
    static char nomex[12] = "aaaaaaaaaa";
    char nome[12] = "programador";
    char *ponteiro = nome;
    printf("%s\n", nome);
    printf("%s\n", ponteiro);
    printf("%p\n", (void *)ponteiro);
    printf("%p\n", (void *)nome);
    printf("%p\n", (void *)nomex);
    printf("%p\n", (void *)&ponteiro);
    return ponteiro;
}

int main(void) {
    char *ponteiro = local();
    printf("%s\n", ponteiro);
    printf("%c\n", ponteiro[0]);
    printf("%p\n", (void *)ponteiro);
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Agora veja este:
#include <stdio.h>
#include <string.h>

char *local(void) {
    static char nomex[12] = "aaaaaaaaaa";
    char nome[12] = "programador";
    char *ponteiro = nome;
    return ponteiro;
}

int main(void) {
    char *ponteiro = local();
    printf("%s\n", ponteiro);
    printf("%c\n", ponteiro[0]);
    printf("%p\n", (void *)ponteiro);
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Dependendo do compilador dará resultados diferentes, mesmo não mudando nada nas variáveis.
Comment: Bom foi uma ótima explicação mas fiquei com uma dúvida a matriz char nome pode ser visto como um unico ponteiro que aponta , pelo que entendi para pilha de dados ou e só um identificador que armazena x endereços de memória onde cada indice x aponta para uma região da memoria?
Comment: É o primeiro, `nome` aponta para o primeiro caractere na pilha, os demais são acessados por aritmética `nome + posicao`
Comment: Muito bom!!! então uma "string" e inteiro é uma constante alocada em uma área estática? e quando faço uma atribuição estou movendo da área estática para uma área dinâmica? já que matriz é alocada na pilha e uma pilha e uma região dinâmica e mutável correto?
Comment: Um literal sim. Uma *string*  geralmente fica em uma área específica de dados, o inteiro já fica na área de código mesmo (a não ser que seja uma sequência de inteiros), mas as duas áreas são estáticas. A primeira atribuição de algo que vem de um literal é mover do estático para o automático (o termo correto da pilha). Uma matriz pode ser alocada na pilha, ou no monte (*heap*) que é dinâmica. Estas regiões são mutáveis. Pesquise o termos aqui no site, já tem perguntas sobre.