Is 155/70 R13 75H suitable for Hyundai Santro?

Question: I have 3 new tyres of size 155/70 R13 75H and 1 tyre of 155/70 R13 75S. Does it make any difference?
Answer: The letter determines the max payload of the tyre (Amount of max load at specified max speed)
It is recommended that you do not mix tyres with different payloads. Even if you do, it should be done in pairs.
God forbid, but during accident claims some insurance companies might create a mayhem if manufacture recommended tyres are not used.
You might find this helpful:
http://www.tyrepower.com.au/tyres/tyre-tips/tyre-loadspeed-rating/
Answer: Technically you should be driving for the lowest rating of your tires, your S one is the lowest rating of the ones you have on (S=180kmh H=210kmh). Think about when you put up the spare tire because you have a flat, that one is the one telling you how to drive (obviously a spare is a spare and you are not supposed to keep it on the car forever). Rather than the suitability of the H tires for your car you should pay attention to the safety issue that is mixing tire rated speeds. While one could say to just adapt to the lowest rated speed, the fact is that tires made for different speeds are engineered in different ways, so now you have a tire that does not react to your driving in the same way the other three do and that can be cause of poor handling. That could be minor but there's always the risk that it will catch up on you at the worst moment.


Does Garmin G300 GPS use true heading or magnetic?

Question: Does Garmin G300 GPS use true heading or magnetic?  Sorry couldn't find this information anywhere else.
Answer: This document from Garmin states on page 265 that headings are magnetic headings. Grid lines shown on the terrain display are oriented to True north, but that is the only reference in the manual to true north. All other occurrences of "true" in the manual refer to True Airspeed.
Which is to be expected; nearly all headings in aviation are magnetic headings. Courses can be true or magnetic, but they're converted to magnetic before they're converted to headings. (Yes, grid navigation near the poles uses other than magnetic headings, but those aren't oriented to true north either, and this Garmin doesn't do grid navigation.)


Difference between firmware, bootloader, and the code memory

Question: I am new to microcontrollers and am facing a problem regarding the understanding of the terms firmware, bootloader and the actual code of a microcontroller. In some places I have read that the firmware is there to communicate with other devices. But in some place I have read that the firmware is the code that runs on the microcontroller mainly the C code in case of Arduino. The bootloader is basically to initialize the counters etc. as far as I've read. Kindly tell me the difference in all of these in simple words as there is no clear explanation as far as I've seen.
Comment: There is no clear distinction. All code running on a MCU is firmware. Bootloader code and it is firmware. So is your own application code. The terms are not fixed as it depends on context. Sure a bootloader is a piece of code that allows you to reprogram the MCU through some interface which might otherwise be impossible. If you have a specific example then we might have a specific answer.
Comment: Considering I just turned ON my microcontroller. After that the bootloader being a part of the firmware will initialize the counters etc. What happens next. Will it wait for the new code or it runs the one present? And what terms to be used in this case?
Comment: But I have seen people distincting the firmware from the program memory code. They take the firmware as the code that is already in there which helps to give specific properties to the controller. Like its interference,bootloading etc?
Comment: Bootloading is a task performed by code running in the microcontroller. Configuring and operating interfaces is a task performed by code running in the microcontroller. Code running in the microcontroller is (probably) firmware (if not then it's software). There's a hazy line between firmware and software though - as a firmware engineer who writes code for microcontrollers I regard anything running under linux (even if it's "embedded") as software. A developer of applications for set-top boxes might have a different opinion ...
Comment: I don't know why the distinction then. Also what counters would a bootloader initialize? It depends on what is the distinction on your specific setup. What is your setup? Bootloader may be what you as a user upload and it prepares system for your application code you upload. Bootloader may be factory made and not removable, and you don't have to use it, or it can be skipped completely when you are not updating the application.
Answer: Different groups use different terminology.
For starters, some groups will use "firmware" exclusively for FPGA bitstreams, and "software" for anything that runs on a processor -- or "firmware" will be for bitstreams and boot code, but not for anything on a thumb drive, etc.  Just be prepared to have to figure things out from context, and if source "A" seems to disagree with source "B" it's probably because they are, actually, in disagreement.
If there's no FPGA in sight, then "firmware" and "bootloader" are both actual code of the microcontroller.
Note that some people get really hot about the precise definitions of these -- I've learned not to care, and just go with whatever the group I'm in uses.

"Firmware" -- usually means the code a microcontroller runs if it's "little", i.e. if it's flashed on and not on something that looks like a disk.
"Software" -- something that's on a disk, or source code for the firmware depending on who you ask.
"Bootloader" -- firmware that boots the microprocessor, and manages downloading applications firmware onto flash.  It may be build in to the chip, or you may have written it to support your own communications scheme.
Comment: And some might call FPGA configuration binaries as gateware. Anyway firmware is more a function described as fixed because most MCUs do not load software applications from a file system. Firmware is a good name for computer/phone program that almost never changes and is used to load/start/boot the OS from disk.
Comment: I hadn't heard "gateware" before.  There's a need for terminology to keep things straight, and the technical environment keeps changing.  So you get new words, and confusion.


How can I create a page that will look different to each user/is customizable by each user?

Question: The reason I want it to be a page rather than using the MySite Site Collection is because I want each user to be able to customize their page with certain document libraries and for it to be accessible in the main site. Not sure if it's even possible, but thought I'd ask anyways. Thanks in advance.
Answer:
How can I create a page that will look different to each user/is customizable by each user?

You can't in any manner which would be manageable. This is a bad idea and not really something that suits for SharePoint's architecture.
To some limit it's possible to have content which shows up as user-specific. This would be possible with e.g. libraries and lists by having views configured to show items created by <code>[Me]</code>, but that's about that.
What is not possible, is that you can't let users to customize one and only one page with varying content, as all of the content would need to be stored in the page despite how it would show up for an individual. Even you managed to achieve a page which shows up as blank for each unless they modify it by content specific to them, the SharePoint's limitations would be faced quickly. A SharePoint page has a limit of maximum 50 web parts per page, so I'd imagine 25 users would overcome that in a moment, or fewer.
To more realistically do something as you'd require, each user should have their own pages, which would solve some above mentioned showstoppers. However, even with this implementation, you'd face a seriously unmanageable permission management challenge. So, in other words, don't.
So what's left is that your best shot to have individually manageable content would be to utilize the built-in my sites.


How to create a thick border around lines?

Question:
This is a cube and I have subdivided it. I want to delete all the faces and create a thick border around the lines. I am not too sure how to do that. Any suggestions?
Comment: Possible duplicate of [How to 'skin' an edge?](https://blender.stackexchange.com/questions/90162/how-to-skin-an-edge)
Comment: Sounds like you need to add a Skin modifier - this creates geometry around all the edges of the mesh.
Comment: What do you mean by thick? Thick as "width" parameter or 3D volume?
Comment: As for simple width you can go with "bevel" (Ctrl B) or "inset faces" (I), just use one of them after subdividing but before face deleting. For 3D volume use "wireframe" modifier
Comment: please add more information on what you are trying to do. Is this for an illustration? you could use Freestyle to render thicker lines. Is this for 3D printing? Is this for a game? depending on your purpose the solutions could be different. Use the [edit] link at the bottom of your question and add more information.
Answer: You can achieve this using the Skin modifier as described in How to 'skin' an edge.
Start with a subdivided cube :

Add the Skin modifier. In Edit mode, select all the edges and adjust the Mean Radius for each edge to affect the distance (use the Ctrl+A sortcut (while in Edit mode) or adjust in the properties side-panel) :

Add a Subdivision Surface modifier to smooth the surface :

Use the Skin modifier Smooth Shading checkbox to affect shading of the resultant mesh.
Note that you don't need to delete the faces since the Skin modifier only uses the edges of the original mesh.
Comment: Where is this in Blender 2.8? Ctrl+A does not work anymore.


Security Strength of BigInteger vs elliptic curve parameter value

Question: Choosing 512 bit prime biginteger as secret value as in RSA
Choosing TypeA curve (rbits=256,qbits=512) and setting secret value by randomly selecting from $Z_r$ value
I wanna know which one has more security strength even though I know 128 bit security can be obtained with 256 bit elliptic curve and 3072-bit RSA keys.I need some detailed explanation.When we set rbits=256 bits, is it 256 bit elliptic curve? Or when we set qbits=256 bits, is it 256 bit elliptic curve?
Comment: A "TypeA curve", do you mean a curve that is designed to do a so-called "Type A pairing"?  Unless you actually need to do a pairing operation, selecting such a curve is silly, as it is a deliberately weak curve (compared to a random elliptic curve of the same size)
Answer: A Type A curve has embedding degree 2. That means via the pairing we get an homomorphism from an ECC curve of bit length k to a finite field with 2 k bits (i.e. qbits).
You have to compare the complexity of:

calculating the discrete logarithm in the EC group with k bits and without using the paring homomorphism (i.e. by a generic algorithm)
calculating the discrete logarithm in the finite field with 2k bits by the number field sieve.

and take the minimum of both.
The complexity of a generic ECC DL algorithm is $2^{k/2}$
The complexity of the number field sieve for a finite field with k bits is approximately
$$\lambda (k) := \exp(1.9 (k \log (2))^{1/3} \log(k \log (2))^{2/3})$$
Therefore we have to compare $2^{k/2}$ with $\lambda (2k)$.
For big values of k, surely the factorisation in the finite field is faster then the generic ECC algorithm. So let us calculate the break-even point:
$$min_k (\lambda (2 k) = 2^{k/2})$$
This gives $k \approx 65$.
From that value of k on we can calculate the running time complexity as $\lambda (2k)$
For instance, an elliptic Type A curve with 256 bits gives you a strength of 63 bits only .
Please take this result with a grain of salt, because I have omitted the $o(1)$ term.
For real cryptographic use its maybe a better idea to use the table from the NIST SP 800-57 document:
<code>Strength  RSA modulus size
      80        1024
     112        2048
     128        3072
     192        7680
     256       15360
</code>
For instance, that would have the following security implication:
In order to get a strong security (i.e. strength >100) type A curve, you need a finite field size of 2048 bits. This means your type A curve must have rbits=1024 and qbits=2048.


Xcode images explanation

Question: What makes an image 1x, 2x or 3x (@1x, @2x, @3x)?  How can you make a 3x image?
Answer: iOS uses points instead of pixels in its coordinate systems. In the original non-retina devices (iPhone, iPhone3G, iPhone3GS, iPad, iPad 2, iPad mini, and early iPod touches) one point in the coordinate system mapped to one pixel on the screen of the device. At that time, life was simple, you provided images to your app that mapped to the point size and everything looked great.
When Apple introduced the first retina display devices (iPhone 4, iPad with Retina Display, and iPod touch 4), the devices had 2 pixels for every point. Apple devised a clever way of dealing with this. The programmer just had to add a second image to their program with the increased resolution and add @2x to the name. No changes to the code were needed. If your code loads an image called "house", iOS will load "house" on a non-retina device (such as the iPad 2 or original iPad mini), and it will use "house@2x" for the retina devices. The iPhone 6 Plus has even higher resolution so it uses a @3x version.
So what makes an image @1x, @2x, or @3x? If your "house" image is 120 pixels by 90 pixels, then your "house@2x" image should be 240 by 180 pixels, that is twice the number of pixels in each dimension ("2x" for short). The "house@3x" version should be 360 by 270 (3 times the number of pixel in each dimension).
It's up to you to make sure that the @2x and @3x versions have more detail, and not just more pixels. You can use a program like Photoshop or Pixelmator to create your images. Start by creating the nice highly detailed version of your image (the @3x version), and then scale it down to the @2x resolution and save that version as your @2x version. Then open your @3x version again and scale it to the @1x resolution and save that as your @1x version. Add all three versions to the Assets Catalog in Xcode, and iOS will load the appropriate version for the appropriate devices.
Comment: It's up to you how big you want your image to be on the screen.  If your image is to be 50 points by 50 points on the screen of the app, make your 3x version 150x150, your 2x version 100x100, and your 1x version 50x50. So in Photoshop, you would create an new image with dimensions 150x150.  After creating this image and saving it, you would rescale it by setting the image size to 100x100 and save that under a new name for the 2x version.  Then reload the 150x150 version and set the image size to 50x50 and save that under a new name for the 1x version.
Comment: Thank-you for this answer. It makes sense! I have one question and I have photoshop. You said to start creating the @3x version of the image. How do I do this? Are their dimensions? A resolution? Can I make the image any size. Thanks for the answer.
Comment: Thanks I am grateful for your answer and will know tick it. Thanks!
Answer: Read this to learn about the different resolutions:
http://www.paintcodeapp.com/news/iphone-6-screens-demystified
If you are looking for an inexpensive and easy way to create graphics, that will export in all three sizes, get Sketch 3:
http://bohemiancoding.com/sketch/
With Sketch you can make a graphic and then export it immediately in any size class you need.
Here are Photoshop step by step instructions for changing size.  If you have a vector drawing - lines and other shapes - you can start at any size and increase or decrease the size. The three photos below show increasing an image size.  If you have an image like a jpeg then you will want to start large and work smaller to avoid distortion.
Comment: Thanks, but I do not know what I makes a image 1x, 2x or 3x. Can you or anyone help.
Comment: Thanks for your answer it also helped but I can only tick one answer and that will be the other person. Sorry but thanks!
Comment: Click the voting arrows up. The ones on the left side of each answer.  Typically you both upvote (10 points) and accept (15 points) your winning answer.  The person receives 25 total reputation.  You can also, upvote any other helpful answers (10 points).  Rep points go to the responder.
Comment: Added some more help for Photoshop.
Comment: Hey no problem.  You got your problem solved.  I see you have >15 reputation, so you can upvote each of the responders for 10 reputation additional.
Comment: Thanks. What do you mean with the last sentence.
Comment: Yes @NathanSchafer you should up vote helpful answers.
Comment: I could not do this before because my reputation was too low.
Answer: There are plenty of online tool out there where you put the largest size there (1024x1024) and it will generate resized version for you. e.g. https://www.iconcutter.com
Answer: You can also use Prepo mac application for different size images like 1x, 2x and 3x.
Prepo link of app store
You need to just add your image and you can export with different sizes of those images (Artwork). It also supports app icons also.

Xcode images explanation


CATiledLayer is being rendered underneath a UIView

Question: I'm making a PDF reader that looks like a real book.
I have a UIImageView inside a scrollview as the book's background (imagine an open book with empty pages).  The UIImageView's layer has 2 sublayers each positioned over each page, CATiledLayers that render PDF content.
I have 2 UIViews whose layer uses an image as its contents.  When I hit a button to turn the page, I take the CATiledLayer attached to the background and remove him but then add him to the UIView's layer as a sublayer.  This UIView's layer animates a page turning, and with it animates that PDF page.  I create a new PDF page and put it where the old one used to be.
So now there is a PDF page as a sublayer on the background UIImageView, and a UIView overtop of that with a PDF page as a sublayer.  For some reason the PDF on the page underneath is visible during the animation.  It should not be visible because the turning page should be obstructing it.  Question is, why is that happening?
Comment: Fixed it.  I just had to change the zPosition property of the UIView's layers to a really high number like 10000.  I had it set to 0.1 initially but that wasn't enough.  Then the compositing worked again.
Answer: I just had to change the zPosition property of the UIView's layers to a really high number like 10000.  I had it set to 0.1 initially but that wasn't enough.  Then the compositing worked again.


Convert between different calendars (Gregorian/Julian) in WinRT... Windows.Globalization.Calendar?

Question: I am looking for a way to convert between the Gregorian and Julian calendars in WinRT.
Usually, I would use DateTime.FromOADate and DateTime.ToOADate, but these methods aren't available. So I found the Windows.Globalization.Calendar type which seems to have some sort of ChangeCalendarSystem method. But who knows how this type works? The method seems to accept something nice, Windows.Globalization.CalendarIdentifiers.Julian, but now I'm beginning to wonder...
And of course, no real docs, no blogs, no nothing - or maybe I'm looking wrong ;)
Can anyone help shed some light on how the type works in this regard, or maybe point me towards the correct types?
Answer: Windows.Globalization.Calendar is the correct thing to use. If you want to convert from Gregorian to Julian, set the calendar system to Gregorian by using ChangeCalendarSystem then set the constituents (starting with largest first: year, month, day,...) to their Gregorian values. Finally, change the calendar system to Julian and then get the constituents.
If you are just wanting to format the value in a different calendar system, you can use the DateTimeFormatter created with the particular calendar system.


PCB via size specification

Question: I am designing a PCB in Kicad and I can define any diameter and hole of a via, but when I send it to be manufactured in china (JLCPCB, PCBWAY, etc) they can put any size of via or will it adjust to the closest value they have?
The via I'm using must carry 5A, what standard value do you recommend? with a diameter of 1.6mm it should be enough but I am not sure if it is a commercial value
Comment: Not a full answer since it doesn't quite answer your question, but consider [a number of standard size vias](https://electronics.stackexchange.com/a/573829/9612) instead of larger ones if feasible.
Comment: Make all vias the same size and use more than one via for high-current links.It saves board space **and** it's cheaper.
Comment: Depends on the manufacturer. Some prefer the Gerber to be final hole size, others prefer pre-plating size. From my experience some manufacturers will also round via sizes (i.e. all holes smaller than x will be made y, and so on). But they generally make it very clear. (I mean, a good fab house SHOULD make it very clear).
Comment: This may be an X-Y problem.  I Just want to reinforce what nanofarad said:  For high currents, multiple smaller vias are almost always better than one large one.
Answer: One approach is to use the minimum size for minimum cost PCB if that works for your design. For example, for PCBWay there is a delta between 0.3 and 0.25mm for regular FR-4 boards, so if you can use 0.3mm or larger for all your vias it will save a bit of money (or a lot of money if you're tempted to use very small vias). The next steps are at 0.2 and 0.15mm.
For higher currents such as 5A you can refer to the design guides that many manufacturers supply. Probably 5 0.3mm (~12 mil) vias would be fine, according to this King Sun data assuming 10°C rise is acceptable. According to this calculator your suggested 1.6mm hole is also fine. They don't specify the rise allowed in their calculation though. Altium claims:

As long as your PCB traces are sized according to the minimum trace widths specified in the IPC 2152 standard, and your vias are sized to comply with DFM standards and applicable IPC standards, you won't have to worry about temperature rise in your vias. The excess heat in the interior of the via gets dissipated into the substrate and the nearby traces. In the case where the traces are very wide, they have a larger surface through which to dissipate heat compared to the via. In this case, the heat leaves the trace at a faster rate than it leaves the via, thus the trace will reach a lower equilibrium temperature. This was confirmed in the experimental study by Douglas Brooks and Johannes Adam in SIJ.

Generally you can request any size hole you want, within the capabilities list, and they will produce the holes within the specified tolerance after plating. For example, for PCBWay a 0.6mm drill results in a finished hole size between 0.52mm and 0.68mm.
Answer: 1.4 mm is the minimum drill size rated for a 5A PTH, so 1.6 mm is adequate.

Using teardrop trace to via connections for large pads makes them more rugged.
download
Answer: The board shop doesn't know or care whether a hole is for a via, for a component lead, or for a mounting hole, or just for ventilation - regardless of your purpose, to them it is just a hole to be drilled, so when specifying a hole size for any purpose, you must follow the shop's requirements for hole sizess.
Comment: Almost, but if the hole is to be plated then PCB packages typically specify the finished size, so the drill size will be slightly larger.

PCB via size specification


Quickbooks Enterprise Hosted integration

Question: I see a lot of integration w Quickbooks Online, but i need Enterprise - Hosted <-> Salesforce. Anyone has experience with this? thanks!
Comment: When you say "Enterprise - Hosted" are you referring to Quickbooks on a local server? If so, this can be done using SOAP or REST custom solution to your enterprise network. Look in the App Exchange for vendors if you don't want to build your own solution. If I'm not mistaken, it can also be done using Dataloader. It just depends on how frequently you want to sync between the two systems.
Comment: Yes on a server that client vpns into. Sync needs to be automated and frequent. Thanks!
Answer: I believe QuickBooks Hosted is just QuickBooks Desktop (and QuickBooks Enterprise) on a Citrix-esque server. So, you need to find a tool that will integrate with QuickBooks Desktop/Enterprise, then see if you can install the application on the Server your QB instance is running on.
So, I'd suggest you first check with the company providing the QB hosting and ask them if you can install a small application on that server.
If the answer is yes, you can look at the solutions provided by Avankia, Interweave, and a few others. Be warned that these solutions were developed a number of years ago and can be a bit heavy to setup.
If none of this works, and integration is an absolute must, you might have to move your QB to self-hosted.
Or, if cloud is more important, move to QuickBooks Online or Xero with an accountant.


Define Generic Data Model for Custom Product Types

Question: I want to create a product catalog that allows for intricate details on each of the product types in the catalog.  The product types have vastly different data associated with them; some with only generic data, some with a few extra fields of data, some with many fields that are specific to that product type.  I need to easily add new product types to the system and respect their configuration, and I'd love tips on how to design the data model for these products as well as how to handle persistence and retrieval.
Some products will be very generic and I plan to use a common UI for editing those products.  The products that have extensible configuration associated with them will get new views (and controllers) created for their editing.  I expect all custom products to have their own model defined but to share a common base class.  The base class would represent the generic product that has no custom fields.
Example products that need to be handled:

Generic product

Description

Light Bulb

Description
Type (with an enum of florescent, incandescent, halogen, led)
Wattage
Style (enum of flood, spot, etc.)

Refrigerator

Description
Make
Model
Style (with an enum in the domain model)
Water Filter information

Part number
Description

I expect to use MEF for discovering what product types are available in the system.  I plan to create assemblies that contain product type models, views, and controllers, drop those assemblies into the bin, and have the application discover the new product types, and show them in the navigation.

Using SQL Server 2008, what would be the best way to store products of these various types, allowing for new types to be added without having to grow the database schema?
When retrieving data from the database, what's the best way to translate these polymorphic entities into their correct domain models?

Updates and Clarifications

To avoid the Inner Platform Effect, if there is a database table for every product type (to store the products of that type), then I still need a way to retrieve all products that spans product types.  How would that be achieved?
I talked with Nikhilk in more detail about his SharePoint reference.  Specifically, he was talking about this: http://msdn.microsoft.com/en-us/library/ms998711.aspx.  It actually seems pretty attractive.  No need to parse XML; and there is some indexing that could be done allowing for simple and fast queries over the data.  For instance, I could say "find all 75-watt light bulbs" by knowing that the first int column in the row is the wattage when the row represents a light bulb.  Something (NHibernate?) in the app tier would define the mapping from the product type to the userdata schema.
Voted down the schema that has the Property Table because this could lead to lots of rows per product.  This could lead to index difficulties, plus all queries would have to essentially pivot the data.
Comment: It seems like the XML field is prevailing.  But I haven't gotten much for how to instantiate domain objects from the data.
Answer: Use a Sharepoint-style UserData table, that has a set of string columns, a set of int columns, etc. and a Type column.
Then you have a list of types table that specifies the schema for each type - its properties, and the specific columns they map to in the UserData table.
With things like Azure and other utility computing storage you don't even need to define a table. Every store object is basically a dictionary.
Answer: I think you need to go with a data model like --
Product Table

ProductId (PK)
ProductName
Details

Property Table

PropertyId (PK)
ProductId (FK)
ParentPropertyId (FK - Self referenced to categorize properties)
PropertyName
PropertyValue
PropertyValueTypeId

Property Value Lookup Table

PropertyValueLookupId (PK)
PropertyId (FK)
LookupValue

And then have a dynamic view based on this. You could use the PropertyValueTypeId coloumn to identify the type, using a convention, like (0- string, 1-integer, 2-float, 3-image etc) - But ultimately you can store everything untyped only. You could also use this column to select the control template to render the corresponding property to the user.
You can use the Value lookup table to keep lookups for a specific property (so that user can choose it from a list)
Answer: Summarizing lets look at the options under consideration for storing product information:
1) some xml format in the database
2) similar to the post above about having x number of type defined columns (sharepoint approach)
3) via generic table with name and type definitions stored in lookup table and values in secondary table with columns id, propertyid, value (similar to #2 however this approach would provide unlimited property information
4) some hybrid of the above option where product table would have x common columns (for storage of properties common with all products) with y user defined columns (this could be m of integer type and n of varchar types).  This may be taking the best of #2 and a normalzied structure as if you knew all the properties of all products.  You would be getting the best sql performance for the properties that you use the most (probably those that are common across all products) while still allowing custom columns for specific properties with each product.
Are there other options? In my opinion I would consider 4 above as the best hybrid of the combinations.

dave
Answer: Put as much of the shared anticipated structure in traditional normalized 3NF model, then augment with XML columns as appropriate.
I don't see MEF (or any other ORM) being able to do all this transparently.
Answer: I think you should avoid the Inner Platform Effect and actually build tables for your specialized entities. You'll be writing specific code to manage them so why not have proper backing tables too?
It will make your deployment slightly harder - drop in an assembly and run a script - but it will probably save you a lot of pain in the long run.
Answer: Jeff,
we currently use a XML field in the Products table to handle all product-specific data. So our Products table has a few common fields that all products share, an XML which contains whatever a particular product needs additionally, and a few computed fields that grab into the XML and surface some of the frequently queried fields as "virtual" fields on the Products table (e.g. "Style" would be set to whatever the current product defines, or NULL, if the product doesn't have a Style property).
So far, we've been quite flexible with that approach - if you create some decent XSD schemas for your XML, you can even create C# proxy classes for these fields.
Works nicely for us - joining the best of both the relational and XML worlds.
Marc
Comment: Could you please reference some documentation or topics to study on this db model? I'm looking for a neat way to create products attributes related to categories. The XML and SQL mixed approach seems interesting.


How to use a supernode or supermesh with regard to this circuit?

Question:
Is the two ohm resistor in parallel with the dependent current source disregarded when using a supermesh? I have not gotten the correct answer of Va=1V Vx=-4 . What are the steps?
Comment: The are **five** 2 Ohm resistors and **none** of them is in parallel to any other component. Which one do you mean when you talk about **the** 2 Ohm resistor?
Answer: Supernodes are used to do nodal analysis on circuits containing voltage sources. You would make a supernode from each pair of nodes that are connected by a voltage source.
Since you ask specifically about the supermesh, I won't give any more detail about supernodes. If you want more detail, you need to name all the nodes in your circuit.
Supermeshes are used to do mesh analysis on circuits containing current sources. You make a supermesh for each pair of meshes where a current source lies on a branch shared by two meshes.
For example, in your circuit, let's call the left mesh (containing the 5 V source) #1, the upper right mesh (containing the \$2 I_x\$ CCVS) #2, and the lower right mesh (containing the 7 V source) #3. We'll define all mesh currents in the clockwise direction.
Now mesh currents \$I_2\$ and \$I_3\$ can't be determined independently because of the VCCS \$0.8 V_x\$.
So you create a supermesh \$I_{23}\$ encompassing those two meshes, with a joining equation \$I_2 - 0.8 V_x - I_3 = 0\$. The mesh equation for the supermesh is made by following the outer perimeter of the supermesh and algebraically summing the voltage drops:
$$ -9\mathrm{V} - 2 I_x + 2 I_3 - 7 \mathrm{V} - 2 I_3 - 2 (I_3 - I_1) = 0$$
Comment: @anonymous editor: You are trying to edit the last equation to use a different sign convention than I used when writing it. Your version would be correct if the mesh current was taken counter clockwise rather than clockwise. But since I said I will take the current clockwise, this change is incorrect. Please stop editing.


How to insert user registration data to non-drupal table

Question: I installed drupal 7.34 with oracle database. Now i need to save user registration data to another non-drupal table. User authentication also need to do with these non-drupal database field. Is there any method to generate the per-existing set of users in non-drupal database as drupal users.
Comment: What issues @drup? (please edit this information into the question)
Comment: Doable, but will require a lot of coding - obviously it is hard to expect anyone had exactly the same use case you do now, right? Have you started implementing it? Do you have a starting code and *specific* question? It's not possible in Q&A format to guide you all the way.
Comment: We partially succeeded to implement user login. Issues raised when we move into user registration.
Comment: I am getting this error. PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DB.register' doesn't exist: INSERT INTO {register} (uid, name) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 11 [:db_insert_placeholder_1] => firstname.lastname@example.com ) in register_user_insert() (line 8 of sites\all\modules\register\register.module).
Answer: This looks similar to what happens when someone tries to access CiviCRM tables from Drupal when the CiviCRM tables exist in different database containers.
https://www.drupal.org/node/1569656.
Are these tables in the same database container or just on the same database server?
You may want to look at How to use separate databases for Drupal tables?
It might also be worth looking at http://wiki.civicrm.org/confluence/display/CRMDOC44/Creating+a+Drupal+user+for+every+CiviCRM+contact
That gives both a manual process of generating Drupal users from a CSV export as well as the drush method.
Comment: Both drupal and non-drupal sites shares same database, but under different users. Like user1.table1 and user2.table2. Do i need to change DB schema for this non-drupal table to save my user registration details?
Comment: "Base table or view not found" means just that. With the db connection configured the way you have it, the db user running this query cannot "see" the table.  Since line 8 of https://www.drupal.org/project/register isn't a query, I'm assuming that this register.module is a custom module.  (FYI you should really prefix your custom modules so they don't conflict with exiting projects).  I don't know much about Oracle db permissions, but my guess is if you try to run the same SQL query that's in register_user_insert() directly using the same dbuser, it will return a similar error. Good luck!


Python multiprocessing's Pool process limit

Question: In using the Pool object from the multiprocessing module, is the number of processes limited by the number of CPU cores? E.g. if I have 4 cores, even if I create a Pool with 8 processes, only 4 will be running at one time?
Comment: There is no limit as to how many you can create; but starting at a certain number the effectiveness of using multiple processes will turn into a penality. How big that number is depends a lot on what the threads will do; if there is only the processor at work, then you shouldn't start more processes than your processor supports threads (e.g. i7 4-core processors have 8 threads).
Comment: The limit of linux (user/system) process is defined in /etc/security/limits.conf.
Answer: You can ask for as many processes as you like.  Any limit that may exist will be imposed by your operating system, not by multiprocessing.  For example,
 p = multiprocessing.Pool(1000000)

is likely to suffer an ugly death on any machine.  I'm trying it on my box as I type this, and the OS is grinding my disk to dust swapping out RAM madly - finally killed it after it had created about 3000 processes ;-)
As to how many will run "at one time", Python has no say in that.  It depends on:

How many your hardware is capable of running simultaneously; and,
How your operating system decides to give hardware resources to all the processes on your machine currently running.

For CPU-bound tasks, it doesn't make sense to create more Pool processes than you have cores to run them on.  If you're trying to use your machine for other things too, then you should create fewer processes than cores.
For I/O-bound tasks, it may make sense to create a quite a few more Pool processes than cores, since the processes will probably spend most their time blocked (waiting for I/O to complete).
Comment: Keep in mind that the processes result from `os.fork`, and so will involve copies of the parent process's memory footprint. This might be copy-on-write in some operating systems, but in general the circumstance of wanting to utilize a large number of 'units' that each perform a task that can be asycnhronously handled to avoid blocking, threads are often a better 'unit' of asychrony than processes (but not always). And even with GIL, threads that perform GIL-releasing operations can benefit from this.
Comment: using more processes can cause memory leaks? multiprocessing.cpu_count() returns 16 on my system, I am using 8 (cpu_count //2).
Comment: Your operating system requires RAM for every process you create.  That's not "a leak": when you create a process, you're _forcing_ the OS to eat that RAM.  8 processes should be close to trivial on any modern box.
Answer: Yes. Theoretically there is no limit on processes you can create, but an insane amount of processes started at once will cause death to the system because of the running out of memory. Note that processes occupy a much larger footprint than threads as they don't use shared space between them but use an individual space for each process.
so the best programming practice is to use semaphore restricted to the number of processors of your system. likely
pool = multiprocessing.Semaphore(4) # no of cpus of your system.

If you are not aware of the number of cores of your system or if you want to use the code in many systems, a generic code like the below will do...
pool = multiprocessing.Semaphore(multiprocessing.cpu_count())
#this will detect the number of cores in your system and creates a semaphore with that  value.

P.S. But it is good to use number of cores-1 always.
Hope this helps :)
Answer: While there is no limit you can set, if you are looking to understand a convenient number to use for CPU bound processes (which I suspect you are looking for here), you can run the following:
>>> import multiprocessing
>>> multiprocessing.cpu_count()
1

Some good notes on limitations (especially in linux) are noted in the answer here:
Answer: That is correct.  If you have 4 cores then 4 processes can be running at once.  Remember that you have system stuff that needs to go on, and it would be nice for you to define the process number to be number_of_cores - 1.  This is a preference and not mandatory.  For each process that you create there is overhead, so you are actually using more memory to do this.  But if RAM isn't a problem then go for it.  If you are running Cuda or some other GPU based library then you have a different paradigm, but that's for another question.


Manual rotation of water pump before starting the engine. Is it necessary?

Question: Today, I came across this article while surfing through Gates website:
https://www.gatestechzone.com/en/news/2017-06-water-pump-replacement
It mentions some points about installing a new water pump. The 5th one says:
A lot of mechanics stick to the following procedure: replace the water pump, tighten the bolts, install the belt, tighten the tensioner, refill the cooling system … and start the engine (or just rev it up). But coolant takes a little time to get everywhere it's supposed to be, so the water pump runs dry for a few seconds. This ruins the seal and heightens the risk of premature leaks or a noisy water pump. Instead we'd advise you to ease the car down after you've installed a new water pump, refill the cooling system, lift the car back up and manually rotate the pump about ten times, all the while making sure it rotates freely. Due to this rotating movement, coolant gets sucked into the mechanical seal component, effectively creating a film, which keeps coolant from spilling out.
I don't understand this paragraph.
It says the pump runs dry for a few seconds. How is this possible? Isn't the pump immersed in coolant when you refill and bleed the system? Why should we rotate it manually?
Answer: Because the coolant does not get fully circulated around the shaft / seals of a pump and seals get damaged when they run dry.
So rotating the pump lubricates the seals and doing that at low rpm is better than engine speed or 2* engine speed depending on pulley ratios.
Comment: "at low rpm" means low rpm like by hand
Comment: Great answer! So, could we just install the new pump, fill the system and rotate pump shaft by hand before installing the belt? (Without having to rotate the engine by crank pulley with the belt on)


Careers in Academia in Belgium and Salary (Intend to move from Canada as a PR)

Question: I am currently working as an Assistant Professor since more than a year in Canada after my PhD (graduated last year). In near future, I intend to move to Belgium, I am looking for some insights what to expect in terms of academic job prospects and salary expectations. I am not a Canadian citizen yet but a permanent resident. Also I do not speak Dutch.
Any other general advice and guidelines based on experience will be appreciated.
Comment: How is your French? Half of Belgium is French-speaking.
Comment: @Buffy: certainly. As are parts of Africa. My comment was in the context of OP considering a move to Belgium but only mentioning their proficiency in Dutch... I wouldn't necessarily expect a permanent resident in Canada to speak French.
Comment: @StephanKolassa, as are parts of Canada and, ummm, Switzerland. ;-)
Answer: Belgian univerities are either French speaking or Flemish (Dutch) speaking.  Most teaching, in my experience, almost all at bachelor level, and some at masters level will be done in whichever is the native language of the university.  Some teaching may occur in English.  The university will also generally run in that language, so meetings, emails etc will be in French or Dutch.  Notice, I'm saying 'or' not 'both' - a Wallonian (French speaking) university will not use any Dutch and vice versa for the Flemish universities.
In the job adverts I've seen, at Flemish universities, it's standard practice to ask that a candidate can reach C1 level in Dutch within 2-3 years.  This is a high level of competancy in a langauge, and it will be extremely hard to reach this level, alongside teaching new courses, getting new research projects up and running etc.  If you want to apply for these posts, start learning the language now, so you can get a head start on this requirement.  Once you get a position there may be some language learning support provided by your department to help you attain this level.
I don't know if Wallonian universities have similar requirements for French, but I would imagine so.
You should also be aware that general networking at conferences will take place in French/Dutch even if the conference talks are in English. I've been to several Belgian/Dutch/Luxembourgian (Benelux) conferences, and the profs generally cluster chatting in their native languages, while the more international phds/postdocs chat in English.
Finally, you asked about job prospects - generally Belgian students have quite a number of publications at completion of their phd, as they are often required by the university or department to publish (sometimes multiple papers) to get their phd.  This can put people who are from countries which tend to write a book form thesis and then extract papers and publish afterwards at a big disadvantage when it comes to job applications and grants especially early in your career.


X11: ^C drop to shell while start X

Question: I use xinit to start X with wm - startx command that using .xinitrc to invoke X11 environment, but when X starts, there a black screen with cursor staying there for few seconds before X is fully started and if I press ctrl-c to interrupt the process, it will drop to shell, meaning user always has a way to go into shell - how to disable this ability?
Comment: Did you try `wm - startx &` to run it as a background task?
Comment: @Zhro: I just use `.profile` to `startx`, what's difference with your command? I'll try and give feedback.
Answer: The issue here is that you're calling startx in the foreground. If you want it to run in the background and not be susceptible to ctrl-c then append & at the end of the command.
For example:
sleep 3s && echo 1

This command will sleep for three seconds and then echo 1 to standard output. As it is in the foreground, you can interrupt it with ctrl-c.
Alternatively, you can continue to work on other things in the foreground while it runs in the background until either you log out or it terminates:
sleep 3s && echo 1 &

See here for more examples:
https://www.cyberciti.biz/faq/unix-linux-jobs-command-examples-usage-syntax/
If you are just running startx then try replacing it with startx &.

X11: ^C drop to shell while start X


Stream rasberry pi audio to my windows pc

Question: On my Raspberry Pi Zero I'm using an HDMI to VGA adapter. So I have no audio output for my RPIZ. I'm wondering how hard would it be to stream audio from my RPIZ to my windows 7 PC.
Comment: Hello and welcome. I believe there have been q&a's about that issue before. Did you search the site for those? It furthermore sounds like a weird setup. You intend to run that windows machine every time the Pi operates? If so, could the windows PC not just do the job ;-) It might be worth considering an additional analogue output to simplify things. There is also a Q about that on the zero.
Comment: I have not found anything yet on the topic. I found people wishing to stream audio to the RPi but not the other way around.
Comment: Further to the oddness: It's *really* common for HDMI to VGA adapters to include a 3.5mm analogue audio out socket. If yours doesn't, it may be worth investing in one that does. They're fairly cheap. I've used [these](https://www.amazon.co.uk/Tendak-Gold-Plated-Adapter-Converter-Projector/dp/B00VTJVJ3S?ie=UTF8&redirect=true&ref_=pe_931411_45466481) Tendak ones before, and they work fairly well on HDMI bus power alone.
Comment: If you only want to stream audio, VLC can do that.

If you want to display video on the HDMI/VGA and stream the audio, I imagine that *can* be done with some low-level VLC, but I'm not sure. But really, why don't you pick up a pHat DAC? Very sweet audio output device.
Comment: After dwelling on this for a moment, I realise that there is a *possible* path, depending on how adventurous you are.. On Ubuntu (at least) you can route the audio output from VLC to JACK and from there route to some streaming software (gstreamer?). It *can* be done, but if your aim is video on HDMI and audio on PC, you'll probably experience lag for the streaming audio that could possibly be adjusted by delaying the video in VLC.
Answer: You can probably work out a solution which uses ffmpeg rtp to stream the audio in real time (with a small amount of latency) from an alsa audio driver to a different computer. I assume you have some sort of networking going on ... possibly over usb ?
Look for information on ffmpeg (avconv on the pi) "-i alsa" using the real time "rtp://" protocol ... which is basically a UDP streamer. You will want to use an ALSA plugin which allows you to copy the output stream in some way for use as an input stream.
If you want audio input/output through the GPIO header, elinux has a good list of available audio add on solutions :
http://elinux.org/index.php?title=RPi_Expansion_Boards#Sound


What to do if the data in a paper you are reviewing is copied from another paper of the same authors which is supposed to be a different device?

Question: I got a paper to review and the authors of this paper already published a conference proceedings on the same topic but supposedly a different device. When comparing the figures of the conference proceedings and the submitted paper it becomes apparent that the data is exactly the same. This should not be possible as even the noise patterns are agreeing and the device structure is different enough to show different results.
What are my options?
Comment: I think a word or two might be missing from the title: "...supposed to be *obtained from* a different device", perhaps?  As it is now, the title seems to refer to the paper itself as a "device", which is confusing.
Comment: @RichardErickson: The field is irrelevant here. One or the other paper commit academic fraud by presenting data that does not match the description. Whether the paper is worth a lot of not does not matter. It's the same as stealing a silver ring from a store -- not worth as much as a gold ring, but still theft.
Comment: What field are you in? I'm in the life sciences and conference proceedings/abstracts usually do not carry much weight. However, I've heard that other fields such as computer science and mathematics gives much more weight to conference proceedings.
Comment: @WolfgangBangerth, You're correct. I misread the original post and didn't notice the `research-misconduct` tag. I was placing more emphasis the `plagiarism`. The question title places the emphasis on coping data rather than fraud, which is the bigger issue regardless of field. (PS thanks for you calling me out on that).
Answer: I didn't quite understand the nuances involving "different device", but if I have the rest right: you've observed that the data of the present submission is identical to that of a past submission.  The present submission involves something different enough so that identical data is not plausible, and therefore you strongly suspect that the data included in the present submission is not legitimate.  Is that it?
If so, I see just one reasonable option: bring this information to the attention of the editors.  It is serious enough that you need not (and perhaps should not) make a recommendation of acceptance or rejection: this needs to be resolved first.
Comment: @WolfgangBangerth, *apparent* academic fraud.  I wouldn't be comfortable saying it *is* academic fraud (as opposed to, say, accidentally pasting the wrong graph into the paper) without better evidence.
Comment: Having been in this position as both a reviewer and an editor, I concur: There is no need for your to write a complete review. Just send an email to the editor (and maybe the managing editor at the publisher) with a note that you have found an instance of academic fraud. They will (hopefully) handle the rest.
Comment: If someone did manage to write a whole paper in which they accidentally analyzed the wrong data in a way that looks like fraud, then that is staggering negligence even if it's not fraudulent (and I wouldn't be unhappy to see it treated similarly to fraud).
Comment: I believe the poster means "a different experimental device."  (If true, this would allow the author to publish a second paper.)
Comment: All fair points. That said, I don't believe that there are cases of "accidentally pasting the wrong graph into a paper". I believe that there are only cases where people do it knowing full well what they are doing and later claiming that it was accidental.
Comment: @AnonymousMathematician Is it possible that they analyzed the right data, but then put the wrong data in the figure?
Comment: Yeah, it's certainly important to check whether the discussion in the body of the paper matches the figure.  If it doesn't, then substituting the wrong figure is much less consequential.
Comment: It'd be tactful to avoid using the words "academic fraud" - just say that you've noticed a figure was copied from another source. The editor certainly knows that this constitutes fraud unless there is a legitimate reason for the copying.


Get something over to somebody?

Question: I am watching The Office (UK) to improve my English. In the beginning of EP1, the actor said "We'll get a CV over to you this afternoon". I guess he will send the CV to another person. Is there any difference between the way he talks and just a simple sentence "I will it send to you" ? I googled it but not much result about it.
Answer: It means that the CV will arrive at its destination sometime in the afternoon but that the means by which it will get there is not specified. It may be sent by courier but it may be taken there by the speaker in person or a member of his team in which case it will have been 'taken' or 'brought' rather than 'sent'. However it will still have been 'got there'.
Answer: There is a slight difference between the two.
"We'll get a CV over to you this afternoon"   - promises that the item will arrive this afternoon.
"I will it send to you" - only says that the item will be sent. It makes no promise as to arrival time. Depending on delivery method, it might take several days.

Get something over to somebody?


can I centralize SQL and AD users via LDAP?

Question: I have to mention that I am talking about 60 - 100 users.
We are having SQL database for specific internal use, where contain all the users in the company. Now we are deploying Windows Active Directory and think of a way to centralize the users.
Here is my confusion, since LDAP is a protocol, where should the users be ? On the Active Directory and shared to the SQL via LDAP ? Or on the SQL and shared the way around ? I am totally confused here..
Answer: There is no way to share users from LDAP to DB or the other way around. The users can be in LDAP, in DB or in both.
LDAP, beside being a protocol, is a directory: user entries may contain attributes (like givenName, surname, mail ecc) other than uid and password.
You can import attributes from DB to LDAP, but then you need to sync the sources.
Generally speaking it depends on what you need to do.
Comment: Thanks for the answer! My idea is to add users to the AD and though LDAP to add the user to the SQL as well, instead of adding the same user twice.
So I have to Host the LDAP from the DC and sync the SQL to that LDAP server ?
Comment: Let me rephrase your question: users are inserted in AD. With a custom procedure you push AD data to SQL using a ldap search. It is that? It's ok, but please remember you have to track user deletions and updates as well!
Comment: Yes, basically that is the idea behind that LDAP that I wanna set up, but I got totally confused about it. So if I got you right, I can not make automatic user export via LDAP from the AD,DC (I plan to place them together), so it has to be done manually? Or scheduled a script for it. So  for LDAP I need to run only services, no need to make it as a server, if AD run LDAP services the authorized SQL can export user data from there? - Is my understanding correct?
Comment: Every authorized user can query the AD LDAP and extract the AD users. This is generally a manual process (or scripted).


Can anyone explain what are the inbound and outbound relay in the mail server?

Question: Can anyone explain what are the inbound and outbound relay in the mail server?
Comment: Are you asking about specific settings in a mail system, or just general inbound/outbound relays?
Comment: What mail server are you referring to?
Comment: Would be good to have answers for both  general inbound/outbound relays and MS exchange specific inbound/outbound relays.
Answer: An inbound SMTP relay can be seen as a firewall filtering data coming from outside, it receives emails that are destined to your domains and redirects them to your main mail server. It usually filters emails with a destination that is not one of your domains, or emails containing spam or viruses...
An outbound SMTP relay receives all the emails from your main mail server which are destined to the outside world and sends them to the appropriate outside mail servers. It can also filter emails that contain spam or viruses.
Be sure to read about Open mail relay and make sure that your relays are not open relays.


How to force a server to use a specific elliptic curve at the beginning of the handshake via openssl?

Question: Is there a possibility or command in openssl to force a server to use a specific elliptic curve that I am requesting with a certificate or key? Can I "ask" the process the curves it is able to use?
Comment: you can specify in a configuration file
Comment: You mean for ECDHE?
Comment: Yes. It should be used for the key exchange. Just ECDH is also possible.
Answer: Your question is ambiguous and the answers are quite different.
Protocol. The supported-curves extension in the ClientHello message specifies the curves (standard/named, or 'explicit' GF(2^k) or GF(p)) the client is willing to have the server use. If it specifies more than one, the server can choose any of them; if it specifies one, that's the only one the server can use. If the server does not support the or any specified curve, the negotiation cannot select any EC suite, and unless other suites are supported by and acceptable to both ends the negotiation fails.
OpenSSL client to any server through 1.0.1 always sends this extension to allow all named curves (in rfc4492) and no explicit curves. Except RedHat (AFAIK still?) nobbles its OpenSSL builds to P-256, P-384 and P-521 only. 1.0.2 adds new API calls to control this extension, see https://www.openssl.org/docs/ssl/SSL_CTX_set1_curves_list.html . So either code and build your client program against 1.0.2* and not on RedHat, or get whoever maintains your client program to do so.
Any client to OpenSSL server for ECDHE. OpenSSL server through 1.0.1 can be configured in advance of handshake, either for all connections sharing an SSL_CTX or for each SSL connection separately, with ECDHE "temporary parameters" which is (are?) the curve. Only the configured curve is used for key-exchange. For ECDHE-ECDSA the publickey in the cert used (with its matching privatekey) to authenticate, can use a different curve; that key and curve was chosen before the cert was issued and "approved" by the CA and can't be changed now, whereas the "temporary" ECDHE choice is made by the server code or configuration. If either the "temp" curve, or the cert curve when the cert is ECC, is not in the list allowed by the client, then ECDHE or ECDHE-ECDSA can't be negotiated.
Instead of configuring in advance, the server can set a callback invoked by OpenSSL library to choose the ECDHE curve (or key) for a particular handshake. This should choose a curve acceptable to the client, unless that is unacceptable to the server. Again for ECDHE-ECDSA, the curve in the cert for authentication may be different, was already chosen before issue and can't be changed, and if not acceptable to the client can't be negotiated. Finally new in 1.0.2 there is an option for OpenSSL to automatically choose an ECDHE curve acceptable to the client while "matching" the strength of the authentication.
In server for static ECDH the curve (and key) used for key-exchange is the one in the cert, which as above was chosen before the cert was issued and cannot be changed. If this curve is not acceptable to the client, ECDH can't be negotiated.
Answer:
Is there a possibility or command in openssl to force a server to use a specific elliptic curve

In general, I'm not sure how to do this through a CONF file. The SSL_CONF_* API calls (shown below) seem to indicate it can be part of a configuration file. But I've never done it.

How to force a server to use a specific elliptic curve at the beginning of the handshake via openssl?

You can, but you have to modify your sources. Here's from one of the OpenSSL devs in a private email. But I'm not sure it works in practice because I use the patching method described below.
Under 0.9.x:
         int nid = OBJ_sn2nid(named_curve);
         ecdh = EC_KEY_new_by_curve_name(nid);
         SSL_CTX_set_tmp_ecdh(ctx,ecdh);
         EC_KEY_free(ecdh);

 Under 1.x:
         SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
         SSL_CONF_cmd(cctx, "-named_curve", "P-256");
         SSL_CONF_CTX_finish(cctx);

For 1.0.1 and below, you can modify the sources to t1_lib.c. In particular, find ssl_prepare_clienthello_tlsext and pref_list and change it to what you like. Here's what it looks like by default:
static int pref_list[] =
 {
   NID_sect571r1, /* sect571r1 (14) */
   NID_sect571k1, /* sect571k1 (13) */
   NID_secp521r1, /* secp521r1 (25) */
   NID_sect409k1, /* sect409k1 (11) */
   NID_sect409r1, /* sect409r1 (12) */
   NID_secp384r1, /* secp384r1 (24) */
   NID_sect283k1, /* sect283k1 (9) */
   NID_sect283r1, /* sect283r1 (10) */
   NID_secp256k1, /* secp256k1 (22) */
   NID_X9_62_prime256v1, /* secp256r1 (23) */
   NID_sect239k1, /* sect239k1 (8) */
   NID_sect233k1, /* sect233k1 (6) */
   NID_sect233r1, /* sect233r1 (7) */
   NID_secp224k1, /* secp224k1 (20) */
   NID_secp224r1, /* secp224r1 (21) */
 };

Also see Issue #3179: Feature Request: Set Preference List for EC Curves in Client.

For OpenSSL 1.0.2 and above, you can use SSL_CTX_set1_curves. pref_list is no longer present when grepping the sources.


preg_match_all not working when trying to get all characters including whitespace

Question: Here is my function:
function grabstuff()
{
    foreach (glob("../folder/*.php") as $fn)
    {
        $file = file_get_contents($fn);

        preg_match_all("#\{\('(\w+)'\)}#", $file, $matches);

        foreach ($matches[1] as $match)
        {

            $query = ("ALTER TABLE xxxxx ADD COLUMN `$match` LONGTEXT AFTER xxxxx;");

            $result = mysql_query($query) or die("Err: ".mysql_error());

        }
    }
}

And here is what it looks for on the pages:
<?/*{('test test')}*/?>

It is ignoring this instance where there is a whitespace.  It works well for testtest and test_test.  Not getting any php errors or mysql errors.  Do I need to use \w+\S or \w+\W?  I tried both of those, even (...) and it still didn't work.  How do I get my above function to recognize any characters within the {('')}, whether they be a normal abc characters or whitespace.  I'm sure this is simple.  I've done research on google and here and wasn't able to find a solution. (There will be multiple instances of {('')} on any given page if that helps).  I've been using this function for a while now, but would like to add the ability to include whitespaces.  Thanks!
Answer: '(\w+)'

\w is all alphanumeric characters and the underscore - that doesn't include whitespace. Just use a character set:
'([\w\s]+)'


If $F$ is a left exact functor is $A$ acyclic iff $F$ preserves exactness of every SES $0\to A\to B\to C\to 0$?

Question: If $F:\mathscr{A}\to\mathscr{B}$ is a left exact functor between abelian categories where $\mathscr{A}$ has enough injectives, is it true that $A$ is an acyclic object iff $F$ preserves exactness of every short exact sequence of the form $0\to A\to B\to C \to 0$?  Certainly one direction is clear, that acyclic objects make $F$ preserve such short exact sequences.  The other direction seems like it should be true but I don't think it is immediate.
Answer: HINT:
Imbed $A$ into an acyclic object $B$ and consider the short exact sequence
$$0\to A \to B \to C \to 0$$
Use the long exact sequence involving the derived functors of $F$. You get $F^1(A)=0$.
The higher derived functors do not have to be zero. Take for instance $Ext(M, \cdot )$ as a left exact functor. $A$ has the exactness property $\iff$  $Ext^1(M,A) = 0$. But you can still have $Ext^2(M,A) \ne 0$. An important particular case is the group cohomology.
Another example  Fix a topological space $X$ and take the abelian category of sheaves of abelian groups on $X$. The functor of global sections
$$\mathcal{F} \mapsto F(\mathcal{F}) \colon = \mathcal{F}(X)$$
is covariant and  left exact. The derived functors $F^{i}(\mathcal{F})$ are the cohomology groups of the sheaf $\mathcal{F}$  $H^{i}(X, \mathcal{F})$. Consider the locally constant sheaf $\mathbb{Z}$ on $X$. If $X$ is a nice topological space (say a CW -complex -- think of a sphere) then
$H^{i}(X, \mathbb{Z})$ are naturally isomorphic to the singular cohomology groups. Therefore we get easily examples where $H^1(X, \mathbb{Z}) = 0$ but $H^2(X, \mathbb{Z})\ne 0$. As example take $X = S^2$ the $2$-dimensional sphere.
Comment: Thanks for the answer.  I can see that $F^1(A)=0$ but I'm not sure about the higher $F^i(A)$.
Comment: Ah, I got a simple explanation for it, will edit the answer.
Comment: @Seth: Oh, I changed the answer, it turns out that the exactness condition is equivalent to $F^1(A) = 0$ but we may still have $F^2(A) \ne 0$.
Comment: Thanks, I was beginning to suspect that.  Unfortunately I don't know any group cohomology so I still don't know a specific example where this occurs.
Comment: Do you know any sheaf cohomology?
Comment: I'm just starting to learn it, which is what inspired me to think about this.
Comment: Ah just read your update, great example!  (I should have thought of that!) Thanks for helping me out.
Comment: No worries! At some point you may want to read about cohomological dimension, I think you had this idea already. Also check out K Brown - cohomology of groups -- makes the connection with topology.


How to securely share AES key between two remote devices (client and server) through UDP protocol?

Question: I have two separate system (client) and (server). I am having a problem which is to encrypt a message from the client and decrypt at the server. In order to do that, I am required to transmit my key along with the message through UDP packets. However, is there any possible ways to ensure the key is transmitted securely?
Answer: You don't transfer the key, not at least un-encrypted.
There are several ways to "establish a shared key" between authenticated systems.
Using key exchange schemes such as Diffie-Hellman, its elliptic-curve versions such as ECDH, X25519/X448, etc, as well as some schemes secure even if you attack it with a quantum computer such as NTRU (formerly NTRUEncrypt), Kyber, Saber.
Notice I said authenticated system. key exchange schemes require the public key of the peer - which is static if you just hard-code it into your application; a better way is to use a digital signature to sign an ephemeral key exchange public key and hard-code the digital signature verification key into the application.
All in all, there is a well-established protocol with existing free and open-source implementations called TLS, which you can use to exchange an initial key, then import that key into your UDP-based protocol.
The QUIC protocol does about just that: it doesn't design new key exchange or authentication handshake protocol, it imports the key from TLS handshake and use it in the en/de-crypting UDP packets.
Comment: Is there any implementation for Kyber and Saber that we can use?
Comment: @kelalaka https://csrc.nist.gov/Projects/post-quantum-cryptography/round-2-submissions Round 3 packages hadn't been published as of this writing.
Comment: I was a bit more like libsodium. Those packages, afaik, for science only. Thanks anyway.
Comment: The OP wants practical stuff, so giving some libraries as a link would help those kinds of questions. Libsoidum seems the best choice for now.


Designing chart drawing software

Question: I am designing software that needs to draw several different kinds of charts--bar charts, pie charts, flow charts/graphs, charts over time. I am looking for resources related to both the programming side of the issue as well as the UI/display side. Books, online resources would all be helpful. Thanks.
Answer: It does depend on the language a bit: here may be some pointers for you. Hope they help:
code.google.com/apis/chart/
home.gna.org/pychart
Practical C# Charts and Graphics
The Excel library can be imported by the Office API, but it does require you to have Excel installed.
Gnuplot
The grammar of graphics: book from the guy that wrote the plotting lib of spss. Somewhat theoretical, but nice xml treatment... gives you the graph xml schema for spss.
But I'm sure there are quite a few others that other people will know.
Answer: Do you have to draw it your self. If you want to save time (and probably money) then you can try embedding one of these into your apps http://code.google.com/apis/chart/
Answer: Ditto with Chris;  If you are developing a new way of building charts, that's great!
Assumption: I have no idea of your needs but it would initially strike me (and thus form my assumption) that you are trying to develop a better charting software and that's usually interface.
Consider checking out the libraries in other programming languages that already do charting.
Adobe Flex/Air have one, PHP does, Java Does, .NET does.. etc.
Answer: Checking out the existing charing libraries for your language of choice helps a lot.  In my case, it helped so much I decided not to write my own. ;)
For .net apps we settled on .netCharting, which can be pretty amazing.
The real lesson I took from it though, is this: there are way, way more kinds of charts than I thought there were, and I work with a lot of charts.  Make sure you end up with something modular enough to handle clicking in new chart types / configurations with minimal effort.
Answer: You want to take a look at EyeSee.
http://moose.unibe.ch/tools/eyesee

Designing chart drawing software


Cannot make callout from a Trigger that is fired through a batch apex

Question: I'm trying to call a method which do an api call. But I'm getting an error because this method get call through the process ran by batch. So even if I directly call the API calling method it gives me an error 'Callout from triggers are currently not supported'. And when I call future method then it says future method cannot be called from batch. I have already implemented the Database.AllowsCallout interface in the batch class.
Please help in this.Thank you.
Answer: Salesforce does not allow callouts in triggers or future methods from the batch class. I think your current code requires a little restructuring where you can make the callouts directly from the batch by isolating the logic that is being called in the trigger and calling it from the batch instead.
The other way to do that would add identification (like a field or picklist) to the record using the batch and using another batch just to make the callouts.
Answer: So, a good practice is to delegate callouts to queueable Apex. This allows the Queueable class to be invoked from either

Trigger
Batchable execute()

If you add an intermediate Async_Request__c object that contains the callable parameters, you can build interesting async patterns that provide retry on error and logging of every callout. One example of this can be found in Advanced Apex, 4th Edition, chapter on Asynchronous Processing
You could also delegate callouts via Platform Events which execute asynchronously. The Platform Event subscriber would accept the callout params and then do the callout


Need Gestures on my Ubuntu and Lenovo T430

Question: I purchased a Lenovo T450 and Installed Ubuntu 18.04. Its awesome the machine is so fast and efficient and everything is so snappy. Just fantastic. I need a few gestures on the trackpad.
Is there a gesture on the trackpad which will do "show applications". This is similar to the gesture on Mac which does launch pad (pinch with thumb and 3 fingers).
I need a gesture to switch between multiple full screen applications. (3 fingered swipe left or right).
I need a gesture to switch between desktops. (???)
I need a gesture to show the desktop. (3 finger swipe up).
If I find these I think I have found the perfect machine for myself.
I tried suggestions given here. They do not work on Ubuntu 18.04
https://www.youtube.com/watch?v=ci6YbQGx3c4&frags=pl%2Cwn
I get error message
Can not see any devices, did you add yourself to the input group and log out/in?
Could not determine touchpad device

When writing the libinput-gestures.conf its easy to say swipe. How do I write the pinch gesture?
Comment: Possible duplicate of [Ubuntu 16.04 multitouch gestures](https://askubuntu.com/questions/789915/ubuntu-16-04-multitouch-gestures)
Answer: It works sorry. after doing the
sudo gpasswd -a $USER input

I had to log off and login again. After I did this everything works.


Pushouts in the category of adjunctions

Question: Let $\mathcal A$ be the category whose objects are all categories, and whose morphisms from a category $\mathcal C$ to a category $\mathcal D$ are all adjunctions $F \dashv G$ with $F : \mathcal C \to \mathcal D$ (and $G : \mathcal D \to \mathcal C$). Does every span in $\mathcal A$ have a pushout, and, if yes, what does such a pushout look like?
Comment: Since this is obviously a 2-categorical situation, you should specify the higher structure to get a relevant answer. I think perhaps the setting of the double category of profunctors could be useful here.
Comment: So I have to specify what morphisms between adjunctions should be. I think that the canonical answer would be that a morphisms from $F \dashv G$ to $F' \dashv G'$ is a pair of natural transformations $\varphi : F \to F'$ and $\gamma : G \to G'$ such that $\varepsilon' \circ (\varphi \bullet \gamma) = \varepsilon : F \bullet G \to \mathrm{Id}$ and $(\gamma \bullet \varphi) \circ \eta = \eta' : \mathrm{Id} \to G' \bullet F'$. However I do not know how pushouts in 2-categories are defined. Any hints?
Answer: $
\newcommand{\Hom}{\mathrm{Hom}}
\newcommand{\ra}[1]{\kern-1.5ex\xrightarrow{\ \ #1\ \ }\phantom{}\kern-1.5ex}
\newcommand{\ras}[1]{\kern-1.5ex\xrightarrow{\ \ \smash{#1}\ \ }\phantom{}\kern-1.5ex}
\newcommand{\da}[1]{\bigg\downarrow\raise.5ex\rlap{\scriptstyle#1}}$
In general, this is false. Let $G_1$ and $G_2$ be two groups and consider the two free/forgetful adjunctions between finite sets and finite sets with an action of $G_i$. The pushout should equal finite sets with an action of the free product $G_1 * G_2$, but it cannot because the free functor takes you to infinite sets. If $H$ is any finite quotient of $G_1 * G_2$, then $H$-sets forms a commutative diagram in the category of adjunctions. If there were a universal adjunction then the unit of the universal adjoint functor applied to a free $G_1$-set would produce a $G_1$-set that is at least as large as the free object on one generator in any of these categories, which is a free $H$-set, and can grow arbitrarily large, so this is impossible.
However, this is correct as long as all categories involved have filtered colimits and the right adjoints commute with them. Daniel Schappi points out a simple argument for this in the comments, but my argument below could serve as an explicit construction.
I am not sure what happens if other colimits are missing or if the colimits exist but the functors do not commute with them.

My construction:
Tt might be helpful to do what I did when thinking of it and view the span in the category of adjunctions as consisting of the free/forgetful adjunctions $\mathbf{Set} \to \mathbf{Ring}$ and $\mathbf{Set} \to \mathbf{Group}$. Then the final category we are constructing is just sets with unrelated group and ring structures, and the main difficulty is categorically defining the free adjoint to the forgetful functor from ring-groups to rings or groups.
Let $F_1: \mathcal C \to \mathcal D_1$ and $G_1: \mathcal D_1 \to \mathcal C$ be one adjunction, and $F_2: \mathcal C \to \mathcal D_2$ and $G_2: \mathcal D_2 \to \mathcal C$ be the other.
Let $\mathcal B$ be the category of pairs of objects $X \in D_1, Y \in D_2$ with an isomorphism between $G_1 X$ and $G_2 Y$. There are natural projection functors $P_1: \mathcal B \to \mathcal D_1$ and $P_2: \mathcal B \to \mathcal D_2$. We will construct adjoints $Q_1: \mathcal D_1 \to \mathcal B$ and $Q_2 : \mathcal D_2 \to \mathcal B$.
We need an adjunction of the form $\Hom_{\mathcal B} (Q_1 X_0, (X,Y) ) = \Hom_{\mathcal D_1} (X_0,X)$. We have a natural map:
$\Hom_{\mathcal D_1}(X_0,X) \to \Hom_{\mathcal C} ( G_1X_0,G_1X) =
\Hom_{\mathcal C}(G_1X_0,G_2 Y)  \to \Hom_{\mathcal D_2} (F_2G_1 X_0, F_2G_2 Y)
\to \Hom_{\mathcal D_2} (F_2 G_1 X_0, Y)$
Let  $Y_1 = F_2G_1 X_0$. Then by the same logic we have a natural map
$\Hom_{\mathcal D_1}(X_0,X) \to \Hom_{\mathcal D_1} ( F_1 G_2 Y_1, X)$. But we
have something slightly more refined. $F_1 G_2 Y_1 = F_ 1 G_2 F_2 G_1 X_0$.
Every element of $\Hom_{\mathcal D_1}(X_0,X)$ gives a commutative diagram:
$$
\begin{array}{c}
F_1G_1X_0 & \ra{} & X_0 \\
\da{} & & \da{} \\
F_1G_2F_2 G_1 X_0 & \ra{} & X \end{array} $$
Call $X_2$ the limit of the top-left three-quarters of this diagram. Every map $X_0 \to X$ gives a natural map $X_2 \to X$. Then let $Y_3$ be the limit of the corresponding diagram starting at $Y_1$. Every map $X_0 \to X$ gives a corresponding map $Y_3 \to Y$.
Define $Y_4$, $X_5$, etc., similarly. Let $X_{\infty} = \lim_{n\to\infty} X_n$
and let $Y_\infty = \lim_{n\to\infty} Y_n$. Then $G_1 X_\infty = G_2 Y_\infty$,
because they are both equal to the limit of the sequence $G_1 X_0 \to G_2 Y_1
\to G_1 X_2 \to G_2 Y_3 \to \dots$, because right adjoints preserve limits and
the limit of a subsequence is the limit of the sequence. So $(X_{\infty},
Y_{\infty})$ is an element of $\mathcal B$, and we have a natural map $\Hom
_{\mathcal D_1}(X_0,X)= \Hom_ {\mathcal B} ( ( X_\infty, Y_\infty), (X,Y))$. To see this is a bijection note that an element on the right side is just a sequence of maps $X_n \to X$, and $Y_m \to Y$. We need to show that all these maps are determined by the map $X_0 \to X$. They satisfy the consistency condition that the families of map $G_1 X_n \to G_1 X$, $G_2 Y_2 \to G_2 Y$ agree.
So for instance we have the unit map $G_1 X_0 \to G_2 F_2 G_1 X_0 = G_2 Y_1$. The map $Y_1 \to Y$ is the unique map such that the functor $F_2$ applied with it, composed with this unit, is the map $G_1 X_0 \to G_1 X=G_2 Y$. In other words it is exactly the map $F_2 G_1 X_0 \to Y$ one obtains by the adjunction. Iterating the process, we see that the maps from $X_2$, $Y_3$, etc. are also so determined.
So define $Q_1 X_1 = (X_{\infty}, Y_{\infty})$. Define $Q_2$ similarly. This completes our span to a commutative square. Is it universal? It clearly is one way. If $\mathcal B'$ is any category with functors $P_1': \mathcal B' \to \mathcal D_1$ and $P_2': \mathcal B' \to \mathcal D_2$, we obtain a unique map $\mathcal B' \to \mathcal B$ by definition. So we only need to construct an adjoint of that map. We do this as follows. Given $X,Y$, and an isomorphism $G_1X = G_2Y$, we form in $\mathcal B'$ the span
$$
\begin{array}{c}
Q_1' F_1G_1 X & \ra{} & Q_1' X \\
 \da{} & \\
Q2' Y & \end{array} $$
with the bottom arrow coming from the identification $Q_1'F_1G_1 X = G_2' F_2 G_1 X = Q_2' F_2 G_2 Y$.
If the pushout of this span in $\mathcal B'$ exists, we can use it to construct
an adjoint functor. A $\Hom$ from this to an element $Z \in B'$ consists of a
$\Hom(Q_1' X, Z)$ plus a $\Hom(Q_2'Y, Z)$ that agree on $\Hom(Q_1'F_1 G_1 X,
Z)$. By adjunction, this is the same as a $\Hom(X, P_1'Z)$ plus a $\Hom(Y,
P_1'Z)$ that agree on $\Hom(G_1X, G_1 P_1'Z)$. This is exactly a an element of
$\Hom_B((X,Y), (P_1'Z,P_2'Z))$.
Comment: On the other hand, if you consider the 2-category of say lfp categories and adjunctions whose right adjoint does preserve filtered colimits, then you do get the desired pushouts. This 2-category is equivalent to finitely cocomplete categories with functors preserving finite colimits, and this is 2-monadic over the category of small categories. Since the 2-monad in question has rank, this 2-category has all bicolimits. I think it would be interesting to see if there are counterexamples if the categories involved do not have (many) colimits.
Comment: I don't think this works quite as intended. First of all, you often talk about limits when you really mean colimits (both in the definition of $X_i$ and $X_{\infty}$). But right adjoints need not preserve colimits (not even filtered colimits in general), so your argument that $G_1 X_{\infty}=G_2 Y_{\infty}$ does not work.
Comment: Small typo: "Then by the same logic we have a natural map $Hom_{\mathcal D_1}(X_0,X) \to Hom_{\mathcal D_1} ( F_2 G_1 Y_1, X)$" - $F_1 G_2 Y_1$ instead of $F_2 G_1 Y_1$.
Comment: Good point. What are good examples of categories without filtered colimits? I don't know any way to find them other than enumerating all the categories I know and checking if they have filtered colimits, which seems tiresome.

Pushouts in the category of adjunctions


What's an Instruction Set Architecture

Question:
I'm a beginner and I don't understand what an Instruction Set Architecture is (I read the wikipedia page related to it).
Can anyone explain it to me in a simple manner please?
Answer: It's a description of how a certain processor is designed, e.g. which commands it understands, how many registers it has, how it handles interrupts, etc. Any program you write (in assembly) or compile (e.g. from C) for a specific ISA can run on any processor that uses that ISA.
To run a program compiled for one ISA on a different ISA, you need an emulator that translates commands and potentially simulates registers, etc.
For example, desktop PCs use the x86 ISA family, which is why you can run Windows, Ubuntu, etc on any x86 processor.
Smartphones and Raspberry Pis have processors with the ARM ISA, which is why you can't run regular x86 Windows on a RaspPi, instead requiring one specially built for ARM.
Comment: I don't think branch prediction or pipelines stages are considered part of the ISA. They are implementation details, and have no effect on the programming interface
Comment: Oh right, I believe you're correct.
Answer: Instruction Set Architecture is the broad concept of defining the nature of instructions in a computer.  Classic differential architectures are CISC vs RISC. RISC is a reduced instruction set, and CISC, complex instruction set, is anything else.
A classic difference is an IBM S/360 being a CISC machine. Just look at the edit instructions and you will see what is meant by a complex instruction. An ARM architecture is considered RISC.
But there is more to instruction sets.  For examples, are registers primarily used or is a stack primarily employed.  How is I/O performed?
For example, a PDP-8, which has a 12 bit word, is considered a CISC processor because of how the instructions are constructed and grouped.  So the size of the word is not the determining factor.
There has been an ongoing battle over whether large word instructions where operands are memory locations are more efficient than instructions which primarily address registers or stacks, with instructions that preload stacks.
The portability of code between processors is a function of the specific instruction set for the processors. It is possible to have very similar architectures, even though the instructions are different, and of course the code would not be portable.
On an aside, decades ago I earned my living by writing device drivers and peripheral diagnostics for various computers.  About 40 of them.  Oddly, the diagnostics were about the same number of bits in size regardless of the computer they ran on.  I cannot say what the result of a similar informal analysis would be today, but it would be interesting.
Answer: Instruction Set or Instruction Set Architecture is the part of the computer that contains the commands for the processor to function. This usually would consist of addressing modes, instructions, native data types, registers, memory architecture, interrupt, and exception handling, and external I/O. An example is the x86 and x64 instruction sets which are popular on most computers of today.

What's an Instruction Set Architecture


Sum elements in an sorted List and then add the summed value into list

Question: So, Here is my issue, I have a list which contains something like this
[4,7,8,23,41]
What I want is
4+7 = 11 so 11 should be added to this list and 4 and 7 should be removed.
then 11 +8 = 19 so 19 added and 11 and 8 should be removed.
  int finalSum=0;
  Collections.sort(myList);

  for(int i =0;i<myList.size();i++)
  {
      for(int j=i+1;i<myList.size();j++)
      {
          int sum = myList.get(i) + myList.get(j);
          myList.remove(i);
          myList.remove(j);
      }
  }

  for(int k=0;k<myList.size();k++)
  {
       finalSum += myList.get(k);
  }

Comment: That's a terrible algorithm. Just sum the `List` and then empty it. It's not a good idea to modify the `List` you are iterating.
Comment: This sounds like something an instructor would assign.
Answer: I am not sure the reason you would want an algorithm like this, however this should behave the way you have described.
public static void main(String[] args) {
    List<Integer> myList = new LinkedList<>(Arrays.asList(4,7,8,23,41));
    Collections.sort(myList);
    while (myList.size() > 1) {
        myList.add(0, myList.remove(0) + myList.remove(0));
    }
    int finalSum = myList.get(0);
    System.out.println(finalSum);
}

A better approach for summing elements in a list would be:
public static void main(String[] args) {
    List<Integer> myList = Arrays.asList(4,7,8,23,41);
    int finalSum = myList.stream().reduce(0, Integer::sum);
    System.out.println(finalSum);
}

Answer: If you just want to get a final total of the list, You can do it via iterating the whole list and adding each value at the same time.
for(int k=0;k<myList.size();k++)
{
   finalSum += myList.get(k);
}

But, as you described that you want to add first two numbers from the list and then it should remove them, add the total back to the list and do the same process then we can use PriorityQueue here. It can help to keep track of ascending order and anyways the time complexity for our code will be O(n logn) where n is the size of the list.
    PriorityQueue<Integer> pq= new PriorityQueue<>(); // by default it maintains the ascending order
    for(int k=0;k<myList.size();k++){
        pq.add(myList.get(k));
    }
    while(pq.size()>1){
        int num1 = pq.poll(); // taking out first smallest number
        int num2 = pq.poll(); // taking out second smallest number
        pq.add(num1+num2);
    }
    finalSum = pq.poll(); // final sum

Answer: Since you keep removing elements from the list, you can continue to use index 0.
      List<Integer> list = new ArrayList<>(Arrays.asList(4,7,8,23,41));

      int first = 0;
      while (list.size() > 0) {
         int v = list.remove(0) + first;
         list.add(0, v);
         System.out.println(list);
         first = list.remove(0);
      }

But if it's just a sum you're after, this is easiest.
      int sum = list.stream().mapToInt(a -> a).sum();


How to prove that an action-value function optimal for one problem formulation is also optimal for another?

Question: I want to ask about the intuition/where-to-look/what-to-try if I want to prove that an action value function optimal for a problem is also optimal for another reformulation of that smae problem. For example, a common approach to solve DEC-POMDP is to recast the problem into a common-knowledge-MDP. In this case (and in any similar case) What is the approach to follow in order to prove that the optimal action-value function optimal for the single agent reformulation is also optimal for the multi-agent formulation?
Answer: The reduction of a Dec-POMDP to a centralized MDP that you mention is discussed at length in the technical report "Dec-POMDPs as Non-Observable MDPs" by Oliehoek and Amato.
Further background that can help understand the method can be found in "Sufficient plan-time statistics for decentralized POMDPs" in IJCAI'13 also by Oliehoek.
A related approach dealing with common/individual knowledge and information gathering is "Multi-agent active perception with prediction rewards" in NeurIPS'20 by Lauri and Oliehoek. (Disclaimer: I am one of the authors).


is it possible to program ActionScript with python?

Question: im making games in ActionScript , Flex and Flashpunk, tho i found it slow to develop in. one of my favourite programming languages are python. So i wonderd "is it possible to program ActionScript with python?". like Jython and java :P
Comment: If you want to program python instead of Actionscript, why not use that?
Comment: because flash do have a much better(and simpler) graphical platform than python and the c family.
Comment: Unless you want to create that interpreter, go ahead, but I guarantee you it won't be efficient since Python isn't view based and the paradigm changes quite abruptly.  Use the language that's better suited for you and learn it.  Ever thought that the reason why it's "slow to develop in" is your lack of skill in that particular tech?  Personally, I like strongly typed functions and what not, and an incredibly easy xml based view layout language that takes out the guess work of creating complex components. But that's just me...
Comment: i wont start on my second interpreter, so i guess i'll just program in ActionScript :P
Comment: Not sure if it helps, but maybe you can workout a nice workflow with something like pygame for python and some jsfl automation to get assets in the right format for your games from Flash, if you are using Flash. A decent IDE could speed you up. If you're on PC, FlashDevelop is better than Flex. If you want to stick to Flex get something like sourcemate. Other options are FDT and IntelliJ Idea.
Answer: See answers to this question where was mentioned such projects as Alchemy and PyPy. But as far as I know there is no any solution at this moment which can be used in production.
Answer: There is an elegant way to make Actionscript 3 apps to talk to Python using Action Message Format (AMF3) and PyAMF. The AMF3 serialized format is wicked fast (compared to XML) and can support unique data types such as ByteArray and ArrayCollection.


EXC_BAD_ACCESS in AppDelegate class declaration

Question: I've been having issues when segueing in my app with EXC_BAD_ACCESS errors, of code EXC_I386_GPFLT. I've been unable to find much information on this, since there isn't a line of code that I've written that is being pointed to as the culprit. The error is occurring at the line
class AppDelegate: UIResponder, UIApplicationDelegate {

which I didn't even write. I'm not sure how to figure out what is a bad access when nothing I've written is being shown as incorrect.
To put the problem into a bit more perspective,
I have a storyboard that contains a navigation controller, which has a ViewController as its root view controller. The ViewController has a table view that, when a cell is selected, segues to another ViewController. That ViewController may then segue to a third ViewController through a tap gesture segue. This third controller is the navigation controller's delegate, and I set it as that inside the 2nd ViewController's prepareForSegue method,
var dvc = segue.destinationViewController as BlockingViewController
self.navigationController!.delegate = dvc

I ran into this issue when trying to disable the InteractivePopoverGestureRecognizer created automatically by the navigation controller. To do this, I added to the viewDidLoad methods of the 2nd and 3rd ViewControllers the following code:
var barItem: UIBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "backButtonPressed")

self.navigationItem.leftBarButtonItem = barItem

and created a backButtonPressed method:
func backButtonPressed() {
    self.navigationController?.popViewControllerAnimated(true)
}

The error occurs when I do the following sequence of actions:
VC1 -> VC2 -> VC3 -> VC2 -> VC1
The error does not occur when I do the following sequence of actions:
VC1 -> VC2 -> VC1
So there must be something happening in VC3 that is causing the issue. The only thing I can think of is that I'm setting it as the navigation controller's delegate, which leads me to wonder if perhaps it's trying to access the delegate during the segue from VC2 -> VC1, which is then causing an error because the delegate is now nil.
Could this be the problem? If not, any insight on what might be the problem would be extremely helpful.
EDIT: I tried the same series of events without setting the navigationController delegate, and didn't have the same issue. The only issue with keeping it like that is that I need the navigationController delegate so I can pass information between VC3 and VC2 when I segue between them.
Answer: I found that the problem stopped when I set the navigationController delegate back to nil when I was performing the segue from VC3 back to VC2. I believe the issue was that the delegate property was still referencing VC3, but VC3 no longer existed, so when the navigationController attempted to perform the viewWillAppear method that I'd implemented, the object it was trying to access as delegate no longer existed.
Answer: I had a similar problem, it was related to a CFString... method call when calling the init method of my custom segue. I fixed the problem by setting am Identifier in the StoryBoard Segue "Attributes Inspector", probably a bug with the xcode version I'm using (6.4).


Is there a way to set the direction of the sun light on an object (without rotations)?

Question: Basically, I'm wondering if I can set the sun lamp's light direction towards a position, such as an object, with a simple command, rather than doing rotations with R which is hard to control.
Answer: One way to do this is with a Track To constraint:

Select the sun lamp
⇧ Shift select the object you wish to point the lamp at
Press ⎈ CtrlT and choose Track To Constraint.

The sun lamp will now always "look" at that object, so you can move it around with G for easy adjustment.
You can adjust the constraint (or remove it) in the Constraints tab of the Properties area when the sun lamp is active:
Comment: @ManWithAComputor I'm not aware of anything exactly like that, however should be possible to create a custom operator which does this (using python). As for something native, you can do some stuff with making the lamp the active camera (`Ctrl Numpad 0`) and using `Ctrl Alt Numpad 0` (align camera to view), which when combined with view manipulation shortcuts (e.g. `Numpad .`) can *sort of* do this. Not exactly "fast" though. In fact, tracking the sun to an empty and snapping said empty to the cursor location (`Shift S`) is likely faster.
Comment: @ManWithAComputer, You could use an Empty (an invisible object) and track to that.
Comment: Although, this works very well for objects, you won't be able to set the direction to a position in 3D space i.e the location of the 3d cursor pointing to that position. Is there a way to do that? Otherwise I'm happy to accept this as the answer.