Invalid JSON:Unexpected non-whitespace character after JSONat line 2, column 1
| {"QuestionId": 21279600, "AnswerCount": 2, "Tags": "<c#><asp.net><linq>", "CreationDate": "2014-01-22T09:58:44.253", "AcceptedAnswerId": "21279677", "Title": "Check last character is \"&\" is not and remove it (make this with linq)", "Body": "<p>I have a string <code>_outputUrl</code> and I want to check whether its last character is <code>\"&\"</code> or not. And if its <code>\"&\"</code> I want to remove it from string. I have made this with If case like this</p>\n\n<pre><code>if (_outputUrl!=null && _outputUrl[_outputUrl.Length - 1].ToString() == \"&\")\n{\n _outputUrl = _outputUrl.Remove(_outputUrl.Length - 1);\n\n}\n</code></pre>\n\n<p>How can I convert this to a linq expression?</p>\n", "Lable": "No"} | |
| {"QuestionId": 21337158, "AnswerCount": 1, "Tags": "<sharepoint><powershell>", "CreationDate": "2014-01-24T16:04:41.240", "AcceptedAnswerId": "21339613", "Title": "Delete Duplicate Items In SharePoint List", "Body": "<p>I have a list which has thousands of records and I need them to be unique. I found a PowerShell script online that will work if I only have 1 unique column. However, I have to group by 2 columns and I can't figure out how to make it work.</p>\n\n<p>For example, if I have this data in a SP list, only if both columns are duplicates should the items be removed.</p>\n\n<pre><code>Title Carrier\n1 Carrier1\n1 Carrier1 *Remove This One\n12 Carrier1\n12 Carrier2\n100 Carrier1 \n100 Carrier1 *Remove This One\n100 Carrier2\n</code></pre>\n\n<p>Here is the code sample I found online that will work for 1 column, but not for 2.</p>\n\n<pre><code>cls\nif((Get-PSSnapin | Where {$_.Name -eq \"Microsoft.SharePoint.PowerShell\"}) -eq $null) {\n Add-PSSnapin Microsoft.SharePoint.PowerShell;\n}\n\n$ListName = \"DuplicateTest\"\n\n$web = Get-SPWeb -identity \"http://MyVM/sites/TestSite\"\n$list = $web.Lists[$ListName]\n\n$AllDuplicates = $list.Items.GetDataTable() | Group-Object Title | where {$_.count -gt 1}\n$count = 1\n$max = $AllDuplicates.Count\nforeach($duplicate in $AllDuplicates) \n{ \n $duplicate.group | Select-Object -Skip 1 | % {$list.Items.DeleteItemById($_.ID)} \n Write-Progress -PercentComplete ($count / $max * 100) -Activity \"$count duplicates removed\" -Status \"In Progress\" \n $count++ \n}\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 21355266, "AnswerCount": 2, "Tags": "<ruby-on-rails><ajax><ruby-on-rails-4><coffeescript>", "CreationDate": "2014-01-25T19:34:55.590", "AcceptedAnswerId": null, "Title": "Using ajax to render partial", "Body": "<p>In my rails app I have a model <code>Song</code>. On one of the user's profile pages <code>user_music_path(@user)</code> I'm rendering all of their songs.</p>\n\n<p>People can also like these songs, which is set up and working, I just want to use AJAX instead of page refreshes. The problem I'm having is when using ajax, I get the error <code>undefined local variable or method \"song\"</code> when I'm clicking the link \"like\".</p>\n\n<p>Here is some of my code:</p>\n\n<p><strong>User's Music Page views/users/music.html.erb</strong></p>\n\n<pre><code>...\n<ul class=\"playlist list-group\">\n <%= render @songs %>\n</ul>\n</code></pre>\n\n<p><strong>views/songs/_song.html.erb</strong></p>\n\n<pre><code><li class=\"list-group-item\">\n <p class=\"pull-right\">\n <%= render :partial => 'songs/like_button', :locals => {:song => song} %>\n <%= render :partial => 'songs/likes', :locals => {:song => song} %>\n </p>\n</li>\n</code></pre>\n\n<p><strong>views/songs/_like_button.html.erb</strong></p>\n\n<pre><code><% if current_user.voted_on?(song) %>\n <%= link_to \"Unlike\", unlike_song_path(song), :method => :post, :remote => true %>\n<% else %>\n <%= link_to \"Like\", like_song_path(song), :method => :post, :remote => true %>\n<% end %>\n</code></pre>\n\n<p><strong>views/songs/_likes.html.erb</strong></p>\n\n<pre><code><%= song.votes.count %>\n</code></pre>\n\n<p><strong>views/songs/like.js.coffee</strong></p>\n\n<pre><code>$(\"p.pull-right\").html('<%= render :partial => \"songs/like_button\", :locals => {:song => song} %><%= render :partial => \"songs/likes\", :locals => {:song => song} %>');\n</code></pre>\n\n<p><strong>controllers/songs_controller.rb</strong></p>\n\n<pre><code>def like\n begin\n @vote = current_user.vote_for(@song = Song.find(params[:id]))\n @vote.save\n respond_with @song.user, :location => user_music_path(@song.user)\n rescue ActiveRecord::RecordInvalid\n redirect_to @song\n end\nend\n</code></pre>\n\n<p>And as mentioned earlier, the <code>:like</code> action worked perfectly before I starting using AJAX. I've also added <code>respond_to :html, :js</code> to my <code>songs_controller</code>. And the error I get when I try to like the song is <code>ActionView::Template::Error (undefined local variable or method \"song\" for #<#<Class:0x000001028de9d0>:0x00000106ecd9f0>):</code></p>\n", "Lable": "No"} | |
| {"QuestionId": 21739432, "AnswerCount": 2, "Tags": "<javascript><jquery><ckeditor><rich-text-editor><prop>", "CreationDate": "2014-02-12T20:57:30.700", "AcceptedAnswerId": null, "Title": "checking the value of CKEditor and disabling the submit button if no content", "Body": "<p>running a basic function that disables a form submit button depending on the input length.</p>\n\n<p>I am using this:</p>\n\n<pre><code> // check if the newpost text area in empty on page load and also input change\n$(document).ready(function(){\n disableNewPost();\n $('#newpost').keyup(disableNewPost);\n});\n\n// disable new post submit button if the new post ckeditor is empty\nfunction disableNewPost() {\n if ($('#newpost').val().length > 0) {\n $(\".addnewpostbtn\").prop(\"disabled\", false);\n } else {\n $(\".addnewpostbtn\").prop(\"disabled\", true);\n }\n}\n</code></pre>\n\n<p>This works with a normal text area see here:<a href=\"http://jsfiddle.net/QA22X/\" rel=\"nofollow\">http://jsfiddle.net/QA22X/</a></p>\n\n<p>But when working with CKEditor it doesn't work.</p>\n\n<p>I have done my research, but cant find anything that works.</p>\n\n<p>I saw this and tried it:</p>\n\n<pre><code> // check if the newpost text area in empty on page load and also input change\n$(document).ready(function(){\n disableNewPost();\n var e = CKEditor.instances['#newpost']\n e.on( 'keyup', function( event ) {\n disableNewPost();\n });\n});\n\n// disable new post submit button if the new post ckeditor is empty\nfunction disableNewPost() {\n var value = CKEDITOR.instances['#newpost'].getData();\n if ($(value).length > 0) {\n $(\".addnewpostbtn\").prop(\"disabled\", false);\n } else {\n $(\".addnewpostbtn\").prop(\"disabled\", true);\n }\n}\n</code></pre>\n\n<p>But that also doesn't work.</p>\n\n<p>Any help on this?</p>\n", "Lable": "No"} | |
| {"QuestionId": 21767161, "AnswerCount": 1, "Tags": "<java><spring><properties><expression><spring-el>", "CreationDate": "2014-02-13T22:44:15.853", "AcceptedAnswerId": null, "Title": "How do I pass a spring expression language evaluation as an argument?", "Body": "<p>This isn't working:</p>\n\n<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<beans xmlns=\"http://www.springframework.org/schema/beans\" \n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns:encryption=\"http://www.jasypt.org/schema/encryption\"\n xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n http://www.springframework.org/schema/beans/spring-beans-3.1.xsd\n http://www.jasypt.org/schema/encryption\n http://www.jasypt.org/schema/encryption/jasypt-spring31-encryption-1.xsd\">\n\n <import resource=\"properties/secure/jasypt-context.xml\" />\n <bean name=\"propEnvironment\" class=\"java.lang.String\">\n <constructor-arg value=\"#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }\" />\n </bean>\n <encryption:encryptable-property-placeholder \n encryptor=\"configurationEncryptor\"\n location=\"classpath:properties/#{propEnvironment}/*.properties,classpath:properties/common.properties\" />\n\n</beans>\n</code></pre>\n\n<p>Only common.properties gets configured by the encryptable property placeholder. It's like the other entry just disappears (no error is thrown or anything, it just doesn't load anything else). I want to stand up an instance with the production config files, but I want to use my dev properties. The spel expression is evaluating properly if I print that out. Is this possible?</p>\n\n<p>When I try this,</p>\n\n<pre><code><bean name=\"propEnvironment\" class=\"java.lang.String\" id=\"testing\">\n <constructor-arg value=\"#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }\" />\n</bean>\n<bean name=\"fullString\" class=\"java.lang.String\">\n <constructor-arg value=\"classpath:properties/#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }/*.properties\" />\n</bean>\n<bean class=\"EchoBean\" lazy-init=\"false\">\n <constructor-arg ref=\"propEnvironment\" />\n</bean>\n<bean class=\"EchoBean\" lazy-init=\"false\">\n <constructor-arg ref=\"fullString\" />\n</bean>\n<bean class=\"EchoBean\" lazy-init=\"false\">\n <constructor-arg value=\"#{@testing.toString()}\" />\n</bean>\n<bean class=\"EchoBean\" lazy-init=\"false\">\n <constructor-arg value=\"blah\" />\n</bean>\n</code></pre>\n\n<p>The third echo using the @ syntax does not produce any output.</p>\n\n<pre><code>2014-02-14 10:03:41,998 [main] INFO EchoBean - local\n2014-02-14 10:03:42,000 [main] INFO EchoBean - classpath:properties/local/*.properties\n2014-02-14 10:03:42,000 [main] INFO EchoBean - blah\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 21783137, "AnswerCount": 7, "Tags": "<c#><json><json.net><camelcasing>", "CreationDate": "2014-02-14T15:23:27.910", "AcceptedAnswerId": null, "Title": "Default camel case of property names in JSON serialization", "Body": "<p>I have a bunch of classes that will be serialized to JSON at some point and for the sake of following both C# conventions on the back-end and JavaScript conventions on the front-end, I've been defining properties like this:</p>\n\n<pre><code>[JsonProperty(PropertyName=\"myFoo\")]\npublic int MyFoo { get; set; }\n</code></pre>\n\n<p>So that in C# I can:</p>\n\n<pre><code>MyFoo = 10;\n</code></pre>\n\n<p>And in Javascript I can:</p>\n\n<pre><code>if (myFoo === 10)\n</code></pre>\n\n<p>But doing this for every property is tedious. Is there a quick and easy way to set the default way JSON.Net handles property names so it will automatically camel case unless told otherwise?</p>\n", "Lable": "No"} | |
| {"QuestionId": 21817378, "AnswerCount": 1, "Tags": "<python><scipy><sparse-matrix>", "CreationDate": "2014-02-16T22:08:32.827", "AcceptedAnswerId": null, "Title": "Efficiently assign a row to a lil_matrix", "Body": "<p>How can I efficiently assign a row to a <code>lil_matrix</code>? I'm currently using:</p>\n\n<pre><code>Q[mid, :] = new_Q\n</code></pre>\n\n<p>where <code>new_Q</code> is the result of <code>lil_matrix.getrow(x)</code></p>\n\n<p>I ran a test on using <code>Q.getrow(i)</code> vs. <code>Q[i, :]</code>, and found the former to be 20x faster. </p>\n\n<p><a href=\"http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.lil_matrix.html\" rel=\"nofollow\">Here's the <code>lil_matrix</code> documentation.</a></p>\n", "Lable": "No"} | |
| {"QuestionId": 21966096, "AnswerCount": 2, "Tags": "<flash><air><publish>", "CreationDate": "2014-02-23T08:47:39.093", "AcceptedAnswerId": "21986967", "Title": "Publish AIR desktop application", "Body": "<p>This is what the users of my <strong>desktop application</strong> see when they launch my AIR installer.</p>\n\n<p>What should I do?</p>\n\n<p><img src=\"https://i.stack.imgur.com/e6l7P.jpg\" alt=\"Do not install installer\"></p>\n", "Lable": "No"} | |
| {"QuestionId": 21974347, "AnswerCount": 0, "Tags": "<netty>", "CreationDate": "2014-02-23T20:51:53.720", "AcceptedAnswerId": null, "Title": "Combining two sequential backend responses to construct the frontend response", "Body": "<p>Netty 4.0 server that makes two outbound requests for every incoming request, and uses the responses of the outbound requests to form the response to the original inbound request. Outbound 1 response is used to build Outbound 2 request if successful.</p>\n\n<p>See diagram here: <a href=\"https://twitter.com/puffybsd/status/437652876928626688/photo/1\" rel=\"nofollow\">https://twitter.com/puffybsd/status/437652876928626688/photo/1</a></p>\n\n<p>Here's what I'm doing now (just a test with 1 remote host):</p>\n\n<ol>\n<li>Create a standard ServerBootstrap with a pipeline that contains a <code>SimpleInboundChannelHandler<FullHttpRequest></code> call it <code>HandlerA</code>.</li>\n<li>When <code>HandlerA</code> receives a <code>channelActive</code> event, create a new Bootstrap, register a new Handler, <code>HandlerB</code>, open the connection to the 1st remote host and store the channel <code>ChannelB</code> in a variable of <code>HandlerA</code>.</li>\n<li>When <code>HandlerA</code> receives a <code>read0</code> event, extract parameters from the <code>FullHttpRequest</code> object, build a <code>FullHttpResponse</code> object and store it in an attribute of the <code>ChannelB</code> variable along with the current context.</li>\n<li>Send a request to the first remote host.</li>\n<li>When <code>HandlerB</code> receives a <code>FullHttpResponse</code> from remote host 1, extract the original context and <code>FullHttpResponse</code> object from the <code>ChannelB</code> attribute set.</li>\n<li>Update the <code>FullHttpResponse</code> and write it to the original context's channel.</li>\n</ol>\n\n<p>This appears to work. Haven't added the 2nd remote host call yet. The two backend remote hosts do not change - they're always the same addresses. What it appears to be doing is opening a socket to the backend when there's a new client request, sending a request to the backend, then sending a response to the client when a response from the backend is received.</p>\n\n<p>Here's some code:</p>\n\n<pre><code>public class MainIncomingRequestHandler extends SimpleChannelInboundHandler<FullHttpRequest> {\n private Channel outboundChannel;\n\n @Override\n public void channelActive(final ChannelHandlerContext ctx) throws Exception {\n\n Bootstrap bootstrap = new Bootstrap();\n bootstrap.group(ctx.channel().eventLoop());\n bootstrap.channel(ctx.channel().getClass());\n bootstrap.handler(new IncomingResponseHandler());\n\n outboundChannel = channelFuture = bootstrap.connect(host, port).channel();\n } \n\n @Override\n public void channelRead0(final ChannelHandlerContext ctx, FullHttpRequest msg)\n throws Exception {\n //create a response object.\n\n //save the response to the outboundChannel's attribute map.\n outboundChannel.attr(CONTEXT_KEY).set(ctx);\n outboundChannel.attr(RESPONSE_KEY).set(response);\n\n //create a request and write it to the outboundChannel.\n outboundChannel.writeAndFlush(req);\n }\n}\n\npublic class IncomingResponseHandler extends SimpleChannelInboundHandler<FullHttpResponse> {\n\n @Override\n protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse inboundResponse)\n throws Exception {\n\n //extract data from the remote response. \n //... \n\n //fetch the original context and response from the channel attributes.\n ChannelHandlerContext ctx = ctx.channel().attr(CONTEXT_KEY).get();\n FullHttpResponse response = ctx.channel().attr(OUTBOUND_RESPONSE_KEY).get();\n\n //update the outbound response with results from the inbound response.\n //...\n\n //send the response to the original inbound request.\n ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);\n\n }\n}\n</code></pre>\n\n<p>Here are the questions:</p>\n\n<ol>\n<li>Will creating a new Bootstrap client for each active channel reuse underlying connections?</li>\n<li>Is there a risk that responses get tied to the wrong incoming request? (I think not due to http rules, but not 100% sure).</li>\n<li>Is there an easier way to do it?</li>\n<li>How should errors and timeouts be handled, particularly clean-up?</li>\n<li>Is there an end-to-end example other that SocksProxy and HexDumpProxy? This seems like an extremely common use case.</li>\n</ol>\n", "Lable": "No"} | |