text:
Q: Is there a way to convert a System.IO.Stream to a Windows.Storage.Streams.IRandomAccessStream? In Windows 8; I would like to pass the contents of a MemoryStream to a class that accepts a parameter of type Windows.Storage.Streams.IRandomAccessStream. Is there any way to convert this MemoryStream to an IRandomAccessStream?

A: To use the extensions: you must add "using System.IO"
In Windows8, .NET and WinRT types are generally converted to/from compatible types under the hood so you don't have to care about it.
For streams, however, there are helper methods to convert between WinRT and .NET streams:
For converting from WinRT streams -> .NET streams:
InMemoryRandomAccessStream win8Stream = GetData(); // Get a data stream from somewhere.
System.IO.Stream inputStream = win8Stream.AsStream()

For converting from .NET streams -> WinRT streams:
Windows.Storage.Streams.IInputStream inStream = stream.AsInputStream();
Windows.Storage.Streams.IOutputStream outStream = stream.AsOutputStream();

UPDATE: 2013-09-01
Let it not be said that Microsoft doesn't listen to it's developer community ;)
In the announcement for .NET FX 4.5.1, Microsoft states that:

Many of you have been wanting a way to convert a .NET Stream to a Windows Runtime IRandomAccessStream. Let's just call it an AsRandomAccessStream extension method. We weren't able to get this feature into Windows 8, but it was one of our first additions to Windows 8.1 Preview.
You can now write the following code, to download an image with HttpClient, load it in a BitmapImage and then set as the source for a Xaml Image control.

    //access image via networking i/o
    var imageUrl = "http://www.microsoft.com/global/en-us/news/publishingimages/logos/MSFT_logo_Web.jpg";
    var client = new HttpClient();
    Stream stream = await client.GetStreamAsync(imageUrl);
    var memStream = new MemoryStream();
    await stream.CopyToAsync(memStream);
    memStream.Position = 0;
    var bitmap = new BitmapImage();
    bitmap.SetSource(memStream.AsRandomAccessStream());
    image.Source = bitmap;

HTH.

A: Found a more elegant solution:

public static class MicrosoftStreamExtensions
{
    public static IRandomAccessStream AsRandomAccessStream(this Stream stream)
    {
        return new RandomStream(stream);
    }

}

class RandomStream : IRandomAccessStream
{
    Stream internstream;

    public RandomStream(Stream underlyingstream)
    {
        internstream = underlyingstream;
    }

    public IInputStream GetInputStreamAt(ulong position)
    {
        //THANKS Microsoft! This is GREATLY appreciated!
        internstream.Position = (long)position;
        return internstream.AsInputStream();
    }

    public IOutputStream GetOutputStreamAt(ulong position)
    {
        internstream.Position = (long)position;
        return internstream.AsOutputStream();
    }

    public ulong Size
    {
        get
        {
            return (ulong)internstream.Length;
        }
        set
        {
            internstream.SetLength((long)value);
        }
    }

    public bool CanRead
    {
        get { return this.internstream.CanRead; }
    }

    public bool CanWrite
    {
        get { return this.internstream.CanWrite; }
    }

    public IRandomAccessStream CloneStream()
    {
        throw new NotSupportedException();
    }

    public ulong Position
    {
        get { return (ulong)this.internstream.Position; }
    }

    public void Seek(ulong position)
    {
        this.internstream.Seek((long)position, SeekOrigin.Begin);
    }

    public void Dispose()
    {
        this.internstream.Dispose();
    }

    public Windows.Foundation.IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
    {
        return this.GetInputStreamAt(this.Position).ReadAsync(buffer, count, options);
    }

    public Windows.Foundation.IAsyncOperation FlushAsync()
    {
        return this.GetOutputStreamAt(this.Position).FlushAsync();
    }

    public Windows.Foundation.IAsyncOperationWithProgress WriteAsync(IBuffer buffer)
    {
        return this.GetOutputStreamAt(this.Position).WriteAsync(buffer);
    }
}

A: After some experimenting I found the following code to be working.
using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage.Streams;

partial class MainPage
{
    public MainPage()
    {
        var memoryStream = new MemoryStream(new byte[] { 65, 66, 67 });
        ConvertToRandomAccessStream(memoryStream, UseRandomAccessStream);
        InitializeComponent();
    }

    void UseRandomAccessStream(IRandomAccessStream stream)
    {
        var size = stream.Size;
    } // put breakpoint here to check size

    private static async void ConvertToRandomAccessStream(MemoryStream memoryStream,
         Action<IRandomAccessStream> callback)
    {
        var randomAccessStream = new InMemoryRandomAccessStream();
        var outputStream = randomAccessStream.GetOutputStreamAt(0);
        var dw = new DataWriter(outputStream);
        var task = new Task(() => dw.WriteBytes(memoryStream.ToArray()));
        task.Start();
        await task;
        await dw.StoreAsync();
        var success = await outputStream.FlushAsync();
        callback(randomAccessStream);
    }
}

UPDATE: I also tried more elegant method implementation:
    private static void ConvertToRandomAccessStream(MemoryStream memoryStream,
        Action<IRandomAccessStream> callback)
    {
        var randomAccessStream = new InMemoryRandomAccessStream();
        var outputStream = randomAccessStream.GetOutputStreamAt(0);
        RandomAccessStream.Copy(memoryStream.AsInputStream(), outputStream);
        callback(randomAccessStream);
    }

Strangely, it doesn't work. When I call stream.Size later, I get zero.
UPDATE I changed the function to return the IRandomAccessStream rather than using the callback function
public static async Task<IRandomAccessStream> ConvertToRandomAccessStream(MemoryStream memoryStream)
{
    var randomAccessStream = new InMemoryRandomAccessStream();

    var outputStream = randomAccessStream.GetOutputStreamAt(0);
    var dw = new DataWriter(outputStream);
    var task = new Task(() => dw.WriteBytes(memoryStream.ToArray()));
    task.Start();

    await task;
    await dw.StoreAsync();

    await outputStream.FlushAsync();

    return randomAccessStream;
}

A: There is no built-in way method on Windows 8. For Windows 8.1 we added a Stream.AsRandomAccessStream() extension method:
internal static IRandomAccessStream ToRandomAccessStream(byte[] array)
{
    MemoryStream stream = new MemoryStream(array);
    return stream.AsRandomAccessStream();
}

A: None of the above works for me today (maybe some API changes since the answers were posted). The only way that works is
IRandomAccessStream inMemoryStream = new InMemoryRandomAccessStream();
using (var inputStream = stream.AsInputStream())
{
    await RandomAccessStream.CopyAsync(inputStream, inMemoryStream);
}
inMemoryStream.Seek(0);

A: This code snippet turns a stream (stream) into an InMemoryRandomAccessStream (ims) which implement IRandomAccessStream. The trick is that CopyTo has to be called on a background thread.
        InMemoryRandomAccessStream ims = new InMemoryRandomAccessStream();
        var imsWriter = ims.OpenWrite();
        await Task.Factory.StartNew(() => stream.CopyTo(imsWriter));

A: Take a look to this link:
How To Convert Byte Array To IRandomAccessStream
It also gives examples and an implementation of a byte array constructor (and one for .NET streams), useful if you want to use the SetSource or SetSourceAsync methods of BitmapImage class (as in my case).
Hope this helps someone...


text:
Q: Magento doesn't show all the categories in admin we have a magento store with various categories one inside another (subcategory). Our problem is that when we enter in the admin to manage categories in the category tree on the left, some of our categories that has subcategories looks correctly with the plus (+) icon on the left but when we try to expand the category magento doesn't display any item.
The ajax call point to this url:

index.php/admin/catalog_category/categoriesJson/key/09b218741dce69171825fdbf4954855d/?isAjax=true

and it returns an empty array without throwing any error. Frontend displays all the categories correctly.
Magento version 1.4.2.1
Any idea ?

A: you want to go into table catalog_category_entity
run the following SQL query:
UPDATE catalog_category_entity SET children_count =
(SELECT COUNT(*) FROM
(SELECT * FROM catalog_category_entity) AS table2
WHERE path LIKE
CONCAT(catalog_category_entity.path,"/%"));

A: After reading Joseph answer i've tried to search for errors in catalog_category_entity and founded that all the categories in my tree has level 1 or 2 except for the categories that doesn't appear that have level 7. The strange things is that level 7 is the correct level for those category anyway i think that the problem is that Magento found a category with level 2 and it direct children has lavel 7 and it doesn't recognize those category as children for the father category.
I've changed level of the children to 2 and everything seems to work.
Why all the category in my tree has level 1 ? i don't know ...

A: Did you create the categories programmatically (as opposed to using the admin interface)? As is often the case in Magento, when some value is missing or incorrect in the database, entries may not show up at all. If this is the case, please take a look at a "good" category record in the database and make sure that the missing categories follow the correct conventions.
Hope that helps!
Thanks,
Joe

A: In my case I imported all of the categories and assigned 'level' as its position in the tree. Maybe that isn't what it's for, because setting all the categories to a level of 2 worked beautifully and kept my tree intact.
Code I used to put all levels to 2 after setting it incorrectly:

    foreach ($categories as $category) {
        $category = $category->load($category->getId());

        $level = $category->getLevel();

        if($level > 2) {
            $category->setLevel(2);
            $category->save();
        }

    }

A: For the mentioned cases, this query could have helped:
select c.entity_id cid, p.entity_id pid
from
  catalog_category_entity c
  inner join catalog_category_entity p on c.parent_id = p.entity_id
where c.level != p.level+1

It didn't help me with my categories, though.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Google Calendar API - get events I'm using PHP and MySQL but I guess this question can be for almost anyone. I have a website where people can register/create an account and login. I have a calendar on my site for each user. I'm wanting to implement Google Calendar API (oauth) so they can login to their Google accounts and sync their Google Calendar events with the calendar on my site.
But through their documentation, I don't see anywhere that says how I can save the google account for each person on my site so that only their google account gets connected and that only their google calendar events go into their calendar on my site.
For example, if user 2 on my site links their google account (user2@gmail.com) through oauth, how does my site know next time it wants to get events from the google account to get it from user2@gmail.com and not another user's google account that have signed in? Here's what I'm trying to say:
user 2 = user2@gmail.com
user 5 = user5@gmail.com
user 8 = user8@gmail.com

so next time a user fetches events from Google calendar API, it will get it from their own google account and not another user's g account.
how should I go about doing this? Should I save something in my MySQL database?
Here is the full google calendar api v3 working code:
link-google-account.php:
<?php
require_once __DIR__.'/vendor/autoload.php';

session_start();

$client = new Google_Client();
$client->setAuthConfig('client_secrets.json');
$client->addScope(Google_Service_Calendar::CALENDAR_READONLY);

if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  $client->setAccessToken($_SESSION['access_token']);

  // Print the next 10 events on the user's calendar.
  $calendarId = 'primary';
  $optParams = array(
    'maxResults' => 10,
    'orderBy' => 'startTime',
    'singleEvents' => TRUE,
    'timeMin' => date('c'),
  );

  $service = new Google_Service_Calendar($client);
  $results = $service->events->listEvents($calendarId, $optParams);

  if (count($results->getItems()) == 0) {
    print "No upcoming events found.\n";
  } else {
    print "Upcoming events:\n";
    foreach ($results->getItems() as $event) {
      $start = $event->start->dateTime;
      if (empty($start)) {
        $start = $event->start->date;
      }
      printf("%s (%s)\n", $event->getSummary(), $start);
    }
  }

} else {
  $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/oauth.php';
  header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
?>

oauth.php:
<?php
require_once __DIR__.'/vendor/autoload.php';

session_start();

$client = new Google_Client();
$client->setAuthConfigFile('client_secrets.json');
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/oauth.php');
$client->addScope(Google_Service_Calendar::CALENDAR_READONLY);

if (! isset($_GET['code'])) {
  $auth_url = $client->createAuthUrl();
  header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
  header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
?>


text:
Q: bootstrap-4.0-dist gives error message,match jdk1.6 with myeclipse 10 I put the bootstrap-4.0-dist folder to the new web project folder of webroot,then I run the server and the console appear some errors and the bootstrap.bundle.js appeaared a big red "X",I copy the error message.

bootstrap.bundle.js error message 1
       Internal validation error java.lang.ArrayIndexOutOfBoundsException: 5 at
       org.eclipse.wst.jsdt.internal.compiler.ast.CaseStatement.resolveCase(CaseStatement.java:82) at
       org.eclipse.wst.jsdt.internal.compiler.ast.SwitchStatement.resolve(SwitchStatement.java:156) at
       org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.ja
       va:338) at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:
       137) at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:
       292) at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:
       363) at
       org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.ja
       va:344) at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:
       137) at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:
       292) at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:
       363) at org.eclipse.wst.jsdt.internal.compiler.ast.FunctionExpression.resolveType(FunctionExpression.java:57) at
       org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:279) at
       org.eclipse.wst.jsdt.internal.compiler.ast.Expression.resolve(Expression.java:477) at
       org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394) at
       org.eclipse.wst.jsdt.internal.compiler.Compiler.process(Compiler.java:612) at
       org.eclipse.wst.jsdt.internal.compiler.Compiler.compile(Compiler.java:361) at
       org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:305) at
       org.eclipse.wst.jsdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:307) at
       org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:232) at
       org.eclipse.wst.jsdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:135) at
       org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:302) at
       org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:214) at
       org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at
       org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
       org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at
       org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at
       org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at
       org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
       org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at
       org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at
       org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at
       org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at
       org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at
       org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

bootstrap.bundle.js error message 2
The default case is already defined
This new web project is a empty project,named bootstrap201805.It's not congigured such as ssh and struts.But the error make me confuse.
2018-5-5 15:57:02 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Myeclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin
2018-5-5 15:57:02 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2018-5-5 15:57:02 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 538 ms
2018-5-5 15:57:02 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2018-5-5 15:57:02 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2018-5-5 15:57:02 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2018-5-5 15:57:03 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2018-5-5 15:57:03 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory bootstrap20180120
2018-5-5 15:57:04 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2018-5-5 15:57:13 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory bootstrap20180120.myeclipse.bak
2018-5-5 15:57:14 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2018-5-5 15:57:22 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Caught exception while loading file struts-default.xml - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:839)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:69)
    at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:213)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:198)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:189)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:175)
    at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
    ... 34 more
2018-5-5 15:57:22 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2018-5-5 15:57:22 org.apache.catalina.core.StandardContext start
严重: Context [/bootstrap20180120.myeclipse.bak] startup failed due to previous errors
2018-5-5 15:57:22 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2018-5-5 15:57:22 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/bootstrap201801.myeclipse.bak] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2018-5-5 15:57:22 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/bootstrap201801.myeclipse.bak] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
2018-5-5 15:57:22 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
严重: The web application [/bootstrap201801.myeclipse.bak] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@970846]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2018-5-5 15:57:23 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory bootstrap201803try
2018-5-5 15:57:24 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2018-5-5 15:57:32 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Caught exception while loading file struts-default.xml - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:839)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:69)
    at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:213)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:198)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:189)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:175)
    at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
    ... 34 more
2018-5-5 15:57:32 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2018-5-5 15:57:32 org.apache.catalina.core.StandardContext start
严重: Context [/bootstrap201803] startup failed due to previous errors
2018-5-5 15:57:32 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2018-5-5 15:57:32 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/bootstrap201803] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2018-5-5 15:57:32 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/bootstrap201803] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
2018-5-5 15:57:32 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
严重: The web application [/bootstrap201803] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@f5d2fd]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2018-5-5 15:57:33 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory bootstrap201803.myeclipse.bak
2018-5-5 15:57:34 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2018-5-5 15:57:42 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Caught exception while loading file struts-default.xml - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:839)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:69)
    at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:213)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:198)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:189)
    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:175)
    at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
    ... 34 more
2018-5-5 15:57:42 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2018-5-5 15:57:43 org.apache.catalina.core.StandardContext start
严重: Context [/bootstrap201803.myeclipse.bak] startup failed due to previous errors
2018-5-5 15:57:43 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2018-5-5 15:57:43 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/bootstrap201803.myeclipse.bak] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2018-5-5 15:57:43 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/bootstrap201803.myeclipse.bak] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
2018-5-5 15:57:43 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
严重: The web application [/bootstrap201803.myeclipse.bak] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@d5c83f]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2018-5-5 15:57:44 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory bootstrap20180504
2018-5-5 15:58:00 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2018-5-5 15:58:00 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2018-5-5 15:58:00 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2018-5-5 15:58:00 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2018-5-5 15:58:00 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2018-5-5 15:58:00 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory xianProject
2018-5-5 15:58:00 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\xianProject\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2018-5-5 15:58:00 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\xianProject\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2018-5-5 15:58:01 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2018-5-5 15:58:01 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2018-5-5 15:58:01 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/40  config=null
2018-5-5 15:58:01 org.apache.catalina.startup.Catalina start
信息: Server startup in 58799 ms

A: A part of problem is solved by searching.I delete other projects in the webapps folder.The details is following.
Tomcat6.o\webapps\
So the third problem is ok.The other problems about bootstrap is still bad.
Thank you very much.
My english is not bad and not good.I wondered if I understood your question right.I was not sure.I took some time to think about my answer.
I found the 2 problems of bootstrap.bundle.js not to influence the project running. So there is not any error message in the server console .You are right.Thanks!


text:
Q: Recursion using XSLT I am new to XSLT and currently working on the recursive function on an input XML to convert to a target XML using xslt.

*

*Input XML:

<?xml version="1.0" encoding="UTF-8"?>
<referenced>
<name>XYZ</name>
<LOCK_STATUS>2</LOCK_STATUS>
    <reference>
        <name>MC</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </reference>
    <reference>
        <name>MC1</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </reference>
    <reference>
        <name>List</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <reference>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </reference>
            <reference>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </reference>
            <reference>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
                    <reference>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </reference>
                    <reference>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </reference>
            </reference>
    </reference>
        <reference>
        <name>entList</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <reference>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </reference>
            <reference>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </reference>
            <reference>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </reference>
    </reference>
</referenced>

*Target XML I want to achieve:

<?xml version="1.0" encoding="UTF-8"?>
<children>
<name>XYZ</name>
<LOCK_STATUS>2</LOCK_STATUS>
    <children>
        <name>MC</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </children>
    <children>
        <name>MC1</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </children>
    <children>
        <name>DocumentList</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <children>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
                    <children>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </children>
                    <children>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </children>
            </children>
    </children>
    <children>
        <name>st</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <children>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
    </children>
</children>

*XSLT Function which I have written:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
        <xsl:template match="/">
        <xsl:apply-templates select="reference"/>
        </xsl:template>
        <xsl:template match="reference[reference]">
        <xsl:apply-templates select="reference"/>
        </xsl:template>
        <xsl:template match="reference">
        <children>
            <name>
            <xsl:value-of select="name" />
            </name>
            <LOCK_STATUS>
            <xsl:value-of select="LOCK_STATUS" />
            </LOCK_STATUS>
        </children>
    </xsl:template>
</xsl:stylesheet>

Somehow I am not able to achieve the target XML with the xslt which I have written.
Hi Tim,
Appreciate your help on this . Trying to understand the code spinet you provided and the tutorials i went over internet to get more understanding :)
No in my case i do not have to rename referenced to reference .
How would the xslt change if the Expected Output xml should appear like this
    <?xml version="1.0" encoding="UTF-8"?>
<nodeInfo>
<name>XYZ</name>
<LOCK_STATUS>2</LOCK_STATUS>
    <children>
        <name>MC</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </children>
    <children>
        <name>MC1</name>
        <LOCK_STATUS>2</LOCK_STATUS>
    </children>
    <children>
        <name>DocumentList</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <children>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
                    <children>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </children>
                    <children>
                        <name>WumentList</name>
                        <LOCK_STATUS>2</LOCK_STATUS>
                    </children>
            </children>
    </children>
    <children>
        <name>st</name>
        <LOCK_STATUS>2</LOCK_STATUS>
            <children>
                <name>entList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>ist</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
            <children>
                <name>WumentList</name>
                <LOCK_STATUS>2</LOCK_STATUS>
            </children>
    </children>
</nodeInfo>

A: One problem you have is that your root element is named referenced, but in your first template it is looking for a root element of reference
    <xsl:template match="/">
       <xsl:apply-templates select="reference"/>
    </xsl:template>

The / symbol matches the top-level document node, which is the parent of the single root element of your XML (referenced in your case).
You also don't need the second template that matches reference[reference] as this will skip over any reference element with a child reference element, which is not what you want.
But if you want recursion, you simply need to add an xsl:apply-templates to your template that matches reference
Try this XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>

    <xsl:template match="referenced">
        <nodeInfo>
            <name>
            <xsl:value-of select="name" />
            </name>
            <LOCK_STATUS>
            <xsl:value-of select="LOCK_STATUS" />
            </LOCK_STATUS>
            <xsl:apply-templates select="reference" />
        </nodeInfo>
    </xsl:template>

    <xsl:template match="reference">
        <children>
            <name>
            <xsl:value-of select="name" />
            </name>
            <LOCK_STATUS>
            <xsl:value-of select="LOCK_STATUS" />
            </LOCK_STATUS>
            <xsl:apply-templates select="reference" />
        </children>
    </xsl:template>
</xsl:stylesheet>

Better still, make use of the identity template, which cuts down on the work you have to do (as it looks like all you are trying to do is rename referenced to nodeInfo, and reference to children):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="referenced">
        <nodeInfo>
            <xsl:apply-templates />
        </nodeInfo>
    </xsl:template>

    <xsl:template match="reference">
        <children>
            <xsl:apply-templates />
        </children>
    </xsl:template>
</xsl:stylesheet>


text:
Q: Proof of correctness of a formula for the area of a polygon Let $P$ be a $n$-gon with vertices $(x_1,y_1),\ldots,(x_n,y_n)$ enumerated clockwise. Then the area $\text{Area}(P)$ of $P$ is
$$ \text{Area}(P) = \sum_{i=1}^n\frac{1}{2}(x_{i+1}-x_i)(y_{i+1}+y_i).$$
What is the easiest way to prove this?
I think one way would be to use induction on the number of vertices. For the inductive step, one could use the fact that every $n$-gon for $n>3$ has a diagonal.

A: Use Green's area formula
$${\rm area\,}(P)={1\over2}\int_{\partial P}(x\>dy-y\>dx)$$
and parametrize the segments $\sigma_k$ making up $\partial P$ as
$$\sigma_k:\quad t\mapsto \bigl((1-t)x_k+t x_{k+1}, \>(1-t)y_k+t y_{k+1}\bigr)\qquad(0\leq t\leq1)\ .$$

A: You may just compute the (oriented) area of a triangle with vertices at $(0,0),(x_i,y_i),(x_{i+1},y_{i+1})$ and add the contributes to get:
$$ A = -\frac{1}{2}\sum_{i=1}^{n}\left(x_i y_{i+1} - x_{i+1} y_i\right)=\frac{1}{2}\sum_{i=1}^{n}(x_{i+1}-x_i)(y_{i+1}+y_i) $$
where the last equality follows from $\sum_{i=1}^{n}\left(x_{i+1}y_{i+1}-x_i y_i\right)=0$.
For short, your formula is equivalent to the shoelace formula.


text:
Q: Exercise of odd and even [If-Else] Exercise of odd and even [If-Else], conditions:

*

*If n is odd, print weird.

*If n is even and in the inclusive range of 2 and 5, print Not Weird

*If n is even and in the inclusive range of 6 and 20, print weird

*If n is even and greater than 20, print Not Weird

A and D can be the same as
if n%2==0:
print("Not Weird")

else:
print("Weird")

So now I have to play around with conditions 2 and 3.
I tried to put in
if n%2==0 or n in range (2,6):
    print("Not Weird")

elif n in range (6,21):
    print("Weird")

Works fine, but I'm having problems with the range between 2 and 6.
If anyone can explain me how to do it and the logic behind it I would appreciate it.

A: n = 8

if (n % 2 == 0 or n in range(2, 6)) and n not in range(6, 21):
    print("Not Weird")

elif n in range(6, 21):
    print("Weird")

A: Translating your conditions into python code:
if (n%2==0) and (n in range(2,6) or n > 20): #Conditions B and D
    print('Not Weird')
elif (n%2 == 1) or (n%2 == 0 and n in range(6, 21)): #Conditions A and C
    print('Weird')

However since they are mutually exclusive you can just use and if-else statement
if (n%2==0) and (n in range(2,6) or n > 20): #Conditions B and D
    print('Not Weird')
else:
    print('Weird')


text:
Q: Html.Hidden returns different value I have problem, which i can't understand.
int i = Convert.ToInt32(Model.dt);
MvcHtmlString s = Html.Hidden("DishType", Convert.ToInt32(Model.dt));
MvcHtmlString ss = Html.Hidden("DishType", 4);

i = 4
s = input id="DishType" name="DishType" type="hidden" value="22"
ss = input id="DishType" name="DishType" type="hidden" value="22"
Why value is 22, if parametr is 4 in both cases ???

A: this is because you passed in on wrong location
what you need to use is:
<%= Html.Hidden("name",null,new{Value = "your attributes here"}) %>
Also read up about this here:
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.WEB.MVC.HTML.INPUTEXTENSIONS.HIDDEN%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29;k%28DevLang-CSHARP%29&rd=true


text:
Q: R: Plot varimax rotated factor analysis I want to analyze my data as here with factor analysis and PCA.
It works so far, but what I did figure out is the following.
How can I perform a varimax rotation and visualize the rotated matrix in the correlation circle?
res.pca <- prcomp(decathlon2.active, scale = TRUE)
my.var <- varimax(res.pca$rotation)

res.pca is a prcomp object, my.var is a list, therefore I cannot use it for the plots as described in the article.
Any ideas?
Edit (output of dput(decathlon2.active)):
> data(decathlon2)
> decathlon2.active <- decathlon2[1:23, 1:10]
> dput(decathlon2.active)
structure(list(X100m = c(11.04, 10.76, 11.02, 11.34, 11.13, 10.83,
11.64, 11.37, 11.33, 11.33, 11.36, 10.85, 10.44, 10.5, 10.89,
10.62, 10.91, 10.97, 10.69, 10.98, 10.95, 10.9, 11.14), Long.jump = c(7.58,
7.4, 7.23, 7.09, 7.3, 7.31, 6.81, 7.56, 6.97, 7.27, 6.8, 7.84,
7.96, 7.81, 7.47, 7.74, 7.14, 7.19, 7.48, 7.49, 7.31, 7.3, 6.99
), Shot.put = c(14.83, 14.26, 14.25, 15.19, 13.48, 13.76, 14.57,
14.41, 14.09, 12.68, 13.46, 16.36, 15.23, 15.93, 15.73, 14.48,
15.31, 14.65, 14.8, 14.01, 15.1, 14.77, 14.91), High.jump = c(2.07,
1.86, 1.92, 2.1, 2.01, 2.13, 1.95, 1.86, 1.95, 1.98, 1.86, 2.12,
2.06, 2.09, 2.15, 1.97, 2.12, 2.03, 2.12, 1.94, 2.06, 1.88, 1.94
), X400m = c(49.81, 49.37, 48.93, 50.42, 48.62, 49.91, 50.14,
51.1, 49.48, 49.2, 51.16, 48.36, 49.19, 46.81, 48.97, 47.97,
49.4, 48.73, 49.13, 49.76, 50.79, 50.3, 49.41), X110m.hurdle = c(14.69,
14.05, 14.99, 15.31, 14.17, 14.38, 14.93, 15.06, 14.48, 15.29,
15.67, 14.05, 14.13, 13.97, 14.56, 14.01, 14.95, 14.25, 14.17,
14.25, 14.21, 14.34, 14.37), Discus = c(43.75, 50.72, 40.87,
46.26, 45.67, 44.41, 47.6, 44.99, 42.1, 37.92, 40.49, 48.72,
50.11, 51.65, 48.34, 43.73, 45.62, 44.72, 44.75, 42.43, 44.6,
44.41, 44.83), Pole.vault = c(5.02, 4.92, 5.32, 4.72, 4.42, 4.42,
4.92, 4.82, 4.72, 4.62, 5.02, 5, 4.9, 4.6, 4.4, 4.9, 4.7, 4.8,
4.4, 5.1, 5, 5, 4.6), Javeline = c(63.19, 60.15, 62.77, 63.44,
55.37, 56.37, 52.33, 57.19, 55.4, 57.44, 54.68, 70.52, 69.71,
55.54, 58.46, 55.39, 63.45, 57.76, 55.27, 56.32, 53.45, 60.89,
64.55), X1500m = c(291.7, 301.5, 280.1, 276.4, 268, 285.1, 262.1,
285.1, 282, 266.6, 291.7, 280.01, 282, 278.11, 265.42, 278.05,
269.54, 264.35, 276.31, 273.56, 287.63, 278.82, 267.09)), .Names = c("X100m",
"Long.jump", "Shot.put", "High.jump", "X400m", "X110m.hurdle",
"Discus", "Pole.vault", "Javeline", "X1500m"), row.names = c("SEBRLE",
"CLAY", "BERNARD", "YURKOV", "ZSIVOCZKY", "McMULLEN", "MARTINEAU",
"HERNU", "BARRAS", "NOOL", "BOURGUIGNON", "Sebrle", "Clay", "Karpov",
"Macey", "Warners", "Zsivoczky", "Hernu", "Bernard", "Schwarzl",
"Pogorelov", "Schoenbeck", "Barras"), class = "data.frame")


text:
Q: PDE Mathematica I'm newbie with Mathematica, so probably my problem is very easy to be solved.
I want to solve a PDE:

The first problem is that the program is not substituting the values inside w[x,y] and its second derivatives, to use them as boundary conditions.
It tells me that Tag Equal in ((w1^(2,0))[x,y]==0)[x,y] is Protected
The other problem is that it gives me also another type of error:
"{NDsolve[{(w1^(0,4))[x,y]+(w1^(2,2))[x,y]+(w1^(4,0))[x,y]==0,{w1[0,y]==0,w1[5,y]==0,((w1^(2,0))[x,y]==0)[0,y]==0,((w1^(2,0))[x,y]==0)[5,y]==0},{w1[x,0]==3,w1[x,5]==3,((w1^(0,2))[x,y]==0)[x,0]==0,((w1^(0,2))[x,y]==0)[x,10]==0}},w1[x,y],{x,0,10},{y,0,5}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing."
Thank you in advance.

I made some changes.
First of all I fixed the boundary conditions because they had a problem.
Moreover I changed also the equation.
Now it still gives me the error:
"{NDsolve[{(w^(0,4))[x,y]+(w^(2,2))[x,y]+(w^(4,0))[x,y]==2,{w[0,y]==0,w[5,y]==0,chix[0,y]==0,chix[5,y]==0},{w[x,0]==0,w[x,10]==0,chiy[x,0]==0,chiy[x,10]==0}},w,{x,0,5},{y,0,10}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing."

If we succeed in fixing this problem, Mathematica should give us a non zero solution.
Thank you very much!

Rewriting it, it doesn't provide any solution. And it also gives no errors. It looks like it is not even substitutiing the boundary conditions. I decided to change them, solving in this way another kind of problem. It still doesn't work. I think that it is very strange, since if the boundary conditions were wrong it should have provided either an indeterminate condition or an impossible one. Any idea?
Thank you very much for your help!


text:
Q: Android Studio error "Private field '' "is assigned but never accessed I am making a bluetooth app and I have encountered an error in Android Studio.
When I mouse over "private Button On,Off,Visible,list" it tells me "Private field '' "is assigned but never accessed".
What it means? And the strange thing is that the app doesn't work in the emulator but it works just fine on my device. Any idea what I am doing wrong?
O.T.: How do I put the code in "spoiler" mode or similar? I don't want to flood the forum with codes :)
The Main Java code is:
   import android.os.Bundle;
   import android.app.Activity;
   import android.bluetooth.BluetoothAdapter;
   import android.bluetooth.BluetoothDevice;
   import android.content.Intent;
   import android.view.Menu;
   import android.view.View;
   import android.widget.ArrayAdapter;
   import android.widget.Button;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.Toast;

    public class MainActivity extends Activity {

private Button On,Off,Visible,list;
private BluetoothAdapter BA;
private Set<BluetoothDevice>pairedDevices;
private ListView lv;
@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    On = (Button)findViewById(R.id.button1);
    Off = (Button)findViewById(R.id.button2);
    Visible = (Button)findViewById(R.id.button3);
    list = (Button)findViewById(R.id.button4);

    lv = (ListView)findViewById(R.id.listView1);

    BA = BluetoothAdapter.getDefaultAdapter();
}

public void on(View view){
    if (!BA.isEnabled()) {
        Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(turnOn, 0);
        Toast.makeText(getApplicationContext(),"Turned on"
                ,Toast.LENGTH_LONG).show();
    }
    else{
        Toast.makeText(getApplicationContext(),"Already on",
                Toast.LENGTH_LONG).show();
    }
}
public void list(View view){
    pairedDevices = BA.getBondedDevices();

    ArrayList list = new ArrayList();
    for(BluetoothDevice bt : pairedDevices)
        list.add(bt.getName());

    Toast.makeText(getApplicationContext(),"Showing Paired Devices",
            Toast.LENGTH_SHORT).show();
    final ArrayAdapter adapter = new ArrayAdapter
            (this,android.R.layout.simple_list_item_1, list);
    lv.setAdapter(adapter);

}
public void off(View view){
    BA.disable();
    Toast.makeText(getApplicationContext(),"Turned off" ,
            Toast.LENGTH_LONG).show();
}
public void visible(View view){
    Intent getVisible = new Intent(BluetoothAdapter.
            ACTION_REQUEST_DISCOVERABLE);
    startActivityForResult(getVisible, 0);

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

}

A: You have four Variables:
 private Button On, Off, Visible, list;

You assign all of them:
 On = (Button)findViewById(R.id.button1);
    Off = (Button)findViewById(R.id.button2);
    Visible = (Button)findViewById(R.id.button3);
    list = (Button)findViewById(R.id.button4);

But you only use "list":
for(BluetoothDevice bt : pairedDevices)
        list.add(bt.getName());

The error (or warning) is telling you that you are wasting variables by not using them. For now split up your private Variables and don't assign them, it should look something like this:
private Button list;
//private Button On, Off, Visible;

and then:
//On = (Button)findViewById(R.id.button1);
//Off = (Button)findViewById(R.id.button2);
//Visible = (Button)findViewById(R.id.button3);
list = (Button)findViewById(R.id.button4);

When you want to use these variables un-comment out them and then your good to go!

A: It is just a warning stating that you are never using it.
Also your naming is off. Fields should start lowercase by convention.

A: It means that you have declared On, Off, Visible and you are not using it. it is just a warning and you can ignore it.


text:
Q: How to execute .ktr file in linux with data parameters(another transformation)? As the question says, I would like to execute the .ktr file but via Linux
I tryied to execute test.ktr like this :
sh pan.sh -file="/path/to/test.ktr"

I got an error of :
 Unable to get database metadata from this database connection, Error connecting to database [${DATABASE_NAME}]
Before executing test.ktr, I have to execute set_database_parameters.ktr firstly, I have many transformations like test.ktr, that's the reason why I set a set_database_parameters.ktr file specially
it there a way to solve it? Thanks so much

A: Use a job to execute the transformations sequencially and execute the job, not the transformations separately


text:
Q: Android 1.6 setZOrderOnTop alternative setZOrderOnTop was introduced with Android API level 5. Is this a convenience method for functionality that existed in the earlier API levels? If so, how would I go about creating the same effect on Android 1.6?
Some background info:
I am trying to get a GLSurfaceView with transparent pixels to render on top of the rest of my layout. So far I have not been succesful, the GLSurfaceView is displayed and renders properly, but pixels that are transparent show up completely black. My guess is that the default GLSurfaceView behaviour is the cause of my problem:

The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed.

A: AFAIK, there isn't any way of changing the ZOrder of SurfaceView (in previous versions).
Because this requires access to the Window in which the SurfaceView is placed and there isn't any way to get reference of that window.


text:
Q: No se puede leer la propiedad 'addEventListener' con un submit de null Estoy haciendo un listado en javascript y html, no consigo solventar el ese error.

var formPeliculas = document.querySelector("#formularioP");
formPeliculas.addEventListener('submit', function(){
var input = document.querySelector("#addmovie").value;
if (input.length >= 1) {
  localStorage.setItem(input, input);

}
});

for(var i in localStorage){
  console.log(localStorage[i]);
if(typeOf(localStorage[i]) == 'string') {
  var movList = document.querySelector("#peliculasList");
    var li = document.createELement("li");
    li.append(localStorage[i]);
    movList.append(li);
  }

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <title></title>

Base de datos de peliculas

Añade tu pelicula:

    <form class="" action="" id="#formularioP">
      <input type="text" id="addmovie"/>
      <button type="submit">Guardar</button>
    </form>

Peliculas

A ver si alguien con más experiencia (estoy aprendiendo poco a poco por mi cuenta) puede ayudarme, gracias.

A: En lugar de usar querySelector, utiliza getElementById:

var formPeliculas = document.getElementById("#formularioP");
formPeliculas.addEventListener('submit', function(){
var input = document.querySelector("#addmovie").value;
if (input.length >= 1) {
  localStorage.setItem(input, input);

}
});

for(var i in localStorage){
  console.log(localStorage[i]);
if(typeOf(localStorage[i]) == 'string') {
  var movList = document.querySelector("#peliculasList");
    var li = document.createElement("li");
    li.append(localStorage[i]);
    movList.append(li);
  }

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <title></title>

Base de datos de peliculas

Añade tu pelicula:

    <form class="" action="" id="#formularioP">
      <input type="text" id="addmovie"/>
      <button type="submit">Guardar</button>
    </form>

Peliculas

A:

var formPeliculas = document.getElementById("#formularioP");
formPeliculas.addEventListener('submit', function(){
var input = document.querySelector("#addmovie").value;
if (input.length >= 1) {
  localStorage.setItem(input, input);

}
});

for(var i in localStorage){
  console.log(localStorage[i]);
if(typeOf(localStorage[i]) == 'string') {
  var movList = document.querySelector("#peliculasList");
    var li = document.createElement("li");
    li.append(localStorage[i]);
    movList.append(li);
  }

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <title></title>

Base de datos de peliculas

Añade tu pelicula:

    <form class="" action="" id="#formularioP">
      <input type="text" id="addmovie"/>
      <button type="submit">Guardar</button>
    </form>

Peliculas


text:
Q: How come this code is not faster with Numba? Why is this monte carlo simulation not faster with numba jit? Removing @jit makes it run a bit faster. However, I thought these loops where what numba was good at...
import numpy as np
from numba import jit

T = 1000
ALPHA = 0.11
BETA = 0.22
GAMMA = 0.33

@jit(nopython=True, fastmath=True)
def sim(n):
  mu = np.array([0.0, 0.1]).reshape(2,1)
  rho = 0.1
  sigma = np.array([[1, rho*4],[rho*4, 4^2]])
  A = np.linalg.cholesky(sigma)

  out = np.empty((n, 2))
  for i in range(n):
    # (a)
    u = np.random.randn(T)

    # X = np.random.multivariate_normal(mu, sigma, T)
    X = mu + A @ np.random.randn(2,T)
    X = np.concatenate((np.ones((T, 1)), X.T), axis=1)

    y = X @ np.array([ALPHA, BETA, GAMMA]) + u

    # (b)
    thetahat = np.linalg.solve(X.T @ X, X.T @ y)

    Xf = X[:,:2].copy()
    thetatilde = np.linalg.solve(Xf.T @ Xf, Xf.T @ y)

    out[i,:] = (thetahat[1], thetatilde[1])

  return out

n = 10**5
s = sim(n)
print(s)

A: As the documentation states:

First, recall that Numba has to compile your function for the argument types given before it executes the machine code version of your function, this takes time. However, once the compilation has taken place Numba caches the machine code version of your function for the particular types of arguments presented. If it is called again the with same types, it can reuse the cached version instead of having to compile again.

A really common mistake when measuring performance is to not account for the above behaviour and to time code once with a simple timer that includes the time taken to compile your function in the execution time.

simply: in the first execution (in your case, the only one) numba compiles it to machine code. It takes time. If you run it once again, then you will see the difference.
For example:
import numpy as np
from numba import jit
import time

T = 1000
ALPHA = 0.11
BETA = 0.22
GAMMA = 0.33

@jit(nopython=True, fastmath=True)
def sim(n):
  mu = np.array([0.0, 0.1]).reshape(2,1)
  rho = 0.1
  sigma = np.array([[1, rho*4],[rho*4, 4^2]])
  A = np.linalg.cholesky(sigma)

  out = np.empty((n, 2))
  for i in range(n):
    # (a)
    u = np.random.randn(T)

    # X = np.random.multivariate_normal(mu, sigma, T)
    X = mu + A @ np.random.randn(2,T)
    X = np.concatenate((np.ones((T, 1)), X.T), axis=1)

    y = X @ np.array([ALPHA, BETA, GAMMA]) + u

    # (b)
    thetahat = np.linalg.solve(X.T @ X, X.T @ y)

    Xf = X[:,:2].copy()
    thetatilde = np.linalg.solve(Xf.T @ Xf, Xf.T @ y)

    out[i,:] = (thetahat[1], thetatilde[1])

  return out

n = 10**2
start = time.time()
sim(n)
end = time.time()
print("Elapsed (with compilation) = %s" % (end - start))

s = sim(n)
start = time.time()
sim(n)
end = time.time()
print("Elapsed (with compilation) = %s" % (end - start))
print(s)

Here I ran the simulation twice. The first run took 5 seconds, but the second run took only 0.01 seconds. Numba improved indeed.
Numba is useful when you have a function you using multiple times. For a single execution, numba has no use.

A: In your case, you can use the "Eager compilation" and the document can be found at https://numba.pydata.org/numba-doc/latest/user/jit.html.
import time
import numpy as np
from numba import jit, float64, uint32

T = 1000
ALPHA = 0.11
BETA = 0.22
GAMMA = 0.33

# using the eager compilation
@jit(float64[:, :](uint32))
def sim(n):
  # the code below is not changed at all
  mu = np.array([0.0, 0.1]).reshape(2,1)
  rho = 0.1
  sigma = np.array([[1, rho*4],[rho*4, 4^2]])
  A = np.linalg.cholesky(sigma)

  out = np.empty((n, 2))
  for i in range(n):
    # (a)
    u = np.random.randn(T)

    # X = np.random.multivariate_normal(mu, sigma, T)
    X = mu + A @ np.random.randn(2,T)
    X = np.concatenate((np.ones((T, 1)), X.T), axis=1)

    y = X @ np.array([ALPHA, BETA, GAMMA]) + u

    # (b)
    thetahat = np.linalg.solve(X.T @ X, X.T @ y)

    Xf = X[:,:2].copy()
    thetatilde = np.linalg.solve(Xf.T @ Xf, Xf.T @ y)

    out[i,:] = (thetahat[1], thetatilde[1])

  return out

n = 10**5
# calculate the elapsed time
start = time.time()
s = sim(n)
end = time.time()
print("Elapsed (with compilation) = %s" % (end - start))
print(s)

On my computer, the code above using the eager compilation is about 7s faster.


text:
Q: VBA to prevent a change event from triggering if another change event triggers this one may be impossible to solve in VBA but I'd like to see what you experts have to say about it.
I have a textbox on a userform that triggers a macro within a TextBox1_Change() type of sub.
If the user types "ABC" in the textbox, the macro gets triggered 3 times: once for "A", once for "AB" and once for "ABC". This macro is actually kind of heavy, so I would like it to run only when the user is actually done typing, and not inbetween single key strokes.
I know I can make the user "press enter" or whatever and only then run the macro, but this is not what I'm looking for. I want him to type freely and see the results of his typing dynamically show up, with no other type of interaction required.
So, I came up with the idea of making the change event wait and see if another change event gets triggered within, say, 1 second from the first. If that happens, the first change event aborts.
Now this would work, and I think I would know how to code it, except that I don't know how to give the user the power to keep typing even when the first change event is running.
What I mean is that when the first macro runs, it "freezes" everything. Waiting to see if another change event triggers will therefore not work, as nothing is going to trigger until the first macro is done running.
Do you guys see my problem here? How would you go about this? Any chance I can achieve the results I'd like?
Any help is greatly appreciated, thanks guys!

A: I tested the following, and it works (assuming I correctly understand what you're trying to do).
In a code module, write this:
Public aRunIsScheduled As Boolean
Public nextRunTime As Variant

Sub MyMacro()
    'Flag macro as having been run, no longer scheduled.
    aRunIsScheduled = False

    'Place your macro code here.
    'I'll just use some dummy code:
    MsgBox "MyMacro is running!"

End Sub

In your sheet module:
Private Sub CommandButton1_Click()

    If aRunIsScheduled Then
        ' Cancel the previously scheduled run.
        Application.OnTime EarliestTime:=nextRunTime, _
            Procedure:="MyMacro", Schedule:=False
        aRunIsScheduled = False
    End If

    ' Schedule a new run 3 seconds from now:
    nextRunTime = Now + TimeValue("00:00:03")
    Application.OnTime EarliestTime:=nextRunTime, _
            Procedure:="MyMacro", Schedule:=True
    aRunIsScheduled = True

End Sub

I put a Commandbutton in my sheet and here I'm using its change event, but you can put this code in your TextBox1_Change() event instead, in exactly the same way.

A: reference: http://www.cpearson.com/excel/SuppressChangeInForms.htm
To suppress events in a form, you can create a variable at the form's module level called "EnableEvents" and set that to False before changing a property that will cause an event to be raised.
Public EnableEvents As Boolean
Private Sub UserForm_Initialize()
    Me.EnableEvents = True
End Sub

Sub Something()
   Me.EnableEvents = False
   ' some code that would cause an event to run
   Me.EnableEvents = True
End Sub

Then, all of the controls on form should have a test if that variable as their order of business in any event code. For example,
Private Sub ListBox1_Change()
    If Me.EnableEvents = False Then
        Exit Sub
    End If
    MsgBox "List Box Change"
End Sub

You can declare the EnableEvents as Private if only procedures with that form need to suppress events. However, if you have forms that are programmatically linked together, such UserForm2 adding an item to a ListBox on UserForm1, you should declare the variable as Public and set it for another form with code like the following:
UserForm1.EnableEvents = False
'
' change something on UserForm1
'
UserForm1.EnableEvents = True

The primary difference between the EnableEvents property and code shown above and the Application.EnableEvents property is that with a UserForm EnableEvents, all control on the form must have code to exit if EnableEvents is True. In other words, all the form's controls must cooperate and respect the setting of EnableEvents.


text:
Q: Ignore mysql row based on column value I have a phpbb forum using mysql databases. The users are identified by "user_id." However, they have multiple groups. Users will either be in the "human" (9) or "zombie" (8) group. However, they will always be in the "registered" (2) group. This creates a table that looks like this:

Three databases are used in total to form a new table.
SELECT phpbb_users.user_id 'ID',
IF( phpbb_user_group.group_id =9,  'Human', IF( phpbb_user_group.group_id =8,  'Zombie', '')) AS Team,

IF( phpbb_profile_fields_data.pf_oz =1,  'Yes',  ' ' ) AS OZ,
phpbb_users.username 'Player', phpbb_users.user_email 'E-mail',
IF( phpbb_profile_fields_data.pf_share_phonenum =1, phpbb_profile_fields_data.pf_phone_number,  ' ' ) AS Phone,
phpbb_profile_fields_data.pf_code 'Tag Code',
phpbb_profile_fields_data.pf_student_id 'Student ID', phpbb_users.starve 'Time Remaining (in hours)'
FROM phpbb_profile_fields_data, phpbb_users, phpbb_user_group
WHERE phpbb_profile_fields_data.user_id = phpbb_users.user_id
AND phpbb_profile_fields_data.user_id = phpbb_user_group.user_id
LIMIT 0 , 300

I need all the rows with blank fields under "Team" (which are the result of the "registered" group) removed from the result set. All help is appreciated!

A: Add a HAVING clause to the end of your WHERE clause, like this:
WHERE phpbb_profile_fields_data.user_id = phpbb_users.user_id
AND phpbb_profile_fields_data.user_id = phpbb_user_group.user_id
HAVING Team <> ''
LIMIT 0 , 300

The HAVING clause will make MySQL to do another filtering pass on the query result (including any aggregate results) and then discards those records not matching the HAVING clause.
You can also have several conditions in the HAVING clause, like this:
HAVING Team <> '' and Player <> 'First Last'


text:
Q: Proof by induction: $\sum\limits_{i=1}^{n} \frac{1}{n+i} = \sum\limits_{i=1}^{n} \left(\frac{1}{2i-1} - \frac{1}{2i}\right)$ How can the following be proved by induction?
$$\sum\limits_{i=1}^{n} \frac{1}{n+i} = \sum\limits_{i=1}^{n} \left(\frac{1}{2i-1} - \frac{1}{2i}\right)$$
I am out of ideas after practicing for a while:
$$\frac{1}{n+1}+\frac{1}{n+2}+\dots+\frac{1}{2n}=\left(1-\frac{1}{2}\right)+\left(\frac{1}{3}-\frac{1}{4}\right)+\dots+\left(\frac{1}{2n-1}-\frac{1}{2n}\right)
$$
Does this involve telescoping series?

A: Hint $  $ For $ \, f(n)=\rm RHS - LHS\ $ show $ \ f(n\!+\!1) - f(n) = 0 = f(1)$ $\overset{\rm induct}\Longrightarrow\ f(n) = f(1) = 0\,.$
Note $  \ f(n\!+\!1)\ =\ f(n)\ $ boils down to $ \displaystyle\ \frac{2}{2n\!+\!2} = \frac{1}{n\!+\!1}\ $ by a very simple algebraic calculation.
Note how a simple transformation reduces inductive proof to the triviality that a function on $ \,\mathbb N\,$ is constant iff its first difference vanishes, i.e. $ \ f(n\!+\!1)-f(n)\ =\ 0.\,$ The inductive proof of this boils down to equality transitivity on a telescoping chain of inequalities $\,f(1) = f(2) = \,\cdots\, = f(n).\,$ While it is intuitively "obvious" that a function that never changes $ \,f(n\!+\!1) = f(n)\,$ is constant $ \,f(n) = f(1)\,$ for all $\,n\in\Bbb N\,$ it does require rigorous proof!
Many inductive proofs aimplify when handled similarly - by transforming the problem so that the induction becomes completely trivial, e.g. that a product of terms $> 1$ is $> 1$. Often, as above, the reduced problem succumbs to a trivial telescopic proof. You can find $\,$ many examples of telescopy in my prior posts here. These methods often serve to reduce inductions to problems that have purely mechanical solution - solvable by using rote algebra with no ingenuity required (e.g. by algorithms in computer algebra systems). For example, the above problem reduces to verifying that a rational function is zero, which requires only simple mechanical polynomial arithmetic.

A: Proof without using induction:
\begin{align}
\text{LHS}&=\sum_{i=1}^n\frac1{n+i}\\
&=\sum_{i=n+1}^{2n}\frac1i\\
&=\sum_{i=1}^{2n}\frac1i-\sum_{i=1}^{n}\frac1i\\
&=\left(\sum_{i=1}^{2n}\frac1i-\frac12\sum_{i=1}^{n}\frac1i\right)-\frac12\sum_{i=1}^{n}\frac1i\\
&=\sum_{i=1}^n\frac1{2i-1}-\sum_{i=1}^n\frac{1}{2i}=\text{RHS}\\
\end{align}
I hope you find it helpful.

A: $n=1$, check.  note that
$$
\frac{1}{2(n+1)-1}-\frac{1}{2(n+1)}=\frac{(2n+2)-(2n+1)}{(2n+1)(2n+2)}=\frac{1}{(2n+1)(2n+2)}
$$
(this is what changes on the rhs for $n+1$).
on the left hand side the change is
$$
\frac{1}{2n+1}+\frac{1}{2n+2}-\frac{1}{n+1}=\frac{(2n+2)+(2n+1)-2(2n+1)}{(2n+1)(2n+2)}=\frac{1}{(2n+1)(2n+2)}
$$
as desired.


text:
Q: Extract attributes and values from XML file in perl This is part of the output XML file I get as output from Stanford CoreNLP:
<collapsed-ccprocessed-dependencies>
      <dep type="nn">
        <governor idx="25">Mullen</governor>
        <dependent idx="24">Ms.</dependent>
      </dep>
      <dep type="nsubj">
        <governor idx="26">said</governor>
        <dependent idx="25">Mullen</dependent>
      </dep>
    </collapsed-ccprocessed-dependencies>
  </sentence>
</sentences>
<coreference>
  <coreference>
    <mention representative="true">
      <sentence>1</sentence>
      <start>1</start>
      <end>2</end>
      1
    </mention>
    <mention>
      <sentence>1</sentence>
      <start>33</start>
      <end>34</end>
      33
    </mention>
  </coreference>
 </coreference>
<mention representative="true">
      <sentence>1</sentence>
      <start>6</start>
      <end>9</end>
      8
    </mention>
    <mention>
      <sentence>1</sentence>
      <start>10</start>
      <end>11</end>
      10
    </mention>
  </coreference>
  <coreference>

How do I parse it using Perl so that I get something like this:
1. sentence 1, head 1
   sentence 1, head 33
2. sentence 1, head 8
   sentence 1, head 10

I have tried with XML::Simple but the output is not easily understandable. Here is what I did:
    use XML::Simple;
    use Data::Dumper;
$outfile = $filename.".xml";
$xml = new XML::Simple;

$data = $xml -> XMLin($outfile);
print Dumper($data);

A: XML::Simple has the hardest interface to use. You could use something like
use XML::LibXML qw( );

my $parser = XML::LibXML->new();
my $doc = $parser->parse_string($xml);

my $coref_count;
for my $coref_node ($doc->findnodes('//coreference/coreference')) {
   ++$coref_count;

   my $mention_count;
   for my $mention_node ($coref_node->findnodes('mention')) {
      ++$mention_count;

      my $sentence = $mention_node->findvalue('sentence/text()');
      my $head     = $mention_node->findvalue('head/text()');

      my $prefix = "$coref_count.";
      $prefix = ' ' x length($prefix) if $mention_count == 1;

      print "$prefix sentence $sentence, head $head\n";
   }
}

A: Regrettably, XML::Simple was first to stake its claim for the Simple namespace. It is perhaps simple in implementation but not so simple in use except in the most trivial of cases. If you want something similar, then XML::Smart offers a nested data-structure API but does it a lot better.
Thankfully there is a lot of choice for excellent Perl XML modules. XML::Twig is one of these, and it allows you to specify callback subroutines that will be executed when specific elements within the XML data are encountered during parsing.
This program uses XML::Twig, and sets a callback on coreference[mention], i.e. coreference elements that have at least one mention child.
The code in the handler subroutine makes no checks and assumes that there will always be at least two mention child elements, each with a sentence and a header element. The text values of these nodes are output in the format you have described.
use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(twig_handlers => {
  'coreference[mention]' => \&handle_coreference
});
$twig->parsefile('myxml.xml');

my $n;
sub handle_coreference {

  my ($twig, $elt) = @_;

  my @mentions = $elt->children('mention');

  for my $i (0 .. $#mentions) {
    printf "%s sentence %d, head %d\n",
      $i == 0 ? sprintf '%3d.', ++$n : '    ',
      map $mentions[$i]->first_child_trimmed_text($_), qw/ sentence head /;
  }
}

output
  1. sentence 1, head 1
     sentence 1, head 33
  2. sentence 1, head 8
     sentence 1, head 10

A: Something like:
use strict;
use warnings;

use XML::Rules;

my $mention_cnt;
my $ref_cnt = 1;
my @rules = (
  coreference => sub {
    $ref_cnt++ if $mention_cnt;
    $mention_cnt = 0;
  },
  mention => sub {
    my $d = $_[1];
    my $str = $mention_cnt++ ? " " x 6 : sprintf("%-6s", "$ref_cnt.");
    print "$str sentence: $d->{sentence} head: $d->{head}\n";
  },
  'sentence,head' => 'content',
);

my $xr = XML::Rules->new(
  rules => \@rules,
);
$xr->parse($xml);


text:
Q: Not able to render the html code in browser using Angular JS When I try to add the  tag in angular JS and render, it doesn't display the image, but rather it displays the img code as it is.
Here is my Angular JS code
$scope.option = '';
    responsePromise.success(function(data, status, headers, config) {
        for(index in data) {
            $scope.usersArray.push({
                name:data[index].name,
                password:data[index].password,
                option:$scope.option
            });
        }
    });

My html code

   {{user.name}}
   {{user.password}}
   {{user.option}}

Other details are coming fine, except the tag. Do I need to add anything extra here?

A: You can try the directive bindHTML.
Html:

Controller:
angular.module('ngBindHtmlExample', ['ngSanitize']).controller('ngBindHtmlCtrl', ['$scope', function ngBindHtmlCtrl($scope) {
  $scope.myHTML =
     'I am an HTMLstring with links! and other stuff';
}]);

Doc: http://docs.angularjs.org/api/ng/directive/ngBindHtml

A: Try:
$scope.option =  $sce.trustAsHtml('');

You need to inject $sce.
What is $sce?
$sce is a service that provides Strict Contextual Escaping services to AngularJS. Strict Contextual Escaping (SCE) is a mode in which AngularJS requires bindings in certain contexts to result in a value that is marked as safe to use for that context.
Refer : http://docs.angularjs.org/api/ng/service/$sce

A: You shouldn't deal withn HTML in the controller, but with structured data. You should generate the HTML in the view:
controller:
$scope.option = {
    src: 'smiley.png',
    alt: 'Smiley face',
    width: 42,
    height: 42
};
responsePromise.success(function(data, status, headers, config) {
    for(index in data) {
        $scope.usersArray.push({
            name:data[index].name,
            password:data[index].password,
            option: $scope.option
        });
    }
});

view:

   {{user.name}}
   {{user.password}}


text:
Q: what mean $\overline{\text{span}(e_1,...,e_n)}$? In functional analysis, what mean
$$\overline{\text{span}(e_1,...,e_n)} \ \ ?$$
is it the closure of $\text{span}(e_1,...,e_n)$ ?
How does it work ? Even if it's that, I don't understand how $\text{span}(e_1,...,e_n)$ can have a closure (because it's a vector space).

A: In functional analysis one of the main objects of study is the study of topological vector spaces. That is a vector space $V$ and a topology $\tau$ of $V$, such that the functions
$$ V\times V \xrightarrow{+} V$$
and
$$ \mathbb{C} \xrightarrow{\cdot v} V$$
are continuous.
One of the main examples of topological vector spaces are normed spaces, where the topology is induced by a norm $\|\cdot\|:V \rightarrow V$. A sub examples of this kind are Banach spaces and Hilbert spaces.
$\overline{span(e_1,\ldots,e_n)}$ just means the closure of $span(e_1,\ldots,e_n)$ with respect to the topology of $V$.


text:
Q: Normalize double array in java I have a double arraylist dataset in Java. I want to normalize the data for data clustering , the function to normalize data for clustering is in here normalization for data cluster

input = {{-1.3,2.4,5.3.2.1,0.7},{6.4,-3.3,1.9.4.1,0.3}}

Below is the code I've tried so far, but I'm not sure it's the right normalization method
public void getMinMax(){
    min = new double[input.size()];
    max = new double[input.size()];
    for(int i=0; i < input.size(); i++){
        min[i] = 0;
        max[i] = 0;
        for(int j = 0; j < input.get(i).size(); j++){
            if(input.get(i).get(j) >= max[i]){
                max[i] = input.get(i).get(j);
            } else if(input.get(i).get(j) <= min[i]){
                min[i] = input.get(i).get(j);
            }
        }
    }
}

private void normalizeMaxMin() {
    for(int i=0; i < input.size(); i++){
        for(int j = 0; j < input.get(i).size(); j++){
            input.get(i).set(j, (input.get(i).get(j) - min[i]) / (max[i] - min[i]));
        }
    }
}

A: This is my method. It's O(n^2) but it works nevertheless.
    public static double[][] normalize(double[][] arr){

    min = Double.MAX_VALUE;
    max = Double.MIN_VALUE;

    for (int i = 0; i < arr.length; i++) {
        for (int j = 0; j < arr[i].length; j++) {

            max = Math.max(arr[i][j],max);
            min = Math.min(arr[i][j],min);

        }
    }

    for (int i = 0; i < arr.length; i++) {
        for (int j = 0; j < arr[i].length; j++) {

            arr[i][j] = (arr[i][j] - min)/(max-min);

        }
    }

    return arr;

}


text:
Q: Available JSF MVC components I'm new to Java-based web programming and am trying to learn JSF from the ground-up. I've heard JSF explained as an entire MVC solution, with Facelets being a pure XML technology comprising the "View" component of the MVC architecture.
So, not knowing any betters, that leads me to ask: what choices/alternatives exist for each component? For each of the 3 (Model, View & Controller), what tools/APIs/libs/technologies exist that will work with JSF. For instance, if understand the View basics correctly, JSP is an (old/obsolescing) alternative to Facelets. Any others? What about the Model component: what are my options there? Controller?
Again, just interested in keeping everything under the JSF umbrella for now: if the component is compatible as some part a JSF solution, I wanna hear about it!
Thanks for any recommendations!

A: I'm surprised BalusC hasn't hit this one already with one of his sickeningly complete answers.  I suspect he'll get around to it, and when he does I'll vote for it because it'll be awesome so don't accept my answer right away.  In the meantime, here are some thoughts:
JSF is meant to be the full MVC stack, with the emphasis on VC.  You've got JSP/Facelets correct.  Simply put, don't use JSP.  Use Facelets.  They are the default view technology for JSF 2.  They are xml based and will keep you from hurting yourself with 'interesting' interactions between the JSF lifecycle and the JSP lifecycle.
You will write java classes and navigation rules to fill the controller role in JSF.  You can use JSF managed beans for your services, or you could use some other framework like Spring for that purpose, but you will implement specific classes to be used as the controllers in JSF.
As for the model... well, any good MVC framework will leave the model to itself.  A model shouldn't know or care about which view it's in.  Hopefully you can take the model and display it in a web page using anything from JSF to Wicket to Vaadin, and then also use it in a desktop app or a RESTful JSON based api.
Here are some links I would suggest you go through to get a handle on JSF

*

*http://www.ibm.com/developerworks/library/j-jsf1/ (older, but will get the basics down)

*http://www.ibm.com/developerworks/library/j-jsf2/ (part 2 of the above)

*http://www.ibm.com/developerworks/library/j-jsf3/ (part 3 of the above)

*http://www.coreservlets.com/JSF-Tutorial/jsf2/ (Marty Hall's tutorial

A: I think your understanding is correct.
I'd say that JSF fills most of the part of the controller. There are other libraries that are compatible with JSF though. For example, you can use Spring WebFlow together with JSF to get more powerful navigation features.
JSF is not very intrusive when it comes to the model. Ideally, there aren't any traces that you are using JSF in your domain model (the exception is that JSF provides annotations that you can optionally use, such as @ManagedBean). This means you are free to use any libraries you want. You can use Spring IOC or EJB if you want to, or you can code your entire model in plain old java objects.
That being said, I should like to emphasize that JSP is not obsolete. As digitaljoel points out, Facelets have replaced JSP as the view technology in JSF, but JSP is still alive and healthy in other frameworks. There is not an agreement that JSF including Facelets are "better" than JSP (together with another web framework); and JSF has not become an industry standard.
Writing a web application using JSF is closer to writing a desktop application, since they have abstracted away much of the request-response handling. There is not a specific method being invoked each time a client does a request, instead each request passes through a lifecycle of which you are not fully in control. Interacting directly with the HttpServletRequest is discouraged.
Ignoring the request-response nature of the web increases the complexity of a request and conflicts with another growing trend: rich web applications that heavily relies on Javascript. The responsibility of the view logic is moved from the server to the browser, which interacts with the server using Ajax against thin HTTP APIs.
The point is that JSF is not the end-all framework that you need to learn and ignore everything else. It can be the correct choice for some applications, but not for all.


text:
Q: Why didn't Luke feel the destruction of Alderaan? In A New Hope, we see that Obi-Wan is visibly affected by the destruction of Alderaan.  If this was such a huge thing to elicit a response, why didn't it affect Luke as well?

A: He likely wasn't yet sensitive enough to the force to understand. He didn't understand his emotions... or rather, he wasn't tuned to them yet.
The force may have been disturbed, but Luke wasn't attuned enough to recognize it... or just missed it. Obi-wan had been trained to identify and recognize when a disturbance in the force had happened.
Luke relied too much on external physical stimulus to see beyond the obvious. This was evident in his training, where he was focusing too much on the physical sphere instead of allowing the force to guide him. It was also evident when he turned off his targeting computer and fully allowed the force to take over.
It was as much about listening and comprehending as it is about receiving.
A radar dish that is super sensitive isn't much good if you don't have an operator who doesn't know how to read the display.
It's like when you feel bad occasionally after eating... but only after being educated understand that those bad feelings are due to a food allergy or intolerance. Once you recognize the symptoms, you can identify and understand the signals. You have to learn how to listen before you can understand. ( Perhaps not the best analogy, but you get the idea )

A: Luke hadn't been trained yet -- he just didn't know how to feel things with the Force very well. Just prior to the scene in which Obi-Wan felt the destruction of Alderaan, we saw Luke training with his lightsaber and the remote droid. Obi-Wan taught Luke to

stretch out with your feelings
Star Wars: Episode IV A New Hope (see script)

while Luke's eyes were covered by his helmet's blast shield. Luke managed to deflect the remote's shots with his lightsaber despite the blast shield, and afterward he remarked

You know, I did feel something. I could almost see the remote.
Star Wars: Episode IV A New Hope

Since Luke could barely sense the remote that was right in front him it would be extremely difficult for him to sense the destruction of a planet light years away (even if it did involve the loss of so much life). Although he had the theoretical capability to sense the destruction of Alderaan, he hadn't yet learned how to stretch out with his feelings in order to do so.
It might help to recall what the Force is and how Force-sensitive individuals communicate with and use it. Obi-Wan explained the Force as:

The Force is what gives a Jedi his power. It's an energy field created by all living things. It surrounds us and penetrates us; it binds the galaxy together.
Star Wars: Episode IV A New Hope

And Qui-Gon explained how a Jedi communicates with that energy field:

Midi-chlorians are a microscopic lifeform that reside within all
  living cells and communicates with the Force...Without the
  midi-chlorians, life could not exist, and we would have no knowledge of the
  Force. They continually speak to you, telling you the will of the Force.
Star Wars: Episode I The Phantom Menace

Luke had a high midi-chlorian count (he was "Force-sensitive") but had not yet learned how to "speak" to the midi-chlorians ("stretch out with his feelings") well enough to sense the destruction of Alderaan.

A: The quick answer is that luke was still very new to the whole force thing, wasnt connected to it enough to feel the disturbences like highly trained jedi/sith.

A: Luke had just started using the force. He wasn't anywhere close to the force  practioner Obi-wan was!


text:
Q: Calculate coordinates of a point based on sine/cosine let me begin by saying that I've read through Calculate point A from given point E and angle and afterwards calculate Point A from E and angle , Calculate point, given x, y, angle, and distance , a problem involving trigonometry functions, and especially How to get coordinates of a point in a coordinate system based on angle and distance and none of them managed to lift the veil of confusion, surrounding me.
What I am doing: I want to create a sort of Instantaneous Field of View (FOV) for a bunch of sequences of points; the FOVs would represent what is visible from each point, depending of course, on the direction at which we are looking at ( 0 - North; 90 - East; 180 - South; 270 - West; 360 - North). The FOV is essentially a triangle, where the central (C) vertex is the point itself, vertex A and vertex B, whose coordinates I am looking for, being the ones connected to the base of the triangle.
The code snippet:  I am essentially approaching this via leveraging two right triangles, that together constitute the FOV, like so:

--------- A VERTEX -------------
for (p in 1:nrow(pnp.90.deg@data)){   #pnp is the spatial points dataframe, containing attribute information such as lon/lat(coordinates) and ca(camera angle - showing the direction of sight/movement in degrees)
   a_alfa1 <- pnp.90.deg@data$ca - (pnp.90.deg@data$ca - 60)
   a_alfa1rad <- a_alfa1 * (pi/180)
   a_x1 <- pnp.90.deg@data$lon + 0.00035 * cos(a_alfa1rad)
   a_y1 <- pnp.90.deg@data$lat + 0.00035 * sin(a_alfa1rad)
   avert1 <- cbind(a_x1, a_y1)
   colnames(avert1) <- c("lon", "lat")
   avert.90<-SpatialPoints(avert1, proj4string=CRS("+proj=longlat +datum=WGS84      +no_defs +ellps=WGS84 +towgs84=0,0,0"), bbox=NULL)
 }

--------- B VERTEX -------------
for (p in 1:nrow(pnp.90.deg@data)){
  b_alfa1 <- pnp.90.deg@data$ca - (pnp.90.deg@data$ca + 60)
  b_alfa1rad <- b_alfa1 * (pi/180)
  b_x1 <- pnp.90.deg@data$lon + 0.00035 * cos(b_alfa1rad)
  b_y1 <- pnp.90.deg@data$lat + 0.00035 * sin(b_alfa1rad)
  bvert1 <- cbind(b_x1, b_y1)
  colnames(bvert1) <- c("lon", "lat")
  bvert.90<-SpatialPoints(bvert1, proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"), bbox=NULL)
}

The result: the code produces the triangle as one would expect, yet it does so only when the angle (ca) is between 0-90 degrees:

The Problem

This formula doesn't seem to work for other camera angles. To my mind (and according to the provided links to topics) the formula should be universally applicable for any angle measure. Can someone provide some input on whether I am a) using the right formula and b) using it in the correct way.

UPDATE: link to the spatial points data frame in shapefile format:
https://drive.google.com/file/d/1ax5OG8c8Cl-Hz3N16ye9OoG4z7l8HSAQ/view?usp=sharing
UPDATE 2: The process of getting from the pnpover (the shared spdf) to pnp.90.deg is just a spatial subset:
pnp.90.deg <- subset(pnpover, pnpover@data$ca <= 90)

I decided to bucket looking angles in ranges of 0-90; 91-180; 181-270; 271-360 in order to test what was going wrong.
Thank you kindly!

A: Look at this picture:

with:

*

*ca is the direction where the camera points to. It is angle that starts at North and goes clockwise, so 0=North, 90=East, etc.

*fa is the inner angle for the field of view (FOV).

*C is the camera position.

*A and B are the coordinates to calculate. Their distance to C is d.
You may already know the conversion from polar to Cartesian coordinates:
x = cx + d * cos(alpha) and y = cy + d * sin(alpha)
But we have said that ca goes clockwise. It means that we must change sin/cos usage.
The needed formulas are:
x = cx + d * sin(alpha)
y = cy + d * cos(alpha)

So, for A, B coordinates:
ax = cx + d * sin(ca - fa/2)
ay = cy + d * cos(ca - fa/2)
bx = cx + d * sin(ca + fa/2)
by = cy + d * cos(ca + fa/2)

These are valid formulas for the whole of {0, 360} range. Or {0, 2PI} as you prefer.
If the origin was different from North (say 0=East) then we would need some sign corrections.
Likely the compiler is able to use any angle, even out of {0, 2PI} range. If not, you must first clamp the angle into the range. I don't speak r, so I write it in general form:
float parts = angle / 360
float rest = parts - int(parts)
float cAngle = rest * 360
better cAngleRadians = rest * 2 *pi