text:
Q: ASP.NET MVC Url Route supporting (dot) I hope that you can help me with the below problem.
I am using ASP.NET MVC 3 on IIS7 and would like my application to support username's with dots.
Example: http://localhost/john.lee
This is how my Global.asax looks like: (http://localhost/{username})
routes.MapRoute(
    "UserList",
    "{username}",
    new { controller = "Home", action = "ListAll" }
);

The applications works when I access other pages such as http://localhost/john.lee/details etc.
But the main user page doesn't work, I would like the app to work like Facebook where http://www.facebook.com/john.lee is supported.
I used below code and it didn't work for me at all:
<httpRuntime relaxedUrlToFileSystemMapping="true" />

I was able to use below code and get the app to accept dots but I definitely wouldn't like to use below code for many different reason, please tell me there is a way to overcome this problem.
<modules runAllManagedModulesForAllRequests="false" />

A: Add a UrlRoutingHandler to the web.config. This requires your url to be a bit more specific however (f.e. /Users/john.lee).
This forces every url starting with /Users to be treated as a MVC url:
<system.webServer>
  <handlers>
    <add name="UrlRoutingHandler"
         type="System.Web.Routing.UrlRoutingHandler,
               System.Web, Version=4.0.0.0,
               Culture=neutral,
               PublicKeyToken=b03f5f7f11d50a3a"
         path="/Users/*"
         verb="GET"/>
  </handlers>
</system.webServer>

A: Just add this section to Web.config, and all requests to the route/{*pathInfo} will be handled by the specified handler, even when there are dots in pathInfo. (taken from ServiceStack MVC Host Web.config example and this answer https://stackoverflow.com/a/12151501/801189)
This should work for both IIS 6 & 7. You could assign specific handlers to different paths after the 'route' by modifying path="*" in 'add' elements
  <location path="route">
    <system.web>
      <httpHandlers>
        <add path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" />
      </httpHandlers>
    </system.web>
    <!-- Required for IIS 7.0 -->
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" />
      <validation validateIntegratedModeConfiguration="false" />
      <handlers>
        <add name="ApiURIs-ISAPI-Integrated-4.0" path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" preCondition="integratedMode,runtimeVersionv4.0" />
      </handlers>
    </system.webServer>
  </location>

A: I was facing the same issue. So the best solution for me is:
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"></modules>
<system.webServer>

A: For anyone getting an 'Cannot create abstract class' exception when using the UrlRoutingHandler approach, it's likely due to:

*

*Using a restricted 'path' (e.g. path="/Files/*") in your web.config declaration, and

*A folder/path with the same name exists in your project

A: I don't think the dot is the problem here. AFAIK the only char that should not be in the user name is a /
Without seeing the route that matches john.lee/details it's hard to say what's wrong, but I'm guessing that you have another route that matches the url, preventing the user details route from being matched correctly.
I recommend using a tool like Glimpse to figure out what route is being matched.


text:
Q: Android Studio Error when building apk file I have bought a source code from Sellmyapp, I was done editing that source code completely but whenever i try to build an apk file it shows me the following error

Error:A problem occurred configuring project ':app'.
  The SDK directory 'C:\Program Files (x86)\Android\android-sdk' does not exist.

I have installed my Android Sdk in C:\Android\sdk and also set sdk location to C:\Android\sdk but still same problem. My Windows is 64-bit, Android Studio is 64-bit, Operating System is 64-bit but still same problem.
Then I copy android sdk and paste it to C:\Program Files (x86)\Android\android-sdk So now it shows this error

Error:A problem occurred configuring project ':app'.
  Failed to find target with hash string 'android-23' in:
      C:\Program Files (x86)\Android\android-sdk

So please tell me what to do next.
Thanks

redpajama_set_name: RedPajamaStackExchange


text:
Q: SQL Case Statement or should I use SQL and Javascript? I want to make it so if you press a button, it changes the value from 0 to 1, or if the value is 1, then 1 to 0.
0 ----> 1
1 ----> 0
I want to limit the things in an array that can have a value of 1 to 10 things.
Ex: favorites[]
My goal is to be able to add items to a collection with a click of a button, and using the same button, take them off while having a limit of 10.
Should I use JS to limit, or can I use LIMIT in my sql to make that happen?
How would I accomplish this?
Right now this is what I have:
SELECT  fav FROM u_collection WHEN username = "' . $username. '"
  CASE
     WHEN fav =  0 THEN fav = 1
     WHEN fav =  1 THEN fav = 0
     ELSE fav = 0

And this is what more form more or less ends up looking like, to give you an idea:

A: I don't know your use case exactly, but if you want to have a dynamic list, then querying SQL on every click doesn't sound right.
I would have all the implementation client-side in JS. So, you can load up an array from SQL once during initialization and then have full control over user actions and a Save button so that changes can be pushed to the database.
Hope that helps.


text:
Q: Is TPL Dataflow BufferBlock thread safe? I have a fairly simple producer-consumer pattern where (simplified) I have two producers who produce output that is to be consumed by one consumer.
For this I use System.Threading.Tasks.Dataflow.BufferBlock<T>
A BufferBlock object is created. One Consumer is listening to this BufferBlock, and processes any received input.
Two 'Producerssend data to theBufferBlock` simultaneously
Simplified:
BufferBlock<int> bufferBlock = new BufferBlock<int>();

async Task Consume()
{
    while(await bufferBlock.OutputAvailable())
    {
         int dataToProcess = await outputAvailable.ReceiveAsync();
         Process(dataToProcess);
    }
}

async Task Produce1()
{
    IEnumerable<int> numbersToProcess = ...;
    foreach (int numberToProcess in numbersToProcess)
    {
         await bufferBlock.SendAsync(numberToProcess);
         // ignore result for this example
    }
}

async Task Produce2()
{
    IEnumerable<int> numbersToProcess = ...;
    foreach (int numberToProcess in numbersToProcess)
    {
         await bufferBlock.SendAsync(numberToProcess);
         // ignore result for this example
    }
}

I'd like to start the Consumer first and then start the Producers as separate tasks:
var taskConsumer = Consume(); // do not await yet
var taskProduce1 = Task.Run( () => Produce1());
var taskProduce2 = Task.Run( () => Produce2());

// await until both producers are finished:
await Task.WhenAll(new Task[] {taskProduce1, taskProduce2});
bufferBlock.Complete(); // signal that no more data is expected in bufferBlock

// await for the Consumer to finish:
await taskConsumer;

At first glance, this is exactly how the producer-consumer was meant: several producers produce data while a consumer is consuming the produced data.
Yet, BufferBlock about thread safety says:

Any instance members are not guaranteed to be thread safe.

And I thought that the P in TPL meant Parallel!
Should I worry? Is my code not thread safe?
Is there a different TPL Dataflow class that I should use?

A: Yes, the BufferBlock class is thread safe. I can't back this claim by pointing to an official document, because the "Thread Safety" section has been removed from the documentation. But I can see in the source that the class contains a lock object for synchronizing the incoming messages:
/// <summary>Gets the lock object used to synchronize incoming requests.</summary>
private object IncomingLock { get { return _source; } }

When the Post extension method is called (source code), the explicitly implemented ITargetBlock.OfferMessage method is invoked (source code). Below is an excerpt of this method:
DataflowMessageStatus ITargetBlock<T>.OfferMessage(DataflowMessageHeader messageHeader,
    T messageValue, ISourceBlock<T> source, bool consumeToAccept)
{
    //...
    lock (IncomingLock)
    {
        //...
        _source.AddMessage(messageValue);
        //...
    }
}

It would be strange indeed if this class, or any other XxxBlock class included in the TPL Dataflow library, was not thread-safe. It would severely hamper the ease of use of this great library.

A: I think an ActionBlock<T> would better suit what your doing since it has a built in buffer that many producers can send data in through. The default block options process the data on single background task but you can set a new value for parallelism and bounded capacity. With ActionBlock<T> the main area of concern to ensure thread safety will be in the delegate you pass that processes each message. The operation of that function has to be independent of each message, i.e. not modifying shared state just like any Parrallel... function.
public class ProducerConsumer
{
    private ActionBlock<int> Consumer { get; }

    public ProducerConsumer()
    {
        Consumer = new ActionBlock<int>(x => Process(x));
    }

    public async Task Start()
    {
        var producer1Tasks = Producer1();
        var producer2Tasks = Producer2();
        await Task.WhenAll(producer1Tasks.Concat(producer2Tasks));
        Consumer.Complete();
        await Consumer.Completion;
    }

    private void Process(int data)
    {
        // process
    }

    private IEnumerable<Task> Producer1() => Enumerable.Range(0, 100).Select(x => Consumer.SendAsync(x));

    private IEnumerable<Task> Producer2() => Enumerable.Range(0, 100).Select(x => Consumer.SendAsync(x));
}


text:
Q: following siblings in /w:tr in xdoc xml where the first contains specific text The XML file data is below. MS adds a ton of stuff for formating. I just want to give a clear idea of what I'm working with.
Traversing the data below is causing issues and is taking way to long to figure out.
`
<w:tbl>
<w:tblPr>
<w:tblStyle w:val="TableGrid"/>
<w:tblpPr w:leftFromText="180" w:rightFromText="180" w:vertAnchor="page" w:horzAnchor="margin" w:tblpY="2512"/>
<w:tblW w:w="0" w:type="auto"/>
<w:tblBorders>
<w:top w:val="none" w:sz="0" w:space="0" w:color="auto"/>
<w:left w:val="none" w:sz="0" w:space="0" w:color="auto"/>
<w:bottom w:val="none" w:sz="0" w:space="0" w:color="auto"/>
<w:right w:val="none" w:sz="0" w:space="0" w:color="auto"/>
<w:insideV w:val="none" w:sz="0" w:space="0" w:color="auto"/>
</w:tblBorders>
<w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="5095"/>
<w:gridCol w:w="2435"/>
<w:gridCol w:w="1784"/>
</w:tblGrid>

Here is a table row within the table node.
<w:tr w:rsidR="00223B3F" w14:paraId="01B6D8D8" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="582"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="5095" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="single" w:sz="4" w:space="0" w:color="7F7F7F" w:themeColor="text1" w:themeTint="80"/>
    <w:right w:val="single" w:sz="6" w:space="0" w:color="7F7F7F" w:themeColor="text1" w:themeTint="80"/>
    </w:tcBorders>
    <w:vAlign w:val="center"/>
</w:tcPr>
<w:p w14:paraId="10D9A4F1" w14:textId="655EE555" w:rsidR="00223B3F" w:rsidRPr="000B6F58" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:r w:rsidRPr="00530DBC">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>Job Title:</w:t>
    </w:r>
    <w:r>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t xml:space="preserve"> </w:t>
    </w:r>
    <w:ins w:id="0" w:author="Joe Bloe" w:date="2019-09-09T11:06:00Z">
    <w:r w:rsidR="004A329B">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Job Title Goes Here</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="4219" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="6" w:space="0" w:color="7F7F7F" w:themeColor="text1" w:themeTint="80"/>
    <w:bottom w:val="single" w:sz="4" w:space="0" w:color="7F7F7F" w:themeColor="text1" w:themeTint="80"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:vAlign w:val="center"/>
</w:tcPr>
<w:p w14:paraId="089971FE" w14:textId="3FC87B7C" w:rsidR="00223B3F" w:rsidRPr="000B6F58" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:r w:rsidRPr="00530DBC">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t xml:space="preserve">Revision: </w:t>
    </w:r>
    <w:ins w:id="1" w:author="Joe Bloe" w:date="2019-09-09T11:06:00Z">
    <w:r w:rsidR="004A329B">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>10</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="1330F531" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="3383"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="9314" w:type="dxa"/>
    <w:gridSpan w:val="3"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
</w:tcPr>
<w:p w14:paraId="354EA9ED" w14:textId="323A59F1" w:rsidR="00223B3F" w:rsidDel="009D3E5D" w:rsidRDefault="000C2C7C" w:rsidP="00223B3F">
    <w:pPr>
    <w:spacing w:before="240"/>
    <w:rPr>
        <w:del w:id="3" w:author="Joe Bloe" w:date="2019-09-09T10:25:00Z"/>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="4" w:author="Joe Bloe" w:date="2019-09-09T10:25:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Job summary Text</w:t>
    </w:r>
    </w:ins>
</w:p>
<w:p w14:paraId="25D9C722" w14:textId="3109C4D6" w:rsidR="00223B3F" w:rsidRPr="004401B9" w:rsidDel="009D3E5D" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:rPr>
        <w:del w:id="5" w:author="Joe Bloe" w:date="2019-09-09T10:25:00Z"/>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:del w:id="6" w:author="Joe Bloe" w:date="2019-09-09T10:25:00Z">
    <w:r w:rsidRPr="004401B9" w:rsidDel="009D3E5D">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:delText>The is expected to encourage safe practices and enforce safety policies.</w:delText>
    </w:r>
    </w:del>
</w:p>
<w:p w14:paraId="2EB93B9E" w14:textId="309E9E7B" w:rsidR="00223B3F" w:rsidRPr="00E7046D" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
    </w:rPr>
    </w:pPr>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="6DBA214C" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="860"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="9314" w:type="dxa"/>
    <w:gridSpan w:val="3"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    <w:vAlign w:val="center"/>
</w:tcPr>
<w:p w14:paraId="583B15A4" w14:textId="77777777" w:rsidR="00223B3F" w:rsidRPr="00B22FC4" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:r w:rsidRPr="00AD57B3">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>Essenti</w:t>
    </w:r>
    <w:r>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t xml:space="preserve">al Duties and Responsibilities – </w:t>
    </w:r>
    <w:r>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>Provide up to ten duties/responsibilities for this job, and the percentage of time spent doing each.   A minimum of two is required.</w:t>
    </w:r>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="7B68CE86" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="432"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="7530" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    <w:vAlign w:val="center"/>
</w:tcPr>
<w:p w14:paraId="189C4FF5" w14:textId="77777777" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="1784" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
    <w:vAlign w:val="center"/>
</w:tcPr>
<w:p w14:paraId="3FB41A7C" w14:textId="77777777" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="00223B3F" w:rsidP="00223B3F">
    <w:pPr>
    <w:ind w:right="360"/>
    <w:jc w:val="right"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="05FE164E" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="432"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="7530" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="7EC7F5D1" w14:textId="581F1E77" w:rsidR="00223B3F" w:rsidRPr="0091752E" w:rsidRDefault="009D3E5D" w:rsidP="0091752E">
    <w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
        <w:ilvl w:val="0"/>
        <w:numId w:val="7"/>
    </w:numPr>
    <w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="7" w:author="Joe Bloe" w:date="2019-09-09T10:25:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Duty 1</w:t>
    </w:r>
    </w:ins>
    <w:ins w:id="8" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r w:rsidR="00E50AD7">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>0 percent</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="1784" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="582E5EF7" w14:textId="45477371" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="009D3E5D" w:rsidP="00223B3F">
    <w:pPr>
    <w:ind w:right="360"/>
    <w:jc w:val="right"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="9" w:author="Joe Bloe" w:date="2019-09-09T10:26:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>10</w:t>
    </w:r>
    </w:ins>
    <w:r w:rsidR="00223B3F" w:rsidRPr="00985A63">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>%</w:t>
    </w:r>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="68C9B037" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="432"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="7530" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="7FAA6960" w14:textId="0C06A70D" w:rsidR="00223B3F" w:rsidRPr="0091752E" w:rsidRDefault="009D3E5D" w:rsidP="0091752E">
    <w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
        <w:ilvl w:val="0"/>
        <w:numId w:val="7"/>
    </w:numPr>
    <w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="10" w:author="Joe Bloe" w:date="2019-09-09T10:26:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Duty 2</w:t>
    </w:r>
    </w:ins>
    <w:ins w:id="11" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r w:rsidR="00E50AD7">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>0 percent</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="1784" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="47998D2C" w14:textId="36D49BCC" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="00223B3F" w:rsidP="00E50AD7">
    <w:pPr>
    <w:ind w:right="360"/>
    <w:jc w:val="right"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:pPrChange w:id="12" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
        <w:pPr>
        <w:framePr w:hSpace="180" w:wrap="around" w:vAnchor="page" w:hAnchor="margin" w:y="2512"/>
        <w:ind w:right="360"/>
        <w:jc w:val="right"/>
        </w:pPr>
    </w:pPrChange>
    </w:pPr>
    <w:del w:id="13" w:author="Joe Bloe" w:date="2019-09-09T10:26:00Z">
    <w:r w:rsidDel="009D3E5D">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:delText>%</w:delText>
    </w:r>
    </w:del>
    <w:ins w:id="14" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r w:rsidR="00E50AD7">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>2</w:t>
    </w:r>
    </w:ins>
    <w:ins w:id="15" w:author="Joe Bloe" w:date="2019-09-09T10:26:00Z">
    <w:r w:rsidR="009D3E5D">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>0%</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="0CF1F853" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="432"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="7530" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="1C7A2904" w14:textId="64B4FBA4" w:rsidR="00223B3F" w:rsidRPr="0091752E" w:rsidRDefault="009D3E5D" w:rsidP="0091752E">
    <w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
        <w:ilvl w:val="0"/>
        <w:numId w:val="7"/>
    </w:numPr>
    <w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="16" w:author="Joe Bloe" w:date="2019-09-09T10:26:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Duty 3</w:t>
    </w:r>
    </w:ins>
    <w:ins w:id="17" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r w:rsidR="00E50AD7">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t xml:space="preserve"> percent</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="1784" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="15843BAC" w14:textId="44E2F591" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="00E50AD7" w:rsidP="00223B3F">
    <w:pPr>
    <w:ind w:right="360"/>
    <w:jc w:val="right"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="18" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>3</w:t>
    </w:r>
    </w:ins>
    <w:r w:rsidR="00223B3F">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>%</w:t>
    </w:r>
</w:p>
</w:tc>
</w:tr>

<w:tr w:rsidR="00223B3F" w14:paraId="43C531F9" w14:textId="77777777" w:rsidTr="00223B3F">
<w:trPr>
<w:trHeight w:val="432"/>
</w:trPr>
<w:tc>
<w:tcPr>
    <w:tcW w:w="7530" w:type="dxa"/>
    <w:gridSpan w:val="2"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="39D03C87" w14:textId="15F7AA96" w:rsidR="00223B3F" w:rsidRPr="0091752E" w:rsidRDefault="009D3E5D">
    <w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
        <w:ilvl w:val="0"/>
        <w:numId w:val="7"/>
    </w:numPr>
    <w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:pPrChange w:id="19" w:author="Joe Bloe" w:date="2019-09-09T10:27:00Z">
        <w:pPr>
        <w:pStyle w:val="ListParagraph"/>
        <w:framePr w:hSpace="180" w:wrap="around" w:vAnchor="page" w:hAnchor="margin" w:y="2512"/>
        <w:numPr>
            <w:numId w:val="7"/>
        </w:numPr>
        <w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
        <w:ind w:left="1080" w:hanging="360"/>
        </w:pPr>
    </w:pPrChange>
    </w:pPr>
    <w:ins w:id="20" w:author="Joe Bloe" w:date="2019-09-09T10:27:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>Duty 4</w:t>
    </w:r>
    </w:ins>
    <w:ins w:id="21" w:author="Joe Bloe" w:date="2019-09-09T15:24:00Z">
    <w:r w:rsidR="00E50AD7">
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>4 percent</w:t>
    </w:r>
    </w:ins>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
    <w:tcW w:w="1784" w:type="dxa"/>
    <w:tcBorders>
    <w:top w:val="nil"/>
    <w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
    <w:bottom w:val="nil"/>
    <w:right w:val="single" w:sz="18" w:space="0" w:color="auto"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p w14:paraId="04AEDF9D" w14:textId="58D98A50" w:rsidR="00223B3F" w:rsidRPr="00985A63" w:rsidRDefault="00E50AD7" w:rsidP="00223B3F">
    <w:pPr>
    <w:ind w:right="360"/>
    <w:jc w:val="right"/>
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    </w:pPr>
    <w:ins w:id="22" w:author="Joe Bloe" w:date="2019-09-09T15:25:00Z">
    <w:r>
        <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
        </w:rPr>
        <w:t>44</w:t>
    </w:r>
    </w:ins>
    <w:r w:rsidR="00223B3F">
    <w:rPr>
        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
        <w:b/>
        <w:sz w:val="20"/>
        <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>%</w:t>
    </w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
`

Also the Duties table has mutlipe columns and I need to pull each colum seperatly. I do not have control over what is entered in the columns, otherwise I would just search for each row specifically.

A: See if following gives you what you need :
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication131
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);

            var results = doc.Descendants()
                .Where(x => x.Name.LocalName == "p")
                .SelectMany(x => x.Descendants().Where(y => y.Name.LocalName == "t")
                    .Select(z => new
                    {
                        paraId = (string)x.Attributes().Where(y => y.Name.LocalName == "paraId").FirstOrDefault(),
                        text = (string)z
                    })).ToList();

        }
    }
}

The following merges the text in same paragraph number :
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication131
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);

            var results = doc.Descendants()
                .Where(x => x.Name.LocalName == "p")
                .Select(x => x.Descendants().Where(y => y.Name.LocalName == "t")
                    .Select(z => new
                    {
                        paraId = (string)x.Attributes().Where(y => y.Name.LocalName == "paraId").FirstOrDefault(),
                        text = (string)z
                    })
                    ).Where(y => y.Count() > 0).Select(y => new { paraId = y.First().paraId, text = string.Join("", y.Select(z => z.text))})
                    .ToList();

        }
    }
}

A: Using 'following-sibling::w:tr worked. We had to offset it due to a blank line but otherwise, it solved the problem. The selectNodes call below returned all the nodes following the one selected. I then was able to loop through the nodes returned and retrieve the data needed.
XmlNodeList essentialDutiesList = xdoc.SelectNodes("//w:tr/*[contains(., 'Essential Duties and Responsibilities')]/../following-sibling::w:tr[position() > 1]", nsManager);


text:
Q: Android: When I save a file in the phone's internal memory will store Where's that file? How can I access it path? we have 2 memories for store files:

*

*1- phone memory

*2- sd card memory

now :
I can access to files and roots in sdcard memory with Environment.getExternalStorageDirectory ... and return : /storage/sdcard0 this is ok.
but :
When i store files and media (music,pic, ...) in phone memory, how can to get path phone memory?

A: There are different ways of storing and retrieving application data; SharedPreferences, Internal Storage, External Storage.
 - SharedPreferences basically restricts other apps from accessing the data.
 - Internal Storage basically stores the data in Phone memory
 - External Storage basically stores the data in any other memory cards which can be mounted or unmounted.
If I understand your question properly, then you are interested in External Storage - Public files which basically stores the files in External storage and allows any other apps / user to access the file.
For example:
File sample = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);

A: For app's internal file directory, use
getFilesDir();

For external storage, use
Environment.getExternalStorageDirectory();

A: Okay, I usually use this helper class to save my media files:
/**
 * This class create, name given the timestamp and save a multimedia file in the Environment.DIRECTORY_PICTURES folder
 * This location works best if you want the created images to be shared
 * between applications and persist after your app has been uninstalled.
 */
public class FileManager {

    public static final int MEDIA_TYPE_IMAGE = 1;
    public static final int MEDIA_TYPE_VIDEO = 2;

    public static Uri getOutputMediaFileUri(int type){
        return Uri.fromFile(getOutputMediaFile(type));
    }

    /** Create a File for saving an image or video */
   public static File getOutputMediaFile(int type){

        File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES), VideoRecordingActivity.TAG);

        if (! mediaStorageDir.exists()){
            if (! mediaStorageDir.mkdirs()){
                Log.d("MyCameraApp", "failed to create directory");
                return null;
            }
        }

        // Create a media file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        File mediaFile;
        if (type == MEDIA_TYPE_IMAGE){
            mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                    "IMG_"+ timeStamp + ".jpg");
        } else if(type == MEDIA_TYPE_VIDEO) {
            mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                    "VID_"+ timeStamp + ".mp4");
        } else {
            return null;
        }

        return mediaFile;
    }
}

Then to use it I will just do:
File currentFile= FileManager.getOutputMediaFile(2);

Note: The media file will be created in sdcard/Pictures/AppName but to be able to see them with your file browser make sure to update your mediaScanner:
MediaScannerConnection.scanFile(getApplicationContext(), new String[]{file.getPath()}, null,
    new MediaScannerConnection.OnScanCompletedListener() {
        @Override
        public void onScanCompleted(String path, final Uri fileUri) {
            //Eventually some UI updates
        }
    });


text:
Q: Servlet.init() for servlet [Jersey Web Application] threw exception An exception is showing up while running a Jersey-framework based web project in a Tomcat server using Eclipse.
"The server encountered an unexpected condition that prevented it from fulfilling the request."
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>org.jersey.dropdown.db</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>
</web-app>

pom.xml

<modelVersion>4.0.0</modelVersion>

<groupId>org.jersey.dropdown</groupId>
<artifactId>db</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>db</name>

<build>
    <finalName>db</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
        <!-- artifactId>jersey-container-servlet</artifactId -->
    </dependency>
    <!-- uncomment this to get JSON support
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
    </dependency>
    -->
</dependencies>
<properties>
    <jersey.version>2.16</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

MyResource.java
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

/**
 * Root resource (exposed at "myresource" path)
 */
@Path("myresource")
public class MyResource {

    /**
     * Method handling HTTP GET requests. The returned object will be sent
     * to the client as "text/plain" media type.
     *
     * @return String that will be returned as a text/plain response.
     */
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getIt() {
        return "Got it!";
    }
}

exception
Type Exception Report
Message Servlet.init() for servlet [Jersey Web Application] threw exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet.init() for servlet [Jersey Web Application] threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.base/java.lang.Thread.run(Thread.java:831)
Root Cause

java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
java.base/java.lang.Class.getDeclaredMethods0(Native Method)
java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3334)
java.base/java.lang.Class.getDeclaredMethods(Class.java:2446)
org.glassfish.jersey.server.model.IntrospectionModeller$2.run(IntrospectionModeller.java:236)
java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:230)
org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:170)
org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:118)
org.glassfish.jersey.server.model.IntrospectionModeller.access$000(IntrospectionModeller.java:80)
org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:111)
org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:108)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:108)
org.glassfish.jersey.server.model.Resource.from(Resource.java:744)
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:404)
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:166)
org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:327)
org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:324)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:336)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.base/java.lang.Thread.run(Thread.java:831)

The project uses Jersey with group ID "org.glassfish.jersey.archetypes", artifact id "jersey-quickstart-webapp" and version 2.14. The jdk version is 1.8. The same error is showing up even in other Jersey versions and other JDK versions as well.


text:
Q: How to make Windows 10 running faster in VirtualBox? Installed Windows 10 in VirtualBox with high spec PC. Even I set the memory to 8GB to run the virtual OS, when I operate it felt very slow.
I saw its Video Memory in Display setting is only 128 MB. Can it be changed? Or is there a way to let it run faster?

A: Start up your VM and on the VM window, go to Devices > Insert Guest Additions CD image. Find the image in your VM and install and restart the VM. This should make the VM feel visually smoother.


text:
Q: Why can the transformation derived from a list of points and a list of their transformed counterparts not be affine or linear? Some context (original question below): I wanted to know if there's a nice concise formula to calculate the transformation based on a list of points and another list of the transformed points. This is all 2D or $\mathbb{R}^2$.
By that I mean some matrix equation that has a matrix that contains the given values, so that one can invert this matrix to solve for the transformation matrix or its components.
The question I link to below has the very same goal and especially a nice answer that I was looking for, but it does not create a linear or affine transform.

In his answer to this question bubba makes the following statement:

The transformation can not be linear or affine, it has to be a "perspective" transform.

Why is that? What if I want to find the affine or linear transformation and not the perspective/nonlinear one?
I'm not sure about this, but I guess that if $c_0 = 0$ and $c_1 = 0$, then the perspective transformation will be linear. Would that help me to find the linear or affine transform of points?

A: Algebraically: to map to four 2D points you need to ensure eight numbers are correct (you have eight equations, basically). But an affine 2D transformation is defined by a 2x2 matrix with four entries and two more numbers for the translation. Eight equations in six variables usually can't be solved.
Geometrically: A linear transformation is a combination of shears, dilations, and rotations. An affine transformation can use translations as well. In particular, a parallelogram like the initial four points were must stay a parallelogram after an affine transformation. (See this math insight page for more) So an affine transformation can't give the desired four output points.


text:
Q: AttributeError: 'DynamicText' object has no attribute 'draw' I'm working through a python book. So far, all of the programs have worked, but now I'm stuck. I typed in the program, and I'm getting this error when I run it. I checked all of the lines several times, and I think everything's right. It is supposed to open a text window and 10 seconds later show a game character. I'm Using Python 3.8.10 On Windows 10 Pro 64-bit and this is the error: AttributeError: 'DynamicText' object has no attribute 'draw' and here is the code:
import pygame
import time
import subprocess
pygame.init()
screen = pygame.display.set_mode((800, 250))
clock = pygame.time.Clock()
font = pygame.font.Font(None, 25)

pygame.time.set_timer(pygame.USEREVENT, 200)

def text_generator(text):
    tmp = ""
    for letter in text:
        tmp += letter
        if letter != " ":
            yield tmp
class DynamicText(object):
    def __init__(self, font, text, pos, autoreset=False):
        self.done = False
        self.font = font
        self.text = text
        self._gen = text_generator(self.text)
        self.pos = pos
        self.autoreset = autoreset
        self.update()

    def reset(self):
        self._gen = text_generator(self.text)
        self.done = False
        self.update()

    def update(self):
        if not self.done:
            try: self.rendered = self.font.render(next(self._gen), True, (0, 128, 0))
            except StopIteration:
                self.done = True
                time.sleep(10)
                subprocess.Popen("python C:\\Users\\david\\Documents\\pythonbook\\pygame1.py 1", shell=True)

                def draw(self, screen):
                    screen.blit(self.rendered, self.pos)
text=("Steve has gone on a quest to defeat the Ender Dragon. Will he make it?")

message = DynamicText(font, text, (65, 120), autoreset=True)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: break
        if event.type == pygame.USEREVENT: message.update()
        else:
            screen.fill(pygame.color.Color('black'))
            message.draw(screen)
            pygame.display.flip()
            clock.tick(60)
            continue
        break

    pygame.quit()

How can I figure out what the error message means? Or does anyone know?


text:
Q: Is a method still "pure" if it invokes a designated callback given as parameter Eg. PureFoo(onSuccess: () => { DoSomething(); }); (example in C#)
Does Purefoo still counts as pure (without "side effects") if it invokes onSuccess? or is the method only "honest" (as in doesn't hide what it does)?
I've searched on Google but it didn't yield relevant results.

A: So, long story short, that sounds like a no.
If there are side effects, from whichever source, it shouldn't/can't be called pure.
However, I guess it can still be made more honest by limiting the side effects to only all clear & explicit intended callbacks which sorta ask as an alternative return + call based on returned values.
Note that you can't ensure the callback is called only when expected and the number of times it's expected, etc. still.

A: In this particular case, onSuccess has a name and a signature (returning void/unit) that signals an intentional side effect. If your function doesn't do anything with the result of the onSuccess() call, then there isn't anything possible to pass into there that will make the outer call pure.


text:
Q: Starting spa development server from asp.net core leads to casing errors within node_modules I have an asp.net core 5 api, with a react frontend. The frontend is a freshly created create-react-app.
If I run npm start directly in the frontend folder, I don't receive any error in the browser console.
As soon as I start it from the asp.net core project I receive these errors in the browser console:
webpackHotDevClient.js:138
{projectPath}/npapp/node_modules/react-refresh/cjs/react-refresh-runtime.development.js
    There are multiple modules with names that only differ in casing.
    This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
    Use equal casing. Compare these module identifiers:
    * {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\cjs\react-refresh-runtime.development.js
        Used by 1 module(s), i. e.
        {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\runtime.js
    * {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\cjs\react-refresh-runtime.development.js
        Used by 1 module(s), i. e.
        {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\runtime.js

and
{projectpath}/npapp/node_modules/react-refresh/runtime.js
    There are multiple modules with names that only differ in casing.
    This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
    Use equal casing. Compare these module identifiers:
    * {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\runtime.js
        Used by 3 module(s), i. e.
        {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-2!{projectpath}\npapp\src\index.js
    * {projectpath}\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\react-refresh\runtime.js
        Used by 2 module(s), i. e.
       {projectpath}\npapp\node_modules\react-scripts\node_modules\babel-loader\lib\index.js??ref--5-oneOf-3!{projectpath}\npapp\node_modules\@pmmmwh\react-refresh-webpack-plugin\client\ReactRefreshEntry.js

This is my Configure method in Startup class:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseRouting();

        app.UseAuthentication();
        app.UseSwagger();
        app.UseSwaggerUI(c =>
        {
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "npApi V1");
        });
        app.UseHttpsRedirection();
        app.UseIdentityServer();

        app.UseStaticFiles();
        app.UseSpaStaticFiles();

        app.UseMvc();
        app.UseSpa(spa =>
        {
            spa.Options.SourcePath = Path.Join(env.ContentRootPath, "npapp");

            if (env.IsDevelopment())
            {
                spa.UseReactDevelopmentServer(npmScript: "start");
            }
        });

I have many other projects with this configuration, but only this one has this behavior. I feel I'm missing something obvious, but really can't spot it...
Many thanks in advance.


text:
Q: How can I do modeling in reverse by parsing a C program and turning it in to a circuit diagram to be displayed How can I do modeling in reverse by parsing a C program and turning it in to a circuit diagram to be displayed.
Example

Except this is psedocode.

A: At a first guess I would say you need to construct a C compiler from scratch (or co-opt one) and inspect the parse tree looking for constructs that you can represent with your list of simple symbols. Once you have done that you need a rendering engine to take the list of detected constructs and lay them out in a pretty picture.
Some random observations:

*

*There are many C concepts that can't be rendered in a simplistic manner (ie pointers)

*Making your pic look pretty will be a bitch

*Doxygen would be a good place to look for ideas (the do a nice function call structure graph)

*Going off on a tangent you might like to look at IEC 61131-3  programming languages for PLCs.  These are graphically laid out languages that provide 5 different ways of describing program control and focus heavily on representations of logic


text:
Q: How to await a Condition without the chance of await being called after signal in Java? I have a wait/notify mechanism in my code which basically wraps Lock and Condition like this:
class ConditionWithTimeout { // timeout part omitted
    private Lock lock = new ReentrantLock();
    private Condition cond = lock.newCondition();

    public void doWait() throws InterruptedException {
        lock.lock();
        cond.await();
        lock.unlock();
    }

    public void doNotify() {
        lock.lock();
        cond.signalAll();
        lock.unlock();
    }
}

My problem is that if I do something like this:
someFunction();
myCond.doWait();

it is possible that if someFunction calls doNotify at some point on myCondition I will wait until myCondition times out because doWait in someFunction might be executed before this code jumps to the next line to execute myCond.doWait.
I worked around it by adding a preWaitFn:
class ConditionWithTimeout {
    private Lock lock = new ReentrantLock();
    private Condition cond = lock.newCondition();
    private Executor hookExecutor = Executors.newSingleThreadExecutor();

    public void doWait() throws InterruptedException {
        doWait(() -> {
        });
    }

    public void doWait(Runnable preWaitFn) throws InterruptedException {
        lock.lock();
        hookExecutor.execute(preWaitFn);
        cond.await();
        lock.unlock();
    }

    public void doNotify() {
        lock.lock();
        cond.signalAll();
        lock.unlock();
    }
}

and it works now but this seems like a code smell to me because it is still possible that doNotify is called before cond.await is called.
So my question is that what is the best practice in such situations? I need to block until someFunction finishes its work but I wish to avoid such corner cases as this.

A: The usual pattern is to check some logical condition and use the signal as a means of notifying another thread that the condition has been updated. In your case, a simple flag should suffice:
private boolean flag = false;

public void doWait() throws InterruptedException {
    lock.lock();
    try {
        // Loop is necessary to avoid spurious wakeup
        while (!flag) {
            cond.await();
        }
    } finally {
        // Unlock in finally in case exception is thrown
        lock.unlock();
    }
}

public void doNotify() {
    lock.lock();
    try {
        flag = true;
        cond.signalAll();
    } finally {
        lock.unlock();
    }
}

A: You could try using a CountDownLatch.  Depending on your use case, this may not be the best answer - it works if you can create a new instance of your flag object for each call, but not if you need to reuse one.  The linked Javadoc page contains examples of how to use it.  This is basically a off-the-shelf replacement for shmosel's answer.


text:
Q: Can make_shared occasionally create duplicate pointers? I'm failing some of my unit tests about 25% of the time per test. The problem is that when I create an "Entity" object, I use the std::make_shared function to create a pointer to another object. It seems that occasionally, pointers in separate Entity objects point to the same transform object. I'm not sure how this is possible. Here's the relevant code:
Entity constructor:
Entity::Entity(std::shared_ptr<Shape> i_shape) :
    shape {i_shape}
{
    transform = std::make_shared<Transform> (Vector2f(0.0f, 0.0f), Vector2f(1.0f, 1.0f), 0.0f);
}

Visual Studio 2017 Unit test code revealing the issue:
        TEST_METHOD(CircleCollisionTest2)
        {
            Entity* testCircleEnt1;
            Entity* testCircleEnt2;
            std::shared_ptr<Circle> testCircle1 = std::make_shared<Circle>(60.0f);
            std::shared_ptr<Circle> testCircle2 = std::make_shared<Circle>(60.0f);
            testCircleEnt1 = &Entity(testCircle1);
            testCircleEnt2 = &Entity(testCircle2);
            testCircleEnt1->GetTransform()->SetPostion(Vector2f(0, 0));
            testCircleEnt2->GetTransform()->SetPostion(Vector2f(200, 0));

            Assert::IsFalse(Physics::TestCollision(testCircleEnt1, testCircleEnt2));
        }

When I instantiate my Entity objects, make_shared is creating pointers to the same Transform objects. I've confirmed that they hold the same address in debug mode, so it shouldn't involve my getters or setters or anything like that.
Also, whenever this happens, the failing test takes ~150ms to complete rather than ~5ms. How can be happening roughly 25% of the time rather than 100% or 0%? I thought it could be related to the Visual studio testing framework but I replicated these results in a custom made test.
Any help would be very welcome. Thanks!

A: Your code code has undefined behavior.  When you do
testCircleEnt1 = &Entity(testCircle1);
testCircleEnt2 = &Entity(testCircle2);

You create two temporary objects and store the address of those.  First, that should not compile.  If it is, you need to turn up your wanring/error options.  Second, temporary objects are destroyed at the end of the full expression they are in so that leaves you with two dangling pointers.  What your code should be is
TEST_METHOD(CircleCollisionTest2)
{
    std::shared_ptr<Circle> testCircle1 = std::make_shared<Circle>(60.0f);
    std::shared_ptr<Circle> testCircle2 = std::make_shared<Circle>(60.0f);
    testCircle1->GetTransform()->SetPostion(Vector2f(0, 0));
    testCircle2->GetTransform()->SetPostion(Vector2f(200, 0));

    Assert::IsFalse(Physics::TestCollision(testCircle1.get(), testCircle2.get()));
}

Since you are using visual studio, you should turn on the /permissive- to enfore stronger compliance to the C++ standard.

A: It's okay, it's just you create two dangling pointers by taking addresses of temporaries and then even dereference them, invoking an undefined behaviour which you observe.

A: I'm surprised that this code compiles, as it isn't legal C++:
testCircleEnt1 = &Entity(testCircle1);
testCircleEnt2 = &Entity(testCircle2);

Here, the expression Entity(testCircle1) produces a temporary Entity object, and you can't take the address of temporary objects in C++. Were you to do so, you'd run into trouble because temporary objects in C++ cease to exist after the statement that creates them finishes running, leaving the pointers pointing to objects that no longer exist. That leads to undefined behavior, hence your periodic crashes.
If you'd like to create new objects to have testCircleEnt1 and testCircleEnt2 point at, you could use new:
testCircleEnt1 = new Entity(testCircle1);
testCircleEnt2 = new Entity(testCircle2);

However, at this point you'd probably be better off either

*

*just declaring testCircleEnt1 and testCircleEnt2 as actual Entity objects rather than pointers to them, or

*declaring testCircleEnt1 and testCircleEnt1 as std::shared_ptr<Entity>s rather than raw pointers.


text:
Q: Set Array of index value from database I have id value and product_image value in database. Image is associated with id value. I'm setting productimg_array image values to buttons for click. SO, here i need to set the id value to this button.So, i'm uisng for loop. If i use int i=0 the images are displaying, but if i set int i= cat_iamgeId the images are not displaying. Why? How to assign the id value as a index
-(void)actionSheetClickedButtonAtIndex:(int)buttonIndex {

    if (buttonIndex >=0 && buttonIndex < [categoryIds count]) {

        NSInteger categoryId = [categoryIds[buttonIndex] intValue];

      NSLog(@"button is %d",buttonIndex);

        NSLog(@"categoryId is %ld", (long)categoryId);

        productimg_array = [[NSMutableArray array]init];

        descript_array = [[NSMutableArray alloc]init] ;

        cat_imageidArray = [[NSMutableArray alloc]init];

        const char *sql = "SELECT id,cat_id,product_image,order_by,description FROM product where cat_id = ?";

        NSLog(@"sql is %s",sql);

        sqlite3_stmt *statement;

        if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
            // We "step" through the results - once for each row.

            if (sqlite3_bind_int(statement, 1, categoryId) != SQLITE_OK)
                NSLog(@"%s: bind failed: %s", __FUNCTION__, sqlite3_errmsg(database));

            while (sqlite3_step(statement) == SQLITE_ROW) {

                cat_iamgeId = sqlite3_column_int(statement, 0);

                NSLog(@"cat_iamgeId is %ld",(long)cat_iamgeId);

                [cat_imageidArray addObject:@(cat_iamgeId)];

                product_image = [[NSString alloc] initWithUTF8String:
                                 (const char *) sqlite3_column_text(statement, 2)];
               // NSLog(@"product_image is %@",product_image);

                [productimg_array addObject:product_image];

                descript = [[NSString alloc] initWithUTF8String:
                            (const char *) sqlite3_column_text(statement, 4)];

             //   NSLog(@"descript is %@",descript);

                [descript_array addObject:descript];

           }

        }

For loop for UIButton click:
    for (int i = 0; i<[productimg_array count]; i++ ) {

       NSLog(@"productimg_array_index %@", cat_imageidArray[i]);

            imgView1=[[UIButton alloc]initWithFrame:CGRectMake(20+(i*74), 0, 72, 72)];

            Width = Width + 20+(i*74);

              imgView1.tag = i;

              NSLog(@"product id is %ld ", (long)imgView1.tag);

            [imgView1 addTarget:self action:@selector(dbsofaClicked:) forControlEvents:UIControlEventTouchUpInside];

            [imgView1 setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:i]]
                             forState:UIControlStateNormal];

            [scrollview addSubview:imgView1];

        }

NSlog tag value:
product id is 202
 product id is 203
 product id is 204
 product id is 205
 clicked
 button 202 is clicked.
 *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 202 beyond bounds [0 .. 3]'

imgView1 click: (dbsofaclicked:)
-(void)dbsofaClicked:(id)sender{

   NSLog(@"clicked");

    NSLog(@"button %d is clicked.", [sender tag]);

          mmageView=[[UIImageView alloc]initWithFrame:CGRectMake(50,50,150,150)];

    [mmageView setUserInteractionEnabled:YES];

    [mmageView setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:[sender tag]]] placeholderImage:nil options:SDWebImageProgressiveDownload completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {

    }];

    [mmageView setTag:[sender tag]];

    [self.view addSubview:mmageView];
}

A: There is a much better way to do this. Use one array to hold the data for each product image.
NSMutableArray *image_array = [NSMutableArray array];

while (sqlite3_step(statement) == SQLITE_ROW) {
    cat_imageId = sqlite3_column_int(statement, 0);
    product_image = [[NSString alloc] initWithUTF8String:
                     (const char *) sqlite3_column_text(statement, 2)];
    [image_array addObject:@{ "id" : @(cat_imageId), @"url" : product_image }];
    NSLog(@"cat_imageId is %ld",(long)cat_imageId);
    NSLog(@"product_image is %@",product_image);
}

This creates an array of dictionaries. This keeps the data for each image together. This allows you to sort the data if needed and you only have one array to deal with.
Then your code to create the buttons becomes (based on your update):
for (NSUInteger i = 0; i < image_array.count; i++) {
    NSDictionary *image_data = image_array[i];

    UIButton *imgView1 = [[UIButton alloc] initWithFrame:CGRectMake(20+(i*74), 0, 72, 72)];
    Width = Width + 20 + (i * 74);

    imgView1.tag = i;
    [imgView1 addTarget:self action:@selector(dbsofaClicked:) forControlEvents:UIControlEventTouchUpInside];
    [imgView1 setImageWithURL:[NSURL URLWithString:image_data[@"url"]] forState:UIControlStateNormal];

    [scrollview addSubview:imgView1];
}


text:
Q: How to remove accent characters from an InputStream I am trying to parse a Rss2.0 feed on Android using a Pull parser.
XmlPullParser parser = Xml.newPullParser();
parser.setInput(url.open(), null);

The prolog of the feed XML says the encoding is "utf-8". When I open the remote stream and pass this to my Pull Parser, I get invalid token, document not well formed exceptions.
When I save the XML file and open it in the browser(FireFox) the browser reports presence of Unicode 0x12 character(grave accent?) in the file and fails to render the XML.
What is the best way to handle such cases assuming that I do not have any control over the XML being returned?
Thanks.

A: Where did you find that 0x12 is the grave accent? UTF-8 has the character range 0x00-0x7F encoded the same as ASCII, and ASCII code point 0x12 is a control character, DC2, or CTRL+R.
It sounds like an encoding problem of some sort. The simplest way to resolve that is to look at the file you've saved in a hex editor. There are some things to check:

*

*the byte order mark (BOM) at the beginning might confuse some XML parsers

*even though the XML declaration says the encoding is in UTF-8, it may not actually have that encoding, and the file will be decoded incorrectly.

*not all unicode characters are legal in XML, which is why firefox refuses to render it.  In particular, the XML spec says that that 0x9, 0xA and 0xD are the only valid characters less than 0x20, so 0x12 will definitely cause compliant parsers to grumble.

If you can upload the file to pastebin or similar, I can help find the cause and suggest a resolution.
EDIT: Ok, you can't upload. That's understandable.
The XML you're getting is corrupted somehow, and the ideal course of action is to contact the party responsible for producing it, to see if the problem can be resolved.
One thing to check before doing that though - are you sure you are getting the data undisturbed? Some forms of communication (SMS) allow only 7-bit characters. This would turn 0x92 (ASCII forward tick/apostrophe - grave accent?) into 0x12. Seems like quite a coincidence, particularly if these appear in the file where you would expect an accent.
Otherwise, you will have to try to make best do with what you have:

*

*although not strictly necessary, be defensive and pass "UTF-8" as the second paramter to setInput, on the parser.

*similarly, force the parser to use another character encoding by passing a different encoding as the second parameter. Encodings to try in addtion to "UTF-8" are "iso-8859-1" and "UTF-16". A full list of supported encodings for java is given on the Sun site - you could try all of these. (I couldn't find a definitive list of supported encodings for Android.)

*As a last resort, you can strip out invalid characters, e.g. remove all characters below 0x20 that are not whitespace (0x9,0xA and 0xD are all whitepsace.) If removing them is difficult, you can replace them instead.
For example
class ReplacingInputStream extends FilterInputStream
{
   public int read() throws IOException
   {
      int read = super.read();
      if (read!=-1 && read<0x20 && !(read==0x9 || read==0xA || read==0xB))
         read = 0x20;
      return read;
   }
}

You wrap this around your existing input stream, and it filters out the invalid characters. Note that you could easily do more damage to the XML, or end up with nonsense XML, but equally it may allow you to get out the data you need or to more easily see where the problems lie.

A: I use to filter it with a regex, but the trick is not trying to get and replace the accents. It depends on the encode and you don't want to change the content.
Try to insert the content of the tags into this tags
Like this
<title>My title</title>
<link>http://mylink.com</link>
<description>My description</description>

To this
<title><![CDATA[My title]]></title>
<link><![CDATA[http://milynk.com]]></link>
<description><![CDATA[My Description]]></description>

The regex shouldn't be very hard to figure out. It works for me, hope it helps for you.

A: The problem with UTF-8 is that it is a multibyte encoding. As such it needs a way to indicate when a character is formed by more than one byte (maybe two, three, four, ...). The way of doing this is by reserving some byte values to signal multibyte characters. Thus encoding follows some basic rules:

*

*One byte characters have no MSB set (codes compatible with 7-bit ASCII).

*Two byte characters are represented by sequence: 110xxxxx 10xxxxxx

*Three bytes: 1110xxxx 10xxxxxx 10xxxxxx

*Four bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

Your problem is that you may be reading some character string supposedly encoded as UTF-8 (as the XML encoding definition states) but the byte chunk might not be really encoded in UTF-8 (it is a common mistake to declare something as UTF-8 but encoding text with a different encoding such as Cp1252). Your XML parser tries to interpret byte chunks as UTF-8 characters but finds something that does not fit the encoding rules (illegal character). I.e. two bytes with two most significate bytes set would bring an illegal encoding error: 110xxxxx must be always followed by 10xxxxxx  (values such as 01xxxxxx 11xxxxxx 00xxxxxx would be illegal).
This problem does not arise when non-variable length encodings are used. I.e. if you state in your XML declaration that your file uses Windows-1252 encoding but you end up using ANSI your only problem will be that non-ASCII characters (values > 127) will render incorrectly.

The solution:

*

*Try to detect encoding by other means.

*

*If you will always be reading data from same source you could sample some files and use an advanced text editor that tries to infer actual encoding of the file (i.e. notepad++, jEdit, etc.).

*Do it programatically. Preprocess raw bytes before doing any actual xml processing.

*Force actual encoding at the XML processor
Alternatively if you do not mind about non-ASCII characters (no matter if strange symbols appear now and then) you could go directly to step 2 and force XML processing to any ASCII compatible 8-byte fixed length encoding (ANSI, any Windows-XXXX codepage, Mac-Roman encoding, etc.). With your present code you just could try:
XmlPullParser parser = Xml.newPullParser();
parser.setInput(url.open(), "ISO-8859-1");

A: Calling setInput(istream, null) already means for the pull parser to try to detect the encoding on its own. It obviously fails, due to the fact that there is an actual problem with the file. So it's not like your code is wrong - you can't be expected to be able to parse all incorrect documents, whether ill-formed or with wrong encodings.
If however it's mandatory that you try to parse this particular document, what you can do is modify your parsing code so it's in a function that takes the encoding as a parameter and is wrapped in a try/catch block. The first time through, do not specify an encoding, and if you get an encoding error, relaunch it with ISO-8859-1. If it's mandatory to have it succeed, repeat for other encodings, otherwise call it quits after two.

A: Before parsing your XML, you may tweak it, and manually remove the accents before you parse it.
Maybe not the best solution so far, but it will do the job.


text:
Q: What javascript object pattern is this example using? I'm making a javascript/canvas game and I saw this example on CSS Tricks. Here's the link
http://css-tricks.com/9876-learn-canvas-snake-game/#comment-100804
Anyways, I'm wondering because I'm refactoring my game code, and creating my own objects and so far this looks like a good pattern to be using.
To me, this looks like the Revealing Module Pattern I read about on
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
So am I right?
/* NOTE: this is just a snippet from the example, go to the link to see the
finished example */

var JS_SNAKE = {};

JS_SNAKE.game = (function () {
  var ctx;
  JS_SNAKE.width = 200;
  JS_SNAKE.height = 200;
  JS_SNAKE.blockSize = 10;
  var frameLength = 500; //new frame every 0.5 seconds
  var snake;

  function init() {
    $('body').append('<canvas id="jsSnake">');
    var $canvas = $('#jsSnake');
    $canvas.attr('width', JS_SNAKE.width);
    $canvas.attr('height', JS_SNAKE.height);
    var canvas = $canvas[0];
    ctx = canvas.getContext('2d');
    snake = JS_SNAKE.snake();
    bindEvents();
    gameLoop();
  }

  function gameLoop() {
    ctx.clearRect(0, 0, JS_SNAKE.width, JS_SNAKE.height);
    snake.advance();
    snake.draw(ctx);
    setTimeout(gameLoop, frameLength); //do it all again
  }

  function bindEvents() {
    var keysToDirections = {
      37: 'left',
      38: 'up',
      39: 'right',
      40: 'down'
    };

    $(document).keydown(function (event) {
      var key = event.which;
      var direction = keysToDirections[key];

      if (direction) {
        snake.setDirection(direction);
        event.preventDefault();
      }
    });
  }

  return {
    init: init
  };
})();

Also, is there a better pattern that I should be using when creating objects in a javascript/canvas game?
If you would like to check out my game, go to my website.
http://magnut.comze.com
The game I created is called Fruit Blitz and the next update which I'm working on right now is going to a big one, with enemies, power ups and such.

A:
Also, is there a better pattern that I should be using when creating objects in a javascript/canvas game?

I'm going to say use prototypes. Your using closures and object literals.
As for the code, it's not bad. It's just namespaced and all logic is triggered by an .init call.
A lot of these "patterns" (they aren't really patterns) are personal preferences.
if you want code review then that's a different question.
References:

*

*JS prototypical OOP

A: It's a immediately instantiated function (IIF) that returns an object with one method. It creates the JS_SNAKE.game.init method that can use everything assigned within the IIF by closure. I don't know if it has has a specific pattern name.. It's known as the module pattern.
See this SO-question about immediate function invocation
From Raynos' answer I'd like to borrow: A lot of these "patterns" (they aren't really patterns) are personal preferences.
You may be interested in reading more about the prototype pattern - the base of javascript - this may be a good start.

A: It's not the revealing module pattern. Module pattern allows you to simulate private members in JS by wrapping public members in the return block.
To me, its just JS with namespacing (namespace being JS_SNAKE).


text:
Q: New XEN Server, Intel i7, Errors were encountered while processing: xen-linux-system-amd64 I have just got a new machine to run XEN VM's on, it has an Intel i7 processor:
- Intel Haswell Core i7-4790 3.6GHz 8MB LGA1150
Update
[Screencast of what I am doing - https://www.youtube.com/watch?v=KVcf0ycMJwU )

I have setup the host with the current 6.2.0
I have set up a new Debian 7 64bit VM and any package I try and run fails with the following errors:
Errors were encountered while processing:
 xen-utils-common
 xen-utils-4.1
 xen-system-amd64
 xen-linux-system-3.2.0-4-amd64
 xen-linux-system-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

    Setting up xen-utils-common (4.1.4-3+deb7u2) ...
[warn] Starting Xen daemons: (warning).
invoke-rc.d: initscript xen, action "start" failed.
dpkg: error processing xen-utils-common (--configure):
 subprocess installed post-installation script returned error exit status 255
dpkg: dependency problems prevent configuration of xen-utils-4.1:
 xen-utils-4.1 depends on xen-utils-common (>= 4.1.4-3+deb7u2); however:
  Package xen-utils-common is not configured yet.

dpkg: error processing xen-utils-4.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of xen-system-amd64:
 xen-system-amd64 depends on xen-utils-4.1; however:
  Package xen-utils-4.1 is not configured yet.

dpkg: error processing xen-system-amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of xen-linux-system-3.2.0-4-amd64:
 xen-linux-system-3.2.0-4-amd64 depends on xen-system-amd64; however:
  Package xen-system-amd64 is not configured yet.

dpkg: error processing xen-linux-system-3.2.0-4-amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of xen-linux-system-amd64:
 xen-linux-system-amd64 depends on xen-linux-system-3.2.0-4-amd64; however:
  Package xen-linux-system-3.2.0-4-amd64 is not configured yet.

dpkg: error processing xen-linux-system-amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 xen-utils-common
 xen-utils-4.1
 xen-system-amd64
 xen-linux-system-3.2.0-4-amd64
 xen-linux-system-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

[Answered: Excuse my noob-ness but should it even be running an AMD package ?]
Any ideas on how to fix this ?
Thanks

A: Sheldon,
I did some searching on Google and came across a bug report on debian.org (Bug#709103): https://lists.debian.org/debian-kernel/2013/05/msg00478.html. This user reported something very similar to what you described above. He ran the below:
root@debian7:~# aptitude install xen-linux-system-amd64

Have you tried updating Debian first and then trying the xen installation again (ie. aptitude update && aptitude dist-upgrade)?
Good luck


text:
Q: Communicating with a class that's in use in VB.NET I'm trying to communicate with a class that's already in use, something like this.
Assume "PROJECTNAME" as a namespace or the whole project
Class1:
Public Class Class1
 Dim Text1 As String
 Sub ChangeString(input as String)
  Text1 = String
 End Sub
 Sub Main()
  Do
   ' Code to prevent the Process stopping (Ignore This)
  Loop
 End Sub
End Class

Class 2:
Imports PROJECTNAME
Public Class Class2
 Dim ForeignClass1 As New Class1
 Dim ForeignClass2 As New Class1
 Sub Main()
  Do
   'Code to prevent the Process stopping(Ignore This)
  Loop
 End Sub
End Class

Class 3:
Imports PROJECTNAME
Public Class Class3
Dim CustomClass As New Class2
 Sub Main()
  'Code here to interact between "ForeignClass2" and "ForeignClass1"
 End Sub
End Class

The codes above is a concept that I'm trying to explain, not the actual code as it's a private code that I'm not suppose to expose. So what I want is to make "ForeignClass2" interact with "ForeignClass1" or make "ForeignClass1" interact with "ForeignClass2" without touching or making a new "Class1" array and just "ForeignClass1" and "ForeignClass2" only. How can I do that?


text:
Q: DJANGO type eror module object is not callable File "/home/mushfiqul/Mushfiqul/django_pro/simplesocial/posts/views.py", line 48, in form_valid
    self.object.save()
  File "/home/mushfiqul/Mushfiqul/django_pro/simplesocial/posts/models.py", line 24, in save
    self.message_html = misaka(self.message)
TypeError: 'module' object is not callable
    def form_valid(self, form):
            self.object = form.save(commit=False)
            self.object.user = self.request.user
            self.object.save()
            return super().form_valid(form)

A: the own misaka is not a callable function, you should use it as below in this situation:
# do something
self.message_html = misaka.html(self.message)
# do something


text:
Q: jQuery Cannot call method 'get' of null I'm getting a Cannot call method 'get' of null
It works in jsfiddle: http://jsfiddle.net/nick_craver/RJMhT/1/
<script>
var divs = $("div.Image").get().sort(function(){
    return Math.round(Math.random())-0.5; //random so we get the right +/- combo
}).slice(0,1)
    $(divs).appendTo(divs[0].parentNode).show();
</script>

A: Try changing your script to this:
<script>
$(document).ready(function() {

    var divs = $("div.Image").get().sort(function() {
               return Math.round(Math.random())-0.5; //random so we get the right +/-              combo
               }).slice(0,1)

    $(divs).appendTo(divs[0].parentNode).show();
});
</script>

This will allow your script to wait until the DOM has finished loading before it executes.

A: Sometimes browsers pretend to be very nicely about loading jQ, without being encapsulated in block. Try with $(document).ready(function() { block first. If that does not solve your problem, there is also chance of jQ to be conflicted w/ something else, so give a try by changing all $() calls, with jQuery().

A: Sometimes jquery pretend to be very nicely about loading jQ, without being encapsulated in block. Try with jQuery.(document).ready(function() { block first. and use the correct jquery  like enter link description here


text:
Q: Pushwoosh device ready fails to function when redircting URL in index.html page (android, ios, windows phone) i am have created a app for Android, iPhone and Windows phone using Phonegap build and in my index.html page i am using this code

Hello World

Connecting to Device

Device is Ready

But when the site is redirected by using window.location.href pushwoosh deviceready fails to function and app is not getting registered pushwoosh.
is there any way i can redirected and pushwoosh deviceready can function.
at this point in time help much appreciated
Thank you

A: I think you do not understand what are you doing. By changing window.location.href you are stopping all Javascript execution on the page, redirecting and loading another page. Javascript from the original page (index.html) is no longer working because the webview is loading another webpage!
Try to use iframe in index.html (http://www.w3schools.com/tags/tag_iframe.asp) or ChildBrowser plugin (https://github.com/phonegap-build/ChildBrowser/, https://build.phonegap.com/plugins/480)


text:
Q: PACKET_MMAP data offset I am writing the code to send an UDP packet using PACKET_TX_RING ring, and I don't understand the example code described here:
http://wiki.ipxwarzone.com/index.php5?title=Linux_packet_mmap#Kernel_Patch
The /usr/src/linux/Documentation/networking/packet_mmap.txt
says that the frame structure is this:
/*
   Frame structure:

*

*Start. Frame must be aligned to TPACKET_ALIGNMENT=16

*struct tpacket_hdr

*pad to TPACKET_ALIGNMENT=16

*struct sockaddr_ll

*Gap, chosen so that packet data (Start+tp_net) aligns to
 TPACKET_ALIGNMENT=16

*Start+tp_mac: [ Optional MAC header ]

*Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16.

*Pad to align to TPACKET_ALIGNMENT=16
*/
If data starts at Start + tp_net, then why the code in the example substracts sizeof(struct sockaddr_ll) instead of summing it, this is the line:
/* get data offset */
        data_offset = TPACKET_HDRLEN - sizeof(struct sockaddr_ll);
printf("data offset = %d bytes\n", data_offset);

After calculating the pointer to packet data, the data is copied:
  // fill data
  off = ((void *) header) + (TPACKET_HDRLEN - sizeof(struct sockaddr_ll));
  memcpy(off, pkt, pktlen);

Tis looks like data corruption to me, the socket address and optional mac address will be overwriten by the data to transmit. In my case, if I use this code, the UDP packet header will be overwritten, is this correct?
Thanks in advance

A: Sorry I'm a little late.
I have had the very same problem and unfortunately using PACKET_TX_RING is not very well documented. But fortunately it's still quite easy to figure out using the linked example program.
First you will need tshark(or wireshark) and the packet_mm source from the link you've posted. The example source fill the buffer with 0 to 150 and then sends it directly of to the given device. Using tshark we will read out what is send.
Run tshark in one shell (tapping the loopback device):
$ tshark -V -i lo

and run packet_mm in another shell:
$ packet_mm lo

Check out one frame:
Frame 1 (150 bytes on wire, 150 bytes captured)
    Arrival Time: Nov 12, 2011 13:07:02.636424000
    [Time delta from previous captured frame: 0.000005000 seconds]    [Time delta from previous displayed frame: 0.000005000 seconds]
    [Time since reference or first frame: 337.280499000 seconds]
    Frame Number: 1001
    Frame Length: 150 bytes
    Capture Length: 150 bytes
    [Frame is marked: False]
    [Protocols in frame: eth:data]
Ethernet II, Src: 06:07:08:09:0a:0b (06:07:08:09:0a:0b), Dst: 3com_03:04:05 (00:01:02:03:04:05)
    Destination: 3com_03:04:05 (00:01:02:03:04:05)
        Address: 3com_03:04:05 (00:01:02:03:04:05)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Source: 06:07:08:09:0a:0b (06:07:08:09:0a:0b)
        Address: 06:07:08:09:0a:0b (06:07:08:09:0a:0b)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
    Type: Unknown (0x0c0d)
Data (136 bytes)

0000  0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d   ................
0010  1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d   .. !"#$%&'()*+,-
0020  2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d   ./0123456789:;<=
0030  3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d   >?@ABCDEFGHIJKLM
0040  4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d   NOPQRSTUVWXYZ[\]
0050  5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d   ^_`abcdefghijklm
0060  6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d   nopqrstuvwxyz{|}
0070  7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d   ~...............
0080  8e 8f 90 91 92 93 94 95                           ........
    Data: 0E0F101112131415161718191A1B1C1D1E1F202122232425...
    [Length: 136]

The destination MAC is 00:01:02:03:04:05 and source MAC 06:07:08:09:0a:0b.
And data start (right after Ethernet header) with 0x0e (14).
So the example program's data offset is the start of the (ethernet) packet to send.
So this is indeed the correct way to fill the buffer for sending (make sure pktlen is not larger than your frame size):
// fill data
off = ((uint8_t *) header) + (TPACKET_HDRLEN - sizeof(struct sockaddr_ll));
memcpy(off, pkt, pktlen);

And no data will be overwritten. But you have to provide ethernet, IP and UDP header yourself.
EDIT:
For the TX_Ring, the frame struct seems to be:

*

*Start. Frame must be aligned to TPACKET_ALIGNMENT=16

*struct tpacket_hdr (size = 32 bytes)

*pad to TPACKET_ALIGNMENT=16 (so effectively padding size is 0)

*packet data

*Pad to align to TPACKET_ALIGNMENT=16 (so next frame is 16Bit aligned)


text:
Q: jQuery events with setTimeout I'm having trouble with jQuery events. What I'm trying to do is when I hover over p element- function fireHover should run, but function fireOver should start running even if first function hasn't finished.
my jQuery:
function fireHover() {
    var eventTimeout;
    clearTimeout(eventTimeout);

    $(this).hide();
    $('.opening').removeClass('hidden');
    setTimeout(function () {
        $('.opening').addClass('hidden');
    }, 1000);
    clearTimeout(eventTimeout);
    setTimeout(function () {
        $('.open').removeClass('hidden');
    }, 1000);
    clearTimeout(eventTimeout);
}

function fireOver() {
    var eventTimeout;
    clearTimeout(eventTimeout);

    $(this).addClass('hidden');
    $('.closing').removeClass('hidden');
    setTimeout(function () {
        $('.closing').addClass('hidden');
    }, 1000);
    clearTimeout(eventTimeout);
    setTimeout(function () {
        $('.closed').removeClass('hidden');
        $('.closed').css('display', 'block');
    }, 1000);
    clearTimeout(eventTimeout);
}

$('.wrap .closed').on('mouseover', fireHover);
$('.wrap .open').on('mouseleave', fireOver);

Here is what I got so far:
http://codepen.io/rolandas/pen/ogpPYR?editors=101


text:
Q: How can I iterate through a dictionary whose length changes in python? I have a dictionary that I want to iterate through and change its value but I think the change of length might cause error, is there any good ways to do this?
example:
d = {'a':'orange','b':'pineapple','c':'dragonfruit'}
rating = {'orange':3, 'pineapple':4, 'dragonfruit':4.5, 'apple':3, 'pear': 3.5}

for key, value in d.items():
    if some conditions met:
        del d['a'] or d['e']='apple' # (or is not operator, i mean literally one of the operation add or delete item...)

for example:
for key, value in d.items():
    if rating[value]<4:
        del d[key]

or
d = {'a':['orange'],'b':['pineapple','peach'],'c':['dragonfruit']}
rating = {'orange':3, 'pineapple':4, 'dragonfruit':4.5, 'apple':3, 'pear': 3.5, 'peach': 5}
for key, value in d.items():
    rating_sum = sum([ rating[v] for v in value])
    if rating_sum > 8 and len(value)>1:
        d['e'] = d[key].pop(-1)

probably not the best example... means the dictionary's length changes in the loop.

A: Don't add or remove keys while you iterate your dictionary. Also, do not shadow built-in dict.
You can use a dictionary comprehension with all your conditions:
d = {k: v for k, v in d.items() if \
     not (conditions and \
     ((k == 'a') or ((k, v) == ('e', 'apple'))))}

I presume your conditions are a function of k and v, otherwise you should calculate and apply this test outside of the dictionary comprehension.
But this can get a bit messy, so there's no harm in separating your logic into a function:
def keep_pair(k, v):
    if conditions:
        if (k == 'a') or ((k, v) == ('e', 'apple')):
            return False
    return True

d = {k, v for k, v in d.items() if keep_pair(k, v)}

A: You can copy your dict to some temporary dict variable and then iterate through the temporary dict but making changes to the original.
temp = dict.copy()

for key, value in temp.items():
    if some conditions met:
        del dict['a'] or dict['e']='apple'

A: Don't. It's not impossible but in most cases there's no reason to not build a new dictionary and reassign the name, which is easier to write and read.
d = <SOME-DICT>
# filter d with dict comprehension, reassign the name d
d = {k:v for k,v in d.items() if <FILTERING-CONDITION>}

Some demos::
>>> d = {'a':'orange','b':'pineapple','c':'dragonfruit'}
>>> {k:v for k,v in d.items() if v != 'pineapple'}
{'a': 'orange', 'c': 'dragonfruit'}
>>> {k:v for k,v in d.items() if not (k == 'd' and v == 'dragonfruit')}
{'a': 'orange', 'b': 'pineapple', 'c': 'dragonfruit'}
>>> {k:v for k,v in d.items() if not (k == 'c' and v == 'dragonfruit')}
{'a': 'orange', 'b': 'pineapple'}
>>> {k:v for k,v in d.items() if not (k == 'a' or (k == 'e' and v == 'pineapple'))}
{'b': 'pineapple', 'c': 'dragonfruit'}


text:
Q: Why would Xcode 6.3 beta debugger show that Swift NSData has a byte count of 190 but no properties? In Xcode 6.3 beta running Swift 1.2 I have seemingly successfully retrieved a JSON object from an API, but the debugger is claiming that the object has no properties. The API is running on localhost and is called like this:
  NSURLConnection.sendAsynchronousRequest( request, queue: queue,
    completionHandler: completionHandler )

completionHandler is a closure with a breakpoint in it:
let completionHandler =
{
  ( response: NSURLResponse!, data: NSData!, error: NSError! ) -> Void in
  // BREAKPOINT HERE
}

The debugger shows that in Xcode 6.3 beta with Swift 1.2 data: NSData! is an ObjectiveC.NSObject of 190 bytes but with no properties, which seems flatly contradictory. I simply want the JSON data that I hope is hidden somewhere in those bytes. I do not know whether the debugger, or code that needs updating for Swift 1.2, or my understanding of things, or something else is to blame. I simply want the JSON.
Post-script
The JSON data was there all along, as the byte count suggested, and getting it was very simple (using SwiftyJSON):
let json = JSON( data: data )

Quite what has happened to the properties in the Xcode 6.3 beta debugger remains a mystery though. I'm not adding this as an answer to my own question, because whilst it works it might not necessarily be the answer. I am too new to Swift to know what the actual answer might be, or even if there is one.

A: NSData is an encapsulation of the raw data bytes, before it's translated into a string or parsed as JSON.
If you want to see what this data contains, then you can use NSJSONSerialization (let jsonDictionary = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil))
and then read the dictionary like any other: let value = jsonDictionary["key"]
I hope that's helpful.