text:
Q: Calculate white areas pixels in contours using opencv and Javacv I have develop a program to detect motions using JavaCV. up to now i have completed cvFindContours of the processed image. source code is given below,
public class MotionDetect {

public static void main(String args[]) throws Exception, InterruptedException {

    //FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(new File("D:/pool.avi"));
    OpenCVFrameGrabber grabber = new OpenCVFrameGrabber("D:/2.avi");
    final CanvasFrame canvas = new CanvasFrame("My Image");
    final CanvasFrame canvas2 = new CanvasFrame("ROI");
    canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
    grabber.start();
    IplImage frame = grabber.grab();
    CvSize imgsize = cvGetSize(frame);
    IplImage grayImage = cvCreateImage(imgsize, IPL_DEPTH_8U, 1);
    IplImage ROIFrame = cvCreateImage(cvSize((265 - 72), (214 - 148)), IPL_DEPTH_8U, 1);
    IplImage colorImage;
    IplImage movingAvg = cvCreateImage(imgsize, IPL_DEPTH_32F, 3);
    IplImage difference = null;
    IplImage temp = null;
    IplImage motionHistory = cvCreateImage(imgsize, IPL_DEPTH_8U, 3);

    CvRect bndRect = cvRect(0, 0, 0, 0);
    CvPoint pt1 = new CvPoint(), pt2 = new CvPoint();
    CvFont font = null;

    //Capture the movie frame by frame.
    int prevX = 0;
    int numPeople = 0;
    char[] wow = new char[65];

    int avgX = 0;

    //Indicates whether this is the first time in the loop of frames.
    boolean first = true;

    //Indicates the contour which was closest to the left boundary before the object
    //entered the region between the buildings.
    int closestToLeft = 0;
    //Same as above, but for the right.
    int closestToRight = 320;

    while (true) {
        colorImage = grabber.grab();
        if (colorImage != null) {
            if (first) {
                difference = cvCloneImage(colorImage);
                temp = cvCloneImage(colorImage);
                cvConvertScale(colorImage, movingAvg, 1.0, 0.0);
                first = false;
                //cvShowImage("My Window1", difference);
            } //else, make a running average of the motion.
            else {
                cvRunningAvg(colorImage, movingAvg, 0.020, null);
            }

            //Convert the scale of the moving average.
            cvConvertScale(movingAvg, temp, 1.0, 0.0);

            //Minus the current frame from the moving average.
            cvAbsDiff(colorImage, temp, difference);

            //Convert the image to grayscale.
            cvCvtColor(difference, grayImage, CV_RGB2GRAY);
            //canvas.showImage(grayImage);
            //Convert the image to black and white.
            cvThreshold(grayImage, grayImage, 70, 255, CV_THRESH_BINARY);

            //Dilate and erode to get people blobs
            cvDilate(grayImage, grayImage, null, 18);
            cvErode(grayImage, grayImage, null, 10);
            canvas.showImage(grayImage);

            ROIFrame = cvCloneImage(grayImage);
            cvSetImageROI(ROIFrame, cvRect(72, 148, (265 - 72), (214 - 148)));
            //cvOr(outFrame, tempFrame, outFrame);
            cvShowImage("ROI Frame", ROIFrame);

            cvRectangle(colorImage, /* the dest image */
                    cvPoint(72, 148), /* top left point */
                    cvPoint(265, 214), /* bottom right point */
                    cvScalar(255, 0, 0, 0), /* the color; blue */
                    1, 8, 0);

            CvMemStorage storage = cvCreateMemStorage(0);
            CvSeq contour = new CvSeq(null);
            cvFindContours(grayImage, storage, contour, Loader.sizeof(CvContour.class),  CV_RETR_CCOMP,  CV_CHAIN_APPROX_SIMPLE);

        }

            //Show the frame.
            cvShowImage("My Window", colorImage);

            //Wait for the user to see it.
            cvWaitKey(10);

        }

        //If this is the first time, initialize the images.

        //Thread.sleep(50);
    }

   }
}

In this code ROIFrame, i need to calculate white contours area or pixel numbers??.. is there any way that i can proceed with

A: Use the function cvContourArea() Documentation here.
In your code, after your cvFindContours, do a loop with all of your contours like as:
CvSeq* curr_contour = contour;

while (curr_contour != NULL) {
   area = fabs(cvContourArea(curr_contour,CV_WHOLE_SEQ, 0));
   current_contour = current_contour->h_next;
}

Don't forget to store the area somewhere.


text:
Q: Eventhub Connection 1000 Tokens limitation issue when uses StartingEventPostion

Without "starting EventPostion", it was running well.
After adding "startingEventPostion", then it got this error:
java.util.concurrent.CompletionException: com.microsoft.azure.eventhubs.QuotaExceededException: status-code: 403, status-description: The maximum number of '1000' tokens per connection has been reached. ...
Please help. Thanks!

redpajama_set_name: RedPajamaStackExchange


text:
Q: From templates to remote provisioning (with self-service site creation enabled) How to allow users to apply branding to new site collection (when self-service site creation is enabled) without having any code, solutions or features running server-side?
The requested functionality has traditionally been done via farm scoped solution packages and web templates, but now the probability of moving to O365 is likely to increase long-term costs of server-side functionality - and thus I am wondering about moving logic away from SharePoint.
What would be the best way to create a "template-style" functionality without deploying any code or declarative solutions server-side when self-service site creation is enabled?
Some possibilities might be

*

*Using PowerShell to add a link globally to the suitebar of all site collections for applying branding from an external solution (MVC via CSOM for example)

*Moving whole site collection creation to an external solution (technically, the external application could create site collections on-premises using the admin web services, and in O365 via CSOM and Tenant)

*Creating a simple slightly customized template on-premises which applies simple branding and puts most logic (and long-term maintenance) to an external solution. However, this would naturally not currently be compatible with O365

Would it be possible to put above-mentioned approaches in order of preference (or shoot them down)? What other alternatives would work and why?
Related question: Easy and maintainable way to create templates for sites?

A: We have only discussed this internally but not created an actual solution yet.
Here are some of the thoughts I have on the subject:
I would probably opt for a pattern with a provider hosted app that create the site collection using the correct master page etc. This means that you could host on your own IIS on-premises, and when you move it to the cloud you could move the app to Azure.
There are several examples with similar issues:
Site provisioning patterns in CAM scenarios:
http://blogs.msdn.com/b/vesku/archive/2013/09/09/sharepoint-2013-site-provisioning-techniques-presentation-video-recording.aspx
Provider hosted app to customize My Site
http://blogs.msdn.com/b/vesku/archive/2013/11/25/office365-apply-automatically-custom-branding-to-personal-site-skydrive-pro.aspx
Vesa also has a lot of recent articles about FTC > CAM scenarios.


text:
Q: Populating UICollectionView in reverse order I would like to populate UICollectionView in reverse order so that the last item of the UICollectionView fills first and then the second last and so on. Actually I'm applying animation and items are showing up one by one. Therefore, I want the last item to show up first.

A: Swift 4.2
I found a simple solution and worked for me to show last item first of a collection view:
Inside viewDidLoad() method:
collectionView.transform = CGAffineTransform.init(rotationAngle: (-(CGFloat)(Double.pi)))

and inside collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) method before returning the cell:
cell.transform = CGAffineTransform(rotationAngle: CGFloat.pi)

(optional) Below lines will be necessary to auto scroll and show new item with smooth scroll.
Add below lines after loading new data:
   if self.dataCollection.count > 0 {
      self.collectionView.scrollToItem(at: //scroll collection view to indexpath
      NSIndexPath.init(row:(self.collectionView?.numberOfItems(inSection: 0))!-1, //get last item of self collectionview (number of items -1)
      section: 0) as IndexPath //scroll to bottom of current section
      , at: UICollectionView.ScrollPosition.bottom, //right, left, top, bottom, centeredHorizontally, centeredVertically
      animated: true)
   }

A: I'm surprised that Apple scares people away from writing their own UICollectionViewLayout in the documentation.  It's really very straightforward.  Here's an implementation that I just used in an app that will do exactly what are asking.  New items appear at the bottom, and the while there is not enough content to fill up the screen the the items are bottom justified, like you see in message apps. In other words item zero in your data source is the lowest item in the stack.
This code assumes that you have multiple sections, each with items of a fixed height and no spaces between items, and the full width of the collection view. If your layout is more complicated, such as different spacing between sections and items, or variable height items, Apple's intention is that you use the prepare() callback to do the heavy lifting and cache size information for later use.
This code uses Swift 3.0.
//
//  Created by John Lyon-Smith on 1/7/17.
//  Copyright © 2017 John Lyon-Smith. All rights reserved.
//

import Foundation
import UIKit

class InvertedStackLayout: UICollectionViewLayout {
    let cellHeight: CGFloat = 100.00 // Your cell height here...

    override func prepare() {
        super.prepare()
    }

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        var layoutAttrs = [UICollectionViewLayoutAttributes]()

        if let collectionView = self.collectionView {
            for section in 0 ..< collectionView.numberOfSections {
                if let numberOfSectionItems = numberOfItemsInSection(section) {
                    for item in 0 ..< numberOfSectionItems {
                        let indexPath = IndexPath(item: item, section: section)
                        let layoutAttr = layoutAttributesForItem(at: indexPath)

                        if let layoutAttr = layoutAttr, layoutAttr.frame.intersects(rect) {
                            layoutAttrs.append(layoutAttr)
                        }
                    }
                }
            }
        }

        return layoutAttrs
    }

    override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
        let layoutAttr = UICollectionViewLayoutAttributes(forCellWith: indexPath)
        let contentSize = self.collectionViewContentSize

        layoutAttr.frame = CGRect(
            x: 0, y: contentSize.height - CGFloat(indexPath.item + 1) * cellHeight,
            width: contentSize.width, height: cellHeight)

        return layoutAttr
    }

    func numberOfItemsInSection(_ section: Int) -> Int? {
        if let collectionView = self.collectionView,
            let numSectionItems = collectionView.dataSource?.collectionView(collectionView, numberOfItemsInSection: section)
        {
            return numSectionItems
        }

        return 0
    }

    override var collectionViewContentSize: CGSize {
        get {
            var height: CGFloat = 0.0
            var bounds = CGRect.zero

            if let collectionView = self.collectionView {
                for section in 0 ..< collectionView.numberOfSections {
                    if let numItems = numberOfItemsInSection(section) {
                        height += CGFloat(numItems) * cellHeight
                    }
                }

                bounds = collectionView.bounds
            }

            return CGSize(width: bounds.width, height: max(height, bounds.height))
        }
    }

    override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
        if let oldBounds = self.collectionView?.bounds,
            oldBounds.width != newBounds.width || oldBounds.height != newBounds.height
        {
            return true
        }

        return false
    }
}

A: Just click on UICollectionView in storyboard,
in inspector menu under view section change semantic to Force Right-to-Left
I have attach an image to show how to do it in the inspector menu:

A: I'm assuming you are using UICollectionViewFlawLayout, and this doesn't have logic to do that, it only works in a TOP-LEFT BOTTOM-RIGHT order. To do that you have to build your own layout, which you can do creating a new object that inherits from UICollectionViewLayout.
It seems like a lot of work but is not really that much, you have to implement 4 methods, and since your layout is just bottom-up should be easy to know the frames of each cell.
Check the apple tutorial here: https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CreatingCustomLayouts/CreatingCustomLayouts.html

A: The data collection does not actually have to be modified but that will produce the expected result.  Since you control the following method:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell

Simply return cells created from inverting the requested index. The index path is the cell's index in the collection, not necessarily the index in the source data set. I used this for a reversed display from a CoreData set.
let desiredIndex = dataProfile!.itemEntries!.count - indexPath[1] - 1;

A: Don't know if this still would be useful but I guess it might be quite useful for others.
If your collection view's cells are of the same height there is actually a much less complicated solution for your problem than building a custom UICollectionViewLayout.
Firstly, just make an outlet of your collection view's top constraint and add this code to the view controller:
-(void)viewWillAppear:(BOOL)animated {
    [self.view layoutIfNeeded]; //for letting the compiler know the actual height and width of your collection view before we start to operate with it
    if (self.collectionView.frame.size.height > self.collectionView.collectionViewLayout.collectionViewContentSize.height) {
        self.collectionViewTopConstraint.constant = self.collectionView.frame.size.height - self.collectionView.collectionViewLayout.collectionViewContentSize.height;
    }

So basically you calculate the difference between collection view's height and its content only if the view's height is bigger. Then you adjust it to the constraint's constant. Pretty simple. But if you need to implement cell resizing as well, this code won't be enough. But I guess this approach may be quite useful. Hope this helps.

A: A simple working solution is here!
// Change the collection view layer transform.
collectionView.transform3D = CATransform3DMakeScale(1, -1, 1)

// Change the cell layer transform.
cell.transform3D = CATransform3DMakeScale(1, -1, 1)

A: It is as simple as:
yourCollectionView.inverted = true

PS : Same for Texture/IGListKit..


text:
Q: Why is .[expression] invalid XPath syntax This syntax in a XLST template:
.[starts-with(@type,'&#x')]

gives the following error message when using Xalan:
XPath error: Use 'self::node()[predicate]' instead of '.[predicate]'.

The XPath 1.0 (http://www.w3.org/TR/xpath/) is unclear on this point, but it appears that you can't use the abbreviated node syntax in front of a predicate?
Can anyone confirm this or point to specific syntax rules governing precisely what can appear just before a predicate?


text:
Q: Can computer literacy be assumed across SE sites? It's entirely possible this has simply been my experience...
...but I've noticed across the SE sites- not just the CS-related ones like SO, Programmers, Theoretical Computer Science, sec.se, etc.- there appears to be a lot of crossover between users of the technical network sites, and the non-technical ones, and as a result people feel comfortable using common abbreviations and referencing common technologies / IT-related terms without citing sources.
I do this myself, and there haven't been any issues, but recently someone complained in a comments section that someone used the abbreviation MSDS (which apparently stands for "Material Safety Datasheet"). While that's not an IT-related term-of-art, it started me wondering whether the de-facto standard of assuming computer literacy actually was a de-facto standard, and more broadly whether it should be.

*

*Does it alienate people who would otherwise use these sites?

*Does it not alienate people, but a significant majority of the site's users would prefer more citations?

*Or is it completely fine?

Post Script:
And I don't just mean using specific abbreviations; I also mean making comparisons to software testing methodologies, or referencing the Jargon File or the "Real Programmer" essay. Things that make sense within tech culture, but not to outsiders. References that you wouldn't make on your grandmother's quilting forum.

A: You can assume basic experience.  Basic experience of what, though, is dependent on the site.  For Arqade, we can assume you're a gamer, and can, reasonably accurately, insert and remove disks, and maybe click an icon to run your game.  We can't assume you're a developer, or even at all technically inclined.
Cooking can be reasonably assumed that you've graduated from the burning water stage, and can follow directions from a recipe.  Electronic Engineering would be knowing what a breadboard is, and the difference between a resistor and a battery.
Most programming related ones can be naturally assumed that you're not going to pour water into your computer while its on, and that you generally know your way around a computer.
The key, though, is that each site has their own expertise, with it's own expectations and values.  What works for one area, isn't going to work for another.  And that's fine.  But there's no sweeping statement you can make about what skills can be assumed network wide.  Other than the core SE tenets.


text:
Q: Time Zone Abbreviation to Current Time? Is there a way that I can use a Time Zone abbreviation (PST, EDT, GMT, etc) and turn it into the current time with C# on WP7?
I would assume I could use something like TimeZoneInfo to find the offset, but how do actually get the offset from the abbreviation, or alternatively from the full time zone name (gotten by mapping the abbreviations to the full names)?

A: Use TimeZoneInfo.Id that's what it's there for.

A: No, that's not going to fly.  There is no agreed-upon standard to abbreviating time zone names.  Hard to make one too, the common abbreviation for China Standard Time and Central Standard Time, CST, will probably be ambiguous forever.  Check this list of common abbreviations.
On top of which Windows Phone doesn't have the time zone database that Windows has (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones).  You'll have to make your own.

A: I hope this isn't too much copy, but based on the solution above, here is the above implemented
var Abbreviations = new Dictionary<string, string>()
            {
            {"A","Alpha Time Zone"},
            {"ACDT","Australian Central Daylight Time"},
            {"ACST","Australian Central Standard Time"},
            {"ADT","Atlantic Daylight Time"},
            {"ADT","Atlantic Daylight Time"},
            {"AEDT","Australian Eastern Daylight Time"},
            {"AEST","Australian Eastern Standard Time"},
            {"AFT","Afghanistan Time"},
            {"AKDT","Alaska Daylight Time"},
            {"AKST","Alaska Standard Time"},
            {"ALMT","Alma-Ata Time"},
            {"AMST","Armenia Summer Time"},
            {"AMST","Amazon Summer Time"},
            {"AMT","Armenia Time"},
            {"AMT","Amazon Time"},
            {"ANAST","Anadyr Summer Time"},
            {"ANAT","Anadyr Time"},
            {"AQTT","Aqtobe Time"},
            {"ART","Argentina Time"},
            {"AST","Arabia Standard Time"},
            {"AST","Atlantic Standard Time"},
            {"AST","Atlantic Standard Time"},
            {"AST","Atlantic Standard Time"},
            {"AWDT","Australian Western Daylight Time"},
            {"AWST","Australian Western Standard Time"},
            {"AZOST","Azores Summer Time"},
            {"AZOT","Azores Time"},
            {"AZST","Azerbaijan Summer Time"},
            {"AZT","Azerbaijan Time"},
            {"B","Bravo Time Zone"},
            {"BNT","Brunei Darussalam Time"},
            {"BOT","Bolivia Time"},
            {"BRST","Brasilia Summer Time"},
            {"BRT","Brasília time"},
            {"BST","Bangladesh Standard Time"},
            {"BST","British Summer Time"},
            {"BTT","Bhutan Time"},
            {"C","Charlie Time Zone"},
            {"CAST","Casey Time"},
            {"CAT","Central Africa Time"},
            {"CCT","Cocos Islands Time"},
            {"CDT","Cuba Daylight Time"},
            {"CDT","Central Daylight Time"},
            {"CEST","Central European Summer Time"},
            {"CET","Central European Time"},
            {"CET","Central European Time"},
            {"CHADT","Chatham Island Daylight Time"},
            {"CHAST","Chatham Island Standard Time"},
            {"CKT","Cook Island Time"},
            {"CLST","Chile Summer Time"},
            {"CLT","Chile Standard Time"},
            {"COT","Colombia Time"},
            {"CST","China Standard Time"},
            {"CST","Central Standard Time"},
            {"CST","Cuba Standard Time"},
            {"CST","Central Standard Time"},
            {"CVT","Cape Verde Time"},
            {"CXT","Christmas Island Time"},
            {"ChST","Chamorro Standard Time"},
            {"D","Delta Time Zone"},
            {"DAVT","Davis Time"},
            {"E","Echo Time Zone"},
            {"EASST","Easter Island Summer Time"},
            {"EAST","Easter Island Standard Time"},
            {"EAT","Eastern Africa Time"},
            {"EAT","East Africa Time"},
            {"ECT","Ecuador Time"},
            {"EDT","Eastern Daylight Time"},
            {"EDT","Eastern Daylight Time"},
            {"EDT","Eastern Daylight Time"},
            {"EEST","Eastern European Summer Time"},
            {"EEST","Eastern European Summer Time"},
            {"EEST","Eastern European Summer Time"},
            {"EET","Eastern European Time"},
            {"EET","Eastern European Time"},
            {"EET","Eastern European Time"},
            {"EGST","Eastern Greenland Summer Time"},
            {"EGT","East Greenland Time"},
            {"EST","Eastern Standard Time"},
            {"EST","Eastern Standard Time"},
            {"EST","Eastern Standard Time"},
            {"ET","Tiempo del Este"},
            {"ET","Tiempo del Este"},
            {"ET","Tiempo Del Este "},
            {"F","Foxtrot Time Zone"},
            {"FJST","Fiji Summer Time"},
            {"FJT","Fiji Time"},
            {"FKST","Falkland Islands Summer Time"},
            {"FKT","Falkland Island Time"},
            {"FNT","Fernando de Noronha Time"},
            {"G","Golf Time Zone"},
            {"GALT","Galapagos Time"},
            {"GAMT","Gambier Time"},
            {"GET","Georgia Standard Time"},
            {"GFT","French Guiana Time"},
            {"GILT","Gilbert Island Time"},
            {"GMT","Greenwich Mean Time"},
            {"GMT","Greenwich Mean Time"},
            {"GST","Gulf Standard Time"},
            {"GYT","Guyana Time"},
            {"H","Hotel Time Zone"},
            {"HAA","Heure Avancée de l'Atlantique"},
            {"HAA","Heure Avancée de l'Atlantique"},
            {"HAC","Heure Avancée du Centre"},
            {"HADT","Hawaii-Aleutian Daylight Time"},
            {"HAE","Heure Avancée de l'Est "},
            {"HAE","Heure Avancée de l'Est "},
            {"HAP","Heure Avancée du Pacifique"},
            {"HAR","Heure Avancée des Rocheuses"},
            {"HAST","Hawaii-Aleutian Standard Time"},
            {"HAT","Heure Avancée de Terre-Neuve"},
            {"HAY","Heure Avancée du Yukon"},
            {"HKT","Hong Kong Time"},
            {"HLV","Hora Legal de Venezuela"},
            {"HNA","Heure Normale de l'Atlantique"},
            {"HNA","Heure Normale de l'Atlantique"},
            {"HNA","Heure Normale de l'Atlantique"},
            {"HNC","Heure Normale du Centre"},
            {"HNC","Heure Normale du Centre"},
            {"HNE","Heure Normale de l'Est"},
            {"HNE","Heure Normale de l'Est"},
            {"HNE","Heure Normale de l'Est"},
            {"HNP","Heure Normale du Pacifique"},
            {"HNR","Heure Normale des Rocheuses"},
            {"HNT","Heure Normale de Terre-Neuve"},
            {"HNY","Heure Normale du Yukon"},
            {"HOVT","Hovd Time"},
            {"I","India Time Zone"},
            {"ICT","Indochina Time"},
            {"IDT","Israel Daylight Time"},
            {"IOT","Indian Chagos Time"},
            {"IRDT","Iran Daylight Time"},
            {"IRKST","Irkutsk Summer Time"},
            {"IRKT","Irkutsk Time"},
            {"IRST","Iran Standard Time"},
            {"IST","Israel Standard Time"},
            {"IST","India Standard Time"},
            {"IST","Irish Standard Time"},
            {"JST","Japan Standard Time"},
            {"K","Kilo Time Zone"},
            {"KGT","Kyrgyzstan Time"},
            {"KRAST","Krasnoyarsk Summer Time"},
            {"KRAT","Krasnoyarsk Time"},
            {"KST","Korea Standard Time"},
            {"KUYT","Kuybyshev Time"},
            {"L","Lima Time Zone"},
            {"LHDT","Lord Howe Daylight Time"},
            {"LHST","Lord Howe Standard Time"},
            {"LINT","Line Islands Time"},
            {"M","Mike Time Zone"},
            {"MAGST","Magadan Summer Time"},
            {"MAGT","Magadan Time"},
            {"MART","Marquesas Time"},
            {"MAWT","Mawson Time"},
            {"MDT","Mountain Daylight Time"},
            {"MESZ","Mitteleuropäische Sommerzeit"},
            {"MEZ","Mitteleuropäische Zeit"},
            {"MHT","Marshall Islands Time"},
            {"MMT","Myanmar Time"},
            {"MSD","Moscow Daylight Time"},
            {"MSK","Moscow Standard Time"},
            {"MST","Mountain Standard Time"},
            {"MUT","Mauritius Time"},
            {"MVT","Maldives Time"},
            {"MYT","Malaysia Time"},
            {"N","November Time Zone"},
            {"NCT","New Caledonia Time"},
            {"NDT","Newfoundland Daylight Time"},
            {"NFT","Norfolk Time"},
            {"NOVST","Novosibirsk Summer Time"},
            {"NOVT","Novosibirsk Time"},
            {"NPT","Nepal Time "},
            {"NST","Newfoundland Standard Time"},
            {"NUT","Niue Time"},
            {"NZDT","New Zealand Daylight Time"},
            {"NZDT","New Zealand Daylight Time"},
            {"NZST","New Zealand Standard Time"},
            {"NZST","New Zealand Standard Time"},
            {"O","Oscar Time Zone"},
            {"OMSST","Omsk Summer Time"},
            {"OMST","Omsk Standard Time"},
            {"P","Papa Time Zone"},
            {"PDT","Pacific Daylight Time"},
            {"PET","Peru Time"},
            {"PETST","Kamchatka Summer Time"},
            {"PETT","Kamchatka Time"},
            {"PGT","Papua New Guinea Time"},
            {"PHOT","Phoenix Island Time"},
            {"PHT","Philippine Time"},
            {"PKT","Pakistan Standard Time"},
            {"PMDT","Pierre & Miquelon Daylight Time"},
            {"PMST","Pierre & Miquelon Standard Time"},
            {"PONT","Pohnpei Standard Time"},
            {"PST","Pacific Standard Time"},
            {"PST","Pitcairn Standard Time"},
            {"PT","Tiempo del Pacífico"},
            {"PWT","Palau Time"},
            {"PYST","Paraguay Summer Time"},
            {"PYT","Paraguay Time"},
            {"Q","Quebec Time Zone"},
            {"R","Romeo Time Zone"},
            {"RET","Reunion Time"},
            {"S","Sierra Time Zone"},
            {"SAMT","Samara Time"},
            {"SAST","South Africa Standard Time"},
            {"SBT","Solomon IslandsTime"},
            {"SCT","Seychelles Time"},
            {"SGT","Singapore Time"},
            {"SRT","Suriname Time"},
            {"SST","Samoa Standard Time"},
            {"T","Tango Time Zone"},
            {"TAHT","Tahiti Time"},
            {"TFT","French Southern and Antarctic Time"},
            {"TJT","Tajikistan Time"},
            {"TKT","Tokelau Time"},
            {"TLT","East Timor Time"},
            {"TMT","Turkmenistan Time"},
            {"TVT","Tuvalu Time"},
            {"U","Uniform Time Zone"},
            {"ULAT","Ulaanbaatar Time"},
            {"UTC","Universal Time Coordinated"},
            {"UYST","Uruguay Summer Time"},
            {"UYT","Uruguay Time"},
            {"UZT","Uzbekistan Time"},
            {"V","Victor Time Zone"},
            {"VET","Venezuelan Standard Time"},
            {"VLAST","Vladivostok Summer Time"},
            {"VLAT","Vladivostok Time"},
            {"VUT","Vanuatu Time"},
            {"W","Whiskey Time Zone"},
            {"WAST","West Africa Summer Time"},
            {"WAT","West Africa Time"},
            {"WEST","Western European Summer Time"},
            {"WEST","Western European Summer Time"},
            {"WESZ","Westeuropäische Sommerzeit"},
            {"WET","Western European Time"},
            {"WET","Western European Time"},
            {"WEZ","Westeuropäische Zeit"},
            {"WFT","Wallis and Futuna Time"},
            {"WGST","Western Greenland Summer Time"},
            {"WGT","West Greenland Time"},
            {"WIB","Western Indonesian Time"},
            {"WIT","Eastern Indonesian Time"},
            {"WITA","Central Indonesian Time"},
            {"WST","Western Sahara Summer Time"},
            {"WST","West Samoa Time"},
            {"WT","Western Sahara Standard Time"},
            {"X","X-ray Time Zone"},
            {"Y","Yankee Time Zone"},
            {"YAKST","Yakutsk Summer Time"},
            {"YAKT","Yakutsk Time"},
            {"YAPT","Yap Time"},
            {"YEKST","Yekaterinburg Summer Time"},
            {"YEKT","Yekaterinburg Time"},
            {"Z","Zulu Time Zone"}

            };

A: This is what I'm using:
    public static readonly Dictionary<string, string> AbbreviationsMap = new Dictionary<string, string>() {
        {"ACDT", "+1030"}, // Australian Central Daylight
        {"ACST", "+0930"}, // Australian Central Standard
        {"ADT", "-0300"}, // (US) Atlantic Daylight
        {"AEDT", "+1100"}, // Australian East Daylight
        {"AEST", "+1000"}, // Australian East Standard
        {"AHDT", "-0900"},
        {"AHST", "-1000"},
        {"AST", "-0400"}, // (US) Atlantic Standard
        {"AT", "-0200"}, // Azores
        {"AWDT", "+0900"}, // Australian West Daylight
        {"AWST", "+0800"}, // Australian West Standard
        {"BAT", "+0300"}, // Bhagdad
        {"BDST", "+0200"}, // British Double Summer
        {"BET", "-1100"}, // Bering Standard
        {"BST", "-0300"}, // Brazil Standard
        {"BT", "+0300"}, // Baghdad
        {"BZT2", "-0300"}, //Brazil Zone 2
        {"CADT", "+1030"}, // Central Australian Daylight
        {"CAST", "+0930"}, // Central Australian Standard
        {"CAT", "-1000"}, // Central Alaska
        {"CCT", "+0800"}, // China Coast
        {"CDT", "-0500"}, // (US) Central Daylight
        {"CED", "+0200"}, // Central European Daylight
        {"CET", "+0100"}, // Central European
        {"CST", "-0600"}, // (US) Central Standard
        {"CENTRAL", "-0600"}, // (US) Central Standard
        {"EAST", "+1000"}, // Eastern Australian Standard
        {"EDT", "-0400"}, // (US) Eastern Daylight
        {"EED", "+0300"}, // Eastern European Daylight
        {"EET", "+0200"}, // Eastern Europe
        {"EEST", "+0300"}, // Eastern Europe Summer
        {"EST", "-0500"}, // (US) Eastern Standard
        {"EASTERN", "-0500"}, // (US) Eastern Standard
        {"FST", "+0200"}, // French Summer
        {"FWT", "+0100"}, // French Winter
        {"GMT", "-0000"}, // Greenwich Mean
        {"GST", "+1000"}, // Guam Standard
        {"HDT", "-0900"}, // Hawaii Daylight
        {"HST", "-1000"}, // Hawaii Standard
        {"IDLE", "+1200"}, // Internation Date Line East
        {"IDLW", "-1200"}, // Internation Date Line West
        {"IST", "+0530"}, // Indian Standard
        {"IT", "+0330"}, // Iran
        {"JST", "+0900"}, // Japan Standard
        {"JT", "+0700"}, // Java
        {"MDT", "-0600"}, // (US) Mountain Daylight
        {"MED", "+0200"}, // Middle European Daylight
        {"MET", "+0100"}, // Middle European
        {"MEST", "+0200"}, // Middle European Summer
        {"MEWT", "+0100"}, // Middle European Winter
        {"MST", "-0700"}, // (US) Mountain Standard
        {"MOUNTAIN", "-0700"}, // (US) Mountain Standard
        {"MT", "+0800"}, // Moluccas
        {"NDT", "-0230"}, // Newfoundland Daylight
        {"NFT", "-0330"}, // Newfoundland
        {"NT", "-1100"}, // Nome
        {"NST", "+0630"}, // North Sumatra
        {"NZ", "+1100"}, // New Zealand
        {"NZST", "+1200"}, // New Zealand Standard
        {"NZDT", "+1300"}, // New Zealand Daylight
        {"NZT", "+1200"}, // New Zealand
        {"PDT", "-0700"}, // (US) Pacific Daylight
        {"PST", "-0800"}, // (US) Pacific Standard
        {"PACIFIC", "-0800"}, // (US) Pacific Standard
        {"ROK", "+0900"}, // Republic of Korea
        {"SAD", "+1000"}, // South Australia Daylight
        {"SAST", "+0900"}, // South Australia Standard
        {"SAT", "+0900"}, // South Australia Standard
        {"SDT", "+1000"}, // South Australia Daylight
        {"SST", "+0200"}, // Swedish Summer
        {"SWT", "+0100"}, // Swedish Winter
        {"USZ3", "+0400"}, //USSR Zone 3
        {"USZ4", "+0500"}, //USSR Zone 4
        {"USZ5", "+0600"}, //USSR Zone 5
        {"USZ6", "+0700"}, //USSR Zone 6
        {"UT", "-0000"}, // Universal Coordinated
        {"UTC", "-0000"}, // Universal Coordinated
        {"UZ10", "+1100"}, //USSR Zone 10
        {"WAT", "-0100"}, // West Africa
        {"WET", "-0000"}, // West European
        {"WST", "+0800"}, // West Australian Standard
        {"YDT", "-0800"}, // Yukon Daylight
        {"YST", "-0900"}, // Yukon Standard
        {"ZP4", "+0400"}, // USSR Zone 3
        {"ZP5", "+0500"}, //USSR Zone 4
        {"ZP6", "+0600"}   //USSR Zone 5
    };


text:
Q: SCSS if function without false (else) clause Anyone know of a way to use the SASS if function (not the @if directive) without a false (aka else) clause?
Use Case: I have a SASS library that's normally used on its own and includes a full CSS reset. Someone wants to take an individual file from the library and add it to a project that includes Zurb Foundation, which, of course, totally destroys the CSS reset. I'd like to accommodate that use case with something like:
$css-reset: false !default;

.form__input {
    border-radius: 4px if(not $css-reset, !important);
}

That's a SASS compile error, though, since the compiler requires a third parameter to the if() function.
Thanks in advance

A: Not super elegant, but this works:
border-radius: 4px if(not $css-reset, !important, unquote("");


text:
Q: How to iterate data from array? I'm developing a Products page using React. I have setup data like this
const data = {
  items: [
    {
      id: 1,
      name: 'Alloha Zune',
      brand: 'Alloha',
      slug: 'asus-zune-4',
      price: '90$',
      image: '/images/alloha_zune.png',
      category: 'Alloha',
    },
    {
      id: 2,
      name: 'Bacleim Pro',
      brand: 'Bacleim',
      slug: 'bacleim-pro',
      price: '110$',
      image: '/images/bacleim_pro.jpg',
      category: 'Bacleim',
    },
    {
      id: 3,
      name: 'Xarin Makeshift',
      brand: 'Xarin',
      slug: 'xarin-makeshift',
      price: '120$',
      image: '/images/xarin_makeshift.png',
      category: 'Xarin',
    },
   ],
  };

export default data;

I want to iterate these items as cards using reusable components.
The card component is as follows:
export default function Card() {
  return (

      <>

{item.name}

{item.price}

{item.brand}

{item.category}

            <button type="submit" className="primary-button">
              Buy
            </button>

      </>

  );
}

And I want to create another component such CardList Component to iterate over the data.
What will be the most code-efficient way to do this in React?

A: Create a reusable Product Component and you can pass data to it in the form of props, like this
return (

            {data.items.map(product => {
                return <ProductComponent ...product />
            })}

)

Note I'm spreading the product object so that all the key-value pairs are passed to the component in the form of props

A: You can map over the data.items and pass required props to Card component.
CODESANDBOX DEMO
export default function App() {
    return (
        <>
            {data.items.map((product) => {
                const { id, ...rest } = product;
                return <Card {...rest} key={id} />;
            })}
        </>
    );
}


text:
Q: endless loop with mdframed The following code leads to an endless loop. pdflatex is at 100% CPU and the log is constantly increasing with number counted upwards.
\documentclass{article}
\usepackage{mdframed}
\begin{document}
\mdframed
\vrule height 210mm
\endmdframed
\end{document}

A: Based on the example of Patrick, I can provide an answer.
The material of the environment mdframed is saved in a simple \vbox. Based on computed lengths related to the text height, the box will be split by \vsplit. Your material can't be split, so you run into an endless loop because mdframed repeats the splitting algorithm. Up to now there is no check for such situations.
In order to avoid the endless loop you can use the option nobreak. However the result is a blank page and the output itself.
\documentclass{scrartcl}
\usepackage{mdframed}
\usepackage{lipsum}
\begin{document}
\begin{mdframed}[nobreak=true]
 \vrule height 250mm
\end{mdframed}
\end{document}


text:
Q: iFrame is not showing result if changed from javascript javascript code:
<script>

    function searchall()
    {
        var search = document.getElementById("txtSearch");
        var frame1 = document.getElementById("frame1");

        frame1.src = "https://www.google.co.in/search?q=" + search.value;
        alert(frame1.src);
    }

</script>

html code:
<asp:TextBox ID="txtSearch" runat="server" class="form-control my-txt-box" ></asp:TextBox>
    <input id="btnAll" class="my-btn" onclick="searchall()" type="button" value="Search All" />

        <iframe id="frame1" src="home.aspx">
            does not support
        </iframe>

my code seems to be correct but still iFrame does not show the result, its blank. I dont understand why. I even checked with alert(frame1.src); iframe src is setting correct but not showing result.
please help

A: It gives me an error (search.value undefined) where is the txtSearch input ?
If I put a txtSearch input it gives me the folowing error:

Refused to display 'https://www.google.co.in/search?q=xxx' in a frame
  because it set 'X-Frame-Options' to 'SAMEORIGIN'.

The header of HTTP response from google.com has:
x-frame-options:SAMEORIGIN

It disables the page rendering in an iframe. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
http://codepen.io/anon/pen/MppZGX
EDIT:
The iframe hosting option for displaying search results is no longer supported by google. See: https://support.google.com/customsearch/answer/4542055?hl=en  and https://support.google.com/customsearch/answer/2641279?hl=en

A: Try to refresh your iframe on function ending:
var iframe = document.getElementById('youriframe');
iframe.src = iframe.src;

Also, switch var "search" ID by "btnAll". The "txtSearch" is not on your HTML.


text:
Q: Is there a way of controlling the version of the Model? I have one workspace A and a workspace B and I am looking to copy models from workspace A to workspace B.
Let's say the model M_1 is in version V_1 in workspace A. I would like to register this model M_1 in workspace B with the same version V_1.
Using the register method
Model.register(workspace_B, model_path, model_from_workspace_A.name)

I am not able to choose the version for this model. By default it sets the version of the registered model as 1 (if it does not exist) or M_2 + 1
if it already exists in workspace B.
Is there a workaround for this?
Thank you!

A: Currently you cannot choose a custom version when registering a model, it is controlled by AzureML. A possible workaround would be to use tags when registering the models. You can use same tag when registering the models in different workspaces.


text:
Q: Fail a build when the post-build event of a referenced project fails I have a winforms app (PostBuildApp) that has a project reference to another project (PostBuildLib) inside the same solution. Both projects have a post-build event. When the post-build event of the Lib fails Visual Studio keeps on compiling and running the post-build event of the App which is dependent on the Lib. Is there a way to fail a build when the post-build event of one of the referenced projects fails?
Screenshot of visual studio succeeding a build when post-build of a referenced project failed.
Update: to be clear, I'm rebuilding the PostBuildApp project. Not running it. I've found this issue which might be related?


text:
Q: Result of an if condition comparing a single variable with attributes() I was trying to understand the following example from w3schools.com: https://www.w3schools.com/xml/xsl_editxml.asp
The line which confused me the most is found in the PHP code:
if($key == $x->attributes())

I have found that attributes() produces an array of attribute names and their corresponding values. The if statement above clearly is interested only in the attribute name. Is the if statement true, even if only one attribute name is equal to $key ?
Another side question. In the same PHP code, there's the following line
$xmlLoad->asXML($xml);

Can someone explain why is the latter added?

A: I'm not surprised, that the example confused you. I hope I can clear it up a little. You probably want the manual to get a better explanation of the steps:
$xml is the the name of the xml file and not a string representation as one might expect.
function updateFile($xml) {
  $xmlLoad = simplexml_load_file($xml);

$postKeysis never used. You can ignore, or delete that line.
  $postKeys = array_keys($_POST);

children() returns a SimpleXMLElement, but the class is traversable. I.e. you can use it 'like an array' (not true for all array operations)
  foreach($xmlLoad->children() as $x) {
    foreach($_POST as $key=>$value) {

attribues() returns yet another SimpleXMLElement, not a string. Thanks to type juggling, loose comparison (==), and the magic __toString() of SimpleXMLElement, the if works.
      if($key == $x->attributes()) {
        $x->value = $value;
  }}}

If you pass it a file name, asXML() does not return the XML content, but writes it to a file. Remember `$xml is a file name. The next line reads the file again.
  $xmlLoad->asXML($xml);
  loadFile($xml,"tool_updated.xsl");
}


text:
Q: retain array class when operation results in 2-dimensional matrix I have an array that can have one or more pages or sheets (my names for the third dimension).  I am attempting to perform operations on the array.  When there is only one sheet or page the result of the operation is a matrix.  I would like the result to be an array.  Is there a way to retain the class array even when the result of the operation has only 1 sheet or page?
Here is an example.  I would like my.var.2 and my.var.3 to be arrays.  The variable my.pages is set to 1 here, which seems to be causing the problem.  However, my.pages can be >1.  If my.pages <- 2 then my.var.2 and my.var.3 are arrays.
set.seed(1234)

my.rows    <- 10
my.columns <- 4
my.pages   <- 1

my.var.1 <- array( rnorm((my.rows*my.columns*my.pages), 10, 2),
                        c(my.rows,my.columns,my.pages))
my.var.1

my.var.2 <-  2 * my.var.1[,-my.columns,]
my.var.3 <- 10 * my.var.1[,-1,]

class(my.var.2)
class(my.var.3)

my.var.2 <- as.array(my.var.2)
my.var.3 <- as.array(my.var.3)

class(my.var.2)
class(my.var.3)

my.var.2 <- as.array( 2 * my.var.1[,-my.columns,])
my.var.3 <- as.array(10 * my.var.1[,-1,]         )

class(my.var.2)
class(my.var.3)

The switch to matrix causes problems when I try to use my.var.1 and my.var.2 in nested for-loops.
The following if statement seems to solve the problem, but also seems a little clunky.  Is there a more elegant solution?
if(my.pages == 1) {my.var.2 <- array(my.var.2, c(my.rows,(my.columns-1),my.pages))}

A: From help([):
Usage:
     x[i, j, ... , drop = TRUE]
...
drop: For matrices and arrays.  If 'TRUE' the result is coerced to
      the lowest possible dimension (see the examples).  This only
      works for extracting elements, not for the replacement.  See
      'drop' for further details.

Your code, revisited:
set.seed(1234)

my.rows    <- 10
my.columns <- 4
my.pages   <- 1

my.var.1 <- array( rnorm((my.rows*my.columns*my.pages), 10, 2),
                        c(my.rows,my.columns,my.pages))
my.var.2 <-  2 * my.var.1[,-my.columns,,drop=FALSE]
my.var.3 <- 10 * my.var.1[,-1,,drop=FALSE]

class(my.var.2)
## [1] "array"
class(my.var.3)
## [1] "array"


text:
Q: Is there any website built by HTML frames? Should I learn this topic? I almost completed to learn HTML and now I started to learn CSS.
The last topic of HTML learning on my book is HTML Frames. But this topic seems me so boring. Actually I skip this topic, because there is no any website touched in my Internet Accessing experience which use the HTML frames!!!
Perhaps I'm wrong.
So my question: "Is there any website built by HTML frames? Should I learn it?"

A: No. It is an extremely old concept that has been out of use for a long time, and is now even deprecated in the spec and may eventually stop working / being supported in browsers.
When I started building websites seriously about 10 years ago they were an old and long out of general use concept then.
If you were bored and just wanted to learn it for historical purposes then have fun. But there is absolutely no practical value in knowing frames.
Skip it. In fact, just tear those pages out. They're not even worth the added weight to the book.

Note: iframes are a completely different thing and are very much in use and you should know them...just specifically frames forget about.

A: As you can see
This is a fact...
Here
and...
Here
HTML frameset Tag. Not Supported in HTML5.

HTML frame Tag. Not Supported in HTML5.

This is an opinion...
Your next question is should you learn it. This is up to you. I would focus on more relevant information but learning things that are no longer supported could be of use to you.
I hope this helps.

A: The short answer is 'NO',
You don't have to, or should I say you don't have the need to do so, since HTML5 doesn't support it.


text:
Q: Reducing list (dr racket) I am a beginner in Dr Racket and now I am looking for a solution to reduce nested lists.
For example:
+ 0 (list 1 2 (list 3 (list 4 5) 6) 7 (list (list 8)) empty 9))
should produce 45.
My current function only works for normal lists, but as soon as there is a list in the list, it doesn´t work anymore.
(define (reduce fun neutral lst)
  (cond
    ((empty? lst) neutral)
     (else
          (fun (car lst)
           (reduce fun neutral (rest lst))))))

A: You must consider the case where (car lst) is also a list. In that case, you will need to reduce (car lst) too, before applying fun.
(define (reduce fun neutral lst)
  (cond
    [(empty? lst)
     neutral]
    [(list? (car lst))
     (fun (reduce fun neutral (car lst))
          (reduce fun neutral (rest lst)))]
    [else
     (fun (car lst)
          (reduce fun neutral (rest lst)))]))


text:
Q: Suppose A ⊆ B. Prove that for every set C, C \ B ⊆ C \ A. I have two problems I'm just trying to figure out the steps to solve. I'm studying for an exam and they were suggested as good study material but I don't understand how either would be solved.

*

*Suppose A ⊆ B. Prove that for every set C,  C \ B ⊆ C \ A.

*Prove that if A ⊆ B and A ⊆ C then A ⊆ B ∩ C.
I believe you can solve both by contradiction but I get lost after a few steps.
Any advice is much appreciated thank you!

A: If $x \in C \setminus B$, then $x \in C$ and $x \notin B$ by definition, implying that $x \in C$ and $x \notin A$ by the assumption that $A \subset B$; this proves the first statement.
If $x \in A$, then $x \in B$ and $x \in C$ by the assumption that $A \subset B$ and $A \subset C$; but this implies by definition that $x \in B \cap C$. We have proved the second statement.

A: Recall that $X \subseteq Y$ by definition means for any $x \in X$, $x \in Y$. So to prove 1, you can show that for any $x$, if $x \in C \backslash B$ then $x \in C \backslash A$. So let $x \in C \backslash B$ be arbitrary. By definition, this means $x \in C$ but $x \not\in B$. But then $x \not\in A$ by assumption that $A \subseteq B$. This proves that $x \in C \backslash A$. And we are done.


text:
Q: Can I nest a ruby embed symbol <%= %> inside another <%= %> I want to use a helper Method inside link_to tag as follows
<%= link_to "Home", root_path, class:"nav-link <%= activeLink('home') %>" %>

This is my helper method
def activeLink(action_name)
    if controller.action_name == action_name
      "active"
    end
  end

I am getting error saying;
ActionView::SyntaxErrorInTemplate in PagesController#about
I want that helper method to check the current action name and
set the 'active' CSS class if current action matches the input action name

A: Can you use nested <%= ... %> notation? No.
However, what you're looking for is a form of string interpolation. As mentioned in the comments Ruby variables can be converted to strings in a couple ways (full details outlined in the linked guide).
The primary method you'll see is by using #{} within a string ie "This is my string #{ruby_variable}".
Which means you could use the following:
my_string = "World!"

hello_world_string = "Hello #{my_string}"

hello_world_string
=> "Hello World!"


text:
Q: Nested Case when statements in Python The following code creates as column called 'Flagged' in SAS:
Case When t3.Proportion=. then case when t3.'Standardised proportion'n >t1.SigmaMultiple Then 1 else 0
End
Else
Case When t3.Proportion=. and  abs(t3.'Standardised proportion'n) > t1.SigmaMultiple Then 1 Else 0
End
End

I'm trying to replicate it in python and usually I would have done a conditions code however the nested Case when aspect is confusing me.
The code i tried but didn't seem to be matching:
conditions =[
     ((dfSigmamissing['Proportion'] == 0) & (dfSigmamissing['SP'] > dfSigmamissing['SigmaMultiple'])),
       ((dfSigmamissing['Proportion'] == 0) & (dfSigmamissing['SP'] < dfSigmamissing['SigmaMultiple'])),
        ((dfSigmamissing['SP'].abs() > (dfSigmamissing['SigmaMultiple'])))
                ]

choices = [1,0,1]

dfSigmamissing['Flagged'] = np.select(conditions, choices, default=0)

Any help would be greatly appreciated.
Thank you

A: You're very close I think, you need to remove the second condition from the conditions list, because if the first condition fails, np.select will fall back there. Otherwise, one of the first two conditions are (almost) always True since they are (almost) complementary. Also, we need
dfSigmamissing['Proportion'] == 0 for the last condition, too:
conditions = [
     (dfSigmamissing["Proportion"] == 0) & (dfSigmamissing["SP"] > dfSigmamissing["SigmaMultiple"]),
     (dfSigmamissing["Proportion"] == 0) & (dfSigmamissing["SP"].abs() > dfSigmamissing["SigmaMultiple"])
]

choices = [1, 1]

default = 0

dfSigmamissing["Flagged"] = np.select(conditions, choices, default)

This works as:

*

*check first condition holds?
-- if so put 1 in the corresponding row
-- if not, go to second condition

*does the second condition hold?
-- if so, put 1 in the corresponding row
-- if not, fallback to default value, i.e., 0
To avoid repetition in the code, we can refactor some condition elements:
zero_prop = dfSigmamissing["Proportion"] == 0
sp = dfSigmamissing["SP"]
sigma_mul = dfSigmamissing["SigmaMultiple"]

conditions = [
    zero_prop & (sp > sigma_mul),
    zero_prop & (sp.abs() > sigma_mul)
]

which might increase readibility.
We can go even further and glue the first two conditions since both will output 1. This means we have 2 conditions now, so we can go for np.where which is this special case of np.select. Furhter, as far as I see, sp > sigma_mul is contained in sp.abs() > sigma_mul, so we can drop the former:
condition = zero_prop & (sp.abs() > sigma_mul)
dfSigmamissing["Flagged"] = np.where(condition, 1, 0)


text:
Q: How To Edit Permission for facebook in setting
- (void)viewDidLoad {
        [super viewDidLoad];

    if (NO == [SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook]) {
        [self showAlert:@"There are no Facebook accounts configured. Please add or create a Facebook account in Settings."];
        return;
    }

    [self getMyDetails];
    // Do any additional setup after loading the view from its nib.
}

- (void) getMyDetails {
    if (! accountStore) {
        accountStore = [[ACAccountStore alloc] init];
    }

    if (! facebookAccountType) {
        facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    }

    NSDictionary *options = @{ ACFacebookAppIdKey: [NSString stringWithFormat:@"1725978560966525"] };

    [accountStore requestAccessToAccountsWithType: facebookAccountType
                                           options: options
                                        completion: ^(BOOL granted, NSError *error) {
        if (granted)
            {
    NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
    facebookAccount = [accounts lastObject];

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET
                                                                                URL:url
                                                                                parameters:nil];
                                                request.account = facebookAccount;

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                                                    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:responseData
                                                                                options:NSJSONReadingMutableContainers
                                                                                error:nil];
                                                    NSLog(@"id: %@", responseDictionary[@"id"]);
                                                    NSLog(@"first_name: %@", responseDictionary[@"first_name"]);
                                                    NSLog(@"last_name: %@", responseDictionary[@"last_name"]);
                                                    NSLog(@"gender: %@", responseDictionary[@"gender"]);
                                                    NSLog(@"city: %@", responseDictionary[@"location"][@"name"]);
                                                }];
                                            } else {
                                                [self showAlert:@"Facebook access for this app has been denied. Please edit Facebook permissions in Settings."];
                                            }
                                        }];
}

- (void) showAlert:(NSString*) msg {
    dispatch_async(dispatch_get_main_queue(), ^(void) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"WARNING"
                                  message:msg
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    });
}

i tried this for getting personal information of Facebook (Logged-in User), But it require permission, as i don't know where To add permissions, i have checked in setting, tried all thing in Simulator But Still Not getting.


text:
Q: What do I select for "GRUB install devices" after an update? After running Update Manager, a debconf window  (titled "Configuring grub-pc"), popped up, requiring me to select the appropriateGRUB install devices for my system.  I've made no changes to grub or the filesystem recently, and I don't remember what options I selected last time I did make a change.
How do I know what to select?  I'm assuming the wrong answer could render my system unable to boot.
Here's the debconf dialog:

Here's the window and text that is displayed when selecting "help" :

A: In your case, the correct selection is /dev/sda, the first one. It's the first and only hard disk in your system, whereas /dev/sda1 is a partition on that hard disk. You can install grub on a partition, but it's a "BAD idea".
If you had multiple hard drives and partitions, first find out where your root partition is:
lsblk

(See also: How do I find out what hard disks are in the system?)
You can then install grub on that hard drive. Look for devices labeled "disk" (e.g. "sda", meaning /dev/sda) to install grub into the master boot record (every physical disk device has only one MBR, no matter the partitions).

A: This issue was still present when I upgraded Ubuntu 16.04 after a fresh install. To fix it, do this:

*

*The selection of /dev/sda is correct, so press Spacebar for the first option.

*An asterisk appears for the /dev/sda option, signifying successful selection.

*Then press Tab key to highlight the 'OK' button and then press Spacebar key to select the OK action.

After this, the installation should proceed smoothly.


text:
Q: There are surprisingly few information about the asymptote package..... what do i do after i download it? Is it a package for LaTeX?
Ive opened it i i get this...... do i type stuff inside? Or.......what should i do with it? Im  very new to asyptote actually   Or cn anybody reccomend me any sites or videos to get me started? I visited every single one I could but to no avail
For example, reading this:

how do i create a test file named test.asy? How do i execute the command asy-V test?  Help haha


text:
Q: Is any abelian subvariety of an abelian variety closed? I am wondering because Milne here in Proposition 10.1, page 42, takes any abelian subvariety $B$ of an abelian variety $A$, with $0\neq B\neq A$, then he takes an ample line bundle $\mathcal{L}$ on $A$ and he says that $\mathcal{L}|B$ is ample because of his result 6.6b (page 31), which says that the restriction of an ample line bundle to a closed subvariety is again ample.
Hence I suppose that $B$ is closed, but we didn't make any assumption about $B$. So every abelian subvariety of an abelian variety is closed, right? Or am I missing some hypotheses in this proof?
Thanks!


text:
Q: Set a start date and a end date to a kubernetes cronjob I would like to create a kubernetes Cronjob that create jobs (according to its schedule) only if the current date is between a configurable start date and end date.
I can't find a way to do this with the basic cronjob resource. Is there a way to do this ? Ideally without resorting to overkill components (airflow ...) ?

A: Actually there is no way to configure the end date. You can run it in every day. You have to stop it manually when the end date will come.


text:
Q: Expressing as 1's complement I have the problem:
Express ( -43) as a word-length 1's complement number

43 is in decimal. I understand how to convert to Hexadecimal and take the 2's compliment, but am confused on what exactly I have to do to get the desired answer here. Could anyone help?

A: $43$ in binary is $101011$.  I think word-length is $16$-bits, so we pad out and say that $43$ is actually $00000000000000101011$.  The first bit is not part of the number; this is the sign bit, by switching it to $1$, we make the number negative.  However, with $1$'s complement, you need to toggle all the other bits when making it negative.  So to make it negative, just toggle all bits:  $-43$ is $11111111111111010100$.


text:
Q: Saxon Xslt Processor Error In my .net application i am trying process an xml using saxon xslt, the xslt version is 2.0.
When the data is large i am getting the following error.
[net.sf.saxon.trans.XPathException] = {"org.xml.sax.SAXParseException: XML document structures must start and end within the same entity."}
Any ideas what it is? Thanks in advance.

A: The message you've provided suggests to me that the XML document you're attempting to transform (or perhaps the XSLT stylesheet) is not well-formed XML.  Can you read the XML document (and the stylesheet) using an XML parser?


text:
Q: Pass data to another Polymer component I am working on a dashboard, in which I have a search panel at the top (let's call it component A), where users can enter a query. The value of this input will change a lot of other components in the dashboard (not only components that are its direct descendants or siblings). I want to send the search value from component A to component B, which should then respond by performing some action with the input value.
I have tried a few things:

*

*Directly calling the function in component B. Haven't been able to get that to work at all.

*Manually setting B's local property value and using an observer to trigger a function call. I manager to set the value, but the observer does not trigger.

*Using a global variable, which I can easily access across components, but I still can't trigger functions in specific components.

How can I best do this?
I'm relatively new to Polymer, so forgive me if my ideas aren't completely 'Polymerised' :)
Approach 1
<dom-module id="component-B">
  <template>
  </template>
  <script>
    Polymer({
      is: 'component-B',
      properties: {
        id: '',
        observer: '_idUpdate'
      },
      _idUpdate: function(){
        console.log("HELLO");
      }
    });
  </script>
</dom-module>

<dom-module id="component-A">
  <template>
  </template>
  <script>
    Polymer({
      is: 'component-A',
      idSearch: function() {
        var id = this.$.search.value;
        document.querySelector('component-B').properties.id = id;
      },
    });
  </script>
</dom-module>

A: As you want to send data to multiple elements (which might not be siblings of the firing element) you can use any of these two methods

*

*Use iron-signal to fire the signal and then in all the elements where you want the data use iron-signal tag to listen to the signal
 <iron-signals on-iron-signal-<signal-name>="<function>"></iron-signals>

*You can also use standard HTML method dispatchEvent to fire a signal and then add eventListeners in all the element where you want data.


text:
Q: Initialize C++ object with arguments from Cython constructor I have implemented a filter class in C++, and I am working on wrapping this with Cython for use in Python. The Cython MyFilter class currently looks like this.
cdef class MyFilter:
    cdef filter f;
    def __cinit__(self, list array_sizes):
        cdef vector[size_t] as = array_sizes
        self.f.init(as)
    def add(self, uint32_t value):
        self.f.add(value)
    def get(self, uint32_t value):
        return self.f.get(value)

Originally, the C++ class had a single constructor which took a std::vector<size_t> as an argument. But to make the Cython wrapper work, I had to define a default argument-less constructor and then add an init() function to initialize the object once the arguments were available from the __cinit__ constructor. This added some unwanted complexity to the C++ code.
Is there are cleaner or better way of doing this? I'd like to avoid pointers if necessary, but might be convinced with a compelling argument.

A: Actually, your solution IS the cleaner better way :)
The other solution is just to add an overloaded constructor, that you can then call from init.:
cdef cppclass myclass:
    myclass() except +
    myclass(args) except +

Then add to your python class
cdef class myPyClass:
    cdef myclass pclass
    def __cinit__(self,args):
        pclass = new myclass(args)


text:
Q: Removing missing values from merged categorical variables in R In response to my previous question here:
Merging binary variables in R to a new variable
I used the following code to merge categorical variables and it worked:
koratest<-koratest%>%
+     rowwise() %>%
+     mutate(
+         CVD = min(ptmi,ptschl,pthyact, ptap )
+     ) %>%
+     ungroup()

What to do if there is missing values in any of the values to be merged. I want missing values to be labelled as 1 but if there is 0 with missing value, i want cvd variable to have value of 1. For example:
 Stroke  MI  BP  CVD
 0       1    1   0
 1       NA   NA  1
 0       NA   1   0

How should i edit the above mentioned code in this case?

A: replace them with 1.
replace(dat, is.na(dat), 1) |> {\(.) transform(., CVD=+(rowSums(.) == 3))}()
#   Stroke MI BP CVD
# 1      0  1  1   0
# 2      1  1  1   1
# 3      0  1  1   0

Data:
dat <- structure(list(Stroke = c(0L, 1L, 0L), MI = c(1L, NA, NA), BP = c(1L,
NA, 1L)), class = "data.frame", row.names = c(NA, -3L))

A: You could first replace the NA with 1 and then apply the same function:
df[is.na(df)] <- 1
df$CVD <- apply(df,1, function(x) !any(0 %in% x)) + 0
df

Output:
  Stroke MI BP CVD
1      0  1  1   0
2      1  1  1   1
3      0  1  1   0


text:
Q: how to importing json file to elasticsearch using python I have a json file which contains multiple id's and I want it to import that file to elasicsearch in kibana using python and there should be different index for different id. Please tell me how can i do that.
import json
from elasticsearch import Elasticsearch
    es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
i = 0
with open('js.json') as raw_data:
    json_docs = json.load(raw_data)
    for json_doc in json_docs:
            i = i + 1
            es.index(index='elasticsearch_index',doc_type='raw_data', id=i, body=json.dumps(json_doc))

This is my code please help me to in it.


text:
Q: Can a matrix be translated by a diagonal matrix to obtain a singular matrix? Let $A$ and $D$ be $k \times k$ matrices with entries in the nonnegative real numbers $\mathbb{R}_+$, where $D$ is diagonal.
Does there exist a scalar $\lambda \ge 0$ such that $\det(A - \lambda D) = 0$?

A: Let us assume $\det(D) > 0$, as otherwise the statement is not true in general.
Notice that for the symmetric root $R = D^{1/2}$ we have
$$ \det(A - \lambda D) = \det(R)\det(R^{-1} A R^{-1} - \lambda I_n) \det(R). $$
Now, the function $\det(R^{-1} A R^{-1} - \lambda I_n)$ has a non-negative zero if and only if $M = R^{-1} A R^{-1}$ has a non-negative eigenvalue.
If $A$ is symmetric:
The matrix $M$ has a non-negative eigenvalue if and only if $M$ is not negative definite. Since $R^{-1}$ is invertible, that is exactly the case if $A$ is not negative definite. Since $A$ is component wise non-negative, $A$ can't be negative definite, as the diagonal elements would negative otherwise. Thus, we obtain following result:

Let $A,D$ be square, component wise non-negative, matrices.
  Assume $A,D$ are symmetric and $D$ is positive definite.
  Then, there exists a $\lambda\ge 0$ with $\det(A - \lambda D)=0$.

If $A$ is not symmetric:
That case is little complicated.
In case $n$ is odd, if $\det(A) \ge 0$, then for $\lambda\to\infty$ we have
$$ \det(A-\lambda D) = -\lambda^n \det(D - A/\lambda) \to -\infty. $$
In case $n$ is even, if $\det(A) \le 0$, then  $\lambda\to\infty$ we have
$$ \det(A-\lambda D) = \lambda^n \det(D - A/\lambda) \to \infty. $$
So in these two cases, $\det(A-\lambda D)$ has a non-negative zero.

A: Hint:
$\det(A-\lambda D)$ is a polynomial in $\lambda$ of degree $k$.


text:
Q: Tikz with positioning does not work with DVI I have the following Tikz picture:
\begin{tikzpicture}
  \node (a) {A};
  \node [below=2cm of a] (b) {B};
\end{tikzpicture}

When I compile this code with PDF-LaTeX, I get the expected result: "B" appears 2 cm below "A".
When I compile the exact same code with plain LaTeX, in the DVI file, "A" and "B" are in the same position, mashed together.  In the PS file, after another re-compilation, they appear correctly again.
Is there some way or workaround to work with PGF/Tikz with positioning straight with the DVI preview?

A: I take it you mean that after dvips the PostScript file looks okay. In that case, you are seeing the expected behaviour. When working in DVI mode, PostScript specials are used for effects that TeX does not support directly. This includes absolute positioning, rotation, scaling and so on. However, DVI viewers do not interpret these specials (unless they do some PostScript breaking out), and so show only the unmodified results. So you will not see these effects until you convert to PostScript.


text:
Q: concurrent modification exception on using addall and removeall on same arraylist I have to remove a sublist from the ArrayList and add the same in begining. I am using below code -
for(int i =0 ;i <m ; i++){
    List<Integer> t = q.subList(j, k);
    q.removeAll(t);
    q.addAll(0, t);
}

I am getting concurrent exception modification on addAll. I tried creating a copy list from q and then calling addAll on that, still it throws the error on same line.
for(int i =0 ;i <m ; i++){
    List<Integer> t = q.subList(j, k);
    q.removeAll(t);
    ArrayList<Integer> q1= new ArrayList<Integer>(q);
    q1.addAll(0, t);
}

How can I perform both actions on same data list?

A: The Javadoc of subList states that:

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

This means calling removeAll may invalidate the list returned by subList.
In addition, the Javadoc of addAll states that:

The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

And in your case, the Collection you are passing to addAll is the sub-list, which is backed by the original List on which you are calling addAll.
What you can do is store the elements of the sub-list in a separate List (copyOfSubList), use clear() to remove the elements of the sub-list (which will remove them also from the original List) and then add the elements of copyOfSubList back to the original List:
for(int i =0 ;i < m ; i++) {
    List<Integer> t = q.subList(j, k);
    List<Integer> copyOfSubList = new ArrayList<> (t);
    t.clear ();
    q.addAll(0, copyOfSubList);
}

A: You can use CopyOnWriteArrayList instead of ArrayList.
Iterators of CopyOnWriteArrayList never throw ConcurrentModificationException. When an iterator is created, it keeps a copy of the list's contents.


text:
Q: How can a thread (recevier) write request & response to an file while thread(sender) will send only request? We have an requirement in which it causes an design constraint and it is show stopper. Here it is,

*

*Sender thread will put requests into the messaging queue. Input source is a text file that contains 10 million requests.

*Recevier thread polls the responses from another queue and write it onto another output file.
Design Constraint:

*

*Recevier thread has to write the request and response onto output file. How this is possible ?

*No Database should be used

*Caching the request before sending and updating it after corresponding response has been recevied cannot be used because of performance bottleneck.

*In few cases, timeout occurs if the response is delayed very long time.
Please advice.

A: Since you have just one Receiver thread, it is guaranteed that only one request will be processed at a time.
Having the sender thread write the request and response is probably not the most elegant design, but you could certainly have the Receiver thread write the {request, response} tuple. The Receiver thread could also write the request before it starts processing and the response after it is done. It will have the same result as what you are aiming for.
If you give out more details about your design, I can provide you with more design help.

A: Several ideas for solutions:
The receiver thread could look up the original request from the file. This requires responses to have some form of unique correlation id.
The handler threads could add the original request to the response. This makes message size bigger but avoids the need of a correlation id. It also requires configuration/code changes to be made to the handler threads.
The sender thread could duplicate the request on a secondary local queue. The receiver thread looks up the original request for a received response on this queue. Responses might not be received in the same order as the requests were sent so the receiver thread might need to 'walk the queue' to find the request which is not very efficient.
The last solution comprises a form of caching. You state this is not allowed due to performance reasons. I don't understand exactly why though. Local caching is fast and there  should not be a large amount of queued requests in the cache at any given time since the sending, handling and receiving are all asynchronous.


text:
Q: Is there a way to see which thread is printing to stdout or stderr with gdb? I am debugging a multithreaded application with gdb.
I can see the threads, and play switch / break with them, but sometimes when I am attached to a particular thread, some of the other threads print something.
How can I find out which thread is printing what part?

A: Aside from setting breakpoints at strategic places [printf, fprintf, write, or some such], I suppose you could prefix (or postfix) any printf with a thread-id (but you would probably need to add that manually for every printf - or ones that you need to know about at least).
If you are using cout rather than printf, it may be a bit easier, as you could do (something as ugly as) something like this:
#define cout cout << pthread_self() << ":"

Although it may cause a few issues with things like cout.flush() or cout.setprecision().

A: First, you need to set conditional breakpoint on write system call with FD number in condition and stop at this breakpoint.
The exact condition depends on architecture you are using.
For 64-bit x86 it can be:
(gdb) catch syscall write
(gdb) condition 1 $rdi==1

For 32-bit:
(gdb) catch syscall write
(gdb) condition 1 $ebx==1

These examples are for stdout. For stderr, condition will change slightly, for example (gdb) condition 1 $rdi==2.
After that done you can easily see thread number either from info threads output or manually call pthread_self() like this:
(gdb) p pthread_self()


text:
Q: asp.net mvc razor yes no dialog not coming in razor   <%= Ajax.AjaxImageActionLink("../../Content/images/delete.png", "Feature", "Delete", new { id = item.int_FeatureId }, new AjaxOptions { UpdateTargetId = "table", HttpMethod = "Post", Confirm = "Delete Feature with Feature ID:" + item.int_FeatureId + " Feature Name:" + item.vcr_FeaturesName })%> pr

i am trying to generate javascript popup when pressing the delete link for yes and no. this works perfectly in .aspx views but how i can make it work in razor. i try to translate it but not working
  @Ajax.ActionLink("Delete Profile", "Delete", new { id = item.int_UserId }, new AjaxOptions {  UpdateTargetId = "UserTable", HttpMethod = "Post", Confirm = "Delete User with User ID:" + item.int_UserId + " User Name:" + item.vcr_UserName })

A: If you rewrite this in razor correctly and is not working, this is definitely not the case with aspx or razor. They're just parsers, and using any of them does not affect internal mvc code execution. Same on razor markup would be just remove aspx code end marker and replace start marker with '@'
  @Ajax.AjaxImageActionLink("../../Content/images/delete.png", "Feature", "Delete", new { id = item.int_FeatureId }, new AjaxOptions { UpdateTargetId = "table", HttpMethod = "Post", Confirm = "Delete Feature with Feature ID:" + item.int_FeatureId + " Feature Name:" + item.vcr_FeaturesName })

A: I was having the following error and it seems to be something to do with the way the razor engine reads the jQuery function when you bundle or internally reference the scripts? I just referenced the files from the cdn and it works fine. This is the error you will likely get trying the former. Try referencing the jquery files from the cdn as this is probably your culprit.

Seems to work fine this way.
 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>


text:
Q: Microsoft Access search for multiple emails In Access when I query the contact table to search for multiple email addresses I use the SQL
 select * from contact_table where email like " 'email1@test.com','email2@test.com',
'email3@test.com'  "

I do not get an error however I get no search results when I know the emails are in the database, what am I missing?
Also is this the best way to query a lookup table of email addresses in Access?

A: It seems like you should be using the in operator, not the like operator:
SELECT *
FROM   contact_table
WHERE  email IN ('email1@test.com',
                 'email2@test.com',
                 'email3@test.com')


text:
Q: How can I manage and a csv file in c? i have a csv file and which look like this :

*

*1;53453;45847865

*1;37567;53687686

*.

*.

*.

*.
n.    1;999768;5645644

and i want to open the file , read it and then split each line to 3 tokens which will be seperated from the semicolon ....
e.g
1;35435;75675
 token1 = 1;
 token2 = 35435;
 token3 = 75675;

the code that i have is a main which i open and read the file and a function which i take manually a string of characters and split it ...
I want to know if there is an easier way to implement this and a way to skip the first line of the file !!!!!
    #include<stdio.h>

    int main(){

    char c;
    FILE *fp;
    char line;

    float x;
    float y;

    if((fp=fopen("test.csv","r"))==NULL){
            printf("cannot open the file");
    }else{

      do{

    c =  fscanf (fp, "%c", &line);
    printf("%c" , line);

     }while(c!=EOF);
     fclose(fp);
    }

  }

________________________________-
         int TokenX(char line) {

char *id;
char *x;
char *y;

char line[] = "1;345345;765767";
char *search = ";";

     id = strtok(line , search);
    // printf(id);

     x = strtok(NULL , search);
     printf(x);

     y = strtok(NULL , search);
     printf(y);

    return(x);

    }

    int TokenY(char line) {

  char *id;
  char *x;
  char *y;

  char line[] = "1;345345;765767";
  char *search = ";";

     id = strtok(line , search);
    // printf(id);

     x = strtok(NULL , search);
     printf(x);

     y = strtok(NULL , search);
     printf(y);

    return(y);

    }

A: You can use fscanf() with while. each iteration in the while loop will read a line from the file.
int token1, token2, token3;
while(fscanf(fp, " %*d . %d ; %d ; %d", &token1, &token2, &token3)>0)
{

  printf("%d  %d   %d\n",token1, token2, token3);
}

if you wantto skip the first line then add an integr parametr and initiate to 0. When you enter in the while loop check if it's equal to 0
int token1, token2, token3;
int check = 0;
while(fscanf(fp, " %*d . %d ; %d ; %d", &token1, &token2, &token3)>0)
{
  if(!check) {check++; continue;}
  printf("%d  %d   %d\n",token1, token2, token3);
}

*

*If the string format of each line in your csv file looks like that
"1. 25;78;547" than use the follwing format " %*d . %d ; %d ; %d"
in the fscanf()

*If the string format of each line in your csv file looks like that
"25;78;547" than you have to use the follwing format " %d ; %d ; %d" in the
fscanf()

A: Trivial state machine:
#include <stdio.h>

int main(void)
{
char token1[123];
char token2[123];
char token3[123];
unsigned nline;
int ch,state;
char *dst=token1;

nline=0;
for (state=0; state >=0; ) {
        ch = getc(stdin);
        // fprintf(stderr, "Line=%u State=%d Ch=%c\n", nline, state, ch);
        switch(ch) {
        case EOF :
                state = -1; break;
        case ';' :
                if (dst) *dst = 0;
                switch(state++) {
                case 0: dst = token2; break;
                case 1: dst = token3; break;
                default: dst = NULL; break;
                }
                break;
        case '\n' :
                nline++;
                if (dst) *dst = 0;
                // if you want to skip the first line
                if (state>=2 && nline> 1) printf("%s:%s:%s\n"
                        , token1, token2 ,token3);
                state =0; dst = token1; break;
        default: *dst++ = ch; break;
                }
        }

return 0;
}


text:
Q: How can Spinner content depend on another Spinner's selected item? I need the spinner2 content to be dependent of the selected item in spinner1, in this code spinner2 takes his content only from case0 : R.array.subMenuTrans regardless of what is selected in spinner1.
package com.example.game1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

public class DialogMenu extends AppCompatActivity {

    Spinner spinner1;
    Spinner spinner2;    **spinners**
    Spinner spinner3;
    ArrayAdapter<CharSequence> adapter1;
    ArrayAdapter<CharSequence> adapter2;
    ArrayAdapter<CharSequence> adapter3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_menu);

        spinner1 = (Spinner) findViewById(R.id.menu);
        adapter1 = ArrayAdapter.createFromResource(this, R.array.menu, android.R.layout.simple_spinner_item);
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner1.setAdapter(adapter1);

        spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override // TODO Auto-generated method stub
            public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
                Toast.makeText(getBaseContext(), spinner1.getSelectedItemPosition() + " is selected.", Toast.LENGTH_LONG).show();
            }

            @Override// TODO Auto-generated method stub
            public void onNothingSelected(AdapterView<?> adapterView) {

            }

        });

        spinner2 = (Spinner) findViewById(R.id.submenu);
        int options = spinner1.getSelectedItemPosition();
        switch (options) {
            case 0://spinner2 takes only content of case0,should take all cases depenting on selection of spinner1....
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuTrans, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 1:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuSights, android.R.layout.simple_spinner_item);**takes content**
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 2:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuEdu, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 3:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuHeal, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 4:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuBus, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 5:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuAthl, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                break;
            case 6:
                adapter2 = ArrayAdapter.createFromResource(this, R.array.subMenuPubServ, android.R.layout.simple_spinner_item);
                adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        }
        spinner2.setAdapter(adapter2);

        spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override// TODO Auto-generated method stub
            public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
                Toast.makeText(getBaseContext(), spinner2.getSelectedItemPosition() + " is selected.", Toast.LENGTH_LONG).show();
            }

            @Override// TODO Auto-generated method stub
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });
    }
}

A: You're setting spinner2's position in onCreate() to be whatever spinner1's position is (during onCreate()).
onCreate() only gets called once, so spinner2's position only gets set once in this case.
One solution would be to change spinner2's position from inside spinner1's onItemSelected() method.

A: Your onItemSelected must trigger the spinner2 init


text:
Q: instruction IF in Doctrine query in Symfony? How can i make something:
  public function executeSearch(sfWebRequest $request)
  {
    $test = 1;

    $this->shows = Doctrine_Core::getTable('Show')
      ->createQuery('a')
      ->where('a.name = ?', 'Tom')
   if ($test == 1) {   ->andWhere('a.last_name = ?', 'Jerry') }
      ->execute();
  }

this doesn't work. How can i instruction if in Doctrine query?
OR:
  public function executeSearch(sfWebRequest $request)
  {
    if(isset($test)){
    $test = 'Jerry';
    }
  //now if isset $test then andWhere search only with Jerry, if not isset andWhere search ALL

    $this->shows = Doctrine_Core::getTable('Show')
      ->createQuery('a')
      ->where('a.name = ?', 'Tom')
      ->andWhere('a.last_name = ?', $test) }
      ->execute();
  }

A: $q = Doctrine_Core::getTable('Show')
  ->createQuery('a')
  ->where('a.name = ?', 'Tom');

if ($test == 1)
{
  $q->andWhere('a.last_name = ?', 'Jerry');
}

$this->shows = $q->execute();


text:
Q: How to get Twain DataSource file (*.ds) on Linux My goal is make same code works on Win7_64 and Linux(Centos 7_64) for scanner(using TWAIN). I am coding on C++ Qt. My programm works fine on Win7_64, but when I tried to launch it on Linux; I found that DataSource Manager couldn't find DataSource. Therefore, I tried to figure out how to get that DataSource. I didn't find any useful information about it; I only know that on Linux DataSource looks like *.ds file, and my question is how to get it? I will appreciate any help.

A: Linux Twain drivers are mostly an abstract idea. If there are any out there, they're very few and come with expensive equipment. So, unfortunately, forget about Twain on Linux. You need to use Sane.
Of course you could insert a Twain adapter layer between Sane and your application. At least one such layer exists, but it's for OS X: Twain Sane. It shouldn't be terribly hard to adapt it for linux, the source is available.


text:
Q: Problems installing WPML plugin? When I try to install the WPML plugin I get an error screen (like the image below), and the plugin isn't enabled, it's quite frustrating since I can't seem to understand what's wrong. Perhaps the table doesn't exist, but I thought that WPML is supposed to create it?
Warning: mysqli_real_connect(): Headers and client library minor  version mismatch. Headers:100023 Library:100113 in /home/goescoot/public_html/booking/wp-includes/wp-db.php on line 1488
WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
SELECT code FROM es_icl_languages WHERE active = 1

WordPress databasefejl: [Table 'goescoot_booking.es_icl_strings' doesn't exist]
ALTER TABLE `es_icl_strings` ADD `gettext_context` TEXT NOT NULL AFTER `status` , ADD `domain_name_context_md5` VARCHAR(32) CHARACTER SET LATIN1 NOT NULL DEFAULT '' AFTER `gettext_context`

WordPress databasefejl: [Table 'goescoot_booking.es_icl_strings' doesn't exist]
SELECT id, name, value, context as domain, gettext_context FROM es_icl_strings WHERE id > 0

WordPress databasefejl: [Table 'goescoot_booking.es_icl_strings' doesn't exist]
ALTER TABLE `es_icl_strings` ADD UNIQUE `uc_domain_name_context_md5` (`domain_name_context_md5`) USING BTREE

WordPress databasefejl: [Table 'goescoot_booking.es_icl_translation_status' doesn't exist]
ALTER TABLE es_icl_translation_status MODIFY COLUMN translation_package longtext NOT NULL

WordPress databasefejl: [Table 'goescoot_booking.es_icl_languages' doesn't exist]
ALTER TABLE es_icl_languages MODIFY default_locale varchar(35), MODIFY tag varchar(35);

Fatal error: Uncaught exception 'Exception' with message 'Error upgrading schema for table "icl_languages": ' in /home/goescoot/public_html/booking/wp-content/plugins/sitepress-multilingual-cms2/inc/upgrade-functions/upgrade-3.3.7.php:54 Stack trace: #0 /home/goescoot/public_html/booking/wp-content/plugins/sitepress-multilingual-cms2/inc/upgrade.php(145): include_once() #1 /home/goescoot/public_html/booking/wp-content/plugins/sitepress-multilingual-cms2/inc/upgrade.php(117): icl_upgrade_version('3.3.7') #2 [internal function]: icl_plugin_upgrade('') #3 /home/goescoot/public_html/booking/wp-includes/plugin.php(525): call_user_func_array('icl_plugin_upgr...', Array) #4 /home/goescoot/public_html/booking/wp-settings.php(276): do_action('plugins_loaded') #5 /home/goescoot/public_html/booking/wp-config.php(83): require_once('/home/goescoot/...') #6 /home/goescoot/public_html/booking/wp-load.php(37): require_once('/home/goescoot/...') #7 /home/goescoot/public_html/booking/wp-admin/admin.php(31): require_once('/home/goescoot/... in /home/goescoot/public_html/booking/wp-content/plugins/sitepress-multilingual-cms2/inc/upgrade-functions/upgrade-3.3.7.php on line 54


text:
Q: Ajuda com consulta criação tarefa agenda Galera,
Estou fazendo um script para disparar uma mensagem de acordo com o registro gravado no banco de dados.
É como se fosse uma tarefa CRON.
Tenho o seguinte registro

Vou colocar uma pagina PHP na tarefa CRON do Cpanel, mas como posso fazer uma consulta que verifica a cada minuto se o registro está na hora e dia para ser disparado?
Nesse exemplo da imagem, deveria retornar o registro quando:
9 horas 5 minuto segunda, terça ou quinta-feita
Veja que mês e dia está com *
SELECT *
FROM  `agendamento`
WHERE 1 =1
AND (mes = MONTH(NOW() ))

Como poderia verificar o asterisco e não entrar nas condições, vou utilizar operador OR será que funciona?

A: SELECT *
FROM  agendamento
WHERE 1 =1
AND (
    (mes = MONTH(NOW())
    OR
    (mes = '*')
    )
AND (
    (dia = DAY(NOW())
    OR
    (dia = '*')
)

Acredito que esse seja o caminho que será necessário trilhar, embora eu julgue que será muito mais interessante ter diversas Crons...


text:
Q: How to match from beginning in css nth-of-child selector? I want to select the first div until div number three.
So I use this selector:
div:nth-of-type(1) ~ div:nth-of-type(3) {
  border:1px solid red;
}

But it only match the 3 div. why? how to match from the begining until 3?

div:nth-of-type(1) ~ div:nth-of-type(3) {
  border:1px solid red;
}

1

2

3

4

5

6

A: You can use :nth-child selector with -n+X pattern, where X is first X number of elements you need to target.

div:nth-child(-n+3) {
  border:1px solid red;
}

1

2

3

4

5

6


text:
Q: Snowflake date_trunc to remove time from date I have snowflake column which contains date in yyyy-mm-dd hh:MM:ss format.
I use the below function
 date_trunc('DAY', '2019-09-23 12:33:25')

Output : 2019-09-23 00:00:00
Expected as per documentation : 2019-09-23
Is it a bug or is there any other way to remove the time component altogether ?

A: Depending on what you're wanting to do with the date, having a midnight time is fine.
If you really must get rid of it, this will work:
cast(date_trunc('DAY', '2019-09-23 12:33:25') as date)

A: date_trunc as the documentation say, truncates a timestamp to values on different grain. But the result is still a timestamp, thus the output format.
if you want just the truncated date, casting to date as cmcau mentions is a simple way to go. But if you are casting to date there is no need to truncate as they are the same value, thus '2019-09-23 12:33:25'::date should be all you need.

A: In certain environments like Mode Analytics, casting to date like some of the other answers mention still displays a 00:00:00 on the end. If this is the case and you are only using the date for display purposes, you can take your truncated date and cast it to varchar instead like this: '2019-09-23 12:33:25'::date::varchar
Note, I would only recommend this if the other answers are not working for you.


text:
Q: what is the right way to use this code? this code is for countdown plug in for coming soon page. how can i write this code in short way or right way ?
$(document).ready(function() {
    else if(month == 2){
        var currentMo = 2564;
    }else if(month == 3){
        var currentMo = 452136;
    }else if(month == 4){
        var currentMo = 86985;
    }else if(month == 5){
        var currentMo = 1236;
    }else if(month == 6){
        var currentMo = 12365;
    }else if(month == 7){
        var currentMo = 12546;
    }
});

A: You can use switch statement here:
var currentMo;
switch (month) {
  case 1:
    currentMo = 1337;
    break;
  case 2:
    currentMo = 2564;
    break;
  case 3:
    currentMo = 452136;
    break;
  // ...
}

or even some array with predefined values:
var months = [1337, 2564, 452136];
var currentMo = months[month - 1];

A: One way to write in short,
$(function() {
    var currentMo;
    if(month == 1)
       currentMo  = 2564;
    else if(month == 2)
        currentMo  = 2564;
    else if(month == 3)
        currentMo = 452136;
    else if(month == 4)
        currentMo = 86985;
    else if(month == 5)
        currentMo = 1236;
    else if(month == 6)
        currentMo = 12365;
    else if(month == 7)
        currentMo = 12546;
});