qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
54,155
A long-time client has asked us to help screen their work machines for pornography. They're worried about liability if sensitive materials were found. Their main concerns (for obvious reasons) are video, audio, and image files. If possible, they'd also like to scan text-based documents for inappropriate content. They have a hierarchy of not-for-work content starting with blatantly illegal (I don't have to list details), moving down to obviously offensive, and also including things that may be offensive to some - think lingerie ads, joke cards featuring butt cracks, and anything related to Howie Mandel. My questions are: * Is this ethical? I think it is since every employee legally agrees that their work machine belongs to the company and is subject to search. The screenings are not to occur on personal machines brought to work. * Is it feasible? I've done a lot of image processing/indexing but this seems like a whole new world of complexity. * Any references to successful techniques for discovering porn? * Is it appropriate for me to archive the results when something is discovered?
2011/03/03
[ "https://softwareengineering.stackexchange.com/questions/54155", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/17429/" ]
You can do this with 90% [Headology](http://wiki.lspace.org/mediawiki/index.php/Headology), 10% software. Firstly, quietly scan employees computers, build a database of files and sizes for each employee. Then leak a memo that all PC's will be scanned for questionable content, i.e. The bosses have a [Shazam](http://itunes.apple.com/ie/app/shazam/id284993459?mt=8) like program that can identify porn etc. Then a couple of days later, scan the computers for files and sizes again. Look at any deleted files, are they movie or image files? Then those are the employees you need to keep an eye on. Routinely scan those employees PC's for images and movies, and manually check them for questionable content.
I just wanted to comment, but only have 1 rep, so I can't. In the case of Gravatar, you could add a function to filter out from a list of clean sites in internet cache locations. I.E. Gravatar and other sites you don't want false positives from. You could also filter out things like the desktop wallpaper. If they are displaying porn on the desktop you'd think people would notice outside of your audit.
54,155
A long-time client has asked us to help screen their work machines for pornography. They're worried about liability if sensitive materials were found. Their main concerns (for obvious reasons) are video, audio, and image files. If possible, they'd also like to scan text-based documents for inappropriate content. They have a hierarchy of not-for-work content starting with blatantly illegal (I don't have to list details), moving down to obviously offensive, and also including things that may be offensive to some - think lingerie ads, joke cards featuring butt cracks, and anything related to Howie Mandel. My questions are: * Is this ethical? I think it is since every employee legally agrees that their work machine belongs to the company and is subject to search. The screenings are not to occur on personal machines brought to work. * Is it feasible? I've done a lot of image processing/indexing but this seems like a whole new world of complexity. * Any references to successful techniques for discovering porn? * Is it appropriate for me to archive the results when something is discovered?
2011/03/03
[ "https://softwareengineering.stackexchange.com/questions/54155", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/17429/" ]
> > * Is this ethical? > > > Depends on the implementation and reasonable expectations of the employees. For example, if your software scans any machine *connected to* the network, then there's an additional requirement that infra needs to prevent unauthorized machines from plugging in. (Maybe that should be obvious, but it's frequently overlooked on networks I've seen.) > > * Is it feasible? I've done a lot of image processing/indexing but this seems like a whole new world of complexity. > > > Is it feasible to drug test every employee? Maybe so, but I question its worth. I would randomize it. Let employees know their machines may be scanned for inappropriate content at any time. > > * Any references to successful techniques for discovering porn? > > > I'm not touching this one. I don't think I could keep my sense of humor in check. But watch out for [The Scunthorpe Problem](http://en.wikipedia.org/wiki/Scunthorpe_problem) when searching text. > > * Is it appropriate for me to archive the results when something is discovered? > > > This one concerns me the most, and I would ask a lawyer. I suspect if you find illegal content you may technically be legally obliged to disclose it. That's bad, particularly if the user was exposed by no real fault of his own. You(r client) will need real legal advice on how to handle this. Get HR and the lawyers involved.
Image and content analysis to determine the differences between a tasteful photograph of a person, a swimsuit photograph, a nude photograph, depictions of pornography... as far as I know is nowhere near sophisticated enough to do in software alone. Fortunately crowdsourcing should be useful here, as @ammoQ suggested in a comment. However I don't believe members of 4chan or any other forum would appreciate the vast number of *non*-pornographic images, such as generic web graphics for buttons, frames, advertisements, etc. being posted. My recommendation would be to look into existing crowdsourcing solutions, such as [Amazon Mechanical Turk](https://www.mturk.com/mturk/welcome). (However the terms of service may explicitly prohibit the involvement of pornographic content, so be advised you might have to find another solution or roll your own.) To make crowdsourcing feasible, your software should be prepared to do some or all of the following: * Store information that links the content with the computer it came from * Identify exact duplicates across the entire inventory and remove them (but origin information is retained) * Downsample images to some dimension, perhaps 320x200, which is sufficient to identify the content of the image without retaining unnecessary detail and wasting storage space/bandwidth * Create still images of video content at some regular interval and apply the same downsampling rule Finally, the database of reduced images that represent the original image and video content is checked by users (or a designated team if you have the resources) according to your company's code of conduct. The program or interface might show a single image at a time, or a screen of thumbnails--whatever you deem best to obtain accurate information. The identity of the computer from which images came should absolutely be secret and unknown to the persons evaluating the data. Additionally it should be randomized and each image probably checked more than once to remove bias. The same technique could be used for text, but first the content could be scored by keyword rankings which remove the bulk of text from crowdsource review. Classifying a long document will of course be more time consuming than classifying an image.
54,155
A long-time client has asked us to help screen their work machines for pornography. They're worried about liability if sensitive materials were found. Their main concerns (for obvious reasons) are video, audio, and image files. If possible, they'd also like to scan text-based documents for inappropriate content. They have a hierarchy of not-for-work content starting with blatantly illegal (I don't have to list details), moving down to obviously offensive, and also including things that may be offensive to some - think lingerie ads, joke cards featuring butt cracks, and anything related to Howie Mandel. My questions are: * Is this ethical? I think it is since every employee legally agrees that their work machine belongs to the company and is subject to search. The screenings are not to occur on personal machines brought to work. * Is it feasible? I've done a lot of image processing/indexing but this seems like a whole new world of complexity. * Any references to successful techniques for discovering porn? * Is it appropriate for me to archive the results when something is discovered?
2011/03/03
[ "https://softwareengineering.stackexchange.com/questions/54155", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/17429/" ]
About legal aspects, in France: The boss owns the computers and the internet connection: He can do whatever pleases him. BUT, employee privacy cannot be violated. If a directory on the computer is labelled PERSONAL, the boss is not allowed to scan it. The only way to bypass that is to get elements of evidence that employee stores illegal material and to get a court request a scan of computer (Note that pornography is not illegal in France.)
Everyone's computer operating system was probably installed from a disk image. 1. start with the disk image and get a list of files you probably don't need to scan. 2. get a list of all the other files on each PC. 3. pull the actual files from 10-20 random machines and use as a test bed 4. search for items in a profanity and questionable word (hotties, jugs, 'barely legal', joke, etc) dictionary 5. View the video - should anyone have any video at all? 6. View photos 7. Any video or image files that are questionable can be used to search the other machines It will take one or two employees to get caught before any one will put anything on their work computer. Charge an obscene amount of money for this service. I'll be Zappos would never do this to their employees.
61,041,421
I need to split the String by `numbers` and `.` symbol. My String is ``` "Nagapur82. Nanavade83. Nandur84. Nandurkichi Wadi85." ``` and I want Array of like ``` [ "Nagapur", "Nanavade", "Nandur", "Nandurkichi Wadi"] ```
2020/04/05
[ "https://Stackoverflow.com/questions/61041421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12134603/" ]
Instead of getting `HttpContext`, get `IHtttpContextAccessor` service from DI container (it does not make any sense to pass the `HttpContext` from the startup class): ``` services.AddHttpContextAccessor(); services.AddTransient<RequestInfo>(sp => { var context = sp.GetService<IHttpContextAccessor>(); return new RequestInfo(context) }); ``` You can alternatively simplify this problem by introducing an `interface` for `RequestInfo`: ``` public interface IRequestInfo { } public class RequestInfo { private readonly IHttpContextAccessor _httpContextAccessor; public RequestInfo(IHttpContextAccessor httpContextAccessor) { _httpContextAccessor = httpContextAccessor; } } ``` and in `ConfigureServices` method: ``` services.AddHttpContextAccessor(); services.AddScoped<IRequestInfo, RequestInfo>(); ```
I've got this working by following [Microsoft Docs - use HttpContext from custom components](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-3.1) to inject directly without creating the instance in ConfigureServices. > > The dependency injection container supplies the IHttpContextAccessor > to any classes that declare it as a dependency in their constructors. > > > * Add `IHttpContextAccessor httpContextAccessor` to the class constructor. * Add `services.AddHttpContextAccessor();` to ConfigureServices.
61,041,421
I need to split the String by `numbers` and `.` symbol. My String is ``` "Nagapur82. Nanavade83. Nandur84. Nandurkichi Wadi85." ``` and I want Array of like ``` [ "Nagapur", "Nanavade", "Nandur", "Nandurkichi Wadi"] ```
2020/04/05
[ "https://Stackoverflow.com/questions/61041421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12134603/" ]
Instead of getting `HttpContext`, get `IHtttpContextAccessor` service from DI container (it does not make any sense to pass the `HttpContext` from the startup class): ``` services.AddHttpContextAccessor(); services.AddTransient<RequestInfo>(sp => { var context = sp.GetService<IHttpContextAccessor>(); return new RequestInfo(context) }); ``` You can alternatively simplify this problem by introducing an `interface` for `RequestInfo`: ``` public interface IRequestInfo { } public class RequestInfo { private readonly IHttpContextAccessor _httpContextAccessor; public RequestInfo(IHttpContextAccessor httpContextAccessor) { _httpContextAccessor = httpContextAccessor; } } ``` and in `ConfigureServices` method: ``` services.AddHttpContextAccessor(); services.AddScoped<IRequestInfo, RequestInfo>(); ```
You just need to register all the dependencies before they are needed as shown below: ``` services.AddHttpContextAccessor(); services.AddTransient<RequestInfo>(); ``` Inside the `RequestInfo` class you can ask for `IHttpContextAccessor` ``` public class RequestInfo { private readonly IHttpContextAccessor _httpContext; public RequestInfo(IHttpContextAccessor httpContext) { _httpContext = httpContext; } } ```
41,926
After reviewing several texts about the second law of thermodynamics and the concept of entropy, from a systemic point of view, it seems to me that entropy is only a circular reasoning concept. Thermodynamics raised from the study of gases, and gases can't exemplify all types of particles behavior. Gas particles only exert rejection towards others. The main issue is that **natural particles could exert attraction or rejection during an interaction: they don't only exert rejection**. Water molecules, several fundamental particles or simply magnetized particles create attraction forces when they interact. And that is not an isolated natural behavior, it is a very common one. In consequence, whatever the concept of entropy is, the second law only expresses a circular reasoning idea: On systems that tend to dissipation, dissipation is more probable. True, but stupid, because *on systems that tend to organization, dissipation is less probable along time*. Let's take the case of magnetized particles (as several natural particles behave) inside an isolated space: after some small time, particles will group. 1. If entropy=chaos, entropy decreases with time. 2. If entropy=membership of a small group of states [see: Daniel Styer, insight into entropy], then, entropy also tends to decrease: small groups happen more often. 3. If entropy=energy dissipation, the same. If particles exert rejection towards others, entropy grows with time. If particles exert attraction, entropy decreases with time. In addition, energy is a subjective concept. An object that is heat for a subject (and therefore can exert work) can be cold for another (not being able to exert work), so energy dissipation becomes a subjective approach. In final terms, **the root problem of the 2nd law is this: it formulates a law that is applicable only to systems that follow that law**. So, can the 2nd law of thermodynamics be a circular argument?
2017/04/09
[ "https://philosophy.stackexchange.com/questions/41926", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/23407/" ]
The 2nd law of thermodynamics is an assertion. It is a statement that someone made that they believe to be true. It is also an assertion that is backed by an enormous body of evidence so vast that the prevailing belief is that no counter example exists. We have never observed a closed system in which entropy does not increase, nor have we observed any almost-closed systems that exhibit a sufficient decrease in entropy to cause us to assume the results were caused by the 2nd law failing. It is considered far more likely that the imperfections in the close system were the cause of the results. Can we prove it? Of course not. Science does not prove anything. That's not its job, never has been. Science's job is to create empirical models of the world which are very effective at predicting what will happen. This happens to be a model which has been empirically validated countless times. However, there's no reason there couldn't be a single pocket of the universe somewhere where the 2nd law doesn't apply. We just haven't seen one, and we currently have no reason to believe there are pockets where the rules are different. As for the magnetic particles, our models predict that they will indeed follow the second law. Because the system is isolated, energy does not get in or out. Thus, as the particles become attracted, they cannot emit energy outside of the system. They will acquire a high velocity. Quickly their path will be unpredictable, so the entropy of the system will increase. Eventually, if they collide and their collisions are not elastic, some of that magnetic potential energy you put into the system at the start will be converted to the random movements of thermal energy. Eventually, the particles may finally form a "group," but they will do so with a thermal energy that causes them to vibrate in a statistical manner. This is where you find the loss of order. When you started, the velocities of your particles was known, well ordered. Now the velocities are less known, more disordered. Again, feel free to test this yourself. Science can never prove itself right. But that's what the models say will happen, and some of those models have withstood quite a beating from the scientific community seeking exotic circumstances where their laws might not apply.
Thanks for your answers, I think I have the answer. The problem was trying to find a relation of proportionality between entropy and any of the presented features. But I realize now that entropy sustains the 2nd law, and viceversa. In simple words, there is some physically measurable quantity (entropy) that always increases (2nd law) on close systems evolving spontaneously. This, independent of order, enthalpy, and even probabilities. A system can get order, evolve towards a particular state out of the median states, or even concentrate its energy, while entropy reaches a maximum.
20,763,508
What are the best methods to `vertically-align` something relative to it's elements dimensions. As of right now, I'm only aware of `vertical-align:middle;` working well inside of a `<tr>`. Are there any other methodologies that I'm overlooking that can work to procedurally accomplish this goal?
2013/12/24
[ "https://Stackoverflow.com/questions/20763508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3117081/" ]
Here are 3 very good techniques for vertically centering a child within a container - even when you don't know the height of the child element. The first 2 come from [this CSS-tricks article](http://css-tricks.com/centering-in-the-unknown/) **Markup (for all methods):** ``` <div class="block"> <div class="centered"> Some text </div> </div> ``` Solution #1: CSS tables method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/7/)**) -------------------------------------------------------------------------------------- CSS: ``` /* This parent can be any width and height */ .block { display: table; width: 100%; background: orange; height: 300px; } .centered { display: table-cell; text-align: center; vertical-align: middle; background: pink; } ``` Solution #2: Pseudo ('Ghost') element method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/6/)**) ---------------------------------------------------------------------------------------------------- **CSS:** ``` /* This parent can be any width and height */ .block { text-align: center; background: orange; height: 300px; } /* The ghost, nudged to maintain perfect centering */ .block:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */ } /* The element to be centered, can also be of any width and height */ .centered { display: inline-block; vertical-align: middle; width: 300px; background: pink; } ``` Solution #3: Flexbox (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/11/)**) ----------------------------------------------------------------------------- **(Relevant) CSS:** ``` .block { background: orange; height: 300px; display: flex; align-items: center; } ```
A great place for you to start is this [article](http://css-tricks.com/what-is-vertical-align/) by CSS Tricks. It goes over every value that `vertical-align` can have and the different uses of each in a clear concise way. Here are the options: ``` vertical-align: baseline /* keyword values */ vertical-align: sub vertical-align: super vertical-align: text-top vertical-align: text-bottom vertical-align: middle vertical-align: top vertical-align: bottom ``` And here are the valid options for table cells: ``` baseline (and sub, super, text-top, text-bottom, <length>, and <percentage>) Align the baseline of the cell with the baseline of all other cells in the row that are baseline-aligned. top Align the top padding edge of the cell with the top of the row. middle Center the padding box of the cell within the row. bottom Align the bottom padding edge of the cell with the bottom of the row. ``` Additionally, you may want to try some other tricks like setting the `line-height` equal to the parent container's height.
20,763,508
What are the best methods to `vertically-align` something relative to it's elements dimensions. As of right now, I'm only aware of `vertical-align:middle;` working well inside of a `<tr>`. Are there any other methodologies that I'm overlooking that can work to procedurally accomplish this goal?
2013/12/24
[ "https://Stackoverflow.com/questions/20763508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3117081/" ]
Here are 3 very good techniques for vertically centering a child within a container - even when you don't know the height of the child element. The first 2 come from [this CSS-tricks article](http://css-tricks.com/centering-in-the-unknown/) **Markup (for all methods):** ``` <div class="block"> <div class="centered"> Some text </div> </div> ``` Solution #1: CSS tables method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/7/)**) -------------------------------------------------------------------------------------- CSS: ``` /* This parent can be any width and height */ .block { display: table; width: 100%; background: orange; height: 300px; } .centered { display: table-cell; text-align: center; vertical-align: middle; background: pink; } ``` Solution #2: Pseudo ('Ghost') element method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/6/)**) ---------------------------------------------------------------------------------------------------- **CSS:** ``` /* This parent can be any width and height */ .block { text-align: center; background: orange; height: 300px; } /* The ghost, nudged to maintain perfect centering */ .block:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */ } /* The element to be centered, can also be of any width and height */ .centered { display: inline-block; vertical-align: middle; width: 300px; background: pink; } ``` Solution #3: Flexbox (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/11/)**) ----------------------------------------------------------------------------- **(Relevant) CSS:** ``` .block { background: orange; height: 300px; display: flex; align-items: center; } ```
with table you can use ``` <table> <tr> <td valign="middle"></td> </tr> </table> ``` or css ``` td{ vertical-align:middle; } ``` If you want css vertical align is middle for div use display: table-cell; and display: table; ``` #abc{ font:Verdana, Geneva, sans-serif; font-size:18px; text-align:left; background-color:#0F0; height:50px; display: table; width: 100%; } #abc span { vertical-align:middle; display: table-cell; } ``` [DEMO HERE](http://jsfiddle.net/79x2a/26/)
20,763,508
What are the best methods to `vertically-align` something relative to it's elements dimensions. As of right now, I'm only aware of `vertical-align:middle;` working well inside of a `<tr>`. Are there any other methodologies that I'm overlooking that can work to procedurally accomplish this goal?
2013/12/24
[ "https://Stackoverflow.com/questions/20763508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3117081/" ]
Here are 3 very good techniques for vertically centering a child within a container - even when you don't know the height of the child element. The first 2 come from [this CSS-tricks article](http://css-tricks.com/centering-in-the-unknown/) **Markup (for all methods):** ``` <div class="block"> <div class="centered"> Some text </div> </div> ``` Solution #1: CSS tables method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/7/)**) -------------------------------------------------------------------------------------- CSS: ``` /* This parent can be any width and height */ .block { display: table; width: 100%; background: orange; height: 300px; } .centered { display: table-cell; text-align: center; vertical-align: middle; background: pink; } ``` Solution #2: Pseudo ('Ghost') element method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/6/)**) ---------------------------------------------------------------------------------------------------- **CSS:** ``` /* This parent can be any width and height */ .block { text-align: center; background: orange; height: 300px; } /* The ghost, nudged to maintain perfect centering */ .block:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */ } /* The element to be centered, can also be of any width and height */ .centered { display: inline-block; vertical-align: middle; width: 300px; background: pink; } ``` Solution #3: Flexbox (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/11/)**) ----------------------------------------------------------------------------- **(Relevant) CSS:** ``` .block { background: orange; height: 300px; display: flex; align-items: center; } ```
This might be a surprise to you, but `vertical-align` has been such a confusing thing that you might get tangled in it even for smallest of `divs` Here are some awesome resources to understand it : * [**Understanding vertical-align, or "How (Not) To Vertically Center Content**](http://phrogz.net/CSS/vertical-align/index.html) * [**vertical-align.com**](http://www.vertical-align.com/) * [**CSS tricks**](http://css-tricks.com/what-is-vertical-align/) ( *already mentioned i guess* ) * [**Last option**](http://www.impressivewebs.com/css-vertical-align/) The thing that you have to understand is when to use this property and when not => in certain cases, it only applies to `table`s while in some, you have to opt for pure `css` methods!
20,763,508
What are the best methods to `vertically-align` something relative to it's elements dimensions. As of right now, I'm only aware of `vertical-align:middle;` working well inside of a `<tr>`. Are there any other methodologies that I'm overlooking that can work to procedurally accomplish this goal?
2013/12/24
[ "https://Stackoverflow.com/questions/20763508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3117081/" ]
Here are 3 very good techniques for vertically centering a child within a container - even when you don't know the height of the child element. The first 2 come from [this CSS-tricks article](http://css-tricks.com/centering-in-the-unknown/) **Markup (for all methods):** ``` <div class="block"> <div class="centered"> Some text </div> </div> ``` Solution #1: CSS tables method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/7/)**) -------------------------------------------------------------------------------------- CSS: ``` /* This parent can be any width and height */ .block { display: table; width: 100%; background: orange; height: 300px; } .centered { display: table-cell; text-align: center; vertical-align: middle; background: pink; } ``` Solution #2: Pseudo ('Ghost') element method (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/6/)**) ---------------------------------------------------------------------------------------------------- **CSS:** ``` /* This parent can be any width and height */ .block { text-align: center; background: orange; height: 300px; } /* The ghost, nudged to maintain perfect centering */ .block:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */ } /* The element to be centered, can also be of any width and height */ .centered { display: inline-block; vertical-align: middle; width: 300px; background: pink; } ``` Solution #3: Flexbox (**[FIDDLE](http://jsfiddle.net/danield770/n2Zg2/11/)**) ----------------------------------------------------------------------------- **(Relevant) CSS:** ``` .block { background: orange; height: 300px; display: flex; align-items: center; } ```
My favorite for modal centering is to use a combination of `position` and `translate`, as described here: <http://css-tricks.com/centering-percentage-widthheight-elements/> In summary: ``` .center { width: 50%; /* or whatever you want your width to be; defaults to 100% */ height: 50%; /* or whatever you want your height to be; defaults to wrapping content */ position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); } ``` This may or may not work according to your use case, but it's a good trick to have in your toolbox.
24,939,678
Hi I have a dynamically generated list of items generated by php mysql. Below a content section there is a link basically "Load Related" link in this case the content is a bunch of thumbnails. I dont want to load the thumbs with the list when the page loads, instead I want to load them with Ajax using JQuery. The code below loads the data triggered by clicking an anchor "a.related" into one statically named div eg "div#pimgs" however it populates all divs named #pimgs ``` $('a.related').bind('click', function(e) { var url = $(this).attr('href'); $('div#pimgs').load(url); e.preventDefault(); }); <a class="related32" href="external-content.php?id=32"></a> <div id="pimgs32"></div> ``` I want to load data driven content into a dynimacilly named div eg"div#pimgs123" when you click an anchor named say "a.related123" or into a JQuery generated container directly below the anchor which is clicked. Can someone help with this? Hope I'm making some sense...
2014/07/24
[ "https://Stackoverflow.com/questions/24939678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/544774/" ]
Can you start from this? ``` $( 'a.related' ).bind( 'click', function( e ) { var url = $( this ).attr( 'href' ); var id = $( this ).attr( 'data-id' ); $( 'div#pimgs' + id ).load( url ); e.preventDefault(); } ); ``` In your dynamically generated `<a>`, put the numbers into `data-id` attribute ([ref](https://www.google.com/search?q=data+attribute)). So maybe: ``` <a href="foo" class="related" data-id="<?php echo $id; ?>">bar</a> <div id="pigms<?php echo $id; ?>"></div> ```
[**demo**](http://jsfiddle.net/p4q6c/1/) Don't use duplicate ID's. ``` $('a[class^="related"]').bind('click', function(e) { e.preventDefault(); var id = $(this).attr('class').split(' ').filter(function(v) { return v.indexOf('related') > -1; })[0]; var url = $(this).attr('href'); $('#' + id).load(url); }); ```
5,399,821
I am a self-taught java programmer, so i don't know the proper way to do a great deal of things. I have written a few simple games (such as Asteroids, Snake, ect.) so i know how to do the basics. Now i am working on a more complicated game, a role-playing game with zombies. I started writing it without putting much thought into how i will structure it. First, I made an 'item' class to hold the data for a simple item (value, weight, damage). Then I made a class to hold the variables for the player (Health, armor, items). I eventually made the menu, which on it's own needed variables to hold what menu item is currently being selected. I soon realized that i have a great deal of global variables that i would need to store somehow. I would need to use the variables in separate classes (such as the class that prints to the screen must know the locations of everything). So what would be the best way to write a big amount of global variables? Like i said, i do not know the proper way to do things, and i cannot find a good site that explains variable declaration on a large scale. Would i make a class that holds all the variables, and make the 'Main' class have a static declaration of that 'VariableStorage' class? Thanks in advance! P.S. Please supply links if you can! :D
2011/03/23
[ "https://Stackoverflow.com/questions/5399821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672229/" ]
There is a reason frequent use of static fields is frowned upon, and that reason is that static fields are less flexible than non-static ones, because there can only be one copy of a static field, but a non-static field can hold a different value for each object instance. By using static fields, you are restricting yourself to only ever have one player. If you ever want to do multiplayer mode, you can't - without rewriting a lot that is. The way this is typically done is something like this: ``` class Player { String name; Location loc; List<Item> inventory; void pickup() { if (itemsOnGround.isEmpty()) { throw new InvalidActionException("There appears to be nothing to pick up here"); } inventory.add(loc.itemsOnGround.get(0)); loc.itemsOnGround.remove(0); } } class Location { List<Items> itemsOnGround; /** null if there isn't a monster here */ Monster monster; } class Game { Player player; } class Ui { Game game; void keypressed(char key) { try { if (key == 'p') { game.player.pickup(); } else { showKeyboardHelp(); } } catch (InvalidActionException e) { showErrorMessage(e.getMessage()); } } } ``` As you can see, nary a static field to be found. This allows you to switch games without restarting your application (just overwriting all static fields is error prone - what if you forget one? Should the player having acquired the amulet of yendor in a previous game really carry over?), while allowing you to create additional items, player (or player-like characters, commonly called NPCs in RPG lingo) at your discretion, and still allows you to logically group related fields into classes, so you can find them again when you look at your code again months from now. If your game gets non-trivial you should also look into encapsulation. A policy I usually use in small projects is that fields may only be written to by code in the class that declares them, but read throughout the entire program. In a larger project, particularly if it involves several people, you will probably want the compiler to enforce that by making the fields private, and accessing their state through public methods (often called "getters") written for that purpose.
There isn't a one answer that can be given. In general, "lots of global variables" is an anti-pattern - whoever doesn't need to know locations of everything shouldnt be able to - that way that part of your code can't screw it up. So take it case by case. You need a way to know locations of all objects? Have a class called ObjectMap, for example, and put all the locations there. Then again, you can always have something like ``` public class Everything { public static HashMap<Object, Object> everythingHolder = new HashMap<Object, Object>(); } ``` but if you go along these lines, your code will become unmaintainable very soon.
5,399,821
I am a self-taught java programmer, so i don't know the proper way to do a great deal of things. I have written a few simple games (such as Asteroids, Snake, ect.) so i know how to do the basics. Now i am working on a more complicated game, a role-playing game with zombies. I started writing it without putting much thought into how i will structure it. First, I made an 'item' class to hold the data for a simple item (value, weight, damage). Then I made a class to hold the variables for the player (Health, armor, items). I eventually made the menu, which on it's own needed variables to hold what menu item is currently being selected. I soon realized that i have a great deal of global variables that i would need to store somehow. I would need to use the variables in separate classes (such as the class that prints to the screen must know the locations of everything). So what would be the best way to write a big amount of global variables? Like i said, i do not know the proper way to do things, and i cannot find a good site that explains variable declaration on a large scale. Would i make a class that holds all the variables, and make the 'Main' class have a static declaration of that 'VariableStorage' class? Thanks in advance! P.S. Please supply links if you can! :D
2011/03/23
[ "https://Stackoverflow.com/questions/5399821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672229/" ]
There is a reason frequent use of static fields is frowned upon, and that reason is that static fields are less flexible than non-static ones, because there can only be one copy of a static field, but a non-static field can hold a different value for each object instance. By using static fields, you are restricting yourself to only ever have one player. If you ever want to do multiplayer mode, you can't - without rewriting a lot that is. The way this is typically done is something like this: ``` class Player { String name; Location loc; List<Item> inventory; void pickup() { if (itemsOnGround.isEmpty()) { throw new InvalidActionException("There appears to be nothing to pick up here"); } inventory.add(loc.itemsOnGround.get(0)); loc.itemsOnGround.remove(0); } } class Location { List<Items> itemsOnGround; /** null if there isn't a monster here */ Monster monster; } class Game { Player player; } class Ui { Game game; void keypressed(char key) { try { if (key == 'p') { game.player.pickup(); } else { showKeyboardHelp(); } } catch (InvalidActionException e) { showErrorMessage(e.getMessage()); } } } ``` As you can see, nary a static field to be found. This allows you to switch games without restarting your application (just overwriting all static fields is error prone - what if you forget one? Should the player having acquired the amulet of yendor in a previous game really carry over?), while allowing you to create additional items, player (or player-like characters, commonly called NPCs in RPG lingo) at your discretion, and still allows you to logically group related fields into classes, so you can find them again when you look at your code again months from now. If your game gets non-trivial you should also look into encapsulation. A policy I usually use in small projects is that fields may only be written to by code in the class that declares them, but read throughout the entire program. In a larger project, particularly if it involves several people, you will probably want the compiler to enforce that by making the fields private, and accessing their state through public methods (often called "getters") written for that purpose.
Honestly, I would do a thorough check of the class structure to see if there was a better design than making everything global. Using paradigms like [MVC](http://jordanhall.co.uk/programming/simple-explanation-of-model-view-controller-mvc-2206990/) can really simplify your code organization. I don't know what your specific needs are, but usually a good design allows you to access the needed data in a simple way. ``` //A possible heirarchy PlayableCharacter |-Stats | |-int totalHealth | |-int currentHealth | |-int speed | \-int strength | |-List<Equipment> inventory |-Helmet head //Helmet would be a subclass of Equipment |-HandEquipment leftHand |-HandEquipment rightHand |-ChestEquipment torso \-LegEquipment legs ``` With an organization structure that both fits your needs and is a good abstraction of the game world, accessing your variables would be easy and meaningful. ``` public int getAttackLevel() { return leftHand.getAttackPoints() + rightHand.getAttackPoints() + stats.getStrength(); } ``` If you *do* find that there are some global variables that are unavoidable, I would again try to organize them in a meaningful way. ``` GameVariables |-LocationVariables | |-int worldX | |-int worldY | \-int worldZ | |-QuestVariables | |-String questName | \-double questProgress | |-GameSettings | |-int resolutionX | |-int resolutionY | \-Difficulty difficultyLevel | | //And so on.... ```
48,084,971
I'm new to python, so bear with me on this one. I want to make a script that searches within all excel files in a specific folder, to see if they contain an '@' sign. If it finds a match it should write to a log.txt files with the name of the excel file. I don't have the name of the excel files in advance. So far I'm stuck at just read in one file, and return true if it finds the string. What I got is ``` import pandas as pd df = pd.read_excel(open('test.xlsx','rb'), sheetname=0) print(df) if '@' in df: print("true") else: print("false") ``` This returns the content of sheet1 in the excel file correctly, but the search to find a match, doesn't seem to work. Any ideas? Maybe Im doing it all wrong.
2018/01/03
[ "https://Stackoverflow.com/questions/48084971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1495850/" ]
You should read through [Pandas - Working with Text Data](https://pandas.pydata.org/pandas-docs/stable/text.html#testing-for-strings-that-match-or-contain-a-pattern) specifically the section on strings that match or contain a pattern. Unfortunately you cannot search a DataFrame with the string methods common to core Python. Instead you would use a StringMethod, like so: ``` out = False for col in df.columns: if df[col].str.contains('@').any(): out = 'True' break print(out) ``` Also, I don't believe it is necessary to use `open` when using [`pd.read_excel`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html). E.g ``` df = pd.read_excel(open('test.xlsx','rb'), sheetname=0) ``` Can be rewritten: ``` df = pd.read_excel('test.xlsx', sheetname=0) ``` As far as iterating over files in a folder take a look at the builtin module [glob](https://docs.python.org/3/library/glob.html).
This an answer without using pandas ``` import logging LOG_FILENAME = r'file_output_location_path\log.txt' logging.basicConfig(filename=LOG_FILENAME, level=logging.WARNING, format='%(asctime)s %(message)s' ) source_folder = r'excel_file_folder_path' def containsString(): for somefile in os.listdir(source_folder): if'@' in somefile: logging.warning(somefile) ```
11,528,017
I am looking at using <http://code.google.com/p/libphonenumber/> for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on. libphonenumber looks awesome ... except that the javascript version (svn co <http://libphonenumber.googlecode.com/svn/trunk/javascript/> libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com : ``` GET base.js GET deps.js GET error.js GET string.js GET asserts.js GET array.js GET useragent.js GET browserfeature.js GET tagname.js GET classes.js GET math.js GET coordinate.js GET size.js GET object.js GET dom.js GET json.js GET util.js GET descriptor.js GET fielddescriptor.js GET message.js GET serializer.js GET objectserializer.js GET stringbuffer.js GET lazydeserializer.js GET pbliteserializer.js ``` I believe if I compile this using the closure compiler ("If you give the use\_closure\_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", <https://developers.google.com/closure/compiler/docs/api-ref>) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one. My question has two possible answers: 1. A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries 2. An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations Any and all suggestions most appreciated.
2012/07/17
[ "https://Stackoverflow.com/questions/11528017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618148/" ]
You can also use my lib. <https://github.com/Gilshallem/phoneparser> Its only got one method but you can do a lot with it ``` parsePhone("12025550104"); result: { countryCode:1, areaCode:202, number:5550104, countryISOCode:"US" } ```
Here are two implementations of Google libphonenumber in JavaScript that have zero dependencies and are implemented in a single file. I've used Nathan Hammond's version without issue but it is not on NPM. Rui Marinho's version is on NPM. * <https://github.com/nathanhammond/libphonenumber> * <https://github.com/ruimarinho/google-libphonenumber>
11,528,017
I am looking at using <http://code.google.com/p/libphonenumber/> for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on. libphonenumber looks awesome ... except that the javascript version (svn co <http://libphonenumber.googlecode.com/svn/trunk/javascript/> libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com : ``` GET base.js GET deps.js GET error.js GET string.js GET asserts.js GET array.js GET useragent.js GET browserfeature.js GET tagname.js GET classes.js GET math.js GET coordinate.js GET size.js GET object.js GET dom.js GET json.js GET util.js GET descriptor.js GET fielddescriptor.js GET message.js GET serializer.js GET objectserializer.js GET stringbuffer.js GET lazydeserializer.js GET pbliteserializer.js ``` I believe if I compile this using the closure compiler ("If you give the use\_closure\_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", <https://developers.google.com/closure/compiler/docs/api-ref>) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one. My question has two possible answers: 1. A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries 2. An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations Any and all suggestions most appreciated.
2012/07/17
[ "https://Stackoverflow.com/questions/11528017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618148/" ]
You can also use my lib. <https://github.com/Gilshallem/phoneparser> Its only got one method but you can do a lot with it ``` parsePhone("12025550104"); result: { countryCode:1, areaCode:202, number:5550104, countryISOCode:"US" } ```
I just spent 2 days figuring this out. For now, anyway, you can download a minified version of libphonenumber-js from [here](https://cdnjs.cloudflare.com/ajax/libs/libphonenumber-js/1.4.2/libphonenumber-js.min.js) drop it in place, with the usual ``` <script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script> ``` and get busy coding! ``` <script> $(".phone-format").keyup(function () { var val_old = $(this).val(); var newString = new libphonenumber.AsYouType('US').input(val_old); $(this).focus().val('').val(newString); }); </script> ```
11,528,017
I am looking at using <http://code.google.com/p/libphonenumber/> for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on. libphonenumber looks awesome ... except that the javascript version (svn co <http://libphonenumber.googlecode.com/svn/trunk/javascript/> libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com : ``` GET base.js GET deps.js GET error.js GET string.js GET asserts.js GET array.js GET useragent.js GET browserfeature.js GET tagname.js GET classes.js GET math.js GET coordinate.js GET size.js GET object.js GET dom.js GET json.js GET util.js GET descriptor.js GET fielddescriptor.js GET message.js GET serializer.js GET objectserializer.js GET stringbuffer.js GET lazydeserializer.js GET pbliteserializer.js ``` I believe if I compile this using the closure compiler ("If you give the use\_closure\_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", <https://developers.google.com/closure/compiler/docs/api-ref>) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one. My question has two possible answers: 1. A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries 2. An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations Any and all suggestions most appreciated.
2012/07/17
[ "https://Stackoverflow.com/questions/11528017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618148/" ]
I've got a [custom build](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) (currently 220KB) that I use for my [International Telephone Input](https://github.com/jackocnr/intl-tel-input) plugin, with plenty of helper functions exposed. Read [the source](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/utils.js) for details.
Here are two implementations of Google libphonenumber in JavaScript that have zero dependencies and are implemented in a single file. I've used Nathan Hammond's version without issue but it is not on NPM. Rui Marinho's version is on NPM. * <https://github.com/nathanhammond/libphonenumber> * <https://github.com/ruimarinho/google-libphonenumber>
11,528,017
I am looking at using <http://code.google.com/p/libphonenumber/> for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on. libphonenumber looks awesome ... except that the javascript version (svn co <http://libphonenumber.googlecode.com/svn/trunk/javascript/> libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com : ``` GET base.js GET deps.js GET error.js GET string.js GET asserts.js GET array.js GET useragent.js GET browserfeature.js GET tagname.js GET classes.js GET math.js GET coordinate.js GET size.js GET object.js GET dom.js GET json.js GET util.js GET descriptor.js GET fielddescriptor.js GET message.js GET serializer.js GET objectserializer.js GET stringbuffer.js GET lazydeserializer.js GET pbliteserializer.js ``` I believe if I compile this using the closure compiler ("If you give the use\_closure\_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", <https://developers.google.com/closure/compiler/docs/api-ref>) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one. My question has two possible answers: 1. A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries 2. An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations Any and all suggestions most appreciated.
2012/07/17
[ "https://Stackoverflow.com/questions/11528017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618148/" ]
I've got a [custom build](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) (currently 220KB) that I use for my [International Telephone Input](https://github.com/jackocnr/intl-tel-input) plugin, with plenty of helper functions exposed. Read [the source](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/utils.js) for details.
I just spent 2 days figuring this out. For now, anyway, you can download a minified version of libphonenumber-js from [here](https://cdnjs.cloudflare.com/ajax/libs/libphonenumber-js/1.4.2/libphonenumber-js.min.js) drop it in place, with the usual ``` <script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script> ``` and get busy coding! ``` <script> $(".phone-format").keyup(function () { var val_old = $(this).val(); var newString = new libphonenumber.AsYouType('US').input(val_old); $(this).focus().val('').val(newString); }); </script> ```
11,528,017
I am looking at using <http://code.google.com/p/libphonenumber/> for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on. libphonenumber looks awesome ... except that the javascript version (svn co <http://libphonenumber.googlecode.com/svn/trunk/javascript/> libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com : ``` GET base.js GET deps.js GET error.js GET string.js GET asserts.js GET array.js GET useragent.js GET browserfeature.js GET tagname.js GET classes.js GET math.js GET coordinate.js GET size.js GET object.js GET dom.js GET json.js GET util.js GET descriptor.js GET fielddescriptor.js GET message.js GET serializer.js GET objectserializer.js GET stringbuffer.js GET lazydeserializer.js GET pbliteserializer.js ``` I believe if I compile this using the closure compiler ("If you give the use\_closure\_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", <https://developers.google.com/closure/compiler/docs/api-ref>) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one. My question has two possible answers: 1. A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries 2. An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations Any and all suggestions most appreciated.
2012/07/17
[ "https://Stackoverflow.com/questions/11528017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618148/" ]
Here are two implementations of Google libphonenumber in JavaScript that have zero dependencies and are implemented in a single file. I've used Nathan Hammond's version without issue but it is not on NPM. Rui Marinho's version is on NPM. * <https://github.com/nathanhammond/libphonenumber> * <https://github.com/ruimarinho/google-libphonenumber>
I just spent 2 days figuring this out. For now, anyway, you can download a minified version of libphonenumber-js from [here](https://cdnjs.cloudflare.com/ajax/libs/libphonenumber-js/1.4.2/libphonenumber-js.min.js) drop it in place, with the usual ``` <script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script> ``` and get busy coding! ``` <script> $(".phone-format").keyup(function () { var val_old = $(this).val(); var newString = new libphonenumber.AsYouType('US').input(val_old); $(this).focus().val('').val(newString); }); </script> ```
51,667,393
I am using excel to input data for my test automation scripts and I am able read data from excel when i know the exact row and the column to read. The challenge which I am facing is when I have merged cells in the sheet. E.g. [Test data excel sample](https://i.stack.imgur.com/f1lDh.png) Here ScriptName and Iteration are my primary keys to identify a unique set of data for my script. So my question here is: 1. **I want to fetch all the ReferenceSetName with respect to a ScriptName, and Iteration i.e. for Login script, Iteration 1: I have to fetch ABC1 Ref set, ABC2 Ref set, ABC3 Ref set** 2. **I want to fetch all the PackageName with respect to a ScriptName, Iteration, and ReferenceSet i.e. for Login script, Iteration 1, ReferenceSet ABC1 Ref set: I have to fetch ABC1, ABC2, ABC3** Currently below is the method - getEntireCellValue() I am using to fetch the data from excel and I need help to solve the above 2 problems. Any kind of support is really appreciated. ``` public void getExcelRowNum() { boolean found = false; String scriptCell = null, iterationCell = null; try { @SuppressWarnings("rawtypes") Iterator iterator = sheet.rowIterator(); while (iterator.hasNext()) { Row row = (Row) iterator.next(); scriptCell = row.getCell(1).toString().trim(); iterationCell = row.getCell(2).toString().trim(); if (row.getCell(2).getCellTypeEnum() == CellType.NUMERIC) iterationCell = iterationCell.substring(0, iterationCell.indexOf(".")).trim(); if ((scriptCell.equals(scriptName) && iterationCell.equals(String.valueOf(iteration).trim())) || (scriptCell.equals(scriptName) && Integer.parseInt(iterationCell) == iteration)) { rowNum = row.getRowNum(); found = true; break; } } if (rowNum == -1 || found == false) throw new Exception("Please check the test name: " + scriptName + " or the iteration: " + iteration + " in the test data sheet"); row = sheet.getRow(0); } catch (Exception e) { e.printStackTrace(); } } public void getExcelColNum(String colName) { boolean found = false; try { for (int i = 0; i < row.getLastCellNum(); i++) { if (row.getCell(i).getStringCellValue().trim().equals(colName.trim())) { col_Num = i; found = true; break; } } if (col_Num == -1 || found == false) throw new Exception("Please check the column name: " + colName + " in the test data sheet"); } catch (Exception e) { e.printStackTrace(); } } public void getCell() { try { row = sheet.getRow(rowNum); cell = row.getCell(col_Num); } catch (Exception e) { e.printStackTrace(); } } //Prior to calling this method. I am connecting to the excel sheet which is in .xlsx or xls format public String getEntireCellValue(String sheetName, String colName) { try { sheet = workbook.getSheet(sheetName); getExcelRowNum(); getExcelColNum(colName); getCell(); if (cell.getCellTypeEnum() == CellType.STRING) return cell.getStringCellValue().trim(); else if (cell.getCellTypeEnum() == CellType.BLANK) return null; } catch (Exception e) { e.printStackTrace(); return null; } } public int getNumOfMergedRows() { int rowsMerged = 0; try { for(int i = 0; i < sheet.getNumMergedRegions(); i++) { CellRangeAddress range = sheet.getMergedRegion(i); if (range.getFirstRow() <= rowNum && range.getLastRow() >= rowNum) { ++rowsMerged; } } System.out.println("Number of rows merged are: " + rowsMerged); } catch (Exception e) { e.printStackTrace(); } return rowsMerged; } ``` P.S. What I am doing here is, I am trying to fetch the number of merged rows for a script e.g. 6 rows are merged for Login script and then find number of cells inside those 6 rows to get the reference set name (3 cells). Note: When I call the above method - getNumOfMergedRows() to determine number of rows merged for Login script, I am getting 4 as output instead of 6.
2018/08/03
[ "https://Stackoverflow.com/questions/51667393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4466798/" ]
The below code will determine the number of merged cells in a column - colName, with begining row as startingRow ``` public int getNumOfMergedRows(String colName, int startingRow) { int rowsMerged = 0, col = 0; XSSFRow mergedRow = null; XSSFCell mergedCell = null; try { col = getExcelColNum(colName); for (int i = startingRow + 1; i < sheet.getPhysicalNumberOfRows(); i++) { mergedRow = sheet.getRow(i); mergedCell = mergedRow.getCell(col); if (mergedCell.getCellTypeEnum() == null || mergedCell.getCellTypeEnum() == CellType.BLANK) rowsMerged++; else break; } rowsMerged++; } catch (Exception e) { e.printStackTrace(); } logger.info(rowsMerged + " rows are merged in columne" + colName + " for " + scriptName + " script"); return rowsMerged; } ```
I have a sample code which takes the fiel as input.It will count the values in 3rd column for all values and stores it in a map. It does so by counting the blank values in excel file and reset the counter at each valid value ``` import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class Demo { public static void main(String[] args) { readFile(new File("excelstack.xlsx")); } public static void readFile(File file) { try { FileInputStream excelFile = new FileInputStream(file); Workbook workbook = new XSSFWorkbook(excelFile); Sheet datatypeSheet = workbook.getSheetAt(0); Iterator<Row> iterator = datatypeSheet.iterator(); Map<String,Integer> map=new HashMap<String,Integer>(); int coltocheck=1; int counter=1; String currentitem=""; while (iterator.hasNext()) { Row currentRow = iterator.next(); Iterator<Cell> cellIterator = currentRow.iterator(); while (cellIterator.hasNext()) { Cell currentCell = cellIterator.next(); if(currentCell.getCellTypeEnum()==CellType.BLANK ) { if(currentCell.getColumnIndex()==coltocheck) map.put(currentitem, counter++); } else if(currentCell.getCellTypeEnum()==CellType.STRING && currentCell.getColumnIndex()==coltocheck) { currentitem=currentCell.getStringCellValue(); counter=1; map.put(currentitem, counter++); } } } for(Map.Entry<String, Integer> m:map.entrySet()) System.out.println(m.getKey()+" "+m.getValue()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } } } ```
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
Your requirements are contradictory: > > ... I will need to insert new elements at specific positions. > > > There is a need for me to enter elements at a position larger than the current size. > > > These imply that positions are stable; i.e. that an element at a given position remains at that position. > > I would expect to find "hi" at index 1 instead of index 0 now. > > > This states that positions are not stable under some circumstances. You really need to make up your mind which alternative you need. * If you must have stable positions, use a `TreeMap` or `HashMap`. (A `TreeMap` allows you to iterate the keys in order, but at the cost of more expensive insertion and lookup ... for a large collection.) If necessary, use a "position" key type that allows you to "always" generate a new key that goes between any existing pair of keys. * If you don't have to have stable positions, use an `ArrayList`, and deal with the case where you have to insert beyond the end position using `append`. I fail to see how it is sensible for positions to be stable if you insert beyond the end, and allow instability if you insert in the middle. (Besides, the latter is going to make the former unstable eventually ...)
even you can use TreeMap for maintaining order of keys.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
even you can use TreeMap for maintaining order of keys.
Use Vector class to solve this issue. Vector vector = new Vector(); **vector.setSize(100);** vector.set(98, "a"); When "setSize" is set to 100 then all 100 elements gets initialized with null values.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
even you can use TreeMap for maintaining order of keys.
For those who are still dealing with this, you may do it like this. ``` Object[] array= new Object[10]; array[0]="1"; array[3]= "3"; array[2]="2"; array[7]="7"; List<Object> list= Arrays.asList(array); ``` But the thing is you need to identify the total size first, this should be just a comment but I do not have much reputation to do that.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
Your requirements are contradictory: > > ... I will need to insert new elements at specific positions. > > > There is a need for me to enter elements at a position larger than the current size. > > > These imply that positions are stable; i.e. that an element at a given position remains at that position. > > I would expect to find "hi" at index 1 instead of index 0 now. > > > This states that positions are not stable under some circumstances. You really need to make up your mind which alternative you need. * If you must have stable positions, use a `TreeMap` or `HashMap`. (A `TreeMap` allows you to iterate the keys in order, but at the cost of more expensive insertion and lookup ... for a large collection.) If necessary, use a "position" key type that allows you to "always" generate a new key that goes between any existing pair of keys. * If you don't have to have stable positions, use an `ArrayList`, and deal with the case where you have to insert beyond the end position using `append`. I fail to see how it is sensible for positions to be stable if you insert beyond the end, and allow instability if you insert in the middle. (Besides, the latter is going to make the former unstable eventually ...)
First and foremost, I would say use `Map` instead of List. I guess your problem can be solved in better way if you use `Map`. But in any case if you really want to do this with `Arraylist` ``` ArrayList<String> a = new ArrayList<String>(); //Create empty list a.addAll(Arrays.asList( new String[100])); // add n number of strings, actually null . here n is 100, but you will have to decide the ideal value of this, depending upon your requirement. a.add(7,"hello"); a.add(2,"hi"); a.add(1,"hi2"); ```
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
First and foremost, I would say use `Map` instead of List. I guess your problem can be solved in better way if you use `Map`. But in any case if you really want to do this with `Arraylist` ``` ArrayList<String> a = new ArrayList<String>(); //Create empty list a.addAll(Arrays.asList( new String[100])); // add n number of strings, actually null . here n is 100, but you will have to decide the ideal value of this, depending upon your requirement. a.add(7,"hello"); a.add(2,"hi"); a.add(1,"hi2"); ```
Use Vector class to solve this issue. Vector vector = new Vector(); **vector.setSize(100);** vector.set(98, "a"); When "setSize" is set to 100 then all 100 elements gets initialized with null values.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
First and foremost, I would say use `Map` instead of List. I guess your problem can be solved in better way if you use `Map`. But in any case if you really want to do this with `Arraylist` ``` ArrayList<String> a = new ArrayList<String>(); //Create empty list a.addAll(Arrays.asList( new String[100])); // add n number of strings, actually null . here n is 100, but you will have to decide the ideal value of this, depending upon your requirement. a.add(7,"hello"); a.add(2,"hi"); a.add(1,"hi2"); ```
For those who are still dealing with this, you may do it like this. ``` Object[] array= new Object[10]; array[0]="1"; array[3]= "3"; array[2]="2"; array[7]="7"; List<Object> list= Arrays.asList(array); ``` But the thing is you need to identify the total size first, this should be just a comment but I do not have much reputation to do that.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
Your requirements are contradictory: > > ... I will need to insert new elements at specific positions. > > > There is a need for me to enter elements at a position larger than the current size. > > > These imply that positions are stable; i.e. that an element at a given position remains at that position. > > I would expect to find "hi" at index 1 instead of index 0 now. > > > This states that positions are not stable under some circumstances. You really need to make up your mind which alternative you need. * If you must have stable positions, use a `TreeMap` or `HashMap`. (A `TreeMap` allows you to iterate the keys in order, but at the cost of more expensive insertion and lookup ... for a large collection.) If necessary, use a "position" key type that allows you to "always" generate a new key that goes between any existing pair of keys. * If you don't have to have stable positions, use an `ArrayList`, and deal with the case where you have to insert beyond the end position using `append`. I fail to see how it is sensible for positions to be stable if you insert beyond the end, and allow instability if you insert in the middle. (Besides, the latter is going to make the former unstable eventually ...)
Use Vector class to solve this issue. Vector vector = new Vector(); **vector.setSize(100);** vector.set(98, "a"); When "setSize" is set to 100 then all 100 elements gets initialized with null values.
10,629,803
Currently I'm using an ArrayList to store a list of elements, whereby I will need to insert new elements at specific positions. There is a need for me to enter elements at a position larger than the current size. For e.g: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add(3,"hi"); ``` Now I already know there will be an OutOfBoundsException. Is there another way or another object where I can do this while still keeping the order? This is because I have methods that finds elements based on their index. For e.g.: ``` ArrayList<String> arr = new ArrayList<String>(); arr.add("hi"); arr.add(0,"hello"); ``` I would expect to find "hi" at index 1 instead of index 0 now. So in summary, short of manually inserting null into the elements in-between, is there any way to satisfy these two requirements: * Insert elements into position larger than current size * Push existing elements to the right when I insert elements in the middle of the list I've looked at [Java ArrayList add item outside current size](https://stackoverflow.com/questions/8925128/java-arraylist-add-item-outside-current-size), as well as HashMap, but HashMap doesn't satisfy my second criteria. Any help would be greatly appreciated. P.S. Performance is not really an issue right now. UPDATE: There have been some questions on why I have these particular requirements, it is because I'm working on operational transformation, where I'm inserting a set of operations into, say, my list (a math formula). Each operation contains a string. As I insert/delete strings into my list, I will dynamically update the unapplied operations (if necessary) through the tracking of each operation that has already been applied. My current solution now is to use a subclass of ArrayList and override some of the methods. I would certainly like to know if there is a more elegant way of doing so though.
2012/05/17
[ "https://Stackoverflow.com/questions/10629803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/822377/" ]
Your requirements are contradictory: > > ... I will need to insert new elements at specific positions. > > > There is a need for me to enter elements at a position larger than the current size. > > > These imply that positions are stable; i.e. that an element at a given position remains at that position. > > I would expect to find "hi" at index 1 instead of index 0 now. > > > This states that positions are not stable under some circumstances. You really need to make up your mind which alternative you need. * If you must have stable positions, use a `TreeMap` or `HashMap`. (A `TreeMap` allows you to iterate the keys in order, but at the cost of more expensive insertion and lookup ... for a large collection.) If necessary, use a "position" key type that allows you to "always" generate a new key that goes between any existing pair of keys. * If you don't have to have stable positions, use an `ArrayList`, and deal with the case where you have to insert beyond the end position using `append`. I fail to see how it is sensible for positions to be stable if you insert beyond the end, and allow instability if you insert in the middle. (Besides, the latter is going to make the former unstable eventually ...)
For those who are still dealing with this, you may do it like this. ``` Object[] array= new Object[10]; array[0]="1"; array[3]= "3"; array[2]="2"; array[7]="7"; List<Object> list= Arrays.asList(array); ``` But the thing is you need to identify the total size first, this should be just a comment but I do not have much reputation to do that.
84,038
The Update Manager recently started itself and found two updates. I can tell by the icon in the launcher. The icon has a (2) on it and a little white arrow saying the application is running. I can also see the update-manager process in a 'ps -A' list. Alt-Tab also shows the Update Manager. The problem is I can't get Update Manager to show up. If I click on the icon or Alt-Tab to it, nothing happens. I've never had any issues starting it manually, but when it starts on it's own after finding an update, I can't switch to it. What can I try to make this work better?
2011/11/30
[ "https://askubuntu.com/questions/84038", "https://askubuntu.com", "https://askubuntu.com/users/26562/" ]
I have the same problem. I didn't find this specific issue on launchpad either. For me, even though the update manager doesn't completely open, it still can be closed from the "x" on the top right panel or ctrl+q. Once closed it reopens fine.
I have this problem with libreoffice. You can use 'super + w'. You will get all the window on screen, click the window you want.
84,038
The Update Manager recently started itself and found two updates. I can tell by the icon in the launcher. The icon has a (2) on it and a little white arrow saying the application is running. I can also see the update-manager process in a 'ps -A' list. Alt-Tab also shows the Update Manager. The problem is I can't get Update Manager to show up. If I click on the icon or Alt-Tab to it, nothing happens. I've never had any issues starting it manually, but when it starts on it's own after finding an update, I can't switch to it. What can I try to make this work better?
2011/11/30
[ "https://askubuntu.com/questions/84038", "https://askubuntu.com", "https://askubuntu.com/users/26562/" ]
I have the same problem. I didn't find this specific issue on launchpad either. For me, even though the update manager doesn't completely open, it still can be closed from the "x" on the top right panel or ctrl+q. Once closed it reopens fine.
This is a bug with Unity, it seems to happen with LibreOffice too. I don't think there is any fix yet, Unity is still being worked on. Link: <https://bugs.launchpad.net/ubuntu/+source/unity/+bug/942222> You can just update manually using a terminal by typing these in sequence: ``` sudo apt-get update sudo apt-get upgrade ``` If the update manager is bugging you, kill it with this command: ``` killall update-manager ```
84,038
The Update Manager recently started itself and found two updates. I can tell by the icon in the launcher. The icon has a (2) on it and a little white arrow saying the application is running. I can also see the update-manager process in a 'ps -A' list. Alt-Tab also shows the Update Manager. The problem is I can't get Update Manager to show up. If I click on the icon or Alt-Tab to it, nothing happens. I've never had any issues starting it manually, but when it starts on it's own after finding an update, I can't switch to it. What can I try to make this work better?
2011/11/30
[ "https://askubuntu.com/questions/84038", "https://askubuntu.com", "https://askubuntu.com/users/26562/" ]
I have the same problem. I didn't find this specific issue on launchpad either. For me, even though the update manager doesn't completely open, it still can be closed from the "x" on the top right panel or ctrl+q. Once closed it reopens fine.
I've seen scenarios where application windows end up outside of the screen area. Sometimes its caused by having windows placed on secondary screens then disconnecting the screen. Leaving the application "unreachable" * Go to the desktop that seems to have the application running. * Make sure the application is selected with alt+tab. * Press alt+space + m (m for move, if you use english ubuntu) drag the mouse cursor to the center of the screen. Your application window should be attached to the mouse cursor if the issue you had was this.
84,038
The Update Manager recently started itself and found two updates. I can tell by the icon in the launcher. The icon has a (2) on it and a little white arrow saying the application is running. I can also see the update-manager process in a 'ps -A' list. Alt-Tab also shows the Update Manager. The problem is I can't get Update Manager to show up. If I click on the icon or Alt-Tab to it, nothing happens. I've never had any issues starting it manually, but when it starts on it's own after finding an update, I can't switch to it. What can I try to make this work better?
2011/11/30
[ "https://askubuntu.com/questions/84038", "https://askubuntu.com", "https://askubuntu.com/users/26562/" ]
I have this problem with libreoffice. You can use 'super + w'. You will get all the window on screen, click the window you want.
I've seen scenarios where application windows end up outside of the screen area. Sometimes its caused by having windows placed on secondary screens then disconnecting the screen. Leaving the application "unreachable" * Go to the desktop that seems to have the application running. * Make sure the application is selected with alt+tab. * Press alt+space + m (m for move, if you use english ubuntu) drag the mouse cursor to the center of the screen. Your application window should be attached to the mouse cursor if the issue you had was this.
84,038
The Update Manager recently started itself and found two updates. I can tell by the icon in the launcher. The icon has a (2) on it and a little white arrow saying the application is running. I can also see the update-manager process in a 'ps -A' list. Alt-Tab also shows the Update Manager. The problem is I can't get Update Manager to show up. If I click on the icon or Alt-Tab to it, nothing happens. I've never had any issues starting it manually, but when it starts on it's own after finding an update, I can't switch to it. What can I try to make this work better?
2011/11/30
[ "https://askubuntu.com/questions/84038", "https://askubuntu.com", "https://askubuntu.com/users/26562/" ]
This is a bug with Unity, it seems to happen with LibreOffice too. I don't think there is any fix yet, Unity is still being worked on. Link: <https://bugs.launchpad.net/ubuntu/+source/unity/+bug/942222> You can just update manually using a terminal by typing these in sequence: ``` sudo apt-get update sudo apt-get upgrade ``` If the update manager is bugging you, kill it with this command: ``` killall update-manager ```
I've seen scenarios where application windows end up outside of the screen area. Sometimes its caused by having windows placed on secondary screens then disconnecting the screen. Leaving the application "unreachable" * Go to the desktop that seems to have the application running. * Make sure the application is selected with alt+tab. * Press alt+space + m (m for move, if you use english ubuntu) drag the mouse cursor to the center of the screen. Your application window should be attached to the mouse cursor if the issue you had was this.
16,245,508
Here's my code so far, ``` $('label').click(function () { if ($('label input').is(':checked')) { $(this).addClass('checked'); $('.donate-now label').not(this).removeClass('checked'); var donateAmount = $(".checked input").val(); $('p').append(donateAmount); } }); ``` I'm checking to make sure the "donateAmount" variable is grabbing only one value, so to test, I'm having it append to the HTML, but it's showing up twice. Is that a function of append() and my variable only has one value, or is something wrong? Essentially I just want to make sure my variable has one value. Here it is in action, <http://jsfiddle.net/YB8UW/15/> Thank you
2013/04/26
[ "https://Stackoverflow.com/questions/16245508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229113/" ]
Try changing your selector to: ``` $('label input').click(function () { .... }); ``` <http://jsfiddle.net/YB8UW/18/> Your problem is that you are clicking the label AND radio when you click on the radio. Since you are clicking the child element, the event fires twice. If you focus the selector in a little more and only capture when the radio button is clicked, it will only fire once. Clicking the label fires a click on the input as well. Changing it from append to replace doesn't fix the issue, just masks it.
Instead of append, use: ``` $('p').html(donateAmount); ``` Append will put a new element in that `<p>` element everytime, rather than replacing the contents of it.
16,245,508
Here's my code so far, ``` $('label').click(function () { if ($('label input').is(':checked')) { $(this).addClass('checked'); $('.donate-now label').not(this).removeClass('checked'); var donateAmount = $(".checked input").val(); $('p').append(donateAmount); } }); ``` I'm checking to make sure the "donateAmount" variable is grabbing only one value, so to test, I'm having it append to the HTML, but it's showing up twice. Is that a function of append() and my variable only has one value, or is something wrong? Essentially I just want to make sure my variable has one value. Here it is in action, <http://jsfiddle.net/YB8UW/15/> Thank you
2013/04/26
[ "https://Stackoverflow.com/questions/16245508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229113/" ]
Instead of append, use: ``` $('p').html(donateAmount); ``` Append will put a new element in that `<p>` element everytime, rather than replacing the contents of it.
You should `.empty()` the container before you append it. :) <http://jsfiddle.net/droppedonjapan/YB8UW/29/> Why your event is being fired twice, I'm not 100% sure, but I think it may be the way the labels' click event goes off. I'm pretty sure it's delegated to your radio input, which then triggers another label click. I also changed your code a bit to reduce the nesting/ chaining. Let me know if that takes care of it for you!
16,245,508
Here's my code so far, ``` $('label').click(function () { if ($('label input').is(':checked')) { $(this).addClass('checked'); $('.donate-now label').not(this).removeClass('checked'); var donateAmount = $(".checked input").val(); $('p').append(donateAmount); } }); ``` I'm checking to make sure the "donateAmount" variable is grabbing only one value, so to test, I'm having it append to the HTML, but it's showing up twice. Is that a function of append() and my variable only has one value, or is something wrong? Essentially I just want to make sure my variable has one value. Here it is in action, <http://jsfiddle.net/YB8UW/15/> Thank you
2013/04/26
[ "https://Stackoverflow.com/questions/16245508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229113/" ]
Instead of append, use: ``` $('p').html(donateAmount); ``` Append will put a new element in that `<p>` element everytime, rather than replacing the contents of it.
you must try `.clone()[0].outerHTML` before append to parent element
16,245,508
Here's my code so far, ``` $('label').click(function () { if ($('label input').is(':checked')) { $(this).addClass('checked'); $('.donate-now label').not(this).removeClass('checked'); var donateAmount = $(".checked input").val(); $('p').append(donateAmount); } }); ``` I'm checking to make sure the "donateAmount" variable is grabbing only one value, so to test, I'm having it append to the HTML, but it's showing up twice. Is that a function of append() and my variable only has one value, or is something wrong? Essentially I just want to make sure my variable has one value. Here it is in action, <http://jsfiddle.net/YB8UW/15/> Thank you
2013/04/26
[ "https://Stackoverflow.com/questions/16245508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229113/" ]
Try changing your selector to: ``` $('label input').click(function () { .... }); ``` <http://jsfiddle.net/YB8UW/18/> Your problem is that you are clicking the label AND radio when you click on the radio. Since you are clicking the child element, the event fires twice. If you focus the selector in a little more and only capture when the radio button is clicked, it will only fire once. Clicking the label fires a click on the input as well. Changing it from append to replace doesn't fix the issue, just masks it.
You should `.empty()` the container before you append it. :) <http://jsfiddle.net/droppedonjapan/YB8UW/29/> Why your event is being fired twice, I'm not 100% sure, but I think it may be the way the labels' click event goes off. I'm pretty sure it's delegated to your radio input, which then triggers another label click. I also changed your code a bit to reduce the nesting/ chaining. Let me know if that takes care of it for you!
16,245,508
Here's my code so far, ``` $('label').click(function () { if ($('label input').is(':checked')) { $(this).addClass('checked'); $('.donate-now label').not(this).removeClass('checked'); var donateAmount = $(".checked input").val(); $('p').append(donateAmount); } }); ``` I'm checking to make sure the "donateAmount" variable is grabbing only one value, so to test, I'm having it append to the HTML, but it's showing up twice. Is that a function of append() and my variable only has one value, or is something wrong? Essentially I just want to make sure my variable has one value. Here it is in action, <http://jsfiddle.net/YB8UW/15/> Thank you
2013/04/26
[ "https://Stackoverflow.com/questions/16245508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229113/" ]
Try changing your selector to: ``` $('label input').click(function () { .... }); ``` <http://jsfiddle.net/YB8UW/18/> Your problem is that you are clicking the label AND radio when you click on the radio. Since you are clicking the child element, the event fires twice. If you focus the selector in a little more and only capture when the radio button is clicked, it will only fire once. Clicking the label fires a click on the input as well. Changing it from append to replace doesn't fix the issue, just masks it.
you must try `.clone()[0].outerHTML` before append to parent element
28,492,530
How do I make it so that if a response has been sent back, then no more responses should be sent? **Actually, the issue is that if a response is sent back, then express (or nodejs) shouldn't continue running through the rest of the code.** I've tried doing next() but terminal throws the error of next() being undefined. res.end() doesn't seem to work either? routing.js: ``` router.post('/user/create', function(req, res, next) { user.createUser(req, res); }); ``` user.js createUser ``` user.prototype.createUser = function(req, res, next) { var body = req.body; checkAllInput(body, res, next); // do some more checks then finally create user } ``` user.js createUser ``` function checkAllInput(body, res, next) { checkError.checkUsername(body, res, next); checkError.checkPassword(body, res, next); ``` } checkError.js ``` userClass.prototype.checkUsername = function(username, res) { if (!username || username === "bob) { res.status(406).send("username"); } } userClass.prototype.checkPassword = function(password, res) { if (!password || password === "hello") { res.status(406).send("password"); } } ``` Call createUser in routing, which then calls checkAllInput which calls checkUsername but should stop if username sends a response back.
2015/02/13
[ "https://Stackoverflow.com/questions/28492530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1883614/" ]
Check the configuration file in /etc/apache2/sites-available/your\_site\_name.conf. If you have a Redirect "/" "<https://your_site_name.whatever>", it might be that the redirect is stripping the forward slash from the URL there. If this is the problem, just add a trailing forward slash to the redirect url. This is what happened to me. I could navigate to the index.php but not to the info.php file I had placed at the root when I set up the virtual host.
Scour your Apache configuration for Redirect\* or Rewrite\* rules; also all .htaccess files in the DocumentRoot. If that doesn't turn up anything, examine the PHP application you're using.
52,905,718
I'm trying to build a RecyclerView filled with a card view items. For each item I need 2 small images that I load from URL. Everything works fine only if I load sample image from Picasso website ([http://i.imgur.com/DvpvklR.png](https://i.imgur.com/DvpvklR.png)). Every other picture I try to load doesn't show up. Here's my code; inside my RecyclerViewAdapter, inside the onBindViewHolder() function I'm calling: ``` fun loadImageInBackground(item : Footballer, holder : ViewHolder){ doAsync { var loadImage = Picasso.get().load(item.footballerImageUrl) var loadFlagImage = Picasso.get().load(item.flagImageUrl) uiThread { loadImage.into(holder?.footballerImage) loadFlagImage.into(holder?.flagImage) } } } ``` I'm using Kotlin ANKO for "doAsync". Any ideas? Thanks in advance!
2018/10/20
[ "https://Stackoverflow.com/questions/52905718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10196657/" ]
For loops in R all run in the same scope, which means a variable defined in the loop will be shared by all iterations. This is an issue if you create a function in each loop iteration that accesses this variable, and assume that it'll be unique for each iteration. Here's a simple demo: ``` counter <- 0; funcs <- list() for (i in 1:3) { counter <- counter + 1 funcs[[i]] <- function() print(counter) } for (i in 1:3) { funcs[[i]]() # prints 3 3 3 } ``` In this Shiny app, the `observeEvent` handler accesses the local variable `add`, and doesn't get called until after the for loop is over, and `add` is at its final value. There are a few ways to get around this and create a unique scope for each loop iteration. My favorite is to use an `apply` function to replace the for loop. Then each `apply` iteration runs in its own function so local variables are unique each item. ``` library(shiny) # Define the UI ui <- fluidPage( #actionButton("adder", "Add"), tags$div(id = 'placeholder') ) # Define the server code server <- function(input, output) { rv <- reactiveValues(counter = 0) lapply(1:3, function(i) { isolate({ rv$counter <- rv$counter + 1 add <- sprintf("%03d",rv$counter) #prefix <- generateRandomString(1,20) filterId <- paste0('adder_', add) divId <- paste0('adder_div_', add) elementFilterId <- paste0('adder_object_', add) removeFilterId <- paste0('remover_', add) insertUI( selector = '#placeholder', ui = tags$div( id = divId, actionButton(removeFilterId, label = "Remove filter", style = "float: right;"), textInput(elementFilterId, label = paste0("Introduce text #",rv$counter), value = "") ) ) }) # Observer that removes a filter observeEvent(input[[removeFilterId]],{ removeUI(selector = paste0("#", divId)) }) }) } # Return a Shiny app object shinyApp(ui = ui, server = server, options = list(launch.browser = T)) ``` Note that I also removed the outer `observeEvent` since the server function runs on session initialization anyway.
I've found a workaround but I guess it should be done in a more efficient way. It looks like this problem is related to lazy evaluation, so only the last object created has its observeEvent working. Thus, I've decided to create, for each iteration of the loop new variables using eval: ``` library(shiny) # Define the UI ui <- fluidPage( #actionButton("adder", "Add"), tags$div(id = 'placeholder') ) # Define the server code server <- function(input, output, session) { rv <- reactiveValues() rv$counter <- 0 rv$init <- T observeEvent(rv$init, { if(!rv$init) return(NULL) for(i in 1:4) { rv$counter <- rv$counter + 1 add <- sprintf("%03d",rv$counter) coding <- paste0( "divId",add," <- paste0('adder_div_', add); elementFilterId",add," <- paste0('adder_object_', add); removeFilterId",add," <- paste0('remover_', add); insertUI( selector = '#placeholder', ui = tags$div( id = divId",add,", actionButton(inputId=removeFilterId",add,", label = \"Remove filter\", style = \"float: right;\"), textInput(inputId=elementFilterId",add,", label = paste0(\"Introduce text #\",rv$counter), value = '') ) ); # Observer that removes a filter observeEvent(input[[removeFilterId",add,"]],{ removeUI(selector = paste0(\"#\", divId",add,")) }) " ) eval(parse(text=coding)) } rv$init <- F }) } # Return a Shiny app object shinyApp(ui = ui, server = server, options = list(launch.browser = T)) ``` As it can be seen, each loop has new variables, so the lazy-evaluation problem is solved. What I would like to now is if it can be done in a more efficient way.
159,934
I have Yosemite. I am considering installing OS X server 4.0. According to [developer.apple.com](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/200-Adopting_a_Continuous_Integration_Workflow/adopt_continuous_integration.html#//apple_ref/doc/uid/TP40013292-CH3-SW1): > > You can, however, install OS X Server and enable Xcode Server on your > development Mac. > > > What exactly is OS X Server 4.0? Does installing require me to have a freshly formatted machine? In other words, does it overwrite Yosemite with a totally new OS (similar to Windows Server 2012 vs Windows 8)? Or, does it simply extend my Mac with new capabilities like a powerful program suite?
2014/12/08
[ "https://apple.stackexchange.com/questions/159934", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/14731/" ]
OS X Server 4 is an application. (.app) that is installed over the OS. It won't require you to format the entire drive to install it. It will just add the needed features to take advantage of the Server.app suite.
OS X Server is primarily an interface. OS X contains (almost - mail and databases are the main exceptions) all the software you will need, so if you want to set things up from the command line it won't make any difference. However, balance your time to work out the command line setup against the $20 Server.app costs. Server.app is rather picky about configuration file layouts - if you want to do your own adjustments I recommend you make a separate file and use an include directive. Behaviour ranges from no problem to service won't start to Server.app crashing (so you can't reset it)
332,242
![exhibit A](https://i.stack.imgur.com/3WORAl.jpg) ![exhibit B](https://i.stack.imgur.com/XKdtzl.jpg) This showed up while I was playing Pokémon Go and I walked into the cloud, but nothing happened. I walked away and came back, still nothing. I think it might be a glitch. Has anybody out there seen this before and know what it means?
2018/05/12
[ "https://gaming.stackexchange.com/questions/332242", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/211530/" ]
Yes, I’ve seen this before. It’s a bug. That is the animation of a gym under attack, despite there being no gym at the center of it. I’m not sure if you got this the same way as me, but I frequently get this visual bug when I check on one of my Pokémon that is currently defending a faraway gym (one that is not within range of me but that I can check on remotely) that is being attacked. The game (for some reason) moves the map to where the gym actually is while you view the gym screen and if it’s under attack, the fighting dustcloud will be rendered as well. Occasionally when I close out of the gym screen, the dustcloud continues to rage on. Opening and closing menus does nothing for me when this happens, I just close and restart the app, and everything is fixed.
It is a known bug. it happens because you feed or looked at your pokemon in a gym you are defending and someone attack it in the same time.
19,826
Is there a version of Snow White where her name is a longer description? [TVTropes says](https://tvtropes.org/Main/NameThatUnfoldsLikeLotusBlossom): > > Snow White. Her real name is "Lips Red as Blood, Hair Black as Ebony, Skin White as Snow" based on the wish her mother made. Everyone just calls her Snow White because it's easier. This is even carried over to the Disney version, but they replace "blood" with "the rose". > > > But at least [this version](https://www.gutenberg.org/files/11027/11027-h/11027-h.htm#littlesnowwhite) doesn't sound like it: > > a certain queen sat working at her window, the frame of which was made of fine black ebony; and, as she was looking out upon the snow, she pricked her finger, and three drops of blood fell upon it. Then she gazed thoughtfully down on the red drops which sprinkled the white snow and said, "Would that my little daughter may be as white as that snow, as red as the blood, and as black as the ebony window-frame!" And so the little girl grew up; her skin was a white as snow, her cheeks as rosy as blood, and her hair as black as ebony; and she was called Snow-White. > > > Although, that is just one [of seven](https://en.wikisource.org/wiki/Snow_White) different translations... But a quick search isolate to that site shows nothing good...
2021/10/24
[ "https://literature.stackexchange.com/questions/19826", "https://literature.stackexchange.com", "https://literature.stackexchange.com/users/566/" ]
Here’s the start of the story ‘Sneewittchen’ as given by the brothers Grimm: > > Es war einmal mitten im Winter und die Schneeflocken fielen wie Federn vom Himmel, da saß eine schöne Königin an einem Fenster, das hatte einen Rahmen von schwarzem Edenholz, und nähte. Und wie sie so nähte und nach dem Schnee aufblickte, stach sie sich mit der Nadel in den Finger, und es fielen drei Tropfen Blut in den Schnee. Und weil das Rothe in dem Weißen so schön aussah, so dachte sie: hätt ich doch ein Kind so weiß wie Schnee, so roth wie Blut und so schwarz wie dieser Rahmen. Und bald darauf bekam sie ein Töchterlein, so weiß wie Schnee, so roth wie Blut, und so schwarz wie Ebenholz, und darum ward es das **Sneewittchen genannt**. > > > Once upon a time, in the middle of winter, when feathery snowflakes fell from the sky, a beautiful queen sat and sewed at a window, which had a frame of black ebony. And as she sewed and looked up at the snow, she pricked her finger with the needle and three drops of blood fell onto the snow. And because the red looked so beautiful against the white, she thought: had I but a child as white as snow, as red as blood, and as black as this frame! Soon afterwards she had a daughter, as white as snow, as red as blood, and as black as ebony, and so she was **called Little-snow-white**. > > > Jacob and Wilhelm Grimm (1812). [*Kinder- und Haus-märchen*, p. 238](https://viewer.deutsche-digitale-bibliothek.de/index.php?id=1&L=1&tx_dlf%5Bid%5D=https%3A%2F%2Fapi.deutsche-digitale-bibliothek.de%2Fitems%2FWDQ2HY2DGRLI3TKCYFP6F5OPALSTRG4O%2Fsource%2Frecord&tx_dlf%5Bpage%5D=138&tx_dlf%5Bdouble%5D=0). Berlin: Realschulbuchhandlung. > > > This is the oldest printed version of the story, and here, it is clear that although the queen’s daughter has all three attributes from her mother’s wish, her name is just “Sneewittchen”. In the Disney animated film (1937) there is a scene with the following dialogue: > > *Queen*: Magic Mirror on the wall, who is the fairest one of all? > > > *Magic Mirror*: Famed is thy beauty, Majesty. But hold, a lovely maid I see. Rags cannot hide her gentle grace. Alas, she is more fair than thee. > > > *Queen*: Alas for her! Reveal her name! > > > *Magic Mirror*: **Lips red as the rose. Hair black as ebony. Skin white as snow.** > > > *Queen*: Snow White! > > > You can see how someone might interpret the highlighted line as the mirror revealing Snow-white’s real name. But I think a more natural interpretation is that the mirror is giving the queen a (not very difficult) riddle, in the usual manner of oracles. Another version of the story that that uses all three of Snow-white’s attributes as a kind of epithet, is a 1982 retelling by [Nancy Garden](https://en.wikipedia.org/wiki/Nancy_Garden): > > “Nothing can save you now, my beauty,” chortled the queen, “for I have used my strongest poison this time, and since you have swallowed it, you will never rise again. So, **Skin-White-as-Snow, Lips-Red-as-Blood, Hair-Black-as-Ebony**, what good is your beauty to you now? This time no one will ever be able to wake you up again.” > > > Nancy Garden (1982). [*Favourite Tales from Grimm*, p. 15](https://archive.org/details/favoritetalesfro00maye/page/14/mode/2up). New York: Four Winds. > > > Again, you can see how a reader of this passage in Garden’s version might conclude that “Skin-White-as-Snow, Lips-Red-as-Blood, Hair-Black-as-Ebony” is Snow-white’s real or unabbreviated name. This is an appealing kind of fairy-tale idea! But elsewhere in Garden’s version she is just called “Snow White”, so it makes as much, or more, sense to take the queen’s phrase here to be a sarcastic epithet that she made up on the spot.
There are uses of the name "Snow White" in longer names, such as the Italian [Snow-White-Fire-Red](https://www.surlalunefairytales.com/book.php?id=110&tale=3437), or the Norwegian Snow-white and Rosy-red (in [The Twelve Wild Ducks](https://www.surlalunefairytales.com/s-z/six-swans/stories/twelvewilducks.html)). However, the first is a variant on the girl helps the hero flee, with elements of the maiden in the tower (like Rapunzel) and the second is the brothers as birds; they are not Snow White variants. Indeed, a look at the [variants](https://www.surlalunefairytales.com/s-z/snow-white-seven-dwarfs/snow-white-seven-dwarfs-related.html) reveals none where it's longer than Snow-White but many where it's something unrelated: Myrsina, or Nourie Hadig, or Gold-Tree. I think that's just someone slipping in a claim made about it and perhaps not even realizing it.
11,112,515
I am messing around with Session in my webapp at the moment and I noticed that whenever I restart the development server (the built-in server that came with Django), the session does not reset itself. It carries over eventhough I have restarted the server over and over again. Where can I set it so that whenever I reset/restart the development server, the sessions are flushed/cleaned out?
2012/06/20
[ "https://Stackoverflow.com/questions/11112515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599378/" ]
Couldn't find a solution for this. Redownloaded and regenerated the font numerous times on different computers, clearing cache each time viewed and still didn't work. Other fonts work fine, so my conclusion is the eot generators don't like the font.
Try using the [font-face](http://www.fontsquirrel.com/fontface/generator) generator.
11,112,515
I am messing around with Session in my webapp at the moment and I noticed that whenever I restart the development server (the built-in server that came with Django), the session does not reset itself. It carries over eventhough I have restarted the server over and over again. Where can I set it so that whenever I reset/restart the development server, the sessions are flushed/cleaned out?
2012/06/20
[ "https://Stackoverflow.com/questions/11112515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599378/" ]
Couldn't find a solution for this. Redownloaded and regenerated the font numerous times on different computers, clearing cache each time viewed and still didn't work. Other fonts work fine, so my conclusion is the eot generators don't like the font.
Try this solution <http://fontface.codeandmore.com/blog/ie-7-8-error-with-eot-css3111/> as it worked many times for our users.
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can use a list comprehension: ``` cleaned = [x for x in your_list if x] ``` Although I would use regex to extract the words: ``` >>> import re >>> sentence = 'This is some cool sentence with, spaces' >>> re.findall(r'(\w+)', sentence) ['This', 'is', 'some', 'cool', 'sentence', 'with', 'spaces'] ```
I'll give you the answer to the question you *should* have asked -- how to avoid the empty string altogether. I assume you do *something* like this to get your list: ``` >>> "He is so .... cool!".replace(".", "").split(" ") ['He', 'is', 'so', '', 'cool!'] ``` The point is that you use [`.split(" ")`](http://docs.python.org/2/library/stdtypes.html#str.split) to split on space characters. However, if you leave out the argument to `split`, this happens: ``` >>> "He is so .... cool!".replace(".", "").split() ['He', 'is', 'so', 'cool!'] ``` Quoth the docs: > > If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. > > > So you really don't need to bother with the other answers (except Blender's, which is a totally different approach), because split can do the job for you!
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can use a list comprehension: ``` cleaned = [x for x in your_list if x] ``` Although I would use regex to extract the words: ``` >>> import re >>> sentence = 'This is some cool sentence with, spaces' >>> re.findall(r'(\w+)', sentence) ['This', 'is', 'some', 'cool', 'sentence', 'with', 'spaces'] ```
You can filter out empty strings very easily using a list comprehension: ``` x = ["He", "is", "so", "", "cool"] x = [str for str in x if str] >>> ['He', 'is', 'so', 'cool'] ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can filter it like this ``` orig = ["He", "is", "so", "", "cool"] result = [x for x in orig if x] ``` Or you can use `filter`. In python 3 `filter` returns a generator, thus `list()` turns it into a list. This works also in python 2.7 ``` result = list(filter(None, orig)) ```
You can use a list comprehension: ``` cleaned = [x for x in your_list if x] ``` Although I would use regex to extract the words: ``` >>> import re >>> sentence = 'This is some cool sentence with, spaces' >>> re.findall(r'(\w+)', sentence) ['This', 'is', 'some', 'cool', 'sentence', 'with', 'spaces'] ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can use a list comprehension: ``` cleaned = [x for x in your_list if x] ``` Although I would use regex to extract the words: ``` >>> import re >>> sentence = 'This is some cool sentence with, spaces' >>> re.findall(r'(\w+)', sentence) ['This', 'is', 'some', 'cool', 'sentence', 'with', 'spaces'] ```
``` lst = ["He", "is", "so", "", "cool"] lst = list(filter(str.strip, lst)) ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can use [`filter`](http://docs.python.org/2/library/functions.html#filter), with `None` as the key function, which filters out all elements which are `False`ish (including empty strings) ``` >>> lst = ["He", "is", "so", "", "cool"] >>> filter(None, lst) ['He', 'is', 'so', 'cool'] ``` Note however, that `filter` returns a list in Python 2, but a generator in Python 3. You will need to convert it into a list in Python 3, or use the list comprehension solution. `False`ish values include: ``` False None 0 '' [] () # and all other empty containers ```
You can filter it like this ``` orig = ["He", "is", "so", "", "cool"] result = [x for x in orig if x] ``` Or you can use `filter`. In python 3 `filter` returns a generator, thus `list()` turns it into a list. This works also in python 2.7 ``` result = list(filter(None, orig)) ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can filter it like this ``` orig = ["He", "is", "so", "", "cool"] result = [x for x in orig if x] ``` Or you can use `filter`. In python 3 `filter` returns a generator, thus `list()` turns it into a list. This works also in python 2.7 ``` result = list(filter(None, orig)) ```
``` >>> from string import punctuation >>> text = "He is so .... cool!" >>> [w.strip(punctuation) for w in text.split() if w.strip(punctuation)] ['He', 'is', 'so', 'cool'] ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
You can filter it like this ``` orig = ["He", "is", "so", "", "cool"] result = [x for x in orig if x] ``` Or you can use `filter`. In python 3 `filter` returns a generator, thus `list()` turns it into a list. This works also in python 2.7 ``` result = list(filter(None, orig)) ```
You can filter out empty strings very easily using a list comprehension: ``` x = ["He", "is", "so", "", "cool"] x = [str for str in x if str] >>> ['He', 'is', 'so', 'cool'] ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
``` lst = ["He", "is", "so", "", "cool"] lst = list(filter(str.strip, lst)) ```
You can do this with a `filter`. ``` a = ["He", "is", "so", "", "cool"] filter(lambda s: len(s) > 0, a) ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
``` >>> from string import punctuation >>> text = "He is so .... cool!" >>> [w.strip(punctuation) for w in text.split() if w.strip(punctuation)] ['He', 'is', 'so', 'cool'] ```
``` lst = ["He", "is", "so", "", "cool"] lst = list(filter(str.strip, lst)) ```
16,099,694
For example I have a sentence ``` "He is so .... cool!" ``` Then I remove all the punctuation and make it in a list. ``` ["He", "is", "so", "", "cool"] ``` How do I remove or ignore the empty string?
2013/04/19
[ "https://Stackoverflow.com/questions/16099694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2289046/" ]
Python 3 returns an `iterator` from `filter`, so should be wrapped in a call to list() ``` str_list = list(filter(None, str_list)) # fastest ```
``` lst = ["He", "is", "so", "", "cool"] lst = list(filter(str.strip, lst)) ```
10,719,654
Can anybody suggest how to make the swapped boxes change background color on click when using the below plugin? <http://www.vertstudios.com/blog/swap-jquery-plugin/> (see demo) I'm not sure how to link to plugins in JSFiddle so can't demonstrate unfortunately. The methods animate the position of all boxes affecting only those where the position has changed. I'm trying to add a method that animates the background color similarly but without success. I don't think this is possible without customising the plugin but I could be wrong. --- Update: Thanks Johan. I should have said that I actually need the background color to animate back to default after the swap. I tried your solution already with the below amendment. As you can see, it behaves inconsistently. I think the way to do this properly is to customise the fakeFloat method. ``` $("#swapTrigger").click(function() { var index1 = $('input:radio[name=index1]:checked').val(); var index2 = $('input:radio[name=index2]:checked').val(); boxes = $(boxes).swap(index1,index2); var $box1 = $('.box').eq(index1); var $box2 = $('.box').eq(index2); var randomHex = '#fc0'; $box1.animate({ backgroundColor: "#fc0" }, 300); $box2.animate({ backgroundColor: "#fc0" }, 300); $(boxes).fakeFloat({margin: 10, offset: 20, speed: 300}).each(function() { $box1.animate({ backgroundColor: "#fff" }, 300); $box2.animate({ backgroundColor: "#fff" }, 300); $(this).html($(this).getIndexOf(boxes)); }); ```
2012/05/23
[ "https://Stackoverflow.com/questions/10719654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1405195/" ]
> > They want something as compact as the JS stated above > > > Who's "they"? Do "they" have any understanding that Objective-C is a compiled language and the "compactness" of the source code is largely irrelevant? Anyway, rant over. You can make a C array of CGPoints like this: ``` CGPoint myArray[] = {{0.0, 14.0}, {10.0, 32.0}, {24.0, 16.0}}; ``` This is a standard C array initialiser. You get the number of elements like this: ``` int nElements = sizeof myArray / sizeof(CGPoint); ```
If you need to manage variable-length arrays of vertices, C++ provides `std::vector<CGPoint>`.
216,295
Suppose I have the following list: ``` l = {"A", "A", "A", "E", "D", "D", "D", "C", "B", "E", "E", "E", "D", "B", "A", "D", "B", "E", "C", "A", "D", "A", "A", "A", "A", "C", "C", "C", "D", "D", "E"} ``` I want to count how many two letters I have namely how many AA, AB,... I have in list `l`. I know this is equivalent of counting the tuples on list `l`, the tuples are, ``` Tuples[l // DeleteDuplicates // Sort, 2] ``` but I am not sure how to count these on `l`. As an example, there are 5 counts of AA on `l`. I wonder what is the solution for this?
2020/03/15
[ "https://mathematica.stackexchange.com/questions/216295", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/2871/" ]
How about ``` Partition[l, 2, 1] // Counts (* <|{"A", "A"} -> 5, {"A", "E"} -> 1, {"E", "D"} -> 2, {"D", "D"} -> 3, {"D", "C"} -> 1, {"C", "B"} -> 1, {"B", "E"} -> 2, {"E", "E"} -> 2, {"D", "B"} -> 2, {"B", "A"} -> 1, {"A", "D"} -> 2, {"E", "C"} -> 1, {"C", "A"} -> 1, {"D", "A"} -> 1, {"A", "C"} -> 1, {"C", "C"} -> 2, {"C", "D"} -> 1, {"D", "E"} -> 1|> *) ```
You can also use `SequenceCases` + `Counts`: ``` Counts[SequenceCases[l, {_, _}, Overlaps -> True]] ``` > > <|{"A", "A"} -> 5, {"A", "E"} -> 1, {"E", "D"} -> 2, {"D", "D"} -> > 3, {"D", "C"} -> 1, {"C", "B"} -> 1, {"B", "E"} -> 2, {"E", "E"} -> > 2, {"D", "B"} -> 2, {"B", "A"} -> 1, {"A", "D"} -> 2, {"E", "C"} -> > 1, {"C", "A"} -> 1, {"D", "A"} -> 1, {"A", "C"} -> 1, {"C", "C"} -> > 2, {"C", "D"} -> 1, {"D", "E"} -> 1|> > > >
42,709,785
Below is my code to fetch a list of stores and then it's products Now the issue is, the API that returns me product list for a store has a rate limiter in place, i.e. 10req/sec. So If get more than 10 stores and I hit for products, the API starts giving me 503 and in the response I get undefined values along with actual values. Is there a way where I can set timeout, i.e. delay the calling for `getProductList` in my case? Below is the code ``` const shops = response.data return Promise.all( shops.map((shop) => { const id = shop.shop_id const shopobj = { id, name: shop.shop_name, } return favAPI.checkFavourite(uid, id) .then((favData) => { shopobj.is_fave_shop = favData // Fetch the products of shop return getProductList(id, uid) .then((responsedata) => { shopobj.products = responsedata.data.products.map(product => ({ id: product.id, name: product.name, })) return shopobj }) .catch(() => { }) }) .catch(err => console.error(err)) })) .then(responses => responses) .catch(err => console.log(err)) ``` Something I can do like this ``` return setTimeout(() => getProductList(id, uid) .then((responsedata) => { shopobj.products = responsedata.data.products.map(product => ({ id: product.id, name: product.name, price: product.price, image_url: product.image_url, is_wishlist: userWishListProd.indexOf(product.id) > -1, url: product.url, shop_name: product.shop.name, labels: product.labels, badges: product.badges, })) return shopobj }) .catch((err) => { console.error(err.name, err.statusCode, err.message) }), 30) ```
2017/03/10
[ "https://Stackoverflow.com/questions/42709785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1258489/" ]
First try using the upgrade command in pip and see if that fixes the version problem ``` pip3 install --upgrade pip ``` otherwise I would recommend uninstalling and performing a fresh install. Use the following commands to setup python ``` sudo apt-get update sudo apt-get -y upgrade sudo apt-get install python3.6 python3-pip idle3 pip3 install numpy pip3 install spyder ``` pip3 is the command for using python installer for python3. to use idle3, just type in into the command window ``` idle3 ``` I suggest to install spyder using pip3 as spyder is a more advanced idle which can track variables and code writing. makes it a bit easier in locating errors and such.
Many linux distribution provide tkinter, IDLE (which uses tkinter), and turtle (which also uses tkinter) as separate distribution. Searching SO for `[tkinter] install tkinter on ubuntu` displays previous questions with answers. ``` sudo apt-get install python3-tk ``` may be what you need but details may have change since previous answers.
9,460,030
I'm using jQuery Cycle for a few slides, with content below it. jQuery Cycle sets the parent to relative and the child slides to absolute, so the content that should be below it is covered. Typically, I would give the parent container a height to solve my problem. Since the layout is responsive, the height can change. Is there a simple solution out there for this? EDIT: Here's what wound up doing it for me: ``` $(window).load(function(){ var rotate_height = $('#rotate div img').height(); $('#rotate').css('height', rotate_height); $(window).resize(function() { if($(window).width() >= 960){ rotate_height = 290; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 768 && $(window).width() <= 959) { rotate_height = 230; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 480 && $(window).width() <= 767) { rotate_height = 210; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() <= 479) { rotate_height = 150; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } }); $('#rotate').cycle({ fx: 'fade', fit: 1, containerResize: 0, slideResize: 0, height: rotate_height }); }); ``` cycle('next') forces the slide to the next after a visitor resizes their monitor. Not ideal, but the images wouldn't scale back up, only after a slide change.
2012/02/27
[ "https://Stackoverflow.com/questions/9460030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882428/" ]
You can use [`ready`](http://api.jquery.com/ready/) and [`resize`](http://api.jquery.com/resize/) events to trigger a function which will set the [`height`](http://api.jquery.com/height/) appropriately based on the [`width`](http://api.jquery.com/width/) of the `window`. As the page 'responds' to the current window width, your jQuery method will appropriately size the height of the slideshow's parent.
i think you can do this: ``` $slideshow.cycle({ containerResize: false, slideResize: false, fit: 1 }); ``` basically, when window resizes, the slide container is forced to resized. (not sure if you should set all to true or false, please give it a try.)
9,460,030
I'm using jQuery Cycle for a few slides, with content below it. jQuery Cycle sets the parent to relative and the child slides to absolute, so the content that should be below it is covered. Typically, I would give the parent container a height to solve my problem. Since the layout is responsive, the height can change. Is there a simple solution out there for this? EDIT: Here's what wound up doing it for me: ``` $(window).load(function(){ var rotate_height = $('#rotate div img').height(); $('#rotate').css('height', rotate_height); $(window).resize(function() { if($(window).width() >= 960){ rotate_height = 290; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 768 && $(window).width() <= 959) { rotate_height = 230; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 480 && $(window).width() <= 767) { rotate_height = 210; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() <= 479) { rotate_height = 150; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } }); $('#rotate').cycle({ fx: 'fade', fit: 1, containerResize: 0, slideResize: 0, height: rotate_height }); }); ``` cycle('next') forces the slide to the next after a visitor resizes their monitor. Not ideal, but the images wouldn't scale back up, only after a slide change.
2012/02/27
[ "https://Stackoverflow.com/questions/9460030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882428/" ]
You can use [`ready`](http://api.jquery.com/ready/) and [`resize`](http://api.jquery.com/resize/) events to trigger a function which will set the [`height`](http://api.jquery.com/height/) appropriately based on the [`width`](http://api.jquery.com/width/) of the `window`. As the page 'responds' to the current window width, your jQuery method will appropriately size the height of the slideshow's parent.
I had the same problem, solved it like this: HTML: ``` <div class="hp_slider"> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/17dd0cc96316523cbba09777c8e512769078b0bc.png" /></a> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/39fbcef502bd01b7f13980a81b73f6e6cb5491b6.jpg" /></a> </div> ``` CSS: ``` .hp_slider {margin-bottom:49%; width:100%; height:auto;} .hp_slider img {width:100%; height:auto;} ``` jQuery: ``` $(document).ready(function() { $('.hp_slider').cycle({ fx: 'fade', containerResize: false, slideResize: false, fit: 1 }); }); ``` It's a little dirty, but the margin-bottom as a percentage pushes the text down from behind the slider and keeps it in place at different sizes so it's still responsive.
9,460,030
I'm using jQuery Cycle for a few slides, with content below it. jQuery Cycle sets the parent to relative and the child slides to absolute, so the content that should be below it is covered. Typically, I would give the parent container a height to solve my problem. Since the layout is responsive, the height can change. Is there a simple solution out there for this? EDIT: Here's what wound up doing it for me: ``` $(window).load(function(){ var rotate_height = $('#rotate div img').height(); $('#rotate').css('height', rotate_height); $(window).resize(function() { if($(window).width() >= 960){ rotate_height = 290; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 768 && $(window).width() <= 959) { rotate_height = 230; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 480 && $(window).width() <= 767) { rotate_height = 210; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() <= 479) { rotate_height = 150; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } }); $('#rotate').cycle({ fx: 'fade', fit: 1, containerResize: 0, slideResize: 0, height: rotate_height }); }); ``` cycle('next') forces the slide to the next after a visitor resizes their monitor. Not ideal, but the images wouldn't scale back up, only after a slide change.
2012/02/27
[ "https://Stackoverflow.com/questions/9460030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882428/" ]
I had the same problem, solved it like this: HTML: ``` <div class="hp_slider"> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/17dd0cc96316523cbba09777c8e512769078b0bc.png" /></a> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/39fbcef502bd01b7f13980a81b73f6e6cb5491b6.jpg" /></a> </div> ``` CSS: ``` .hp_slider {margin-bottom:49%; width:100%; height:auto;} .hp_slider img {width:100%; height:auto;} ``` jQuery: ``` $(document).ready(function() { $('.hp_slider').cycle({ fx: 'fade', containerResize: false, slideResize: false, fit: 1 }); }); ``` It's a little dirty, but the margin-bottom as a percentage pushes the text down from behind the slider and keeps it in place at different sizes so it's still responsive.
i think you can do this: ``` $slideshow.cycle({ containerResize: false, slideResize: false, fit: 1 }); ``` basically, when window resizes, the slide container is forced to resized. (not sure if you should set all to true or false, please give it a try.)
9,460,030
I'm using jQuery Cycle for a few slides, with content below it. jQuery Cycle sets the parent to relative and the child slides to absolute, so the content that should be below it is covered. Typically, I would give the parent container a height to solve my problem. Since the layout is responsive, the height can change. Is there a simple solution out there for this? EDIT: Here's what wound up doing it for me: ``` $(window).load(function(){ var rotate_height = $('#rotate div img').height(); $('#rotate').css('height', rotate_height); $(window).resize(function() { if($(window).width() >= 960){ rotate_height = 290; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 768 && $(window).width() <= 959) { rotate_height = 230; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 480 && $(window).width() <= 767) { rotate_height = 210; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() <= 479) { rotate_height = 150; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } }); $('#rotate').cycle({ fx: 'fade', fit: 1, containerResize: 0, slideResize: 0, height: rotate_height }); }); ``` cycle('next') forces the slide to the next after a visitor resizes their monitor. Not ideal, but the images wouldn't scale back up, only after a slide change.
2012/02/27
[ "https://Stackoverflow.com/questions/9460030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882428/" ]
This is my solution: ``` $(window).resize(function(){ $('.cycle-container').each(function(){ $(this).height($(this).find('> *:first').outerHeight()); }) }); ```
i think you can do this: ``` $slideshow.cycle({ containerResize: false, slideResize: false, fit: 1 }); ``` basically, when window resizes, the slide container is forced to resized. (not sure if you should set all to true or false, please give it a try.)
9,460,030
I'm using jQuery Cycle for a few slides, with content below it. jQuery Cycle sets the parent to relative and the child slides to absolute, so the content that should be below it is covered. Typically, I would give the parent container a height to solve my problem. Since the layout is responsive, the height can change. Is there a simple solution out there for this? EDIT: Here's what wound up doing it for me: ``` $(window).load(function(){ var rotate_height = $('#rotate div img').height(); $('#rotate').css('height', rotate_height); $(window).resize(function() { if($(window).width() >= 960){ rotate_height = 290; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 768 && $(window).width() <= 959) { rotate_height = 230; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() >= 480 && $(window).width() <= 767) { rotate_height = 210; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } else if ($(window).width() <= 479) { rotate_height = 150; $('#rotate').css('height', rotate_height); $('#rotate').cycle('next'); } }); $('#rotate').cycle({ fx: 'fade', fit: 1, containerResize: 0, slideResize: 0, height: rotate_height }); }); ``` cycle('next') forces the slide to the next after a visitor resizes their monitor. Not ideal, but the images wouldn't scale back up, only after a slide change.
2012/02/27
[ "https://Stackoverflow.com/questions/9460030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882428/" ]
This is my solution: ``` $(window).resize(function(){ $('.cycle-container').each(function(){ $(this).height($(this).find('> *:first').outerHeight()); }) }); ```
I had the same problem, solved it like this: HTML: ``` <div class="hp_slider"> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/17dd0cc96316523cbba09777c8e512769078b0bc.png" /></a> <a href="#"><img class="slide" alt="" width="940" height="420" src="/assets/images/cache/39fbcef502bd01b7f13980a81b73f6e6cb5491b6.jpg" /></a> </div> ``` CSS: ``` .hp_slider {margin-bottom:49%; width:100%; height:auto;} .hp_slider img {width:100%; height:auto;} ``` jQuery: ``` $(document).ready(function() { $('.hp_slider').cycle({ fx: 'fade', containerResize: false, slideResize: false, fit: 1 }); }); ``` It's a little dirty, but the margin-bottom as a percentage pushes the text down from behind the slider and keeps it in place at different sizes so it's still responsive.
22,149,795
Does anyone know of a way to make Amazon's Elastic Load Balancers timeout if an HTTP response has not been received from upstream in a set timeframe? Occasionally Amazon's Elastic Beanstalk will fail an update and any requests to the specified resource (running Nginx + Node if tht's any use) will hang any request pages whilst the resource attempts to load. I'd like to keep the request timeout under 2s, and if the upstream server has no response by then, to automatically fail over to a default 503 response. Is this possible with ELB? Cheers
2014/03/03
[ "https://Stackoverflow.com/questions/22149795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1764563/" ]
Using the first HTML sample: ``` grep '<strong>First ascent:</strong>' | sed 's/.*by \([^>]*\)<.*/\1/' ``` Output: ``` Sir Edmund Hillary and Tenzing Norgay Achille Compagnoni and Lino Lacedelli George Band and Joe Brown Kurt Diemberger, Peter Diener, Nawang Dorje, Nima Dorje, Ernst Forrer and Albin Schelbert Hermann Buhl Maurice Herzog and Louis Lachenal Andrew Kauffman and Peter Schoening Hermann Buhl, Kurt Diemberger, Marcus Schmuck and Fritz Wintersteller ``` It finds all lines with the 'First ascent' label and grabs everything between `by` and the `<br />` tag. Edit: The original answer doesn't filter by the name of the mountain. In addition, the `<strong>First ascent:</strong>` is too specific for the page (sometimes there is a space after the `:`). The following should work. ``` grep -i "$1" -A3 | grep 'First ascent:' | sed 's/.*by \([^>]*\)<.*/\1/' ``` Explanation: `grep -i "$1" -A3` selects the line with the mountain. `-i` makes the search case insensitive. The `-A3` selects the 3 lines following the matched line, which gets the line with the list of climbers. The quotes around `"$1"` are for mountains with names that have spaces.
Firstly, go with the first page in your question. Here's a Java scraper for the "curl" downloaded file: ``` import java.util.Scanner; import java.io.*; public class PageInfo { public static void main(String[] args) { Scanner scan = new Scanner(new File(args[0])); //file you downloaded PrintWriter output = new PrintWriter("climbers.txt"); while (scan.hasNextLine()) { String s = scan.nextLine(); if (s.contains("wp-caption-text\">") { s = s.split("wp-caption-text\">")[1]; if (s.length() > 1) output.println(s.split("</p>")[0]); } else if (s.contains("First ascent:")) { s = s.split("by ")[1]; output.println(s.split("<br")[0]); } } scan.close(); output.close(); } } ```
22,149,795
Does anyone know of a way to make Amazon's Elastic Load Balancers timeout if an HTTP response has not been received from upstream in a set timeframe? Occasionally Amazon's Elastic Beanstalk will fail an update and any requests to the specified resource (running Nginx + Node if tht's any use) will hang any request pages whilst the resource attempts to load. I'd like to keep the request timeout under 2s, and if the upstream server has no response by then, to automatically fail over to a default 503 response. Is this possible with ELB? Cheers
2014/03/03
[ "https://Stackoverflow.com/questions/22149795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1764563/" ]
You can use my [Xidel](http://videlibri.sourceforge.net/xidel.html) which does pattern matching on the html tree: ``` xidel http://www.alpineascents.com/8000m-peaks.asp -e "<tr><strong>Everest</strong><td/>{3}<td>{.}</td></tr>" ``` Just 109 characters... (Replace Everest with $1 if it is inside a script with that as parameter) Or for the other site: ``` xidel http://www.valandre.com/blog/2011/06/21/the-14-peaks-over-8000-meters/ -e "<p class=\"wp-caption-text\">Everest</p><strong>First ascent:</strong>{text()}" ```
Firstly, go with the first page in your question. Here's a Java scraper for the "curl" downloaded file: ``` import java.util.Scanner; import java.io.*; public class PageInfo { public static void main(String[] args) { Scanner scan = new Scanner(new File(args[0])); //file you downloaded PrintWriter output = new PrintWriter("climbers.txt"); while (scan.hasNextLine()) { String s = scan.nextLine(); if (s.contains("wp-caption-text\">") { s = s.split("wp-caption-text\">")[1]; if (s.length() > 1) output.println(s.split("</p>")[0]); } else if (s.contains("First ascent:")) { s = s.split("by ")[1]; output.println(s.split("<br")[0]); } } scan.close(); output.close(); } } ```
22,149,795
Does anyone know of a way to make Amazon's Elastic Load Balancers timeout if an HTTP response has not been received from upstream in a set timeframe? Occasionally Amazon's Elastic Beanstalk will fail an update and any requests to the specified resource (running Nginx + Node if tht's any use) will hang any request pages whilst the resource attempts to load. I'd like to keep the request timeout under 2s, and if the upstream server has no response by then, to automatically fail over to a default 503 response. Is this possible with ELB? Cheers
2014/03/03
[ "https://Stackoverflow.com/questions/22149795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1764563/" ]
Using the first HTML sample: ``` grep '<strong>First ascent:</strong>' | sed 's/.*by \([^>]*\)<.*/\1/' ``` Output: ``` Sir Edmund Hillary and Tenzing Norgay Achille Compagnoni and Lino Lacedelli George Band and Joe Brown Kurt Diemberger, Peter Diener, Nawang Dorje, Nima Dorje, Ernst Forrer and Albin Schelbert Hermann Buhl Maurice Herzog and Louis Lachenal Andrew Kauffman and Peter Schoening Hermann Buhl, Kurt Diemberger, Marcus Schmuck and Fritz Wintersteller ``` It finds all lines with the 'First ascent' label and grabs everything between `by` and the `<br />` tag. Edit: The original answer doesn't filter by the name of the mountain. In addition, the `<strong>First ascent:</strong>` is too specific for the page (sometimes there is a space after the `:`). The following should work. ``` grep -i "$1" -A3 | grep 'First ascent:' | sed 's/.*by \([^>]*\)<.*/\1/' ``` Explanation: `grep -i "$1" -A3` selects the line with the mountain. `-i` makes the search case insensitive. The `-A3` selects the 3 lines following the matched line, which gets the line with the list of climbers. The quotes around `"$1"` are for mountains with names that have spaces.
You can use my [Xidel](http://videlibri.sourceforge.net/xidel.html) which does pattern matching on the html tree: ``` xidel http://www.alpineascents.com/8000m-peaks.asp -e "<tr><strong>Everest</strong><td/>{3}<td>{.}</td></tr>" ``` Just 109 characters... (Replace Everest with $1 if it is inside a script with that as parameter) Or for the other site: ``` xidel http://www.valandre.com/blog/2011/06/21/the-14-peaks-over-8000-meters/ -e "<p class=\"wp-caption-text\">Everest</p><strong>First ascent:</strong>{text()}" ```
55,302
I think the question title says it all: Given a distribution board in the house (220 VAC), is it enough to shut off only the room's fuses, or must one shut off the main switch for the board before safely touching wires? Does the answer depend in any way on the fuse type?
2014/12/14
[ "https://diy.stackexchange.com/questions/55302", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/7302/" ]
And here is why you check it before hand, even though you have turned off that room. People get into Junction boxes and re-wire - joining two separate circuits into one - in that case one circuit in the house can be fed from two breakers (as long as they are on the same phase). Always check with testor - and NOT JUST a proximity induction testor - but an actual touch the wires testor. OK. Be safe.
Yes. Once you shut off the room fuse, no electricity will be going to that room. However it is important to test all connections before working on them so you are positive that they are not powered.
55,302
I think the question title says it all: Given a distribution board in the house (220 VAC), is it enough to shut off only the room's fuses, or must one shut off the main switch for the board before safely touching wires? Does the answer depend in any way on the fuse type?
2014/12/14
[ "https://diy.stackexchange.com/questions/55302", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/7302/" ]
You say "that room". Circuits are not nearly always designated to one room or area. Many, many times a room will have some devices on one circuit while others on another circuit. It is pretty rare that rooms are strictly wired so that one circuit distinctly feeds one room. Also, panel directories are not always extremely accurate. So something that says the breaker is for one room might also have other things one it. Again, a tester is the ONLY way to be sure what you are working on is dead. IMO you should not even pick up a tool or open a box until you are in possession of a decent tester.
Yes. Once you shut off the room fuse, no electricity will be going to that room. However it is important to test all connections before working on them so you are positive that they are not powered.
55,302
I think the question title says it all: Given a distribution board in the house (220 VAC), is it enough to shut off only the room's fuses, or must one shut off the main switch for the board before safely touching wires? Does the answer depend in any way on the fuse type?
2014/12/14
[ "https://diy.stackexchange.com/questions/55302", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/7302/" ]
And here is why you check it before hand, even though you have turned off that room. People get into Junction boxes and re-wire - joining two separate circuits into one - in that case one circuit in the house can be fed from two breakers (as long as they are on the same phase). Always check with testor - and NOT JUST a proximity induction testor - but an actual touch the wires testor. OK. Be safe.
You say "that room". Circuits are not nearly always designated to one room or area. Many, many times a room will have some devices on one circuit while others on another circuit. It is pretty rare that rooms are strictly wired so that one circuit distinctly feeds one room. Also, panel directories are not always extremely accurate. So something that says the breaker is for one room might also have other things one it. Again, a tester is the ONLY way to be sure what you are working on is dead. IMO you should not even pick up a tool or open a box until you are in possession of a decent tester.
7,305,997
You can see my fiddle of what i'm doing here: [fiddle](http://jsfiddle.net/tigreton/JGNmK/) In vote\_up.php I insert the vote into MySQL and replaces the link with 2 messages: "successful" or "error" But the problem now is, I don't need to change the link, I must update the 2 boxes showing a new question without reloading the page. This is before I vote: ![Before voting up](https://i.stack.imgur.com/9zus5.jpg) And after I vote:![After voting up](https://i.stack.imgur.com/Db2iu.jpg) What i need when they click up(Aceptar) is it changes the question instead of showing that I voted. Thanks.
2011/09/05
[ "https://Stackoverflow.com/questions/7305997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/873444/" ]
You need a backend that gives the information back in a format (like JSON or XML) and then parse it into the page. When they click the vote link there happens a ajax request to vote. And the response of this ajax request is your new question. Then you parse the request, replace your old question with the new one. And replace your ajax request URL with the new ID of the new question. (so you can vote always again)
My problem resolved in other post: ``` $(document).ready(function() { $(document).delegate('.vote, .vote1', 'click', function() { ... ```
33,592,169
I'm currently reading K&R's "The C Programming Language" book. In "Structures" chapter, under the subtopic of "Table Lookup" (Page 144) I found this hash generating function ``` #define HASHSIZE 101 struct nlist { struct nlist *next; char *name; char *defn; } static struct nlist *hashtab[HASHSIZE]; unsigned hash(char *s) { unsigned hashval; for (hashval = 0; *s != '\0'; s++) hashval = *s + 31 * hashval; return hashval % HASHSIZE; } ``` What I don't understand is what this function actually does. I think it generates an unique address (as an index on hashtab) for the given string (char \*s). But I think two different strings can be given the same index since (hashval % HASHSIZE) is the given address (203 % 101 = 405 % 101 = 1). And why is HASHSIZE 101 and hashval multiplied by 31? Why not 100 or 32?
2015/11/08
[ "https://Stackoverflow.com/questions/33592169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463878/" ]
> > What I don't understand is what this function actually do? > > > It basically hashes the string pointed to by the `char *s` pointer, until it encounters the end of the string, which is marked by the null character `'\0'`. In other words, it calculates (or *maps*) a given input string to an integer value. You can also see that it does this by going through each character in the string (i.e. the `s++`), making the time complexity of this function *linearly* dependent on string length --or `O(N)`-- and that it avoids generating a value that goes beyond the bounds of the array with the final modulus operation. > > I think it generates an unique address (as an index on hashtab) for the given string(char \*s). > > > It takes the input value (i.e. the string being hashed) and uses it to find out the *index* within the array in which the string should be placed. So it's not technically generating an *address* because the function does not return a *pointer*. The word *offset* would be more accurate here. > > But I think two different strings can be given the same index since (hashval % HASHSIZE) is the given address (203 % 101 = 405 % 101 = 1). > > > True. This is called a *collision*. Writing hash functions that are good at avoiding collisions is not easy. In most discussions, you'll see methods for collision resolution in order to handle these cases. For example, one method could be to turn each array element into a pointer to a linked list where the elements that have collided (i.e. hashed the same index value) are appended to. There're other methods, but that's a different discussion. Ideally, [perfect hash functions](https://en.wikipedia.org/wiki/Perfect_hash_function) would be used because they're guaranteed to *never* generate the same hash value for two *different* inputs, making collision resolution unnecessary. There're book chapters written on these topics, mainly when it comes to searching, so you might want to give those a read. > > And Why HASHSIZE is 101 and hashval is multiplied by 31 (why not 100 or 32)? > > > Because 101 and 31 are *prime* numbers and therefore *less likely* to end up generating collisions by multiplying/dividing themselves into the same bucket as a previous, and different, string.
Hash functions in general might generate the same hash value for different strings. Thats why a [collision resolution](https://en.wikipedia.org/wiki/Hash_table#Collision_resolution) is needed. About the value for HASHSIZE and hashval: I am not a expert in hash functions, but in the few ones I read about, the numbers used were empirically obtained. You can read the [answer](https://stackoverflow.com/questions/10696223/reason-for-5381-number-in-djb-hash-function/13809282#13809282) to this other topic, this might help you.
31,175,741
I'm passing db values using `json _encode()`. Below is the query and all works okay. But when I add an additional data to the array I get a number in front of the output data. ``` $sql = "SELECT item, price, availability FROM items WHERE category = :category ORDER BY item DESC"; $stmt= $connect->prepare($sql); $stmt->execute(array(':category'=>"fruits")); $rslt = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rslt as $val){ $data[] = $val; } $data['additional'] = $someAdditionalData; echo json_encode($data); ``` Current output: ``` {"0":{"item":"lychee"},"1":{"item":"ornage"},"2": "item":"apple"},"additional":ABC} ``` My question is, how do I get the output without the index numbers (as below) ``` [{"item":"lychee"},{"item":"ornage"},{"item":"apple"},{"additional":"ABC"}] ```
2015/07/02
[ "https://Stackoverflow.com/questions/31175741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739628/" ]
Index numbers were assigned automatically because you have assigned an index yourself called "additional". In your code try changing ``` $data['additional'] = $someAdditionalData; ``` to ``` $data[] = array('additional' => $someAdditionalDat); ```
Use `array_values()` for your issue: ``` $arr['additional'] = array_values($arr['additional']); $arr = json_encode($arr); ``` Why? Because you're unsetting array's key without re-ordering it. So after this the only way to keep that in JSON will be encode keys too. After applying `array_values()`, however, you'll get ordered keys (starting from `0`) which can be encoded properly without including keys.
31,175,741
I'm passing db values using `json _encode()`. Below is the query and all works okay. But when I add an additional data to the array I get a number in front of the output data. ``` $sql = "SELECT item, price, availability FROM items WHERE category = :category ORDER BY item DESC"; $stmt= $connect->prepare($sql); $stmt->execute(array(':category'=>"fruits")); $rslt = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rslt as $val){ $data[] = $val; } $data['additional'] = $someAdditionalData; echo json_encode($data); ``` Current output: ``` {"0":{"item":"lychee"},"1":{"item":"ornage"},"2": "item":"apple"},"additional":ABC} ``` My question is, how do I get the output without the index numbers (as below) ``` [{"item":"lychee"},{"item":"ornage"},{"item":"apple"},{"additional":"ABC"}] ```
2015/07/02
[ "https://Stackoverflow.com/questions/31175741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739628/" ]
PHP chooses to serialise your array into an object when *any* array key is not numeric or when the array has missing indices. You can either push another element on the existing array: ``` $data[] = ['additional' => $someAdditionalData]; ``` Or, perhaps better, pick a different structure: ``` $items = []; foreach ($rslt as $val){ $items[] = $val; } echo json_encode([ 'items' => $items, 'additional' => $someAdditionalData; ]); ``` In JavaScript, you can then access the items using `data.items` and the additional data via `data.additional`.
Index numbers were assigned automatically because you have assigned an index yourself called "additional". In your code try changing ``` $data['additional'] = $someAdditionalData; ``` to ``` $data[] = array('additional' => $someAdditionalDat); ```
31,175,741
I'm passing db values using `json _encode()`. Below is the query and all works okay. But when I add an additional data to the array I get a number in front of the output data. ``` $sql = "SELECT item, price, availability FROM items WHERE category = :category ORDER BY item DESC"; $stmt= $connect->prepare($sql); $stmt->execute(array(':category'=>"fruits")); $rslt = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rslt as $val){ $data[] = $val; } $data['additional'] = $someAdditionalData; echo json_encode($data); ``` Current output: ``` {"0":{"item":"lychee"},"1":{"item":"ornage"},"2": "item":"apple"},"additional":ABC} ``` My question is, how do I get the output without the index numbers (as below) ``` [{"item":"lychee"},{"item":"ornage"},{"item":"apple"},{"additional":"ABC"}] ```
2015/07/02
[ "https://Stackoverflow.com/questions/31175741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739628/" ]
PHP chooses to serialise your array into an object when *any* array key is not numeric or when the array has missing indices. You can either push another element on the existing array: ``` $data[] = ['additional' => $someAdditionalData]; ``` Or, perhaps better, pick a different structure: ``` $items = []; foreach ($rslt as $val){ $items[] = $val; } echo json_encode([ 'items' => $items, 'additional' => $someAdditionalData; ]); ``` In JavaScript, you can then access the items using `data.items` and the additional data via `data.additional`.
Use `array_values()` for your issue: ``` $arr['additional'] = array_values($arr['additional']); $arr = json_encode($arr); ``` Why? Because you're unsetting array's key without re-ordering it. So after this the only way to keep that in JSON will be encode keys too. After applying `array_values()`, however, you'll get ordered keys (starting from `0`) which can be encoded properly without including keys.
55,029,842
I build an API, which will send data to another API when has been collect 10 hashes. The client sends 1 hash per hour. For example: 1. The client POST hash to API 2. API need to store it somewhere until the hashes number becomes to 10 3. When the number of hashes becomes 10 need to send data to another API and start from 0 again My question related to the 2nd point. I can store the hashes in the array, the problem is that the data will be lost when the server will be shut down suddenly. This is the only data which I need to store in API, so I don't want to use DBS. By the way, it's my first time of developing API, so will be glad to your help. Thanks in advance.
2019/03/06
[ "https://Stackoverflow.com/questions/55029842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sorry but your only options of storing data are either **memory** or **disk**. If you store data in variables, you're using **memory**. It is fast and instant but it's not durable as you already said. If you store data in database, you're using disk **storage**. It is slower but it is durable. If you need durability, then **database** is your only option. Or maybe if you don't want to store the data in your machine, you could use cloud database such as firebase database.
Maybe your problem will be solved with [Redis](https://redis.io/). I had one feature where I needed to use some user's pieces of information on the server side in runtime and it could not be persisted at the database. So, I used [this](https://www.npmjs.com/package/express-redis-cache). In simple words, the redis will save the information in your cache and you can retrieve when you need. There's no disk use and are more stable than a hand made memory control. I hope this helps you.
31,326,104
I need to find max date from a table(mysql database). I am storing my date as varchar. `select max(completion_date) from table_name` returns wrong value. <http://sqlfiddle.com/#!9/c88f6/3>
2015/07/09
[ "https://Stackoverflow.com/questions/31326104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/768294/" ]
I am not sure why you would want to keep it as varchar not date. But this will work for varchar: ``` SELECT completion_date FROM test ORDER BY STR_TO_DATE(completion_date, '%m/%d/%Y') DESC LIMIT 1; ``` <http://sqlfiddle.com/#!9/c88f6/10>
``` <?php // Store dates $dates = array(); // Loop through and transfer the result set foreach ($result as $row => $data) { $dates[$row] = $data['date']; } // Sort the array usort( $dates, "date_sort_function" ); // Max is last date in array. foreach ($dates as $date) { $max = $date; } ?> ``` Well, something like that. It is a php script and all you have to provide is the sorting function which returns 0 if equal, 1 if older, and -1 if earlier.
31,326,104
I need to find max date from a table(mysql database). I am storing my date as varchar. `select max(completion_date) from table_name` returns wrong value. <http://sqlfiddle.com/#!9/c88f6/3>
2015/07/09
[ "https://Stackoverflow.com/questions/31326104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/768294/" ]
Assuming the date time format you have in your fiddle (e.g. '12/19/2012 05:30 PM') then: ``` select max(STR_TO_DATE(completion_date, '%m/%d/%Y %l:%i %p')) from test; ``` <http://sqlfiddle.com/#!9/c88f6/15> It's unclear if you want to factor the time into your rankings or just the date. This example accounts for time too, but you can remove that part of the formatter if desired.
I am not sure why you would want to keep it as varchar not date. But this will work for varchar: ``` SELECT completion_date FROM test ORDER BY STR_TO_DATE(completion_date, '%m/%d/%Y') DESC LIMIT 1; ``` <http://sqlfiddle.com/#!9/c88f6/10>
31,326,104
I need to find max date from a table(mysql database). I am storing my date as varchar. `select max(completion_date) from table_name` returns wrong value. <http://sqlfiddle.com/#!9/c88f6/3>
2015/07/09
[ "https://Stackoverflow.com/questions/31326104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/768294/" ]
Assuming the date time format you have in your fiddle (e.g. '12/19/2012 05:30 PM') then: ``` select max(STR_TO_DATE(completion_date, '%m/%d/%Y %l:%i %p')) from test; ``` <http://sqlfiddle.com/#!9/c88f6/15> It's unclear if you want to factor the time into your rankings or just the date. This example accounts for time too, but you can remove that part of the formatter if desired.
``` <?php // Store dates $dates = array(); // Loop through and transfer the result set foreach ($result as $row => $data) { $dates[$row] = $data['date']; } // Sort the array usort( $dates, "date_sort_function" ); // Max is last date in array. foreach ($dates as $date) { $max = $date; } ?> ``` Well, something like that. It is a php script and all you have to provide is the sorting function which returns 0 if equal, 1 if older, and -1 if earlier.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
When you tilt the device your activity is destroyed and oncreate is called again . You have to retain the value you want to get back when its is restarted. There are several ways to do it . In shortcut you can just add a flag in Activity in manifest file which is android:configchanges = "orientation". ``` <activity android:name=".Splash" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ``` Aur save your values in onPause or onBundleSaveinstance lifecycle callback methods.
you need to assign `android:screenOrientation="landscape"` in AndroidManifest.xml, look at following code, ``` <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="landscape" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> ```
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
You need to use onSaveInstanceState to save your data because data get lost when orientation changes. Google onSaveInstanceState and if you still have problems ask.
Activity's are destroyed and recreated when the screen orientation is changed. You can either lock it to one orientation. or Save the state of your application using [onSaveInstanceState](http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29) then restore it in onCreate or [onRestoreInstanceState](http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29)
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
When you tilt the device your activity is destroyed and oncreate is called again . You have to retain the value you want to get back when its is restarted. There are several ways to do it . In shortcut you can just add a flag in Activity in manifest file which is android:configchanges = "orientation". ``` <activity android:name=".Splash" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ``` Aur save your values in onPause or onBundleSaveinstance lifecycle callback methods.
Yes, because your activity will be restarted. You need to save your data on orientation changes to saved instant or else you need to restrict orientation changes in your activity.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
When you tilt the device your activity is destroyed and oncreate is called again . You have to retain the value you want to get back when its is restarted. There are several ways to do it . In shortcut you can just add a flag in Activity in manifest file which is android:configchanges = "orientation". ``` <activity android:name=".Splash" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ``` Aur save your values in onPause or onBundleSaveinstance lifecycle callback methods.
You need to use onSaveInstanceState to save your data because data get lost when orientation changes. Google onSaveInstanceState and if you still have problems ask.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
Activity's are destroyed and recreated when the screen orientation is changed. You can either lock it to one orientation. or Save the state of your application using [onSaveInstanceState](http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29) then restore it in onCreate or [onRestoreInstanceState](http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29)
Your activity is relaunched (onCreate is called) every time the activity changes orientation, to avoid this you can set in your androidmanifest android:configChanges="orientation" to the activity.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
When you tilt the device your activity is destroyed and oncreate is called again . You have to retain the value you want to get back when its is restarted. There are several ways to do it . In shortcut you can just add a flag in Activity in manifest file which is android:configchanges = "orientation". ``` <activity android:name=".Splash" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ``` Aur save your values in onPause or onBundleSaveinstance lifecycle callback methods.
Your activity is relaunched (onCreate is called) every time the activity changes orientation, to avoid this you can set in your androidmanifest android:configChanges="orientation" to the activity.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
Yes, because your activity will be restarted. You need to save your data on orientation changes to saved instant or else you need to restrict orientation changes in your activity.
Activity's are destroyed and recreated when the screen orientation is changed. You can either lock it to one orientation. or Save the state of your application using [onSaveInstanceState](http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29) then restore it in onCreate or [onRestoreInstanceState](http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29)
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
You need to use onSaveInstanceState to save your data because data get lost when orientation changes. Google onSaveInstanceState and if you still have problems ask.
Your activity is relaunched (onCreate is called) every time the activity changes orientation, to avoid this you can set in your androidmanifest android:configChanges="orientation" to the activity.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
you need to assign `android:screenOrientation="landscape"` in AndroidManifest.xml, look at following code, ``` <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="landscape" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> ```
Your activity is relaunched (onCreate is called) every time the activity changes orientation, to avoid this you can set in your androidmanifest android:configChanges="orientation" to the activity.
12,067,728
I have a styled file Upload laying on top the vanilla asp.net fileupload control, which is hidden. If the user comes back to edit his chosen files, there are buttons to view the file or delete it from the dataset; In addition the control is hidden. However the fake fileupload remains visible. I have written a custom method to call Jquery from Code behind, but I'm lacking the Jquery skills to hide this fake control and show it on demand. The task is: Hide the fileupload which is contained in a and show it again if the user clicks on "remove file" & set the control to visible again, so he can choose another file. Kind regards. edit: the c# Method containing the Jquery code looks like this right now: ``` runjQueryCode(@"$(document).ready(function() { $('#" + Btn_removeFile.ClientID + @"').click(function(){ $('.fakefile').show(); $('"+ fu.ClientID +@"').show(); }); $('.fakefile').hide(); $('"+ fu.ClientID +@"').hide(); });"); ```
2012/08/22
[ "https://Stackoverflow.com/questions/12067728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249641/" ]
Yes, because your activity will be restarted. You need to save your data on orientation changes to saved instant or else you need to restrict orientation changes in your activity.
Your activity is relaunched (onCreate is called) every time the activity changes orientation, to avoid this you can set in your androidmanifest android:configChanges="orientation" to the activity.
19,173,356
I'm newbie to Laravel and even Frameworks... I've tried some basic authentication in Laravel. Now here's my problem. I've got an LDAP login script in conventional PHP and I want to switch to Laravel LDAP login. Can anyone help me with the code/bundle or anything? I'll be very grateful for this help. ``` function check_login($username,$password){ if($username=="" || $password=="") return 1 ; $server1="ldap.xyz.com"; //server1 ip or dns $server2="ldap.xyz.com"; //server2 ip or dns $firstqry=array("alias,sn,givenname,mail,dn"); $secqry=array("givenname,jobtitledescription,sn,alias,mail,l,employeenumber"); $firstfilter="(alias=$username)"; $searchin="o=XYZ,c=AN"; $ldap=ldap_connect($server1,389); if (!($res = @ldap_bind($ldap))) { //echo "<b>Cannt Contact Server 1 :" .$server1 .", Now Contacting Server 2 :".$server2. ".....</b><br>"; $laststatus=ldap_errno($ldap); if($laststatus==81){ $ldap=ldap_connect($server2,389); if (!($res = @ldap_bind($ldap))) { //echo "<b>Cannt Contact Server 2 :" .$server2 ."...</B><br>"; $laststatus=ldap_errno($ldap); if($laststatus==81){ //echo "<b>Please Contact The Network Adminstartion!!</b><br>"; return 2 ; // server not found } }else{ $laststatus=ldap_errno($ldap); } } }else{ $laststatus=ldap_errno($ldap); } //echo "Connection :" .ldap_error($ldap)."<br>"; if($laststatus==0){ $sr=ldap_search($ldap,$searchin,$firstfilter,$firstqry); $info = ldap_get_entries($ldap, $sr); for ($i=0; $i<$info["count"]; $i++) { $searchdn=$info[$i]["dn"]; $searchalias=$info[$i]["alias"][0]; } if($searchdn){ $secfilter=$firstfilter; $sr2=ldap_search($ldap,$searchin,$secfilter); $info2 = ldap_get_entries($ldap, $sr2); $i=0; if(count($info2)){ if (!($res = @ldap_bind($ldap,$searchdn,addslashes($password)))) { return 1 ; }else{ ldap_close($ldap); return 0 ; } } }else{ return 1 ; } } } ```
2013/10/04
[ "https://Stackoverflow.com/questions/19173356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2845144/" ]
On the server use `header("Content-Disposition: attachment; filename='Original name'")`
Try Below Code ``` header('Content-Disposition: attachment; filename='.basename('newfilename.txt')); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize('filename.txt')); ob_clean(); flush(); readfile('filename.txt'); ```
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
using `android:ellipsize="end"` fixed it for me Weird bug !! (but Android has a lot of these weirdo bug)
This is how, I did for by `EditText` to have hint in it. ``` <EditText android:id="@+id/productQuantity" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right|center_vertical" android:hint="@string/quantity" android:inputType="numberSigned" android:ellipsize="end" android:singleLine="true" > </EditText> ``` ![Screenshot of what the above code should look like](https://i.stack.imgur.com/DiICB.png)
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
The below worked for me: ``` <EditText android:id="@+id/UserText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignRight="@+id/UserPassword" android:layout_marginTop="85dp" android:ems="10" android:hint="@string/UserHint" android:inputType="textPersonName" android:singleLine="true" android:text="@string/UserName" > <requestFocus /> </EditText> ```
I changed the style to `"@style/Base.WidgetMaterialComponents.TextImputEditText"`. For me it wasn't gravity or color.
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :( I found no other solution than to: ``` if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*")) editText.setGravity(Gravity.LEFT); else editText.setGravity(Gravity.CENTER); ```
This is how, I did for by `EditText` to have hint in it. ``` <EditText android:id="@+id/productQuantity" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right|center_vertical" android:hint="@string/quantity" android:inputType="numberSigned" android:ellipsize="end" android:singleLine="true" > </EditText> ``` ![Screenshot of what the above code should look like](https://i.stack.imgur.com/DiICB.png)
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
No need of `android:scrollHorizontally` attribute. Remove it.`EditText` is a fixed item on the screen. we want scroll the layout contains the EditText is enough. that is the best design too. you have put `android:ellipsize="end"` instead of `android:scrollHorizontally`.
This is how, I did for by `EditText` to have hint in it. ``` <EditText android:id="@+id/productQuantity" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right|center_vertical" android:hint="@string/quantity" android:inputType="numberSigned" android:ellipsize="end" android:singleLine="true" > </EditText> ``` ![Screenshot of what the above code should look like](https://i.stack.imgur.com/DiICB.png)
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :( I found no other solution than to: ``` if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*")) editText.setGravity(Gravity.LEFT); else editText.setGravity(Gravity.CENTER); ```
I changed the style to `"@style/Base.WidgetMaterialComponents.TextImputEditText"`. For me it wasn't gravity or color.
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
using `android:ellipsize="end"` fixed it for me Weird bug !! (but Android has a lot of these weirdo bug)
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :( I found no other solution than to: ``` if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*")) editText.setGravity(Gravity.LEFT); else editText.setGravity(Gravity.CENTER); ```
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
You need to give text color to hint ``` android:textColorHint="#000000" ```
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :( I found no other solution than to: ``` if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*")) editText.setGravity(Gravity.LEFT); else editText.setGravity(Gravity.CENTER); ```
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
I wanted my single-line `EditText` box to scroll but keep the hint on the right also. I had the same issue and got the hint to stick by keeping `gravity="right"`, and setting `singleLine="true"` and `ellipsize="end"`.
No need of `android:scrollHorizontally` attribute. Remove it.`EditText` is a fixed item on the screen. we want scroll the layout contains the EditText is enough. that is the best design too. you have put `android:ellipsize="end"` instead of `android:scrollHorizontally`.
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
You need to give text color to hint ``` android:textColorHint="#000000" ```
I changed the style to `"@style/Base.WidgetMaterialComponents.TextImputEditText"`. For me it wasn't gravity or color.
3,608,234
My `EditText` configured as follows won't show the hint: ``` <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:hint="The hint..." android:scrollHorizontally="true" android:singleLine="true" /> ``` It works if I set `android:gravity="left"` or if I remove `android:scrollHorizontally` and `android:singleLine` attributes, which is not desirable. Any suggestions?
2010/08/31
[ "https://Stackoverflow.com/questions/3608234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435830/" ]
You need to give text color to hint ``` android:textColorHint="#000000" ```
The below worked for me: ``` <EditText android:id="@+id/UserText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignRight="@+id/UserPassword" android:layout_marginTop="85dp" android:ems="10" android:hint="@string/UserHint" android:inputType="textPersonName" android:singleLine="true" android:text="@string/UserName" > <requestFocus /> </EditText> ```
229,582
The [Antagonist](http://borderlands.wikia.com/wiki/Antagonist) Seraph shield explicitly states its Damage Reduction on the card (49% maximum, I believe, with the right parts). The [Blockade](http://borderlands.wikia.com/wiki/Blockade) does not explicitly state its Damage Resistance on the card, but [the Wiki](http://borderlands.wikia.com/wiki/Borderlands_Wiki) gives at least one specific value: > > The resistance effect is currently bugged, and is equal to up to 38% (depending on the shield's parts and level) independently of shield charge, even when the shield is depleted. > > > <http://borderlands.wikia.com/wiki/Blockade> Damage Reduction is potentially different from Damage Resistance. I imagine Damage Reduction is straightforward, but I cannot find any formula for Damage Resistance. So, which blocks more damage in the end? And if the Antagonist blocks more damage, is it better than the Blockade?
2015/07/27
[ "https://gaming.stackexchange.com/questions/229582", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/46216/" ]
The Blockade blocks more damage, when throwing Chain Lightning at my feet. I recorded some values (and don't remember other conditions, like level): ``` Antagonist (Hyperion) 1827 → 1005 (822) Blockade (Hyperion) 1403 → 710 (693) Blockade (max cap.) 2420 → 1727 (693) Blockade (1563 listed) 1799 → 1105 (694) Blockade (1930 listed) 2166 → 1473 (693) ``` The Blockade seems to block the same amount of damage across different parts. The Orphan Maker dealt the same amount of damage between both shields, so I don't think the Orphan Maker is suitable for testing.
Antagonist blocks more. According to the [wiki](http://borderlands.wikia.com/wiki/Blockade) Blockade's damage resistance effect can be up to 38%. And the [Antagonist wiki](http://borderlands.wikia.com/wiki/Antagonist) shows an image of a level 61 shield with 49% damage reduction. The percentage of damage reduction for both shields will increase with the shield's level.