text:
Q: Lazzy Listbox in windows phone I'm using the very popular LazyListBox from Peter Torr.
<lazy:LazyListBox x:name="lazy"> // cause error
    <lazy:LazyListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Number}"></TextBlock>
        </DataTemplate>
    </lazy:LazyListBox.ItemTemplate>
    <lazy:LazyListBox.LoadedItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Number}"></TextBlock>
                <Image Source="{Binding ImageUri}"></Image>
            </StackPanel>
        </DataTemplate>
    </lazy:LazyListBox.LoadedItemTemplate> </lazy:LazyListBox>

It gives me an error when i assigned name to listbox.
The type 'UIExtensionMethods.ISupportOffsetChanges' is defined in an assembly that is not referenced. You must add a reference to assembly 'UIExtensionMethods, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. D:\projectEG\Size4u(day1)\Size4u\Size4u\obj\Debug\Size4uView\HomePage.g.cs

A: You should add the reference to the dll in the project.
In Visual studio project explorer search for "References" and Add Reference.. Now i'm at phone so i don't remember the names bur search for references list.


text:
Q: Error while Initialization of character array I initialized my array like this:
    char x[]={'m'};
It worked.
But for the following lines i got error:Size of the type is unknown or zero
char x[][]={{'m'},{'m'}};

or
char x[][]={{'m'}};

I am unable to find the reason of the error.

A: While defining a 2D array, specifying the column size is mandatory.
char x[][1]={{'m'}};

A: You have to set the number of columns. The compiler calculates the number of rows:
char x[][1]={{'m'},{'m'}};

A: In c you must specify the right most array size, so putting
char x[][1];

would work

A: For row major architecture, you should specify at least the number of columns. Why? Because, when you assign the values, the compiler has no idea how to assign them in the 2D array.
So, as others have already said, try this:
char x[][1]={{'m'}};

or
char x[1][1]={{'m'}}; // note: specifying the number of rows is redundant

redpajama_set_name: RedPajamaStackExchange


text:
Q: Remove a String Section from a file in python, with dynamic string matching? Hi i have a big xml(See in end) file which is dynamically generated every time.
So what i want to do is delete a particular section of line but the thing is see the following example:
Out of the big xml file i need to delete this particular section through python:
<p:modifyVerifier cryptProviderType="rsaAES" cryptAlgorithmClass="hash" cryptAlgorithmType="typeAny" cryptAlgorithmSid="14" spinCount="100000" saltData="B8OqF9PY5YtJrJhHXdG2rg=="
 hashData="28wWrnLt7bZyEQJkDW3eIf0gkY8cGlJtMcy0fr4VoBQREbp2gg4l8d7H3vzTx8F3KsGCxys8pGz/n0lv+G9XOg=="/>

But here the hashData and saltData changes every time so hard-coded string matching approach wont work!
<p:modifyVerifier cryptProviderType="rsaAES" cryptAlgorithmClass="hash" cryptAlgorithmType="typeAny" cryptAlgorithmSid="14" spinCount="100000" saltData="9cRceofvEcHNy86qpf/jaA=="
 hashData="CWQjhCx80vjXRgWTJZCylIHIghBgLpWkcSlcBOZ8dNu5bMdqSCRoW0gt/8mM0jRN429HRrA+Ix4TRtAtQtrTag=="/>

And also this is not a different line i.e it is joint string without spaces.
For example there are more data before and after of the string without any space example:
</p:defaultTextStyle><p:modifyVerifier cryptProviderType="rsaAES" cryptAlgorithmClass="hash" cryptAlgorithmType="typeAny" cryptAlgorithmSid="14" spinCount="100000" saltData="B8OqF9PY5YtJrJhHXdG2rg==" hashData="28wWrnLt7bZyEQJkDW3eIf0gkY8cGlJtMcy0fr4VoBQREbp2gg4l8d7H3vzTx8F3KsGCxys8pGz/n0lv+G9XOg=="/><p:extLst>

Notice the </p:defaultTextStyle> without space before the <p:modifyVerifier I need the </p:defaultTextStyle> and remove the section mentioned above and also need the code afterwards.
So how do i first match a string with the following section with dynamically changing string in python!
So normal hard-coding of string and matching wont work!
And also how do i delete the section after finding it from the xml file python.
this is the full file
<?xml version="1.0" encoding="UTF-8"?>
<p:presentation xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" showSpecialPlsOnTitleSld="0" saveSubsetFonts="1">
   <p:sldMasterIdLst>
      <p:sldMasterId id="2147483648" r:id="rId1" />
   </p:sldMasterIdLst>
   <p:notesMasterIdLst>
      <p:notesMasterId r:id="rId15" />
   </p:notesMasterIdLst>
   <p:handoutMasterIdLst>
      <p:handoutMasterId r:id="rId16" />
   </p:handoutMasterIdLst>
   <p:sldIdLst>
      <p:sldId id="569" r:id="rId2" />
      <p:sldId id="362" r:id="rId3" />
      <p:sldId id="560" r:id="rId4" />
      <p:sldId id="561" r:id="rId5" />
      <p:sldId id="566" r:id="rId6" />
      <p:sldId id="562" r:id="rId7" />
      <p:sldId id="563" r:id="rId8" />
      <p:sldId id="565" r:id="rId9" />
      <p:sldId id="564" r:id="rId10" />
      <p:sldId id="567" r:id="rId11" />
      <p:sldId id="568" r:id="rId12" />
      <p:sldId id="540" r:id="rId13" />
      <p:sldId id="557" r:id="rId14" />
   </p:sldIdLst>
   <p:sldSz cx="9144000" cy="6858000" type="screen4x3" />
   <p:notesSz cx="6858000" cy="9144000" />
   <p:defaultTextStyle>
      <a:defPPr>
         <a:defRPr lang="en-US" />
      </a:defPPr>
      <a:lvl1pPr marL="0" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl1pPr>
      <a:lvl2pPr marL="457200" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl2pPr>
      <a:lvl3pPr marL="914400" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl3pPr>
      <a:lvl4pPr marL="1371600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl4pPr>
      <a:lvl5pPr marL="1828800" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl5pPr>
      <a:lvl6pPr marL="2286000" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl6pPr>
      <a:lvl7pPr marL="2743200" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl7pPr>
      <a:lvl8pPr marL="3200400" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl8pPr>
      <a:lvl9pPr marL="3657600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
         <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
               <a:schemeClr val="tx1" />
            </a:solidFill>
            <a:latin typeface="+mn-lt" />
            <a:ea typeface="+mn-ea" />
            <a:cs typeface="+mn-cs" />
         </a:defRPr>
      </a:lvl9pPr>
   </p:defaultTextStyle>
   <p:modifyVerifier cryptProviderType="rsaAES" cryptAlgorithmClass="hash" cryptAlgorithmType="typeAny" cryptAlgorithmSid="14" spinCount="100000" saltData="B8OqF9PY5YtJrJhHXdG2rg==" hashData="28wWrnLt7bZyEQJkDW3eIf0gkY8cGlJtMcy0fr4VoBQREbp2gg4l8d7H3vzTx8F3KsGCxys8pGz/n0lv+G9XOg==" />
   <p:extLst>
      <p:ext uri="{EFAFB233-063F-42B5-8137-9DF3F51BA10A}">
         <p15:sldGuideLst xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main">
            <p15:guide id="1" orient="horz" pos="2160">
               <p15:clr>
                  <a:srgbClr val="A4A3A4" />
               </p15:clr>
            </p15:guide>
            <p15:guide id="2" pos="2880">
               <p15:clr>
                  <a:srgbClr val="A4A3A4" />
               </p15:clr>
            </p15:guide>
         </p15:sldGuideLst>
      </p:ext>
      <p:ext uri="{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}">
         <p15:notesGuideLst xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" />
      </p:ext>
   </p:extLst>
</p:presentation>

A: This is an approach i found by asking on r/regex on redit.
This is the regex i need to use:
regex = r"<p:modifyVerifier[^>]+>"
Hence the code will be
import re
file = open("my_file.xml", "r")
s =file.read()
file.close()
new_s = re.sub(r"<p:modifyVerifier[^>]+>", '',s)
file1 = open("new_file.xml", "w+")
file1.write(new_s)
file1.close()


text:
Q: Why am i getting a discrepancy in memory usage in my C application? How can I understand the discrepancy between the 21 MiB of private memory bytes reported for my C application by ps_mem and the much smaller numbers reported by valgrind for current allocations.

System monitor shows below readings.

I've also used ps_mem to check used memory.

Running proc/2101/smaps outputs the following. 4432 is the pid of my application.


text:
Q: Does a Parent's onAreaTouched Trigger the Child's? I have a sprite with an attached child right next to it. When touched the image is rotated 180 degrees, but to keep the image in place I only have the parent call rotate. This means that if the child is touched, it calls its parent's rotate. This works fine when the child is touched, but I found that if the parent is touched, then the child's onAreaTouched() is called as well, which then calls the parent's rotate, which undoes the rotate.
I can't find in the code anything that says the children's onAreaTouched() is called when a parent's, but is that what's happening?

A: Here I consider Scene as a parent object and Rectangle as a child object.
Scene mScene = new Scene();
mScene.setOnSceneTouchListener(this);

Rectangle rectangle = new Rectangle(x,y,width,height){
     public boolean onAreaTouch(){
          if(pSceneTouchEvent.isActionDown()){
               return true;
          }
          return false;
     }
};

mScene.registerTouchArea(rectangle);
mScene.attachChile(rectangle);

public boolean onSceneTouchEvent(){
      if(pSceneTouchEvent.isActionDown()){
           return true;
      } else if(pSceneTouchEvent.isActionUp()){
           return true;
      }
      return false;
}

In the above code snippet I write all the basic things those are necessary for understanding this concept. Here rectangle is a child of scene. Rectangle contains area touch with three events action down,move and up. I return true in only action down event so parent object action down event doesn't called.
For all other event of child object I return false, so its parent object perform remaining to action such as move and up action.
If child object return directly true to onAreaTouch method then parent object scene touch method does not call at all. This was a small example through which I tried to explain this concept.


text:
Q: How do I return the custom metaData from firebase storage, using the admin.storage() method so I am trying to add image moderation to my firebase app, using this guide here here is the repo and this also might be useful. I tested it out and it seems to work well, however I wanted to update the same image from storage, not upload it to a separate path. This caused the firebase function to fire recursively and I cost my company a couple of dollars. To solve this I decided whenever an image is uploaded there would be custom metadata saying if it has been blurred or not. The code for this is down below and works.
const metaData = {
           customMetadata: {
              blurred: 'false',
          },
      }

const imageBytes = await uploadBytesResumable(storageRef, blobFile, metaData);

Now in my firebase function every time an image is uploaded it will check the object.metaData to see if it is equal to 'true'. Here is the code down below for that.
export const blurOffensiveImages = functions.storage.object().onFinalize(async (object) => {
// Ignore things we've already blurred
if (object.metadata?.customMetadata.blurred === 'true') {
    functions.logger.log(`meta datas are the same, stopping function`);
    return null;
}

If the metadata is equal to false then it will run the normal function and check if the image is worth blurring. If it is then all it does is change the metadata to true since this will stop the recursion.
My problem, I am having type errors saying 'Property "blurred' does not exist on type 'string'".  I have played around with this for a while and cant seem to find a solution to get the customMetaData to come out the way I would like. If i remove the .blurred I get no errors but I also know this would not give the correct data when I check if it is equal to 'true'or 'false'. If anyone knows how to fix this that would be really appreciated. OR if someone has a good solution to stop this recurson from happening that would also be great since this has been giving me issues for a few days. Thanks!


text:
Q: JQuery mobile clicking inside Collapsible adds ui-mobile-viewport-transitioning viewport-slidefade to body, which hides the ability to scroll Weirdest thing, using JQuery Mobile 1.2.0.  When a user travels to a page with a collapsible, clicking anywhere inside that collapsible div except on buttons adds ui-mobile-viewport-transitioning viewport-slidefade to the body, which is freezing the pane and hiding the scroll bar, and snapping the view to the top of the page.  Before click :

After clicking inside a collapsible (Not anywhere else):

If I f5 and reload the page, it doesn't do this anymore.  Only after following a link.
Example of a link that leads to the page :

Info here

This is happening on every single page across our entire mobile application, no matter the browser.  iOS, Android, Chrome on PC, Firefox on PC, etc.


text:
Q: How to populate laravel SELECT default value from the database Hi i'm using laravel collective, im trying to load the selected default value from the datbase
// $ring->homepage
// holds 0 or 1
{!! Form::select('onhome', [0 => 'Nee', 1 => 'Ja'], null, ['class' => 'form-control selectpicker']) !!}

According to the documentation this should work
{!! Form::select('onhome', [0 => 'Nee', 1 => 'Ja'], $ring->homepage, ['class' => 'form-control selectpicker']) !!}

But it's not working

It still shows 0 => 'Nee' while it is 1 => 'Ja'
Am i doing something wrong?

A: The value matches, but the key doesn't. The key has to match with the value in $ring->homepage, so you either have to change the keys to 'Ja' and 'Nee', or the value $ring->homepage to an integer (0 or 1 in this case).


text:
Q: Joomla Accessing getModules datastructure From this
jimport( 'joomla.application.module.helper' );
$modules = JModuleHelper::getModules( 'top' );
echo '<pre>';
print_r( $modules );
echo '</pre>';

which outputs this structure
Array
(
    [0] => stdClass Object
        (
            [id] => 25
            [title] => Newsflash
            [module] => mod_newsflash
            [position] => top
            [content] =>
            [showtitle] => 1
            [control] =>
            [params] => catid=3
style=random
items=
moduleclass_sfx=
            [user] => 0
            [name] => newsflash
            [style] =>
        )

)

I currently call this function to get it to output it
<?=$modules[0]->content ?>

I would like to call with one line but it doesnt work
<?=JModuleHelper::getModules( 'top' )[0]->content ?>

I can do it on the singular version of getmodule and it works, it works because its not wrapped in an array.
<?=JModuleHelper::getModule( 'top' )->content ?>

Anybody know how to drill down on this data structure with one line of code?

A: PHP's reset() resets the internal pointer of the array and returns the first element.
Therefore,
$modules = reset(JModuleHelper::getModules( 'top' ))->content;

will get the first element's content.
This will fail, however, if an empty array is returned by JModuleHelper, for obvious reasons. Unfortunately, it will not fail quietly, since reset() returns false when provided with an empty array.


text:
Q: Python import csv and randomly select rows and print with other random values Sorry but im new to Python.
Ive created a Colab notebook using Python to import a CSV. I want it to randomly select 3 rows from the CSV. The problem is that it keeps selecting the same row. How do i get it to randomly select 3 rows and print it together with another random value?
My code so far:
import csv
import random

names = ['Name 1', 'Name 2','Name 3','Name 4','Name 5', 'Name 6', 'Name
7','Name 8', 'Name 9', 'Name 10']

with open('Sheet.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)

next(csv_reader) #skips header in csv

chosen_row = random.choice(list(csv_reader))

paraone = (chosen_row[1])

for num in range (3):
  area = random.choice(names)

  print(f'{area}\n{paraone}\n')

That outputs:
Name 10
this is paragraph 10
Name 5
this is paragraph 10
Name 1
this is paragraph 10
But what i want is something like:
Name 10
this is paragraph 2
Name 5
this is paragraph 8
Name 1
this is paragraph 10
My csv is like this:

A: Try adding a Seed to the random function.
random.seed()

You can read more here: https://pynative.com/python-random-seed/


text:
Q: Can't find Github Timeline API
https://developer.github.com/v3/
I read this document and try called most of APIs.
but I can't find the API that I needed.
If you have any information about this API, please share it with me.

A: It's called "Activity", and here is the API documentation:
https://developer.github.com/v3/activity/


text:
Q: Search for a string in all of the files in git's staging area and all those files changed but not staged I am trying to search for a string (e.g. search for string "TODO") in all of my files which are changed locally. That includes files which were already staged and those that are changed but are not added to staging area yet.

A: Answering my own question. I was able to do it with the following command
git diff --name-only | xargs grep 'My search string goes here'

A: The correct answer would be
git diff-index -S{STRINGTOSEARCH} -u HEAD
newly added files have to be added to staging through
git add path/to/filename
searches the intented string in only added/removed strings.

A: I found the -S{STRING} version rather hard to use since regex are not straight forward. An easier version for me is to pipe the output into grep and use it's pattern matching:
git diff-index --cached -u HEAD | grep -i string

Or for multiple strings at the same time:
git diff-index --cached -u HEAD | grep -i -e string1 -e string2 -e string3

-i is for case insensitivity and -e is to add more patterns.
You can add this as an alias to your rc and check for your personal details for every commit if you want.

A: Here is a bash snippet that works on Debian to accomplish this:
for file in `git status -s -uno`
        do
                if [[ ! $file =~ [A-Z] ]]; then
                        echo "$file"
                        grep -n "TODO" $file
                fi
        done

Explanation:
git status -s -uno is short form of git status but excludes untracked files.
The if condition in the for loop skips over the status part of git status -s to avoid searching through files that don't exist.
Finally the -n option ot grep prints the line numbers. Simply change TODO to whatever you want to find.
I imagine it ought to work on git-bash in windows too...


text:
Q: htaccess reverse directory It is possible to let htaccess look for a specific file related to the url and go back one step if not found?
Example:

/example/here/where/from

Htaccess looks if the '/example/here/where/from' is indeed a file of some sort(/example/here/where/from.php) if this fails it goes back one step and checks if ' '/example/here/where' is a file(/example/here/where.php) and so forth.
If it had to go back in the tree assume them as parameters as in:
/example/here.php
$_GET['params'] = 'where/from';
Thanks in advance
Edit:
spelling

A: This is very tricky but here is a code that recursively traverse to parent dir of the given REQUEST_URI and it supports infinite depth.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
# don't do anything
RewriteRule ^ - [L]

# if current ${REQUEST_URI}.php is not a file then
# forward to the parent directory of current REQUEST_URI
RewriteCond %{DOCUMENT_ROOT}/$1/$2.php !-f
RewriteRule ^(.*?)/([^/]+)/?$ $1/ [L]

# if current ${REQUEST_URI}.php is a valid file then
# load it be removing optional trailing slash
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

Explanation:
Let's say original URI is: /index/foo/bar/baz. Also let's say that %{DOCUMENT_ROOT}/index.php exists but no other php files exist under DOCUMENT_ROOT.
RewriteRule #1 has a regex that is breaking current REQUEST_URI into 2 parts:

*

*All but lowest subdir into $1 which will be index/foo/bar here

*Lowest subdir into $2 which will be baz here

RewriteCond checks whether %{DOCUMENT_ROOT}/$1/$2.php (which translates to whether %{DOCUMENT_ROOT}/index/foo/bar/baz.php) is NOT a valid file.
If condition succeeds then it is internally redirected to $1/ which is index/foo/bar/ here.
RewriteRule #1's logic is repeated again to make REQUEST_URI as (after each recursion):

*

*index/foo/bar/

*index/foo/

*index/
At this point RewriteCond fails for rule # 1 because ${DOCUMENT_ROOT}/index.php exists there.
My RewriteRule #2 says forward to $1.php if %{DOCUMENT_ROOT}/$1.php is a valid file. Note that RewriteRule #2 has regex that matches everything but last slash and puts it into $1. This means checking whether %{DOCUMENT_ROOT}/index.php is a valid file (and it indeed is).
At this point mod_rewrite processing is complete as no further rule can be fired since both RewriteCond fails after that, therefore %{DOCUMENT_ROOT}/index.php gets duly served by your Apache web server.


text:
Q: Cut string in android Hi guys i have a string:
String a = "234 - 456";

I want cut this string and assign the first number in int firstnumber and second number a int secondnumber.
is possible?
P.S 123 and 456 are dinamyc number!
The numbers are separated with a " - "
Thank you

A: You can use str.split(); Example:
String a = "234 - 456";
String[] strings = a.split(" - ");
// Then you can parse them
// You may want to do a check here to see if the user entered real numbers or not
// This is only needed for user input, if the numbers are hard coded you don't need this, although it doesn't hurt to have it
int firstNumber = 0; // Assign them before hand so you can use them after the try catch
int secondNumber = 0;
try {
    firstNumber = Integer.parseInt(strings[0]); // firstNumber becomes 234
    secondNumber = Integer.parseInt(strings[1]); // secondNumber becomes 456
} catch(NumberFormatException e) {
    System.out.println("Please enter real numbers!");
}

A: You will want to put validation code in for each step. You want to know the value you have is good.
if(a!=null &&a.Contains(" - ")) {
     String[] separated = CurrentString.split(" - ");
}

separated[0]; // This will contain the first number
separated[1]; //  This will contain the second number

Edit
int valueOne= 0;
int valueTwo= 0;
try {
    valueOne = Integer.parseInt(strings[0]); // firstNumber becomes 234
    valueTwo = Integer.parseInt(strings[1]); // secondNumber becomes 456
} catch(NumberFormatException e) {
    System.out.println("Please enter real numbers!");
}

A: Below should work, use split() function:
String[] strArray = input.split(" - ");
int[] intArray = new int[strArray.length];
for(int i = 0; i < strArray.length; i++) {
    intArray[i] = Integer.parseInt(strArray[i]);
}

int intA = intArray[0];
int intB = intArray[1];

A: String[] parts = a.split(" - ");
int[] numb = new int[parts.length];
for(int n = 0; n < parts.length; n++) {
   numb[n] = Integer.parseInt(parts[n]);
}
firstnumber = numb[0];
secondnumber = numb[1];

A: To separate your string you should use a StringTokenIzer and make with a "-" as a delimiter and make sure to trim the token you got.
String a = "234 - 456";

        int number_1 = 0, number_2 = 0;

        StringTokenizer stringTokenizer = new StringTokenizer(a, "-");

        if(stringTokenizer.hasMoreTokens()){

            number_1 =  Integer.valueOf(stringTokenizer.nextToken().trim()).intValue();
            number_2 =  Integer.valueOf(stringTokenizer.nextToken().trim()).intValue();

        }


text:
Q: When does $\det(I+G^\top A^{-1}G) \leq \det(I+G^\top D^{-1}G) $ hold? Let $A$ be a SPD matrix, let $D$ be the diagonal of $A$, and let $G$ be an arbitrary matrix of the proper size (not necessarily full rank). Do we have the following inequality$$\det(I+G^\top A^{-1}G) \leq \det(I+G^\top D^{-1}G) $$
I feel like this is not true. We can surely prove that $\det(A^{-1})\leq \det(D^{-1})$, but I don't know if this the inequality hold in general.
Also, if this is not true,  what condition do we have to impose to $G, A, D$ for this inequality to hold?

A: The A produced by @user1551, namely $A=\begin{pmatrix}
2 &2\\
1 & 2\\
\end{pmatrix}$ combined with $G = I$, produces a counterexample:
$\det(I+G^T A^{-1}G) = 8/3 > 9/4 = \det(I+G^T D^{-1}G)$
$\det(I+G^T A^{-1}G) \le \det(I+G^T D^{-1}G)$ is trivially true when $G =$ zero matrix and/or $A$ is a diagonal matrix.


text:
Q: Serve http server behind an Apache https Proxy It seems that it is possible to get Apache server to Proxy and Manage SSL handshake on https requests and service them as 'http' thru another server behind it.
I have configured an apache server for ProxyPass using following configuration
SSLProxyEngine On
ProxyPass / http://localhost:8081/
ProxyPassReverse / http://localhost:8081/

I am able to get all all traffic to the apache server that is listening to port 8080 direct and serve by the localhost:8081 server so
http://localhost:8080/hi is being correctly served by http://localhost:8081/hi

However the following does not work :
http**s**://localhost:8080/hi to be served by http://localhost:8081/hi

Apache is trying to pass the https:// traffic to the 8081 server, without managing the SSL handshake.

A: Your Apache listener on port 8080 is an http listener, not an https listener.  You can't handle both types of traffic on the same port.  If you want to handle SSL traffic, you'll need to set up a new context on another port with SSLEngine On and all the other normal SSL configuration (certificate, key, etc).
This question has one version of this configuration.
Also this post.


text:
Q: HTML/Javascript-Why I can't use offsetTop for div inside tables ? The offsetTop property should return the absolute position of a object. It works nice when I use objects out of tables, but if the object is inside a table it returns always 1. Why it happens and how to avoid it ?
See the problems sample:
http://jsfiddle.net/6Y7qp/

a

b in table

 <button onclick="document.getElementById('p').innerHTML='offsetTop:\na='+document.getElementById('a').offsetTop+'\nb='+document.getElementById('b').offsetTop">Show Off Set Top</button>

In this sample, I need to get "a" and "b" offsetTop, but it always return 1 for "b" in my firefox and chrome browsers

A: Because that's the way it's supposed to work. As MDN states:

offsetTop returns the distance of the current element relative to
  the top of the offsetParent node.

What's the offsetParent you say? Glad you asked:

offsetParent returns a reference to the object which is the closest
  (nearest in the containment hierarchy) positioned containing element.
  If the element is non-positioned, the nearest table cell or root element (html in standards compliant mode; body in quirks rendering
  mode) is the offsetParent.

One way around this is to just set a position on the div in the table cell via:
td div {
    position:relative;
}

jsFiddle example


text:
Q: Can we show $\text E\left[X\mid\mathcal F_\sigma\right]=\text E\left[X\mid\mathcal F_{\sigma\:\wedge\:\tau}\right]$ on $\{\sigma\le\tau\}$? Let $I\subseteq\overline{\mathbb R}$, $(\mathcal F_t)_{t\in I}$ be a filtration on a probability space $(\Omega,\mathcal A,\operatorname P)$ and $\sigma,\tau:\Omega\to I\cup\{\sup I\}$ be $(\mathcal F_t)_{t\in I}$-stopping times. Moreover, let $\mathcal F_\tau$ denote the $\sigma$-algebra of the $\tau$-past, i.e. $$\mathcal F_\tau=\{A\in\mathcal A:A\cap\{\tau\le t\}\in\mathcal F_t\},$$ and $\left.\mathcal F\right|_A:=\{A\cap B:B\in\mathcal F\}$ denote the trace of a $\sigma$-algebra $\mathcal F$ on a set $A$.

Now, if $X$ is an integrable random variable on $(\Omega,\mathcal A,\operatorname P)$, are we able to show that $$\operatorname E\left[X\mid\mathcal F_\sigma\right]=\operatorname E\left[X\mid\mathcal F_{\sigma\:\wedge\:\tau}\right]\tag1$$ on $\{\sigma\le\tau\}$?

Since $$\left.\mathcal F_{\sigma}\right|_{\{\:\sigma\:\le\:\tau\:\}}=\left.\mathcal F_{\sigma\:\wedge\:\tau}\right|_{\{\:\sigma\:\le\:\tau\:\}}\tag1,$$ the desired claim would immediately follow from the the local property of conditional expectation if we could show that $\{\sigma\le\tau\}\in\mathcal F_\sigma$ and $\{\sigma\le\tau\}\in\mathcal F_{\sigma\:\wedge\:\tau}$.
Now $\mathcal F_{\sigma\:\wedge\:\tau}\subseteq\mathcal F_\sigma$. So, it is sufficient to show $\{\sigma\le\tau\}\in\mathcal F_{\sigma\:\wedge\:\tau}$. But is this really true?

A: Proof of $\{\sigma \leq \tau\} \in \mathcal F_{\sigma \wedge \tau}$:
We have to show that $\{\sigma \leq \tau\} \cap \{\sigma \wedge \tau \leq t\}  \in \mathcal F_t$ for all $t$.
Write this as $$\{\tau >t, \sigma \leq t\} \cup \{\sigma \leq t, \tau \leq t, \sigma \leq \tau\} $$
(by considering the cases $\tau \leq t$ and $\tau >t$).
Now,  $\{\sigma \leq t, \tau \leq t, \sigma \leq \tau\}=\{\sigma \leq t, \tau \leq t\} \setminus \{\sigma \leq t, \tau \leq t, \sigma > \tau\}$.
Finally, write $\{\sigma \leq t, \tau \leq t, \sigma > \tau\}$ as $$\bigcup_{r \in \mathbb Q, r <t} \{\sigma \leq t, \tau \leq t, \sigma > r>\tau\} \,.$$
Since $\{\sigma \leq t, \tau \leq t, \sigma > r>\tau\}$ is the intersection of $\{\sigma \leq t\}, \{\tau \leq t\}, \{\sigma > r\}$ and $\{\tau <r\}$ we are done. [The last event is the union over $n$ of $\tau \leq r-\frac 1  n$].


text:
Q: How can I get the max value from one column where values match another column? I have a very large dataframe where one column has a set of names in it. Unfortunately, the same column also has some other data there. What I want to do is to find all the rows that contain the names, look for those in another column, get the max value from a third column. Then, I need to place that value in the same row as the name.
I'm currently using a for loop, which does exactly what I want, but it is extremely slow. I've tried fooling around with lookup but can't get it to work. Just bear in mind that the real dataframe has something like 20,000 rows!
import pandas as pd
import numpy as np

friends = ['Mickey', 'Minnie', 'Goofy', 'Donald', 'Daisy', 'Pluto']

df_data = {'Name':['Mickey', 'Ravens', 'Vikings',
                    'Minnie', 'Packers', 'Browns',
                    'Goofy', 'Cowboys', 'Steelers',
                    'Donald', '49ers', 'Bears',
                    'Daisy', 'Chiefs', 'Raiders',
                    'Pluto', 'Patriots', 'Colts'],
        'Owner': [np.nan, 'Mickey', 'Mickey',
                    np.nan, 'Minnie', 'Minnie',
                    np.nan, 'Goofy', 'Goofy',
                    np.nan, 'Donald', 'Donald',
                    np.nan, 'Daisy', 'Daisy',
                    np.nan, 'Pluto', 'Pluto'],
        'Wins': [np.nan, 14, 10,
                np.nan, 13, 6,
                np.nan, 8, 8,
                np.nan, 13, 8,
                np.nan, 12, 7,
                np.nan, 12, 7]}

df = pd.DataFrame(data = df_data)

for f in friends:
    df.loc[df['Name'] == f, 'Wins'] = df.loc[df['Owner'] == f, 'Wins'].max()

print(df.to_string())

A: IIUC, you can use
df['Wins'].update(df['Name'].map(df.groupby('Owner')['Wins'].max()))

A: Use, DataFrame.groupby on Owner then use the agg function max to create a mapping series s, Now using the series s update the values in Wins column in df using Series.update:
s = df.groupby('Owner')['Wins'].max()
df = df.set_index('Name')
df['Wins'].update(s)
df = df.reset_index()

# print(df)
        Name   Owner  Wins
0     Mickey     NaN  14.0
1     Ravens  Mickey  14.0
2    Vikings  Mickey  10.0
3     Minnie     NaN  13.0
4    Packers  Minnie  13.0
5     Browns  Minnie   6.0
6      Goofy     NaN   8.0
7    Cowboys   Goofy   8.0
8   Steelers   Goofy   8.0
9     Donald     NaN  13.0
10     49ers  Donald  13.0
11     Bears  Donald   8.0
12     Daisy     NaN  12.0
13    Chiefs   Daisy  12.0
14   Raiders   Daisy   7.0
15     Pluto     NaN  12.0
16  Patriots   Pluto  12.0
17     Colts   Pluto   7.0


text:
Q: Approximating a Gaussian Integral: Can you do better? I have attempted to approximate this Gaussian:

$$
I =\int_{0}^{\lambda}dx\left(r+x\right)\exp\left(-\rho\left(ax^{1/2}+bx^{3/2}\right)\right)\
$$

using

$$
I =\int_{0}^{\lambda}dx\left(r+x\right)e^{-\rho\left(ax^{1/2}\right)}\left(1-b\rho x^{3/2}\right)\
$$

where the exponent

$$
ax^{1/2}+bx^{3/2}\
$$

is only really an approximation to a much more complicated function, valid for small $x$ (hence the approximation in the second equation).
The question is, I may well be loosing too much accuracy by making this approximation. Can anyone think of a clever or simply better way to approximate $I$? Or is my approximation the best I can do, given the conditions?

A: If you have only a few of these integrals to do, or if you want to evaluate a few "benchmarks" to test a self-written software implementation, then I'd recommend an interactive CAS with numeric capabilities such as Maxima or Sage.
You would only be able to develop a competitive numerical integration routine under special circumstances, e.g. possessing knowledge of the integrand that can be exploited for improved approximation.  The theory of numerical integration (quadrature) is not deep and is often treated in introductory numerical analysis courses.  But coding and testing of adaptive quadrature routines has reached a high state of the art in many off-the-shelf libraries.  Why reinvent the wheel?
What does make sense is to take a close look at the parameters of your integral to see if some of them can be removed or combined.  For example, the parameter $r$ appears in a relatively trivial way:
$$ I =\int_{0}^{\lambda} \exp\left(-\rho\left(ax^{1/2}+bx^{3/2}\right)\right)
 \left(r+x\right) dx $$
$$ = r \int_{0}^{\lambda} \exp\left(-\rho\left(ax^{1/2}+bx^{3/2}\right)\right) dx
 + \int_{0}^{\lambda} \exp\left(-\rho\left(ax^{1/2}+bx^{3/2}\right)\right)  x dx  $$
Furthermore $\rho$ can obviously be combined with $a$ and $b$, so that using $A = \rho a$ and $B = \rho b$ the integrals can be rewritten in the forms:
$$ \int_{0}^{\lambda} \exp\left(-Ax^{1/2}-Bx^{3/2}\right) x^k dx $$
for $k=0,1$, and both integrals have three parameters: $\lambda, A, B$.  We can go further and make a substitution $u = \lambda x$ to remove the variable upper limit of integration, but since you've indicated this was only a simplified version of the integrals, I won't try to carry the discussion (of parameter reduction) to a final conclusion.
Some open source (GPL licensed) numerical integration routines are available in C, derived from Fortran routines written for QUADPACK (in the public domain, available in Netlib).
In some situations, perhaps where the number of parameters can be reduced to one or two, you might be able to fit a polynomial or rational approximation to a finite set of values produced with high-precision adaptive quadrature routines, and thus replace the overhead of calling the quadrature routines themselves with calls to these efficient approximations.


text:
Q: How to prevent select statement to return output In a query I have multiple lines of statements like the one bellow:
set @query = '';
select @query := concat(@query, ' union (select \'',bi.param2,'\' as tableName, ',bi.param3,' id, ', bi.param4, ' text from ', bi.param2,' where ',if(TRIM(bi.param5) is null, '1=1', bi.param5),')')
from itmanagement.BasicInfo bi where bi.param2 != '';
set @query := concat(SUBSTR(@query, 7, LENGTH(@query)));
set @wholeQuery := concat('select pe.*, bi.title label
, (case when bi.param1 = \'textfield\' then pe.ElemValue else od.text end) text
 from PRC_PcdElements pe join BasicInfo bi on pe.ElemType = bi.InfoID join
 (',@query,")
 od on bi.param2 = od.tableName and pe.ElemValue = od.id
 where bi.TypeID = 3 and pe.ProcedureID = '2';");
prepare stmt1 from @wholeQuery ;
execute stmt1 ;

This query returns two columns. One for the first select statement, which is just an assigning statement, and the output of exec statement which is the desired one.
I want to prevent first select statement to print out a table to the output or replace it with a better command if available.

A: You can try the following solution, using the SELECT ... INTO syntax:
SET @query = '';
SELECT CONCAT(@query, ' UNION(SELECT \'',bi.param2,'\' AS tableName, ',bi.param3,' id, ', bi.param4, ' text FROM ', bi.param2,' WHERE ', IF(TRIM(bi.param5) IS NULL, '1=1', bi.param5),')') INTO @query
FROM itmanagement.BasicInfo bi WHERE bi.param2 != '' LIMIT 1;
SET @query := CONCAT(SUBSTR(@query, 7, LENGTH(@query)));
SET @wholeQuery := CONCAT('SELECT pe.*, bi.title label
 , (CASE WHEN bi.param1 = \'textfield\' THEN pe.ElemValue ELSE od.text END) text
 FROM PRC_PcdElements pe JOIN BasicInfo bi ON pe.ElemType = bi.InfoID JOIN
 (',@query,")
 od ON bi.param2 = od.tableName AND pe.ElemValue = od.id
WHERE bi.TypeID = 3 AND pe.ProcedureID = '2';");
PREPARE stmt1 FROM @wholeQuery;
EXECUTE stmt1;

You can set the @query variable with a statement like this (without output):
SELECT column_name INTO @query FROM table_name WHERE condition = true LIMIT 1

A: You can create a temporary table and insert-select the desired result into it. Also, you can select your query into a cursor, iterate it and build up the variable you need.


text:
Q: Local subdomains for a standalone application I have a website, which is composed by three smaller 'independent' subsites:

*

*mysite

*

*index.html

*favicons

*images

*doc

*

*index.html

*css

*img

*js

*...

*editor

*

*index.html

*images

*js

*src

*...

Where doc is a site created with Hugo :: A fast and modern static website engine, editor is the mxgraph Graphditor example; and the remaining files make a hand-made landing page.
Besides deploying to any web server, I'd like to distribute the site as an 'standalone application'. To allow so, I wrote this really simple server in go:
package main

import (
  flag "github.com/ogier/pflag"
  "fmt"
  "net/http"
  "net/http/httputil"
  "os"
  "path/filepath"
)

var port = flag.IntP("port", "p", 80, "port to serve at")
var dir = flag.StringP("dir", "d", "./", "dir to serve from")
var verb = flag.BoolP("verbose", "v", false, "")

func init() {
  flag.Parse();
}

type justFilesFilesystem struct {
  fs http.FileSystem;
}
type neuteredReaddirFile struct {
  http.File
}

func (fs justFilesFilesystem) Open(name string) (http.File, error) {
  f, err := fs.fs.Open(name)
  if err != nil { return nil, err; }
  return neuteredReaddirFile{f}, nil
}

func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
  return nil, nil;
}

func loggingHandler(h http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        requestDump, err := httputil.DumpRequest(r, true)
        if err != nil { fmt.Println(err); }
        fmt.Println(string(requestDump))
        h.ServeHTTP(w, r)
    })
}

func main() {
  str, err := filepath.Abs(*dir)
  if err != nil { os.Exit(1); }
  fmt.Printf("Serving at port %d from dir %s\n\n",*port,str)

  http.ListenAndServe(fmt.Sprintf(":%d",*port), loggingHandler(http.FileServer(justFilesFilesystem{http.Dir(*dir)})))
}

As a result, I can run simpleserver -d <path-to-mysite> and browse the sites through localhost, localhost/doc and localhost/editor.
Then, I'd like to use custom (sub)domain(s) such as mylocal.app, doc.mylocal.app and editor.mylocal.app. So, I added the following line to my the /etc/hosts file: 127.0.0.1   mylocal.app. Therefore, I can browse mylocal.app, mylocal.app/editor and mylocal.app/doc. Moreover, I was able to change it to mylocal.app, mylocal.app:<editor-port> and mylocal.app:<doc-port> with different packages.
However, when I try to use a subdomain, it is not properly resolved, so any reverse-proxy strategy won't work. Since wildcards are not supported, I can add additional entries in the /etc/hosts file, but I'd prefer to avoid it.
Although, an alternative solution is to run dnsmasq, I'd like to keep the application standalone. I found some equivalent golang packages. However, I feel that many features are supported which I don't really need.
Furthermore, since I don't really have to resolve any IP, but to provide an alias of localhost, I think that a proxy could suffice. This would also be easier to configure, since the user could configure the browser only, and no system-wide modification would be required.
Yet, all the traffic from the user would be 'filtered' by my app. Is this correct? If so, can you point me to any reference to implement it in the most clean way. I know this is quite subjective, but I mean a relatively short (say 10 lines of code) snippet so that users can easily check what is going on.
EDIT
I'd like to use something like:
func main() {
    mymux := http.NewServeMux()
    mymux.HandleFunc("*.mylocal.app", myHandler)
    mymux.HandleFunc("*", <systemDefaultHandler>)
    http.ListenAndServe(":8080", mymux)
}

or
func main() {
    mymux := http.NewServeMux()
    mymux.HandleFunc("editor.mylocal.app", editorHandler)
    mymux.HandleFunc("doc.mylocal.app", docHandler)
    mymux.HandleFunc("*.mylocal.app", rootHandler)
    mymux.HandleFunc("*", <systemDefaultHandler>)
    http.ListenAndServe(":8080", mymux)
}

These are only snippets. A complete example is this, which was referenced in the comments by @Steve101.
However, at now, I don't know what systemDefaultHandler is. And that is not solved there.
Apart from that, @faraz suggested using goproxy. I think that the HTTP/HTTPS transparent proxy is the default handler I am looking for. But, using a package only to do that seems excessive to me. Can I achieve the same functionality with built-in resources?

A: Unfortunately, there's no dead simple way to do this through Go. You'll need to intercept your system's DNS requests just like dnsmasq, and that's inevitably going to require some modification the system DNS config (/etc/resolv.conf in Linux, /etc/resolver on a Mac, or firewall rule) to route your DNS requests to your app. Going the DNS has the downside that you'd need to build a DNS server inside your app similar to pow.cx, which seems unnecessarily complicated.
Since mucking with system config is inevitable, I'd vote for making changes to the hosts file on boot or when a directory is added/removed (via fsnotify.) On shutdown, you can clear the added entries too.
If you're looking to isolate these changes to a specific browser instead of make a system-wide change, you could always run your application through a proxy server like goproxy and tell your browser to use that proxy for requests. For example, you can do this in Chrome through its preferences or by setting the --proxy-server flag:
--proxy-server=<scheme>=<uri>[:<port>][;...] | <uri>[:<port>] | "direct://"

See Chrome's network settings docs for more details.
Also, if you're willing to much with browser configs, you could just use an extension to handle the requests as needed.

A: there is only solution that would work without proxy is that you register an domain for this and make an offical dns entry with wildcard to 127.0.0.1 like *.myApp.suche.org. So any client that resolve the ip get 127.0.0.1 and work local. this way you do not need administrator rights to modify the /etc/hosts or equivalent.
If it should work behind proxy without modify the resolver (etc/hosts etc) you can provide an wpad.dat (Javascript for Proxy detection) that say for your domain all traffic goes you server and the rest to the real proxy. If this is served in you server the script can automaticaly contain the real proxy as default.


text:
Q: How to export an image machine to another GCP account? I would like to import a machine image created in an account into a another google cloud platform account. could you help me?

A: Start by looking at these docs: Here
This should give you an insight into sharing images across accounts.
Once you have properly shared access to the other account's image. I believe you could do something like:
gcloud compute --project=destinationproject images create dest-image --source-image=src-image --source-image-project=sourceproject

A: There is a way to create an instance and a new machine image using a machine image from a different project.
I've reproduced this scenario in my own projects and I was able to use a machine image from a different project to create my instance, I've followed the next documentation
I already created a machine image my-machine-image on my machine-image-project-origin and I granted permission to the service account 123456789000-compute@developer.gserviceaccount.com that is under the new project  vm-project-destination.
It is worth mentioning that my machine-image-project-origin  and my vm-project-destination are under different organizations and were created with different accounts.
To grant access to the my-machine-image that is stored in the project  machine-image-project-origin using the gcloud command-line tool:
gcloud beta compute machine-images add-iam-policy-binding my-machine-image \
    --project=machine-image-project-origin \
    --member='serviceAccount:123456789000-compute@developer.gserviceaccount.com' \
    --role='roles/compute.admin'

You will obtain something like:
Updated IAM policy for machine image [my-machine-image].
bindings:
- members:
  - serviceAccount:123456789000-compute@developer.gserviceaccount.com
  role: roles/compute.admin
etag: BwXtXMjY8wZ=
version: 1

Then to use this image to create a new instance my-instance, in my new project vm-project-destination :
gcloud beta compute instances create my-instance \
 --project=vm-project-destination \
 --zone us-east1-b \
 --source-machine-image projects/machine-image-project-origin/global/machineImages/machine-image-to-share \
 --service-account 123456789000-compute@developer.gserviceaccount.com

And you will obtain something like:
Created [https://www.googleapis.com/compute/beta/projects/vm-project-destination/zones/us-east1-b/instances/my-instance].
NAME             ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP   STATUS
my-instance      us-east1-b  n1-standard-1               10.122.0.2   35.222.19.36  RUNNING

Then if you want, you can create a new machine image based in this new instance that we already created, that basically will be a copy from the machine image created in the original project.
On the other hand, I recommend you to review the following guides on asking questions: How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example in order to provide a better context on what you are doing and what you want to achieve.
I hope you find this information useful.


text:
Q: iOS Testflight - App not processed due to app thinning with no variants Since updating to Xcode 13, TestFlight builds get stuck in 'Processing' indefinitely. Every time I call Apple they give me the error:
Your app was not processing due to app thinning with no variants. For more information please visit
https://help.apple.com/xcode/mac/9.0/#/devbbdc5ce4f.
Bit code was enabled (accidentally) so I disabled it on the target/project, as I cannot use it due to a dependency. This is a react native app so I believe no asset catalog is needed?
I also locally exported the archive as Ad Hoc and rebuild from bitcode with App Thinning enabled for All compatible device variants with no errors. It creates an App thinning report and all the required ipas.
Is there anywhere else I should be looking for App Thinning related settings or another way to diagnose the issue?

A: After changing nothing in my Xcode project I now get a specific error when I try and upload a build which was not happening previously. I get asset validation failed (kinda makes sense as it is related to app thinning) which points to a 3rd party framework with an invalid CFBundleSupportedPlatforms value for iPhoneSimulator. I guess Apple must have changed something on their end to show the error. Removing the iPhoneSimulator value resolved the issue


text:
Q: Function error - Use of undefined constant 'pre_get_posts' - assumed ''pre_get_posts'' On my functions I have this code to display categories archive for custom posts.
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters']
) ) {

// Get all your post types
$post_types = get_post_types();

$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

But I am getting the following error messages:
Use of undefined constant 'pre_get_posts' - assumed ''pre_get_posts''
Use of undefined constant 'add_custom_types_to_tax' - assumed ''add_custom_types_to_tax''
How to I get this to work without the errors?

A: Those look like curly apostrophes, not straight... try changing them to straight (all of them in your code) like this:
function add_custom_types_to_tax( $query ) {
    if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        // Get all your post types
        $post_types = get_post_types();
        $query->set( 'post_type', $post_types );
        return $query;
    }
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );


text:
Q: Is possible to prove the existence of a set that contains exactly n given sets? Studying Set Theory by Karel Hrbacek, I started to question the existence of a set S that contains exactly n given sets, a set of the form:
$$\forall X_{1}, X_{2}, \cdots ,X_{n} \space \exists S \space\forall a (a \in S \iff a = X_{1} \space \vee a=X_{2} \space \vee \cdots \vee \space a= X_{n} )$$
I felt this could be done using the Axioms of Pair and Union, so i tried this:
$$\forall X_{1} \space \exists Y_{1} \space \forall a \space(a \in Y_{1} \iff a = X_{1})$$
$$\forall X_{2} \space \exists Y_{2} \space \forall a \space(a \in Y_{2} \iff a = X_{2})$$
$$\vdots $$
$$\forall X_{n} \space \exists Y_{n} \space \forall a \space(a \in Y_{n} \iff a = X_{n})$$
Now, it is necessary to construct a set $Z$ that contains $Y_{1}, Y_{2}, \cdots, Y_{n} $ and apply the operation of union to $Z$, so there exists a set $ \cup Z = S$ that contains exactly the wanted elements. I think that the problem here is in fact the construction of $Z$, but this is redundant because the construction of $Z$ is a problem equivalent to the construction of $S$.
I don't know if my actual knowledge is enough to answer this question, so any help is appreciated.


text:
Q: MongoDB - Complex Grouping Query I have the following MongoDB aggregation query which groups by IDC, type and cluster - which works perfectly.
I would like to additionally group "environment", inside this existing grouping. Please see my query below, my existing output, and what I would like to see (desired output).
If you have any questions or wish to see the source (I didn't think it was necessary, as it would take up room on the question, then please comment).
Thanks
Example Source (around 1000 documents):
   {
        "_id":"55d5dc40281077b6d8af1bfa",
        "hostname":"1",
        "domain":"domain",
        "description":"VMWare ESXi 5",
        "cluster":1,
        "type":"Physical",
        "os":"EXSi",
        "idc":"AMS",
        "environment":"DR",
        "deviceclass":"host",
        "cores":64,
        "memory":256,
        "clusters":0,
        "customer":"MnS",
        "mounts":[],
        "roles":["ESX-HOST"],
        "ipset":{"backnet":"1"},
        "frontnet":[],
        "created":"2015-09-28T11:12:36.526Z"
    }

Query:
Machine.aggregate([
{ "$match": {
    "idc": req.query.idc, "customer": req.query.customer}
} ,
{ "$group": {
    "_id": {
        "cluster": "$cluster",
        "idc":"$idc",
        "type": "$type"
    },
    "SumCores": { "$sum":"$cores" },
    "SumMemory": { "$sum":"$memory" }
}},
{ "$group": {
    "_id": {
        "cluster": "$_id.cluster",
        "idc": "$_id.idc"
    },
    "data": {
        "$push": {
            "type": "$_id.type",
            "SumCores": "$SumCores",
            "SumMemory": "$SumMemory"
        }
    }
}},
{ "$project": {
    "Physical": {
        "$setDifference": [
            { "$map": {
                "input": "$data",
                "as": "el",
                "in": {
                    "$cond": [
                        { "$eq": [ "$$el.type", "Physical" ] },
                        {
                            "SumCores": "$$el.SumCores",
                            "SumMemory": "$$el.SumMemory"
                        },
                        false
                    ]
                }
            }},
            [false]
        ]
    },
    "Virtual": {
        "$setDifference": [
            { "$map": {
                "input": "$data",
                "as": "el",
                "in": {
                    "$cond": [
                        { "$eq": [ "$$el.type", "Virtual" ] },
                        {
                            "SumCores": "$$el.SumCores",
                            "SumMemory": "$$el.SumMemory"
                        },
                        false
                    ]
                }
            }},
            [false]
        ]
    }
}},
{ "$unwind": "$Physical" },
{ "$unwind": "$Virtual"},
{ "$sort" : { "_id.idc": -1, "_id.cluster": 1 } }
]);

Which gives me the following output:
{
    "_id" : {
            "cluster" : 1,
            "idc" : "LH5"
    },
    "Physical" : {
            "SumCores" : 192,
            "SumMemory" : 768
    },
    "Virtual" : {
            "SumCores" : 112,
            "SumMemory" : 384
    }
}

My desired output is:
[
{
    "_id": {
        "cluster": 1,
        "idc": "LH8"
    },
    "Physical": [
        {
            "environment": "DR",
            "SumCores": 256,
            "SumMemory": 1024
        },
        {
            "environment": "PROD",
            "SumCores": 256,
            "SumMemory": 1024
        }
    ],
    "Virtual": [
        {
            "environment": "DR",
            "SumCores": 232,
            "SumMemory": 469
        },
        {
            "environment": "PROD",
            "SumCores": 232,
            "SumMemory": 469
        }
    ]
}
]

Essentially, I want to group the sums based on the environment

A: Very much as in your initial query ( actually written by myself ), all you really need to do is add in that field detail to the initial _id of $group and then carry that through into the subsequent array entries:
Machine.aggregate([
    { "$match": {
        "idc": req.query.idc, "customer": req.query.customer}
    } ,
    { "$group": {
        "_id": {
            "cluster": "$cluster",
            "idc":"$idc",
            "type": "$type",
            "environment": "$environment"
        },
        "SumCores": { "$sum":"$cores" },
        "SumMemory": { "$sum":"$memory" }
    }},
    { "$group": {
        "_id": {
            "cluster": "$_id.cluster",
            "idc": "$_id.idc"
        },
        "data": {
            "$push": {
                "type": "$_id.type",
                "environment": "$_id.environment",
                "SumCores": "$SumCores",
                "SumMemory": "$SumMemory"
            }
        }
    }},
    { "$project": {
        "Physical": {
            "$setDifference": [
                { "$map": {
                    "input": "$data",
                    "as": "el",
                    "in": {
                        "$cond": [
                            { "$eq": [ "$$el.type", "Physical" ] },
                            {
                                "environment": "$$el.environment",
                                "SumCores": "$$el.SumCores",
                                "SumMemory": "$$el.SumMemory"
                            },
                            false
                        ]
                    }
                }},
                [false]
            ]
        },
        "Virtual": {
            "$setDifference": [
                { "$map": {
                    "input": "$data",
                    "as": "el",
                    "in": {
                        "$cond": [
                            { "$eq": [ "$$el.type", "Virtual" ] },
                            {
                                "environment": "$$el.environment",
                                "SumCores": "$$el.SumCores",
                                "SumMemory": "$$el.SumMemory"
                            },
                            false
                        ]
                    }
                }},
                [false]
            ]
        }
    }},
    { "$unwind": "$Physical" },
    { "$unwind": "$Virtual"},
    { "$sort" : { "_id.idc": -1, "_id.cluster": 1 } }
]);

But you also "really" should be using the query form I recommended you did in the first place, since it is clear that all you want to do is diplay this in a template, and looping array content should be very simple:
Machine.aggregate([
    { "$match": {
        "idc": req.query.idc, "customer": req.query.customer}
    } ,
    { "$group": {
        "_id": {
            "cluster": "$cluster",
            "idc":"$idc",
            "type": "$type",
            "environment": "$environment"
        },
        "SumCores": { "$sum":"$cores" },
        "SumMemory": { "$sum":"$memory" }
    }},
    { "$group": {
        "_id": {
            "cluster": "$_id.cluster",
            "idc": "$_id.idc"
        },
        "data": {
            "$push": {
                "type": "$_id.type",
                "environment": "$_id.environment",
                "SumCores": "$SumCores",
                "SumMemory": "$SumMemory"
            }
        }
    }},
    { "$sort" : { "_id.idc": -1, "_id.cluster": 1 } }
]);


text:
Q: How to use HttpWebRequest in c++ compare c#? I want to understand how to use httpwebreuqest in c++.
For c# it is easy -
string html = string.Empty;
string url = @"https://api.stackexchange.com/2.2/answers?order=desc&sort=activity&site=stackoverflow";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.AutomaticDecompression = DecompressionMethods.GZip;

    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    using (Stream stream = response.GetResponseStream())
    using (StreamReader reader = new StreamReader(stream))
    {
        html = reader.ReadToEnd();
    }

    Console.WriteLine(html);

But i dont know how to start for c++.

A: You need to use CPPRest SDK / Casablanca in C++. I could find some examples here - http://ramvellanki.github.io/blog/2016/05/15/working-with-casablanca-cpprestsdk/


text:
Q: Web Worker FileReaderSync I am reading in files inside of a web worker. However, when I try to read the file I keep getting this error: Uncaught DataCloneError: An object could not be cloned. The only line of code that throws this error is the reader.readAsText(file). Can anyone explain why this is happening?
self.requestFileSystemSync = self.webkitRequestFileSystemSync || self.requestFileSystemSync;

try{
    var fs = requestFileSystemSync(TEMPORARY, 1024 * 1024);
}
catch (error) {onError(error);}

self.addEventListener('message', function (e) {
    try{
        var path = e.data;
        var file = fs.root.getFile(path, { create: false });
        var reader = new FileReaderSync();
        self.postMessage(reader.readAsText(file));
    }
    catch (error) { onError(error); }
});

function onError(error) { self.postMessage(error); }


text:
Q: Wampserver did not work on localhost I just installed Wampserver. after installing it, the icon color is green and say the server is online. then I tried localhost on my browser. it showed "the site can't be reach" but when I entered http://127.0.0.1/ it works and displays  Wampserver homepage. Why it did not work when I entered "localhost"? it only can enter http://127.0.0.1/ . Is there something that I must change in the settings? when I tried to change the port be port 80, it showed "CLI stop working".

A: localhost does not exists automatically. Its actually a domain name you have to create on your PC. You do this by adding it to your HOSTS file.
Edit the file C:\windows\system32\drivers\etc\hosts
Add these lines to it
localhost  127.0.0.1
localhost ::1

You also need the ::1 version as well as that is IPV6, and lots of browsers will attempt to use the IPV6 network in preference to the IPV4 (127.0.0.1)
You will have to be an Administrator to edit this file as it is protected by windows.
Or open your editor by right clicking on it, and selecting the "Run as Administrator" menu option.


text:
Q: reset button in form doesn't reset selection to first element because of selected keyword in HTML I have a reset button in a form
<input type="reset" value="Reset">

and some selections
<select>
<option value="0">A</option>
<option value="10" selected="selected">B</option>
</select>

If I click on reset nothing happens. Here is an example.
Edit:
I thought that the reset button will reset to the first value of a selection list. It seems that was a missunderstanding of my side. I want to reset to the first element of a selection.
So is the only way to create a reset function in Javascript? What if the user has turned off Javascript?

A: Force value to nothing of all inputs, select, etc...
$("#filter_form").find("select, input, checkbox").val("");

A: When I click on reset button, form reset in defaults. It's working in your example (option 10 is default).


text:
Q: dropbear-initramfs can't find modprobe and blkid I'm trying to have dropbear remote ssh boot on a debian system which is encrypted with lvm crypto luks.
I can get it work on my raspberry pi but not on my regular system
steps:
1 install debian with encrypted LVM
ls -l /lib/modules/ |awk -F" " '{print $9}'
mkinitramfs -o /boot/initramfs.gz
echo initramfs initramfs.gz >> /boot/config.txt

then create an rsa ssh key with the following line in front and save it to /etc/dropbear-initramfs/authorized_keys:
command="/scripts/local-top/cryptroot && kill -9 `ps | grep -m 1 'cryptroot' | cut -d ' ' -f 3`" ssh...
then:
mkinitramfs -o /boot/initramfs.gz
reboot

i can type the password and decrypt with a keyboard but when i login with ssh I get :
/scripts/local-top/cryptroot: line 218: modprobe: not found
/scripts/local-top/cryptroot: line 378: blkid: not found
/scripts/local-top/cryptroot: line 378: blkid: not found
/scripts/local-top/cryptroot: line 378: blkid: not found
/scripts/local-top/cryptroot: line 378: blkid: not found
/scripts/local-top/cryptroot: line 378: blkid: not found
...

please help?
extra info:
my blkid
/dev/sda1: UUID="42a9ca50-b757-4e11-985f-8fc75323b598" TYPE="ext2" PARTUUID="38de37f0-01"
/dev/sda5: UUID="3448b157-a1f9-4f6a-a1ea-37e6362cdea8" TYPE="crypto_LUKS" PARTUUID="38de37f0-05"
/dev/mapper/sda5_crypt: UUID="nzAaP7-Ocx9-BJzO-BM7S-SQcY-BHqp-tbgvH6" TYPE="LVM2_member"
/dev/mapper/deb--vg-root: UUID="f8ec5b07-75fe-4870-9fb6-9e9035d21a20" TYPE="ext4"
/dev/mapper/deb--vg-swap_1: UUID="ff915ae6-210f-4bbb-8988-b30aacae3dea" TYPE="swap"

my /etc/fstab
/dev/sda1: UUID="42a9ca50-b757-4e11-985f-8fc75323b598" TYPE="ext2" PARTUUID="38de37f0-01"
/dev/sda5: UUID="3448b157-v4a5-4f6a-a1ea-28e6362cdea9" TYPE="crypto_LUKS" PARTUUID="38de37f0-05"
/dev/sdb1: UUID="CC55-BAFE" TYPE="vfat" PARTUUID="0000370e-01"                                          /dev/mapper/sda5_crypt: UUID="nzAaP7-Ocx9-BJzO-BM7S-SQcY-BHqp-tbgvH6" TYPE="LVM2_member"
/dev/mapper/theproject1--vg-root: UUID="f8ec5b07-75fe-4870-9fb6-9e9035d21a20" TYPE="ext4"
/dev/mapper/theproject1--vg-swap_1: UUID="ff915ae6-210f-4bbb-8988-b30aacae3dea" TYPE="swap"

my /etc/crypttab
sda5_crypt UUID=3448b157-v4a5-4f6a-a1ea-28e6362cdea9 none luks,discard

A: I had a similar issue, but different resolution.
I have a encrypted Kali Linux computer and use the dropbear-initramfs package to unlock the root disk at boot remotely over the dropbear ssh session using cryptroot-unlock.
This worked fine for a long time, but after some update it stopped working.  I could SSH to the initramfs disk dropbear session but when I did "cryptroot-unlock" it would hang and I would get the error "Error: Timeout reached while waiting for askpass."
Eventually I found the solution:-
https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1687842.html
Basically to fix I uninstalled "cryptsetup-nuke-password" package "apt remove cryptsetup-nuke-password".  Then rebooted and then I could successfully open the encrypted /root partition remotely via the dropbear-initramfs.
If you are getting the error "Error: Timeout reached while waiting for askpass." when ssh'ed to your dropbear-initramfs at boot, trying to cryptroot-unlock the drive.  To confirm if the issue is the same as mine then do a "ps" and look through the processes running. If see something similar to "/lib/cryptsetup/askpass.cryptsetup Please unlock disk .." then I suggest logging on via the console and removing "cryptsetup-nuke-password", to resolve the issue.


text:
Q: Visual Studio 2022 - VC++ copy to output folder I have a problem with a C++ library that I have.
This C++ library includes a Library file (abc.lib) but I also need this library file copied to the output folder.
The C++ library is then used in a C# application and I need the library file to be automatically included in the c# application when it is referenced.
I can't seem to find a way to copy the library file to the output folder and use the library in the c++ app. I do not want to use a post build event as this won't then get the library file copied to the c# application.
  <ItemGroup>
    <Library Include="abc.lib">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Library>
  </ItemGroup>

The CopyToOutputDirectory directive does not work above (I am not sure it is even supported)
Any thoughts?
I know you can set the Item Type property to Copy File, but then it is not treated as a library as the app does not compile.


text:
Q: UnityEditor.SceneAsset class not accessible in build I am new to unity addressables and would like to load a scene with an AssetReference. To enforce AssetReferences being a scene, I created the following class in a utility assembly:
using System;
using UnityEngine;
using UnityEngine.AddressableAssets;

[Serializable]
public sealed class SceneReference : AssetReferenceT<SceneAsset>
{
    public SceneReference(string guid) : base(guid) { }
}

JetBrains Rider then said SceneAsset had to be referenced from assembly: UnityEditor.CoreModule. I used its suggestion, and Rider automatically set up the
assembly reference. Everything worked great, and indeed I could only drag scenes into a SceneReference field.
But everything broke down when I went to make a build. I get four errors:
1:Internal build system error. Backend exited with code 139.
2:Error building Player because scripts had compiler errors
3:Build completed with a result of 'Failed' in 11 seconds (11360 ms) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
4:UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ce] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:193  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:94  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
I have tried to manually locate assembly UnityEditor.CoreModule and reference it in my utility assembly's assembly definition asset but couldn't find it. It still works great in the editor but won't compile for a build. If anyone has a solution or at least knows why this isn't working, I would be most appreciative.

A: SceneAsset indeed can not be in a build and only exists within the Unity Editor - for what reason ever.
It is a special case of an asset that only exists in editor since later on in a build the scenes are handled completely different as runtime Scene.
The entire UnityEditor namespace is completely stripped of in a build.

For serialization the best option is usually to serialize and store the asset path and later use that for loading the scene.

You can still make scenes Addressables though and load them via the usual more manual Addressables route e.g. using a "normal" generic
public AssetReference Scene;

See Addressables - Scene Loading.


text:
Q: How to convert a keyedArchiver to a string and back again I want to convert a custom object into a propertyList. Then later I want to retrieve it via NSOutlineView.  I use a NSKeyedArchiver/unArchiver to convert my object to and from a NSData.
In my custom object (OutlineItem):
-(id)pasteboardPropertyListForType:(NSPasteboardType)type
{
if ([[[info draggingPasteboard] types] containsObject: kPrivateDragUTI])
{
     NSData *itemData = [NSKeyedArchiver archivedDataWithRootObject:self];
     NSString* itemString = [[NSString alloc]initWithData:itemData encoding:NSASCIIStringEncoding];
     return itemString;
}

In NSOutlineView:
- (id<NSPasteboardWriting>)outlineView:(NSOutlineView *)outlineView pasteboardWriterForItem:(id)item
{
   OutlineItem* anItem = item;
   return anItem;
}

Later:
- (BOOL)outlineView:(NSOutlineView *)destinationOutlineView
             acceptDrop:(id <NSDraggingInfo>)info item:(id)destinationParentItem
             childIndex:(NSInteger)destinationIndex
{
    NSPasteboard *pboard = [info draggingPasteboard];
    OutlineItem* pbItem = nil;
    if ([[pboard types] containsObject: kPrivateDragUTI])
    {
        NSString* stringForData = [[info draggingPasteboard] stringForType:kPrivateDragUTI];
        NSData *data = [stringForData dataUsingEncoding:NSASCIIStringEncoding];

StringForData looks OK, but data is nil at this point.
Why is data nil?


text: Q: html/css breaking multicolumn text i looking for solution for this situation: i have large html text in one div container. I using css3 multicolumns on that. And I would like to breaks this container after contant height. So I would a n this same heights "tables" with multicolumn layouts. I'ts similar to newspaper - large block text breaking after page height - next page is continuing previous page text with the same multicolumn layout... how can i do it ?


text:
Q: Form - submit POST request to multiple iframes I know that it is possible to submit POST request to an iframe by using target attribute.
Is there any way to submit POST request from one form to multiple iframes at the same time?
Both HTML and JS solutions are acceptable.

A: A Javascript solution would be your best bet.
<form id="form">
  <input type="text" name="xyz" value="random data" />
  <button type="submit">Go</button>
</form>

In JS, you would attach an event listener to your form when it is submitted. The listener would trigger a function that could send the form data to multiple targets:
var form = document.getElementById("form");

if(form.attachEvent) {
  form.attachEvent("submit", submitForm);

} else {
  form.addEventListener("submit", submitForm);
}

function submitForm(e) {
  if(e.preventDefault) {
    e.preventDefault();
  }

  this.target = "first_iframe";
  this.submit();

  var secondForm = this.cloneNode();
  secondForm.target = "second_iframe";
  secondForm.submit();
}


text:
Q: Hierarchial clustering in R I am getting the following  error when I use hclust function? How can I solve this problem?
I am using windows 7 and 2.12.3 version of R.
n_seq <- 250
mat <- matrix(NA, ncol=n_seq, nrow=n_seq)
for (idx in 1:n_seq)
{mat[idx,idx] <- 0.0}
for(idx in 1:(n_seq-1) )
{intemp <- read.xls("C:// clustal.xls", sheet = idx );
mat[(1+idx):n_seq,idx] <- intemp[1:(n_seq-idx), 11]}

fit <- hclust(as.dist(mat), method="single")

Error in hclust(as.dist(mat), method = "single") :
NA/NaN/Inf in foreign function call (arg 11)

Please help me to solve this problem.

A: This error message arises because the distance matrix as.dist(mat) has a bad value (NA, NaN or Inf) in it. If you look in the code of hclust, the 11th argument to the foreign function call (i.e. by compiled code) is the values of the distance matrix, and this is what R is complaining about. By default, NA, NaN or Inf are not accepted by foreign function calls. See ?.Fortran for more info.


text:
Q: How does the Fourier transform of the periodic extension relate to the Fourier series of ? (continuous signal) We know that in discrete signals, the relation between the Fourier transform of a signal and its Fourier series coefficient is as follows:
$$X(jkw_0) = 2\pi a_k$$
Or:
$$X(jw) = 2\pi\sum_{k=0}^{k=N}{a_k\delta(w-kw_0)} $$
Which is provable very easily. But what is the relation between CT FS and CT FT? As we know if we have a $x_1(t)$ defined is:
$$x_1(t)=\left\{
\begin{array}{ll}
        f(t) & |t|< \frac{T_1}{2} \\
        0 & \mbox{oth.}
    \end{array}
\right.$$
We can convolve it into a impulse train to create the periodic function $x_(t)$.
$$x(t) = x_1(t) * \sum_{k=-\infty}^{+\infty}\delta(t-kT)$$
And the fourier transform will be:
$$
X(jw) = X_1(jw) \times F(\sum_{k=-\infty}^{+\infty}\delta(t-kT))
$$
$$
X(jw) = X_1(jw) \times \sum_{k=-\infty}^{+\infty}e^{jwkT}
$$
Which does not give any indication of any linear relation between CTFS and CTFT of a function.


text:
Q: Css for dynamically adjusting the column size Following is a html table code that I have.

    .table_header
    {
     text-align: center;
     width:50px;
     vertical-align: middle;
     background-color: gainsboro;
    }

          header 1
          header 2

          very large row header 1
          <input class="qty_input" value="0" type="text"/>
          <input class="qty_input" value="0" type="text"/>

          row header 2
          <input class="qty_input" value="0" type="text"/>
          <input class="qty_input" value="0" type="text"/>

The first column correctly set to 50px. But all other columns have different size. So i provided style with width 40px for the td and input field. It partially fixed, but the problem is when the length of the row header name id large, then its height is adjusted, but the input field remains the same. I heed to get the input field also adjusted when the row header size is increased.
Input fields are used to save float values. so small width is needed otherwise the table will become bigger

A: Use thead and tbody. Try this markup:

      header 1
      header 2
      header 3

      very large row header 1
      <input class="qty_input" value="0" type="text"/>
      <input class="qty_input" value="0" type="text"/>

      row header 2
      <input class="qty_input" value="0" type="text"/>
      <input class="qty_input" value="0" type="text"/>

A: You can either provide full width to your table and then let the columns adjust as per the data provided to display.
HTML:

          header 1
          header 2
          header 3

          very large row header 1
          <input class="qty_input" value="0" type="text"/>
          <input class="qty_input" value="0" type="text"/>

          row header 2
          <input class="qty_input" value="0" type="text"/>
          <input class="qty_input" value="0" type="text"/>

CSS:
  .my_table
    {
        text-align: center;
        width:100%;
        vertical-align: middle;
        background-color: gainsboro;
    }


text:
Q: Should we use OpenGL for 2D graphics? If we want to make an application like MS Paint, should we use OpenGL for render graphics?
I want to mention about performance if using traditional GDI vs. OpenGL.
And if there are exist some better libs for this purpose, please see me one.

A: GDI, X11, OpenGL... are rendering APIs, i.e. you usually don't use them for image manipulation (you can do this, but it requires some precautions).
In a drawing application like MS Paint, if it's pixel based, you'll normally manipulate some picture buffer with customary code, or a special image manipulation library, then send the full buffer to the rendering API.
If your data model consists of strokes and individual shapes, i.e. vector graphics, then OpenGL makes a quite good backend. However it may be worth looking into some other API for vector graphics, like OpenVG (which in its current implementations sits on top of OpenGL, but native implementations operating directly on the GPU may come).
In your usage scenario you'll not run into any performance problems on current computers, so don't choose your API from that criteria. OpenGL is definitely faster than GDI when it comes to texturing, alpha blending, etc. However depending on system and GPU pure GDI may outperform OpenGL for so simple things like drawing an arc or filling a complex self intersecting polygon with complex winding rules.

A: There is no good reason not to use OpenGL for this. Except maybe if you have years of experience with GDI but don't know a single thing about OpenGL.
On the other hand, OpenGL may very well be superior in many cases. Compositing layers or adjusting hue/saturation/brightness/contrast in a GLSL shader will be several orders of magnitude faster (in fact, pretty much "instantly") if there is a reasonably new card in the computer. Stroking a freedraw path with a "fuzzy" pen (i.e. blending a sprite with alpha transparency over and over again) will be orders of magnitude faster. On images with somewhat reasonable dimensions, most filter kernels should run close to realtime. Rescaling with bilinear filtering runs in hardware.
Such things won't matter on a 512x512 image, as pretty much everything is instantaneous at such resolutions, but on a typical 4096x3072 (or larger) image from your digital camera, it may be very noticeable, especially if you have 4-6 layers.


text:
Q: DB Design for 2 tables where we want to link their primary keys There are two tables feedback and action both tables have primary key feedback_Id and action_Id respectively.
We have frontend pages for Action where for a given action we can view the feedback(using the feedback_Id) and on Feedback frontend page we can view the Action related to it.
so now i decided to link these two table for that i have created another table LinkActionFeedback which have two foreign fields which refer to  feedback.feedback_Id and action.action_Id.
We are fetching actions using pagination. At this time, we also need the feedback_Id for each action. one way to retrieve feedback_Id is to  perform join operation with LinkActionFeedback table.
Is there any other option for retrieving feedback_Id related to the actions while fetching actions using pagination by using a different DB design. I have a feeling that the Join operation might be expensive because in a single pagination call we retrieve 30 actions.


text:
Q: Prevalence of B-fields I am wondering how B-fields, which are basic objects in Generalized Geometry, relate to the B-fields of Ben's question and the answers to it.
In Generalized Geometry, the B-field is a (1,1)-form, and when it is closed it preserves the generalized complex structure.  Furthermore, the Dolbeault cohomology class of the B-field acts on the equivalence class of a "generalized holomorphic bundle" (the natural generalization of holomorphic bundles to generalized complex manifolds).  In what ways are these B-fields connected to the physics B-fields discussed in Ben's post?

A: The short answer is that both B-fields are the same object!
The way the B-field comes to us from string theory it doesn't come alone, but comes together (among other fields) with the Riemannian metric. Due to the way both originate in the string, they are interrelated by what is called T-duality that mixes them and shows that both fields have to be regarded as two aspects of one and the same unified entity.
Physicists had understood various aspects of how these two fields unify, when Nigel Hitchin came along and noticed that there is a nice and useful mathemtical formalization of what is going on. This is the origin of generalized complex geometry.
But some aspects of the picture are still mising. For instance it is well-know that in full beauty the B-field is a gerbe with connection . Last I checked, this is represented in generalized complex geometry only rationally , meaning that the integral degree 3 class of this gerbe is seen only in its image in deRham cohomology.
This has to do with the fact that generalized complex geometry is really a theory of Couran algebroids (certain Lie 2-algebroids) and it is only their integration that knows about the full Lie 2-groupoids that yield the gerbe.
(I think I know the full story, but it is not written up yet.)


text:
Q: MySQL case function not working with integers I have been trying to use Case functions to categorise employees based on experience. Whenever I execute the code in MySQL workbench I always get the value that I assign to ELSE regardless of the years of experience.
SELECT
EXP,
CASE EXP
WHEN EXP > 12 THEN 'Manager'
WHEN EXP BETWEEN 10 AND 12 THEN 'LEAD'
WHEN EXP BETWEEN 5 AND 10 THEN 'SENIOR'
WHEN EXP BETWEEN 2 AND 5 THEN 'ASSOCIATE'
ELSE 'JUNIOR'
END AS RANKING

FROM DATA_SCIENCE_TEAM
I get junior regardless of the experience number
Results


text:
Q: Why is my second monitor not working? Since I have my new computer, I have a very weird problem.
Facts:
New Computer:

*

*Motherboard: ASRock Z77 Pro 3

*Graphics-card: Asus1GB D5 X EN GTX560 DCII OC/2DI R

*CPU: Intel i5-3570

*Windows 7 64-bit (newly installed)

*500W beQuiet special edition (92% efficiency)

*8GB 1333MHz DDR3 Corsair RAM (CL9)

*Scythe Mugen 2

*2 magnetic HDDs + 1 SSD

*1 DVD-R

Old Computer:

*

*mobo: Asus P55 something

*GPU: Asus1GB D5 X EN GTX560 DCII OC/2DI R

*CPU: Intel i7-870

*OS: Windows 7 64-bit

*PSU: 550W Corsair

*RAM: 8GB 1333MHz DDR3 Corsair (CL9)

*Scythe Mugen 3

*2 magnetic HDDs + 1 SSD

*1 DVD-R

On the old computer it worked fine with two monitors.
Moving to the new (I took the same Graphics-card) it only works with one. The weird thing I mentioned above: no matter which one, but if I put both there only one is available.
There is no reaction at the start (where normally - at least if I remember correctly - the monitor shortly went from "standby" to "on").
Windows does not recognize a second monitor in the Device Manager.
I have the latest drivers for the motherboard and graphics card. I have the latest BIOS drivers.
I am out of ideas.

Edit: completed computer setup

A: The solution to this very simple.

*

*For one, you have only replaced your Motherboard and Processor, and that is the only difference between your old and new computer. Nothing else has changed. Nevermind the SMPS, it doesn't matter!

*Second, it looks like your using the same hard drives in the same order. It also seems your booting from the same old installed same Operating System on those hard drives, without doing a clean install.

*If you search Google properly, most people have reported Graphic Card issues and driver issues, When they have replaced their Motherboard and the Processor with a different one.

*The only solution to this is, do a clean install, or get a temporary hard drive and clean install the OS and drivers on it and check if it works. A clean install will definitely solve you problem.
Here are some links to support what i have said. Please read these threads:

*

*Upgrading the Motherboard on Windows 7

*Upgrading the Motherboard and CPU on windows 7


text:
Q: Is it possible to set up a Vagrant sync folder with variable host/source directory, possibly from config file? I'm trying to set up a Vagrantfile that will mount a code base on the developer's machine.  The place the developer puts the codebase on their machine could be anywhere they like based on how they like to organize their machine.  If I offer up this Vagrantfile to set up a small development and test environment that closely resembles production, I'd like them to be able to set the location of their code without having to edit the Vagrantfile (leaving it unchanged in source control).
Is there a way to make the Vagrantfile look somewhere else for a value to use as the host directory path for a sync folder?
I tried asking on the HashiCorp forum (might require login) yesterday, but haven't gotten a response yet and it seems like a low traffic site.  I'll keep checking there in case a solid answer comes back, but I'm hoping someone here has dealt with this before.  Thank you for any help.

A: You can customize additional synced folders with an additional line of code in the Vagrantfile described here:
config.vm.synced_folder '<host_path>', '<guest_path>'

This solves the problem of additional customized synced folders. However, you also stated you desired to customize this per user based on a config file. You can accomplish this with basic Ruby. We will assume the config file is YAML like:
# config.yaml
---
host_path: '/path/on/host'
guest_path: '/path/on/guest'

Then we can read in the file with normal Ruby and utilize its key-value pairs as per normal. This assumes the file is in the same directory as where vagrant commands are being executed; otherwise the code will need to be customized further:
require 'yaml'

paths = YAML.load_file('config.yaml')
config.vm.synced_folder paths['host_path'], paths['guest_path']

The code can also be easily modified for different config file formats.


text:
Q: How do I get left and right Y axes with the same scale but different labels? Using the code below (and with the help of this really good page: Modify tick label text) I have been able to convert the numerical Y axis values to my custom values as shown in left Y axis in the image.
What I really want to do now is to include those original numerical Y axis values in a second Y axis on the right hand side, as show in my red hand-drawn edits in the image.
I have played with and don't think this is a case for axes.twinx()(https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.twinx.html) because I have only one plot, but happy to be corrected.
I'm still pretty green in Matplotlib and getting my head around all the different parts, so it's probably a really easy fix but I just can't logic it out!
Thanks!
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker

fig = plt.figure()

ax = df.groupby(['Id']).mean().boxplot(column='Ach_Num', by = 'Yr_Lvl_Cd', figsize=(14,10))

def update_ticks(x, pos):
    if x==5:
        return 'A'
    elif x==4.5:
        return ''
    elif x==4.0:
        return 'B'
    elif x==3.5:
        return ''
    elif x==3.0:
        return 'C'
    elif x==2.5:
        return ''
    elif x==2.0:
        return 'D'
    elif x==1.5:
        return ''
    elif x==1.0:
        return 'E'
    elif x==0.5:
        return ''
    elif x==0.0:
        return 'N'
    else:
        return x

ax.yaxis.set_major_formatter(mticker.FuncFormatter(update_ticks))
plt.show()

A: You can use secondary_yaxis() to set a second y-axis on the other side for the same plot. Also, as you indicated that you want to show the ticks at 0.5 distance, you can use set_yticks() for that. Add these two lines just before the plt.show()
ax2 = ax.secondary_yaxis("right")
ax2.set_yticks(np.arange(0, max(df['Ach_Num'])+.5, 0.5))

Updated plot (using random data)


text:
Q: When does a "representable functor" into a category other than Set preserve limits? This might be a dumb question.  If $C$ is an ordinary category, then for any $c \in C$ the covariant representable functor $\text{Hom}(c, -) : C \to \text{Set}$ preserves limits.  However, it can happen that $c$ can be equipped with extra structure which in turn gives the morphisms out of $c$ extra structure, so that there is a "representable functor" $\text{Hom}(c, -) : C \to D$ where $D$ is a category equipped with a forgetful functor $F : D \to \text{Set}$ such that composing with the above gives the original representable functor.
In this situation, when does the functor into $D$ still preserve limits?  How is this situation formalized?  (Assume that $C$ is not enriched over $D$ in any obvious way.)
There are several examples of this coming from algebra, but the one that got me curious is the following.  Let $C$ denote the homotopy category of pointed (path-connected?) topological spaces and let $S^1$ denote the circle with a distinguished point.  I believe I am correct in saying that if the fundamental group functor $\pi_1 : C \to \text{Grp}$ is composed with the forgetful functor $U : \text{Grp} \to \text{Set}$, then $S^1$ represents the resulting functor $U(\pi_1(-))$.  (The extra structure on $S^1$ that makes this possible is, if I'm not mistaken, a cogroup structure internal to $C$.)  Can I conclude that $\pi_1$ preserves limits?

Edit:  I've been told that the above example is problematic, so here's a simpler one.  Let $C = \text{Set}$ and suppose that $c \in C$ is equipped with a morphism $f : c \to c$.  Then by precomposition $\text{Hom}(c, d)$ is also equipped with such a morphism, so $\text{Hom}(c, -)$ has values in the category of dynamical systems.  Does it preserve limits?  Another example is my attempted answer to question #23188.

A: [Collecting my sporadic comments into one (hopefully) coherent answer.]
A more general question is as follows: For functors
$C\stackrel{F}{\to}D\stackrel{U}{\to}E$ and for an index category
$J$ such that $UF$ preserves $J$-limits, when does $F$ preserve $J$
limits?
A useful sufficient condition is that if $U$ creates $J$-limits, then
in the above situation $F$ preserves $J$-limits.  Proof:  Let $T\colon
J\to C$ be a functor, and suppose that $\tau\colon
\ell\stackrel{\cdot}{\to} T$ is a limiting cone in $C$.  Since $UF$
preserves $J$-limits, $UF\tau\colon UF\ell\stackrel{\cdot}{\to} UFT$ is a limiting cone in
$E$. As $U$ creates $J$-limits, there is a unique lifting of $UF\tau$ to a cone in
$D$, and this cone is a limiting cone.  But $F\tau\colon
F\ell\stackrel{\cdot}{\to} FT$ is such a lift, and hence we're done.
This condition is quite useful, because many forgetful functors are
monadic, and monadic functors create all limits (by combining their definition
on pp. 143--144 of Mac Lane and Ex. 6.2.2 on p. 142 of Mac Lane, or by
Proposition 4.4.1 on p. 178 of Mac Lane--Moerdijk, or really by a
comment of Tom Leinster from which I learned this :)).
For example, consider the category of all small algebraic systems of
some type.  From the AFT, we know that the forgetful functor to
$\mathbf{Set}$ has a left adjoint, and it is the content of Theorem
6.8.1, p. 156 of Mac Lane that this forgetful functor is monadic.
Returning to the original question, this means that whenever the
category $D$ is one of $\mathbf{Grp}$, $\mathbf{Rng}$,
$\mathbf{Ab}$,... and $U\colon D\to \mathbf{Set}$ is the forgetful
functor, then for any $J$, $UF$ preserves $J$-limits implies $F$ preserves $J$
limits.  In particular, if $UF$ is a representable functor
(and hence preserves all limits), then $F$ preserves all limits.
Next, let me try to comment on your motivating examples (the one from
Q. 23188 and the one from the 'Edit' part of the current question.)
Regarding your example in Q. 23188:  Unfortunately I know nothing of
Hopf algebras, so I can't understand all the details of your
construction. If I understand correctly, you construct a functor
$F\colon\mathbf{Rng}\to\mathbf{Grp}$ whose composition with the
forgetful functor $U\colon \mathbf{Grp}\to \mathbf{Set}$ is
representable. If this is indeed the case, then by the above $F$
itself preserves all limits.
[EDIT: corrected the part concerning the last example.]
Finally, regarding your example in the edited question:
While I
know nothing of dynamical systems, from a quick glance at Terence
Tao's blog
it seems that the category of dynamical systems is the
category whose objects are pairs $\langle X,f\colon X\to X\rangle$ with
$X$ a (small) set and whose arrows
$\phi\colon\langle X, f\rangle\to\langle Y, g\rangle$ are those
functions $\phi\colon X\to Y$ with $g\circ\phi =\phi\circ f$.
To show that the above sufficient condition works in this case, we
would like to show that the forgetful functor to $\mathbf{Set}$ crates
limits.  More generally, we will show that if $C$ is a
category and $D$ is the category whose objects are pairs $\langle
x,f\colon x\to x\rangle$ (where $x\in\operatorname{obj}(C)$,
$f\in\operatorname{arr}(C)$), and whose arrows $\phi\colon \langle
x,f\rangle\to \langle y,g\rangle$ are those arrows $\phi\colon x\to y$
with $g\circ\phi =\phi\circ f$, then the forgetful functor $U\colon
D\to C$ creates limits.
[I'm sure that this follows from some well-known result, but since I
don't see it, I'll just continue with a direct proof.]
So, let $J$ be an index category, let
$F\colon J\to D$ be a functor, and suppose that $\tau\colon
x\stackrel{.}{\to} UF$ is a limiting cone in $C$.  We would like to
show that there exists a
unique cone $\sigma\colon L\stackrel{.}{\to} F$ in $D$ such that
$U\sigma=\tau$, and that this unique cone is a limiting cone.
For uniqueness, suppose that $\sigma\colon L\stackrel{.}{\to} F$
satisfies $U\sigma = \tau$. Write $F_j:=\langle y_j,f_j\rangle$.  Then
we must have for all $j$
$$
\sigma_j=(x\stackrel{f}{\to}x)\stackrel{\tau_j}{\to}(y_j\stackrel{f_j}{\to}y_j)
$$
for some $f\colon x\to x$ (hence we immediately see that $\sigma$ is
determined up to $f$). Now, since by the above we see that $\tau_j$
must be an arrow
$$
(x\stackrel{f}{\to}x)\stackrel{\tau_j}{\to}(y_j\stackrel{f_j}{\to}y_j)
$$
of $D$, the following diagram must be commutative for all $j$:
$$
\begin{matrix}
x & \stackrel{\tau_j}{\longrightarrow} & y_j =UF_j\\
f\downarrow & & f_j\downarrow\\
x&\stackrel{\tau_j}{\longrightarrow} & y_j = UF_j.
\end{matrix} \quad \text{(Diagram 1)}
$$
Now we claim that the $\to\downarrow$ part of the above diagram
forms a cone to $UF$, that is, we claim that the family
$\{f_j\tau_j\}$ forms a cone $x\stackrel{.}{\to} UF$.  Indeed, for an
arrow $g:j\to j'$ of $J$, consider the following diagram:
$$
\begin{matrix}
&&&&x\\
&&&\stackrel{\tau_j}{\swarrow}&&\stackrel{\tau_{j'}}{\searrow}\\
&&y_j && \stackrel{UFg}{\longrightarrow} && y_{j'}\\
&\stackrel{f_j}{\swarrow} &&&&&&\stackrel{f_{j'}}{\searrow}\\
y_j&&&&\stackrel{UFg}{\longrightarrow}&&&&y_{j'}
\end{matrix}
$$
The upper triangle is commutative because $\tau$ is a cone to the base
$UF$, and the lower trapezoid is commutative because $F$ is a
functor, and hence $Fg$ is an arrow $F_j\to F_{j'}$ in $D$. Hence the
outer triangle commutes, as required. From the universality of $\tau$,
it follows that there is a unique $f$ for which Diagram 1 is
commutative, and we have uniqueness.
For existence, we can take $f$ to be the unique arrow $x\to x$ for
which Diagram 1 is commutative, and we get a cone
$$
\sigma=\{\sigma_j=\tau_j\colon (x\stackrel{f}{\to}x)\to F_j=(y_j\stackrel{f_j}{\to}y_j)\}
$$
with $U\sigma=\tau$.  We claim that this is a limiting cone.
To see this, let $\alpha\colon(z\stackrel{g}{\to}z)\stackrel{.}{\to}F$
be a cone, so that
for all $j$ the following diagram is commutative:
$$
\begin{matrix}
z & \stackrel{\alpha_j}{\longrightarrow} & y_j\\
g\downarrow & & f_j\downarrow\\
z &\stackrel{\alpha_j}{\longrightarrow} & y_j.
\end{matrix} \quad\text{(Diagram 2)}
$$
Then $U\alpha$ is a cone $z\stackrel{.}{\to} UF$ in $C$, and by the
universality of $\tau$ there exists a unique arrow $h\colon z\to x$
for which the following diagram is commutative for all $j$:
$$
\begin{matrix}
z & \stackrel{\alpha_j}{\longrightarrow} & y_j\\
h\downarrow& \stackrel{\tau_j}{\nearrow}\\
x&
\end{matrix}\quad\text{(Diagram 3)}
$$
If this $h$ is an arrow $(z\stackrel{g}{\to}z)\to
(x\stackrel{f}{\to}x)$ in $D$, then we're done.  In other words, all
that remains to do is to show that the outer rectangle of the
following diagram is commutative:
$$
\begin{matrix}
z && \stackrel{h}{\longrightarrow} && x\\
& \stackrel{\alpha_j}{\searrow} && \stackrel{\tau_j}{\swarrow}\\
&& y_j\\
g\downarrow&& \downarrow f_j && \downarrow f\\
&& y_j\\
& \stackrel{\alpha_j}{\nearrow} && \stackrel{\tau_j}{\nwarrow}\\
z && \stackrel{h}{\longrightarrow} && x\\
\end{matrix}
$$
Now, the left trapezoid is just Diagram 2, the upper
and lower triangles are just Diagram 3, and the
right trapezoid is commutative for all $j$ by the definition of $f$.
It follows that both paths of the outer rectangle have the same
composition with the limiting cone $\tau$, and hence the outer rectangle
is commutative, as required.