Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
34,747,954 | Unable to reverse all the characters in the below code along with spaces | The code below reverses all the characters in a sentence.But it is unable to do so.This is a kid stuff but at this moment it's not compiling.Can anyone figure out the issue
Let's say: "Smart geeks are fast coders".The below code should reverse as following: "trams skeeg era tsaf sredoc"
function solution(S)
{
var result = false;
if(S.length === 1)
{
result = S;
}
if(S.length > 1 && S.length < 100)
{
var wordsArray = S.split(" ");
var wordsCount = wordsAray.length;
var reverseWordsString = '';
for(var i=0; i<wordsCount; i++)
{
if(i > 0)
{
reverseWordsString = reverseWordsString + ' ';
}
reverseWordsString = reverseWordsString + wordsAray[i].split("").reverse().join("");
}
result = reverseWordsString;
}
return result;
}
| <javascript> | 2016-01-12 15:45:59 | LQ_EDIT |
34,748,034 | How to get the progress of WebView while loading the data, Xamarin.Forms | <p>I am developing an App using Xamarin.Forms for listing the news from different sources. I use a webView to open the link corresponding to the news. But I want to show the progress while loading the webpage into web view, like the progress bar on Safari App. For this I have used the ProgressBar element like this:</p>
<pre><code><StackLayout>
<!-- WebView needs to be given height and width request within layouts to render. -->
<ProgressBar Progress ="" HorizontalOptions="FillAndExpand" x:Name="progress"/>
<WebView x:Name="webView"
HeightRequest="1000"
WidthRequest="1000"
VerticalOptions= "FillAndExpand"
Navigating="webOnNavigating"
Navigated="webOnEndNavigating"/>
</StackLayout>
</code></pre>
<p>and in the code I have used</p>
<pre><code>void webOnNavigating (object sender, WebNavigatingEventArgs e)
{
progress.IsVisible = true;
}
void webOnEndNavigating (object sender, WebNavigatedEventArgs e)
{
progress.IsVisible = false;
}
</code></pre>
<p>But I want to show also the progress of loading the data, not just an indication that is loading and load. I want the user to know that the data are loading. Is there a way to achieve this.</p>
| <webview><progress-bar><xamarin.forms><progress> | 2016-01-12 15:49:17 | HQ |
34,748,386 | jQuery id^= not working? | <p>Hi I'm trying to simulate a click on multiple buttons which all start with the same id values. I did not make this site I'm trying to make a script so users don't have to press every button. Selecting the individual id works but when I try to use id^= it does not:</p>
<pre><code>$(id='UnsubscribeItemBtn485527146')
<a href="javascript:UnsubscribeItem( '485527146', '255710' );" id="UnsubscribeItemBtn485527146" class="btn_grey_black btn_medium">…</a>
$(id^='UnsubscribeItemBtn')
0
</code></pre>
<p>Can anyone shed some light on this?
If I'm being really stupid go easy I'm new to this!
</p>
| <jquery> | 2016-01-12 16:04:59 | LQ_CLOSE |
34,748,872 | How to check whether DbContext has transaction? | <p>Background:
I have WCF service with SimpleInjector as IoC which creates instance of DbContext per WCF request.</p>
<p>Backend itself is CQRS. CommandHandlers have a lot of decorators (validation, authorization, logging, some common rules for different handler groups etc) and one of them is Transaction Decorator:</p>
<pre><code>public class TransactionCommandHandlerDecorator<TCommand> : ICommandHandler<TCommand>
where TCommand : ICommand
{
private readonly ICommandHandler<TCommand> _handler;
private readonly IMyDbContext _context;
private readonly IPrincipal _principal;
public TransactionCommandHandlerDecorator(ICommandHandler<TCommand> handler,
IMyDbContext context, IPrincipal principal)
{
_handler = handler;
_context = context;
_principal = principal;
}
void ICommandHandler<TCommand>.Handle(TCommand command)
{
using (var transaction = _context.Database.BeginTransaction())
{
try
{
var user = _context.User.Single(x => x.LoginName == _principal.Identity.Name);
_handler.Handle(command);
_context.SaveChangesWithinExplicitTransaction(user);
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
throw;
}
}
}
}
</code></pre>
<p>Problem occurs when any command tries to chain execute another command within the same WCF request.
I got an expected exception at this line:</p>
<pre><code>using (var transaction = _context.Database.BeginTransaction())
</code></pre>
<p>because my DbContext instance already has a transaction.</p>
<p>Is there any way to check current transaction existence?</p>
| <c#><entity-framework><simple-injector> | 2016-01-12 16:28:55 | HQ |
34,749,333 | PowerShell guidelines for -Confirm, -Force, and -WhatIf | <p>Are there any official guidelines from Microsoft about when to add <code>-Confirm</code>, <code>-Force</code>, and <code>-WhatIf</code> parameters to custom PowerShell cmdlets? There doesn't seem to be a clear consensus about when/how to use these parameters. For example <a href="https://github.com/Azure/azure-powershell/issues/475" rel="noreferrer">this issue</a>.</p>
<p>In the absence of formal guidelines, is there a best practice or rule of thumb to use? Here is some more background, with my current (possibly flawed) understanding:</p>
<h2>-WhatIf</h2>
<p>The <code>-WhatIf</code> flag displays what the cmdlet <em>would do</em> without actually performing any action. This is useful for a dry run of a potentially destabilizing operation, to see what the actual results would be. The parameter is automatically added if the cmdlet's <code>Cmdlet</code> attribute has the <a href="https://msdn.microsoft.com/en-us/library/system.management.automation.cmdletcommonmetadataattribute.supportsshouldprocess(v=vs.85).aspx" rel="noreferrer"><code>SupportsShouldProcess</code></a> property set to true.</p>
<p>It seems like (but I'd love to see more official guidance here) that you should add <code>-WhatIf</code> if you are ever adding or removing resources. (e.g. deleing files.) Operations that update existing resources probably wouldn't benefit from it. Right?</p>
<h2>-Force</h2>
<p>The <code>-Force</code> switch is used to declare "I know what I'm doing, and I'm sure I want to do this". For example, when copying a file (<a href="https://technet.microsoft.com/en-us/library/hh849793.aspx" rel="noreferrer"><code>Copy-File</code></a>) the <code>-Force</code> parameter means:</p>
<blockquote>
<p>Allows the cmdlet to copy items that cannot otherwise be changed, such as copying over a read-only file or alias.</p>
</blockquote>
<p>So to me it seems like (again, I'd love some official guidance here) that you should add an optional <code>-Force</code> parameter when you have a situation where the cmdlet would otherwise fail, but can be convinced to complete the action.</p>
<p>For example, if you are creating a new resource that will clobber an existing one with the same name. The default behavior of the cmdlet would report an error and fail. But if you add <code>-Force</code> it will continue (and overwrite the existing resource). Right?</p>
<h2>-Confirm</h2>
<p>The <code>-Confirm</code> flag gets automatically added like <code>-WhatIf</code> if the cmdlet has <code>SupportsShouldProcess</code> set to true. In a cmdlet if you call <a href="https://msdn.microsoft.com/en-us/library/system.management.automation.cmdlet.shouldprocess(v=vs.85).aspx" rel="noreferrer"><code>ShouldProcess</code></a> then the user will be prompted to perform the action. And if the <code>-Confirm</code> flag is added, there will be no prompt. (i.e. the confirmation is added via the cmdlet invocation.)</p>
<p>So <code>-Confirm</code> should be available whenever a cmdlet has a big impact on the system. Just like <code>-WhatIf</code> this should be added whenever a resource is added or removed.</p>
<p>With my potentially incorrect understanding in mind, here are some of the questions I'd like a concrete answer to:</p>
<ul>
<li>When should it be necessary to add <code>-WhatIf</code>/<code>-Confirm</code>?</li>
<li>When should it be necessary to add <code>-Force</code>?</li>
<li>Does it ever make sense to support both <code>-Confirm</code> and <code>-Force</code>?</li>
</ul>
| <powershell> | 2016-01-12 16:49:54 | HQ |
34,749,943 | Python with...as for custom context manager | <p>I wrote a simple context manager in Python for handling unit tests (and to try to learn context managers):</p>
<pre><code>class TestContext(object):
test_count=1
def __init__(self):
self.test_number = TestContext.test_count
TestContext.test_count += 1
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, exc_traceback):
if exc_value == None:
print 'Test %d passed' %self.test_number
else:
print 'Test %d failed: %s' %(self.test_number, exc_value)
return True
</code></pre>
<p>If I write a test as follows, everything works okay.</p>
<pre><code>test = TestContext()
with test:
print 'running test %d....' %test.test_number
raise Exception('this test failed')
</code></pre>
<p>However, if I try to use with...as, I don't get a reference to the TestContext() object. Running this:</p>
<pre><code>with TestContext() as t:
print t.test_number
</code></pre>
<p>Raises the exception <code>'NoneType' object has no attribute 'test_number'</code>.</p>
<p>Where am I going wrong?</p>
| <python> | 2016-01-12 17:19:11 | HQ |
34,751,196 | Creating Hyper-V Administrators group in Windows 10 | <p>I am receiving the error "Unable to add user to the Hyper-V Administrators group. Exit code 2220" while attempting to deploy to an MS Android emulator. I am able to deploy windows mobile emulators as well as Linux VMs in Hyper-V.</p>
<ul>
<li>Windows 10 Pro</li>
<li>Visual Studio 2015 Professional Update 1</li>
<li>MS VS Emulator for Android 1.0.60106.1</li>
<li>Xamarin 4.0.0.1717</li>
</ul>
<p>I do not have a Hyper-V Administrators group. Numerous questions and blogs have suggested that I uninstall Hyper-V and reinstall. I tried this, it didn't create the Hyper-V Administrators group.</p>
<p>I've read several articles from Ben Armstrong (aka twitter @virtualpcguy) a Hyper-V Program Manager on how to manually create/add users to the group, as well as some powershell scripts to automate this. Unfortunately these are based on Server 2008 R2, Windows 7, and Windows 8. In my reading it looks like windows 10 does not use <strong>InitialStore.xml</strong> </p>
<ul>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/01/17/allowing-non-administrators-to-control-hyper-v.aspx">Allowing non-Administrators to control Hyper-V</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/06/11/allowing-non-administrators-to-control-hyper-v-updated.aspx">Allowing non-Administrators to control Hyper-V–Updated</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/28/creating-a-hyper-v-administrators-local-group-through-powershell.aspx">Creating a “Hyper-V Administrators” local group through PowerShell</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/27/setting-up-non-administrative-control-of-hyper-v-through-powershell.aspx">Setting up non-administrative control of Hyper-V through PowerShell</a></li>
</ul>
<p>Although I can manually add a group, Hyper-V Administrators, using lusrmgr.msc and add myself as a user I don't know how to apply the permissions for Hyper-V.</p>
<p>Note: This Windows 10 was installed with a non pro version, then upgraded to Pro. Might this be a factor in the missing Hyper-V Supervisors group? </p>
| <windows><visual-studio><xamarin><hyper-v> | 2016-01-12 18:27:38 | HQ |
34,751,837 | Git - Can we recover deleted commits? | <p>I am surprised, I couldn't find the answer to this on SO.</p>
<blockquote>
<p>Can we recover/restore deleted commits in git?</p>
</blockquote>
<p>For example, this is what I did:</p>
<pre><code># Remove the last commit from my local branch
$ git reset --hard HEAD~1
# Force push the delete
$ git push --force
</code></pre>
<p>Now, is there a way to get back the commit which was deleted? Does git record(log) the delete internally?</p>
| <git><restore><git-commit> | 2016-01-12 19:06:00 | HQ |
34,752,722 | C--> Why isn't the compound assignment taken into account when displaying the latter 'tot'? |
#include <stdio.h>
main(){
int pro;
int dot;
int tot;
char prelude[] = "\nNow we shall do some simple mathematics\n\n";
printf("%s", prelude);
pro = 3;
dot = 5;
tot = pro + dot;
printf("%d", tot);
dot += 23;
printf("\n%d\n", tot);
return 0;}
| <c><compound-assignment> | 2016-01-12 19:59:38 | LQ_EDIT |
34,752,763 | How to show json value in php page | someone please tell me how we can show this value on php file viea {echo json_encode($array);} ?
var formData=new FormData();
formData.append("fieldname","value");
formData.append("image",$('[name="filename"]')[0].files[0]);
$.ajax({
url:"page.php",
data:formData,
type: 'POST',
dataType:"JSON",
cache: false,
contentType: false,
processData: false,
success:function(data){ }
});
| <php><jquery><ajax> | 2016-01-12 20:01:56 | LQ_EDIT |
34,753,001 | Spark Framework: Match with or without trailing slash | <p>I have noticed something in the Spark Framework. It does not match trailing slashes with a mapped route. So it considers /api/test and /api/test/ as different URIs.</p>
<p>That's fine if there is a way to wildcard them together, but there doesn't seem to be. Am I missing anything?</p>
<p>I want this route:</p>
<pre><code>Spark.get("/api/test", (req, res) -> {
return "TEST OK";
});
</code></pre>
<p>To match /api/test OR /api/test/. As it stands, it only matches /api/test, and if I switch it to:</p>
<pre><code>Spark.get("/api/test/", (req, res) -> {
return "TEST OK";
});
</code></pre>
<p>It only matches <code>/api/test/</code></p>
| <java><routes><spark-java><spark-framework> | 2016-01-12 20:17:40 | HQ |
34,753,050 | data.table - select first n rows within group | <p>As simple as it is, I don't know a <code>data.table</code> solution to select the first n rows in groups in a data table. Can you please help me out?</p>
| <r><data.table> | 2016-01-12 20:20:44 | HQ |
34,753,214 | JSON formatted logging with Flask and gunicorn | <p>I am trying to do something very similar to what's explained here: <a href="https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/" rel="noreferrer">https://sebest.github.io/post/protips-using-gunicorn-inside-a-docker-image/</a></p>
<p>I want to get my Flask app + gunicorn both outputting JSON formatted logging. I've got this working for the Flask app, but I can't seem to get it working with gunicorn.</p>
<p>Here's my current output:</p>
<pre><code> * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 317-187-130
192.168.99.1 - - [12/Jan/2016 20:09:29] "GET /nothing HTTP/1.1" 404 -
{"asctime": "2016-01-12 20:20:25,541", "levelname": "WARNING", "module": "app", "funcName": "err", "lineno": 17, "message": "will assert false..."}
192.168.99.1 - - [12/Jan/2016 20:20:25] "GET /err HTTP/1.1" 500 -
</code></pre>
<p>The line that begins <code>{"asctime":</code> is the output of the code <code>app.logger.warning('will assert false...')</code> which is being correctly logged as JSON. Yay. The lines that begin with <code>192.168.99.1</code> are output from my gunicorn WSGI server and, frustratingly, they are not JSON formatted.</p>
<p>Here's the command I am using to start gunicorn:</p>
<pre><code>gunicorn --log-config gunicorn_logging.conf -c gunicorn_config.py api.app:app
</code></pre>
<p>where the <code>gunicorn_logging.conf</code> file contains:</p>
<pre><code>[loggers]
keys=root, gunicorn.error
[handlers]
keys=console
[formatters]
keys=json
[logger_root]
level=INFO
handlers=console
[logger_gunicorn.error]
level=ERROR
handlers=console
propagate=0
qualname=gunicorn.error
[handler_console]
class=StreamHandler
formatter=json
args=(sys.stdout, )
[formatter_json]
class=jsonlogging.JSONFormatter
</code></pre>
<p>and the file <code>gunicorn_config.py</code> contains:</p>
<pre class="lang-python prettyprint-override"><code>import os
import multiprocessing
addr = os.environ.get('HTTP_ADDR', '0.0.0.0')
port = os.environ.get('HTTP_PORT', '5000')
loglevel = os.environ.get('LOG_LEVEL', 'info')
bind = '{0}:{1}'.format(addr, port)
workers = multiprocessing.cpu_count() * 5 + 1
worker_class = 'gevent'
timeout = 0
</code></pre>
<p>Here's the output of <code>pip freeze</code>:</p>
<pre><code>aniso8601==1.1.0
coverage==4.0.3
flake8==2.5.1
Flask==0.10.1
Flask-MySQLdb==0.2.0
Flask-RESTful==0.3.5
Flask-Script==2.0.5
gevent==1.1rc3
greenlet==0.4.9
gunicorn==19.4.5
itsdangerous==0.24
Jinja2==2.8
json-logging-py==0.2
MarkupSafe==0.23
marshmallow==2.4.2
mccabe==0.3.1
mysqlclient==1.3.7
nose==1.3.7
pep8==1.5.7
pyflakes==1.0.0
python-dateutil==2.4.2
python-json-logger==0.1.4
pytz==2015.7
six==1.10.0
SQLAlchemy==1.0.11
Werkzeug==0.11.3
</code></pre>
| <python><json><logging><flask><gunicorn> | 2016-01-12 20:30:30 | HQ |
34,753,816 | AFNetworking 3.0 AFHTTPSessionManager using NSOperation | <p>I'm stuck now some time and I need help. So in AFNetworking 2.0 we have <code>AFHTTPRequestOperation</code> so I could easily use <code>NSOperationQueue</code> and have some dependencies. So what we have now is only <code>AFHTTPSessionManager</code>and <code>NSURLSession</code> that does not subclass <code>NSOperation</code>. I have class <code>APIClient</code> that subclasses <code>AFHTTPSessionManager</code>. I am using that class as singleton as <code>sharedClient</code>. I have overriden GET and POST so for example GET looks this: </p>
<pre><code>- (NSURLSessionDataTask *)GET:(NSString *)URLString
parameters:(NSDictionary *)parameters
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure {
NSURLSessionDataTask *task = [super GET:URLString parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
success(task, responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
failure(task, [Response createErrorWithAFNetworkingError:error]);
}];
return task;
}
</code></pre>
<p>Do you have any idea how to implement in that manner (if it's possible) to wrap that as <code>NSOperation</code>? So what I want to do - I want to be able to run in parallel two network calls, and after that have another method call that depends on second network call of first two calls. Do you have any idea what would be best approach?</p>
| <ios><objective-c><afnetworking><nsurlsession> | 2016-01-12 21:07:28 | HQ |
34,754,012 | Securing Registration RESTful API against registering many users | <p>I am developing <code>RESTful APIs</code> with <code>ASP.NET WebAPI</code> for an <code>Android application</code> and there is an option to make a registration through our application. Suppose that our registration endpoint is something like '/api/register/' with some parameters like 'username', 'password' and 'email address'. So this endpoint is likely to be opened not only for Android device, but for everyone.</p>
<p>I mean it is easy to trace all the requests and responses to and from our server, so a bad person may calls this endpoint to start registering many users in our system.</p>
<p>I want to know how I can secure my API?</p>
| <rest><security> | 2016-01-12 21:22:10 | HQ |
34,754,295 | Angular2 Router - Anyone know how to use canActivate in app.ts so that I can redirect to home page if not logged in | <p>Angular2 Router - Anyone know how to use canActivate in app.ts so that I can redirect to home page if not logged in</p>
<p>I'm using typescript and angular 2.</p>
<p><strong>Current attempt under my constructor in my app.ts file:</strong></p>
<pre><code> canActivate(instruction) {
console.log("here - canActivate");
console.log(instruction);
this.router.navigate(['Home']);
}
</code></pre>
<p>It currently doesnt get hit.
Any idea why?</p>
| <typescript><angular><angular2-routing> | 2016-01-12 21:40:56 | HQ |
34,754,413 | Is it possible to execute functions in a hosted php file from android/java? | <p>I have an amazon web services MySql database that I want to perform CRUD operations on from an android application. I think that the way to do this is through some HTTP protocol and get and post operations. However, I have access to PHP code that connects to the database and allows me to execute quires. This PHP code is hosted on an elastic beanstalk application. Someone else has used this same code to connect the database to IOS. I am just trying to figure out how it all works.</p>
<p>Is it possible to use the PHP that is hosted to act as an API for me? </p>
<p>--I cant post any links due to security concerns, sorry.--</p>
| <java><php><android><amazon-web-services><amazon-elastic-beanstalk> | 2016-01-12 21:50:37 | LQ_CLOSE |
34,755,394 | RUBY: How to read an array from a file and store it in an array | I am trying to read an array from a file and save it in myArray[]. Ex File1.txt is ["abc", "def"...] I want to be able to parse myArray[0] which is "abc", myArray[1] which is "def" and so on..How do I do it in Ruby? | <arrays><ruby><file> | 2016-01-12 22:59:50 | LQ_EDIT |
34,755,770 | modal appear behind fixed navbar | <p>so i have bootstrap based site with fixed navigation bar (that follow you around the page at the top) and when i want to show modal popup, it appear behind those navigation bar, how to fix?</p>
<p>and i using <a href="https://graygrids.com/item/margo-free-multi-purpose-bootstrap-template/" rel="noreferrer">margo template from graygrids</a></p>
<p>it also appear in summernote modals for uploading picture, so it looks like all modal will appear behind those navigation bar.</p>
<p><a href="https://i.stack.imgur.com/mZy6x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mZy6x.png" alt="enter image description here"></a></p>
| <html><css><twitter-bootstrap> | 2016-01-12 23:31:52 | HQ |
34,756,264 | Spring Boot with datasource when testing | <p>I am using Spring Boot application and the auto cofiguration is enabled. The main Application file is marked as <code>@EnableAutoConfiguration</code>. The datasource is lookedup from JNDI is configured using java config and the class which create the datasource is marked as <code>@Configuration</code>.</p>
<p>I have a test class as below.</p>
<pre><code>@RunWith( SpringJUnit4ClassRunner.class )
@WebAppConfiguration
@ContextConfiguration( classes = Application.class )
public class TestSomeBusiness {}
</code></pre>
<p>The issue is when I run the test case, the datasource jndi lookup happens, which fails because the test case is not running inside a server environment. As far as I know the classes in classpath marked with <code>@Configuration</code> are executed and that the reason the datasource lookup is being called.</p>
<p>The work around for now I have found is instead of JNDI lookup create the datasource using <code>DriverManagerDataSource</code>, so that even if its not a server environment the datasource lookup won't fail.</p>
<p>My questions are:</p>
<p>1) How do we generally deal with datasource (when looking up from JNDI) in
spring boot application for testing ?</p>
<p>2) Is there a way to exclude the datasource configuration class from being called when executing test case ?</p>
<p>3) Should I create an embedded server so that the JNDI lookup can be done when executing test case ?</p>
| <java><spring><spring-boot> | 2016-01-13 00:16:22 | HQ |
34,756,402 | javascript: loop add number | <p>How to loop like this one in javascript?
11
21
32
43</p>
<p>I have this code already.</p>
<pre><code>for(var i=11; i <= 43; i += 10){
document.write(i+'<br>');
}
</code></pre>
| <javascript><loops> | 2016-01-13 00:31:47 | LQ_CLOSE |
34,756,524 | C - double result returning the value of 0 | <pre><code>#include <stdio.h>
int main(int argc, const char * argv[]) {
int a = 10;
int b = 20;
double result = a / b;
printf("%d divided by %d makes %f\n", a, b, result);
return 0;
}
</code></pre>
<p>Expecting that the <code>%f</code> would return 0.500000, I ran the code and it turned out to be 0.000000.</p>
<p>Is there a reason that the <code>result</code> variable is returning a zero value?</p>
| <c> | 2016-01-13 00:45:59 | LQ_CLOSE |
34,756,944 | How is document.querySelector implemented? | <p>I suppose the answer to this question depends on what browser you are using, but I guess that just makes it all the more interesting. </p>
<p>I'm wondering how the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector" rel="noreferrer"><code>querySelector()</code></a> method is actually implemented. Similarly, I'm curious about <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll" rel="noreferrer"><code>querySelectorAll()</code></a> and other methods like <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById" rel="noreferrer"><code>getElementById()</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName" rel="noreferrer"><code>getElementByClassName()</code></a> etc.</p>
<p>Is it a depth first search, breadth first search, or does it utilize some auxiliary data structure, like a global hash table to act as a registry?</p>
| <javascript><algorithm><dom><browser><tree> | 2016-01-13 01:32:18 | HQ |
34,757,477 | Illegal instruction (core dumped) neural network | I have a 3-layed neural network, and I keep getting the above error. I tried the fix here: http://stackoverflow.com/questions/10354147/find-which-assembly-instruction-caused-an-illegal-instruction-error-without-debu
And that actually did fix something because before it wasn't saying (core dumped)
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <fcntl.h>
#define NUMPAT 51
#define NUMIN 51
#define NUMHID 20
#define NUMOUT 20
#define rando() ((double)rand()/(RAND_MAX+1))
int main() {
int i, j, k, p, np, op, ranpat[NUMPAT+1], epoch, temp1, temp2, game;
int NumPattern = NUMPAT, NumInput = NUMIN, NumHidden = NUMHID, NumOutput = NUMOUT;
// double Input[NUMPAT+1][NUMIN+1] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 };
double Input[20][2][51] = { ...blah blah a bunch of data the problem isn't here...
double Target[20] = {10,10,3,-4,11,-2,13,-5,4,3,4,5,-5,25,13,25,3,2,5,17};
double SumH[NUMPAT+1][NUMHID+1], WeightIH[NUMIN+1][NUMHID+1], Hidden[NUMPAT+1][NUMHID+1];
double SumO[NUMPAT+1][NUMOUT+1], WeightHO[NUMHID+1][NUMOUT+1], Output[NUMPAT][20];
double DeltaO[NUMOUT+1], SumDOW[NUMHID+1], DeltaH[NUMHID+1];
double DeltaWeightIH[NUMIN+1][NUMHID+1], DeltaWeightHO[NUMHID+1][NUMOUT+1];
double Error, eta = 0.5, alpha = 0.9, smallwt = 0.5;
for( j = 0 ; j < NumHidden ; j++ ) { /* initialize WeightIH and DeltaWeightIH */
for( i = 0 ; i < NumInput ; i++ ) {
DeltaWeightIH[i][j] = 0.0 ;
WeightIH[i][j] = 2.0 * ( rando() - 0.5 ) * smallwt ;
}
}
for( k = 0 ; k < NumOutput ; k ++ ) { /* initialize WeightHO and DeltaWeightHO */
for( j = 0 ; j < NumHidden ; j++ ) {
DeltaWeightHO[j][k] = 0.0 ;
WeightHO[j][k] = 2.0 * ( rando() - 0.5 ) * smallwt ;
}
}
for( epoch = 0 ; epoch < 100000 ; epoch++) { /* iterate weight updates */
for( p = 1 ; p <= NumPattern ; p++ ) { /* randomize order of individuals */
ranpat[p] = p ;
}
for( p = 1 ; p <= NumPattern ; p++) {
np = p + rand() * ( NumPattern + 1 - p ) ;
op = ranpat[p] ; ranpat[p] = ranpat[np] ; ranpat[np] = op ;
}
Error = 0.0 ;
for( np = 1 ; np <= NumPattern ; np++ ) { /* repeat for all the training patterns */
p = ranpat[np];
for (game = 0; game < 20; game++){
for( j = 0 ; j < NumHidden ; j++ ) { /* compute hidden unit activations */
SumH[p][j] = WeightIH[0][j] ;
for( i = 0 ; i < NumInput ; i++ ) {
temp1 = Input[game][0][i] * WeightIH[i][j] ;
temp2 = Input[game][1][i] * WeightIH[i][j] ;
SumH[p][j] += temp1 - temp2 ;
}
Hidden[p][j] = 1.0/(1.0 + exp(-SumH[p][j])) ;
}
for( k = 0 ; k < NumOutput ; k++ ) { /* compute output unit activations and errors */
SumO[p][k] = WeightHO[0][k] ;
for( j = 0 ; j < NumHidden ; j++ ) {
SumO[p][k] += Hidden[p][j] * WeightHO[j][k] ;
}
Output[p][k] = 1.0/(1.0 + exp(-SumO[p][k])) ; /* Sigmoidal Outputs */
/* Output[p][k] = SumO[p][k]; L
ear Outputs */
Error += 0.5 * (Target[k] - Output[p][k]) * (Target[k] - Output[p][k]) ; /* SSE */
/* Error -= ( Target[p][k] * log( Output[p][k] ) + ( 1.0 - Target[p][k] ) * log( 1.0 - Output[p][k] ) ) ; Cross-Entropy Error */
DeltaO[k] = (Target[k] - Output[p][k]) * Output[p][k] * (1.0 - Output[p][k]) ; /* Sigmoidal Outputs, SSE */
/* DeltaO[k] = Target[p][k] - Output[p][k]; Sigmoidal Outputs, Cross-Entropy Error */
/* DeltaO[k] = Target[p][k] - Output[p][k]; Linear Outputs, SSE */
}
for( j = 0 ; j < NumHidden ; j++ ) { /* 'back-propagate' errors to hidden layer */
SumDOW[j] = 0.0 ;
for( k = 0 ; k < NumOutput ; k++ ) {
SumDOW[j] += WeightHO[j][k] * DeltaO[k] ;
}
DeltaH[j] = SumDOW[j] * Hidden[p][j] * (1.0 - Hidden[p][j]) ;
}
for( j = 0 ; j < NumHidden ; j++ ) { /* update weights WeightIH */
DeltaWeightIH[0][j] = eta * DeltaH[j] + alpha * DeltaWeightIH[0][j] ;
WeightIH[0][j] += DeltaWeightIH[0][j] ;
for( i = 0 ; i < NumInput ; i++ ) {
DeltaWeightIH[i][j] = eta * Input[game][0][i] * DeltaH[j] + alpha * DeltaWeightIH[i][j];
WeightIH[i][j] += DeltaWeightIH[i][j] ;
}
}
for( k = 0 ; k < NumOutput ; k ++ ) { /* update weights WeightHO */
DeltaWeightHO[0][k] = eta * DeltaO[k] + alpha * DeltaWeightHO[0][k] ;
WeightHO[0][k] += DeltaWeightHO[0][k] ;
for( j = 0 ; j < NumHidden ; j++ ) {
DeltaWeightHO[j][k] = eta * Hidden[p][j] * DeltaO[k] + alpha * DeltaWeightHO[j][k] ;
WeightHO[j][k] += DeltaWeightHO[j][k] ;
}
}
}
}
if( epoch%100 == 0 ) fprintf(stdout, "\nEpoch %-5d : Error = %f", epoch, Error) ;
if( Error < 0.0004 ) break ; /* stop learning when 'near enough' */
}
int sum = 0;
double weights[51];
for (i = 0; i < NumInput; i++){
for (j = 0; j < NumHidden; j++){
sum = WeightIH[i][j];
}
sum /= 51;
weights[i] = sum;
}
for (i = 0; i < 51; i++){
printf("weight[%d] = %G\n", i, weights[i]);
}
return 1 ;
}
I'm compiling with: `gcc nn.c -O -lm -o nn -mmacosx-version-min=10.11` and it compiles fine.
Any idea what's going on here? | <c><machine-learning><neural-network><instructions> | 2016-01-13 02:38:00 | LQ_EDIT |
34,757,759 | Why is the compiler-generated enumerator for "yield" not a struct? | <p>The <a href="http://csharpindepth.com/Articles/Chapter6/IteratorBlockImplementation.aspx">compiler-generated implementation</a> of <code>IEnumerator</code> / <code>IEnumerable</code> for <code>yield</code> methods and getters seems to be a class, and is therefore allocated on the heap. However, other .NET types such as <code>List<T></code> specifically return <code>struct</code> enumerators to avoid useless memory allocation. From a quick overview of the <em>C# In Depth</em> post, I see no reason why that couldn't also be the case here. </p>
<p>Am I missing something?</p>
| <c#><struct><heap><ienumerable><yield> | 2016-01-13 03:09:58 | HQ |
34,758,047 | Sql server Row To Columns Data | I have data in a SQL Table with the following structure:
Engine_No Date Process Bolt_No1 B1Value1 B1Value2 B1Value3 Bolt_No2 B2Value1 B2Value2 B2Value3 Bolt_No3 B3Value1 B3Value2 B3Value3 Bolt_No4 B4Value1 B4Value2 B4Value3
I want to display the following results of a query:
Engine_No Date Process Bolt_No1 B1Value1 B1Value2 B1Value3
Engine_No Date Process Bolt_No2 B2Value1 B2Value2 B2Value3
Engine_No Date Process Bolt_No3 B3Value1 B3Value2 B3Value3
Engine_No Date Process Bolt_No4 B4Value1 B4Value2 B4Value3
Can someone suggest a auery that achieves this? | <sql-server> | 2016-01-13 03:45:26 | LQ_EDIT |
34,758,552 | How to change Facebook iOS SDK's done button color when login? | <p><a href="https://i.stack.imgur.com/Bunc3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Bunc3.png" alt="enter image description here"></a></p>
<p>My app use white UITabBarItem text color and orange UINavigationBar BarTintColor, when click the Login button added from Facebook SDK, it will popup a webview for login.</p>
<p>but the topbar background color always light gray, if I change the UITabBarItem color, other view will all changed, How can I only custom the button color in Facebook login view or change the navbar background color?</p>
| <customization><facebook-login><facebook-ios-sdk> | 2016-01-13 04:42:44 | HQ |
34,758,568 | How can I get sql results over 100 in apache zeppelin? | <p>When I execute this query in apache-zeppelin I get only 100 results with 'Results are limited by 100.' message.</p>
<pre><code>%sql
SELECT ip
FROM log
</code></pre>
<p>So I appended 'Limit 10000' in SQL query, but it returns only 100 results again.</p>
<pre><code>%sql
SELECT ip
FROM log
LIMIT 10000
</code></pre>
<p>So, How can I get sql results over 100 in zeppelin?</p>
| <apache-zeppelin> | 2016-01-13 04:45:07 | HQ |
34,758,860 | How to get the count of no of tags in one element in xml using xml or java code | My .xml doc contains data like this
<Test-Set>
<Test-Case Name="Verify using Interface user in WebService we are able to do database transactions" />
<Test-Case Name="Verify using Interface user in JMS we are able to post a message to queue and get message from queue" />
<Test-Case Name="Verify using Interface user we are able to login BPD"/>
</Test-Set>
My excepted output is 3 | <java><xml> | 2016-01-13 05:14:35 | LQ_EDIT |
34,759,034 | what is wrong with: select CONVERT(date,N'13/01/2016') | I used sql server 2028 R when I run the above a script I get this error anyone could help please
error message:
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string. | <sql><sql-server-2008-r2> | 2016-01-13 05:29:01 | LQ_EDIT |
34,759,443 | How to clear all items in a listbox when we change our selection in a dropdownlistbox? | I have a Listbox named listbox1 ,a show button and a dropdownlist box in my aspx page.
*dropdownlistbox lists grouptypes.
*show button on click will fetch data based on grouptype from DB and populate in Listbox1.
*But if i change my selection of grouptype the items in listbox remains the same of earlier selection.I want to clear the items upon change in selection in dropdownlistbox before clicking the show button.
Someone help me out.
| <asp.net><drop-down-menu><listbox><pageload> | 2016-01-13 06:00:45 | LQ_EDIT |
34,759,780 | Why do we use concrete clases in java? | <p><strong>why do we use concrete classes in java?</strong>
I've tried a lot to search a proper reason,but all i found is comparison between abstract class and concrete class.
i want to know in what kind of conditions we need to create concrete classes.</p>
| <java> | 2016-01-13 06:26:08 | LQ_CLOSE |
34,760,749 | Dropdown item select chage event | net. I have one dropdown list. On select item in dropdown list i want to open dropdown list2. As same on select of dropdownlist2 item i want to open 2 textboxes and 2 labels. This should be change on dropdownlist2 item select. Hope you getting my question. Help Me. Thanx & | <asp.net> | 2016-01-13 07:28:58 | LQ_EDIT |
34,760,785 | Scroll second child in AppBarLayout | <p>I'm trying to obtain this effect where if the user scroll a <code>RecyclerView</code> a certain layout scroll up together with the recycler and disappear behind a <code>Toolbar</code>.</p>
<p>A similar behavior could be obtained using the <code>CoordinatorLayout</code>, this would be possible by setting</p>
<pre><code>app:layout_behavior="@string/appbar_scrolling_view_behavior"
</code></pre>
<p>on the said Recycler, and doing</p>
<pre><code><android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
</code></pre>
<p>Also, If I put a second child inside the <code>AppBarLayout</code>, and set <code>app:layout_scrollFlags</code> to it, the effect obtained is the same, with both layout scrolling together with the Recycler.</p>
<p>What I'm trying to achieve is to keep the first child (The toolbar) fixed in position, and let the second child (a <code>LinearLayout</code>) to scroll and hide behind the toolbar. Unfortunately I couldn't get to this behavior.</p>
<p>Is it possible without using 3rd part library?
Thanks in advance and sorry for my english.</p>
| <android><android-coordinatorlayout><android-appbarlayout><custom-scrolling> | 2016-01-13 07:30:59 | HQ |
34,761,047 | How to install jenkins plugins from command line? | <p>Is there any option to install jenkins plugins from command line ?</p>
<p>I found a command for this after a bit google search : </p>
<pre><code>java -jar /var/lib/jenkins/jenkins.war -s http://127.0.0.1:8080/ install-plugin ${Plugin_Name}
</code></pre>
<p>But it's not working.</p>
| <testing><jenkins><jenkins-plugins> | 2016-01-13 07:47:12 | HQ |
34,761,224 | Angular2 child property change not firing update on bound property | <p>I have a simple custom directive with an input, that I'm binding to in my component. But for whatever reason, the ngOnchanges() method doesn't fire when changing a child property of the input property.</p>
<p>my.component.ts</p>
<pre><code>import {Component} from 'angular2/core';
import {MyDirective} from './my.directive';
@Component({
directives: [MyDirective],
selector: 'my-component',
templateUrl: 'Template.html'
})
export class MyComponent {
test: { one: string; } = { one: "1" }
constructor( ) {
this.test.one = "2";
}
clicked() {
console.log("clicked");
var test2: { one: string; } = { one :"3" };
this.test = test2; // THIS WORKS - because I'm changing the entire object
this.test.one = "4"; //THIS DOES NOT WORK - ngOnChanges is NOT fired=
}
}
</code></pre>
<p>my.directive.ts</p>
<pre><code>import {Directive, Input} from 'angular2/core';
import {OnChanges} from 'angular2/core';
@Directive({
selector: '[my-directive]',
inputs: ['test']
})
export class MyDirective implements OnChanges {
test: { one: string; } = { one: "" }
constructor() { }
ngOnChanges(value) {
console.log(value);
}
}
</code></pre>
<p>template.html</p>
<pre><code><div (click)="clicked()"> Click to change </div>
<div my-directive [(test)]="test">
</code></pre>
<p>Can anyone tell me why?</p>
| <typescript><angular> | 2016-01-13 07:59:56 | HQ |
34,761,305 | What is Callback URL in Facebook webhook page subscription? | <p>I'm trying to stream the real time public feeds using Facebook Web-hook API. Here I'm trying to set up a page subscription in Web-hook console. There is a field called Callback URL. What is this URL about?</p>
<p>I have also tried going through the documentation for Setting up callback URL. but I Couldn't figure out. </p>
<p><a href="https://developers.facebook.com/docs/graph-api/webhooks#setup" rel="noreferrer">https://developers.facebook.com/docs/graph-api/webhooks#setup</a></p>
<p>Cant the callback URL be SSL localhost? Whenever I try to give a localhost URL i get a error message "Unable to verify provided URL". </p>
| <facebook><facebook-graph-api><webhooks><facebook-public-feed-api> | 2016-01-13 08:05:14 | HQ |
34,761,622 | How to get user's high resolution profile picture on Twitter? | <p>I was reading the Twitter documentation at <a href="https://dev.twitter.com/overview/general/user-profile-images-and-banners" rel="noreferrer">https://dev.twitter.com/overview/general/user-profile-images-and-banners</a> and it clearly states that:</p>
<blockquote>
<p>Alternative image sizes for user profile images You can obtain a
user’s most recent profile image, along with the other components
comprising their identity on Twitter, from GET users/show. Within the
user object, you’ll find the profile_image_url and
profile_image_url_https fields. These fields will contain the resized
“normal” variant of the user’s uploaded image. This “normal” variant
is typically 48px by 48px.</p>
<p>By modifying the URL, you can retrieve other variant sizings such as
“bigger”, “mini”, and “original”. Consult the table below for more
examples:</p>
<p>Variant Dimensions Example URL normal 48px by
48px <a href="http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png" rel="noreferrer">http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png</a>
<a href="https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png" rel="noreferrer">https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png</a>
bigger 73px by
73px <a href="http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_bigger.png" rel="noreferrer">http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_bigger.png</a>
<a href="https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_bigger.png" rel="noreferrer">https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_bigger.png</a>
mini 24px by
24px <a href="http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_mini.png" rel="noreferrer">http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_mini.png</a>
<a href="https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_mini.png" rel="noreferrer">https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_mini.png</a>
original original <a href="http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png" rel="noreferrer">http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png</a>
<a href="https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png" rel="noreferrer">https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png</a>
Omit the underscore and variant to retrieve the original image. The
images can be very large.</p>
</blockquote>
<p>Twitter API's response is like this for my own account: </p>
<pre><code>{
....
"profile_image_url_https" = "https://pbs.twimg.com/profile_images/559415382457348097/qSYxxIAo_normal.png";
...
}
</code></pre>
<p>That image URL works, but it's too small. I need the highest resolution available. I do exactly what Twitter says, and omit the <code>_normal</code> suffix, and try this URL:</p>
<p><a href="https://pbs.twimg.com/profile_images/559415382457348097/qSYxxIAo.png" rel="noreferrer">https://pbs.twimg.com/profile_images/559415382457348097/qSYxxIAo.png</a></p>
<p>But it's not found. Is Twitter docs outdated or am I missing a point?</p>
<p><strong>UPDATE:</strong> I've tried with a few friends' profiles and most of them seem to work, and removing any suffixes and adding <code>_400x400.[jpg|png]</code> also seems to work, but it's undocumented and unreliable, so I really doubt that I should be using this undocumented API in production.</p>
<p><strong>UPDATE 2:</strong> I've refreshed my user object as Twitter also states in case of outdated images, but nothing has changed.</p>
| <twitter> | 2016-01-13 08:24:16 | HQ |
34,761,666 | JAVA - How do i compile this specific GitHub? I've tried, but failed | I've tried for few hours.. and failed. i can't seem to get it to work. ( in NetBeans)
I've added libraries that creator pointed out, source and nbproject - I get errors.
Can someone tell me what to do step by step? Thank you in advance.
**LINK TO GITHUB:** https://github.com/lucidexploration/JonBot-NG | <java><netbeans> | 2016-01-13 08:27:09 | LQ_EDIT |
34,763,477 | convert D/M/YYYY to YYYY/MM/DD (ex : 1/6/2015 --> 2015/06/01 not 2015/6/1) | Hello i have to convert a date like D/M/YYYY to YYYY/MM/DD Ex : 1/6/2015 --> 2015/06/01 not 2015/6/1
I have some conditions to be met :
- when it convert the month like Jan "1" must give : 01
Feb "2" must give : 02 etc
- i have to use Date()
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
var st = "D/M/YYYY"
var dt = new Date(st);
var maFonction = function (userdate){
var day = st.getDate();
var month = st.getMonth();
var year = st.getFullYear();
var maDate = year + "/" + day + "/" + month;
return maDate;
}
console.log(maFonction(st));
<!-- end snippet -->
I tried but it doesn't works :
I am a beginner so explain to me :)
Thanks a lot !
| <javascript><date> | 2016-01-13 09:56:29 | LQ_EDIT |
34,764,287 | Turning off eslint rule for a specific file | <p>Is it possible to turn off the eslint rule for the whole file? Something such as:</p>
<pre><code>// eslint-disable-file no-use-before-define
</code></pre>
<p>(Analogous to eslint-disable-line.) It happens to me quite often, that in a certain file, I'm breaking a specific rule on many places which is considered OK for that file, but I don't want to disable the rule for the whole project nor do I want to disable other rules for that specific file.</p>
| <javascript><configuration><lint><eslint> | 2016-01-13 10:31:09 | HQ |
34,764,659 | what is the mistake in this code? It gives an error:undefined filename | //this is my form controller to insert details with image in database table
public function store(Applicant $appl, ApplicantForm $request)
{
if($request->hasFile('ppimg_filename'))
{
$destinationPath="offerimages";
$file = $request->file('ppimg_filename');
$filename=$file->getClientOriginalName();
$request->file('ppimg_filename')->move($destinationPath,$filename);
}
$a=$appl->create($request->all());
$a['ppimg_filename'] = $filename;
return 'done';
} | <php><laravel-5.1> | 2016-01-13 10:48:25 | LQ_EDIT |
34,764,910 | Unhandled Exception: Access violation writing location 0x00000000 | <p>I am doing a simple application to define a structure and place data in tha structure to learn the concept of structures. But when trying to insert data to structure i am getting an access violation. Following is the code portions.</p>
<p>In Test.h file</p>
<pre><code>typedef struct Msg
{
unsigned char* message_id;
unsigned char* message_name;
}Msg_t;
</code></pre>
<p>In Test.cpp file</p>
<pre><code>Msg_t *new_node[10];
const char *src = "E0";
new_node[0]->message_id = (unsigned char *)_strdup(src); //getting access violation error here.
</code></pre>
<p>Why am i getting error? Please help.</p>
| <c++><visual-c++> | 2016-01-13 11:00:45 | LQ_CLOSE |
34,764,943 | FBSDKCorekit.h, FBSDKCopying.h file note found using Cocoapods | <p>For some odd reason after adding an unrelated pod I have been receiving an error message during the build process that indicates FBSDKCorekit.h, FBSDKCopying.h and FBSDKButton.h files are not found. I have followed countless suggestions changing properties in the projects build settings based on suggestions I've found on stackoverflow; however, none seem to work. </p>
<p>I am using Cocoapods so I attempted to uninstall and reinstall it as well as the pre-release version. I cleared the pod cache as well as removed the actual pods folder and podfile.lock and the xcworkspace and re-installed the pod into the project; however, I still recieve the error.</p>
<p>I also removed the project cache and rebuilt it...</p>
<p>Any assistance would be appreciated</p>
<blockquote>
<p>Podfile</p>
</blockquote>
<pre><code># define a global platform for your project
platform :ios, '8.4'
# using Swift
use_frameworks!
#
source 'https://github.com/CocoaPods/Specs.git'
# disable bitcode in every sub-target
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
target 'MyApp' do
# other pods
pod ...
# Facebook
pod 'FBSDKCoreKit' , '4.9.0-beta2'//4.8 gives same issue
pod 'FBSDKLoginKit', '4.9.0-beta2'
pod 'FBSDKShareKit', '4.9.0-beta2'
# Uber(New pod added)
pod 'UberRides' //actually just realized it's just a wrapper for very simple calls
# ==============================================================
# Sets the inheritance mode for the tests target inheriting
# only the search paths
target 'MyAppTests' do
inherit! :search_paths
end
end
</code></pre>
| <xcode7><cocoapods><fbsdk> | 2016-01-13 11:01:55 | HQ |
34,765,522 | passing data from my page to iframe using javascript | <p>I want to use Payment Gateway in PhoneGap but Payment Gateway not made for PhoneGap then I thought that using java script pass data to another jsp page using Iframe that control Payment Gateway .i just only pass value to that page .have anyone solution.</p>
| <javascript><html><css><iframe> | 2016-01-13 11:29:48 | LQ_CLOSE |
34,765,641 | What is the error of my code? | <p>Can anyone tell what is wrong with my coding? There is undefined variable on every "$current...". Why does it has error while when i click on the search button, the result come out in the table?</p>
<p><a href="http://i.stack.imgur.com/4fw26.jpg" rel="nofollow">Here is the error occur</a></p>
<pre><code><html>
<head><title>Search Book</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container" align="center">
<div class="row">
<div class="col-md-5">
<form method="get" action="" class="form-horizontal" name="search"><br>
<table border="0" bgcolor="#E0FFFF">
<td><h3>Search Book By ISBN:</h3></td>
<div class="form-group">
<td><input type="text" name="id" class="form-control" placeholder="eg: 978-0320037825"></td>
</div>
<br/>
<tr><td><center><button type="submit" class="btn btn-success">Search</button>&nbsp;</center></td>
<td><a href="index.php">Back</a></td></tr>
<tr><td>
<?php
if (isset($_GET['id']) !='')
{
$id = $_GET['id'];
$xml = simplexml_load_file("bookstore.xml");
$notThere = True;
foreach ($xml->children() as $book)
{
if ($book->isbn == $id)
{
$currentisbn = $book->isbn;
$currenttitle = $book->title;
$currentfirstname = $book->firstname;
$currentlastname = $book->lastname;
$currentprice = $book->price;
$currentyear = $book->year;
$currentpublisher = $book->publisher;
$notThere = False;
}
}
if($notThere)
{
echo "ISBN Does Not Exist!";
}
}
?>
</td>
</tr>
</table>
</form>
<html>
<form method="POST" action="" class="form-horizontal" name="delete">
<table width="600" bgcolor="#ffffff" border="1" cellpadding="8">
<tr colspan="2"><h2>Delete Book</h2></tr>
<tr>
<td width="150">ISBN</td>
<td width="320"><?php echo $currentisbn;?></td>
</tr>
<tr>
<td width="150">Title</td>
<td width="320"><?php echo $currenttitle;?></td>
</tr>
<tr>
<td>First Name</td>
<td><?php echo $currentfirstname;?></td>
</tr>
<tr>
<td>Last Name</td>
<td><?php echo $currentlastname;?></td>
</tr>
<tr>
<td width="150">Price</td>
<td width="320"><?php echo $currentprice;?></td>
</tr>
<tr>
<td width="150">Year</td>
<td width="320"><?php echo $currentyear;?></td>
</tr>
<tr>
<td width="150">Publisher</td>
<td width="320"><?php echo $currentpublisher;?></td>
</tr>
<td colspan="2" align="center"> <input name="submit" type="submit" value="Delete"/> &nbsp;
<a class="btn btn-default" href="index.php" role="button">Home</a></td>
</tr>
</table>
</form>
<?php
if (isset($_GET['id'])!='' && isset($_POST['submit'])!=''){
$id = $_GET['id'];
$success=False;
$dom = new DOMDocument();
$dom -> load("bookstore.xml");
$xpath = new DOMXpath($dom);
$node = $xpath->query("//*[isbn='$id']");
foreach ($node as $book)
{
$book->parentNode->removeChild($book);
$success=True;
}
if($success)
{
echo "<h1 style='text-align: center;'>Successfully Deleted!</h1>";
}
$dom->save("bookstore.xml");
}
?>
<script>
function goBack() {
window.history.back();
}
</script>
</html>
</code></pre>
| <php><html><xml> | 2016-01-13 11:35:02 | LQ_CLOSE |
34,765,723 | Get the last word of string | <p>How can I get the last word of an string if my string is like that "hello is my new car "(after the word car there is an white space).</p>
<p>I want to know how remove it too.</p>
<p>Thank you so much</p>
| <java><string> | 2016-01-13 11:38:02 | LQ_CLOSE |
34,766,212 | Error unexpected ;; | <p>I can´t found my syntax error:</p>
<pre><code>$params['title_header'] = '<a href="/product/'.str_slug($article_info->name.'/'.$article_info->article_id.'">'.$article_info->name.'</a> > MODELS';
</code></pre>
<p>Can you help me to find him?</p>
<p>I´m coding in a laravel controller.php file.</p>
| <php><laravel> | 2016-01-13 12:02:13 | LQ_CLOSE |
34,766,562 | How to create a div box with dynamic width based on text content? | <p>I want to create a simple <code>div</code> that shrinks and expands according to the content contained.</p>
<p><a href="https://jsfiddle.net/qa5dr0x8/" rel="noreferrer">https://jsfiddle.net/qa5dr0x8/</a></p>
<pre><code><body>
<div style="border: 1px solid red; padding: 15px; width:auto;">
test text
</div>
</body>
</code></pre>
<p>Result: the red box expands to the full width of the page. Why?</p>
| <html><css> | 2016-01-13 12:19:32 | HQ |
34,766,731 | format a string like a date | <p>I'm receiving a "<em>date</em>" represented by a string in the form <strong>yyyymmdd</strong> from a database table over which I have no control. (I cannot modify the type/format of the date field)</p>
<p>I would like to insert the character '<strong>/</strong>' at the right place. (<em>20150113 = 2015/01/13</em>)</p>
<p>As I haven't been able to use <code>new Date('20150113')</code> I am using a regex to insert the slash like so:</p>
<pre><code>string = string.toString().replace(/(^[0-9]{4})/g , "$1\/");
string = string.replace(/(^[0-9\/]{7})/g , "$1\/");
</code></pre>
<p>Is it possible to merge both regexes into one or is there an existing function (angular, javascript) that can understand that date format (<em>20150113</em>)?</p>
| <javascript><angularjs><date-formatting> | 2016-01-13 12:27:09 | LQ_CLOSE |
34,767,233 | How do you implement strtol under const-correctness? | <p>According to <a href="http://www.cplusplus.com/reference/cstdlib/strtol/">http://www.cplusplus.com/reference/cstdlib/strtol/</a> this function has a signature of <code>long int strtol (const char* str, char** endptr, int base)</code>.</p>
<p>I wonder, though: If it gets passed a <code>const char *</code> to the beginning of the string, how does it manage to turn that into a non-const pointer to the first unprocessed character without cheating? What would an implementation of strtol look like that doesn't perform a const_cast?</p>
| <c> | 2016-01-13 12:50:53 | HQ |
34,767,264 | how do i insert expandable listview child item into sqlite? | <p>I am new in android. I want to insert expandable listview child click item into sqlite database Any help please give me suggestion.</p>
| <android><sqlite> | 2016-01-13 12:52:18 | LQ_CLOSE |
34,767,372 | when you create a library, do you need to provide the cs file or dll file is enough | <p>As title, I would like to make a basic library of math functions but I would like to know if user need my source code (.cs class) or just providing the .dll file and user adding it in references </p>
| <dll><c#> | 2016-01-13 12:57:12 | LQ_CLOSE |
34,767,713 | am trying to update a column in the database, from a list | command = new SqlCommand("update Login_Users set Password=@a where UserName !='" + null + "'", Db);
Db.Open();
for (int i = 0; i < list.Count; i++)
{
list[i] = Encrypt(list[i]);
command.Parameters.AddWithValue("@a",list[i]);
int a = command.ExecuteNonQuery();
}
but i get this error variable name already been declared
| <c#><sql> | 2016-01-13 13:15:53 | LQ_EDIT |
34,767,949 | Throwing an array local to a try block | <p>From C++ Primer 18.1.1:</p>
<blockquote>
<p>If the [thrown] expression has an array or function type, the expression is
converted to its corresponding pointer type.</p>
</blockquote>
<p>How is it that this program can produce correct output of <code>9876543210</code> (g++ 5.2.0)?</p>
<pre><code>#include <iostream>
using namespace std;
int main(){
try{
int a[10] = {9,8,7,6,5,4,3,2,1,0};
throw a;
}
catch(int* b) { for(int i = 0; i < 10; ++i) cout << *(b+i); }
}
</code></pre>
<p>From the quote, <code>throw a</code> would create an exception object of type <code>int*</code> which is a pointer to the first element of the array. But surely the array elements of <code>a</code> would be destroyed when we exit the <code>try</code> block and enter the catch clause since we change block scope? Am I getting a false positive or are the array elements "left alone" (not deleted) during the duration of the catch clause?</p>
| <c++><arrays><c++11><throw> | 2016-01-13 13:26:44 | HQ |
34,768,189 | Your project.json doesn't list 'win10' as a targeted runtime | <p>I hate reposting, but I thought posting to the <a href="https://social.msdn.microsoft.com/Forums/en-US/efb7e560-e2e4-4385-8287-a6ada4e3622b/uwphtml-problem-with-uap-app-running-with-references-to-a-pcl?forum=wpdevelop" rel="noreferrer">MSDN forum</a> was the right thing to do since it looks there are not many people working on UWP apps with HTML/JavaScript, but, since I had no answers at all, I'm turning to the great SO community for help.</p>
<p><em>Problem:</em><br>
I have a very simple UAP app in HTML/JavaScript that has a reference to a Windows Runtime Component which has a reference to a Class Library.</p>
<p>I need to project to run in either PCs and/or mobiles so I need to compile it with Any CPU. The problem is that whenever I want to compile my app I get the following error:</p>
<p><code>Your project.json doesn't list 'win10' as a targeted runtime. You should add '"win10": { }' inside your "runtimes" section in your project.json, and then re-run NuGet restore.</code></p>
<p>And If I do add the plain win10 entry under runtimes, I get many other errors. This is what my project.json looks like:</p>
<pre><code>{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": { }
},
"runtimes": {
"win10-arm": { },
"win10-arm-aot": { },
"win10-x86": { },
"win10-x86-aot": { },
"win10-x64": { },
"win10-x64-aot": { }
}
}
</code></pre>
<p>Also, there's a minimal repro <a href="http://1drv.ms/1SOmXSW" rel="noreferrer">here</a> if anybody is interested in checking it out.</p>
| <javascript><windows-runtime><win-universal-app><uwp> | 2016-01-13 13:38:51 | HQ |
34,768,600 | when i run this code it give error unexpected else please suggest mi how to write it | <p>when i run this code it give error unexpected else please suggest mi how to write it i am confused with open and close bracket</p>
<pre><code> <?php
}
for ($i = $start_loop; $i <= $end_loop; $i++)
{
//if ($cur_page == $i)
if($i != $page)?>
<a href="javascript:callonce_search( <?php echo $i?>,'<?php echo $txt?>')"> $i </a>
<?php
else
echo " <a class='paginationcurrnt'><b> $i</b>";
}
// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations)
{
$nex = $cur_page + 1; ?>
</code></pre>
| <php> | 2016-01-13 13:57:47 | LQ_CLOSE |
34,769,296 | Build versus Runtime Dependencies in Nix | <p>I am just starting to get to grips with Nix, so apologies if I missed the answer to my question in the docs.</p>
<p>I want to use Nix to setup a secure production machine with the minimal set of libraries and executables. I don't want any compilers or other build tools present because these can be security risks. </p>
<p>When I install some packages, it seems that they depend on only the minimum set of runtime dependencies. For example if I install <code>apache-tomcat-8.0.23</code> then I get a Java runtime (JRE) and the pre-built JAR files comprising Tomcat.</p>
<p>On the other hand, some packages seem to include a full build toolchain as dependencies. Taking another Java-based example, when I install <code>spark-1.4.0</code> Nix pulls down the Java development kit (JDK) which includes a compiler, and it also pulls the Maven build tool etc.</p>
<p>So, my questions are as follows:</p>
<ol>
<li>Do Nix packages make any distinction between build and runtime dependencies?</li>
<li>Why do some packages appear to depend on build tools whereas others only need runtime? Is this all down to how the package author wrapped up the application?</li>
<li>If a package contains build dependencies that I don't want, is there anything that I, as the operator, can do about it except design my own alternative packaging for the same application?</li>
</ol>
<p>Many thanks.</p>
| <nix><nixos><nixpkgs> | 2016-01-13 14:31:08 | HQ |
34,769,673 | Get process memory on Windows | <p>I have a library in Ruby that shells out to get memory usage of the current process, I just received a report that it doesn't work on Windows. On mac and linux I can shell out to <code>ps -o rss= -p 3432</code> to get the RSS memory for process with a PID of 3432. Is there an equivalent command in Windows?</p>
| <windows><command-prompt> | 2016-01-13 14:49:48 | HQ |
34,770,159 | How to filter multiple words in Android Studio logcat | <p>I want to see just a couple of words in logcat. In other words, just a given tags. I tried to enable <em>Regex</em> and type <code>[Encoder|Decoder]</code> as filter, but it doesn't work.</p>
| <regex><android-studio><logcat><android-logcat> | 2016-01-13 15:10:37 | HQ |
34,770,482 | How do I compile a GitHub project? | <p>I've tried for few hours.. and failed. i can't seem to get it to work. ( in NetBeans)</p>
<p>I've added libraries that creator pointed out, source and nbproject - I get errors.</p>
<p>Can someone tell me what to do step by step? Thank you in advance.</p>
<p>LINK TO GITHUB: <a href="https://github.com/lucidexploration/JonBot-NG" rel="nofollow">https://github.com/lucidexploration/JonBot-NG</a></p>
<p>( i've tried adding it - I downloaded the zip from github then I created new project in netbeams (selected as just Java) then I went to "files" tab and dragged and dropped down src folder from zip i downloaded from GitHub then nbproject and the rest. I've got an JAVADOC error. )</p>
| <java> | 2016-01-13 15:24:44 | LQ_CLOSE |
34,770,675 | How do I save a text file into an array? | <p>This is how I print out the text file</p>
<pre><code>FILE *file;
char array[200];
file = fopen("test.txt", "r");
fread(array,1, 200, file);
printf("\n%s", array);
fclose(file);
</code></pre>
<p>Instead I want to save the text file rows to an array so i can print out the text file with the array.</p>
<p>I can only use those fopen,fprintf,fwrite,fscanf,fread,fseek,fclose. Not fget.</p>
<p>How do i save the text file lines to an array?</p>
| <c> | 2016-01-13 15:33:54 | LQ_CLOSE |
34,770,720 | Broadcast a dictionary to rdd in PySpark | <p>I am just getting the hang of Spark, and I have function that needs to be mapped to an <code>rdd</code>, but uses a global dictionary:</p>
<pre><code>from pyspark import SparkContext
sc = SparkContext('local[*]', 'pyspark')
my_dict = {"a": 1, "b": 2, "c": 3, "d": 4} # at no point will be modified
my_list = ["a", "d", "c", "b"]
def my_func(letter):
return my_dict[letter]
my_list_rdd = sc.parallelize(my_list)
result = my_list_rdd.map(lambda x: my_func(x)).collect()
print result
</code></pre>
<p>The above gives the expected result; however, I am really not sure about my use of the global variable <code>my_dict</code>. It seems that a copy of the dictionary is made with every partition. And it just does not feel right..</p>
<p>It looked like <a href="http://spark.apache.org/docs/latest/programming-guide.html#broadcast-variables">broadcast</a> is what I am looking for. However, when I try to use it:</p>
<pre><code>my_dict_bc = sc.broadcast(my_dict)
def my_func(letter):
return my_dict_bc[letter]
</code></pre>
<p>I get the following error:</p>
<pre><code>TypeError: 'Broadcast' object has no attribute '__getitem__
</code></pre>
<p>This seems to imply that I cannot broadcast a dictionary.</p>
<p>My question: If I have a function that uses a global dictionary, that needs to be mapped to <code>rdd</code>, what is the proper way to do it?</p>
<p>My example is very simple, but in reality <code>my_dict</code> and <code>my_list</code> are much larger, and <code>my_func</code> is more complicated.</p>
| <apache-spark><pyspark> | 2016-01-13 15:35:38 | HQ |
34,771,128 | Is there something similar to NEGATIVE_INFINITY in php? | <p>I love the negative infinity value in javascript, I think it's useful and clean in many case to use it but couldn't find something similar in PHP, does it exists?</p>
| <php> | 2016-01-13 15:52:15 | HQ |
34,771,255 | Where should the android service calls and calls to GoogleAPIClient be written while using MVP pattern in android? | <p>I am trying to implement <strong>MVP pattern</strong> in my android project by referring to this link : <a href="https://github.com/jpotts18/android-mvp" rel="noreferrer">https://github.com/jpotts18/android-mvp</a></p>
<p>I have successfully implemented the <strong>view / presenter / interactor</strong> classes. I am not clear on </p>
<ul>
<li><strong>Where to put the <code>service</code> call code?</strong></li>
</ul>
<blockquote>
<p>Since i cannot get the context inside the presenter or interactor
class, I am not able to put the <code>service</code> call there</p>
</blockquote>
<ul>
<li><strong>Where to implement the <code>GoogleApiClient</code> class?</strong></li>
</ul>
<blockquote>
<p>Since <code>GoogleApiClient</code> also requires context to run, it also cannot be
implemented inside the presenter or interactor without a context</p>
</blockquote>
| <android><design-patterns><android-service><mvp><android-googleapiclient> | 2016-01-13 15:57:35 | HQ |
34,771,256 | How does Pandas to_sql determine what dataframe column is placed into what database field? | <p>I'm currently using Pandas to_sql in order to place a large dataframe into an SQL database. I'm using sqlalchemy in order to connect with the database and part of that process is defining the columns of the database tables.</p>
<p>My question is, when I'm running to_sql on a dataframe, how does it know what column from the dataframe goes into what field in the database? Is it looking at column names in the dataframe and looking for the same fields in the database? Is it the order that the variables are in?</p>
<p>Here's some example code to facilitate discussion:</p>
<pre><code>engine = create_engine('sqlite:///store_data.db')
meta = MetaData()
table_pop = Table('xrf_str_geo_ta4_1511', meta,
Column('TDLINX',Integer, nullable=True, index=True),
Column('GEO_ID',Integer, nullable=True),
Column('PERCINCL', Numeric, nullable=True)
)
meta.create_all(engine)
for df in pd.read_csv(file, chunksize=50000, iterator=True, encoding='utf-8', sep=',')
df.to_sql('table_name', engine, flavor='sqlite', if_exists='append', index=index)
</code></pre>
<p>The dataframe in question has 3 columns TDLINX, GEO_ID, and PERCINCL</p>
| <python><database><pandas><sqlite><sqlalchemy> | 2016-01-13 15:57:36 | HQ |
34,772,109 | What does (void (^)(BOOL supported)) mean? | <p>as I am working myself into some new code, I came across a thing, where I couldnt find any explanation for in the web so far. So hopefully you can give me one.</p>
<p>I have this method signature in Objective-C code:</p>
<pre><code>-(void) supportsUrl: (NSString*) url callback:(void (^)(BOOL supported)) callback;
</code></pre>
<p>Can someone please tell me what it is about in the last parameter?</p>
<p>Thanks a lot!</p>
| <objective-c> | 2016-01-13 16:36:12 | LQ_CLOSE |
34,772,259 | C++ sort() function for sorting strings | <p><br>
Some days ago I wanted to use c++ <code>sort()</code> function to sort an array of strings which the total size, but I had a problem!<br>
Does this function use the same algorithm for sorting numbers array and strings array?
And if we use it to sort an array of strings which the total size of them is less than 100,000 characters, would it work in less than 1 second(in the worst case)?</p>
| <c++><string><sorting> | 2016-01-13 16:42:56 | LQ_CLOSE |
34,772,494 | RxSwift minimal Observable.create example | <p>Currently I am trying to get RxSwift working. And I want to create a custom Observable. But I think I am doing something wrong. </p>
<p>I have distilled what I do to this minimal sample:</p>
<pre><code>import Foundation
import RxSwift
class Example
{
let exampleObservable : Observable<String> = Observable.create { (observer) in
observer.on(.Next("hello"))
observer.on(.Completed)
return AnonymousDisposable { }
}
let exampleObserver : AnyObserver<String>?
func run()
{
self.exampleObserver = exampleObservable.subscribeNext({ (text) -> Void in
print(text)
})
}
}
let ex = Example()
ex.run()
</code></pre>
<p>Is this correct? In the run method, the subscribeNext method is autocompleted that way by XCode.</p>
<p><a href="https://i.stack.imgur.com/kMKjb.png"><img src="https://i.stack.imgur.com/kMKjb.png" alt="Example"></a></p>
<p>But when I run it I get the following compilation error: </p>
<pre><code>Cannot Invoke 'substribeNext' with an argument list of type ((String) -> Void)
</code></pre>
| <swift><rx-swift> | 2016-01-13 16:53:43 | HQ |
34,774,032 | How to Trim leading and trailing tab spaces in MSSQL query | <p>I have data which has leading and trailing spaces in the string. when storing that data in database I want to trim the space in query itself before storing into DB.</p>
<p>Normal spaces are trimming properly with RTRIM and LTRIM function but if a string contains tab space,its not trimming the tab space from the input string.</p>
<p>Can anyone help me to get the string with trimmed with tab space from leading and trailing.</p>
| <sql><sql-server><sql-server-2005> | 2016-01-13 18:11:45 | HQ |
34,774,050 | Does Java's lack of multiple inheritance hurt its potential for Android game development? | <p>I'm currently enrolled in a mobile app development class, and I have an idea for a game that I'd like to do that involves virtual pets. I'm confident that I'll be able to utilize Java's capabilities for this class without a problem, but further down the line if I wanted to, say, fuse pets and/or breed, I imagine it might become difficult to implement my ideas using Java. </p>
<p>I know that objects can inherit from multiple interfaces and there are ways of obtaining variables through other means, but in terms of code and app efficiency, would I be better off using another language down the line?</p>
<p>Really looking forward to this discussion, as I enjoy hearing the pros and cons of each side. Java's my favorite language at the moment because I'm most familiar with it, but even so... I'd love to branch out if I'd be better off doing so. I've looked this up using search engines many times but I thought this would be a more hands-on approach to engage with people in conversation as opposed to simply reading past threads. </p>
<p>Thanks in advance!</p>
| <java><android><performance> | 2016-01-13 18:12:53 | LQ_CLOSE |
34,775,068 | PHP Throws error when calling class method inside function | <pre><code>include "sys.php";
$logger = new logger();
$logger->write("Hello!");
</code></pre>
<p>This works. However,</p>
<pre><code>include "sys.php";
$logger = new logger();
function test() {
$logger->write("Hello!");
}
test();
</code></pre>
<p>This does not. The server crashes, error 500.</p>
<p>Why?</p>
| <php> | 2016-01-13 19:10:04 | LQ_CLOSE |
34,775,157 | Angular UI Bootstrap Pagination ng-model not updating | <p>I am trying to use a UI Bootstrap Pagination directive in my project, but for some strange reason the ng-model used for updating the current page is not working. The pagination is showing up correctly with the correct number of tabs and everything, but when I click on a different number, the ng-model variable is not getting updated. For the life of me, I can't figure out why not.</p>
<p>The code I am using is taken from the examples on the UI Bootstrap homepage:</p>
<pre><code><uib-pagination total-items="totalItems" ng-model="currentPage"
ng-change="pageChanged()"></uib-pagination>
</code></pre>
<p>The controller looks like this: </p>
<pre><code>$scope.currentPage = 1;
$scope.totalItems = 160;
$scope.pageChanged = function() {
console.log('Page changed to: ' + $scope.currentPage);
};
</code></pre>
<p>Here are the different required sources I am including:</p>
<pre><code><link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://code.angularjs.org/1.4.8/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.0.3.js"></script>
</code></pre>
<p>The strangest thing is I have created a plnkr which replicates my code and it works! You can see here: <a href="http://plnkr.co/edit/4DoKnRACbKjLnMH5vGB6">http://plnkr.co/edit/4DoKnRACbKjLnMH5vGB6</a></p>
<p>Can anybody think of any ideas that might be causing this not to work? I'm scratching my head here, and can't think of anything obvious I am doing wrong...</p>
<p>All help much apprecatiated!</p>
| <angularjs><twitter-bootstrap><angular-ui-bootstrap> | 2016-01-13 19:14:44 | HQ |
34,775,353 | Is it possible to shuffle or randomly select entire rows of an array in Python? | <p>I'm working with a multidimensional array where each column contains ordered data and each row is a different sample. I would like to randomly downsample to a specific number of rows, but I don't know how to randomly select an entire row or how to randomly shuffle only the orders of the rows of the array.</p>
| <python><arrays><random> | 2016-01-13 19:25:57 | LQ_CLOSE |
34,775,504 | Printf is not working in AJAX php file? | <p>Hi I want to update some data in my mysql database by using form in html and AJAX technology. I have problem because data is not updated after click on submit and in response message I have not only message but clear mysql ask too! Let's look at my alert:
<a href="https://i.stack.imgur.com/gc8od.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gc8od.png" alt="enter image description here"></a></p>
<p>My idea is the printf is not really post text into "query" function but this text output is going stright into response data and query is always wrong from empty text...</p>
<p>Let's look at my AJAX php file:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
session_start();
error_reporting(0);
$imie = $_POST['imie'];
$nazwisko = $_POST['nazwisko'];
$kodpocztowy = $_POST['kodpocztowy'];
$ulica = $_POST['ulica'];
$nrdomu = $_POST['nrdomu'];
$nrmieszkania = $_POST['nrmieszkania'];
$miasto = $_POST['miasto'];
try
{
if (! @include_once('connect.php'))
throw new Exception ('connect.php kurwa nie istnieje</br>');
if (!file_exists('connect.php' ))
throw new Exception ('connect.php nie istnieje</br>');
else
require_once('connect.php');
}
catch(Exception $e)
{
echo "Wiadomość: " . $e->getMessage();
echo "Kod: " . $e->getCode();
}
require_once "connect.php";
$polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
if($rezultat = @$polaczenie->query(printf("UPDATE adresy SET imie='%s', nazwisko='%s', kodpocztowy='%s', ulica='%s', nrdomu='%s', nrmieszkania='%s', miasto='%s' WHERE id=%s",$imie,$nazwisko,$kodpocztowy,$ulica,$nrdomu,$nrmieszkania,$miasto,$_SESSION['id'])))
{
$polaczenie->close();
echo "Good!";
}
else
{
$polaczenie->close();
echo "Not good!";
}
?></code></pre>
</div>
</div>
</p>
<p>Have you any idea how to solve this problem? Maybe what to use instead printf or echo? Please help, greatings.</p>
| <php><mysql><ajax><printf> | 2016-01-13 19:35:20 | LQ_CLOSE |
34,775,937 | Python lists in lists | I have the following code:
`addresses = [['Jim', 543, 65], ['Jack', 4376, 23], ['Hank', 764, 43]]
print addresses[0:][0] # I want this to return: ['Jim', 'Jack', 'Hank']`
How would I make this print out only the names in `addresses`?
Thank you! | <python> | 2016-01-13 20:00:45 | LQ_EDIT |
34,776,201 | Why wont this work ? Dynamic memory beginner program | enter code here
int main()
{
//FILE *out = fopen("keimeno.txt", "w+");
FILE *in = fopen("keimeno.txt", "r");
int fullbufflen=0 , i;
char buffer[100];
fgets(buffer, 100, in);
int bufflen = strlen(buffer);
char *text;
text =calloc(bufflen,sizeof(char));
char *strcat(text, buffer);
// printf("line of \"keimeno.txt\": %s", buffer);
// printf("size of line \"keimeno.txt\": %i\n\n", bufflen);
fullbufflen = bufflen;
while(fgets(buffer, 100, in)!=NULL)
{
// printf("line of \"keimeno.txt\": %s", buffer);
// printf("size of line \"keimeno.txt\": %i\n\n", bufflen);
text =realloc(text,bufflen*sizeof(char));
char *strcat(text, buffer);
fullbufflen = bufflen + fullbufflen ;
}
for (i = 0;i<fullbufflen;i++)
{
printf("%c\n",text[i]);
}
}
I am trying to copy the full text file (keimeno.txt) into a dynamic memory array,with a buffer of 100 character at most everytime .To test it at the end i tried to prinf the results .And i just cant get it to work .Dont know if there is a problem on the printf at the end,or the whole program is just wrong.(also the dynamic array is supposed to have 0 size at the beggining ,so if someone could tell me how to do that too ,it would be welcome .)Thanks in advance. | <c><file><dynamic><malloc><realloc> | 2016-01-13 20:15:23 | LQ_EDIT |
34,776,213 | How to make a POST request using retrofit 2? | <p>I was only able to run the hello world example (GithubService) from the docs. </p>
<p>The problem is when I run my code, I get the following Error, inside of <code>onFailure()</code></p>
<blockquote>
<p>Use JsonReader.setLenient(true) to accept malformed JSON at line 1
column 1 path $</p>
</blockquote>
<p>My API takes POST params value, so no need to encode them as JSON, but it does return the response in JSON.</p>
<p>For the response I got ApiResponse class that I generated using tools.</p>
<p>My interface:</p>
<pre><code>public interface ApiService {
@POST("/")
Call<ApiResponse> request(@Body HashMap<String, String> parameters);
}
</code></pre>
<p>Here is how I use the service:</p>
<pre><code>HashMap<String, String> parameters = new HashMap<>();
parameters.put("api_key", "xxxxxxxxx");
parameters.put("app_id", "xxxxxxxxxxx");
Call<ApiResponse> call = client.request(parameters);
call.enqueue(new Callback<ApiResponse>() {
@Override
public void onResponse(Response<ApiResponse> response) {
Log.d(LOG_TAG, "message = " + response.message());
if(response.isSuccess()){
Log.d(LOG_TAG, "-----isSuccess----");
}else{
Log.d(LOG_TAG, "-----isFalse-----");
}
}
@Override
public void onFailure(Throwable t) {
Log.d(LOG_TAG, "----onFailure------");
Log.e(LOG_TAG, t.getMessage());
Log.d(LOG_TAG, "----onFailure------");
}
});
</code></pre>
| <java><android><post><retrofit><retrofit2> | 2016-01-13 20:16:12 | HQ |
34,776,245 | How do I get the current action from within a controller? | <p>How do I get the current action from within a controller? <code>current_page?</code> works for views, but not controllers.</p>
<pre><code>redirect_to step3_users_path unless current_page?(step3_users_path)
</code></pre>
<p>I also tried</p>
<pre><code>controller.action_name == 'step3'
</code></pre>
<p>I also tried</p>
<pre><code>params[:action_name] == 'step3'
</code></pre>
| <ruby-on-rails><ruby-on-rails-4> | 2016-01-13 20:17:59 | HQ |
34,776,325 | Convert text data set to .arrd file | I have this data set https://archive.ics.uci.edu/ml/datasets/Sentiment+Labelled+Sentences
and I need to convert it from .txt to .arff file to make classification with weka program .
any help ?
| <converter><weka><text-mining><text-classification><arff> | 2016-01-13 20:22:30 | LQ_EDIT |
34,778,147 | Cannot boot Windows guest in VirtualBox without kernel module error | <p>I'm running Vagrant (1.8.1) + VirtualBox (5.0.12) on Windows 7 and trying to boot up a Windows 7 image (modernIE/w7-ie8). However, I get this error:</p>
<pre><code>---------------------------
VirtualBox - Error In supR3HardenedWinReSpawn
---------------------------
<html><b>NtCreateFile(\Device\VBoxDrvStub) failed: 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND (0 retries) (rc=-101)</b><br/><br/>Make sure the kernel module has been loaded successfully.<br><br><!--EOM-->where: supR3HardenedWinReSpawn
what: 3
VERR_OPEN_FAILED (-101) - File/Device open failed.
Driver is probably stuck stopping/starting. Try 'sc.exe query vboxdrv' to get more information about its state. Rebooting may actually help.</html>
---------------------------
OK
---------------------------
</code></pre>
<p>I ran the query command, but the service "is not found".</p>
<pre><code>> sc.exe query vboxdrv
[SC] EnumQueryServicesStatus:OpenService FAILED 1060:
The specified service does not exist as an installed service.
</code></pre>
<p>I tried rebooting, too. Nothing.</p>
| <windows><service><kernel><virtualbox> | 2016-01-13 22:18:00 | HQ |
34,778,476 | Java Threads producer-consumer shared buffer | <p>Implement producer consumer problem using threads in Java. Producers and consumers share a buffer, producers put elements in buffer and consumers consume elements from the shared buffer. If the buffer is full producers should wait till consumers take out elements, similarly consumers should wait till producers put elements if the buffer is empty.
Your program should accept the following inputs:</p>
<pre><code>m: the number of producer threads
n: the number of consumer threads
k: the size of the bounded buffer
</code></pre>
<p>Your code should prompt for the above inputs in that order. You can assume that a valid integer is provided by the user for each of these. You will need to spawn m Producer threads and n Consumer threads. Each producer generates 20 integers ranging between 0 and 9 and puts them in the buffer. After putting a number in the buffer, it prints its id along with the generated number. The producer sleeps for a random amount of time before repeating the number generating cycle again. Each consumer takes a number from the buffer then prints its id along with the value it got. Then, it sleeps for a random amount of time before reading from the buffer again.
A sample output of the program is:</p>
<pre><code>Producer #2 put: 1
Producer #1 put: 4
Consumer #3 got: 1
Producer #1 put: 3
Consumer #3 got: 4
Consumer #3 got: 3
...
</code></pre>
<p>i have this problem. it is clear that the <strong>array of buffer</strong> is a global variable for two method because of that array is shared with Producer & Consumer. so? Unfortunately i have no idea how to do this project. anybody have an idea?</p>
| <java><multithreading><algorithm><producer-consumer><critical-section> | 2016-01-13 22:42:07 | LQ_CLOSE |
34,778,937 | Replacing word except when it is between letters | <p>For example I would like to change every "hi" to hello
The problem is when I try to do it I get into some kind of problems.
It translates other words badly like:
from "his dog is nice" to "hellos dog is nice"
How can I fix it
(I am using php)</p>
| <php><regex><replace><preg-replace> | 2016-01-13 23:18:44 | LQ_CLOSE |
34,778,950 | How to compare "Any" value types | <p>I have several "Any" value types that I want to compare.</p>
<pre><code>var any1: Any = 1
var any2: Any = 1
var any3: Any = "test"
var any4: Any = "test"
print(any1 == any2)
print(any2 == any3)
print(any3 == any4)
</code></pre>
<p>Using the == operator shows an error:</p>
<blockquote>
<p>"Binary operator '==' cannot be applied to two 'Any' (aka
'protocol<>') operands"</p>
</blockquote>
<p>What would be the way to do this ? </p>
| <swift> | 2016-01-13 23:19:37 | HQ |
34,779,642 | Dynamic href tag React in JSX | <pre><code>// This Javascript <a> tag generates correctly
React.createElement('a', {href:"mailto:"+this.props.email}, this.props.email)
</code></pre>
<p>However, I'm struggling to recreate it in JSX</p>
<pre><code><a href="mailto: {this.props.email}">{this.props.email}</a>
// => <a href="mailto: {this.props.email}"></a>
</code></pre>
<p>The href tag thinks the <code>{this.props.email}</code> is a string instead of dynamically inputting the value of <code>{this.props.email}</code>. Any ideas on where I went amiss?</p>
| <javascript><reactjs><react-jsx> | 2016-01-14 00:29:54 | HQ |
34,780,267 | Anaconda Python installation error | <p>I get the following error during Python 2.7 64-bit windows installation. I previously installed python 3.5 64-bit and it worked fine. But during python 2.7 installation i get this error:</p>
<pre><code>Traceback (most recent call last):
File "C:\Anaconda2\Lib\_nsis.py", line 164, in <module> main()
File "C:\Anaconda2\Lib\_nsis.py", line 150, in main
mk_menus(remove=False)
File "C:\Anaconda2\Lib\_nsis.py", line 94, in mk_menus
err("Traceback:\n%s\n" % traceback.format_exc(20))
IOError: [Errno 9] Bad file descriptor
</code></pre>
<p>Kindly help me out.</p>
| <python><python-2.7><installation><anaconda> | 2016-01-14 01:37:32 | HQ |
34,780,328 | How to automatic update status? | [this is the image][1]I have a problem on how to update all status in one click. As you can see in the picture, if I click the lock it will then automatically update all status of the student to "lock", if I click the unlock button also it will automatic the status into "unlock", how to do that?
Here's my code:
<a href="unlock.php" title="Lock"><img src="images/lock.png" height="40" width="40"></a>
<a href="lock.php" title="Unlock"><img style="margin-left:8px;" src="images/unlock.png" height="40" width="40"></a>
when I click the lock.php here's what the codes like:
<?php
include '../connection/connect.php';
include '../dbcon.php';
$idnum=$_POST['idnum'];
$stat='LOCK';
$sqla = "UPDATE student
SET status=?
WHERE idno=?";
$qa = $db->prepare($sqla);
$qa->execute(array($stat,$idnum));
Header ('Location:lock_unlock.php');
}
?>
[1]: http://i.stack.imgur.com/CMUVY.png | <php> | 2016-01-14 01:44:20 | LQ_EDIT |
34,780,767 | Free problems in C language | I'm working on a project in C language. The purpose of the project is to code a function that returns the next line of a file every time it's called.
I'm only allowed to use the malloc, free and read functions.
Here's the errors I'm getting :
[Errors][1]
[1]: http://i.stack.imgur.com/VYh0l.jpg
And here's my code :
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "get_next_line.h"
int my_putstr(char *str)
{
int i;
if (str == NULL)
return (1);
i = 0;
while (str[i] != '\0')
{
write(1, &str[i], 1);
i = i + 1;
}
return (0);
}
char *my_strcpy(char *src, char *dest)
{
int i;
int r;
r = 0;
i = 0;
if (src == NULL)
return (dest);
while (dest != NULL && dest[i] != '\0')
i = i + 1;
while (src[r] != '\0')
{
dest[i] = src[r];
i = i + 1;
r = r + 1;
}
dest[i] = '\0';
return (dest);
}
int check_back_n(t_stock *stock)
{
int i;
if (stock->save == NULL)
return (1);
i = 0;
while (stock->save[i] != '\0')
{
if (stock->save[i] == '\n')
return (0);
i = i + 1;
}
return (1);
}
int my_realloc(t_stock *stock)
{
if ((stock->temp = malloc(sizeof(char) *
(READ_SIZE * stock->counter) + 1)) == NULL)
return (1);
stock->temp = my_strcpy(stock->save, stock->temp);
free(stock->save);
if ((stock->save = malloc(sizeof(char) *
(READ_SIZE * (stock->counter + 1)) + 1)) == NULL)
return (1);
stock->save = my_strcpy(stock->temp, stock->save);
free(stock->temp);
return (0);
}
char *fill_over(t_stock *stock, char *over)
{
stock->r = 0;
stock->i = 0;
while (stock->save[stock->i] != '\n')
stock->i = stock->i + 1;
stock->save[stock->i] = '\0';
stock->i = stock->i + 1;
if ((over = malloc(sizeof(char) * READ_SIZE) + 1) == NULL)
return (NULL);
while (stock->save[stock->i] != '\0')
{
stock->save[stock->i] = over[stock->r];
stock->save[stock->i] = '\0';
stock->i = stock->i + 1;
stock->r = stock->r + 1;
}
return (over);
}
char *get_next_line(const int fd)
{
t_stock stock;
static char *over;
stock.counter = 2;
if ((stock.save = malloc(sizeof(char) * READ_SIZE) + 1) == NULL)
return (NULL);
stock.save = my_strcpy(over, stock.save);
free(over);
while (check_back_n(&stock) == 1)
{
if (my_realloc(&stock) == 1)
return (NULL);
if ((stock.buffer = malloc(sizeof(char) * READ_SIZE) + 1) == NULL)
return (NULL);
if ((stock.read_return = read(fd, stock.buffer, READ_SIZE)) == -1||
(stock.read_return == 0))
return (stock.save);
stock.counter = stock.counter + 1;
stock.save = my_strcpy(stock.buffer, stock.save);
free(stock.buffer);
}
if ((over = fill_over(&stock, over)) == NULL)
return (NULL);
return (stock.save);
}
int main()
{
char *s;
int fd;
fd = open("test", O_RDONLY);
while (s = get_next_line(fd))
{
my_putstr(s);
write(1, "\n", 1);
free(s);
}
return (0);
}
| <c><malloc><free> | 2016-01-14 02:37:58 | LQ_EDIT |
34,781,308 | Disable home ,menu and back button in LockScreen Activity? | <p>Hi guys i am working on Pattern Lock App.I want to Disable home , app switch menu and back buttons on lock-screen Activity actually These button are not disable in KITKAT , JELLYBEANS AND OTHER DEVICE ALL BUTTON DISABLE INSTEAD OF HOME BUTTON .please help me i am already in tension. thanks in Advance.</p>
| <android><android-layout><android-intent><android-activity> | 2016-01-14 03:38:24 | LQ_CLOSE |
34,781,748 | Data from PHP form is not posting to mySQL | <p>I am a novice with coding, so I am unsure why I am not getting data to store in mySQL after submitting a form. I started with a code generator, but it just ins't working. Thanks for any help. Here is my code:</p>
<p>Form:</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<body>
<form id="FormName" action="added.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr><td width = "150"><div align="right"><label for="name">Name of Farm </label></div></td>
<td><input id="name" name="name" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="owners">Name of Owners</label></div></td>
<td><input id="owners" name="owners" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="location">Location (city,state)</label></div></td>
<td><input id="location" name="location" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="phone">Phone</label></div></td>
<td><input id="phone" name="phone" type="text" size="25" value="" maxlength="10"></td></tr><tr><td width = "150"><div align="right"><label for="email">Email</label></div></td>
<td><input id="email" name="email" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="website">Website</label></div></td>
<td><input id="website" name="website" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="description">Description</label></div></td>
<td><textarea id="description" name="description" rows="4" cols="40"></textarea></td></tr><tr><td width = "150"><div align="right"><label for="dateadded">Today's Date</label></div></td>
<td><input id="dateadded" name="dateadded" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="logo">Logo</label></div></td>
<td><input id="logo" name="logo" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="state">State</label></div></td>
<td><input id="state" name="state" type="text" size="25" value="" maxlength="2"></td></tr><tr><td width="150"></td><td>
<input type="submit" name="submitButtonName" value="Add"></td>
</tr></table></form>
</body>
</html>
PHP is in 2 files - one with db connection instructions and the other to post the data in the mySQL.
**Code to Connect to mySQL:**
<?php
$hostname='localhost'; //// specify host, i.e. 'localhost'
$user='llamabre_visitor'; //// specify username
$pass='llama'; //// specify password
$dbase='llamabre_farms1'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>
<a href="index.php">Back to List</a>
**Code for posting to mySQL:**
<?php
include("connect.php");
$name = trim($_POST['name']);
$owners = trim($_POST['owners']);
$location = trim($_POST['location']);
$phone = trim($_POST['phone']);
$email = trim($_POST['email']);
$website = trim($_POST['website']);
$description = trim($_POST['description']);
$dateadded = trim($_POST['dateadded']);
$logo = trim($_POST['logo']);
$state = trim($_POST['state']);
$query = "INSERT INTO farmsdir (id, name, owners, location, phone, email, website, description, dateadded, logo, state)
VALUES ('', '$name', '$owners', '$location', '$phone', '$email', '$website', '$description', '$dateadded', '$logo', '$state')";
$results = mysql_query($query);
if ($results)
{
echo "Details added.";
}
mysql_close();
?></code></pre>
</div>
</div>
</p>
| <php><mysql> | 2016-01-14 04:27:44 | LQ_CLOSE |
34,782,249 | Can a React-Redux app really scale as well as, say Backbone? Even with reselect. On mobile | <p>In Redux, every change to the store triggers a <code>notify</code> on all connected components. This makes things very simple for the developer, but what if you have an application with N connected components, and N is very large?</p>
<p>Every change to the store, even if unrelated to the component, still runs a <code>shouldComponentUpdate</code> with a simple <code>===</code> test on the <code>reselect</code>ed paths of the store. That's fast, right? Sure, maybe once. But N times, for <em>every</em> change? This fundamental change in design makes me question the true scalability of Redux.</p>
<p>As a further optimization, one can batch all <code>notify</code> calls using <code>_.debounce</code>. Even so, having N <code>===</code> tests for every store change <em>and</em> handling other logic, for example view logic, seems like a means to an end.</p>
<p>I'm working on a health & fitness social mobile-web hybrid application with millions of users and am transitioning from <strong>Backbone to Redux</strong>. In this application, a user is presented with a swipeable interface that allows them to navigate between different stacks of views, similar to Snapchat, except each stack has infinite depth. In the most popular type of view, an endless scroller efficiently handles the loading, rendering, attaching, and detaching of feed items, like a post. For an engaged user, it is not uncommon to scroll through hundreds or thousands of posts, then enter a user's feed, then another user's feed, etc. Even with heavy optimization, the number of connected components can get very large.</p>
<p>Now on the other hand, Backbone's design allows every view to listen precisely to the models that affect it, reducing N to a constant.</p>
<p>Am I missing something, or is Redux fundamentally flawed for a large app?</p>
| <performance><backbone.js><mobile><reactjs><redux> | 2016-01-14 05:22:27 | HQ |
34,782,370 | I am trying to set attributes string to UITableViewCell's text label I am using following code | NSDictionary * dic = [arrayForTableView objectAtIndex:indexPath.row];
NSNumber* lostPets = [dic valueForKey:@"lostPets"];
NSNumber * foundPets = [dic valueForKey:@"foundPets"];
NSString * breed = [dic valueForKey:@"breed"];
NSMutableAttributedString* message = [[NSMutableAttributedString alloc] init];
//set text
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ (",breed]]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[foundPets stringValue] attributes:@{
NSFontAttributeName : [UIColor greenColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@"), ("]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[lostPets stringValue] attributes:@{
NSFontAttributeName : [UIColor redColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@")"]];
cell.textLabel.attributedText = message;
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICachedDeviceRGBColor ctFontRef]: unrecognized selector sent to instance
I tried to debug the code but unable to get the point of crash. Kindly help.
Thanks in advance. | <ios><nsattributedstring> | 2016-01-14 05:34:13 | LQ_EDIT |
34,782,410 | sdl compile error, cannot open file 'SDL_lib.obj' in vs2005 | When I compile a project with sdl in mvs2005,I encounter the problem.
**LINK : fatal error LNK1104: cannot open file 'SDL_lib.obj'**
How can I solve the problem? | <c><sdl><fatal-error> | 2016-01-14 05:38:52 | LQ_EDIT |
34,783,317 | Automate Microsoft Microsoft Visual C# / Basic .NET | <p>I have to test a desktop application (it has login field/password field/settings/text box etc).Is there any free tool /perl /python module which can be used to automate application written in Microsoft Visual C# ?Sikuli is not an option as per our company .Please help</p>
| <python><perl><testing><automation><automated-tests> | 2016-01-14 06:50:35 | LQ_CLOSE |
34,783,546 | Android Certifications Recognized | <p>I am working as an Android developer for already more than 1 year and I was wondering, if there exists any Android certifications well-known as those from Oracle,Microsoft or Cisco ?</p>
| <android> | 2016-01-14 07:06:48 | LQ_CLOSE |
34,784,539 | Android Studio: Text cursor disappears/gone after open some other class or pasting text in different classes | <p><strong>Android Studio:</strong> Text cursor disappears/gone after open some other class or pasting text in different classes.
Cursor is randomly disappear while coding in Android Studio. Currently using version 1.5.1
Some time cursor is only visible in one file either in java or xml
Right click is working but cursor is not visible in java/ or xml file so I am not able to type the code.</p>
<p><strong>Observed scenario</strong>
The text cursor is not visible or the cursor is gone when I open a different file (e.g. ApplicationTest.java instead of activity_main.xml) the cursor appears again.</p>
<p><strong>Expected scenario:</strong>
The text cursor should be located after the insertion point.</p>
<p><strong>Action taken to solved</strong>
I used synchronize, restart Android Studio….. but not able to get solution.
I am using window 7 and I have cleared temp</p>
<p><strong>R&D</strong> <a href="https://code.google.com/p/android/issues/detail?id=78384" rel="noreferrer">https://code.google.com/p/android/issues/detail?id=78384</a></p>
<p>I stuck to this problem so please help me. Appreciate, if anyone can help to troubleshoot.</p>
| <java><android><xml><android-studio> | 2016-01-14 08:13:52 | HQ |
34,784,588 | ESLint says array never modified even though elements are pushed into array | <p>I am converting some existing code to follow ECMA script and I am using ESLint to follow a coding standard. I have the following ecmascript method</p>
<pre><code>static getArrayOfIndices(text, char) {
let resultArray = [];
let index = text.indexOf(char);
const lastIndex = text.lastIndexOf(char);
while (index <= lastIndex && index !== -1) {
resultArray.push(index);
if (index < lastIndex) {
index = text.substr(index + 1).indexOf(char) + index + 1;
} else {
index = lastIndex + 1999; // some random addition to fail test condition on next iteration
}
}
return resultArray;
}
</code></pre>
<p>For the declaration of resultArray, ESLint throws the error </p>
<pre><code>ESLint: `resultArray` is never modified, use `const`instead. (prefer-const)
</code></pre>
<p>But since elements are being pushed into the array, isn't it being modified? </p>
| <javascript><arrays><ecmascript-6><eslint> | 2016-01-14 08:16:44 | HQ |
34,784,644 | What is the difference between OAuth based and Token based authentication? | <p>I thought that OAuth is basically a token based authentication specification but most of the time frameworks act as if there is a difference between them. For example, as shown in the picture below <a href="https://jhipster.github.io/" rel="noreferrer">Jhipster</a> asks whether to use an OAuth based or a token based authentication. </p>
<p>Aren't these the same thing ? What exactly is the difference since both includes tokens in their implementations ?</p>
<p><a href="https://i.stack.imgur.com/vCcXA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vCcXA.png" alt="enter image description here"></a></p>
| <authentication><oauth><oauth-2.0><access-token><jwt> | 2016-01-14 08:19:40 | HQ |
34,785,161 | How to debug java source code when I implement a custom Detector for Lint? | <p>I am a Android developer.
I have already design my own lint rules by implementing new XXXDetector and XXXIssueRegistry, here is my source code snip:</p>
<p>My XXXIssueRegistry file:</p>
<pre><code>public class MyIssueRegistry extends IssueRegistry {
@Override
public List<Issue> getIssues() {
System.out.println("!!!!!!!!!!!!! ljf MyIssueRegistry lint rules works");
return Arrays.asList(AttrPrefixDetector.ISSUE,
LoggerUsageDetector.ISSUE);
}
}
</code></pre>
<p>My XXXDetector file:</p>
<pre><code>public class LoggerUsageDetector extends Detector
implements Detector.ClassScanner {
public static final Issue ISSUE = Issue.create("LogUtilsNotUsed",
"You must use our `LogUtils`",
"Logging should be avoided in production for security and performance reasons. Therefore, we created a LogUtils that wraps all our calls to Logger and disable them for release flavor.",
Category.MESSAGES,
9,
Severity.ERROR,
new Implementation(LoggerUsageDetector.class,
Scope.CLASS_FILE_SCOPE));
@Override
public List<String> getApplicableCallNames() {
return Arrays.asList("v", "d", "i", "w", "e", "wtf");
}
@Override
public List<String> getApplicableMethodNames() {
return Arrays.asList("v", "d", "i", "w", "e", "wtf");
}
@Override
public void checkCall(@NonNull ClassContext context,
@NonNull ClassNode classNode,
@NonNull MethodNode method,
@NonNull MethodInsnNode call) {
String owner = call.owner;
if (owner.startsWith("android/util/Log")) {
context.report(ISSUE,
method,
call,
context.getLocation(call),
"You must use our `LogUtils`");
}
}
}
</code></pre>
<p>Now I can run my custom lint rules by runnig command:</p>
<pre><code>$gradle lint
</code></pre>
<p>And I will get output message like I expected in console.</p>
<p>But I want to debug my XXXDetector source file. How can I do that?
If I click "debug" or "run" or "build" , my custom lint rules will NOT run! So I have to run it in console, which don't support debug.
How can I solve this?</p>
| <java><android><lint> | 2016-01-14 08:52:29 | HQ |
34,785,569 | Html code not working in safari.But working in all other browsers | And i think its not able to submit form in safari browser
This is working fine in all the browsers except safari
<form action="/commonDashboard" name="loginForm" method="post" autocomplete="off" id="loginForm">
<div>
<label>User Email ID</label>
<input type="text" placeholder="Enter your Email Address" id="userEmail" name="userEmail" tabindex="1" />
</div>
<div>
<label>Password</label>
<input type="password" placeholder="Enter your password" id="userPassword" name="userPassword" tabindex="2" />
</div>
<div>
<input type="button" value="Sign In" onclick="validatelogin();" tabindex="3" />
</div>
</form>
| <html><safari> | 2016-01-14 09:14:16 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.