qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
4,413,878 | In my iPhone application, I need to get the data in an xml file. I'm using TBXML to do that.
Here's the the xml (simplified) that I need to get the data from:
```
<ResultSet version="1.0">
<Result>
<woeid>12792023</woeid>
</Result>
</ResultSet>
```
I need to put the data in `woeid` into an NSString.... | 2010/12/10 | [
"https://Stackoverflow.com/questions/4413878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456851/"
] | When you *Attach* an entity, it goes to *Unchanged* state (it has not been changed since it attached to the context). All you need to is to explicitly change the Entity State to *Modified*:
```
_context.Users.Attach(user);
_context.Entry(user).State = System.Data.Entity.EntityState.Modified;
_context.SaveChanges();
`... | I believe u do not need to attach the entity before u call modified. simply setting to modified will do the job.
```
if (_context.Entry(user).State == EntityState.Detached)
{
_context.Entry(user).State = EntityState.Modified;
}
``` |
30,749,778 | i have two lists based on other objects.
```
List<Emyployee> emyployeeList;
List<Display> displayEmployeeList;
```
both of them have the id's of the employees, but the second list only have a few of them.
I want to filter the employeeList that i have all id's that arent in the displayEmployeeList.
how can i do that... | 2015/06/10 | [
"https://Stackoverflow.com/questions/30749778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4968222/"
] | Do not do this in JavaScript. Anyone can look at your source code and see the password. Do the password check in PHP instead. Then use `$_SESSION` variables to save the state while they are on your site. You may also want to use `$_COOKIE` variables for long term access, but just `$_SESSION` by itself is generally pref... | This is not safe. User can have disabled JS.
One of correct ways is to use [http auth](http://httpd.apache.org/docs/2.2/howto/auth.html). |
6,522,865 | ```
return *reinterpret_cast<UInt32*>((reinterpret_cast<char*>(this) + 2));
```
Struct is pragma packed 1 and contains a bunch of uint, char, short fields...
Since it's UInt32, should it first be reinterpret\_cast to unsigned char\* instead or does it even matter?
Also, speed is critical here and I believe reinterp... | 2011/06/29 | [
"https://Stackoverflow.com/questions/6522865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/582204/"
] | Can't you just access the member directly? This is undefined behavior and won't work at all on systems that enforce word alignment (which is probably not a problem given you're doing it but needs to be mentioned).
`reinterpret_cast` wouldn't be any faster than `static_cast` because they just tell the compiler how to u... | Since you say that the struct contains ints and shorts, I'm going to go out on a limb and answer on the assumption that this union is POD. If so then you benefit from 9.5/1:
>
> one special guarantee is made in
> order to simplify the use of unions:
> If a POD-union contains several
> POD-structs that share a comm... |
31,749,755 | A simple question with i had problems several times and i dind´t find a solution so far. For sure it is a peanut for you.
I am trying to bind the Text property of a comboBox to a column in the dataTable. If the column name has no spaces it is working:
For example:
```
Text="{Binding Path= MyColumn, ... }"
```
If th... | 2015/07/31 | [
"https://Stackoverflow.com/questions/31749755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4321369/"
] | The following delimiters did not work: `"" [] {}`
What you need is single quotes `''`
```
Text="{Binding Path= 'My Column', ... }"
``` | ```
Text="{Binding Path= 'My Column', ... }"
```
didn't work for me so I tried the code below that worked fine.
```
<TextBox>
<TextBox.Text>
<Binding Path="My Column"/>
</TextBox.Text>
</TextBox>
``` |
4,697,540 | If a float is repeatedly multiplied by a number that is less than one, is it plausible that the the float could become zero?
Here is an example:
```
float number = 1.0f;
for ( int i = 0; i < ONE_BILLION; ++i )
{
number *= 0.01f;
}
```
But please don't limit your answer to the example.
Thanks! | 2011/01/15 | [
"https://Stackoverflow.com/questions/4697540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Yes, when the result of the multiplication would be smaller than the representable number closest to zero, it will become zero. With IEEE floating point, this will happen for any multiplier less than or equal to `0.5f` (but greater than zero); however, if the multiplier is even slightly larger than `0.5f` (for instance... | Depends on the implementation. With typical IEEE 754 implementation you'll first get down into denormals (losing precision) and then snap to 0. But some other implementation may give you a floating point underflow error, bang crash.
Cheers & hth., |
54,474,066 | I am using filter search for recyclerview.My app crashes automatically after some time,it looks like that text watcher is calling automatically.
I am getting this error
```
> Caused by: java.lang.NullPointerException: Attempt to invoke virtual
> method 'void
> com.qasoftearth.abcipl.Adapter.ProductAdapter.filterList(... | 2019/02/01 | [
"https://Stackoverflow.com/questions/54474066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10999478/"
] | After testing all the way I got a perfect solution for "fopen faild" & "execution time expired".
It happens when you'll use your invoice code in extending the master file like
```
@extends('admin.master')
@section('body')
/* your invoice code*/
@sectionend
```
To avoid all issue just paste source code of your invoi... | At first run this :
```
php artisan vendor:publish
```
Then create fonts directory in storage
/storage/fonts
Make sure fonts directory has writable permission. |
50,890 | Any ideas what the average user's download speed is? I'm working on a site that streams video and am trying to figure out what an average download speed as to determine quality.
I know i might be comparing apples with oranges but I'm just looking for something to get a basis for where to start. | 2008/09/08 | [
"https://Stackoverflow.com/questions/50890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | It would depend on the geography that you are targeting. For example, in India, you can safely assume it would be a number below 256kbps. | There are a lot of factors involved (server bandwidth, local ISP, network in between, etc) which make it difficult to give a hard answer. With my current ISP, I typically get 200-300 kB/sec. Although when the planets align I've gotten as much as 2 MB/sec (the "quoted" peak downlink speed). That was with parallel stream... |
3,989,816 | >
> **Possible Duplicate:**
>
> [Easiest way to split a string on newlines in .net?](https://stackoverflow.com/questions/1547476/easiest-way-to-split-a-string-on-newlines-in-net)
>
>
>
I'm trying to read out and interpret a string line per line. I took a look at the StringReader class, but I need to find out w... | 2010/10/21 | [
"https://Stackoverflow.com/questions/3989816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/254850/"
] | The StreamReader class has an EndOfStream property. Have you looked into using that? | Dismissile is correct:
<http://msdn.microsoft.com/en-us/library/system.io.streamreader.endofstream.aspx>
```
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
}
``` |
10,229 | Which are the parallel lines?

I prove that $a$ and $b$ are parallel but can't prove that $c$ and $d$ are parallel.
The angles, which are $135^o$ and $45^o$ are alternate angles.They aren't equal , so $c$ *isn't* parallel to $d$ but the answer is that $c$ is parallel to ... | 2010/11/14 | [
"https://math.stackexchange.com/questions/10229",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1795/"
] | This is a problem with extra information. Part of solving problems is knowing what to ignore! You are thinking about 4 lines, but to show two lines are parallel, you only really need 3.
So, you don't need to use **all** of the information given to solve this problem. In fact, you can *ignore line d* and just focus on ... | Use corresponding angles to see if the lines are parallel. Note if the alternate interior angles are congruent. This will prove if any of these two pairs might fall under the category of Euclidean parallel lines. |
30,657,373 | I'm trying to embed these pages into my website.
<http://globalnews.ca/regina/feed/>
<http://weather.gc.ca/rss/city/sk-32_e.xml>
I'm not sure exactly how these pages are supposed to work. Are these pages only used for scraping data? I'm not sure how to get the information from these XML/RSS feeds? | 2015/06/05 | [
"https://Stackoverflow.com/questions/30657373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2192106/"
] | After some more search I discovered that I need to parse them XML in some fashion. I am using PHP so my first step is to use
```
simplexml_load_file('http://weather.gc.ca/rss/city/sk-32_e.xml');
```
and then read it from an array. | RSS (Rich Site Summary) is a format for delivering regularly changing web content. Many news-related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it.
Taggbox: the Free Online Feed Widget - Taggbox is a RSS feed widget. Simply copy & paste the snippet of code to emb... |
553,669 | In Russian we have the word *сор**о**ка* (magpie) for a person that (among other negative traits) likes and is attracted to shiny things (e.g. gold), usually cheap ones like fake jewelry, or just kind of hoards cheap things in general.
**What is the closest equivalent to this in English (preferably American English), ... | 2020/12/04 | [
"https://english.stackexchange.com/questions/553669",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/377101/"
] | Perhaps surprisingly, the answer is in your own question: "сорока" = *magpie*
>
> magpie (countable noun): If you describe someone as a magpie, you mean that they like collecting and keeping things, often things that have little value.
>
>
> {informal} "A born magpie, Mandy collects any object that catches her eye.... | @Anton's answer of *magpie* is probably the way to go here. But I feel compelled to throw in
>
> *positive phototaxis* which is the compulsion of an organism to move towards bight objects. ([Wikipedia](https://en.wikipedia.org/wiki/Phototaxis)) Like a moth to a flame.
>
>
>
Next time I'm feeling clever with my wi... |
34,628,683 | I want to select image into gallery and that image i want to upload in dropbox.How can i do this?
i tried dropbox SDK but i do not know how to upload selected image
```
- (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString *)sourcePath
```
this method is defined in `DBRestClient.h`,a li... | 2016/01/06 | [
"https://Stackoverflow.com/questions/34628683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5055722/"
] | You should check whether there are rows first. dr.Read() returns whether the DataReader has rows, use it.
Your DataReader returns no results...
```
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read()) {
// read data for first record here
}
```
If you have more than one result, use a 'while' loop.
```
while (dr.... | You should use dr.HasRows to check whether there is data or not. |
5,348,577 | This is a homework question.
I need to calculate 45^60 mod 61. I want to know of any fast method to get the result either programmatically or manually whichever is faster. | 2011/03/18 | [
"https://Stackoverflow.com/questions/5348577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665582/"
] | The result would be 1 because of Fermat's little theorem

if `p` is prime.
61 is a prime number so `a``p-1` when divided by `p` would give 1 as the remainder.
However if `p` is non-prime the usual trick is repeated-squaring. | Wolfram Alpha
--------------
Always have [Wolfram Alpha](http://www.wolframalpha.com/input/?i=45%5E60+mod+61) at hand :D
 |
15,285,032 | Is there a way to automatically apply [autopep8](https://github.com/hhatto/autopep8) to a file being edited in vim? I have the following [vimrc](https://github.com/mictadlo/vimrc4GO/blob/master/.vimrc).
Thank you in advance. | 2013/03/08 | [
"https://Stackoverflow.com/questions/15285032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/977828/"
] | autopep8 is included into [python-mode](https://github.com/klen/python-mode "python-mode").
Call :PymodeLintAuto or map it:
```
" Automatically fix PEP8 errors in the current buffer:
noremap <F8> :PymodeLintAuto<CR>
``` | The plugin didn't exist yet when the question has been submitted, but now there is vim-autopep8.
<https://github.com/tell-k/vim-autopep8> |
26,945,819 | I want my mysql query to be executed when the user clicks on delete button on the pop up box.I have button named 'Delete' and when the user clicks on the button a confirm box pops up and if the user clicks ok then the data should be deleted.I am not asking the query i want to know where should i write the code and how.... | 2014/11/15 | [
"https://Stackoverflow.com/questions/26945819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4255462/"
] | OpenCL is a standard defined by Kronos. They [distribute header files](https://github.com/KhronosGroup/OpenCL-Headers) that you have to give to your compiler. They do not distribute binaries to link against. For that, you must get an ICD (Installable Client Driver), on Windows this is in the form of a DLL file. You wil... | Khronos defines OpenCL standard. Each vendor/ open source will implement that standards.
Khronos defines set of conformance tests which need to pass if a vendor claims that his opencl implementation is as per standard. |
45,071,557 | How do redirect
* stderr to logfile
* stdout to object
Things I've looked at:
`>>` and `2>>` only redirect to file .
`-RedirectStandardOutput` and `-RedirectStandardError` only redirect to file again.
`| Out-File` cannot redirect stderr.
`| Tee-Object` same issue. | 2017/07/13 | [
"https://Stackoverflow.com/questions/45071557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2778405/"
] | A comprehensive explanation in [about\_Redirection](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_redirection) MSDN article.
[A Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) (*`stdout` to pipe*):
```none
PS D:\PShell> -1,5,0,2| ForEac... | ```
cls
function GetAnsVal {
param([Parameter(Mandatory=$true, ValueFromPipeline=$true)][System.Object[]][AllowEmptyString()]$Output,
[Parameter(Mandatory=$false, ValueFromPipeline=$true)][System.String]$firstEncNew="UTF-8",
[Parameter(Mandatory=$false, ValueFromPipeline=$true)][System.String]$s... |
23,917,646 | I am currently building a layout where I have several 'triggers' inside a `<nav><ul><li><a>` element - each display a `<div>` which effectively sits 'behind' (z-index).
I need the divs (#showme and #showmetoo) to stay visible even if the user moves the mouse from the respective trigger (.thetrigger, .thenextrigger) - ... | 2014/05/28 | [
"https://Stackoverflow.com/questions/23917646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1050226/"
] | [**Demo**](http://jsfiddle.net/24bcs/4/)
It sounds like you want the div to remain until the next trigger is hovered over.
You can use a lot less jQuery if you use a class for the triggers, and find their respective divs using data. With this you can add as many triggers + corresponding divs as you like without havin... | I think what you actually want, if I understand you question, is to hide the other #showme element when you hover into the trigger element associated with the #showmetoo element.
Like this:
```
$(document).ready(function() {
$('.thetrigger').hover(function() {
$('#showme').fadeIn();
$('#showmetoo').fadeOut... |
17,987,884 | I am new to android application development. I was doing this tutorial app.
When I run it in the emulator ,it says "Unfortunately AndroidJSONParsingActivity has stopped working.
" There are no errors in the code. The API level is 17 and the emulator is Nexus S.
Please help me out.
I got the tutorial CODE from [JSON t... | 2013/08/01 | [
"https://Stackoverflow.com/questions/17987884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640948/"
] | For Android 4.0 and above you cant do network operations on UI Thread and need to use background threads.
>
> You are calling the following code from the main thread instead of
> background thread therefore this exception is thrown .
>
>
>
```
// getting JSON string from URL
JSONObject json = jParser.get... | you have called the Web from main thread. that's why you have got
```
Caused by: android.os.NetworkOnMainThreadException
```
after android 4.0 you cant do network operations on its UIThread. you need to use background threads. i will prefer to use AsyncTask for network call.
Hope it Helps!! |
37,656,207 | In my HTML,
```
<a id="appLink" style="display:none" ></a>
```
in JS,
```
$("#appLink").prop("href", appSchemaURL);
$("#appLink").focus();
$("#appLink")[0].click();
```
How to bring the app window to front if already open? | 2016/06/06 | [
"https://Stackoverflow.com/questions/37656207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5361812/"
] | You mean *SetTimeout* that is used to run code after x amount of milliseconds ([here more](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout)).
Here is a working solution:
```
$(function() {
var global = '0'
run(); // run function run on page load.
function run(){
var cars ... | ```
<script>
var index = 0;
var cars = [];
$( document ).ready(function() {
var obj = {car: "Volvo", timeout: "2000"};
cars.push(obj);
var obj = {car: "Saab", timeout: "5000"};
cars.push(obj);
var obj = {car: "BMW", timeout: "10000"};
cars.push(obj);
alertAndReRun();
});
function alertAndReRun(){
c... |
885,609 | I have a class that references a bunch of other classes. I want to be able to add these references incrementally (i.e. not all at the same time on the constructor), and I want to disallow the ability to delete the object underlying these references from my class, also I want to test for NULL-ness on these references so... | 2009/05/19 | [
"https://Stackoverflow.com/questions/885609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60800/"
] | I agree with other comments that you should use `boost::shared_ptr`.
However if you don't want the class holding these references to part-control the lifetime of the objects it references you should consider using `boost::weak_ptr` to hold the references then turn this into a `shared_ptr` when you want to us it. This... | You are most likely looking for `boost::shared_ptr`. |
2,118,184 | I have been able to use Jquery with ASP.NET because I know where to drop the JQuery Library, but I am trying to integrate JQuery with Java Web Applications using JSP's,Servlets, etc.
It seems like a trivial question, but for some reason I am unable to figure out where to drop the JQuery Javascript file. | 2010/01/22 | [
"https://Stackoverflow.com/questions/2118184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/180253/"
] | If you have access to modify headers of html files you can load the jQuery library with [Google CDN for Ajax Libraries](http://code.google.com/apis/ajaxlibs/documentation/) without having to drop it physically on your server anywhere. | In modern Digital web platforms, put jquery.js in a folder /javascripts following the Twitter Bootstrap convention.
If you are using JSF 2.x then under folder /resources/javascripts |
1,235,116 | I'm loading jQuery from google on my site (<http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js>) which is minned and gzip'd. In firefox, the jquery file shows as a 19k request, but Safari shows it as a 56k request. I'm assuming then that Safari is not accepting it as a gzip'd file. What's the deal? It's comi... | 2009/08/05 | [
"https://Stackoverflow.com/questions/1235116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74389/"
] | Might want to have a look at [this link](http://www.webveteran.com/blog/index.php/web-coding/coldfusion/fix-for-safari-and-gzip-compressed-javascripts/).
>
> After some digging around I learned that you cannot send compressed javascripts to Safari with the extension of “gz”. It must be “jgz”
>
>
>
So seems the is... | I see at least two possibilities :
* maybe safari is not sending the HTTP header that indicates "I am able to receive gzip" ; that header is `Accept-Encoding`, and its value is generally `compress, gzip`
* maybe Safari is indicating the size of the un-compressed data ?
Do you have some kind of "network sniffer", like... |
7,049,960 | This is absolutely annoying me to death what can I do about this?
```
Guard is now watching at '/home/pma/Sites/somesite.com'
Starting Spork for RSpec & Cucumber
/home/pma/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc9/lib/spork/test_framework/rspec.rb:2: warning: already initialized constant DEFAULT_PORT
/home/pma/.... | 2011/08/13 | [
"https://Stackoverflow.com/questions/7049960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75173/"
] | I'm not really sure which output you trying to cleanup, but here's what I'm seeing:
You have the standard spork messages that only happen at startup. The startup messages such as `Spork is ready and listening on 8989!` are a good thing since they tell you when spork is ready to start testing your files
Some messages ... | I get similar warnings. Beerlington is right, mine are because I was requiring something when I didn't need to. Namely, I was requiring the model in each model spec file. I was doing so because when I run that model spec alone, unless I require the model explicitly, the partial code coverage results would end up not co... |
14,947,341 | If I have a defaultdict(list)
```
from collections import defaultdict
d =defaultdict(list)
such as 1: 0
1:0.2
1: 0.3
2: 0.2
2: 0.4
2: 0.1
```
...... how I transform it into a similar defaultdict(list)
which values is the accumulation of values of the 1st dict with the same ke... | 2013/02/18 | [
"https://Stackoverflow.com/questions/14947341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1830108/"
] | In your first code:
```
x = y
y = x + y
```
You are actually assigning `y + y` to `y`. Since the value of `x` is already overwritten. And this is not you wanted right?
---
And in your 2nd code:
```
x, y = y, x + y
```
First `y` and `x + y` on the RHS is evaluated, and then the evaluated value is assigned to `x,... | I would guess that in the second version, when it evaluates `y, x+y` it uses the original value of x in the x+y.
In the two line version, when it evaluates `x+y` x has been set to y which leads to x+y being the same as `y+y` |
15,333,824 | I am stuck on one query ,
where in i have 52 weeks data which i can arrange according to sysdate by getting the week number and comparing with datas week number.
now what i want to do is if the current week number is 10 i want to arrange all the weeks in descending order like depending on the sysdate week number week1... | 2013/03/11 | [
"https://Stackoverflow.com/questions/15333824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1833043/"
] | If I understand correctly you can try
```sql
SELECT * FROM
(SELECT "Weekly","Quarter","SALES","Monthly",week_number FROM fiscal_calendar
WHERE week_number <= TO_NUMBER(TO_CHAR(SYSDATE,'IW'))
ORDER BY week_number desc) t1
UNION ALL
SELECT * FROM
(SELECT "Weekly","Quarter","SALES","Monthly",week_number FROM fisca... | We can use `case()` (or `decode()`) in the order by clause ...
```
order by case
when week_number = to_number(to_char(sysdate, 'WW')) then 1
when week_number < to_number(to_char(sysdate, 'WW')) then 2
when week_number > to_number(to_char(sysdate, 'WW')) then 3
end ASC
... |
15,765,857 | I know that maybe the title sounds a bit weird but I believe that my problem is weird indeed. I have an ASP.NET MVC 4 application (this is my first MVC real-world application) with Razor view-engine.
I have a layout view where I'm rendering two partial views like this:
```
<!-- Login -->
@Html.Action("RenderLoginPo... | 2013/04/02 | [
"https://Stackoverflow.com/questions/15765857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1016557/"
] | Go to [www.anindya.com](http://www.anindya.com) download \*php\_curl-5.4.3-VC9-x64.zip\* under "Fixed curl extensions:" and replace the php\_curl.dll in ext folder.
via. <http://forum.wampserver.com/read.php?2,85642> | I solved the problem installing WAMP 32 bit version on WIN 7 64BIT, in this way CURL worked. |
6,491,109 | I have one Runnable that is used by more than one thread:
```
Runnable myRunnable = new MyWorker();
Thread one = new Thread(myRunnable);
Thread two = new Thread(myRunnable);
one.start();
two.start();
```
How can I get all threads that are created with `myRunnable`?
(Of course the example is simplified. I create new... | 2011/06/27 | [
"https://Stackoverflow.com/questions/6491109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/462642/"
] | As already said best way is to track this yourself. This forces you to get a clear understanding of what you are doing. A good thing if you work with threads ... hmmm ... a good thing in every case ;).
But if you **realy** want to detect the threads you can use reflection with the Thread class to get the required info... | The best way to do this is to track this yourself. Use a global singleton for instance that launches the threads and track which ones you started. |
5,804 | My wife is transferring with her current employer for two years to Ireland on a Critical Skills work permit. I will be going with her and plan on continuing to work my current US job remotely from Ireland. I am a software developer for a small US business with no foreign presence.
It seems to me that a Work Permit is ... | 2015/03/13 | [
"https://expatriates.stackexchange.com/questions/5804",
"https://expatriates.stackexchange.com",
"https://expatriates.stackexchange.com/users/6233/"
] | [Verizon](http://www.verizonwireless.com/b2c/store/controller?&item=prepayItem&action=viewPrepayOverview&zipRdr=y), and probably all the major carriers, offer prepaid sim only deals where $100 will keep your number for a year. At $8.50 or so a month it is probably cheaper any other plan you will find. As you only need ... | You can use an unlocked VoIP SIP service like [Anveo.com](http://Anveo.com/), where the cost of keeping a US/Canada phone number on the *Personal Unlimited* rate plan is 2 USD per month, which includes an unlimited number of incoming voice calls for personal use, plus they even support SMS (most unlocked VoIP providers... |
3,924,810 | I'm using this PHP/CodeIgniter library for jQuery Highcharts: <http://www.crustiz.com/php-jquery/highcharts-library-for-codeigniter/>
The way that library does things is that it builds a PHP array of options, then converts it to json using json\_encode (see line 273 of that library) which is then used by the jQuery Hi... | 2010/10/13 | [
"https://Stackoverflow.com/questions/3924810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/183929/"
] | JSON isn't meant to convey functions. If you take a look at the [documentation](http://www.json.org/), there are only specifications for four types - object, array, string and number - plus the values `true`, `false` and `null`.
If you insist on doing this, perhaps an article like [Sending Javascript Functions Over JS... | JSON doesn't have a "function callback" type so I think this is not possible. It knows [only the basic types](http://json.org/): `string` / `number` / `object` / `array` |
9,873,190 | I am trying to find my current location for an android project. When the application is loaded my current location is always null. I have set up the permissions in the manifest etc. When I find the current location I intend to use the coordinates to find distances to other locations on the map. My code snippet is below... | 2012/03/26 | [
"https://Stackoverflow.com/questions/9873190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1240449/"
] | `getLastKnownLocation()` uses the location(s) previously found by other applications. if no application has done this, then `getLastKnownLocation()` will return null.
One thing you can do to your code to have a better chance at getting as last known location- iterate over all of the enabled providers, not just the bes... | Try this this will not give you null current location
```
class GetLastLocation extends TimerTask {
LocationManager mlocManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListenerTmp = new CustomLocationListener();
private final Handler mLocHandler;
... |
3,184,727 | How do I make fields accessible across a package? Currently, even if they are declared public i'm not able to access the fields from another class in the same package. | 2010/07/06 | [
"https://Stackoverflow.com/questions/3184727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381699/"
] | You could echo the table headings before the while loop;
```
<thead>
<tr>
<th>Name:</th>
<th>Quantity:</th>
<th>Cost:</th>
</tr>
</thead>
<?php
$sqlstr = mysql_query("SELECT * FROM sales where passport = '{$therecord['passport']}'");
if (mysql_numrows($sqlstr) != 0) {
....
}
....
?>... | ```
sqlstr = mysql_query(
"SELECT * FROM sales where passport = '{$therecord['passport']}'");
if (mysql_numrows($sqlstr) != 0) {
echo "<b>Sales for {$therecord['firstname']} {$therecord['lastname']}</b>";
while ($row = mysql_fetch_array($sqlstr)) {
echo "<table><tr>";
echo "<td>{$row['produc... |
35,488,772 | My data looks like this
```
Peak Ret. Time: 2.083 Min
Number of Points: 6
187.0 194009.0
188.0 308396.0
189.0 319163.0
190.0 321506.0
191.0 321962.0
192.0 321474.0
Peak Ret. Time: 2.683 Min
Number of Points: 6
187.0 194009.0
188.0 308396.0
189.0 319163.0
190.0 321506.0
191.0 321962.0
192.0 321... | 2016/02/18 | [
"https://Stackoverflow.com/questions/35488772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5918251/"
] | In python, strictly speaking, the language has only naming references to the objects, that behave as labels. The assignment operator only binds to the name. The objects will stay in the memory until they are garbage collected | Ok, first things first.
Remember, there are two types of objects in python.
1. Mutable : Whose values can be changed. Eg: dictionaries, lists and user defined objects(unless defined immutable)
2. Immutable : Whose values can't be changed. Eg: tuples, numbers, booleans and strings.
Now, when python says PASS BY OBJECT... |
57,839,723 | So my friend got this email from OneSignal
>
> Due to a change that may occur as part of the upcoming iOS 13 release, you must update to the latest version of the iOS SDK before building your app with Xcode 11. All of OneSignal’s wrapper SDKs including React Native, Unity, and Flutter have been updated as well.
> Th... | 2019/09/08 | [
"https://Stackoverflow.com/questions/57839723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6449292/"
] | Correctly capture iOS 13 Device Token in Xamarin.iOS
```
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
//DeviceToken = Regex.Replace(deviceToken.ToString(), "[^0-9a-zA-Z]+", "");
//Replace the above line whick worked up to iOS12 with the code below:
... | use `deviceToken.debugDescription` |
3,947,227 | I want to make a deep copy of an object array using a constructor.
```
public class PositionList {
private Position[] data = new Position[0];
public PositionList(PositionList other, boolean deepCopy) {
if (deepCopy){
size=other.getSize();
data=new Position[other.data.length];
... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3947227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/458960/"
] | What you have implemented is a **shallow** copy. To implement a **deep** copy, you must
change
```
data[i] = other.data[i];
```
to some thing that assigns a **copy** of `other.data[i]` to `data[i]`. How you do this depends on the `Position` class. Possible alternatives are:
* a copy constructor:
`data[i] = new Pos... | Instead of saying:
```
data[i]=other.data[i]
```
You will want to make a copy constructor for `Position` (in other words, a constructor for Position that takes in another `Position` and copies the primitive data inside it) and say `data[i]=new Position(other.data[i]);`
Basically your "deep copy" constructor the `Po... |
32,396,791 | My VBScript checks if the timestamp of a certain file is older then what has been passed in a argument.
If it is older then the argument allows, then the status of the log file created by this script is set to STATUS="ERROR". When STATUS="ERROR" then the tail of the error log (10 lines of code) is to be written to th... | 2015/09/04 | [
"https://Stackoverflow.com/questions/32396791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3430698/"
] | >
> Is there a way to make the script ignore other files extension than .log and .txt files
>
>
>
Yes. There is the FileSystemObject's [`GetExtensionName` function](https://msdn.microsoft.com/en-us/library/aa265296(v=vs.60).aspx):
```
ext = LCase(FSO.GetExtensionName(file))
Select Case ext
Case "log", "txt"
... | @Tomalak
Can you see something wrong with this ? in the log file it wrote *Invalid Character*
We decided that it should just ignorer the ZIP and RAR files instead of opening them.
**CODE**
`ext = LCase(FSO.GetExtensionName(sNewestFile))
```
Select Case ext
Case "log", "txt":
if(STATUS = "ER... |
11,197,097 | I have to manage servos from a computer.
So I have to send manage messages from computer to Arduino. I need manage the number of servo and the corner. I'm thinking of sendin something like this : "1;130" (first servo and corner 130, delimeter ";").
Are there any better methods to accomplish this?
Here is my this ... | 2012/06/25 | [
"https://Stackoverflow.com/questions/11197097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1222982/"
] | This is a Great sub I found. This was super helpful and I hope it will be to you as well.
This is the method that calls the sub.
```
String xval = getValue(myString, ':', 0);
```
This is The sub!
```
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {
0, -1 };
in... | It looks like you just need to correct
```
foo = ''; >>to>> foo = "";
foo += Serial.read(); >>to>> foo += char(Serial.read());
```
I made also shomething similar..:
```
void loop(){
while (myExp == "") {
myExp = myReadSerialStr();
delay(100);
}
}
String myReadSerialStr() {
String str = "... |
7,568,935 | How do I convert (or create) a singleton class that compiles and behaves correctly when using automatic reference counting (ARC) in Xcode 4.2? | 2011/09/27 | [
"https://Stackoverflow.com/questions/7568935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/304383/"
] | Alternatively, Objective-C provides the +(void)initialize method for NSObject and all its sub-classes. It is always called before any methods of the class.
I set a breakpoint in one once in iOS 6 and dispatch\_once appeared in the stack frames. | Singleton Class : No one can create more than one object of class in any case or through any way.
```
+ (instancetype)sharedInstance
{
static ClassName *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[ClassName alloc] init];
// Perfor... |
9,792,409 | I want to count the WMC for a program. For this am counting the no. of "void", "return", "main", "set" and "get" between 2 " { " and " } " symbols, because they indicate the begin n end of a class. Am using the following code:-
```
namespace ConsoleApplication27
{
class Program
{
static void Main(string[] args)
... | 2012/03/20 | [
"https://Stackoverflow.com/questions/9792409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1260907/"
] | I believe this split will work better:
```
string[] words = var1.Split(new char[] { ' ', '\r', '\n', '\t' },
StringSplitOptions.RemoveEmptyEntries);
``` | You only split on ' '. If the file you're reading is an average source file, it also contains other kinds of whitespace you should split on. Carriage returns, line feeds, tabs.
And it's perfectly possible to have a `{` directly followed by a non-space character, so you should also check for that.
And I don't see wher... |
25,702,732 | I'm new to javascript and simply trying to pull links from a webpage so I'm doing the following:
```
for(link in document.links) {
console.log(link.getAttribute("href");
}
```
But if I do this:
```
document.links.item(0).getAttribute("href")
```
It returns the link for the first `href`
What am I doing wrong?... | 2014/09/06 | [
"https://Stackoverflow.com/questions/25702732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1492471/"
] | Just get the elements by tag name and [avoid the `for in` loop](https://stackoverflow.com/questions/5263847/javascript-loops-for-in-vs-for).
```
var links = document.getElementsByTagName('a'),
i;
for(i = 0; i < links.length; i += 1){
console.log(links[i].getAttribute("href"));
}
```
[**Example Here**](http:... | ```
document.links.item
```
is an array of items.
document.links.item(0) gets the first item in that array.
document.links.item(1) gets the second item in that array.
To answer your question, what you are doing wrong is that you are not looping the links.item array as you did in your first example. |
774,311 | I had a functioning Bash prompt colored how I wanted it, but after reinstalling the background is gray rather than black like this setting should make it.
My `PS1` is
```
\[\e[33;40m\]\T \[\e[36;1m\]\u\[\e[31;40m\]@\[\e[32;1m\]\h \W> \[\e[0m\]
```
Below is a screenshot for clarification. I am talking about the gray ... | 2014/06/27 | [
"https://superuser.com/questions/774311",
"https://superuser.com",
"https://superuser.com/users/339365/"
] | Your terminal's color scheme has dark gray in its "black" slot. (The rest of the terminal is actually black because the *default* background is a completely separate slot.) This used to be the default setting in GNOME Terminal until version 3.12.
Go to "Edit → Profile Preferences", open the "Color" tab, find the 16 co... | I used the ["List of colors for prompt and Bash"](https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash) from the ArchWiki, and came up with this:
```
txtylw='\e[0;33m' # Yellow
txtred='\e[0;31m' # Red
bldcyn='\e[1;36m' # Bold Cyan
bldgrn='\e[1;32m' # Bold Green
txtrst='\e[0m' # ... |
11,167,465 | I want increment `#hidtr` value in jquery.
```
<script type="text/javascript">
$('#hidtr').val(parseInt($('#hidtr').val()+1));
alert($('#hidtr').val());
</script>
``` | 2012/06/23 | [
"https://Stackoverflow.com/questions/11167465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428429/"
] | Try this
```
var val = $('#hidtr').val();
$('#hidtr').val((val*1)+1);
``` | **Or another working demo** <http://jsfiddle.net/AuJv2/5/> **OR** in case of initial empty input: <http://jsfiddle.net/AuJv2/8/>
Please note `parseInt($('#hidtr').val()+1)` should be `parseInt($('#hidtr').val())+1`
Hope this helps,
**code**
```
var num = parseInt($('#hidtr').val()) || 0;
$('#hidtr').val(parseInt(nu... |
246,800 | I'm a PhD in bioinformatics, mostly self-taught, and I'm coming to a point where I want to clean up my various directory structures (i.e. my data), but I'm also thinking about how I'm storing the various bioinformatic packages I'm using. Having no formal training and having taken only a single Unix course, there's stil... | 2015/12/02 | [
"https://unix.stackexchange.com/questions/246800",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/145643/"
] | Agreeing that there is nothing wrong with doing it this way, there are pros and cons. I have found it useful to keep a distinction between scripts which I develop locally and programs that I obtain from other places:
* scripts that I develop locally have a change history which I need to refer to, while
* programs that... | This started out as a comment but became too long and detailed...
There is nothing wrong with doing it this way for personal-use programs and scripts (i.e. that are only going to be used by your user-id). In fact, what you are doing is good practice, although you might want to symlink the binaries into /Users/saberj/b... |
10,141 | I know that motion estimation has to do with calculating motion vectors, but where does motion compensation come into play. Can't we just do it with motion vectors, since, we are still calculating the differences in the displacement of the blocks in the reference and the target frames. | 2014/02/08 | [
"https://avp.stackexchange.com/questions/10141",
"https://avp.stackexchange.com",
"https://avp.stackexchange.com/users/2161/"
] | Motion compensation is the use of the motion estimation information to achieve compression. If you can describe the motion, then you only have to describe the changes that occur after compensating for that motion.
I used [this article](http://www.cmlab.csie.ntu.edu.tw/cml/dsp/training/coding/motion/me1.html) as a prim... | My understanding of their differences:
Motion Estimation:
* It is to generate the motion vector(s).
* It's in the *encoder only*, since decoder only *consumes* the motion vector data.
Motion Compensation:
* It's using *existing* motion vector(s) information, along with the reference image(s), to generate a predicte... |
4,410,629 | I'm trying to find the `n`th digit of an integer of an arbitrary length. I was going to convert the integer to a string and use the character at index n...
`char Digit = itoa(Number).at(n);`
...But then I realized the `itoa` function isn't standard. Is there any other way to do this? | 2010/12/10 | [
"https://Stackoverflow.com/questions/4410629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/497934/"
] | `(number/intPower(10, n))%10`
just define the function `intPower`. | ```
const char digit = '0' + number.at(n);
```
Assuming `number.at(n)` returns a decimal digit in the range 0...9, that is. |
23,521,315 | I have the following code which I am using to populate a `ImageList` from a SQLite database with images stored as blobs.
```
Public Sub populateImagesStyles()
ShoeImages1.Images.Clear()
StyleImagesLView.Items.Clear()
Dim s As SQLiteDataReader
Dim rcount As Integer = 0
dbLocalQuery = New SQLiteCom... | 2014/05/07 | [
"https://Stackoverflow.com/questions/23521315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1619795/"
] | You are creating a lot of memory streams without disposing of them. Try this:
```
Public Function byte2img(ByVal imgByte As Byte()) As Image
Dim img As Image
Try
Using ms As New MemoryStream(imgbyte)
img = Drawing.Image.FromStream(ms)
End Using ' auto dispose of the MS
Catch... | Ok, I've found a solution/workaround that seems to work - call the `PopulateImageStyles` sub when a user visits the specific `TabPage` the `ImageList` resides on.
For some arbitrary reason, when run this way (as above, when called on the form), the process never proceeds to consume more than 50-60 MB of working memory... |
9,104,770 | I need to write these four `if`s in Python. Notice what it does, is changing between four possible states in a loop: `1,0 -> 0,1 -> -1,0 -> 0,-1` and back to first.
```
if [dx, dy] == [1,0]:
dx, dy = 0, 1
if [dx, dy] == 0, 1:
dx, dy = -1, 0
if [dx, dy] == [-1, 0]
dx, dy = 0, -1
if [dx, dy] == [0, -1]:
... | 2012/02/01 | [
"https://Stackoverflow.com/questions/9104770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/661230/"
] | ```
dx, dy = -dy, dx
```
When in doubt, apply maths. ;) | While I would go with Magnus' answer, here's yet another approach for rotating over a set of values:
```
def rotate(*states):
while 1:
for state in states:
yield state
for dx, dy in rotate((1, 0), (0, 1), (-1, 0), (0, -1)):
pass
```
Note that there should be a `break` somewhere in the `f... |
15,475,792 | I am curious about the compiler efficiency in next case:
```
double total = list.Sum(x => x.Value) ?? 0;
```
Q: will compiler produce code that will execute the Sum function once or twice?
It could generate something like:
```
double total = list.Sum(x => x.Value) == null ? 0 : (double)list.Sum(x => x.Value);
```... | 2013/03/18 | [
"https://Stackoverflow.com/questions/15475792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916236/"
] | The code will execute the `Sum` once. That is the whole point of introducing a new operator into the language. You can verify this by introducing a condition with a side effect, and verifying that the side effect is applied only once:
```
int? x = 5;
int y = x++ ?? 100;
```
After executing this code, `x` is `6`, not... | The `??` operator is only applicable to the nullable types, and `double` is not a nullable type, so this code won't compile.
Same, the `.Sum()` extension method will never return `null` on this list, it will always return `0`. |
21,023,759 | I got a problem that consumes a lot of time during the development i have to test somes HQL that i put in DAO, but i had to recompile all the project in eclipse and put in tomcat that takes something like 40-60seconds just to start again and if something goes wrong... again had to redeploy...
So, there is a way to tes... | 2014/01/09 | [
"https://Stackoverflow.com/questions/21023759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893942/"
] | Assuming you are accessing your DAO through a service I would do something like this:
```
public static void main(String[] args) {
AbstractApplicationContext factory = new ClassPathXmlApplicationContext("application-context.xml");
YourService yourservice = (YourService)factory.getBean("YourService");
YourObjec... | What I've done in the past to test HQL is write a limited set of integration tests using an in memory db like [Hypersonic](http://hsqldb.org/) and the [Spring JUnit test extensions](http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/testing.html). [This post](http://www.cybersnippet.nl/easy-integra... |
5,832,337 | I have an array ($title, $depth)
```
$title($depth)
////////////////////////////////////
ELECTRONICS(0)
TELEVISIONS(1)
TUBE(2)
LCD(2)
PLASMA(2)
PORTABLE ELECTRONICS(1)
MP3 PLAYERS(2)
FLASH(3)
CD PLAYERS(2)
2 WAY RADIOS(2)
//////////////////////
```
... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5832337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/703617/"
] | Product ID (ProductCode) uniquely identifies everything in the installer package as a particular product. When you search to see if a previous version is installed search is performed on the Upgrade Code. For all items found with the particular Upgrade code Installer will note each of the Product Codes as different inc... | This may be somewhat misguided but I did have a lot of files I was importing as components into a new WiX `Product.wxs` file. I discovered after I had created all the components with `Guid="*"` that when trying to build the installer, WiX reported the following error for each component:
>
> The component 'AjaxControl... |
3,882,095 | Why does this throw `NullPointerException`
```
public static void main(String[] args) throws Exception {
Boolean b = true ? returnsNull() : false; // NPE on this line.
System.out.println(b);
}
public static Boolean returnsNull() {
return null;
}
```
while this doesn't
```
public static void main(String... | 2010/10/07 | [
"https://Stackoverflow.com/questions/3882095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157882/"
] | **The difference is that the explicit type of the `returnsNull()` method affects the static typing of the expressions at compile time:**
```
E1: `true ? returnsNull() : false` - boolean (auto-unboxing 2nd operand to boolean)
E2: `true ? null : false` - Boolean (autoboxing of 3rd operand to Boolean)
```
See Java Lan... | From [Java Language Specification, section 15.25](http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25):
>
> * If one of the second and third
> operands is of type boolean and the
> type of the other is of type Boolean,
> then the type of the conditional
> expression is boolean.
>
>
>
... |
34,659,628 | I'm trying to figure out how to change the hover color, but only when the text has a link
This is the css code, but it changes color with or without links
```
h1, h2, h3, h4 {
color:#3F3F3F;
}
h1:hover, h2:hover, h3:hover, h4:hover {
color:#000000;
}
``` | 2016/01/07 | [
"https://Stackoverflow.com/questions/34659628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5708568/"
] | Sample:
```
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover {
color:grey;
}
``` | The anwser you are looking for is simple:
```
h1 a:hover, h2 a:hover, ect {
color:#000000;
}
```
You stated that the header when hovered should change color, which is not what you want.
Now it says that a header which contains a link (a) should change color when it is hovered. ;) |
2,975,635 | Hey. I've got the following code that populates my list box
```
UsersListBox.DataSource = GrpList;
```
However, after the box is populated, the first item in the list is selected by default and the "selected index changed" event fires. How do I prevent the item from being selected right after the list box was popula... | 2010/06/04 | [
"https://Stackoverflow.com/questions/2975635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139077/"
] | Well, it looks like that the first element is automatically selected after ListBox.DataSource is set. Other solutions are good, but they doesn't resolve the problem. This is how I did resolve the problem:
```
// Get the current selection mode
SelectionMode selectionMode = yourListBox.SelectionMode;
// Set the selecti... | set `IsSynchronizedWithCurrentItem="False"` and Also `SelectedIndex=-1` and every thing should work for you |
53,190,253 | I've trained an LSTM model (built with Keras and TF) on multiple batches of 7 samples with 3 features each, with a shape the like below sample (numbers below are just placeholders for the purpose of explanation), each batch is labeled 0 or 1:
Data:
```
[
[[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]]
... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53190253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1115237/"
] | I think there might be an easier solution.
If your model does not have convolutional layers or any other layers that act upon the length/steps dimension, you can simply mark it as `stateful=True`
Warning: your model has layers that act on the length dimension !!
------------------------------------------------------... | **Note: This answer assumes that your model in training phase is not stateful. You must understand what an stateful RNN layer is and make sure that the training data has the corresponding properties of statefulness. In short it means there is a dependency between the sequences, i.e. one sequence is the follow-up to ano... |
8,130,990 | How can I redirect to the same page using PHP?
For example, locally my web address is:
```
http://localhost/myweb/index.php
```
How can I redirect within my website to another page, say:
```
header("Location: clients.php");
```
I know this might be wrong, but do I really need to put the whole thing? What if late... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8130990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/710502/"
] | My preferred method for reloading the same page is $\_SERVER['PHP\_SELF']
```
header('Location: '.$_SERVER['PHP_SELF']);
die;
```
Don't forget to die or exit after your header();
Edit: (Thanks @RafaelBarros )
If the query string is also necessary, use
```
header('Location:'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUER... | Simple line below works just fine:
```
header("Location: ?");
``` |
38,010,397 | So if you have this:
```
List<Integer> subList;
for example contains: [0, 6] or [2, 6] , [7, 6]
[[0, 6], [2, 6], [7, 6]]
List<List> list;
contains subLists: [0, 6], [2, 6], [7, 6] or [55, 4], [57, 5], [58, 5]
[[[0, 6], [2, 6], [7, 6]], [[55, 4], [57, 5], [58, 5]]]
```
How do you sort the List... | 2016/06/24 | [
"https://Stackoverflow.com/questions/38010397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6508217/"
] | ```
Collections.sort(new ArrayList<List<Integer>>(), new Comparator<List<Integer>>() {
public int compare(final List<Integer> o1, final List<Integer> o2) {
return o1.get(1) - o2.get(1);
}
});
``` | You can use a comparator that sorts based on the content of the sublist:
1. Make sure all sublists are sorted in descending order (your example seems to reflect this requirement):
`list.forEach(sublist -> Collections.sort(sublist.sort(Collections.reverseOrder())));`
2. Sort the outer list based on the first element o... |
27,160,499 | I'm attempting to inspect http (non-SSL) traffic using XCode 6.1 and iOS Simulator 8.1 using Charles and my localhost apache server.
I've got Charles working correctly, but it only captures traffic when I use my local network IP address: `192.168.1.X` as the target host for requests in iOS.
I've tried the other sugge... | 2014/11/26 | [
"https://Stackoverflow.com/questions/27160499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300408/"
] | Use `localhost.charlesproxy.com` instead of `localhost`. That's setup on the charlesproxy.com DNS to point to 127.0.0.1, and always will. And because it's not literally `localhost` it *should* bypass the OS's hardwired logic for `localhost`.
It is also possible to use `local.charles`, but only if Charles is actually r... | I am using my hostname instead of localhost. To get your hostname simply type `hostname` in the terminal and then change the URL to `"http://your-host-name"` |
12,342,880 | ```
//Skip straight to main home view
MySpyHomeViewController *homeViewController = [[MySpyHomeViewController alloc] initWithNibName:nil bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
```
I use the above code to skip straight to a view if ... | 2012/09/09 | [
"https://Stackoverflow.com/questions/12342880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1523603/"
] | >
> Is there any way to turn on warnings when you implicitly use default properties?
>
>
>
No.
>
> Is there any good practice for marking variables as "this should only be used to read from the spreadsheet"?
>
>
>
Well, you could make your own variable naming convention, à la [Making Wrong Code Look Wrong](... | Maybe write your own custom function and use it instead ?
```
Sub offset_rng(ByRef my_rng As Range, _
Optional row As Integer, Optional col As Integer)
Set my_rng = my_rng.Offset(row, col)
End Sub
```
Can be used like this:
```
Sub test()
Dim rng As Range
Set rng = Range("A1")
offset_rng my_rng:... |
15,800,724 | I have an existing wordpress that I copied to my localhost (including databases). I changed the `wp-config.php` for localhost, but when I try to go to wordpress/wp-admin, it connects to my live site...
What do I need to change? (btw, using XAMMP) | 2013/04/04 | [
"https://Stackoverflow.com/questions/15800724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1591067/"
] | This problem, involving array allocations, comes up all the time in dealing with C/C++ and MPI. This:
```
int **array2D;
array2D = new int*[dim];
for (int i=0; i<dim; i++) {
array2D[i] = new int[dim](); // the extra '()' initializes to zero.
}
```
allocates `dim` 1d arrays, each `dim` ints in length. However, th... | I just wanted to summarise the solution which @Hristolliev and @JonathanDursi helped me get to.
1. MPI commands like `MPI_Gatherv()` work with contiguously allocated blocks of memory, hence use of '`new`' to construct 2D arrays which then feed into MPI commands won't work since '`new`' doesn't guarantee contiguous bl... |
1,186,621 | Why big companies and even US government still have Internet Explorer 6 as their recommended browser?
I'm working at Cisco Systems and their recommended browser is IE6 which makes my life, as a web developer, miserable. I have to spend three times more time debugging problems for IE6 than for any other browsers and I t... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1186621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51230/"
] | There's nearly the same question on [server fault](https://serverfault.com/questions/254/how-can-i-convince-my-it-manager-to-upgrade-the-enterprise-from-ie6-to-a-newer-br). The short answer is, the very thing you desire in IE7/IE8 (standards compliance) is what prevents the adoption - it breaks all those enterprise web... | I just went though this exact same thing with a global brand. Initially I agreed with you, and wrote a whole bunch of angry emails to try and state my case, at the end of the day IE6 was clearly stated in the spec and I had no choice but to get it done properly to the clients requirements.
The biggest issue I had wit... |
10,649,406 | ```
var num = "10.00";
if(!parseFloat(num)>=0)
{
alert("NaN");
}
else
{
alert("Number");
}
```
I want to check if a value is not a float number, but the above code always returns `NaN`, any ideas what I am doing wrong? | 2012/05/18 | [
"https://Stackoverflow.com/questions/10649406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/510785/"
] | `!parseFloat(num)` is `false` so you are comparing `false >= 0`
You could do this:
```
if(! (parseFloat(num)>=0))
```
But it would be more readable to do this:
```
if(parseFloat(num) < 0)
``` | Because `!` has a higher precedence than `>=`, so your code does
`!parseFloat(num)` which is `false`
Then
`>= 0`, `false` is coerced into `0`, and `0 >= 0` is true, thus the `alert("NaN")`
<https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence> |
72,730,693 | I would like to use `numpy` broadcasting feature on mathematical function which involves linear algebra *(bivariate gaussian distribution without the denominator part)*.
The Minimal, Reproducible Example of my code is this:
I have the following function
```
import numpy as np
def gaussian(x):
mu = np.array([[2],... | 2022/06/23 | [
"https://Stackoverflow.com/questions/72730693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14687313/"
] | `fgets` can be used to read each line of the file.
Use `strncmp` to compare the first characters of the line to the serial number. `strncmp` will return `0` for a match.
Upon a match, `sscanf` can parse the fields from the line. The scanset `%19[^;];` will scan up to 19 characters that are not a semi-colon, then ... | <https://en.cppreference.com/w/c/string/byte/strtok>:
>
> This function is destructive: it writes the '\0' characters in the elements of the string str. In particular, a string literal cannot be used as the first argument of strtok.
>
>
>
I'm pretty sure you'll be happier just reading lines using `fscanf`.
On an... |
153,794 | Just so you people don't think of me as a monster. I ask this question because recently I was playing [NetHack](http://en.wikipedia.org/wiki/NetHack) and there is a [magic scroll](http://nethack.wikia.com/wiki/Scroll_of_genocide) that allows you to genocide a species of monsters (usually evil bad ones that want to hurt... | 2014/02/24 | [
"https://english.stackexchange.com/questions/153794",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/66938/"
] | This actually ties in to some more general issues, so I'll start with a brief discussion of them.
The first parallel I thought of is *suicide*, which like *genocide* is mainly used as a noun. The corresponding verbal expression is normally *to commit suicide*; it's relevant that the verb *to suicide* actually is atte... | The direct answer to your problem is that you should have said that you collected 16 different types of "Genocide Scrolls" and then used them. |
391,653 | I am updating an LWC in my dev org and adding a new property to be configured in the app builder however when I install the new version of the managed package which has more properties than the first version it raises an error.
>
> BearBonesTest: Invalid property [text2] in component [lwcManaged:bearBones]
>
>
>
... | 2022/12/09 | [
"https://salesforce.stackexchange.com/questions/391653",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/120140/"
] | Technically you can register a Platform Event on LWC using [lighting EMP Api](https://developer.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation).
And then in finish method fire a platform event with the record Id and then display that on UI.
**But not sure of the use case, so this is just ... | There are a few ways you can pass the id of the record inserted by the batch job to your LWC component. One approach is to use the @api decorator in your Apex controller to expose a public method that returns the id of the record. Then, in your LWC component, you can use the @wire decorator to call the Apex method and ... |
50,466,080 | I know that checkbox is a relatively new feature in Google Sheets, so I'm trying to find a way to automatically create checkboxes in cells.
So far, I haven't found a reference regarding this in Google Apps Script documentation.
Currently I'm doing it manually, but any suggestion using script will be much appreciate... | 2018/05/22 | [
"https://Stackoverflow.com/questions/50466080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8806682/"
] | ### UPDATE(April 2019)
You can now directly `insertCheckboxes`(or `removeCheckboxes`) on a [`Range`](https://developers.google.com/apps-script/reference/spreadsheet/range#insertcheckboxes) or [`RangeList`](https://developers.google.com/apps-script/reference/spreadsheet/range-list#insertCheckboxes()) without any workar... | The checkbox is the recently added Data Validation criterion. Interestingly enough, when I attempt to call the 'getDataValidation()' method on the range that contains checkboxes, the following error is thrown:
```
var rule = range.getDataValidation();
```
>
> We're sorry, a server error occurred. Please wait a bit ... |
27,349,165 | I'm writing a piece of code using JavaScript to check if a number is prime or not. The code correctly tells me the result for number = 1,2,3 but fails on certain others such as 10. I can't figure out what the problem is that is causing it to fail on only certain numbers. If anyone can help identify the problem and sugg... | 2014/12/07 | [
"https://Stackoverflow.com/questions/27349165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2258185/"
] | You should exit out of the loop as soon as you know that it's not a prime, otherwise the result will be overwritten in the next itaration. There is actually no point in having the `else` clause (as it just sets the same value over and over), just set that value before the loop:
```
prime = "this is a prime number";
fo... | Guffa your approach is right but you can increase the efficiency of your algorithm for large numbers by including two conditions.
1. Check whether a number is divisible by 2.
For even numbers, it directly gives the result.
This condition already lessens the number of repetitions by half if the
number is odd.
2. T... |
55,050,850 | I want to return False whenever the user enters the wrong input. To do this, I need to check the input and make sure it only contains specific letters. In this case I want to make sure their input only contains 'b', 'r', 'g', 'p', 'y', or 'o'. Theses letters represent colors in a "mastermind" game I am programming.
Th... | 2019/03/07 | [
"https://Stackoverflow.com/questions/55050850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7944978/"
] | ```
import string
letters = set(string.ascii_letters)
chars = ['b','r','g','p','y','o']
bad_chars = letters-set(chars)
if bad_chars in player_input_string:
return False
```
Use the set here to be able to substract list from another list. | result = re.search('[^brgpyo]\*', player\_input\_string)
if result:
return False |
50,130,077 | ```
x = IntVar()
x.set(1)
def add():
x.set(x.get()+1)
```
I am using this piece of code to update the question number on a tkinter quiz I am making.
```
self.recordNum = Label(self.quizf, text=x)
self.recordNum.pack()
self.Submit = Button(self.quizf, text = 'submit', command=lambda:[self.confirmAnswer(),add()]... | 2018/05/02 | [
"https://Stackoverflow.com/questions/50130077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9552785/"
] | ```
self.recordNum = Label(self.quizf, text=x.get())
self.recordNum.pack()
self.Submit = Button(self.quizf, text = 'submit', command=lambda:[self.confirmAnswer(),add()])
```
In the label, you have to use `x.get()` instead of just `x`, as you want the value of `x`.
Just using `x` will reference to the object which i... | You need to use “textvariable” as argument for your variable. Then the label will update itself. |
5,916 | For any of the 4 races, how do you place your buildings/what hero do you get/what do you build first to effectively protect yourself against that all-annoying BladeMaster rush with WindWalk, early game?
I'm talking *no* peon losses, ideally causing him to have to TP. | 2010/08/19 | [
"https://gaming.stackexchange.com/questions/5916",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/3026/"
] | I haven't played in a long time so bare with me:
**Night Elf:**
```
Mana Burn (Demon Hunter)
Dust+Entangling Roots+Surround/Focus Fire (KotG)
Shadow Strike will slow allowing you to attack him with units(Warden)
Build your wells in a manner that blocks your trees so melee heroes cant get in
```
Alternatively, put ... | Hero Rushing is a standard part of Warcraft III. To Hero Rush means to attack the enemy town, especially workers, as early as possible. Players head to the enemy town as soon as the Hero has been trained. Players are typically either Hero Rushing the enemy or defending against a Hero Rush. Sometimes players may not Her... |
59,804,247 | ```
void sort(int *ptr, int n) {
int i,j,tmp;
for (i=0;i<n;i++)
for (j=i;j<n;j++)
if (ptr[i] > ptr[j])
{
tmp=ptr[i];
ptr[i]=ptr[j];
ptr[j]=tmp;
}
}
```
AND
```
void sort(int *ptr, int n) {
... | 2020/01/18 | [
"https://Stackoverflow.com/questions/59804247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10515106/"
] | The two pieces of code are semantically equivalent.
Section 6.5.2.1p2 of the [C standard](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) regarding the array subscript operator `[]` states:
>
> A postfix expression followed by an expression in square
> brackets `[]` is a subscripted designation of an el... | Nothing. It's merely a matter of style. |
17,448,269 | In SQL Server database I have a View with a lot of INNER JOINs statements. The last join uses LIKE predicate and that's why it's working too slowly. The query looks like :
```
SELECT *
FROM A INNER JOIN
B ON A.ID = B.ID INNER JOIN
C ON C.ID1 = B.ID1 INNER JOIN
...........................
X ON X.Name LIKE '%' + W.Name ... | 2013/07/03 | [
"https://Stackoverflow.com/questions/17448269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1473178/"
] | You can create a join using a LIKE..
something like this:
```
SELECT * FROM TABLE_ONE
FULL OUTER JOIN TABLE_TWO ON TABLE_ONE.String_Column LIKE '%' + TABLE_TWO.Name + '%'
```
ie - select everything from TABLE\_ONE where the string\_column is contained in the TABLE\_TWO name | In short there isn't a way to do this using CONTAINS, it simply is not allowed in a JOIN like this.
see: [TSQL - A join using full-text CONTAINS](https://stackoverflow.com/questions/5152783/tsql-a-join-using-full-text-contains)
So although there is performance hit, IMO like is the easiest solution here. |
2,796 | Ich denke, dass man bei (Arbeits-)**Stelle** im Allgemeinen explizit dazu sagt, wenn es sich um eine zeitlich **befristete** Stelle handelt.
Bei **Arbeit**, wie in
>
> Ich habe Arbeit.
>
>
>
kann man vermutlich noch nicht mal sicher sein, dass es sich um bezahlte Arbeit handelt, es kann sich dabei durchaus auch... | 2011/10/16 | [
"https://german.stackexchange.com/questions/2796",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/104/"
] | Ich würde sagen: Der Begriff hat einen Bedeutungswandel hinter sich. War ein Job früher eine Nebenbeschäftigung oder eine befristete Anstellung, so ist die Bezeichnung "mein Job" heute auch für den Hauptberuf mit einem unbefristeten Vertrag gängig, analog zu der Bedeutung im Englischen. Siehe auch: Jobcenter, wo auch "... | Der Begriff Job ist ein wenig doppeldeutig.
Auf der einen Seite kann es ein klassisches vertragliches Arbeitsverhältnis bezeichnen, wobei es hier egal ist, ob das Ganze befristet oder unbefristet ist.
Auf der anderen Seite wird es häufig auch einfach als Alternative zum Wort "Aufgabe" verwendet ("Mein Job ist es, hie... |
376,950 | I first noticed it earlier today at work, and now on my system at home, that the page size when searching defaults to 1 now. For example, <https://stackoverflow.com/questions/tagged/c%23> shows me 1 question per page.
Has this happened to anyone else? Was the default page size perhaps set to 1 by accident? | 2018/11/22 | [
"https://meta.stackoverflow.com/questions/376950",
"https://meta.stackoverflow.com",
"https://meta.stackoverflow.com/users/247702/"
] | Clicking on desired page size again to fixes the issue.
Looks like a bug - probably someone changed how this value is stored. I have low expectations for quick root cause or fix as there is Thanksgiving in US :) | It seems to hold the last value you use. Asking for `?pagesize=4` will hold that value as default for pagination.
That's my favourite ~~bug~~ rogue feature of the week, I must say. |
11,543,714 | I want call method path from class Path. I need set some number - array length and appropriate values of array on entrance.
This is my class:
```
class Path {
int number;
String[] path_name = new String [number];
Path (int n, String [] p){
number=n;
path_name=p;
}
public void path(){
for (int i=1; i<... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11543714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1407907/"
] | Try something like:
```
Path pa = new Path(6, String[] {"one", "two", "three"} );
```
If you can change the code you can probably use varargs to make it easier:
```
Path (int n, String p...)
```
Then you could just to:
```
Path pa = new Path(6, "one", "two", "three");
``` | The n number you refer to can be eliminated if you accept the invariant that all elements of the array are valid elements to path for.
With this in mind, you can simply have
```
class Path {
final String[] pathNames;
// uses var args
Path(String... paths) {
pathNames = paths;
}
void path(... |
5,639,346 | **What is the shortest, accurate, and cross-browser compatible method for reading a cookie in JavaScript?**
Very often, while building stand-alone scripts (where I can't have any outside dependencies), I find myself adding a function for reading cookies, and usually fall-back on the [QuirksMode.org `readCookie()`](ht... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5639346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172322/"
] | code from google analytics ga.js
```
function c(a){
var d=[],
e=document.cookie.split(";");
a=RegExp("^\\s*"+a+"=\\s*(.*?)\\s*$");
for(var b=0;b<e.length;b++){
var f=e[b].match(a);
f&&d.push(f[1])
}
return d
}
``` | Here is the simplest solution using javascript string functions.
```
document.cookie.substring(document.cookie.indexOf("COOKIE_NAME"),
document.cookie.indexOf(";",
document.cookie.indexOf("COOKIE_NAME"))).
substr(COOKIE_NAME.length);
``` |
3,739,369 | currently I am thinking about data encapsulation in C# and I am a little bit confused.
Years ago, when I started to learn programing with C++, my professor told me:
- "Create a class and hide it data members, so it can't be manipulated directly from outside"
Example:
You are parsing an XML file and store the parsed d... | 2010/09/17 | [
"https://Stackoverflow.com/questions/3739369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/451089/"
] | Well so properties aren't the wild west you are taking them to be at a first glance. The unfortunate truth of OOP is that a lot of your methods are getters and setters, and properties are just a way to make this easier to write. Also you control what you'd like the property to allow someone to do. You can make a proper... | There still is data encapsulation, if you need it to be. Encapsulating data is not about hiding it from the client of the class or making it unaccessible, it's about ensuring a consistent interface and internal object state.
Let's say you have an object representing a stick shift car, and a property to set the speed. ... |
246,490 | I am working on REST call. Everything works fine but my column contains special character `&`
So rest call like below works:
```
http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq 'DAD'
```
But below fails:
```
http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq '... | 2018/08/03 | [
"https://sharepoint.stackexchange.com/questions/246490",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/67615/"
] | Use something like this:
```
"http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq " + encodeURIComponent("D&D")
``` | Perhaps try putting the encoded value in directly. Have you tried something like this yet:
```
"http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq 'D%26D'"
``` |
14,414,086 | Some years ago there was an opinion, that $\_FILES[$file]['type'] contains mimetype sent from a browser, but not real mimetype, for example here:
<http://php.net/manual/ru/reserved.variables.files.php#109902>
Is it still so and do i still need to use fileinfo extension to detect mimetype?
(i am using php5.4) | 2013/01/19 | [
"https://Stackoverflow.com/questions/14414086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391074/"
] | In iOS 6 and later
```
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setTextColor:[UIColor whiteColor]];
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setFont:[UIFont systemFontOfSize:18.0f]];
[[UIView appearanceWhenContainedIn:[UITableViewHeaderFooterVie... | ```
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection: (NSInteger)section
{
UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease];
if (section == integerRepresentingYourSectionOfInterest)
[hea... |
6,184,656 | This question is a common issue, and I have tried to look at some thread as [Is Java "pass-by-reference" or "pass-by-value"?](https://stackoverflow.com/questions/40480/is-java-pass-by-reference) or [How to change an attribute of a public variable from outside the class](https://stackoverflow.com/questions/3379788/how-t... | 2011/05/31 | [
"https://Stackoverflow.com/questions/6184656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/588925/"
] | 1. You could extract `public void setb(){}` into an interface (let's call it `BSettable`), make `Test` implement `BSettable`, and pass an argument of type `BSettable` into `doSomething`.
2. Alternatively, you could make `b` into an [`AtomicBoolean`](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/... | I think your question is not very clear and your sample code is really badly done. Do you actually mean something like this?
```
public class Test{
private boolean b;
public boolean getb(){return b;}
public void setb(boolean b){this.b = b;}
String test = ClassSingleton.getInstance().doSomething(this);
... |
3,279,524 | I am currently looking for some code or a tool/service that allows me to store Log4Net Messages in a SQL Server database. Does something like this already exist or would I have to implement this on my own? I couldn't find anything on SO or Google.
Thanks in advance for any information. | 2010/07/19 | [
"https://Stackoverflow.com/questions/3279524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297303/"
] | The links from Moin Zaman show test results that are outdated (from 2008). As of my thorough testing today Gmail does support displaying embedded images for both methods.
Use base64 encoding image inline within `<img src="...">`
```
<html><body><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9QAAADmCAIAAAC77... | ```
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[picker addAttachmentData:UIImageJPEGRepresentation(_tempImage,1) mimeType:mimeType fileName:filename];
[picker setMessageBody:emailBody isHTML:YES];
```
If `isHTML` is `YES`, `addAttachmentData` will auto change to base64 string,... |
20,740 | I generally have one of Fink, MacPorts, Homebrew installed. Most often for a single, small, and trivial package. I've found that all my day-to-day software exists in OS X versions.
So, which non-OS X unix software do you find is required, interesting, or otherwise always on your computer.
I'm looking to broaden my ho... | 2011/08/08 | [
"https://apple.stackexchange.com/questions/20740",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/669/"
] | I frequently reinstall MacPorts (e.g., when there's a new major version of Xcode) so I keep a file with a list of my essential ports for easy reinstalling.
Here's my list of essential software that doesn't come with OS X.
* [arping](http://en.wikipedia.org/wiki/Arping)
* [dnstracer](http://linux.die.net/man/8/dnstrac... | * wget (download files from inet)
* nmap (scan ip)
* unrar (It's more up to date that the GUI)
* imagemagick (way faster to do thumbs than photoshop)
* mencoder (to do some trasnformations between media formats, I use it regularly to extract audio from DVD's)
developer stuff:
git, postgresql, mongod |
40,295,830 | I am developing a website which require the use of the navigator.geolocation object through a local development environment on MACOSX. I am using Chrome 53. Considering geolocation is blocked on anything that isn't HTTPS how am I suppose to develop my website locally? The Google Developers site quotes:
>
> Does this... | 2016/10/27 | [
"https://Stackoverflow.com/questions/40295830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5024907/"
] | `http://localhost` is treated as a secure origin, so you don't need to do anything, the Geolocation will work.
If you're using another hostname that points to the localhost (Ex: `http://mysite.test`) then you should run chrome from the command line with the following option: `--unsafely-treat-insecure-origin-as-secure... | Use `file:` protocol. Launch chrome with `--allow-file-access-from-files` flag set, see [Jquery load() only working in firefox?](https://stackoverflow.com/questions/32996001/jquery-load-only-working-in-firefox/32996188?s=1|2.0351#32996188). At `Settings` select `Content settings`, scroll to `Location`, select `Ask when... |
8,447,129 | I am maintaining an ASP.NET MVC project. In the project the original developer has an absolute ton of interfaces. For example: `IOrderService`, `IPaymentService`, `IEmailService`, `IResourceService`. The thing I am confused about is each of these is only implemented by a single class. In other words:
```
OrderService ... | 2011/12/09 | [
"https://Stackoverflow.com/questions/8447129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/594058/"
] | It's good practice to program against interfaces rather than objects. [This](https://stackoverflow.com/questions/4456424/what-do-programmers-mean-when-they-say-code-against-an-interface-not-an-objec) question gives good reasons why, but some reasons include allowing the implementation to change (ex. for testing).
Just... | These are service interfaces, which encapsulate some kind of externality. You often have just a single implementation of them in your main project, but your tests use simpler implementations that don't depend on that external stuff.
For example if your payment service contacts paypal to verify payments, you don't want... |
16,113,290 | I have an ATL COM service and in the .IDL file, I've declared an enum like so:
In Gourmet.idl
```
typedef enum Food
{
Chocolate = 0,
Doughnut,
HotDog
} Food;
```
A header file is automatically generated, creating Gourmet\_i.h.
In another .CPP file (let's just call it Decadence.cpp) of the same ATL COM ... | 2013/04/19 | [
"https://Stackoverflow.com/questions/16113290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1628921/"
] | Short of renaming the namespace or enum member about the only solution for this is to wrap the contents of the generated header file in a namespace. This is not without pitfalls and depending on how the contents of your MIDL file it may eventually cause a few headaches. The cleanest way that I can see would be to creat... | If you are using C++11 you can use Scoped Enumeration by including `class`:
```
typedef enum class Food
{
Chocolate = 0,
Doughnut,
HotDog
} Food;
```
Now you need to write `Food::Chocolate` when using the value. |
46,044,959 | I am reading through Eloquent Javascript and am currently on Chapter 4 working on the exercise regarding arrays to list and vice versa. The exercise wants me to get the console to print [10, 20, 30] but I am instead getting it to print [[10],[20],[30]] and am unsure why. I suppose you could argue that it doesn't make a... | 2017/09/04 | [
"https://Stackoverflow.com/questions/46044959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8502738/"
] | Every time you get the next line from your scanner, it increases array size by one. So, entering the alphabet, you would get `a,b,c,d,e...` and so on.
After every input, your for loop outputs the entire array. So, the first time the array will have `a`, the second time it will have `a,b`, and so on. If you went on, yo... | The duplication occurs because you are attempting to print all the values of the ArrayList myArray over and over again. So when the user inputs A, the myArray will store A then the for loop prints A, then on the next line, when the user inputs B, myArray = A,B, the for loop prints A and B and so on. Put the for loop ou... |
21,323 | We're redoing our front room in our house. We're thinking of going with a 'seaside cottage' feel and installing some wainscoting on the walls about 2/3rds the way up.
The catch is that our house currently has doors with casings, but the windows are using a finished sheetrock return. They do have a stool, but not casin... | 2012/12/07 | [
"https://diy.stackexchange.com/questions/21323",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1209/"
] | [houzz.com](http://www.houzz.com/Wainscoting)

It appears to be just a matter of how you trim it out. You can do something detailed like in the photo or as simple as 1/4 round trim to cover the edge. | I didn't have pics of how I did the window area but here is pic which shows one method of edging: I would make an apron for under the window sill and for beside the window - experiment with widths that look good for the particular style of wainscot you are using. If it is stain grade wainscot - you should be able to pi... |
28,787 | *NOTE: I asked this question this morning with respect to EC2 boxes, but only got back links to tools to start and stop instances, so I'll rephrase...*
I have a few Linux boxes that do nightly processing jobs for one of my projects. From time to time, I'll need to get in, make some code changes, configure some things,... | 2009/06/19 | [
"https://serverfault.com/questions/28787",
"https://serverfault.com",
"https://serverfault.com/users/6681/"
] | If you're looking for a nice GUI to work with file management via SSH from Windows boxes, have a look at WinSCP: <http://winscp.net>
I don't administer any EC2 instances, but in general if I have more than a single machine performing a role I'll try and write a script to perform work on all the like boxes, in lieu of ... | SSH has always been enough for me. There are other options X11 is essentially remote desktop though it's inherently insecure as it alone is not encrypted. However it can be tunneled through an SSH connection (and you get the benefit of not having to open up additional ports). This of course assumes that you have an X e... |
82,387 | I am a beginner photographer and I decided to start experimenting with light. I want to buy two cheap inexpensive flashes and I found this Yongnuo model: YN560III.
I don't have any knowledge about flashes and pairing them with another one. I just know that this is a manual flash model. Can somebody explain to me:
* Is... | 2016/08/31 | [
"https://photo.stackexchange.com/questions/82387",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/56273/"
] | * Yes, this flash and the IV are fine for the 750D
* That depends on your definition of good. The YNs are excellent flashes *for the money*. I have 3 of them, a III and two IVs, and the III has failed (it is stuck on full power, a common problem). But they are dirt cheap, pretty well made, and have all the features you... | >
> Is this model suitable for Canon 750d?
>
>
>
Depends on your definition of suitable. It will work on a 750D and won't hurt the camera.
>
> Is this flash good?
>
>
>
It does what it's designed to do, and is decent value for the money if you're a hobbyist and planning on occasional usage; for a pro doing ... |
2,461,616 | I have added paypal pro (uk) express to my Magento shopping cart. The paypal button now appears below the checkout button in the shopping cart.
The problem is when I click the paypal button I get a 404 error.
Any ideas? | 2010/03/17 | [
"https://Stackoverflow.com/questions/2461616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239768/"
] | Yes you can, use Reachability APIs in SystemConfiguration.framework. See [here](http://developer.apple.com/mac/library/DOCUMENTATION/Networking/Conceptual/SystemConfigFrameworks/SC_ReachConnect/SC_ReachConnect.html). A sample code (for iphone) is available [here](http://developer.apple.com/iphone/library/samplecode/Rea... | I found a way of getting network change event using growl framework.
Added code on top of it to receive network change event.
Growl framework can be found at <http://growl.info/documentation/developer/> |
63,263,946 | An array of costs was given. You can either take two jumps forward or one jump backward. If you land on a particular index, you have to add the cost to your total. Find the minimum cost needed to cross the array or reach the end of the array.
**Input:**
```
5 (Number of elements in the array)
[9,4,6,8,5] (Array)
1 ... | 2020/08/05 | [
"https://Stackoverflow.com/questions/63263946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11703262/"
] | ```
function solve(A_i) {
A_i.sort((a,b) => a-b);
let totalcost = A_i[0];
for(let i=2; i<A_i.length;i++) {
if(i + 1 == A_i.length -1) {
totalcost = totalcost + A_i[i];
break;
}
const preSum = A_i[i] + A_i[i+2];
const postSum = A_i[i] + A_i[i-1] + A_i... | **JAVA Solution: The solution takes O(n2)**
```
int minCost[] = new int[N];
Arrays.fill(minCost,Integer.MAX_VALUE);
for(int i=0;i<A.length;i++){
for(int j=0;j<A.length;j++){
if(j == 0){
minCost[j] = 0;
continue;
}
if(j-2>=0 && minC... |
6,909,306 | I'm still relatively new to Java, so please bear with me.
My issue is that my Java application depends on two libraries. Let's call them Library 1 and Library 2. Both of these libraries share a mutual dependency on Library 3. However:
* Library 1 requires exactly version 1 of Library 3.
* Library 2 requires exactly v... | 2011/08/02 | [
"https://Stackoverflow.com/questions/6909306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/393005/"
] | I can't believe that for more than 4 years no one has answered this question correctly.
<https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html>
>
> The ClassLoader class uses a delegation model to search for classes
> and resources. Each instance of ClassLoader has an associated parent
> class loade... | Trying to get rid of `classpath lib2` and invoke the `bar()` method by reflection:
```
try {
cls.getMethod("bar").invoke(cls.newInstance());
} catch (Exception e) {
e.printStackTrace();
}
```
gives following output:
```
Exception in thread "main" java.lang.ClassNotFoundException: Library2
at java.net.UR... |
10,745,661 | I'm curious if I'll have to roll my own or if there's a pre-made PHP SQL library that I'm overlooking whereby I can pass in a sql select query and have it give me back a JSON object (or String) as a result.
In pseudo code what I want is this:
```
$startIndex = 0;
$myJSON = magicSqlToJSON("select first_name, last_name... | 2012/05/24 | [
"https://Stackoverflow.com/questions/10745661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59947/"
] | PHP
---
PHP has the `json_encode()` and `json_decode()` functions for this purpose, but you would need to manually loop over your data with a `foreach` or similar.
MySQL
-----
You can make use of a User Defined Function such as [lib\_mysqludf\_json](http://www.mysqludf.org/lib_mysqludf_json/index.php), which would a... | Ill assume you use PDO
```
echo json_encode($pdo->exec($sql)->fetchAll());
```
otherwise, the general pattern is
```
$handle = execute_query($sql);
$rows = array();
while ($row = get_row_assoc($handle)) {
$rows[] = $row;
}
echo json_encode($rows);
``` |
22,083,090 | I am building a Django application that exposes a REST API by which users can query my application's models. I'm following the instructions [**here**](http://www.django-rest-framework.org/tutorial/quickstart#testing-our-api).
My Route looks like this in myApp's url.py:
```
from rest_framework import routers
router = ... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22083090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1742777/"
] | Try doing this in your urls.py. The third parameter 'Person' can be anything you want.
```
router.register(r'person/food', views.PersonViewSet, 'Person')
``` | An alternative solution might be to use a [ModelViewSet](http://www.django-rest-framework.org/api-guide/viewsets#modelviewset) which will derive the basename automatically from the model.
Just make sure and tell it which model to use:
>
> Because ModelViewSet extends GenericAPIView, you'll normally need to
> provid... |
71,055,853 | I have been wondering how to extract string in R using stringr or another package between the exact word "to the" (which is always lowercase) and the very second comma in a sentence.
For instance:
String: "This not what I want to the THIS IS WHAT I WANT, DO YOU SEE IT?, this is not what I want"
Desired output: "THIS... | 2022/02/09 | [
"https://Stackoverflow.com/questions/71055853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15587184/"
] | You were close!
```
str_extract(string = x, pattern = "(?<=to the )[^,]*,[^,]*")
# [1] "THIS IS WHAT I WANT, DO YOU SEE IT?"
# [2] "I WANT, THIS"
# [3] "xxxx,"
```
The look-behind stays the same, `[^,]*` matches anything but a comma, then `,` matches exactly one comma, then `[^,]*` again... | Alternative approach, by far not comparable with Gregor Thomas approach, but somehow an alternative:
1. vector to tibble
2. separate twice by first `to the` then by `,`
3. paste together
4. pull for vector output.
```
library(tidyverse)
as_tibble(x) %>%
separate(value, c("a", "b"), sep = 'to the ') %>%
separat... |
20,553,725 | As I know, if we want to prevent robots accessing our web sites we have to parse 'User-Agent' header in http request then check whether the request coming from robots or browsers.
I think we can not completely prevent robot accessing our web sites because someone can program to use any http client to send Http request... | 2013/12/12 | [
"https://Stackoverflow.com/questions/20553725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3018377/"
] | You cannot eliminate the bots, but you can greatly reduce them.
Obvious option you're already using is user-agent detection
You could also load your page content through ajax using JavaScript which would eliminate any bot that cannot process javascript. So just have an empty div with the id="content" and on page read... | I think that autentication with captcha is the easier way and the most used. Other options would be to ask simply questions to the user (simply to humans but not to bots). However all these methods are annoying for human users. |
20,963,162 | I need to ask a problem on the operator "choice when" in Apache Camel route. In the following example, if I have two soap-env:Order elements which have 1, 2 value, then I want to create two xml file named output\_1.xml and output\_2.xml. However, the code can only create one file output\_1.xml.
Can anyone give me any i... | 2014/01/07 | [
"https://Stackoverflow.com/questions/20963162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1241673/"
] | There is nothing wrong with the DSL and you dontt need end blocks here. I would look at your data and trace through why all calls are ending up in the same when block. Put a couple of log lines in or enable the tracer and look at the exchanges going through. | In Camel root choice() if you have multiple when() cases you have to write otherwise(). Please refer below.
```
from("direct:a")
.choice()
.when(header("foo").isEqualTo("bar"))
.to("direct:b")
.when(header("foo").isEqualTo("cheese"))
.to("dir... |
21,889,835 | Im trying to get the to populate with companyName from an array. I am not seeing any changes.
Javascript:
```
var webName = {
coinstar: {
companyName: "Coinstar",
projectName: "Online App",
role: "Web Developer",
detailText: "This is some text"
},
google: {
companyName: "Google",
project... | 2014/02/19 | [
"https://Stackoverflow.com/questions/21889835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3328590/"
] | For now, I'll ignore the fact that `id="companyName>` is missing an ending quote.
In the function:
```
var search = function(coName) {
for(var prop in coName) {
```
`coName` is the string `coinstar`:
```
search("coinstar");
```
You're attempting to iterate through each property in a `string`, which is probabl... | try this.
```
var search = function(coName){
for(var prop in webName){
if(webName[prop].companyName === coName){
document.getElementById("companyName").innerHTML = webName[prop].companyName;
}
}
}
``` |
102,331 | I applied for an entry level software engineer position, and before even getting an interview with a company, they asked me to complete what I'd consider to be a rather significant coding project. I am given two days to build an application stack using SQL database, node.js, REST APIs, front end UI with react.js. I'm c... | 2017/11/09 | [
"https://workplace.stackexchange.com/questions/102331",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/79396/"
] | They might be trying to get you to do some work for free, without having any intention of calling you in for an interview. Or they may have so many talented applicants that they only want the very best.
I'd be a little bit cautious in this instance because of the minimal contact that you've had with them. I would typ... | Let's not talk about 2 **days**, because nobody really will work 48 hours straight on it.
Let's assume you're unemployed, you got time, and you sink 4 hours per day into it. 8 hours of work.
Did they give you any specifications? If not, a smart programmer will be spending that 8 hours hammering out the specs. Not a s... |
34,334 | Is it possible to attain stream-entry if one is only following "the 5 precepts"?
Are there any suttas that seem to address this question? | 2019/07/29 | [
"https://buddhism.stackexchange.com/questions/34334",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/14288/"
] | "entering the stream" means you understood the main point of Buddhism and started applying that point to your entire life.
Which point? -- That you should stop creating causes for future dukkha.
Which causes create dukkha? -- Whatever leads to increase of conflict, increase of side-taking, increase of attachment, inc... | **Would experiential faith in the Buddha, the Teaching, the Sangha and following the 5 precepts be enough for stream-entry?**
I'd like to say "yes" -- and that "experiential faith" is already *a lot* and must be enough to begin to work with.
What troubles me, about that answer, is that maybe there is something else i... |
7,587,442 | my development style brings me to write a lot of **throw-away "assisting" code**,
whether for automatic generation of code parts, semi-automated testing, and generally to build dummies, prototypes or temporary "sparring partners" for the main development; **I know I'm not the only one...**
since I frequently work bo... | 2011/09/28 | [
"https://Stackoverflow.com/questions/7587442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120747/"
] | The problem is that you're displaying `time()`, which is a UNIX timestamp based on GMT/UTC. That’s why it doesn’t change. `date()` on the other hand, *formats* the time based on that timestamp.
A *timestamp* is the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
```php
echo date('Y-m-d H:i:s T'... | In PHP DateTime (PHP >= 5.3)
```
$dt = new DateTime();
$dt->setTimezone(new DateTimeZone('UTC'));
echo $dt->getTimestamp();
``` |
13,248,094 | I am developing an app where I am using customized listview. First i will go with code and i will ask my question(at bottom).
Main.java (using adapter class to set data to listview)
```
Myadapter adapter = new Myadapter();
listview.setAdapter(adapter);
```
}
custom.xml
```
<LinearLayout xmlns:android="htt... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13248094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You make your live very hard yourself in NOT implementing a proper Model. You should parse your Json outside the Adapter and make Java-classes out of these informations. Then pass a List or an Array as data to your Adapter, while returning Model-objects in `getItem(position)`!
This way you flawlessly can implement an `... | ```
for that you have to implement the OnItemClickListener event on listview .
listview.OnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.