text:
Q: Why is my radiobutton asp code getting an "Invalid postback or callback argument"? Why is my radiobutton asp code failing with "Invalid postback or callback argument" even though I have added the steps that worked with the checkbox controls?
In a related question here, I eventually incorporated a threefold approach to solve a problem of my code-behind not being called. The steps were these:

*

*Incorporating the accepted answer there by adding this (AutoPostBack="true") to the checkboxes like so:
<asp:checkbox id="ckbxAllGenres" runat="server" Checked="True" class="genres" OnCheckedChanged="ckbxAllGenres_CheckedChanged" AutoPostBack="true" />
All

*Adding EnableEventValidation="true" to the to of the Page so that it became this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" EnableEventValidation="true" Inherits="Flix4Fams_WebForms.WebForm1" %>

*Overriding the Render method in the code-behind file, as mentioned here like so:
protected override void Render(HtmlTextWriter writer)
{
// Register controls for event validation
foreach (Control c in this.Controls)
{
this.Page.ClientScript.RegisterForEventValidation(
c.UniqueID.ToString());
}
base.Render(writer);
}
That worked perfect with the Checkbox controls as shown above, but now that I have gotten to the radiobuttons, I get a similar exception as I was before with the checkboxes prior to making those changes, namely:

[ArgumentException: Invalid postback or callback argument.  Event
validation is enabled using  in
configuration or <%@ Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to
postback or callback events originate from the server control that
originally rendered them.  If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId,
String argument) +9830282
System.Web.UI.Control.ValidateEvent(String uniqueID, String
eventArgument) +114
System.Web.UI.WebControls.RadioButton.LoadPostData(String postDataKey,
NameValueCollection postCollection) +77
System.Web.UI.WebControls.RadioButton.System.Web.UI.IPostBackDataHandler.LoadPostData(String
postDataKey, NameValueCollection postCollection) +15
System.Web.UI.Page.ProcessPostData(NameValueCollection postData,
Boolean fBeforeLoad) +471
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1897

Prior to getting this error (when it was working), the radiobutton code was this:
<input type="radio" id="rdbtnAllIMDB" />
All
<input type="radio" id="rdbtnGOE" checked="checked" />
>=
<input type="number" step="0.1" value="7.5" />

Now it is this, with a similar type of morphing:
<asp:radiobutton name="imdb" id="rdbtnAllIMDB" runat="server" AutoPostBack="true" />
All
<asp:radiobutton name="imdb" id="rdbtnGOE" Checked="True" runat="server" AutoPostBack="true" />
>=
<asp:textBox runat="server" type="number" AutoPostBack="true" step="0.1" value="7.5" />

Why did the changes I made get the Checkboxes to work, but it doesn't work with the radiobuttons? What do I need to do yet to get it to work?

A: I read somewhere that for the RadioButtons to be mutually exclusive, they had to both have the same Name value (but different ID values).
Apparently the person was talking about the GroupName property (which does make sense), as when I changed the code to the following it worked:
<asp:RadioButton GroupName="imdbGroup" id="rdbtnAllIMDB" runat="server" />
All
<asp:RadioButton GroupName="imdbGroup" id="rdbtnGOE" Checked="True" runat="server" />


text:
Q: Shortcut keys do not work in a Custom Panel in a Visio 2013 add-in I have created add-in for Visio but I have some problem related to Custom Panel.  For implementing Custom Panel in Visio I used solution described in next link:
How can you add a Custom Panel in a Visio 2013 add-in?
My Custom Panel contain TextBoxes and Buttons. Buttons work correct and I can type text into any TextBox but I CAN'T insert text by using shortcut(Ctrl+V). When I type Ctrl+V my text is inserted in new shape of opened document. Another commands like Ctrl+X Ctrl+A etc do not work too.
How can I resolve this problem?

A: Visio intercepts many keyboard events before they reach your add-in. It provides "KeystrokeMessageForAddon" event though. You could check how it can be used in one of my Visio projects (it is specialized a bit for browser control but I hope it will give you an idea)
https://github.com/nbelyh/HtmlFormData/blob/master/HtmlFormData/HtmlFormData/ShortcutManager.cs

redpajama_set_name: RedPajamaStackExchange


text:
Q: Getting the url of an image if selected I'm pretty new to js and having some trouble trying to get the img src next to a checkbox.
The structure of the elements looks like this:
'<input type="checkbox" class="myCheck" id="myCheck" data-s3="object">';
Being object2hrefvirt(s3exp_config.Bucket, data) the image url.
The goal is to get all the urls to download them in a pack (not necessarily in a zip but to download all  the selected urls at once) when a button is clicked.
Here's what I have so far to know if a checkbox has been selected:
$(document).ready(function() {
    $('#download-checker').click(function(e) {
        checkDownload();
    });

    function checkDownload(){
        if(document.getElementsByTagName("input")){
            if(document.getElementById("myCheck").checked){
                //get img url
            } else if (!document.getElementById("myCheck").checked){
                alert("No selected files");
            } else {
                alert("Error");
            }
        }
    }
}

A: Like this
NOTE: IDs need to be unique

const checkDownload = () => {
  const list = $(".myCheck:checked")
    .map(function() { return $(this).next().attr("src") })
    .get();
  $("#list").text( list.join(", ")); // or return list.length>0 if you want
}
$(function() {
   $('#download-checker').on("click",checkDownload);
});

<input type="checkbox" class="myCheck"  data-s3="object">

<input type="checkbox" class="myCheck" data-s3="object">

<button type="button" id="download-checker">Check</button>


text:
Q: Prolog, operations with files As input data I have a file containing 100 lines. On each line I have a number followed by dot. I need to print into another file the sorted numbers increasingly.
I know reading from a file and printing into a file with see and tell but when it comes to going through all of them from 1 to 100, without doing a read(X),read(Y) etc. for each line in the see() I am lost. So how would you approach this problem?

A: Please note that this description it's far more verbose than the actual code required.
?- read_input(L), msort(L, S), write_output(S).

I.e. (using Edinburgh-style I/O) see the input file, keep reading, storing in a list til the input = end_of_file (then close the list), after that use msort to order the list, then tell the output file, and with a loop write each element of the list. You can check if actually there are 100 numbers using length/2.
edit untested code to read a list from current input
read_list(L) :-
  read(N), N \= end_of_file
  -> L = [N|Ns], !, read_list(Ns)
  ;  L = []
  .


text:
Q: .Net Observer Pattern changes. When did these happen and why? I was just trying to explain the Observer pattern to a colleague for use in a C# application. I remarked that is should be easy enough to implement by looking up some MSDN documentation. However, I was surprised to find that the MSDN example deviates from how I've been taught the Observer pattern. Mind you, I've primarily used the pattern in Java, but I was under the impression that the .Net implementation was pretty much the same.
The pattern I know uses the methods Notify, Subscribe and Unsubscribe. This new implementation explained on MSDN uses OnNext, OnCompleted, OnError and Subscribe. I'm able to find articles from just a few years ago explaining the Notify version of it, however.
At first glance, this new version seems unnecessarily convoluted and it has me slightly confused. Since when has this implementation been around, and why was it implemented this way? Wat are the advantages?

A: Bear in mind that the .NET Observer interfaces are closely related to the MS Reactive Extensions.  If you want to understand the added functionality provided by OnError/OnCompleted, this is probably the best place to research.  The rest of the pattern pretty much matches as-is:

*

*Subscribe is still just Subscribe.

*Unsubscribe is intended to be implemented through Disposal of a context returned by Subscribe.

*OnNext corresponds to Notify.

So really the only new functionality is OnError (providing a parallel error-reporting channel to let the observer know that the observable has entered an error state) and OnCompleted (to let the observer know that the observable won't be providing any more messages.)  You could accomplish this with details in the message to indicate these state transitions, but having them baked-in makes sense if you think of an observable as a sort of message channel which can undergo state changes that are somewhat orthogonal to the intention of the messages themselves.

A: The four interfaces to look at are the following.
IEnumerable<T>
    IEnumerator<T> GetEnumerator()

IEnumerator<T>
    bool MoveNext()
    T Current { get; }
    void Dispose()

IObservable<T>
    IDisposable Subscribe(IObserver<T>)

IObserver<T>
    void OnNext(T)
    void OnError(Exception)
    void OnCompleted()

The IEnumerable<T> and IObservable<T> interfaces are duals. Same goes for IEnumerator<T> and IObserver<T>. The interactive interfaces, IEnumerable<T> and IEnumerator<T>, use pull semantics to describe a sequence of Ts.  The reactive interfaces, IObservable<T> and IObserver<T>, use push semantics to describe a sequence of Ts.
Suppose I have an IEnumerator<T> named e.  When I call e.MoveNext() followed by e.Current in the case of success, I am conceptually getting one of three things:

*

*e.MoveNext() returns true and I get a T

*e.MoveNext() throws an Exception

*e.MoveNext() returns false and I have completion

Notice how these correspond exactly to the IObserver<T> methods OnNext, OnError, OnCompleted. The difference is in the IEnumerator<T> case I pull out information but in the IObserver<T> case I push in information.
When I call IEnumerator<T>.Dispose, the sequence of Ts is canceled. Similarly, when I call Disposeon the IDisposable returned by IObservable<T>.Subscribe, the sequence of Ts is canceled.
When I call IEnumerable<T>.GetEnumerator I pull out an IEnumerator<T>. When I call IObservable<T>.Subscribe I push in an IObserver<T>.


text:
Q: Foreach Loop Within A Foreach Loop In A Method And Return Values I have the following code where I am trying to enumerate through files on a shared drive, collect properties for each file, and then return each entry from that collection.
Visual Studio gives me "CS0161: 'Program.EnumerateYourFiles(string)': not all code paths return a value." error when I hover over the EnumerateYourFiles method.  I am guessing that it has to do with the fact that the "l" variable I am trying to return is out-of-scope.  How do I get that "l" variable into scope so it returns for the function?
using System;
using System.IO;
using System.Collections.Generic;

namespace FileShareMachine
{
    public class Program
    {

        static void Main(string[] args)
        {
            Console.WriteLine(EnumerateYourFiles(@"E:\"));

        }
        public static object EnumerateYourFiles(string pathToSearch)
        {
            string filePath = pathToSearch;
            DirectoryInfo currentParentFileList = new DirectoryInfo(filePath);
            DirectoryInfo[] listOfSubDirectories = currentParentFileList.GetDirectories();
            List<string> listOfAllFiles = new System.Collections.Generic.List<string>();

            foreach (var parentPath in listOfSubDirectories)
            {
                string pathForEnumeration = parentPath.ToString();
                DirectoryInfo individualSubFolder = new DirectoryInfo(pathForEnumeration);

                try
                {
                    foreach (var eachFile in individualSubFolder.EnumerateFiles("*", SearchOption.AllDirectories))
                    {
                        string individualPaths = eachFile.FullName.ToString();
                        string lastAccessed = eachFile.LastAccessTime.ToString();
                        string fileSize = eachFile.Length.ToString();
                        string creationTime = eachFile.CreationTime.ToString();
                        string lastWriteTime = eachFile.LastWriteTime.ToString();
                        string fileDirectory = eachFile.Directory.ToString();

                        //The following works like a dream. This is how you write to a file. You need an array or list
                        listOfAllFiles.Add(individualPaths);
                        listOfAllFiles.Add(fileSize);
                        listOfAllFiles.Add(fileDirectory);
                        listOfAllFiles.Add(creationTime);
                        listOfAllFiles.Add(lastAccessed);
                        listOfAllFiles.Add(lastWriteTime);

                    }
                }
                catch (System.UnauthorizedAccessException)
                {
                    bool errorThrown = true;
                    if (errorThrown)
                    {
                        Console.WriteLine("The following path had an access error {0}", individualSubFolder);
                        continue;
                    }
                    else
                    {
                        continue;
                    }

                }
            }

            //return listOfSubDirectories;
            foreach(object l in listOfAllFiles)
            {
                return l;
            }

        }

    }
}

A: foreach(object l in listOfAllFiles)
{
    return l;
}

isn't going to work.
Try
return listOfAllFiles

instead.
Consider returning something other than an object, like IEnumerable<string>, unless your use case requires object (it's not unprecedented; there are places in WPF that are like that).
If you're trying to return one item from the list each time you call the method, try
yield return l;

instead.  Your method should then return a string.


text:
Q: Where is a SiteLogoUrl in CSOM? I found SPWeb.SiteLogoUrl and expected this property in CSOM and REST. But I didn't find it. How can I get a SiteLogoUrl using CSOM or REST?
SP.js
Microsoft.SharePoint.Client.dll

A: It was moved to the POST request that SharePoint creates while redirecting via appredirect.aspx. So, the only one way to get Site Logo Url is to handle appredirect POST request.
To initiate redirect you should use this code snippet:
Response.Redirect(TokenHelper.GetAppContextTokenRequestUrl(sharePointHostUrl, Server.UrlEncode(targetUrl)));

ContextToken, SiteLogo, Url, Title and so on can be found in the POST FormData.


text:
Q: Nuxtjs deleting all from layouts/default.vue I am following tutorial where guy put his header component into layouts/default.vue component. I did same except mine was inside nuxt folder, so nuxt/layouts/default.vue... I guess its just older version of nuxt but, problem is that everyting i put there, component and styles are deleted after refresing my app, all that is left was default template with  component. I dont know what is happening. This is code from default.vue
<template>
  <div class="container">
    <AppHeader/>
    <nuxt/>
  </div>
</template>

<script>
import AppHeader from "@/components/AppHeader";
export default {
  components: {
    AppHeader
  }
};
</script>

<style>
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: #f4f4f4;
}
a {
  color: #666;
  text-decoration: none;
}
ul {
  list-style: none;
}
.container {
  max-width: 800px;
  margin: 2rem auto;
  overflow: hidden;
  padding: 1rem 2rem;
  background: #fff;
}
</style>

EDIT: My actual question is how do i put global components in nuxt, navbar for example? Am i doing something wrong above?


text:
Q: Installing opengeo on Arch Linux I am trying to install the opengeo suite (community) for a project I have. The thing is that my Linux distribution is Arch Linux, for which the package manager is pacman and not apt-get as it is the case in Ubuntu.
Is it possible to install it on Arch Linux?
The installation manual says that it provides packages for both debian and red hat, but is possible to build a package from sources somewhere?
I know they have a git repository, however, I cannot see how to build a package from it (my knowledge of writing PKGBUILDs is slim at best).

A: I also run arch linux.
When I set up geonode (a component of the suite) on my arch system, I used vagrant with ubuntu linux. There are so many parts to the suite, so many things that could conflict with existing arch packages that it would likely be quite the challenge to get working.
If you really wanted to, you probably could translate the open geo build instructions into your own package, but that sounds like a lot of work.


text:
Q: TestCafe only running first test in loop I have the following function to run parameterized tests:
export function multiTest<T>({cases, setup, testFn, testNamePrefix, skip, options: _options}: {
  cases: TestCases<T>
  setup: (t: SetupHelper, cases: TestCases<T>) => (void | Promise<void>)
  testFn: MultiTestFn<T>,
  testNamePrefix?: string,
  skip?: boolean
  options?: HelperOptions
}): Promise<void> {
  const doSetup = async () => {
    if (skip) {
      return;
    }

    // some setup code here left out

    await setup(new SetupHelper(options), cases);
  }

  let wrappedFn = test.page(someUrl);
  if(skip) {
    wrappedFn = wrappedFn.skip;
  }

  let didSetup = false;
  cases.forEach(([testName, caseData]) => {
    wrappedFn(`${testNamePrefix || ""}${testName}`, async (t) => {
      if(!didSetup) {
        await doSetup();
        didSetup = true;
      }
      await testFn(t, new Helper(t, options), caseData)
    })
  });
}

The test code that calls this:
skeleton.multiTest({
  testNamePrefix: "Content masking: ",
  cases: [
    { suppressMessages: "off", suppressTypes: "all", expectedMasks: 0},
    { suppressMessages: "all", suppressTypes: "all", expectedMasks: 12},
    { suppressMessages: "otherOnly", suppressTypes: "all", expectedMasks: 6 },
    { suppressMessages: "all", suppressTypes: "links", expectedMasks: 2 },
    { suppressMessages: "all", suppressTypes: "phones", expectedmasks: 4, replacement: "" },
    { suppressMessages: "all", suppressTypes: "emails", expectedMasks: 6, replacement: "[TEST]" },
  ].map(makeFullCase),
  setup: setup,
  testFn: async (t, s, testCase) => {
      await t.expect(/* ... */)
  }
});

I feel like this does essentially the same thing as the data driven test example described here: https://testcafe.io/documentation/402804/recipes/best-practices/create-data-driven-tests
Yet testCafe seems to run only one of the cases.

A: You cannot wrap test in this way. Each first call of test creates a Test instance. You do this only once and reuse one instance many times, but one instance can keep information only about one test.
Try rewriting your multiTest function as follows:
export function multiTest<T>({cases, setup, testFn, testNamePrefix, skip, options: _options}: {
  cases: TestCases<T>
  setup: (t: SetupHelper, cases: TestCases<T>) => (void | Promise<void>)
  testFn: MultiTestFn<T>,
  testNamePrefix?: string,
  skip?: boolean
  options?: HelperOptions
}): Promise<void> {
  const doSetup = async () => {
    if (skip) {
      return;
    }

    // some setup code here left out

    await setup(new SetupHelper(options), cases);
  }

  let didSetup = false;
  cases.forEach(([testName, caseData]) => {
    let wrappedFn = test.page(someUrl);
    if(skip) {
      wrappedFn = wrappedFn.skip;
    }

    wrappedFn(`${testNamePrefix || ""}${testName}`, async (t) => {
      if(!didSetup) {
        await doSetup();
        didSetup = true;
      }
      await testFn(t, new Helper(t, options), caseData)
    })
  });
}


text:
Q: Can every periodic binary sequence be expressed as the output of a Linear or Non-Linear Feedback Shift Register? Quick background: The output of a Linear Feedback Shift Register (LFSR) with length $n$ is a binary sequence which is periodic of length dividing $2^n-1$. From a mathematical point of view, such a sequence is constructed recursively as follows: each state of the LFSR with length at most $n$ (such a state is an element of ${\mathbb{Z}_2}^n)$ is constructed using the previous state $s$  by "shifting" $s$ to the right and inserting a new bit $f(s)$ to the left-most position, where $f$ is a linear boolean function of degree $n$ corresponding to the LFSR (the feedback function. The right-most bit that is "ejected" from that shift, is the output bit for that state. All those output bits form a binary sequence of period $\leq2^n-1$. A Non Linear Feedback Shift Register (NLFSR) Sequence is one which follows the same principle as above, using however a Non Linear feedback function. Although there is a rich mathematical background and known facts for LFSR's, much less is known for NLFSR's due to their non-linear nature.
My Question: Can every binary sequence of arbitrary length $N$ be expressed as the output of some Feedback Shift Register (Linear or not)?
EDIT: When $N|2^n-1$ for some $n$ there is a $1-1$ correspondence between sequcences of period $N$ and boolean functions in ${\mathbb{Z}_2}^n$ (Golomb, Gong, Signal Design for Good Correlation, 2005). In other words, if a binary sequence has period $N=2^n-1$ for some $n$, there exists a Linear FSR with that ouputs this sequence. Can that be generalized to any $N$?
EDIT 2: So, my question was trivial, see joriki's answer below. I now wonder if we can now say anything about the minimal FSR that outputs a given sequence. For instance, a sequence with (potentially huge) period $N=2^n-1$ can be constructed from a LFSR with only $n$ stages. Can anything similar be said for a general $N$?

A: The answer is trivially yes. Choose $n=N$, start out with the desired sequence in the register, and let the non-linear feedback function return the right-most bit of $s$.


text:
Q: Python dictionary not clearing after function calls I have the following code, that checks if the target sum can be achieved using the list of numbers given. I am trying to memoize the function by storing the values in a dictionary.
def how_Sum(target_Sum, numbers, memo={}):
    if target_Sum in memo:
        return memo[target_Sum]
    if target_Sum == 0:
        return []
    if target_Sum < 0:
        return None

    for num in numbers:
        remainder = target_Sum - num
        remainder_Result = how_Sum(remainder, numbers, memo)
        if remainder_Result != None:
            memo[target_Sum] = remainder_Result + [num]
            print(memo)
            return memo[target_Sum]

    memo[target_Sum] = None
    return None

Now when I call the function like this, I get the following result which is correct.
print(how_Sum(7, [2, 3])) gets me,
{1: None, 3: [3]}
{1: None, 3: [3], 5: [3, 2]}
{1: None, 3: [3], 5: [3, 2], 7: [3, 2, 2]}
[3, 2, 2]

And when I call this function, print(how_Sum(7, [5, 3, 4]) I get the following which is also correct,
{2: None, 1: None, 4: [4]}
{2: None, 1: None, 4: [4], 7: [4, 3]}
[4, 3]

Now when I run both of them together,
print(how_Sum(7, [2, 3]))
print(how_Sum(7, [5, 3, 4]))

I get this result,
{1: None, 3: [3]}
{1: None, 3: [3], 5: [3, 2]}
{1: None, 3: [3], 5: [3, 2], 7: [3, 2, 2]}
[3, 2, 2]
[3, 2, 2]

Now from my understanding, the dictionary gets created for the first function and doesn't get cleared for the second call. Can someone explain me why this behaves this way, and how to rectify this?


text:
Q: Image is not showing in the iOS device after getting downloaded through rn-fetch-blob ( React native fetch blob) I am trying to download a small image using this particular code snippet :
Plug in Used :  "rn-fetch-blob": "^0.10.14"

 RNFetchBlob.
config({
  fileCache: true,

}).
fetch('GET', url, {      //getting image URL from server
  // some headers ..
})
  .then((response) => {
    const base64Str = response.data;
    RNFetchBlob.fs
          .writeFile(imageLocation, base64Str, 'base64')
          .then(() => {

              console.log("Download successful");

          }).catch((err) => {
            console.log('Failed to save file. ', err);
          });

variable imageLocation points to ${RNFetchBlob.fs.dirs.DocumentDir}/${filename}.
Also tried with ${RNFetchBlob.fs.dirs.CacheDir}/${filename}.
Download is successful but no image is shown in device photos.

A: On iOS both documents and cache directory are contained within the application's own directory. So you are not storing the image in the device photos.
To download it to the device photos you need to use CameraRoll from react-native https://facebook.github.io/react-native/docs/cameraroll
import { CameraRoll } from 'react-native';

This tutorial shows you how to use CameraRoll
https://medium.com/react-native-training/mastering-the-camera-roll-in-react-native-13b3b1963a2d
However the crux of it is you can use something like this to download images to the camera roll
saveToCameraRoll = (image) => {
  if (Platform.OS === 'android') {
    RNFetchBlob
      .config({
        fileCache : true,
        appendExt : 'jpg'
      })
      .fetch('GET', image.urls.small)
      .then((res) => {
        CameraRoll.saveToCameraRoll(res.path())
          .then(Alert.alert('Success', 'Photo added to camera roll!'))
          .catch(err => console.log('err:', err))
      })
  } else {
      CameraRoll.saveToCameraRoll(image.urls.small)
        .then(Alert.alert('Success', 'Photo added to camera roll!'))
  }
}

A: What you wanted to do is to write base64 encoded image to a file but what you're writing is the image url only.


text:
Q: How to Fetch database table value to frontend I have a custom module that checks Pincode, kindly check the screenshots below:-

I have created a custom import function and added a table to the database which will hold the value imported by CSV below is the screenshot:-

now I want to fetch this table on the frontend where I check Pincode and if the Pincode exist in the database then it should show the message of delivery available.
please also check the code below
vendor/module/Model/Pincode.php
<?php
namespace Learn\CheckDelivery\Model;

class Pincode extends \Magento\Framework\Model\AbstractModel
{
    public function _construct()
    {
        $this->_init('Learn\CheckDelivery\Model\ResourceModel\Pincode');
    }
}

vendor/module/Model/ResourceModel/Pincode.php
<?php
namespace Learn\CheckDelivery\Model\ResourceModel;

class Pincode extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    public function _construct()
    {
        $this->_init('learn_checkdelivery', 'id');
    }
}

vendor/module/Model/ResourceModel/Pincode/Collection.php
<?php
namespace Learn\CheckDelivery\Model\ResourceModel\Pincode;

class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
    protected function _construct()
    {
        $this->_init('Learn\CheckDelivery\Model\Pincode','Learn\CheckDelivery\Model\ResourceModel\Pincode');
    }

    //print_r($datacollection);
}

now I want to know how to achieve this
UPDATE
VENDOR/MODULE/view/frontend/layout/templates/product/view/check_delivery.phtml
<?php $product = $this->getCurrentProduct()  ?>

<?php $helper=$this->helper("Learn\CheckDelivery\Helper\Data");?>
<?php if($product && $product->getCheckDeliveryEnable() != 2 && $helper->getIsActive() == 1): ?>
    <form class="form" id="check-delivery-form" method="post">
       <fieldset class="fieldset">
           <legend class="legend"><?php echo __('Check Delivery') ?></legend>

                <?php echo __('Postcode') ?>

                    <input type="text" name="postcode" id="delivery_postcode" value="" title="<?php echo __('Postcode') ?>" class="input-text" data-validate="{required:true, 'validate-digits':true}">

       </fieldset>

                <button type="submit" class="action submit primary action-check-delivery" title="<?php  echo __('Check') ?>"><?php echo __('Check') ?></button>

    </form>

<?php endif; ?>

Block.php
<?php

namespace Learn\CheckDelivery\Block\Product\View;

use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

class CheckDelivery extends Template
{

    protected $_registry;

    public function __construct(
        Context $context,
        Registry $registry,
        array $data = []
    ) {
        parent::__construct($context, $data);
        $this->_registry = $registry;
    }

    public function getCurrentProduct()
    {
        return $this->_registry->registry('current_product');
    }
}

A: You need to call the model collection factory into your constructor
protected $yourCollectionFactory;
public function __construct(
    ....
    \[Namespace]\[Module]\Model\ResourceModel\[Entity]\CollectionFactory $yourCollectionFactory,
    ...
)
{
    ...
    $this->yourCollectionFactory = $yourCollectionFactory;
    ...
}

And use in your method like the below example.
public function yourMethod(){
    $collection = $this->yourCollectionFactory->create();
}

I hope it'll help you.

A: @pramod
you can simply get the collection of your model like :
this code you need to write down in your block file.
<?php

namespace Learn\CheckDelivery\Block\Product\View;

use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

class CheckDelivery extends Template
{

    protected $_registry;
    protected $_$pincode;
    public function __construct(
        Context $context,
        Registry $registry,
        \Learn\CheckDelivery\Model\PincodeFactory $pincode,
        array $data = []
    ) {
        parent::__construct($context, $data);
        $this->_registry = $registry;
        $this->_pincode = $pincode;
    }

    public function getPincodeCollection($pincode){
      $collection = $this->_pincode->create();
$collection->getCollection();
$collection->addFiledtoFilter('pincode',$pincode);
$collection->getData();
//you can check the data here like
return $collection;
    }

    public function getCurrentProduct()
    {
        return $this->_registry->registry('current_product');
    }
}

in your phtml :


text:
Q: Difficult SQL-Query i have 2 tables i.e. table 1 calls game and table 2 calls game_medias
structure table 1 (game)
-id
-genre_id
-title
-created

etc.
structure table 2 (game_medias)
-id
-game_id
-thumb

etc
example query:
select g.id,g.genre_id,g.title, gm.*
from games g inner join game_medias as gm
group by rand(g.id) limit 8;

is it possible to make a query with a extra like " where g.id = '2' " - get the genre_id from it and get into the random 8 only "items" with this genre_id ? i'm not sure if the join is the right solution - maybe someone knows a better way?
regards

A: There are many ways to do this but I believe this will work:
select g.id,g.genre_id,g.title, gm.*
from games g inner join game_medias as gm
where (g.genre_id = (SELECT genre_id FROM games WHERE id = 2))
group by rand(g.id) limit 8;

If there is an index on games.id then it should be quite fast.


text:
Q: How do you put data from a web table into Excel? I'm trying to build a spreadsheet from a few different webpages that have data in a table format.
How do you put data from a web table into Excel?

A: Easiest thing to do would just to start at the top of the table and end at the bottom.
Copy it and paste it in to a new Excel file, extract the data you require and put it in to the final spreadsheet.
There are a few tricks you may need to do, but excel can understand a wide range of files including web pages, so it should be able to extract the data in a tabular form.

A: What you want is a web query. It can be set up to be live (automatically refreshed) or manually refreshed.
In 2003, it's under the Data menu, then Import External Data, New Web Query.
Enter the web address, then find and click on the table to import.

*

*Excel 2002 Getting data from the Web in Excel

*Excel 2003 About getting data from a Web page

*Excel 2007 Get external data from a Web page
Alternatively, you can copy the static table data. In IE, right-click and Export Table to Excel. In Firefox, you will need an extension like Table2Clipboard.

A: Found a video that explains it for Excel 2000, but Excel 2007 is basically the same.

A: If you use Internet explorer and have Excel installed, right click on the table and click "Import Into Microsoft Excel".

A: On Windows with Internet Explorer (versions 6 - 8), I've been able to do this simply by highlighting the entire table, then choosing Edit:Copy (or right-clicking and choosing copy), then pasting into Excel.
On Windows, with Firefox, I can still do it, but it seems a bit trickier -- I feel like I have to highlight a little above the table and a little below it, then trim that in Excel.
I've not even attempted it on Mac, nor with Safari nor Chrome. I imagine in the Windows world, if Safari and Chrome were using the Clipboard correctly, they'd "just work" like Firefox does.

A: You can take any html file with table, rename it with a "*.xls" extension, and Excel will happily open it up as if it were a native document.

A: This will sometimes work:

*

*Select the web page text in your browser

*In a blank Excel worksheet, hit Control + A to highlight all columns and rows

*From the menu, choose Edit > Paste Special and choose unformatted text

*If it says the areas aren't the same size and shape, tell it to paste anway

If you're lucky, the data will end up in proper columns and rows. You can then re-copy and paste it wherever you want it.


text:
Q: Creating custom unique constraints I Defined my @FuSsA_UniqueKey constraint annotation:
package com.fussa.employee.util;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

@Constraint(validatedBy = { UniqueIDValidator.class })
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface FuSsA_UniqueKey {

    String columnNames();

    String message() default "{Value is not unique}";

    Class<?>[]groups() default {};

    Class<? extends Payload>[]payload() default {};

}

Having defined my annotation, i created a constraint validator UniqueIDValidator, which is able to validate elements with a @FuSsA_UniqueKey annotation:
   package com.fussa.employee.util;

import java.io.Serializable;
import java.util.List;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder;
import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext;

import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

public class UniqueIDValidator implements ConstraintValidator<FuSsA_UniqueKey, Serializable> {

    @Autowired
    private SessionFactory sessionFactory;

    private Session s;

    private String uniqueField;
    private FuSsA_UniqueKey unique;

    public void initialize(FuSsA_UniqueKey unique) {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        uniqueField = unique.columnNames();
    }

    @Override
    public boolean isValid(Serializable arg0, ConstraintValidatorContext arg1) {
        String a = arg0.getClass().getSimpleName();
        String query = String.format("from %s where %s = :%s ", a, uniqueField, uniqueField);
        List<?> list = null;
        try {
            s = sessionFactory.getCurrentSession();
            s.setFlushMode(FlushMode.COMMIT);
            list = s.createQuery(query).setParameter(uniqueField, "FuSsA").list();

        } catch (HibernateException e) {
            s = sessionFactory.openSession();
            s.setFlushMode(FlushMode.COMMIT);
            list = s.createQuery(query).setParameter(uniqueField, "FuSsA").list();
        } finally {
            // this is to reset the hibernate config I think
            s.setFlushMode(FlushMode.AUTO);
        }
        if (list != null && !(list.size() > 1)) {
            return true;
        } else {
            ConstraintViolationBuilder cvb = arg1.buildConstraintViolationWithTemplate(unique.message());
            NodeBuilderDefinedContext nbdc = cvb.addNode(unique.columnNames());
            ConstraintValidatorContext cvc = nbdc.addConstraintViolation();
            cvc.disableDefaultConstraintViolation();
            return false;
        }
    }
}

methode saveEmployee on my Controller:
    @Autowired
    EmployeeService service;

    @Autowired
    MessageSource messageSource;
    @Autowired
    private Validator validator;

  @RequestMapping(value = { "/new" }, method = RequestMethod.POST)
    public String saveEmployee(@Valid Employee employee, BindingResult result, ModelMap model) {

        if (result.hasErrors()) {
            return "registration";
        }

        Set<ConstraintViolation<Employee>> violations = validator.validate(employee);

        if (!violations.isEmpty()) {

            FieldError ssnError = new FieldError("employee", "ssn", messageSource.getMessage("non.unique.ssn",
                    new String[] { employee.getSsn() }, Locale.getDefault()));
            result.addError(ssnError);

            return "registration";
        } else {
            service.saveEmployee(employee);

            model.addAttribute("success", "Employee " + employee.getName() + " registered successfully");
            return "success";
        }
    }

Edit
i also add to my @Configuration class AppConfig this methode, so i can autowired it on my controller "not sure if its correct":
@Bean
    public Validator localValidatorFactoryBean() {
        return new LocalValidatorFactoryBean();
    }

when i try to save my object .. i got this errors:
Caused by: javax.validation.ValidationException: HV000028: Unexpected exception during isValid call.
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:451)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:127)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:87)
    at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:592)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:555)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:490)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:454)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:406)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:204)
    at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:108)
    at org.springframework.validation.DataBinder.validate(DataBinder.java:866)
    at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.validateIfApplicable(ModelAttributeMethodProcessor.java:164)
    at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:99)
    at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    ... 31 more
Caused by: java.lang.NullPointerException
    at com.fussa.employee.util.UniqueIDValidator.isValid(UniqueIDValidator.java:54)
    at com.fussa.employee.util.UniqueIDValidator.isValid(UniqueIDValidator.java:1)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:448)
    ... 54 more

so the error is catched on that line :
ConstraintViolationBuilder cvb = arg1.buildConstraintViolationWithTemplate(unique.message());

thanks for any advices..

A: I fixed this issue by Initializing the variable unique :
public void initialize(FuSsA_UniqueKey unique) {
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            this.unique = unique;
            uniqueField = unique.columnNames();
        }


text:
Q: Oracle Scalar function in select vs table valued function join I have have a query that is performing poorly. One aspect of the query is the use of a cross join on a table-valued function, in all honestly I was mimicking my TSQL behaviors of using CROSS APPLY on a function to avoid using a scalar function call. Is this a bad behavior in Oracle?
The main issue I'm running into is that Oracle Tuning Advisor will not parse my query so I'm unable to research index optimizations yet. Normally I wouldn't post this much code but I suspect it is my query more than table optimization that may be causing an issue.
The statistics se table is really the only table with volumn more than 4,000,000 records.  Can anyone recommend the removal of blatant bad Oracle behaviors? Or if all looks well a good tool to get some index tuning advisory? The Oracle Enterprise Manager won't parse this query to provide any recommendations.
Additional Performance Information captured from trace and formatted
through TKPROF

Parse: Count(1) | CPU(0.04) | Elapsed(0.04) | Disk(0) | Query(852) | Current(0) | Rows(0)
Execute: Count(1) | CPU(0.00) | Elapsed(0.00) | Disk(0) | Query(0) | Current(0) | Rows(0)
Fetch: Count(1) | CPU(9.64) | Elapsed(14.50) | Disk(34578) | Query(35610) | Current(4) | Rows(4)
Misses in library cache during parse: 1
  Optimizer mode: ALL_ROWS
  Parsing user id: 1165
Rows     Row Source Operation

  4  HASH JOIN OUTER (cr=38069 pr=34578 pw=0 time=19208475 us)
  2   COLLECTION ITERATOR PICKLER FETCH REPORT_INTERVAL_SEQUENCE_UDF (cr=97 pr=0 >                                                                    pw=0 time=13766 us)
  4   VIEW  (cr=37972 pr=34578 pw=0 time=19194353 us)
  4    HASH GROUP BY (cr=37972 pr=34578 pw=0 time=19194329 us)

60650     FILTER  (cr=37972 pr=34578 pw=0 time=19673947 us)
    60650      NESTED LOOPS  (cr=37972 pr=34578 pw=0 time=19431329 us)
    60650       HASH JOIN  (cr=37941 pr=34578 pw=0 time=5294908 us)
        4        COLLECTION ITERATOR PICKLER FETCH REPORT_MACHINEINFO_GETT_UDF (cr=2331 pr=0 pw=0 time=212033 us)
    60650        TABLE ACCESS FULL ELS_STATISTIC_ENTRY (cr=35610 pr=34578 pw=0
                                                                     time=4416705 us)
     60650       COLLECTION ITERATOR PICKLER FETCH REPORT_INTERVAL_GETT_UDF (cr=31 pr=0 >                                                                    pw=0 time=13372794 us)

SELECT
         TimeInterval,
         stats.During,
         stats.Name,
         stats.cnt
    FROM
        TABLE (GET_INTERVAL_SEQUENCE_UDF(
                                         TO_TIMESTAMP ('07/15/2011','mm/dd/yyyy')
                                        ,TO_TIMESTAMP ('07/20/2011','mm/dd/yyyy')
                                        ,2)) dtRange
    LEFT JOIN
    (
         SELECT
              i.During
              , mi.Name
              , SUM (CAST (VALUE_NUMERIC AS INT)) cnt

         FROM
              statistics se
         JOIN TABLE (Get_Context_Info_udf ()) mi
              ON (se.Context_ID = mi.Context_ID)
         CROSS JOIN TABLE (Interval_GetT (se.EntryDate, 2)) i
         WHERE
              StatisticTypeID = HEXTORAW ('6CF933B091AE46FEA7F56BE96308190F')
              AND EntryDate < TO_TIMESTAMP ('07/20/2011','mm/dd/yyyy')
              AND EntryDate > TO_TIMESTAMP ('07/15/2011', 'mm/dd/yyyy')
         GROUP BY
             i.During
             , mi.Name
    ) stats ON dtRange.TimeInterval = stats.TimeInterval

The following are for reference in the aforementioned query.

CREATE OR REPLACE FUNCTION Interval_GetT(datestamp IN timestamp,  timeInterval IN int)
RETURN TReportIntervalList AS vResult TReportIntervalList;
BEGIN
     SELECT TReportInterval(
                            CASE timeInterval
                            WHEN 1 THEN TO_CHAR(datestamp, 'YYYY-MM-DD HH24')
                            WHEN 2 THEN TO_CHAR(datestamp, 'YYYY-MM-DD')
                            WHEN 3 THEN TO_CHAR(datestamp, 'YYYY-WW')
                            END
                           )
     BULK COLLECT INTO vResult
     FROM Dual WHERE ROWNUM = 1;

     RETURN vResult;
END;

CREATE OR REPLACE FUNCTION GET_INTERVAL_SEQUENCE_UDF(
      startTime IN timestamp,
      endTime IN timestamp,
      inputInterval IN int)
      RETURN t_interval_list_table   AS  intervalList t_interval_list_table := t_interval_list_table();
    BEGIN

    SELECT
         CASE inputInterval
         WHEN 1 THEN (t_interval(REPORT_Interval_Get_udf((startTime + ((ROWNUM-1) * 1/24)), inputInterval))) --Hour
         WHEN 2 THEN (t_interval(REPORT_Interval_Get_udf((startTime + (ROWNUM-1)), inputInterval))) --Day
         WHEN 3 THEN (t_interval(REPORT_Interval_Get_udf((startTime + ((ROWNUM-1)*7)), inputInterval))) --Week
            END
          BULK COLLECT INTO intervalList
          FROM dual CONNECT BY LEVEL <= (CASE inputInterval
                                          WHEN 1 THEN CAST(CEIL(((TRUNC(endTime, 'HH') - TRUNC(startTime, 'HH')) * 24)) AS INT)
                                          WHEN 2 THEN CAST(TRUNC(endTime, 'DD') - TRUNC(startTime, 'DD') AS INT)
                                          WHEN 3 THEN CAST(CEIL(((TRUNC(endTime, 'DD') - TRUNC(startTime, 'DD')) )/7) AS INT)
                                       END);
      RETURN intervalList;

    END GET_INTERVAL_SEQUENCE_UDF;

CREATE OR REPLACE FUNCTION      Get_Context_Info_udf
    RETURN TTRFRMENGMACHINEINFOLIST AS vResult TTRFRMENGMACHINEINFOLIST;
    BEGIN
        SELECT TTrfrmEngMachineInfo(ch.Context_ID, mac.Name)
        BULK COLLECT INTO vResult
        FROM
            a ch
        INNER JOIN
            b cxm  ON ch.CONTX_MACHINE_ID = cxm.CONTX_MACHINE_ID
        INNER JOIN
            c mac ON cxm.MACHINE_ID = mac.MACHINE_ID
        INNER JOIN
            d ic  ON mac.MACHINE_ID = ic.MACHINE_ID
        WHERE
            ic.ONFIGURABLE_ENTITY_ID =  HEXTORAW(Format_Guid_udf('11111111-FAE9-47A1-91A9-60A53E9660FE'))
            AND mac.IS_DELETED = 'N'
            AND ic.IS_DELETED = 'N';

        RETURN vResult;
     END;

A: It all looks alien to me :)
Firstly, a SELECT FROM DUAL is unusual in PL/SQL.
CREATE OR REPLACE FUNCTION Interval_GetT(datestamp IN timestamp,  timeInterval IN int)
RETURN TReportIntervalList AS vResult TReportIntervalList;
BEGIN
     SELECT TReportInterval(
              CASE timeInterval
                     WHEN 1 THEN TO_CHAR(datestamp, 'YYYY-MM-DD HH24')
                     WHEN 2 THEN TO_CHAR(datestamp, 'YYYY-MM-DD')
                     WHEN 3 THEN TO_CHAR(datestamp, 'YYYY-WW')
              END)
     BULK COLLECT INTO vResult
     FROM Dual WHERE ROWNUM = 1;

     RETURN vResult;
END;

would be done as a simpler
CREATE OR REPLACE FUNCTION Interval_GetT(datestamp IN timestamp,  timeInterval IN int)
RETURN TReportIntervalList;
BEGIN
  IF timeInterval  = 1 THEN
       RETURN TReportInterval(TO_CHAR(datestamp, 'YYYY-MM-DD HH24'));
  ELSIF timeInterval  = 2 THEN
       RETURN TReportInterval(TO_CHAR(datestamp, 'YYYY-MM-DD'));
  ELSIF timeInterval  = 3 THEN
       RETURN TReportInterval(TO_CHAR(datestamp, 'YYYY-WW'));
  ELSE
       RETURN NULL;
  END IF;
END;

Can't tell what TReportInterval does, so its hard to know what that module does.
I'd look at a PIPELINED PL/SQL function to replace GET_INTERVAL_SEQUENCE_UDF. The difficulty you will face with something like that is that the optimizer will never have a valid idea of how many rows it will return so it will often guess wrong.
A similar problem will arise with Get_Context_Info_udf. There's no obvious indication whether it will return 1 rows or 10,000. Again TTrfrmEngMachineInfo is totally opaque.
Bluntly, everything possible is being done to keep the optimizer ignorant of how to best action the query.
If the statistics table is the main one, I think you are filtering the table based on
 WHERE
      StatisticTypeID = HEXTORAW ('6CF933B091AE46FEA7F56BE96308190F')
      AND EntryDate < TO_TIMESTAMP ('07/20/2011','mm/dd/yyyy')
      AND EntryDate > TO_TIMESTAMP ('07/15/2011', 'mm/dd/yyyy')

summarising value_numeric based on Context_ID.
maybe some sort of summary across a date dimension (perhaps daily / weekly / monthly totals ?)
I'd try and get rid of as much PL/SQL as possible. Start with a simple query against statistics and describe what you want to do at each stage.

A: You can investigate where time is being spent and the execution plan Oracle chooses by following the advice in this OTN thread
Regards,
Rob.


text:
Q: Autoresize mask - pin top left corner of UIImageView The X is an image view, with parent UIScrollView. The X content mode is set to Aspect Fit.
4 inch
______
|    |
|    |
|X   |
|____|

When I switch between 4 inch to 3.5 inch display I want X to be pinned in the top left corner. Therefore, to my understanding I try to set the autoresize masks as following:

Now what happens instead, is that the X is pushed more to the centre. I would assume this is due to the fact that Aspect Fit tries to preserve ratio.
3.5 inch
______
|    |
| X  |
|____|

Is it possible to achieve this?
Edit after comments
In Storyboard/Interface Builder the VC Custom class is set to ContactVC, which is a subclass of UIViewController. It has one UIScrollview and an UIImageView subview created in IB, as already explained above. . In my ContactVC.m I override didLayoutSubviews or layoutSubviews but they are not getting called.
@implementation ContactViewController

-(void) viewDidLayoutSubviews {
    UIViewAutoresizing mask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [someImageView setAutoresizingMask:mask];
}

-(void) viewLayoutSubviews {
    UIViewAutoresizing mask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [someImageView setAutoresizingMask:mask];
}

A: It seems your autoresize mask is overridden later, after the view has been created with the autoresize mask from the xib.
Try to set your autoresize mask in layoutSubviews, or maybe in the view controller's viewDidLayoutSubviews.


text:
Q: Strange C program Latency behaviour A simple (vanila) DFT program was being written and an unusual behaviour was observed:
To recreate
Compile the following program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <complex.h>

#define N   16384
#define PI2  (2 * M_PI)  //6.2832

int main(void) {
    // time and frequency domain data arrays
    int n, k;             // indices for time and frequency domains
    float Xre[2000], Xim[2000]; // DFT of x (real and imaginary parts)
    float P[2000];           // power spectrum of x

    float x[N] = { 0 };

    // Generate 2*pi*50*t sine wave  in range (-1,+1)
    float y[] = {
        0.0, 0.0984079408900634, 0.195860568724094, 0.291411844321996, 0.384134186227703, 0.473127475375545, 0.557527793160445, 0.636515808085535, 0.709324729572274, 0.775247751720011, 0.833644914753334, 0.883949317548447, 0.925672620929349, 0.958409788309562, 0.981843017658750, 0.995744826623968,
        0.999980260856137, 0.994508204104035, 0.979381777357810, 0.954747823167273, 0.920845480141026, 0.878003861464755, 0.826638859974879, 0.767249110802900, 0.700411150783807, 0.626773821619470, 0.547051971129342, 0.462019513734716, 0.372501917543151, 0.279368190966096, 0.183522446661037, 0.0858951246927854,
        -0.0125660398833526, -0.110905217332694, -0.208167762132862, -0.303409480369524, -0.395705795671223, -0.484160724703344, -0.567915575089941, -0.646157281326779, -0.718126297763189, -0.783123972030169, -0.840519327335832, -0.889755187787833, -0.930353587280090, -0.961920409436037, -0.984149213565316, -0.996824209492737,
        -0.999822352380809, -0.993114537209969, -0.976765881320872, -0.950935092275919, -0.915872927176609, -0.871919758393194, -0.819502269337733, -0.759129312356960, -0.691386968955206, -0.616932860301177, -0.536489763250371, -0.450838593856768, -0.360810826487642, -0.267280422134304, -0.171155344276191, -0.0733687446595907,
        0.0251300954433374, 0.123384980555854, 0.220442083438833, 0.315359204542867, 0.407214918582441, 0.495117519440145, 0.578213676566644, 0.655696718842807, 0.726814465486903, 0.790876527986881, 0.847261012172933, 0.895420555368697, 0.934887640014398, 0.965279132178928, 0.986300000902440, 0.997746182263274,
        0.999506560365732, 0.991564046017929, 0.973995742628244, 0.946972197709905, 0.910755747259856, 0.865697969084168, 0.812236269792286, 0.750889638592492, 0.682253609109396, 0.606994478132532, 0.525842837418596, 0.439586481338564, 0.349062759219976, 0.255150446625443, 0.158761214478388, 0.0608307788510959,
        -0.0376901826699336, -0.135845259860259, -0.232681594384382, -0.327259129842054, -0.418659737537428, -0.505996129381040, -0.588420471400950, -0.665132614245854, -0.735387860781017, -0.798504195371694, -0.853868904674451, -0.900944525663825, -0.939274063152787, -0.968485426156976, -0.988295040035869, -0.998510599345391,
        -0.999032934678125, -0.989856975368447, -0.971071798716938, -0.942859765256222, -0.905494748452794, -0.859339476030335, -0.804842008724098, -0.742531390649502, -0.673012513509774, -0.596960244499286, -0.515112874907027, -0.428264953019107, -0.337259570896168, -0.242980179903264, -0.146342014444403, -0.0482832071574495,
        0.0502443181797695, 0.148284087623366, 0.244884362208849, 0.339107377130930, 0.430038445266602, 0.516794836667414, 0.598534347821637, 0.674463477498649, 0.743845129807025, 0.806005769687504, 0.860341961377560, 0.906326226374270, 0.943512164028194, 0.971538785059195, 0.990134015925798, 0.999117340028769,
        0.998401550108975, 0.987993594827769, 0.967994511311594, 0.938598444315629, 0.900090761528124, 0.852845283311457, 0.797320653772707, 0.734055888392230, 0.663665141432458, 0.586831743923250, 0.504301570101134, 0.416875796698963, 0.325403125376477, 0.230771543793960, 0.133899705309884, 0.0357280109856745,
        -0.0627905195293142, -0.160699499610071, -0.257048459953733, -0.350902075433899, -0.441349244940104, -0.527511936058200, -0.608553708730373, -0.683687835149718, -0.752184937064112, -0.813380066348762, -0.866679160111565, -0.911564807667102, -0.947601273395360, -0.974438726724819, -0.991816638176614, -0.999566308502021,
        -0.997612506361225, -0.985974198645282, -0.964764366351565, -0.934188907800099, -0.894544639838025, -0.846216416435848, -0.789673392647252, -0.725464470200735, -0.654212968935859, -0.576610575812079, -0.493410630231271, -0.405420810857945, -0.313495294931096, -0.218526466182705, -0.121436251859683, -0.0231671729467908,
        0.0753268055279309, 0.173089535282900, 0.269171966766988, 0.362641362231371, 0.452590350451546, 0.538145735199171, 0.618476971953920, 0.692804230566056, 0.760405965600031, 0.820625920868545, 0.872879500159325, 0.916659442309612, 0.951540745536515, 0.977184793219440, 0.993342641082758, 0.999857433867821,
        0.996665928034030, 0.983799105707054, 0.961381873914185, 0.929631852026567, 0.888857259179404, 0.839453922178432, 0.781901432938911, 0.716758492759546, 0.644657488627590, 0.566298354206707, 0.482441775103100, 0.393901804371106, 0.301537959944494, 0.206246880709201, 0.108953622217581, 0.0106026765427436,
        -0.0878511965507475, -0.185452238111593, -0.281252968206354, -0.374323383753877, -0.463759986700061, -0.548694554890174, -0.628302570493986, -0.701811224163148, -0.768506917219076, -0.827742189042424, -0.878942002415270, -0.921609325799925, -0.955329958363339, -0.979776550907327, -0.994711783670682, -0.999990670154097,
        -0.995561964603080, -0.981468659485473, -0.957847568134224, -0.924927996606965, -0.883029517655600, -0.832558868415444, -0.774006001930223, -0.707939330843420, -0.635000209428760, -0.555896707526464, -0.471396736825997, -0.382320596223098, -0.289533008618479, -0.193934726462339, -0.0964537875354998, 0.00196349414684702,
        0.100361714851215, 0.197785655882052, 0.293289556541649, 0.385946295274789, 0.474856389870597, 0.559156729350287, 0.638028952774654, 0.710707393632289, 0.776486512687080, 0.834727747129162, 0.884865709540016, 0.926413676494061, 0.958968313515203, 0.982213590519895, 0.995923849736900, 0.999965996321297,
        0.994300790396999, 0.978983227985015, 0.954162007119530, 0.920078084334595, 0.877062335534554, 0.825532343955807, 0.765988346401266, 0.699008377100263, 0.625242656335702, 0.545407278311946, 0.460277259539545, 0.370679015220949, 0.277482336674029, 0.181591947674010, 0.0839387216822394, -0.0145293547779467,
        -0.112856384873481, -0.210087841004649, -0.305279831056042, -0.397508261401654, -0.485877807712459, -0.569530606480889, -0.647654582887413, -0.719491334165196, -0.784343491933411, -0.841581492028159, -0.890649686111535, -0.931071735729352, -0.962455236453648, -0.984495527220340, -0.996978647882129, -0.999783416265704,
        -0.992882604569814, -0.976343203684123, -0.950325772862918, -0.915082881066822, -0.870956655103499, -0.818375458369187, -0.757849732432795, -0.689967041831200, -0.615386370179169, -0.534831722965621, -0.449085099138105, -0.358978899705249, -0.265387847051938, -0.169220493412062, -0.0714104009317734, 0.0270929210554974,
        0.125333233564306, 0.222356850821733, 0.317221898346202, 0.409007456365973, 0.496822499816019, 0.579814548126516, 0.657177940833683, 0.728161658675826, 0.792076614249970, 0.848302341453640, 0.896293018772879, 0.935582767944242, 0.965790176553122, 0.986622000664402, 0.997876011541515, 0.999442958818825,
        0.991307631069506, 0.973549003473241, 0.946339471150244, 0.909943175604153, 0.864713440520154, 0.811089341810776, 0.749591445206302, 0.680816752767877, 0.605432907381000, 0.524171711490274, 0.437822022993559, 0.347222097259867, 0.253251449612327, 0.156822317272532, 0.0588708036511916, -0.0396522090467458,
        -0.137790290684639, -0.234590747914437, -0.329113872621261, -0.420442064311573, -0.507688737887499, -0.590006930333573, -0.666597522764850, -0.736716998019437, -0.799684658487090, -0.854889234105571, -0.901794816376402, -0.939946060794457, -0.968972607187923, -0.988592675057273, -0.998615799010932, -0.998944677742839,
        -0.989576118602650, -0.970601068588971, -0.942203731464759, -0.904659779565662, -0.858333677660472, -0.803675144842848, -0.741214788801068, -0.671558954847019, -0.595383839708351, -0.513428927225288, -0.426489809676181, -0.335410464420208, -0.241075060833035, -0.144399377071172, -0.0463219099882471, 0.0522052354945227,
        0.150225589120753, 0.246787600408572, 0.340953876000616, 0.431810279581299, 0.518474806021958, 0.600106143606748, 0.675911841219724, 0.745156001208767, 0.807166423246402, 0.861341129837251, 0.907154210124478, 0.944160925265473, 0.972002025815363, 0.990407239206624, 0.999197893469363, 0.998288651722103,
        0.987688340595138, 0.967499864544408, 0.937919206887704, 0.899233527260826, 0.851818373962972, 0.796134038253055, 0.732721085988247, 0.662195109982227, 0.585240754025510, 0.502605066580843, 0.415090248673835, 0.323545866380009, 0.228860603507013, 0.131953634534243, 0.0337657015587562, -0.0647500181304328,
        -0.162637165194890, -0.258945482279751, -0.352740038810489, -0.443110307002175, -0.529179000974195, -0.610110593163201, -0.685119425359456, -0.753477335627384, -0.814520727070512, -0.867657009819546, -0.912370353706714, -0.948226695781328, -0.974877954055122, -0.992065406571739, -0.999622202997347, -0.997474984350731,
        -0.985644595148997, -0.964245881055618, -0.933486573995179, -0.893665275557789, -0.845168558269628, -0.788467212869540, -0.724111678021981, -0.652726696833165, -0.575005252043276, -0.491701838769995, -0.403625140109338, -0.311630176696852, -0.216610006438655, -0.119487054988758, -0.0212041611335505, 0.0772845759878599,
        0.175023058975285, 0.271062473657499, 0.364470499879154, 0.454340362168866, 0.539799632427741, 0.620018699184368, 0.694218821199767, 0.761679687240114, 0.821746408629595, 0.873835876701791, 0.917442423433567, 0.952142730309724, 0.977599937764792, 0.993566915308769, 0.999888660591489, 0.996503804116233,
        0.983445204995330, 0.960839631964316, 0.928906532751298, 0.887955903748049, 0.838385280663432, 0.780675879372910, 0.715387924427582, 0.643155210572020, 0.564678950066079, 0.480720965538817, 0.392096294456247, 0.299665276996257, 0.204325204139264, 0.107001607052153, 0.00863927232549537, -0.0898069297148414,
        -0.187381314585722, -0.283136661128381, -0.376143406830793, -0.465498671725509, -0.550335023261759, -0.629828897065438, -0.703208591840560, -0.769761760800563, -0.828842326904764, -0.879876754769274, -0.922369618366427, -0.955908410463418, -0.980167547111590, -0.994911528312078, -0.999997224175046, -0.995375264379227,
        -0.981090517443334, -0.957281655156723, -0.924179806397673, -0.882106313407595, -0.831469612302545, -0.772761268105050, -0.706551202786880, -0.633482162647440, -0.554263478736693, -0.469664180894493, -0.380505532252943, -0.287653056674601, -0.192008136521520, -0.0944992623213991, 0.00392698072380246, 0.102315101886539,
        0.199709980514407, 0.295166138038260, 0.387756916378113, 0.476583473645635, 0.560783509815936, 0.639539637662464, 0.712087317692860, 0.777722280055610, 0.835807361368273, 0.885778690097328, 0.927151160444101, 0.959523141597856, 0.982580376640236, 0.996099033251688, 0.999947876604571, 0.994089543349219,
        0.978580904325473, 0.953572512478617, 0.919307141339182, 0.876117428254551, 0.824422645251177, 0.764724628874819, 0.697602908520652, 0.623709080545813, 0.543760482778796, 0.458533230831479, 0.368854683815130, 0.275595412600709, 0.179660748593197, 0.0819819950616476, -0.0164926136573281, -0.114807117317581,
        -0.212007109922050, -0.307149004793269, -0.399309194613317, -0.487593017510555, -0.571143442153087, -0.649149387536929, -0.720853596702917, -0.785559987947003, -0.842640412160429, -0.891540750701937, -0.931786294605665, -0.962986352905092, -0.984838045336978, -0.997129242606799, -0.999740625672616, -0.992646844056464,
        -0.975916761938747, -0.949712789646630, -0.914289307026130, -0.869990194003309, -0.817245492307110, -0.756567230760720, -0.688544454668300, -0.613837507550104, -0.533171620737190, -0.447329873055838, -0.357145588946850, -0.263494248816364, -0.167284990149970, -0.0694517818945103, 0.0290556422159688, 0.127281003373913,
        0.224270760949379, 0.319083369159829, 0.410798417297745, 0.498525564785646, 0.581413184319829, 0.658656629197908, 0.729506044573661, 0.793273646809804, 0.849340400263315, 0.897162026686948, 0.936274288909695, 0.966297497503909, 0.986940196689757, 0.998001993695415, 0.999375504106507, 0.991047394319906,
        0.973098510982126, 0.945703096155735, 0.909127095832718, 0.863725578215192, 0.809939286825997, 0.748290361910482, 0.679377271664694, 0.603869002496122, 0.522498564715948, 0.436055876707622, 0.345380096649905, 0.251351476235615, 0.154882815467577, 0.0569106014859085, -0.0416140825518728, -0.139734790284324,
        -0.236498997023725, -0.330967346563474, -0.422222770149962, -0.509379389094972, -0.591591114604805, -0.668059861341758, -0.738043294983249, -0.800862038567848, -0.855906267671136, -0.902641630387714, -0.940614434649876, -0.969456052526198, -0.988886498744503, -0.998717148700020, -0.998852569563171, -0.989291446711198,
        -0.970126596490105, -0.941544065183020, -0.903821322931938, -0.857324570145646, -0.802505182542385, -0.739895329337642, -0.670102807114307, -0.593805139526380, -0.511743000114341, -0.424713022081554, -0.333560064831927, -0.239169012343003, -0.142456182993156, -0.0443604342336034, 0.0541659515417433, 0.152166511451484,
        0.248689887164858, 0.342799060386402, 0.433580449132212, 0.520152776493846, 0.601675625794849, 0.677357599089101, 0.746463999800899, 0.808323964926108, 0.862336977557309, 0.907978696511290, 0.944806046466880, 0.972461519199504, 0.990676644157565, 0.999274594689349, 0.998171904620035, 0.987379278514827,
        0.967001487762437, 0.937236353487686, 0.898372826166838, 0.850788180588052, 0.794944353387510, 0.731383458715156, 0.660722525562598, 0.583647507841499, 0.500906625360716, 0.413303100345869, 0.321687360012960, 0.226948780890808, 0.130007055036036, 0.0318032619544833, -0.0667092670999465, -0.164574203762531,
        -0.260841506289903, -0.354576642263842, -0.444869660735319, -0.530844025739510, -0.611665125428735, -0.686548374219374, -0.754766829299691, -0.815658247559921, -0.868631514438194, -0.913172382273058, -0.948848462456602, -0.975313422925793, -0.992310350244224, -0.999674243636218, -0.997333616761983, -0.985311191684313,
        -0.963723678290009, -0.932780641307352, -0.892782465918221, -0.844117441714098, -0.787257993303952, -0.722756094166077, -0.651237908264765, -0.573397711449273, -0.489991151644234, -0.401827913259485, -0.309763857030723, -0.214692711595228, -0.117537397457843, -0.0192410675716325, 0.0792420484915564, 0.176955907898970,
        0.272951935517313, 0.366298232379078, 0.456088622261896, 0.541451448559776, 0.621558036048674, 0.695630735402642, 0.762950472366612, 0.822863728301042, 0.874788884333453, 0.918221867529835, 0.952741044274703, 0.978011313356413, 0.993787359023354, 0.999916032431425, 0.996337838364386, 0.983087512794541,
        0.960293685676943, 0.928177632250618, 0.887051124968773, 0.837313406910770, 0.779447316057058, 0.714014598051266, 0.641650452951816, 0.563057368911361, 0.478998302644763, 0.390289272887461, 0.297791438744591, 0.202402739831719, 0.105049179362040, 0.00667583480114843, -0.0917623166451206, -0.189309668646243,
        -0.285019262469973, -0.377961979757159, -0.467235562107885, -0.551973369919598, -0.631352795449380, -0.704603248428773, -0.771013636709533, -0.829939269320517, -0.880808114923002, -0.923126354909364, -0.956483177237392, -0.980554764463184, -0.995107437258145, -0.999999922893717, -0.995184726672197, -0.980708592990188,
        -0.956712051558832, -0.923428053185976, -0.881179708363663, -0.830377150614053, -0.771513555043328, -0.705160350754312, -0.631961673594109, -0.552628113087742, -0.467929814260579, -0.378689001314870, -0.285771995738146, -0.190080806329236, -0.0925443727830621, 0.00589045216103947, 0.104268094465144, 0.201633535202275,
        0.297041581577028, 0.389566042557161, 0.478308720042225, 0.562408128285632, 0.641047856924812, 0.713464496433956, 0.778955049061354, 0.836883753308413, 0.886688255700559, 0.927885069936238, 0.960074270418487, 0.982943374605696, 0.996270376492941, 0.999925901775817, 0.993874463775118, 0.978174807930265,
        0.952979341517217, 0.918532654127013, 0.875169143267650, 0.823309768139218, 0.763457963095587, 0.696194750463496, 0.622173100162199, 0.542111590878786, 0.456787434334296, 0.367028930359057, 0.273707426020814, 0.177728856863960, 0.0800249523748130, -0.0184558089525184, -0.116757407144309, -0.213925561485702,
        -0.309016994374950, -0.401108588363064, -0.489306347484964, -0.572754075888567, -0.650641689512372, -0.722213080124420, -0.786773455380986, -0.843696083650190, -0.892428378123718, -0.932497261154178, -0.963513756742748, -0.985176766594716, -0.997275993086157, -0.999693980766518, -0.992407256578852, -0.975486557728811,
        -0.949096144990295, -0.913492208114000, -0.869020378818633, -0.816112375507883, -0.755281812285189, -0.687119212951036, -0.612286278385335, -0.531509462965285, -0.445572922376897, -0.355310901280419, -0.261599634727995, -0.165348841951888, -0.0674928950989053, 0.0310182513578315, 0.129228282475433, 0.226183806443067,
        0.320943609807221, 0.412587794473066, 0.500226707783204, 0.583009578983345, 0.660132778234681, 0.730847617997353, 0.794467621051437, 0.850375184599931, 0.898027575760620, 0.936962200244736, 0.966801093075418, 0.987254587751762, 0.998124128239275, 0.999304196488835, 0.990783336772423, 0.972644266891692,
        0.945063075179802, 0.908307511091783, 0.862734385977789, 0.808786109271773, 0.746986393721116, 0.677935171349503, 0.602302769507245, 0.520823403546116, 0.434288049289797, 0.343536764491561, 0.249450533820281, 0.152942716540872, 0.0549501799124448, -0.0435757956216944, -0.141678751162651, -0.238406334355361,
        -0.332819544522994, -0.424001848187439, -0.511068076485486, -0.593173018107150, -0.669519624338816, -0.739366746559169, -0.802036331074781, -0.856920001450147, -0.903484964433038, -0.941279182142260, -0.969935760307973, -0.989176509964781, -0.998814648021921, -0.998756610494226, -0.989002960791592, -0.969648384249581,
        -0.940880768954224, -0.902979381784135, -0.856312157376272, -0.801332126333271, -0.738573017346144, -0.668644075925549, -0.592224150039745, -0.510055100073975, -0.422934597085312, -0.331708379265198, -0.237262041781567, -0.140512439701961, -0.0423987874555876, 0.0561264587622677, 0.154106847132682, 0.250591215143780,
        0.344642923174507, 0.435348947094810, 0.521828741614001, 0.603242788335117, 0.678800745532949, 0.747769120540683, 0.809478390263939, 0.863329500698409, 0.908799682356035, 0.945447525145274, 0.972917263440128, 0.990942229739981, 0.999347443393019, 0.998051309252864, 0.987066409778365, 0.966499382887074,
        0.936549886748192, 0.897508661564435, 0.849754707158412, 0.793751603762675, 0.730043011729913, 0.659247393850829, 0.582052011513663, 0.499206252988763, 0.411514358605109, 0.319827613440464, 0.225036083316014, 0.128059974319935, 0.0298406997386746, -0.0686682588843781, -0.166510607845101, -0.262736524674396,
        -0.356411878713249, -0.446627299356684, -0.532507003934973, -0.613217299533782, -0.687974676220444, -0.756053413109658, -0.816792623431512, -0.869602670210485, -0.913970890274060, -0.949466571024084, -0.975745131657964, -0.992551468249736, -0.999722430218001, -0.997188404139995, -0.984973989536599, -0.963197760067995,
        -0.932071112458212, -0.891896214322823, -0.843063070821639, -0.786045738612394, -0.721397723859212, -0.649746608970392, -0.571787960227613, -0.488278575449232, -0.400029137237269, -0.307896343128008, -0.212774589044232, -0.115587286783459, -0.0172778998293627, 0.0811992154923688, 0.178888074602276, 0.274840345062014
    };
    float freq=0;
    float ind=0;
    float val = 0;
    float maxV = 0;

    int XN = sizeof(y) / sizeof(*y);

    for (k = 0; k < XN; k++) {
        x[k] = y[k];
    }

    struct timespec sT, eT;
    clock_gettime(CLOCK_MONOTONIC, &sT);

    printf("Starting DFT\n");
    // Calculate DFT of x using brute force
    for (k = 0; k < 2000; ++k) {
        // Real part of X[k]
        Xre[k] = 0;
        for (n = 0; n < XN; ++n)
            Xre[k] += x[n] * cos(n * k * PI2 / N);

        // Imaginary part of X[k]
        Xim[k] = 0;
        for (n = 0; n < XN; ++n)
            Xim[k] -= x[n] * sin(n * k * PI2 / N);

        // Power at kth frequency bin
        P[k] = Xre[k] * Xre[k] + Xim[k] * Xim[k];

        //  printf("\n%+f %+f %f",Xre[k],Xim[k],P[k]);
    }
    printf("DFT over\n");

    ind = 0;

    printf("Freq Compute start\n");
/*
    for (k = 0; k < 2000; k++) {
        //val = (Xre[k] * Xre[k]) + (Xim[k] * Xim[k]);
        val = P[k];

        if (val > maxV) {
            //printf("%f\n", val);
            maxV = val;
            ind = k;
        }
    }
    printf("Freq Compute over\n");

    freq = ind * 0.195;

    printf("maxV=%f ind = %f Freq= %f\n", maxV, ind, freq);
*/
    clock_gettime(CLOCK_MONOTONIC, &eT);

    printf("%ld.%09ld  %ld uSec\n",
           eT.tv_sec, eT.tv_nsec,
           ((eT.tv_sec - sT.tv_sec) * 1000000 + (eT.tv_nsec - sT.tv_nsec) / 1000));

    return 0;
}

with following compiler flag:

gcc -O3 DFT.c -o DFT_try -lm -lrt

This program takes just 3-5 us (micro seconds) to run on BeagleBone Black and even lesser on PC. Where as now,
if you uncomment the "Freq compute" part show below:
for (k=0;k<2000;k++)
{
    val = (Xre[k]*Xre[k])+(Xim[k]*Xim[k]);

    if(val> maxV){
        printf("%f",val);
        maxV = val;
        ind = k;
        a=val;
    }
}

to make the code look like the following:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <complex.h>

#define N   16384
#define PI2  (2 * M_PI)  //6.2832

int main(void) {
    // time and frequency domain data arrays
    int n, k;             // indices for time and frequency domains
    float Xre[2000], Xim[2000]; // DFT of x (real and imaginary parts)
    float P[2000];           // power spectrum of x

    float x[N] = { 0 };

    // Generate 2*pi*50*t sine wave  in range (-1,+1)
    float y[] = {
        //<Copy data HERE, from above program        };
    float freq=0;
    float ind=0;
    float val = 0;
    float maxV = 0;

    int XN = sizeof(y) / sizeof(*y);

    for (k = 0; k < XN; k++) {
        x[k] = y[k];
    }

    struct timespec sT, eT;
    clock_gettime(CLOCK_MONOTONIC, &sT);

    printf("Starting DFT\n");
    // Calculate DFT of x using brute force
    for (k = 0; k < 2000; ++k) {
        // Real part of X[k]
        Xre[k] = 0;
        for (n = 0; n < XN; ++n)
            Xre[k] += x[n] * cos(n * k * PI2 / N);

        // Imaginary part of X[k]
        Xim[k] = 0;
        for (n = 0; n < XN; ++n)
            Xim[k] -= x[n] * sin(n * k * PI2 / N);

        // Power at kth frequency bin
        P[k] = Xre[k] * Xre[k] + Xim[k] * Xim[k];

        //  printf("\n%+f %+f %f",Xre[k],Xim[k],P[k]);
    }
    printf("DFT over\n");

    ind = 0;

    printf("Freq Compute start\n");

    for (k = 0; k < 2000; k++) {
        //val = (Xre[k] * Xre[k]) + (Xim[k] * Xim[k]);
        val = P[k];

        if (val > maxV) {
            //printf("%f\n", val);
            maxV = val;
            ind = k;
        }
    }
    printf("Freq Compute over\n");

    freq = ind * 0.195;

    printf("maxV=%f ind = %f Freq= %f\n", maxV, ind, freq);

    clock_gettime(CLOCK_MONOTONIC, &eT);

    printf("%ld.%09ld  %ld uSec\n",
           eT.tv_sec, eT.tv_nsec,
           ((eT.tv_sec - sT.tv_sec) * 1000000 + (eT.tv_nsec - sT.tv_nsec) / 1000));

    return 0;
}

and then recompile it, as above
This program will take humongous time of 16198709 uSec or even more to run on BeagleBone Black and approx 0.001 sec on 64bit modern system(s) as stated by chqrlie in comments
Can anyone tell Why such odd behaviour?

A: When you comment the block of code, the compiler can determine that you do not use any of the computation results in the first loop and removes all the code, leaving a simple output statement:
maxV = 0;
ind = 0;
freq = 0;
printf("maxV=%f ind = %f Freq= %f\n", maxV, ind, freq);

If you uncomment the loop, ind is computed from the complex values Xre[k] and Xim[k] computed in the first loop, so it must compute these too, hence a much longer computation time, although not as long as you mention (1s on my laptop).
Note that a more aggressive optimizer would determine that the computation can be performed at compile time and produce a trivial program that executes as fast in both cases.  To avoid protentially infinite compile times, such a compiler would set a timeout and give up after a while, but it only takes 1 second on my laptop to run the full code.
There are more problems in your code:

*

*you should use a more precise value for 2*PI: 2 * M_PI.

*there are only 960 values in the y array. entries in the x array are zero all the way to 16383.  The computation can be simplified: the inner loops can be stopped at the size of y.

*you compute P[k] in the first loop but you do not use it in the second loop.
If you reduce the value of N to the size of y, the computation is much faster.  It runs 20 times faster on my system:
maxV=228694.692537 ind = 257.000000 Freq= 50.115000
2115850.697709000  47955 uSec

Regarding the huge difference between the Beaglebone system and a 64-bit modern PC, the embedded processor does not seem to have a floating point unit, making the computation times much slower, even as float.  Note that on the PC, computing as double is actually sightly faster than float due to fewer conversions.
Here is the updated code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <complex.h>

#define N   16384
#define PI2  (2 * M_PI)  //6.2832

int main(void) {
    // time and frequency domain data arrays
    int n, k;             // indices for time and frequency domains
    float a = 1.09;  // unused: b = 2.098;
    float Xre[2000], Xim[2000]; // DFT of x (real and imaginary parts)
    float P[2000];           // power spectrum of x

    float x[N] = { 0 };

    // Generate random discrete-time signal x in range (-1,+1)
    float y[] = {
        0.0, 0.0984079408900634, 0.195860568724094, 0.291411844321996, 0.384134186227703, 0.473127475375545, 0.557527793160445, 0.636515808085535, 0.709324729572274, 0.775247751720011, 0.833644914753334, 0.883949317548447, 0.925672620929349, 0.958409788309562, 0.981843017658750, 0.995744826623968,
        0.999980260856137, 0.994508204104035, 0.979381777357810, 0.954747823167273, 0.920845480141026, 0.878003861464755, 0.826638859974879, 0.767249110802900, 0.700411150783807, 0.626773821619470, 0.547051971129342, 0.462019513734716, 0.372501917543151, 0.279368190966096, 0.183522446661037, 0.0858951246927854,
        -0.0125660398833526, -0.110905217332694, -0.208167762132862, -0.303409480369524, -0.395705795671223, -0.484160724703344, -0.567915575089941, -0.646157281326779, -0.718126297763189, -0.783123972030169, -0.840519327335832, -0.889755187787833, -0.930353587280090, -0.961920409436037, -0.984149213565316, -0.996824209492737,
        -0.999822352380809, -0.993114537209969, -0.976765881320872, -0.950935092275919, -0.915872927176609, -0.871919758393194, -0.819502269337733, -0.759129312356960, -0.691386968955206, -0.616932860301177, -0.536489763250371, -0.450838593856768, -0.360810826487642, -0.267280422134304, -0.171155344276191, -0.0733687446595907,
        0.0251300954433374, 0.123384980555854, 0.220442083438833, 0.315359204542867, 0.407214918582441, 0.495117519440145, 0.578213676566644, 0.655696718842807, 0.726814465486903, 0.790876527986881, 0.847261012172933, 0.895420555368697, 0.934887640014398, 0.965279132178928, 0.986300000902440, 0.997746182263274,
        0.999506560365732, 0.991564046017929, 0.973995742628244, 0.946972197709905, 0.910755747259856, 0.865697969084168, 0.812236269792286, 0.750889638592492, 0.682253609109396, 0.606994478132532, 0.525842837418596, 0.439586481338564, 0.349062759219976, 0.255150446625443, 0.158761214478388, 0.0608307788510959,
        -0.0376901826699336, -0.135845259860259, -0.232681594384382, -0.327259129842054, -0.418659737537428, -0.505996129381040, -0.588420471400950, -0.665132614245854, -0.735387860781017, -0.798504195371694, -0.853868904674451, -0.900944525663825, -0.939274063152787, -0.968485426156976, -0.988295040035869, -0.998510599345391,
        -0.999032934678125, -0.989856975368447, -0.971071798716938, -0.942859765256222, -0.905494748452794, -0.859339476030335, -0.804842008724098, -0.742531390649502, -0.673012513509774, -0.596960244499286, -0.515112874907027, -0.428264953019107, -0.337259570896168, -0.242980179903264, -0.146342014444403, -0.0482832071574495,
        0.0502443181797695, 0.148284087623366, 0.244884362208849, 0.339107377130930, 0.430038445266602, 0.516794836667414, 0.598534347821637, 0.674463477498649, 0.743845129807025, 0.806005769687504, 0.860341961377560, 0.906326226374270, 0.943512164028194, 0.971538785059195, 0.990134015925798, 0.999117340028769,
        0.998401550108975, 0.987993594827769, 0.967994511311594, 0.938598444315629, 0.900090761528124, 0.852845283311457, 0.797320653772707, 0.734055888392230, 0.663665141432458, 0.586831743923250, 0.504301570101134, 0.416875796698963, 0.325403125376477, 0.230771543793960, 0.133899705309884, 0.0357280109856745,
        -0.0627905195293142, -0.160699499610071, -0.257048459953733, -0.350902075433899, -0.441349244940104, -0.527511936058200, -0.608553708730373, -0.683687835149718, -0.752184937064112, -0.813380066348762, -0.866679160111565, -0.911564807667102, -0.947601273395360, -0.974438726724819, -0.991816638176614, -0.999566308502021,
        -0.997612506361225, -0.985974198645282, -0.964764366351565, -0.934188907800099, -0.894544639838025, -0.846216416435848, -0.789673392647252, -0.725464470200735, -0.654212968935859, -0.576610575812079, -0.493410630231271, -0.405420810857945, -0.313495294931096, -0.218526466182705, -0.121436251859683, -0.0231671729467908,
        0.0753268055279309, 0.173089535282900, 0.269171966766988, 0.362641362231371, 0.452590350451546, 0.538145735199171, 0.618476971953920, 0.692804230566056, 0.760405965600031, 0.820625920868545, 0.872879500159325, 0.916659442309612, 0.951540745536515, 0.977184793219440, 0.993342641082758, 0.999857433867821,
        0.996665928034030, 0.983799105707054, 0.961381873914185, 0.929631852026567, 0.888857259179404, 0.839453922178432, 0.781901432938911, 0.716758492759546, 0.644657488627590, 0.566298354206707, 0.482441775103100, 0.393901804371106, 0.301537959944494, 0.206246880709201, 0.108953622217581, 0.0106026765427436,
        -0.0878511965507475, -0.185452238111593, -0.281252968206354, -0.374323383753877, -0.463759986700061, -0.548694554890174, -0.628302570493986, -0.701811224163148, -0.768506917219076, -0.827742189042424, -0.878942002415270, -0.921609325799925, -0.955329958363339, -0.979776550907327, -0.994711783670682, -0.999990670154097,
        -0.995561964603080, -0.981468659485473, -0.957847568134224, -0.924927996606965, -0.883029517655600, -0.832558868415444, -0.774006001930223, -0.707939330843420, -0.635000209428760, -0.555896707526464, -0.471396736825997, -0.382320596223098, -0.289533008618479, -0.193934726462339, -0.0964537875354998, 0.00196349414684702,
        0.100361714851215, 0.197785655882052, 0.293289556541649, 0.385946295274789, 0.474856389870597, 0.559156729350287, 0.638028952774654, 0.710707393632289, 0.776486512687080, 0.834727747129162, 0.884865709540016, 0.926413676494061, 0.958968313515203, 0.982213590519895, 0.995923849736900, 0.999965996321297,
        0.994300790396999, 0.978983227985015, 0.954162007119530, 0.920078084334595, 0.877062335534554, 0.825532343955807, 0.765988346401266, 0.699008377100263, 0.625242656335702, 0.545407278311946, 0.460277259539545, 0.370679015220949, 0.277482336674029, 0.181591947674010, 0.0839387216822394, -0.0145293547779467,
        -0.112856384873481, -0.210087841004649, -0.305279831056042, -0.397508261401654, -0.485877807712459, -0.569530606480889, -0.647654582887413, -0.719491334165196, -0.784343491933411, -0.841581492028159, -0.890649686111535, -0.931071735729352, -0.962455236453648, -0.984495527220340, -0.996978647882129, -0.999783416265704,
        -0.992882604569814, -0.976343203684123, -0.950325772862918, -0.915082881066822, -0.870956655103499, -0.818375458369187, -0.757849732432795, -0.689967041831200, -0.615386370179169, -0.534831722965621, -0.449085099138105, -0.358978899705249, -0.265387847051938, -0.169220493412062, -0.0714104009317734, 0.0270929210554974,
        0.125333233564306, 0.222356850821733, 0.317221898346202, 0.409007456365973, 0.496822499816019, 0.579814548126516, 0.657177940833683, 0.728161658675826, 0.792076614249970, 0.848302341453640, 0.896293018772879, 0.935582767944242, 0.965790176553122, 0.986622000664402, 0.997876011541515, 0.999442958818825,
        0.991307631069506, 0.973549003473241, 0.946339471150244, 0.909943175604153, 0.864713440520154, 0.811089341810776, 0.749591445206302, 0.680816752767877, 0.605432907381000, 0.524171711490274, 0.437822022993559, 0.347222097259867, 0.253251449612327, 0.156822317272532, 0.0588708036511916, -0.0396522090467458,
        -0.137790290684639, -0.234590747914437, -0.329113872621261, -0.420442064311573, -0.507688737887499, -0.590006930333573, -0.666597522764850, -0.736716998019437, -0.799684658487090, -0.854889234105571, -0.901794816376402, -0.939946060794457, -0.968972607187923, -0.988592675057273, -0.998615799010932, -0.998944677742839,
        -0.989576118602650, -0.970601068588971, -0.942203731464759, -0.904659779565662, -0.858333677660472, -0.803675144842848, -0.741214788801068, -0.671558954847019, -0.595383839708351, -0.513428927225288, -0.426489809676181, -0.335410464420208, -0.241075060833035, -0.144399377071172, -0.0463219099882471, 0.0522052354945227,
        0.150225589120753, 0.246787600408572, 0.340953876000616, 0.431810279581299, 0.518474806021958, 0.600106143606748, 0.675911841219724, 0.745156001208767, 0.807166423246402, 0.861341129837251, 0.907154210124478, 0.944160925265473, 0.972002025815363, 0.990407239206624, 0.999197893469363, 0.998288651722103,
        0.987688340595138, 0.967499864544408, 0.937919206887704, 0.899233527260826, 0.851818373962972, 0.796134038253055, 0.732721085988247, 0.662195109982227, 0.585240754025510, 0.502605066580843, 0.415090248673835, 0.323545866380009, 0.228860603507013, 0.131953634534243, 0.0337657015587562, -0.0647500181304328,
        -0.162637165194890, -0.258945482279751, -0.352740038810489, -0.443110307002175, -0.529179000974195, -0.610110593163201, -0.685119425359456, -0.753477335627384, -0.814520727070512, -0.867657009819546, -0.912370353706714, -0.948226695781328, -0.974877954055122, -0.992065406571739, -0.999622202997347, -0.997474984350731,
        -0.985644595148997, -0.964245881055618, -0.933486573995179, -0.893665275557789, -0.845168558269628, -0.788467212869540, -0.724111678021981, -0.652726696833165, -0.575005252043276, -0.491701838769995, -0.403625140109338, -0.311630176696852, -0.216610006438655, -0.119487054988758, -0.0212041611335505, 0.0772845759878599,
        0.175023058975285, 0.271062473657499, 0.364470499879154, 0.454340362168866, 0.539799632427741, 0.620018699184368, 0.694218821199767, 0.761679687240114, 0.821746408629595, 0.873835876701791, 0.917442423433567, 0.952142730309724, 0.977599937764792, 0.993566915308769, 0.999888660591489, 0.996503804116233,
        0.983445204995330, 0.960839631964316, 0.928906532751298, 0.887955903748049, 0.838385280663432, 0.780675879372910, 0.715387924427582, 0.643155210572020, 0.564678950066079, 0.480720965538817, 0.392096294456247, 0.299665276996257, 0.204325204139264, 0.107001607052153, 0.00863927232549537, -0.0898069297148414,
        -0.187381314585722, -0.283136661128381, -0.376143406830793, -0.465498671725509, -0.550335023261759, -0.629828897065438, -0.703208591840560, -0.769761760800563, -0.828842326904764, -0.879876754769274, -0.922369618366427, -0.955908410463418, -0.980167547111590, -0.994911528312078, -0.999997224175046, -0.995375264379227,
        -0.981090517443334, -0.957281655156723, -0.924179806397673, -0.882106313407595, -0.831469612302545, -0.772761268105050, -0.706551202786880, -0.633482162647440, -0.554263478736693, -0.469664180894493, -0.380505532252943, -0.287653056674601, -0.192008136521520, -0.0944992623213991, 0.00392698072380246, 0.102315101886539,
        0.199709980514407, 0.295166138038260, 0.387756916378113, 0.476583473645635, 0.560783509815936, 0.639539637662464, 0.712087317692860, 0.777722280055610, 0.835807361368273, 0.885778690097328, 0.927151160444101, 0.959523141597856, 0.982580376640236, 0.996099033251688, 0.999947876604571, 0.994089543349219,
        0.978580904325473, 0.953572512478617, 0.919307141339182, 0.876117428254551, 0.824422645251177, 0.764724628874819, 0.697602908520652, 0.623709080545813, 0.543760482778796, 0.458533230831479, 0.368854683815130, 0.275595412600709, 0.179660748593197, 0.0819819950616476, -0.0164926136573281, -0.114807117317581,
        -0.212007109922050, -0.307149004793269, -0.399309194613317, -0.487593017510555, -0.571143442153087, -0.649149387536929, -0.720853596702917, -0.785559987947003, -0.842640412160429, -0.891540750701937, -0.931786294605665, -0.962986352905092, -0.984838045336978, -0.997129242606799, -0.999740625672616, -0.992646844056464,
        -0.975916761938747, -0.949712789646630, -0.914289307026130, -0.869990194003309, -0.817245492307110, -0.756567230760720, -0.688544454668300, -0.613837507550104, -0.533171620737190, -0.447329873055838, -0.357145588946850, -0.263494248816364, -0.167284990149970, -0.0694517818945103, 0.0290556422159688, 0.127281003373913,
        0.224270760949379, 0.319083369159829, 0.410798417297745, 0.498525564785646, 0.581413184319829, 0.658656629197908, 0.729506044573661, 0.793273646809804, 0.849340400263315, 0.897162026686948, 0.936274288909695, 0.966297497503909, 0.986940196689757, 0.998001993695415, 0.999375504106507, 0.991047394319906,
        0.973098510982126, 0.945703096155735, 0.909127095832718, 0.863725578215192, 0.809939286825997, 0.748290361910482, 0.679377271664694, 0.603869002496122, 0.522498564715948, 0.436055876707622, 0.345380096649905, 0.251351476235615, 0.154882815467577, 0.0569106014859085, -0.0416140825518728, -0.139734790284324,
        -0.236498997023725, -0.330967346563474, -0.422222770149962, -0.509379389094972, -0.591591114604805, -0.668059861341758, -0.738043294983249, -0.800862038567848, -0.855906267671136, -0.902641630387714, -0.940614434649876, -0.969456052526198, -0.988886498744503, -0.998717148700020, -0.998852569563171, -0.989291446711198,
        -0.970126596490105, -0.941544065183020, -0.903821322931938, -0.857324570145646, -0.802505182542385, -0.739895329337642, -0.670102807114307, -0.593805139526380, -0.511743000114341, -0.424713022081554, -0.333560064831927, -0.239169012343003, -0.142456182993156, -0.0443604342336034, 0.0541659515417433, 0.152166511451484,
        0.248689887164858, 0.342799060386402, 0.433580449132212, 0.520152776493846, 0.601675625794849, 0.677357599089101, 0.746463999800899, 0.808323964926108, 0.862336977557309, 0.907978696511290, 0.944806046466880, 0.972461519199504, 0.990676644157565, 0.999274594689349, 0.998171904620035, 0.987379278514827,
        0.967001487762437, 0.937236353487686, 0.898372826166838, 0.850788180588052, 0.794944353387510, 0.731383458715156, 0.660722525562598, 0.583647507841499, 0.500906625360716, 0.413303100345869, 0.321687360012960, 0.226948780890808, 0.130007055036036, 0.0318032619544833, -0.0667092670999465, -0.164574203762531,
        -0.260841506289903, -0.354576642263842, -0.444869660735319, -0.530844025739510, -0.611665125428735, -0.686548374219374, -0.754766829299691, -0.815658247559921, -0.868631514438194, -0.913172382273058, -0.948848462456602, -0.975313422925793, -0.992310350244224, -0.999674243636218, -0.997333616761983, -0.985311191684313,
        -0.963723678290009, -0.932780641307352, -0.892782465918221, -0.844117441714098, -0.787257993303952, -0.722756094166077, -0.651237908264765, -0.573397711449273, -0.489991151644234, -0.401827913259485, -0.309763857030723, -0.214692711595228, -0.117537397457843, -0.0192410675716325, 0.0792420484915564, 0.176955907898970,
        0.272951935517313, 0.366298232379078, 0.456088622261896, 0.541451448559776, 0.621558036048674, 0.695630735402642, 0.762950472366612, 0.822863728301042, 0.874788884333453, 0.918221867529835, 0.952741044274703, 0.978011313356413, 0.993787359023354, 0.999916032431425, 0.996337838364386, 0.983087512794541,
        0.960293685676943, 0.928177632250618, 0.887051124968773, 0.837313406910770, 0.779447316057058, 0.714014598051266, 0.641650452951816, 0.563057368911361, 0.478998302644763, 0.390289272887461, 0.297791438744591, 0.202402739831719, 0.105049179362040, 0.00667583480114843, -0.0917623166451206, -0.189309668646243,
        -0.285019262469973, -0.377961979757159, -0.467235562107885, -0.551973369919598, -0.631352795449380, -0.704603248428773, -0.771013636709533, -0.829939269320517, -0.880808114923002, -0.923126354909364, -0.956483177237392, -0.980554764463184, -0.995107437258145, -0.999999922893717, -0.995184726672197, -0.980708592990188,
        -0.956712051558832, -0.923428053185976, -0.881179708363663, -0.830377150614053, -0.771513555043328, -0.705160350754312, -0.631961673594109, -0.552628113087742, -0.467929814260579, -0.378689001314870, -0.285771995738146, -0.190080806329236, -0.0925443727830621, 0.00589045216103947, 0.104268094465144, 0.201633535202275,
        0.297041581577028, 0.389566042557161, 0.478308720042225, 0.562408128285632, 0.641047856924812, 0.713464496433956, 0.778955049061354, 0.836883753308413, 0.886688255700559, 0.927885069936238, 0.960074270418487, 0.982943374605696, 0.996270376492941, 0.999925901775817, 0.993874463775118, 0.978174807930265,
        0.952979341517217, 0.918532654127013, 0.875169143267650, 0.823309768139218, 0.763457963095587, 0.696194750463496, 0.622173100162199, 0.542111590878786, 0.456787434334296, 0.367028930359057, 0.273707426020814, 0.177728856863960, 0.0800249523748130, -0.0184558089525184, -0.116757407144309, -0.213925561485702,
        -0.309016994374950, -0.401108588363064, -0.489306347484964, -0.572754075888567, -0.650641689512372, -0.722213080124420, -0.786773455380986, -0.843696083650190, -0.892428378123718, -0.932497261154178, -0.963513756742748, -0.985176766594716, -0.997275993086157, -0.999693980766518, -0.992407256578852, -0.975486557728811,
        -0.949096144990295, -0.913492208114000, -0.869020378818633, -0.816112375507883, -0.755281812285189, -0.687119212951036, -0.612286278385335, -0.531509462965285, -0.445572922376897, -0.355310901280419, -0.261599634727995, -0.165348841951888, -0.0674928950989053, 0.0310182513578315, 0.129228282475433, 0.226183806443067,
        0.320943609807221, 0.412587794473066, 0.500226707783204, 0.583009578983345, 0.660132778234681, 0.730847617997353, 0.794467621051437, 0.850375184599931, 0.898027575760620, 0.936962200244736, 0.966801093075418, 0.987254587751762, 0.998124128239275, 0.999304196488835, 0.990783336772423, 0.972644266891692,
        0.945063075179802, 0.908307511091783, 0.862734385977789, 0.808786109271773, 0.746986393721116, 0.677935171349503, 0.602302769507245, 0.520823403546116, 0.434288049289797, 0.343536764491561, 0.249450533820281, 0.152942716540872, 0.0549501799124448, -0.0435757956216944, -0.141678751162651, -0.238406334355361,
        -0.332819544522994, -0.424001848187439, -0.511068076485486, -0.593173018107150, -0.669519624338816, -0.739366746559169, -0.802036331074781, -0.856920001450147, -0.903484964433038, -0.941279182142260, -0.969935760307973, -0.989176509964781, -0.998814648021921, -0.998756610494226, -0.989002960791592, -0.969648384249581,
        -0.940880768954224, -0.902979381784135, -0.856312157376272, -0.801332126333271, -0.738573017346144, -0.668644075925549, -0.592224150039745, -0.510055100073975, -0.422934597085312, -0.331708379265198, -0.237262041781567, -0.140512439701961, -0.0423987874555876, 0.0561264587622677, 0.154106847132682, 0.250591215143780,
        0.344642923174507, 0.435348947094810, 0.521828741614001, 0.603242788335117, 0.678800745532949, 0.747769120540683, 0.809478390263939, 0.863329500698409, 0.908799682356035, 0.945447525145274, 0.972917263440128, 0.990942229739981, 0.999347443393019, 0.998051309252864, 0.987066409778365, 0.966499382887074,
        0.936549886748192, 0.897508661564435, 0.849754707158412, 0.793751603762675, 0.730043011729913, 0.659247393850829, 0.582052011513663, 0.499206252988763, 0.411514358605109, 0.319827613440464, 0.225036083316014, 0.128059974319935, 0.0298406997386746, -0.0686682588843781, -0.166510607845101, -0.262736524674396,
        -0.356411878713249, -0.446627299356684, -0.532507003934973, -0.613217299533782, -0.687974676220444, -0.756053413109658, -0.816792623431512, -0.869602670210485, -0.913970890274060, -0.949466571024084, -0.975745131657964, -0.992551468249736, -0.999722430218001, -0.997188404139995, -0.984973989536599, -0.963197760067995,
        -0.932071112458212, -0.891896214322823, -0.843063070821639, -0.786045738612394, -0.721397723859212, -0.649746608970392, -0.571787960227613, -0.488278575449232, -0.400029137237269, -0.307896343128008, -0.212774589044232, -0.115587286783459, -0.0172778998293627, 0.0811992154923688, 0.178888074602276, 0.274840345062014
    };
    float freq;
    float ind;
    float val = 0;
    float maxV = 0;

    int XN = sizeof(y) / sizeof(*y);

    for (k = 0; k < XN; k++) {
        x[k] = y[k];
    }

    struct timespec sT, eT;
    clock_gettime(CLOCK_MONOTONIC, &sT);

    printf("Starting DFT\n");
    // Calculate DFT of x using brute force
    for (k = 0; k < 2000; ++k) {
        // Real part of X[k]
        Xre[k] = 0;
        for (n = 0; n < XN; ++n)
            Xre[k] += x[n] * cos(n * k * PI2 / N);

        // Imaginary part of X[k]
        Xim[k] = 0;
        for (n = 0; n < XN; ++n)
            Xim[k] -= x[n] * sin(n * k * PI2 / N);

        // Power at kth frequency bin
        P[k] = Xre[k] * Xre[k] + Xim[k] * Xim[k];

        //  printf("\n%+f %+f %f",Xre[k],Xim[k],P[k]);
    }
    printf("DFT over\n");

    ind = 0;

#if 1
    printf("Freq Compute start\n");

    for (k = 0; k < 2000; k++) {
        //val = (Xre[k] * Xre[k]) + (Xim[k] * Xim[k]);
        val = P[k];

        if (val > maxV) {
            //printf("%f\n", val);
            maxV = val;
            ind = k;
            a = val;
        }
    }
    printf("Freq Compute over\n");

#endif

    freq = ind * 0.195;

    printf("maxV=%f ind = %f Freq= %f\n", maxV, ind, freq);

    clock_gettime(CLOCK_MONOTONIC, &eT);

    printf("%ld.%09ld  %ld uSec\n",
           eT.tv_sec, eT.tv_nsec,
           ((eT.tv_sec - sT.tv_sec) * 1000000 + (eT.tv_nsec - sT.tv_nsec) / 1000));

    return 0;
}