text:
Q: How can we pass multiple filters to OData read I have come across with situation where more than 10 input values has to be passed to back end as filters. Is there any other option to create and pass filters instead of creating it in controller for each input filed?

A: If you want to have more sophisticated way of controlling the filter stuff declaratively via the XML view, for example, you can go with the following approach:

*

*Assign to all the affected inputs a "customData" property, defining the "filterProperty" and "filterOperation"

*Assign to all affected inputs the same "fieldGroupId"

*On the filter button trigger, grab all the input via the "getControlsByFieldGroupId" method and construct the filters using the custom data form each input via the "data" function call

for using custom data include the namespace to the view:
xmlns:data="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
customData doc
in XML:
<Input fieldGroupIds="InputGroup" data:filterName="Id" data:filterOperation="EQ" />
<Input fieldGroupIds="InputGroup" data:filterName="Name" data:filterOperation="Constains" />
<Input fieldGroupIds="InputGroup" data:filterName="Color" data:filterOperation="LT" />
in JS:
var aInputs = oView.getControlsByFieldGroupId("InputGroup");
var aFilters = aInputs.map(function(oInput) {
    var sFilterName = oInput.data("filterName");
    var sFilterOperation = oInput.data("filterOperation");

    return new Filter(sFilterName, sFilterOperation, oInput.getValue());
});

See example

A: You can create filter for every input and push it to the array of filters which you will use as you need.
E.g.:
var oFilter1 = new sap.ui.model.Filter("Input1", sap.ui.model.FilterOperator.Contains, value1);
var oFilter2 = new sap.ui.model.Filter("Input2", sap.ui.model.FilterOperator.Contains, value2);
var oFilter3 = new sap.ui.model.Filter("Input3", sap.ui.model.FilterOperator.Contains, value3);
var oFilter4 = new sap.ui.model.Filter("Input4", sap.ui.model.FilterOperator.Contains, value4);
var allFilters = new sap.ui.model.Filter([oFilter1, oFilter2, oFilter3, oFilter4], false);

For more info look here.

A:     //Create an array
    var aFilters = [];
        if (yourVal1) {
            aFilters.push(new sap.ui.model.Filter("Dimension", sap.ui.model.FilterOperator.EQ, yourVal1));
        }
        if (yourVal2) {
            aFilters.push(new sap.ui.model.Filter("Language", sap.ui.model.FilterOperator.EQ, yourVal1));
        }

        this.getModel().read("/YourEntitySet", {
            filters: aFilters,
            success: function(oData) {
                // use the response as required.
            },
            error: function() {

            }
        });


text:
Q: Scalar curvature and the degree of symmetry Let $M$ be a closed connected smooth manifold. We define the degree of symmetry of $M$ by $N(M):=\sup_\limits{g}\mathrm{dim}\,\mathrm{Isom}(M,g)$, where $g$ is  a smooth Riemannian metric on $M$ and $\mathrm{Isom}$ is the isometry group of the Riemannian manifold $(M,g)$.
The torus $T^n$ does not admit a Riemannian metric with positive scalar curvature and has $N(T^n)\neq 0$.
Is there a closed connected manifold $M$ with $N(M)=0$ such that $M$  admits a metric with positive scalar curvature?  That is, does admitting a metric with positive scalar curvature imply its degree of symmetry is nonzero?

A: It seems that there are examples. By a theorem of Gromov and Lawson every simply connected manifold of dimension $n \geq 5$ which is not spin admits a metric of positive scalar curvature.
There are many examples of simply connected, non-spin, closed $6$-manifolds which cannot admit a smooth circle action, constructed by Puppe. Theorem 7 of https://arxiv.org/pdf/math/0606714.pdf.
Then, since the isomotetry group of a closed manifold is a compact Lie group, if $N(M)>0$ then taking a maximal torus gives a non-trivial circle action, which contradicts the above. So every metric has isometry group of dimension $0$.
Edit: A specific example would be a quartic $3$-fold $X \subset \mathbb{CP}^4$. It admits a metric with positive Ricci curvature (since it is Fano), or alternatively since it is not spin we can apply Gromov-Lawson. It does not admit any smooth circle action due to a Theorem of Dessai and Wiemeler  https://arxiv.org/pdf/1108.5327.pdf.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Refresh the Grid with the latest Data in DATABASE I am using a grid where I am passing the values to the controller class and saving the data to Database, but if I refresh the page the new changes are gone. The datas that were present before saving the grid will be displayed again.
Here is my Code Snippet of ajax call.
$("#btnSaveJobCode").click(function(){

   var rowscount = $("#activityCodeRatioDistribution").jqxGrid('getdatainformation').rowscount;
   var postdata = "";
   var rows = $('#activityCodeRatioDistribution').jqxGrid('getrows');

 $.ajax({
          url : "saveActivityCodeRatio.htm",
          cache : false,
          type : "POST",
          contentType : "application/json",
          async : false,
          dataType : "json",
          data : JSON.stringify(rows)

          }).done(function(data) {
              alert("Save Successful.");
              $('#activityCodeRatioDistribution').trigger( 'reloadGrid' );

             }).fail(function() {alert("fail");});
       });

What should I do to get the latest data from Database at each refresh? I am using Spring MVC and JQX grid. Thanks in advance.

A: to reload grid use below code after ajax call
$("#activityCodeRatioDistribution").jqxGrid('updatebounddata', 'cells');

If your jqxGrid source attribute is retrieving values from DB then above mentioned reload will update the latest values from DB.

A: The ajax call mentioned above are pretty well. I don't think it has any problem.
Are the data being saved in the database? First of all check that manually.
If no, then correct the code in the controller to save data.
If yes, then, you have to check the source of the jqxgrid which you haven't mentioned here.
In source, check the 'id' that you have mentioned. jqxgrid doesn't display rows if two rows have same 'id'.
So, it would be better if you had given the snippet of jqxgrid too.
Thanks


text:
Q: Dumping $_POST variable in PHP I have a page that has a huge number of checkboxes, the name of the checkboxes are dynamically generated as they convey certain information about each checkbox.
I am trying to view the contents of the posted array with:
var_dump($_POST);

But I am getting an output of:
array(0) {}

Any ideas on how to display the $_POST array? Or maybe transfer it into another array and display it?
Example generated html:

Testing
Another Test
Another Test Collection

<form action="127.0.0.1/view_products.php?product=dvds&page=1" name="checkboxes"      method="post">

<input type="checkbox" name="21,dvds,1">

<input type="checkbox" name="21,dvds,2">

<input type="checkbox" name="21,dvds,3">

<input type="checkbox" name="21,dvds,4">

<input type="checkbox" name="21,dvds,5">

<input type="checkbox" name="21,dvds,6">

<input type="checkbox" name="21,dvds,7">

<input type="checkbox" name="21,dvds,8">

<input type="checkbox" name="21,dvds,9">

<input type="checkbox" name="21,dvds,10">

<input type="checkbox" name="22,dvds,1">

<input type="checkbox" name="22,dvds,2">

<input type="checkbox" name="22,dvds,3">

<input type="checkbox" name="22,dvds,4">

<input type="checkbox" name="22,dvds,5">

<input type="checkbox" name="22,dvds,6">

<input type="checkbox" name="22,dvds,7">

<input type="checkbox" name="22,dvds,8">

<input type="checkbox" name="22,dvds,9">

<input type="checkbox" name="22,dvds,10">

<input type="checkbox" name="23,dvds,1">

<input type="checkbox" name="23,dvds,2">

<input type="checkbox" name="23,dvds,3">

<input type="checkbox" name="23,dvds,4">

<input type="checkbox" name="23,dvds,5">

<input type="checkbox" name="23,dvds,6">

<input type="checkbox" name="23,dvds,7">

<input type="checkbox" name="23,dvds,8">

<input type="checkbox" name="23,dvds,9">

<input type="checkbox" name="23,dvds,10">

<input type="submit" value="Update">
</form>

Solved:
I didn't realise unticked boxes didn't get posted, turns out I needed to tick the checkboxes before posting. Sorry for the inconvinience.

A: Only checked checkboxes are returned in php $_POST. Try using hidden input if you want all values to be returned.
<input name="checkboxstatus[]" type="hidden" value="0">

You can manupulate hidden iput values using js.

A: Your form action is incorrect, that will try and submit to a the current URL /127.0.0.1/view_products.php?product=dvds&page=1.
try this:
<form action="http://127.0.0.1/view_products.php?product=dvds&page=1" name="checkboxes"      method="post">

A: Try using print_r($_POST)
But it looks like it isn't posting any data. Check that your html document that is posting the data is wrapped in <form action="submit.php" method="post"></form>

A: What you want to dump?
You are dumping nothing so it gives empty array.
ever
var_dump($_POST[username]);

this will dump username. likewise you can update your code to dump what ever you want


text:
Q: C# IDictionary with ICollection values without exposing implementation details I'm setting up a Dictionary with values of some sort of collection type as follows:
IDictionary<string, ICollection<decimal>> goodPrices =
    new Dictionary<string, List<decimal>>();

However, this line of code results in an compilation error about not being able to implicitly convert the right-hand side to the left-hand side.  Obviously, the following line produces no error:
IDictionary<string, List<decimal>> goodPrices =
    new Dictionary<string, List<decimal>>();

So what is the correct way of declaring "goodPrices" as a set of string-collection pairs without exposing the underlying implementation of the collection?

A: What about this :
IDictionary<string, ICollection<decimal>> goodPrices = new Dictionary<string, ICollection<decimal>>();
goodPrices.Add("myString", new List<decimal>() { /* my values */ });


text:
Q: Function doesBucketExist of amazon aws gives false result with bucket name contains .(dot) I am Using AWS api for Php. When I use doesBucketExist function and pass the bucket name as abc.def, it gives false result. But this bucket is present in S3. It is working fine with other buckets having simple name like wxyz.Basically it cannot take . (dot) in the name of bucket. So how I will read abc.def bucket.

A: Actually this problem occur due to PHP api. Download API from this link. It will solve your problem.
https://github.com/aws/aws-sdk-php


text:
Q: What is the most efficient way to render a HTML Table in Razor C# I am trying to create a html table that has about 5,000 rows.
I am retrieving the data from a SQL database which is grabbed in less than a second (ive only included the relevant code):
ViewBag.Jobs = dbContext.Jobs.Where(a=>a.State == "Completed");

This call is quick enough.
However the bottle neck is in the razor code:

@foreach (Job job in jobs)
{

       @job.id
       @job.Name
       @job.Description

 }

Is there a more efficient way to render the html table? I know I could convert the  to  using classes, but I don't believe it'll make noticeable difference?

A: 5000 rows is a lot of rows to show on a browser.
Any approach that you take will need to iterate through the rows to generate the output, so you might want to consider using some pagination to render the data.
Using html parsers like KnockoutJS or AngularJS to bind your element will help to render the page faster than this one...
Or you could consider using some ajax call and render the data after the page is loaded.


text:
Q: Nodejs Service returning datetime instead of just date when trying to cast datetime field to date of a SQL Server Query My database is SQL Server. I have the following sql query
SELECT RQI,RQIOver,PCI,PCIOver,PQI,PQIOver,SR,SROver,IRI,IRIOver,RUT,RUTOver,cast(DateCollected as date) as DateCollected,cast(DateCollectedOver as date) as DateCollectedOver from dbo.PF_Condition where SegmentId=12665
The result I am getting for DateCollected is just the date, which I need, when run it in SQL Management Studio. However when I put the same SQL query in a nodejs service which I created the result is not the same.
I needed to extract YYYY-MM-DD from datetime field DateCollected and DateCollectedOver as mentioned in the query above.
Can someone help me with it?

A: I made it work with the slice operator of javascript and sliced the date part only and displayed in the frontend where I need to. The results returned are of type string so the slice operator worked.
If someone can help why the cast function is not working in the sql query when I put it in the nodejs service it will be really helpful

A: After casting as DATE, you can then use the LEFT function to truncate the result to 10 characters:
LEFT(cast(DateCollected as date), 10) as DateCollected

which would return a string with the format 'YYYY-MM-DD'


text:
Q: Swift memory management hole: boundary case, feature or bug? Perhaps this will save somebody an hour or several of debugging time. Implementing an XML parser in Swift, analogous to Objective-C, seems simple enough:
private class Customparser : NSObject,NSXMLParser
{
    // ... implement the parser protocol methods
}

...

let parser=NSXMLParser(data:data)
parser.delegate=CustomParser()
let success=parser.parse()

This code fails with really unhelpful runtime errors (bad access).

A: Turns out the main problem is that assigning to the parser.delegate property directly triggers the automatic reference counting deallocation immediately, because it's an 'assign' property. So if the reader is attached to a different object instance, it lives long enough to actually perform its task:
let reader=CustomParser()
let parser=NSXMLParser(data:data)
parser.delegate=reader
let success=parser.parse()

In hindsight it's hard to say if it's a bug, because it is consistent with how the underlying Objective-C framework behaves, but it would sure seem that way to someone starting out with Swift.
There's another problem though: declaring the parser class as private does not cause any compiler errors, but it brings back the runtime crash. Taking out the private modifier solves the problem. Does this mean that private classes are compiled in a way that means they can't be handed off to other codeblocks?


text:
Q: Running total with annotated querysets in Django I have a running total template tag which looks like
from django.template import Library

register = Library()

@register.filter
def running_total(list, var_name):
    return sum(getattr(obj, var_name) or 0 for obj in list)

It works when I need a running total in normal querysets, but when I use a annotated queryset I get the exception 'dict' object has no attribute 'total'.
When I print a normal queryset in my template I get [<Item: Item #1>], but when I print a annotated queryset I get a list with a tuple [{'total_amount': Decimal('0.00'), ...].
Should I somehow convert the list in my templatetag?
I've tried adding
list = list(list)

but it still doesn't work.

A: arr = []
for obj in list:
    if isinstance(obj, dict):
        arr.append(obj[var_name] if var_name in obj else 0)
    else:
        arr.append(getattr(obj, var_name) or 0)
return sum(arr)

The reason is that elements in annotated queryset is not model instance anymore, it's dict.


text:
Q: How to unmarshal XML file in apache camel I have two classes ItemsDto and ItemDto
they represent data from XML file
@XmlR
ootElement(name = "items")
@XmlAccessorType(XmlAccessType.FIELD)
public class ItemsDto {

    @XmlElementRef
    private List<ItemDto> items;

    public List<ItemDto> getItems() {
        return items;
    }

    public void setItems(List<ItemDto> items) {
        this.items = items;
    }
}

and another
@XmlRootElement(name = "item")
@XmlAccessorType(XmlAccessType.FIELD)
public class ItemDto {

    @XmlElement
    private int itemNo;
    @XmlElement
    private String name;
    @XmlElement
    private String description;
    @XmlElement
    private int number;
    @XmlElement
    private int rating;

    public ItemDto() {
    }

    public ItemDto(int itemNo, String name, String description, int number) {
        this.itemNo = itemNo;
        this.name = name;
        this.description = description;
        this.number = number;
    }

    //getters and setters

}

and I have test.xml file
<items>
  <item>
    <itemNo>998</itemNo>
    <name>Rider Auto Part Generic Brakepad</name>
    <description>Basic brakepad for any motorbike</description>
    <number>100</number>
  </item>
</items>

I want to set a route to read from a file, but I don't know how to set unmarshaling part
I can't figure out what to do...
from("file:inputXML")
.unmarshal().  something
.process(exchange -> {
   System.out.println(exchange.getIn().getBody());
  })

A:     unmarshal(new JaxbDataFormat(JAXBContext.newInstance(ItemsDto.class))).process(e-> exchange.getIn().getBody(ItemsDto.class);)

after that u can use this class in processor


text:
Q: lineTo() Not working lineTo() function is not working for me, why? Here is the code.
<canvas id="sid" height="1000px" width="1000px"> </canvas>
<script>
    var can = document.querySelector('#sid');

    var a = can.getContext('2d');

    a.beginPath();
    a.moveTo(0, 0);
    a.lineTo(140, 140);
    a.lineTo(160, 160);

</script>

A: You forgot to call the stroke() function. It would be very helpful for you to check out the documentation, where it's explained in a more clear way.
From the docs:

The CanvasRenderingContext2D.stroke() method of the Canvas 2D API strokes the current or given path with the current stroke style using the non-zero winding rule.

<canvas id="sid" height="1000px" width="1000px"></canvas>
<script>
  var can = document.querySelector('#sid');

  var a = can.getContext('2d');

  a.beginPath();
  a.moveTo(0, 0);
  a.lineTo(140, 140);
  a.lineTo(160, 160);
  // After this you need to run the stroke command to get the line.
  a.stroke();
</script>

A: You're not stroking the line after you've defined it. Just add the stroke() method.
<canvas id="sid" height="1000px" width="1000px">       </canvas>
<script>
var can = document.querySelector('#sid');
var a = can.getContext('2d');
a.beginPath();
a.moveTo(0, 0);
a.lineTo(140, 140);
a.lineTo(160, 160);
a.stroke();  // This line is the import one being omitted.
a.closePath(); // You should close your path also. Not absolutely necessary in this case, given that stroke() will do this for you.
</script>

A: this help you :
<html>
<head>
   <meta charset="utf-8">

</head>
<body>
   <canvas id="sid" height="1000px" width="1000px"></canvas>
   <script>
        var can = document.getElementById("sid");
        var a = can.getContext('2d');
        a.beginPath();
        a.lineWidth = "5";
        a.strokeStyle = "green";
        a.moveTo(0,0);
        a.lineTo(140,140);
        a.lineTo(160,160);
       a.stroke();
   </script>
</body>
</html>


text:
Q: My jframe doesn't shows I'm beginner woth java programming
I tried to make my jframe shows but it didn't
jframe.setVisible(true);

it doesn't works

A: I think you didn't declare correctly your JFrame. Here is an example creating a simple frame :
public static void main(String[] args)
{
    // Creating a frame
    JFrame frame = new JFrame("Example");
    // Setting the position and the size of the frame
    frame.setBounds(0,0,800,600);
    // This will terminate the program when closing the frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Then you can display your frame
    frame.setVisible(true);
}


text:
Q: Is this htaccess rewrite correct? I have the following in my htaccess file. What I'm trying to do is to make
domain.com/index.php/view/whatever accessable via  domain.com/whatever
and also redirect from non www to www.
This works for all urls that have index.php/view in them but now other URLs that don't have index.php/view in them are breaking not working. Ex: domain.com/index.php/site/pages no longer works since it doesn't have index.php/view in it.
I want htaccess to only affect those URLs that have index.php/view in them and not anything else. What do I need to do to fix that?
RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php/view/$1 [L]

RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

UPDATE. To narrow things down, How can i have both rules like so. i need them both
RewriteRule ^(.*)$ /index.php/view/$1
RewriteRule ^(.*)$ /index.php/site/$1

A: So if a request is made to something like http://domain.com/index.php/site/pages, you want it to pass through untouched, but if it's something like http://domain.com/whatever, you want it to get rewritten?
The first rule you have there matches everything (except files and directories). You probably want to narrow the RewriteRule with something like:
RewriteRule !^index.php /index.php/view/$1 [L]
HTH
Neal


text:
Q: How to parse a and displat TMX map object in SDL using tmxparser ?/How to make a platform game using tiled editor and SDL? I am newbie in this field getting too much trouble in simple platform game for one of my project module
if you guys could help or share some code. This is what I have done till now.
I could parse a Tmx Map (created using tiled map editor)and display it using TmxParser library, But I don't know how to handle Map Object , Although I could get on internet how to parse also used an example given in the library it self. But I am not good at programming I would like to share code.
Objective : To make a simple Platform game where player can move and jump
Tools to be used : C++, Tiled , tmxparser and SDL
please help thanks in advance!
here is my code
#include <iostream>
#include <map>
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_image.h>
#include <tmxparser/Tmx.h>
#include <tmxparser/TmxLayer.h>
#include <tmxparser/TmxMap.h>
#include <tmxparser/TmxMapTile.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char * argv[])
{ SDL_Window *sdlWindow;
    SDL_Renderer *sdlRenderer;
    SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_MAXIMIZED, &sdlWindow, &sdlRenderer);
    SDL_SetWindowTitle(sdlWindow, "Tiled Test");
    SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 0, 255);
    SDL_RenderClear(sdlRenderer);
    SDL_RenderPresent(sdlRenderer);
    SDL_Event event;
    SDL_Texture* background = SDL_CreateTexture(sdlRenderer,
                               SDL_PIXELFORMAT_ARGB8888,
                               SDL_TEXTUREACCESS_STREAMING,
                               640, 480);

    Tmx::Map *map = new Tmx::Map();
    std::string fileName = (argc > 1) ? argv[1] : "./example/example.tmx";
    map->ParseFile(fileName);

    if (map->HasError())
    {
        printf("error code: %d\n", map->GetErrorCode());
        printf("error text: %s\n", map->GetErrorText().c_str());

        return map->GetErrorCode();
    }

    printf("====================================\n");
    printf("Map\n");
    printf("====================================\n");

    printf("Version: %1.1f\n", map->GetVersion());
    printf("Orientation: %d\n", map->GetOrientation());
    if (!map->GetBackgroundColor().empty())
        printf("Background Color (hex): %s\n",
               map->GetBackgroundColor().c_str());
    printf("Render Order: %d\n", map->GetRenderOrder());
    if (map->GetStaggerAxis())
        printf("Stagger Axis: %d\n", map->GetStaggerAxis());
    if (map->GetStaggerIndex())
        printf("Stagger Index: %d\n", map->GetStaggerIndex());
    printf("Width: %d\n", map->GetWidth());
    printf("Height: %d\n", map->GetHeight());
    printf("Tile Width: %d\n", map->GetTileWidth());
    printf("Tile Height: %d\n", map->GetTileHeight());
    std::map<const char*, SDL_Texture*> tilesets;
    // Iterate through the tilesets.
    for (int i = 0; i < map->GetNumTilesets(); ++i)
    {
        printf("                                    \n");
        printf("====================================\n");
        printf("Tileset : %02d\n", i);
        printf("====================================\n");

        // Get a tileset.
        const Tmx::Tileset *tileset = map->GetTileset(i);

        // Print tileset information.
        printf("Name: %s\n", tileset->GetName().c_str());
        printf("Margin: %d\n", tileset->GetMargin());
        printf("Spacing: %d\n", tileset->GetSpacing());
        printf("First gid: %d\n", tileset->GetFirstGid());
        printf("Image Width: %d\n", tileset->GetImage()->GetWidth());
        printf("Image Height: %d\n", tileset->GetImage()->GetHeight());
        printf("Image Source: %s\n", tileset->GetImage()->GetSource().c_str());

        //create tecture for tileset
        std::string location = "./example/" + tileset->GetImage()->GetSource();
                tilesets.insert(std::pair<const char*, SDL_Texture*>(tileset->GetName().c_str(), SDL_CreateTextureFromSurface(sdlRenderer, IMG_Load(location.c_str()))));

        if (!tileset->GetImage()->GetTransparentColor().empty())
            printf("Transparent Color (hex): %s\n",
                   tileset->GetImage()->GetTransparentColor().c_str());

        if (tileset->GetTiles().size() > 0)
        {
            // Get a tile from the tileset.
            const Tmx::Tile *tile = *(tileset->GetTiles().begin());

            // Print the properties of a tile.
            std::map<std::string, std::string> list =
                    tile->GetProperties().GetList();
            std::map<std::string, std::string>::iterator iter;
            for (iter = list.begin(); iter != list.end(); ++iter)
            {
                printf("%s = %s\n", iter->first.c_str(), iter->second.c_str());
            }

            if (tile->IsAnimated())
            {
                printf(
                        "Tile is animated: %d frames with total duration of %dms.\n",
                        tile->GetFrameCount(), tile->GetTotalDuration());

                const std::vector<Tmx::AnimationFrame> &frames =
                        tile->GetFrames();

                int i = 0;
                for (std::vector<Tmx::AnimationFrame>::const_iterator it =
                        frames.begin(); it != frames.end(); it++, i++)
                {
                    printf("\tFrame %d: Tile ID = %d, Duration = %dms\n", i,
                            it->GetTileID(), it->GetDuration());
                }
            }

            if(tile->HasObjects())
            {
                printf(
                        "Tile has objects.\n");

                // Iterate through all Collision objects in the tile.
                for (int j = 0; j < tile->GetNumObjects(); ++j)
                {
                    // Get an object.
                    const Tmx::Object *object = tile->GetObject(j);

                    // Print information about the object.
                    printf("Object Name: %s\n", object->GetName().c_str());
                    printf("Object Position: (%03d, %03d)\n", object->GetX(),
                           object->GetY());
                    printf("Object Size: (%03d, %03d)\n", object->GetWidth(),
                           object->GetHeight());

                    // Print Polygon points.
                    const Tmx::Polygon *polygon = object->GetPolygon();
                    if (polygon != 0)
                    {
                        for (int i = 0; i < polygon->GetNumPoints(); i++)
                        {
                            const Tmx::Point &point = polygon->GetPoint(i);
                            printf("Object Polygon: Point %d: (%f, %f)\n", i, point.x,
                                   point.y);
                        }
                    }

                    // Print Polyline points.
                    const Tmx::Polyline *polyline = object->GetPolyline();
                    if (polyline != 0)
                    {
                        for (int i = 0; i < polyline->GetNumPoints(); i++)
                        {
                            const Tmx::Point &point = polyline->GetPoint(i);
                            printf("Object Polyline: Point %d: (%f, %f)\n", i, point.x,
                                   point.y);
                        }
                    }
                }

            }
        }
    }

    // Iterate through the tile layers.
    for (int i = 0; i < map->GetNumTileLayers(); ++i)
    {
        printf("                                    \n");
        printf("====================================\n");
        printf("Layer : %02d/%s \n", i, map->GetTileLayer(i)->GetName().c_str());
        printf("====================================\n");

        // Get a layer.
        const Tmx::TileLayer *tileLayer = map->GetTileLayer(i);

        for (int y = 0; y < tileLayer->GetHeight(); ++y)
        {
            for (int x = 0; x < tileLayer->GetWidth(); ++x)
            {
                if (tileLayer->GetTileTilesetIndex(x, y) == -1)
                {
                    printf("........    ");
                }
                else
                {
                    // Get the tile's id and gid.
                    printf("%03d(%03d)", tileLayer->GetTileId(x, y), tileLayer->GetTileGid(x, y));

                    const Tmx::Tileset *tileset = map->GetTileset(tileLayer->GetTile(x,y).tilesetId);//map->FindTileset(layer->GetTileId(x, y));

                                      if (tileset != 0)
                                      {
                                          SDL_Rect rect; rect.x = x*tileset->GetTileWidth(); rect.y=y*tileset->GetTileHeight();rect.w=tileset->GetTileWidth();rect.h=tileset->GetTileHeight();
                                          const Tmx::MapTile *tile = &tileLayer->GetTile(x,y);
                                          tilesets.find(tileset->GetName().c_str());
                                          int tilesPerRow = tileset->GetImage()->GetWidth() / tileset->GetTileWidth();
                                          int tilyyyy = (tileLayer->GetTileId(x, y)) / tilesPerRow;
                                          SDL_Rect srcRect; srcRect.x = ((tileLayer->GetTileId(x, y) - (tilyyyy*tilesPerRow))*tileset->GetTileWidth()); srcRect.y = tilyyyy*tileset->GetTileHeight(), srcRect.h = tileset->GetTileHeight(); srcRect.w = tileset->GetTileWidth();
                                          SDL_Texture* tester = tilesets.find(tileset->GetName().c_str())->second;
                                          SDL_RenderCopy(sdlRenderer, tester, &srcRect,&rect);
                                          SDL_RenderPresent(sdlRenderer);
                    }

                    // Find a tileset for that id.
                    //const Tmx::Tileset *tileset = map->FindTileset(layer->GetTileId(x, y));
                    if (tileLayer->IsTileFlippedHorizontally(x, y))
                    {
                        printf("h");
                    }
                    else
                    {
                        printf(" ");
                    }
                    if (tileLayer->IsTileFlippedVertically(x, y))
                    {
                        printf("v");
                    }
                    else
                    {
                        printf(" ");
                    }
                    if (tileLayer->IsTileFlippedDiagonally(x, y))
                    {
                        printf("d ");
                    }
                    else
                    {
                        printf("  ");
                    }
                }
            }

            printf("\n");
        }
    }

    printf("\n\n");

    // Iterate through all of the object groups.
    for (int i = 0; i < map->GetNumObjectGroups(); ++i)
    {
        printf("                                    \n");
        printf("====================================\n");
        printf("Object group : %02d\n", i);
        printf("====================================\n");

        // Get an object group.
        const Tmx::ObjectGroup *objectGroup = map->GetObjectGroup(i);

        // Iterate through all objects in the object group.
        for (int j = 0; j < objectGroup->GetNumObjects(); ++j)
        {
            // Get an object.
            const Tmx::Object *object = objectGroup->GetObject(j);

            // Print information about the object.
            printf("Object Name: %s\n", object->GetName().c_str());
            printf("Object Position: (%03d, %03d)\n", object->GetX(),
                    object->GetY());
            printf("Object Size: (%03d, %03d)\n", object->GetWidth(),
                    object->GetHeight());

            // Print Polygon points.
            const Tmx::Polygon *polygon = object->GetPolygon();
            if (polygon != 0)
            {
                for (int i = 0; i < polygon->GetNumPoints(); i++)
                {
                    const Tmx::Point &point = polygon->GetPoint(i);
                    printf("Object Polygon: Point %d: (%f, %f)\n", i, point.x,
                            point.y);
                }
            }

            // Print Polyline points.
            const Tmx::Polyline *polyline = object->GetPolyline();
            if (polyline != 0)
            {
                for (int i = 0; i < polyline->GetNumPoints(); i++)
                {
                    const Tmx::Point &point = polyline->GetPoint(i);
                    printf("Object Polyline: Point %d: (%f, %f)\n", i, point.x,
                            point.y);
                }
            }
        }
    }

    delete map;
    bool quit = false;
    while (!quit)
    {
      while (SDL_PollEvent(&event))
      {
        switch (event.type)
        {
          case SDL_QUIT:
            quit = true;
            break;
        }
      }
    }
    SDL_DestroyRenderer(sdlRenderer);
    SDL_DestroyWindow(sdlWindow);
    SDL_Quit();
    return 0;
    return 0;
}

A: The code is working fine and should be able to display example.tmx with no problem (make sure you have a "example" directory with the needed files in there). As for information on Map object, I don't think there's other way other than to read the tiled map format (available here : http://doc.mapeditor.org/reference/tmx-map-format/ ). Also you could get help from Tiled's forum (http://forum.mapeditor.org/) if you have further questions.
As for your objective to "To make a simple Platform game where player can move and jump ", that in itself is a quite broad topic and I don't think that could be answered fully here.
Hope that helps.


text:
Q: Why is Contribute Being Required At the Site Level? We are running SharePoint 2013. I'm running into the oddest issue. On other SharePoint setups I was able to give everyone read access at the site level and then different groups contribute access to various lists. For some reason with this site, contribute permissions on a library will not work unless the person has contribute permission on the parent site.
Has anyone ran into this? The little bit I've been able to gather is that it has to do with content types. I'm not using any custom content types, just the default for the library. I'm stumped as this should be basic functionality.

A: Did you create the different groups from scratch? If so, and if the only permission you set for that group is "Contribute" on the library, you might also need to grant it the "Limited Access" permission at the site level.


text:
Q: GNOME Input Source switching - I can only switch once using shortcuts? I have GNOME installed on Ubuntu 13.10, and I enables several input methods (Japanese Anthy, Korean Hangeul and Chinese Pinyin) in addition to my English (US) keyboard. I set the shortcut to Ctrl+Space, then Super+Space, then Alt+Shift and multiple other combinations, however, whenever I use these shortcuts to attempt to cycle through my input methods, it only goes to the next one and stops.
For example, if I Ctrl+Space from English (US) to Japanese (Anthy), I cannot press Ctrl+Space to change further. I am stuck at Japanese (Anthy) until I let go of Ctrl+Space and repeat. However, clicking on the input method icon and changing still works for all input methods.
Does anyone know what the problem might be? To clarify again, I am using GNOME's input sources from System Settings.
UPDATE: The latest system updates have solved this problem.
UPDATE2: I have checked and realized that the problem exists in GNOME but not in GNOME Classic.
UPDATE2B: After further experimentation, I have found that the problem sometimes exists and sometimes doesn't exist, and doesn't depend on whether it is in GNOME or GNOME Classic. Logging out and in usually solves the problem.

A: Have you tried reassigning the same shortcut for Previous Source, in an attempt to blank it?
I remembered seeing this problem a few days ago as well, on a 13.10 fresh installation. Didn't have the keyboard option when I installed over a freshly formatted partition.
Later on, I reinstalled Ubuntu entirely due to another unrelated problem, and this time, I was given the option to set my keyboard. Did so, and the shortcut problem was gone.
Looking back upon this, you might want to try reconfiguring your keyboard settings.
sudo dpkg-reconfigure keyboard-configuration


text:
Q: Recovering data from a hard drive which disappears from /dev upon reading data in a bad block I'm attempting to recover as much data as possible from a failed 750 GB hard drive which is connected via a USB 3 drive enclosure.
The drive itself has over 1500 bad blocks, detected by badblocks on Linux.
It mounts perfectly on my computer (running macOS 10.12), but when data from a corrupt block is read, the drive idles for a few seconds, disappears from /dev, and then reappears — as if someone had unplugged the USB cable and then quickly plugged it back in again.
The first bad block occurs about 136 GiB from the start of the disk, however this is not the only one. This is evidenced by output from badblocks, along with when both dd and ddrescue fail.
dd and ddrescue both fail as soon as they read data from a bad block, since the drive then disappears from /dev:
dd if=/dev/rdisk3 of=image.img bs=16m:

ddrescue -v /dev/disk4 image.img logfile:

Rerunning ddrescue after the initial termination with the same log file results in it immediately terminating and not advancing further.
Since I am able to traverse the filesystem and access some files normally, I wrote a script to determine which files are accessible and which aren't, so I can copy the known good files from the disk. However, this is slow, and I'm worried that it may damage the disk further.
Is there any tool similar to dd or ddrescue which can recover data from this drive, which just waits for the drive to remount instead of automatically quitting upon reading a bad block?
I'm able to use both macOS as well as Linux (Ubuntu), so solutions for either platform would work for me.

A:
when data from a corrupt block is read, the drive idles for a few seconds, unmounts, and then remounts

I had the same problem with a drive that would "disappear" and then reappear later. It wasn't actually mounting either, but ddrescue was stopping when the device was disappearing. I was using it under Linux, but the situation is very similar.
I suggest you use a bit of simple shell programming and the fact that the drive actually eventually shows up again after a while. In other words, do:
while [ 1 ]; do
    ddrescue -v /dev/disk4 image.img logfile
    sleep 3
done

This works as follows:

*

*ddrescue is started

*if it stops running, the shell waits for 3 seconds then it starts it again

*ddrescue is able to continue because you are making good use of its logging capabilities

After a number of attempts (I think the default is 3 but I may be wrong), ddrescue will mark sectors as definitely bad and it will go on reading other parts of the drive. After some hours you will see that ddrescue will be done and you can kill the loop with Ctrl+C.

A: From GNU ddrescue Manual:

Example 6: While rescuing a partition in /dev/sda1 to the file hdimage, /dev/sda1 disappears from /dev.
ddrescue -f -n /dev/sda1 hdimage mapfile     <-- /dev/sda1 fails here
  (restart /dev/sda or reboot computer and then repeat the above
   command as many times as needed until it succeeds)
ddrescue -d -f -r3 /dev/sda1 hdimage mapfile

Andrea Lazzarotto's answer covers the "repeat the above command" part. There is an additional step in the example that uses -d switch. The manual explains it a little:

-d
--idirect
Use direct disc access to read from infile, bypassing the kernel cache. (Opens the file with the O_DIRECT flag). Sector size must be correctly set for this to work. Not all systems support this.

It is advised to further read the proper section of the manual. From therein:

Try the --idirect option first. If direct disc access is not available in your system, try raw devices. Read your system documentation to find how to bind a raw device to a regular block device. Some OSs provide raw access through especial device names, like /dev/rdisk.

MacOS does provide /dev/rdisk names. In your question however you use rdisk with dd but disk with ddrescue, so it seems to me you may still benefit from the additional step.
Linux users will find raw command useful. They should refer to man raw and to Example 2: using a raw device in the already mentioned section of the GNU ddrescue Manual.


text:
Q: I have to find the names of the employees who have never worked for two consecutive days in the same center I have to create a code, in sql, that allows me to find the id of the employees who haven't worked for two days in a row
My data has this structure:

id_emp
date
id_center

0001
2020-12-11
0045

0001
2020-12-12
0045

0001
2020-12-13
0045

0002
2020-12-11
0047

0002
2020-12-13
0047

0003
2020-12-11
0043

0003
2020-12-12
0043

...
...
...

The table to be returned must be structured like this:

id_emp

0002

A: Test this:
WITH cte AS (
    SELECT id_emp, DATEDIFF(date, LAG(date) OVER (PARTITION BY id_emp, id_center ORDER BY date)) = 1 consecutive
    FROM src_table
),
SELECT id_emp
FROM cte
GROUP BY id_emp
HAVING NOT SUM(consecutive)

A: select distinct id_emp
from mystery_table_name
where id_emp not in (
    select distinct id_emp
    from mystery_table_name a
    join mystery_table_name b on b.id_emp=a.id_emp and b.id_center=a.id_center and b.date=a.date + interval 1 day
)

Though looking for employees in your table of who worked when and where is strange, and will leave out employees who have never worked.  Surely you have an employee table.
If on mysql 8 or mariadb 10.2 or better, Akina's answer may be more performant, especially if you do not have an (id_emp,id_center,date) index.


text:
Q: How to update MST from the old MST if one edge is deleted I am studying algorithms, and I have seen an exercise like this
I can overcome this problem with exponential time but. I don't know how to prove this linear time O(E+V)
I will appreciate any help.

A: Let G be the graph where the minimum spanning tree T is embedded; let A and B be the two trees remaining after (u,v) is removed from T.

Premise P: Select minimum weight edge (x,y) from G - (u,v) that reconnects A and B. Then T' = A + B + (x,y) is a MST of G - (u,v).

Proof of P: It's obvious that T' is a tree. Suppose it were not minimum. Then there would be a MST - call it M - of smaller weight. And either M contains (x,y), or it doesn't.
If M contains (x,y), then it must have the form A' + B' + (x,y) where A' and B' are minimum weight trees that span the same vertices as A and B.  These can't have weight smaller than A and B, otherwise T would not have been an MST.  So M is not smaller than T' after all, a contradiction; M can't exist.
If M does not contain (x,y), then there is some other path P from x to y in M. One or more edges of P pass from a vertex in A to another in B. Call such an edge c. Now, c has weight at least that of (x,y), else we would have picked it instead of (x,y) to form T'. Note P+(x,y) is a cycle. Consequently, M - c + (x,y) is also a spanning tree. If c were of greater weight than (x,y) then this new tree would have smaller weight than M. This contradicts the assumption that M is a MST. Again M can't exist.
Since in either case, M can't exist, T' must be  a MST. QED
Algorithm
Traverse A and color all its vertices Red. Similarly label B's vertices Blue.  Now traverse the edge list of G - (u,v) to find a minimum weight edge connecting a Red vertex with a Blue. The new MST is this edge plus A and B.

A: When you remove one of the edges then the MST breaks into two parts, lets call them a and b, so what you can do is iterate over all vertices from the part a and look for all adjacent edges, if any of the edges forms a link between the part a and part b you have found the new MST.
Pseudocode :
for(all vertices in part a){
    u = current vertex;
    for(all adjacent edges of u){
        v = adjacent vertex of u for the current edge
        if(u and v belong to different part of the MST) found new MST;
    }
}

Complexity is O(V + E)
Note : You can keep a simple array to check if vertex is in part a of the MST or part b.
Also note that in order to get the O(V + E) complexity, you need to have an adjacency list representation of the graph.

A: Let's say you have graph G' after removing the edge. G' consists have two connected components.
Let each node in the graph have a componentID. Set the componentID for all the nodes based on which component they belong to. This can be done with a simple BFS for example on G'. This is an O(V) operation as G' only has V nodes and V-2 edges.
Once all the nodes have been flagged, iterate over all unused edges and find the one with the least weight that connects the two components (componentIDs of the two nodes will be different). This is an O(E) operation.
Thus the total runtime is O(V+E).


text:
Q: Using custom array adapter i am learning to use custom adapter and i think i am headed to the right direction until i have problem with the super method of the constructor of class Custom Adapter. Could you identify the problem behind it ?
Before that i used Simple Adapter but i want more flexibility in controlling the layout.
Here is my xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">

    <!-- Name Label -->

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello This is testing"
        android:id="@+id/guid"
        android:visibility="gone"/>

    <TextView
        android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="2dip"
        android:paddingTop="6dip"
        android:textColor="#43bd00"
        android:text="name:"
        android:textStyle="bold"
        android:visibility="gone"/>

    <!-- Email label -->
    <TextView
        android:id="@+id/email"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="2dip"
        android:textColor="#acacac"
        android:text="email"
        android:textStyle="bold"
        />

    <!-- Mobile number label -->
    <TextView
        android:id="@+id/mobile"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:text="Mobile: "
        android:textColor="#5d5d5d"
        android:maxLines="1"/>

</LinearLayout>

here is my fragment class
public class NewsFragment extends Fragment{

    private ProgressDialog pDialog;// Progress Dialog
    ListView newsList;
    ArrayList<HashMap<String, String>> postList; //Declare Array
    private static String url = "http://wangeltmg.com/GKN_ADMIN/GET_POSTS/get_news.php";
    GetNews.CustomAdapter CA;

    // JSON Node names
    private static final String TAG_ID = "id";
    private static final String POST_ALLPOSTS = "posts";
    private static final String POST_ID = "ID";
    private static final String POST_TITLE = "post_title";
    private static final String POST_CONTENT = "post_content";
    private static final String GUID = "guid";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.news, container, false);
        newsList = (ListView) view.findViewById(R.id.newsListView);
        TextView topic = (TextView) view.findViewById(R.id.topic);
        postList = new ArrayList<HashMap<String, String>>();
        //Get arguments
        Bundle args = getArguments();
        String mytopic = args.getString("Topic");
        //Set topic
        topic.setText(mytopic.toUpperCase());
        //Execute getContacts
        new GetNews().execute();

        newsList.setOnItemClickListener(new newsListClick());

        return view;
    }

    public class newsListClick implements ListView.OnItemClickListener{

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d("News List","Clicked " + id);
            android.support.v4.app.FragmentManager fragmentManager = getFragmentManager();
            android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            SinglePost singleFrag = new SinglePost();
            fragmentTransaction.replace(R.id.content_frame, singleFrag);
            fragmentTransaction.commit();
        }
    }

    //Async Task
    private class GetNews extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Showing progress dialog
            pDialog = new ProgressDialog(getActivity());
            pDialog.setMessage("Please wait...");
            pDialog.setCancelable(false);
            pDialog.show();

        }

        @Override
        protected Void doInBackground(Void... arg0) {

            // Creating service handler class instance
            ServiceHandler sh = new ServiceHandler();

            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
            Log.d("Strings","Checking Json");
            Log.d("Response: ", "> " + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);
                    // contacts JSONArray
                    JSONArray posts = null;
                    // Getting JSON Array node
                    posts = jsonObj.getJSONArray(POST_ALLPOSTS);

                    // looping through All Contacts
                    for (int i = 0; i < posts.length(); i++) {

                        JSONObject c = posts.getJSONObject(i);
                        Log.d("Post->",posts.getJSONObject(i).toString());

                        String id = c.getString(POST_ID);

                        Log.d("Post->ID",id);
                        String post_title = c.getString(POST_TITLE);
                        String post_content = c.getString(POST_CONTENT);
                        String guid = c.getString(GUID);
                        Log.d("GUID->",guid);
                        //String gender = c.getString(TAG_GENDER);

                        // tmp hashmap for single post
                        HashMap<String, String> post = new HashMap<String, String>();

                        // adding each child node to HashMap key => value
                        post.put(POST_ID, id);
                        post.put(POST_TITLE, post_title);
                        post.put(POST_CONTENT, post_content);
                        post.put(GUID, guid);

                        // adding contact to contact list
                        postList.add(post);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

            return null;
        }

        @Override
        public void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            if (pDialog.isShowing())
                pDialog.dismiss();

             // Updating parsed JSON data into ListView
            /*
            ListAdapter adapter = new SimpleAdapter(getActivity(), postList, R.layout.list_item,
                    new String[] { POST_TITLE,POST_CONTENT, GUID },
                    new int[] {R.id.email, R.id.mobile, R.id.guid });
            */

            CA = new CustomAdapter( getActivity(), R.layout.list_item, postList);
            newsList.setAdapter(CA);
        }

        public class CustomAdapter extends ArrayAdapter<HashMap<String, String>>{

            public CustomAdapter(Context context, int resource, ArrayList<HashMap<String, String>> objects) {
                //something is wrong with super
                super(context, resource, objects);

            }
            public View getView(int position, View convertView, ViewGroup Parent){
                if(convertView == null){
                    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    convertView = inflater.inflate(R.layout.list_item,null);

                }

                HashMap<String, String> objects = new HashMap<String, String>();

                TextView thisview = (TextView) convertView.findViewById(R.id.email);
                thisview.setText(objects.get(position).get(POST_TITLE));

                return convertView;
            }
        }//

    }
}

A: Change this line
CA = new CustomAdapter(this, R.layout.list_item, postList);

to
CA = new CustomAdapter(getActivity(), R.layout.list_item, postList);

NOTE : While you are using Fragment you should use getActivity() as a Context.
Also keep in mind that you's using HashMap<String,String> so your ArrayAdapter will be ArrayAdapter<HashMap<String, String>> instead of ArrayAdapter<String>.

A: You are extending ArrayAdapter<String> and passing ArrayList as constructor argument. They both have to be of the same type.
Also, you need to pass Context and not your asynctask GetNews.
You could also look at BaseAdapter where you need not pass any array as constructor argument.

A: To expand on Piyush's answer, you will also need to modify the CustomAdapter constructor
From this:
public CustomAdapter(GetNews context, ... ) { }

to this
public CustomAdapter(Context context, ... ) { }

This is because getActivity() will return an Activity, which is an instance of the Context class - Not an instance of GetNews

A:     private ArrayList<HashMap<String, String>> mList;
    public void setmList(ArrayList<HashMap<String, String>> mList) {
        this.mList = mList;
    }

    public CustomAdapter(Context context, int resource) {
        //something is wrong with super
        super(context, resource);
    }

and initialize it with setting list
CA = new CustomAdapter(getActivity, R.layout.list_item);
CA.setmList(yourlist);

don't know why the super with three parameter is not working in this case but it will surely resolve your issue


text:
Q: Azure DevOps hosted agent using wrong typescript version for .njsproj Our .njsproj project uses typescript 3.8.2. It's defined in the package.js as well as in the .njsproj file with <TypeScriptToolsVersion>3.8</TypeScriptToolsVersion>.
But the Azure DevOps agent always uses version 4.1 for this project and then the build fails.
For .csproj you can just install the appropriate typescript.msbuild nuget package, but how do I set the version for .njsproj files to be picked up by the build agent?
Researching this issue gives me lots of different answers from "it's not possible" to "try this solution" which then never worked for the thread starter and for me.

A: Please refer to this doc:  The Typescript has these method to install.

The TypeScript NuGet package.

The TypeScript npm package.

The TypeScript SDK,

In Azure Devops Agent, it only comes pre-installed Typescript 4.1(Windows-2019). So when you run the pipeline, it will use the version 4.1 by default.
Based on your situation, the method 3 (The TypeScript SDK) could meet your requirement.
You could  download the TypeScript SDK from the website: Typescript 3.8.2.
Here is the Powershell script example:
$client = new-object System.Net.WebClient
$client.DownloadFile('https://marketplace.visualstudio.com/_apis/public/gallery/publishers/TypeScriptTeam/vsextensions/typescript-382/3.8.2/vspackage','C:/installer1.exe')

$pathvargs = {C:/installer1.exe /S /v/qn }
Invoke-Command -ScriptBlock $pathvargs

sleep -s 30

Result:

Run the following command to check:
Get-ChildItem -Path  'C:\Program Files (x86)\Microsoft SDKs\TypeScript'  -Recurse -Directory -Force -ErrorAction SilentlyContinue | Select-Object FullName

On the other hand , you could directly download the exe file from the website and  upload it to your repo. Then you could directly run the following command to install it.
$pathvargs = {$(build.sourcesdirectory)/TypeScript_SDK.exe /S /v/qn }
Invoke-Command -ScriptBlock $pathvargs

sleep -s 30


text:
Q: JQuery - $ is not defined I have a simple jquery click event
<script type="text/javascript">
    $(function() {
        $('#post').click(function() {
            alert("test");
        });
    });
</script>

and a jquery reference defined in the site.master
<script src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.js")%>" type="text/javascript"></script>

I have checked that the script is being resolved correctly, I'm able to see the markup and view the script directly in firebug, so I must be being found. However, I am still getting:

$ is not defined

and none of the jquery works. I've also tried the various variations of this like $(document).ready and jQuery etc.
It's an MVC 2 app on .net 3.5, I'm sure I'm being really dense, everywhere on google says to check the file is referenced correctly, which I have checked and checked again, please advise! :/

A: First you need to make sure that jQuery script is loaded. This could be from a CDN or local on your website.  If you don't load this first before trying to use jQuery it will tell you that jQuery is not defined.
<script src="jquery.min.js"></script>

This could be in the HEAD or in the footer of the page, just make sure you load it before you try to call any other jQuery stuff.
Then you need to use one of the two solutions below
(function($){
// your standard jquery code goes here with $ prefix
// best used inside a page with inline code,
// or outside the document ready, enter code here
 })(jQuery);

or
jQuery(document).ready(function($){
// standard on load code goes here with $ prefix
// note: the $ is setup inside the anonymous function of the ready command
});

please be aware that many times $(document).ready(function(){//code here}); will not work.

A: Are you using any other JavaScript libraries? If so, you will probably need to use jQuery in compatibility mode:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries

A: That error can only be caused by one of three things:

*

*Your JavaScript file is not being properly loaded into your page

*You have a botched version of jQuery.  This could happen because someone edited the core file, or a plugin may have overwritten the $ variable.

*You have JavaScript running before the page is fully loaded, and as such, before jQuery is fully loaded.

First of all, ensure, what script is call properly, it should looks like
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

and shouldn't have attributes async or defer.
Then you should check the Firebug net panel to see if the file is actually being loaded properly.  If not, it will be highlighted red and will say "404" beside it.  If the file is loading properly, that means that the issue is number 2.
Make sure all jQuery javascript code is being run inside a code block such as:
$(document).ready(function () {
  //your code here
});

This will ensure that your code is being loaded after jQuery has been initialized.
One final thing to check is to make sure that you are not loading any plugins before you load jQuery.  Plugins extend the "$" object, so if you load a plugin before loading jQuery core, then you'll get the error you described.
Note: If you're loading code which does not require jQuery to run it does not need to be placed inside the jQuery ready handler. That code may be separated using document.readyState.

A: If the jQuery plugin call is next to the </body>, and your script is loaded before that, you should make your code run after window.onload event, like this:
window.onload = function() {
  //YOUR JQUERY CODE
}

`
so, your code will run only after the window load, when all assets have been loaded. In that point, the jQuery ($) will be defined.
If you use that:
$(document).ready(function () {
  //YOUR JQUERY CODE
});

`
the $ isn't yet defined at this time, because it is called before the jQuery is loaded, and your script will fail on that first line on console.

A: after some tests i found a fast solution ,
you can add in top of your index page:
<script>
$=jQuery;
</script>

it work very fine :)

A: I had the same problem and resolved it by using
document.addEventListener('DOMContentLoaded', () => {
 // code here
});

A: I got the same error message when I misspelled the jQuery reference and instead of type="text/javascript" I typed "...javascirpt". ;)

A: It sounds like jQuery isn't loading properly. Which source/version are you using?
Alternatively, it could a be namespace collision, so try using jQuery explicitly instead of using $. If that works, you may like to use noConflict to ensure the other code that's using $ doesn't break.

A: I just did the same thing and found i had a whole lot of
type="text/javacsript"

So they were loading, but no further hint as to why it wasn't working. Needless to say, proper spelling fixed it.

A: That error means that jQuery has not yet loaded on the page.  Using $(document).ready(...) or any variant thereof will do no good, as $ is the jQuery function.
Using window.onload should work here.  Note that only one function can be assigned to window.onload.  To avoid losing the original onload logic, you can decorate the original function like so:
originalOnload = window.onload;
window.onload = function() {
  if (originalOnload) {
    originalOnload();
  }
  // YOUR JQUERY
};

This will execute the function that was originally assigned to window.onload, and then will execute // YOUR JQUERY.
See https://en.wikipedia.org/wiki/Decorator_pattern for more detail about the decorator pattern.

A: It could be that you have your script tag called before the jquery script is called.
<script type="text/javascript" src="js/script.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

This results as $ is not defined
Put the jquery.js before your script tag  and it will work ;) like so:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript" src="js/script.js"></script>

A: Use a scripts section in the view and master layout.
Put all your scripts defined in your view inside a Scripts section of the view. This way you can have the master layout load this after all other scripts have been loaded. This is the default setup when starting a new MVC5 web project. Not sure about earlier versions.
Views/Foo/MyView.cshtml:
// The rest of your view code above here.

@section Scripts
{
    // Either render the bundle defined with same name in BundleConfig.cs...
    @Scripts.Render("~/bundles/myCustomBundle")

    // ...or hard code the HTML.
    <script src="URL-TO-CUSTOM-JS-FILE"></script>

    <script type="text/javascript">
      $(document).ready(function () {

        // Do your custom javascript for this view here. Will be run after
        // loading all the other scripts.
      });
    </script>
}

Views/Shared/_Layout.cshtml
<html>
<body>
    <!-- ... Rest of your layout file here ... -->

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

Note how the scripts section is rendered last in the master layout file.

A: It means that your jQuery library has not been loaded yet.
You can move your code after pulling jQuery library.
or you can use something like this
window.onload = function(){
  // Your code here
  // $(".some-class").html("some html");
};

A: I use Url.Content and never have a problem.
<script src="<%= Url.Content ("~/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"></script>

A: In the solution it is mentioned -
"One final thing to check is to make sure that you are not loading any plugins before you load jQuery. Plugins extend the "$" object, so if you load a plugin before loading jQuery core, then you'll get the error you described."
For avoiding this -
Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():

A: As stated above, it happens due to the conflict of $ variable.
I resolved this issue by reserving a secondary variable for jQuery with no conflict.
var $j = jQuery.noConflict();

and then use it anywhere
$j( "div" ).hide();

more details can be found here

A: make sure you really load jquery
this is not jquery - it's the ui!
  <script language="JavaScript"
    src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js">
  </script>

This is a correct script source for jquery:
 <script language="JavaScript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>

A: I had this problem once for no apparent reason. It was happenning locally whilst I was running through the aspnet development server. It had been working and I reverted everything to a state where it had previously been working and still it didn't work. I looked in the chrome debugger and the jquery-1.7.1.min.js had loaded without any problems. It was all very confusing. I still don't know what the problem was but closing the browser, closing the development server and then trying again sorted it out.

A: Just place  jquery url on the top of your jquery code
like this--
<script src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.js")%>" type="text/javascript"></script>

<script type="text/javascript">
    $(function() {
        $('#post').click(function() {
            alert("test");
        });
    });
</script>

A: I had the same problem and it was because my reference to the jQuery.js was not in the  tag.  Once I switched that, everything started working.
Anthony

A: *

*Check the exact path of your jquery file is included.
<script src="assets/plugins/jquery/jquery.min.js"></script>
if you add this on bottom of your page , please all call JS function below this declaration.

*Check using this code test ,
<script type="text/javascript">
/***
 * Created by dadenew
 * Submit email subscription using ajax
 * Send email address
 * Send controller
 * Recive response
 */
$(document).ready(function() { //you can replace $ with Jquery

  alert( 'jquery working~!' );
});

Peace!

A: This is the common issue to resolve this you have to check some point

*

*Include Main Jquery Library

*Check Cross-Browser Issue

*Add Library on TOP of the jquery code

*Check CDNs might be blocked.

Full details are given in this blog click here

A: I came across same issue, and it resolved by below steps.
The sequence of the scripts should be as per mentioned below
    <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script src="~/Scripts/jquery-ui.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>

This sequence was not correct for my code, I corrected this as per the above and it resolved my issue of Jquery not defined.

A: We have the same problem....but accidentally i checked folder properties and set something...
You have to check the properties of each folders that you're accessing..

*

*right click folder

*'permissions' tab

*set the folder access :
 OWNER: create and delete files
 GROUP: access files
 OTHERS: access files

I hope that this is the solution......

A: When using jQuery in asp.net, if you are using a master page and you are loading the jquery source file there, make sure you have the header contentplaceholder after all the jquery script references.
I had a problem where any pages that used that master page would return '$ is not defined' simply because the incorrect order was making the client side code run before the jquery object was created. So make sure you have:
<head runat="server">
    <script type="text/javascript" src="Scripts/jquery-VERSION#.js"></script>
    <asp:ContentPlaceHolder id="Header" runat="server"></asp:ContentPlaceHolder>
</head>

That way the code will run in order and you will be able to run jQuery code on the child pages.

A: In my case I was pointing to Google hosted JQuery.  It was included properly, but I was on an HTTPS page and calling it via HTTP.  Once I fixed the problem (or allowed insecure content), it fired right up.

A: After tried everything here with no result, I solved the problem simply by moving the script src tag from body to head

A: I was having this same problem and couldn't figure out what was causing it. I recently converted my HTML files from Japanese to UTF-8, but I didn't do anything with the script files. Somehow jquery-1.10.2.min.js became corrupted in this process (I still have no idea how). Replacing jquery-1.10.2.min.js with the original fixed it.

A: it appears that if you locate your jquery.js files under the same folder or in some subfolders where your html file is, the Firebug problem is solved. eg if your html is under C:/folder1/, then your js files should be somewhere under C:/folder1/ (or C:/folder1/folder2 etc) as well and addressed accordingly in the html doc. hope this helps.

A: I have the same issue and no case resolve me the problem. The only thing that works for me, it's put on the  of the Site.master file, the next:
<script src="<%= ResolveUrl("~/Scripts/jquery-1.7.1.min.js") %>" type="text/javascript"></script>
<script src="<%= ResolveUrl("~/Scripts/bootstrap/js/bootstrap.min.js") %>" type="text/javascript"></script>

With src="<%= ResolveUrl("")... the load of jQuery in the Content Pages is correct.

A: I had a very similar issue. In my C# MVC application, JQuery was not being recognized. I needed to move the @Scripts.Render("~/bundles/jquery") from the bottom of my _Layout.cshtml file to the head of the section. Also make sure you have grabbed Jquery as a Nuget package if you are using visual studio!
<head>
    @Scripts.Render("~/bundles/jquery")
</head>

A: There is a way to make it automatically load up javascript before the rest of the code runs.
Go into Views\Shared_Layout.html and add the following
<head>
  <*@ Omitted code*@>
  <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
</head>

A: if script tag has defer attribute it show the error

Uncaught ReferenceError: $ is not defined

and must remove the attribute defer from script tag

A: Something that I didn't find here, but did happen to me. Make sure you don't have the jQuery slim version included, as that version of the jQuery library doesn't include the Ajax functionality.
The result is that "$" works, but $.get for example returns an error message stating that that function is undefined.
Solution: include the full version of jQuery instead.

A: I was having the same issue and now I have it resolved. My environment is as below;
Laravel with Blade Pages. I had a main layout and used sections to create new pages form my main page layout(template).
I was loading JQuery from my section page and not my main layout. I changed it from the section page to load JQuery from the main layout and also at the top in the head tag.

A: u just add at starting of your page
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

and check your src link in a any browser address bar, if you are getting some code then this will work for you.
asif


text:
Q: Fastest way to draw [grayscale bitmap * colorValue] additively to screen on Android What I want to do is multiple a grayscale alpha bitmap with an RGB color value, and then draw the resulting RGB bitmap to screen additively, that is, at each pixel I want:
p_new[r/g/b] = p_old[r/g/b] + colorValue[r/g/b] * grayscaleBitmapValue

I know I can construct an intermediate RGB bitmap or texture holding (colorValue[r/g/b] * grayscaleBitmapValue), but I'd rather avoid this wasteful step if possible, because each alpha bitmap will be multiplied with quite a number of different color values.
What's the fastest way to do this in either 2D or OpenGL ES ?

A: For 2D drawing, set up your Paint object like this:
paint.setColorFilter(
    new PorterDuffColorFilter(colorValue, PorterDuff.Mode.MULTIPLY));
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));

For OpenGL, your fragment shader could look like this:
varying vec2 texcoord;
uniform sampler2D texture;
uniform vec4 multColor;
void main() {
    gl_FragColor = texture2D(texture, texcoord)*multColor;
}

... and call glBlendFunc(GL_ONE,GL_ONE) to do additive blending.


text:
Q: Exceeding recursion limit with no obvious recursion: Optional pattern-matching causing nonlocal behavior So, I've come across something strange, and wanted to get a deeper understanding of what was going on. Consider the following code:
f[a : {{__}..}, k_ : 0] := 1

a = Table[Table[0, {5}], {10000}]

f[a, 2]

So, f takes a list of lists and a single optional expression, which can take the default value 0. This should obviously give 1, right? After all, the arguments seem ok: MatchQ[a, {{__}..}] gives True, and even MatchQ[{a, 2}, {{{__}..}, _}] gives True. More closely, even,
MatchQ[{a, 2}, {{{__}..}, _ | PatternSequence[] }]

gives True.
However, instead of producing 1, f[a, 2] gives an error message "General::maxrec: Recursion limit exceeded; positive match might be missed." and does not evaluate further.
This behavior is also present when defining Default[f]. And, indeed,  as soon as we use the Optional pattern in MatchQ[{a,2}, {{__}..}, k_:0}], MatchQ breaks down and gives the same error message as f does. But it can be avoided by removing the default value and providing it in a different (but still definitional) way, e.g.
(* Works: *)

f1[a : {{__}..}] := f1[a : {{__}..}, 0]

f1[a : {{__}..}, k_] := 1

(Also, it doesn't happen with the shallower pattern a : {__}.)
Now, I'm not the first person to notice this behavior and ask about it here. The answer there says it was an intentional change, and I understand there were probably good reasons—I'm not asking for the rationale, or how to change it. But this is not a duplicate question (at least not to that one), because I'm trying to figure something that wasn't asked there:

Why does the Optional pattern, e.g. k_:0, put a recursion limit on matching the pattern occurring before it? Why does it do so when apparently equivalent pattern matchings (such as k:(_ | PatternSequence[]), the alternative implementation of a default value for f, or a match made in isolation) don't?

Note: A previous version of this question asked why the behavior of pattern matching for function definitions didn't agree with the behavior of pattern matching for MatchQ, until @WReach pointed out in the comments that they do, in fact, agree! I simply wasn't using the same pattern verbatim to check.
Possibly related question: the linked answer says something about "dynamic backtracking"; what is that, and is that somehow present for Optional matching but not the other working matchings shown here?


text:
Q: Rails API how to send attached images with the Product as response I am trying to send a response back to a frontend client.
This is the response I am trying to create:
{
    "data": [
        {
            "id": 1,
            "product_title": "Some item"
            "images": ["imageurl1", "imageurl2", "imageurl3"]
            // other product info
        },
        {
            "id": 2,
            "product_title": "Some item"
            "images": ["imageurl4", "imageurl5", "imageurl6"]
            // other product info
        }
    ]
}

Currently it just looks like:
{
    "data": [
        {
            "id": 1,
            "product_title": "Some item"
            // other product info
        },
        {
            "id": 2,
            "product_title": "Some item"
            // other product info
        }
    ]
}

My product.rb looks like:
class Product < ApplicationRecord
  has_many_attached :images
end

Is there a way I can include the attached images in the Product object?
I have been messing around myself and I have tried looking on other posts but I have not found a solution that works.

A: You can use ActiveStorage's helpers for linking to files, as described in the Active Storage Overview Rails Guide.
Example:
url_for(user.avatar)

Example for a download link with the content disposition set:
rails_blob_path(user.avatar, disposition: "attachment")

If you are generating your API output from a serializer class or something else besides the controller action, note the section on using the URL helpers from outside of the controller/view context:
Rails.application.routes.url_helpers.rails_blob_path(user.avatar, only_path: true)

These examples use user.avatar but in your example that would be an instance of one of the many images on your Product model.
It's worth reading the entirety of that guide before deciding how to expose URLs in an API. For example, consider whether you need private/signed/authenticated URLs because by default these methods generate public URLs.


text:
Q: Array Copy and add new value I really don't know how to add in a new value once I copy the array. Does anybody know how I could achieve it?
The output I want:-
New Array Value: I Love Coding
public static void main(String[] args) {

  String originalArray[] = {"I", "Love","Java"};
  String newArray[] = new String[originalArray.length];

  System.arraycopy(originalArray, 0, newArray, 0, 2);
  System.out.println("Original Array Value: " + Arrays.toString(originalArray));
  System.out.println("New Array Value: " + Arrays.toString(newArray) + Coding);

}

And by the way, can I make the array like this:-
String originalArray[] = {"I Love Java"};
//Instead breaking up to {"I","Love","Java"}
//and if change it to one way is the steps going to be the same and the copy ways too?

A:
I really don't know how to add in a new value once I copy the array.

You would have to create a new array, copy all the elements of the old array into the new array, and add the new value. Bear in mind, however, that Java ArrayList is more appropriate for such kinds of operations (e.g., add, remove, and so on).
Nonetheless, in your case, to get the output "I Love Coding" you just need to change your code to:
public static void main(String[] args) {

  String originalArray[] = {"I", "Love","Java"};
  String newArray[] = new String[originalArray.length];

  System.arraycopy(originalArray, 0, newArray, 0, 2);
  newArray[newArray.length - 1] = "Coding";
  System.out.println("Original Array Value: " + Arrays.toString(originalArray));
  System.out.println("New Array Value: " + Arrays.toString(newArray));

}

And by the way, can I make the array like this:-

String originalArray[] = {"I Love Java"};

Yes you can. However, it would be now an array with a single string "I Love Java", whereas
String originalArray[] = {"I","Love","Java"}

is an array with three strings, namely "I", "Love", "Java". In this case, you would have to replace the String Java with Coding, without having to copy all the array elements.
public static void main(String[] args) {

    String originalArray[] = {"I Love Java"};
    String newArray[] = new String[originalArray.length];
    newArray[0] = originalArray[0].replace("Java", "Coding");
    System.out.println("Original Array Value: " + Arrays.toString(originalArray));
    System.out.println("New Array Value: " + Arrays.toString(newArray));

}

A: I think the point of this exercise is that you can change the last element in your new array
newArray[newArray.length - 1] = "Coding";

Then if you print newArray like you were printing the original array, you will see the change

A: you can replace the last element of your array and then printing them as a single String using String.join method:
String originalArray[] = {"I", "Love","Java"};
originalArray[originalArray.length-1] = "Coding";
System.out.println(String.join(" ", originalArray));


text:
Q: Should I add memcached on my php app running apc I have a php mysql application running on a single 32gb 12core server.
I already have APC Varnish installed, but I would like o try memcached + FastCgi aswell.
I've seen some people saying that running memcached together with APC is a bad idea, why?
since memcache is a memory object cache and APC is opcode cache I dont understand that.
Memcached should be good on my site since I have a lot of queries going on.
Also, on APC I have apc.shm_size set to 64M, maybe I should bring it up a bit consider I have a 32gb server.
Thanks


text:
Q: This code gives me runtime error. How to fix this code? /**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */

this is a leetcode question and it start like this You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
int reverse(int n) {
  int reversedNumber = 0, remainder;

  while (n != 0) {
    remainder = n % 10;
    reversedNumber = reversedNumber * 10 + remainder;
    n /= 10;
  }

  return reversedNumber;

}
int converttoint(vector < int > array) {

  int number = 0;

  for (int i = 0; i < 3; i++) {
    number *= 10;
    number += array[i];
  }

  return number;

}
class Solution {
  public:
    ListNode * addTwoNumbers(ListNode * l1, ListNode * l2) {
      vector<int> vec, vec2;

      while (l1->next != NULL || l2->next != NULL) {
        if (l1->val != 0) {
          vec.insert(vec.begin(), l1->val);
          l1 = l1->next;
        }
        if (l2->val != 0) {
          vec2.insert(vec2.begin(), l2->val);
          l2 = l2->next;
        }

      }

      //adding the value
      int result = converttoint(vec) + converttoint(vec2);
      int reversedvalue = reverse(result);
      vector<int> otp;

      struct ListNode * r1;
      for (int i = to_string(reversedvalue).length(); i >= 0; i--) {
        otp.push_back(reversedvalue % 10);

        r1->val = reversedvalue % 10;
        r1 = r1->next;
        reversedvalue /= 10;
      }
      r1->next = NULL;

      return r1;
    }
};

A: In the converttoint function, I don't understand why you have:
for (int i = 0; i < 3; i++) {
    number *= 10;
    number += array[i];
}

I think it needs to be:
for (int i = 0; i < array.size(); i++) {
    number *= 10;
    number += array[i];
}

On a side note, you don't need all this vector stuff either (unless you're explicitly asked to do so). The list would be something like:
1 --> 2 --> NULL
3 --> 4 --> 5 --> NULL

You can add it simply because the number is given in reverse! (take care of carry appropriately)
4 --> 6 --> 5 --> NULL


text:
Q: Can a domain be configured to only have secondary DNS nameserver records? I'm asking if someone can verify if my DNS hosting idea is possible or has any flaws.
We would host our own primary DNS server for all zones and configure it to allow zone transfers to a set of IPs which will host the same data as secondary dns.
At my registrar for each domain, I'd like to set the NS records to only point at the secondary DNS servers because we don't want folks to rely on our primary server being available at all times.
Assuming the zone transfers have completed for the secondary nameservers already, will this plan work even though the primary DNS server is not listed in the zone for every domain?

A: Sure, this arrangement is commonly called "stealth master". For example, see the article Why you should use stealth master DNS.
The DNS system does not make a distinction between "primary" and "secondary" DNS servers. There are simply a bunch of NS records listed for each domain, their order or priority is not relevant (they are all presumed to contain the same data). How you arrange distributing the data amongst those NS servers is up to you.


text:
Q: changing UI dynamically in iPhone app I was wondering if anyone knew if it's possible to change an iPhone app UI dynamically based on server calls, so for example, if user X logs in, he will see one type of a UI, and if another user logs in, another UI will appear.
Does it align with the Apple HIG (I could not find...)? I am guessing that it should be fine since theoretically I could do everything with web views, but it just doesn't sound like something apple will like.
thanks.

A: There was a talk on WWDC10 that is about this topic: "Building a Server-driven User Experience"

A: I believe you can use the new appearance API in iOS 5 framework. Here is one article which talks about it:
http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5


text:
Q: What's the difference between the inner workings of Java's JVM and .NET's CLR? What's the difference between the inner workings of Java's JVM and .NET's CLR?
Perhaps a starting point would be, are they basically the same thing in their respective environments (Java > JVM > Machine code) (C# > CLR > IL).

Update:  Several people have alluded to the points I was trying to cover:

*

*Garbage Collection

*Boxing/Unboxing

*JIT debugging

*Generics/Templates

*Please feel free to suggest other good topics that differentiate the two.

@George Mauer - this sounds very interesting:

Already posted this once but here is a series of interviews with c# chief language designer Anders Hejlsberg.

A: This should be a great thread.
One of the biggest differences is between the CLR and JVM is the CLR"s native integration of generics.
Java instead removes the generic types and the JVM can only work with objects by autoboxing the objects it appears to be pseudo generics.

A: From here. I couldn't have said it better (Well, with the exception of a flame war, this is a flameless place :-) ).

Hello,
Responding to your question seems
  fraught with peril by starting a flame
  war, so I'll proceed cautiously.
There are a number of fundamental
  technical similarities between the
  Java Runtime and the Common Language
  Runtime, including garbage collected
  memory, an intermediate language
  (Microsoft IL versus Java ByteCode),
  core system libraries, and support for
  fairly high level languages, code
  security, and deployment.
However, each of these 'similar' areas
  also have a number of sizable and
  small differences, and it's beyond the
  scope of a simple Forum post to
  describe most of them.
I would suggest asking a more
  targetted question about any of the
  various runtime features and component
  areas (e.g. memory management,
  compilation, system libraries,
  security, etc.) and then we can
  provide a more targetted response
  (e.g. a blog, a technical article, or
  some books).

A: One essential difference is that the JVM is portable across platforms and runs on Linux, Macintosh, and many cell phones and embedded devices.
CLR runs on Microsoft supported platforms with the Mono project providing partial support of older versions of CLR on a few more.
Internally this means the JVM's performance will vary on those different platforms based on capabilities provided by the platforms themselves.

A: The CLR and JVM have goals and philosophies that differ more than you might think. In general, the JVM aims to optimize more dynamic, higher-level code while the CLR gives you more low-level tools to do these kinds of optimizations yourself.
A good example is stack allocation. On the CLR you have explicit stack allocation of custom value types. On the JVM the only custom types are reference types but the JVM can convert heap allocations to stack allocations in certain circumstances through Escape Analysis.
Another example. In Java, methods are virtual by default. On C# at least, they are not. It is much more difficult to optimize virtual method calls because the code that gets executed at a given call site cannot be determined statically.
Under the hood, their execution systems are quite different. Most JVMs (in particular, Hotspot) start out with a bytecode interpreter and only JIT-compile parts of the code that are executed heavily e.g. tight loops. They can also re-compile these over and over each time using execution statistics collected from previous runs to drive optimizations. This allows more optimization effort to be applied to the parts of the program that need it most. This is called adaptive optimization.
The CLR compiles everything up-front only once. It does fewer optimization both because it has more code to compile and so has to be fast and because it doesn't have any statistics of the actual execution paths taken to feed into its optimizations. This approach does have the very significant advantage of allowing you to cache compilation results across processes, which CLR does but JVM does not.
A large percentage of the Hotspot JVM code is dedicated to these adaptive optimizations and they are what put Java in the same performance ballpark as native code for most general purpose computation in the early 2000s. They are also what makes the JVM a decent target for dynamic languages. I'm excluding here the more recent developments of the Dynamic Languages Runtime and invokedynamic as I don't know enough about the DLR.

A: Miguel de Icaza mentions here:

Seasoned industry programmers will notice that the above is
very much like Java and the Java VM.   They are right, the above
is just like Java.
The CIL has one feature not found in Java though: it is
byte code representation that is powerful enough to be used as a
target for many languages: from C++, C, Fortran and Eiffel to Lisp
and Haskell including things like Java, C#, JavaScript and Visual
Basic in the mix.
I wish I had the time to go in more detail, but for the sake
of this argument, the above will suffice.

The comments go into some details, though, like tail call optimizations. Lot have changed since 2002 though - both CLR and JVM now have multiple languages targeting it. But nonetheless worth a read.

A: As Vinko said, the full details are way beyond the scope of a forum post. The differences/similarities boil down to this:
They are both a runtime environment "sandbox" that include a "just-in-time" compiler to translate program instructions in an intermediate language (MSIL or ByteCode) to native machine code and provide automatic memory management (garbage collection). Sitting on top of the respective runtime environments are a set of class libraries that provide higher level abstractions to developers to simplify development tasks.
The internals of how those runtime environments are actually implemented are, for the most part, proprietary to Microsoft and Sun. The algorithms used by the garbage collection systems, for example, while probably similar in technical functionality are different in implementation.

A: As far as I know, .Net CLR still has much more flexible and powerful Code Access Security built into the runtime, allowing much finer grained permissions and execution policy.

A: There differences in garbage collection as well.
JVM uses Copying collector and Mark and sweep. .NET user Copying collector and Mark and compact (Much harder to implement).
Also type erasure mentioned by Flyswat is important. JVM doesn't have a clue about generics and everything is object and associated perf. penalty of boxing and unboxing. Also reflection won't give you generic information. CLR supports generics natively.


text:
Q: Take set of enums in a constructor and create list - Java I am wanting to create a new student and instantiate them with a list of subjects that they are signed up for, but am unaware if it is possible or how to accomplish it?
I have initially put an ArrayList in the constructor, but I am certain that this is wrong.
The eventual outcome is that I have a student with Name, ID and an editable list of subjects that they are studying so that they can be added to and taken out of courses as and when...
Student.java
private String name;
private int id;
private static int counter;
private ArrayList<Subjects> subjects;

public Student(String name, ArrayList<Subjects> subjects) {
    this.name = name;
    this.subjects = subjects;
    counter++;
    id=counter;
}

School.java
  public class School {

    List<Student> students = new ArrayList<>();

    public void addStudent(String name, ArrayList<Subjects> subjects) {
        Student tempStudent = new Student(name,subjects);
        students.add(tempStudent);
    }
}

Run.java where my problems come...
 public class Run {

    public static void main(String[] args) {
        School school = new School();

        school.addStudent("ABC", Subjects.English.toString().......... );
    }
}

Subjects.java
public enum Subjects {
    Maths,
    English,
    Science
}

A: You are no creating an Array nor adding an Enum. Change your Student class and every method associated with it to take a List and not an ArrayList e.g.
private List<Subjects> subjects;

Then you could use
 school.addStudent("ABC", Arrays.asList(Subjects.Maths, Subjects.English));

A: Here's what I would do:
private String name;
private int id;
private static int counter;
private List<Subjects> subjects;

public Student(String name, Collection<Subjects> subjects) {
    this.name = name;
    this.subjects = new ArrayList<>(subjects);
    counter++;
    id=counter;
}

// second constructor for convenience
public Student(String name, Subjects... subjects) {
    this(name, Arrays.asList(subjects));
}

...
public class School {
    List<Student> students = new ArrayList<>();

    public void addStudent(String name, List<Subjects> subjects) {
        Student tempStudent = new Student(name,subjects);
        students.add(tempStudent);
    }

    public void addStudent(String name, Subjects... subjects) {
        Student tempStudent = new Student(name,subjects);
        students.add(tempStudent);
    }
}


text:
Q: CSS flexbox horizontal timeline I am trying to make a flexbox horizontal timeline
I got the idea of apply a :nth-child(2n) { transform: translateY(100%); } but I run into a huge number of issues to take it work:

*

*Content before the timeline go inside of the timeline (without a way to clear them)

*Adding an overflow-x: auto; to the parent automatically adds an overflow-y too and if you hide the overflow-y then just the half of timeline is visible

There is another way to make it possible with flexboxes? I tried with margins too, but items position is not well centered

@import "compass/css3";

.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;

  display: flex;

  /* This line make an undesired Y scrollbar */
  overflow-x: auto;
}

.flex-item {
  background: tomato;
  width: 200px;
  height: 150px;

  color: white;

  display: flex;
  align-self: flex-end;
  align-items: flex-end;
  justify-content: center;
}

.flex-item:nth-child(2n) {
  align-self: flex-end;
  align-items: flex-start;
  transform: translateY(100%);
}

/* Random heights for testing */
.flex-item:nth-child(5) {
  height: 100px;
}

.flex-item:nth-child(3) {
  height: 200px;
}

.flex-item:nth-child(4) {
  height: 100px;
}

.flex-item:nth-child(6) {
  height: 200px;
}

This text is ok, but there is an undesired Y scrollbar on the timeline

text

text

text

text

text

text

This text should go after the timeline

A: Here is a lame but working solution ;-)
Add it as first child to the flexbox (you should tidy this up though).
You can use position:absolute/relative if you want it to overlay on top of the time line instead of before it.

@import "compass/css3";
.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  /* Uncomment this line to see the issue */
  /*overflow-x: auto;*/
}

.flex-item {
  background: tomato;
  width: 200px;
  height: 150px;
  color: white;
  display: flex;
  align-self: flex-end;
  align-items: flex-end;
  justify-content: center;
}

.flex-item:nth-child(2n) {
  align-self: flex-end;
  align-items: flex-start;
  transform: translateY(100%);
}

/* Random heights for testing */

.flex-item:nth-child(5) {
  height: 100px;
}

.flex-item:nth-child(3) {
  height: 200px;
}

.flex-item:nth-child(4) {
  height: 100px;
}

.flex-item:nth-child(6) {
  height: 200px;
}

This text should go before

text

text

text

text

text

text

A: Since your moving your items down with translateY you need to position everything that comes after accordingly
I just added a class other_content to your div, set position:relativeand top:200px
Although you need to keep in mind to adjust the top value, depending on how big your items get

.flex-item {
  background: tomato;
  width: 200px;
  height: 150px;

  color: white;

  display: flex;
  align-self: flex-end;
  align-items: flex-end;
  justify-content: center;
}

.flex-item:nth-child(2n) {
  align-self: flex-end;
  align-items: flex-start;
  transform: translateY(100%);
}

/* Random heights for testing */
.flex-item:nth-child(5) {
  height: 100px;
}

.flex-item:nth-child(3) {
  height: 200px;
}

.flex-item:nth-child(4) {
  height: 100px;
}

.flex-item:nth-child(6) {
  height: 200px;
}
.other_content{
  position:relative;
  top:200px;
}

This text is ok, but there is an undesired Y scrollbar on the timeline

text

text

text

text

text

text

This text should go after the timeline