pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
28,803,403
0
<p>You can try the below, using <a href="https://msdn.microsoft.com/en-us/library/tabh47cf%28v=vs.110%29.aspx" rel="nofollow">String.Split</a> which has been implemented specifically for these issues in .net. </p> <pre><code>Private Sub btnEnter_Click(sender As Object, e As EventArgs) Handles btnEnter.Click Dim Street As String, City As String, State As String, Zip As String Dim data() as string data = txtAddress.Text.Split("/"c) Street = data(0) City = data(1) State = data(2) Zip = data(3) TextBox1.Text = Street &amp; vbCrLf &amp; City &amp; " " &amp; State End Sub </code></pre>
27,398,755
0
PIN Block translation on thales HSM not working <p>I have encrypted a PIN block under a TPK (clear)</p> <p>When I am going to translation my PIN block from encryption under TPK to encryption under ZPK given from client on real HSM then it is giving me either error code 24 or 20.</p> <p>What can i do to resolve my issue ? I have tried many ways but it is not getting resolved.</p> <p>Translation command I am using is CA - Translate a PIN from TPK to ZPK/BDK (3-DES DUKPT) Encryption.</p> <p>Al these my operations working beautifully with thales HSM simulator.</p>
31,136,934
0
<p>You can use <code>new Function</code> for that. It wraps your code into a function like this:</p> <pre><code>var fn = new Function(output); fn(); </code></pre> <p>Or shorter:</p> <pre><code>new Function(output)(); </code></pre> <p>Which is the equivalent of:</p> <pre><code>function(){ var newElement = document.createElement("h1"); var element = document.createTextNode("Hello World!"); newElement.appendChild(element); document.body.appendChild(newElement); } </code></pre>
17,968,979
0
<p>Since your tree is essentially an object array, where each object has a label and an optional child array, what you need to prune are array elements, either in the main tree array or in one of it's branches. </p> <p>You definitely do not want to use <code>delete</code> to delete array elements, since that leaves you with a sparse array. Instead, you should <code>splice</code> out array elements. </p> <p>You should, on the other hand, use <code>delete</code> to remove object properties, like <code>children</code> once they're empty. Here's the code I would use:</p> <pre><code>function prune(array, label) { for (var i = 0; i &lt; array.length; ++i) { var obj = array[i]; if (obj.label === label) { // splice out 1 element starting at position i array.splice(i, 1); return true; } if (obj.children) { if (prune(obj.children, label)) { if (obj.children.length === 0) { // delete children property when empty delete obj.children; // or, to delete this parent altogether // as a result of it having no more children // do this instead array.splice(i, 1); } return true; } } } } </code></pre> <p>Now assuming your tree was called <code>tree</code> and the label you wanted pruned was <code>node3</code>, you would call prune like so:</p> <pre><code>var wasItPruned = prune(tree, "node3"); </code></pre>
32,032,574
0
How do i make a class that MUST be instantiated <p>how do I make a class that MUST be instantiated it, or anything like that. If it is possible anyway..</p>
26,763,112
0
Boostrap Popover error: Uncaught TypeError: undefined is not a function <p>I am getting a Uncaught TypeError: undefined is not a function on one page of my site. The function works without error on all the other pages. its a bit of a lengthy page code wise so i will only post it if need be, but here is the basics.</p> <p><strong>the button for the popover:</strong></p> <pre><code>&lt;button class="btn btn-info" id="help" type="button" data-toggle="popover" data-trigger="focus" data-html="true" data-placement="bottom" title="ActiveMLS Documentation" data-content="&lt;small&gt;&lt;p&gt;&lt;strong&gt;List Custom Property Listings&lt;/strong&gt;&lt;/p&gt;&lt;/small&gt;"&gt;&lt;i class="fa fa-question-circle"&gt;&lt;/i&gt;&lt;/button&gt; </code></pre> <p><strong>the error</strong></p> <blockquote> <p>Uncaught TypeError: undefined is not a function shell.js:23</p> </blockquote> <p><strong>the jquery from shell.js line 23</strong></p> <pre><code>/*******************************/ /* POPOVER HELPER /*******************************/ $(document).ready(function(){ $('#help').popover() }); </code></pre> <p>I'm baffled as to why it breaks on this page only?</p> <pre><code>&lt;!-- blueimp Gallery styles --&gt; &lt;link rel="stylesheet" href="/static/uploadlib/css/blueimp-gallery.min.css"&gt; &lt;!-- CSS to style the file input field as button and adjust the Bootstrap progress bars --&gt; &lt;link rel="stylesheet" href="/static/uploadlib/css/jquery.fileupload-ui.css"&gt; &lt;div class="row-fluid"&gt; &lt;div class="col-md-12"&gt; &lt;div class="row-fluid"&gt; &lt;div class="section-header text-center"&gt; &lt;button class="btn btn-info" id="help" type="button" data-toggle="popover" data-trigger="focus" data-html="true" data-placement="bottom" title="ActiveMLS Documentation" data-content="&lt;small&gt;&lt;p&gt;&lt;strong&gt;List Custom Property Listings&lt;/strong&gt; - The list Custom Property listings page is an overview of all the Custom Property listings listings and information displayed on the website frontend&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Add Custom Property Listings&lt;/strong&gt; - Shortcut to the &lt;em&gt;Add Custom Property Listings&lt;/em&gt; page.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Records Per Page&lt;/strong&gt; - Display any list 10, 25, 50, or 100 records at a time.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Search&lt;/strong&gt; - Search any list by keyword(s).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Listing ID&lt;/strong&gt; - The Custom Property ID of the Custom Property listing.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Address&lt;/strong&gt; - The address of the Custom Property listing.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Edit Custom Property Listing&lt;/strong&gt; - Access the &lt;em&gt;Edit Custom Property Listing&lt;/em&gt; page for this listing.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Delete Custom Property Listing&lt;/strong&gt; - Access the &lt;em&gt;Delete Custom Property Listing&lt;/em&gt; page for this listing.&lt;/li&gt;&lt;/ul&gt;&lt;/small&gt;"&gt;&lt;i class="fa fa-question-circle"&gt;&lt;/i&gt;&lt;/button&gt; &lt;!-- TMPL_IF add_mode --&gt; &lt;h1&gt;Add Custom Property Listing&lt;/h1&gt; &lt;!-- /TMPL_IF --&gt; &lt;!-- TMPL_IF edit_mode --&gt; &lt;h1&gt;Edit Custom Property Listing&lt;/h1&gt; &lt;!-- /TMPL_IF --&gt; &lt;!-- TMPL_IF delete_mode --&gt; &lt;h1&gt;Delete Custom Property Listing&lt;/h1&gt; &lt;!-- /TMPL_IF --&gt; &lt;/div&gt; &lt;/div&gt; &lt;form id="fileupload" method="post" action="&lt;!-- TMPL_VAR request_path --&gt;"&gt; &lt;div class="row-fluid"&gt; &lt;!-- TMPL_IF error_message --&gt; &lt;div class="alert alert-danger alert-dismissable" role="alert" &gt; &lt;button type="button" class="close" data-dismiss="alert"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt; Warning!&lt;br /&gt; &lt;!-- TMPL_VAR error_message ESCAPE=0 --&gt; &lt;/div&gt; &lt;!-- /TMPL_IF --&gt; &lt;/div&gt; &lt;div class="row-fluid"&gt; &lt;fieldset&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Listing Category&lt;/label&gt; &lt;!-- TMPL_VAR category ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Listing ID&lt;/label&gt; &lt;!-- TMPL_VAR listing_id ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Agent Name&lt;/label&gt; &lt;!-- TMPL_VAR l_ag1_id ESCAPE=0 --&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;hr /&gt; &lt;div class="row-fluid"&gt; &lt;fieldset&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Price&lt;/label&gt; &lt;!-- TMPL_VAR price ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="row-fluid"&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Street Address&lt;/label&gt; &lt;!-- TMPL_VAR street_no ESCAPE=0 --&gt; &lt;!-- TMPL_VAR street ESCAPE=0 --&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;City&lt;/label&gt; &lt;!-- TMPL_VAR city ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;State&lt;/label&gt; &lt;!-- TMPL_VAR state ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Zip Code&lt;/label&gt; &lt;!-- TMPL_VAR zip ESCAPE=0 --&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;hr /&gt; &lt;div class="row-fluid"&gt; &lt;fieldset&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Description&lt;/label&gt; &lt;!-- TMPL_VAR remarks_general ESCAPE=0 --&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;hr /&gt; &lt;div class="row-fluid"&gt; &lt;fieldset&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Business Type&lt;/label&gt; &lt;!-- TMPL_VAR business_type ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;For Lease&lt;/label&gt; &lt;!-- TMPL_VAR for_lease_yn ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;For Sale&lt;/label&gt; &lt;!-- TMPL_VAR for_sale_yn ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Parcel Type&lt;/label&gt; &lt;!-- TMPL_VAR parcel_type ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Area&lt;/label&gt; &lt;!-- TMPL_VAR area_desc ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;County&lt;/label&gt; &lt;!-- TMPL_VAR county ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;School District&lt;/label&gt; &lt;!-- TMPL_VAR schools_d ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Elementary School&lt;/label&gt; &lt;!-- TMPL_VAR schools_e ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;High School&lt;/label&gt; &lt;!-- TMPL_VAR schools_h ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Year Built&lt;/label&gt; &lt;!-- TMPL_VAR year_built ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Type&lt;/label&gt; &lt;!-- TMPL_VAR type ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Rooms&lt;/label&gt; &lt;!-- TMPL_VAR no_rooms ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Bedrooms&lt;/label&gt; &lt;!-- TMPL_VAR bdrms ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Baths, Full&lt;/label&gt; &lt;!-- TMPL_VAR baths_full ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Baths, Half&lt;/label&gt; &lt;!-- TMPL_VAR baths_part ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Approx. Sq. Ft.&lt;/label&gt; &lt;!-- TMPL_VAR sqft ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Approx. Lot Size&lt;/label&gt; &lt;!-- TMPL_VAR lot_size ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Approx. Acre&lt;/label&gt; &lt;!-- TMPL_VAR acres ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Foundation&lt;/label&gt; &lt;!-- TMPL_VAR foundation ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Exterior&lt;/label&gt; &lt;!-- TMPL_VAR exterior ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Heating&lt;/label&gt; &lt;!-- TMPL_VAR heating ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Cooling&lt;/label&gt; &lt;!-- TMPL_VAR cooling ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Fuel&lt;/label&gt; &lt;!-- TMPL_VAR heat_fuel ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Parking Spaces&lt;/label&gt; &lt;!-- TMPL_VAR gar_prk_no ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Sewer&lt;/label&gt; &lt;!-- TMPL_VAR sewer ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Water&lt;/label&gt; &lt;!-- TMPL_VAR water ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Fireplace&lt;/label&gt; &lt;!-- TMPL_VAR fireplace ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Tax 1&lt;/label&gt; &lt;!-- TMPL_VAR tax_1 ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Tax 2&lt;/label&gt; &lt;!-- TMPL_VAR tax_2 ESCAPE=0 --&gt; &lt;/div&gt; &lt;div class="form-group col-md-6"&gt; &lt;label class="col-md-6"&gt;Six Month Tax&lt;/label&gt; &lt;!-- TMPL_VAR six_mo_taxes ESCAPE=0 --&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;hr /&gt; &lt;!-- TMPL_IF delete_mode --&gt; &lt;p&gt; &lt;!-- TMPL_LOOP Thumbnails --&gt; &lt;img src="/custom_prop/photo_thumbnail?filename=&lt;!-- TMPL_VAR filename --&gt;"&gt; &lt;!-- /TMPL_LOOP --&gt; &lt;/p&gt; &lt;!-- TMPL_ELSE --&gt; &lt;!-- Start Upload --&gt; &lt;noscript&gt;&lt;p&gt;JavaScript is required for photo upload.&lt;/p&gt;&lt;/noscript&gt; &lt;input type="hidden" name="nonce" value="&lt;!-- TMPL_VAR nonce --&gt;"/&gt; &lt;!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --&gt; &lt;div class="row fileupload-buttonbar"&gt; &lt;div class="col-md-7"&gt; &lt;!-- The fileinput-button span is used to style the file input field as button --&gt; &lt;span class="btn btn-success fileinput-button"&gt; &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt; &lt;span&gt;Add photos...&lt;/span&gt; &lt;input type="file" name="files" multiple&gt; &lt;/span&gt; &lt;button type="submit" class="btn btn-primary start"&gt; &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt; &lt;span&gt;Start upload&lt;/span&gt; &lt;/button&gt; &lt;button type="reset" class="btn btn-warning cancel"&gt; &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt; &lt;span&gt;Cancel upload&lt;/span&gt; &lt;/button&gt; &lt;button type="button" class="btn btn-danger delete"&gt; &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;span&gt;Delete&lt;/span&gt; &lt;/button&gt; &lt;!-- The loading indicator is shown during file processing --&gt; &lt;span class="fileupload-loading"&gt;&lt;/span&gt; &lt;/div&gt; &lt;!-- The global progress information --&gt; &lt;div class="span5 fileupload-progress fade"&gt; &lt;!-- The global progress bar --&gt; &lt;div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"&gt; &lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- The extended global progress information --&gt; &lt;div class="progress-extended"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- The table listing the files available for upload/download --&gt; &lt;table role="presentation" class="table table-striped"&gt;&lt;tbody class="files"&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;!-- The blueimp Gallery widget --&gt; &lt;div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even"&gt; &lt;div class="slides"&gt;&lt;/div&gt; &lt;h3 class="title"&gt;&lt;/h3&gt; &lt;a class="prev"&gt;‹&lt;/a&gt; &lt;a class="next"&gt;›&lt;/a&gt; &lt;a class="close"&gt;×&lt;/a&gt; &lt;a class="play-pause"&gt;&lt;/a&gt; &lt;ol class="indicator"&gt;&lt;/ol&gt; &lt;/div&gt; &lt;!-- /TMPL_IF --&gt; &lt;div class="row"&gt; &lt;div class="col-md-6"&gt; &lt;!-- TMPL_IF edit_mode --&gt; &lt;input type="submit" name="submit" class="btn btn-primary" value="Save"/&gt; &lt;input type="submit" name="cancel" class="btn" value="Cancel"/&gt; &lt;!-- /TMPL_IF --&gt; &lt;!-- TMPL_IF add_mode --&gt; &lt;input type="submit" name="submit" class="btn btn-primary" value="Save"/&gt; &lt;input type="submit" name="cancel" class="btn" value="Cancel"/&gt; &lt;!-- /TMPL_IF --&gt; &lt;!-- TMPL_IF delete_mode --&gt; &lt;p&gt;Are you sure you want to delete this listing?&lt;/p&gt; &lt;input type="submit" name="confirm" class="btn btn-primary" value="Yes"/&gt; &lt;input type="submit" name="cancel" class="btn" value="No"/&gt; &lt;!-- /TMPL_IF --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- The template to display files available for upload --&gt; &lt;script id="template-upload" type="text/x-tmpl"&gt; {% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-upload fade"&gt; &lt;td&gt; &lt;span class="preview"&gt;&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;p class="name"&gt;{%=file.name%}&lt;/p&gt; {% if (file.error) { %} &lt;div&gt;&lt;span class="label label-important"&gt;Error&lt;/span&gt; {%=file.error%}&lt;/div&gt; {% } %} &lt;/td&gt; &lt;td&gt; &lt;p class="size"&gt;{%=o.formatFileSize(file.size)%}&lt;/p&gt; {% if (!o.files.error) { %} &lt;div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"&gt;&lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt;&lt;/div&gt; {% } %} &lt;/td&gt; &lt;td&gt; {% if (!o.files.error &amp;&amp; !i &amp;&amp; !o.options.autoUpload) { %} &lt;button class="btn btn-primary start"&gt; &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt; &lt;span&gt;Start&lt;/span&gt; &lt;/button&gt; {% } %} {% if (!i) { %} &lt;button class="btn btn-warning cancel"&gt; &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt; &lt;span&gt;Cancel&lt;/span&gt; &lt;/button&gt; {% } %} &lt;/td&gt; &lt;/tr&gt; {% } %} &lt;/script&gt; &lt;!-- The template to display files available for download --&gt; &lt;script id="template-download" type="text/x-tmpl"&gt; {% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-download fade"&gt; &lt;td&gt; &lt;span class="preview"&gt; {% if (file.thumbnailUrl) { %} &lt;a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery&gt;&lt;img src="{%=file.thumbnailUrl%}"&gt;&lt;/a&gt; {% } %} &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;p class="name"&gt; &lt;a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}&gt;{%=file.name%}&lt;/a&gt; &lt;/p&gt; {% if (file.error) { %} &lt;div&gt;&lt;span class="label label-important"&gt;Error&lt;/span&gt; {%=file.error%}&lt;/div&gt; {% } %} &lt;/td&gt; &lt;td&gt; &lt;span class="size"&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}&gt; &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;span&gt;Delete&lt;/span&gt; &lt;/button&gt; &lt;/td&gt; &lt;/tr&gt; {% } %} &lt;/script&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included --&gt; &lt;script src="/static/uploadlib/js/vendor/jquery.ui.widget.js"&gt;&lt;/script&gt; &lt;!-- The Templates plugin is included to render the upload/download listings --&gt; &lt;script src="/static/uploadlib/js/tmpl.min.js"&gt;&lt;/script&gt; &lt;!-- The Load Image plugin is included for the preview images and image resizing functionality --&gt; &lt;script src="/static/uploadlib/js/load-image.min.js"&gt;&lt;/script&gt; &lt;!-- blueimp Gallery script --&gt; &lt;script src="/static/uploadlib/js/jquery.blueimp-gallery.min.js"&gt;&lt;/script&gt; &lt;!-- The Iframe Transport is required for browsers without support for XHR file uploads --&gt; &lt;script src="/static/uploadlib/js/jquery.iframe-transport.js"&gt;&lt;/script&gt; &lt;!-- The basic File Upload plugin --&gt; &lt;script src="/static/uploadlib/js/jquery.fileupload.js"&gt;&lt;/script&gt; &lt;!-- The File Upload processing plugin --&gt; &lt;script src="/static/uploadlib/js/jquery.fileupload-process.js"&gt;&lt;/script&gt; &lt;!-- The File Upload image preview &amp; resize plugin --&gt; &lt;script src="/static/uploadlib/js/jquery.fileupload-image.js"&gt;&lt;/script&gt; &lt;!-- The File Upload validation plugin --&gt; &lt;script src="/static/uploadlib/js/jquery.fileupload-validate.js"&gt;&lt;/script&gt; &lt;!-- The File Upload user interface plugin --&gt; &lt;script src="/static/uploadlib/js/jquery.fileupload-ui.js"&gt;&lt;/script&gt; &lt;!-- The main application script --&gt; &lt;script&gt; $(function () { 'use strict'; // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ url: '/custom_prop/file_upload_handler?nonce=&lt;!-- TMPL_VAR nonce --&gt;' }); // Load existing files: $('#fileupload').addClass('fileupload-processing'); $.ajax({ url: $('#fileupload').fileupload('option', 'url'), dataType: 'json', context: $('#fileupload')[0] }).always(function () { $(this).removeClass('fileupload-processing'); }).done(function (result) { $(this).fileupload('option', 'done') .call(this, null, {result: result}); }); }); &lt;/script&gt; &lt;!-- End Upload --&gt; </code></pre>
33,576,878
0
Can't figure out which function called when <p>There is an <code>elements</code> object, which is not Array but array-like HTML object.<br> I need to <code>alert</code> <code>innerHTML</code> of each <code>element</code> in 1 second after <code>click</code> on it.<br> I wrote this code (below), but it doesn't work.</p> <pre><code>[].forEach.call(elements, function (element) { element.onclick = () =&gt; setTimeout(alert(element.innerHTML), 1000); }); </code></pre> <p>I intuitively know that there is an error in this code (even without its execution), but I don't know where and what is it like (something wrong with arguments maybe?).<br> Use of <code>forEach</code> is mandatory (indexer <code>i</code> is used in original code).</p> <hr> <p>Perhaps omitting insignificant details of the problem, I missed something meaningful. So I bring a more complete piece of code:</p> <pre><code>var colors = ["red", "green", "blue"]; var fragment = document.createDocumentFragment(); colors.forEach(function (color, i) { var span = document.createElement("SPAN"); span.style.backgroundColor = color; span.tabIndex = i + 1; span.onclick = () =&gt; setTimeout(console.log(span.innerHTML), 1000); fragment.appendChild(span); }); </code></pre>
38,003,890
0
RecyclerView's textview store/restore state in android fragment not working <p>I am developing one android application my problem structure is like this.</p> <p>One activity contains one fragment and this fragment contains one RecyclerView. RecyclerView item contains two textviews which displays simple text like this :</p> <pre><code> TextTitle TextValue --&gt; item1 TextTitle TextValue --&gt; item2 TextTitle TextValue --&gt; item3 </code></pre> <p>If User taps on text value, its value gets changed (Value is binary so it will be only two). If user change first two item's value by tapping and I want to restore those two values when I will come back to this fragment with a help of restore/save state.</p> <p>I followed many articles and gather information that if I have to use proper unique id in item's view layout for both textviews then recyclerview state will be stored automatically, only just you need to save whole recyclerview state. Its not working in my case. What am I doing wrong? Do I need to fill adapter again?</p> <p>any help would be appreciated.</p> <pre><code> @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(INSTANCE_STATE_CONTENT_RECYCLER_VIEW,recyclerView.getLayoutManager().onSaveInstanceState()); } // again restore it restore it if (recyclerViewState != null) { recyclerView.getLayoutManager().onRestoreInstanceState(recyclerViewState); recyclerViewState = null; } @Override public void onViewBound(@Nullable Bundle savedInstanceState) { //super.onViewBound(savedInstanceState); if (savedInstanceState != null) { recyclerViewState = savedInstanceState.getParcelable(INSTANCE_STATE_CONTENT_RECYCLER_VIEW); } // continue with my work. } </code></pre>
8,791,424
0
Setting ASP.NET Cache control headers <p>In my asp.net forms app. I'm trying to prevent caching of certain pages. to do so I've set a series of cache control headers using Response.AppendHeader e.g.</p> <pre> protected override void OnLoad(Eventargs e) { ... Response.ClearHeaders(); Response.AppendHeader("Cache-Control","no-cache"); .... base.OnLoad(e); } </pre> <p>Trouble is when I view my site and look at the Net tab in the Firefox console to view the request/response headers I see a behavior as follows:</p> <ol> <li><p>a POST request/response for the page1.aspx which triggers a redirect (to page2.aspx) the response here contains the correct headers. </p></li> <li><p>a GET request/response for page2.aspx associated response has the cache-control header just has a value 'pre-check=0'</p></li> </ol> <p>That second request seems to allow the caching to happen for the page.. note: page1.aspx and page2.aspx both have the OnLoad logic I describe above. Also if I take some action on page2.aspx, the POST response will again have the correct headers.</p> <p>What am I missing here? My expectation was that with the logic in OnLoad should mean that I always get the headers in the response and therefore 'always' get the current version of the page? </p> <p>What I'm seeing is firefox loading it's cached version of the page.</p> <p>I'm considering creating a random identifier in the request url to force the matter, but that seems a little heavy handed.</p> <p>-----update----- It seems that, this may be related to having the caching code in 'OnLoad'. I've added these headers to the Page_Load() of the page and it works fine? any thoughts.</p>
13,968,272
0
<p>It's a hack, but the best way I could find (without using ugly <code>ScrollPaneManager</code>s) was to implement a <code>ComponentListener</code> on the <code>JScrollPane</code> to resize the child component whenever it was resized.</p> <pre><code>jsp.addComponentListener(new ComponentListener() { @Override public void componentShown(ComponentEvent e) {} @Override public void componentResized(ComponentEvent e) { Dimension jspSize = ((JScrollPane)e.getComponent()).getViewport().getSize(); jep.setBounds(0, 0, jspSize.width, jspSize.height); } @Override public void componentMoved(ComponentEvent e) {} @Override public void componentHidden(ComponentEvent e) {} }); </code></pre>
2,990,839
0
<p>Try changing the C# interface to take a <code>ref</code> parameter.</p>
325,729
0
<p>You cannot have multiple inheritance in Java. However by using AOP you can have "limited" multiple inheritance. Try to google this to see some examples.</p> <p>I also agree with Eyvid. Hannemann and Kiczales paper is great for learning the basics on design patterns and getting some great AOP examples.</p>
38,648,351
0
<p>Pretty simple to translate, you just need to get used to the differences between Java and the C# wrappers. C# will use properties instead of getXXX methods, and use CamelCase instead of all caps.</p> <p>Inside your activity class:</p> <pre><code>using Android.Telephony; public class MyActivity : Activity { private string GetMyPhoneNumber() { var tMgr = (TelephonyManager)GetSystemService(TelephonyService); return tMgr.Line1Number; } } </code></pre>
11,084,216
0
Select statement to get a specific row from an inner join <p>The question I have is kind of simular to this one - <a href="http://stackoverflow.com/questions/10914079/mysql-select-1-row-from-inner-join">MySQL select 1 row from inner join</a></p> <p>However, it was never really answered in the way that I needed it. So I thought I would ask.</p> <p>I have a table A (tableA) and this table has a load of states in tableB. New states keep being added all the time.</p> <p>TableB has a column 'State' which has a foreign key to TableA.Id. This table B has a value and timestamp</p> <p>I am trying to get ONE query which will bring back ALL values in TableA, with an inner join to bring the LATEST 'value' of those rows from tableB. The latest being the one with the latest time.</p> <p>I know how to do an inner join where it needs to be, and I know how to order a table to bring back the latest 'time' row, however I dont know how to put these two together and create a single query.</p> <p>I'm sure I will have to have a Select within a select, which is fine. However, what I am trying to avoid is to bring a DataTable back with all my results from TableA and do a query for each of those on tableB seperately.</p> <p>Any ideas?</p> <p>EDIT - I have made a mistake with the question, I only really noticed when trying to implement one of the answers.</p> <p>I have a foreign key between TableA.id and TableB.proId</p> <p>TableA - 'Id', 'Name' TableB - 'Id', 'proId', 'State', 'time'</p> <p>I want to bring back all values of TableA with a join on B, to bring back the 'State' of the Max time</p>
19,060,155
0
<p>Referencing the docs here: <a href="http://php.net/manual/en/function.mysql-query.php" rel="nofollow">http://php.net/manual/en/function.mysql-query.php</a>, mysql_query will return false in certain cases:</p> <p>"mysql_query() will also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query."</p> <p>Further, you either have a bare word in there "tblurser" or there is a "$" missing. Either way that should likely be fixed.</p>
31,617,194
0
<p>In ICEfaces for controls that has disabled property use:</p> <pre><code>&lt;ice:inputText disabled="[true/false]"/&gt; </code></pre> <p><strong>Example</strong></p> <p>I used this in my code:</p> <pre><code>&lt;ice:inputText disabled="#{ABMUsuario.accion!='3'}"/&gt; </code></pre>
8,785,620
0
<p>I would suggest ensuring that you have the correct connection details. The easiest way I can think of would be :</p> <ol> <li>Create a new text file ( f.e. connection.txt )</li> <li>Rename '.txt' to '.udl'</li> <li>Double-click the created connection.udl file</li> <li>Provide all the required connection details, hit 'Test connection' button</li> <li>If it works, hit 'OK' button, open the file with Notepad - connection string will be inside of your connection.udl file. If it doesn't work - you need to find out proper server details ( check instance name, port number, if your user has the correct permissions )</li> </ol>
30,776,166
0
How to make OR operator in regular expression? <p>What i want is something like this:</p> <pre><code>( [integer OR (ANY but not integer or white-space)] [(ONE white-space OR NONE)] [integer OR (ANY but not integer or white-space)] ) </code></pre> <p>Example of strings that will match: <code>99 $</code> <code>99$</code> <code>$ 99</code> <code>$99</code></p> <p>what i have now is two regular expression :</p> <p><code>^[^\d\s](\s{0,1})\d+</code> AND <code>^\d+(\s{0,1})[^\d\s]</code></p> <p>any ideas of how to replace those two with only one regular expression?</p>
12,681,588
0
Is it possible to open a PDF with fancybox 2.1 in IE8? <p>I'm working on a site that hosts a lot of PDF files and I want to open them in fancybox (2.1) for a preview. It works just fine in Chrome and Firefox. But it just won't work in IE8. I've tried linking directly to the PDF file, linking to an iframe, and linking to an embed tag (among other crazier things). I can't use google to wrap them. Here is a page that demonstrates the problem. </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt; &lt;head&gt; &lt;title&gt;My Page&lt;/title&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery.fancybox.js?v=2.1.0"&gt;&lt;/script&gt; &lt;link type="text/css" rel="stylesheet" media="screen" href="jquery.fancybox.css" /&gt; &lt;/head&gt; &lt;body style="background-color:grey"&gt; &lt;p&gt;&lt;a href="mypdffile.pdf" class="fancypdf"&gt;a link&lt;/a&gt; to a PDF file.&lt;/p&gt; &lt;p&gt;&lt;a href="#Frame1" class="fancy"&gt;a link&lt;/a&gt; to an iframe with the pdf in it.&lt;/p&gt; &lt;div style="display:none"&gt; &lt;iframe id="Frame1" src="mypdffile.pdf" style='width:100%;' height="600" frameborder="0" allowTransparency="true"&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;p&gt;&lt;a class="fancy" href="#mypdf" &gt;a link&lt;/a&gt; to a pdf in an embed tab&lt;/p&gt; &lt;div style="display:none"&gt;&lt;div id="mypdf"&gt; &lt;embed src="mypdffile.pdf" type="application/pdf" width="640" height="480" /&gt; &lt;/div&gt;&lt;/div&gt; &lt;script type='text/javascript'&gt; $(function(){ $("a.fancypdf").fancybox({type:'iframe'}); $("a.fancy").fancybox(); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The results are different each time. In IE for the first link the spinner appears and hangs. For the second two, a fancybox popup appears, but it's empty. What am I doing wrong?</p>
39,491,970
0
Using Swift 3 Measurement and Unit classes in Realm <p>Does Realm support the new Measurement and Unit classes in Swift 3 Foundation? It doesn't appear to be the case currently. If not, is there a recommended strategy for a workaround?</p>
37,534,546
0
<p>adding stuff to @theatlasroom answer, it can be called <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping" rel="nofollow">grouping</a>, basically you are adding +1 to a value coming from myName.length without breaking things before or after it.</p> <p>javascript could compare it before being myName.length + 1 </p>
32,425,573
0
<p>You can write in this way </p> <pre><code> &lt;script&gt; var x = -40; var y = 72; document.cookie = 'latitude' + "=" + x; document.cookie = 'longitude' + "=" + y; &lt;/script&gt; &lt;?php if(isset($_COOKIE['latitude']) &amp;&amp; isset($_COOKIE['longitude'])) { echo $_COOKIE['latitude']; echo $_COOKIE['longitude']; }else{ ?&gt; &lt;script type="text/javascript"&gt; document.body.innerHTML = x +'&lt;br&gt;'+y; // or in some element as you like &lt;/script&gt; &lt;?php } ?&gt; &lt;/body&gt; </code></pre>
13,864,329
0
<p>I think the best way to store those coordinates is to create a very simple class for each country which have just a 2D <code>float</code> tab(first D is for geopoint number, the second D has a size of 2 and contains lat or long)</p> <p>With you coordinates list, you can create a list of <code>Region</code>(using <code>Path</code> and <code>Region.setPath(Path, Region)</code>) and call <code>Region.contain(X, Y)</code> to chack if the point X,Y is inside your country.</p>
34,942,048
0
<p>So I have made so headway.<br> I started experimenting. <br> First if Magmi's Attribute Set Importer v0.0.2 was set ON - it would error and create 26 empty attributes no matter what I did.<br> Next it turns out you can not create and use custom attribute <B>product_id.</B> This also causes errors. I deleted that and changed it to manufacturer_id and it imports correctly.</p> <p>Here is the header I have so far:</p> <pre><code>sku name _attribute_set root_category_id weight description short_description categories _type status visibility manage_stock tax_class_id price cost qty manufacturer vendor color upc manufacturer_id </code></pre> <p>Here is example data:</p> <pre><code> 400100433072 Daewon Song Gold and Purple Default 2 0.25 Daewon Song Gold and Purple ear buds ear buds accessories::1::0::1/earbuds::1::0::0 simple 1 4 1 2 21.99 10 1 LOUD HAPPY HOUR gold purple 400100433072 02-02-0009 </code></pre> <p>Will just have to figure out how to deal with new attributes... </p>
1,137,446
0
<p>There isn't a "standard" black one, but it's not that much work to do what you're asking.</p> <p>Create (in photoshop or something similar) your own black version of the detail disclosure button. You can screen grab and colour it in if that's easier. Then add it as a resource to your project and put it inside a UIImage like so:</p> <pre><code>UIImage myImage = [UIImage imageNamed:@"blackbutton.png"]; </code></pre> <p>Then create a UIImageView which contains that image:</p> <pre><code>UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage]; </code></pre> <p>Finally then you can assign that to the "accessory view" for the cell you've set up already:</p> <pre><code>[cell setAccessoryView:imageView]; </code></pre> <p>Hope that helps!</p> <p>//EDIT - I felt like having a quick 5 mins in photoshop so created a black one for you. have fun!</p> <p><em>removed dead ImageShack link</em></p>
15,833,182
0
<p>you can use mask array:</p> <pre><code>import numpy as np a=np.array([1,2,3,4,5,6,7,8,9]) b=np.array([-1,-2,-3,-4,-5,1,2,-3,-4]) plot(a, b) m = b &gt; 0 plot(np.ma.array(a, mask=m), np.ma.array(b, mask=m), 'r--', lw=2) </code></pre> <p><img src="https://i.stack.imgur.com/6d3oW.png" alt="enter image description here"></p> <p>However, I think this maybe not what you want. Here is a quick method that can split the lines into two parts:</p> <pre><code>import numpy as np a=np.array([1,2,3,4,5,6,7,8,9]) b=np.array([-1,-2,-3,-4,-5,1,2,-3,-4]) x = np.linspace(a.min(), a.max(), 1000) y = np.interp(x, a, b) m = y &lt;= 0 plot(np.ma.array(x, mask=m), np.ma.array(y, mask=m), 'b-', lw=2) m = y &gt; 0 plot(np.ma.array(x, mask=m), np.ma.array(y, mask=m), 'r--', lw=2) </code></pre> <p><img src="https://i.stack.imgur.com/p4ftX.png" alt="enter image description here"></p> <p><code>np.interp()</code> will use many memory for large dataset, here is another method that find all zero points. The output is the same as above.</p> <pre><code>idx1 = np.where(b[1:] * b[:-1] &lt; 0)[0] idx2 = idx1 + 1 x0 = a[idx1] + np.abs(b[idx1] / (b[idx2] - b[idx1])) * (a[idx2] - a[idx1]) a2 = np.insert(a, idx2, x0) b2 = np.insert(b, idx2, 0) m = b2 &lt; 0 plot(np.ma.array(a2, mask=m), np.ma.array(b2, mask=m), 'b-', lw=2) m = b2 &gt; 0 plot(np.ma.array(a2, mask=m), np.ma.array(b2, mask=m), 'r--', lw=2) </code></pre>
17,863,814
0
<p>Handling the TextChanged event should work, however you need to set the DropDownStyle to DropDownList so that the Text property can only be a given value. Then check to see that both comboboxes have values selected. something like this should work:</p> <p>If ComboBox_Ticker.Text &lt;> "" AndAlso DateTime.TryParse(ComboBox_Date.Text, Nothing) Then</p>
36,355,238
0
<p>You can also make this:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.outer{ margin-top: 10px; position:absolute; width:80px;height:80px; border:1px solid #d3d3d3; padding: 1px; } .inner{ position:relative; width:100%; height:100%; background:red; }</code></pre> </div> </div> </p>
6,723,161
0
Simple example of CALayers in an NSView <p>I am trying to add several CALayers to an NSView but my view remains empty when shown:</p> <p>Here is my code:</p> <pre><code>- (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { self.layer = [CALayer layer]; self.wantsLayer = YES; CALayer *newLayer = [CALayer layer]; NSImage *image = [NSImage imageNamed:@"page.png"]; newLayer.backgroundColor = [NSColor redColor].CGColor; newLayer.contents = (id)[image CGImageForProposedRect:NULL context:NULL hints:nil]; newLayer.frame = NSMakeRect(100,100,100,100);//NSMakeRect(0,0,image.size.width,image.size.height); newLayer.position = CGPointMake(20,20); [self.layer addSublayer:newLayer]; } return self; </code></pre> <p>}</p> <p>DO have any idea (or example of code) to perform this task?</p> <p>Thanks and regards,</p>
21,703,433
0
Loop an array to replace DIV class <p>I have a landing page with a full page banner and an enter button central. My problem is, to maintain visibility of the button. I need to change it's class from <code>.dark</code> to <code>.light</code> depending on if the background is a dark one or a light one.</p> <p>I have looked into changing the DIV for a set time that matches my slider and make an array that matches the colour of the background image so the button will change colour according to my array. I also want the transition from changing each DIV to 'if possible' be a fade transition. </p> <p>I know I am at risk of a duplicate post here but I want to stress this question is unique to stack overflow and I cannot find my answers elsewhere.</p> <p>There seems to be plenty of solutions for cycling DIVs but I need to find the one right for my problem.</p> <p>Okay, so from what I have read I have tried this with jQuery:</p> <pre><code>$(window).load(function(){ setTimeout( function(){ $('#one').replaceWith($('#two')); $('#two').show(); }, 10000 ); }); </code></pre> <p>I do not know how to move this into an array or add the transition, AND.. I believe this may just replace with a separate DIV, rather than just replacing the class in my DIV.</p> <p>I have also looked at this:</p> <pre><code>$(document).ready(function(){ window.setTimeout(function(){ $(".one").replaceClass(".two"); },100); }); </code></pre> <p>However, this doesn't seem to operate and I am unsure as to how to fix? Can someone offer me a hand to solve this puzzle I am having.</p> <p>EDIT:</p> <pre><code>&lt;div class="door"&gt; &lt;img src="img/logo-inv.png"&gt; &lt;br&gt; &lt;a href="#" class="btn btn-dark"&gt;ENTER&lt;/a&gt; &lt;/div&gt; </code></pre> <p>I've simplified the code to avoid confusion. The tag I would like to change is "btn-dark".</p>
26,927,013
0
How to set frame for CATransition in iOS <p>Iam new to ios development.I have one doubt related to CATransition.I placed one imageview with one image from top to middle of the screen(0,0,320,250).Iam using animation to animate the image from bottom to top in viewdidload method.But the image is animating from bottom of self.view, But i need to animate the image from height 250 not from 568.</p> <p>The code what iam using is below: </p> <pre><code>CATransition *transition = [CATransition animation]; transition.duration = 1.0f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromTop; [topImage.layer addAnimation:transition forKey:nil]; </code></pre> <p><img src="https://i.stack.imgur.com/BNvcq.png" alt="enter image description here"></p> <p>in the image where we have cyan color iam placing image there.i need to animate the image from starting of black color.</p> <p>If any konw the answer please let me know.</p> <p>Thanks in advance.....</p>
18,665,445
0
PHP inverse function for base_convert? <p>I have to do arithmetic with some ternary (base 3) numbers. I know I can use base_convert to get from a ternary string ("2001022210") to an integer. Is there an existing function to do the inverse?</p> <p>I want "some_function" such that:</p> <pre><code>$someInteger = base_convert("2001022210", 10, 3); some_function($someInteger); </code></pre> <p>answers "2001022210". I'm happy to provide extra arguments ...</p> <pre><code>some_function($someInteger, 3); some_function($someInteger, 3, 10); </code></pre> <p>I know I can code this myself, but I'm hoping it's already there.</p>
39,332,949
0
<p>I am not really sure what you mean by integrating bootstrap with Meanjs, according to me it is already integrated in the default app. If you go to <code>config/assets/default.js</code> and <code>config/assets/production.js</code> (one is for development and the other for production) under <code>client.lib.css</code> and <code>client.lib.js</code> the bootstrap modules are specified. These modules are loaded in <code>modules/core/server/views/layout.server.view.html</code> just under the comments <code>&lt;!-- Application CSS Files --&gt;</code> and <code>&lt;!--Application JavaScript Files--&gt;</code> when the application starts.</p> <p>If you want to upgrade to the latest Bootstrap just change the version number in your <code>bower.json</code> file and run the command <code>bower update</code>. </p>
12,253,702
0
<p>You can add needful system qml-files to your project and edit it. For your example, change code from PageStack.qml:</p> <pre><code>// Start state for pop entry, end state for push exit. State { name: "left" PropertyChanges { target: container; x: -width } }, // Start state for push entry, end state for pop exit. State { name: "right" PropertyChanges { target: container; x: width } }, </code></pre> <p>to</p> <pre><code>// Start state for pop entry, end state for push exit. State { name: "left" PropertyChanges { target: container; x: width } }, // Start state for push entry, end state for pop exit. State { name: "right" PropertyChanges { target: container; x: -width } }, </code></pre> <p>And I also want to know how to do it easier.</p>
14,589,676
0
<p>One traditional "Microsoft" answer to this is to let them keep using Access... only point it at the SQL server and just let them build their custom queries there.</p> <p>If you want to get fancy, you can build in a query user role and account, grant only read access to it, and even limit that baked-in role user account to some percentage of the total system load with the Resource Governor stuff if necessary.</p> <p>There is no shame in prototyping new stuff in Access before rolling it up into real code, either.</p>
11,101,158
0
How to work with initialize.php? <p>I want to learn and work with <strong>initialize.php</strong> so I try to build simple php file like <strong>index.php</strong> and just to see if it call to <strong>hello.php</strong> I got some truble on my local host using windows xp.</p> <p>the details are:</p> <p><strong>http://127.0.0.1/www/oop/shape2/index.php</strong> the file <strong>index.php</strong></p> <pre><code>&lt;?php defined('DS') ? null : define('DS', '/'); defined('SITE_ROOT') ? null :defined('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); echo (LIB_PATH.DS.'hello.php'); require_once(LIB_PATH.DS.'hello.php'); ?&gt; </code></pre> <p><strong>the output is:</strong></p> <pre><code>SITE_ROOT/includes/hello.php </code></pre> <p><strong>http://127.0.0.1/www/oop/shape2/includes/hello.php</strong> the file <strong>hello.php</strong></p> <pre><code>&lt;?php echo ('hi'); ?&gt; </code></pre> <p>if i run it I got <code>hi</code></p> <p>here is my local folder on windows: <strong>C:\Program Files\Zend\Apache2\htdocs\www\oop\shape2</strong></p> <p>what shell I do slove the problem. Thx</p>
37,569,777
0
PHP image generator caching <p>I have a script that takes an image and generates a resized version. </p> <p>i.e. requesting <code>/images/50x50-logo.png</code> will call <code>image-conroller.php</code> which will then return a <code>50x50</code> version of <code>logo.png</code></p> <p>The image is returned using;</p> <pre><code>header('Content-Type: '.mime_content_type($sOutputPath)); readfile($sOutputPath); </code></pre> <p>As far as I'm aware, using this method to return the image, there is no safe way to check if the user already has a cached a version of this image. So how am I supposed to know if to send a <code>304</code> or serve the image?</p> <p>Would someone please mind explaing if it's possible to achieve this. Or provide some direction to a soloution/workaround?</p> <p>N.B. I can't think of a suitable title, any suggestions/edits would be apprecaited.</p>
8,308,572
0
<p>I think that they mean <code>string</code>, <code>number</code>, <code>boolean</code> and <code>undefined</code> because when you assign them to another variable, you copy the value, not a pointer.</p> <pre><code>var a = 'abc'; var b = a; a = 'def'; // b === 'abc' var a = { b: 'abc' }; var b = a; a.b = 'def'; // b.b === 'def' </code></pre>
10,052,748
0
<p>When you create a new App Engine project, all the required libraries are automatically added to the <a href="http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html" rel="nofollow noreferrer">Module Dependencies</a>:</p> <p><img src="https://i.stack.imgur.com/LcjVO.png" alt="libraries"></p> <p>If you need more libraries, you should add them to the <a href="http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html" rel="nofollow noreferrer">Dependencies</a> manually and then <a href="http://www.jetbrains.com/idea/webhelp/configuring-artifacts.html" rel="nofollow noreferrer">configure the Artifact</a> to include the libs:</p> <p><img src="https://i.stack.imgur.com/OTWxR.png" alt="artifact"></p> <p>If you are using API from <code>lib/shared</code> in your code, you need to add these jars to the dependencies as well, but with the <strong>Provided</strong> scope (and don't add it to the Artifact).</p>
29,391,036
0
How to remove unknown white border of asp:image inside panel <p>I have white border of an asp:image control and i want to remove it but can't find where the problem is</p> <p>here is my html and css:</p> <pre><code>&lt;asp:Panel runat="server" CssClass="nav" ID="nav"&gt; &lt;asp:Image runat="server" ID="Logo" CssClass="logo" /&gt; &lt;asp:LinkButton runat="server" ID="lb1" CssClass="navButtons"&gt;Home&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton1" CssClass="navButtons"&gt;Restorant&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton2" CssClass="navButtons"&gt;Rooms&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton3" CssClass="navButtons"&gt;Spa&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton4" CssClass="navButtons"&gt;Contact&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton5" CssClass="navButtons"&gt;Contact&lt;/asp:LinkButton&gt; &lt;asp:LinkButton runat="server" ID="LinkButton6" CssClass="navButtons"&gt;Contact&lt;/asp:LinkButton&gt; &lt;/asp:Panel&gt; </code></pre> <p>the image with ID="Logo" is white bordered and i need to remove this border</p> <p>CSS of image and Nav panel:</p> <pre><code>.logo { width:100%; height:150px; background-image:url(Background/logo.jpg); float:left; background-repeat:no-repeat; -moz-background-size: 100% 100%; -o-background-size: 100% 100%; -webkit-background-size: 100% 100%; background-size: 100% 100%; position:relative; border:none; } .nav { position:absolute; background-color:black; opacity:0.6; filter: alpha(opacity=60); height:550px; width:250px; z-index:3; max-height:550px; max-width:250px; } </code></pre>
32,530,517
0
<p>"Global" means global to the module. Your <code>x</code> is not global; it is local to <code>banana</code>, but not to <code>apple</code>.</p> <p>In Python 3, you can use <code>nonlocal x</code> to make <code>x</code> assignable inside <code>apple</code>. In Python 2 there is no way to assign to <code>x</code> from inside <code>apple</code>. You must use a workaround such as making <code>x</code> a mutable object and mutating it (instead of assigning to it) in <code>apple</code>.</p>
14,784,187
0
Validating input values with an if/else statement in C++ <p>So I've looked around but I'm apparently either not looking in the right place or I'm misunderstanding something.</p> <p>The directions given are that the program can only accept values between 2.0 and 5.0 for vault heights. I get the feeling it has to do with my if condition but I'm not sure how to correct it. </p> <p>When I input the height during debugging, it jumps to my else statement, and doesn't give me a chance to re-enter the new input.</p> <pre><code>//Retrieving name and first vault and date cout &lt;&lt; "Please enter the name of the pole vaulter.\n"; getline(cin, name); cout &lt;&lt; "Please enter the height of the first vault attempt.\n"; cin &gt;&gt; vault1; if(5.0 &gt;= vault1 &gt;= 2.0) { cout &lt;&lt; "What date was this vault accomplished?\n"; getline(cin, date1); } else { cout &lt;&lt; "Only jumps between 2.0 meters and 5.0 meters are valid inputs. Please enter the height of the first vault attempt.\n"; cin &gt;&gt; vault1; cout &lt;&lt; "What date was this vault accomplished?\n"; getline(cin, date1); } </code></pre>
5,475,468
0
<p>There aren't really a great number of ways to do it. In fact, there's the recommended way - via Apache/mod_wsgi - and all the other ways. The recommended way is fully documented <a href="http://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/" rel="nofollow">here</a>.</p> <p>For a low-traffic site, you should have no trouble fitting it in your 512MB VPS along with your PHP sites. </p>
22,543,814
0
<p>You could just use <code>transitionTo()</code>. </p> <p>Alternatively <a href="http://stackoverflow.com/questions/19076834/change-url-without-transition">this answer</a> suggests using </p> <pre><code>Ember.HistoryLocation.replaceState(&lt;string&gt;); </code></pre> <p>or </p> <pre><code>router.replaceWith('index'); </code></pre>
23,121,026
0
Sorting by time.Time in Golang <p>I am trying to sort struct in GOlang by its member which is of type time.Time. the structure is as follows.</p> <pre><code>type reviews_data struct { review_id string date time.Time score int firstname string anonymous bool review_text string title_text string rating float64 upcount int } </code></pre> <p>I have the below functions for sorting </p> <pre><code>type timeSlice []reviews_data // Forward request for length func (p timeSlice) Len() int { return len(p) } // Define compare func (p timeSlice) Less(i, j int) bool { return p[i].date.Before(p[j].date) } // Define swap over an array func (p timeSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } </code></pre> <p>A map is defined as follows</p> <pre><code>var reviews_data_map = make(map[string]reviews_data) </code></pre> <p>After the map gets filled with values,sorting of the map by values is done as below</p> <pre><code>//Sort the map by date date_sorted_reviews := make(timeSlice, 0, len(reviews_data_map)) for _, d := range reviews_data_map { date_sorted_reviews = append(date_sorted_reviews, d) } sort.Sort(date_sorted_reviews) </code></pre> <p>The problem is that the result is not sorted.Can anyone tell me what the problem is. Thanks in advance.</p>
5,106,465
0
<p>If you want the five themes that have the most items in common with a given theme, you might try something like:</p> <pre><code>DECLARE @target_id_theme INT; SET @target_id_theme = 1; -- this is the id_theme you want to find similar themes for SELECT t.id_theme, COUNT(*) as matching_things FROM theme AS t LEFT OUTER JOIN theme_color AS tc ON tc.id_theme = t.id_theme LEFT OUTER JOIN theme_tag AS tt ON tt.id_theme = t.id_theme WHERE tc.id_color IN (SELECT id_color FROM theme_color WHERE id_theme = @target_id_theme) OR tt.id_tag IN (SELECT id_tag FROM theme_tag WHERE id_theme = @target_id_theme) GROUP BY t.id_theme ORDER BY COUNT(*) DESC LIMIT 5 </code></pre> <p>Not tested, buyer beware, but I hope you get the idea. This creates a row for every color or tag that matches a color or tag assigned to the @target_id_theme, orders them by count descending, and gives you the top 5.</p>
21,028,662
0
Calculate variable based on remainder <p>How do I use JavaScript to calculate the <code>x</code> value in this formula?</p> <pre><code>(x * y) % z = 1 </code></pre> <p><code>y</code> and <code>z</code> are known integers.</p> <p>For example, <code>y = 7</code>, <code>z = 20</code>. 3 multiplied by 7 results into 21, that divided by 20 results into remainder of 1. Solution <code>x = 3</code>.</p> <p>(3 * 7) % 20 = 1</p>
5,651,934
0
<p>I had to change the line:</p> <pre><code>return err!=nil &amp;&amp; [res statusCode]!=404; </code></pre> <p>to </p> <pre><code>return err==nil &amp;&amp; [res statusCode]!=404; </code></pre> <p>for the correct Bool return. The error should remain nil.</p>
27,589,943
0
docker and elastic beanstalk container stopped unexpectedly and permission denied <p>I am trying to extend <a href="https://github.com/Ir1sh/dockeractivator" rel="nofollow">this docker image</a> which is provisioned with ansible and build successfully on <a href="https://registry.hub.docker.com/u/ir1sh/dockeractivator/" rel="nofollow">docker hub</a> at least, part of this image includes a user called play which owns a directory called /home/play/Code that has 755 permissions. I am using boot2docker on mac</p> <p>This is my docker file locally</p> <pre><code>FROM ir1sh/dockeractivator MAINTAINER Mark Moore EXPOSE 9000 </code></pre> <p>which builds ok and when I run</p> <pre><code>docker run --rm -it -v "/my/local/dir:/home/play/Code" -p 9000:9000 300b01a6199c </code></pre> <p>the container starts correctly and I get a session with user root starting in /home/play/Code. If I add -u play to that commade I get a session with the play user instead in the same directory.</p> <p>Now if I push that container to elastic beanstalk with their cli tool I get the following error</p> <blockquote> <p>Output: [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/04run.sh] command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh b07ae15d619ad90441f6f410a31a7d51885151c92cd8675c5d8e47f63b43dd95 Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Sun Dec 21 13:36:06 UTC 2014:. Check snapshot logs for details..</p> </blockquote> <p>The logs aren't very enlightening</p> <p>Now per another suggestion I dont have a CMD or an ENTRYPOINT in my docker file so I add those.</p> <pre><code>FROM ir1sh/dockeractivator MAINTAINER Mark Moore EXPOSE 9000 ENTRYPOINT ["/home/play/Code", "-DFOREGROUND"] CMD [] </code></pre> <p>The image builds but now when I try docker run with the same options as above I get </p> <blockquote> <p>exec: "/home/play/Code": permission denied2014/12/21 13:34:33 Error response from daemon: Cannot start container 2703462a68a32e8d774e9b4d8cbc3c809e79f53bb1d08f0398b45436d07546a3: exec: "/home/play/Code": permission denied</p> </blockquote> <p>This happens whether I try to start the session as root or as play. I get the same error if I push this dockerfile to elastic beanstalk so its not related to boot2docker Any idea what my permission problem is here? I have tried changing that directories permission to 777 to no avail</p> <p>edit1: running as privileged also does not help</p> <p>edit2: changing the dockerfile to </p> <pre><code>FROM ir1sh/dockeractivator MAINTAINER Mark Moore EXPOSE 9000 CMD ["bash"] </code></pre> <p>Allows me to run the container locally but afterpushing to elastic beanstalk I get the container quit unexpectedly error again</p>
4,938,961
0
<ul> <li><p><strong>ODBC</strong> is the very old, long gone DB-access standard - don't use it unless you absolutely must. (it was "hip" back in the 1990's or so)</p></li> <li><p><strong>SqlClient</strong> is the .NET bare-bones ADO.NET level of accessing SQL Server databases, and the foundation for all other technologies. It can basically do anything with SQL Server that you need to do - run data queries, run DDL queries, execute stored procedures and so forth. It's fairly basic and bare-bones, e.g. you have to type a lot of repeating, boring code yourself</p></li> <li><p><strong>EnterpriseLibrary.Data</strong> is a layer on top of ADO.NET which simplifies common tasks by handling some of the repetitive code for you.</p></li> </ul> <p>There are additional things on top of the ADO.NET foundation - things like NHibernate, Entity Framework and so forth - but the <strong>SqlClient</strong> / ADO.NET is really the basis for all current, modern database access (to SQL Server, mostly) in the .NET world</p>
7,626,779
0
<pre><code>netstat -a -o </code></pre> <p>prints it. I suppose they are on the same machine becase you are listening on 127.0.0.1.</p>
25,589,120
0
Harder investigation of a really strange unexpected result <p>I posted before about that problem.. but the problem couldn't be solved. So i can honestly say that is the weirdest, unexplained complication i ever had in my programming experience.</p> <p>The problem is when i draw a bmp from buffer. <img src="https://i.stack.imgur.com/f3134.png" alt="enter image description here"></p> <p>If i change the image's dimension for example if i make width > height or height > width, the images goes rendered normally. Take a look at the code:</p> <pre><code>void bmp_bdraw (BYTE* BUFF) { word WIDTH, HEIGHT, W, H; // word - unsigned short BYTE R, G, B; // BYTE - unsigned char (!BUFF || !BUFF[COUNT-1]) ? // debug1 (error("Error in function 'bmp_bdraw'. There is no data to read from.")) : ; WIDTH = BUFF[18] + BUFF[19] * 256; HEIGHT = BUFF[22] + BUFF[23] * 256; ofs = 54; if(BUFF[0] != 'B' | BUFF[1] != 'M') error // debug2 ("Warning: Data identifier error in function 'bmp_bdraw' occurred. Invalid BMP file loaded."); for(H=HEIGHT-1; H&gt;=1; H--) { for(W=0; W&lt;WIDTH; W++) { B = sgetc(BUFF); // fgetc-like function but from buff G = sgetc(BUFF); R = sgetc(BUFF); setpen(R, G, B, 0, 1); // sets the color, transparancy and size of the pen putpixel(W, H); // and puts the pixel at the right location } } if(W != WIDTH || H &gt; 1) // debug3 error("Error in function 'bmp_bdraw'. Rendering failed. The file might be damaged."); if(real_fps &lt; 11) error("Too low fps rate."); // debug4 </code></pre> <p>What i have noticed in the line: <code>for(H=HEIGHT-1; H&gt;=1; H--)</code> is the <code>H&gt;=1</code> In the direct draw (bmp to render) function (that works 100% and uses the same method) it is <code>H&gt;=0</code> However.. if i change the <code>H&gt;=1</code> to <code>H&gt;=0</code> it returns an error for buffer overflow, returned by the <code>sgetc</code> function.</p>
34,596,800
0
<p><code>ActionLink</code> helper method renders an anchor tag. It is ok to pass few query string items via a link. Remember Query string <a href="http://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string">has a limit</a> about how much data you can pass and it varies from browser to browser.</p> <p>What you should be doing is a form posting. You can do a form posting on a click event on a div with the help of a little javascript.</p> <p>Let's create a new view model for our search page</p> <pre><code>public class SearchVm { public List&lt;SelectListItem&gt; Operators { set; get; } public List&lt;SearchViewModel&gt; Filters { set; get; } } public class SearchViewModel { //Property has a property called "SqlColumnName" public Property Property { get; set; } public SearchOperator Operator { get; set; } public string Value { get; set; } } </code></pre> <p>So in your GET action, You will send a list of <code>SearchViewModel</code> to the view.</p> <pre><code>public ActionResult Index() { var search = new SearchVm { Filters = new List&lt;SearchViewModel&gt; { new SearchViewModel {Property = new Property {SqlColumn = "Name"}}, new SearchViewModel {Property = new Property {SqlColumn = "Age"}}, new SearchViewModel {Property = new Property {SqlColumn = "Location"}} } }; //Convert the Enums to a List of SelectListItem search.Operators= Enum.GetValues(typeof(SearchOperator)).Cast&lt;SearchOperator&gt;() .Select(v =&gt; new SelectListItem { Text = v.ToString(), Value = ((int)v).ToString() }).ToList(); return View(search); } </code></pre> <p>And in your view, which is strongly typed to your <code>SearchVm</code> view model, We will manipulate the form field names so that the model binding will work when the form is submitted.</p> <pre><code>@model SearchVm @using (Html.BeginForm()) { var i = 0; foreach (var criteria in Model.Filters) { &lt;label&gt;@criteria.Property.SqlColumn&lt;/label&gt; @Html.HiddenFor(f =&gt; f.Filters[i].Property.SqlColumn) @Html.DropDownList("Filters[" + i+ "].Operator",Model.Operators) @Html.TextBoxFor(f=&gt;f.Filters[i].Value) i++; } &lt;div id="someDiv"&gt;Search button using Div&lt;/div&gt; &lt;input type="submit" value="Search" /&gt; } </code></pre> <p>And your HttpPost action method to handle the form submit.</p> <pre><code>[HttpPost] public ActionResult Index(SearchVm model) { foreach(var f in model.Filters) { //check f.Property.SqlColumn, f.Value &amp; f.Operator } // to do :Return something useful } </code></pre> <p>If you want the form to be submitted on the click event on the div, Listen to the click event on the specific div and call the submit method on the form the div resides in.</p> <pre><code>&lt;script&gt; $(function () { $("#someDiv").click(function(e) { $(this).closest("form").submit(); }); }); &lt;/script&gt; </code></pre>
4,895,049
0
<p>I'm assuming the solution you're mentioning in the comment is something like this:</p> <p>Start at the left or right (so index = 0), and scan which bits are set (upto 100 operations). Name that set x. Also set a variable block=0.</p> <p>At index=1, repeat and store to set y. If x XOR y = 0, both are identical sets, so move on to index=2. If it x XOR y = z != 0, then range [block, index) is contiguous. Now set x = y, block = index, and continue.</p> <p>If you have 100 bit-arrays of length 22 each, this takes something on the order of 2200 operations.</p> <p>This is an optimum solution because the operation cannot be reduced further -- at each stage, your range is broken if another set doesn't match your set, so to check if the range is broken you must check all 100 bits.</p>
40,844,610
0
Represent Runner competitors using Java multithreading <p>I need to represent 10 runner who run on a 100 meter track , and display the winner ( who finishes the track first ) and the time he took to finish the track . I am beginner so I got multiple error in order to achieve this.</p>
4,581,263
0
<p>I'm pretty sure if the app developer didn't build in such an api for you to hook into you are out of luck </p>
26,288,956
0
Regx + Java : split a text into words and removing punctuation only if they are alone or at the end <p>I am trying to split a string into words but I want to keep, "a.b.c" as a word, and remove the punctuation only if it is alone or at the end of a word e.g. </p> <pre><code>"a.b.c" --&gt; "a.b.c" "a.b." --&gt; "a.b" </code></pre> <p>e.g </p> <pre><code>String str1 = "abc a.b a. . b, , test"; should return "abc","a.b","a","b","test" </code></pre>
36,171,857
0
$LinkingMode Values in Silverstripe <p>Why use $LinkingMode in Silverstripe? How can the $LinkingMode of Silverstripe have only one value at a time when it can be a section and current at the same time or link and section as well?</p>
28,642,091
0
<p>You can record a macro as you do it manually one time. Then assign that macro to a button. Then click the button anytime you need the sheet updated.</p> <p>Steps:</p> <ol> <li><p>Start on a sheet other than the one with the data. Explanation in #3 below.</p></li> <li><p>Start recording your macro by going to View > Macros > Record Macro. In the bottom left you'll now see a square stop button for when you want to stop recording.</p></li> <li><p>Select the sheet with the data. This way the macro will always remember to select the right sheet regardless of where you are.</p></li> <li><p>Select the two-column range of cells that has your data, then continue selecting a few hundred rows down, or at least well beyond where you think your data will eventually go down to.</p></li> <li><p>Copy</p></li> <li><p>Select the sheet where you want to have the summarized data.</p></li> <li><p>Paste</p></li> <li><p>Sort by name (ascending) and date (descending) all at once (rather than two operations). Do this by going to the Data tab in the ribbon and selecting the white and blue sort button that has two A's and two Z's and says "Sort".</p></li> <li><p>With this pasted and sorted range still selected, remove duplicates in the name column. To do this, do not change the selection. Go to the Data tab and select Remove Duplicates.</p></li> <li><p>Now your items will appear once and the date will be the most recent date.</p></li> <li><p>Click the "stop recording" square blue button in the bottom left to stop recording your Macro.</p></li> <li><p>You can assign this macro to a button or to a shortcut. To add a button you need to show the developer tab and then draw the button using one of the options on the developer tab. I can't remember offhand how to show the developer tab. Once you have a button, right click and assign the macro to the button.</p></li> </ol> <p>13A. If you want to customize the macro, click ALT+F11 to get to the visual basic editor. Double click on one of the things named something like "module" on the left and you can edit your the range in your macro, for example if your data suddenly goes down 100 more rows than what you planned and you want the macro to cover it. Save with CTRL+S. The next time you run your macro, it will reflect these changes.</p> <p>13B. View > Macros to edit your macro if you want to assign a shortcut key to it instead of adding a button.</p> <p>Try all this with a copy of your spreadsheet so that you don't delete data by accident.</p> <p>Does it work for you?</p>
26,311,271
0
Best way to define module for both node and client <p>I'm trying to write a small module that I want to be available both on the Browser and Node.js environment.</p> <p>So far I've come up with the following</p> <pre><code>(exports &amp;&amp; window = exports) (function(global){ // make it available to either exports OR window depending on the environment global.Awesome = function() { } })(window) </code></pre> <p>is that sufficient or is there any better way to do this? Thanks in advance.</p>
11,928,385
0
<p><a href="http://en.wikipedia.org/wiki/Signature_block#E-mail_and_Usenet" rel="nofollow">http://en.wikipedia.org/wiki/Signature_block#E-mail_and_Usenet</a> gives an overview about email signatures. As guys already mentioned, signature is just a part of the email body. The only restrictions are: "<em>it should be delimited from the body of the message by a single line consisting of exactly two hyphens, followed by a space, followed by the end of line (i.e., "-- \n")</em>".</p>
30,140,474
0
Brute force Caesar Cipher <p>How do I make my program print the answers on separate lines + with what key the line corresponds to?</p> <pre><code>def break_crypt(message): for key in range(1,27): for character in message: if character in string.uppercase: old_ascii=ord(character) new_ascii=(old_ascii-key-65)%26+65 new_char=chr(new_ascii) sys.stdout.write(new_char), elif character in string.lowercase: old_ascii=ord(character) new_ascii=(old_ascii-key-97)%26+97 new_char=chr(new_ascii) sys.stdout.write(new_char), else: sys.stdout.write(character), </code></pre>
8,727,334
0
<p>A few issues you can run into if you just kill the sqlldr process:</p> <ul> <li>If the number of commit rows is small you may have data already-commited which will now have to be removed. This may not matter if you are truncating the tables before use but the cleanup is an operational issue that is dependent upon your system.</li> <li>If the number of commit rows and the size of your file is large then you may get issues with the rollback segments being too small or the rollback itself taking a long time to complete (shouldn't an issue if you are using direct path).</li> </ul> <p>You can kill using <code>kill -9</code> as mentioned, or you can kill the session from within the database:</p> <pre><code>alter system kill session 'sid,serial#'; </code></pre> <p>If you are using Windows then you can use the <a href="http://www.oracleutilities.com/OSUtil/orakill.html" rel="nofollow">orakill</a> utility.</p>
28,060,089
0
rails protect_from_forgery raises with exception <p>I have Rails project which is working on production. But on localhost it raises on every POST request with <code>ActionController::InvalidAuthenticityToken</code>. I know what is it. AuthToken is protection from csrf attacks. I have in my <em>application_controller.rb</em></p> <p><code>protect_from_forgery with: :exception #this line raise exception</code></p> <p>and <code>csrf_meta_tags</code> present. I have no any problems in other Rails projects with it.</p> <p>If I remove param <code>with: :exception</code> session will reset after reloading page.</p> <p>what is the problem?</p>
23,708,509
0
<p>It doesn't make sense to read the input until EOS and then expect to be able to write a response back to the same connection.</p> <p>You haven't actually written anything like an 'simple HTTP server yet. You need to study the HTTP RFC, in particular the part about content-length of requests. They are delimited by length, not by end of stream.</p>
7,859,487
0
Plot frequency of a value of 2 factors in the same plot in R <p>I'd like to plot the frequency of a variable color coded for 2 factor levels for example blue bars should be the hist of level A and green the hist of level B both n the same graph? Is this possible with the hist command? The help of hist does not allow for a factor. Is there another way around?</p> <p>I managed to do this by barplots manually but i want to ask if there is a more automatic method</p> <p><img src="https://i.stack.imgur.com/ZZkfj.png" alt="enter image description here"></p> <p>Many thanks EC</p> <p>PS. I dont need density plots</p>
22,816,450
0
Basic controllers comunication in angular.js <p>I have a project in Angular.js that consist of a login page and another page. I have a common navigation bar that resides in the "Layout", before then ng-view div. This navbar relies on a controller (let's say NavBarController), and based on the authenticated user, it shows some buttons or not. The problem is that when The user Log's in, the next page is loaded on then ng-view, but the NavVar controller do not know about this, so it does not refresh it's $scope, therefore the proper buttons wont show up.</p> <p>I guess my question is: How can I trigger a "Refresh" action on a controller based on another controller's function. ? is that event possible ? or do I have to repeat the nav bar inside every controller's html ?</p> <p>Here's my main html: </p> <pre><code>&lt;div ng-app='theApp'&gt; &lt;div data-ng-controller="NavBarController"&gt; &lt;nav class="navbar navbar-default" role="navigation"&gt; &lt;div class="container-fluid"&gt; &lt;div class="navbar-header"&gt; &lt;a class="navbar-brand"&gt;The App&lt;/a&gt; &lt;/div&gt; &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li class="active" ng-show="user.role == 'admin'"&gt;&lt;a href="#"&gt;Link visible only by admin&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link visible by all&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="nav navbar-nav navbar-right"&gt; &lt;li class="dropdown"&gt; &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;{{ user.name }} &lt;b class="caret"&gt;&lt;/b&gt;&lt;/a&gt; &lt;ul class="dropdown-menu"&gt; &lt;li&gt;&lt;a href="#"&gt;Action&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Another action&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Something else here&lt;/a&gt;&lt;/li&gt; &lt;li class="divider"&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" ng-click="LogOut()"&gt;Log out&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/nav&gt; &lt;/div&gt; &lt;div ng-view&gt;&lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js" /&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js" /&gt; &lt;script src="app/app.js"&gt;&lt;/script&gt; &lt;!-- controllers --&gt; &lt;script src="app/controllers/membershipController.js"&gt;&lt;/script&gt; &lt;script src="app/controllers/navBarController.js"&gt;&lt;/script&gt; &lt;!-- factories --&gt; &lt;script src="app/factories/membershipFactory.js"&gt;&lt;/script&gt; &lt;!-- services --&gt; &lt;script src="app/services/userService.js"&gt;&lt;/script&gt; &lt;/div&gt; </code></pre> <p>Now, the NavBarController is something like: </p> <pre><code>(function () { var NavBarController = function ($scope, UserService) { function init() { $scope.user = UserService.getUser(); /* functions */ $scope.LogOut = function () { UserService.clearUser(); }; } init(); } NavBarController.$injenct = ['$scope', 'UserService']; angular.module("theApp").controller('NavBarController', NavBarController); }()); </code></pre> <p>The initialization of angular is like: </p> <pre><code>(function() { var theApp = angular.module("theApp", ['ngRoute', 'ngCookies', 'ui.bootstrap']); angular.module("theApp").config(function($routeProvider){ $routeProvider .when('/', { controller: 'MembershipController', templateUrl: 'app/views/login.html' }) .when('/index', { templateUrl: 'app/views/index.html' }) .otherwise ( { redirectTo: '/' } ); }); }()); </code></pre> <p>login.html is just a typical login password page, that triggers the MembershipController Authenticate() function. It redirects to '/index' on successfull authentication and set's the User in the UserService. Now. the index.html page successfully renders at ng-view, but my navbar stays the same (initial state, no show the 'link visible by admin' link, nor the dropdown on the right.</p>
23,941,676
0
<p>My solution has two steps:</p> <ol> <li>Collect the relevant elements from the original array, and sort them according to the subset order.</li> <li>Replace them in the original array with the new order.</li> </ol> <p>Here is the code:</p> <pre><code>mapped_elements = subset.map { |i| original.find { |j| j.keys == i.keys } } result = original.map do |i| if subset.find { |j| j.keys == i.keys } mapped_elements.shift else i end end </code></pre> <p>For <code>subset = [{c: "Gill", points: 2}, {b: "Will", points: 1}]</code> the result will be:</p> <pre><code>[{a: "Bill", points: 4}, {c: "Gill", points: 2}, {b: "Will", points: 3}, {d: "{Pill}", points: 1}] </code></pre> <p>For <code>subset = [{c: "Gill", points: 3}, {b: "Will", points: 2}, {a: "Bill", points: 1}]</code> the result will be:</p> <pre><code>[{c: "Gill", points: 3}, {b: "Will", points: 2}, {a: "Bill", points: 4}, {d: "Pill", points: 1}] </code></pre>
33,914,446
0
<p>Try this class... its working for me...I am using <strong>Android ksoap2</strong> library...</p> <pre><code>private static final String NAMESPACE = "urn:Magento"; private static final String URL = "http://localhost:8888/Magento/index.php/api/v2_soap/"; private class magentoUserlogin extends AsyncTask&lt;String, String, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... params) { Object result= null; try { SoapSerializationEnvelope env = new SoapSerializationEnvelope( SoapEnvelope.VER11); env.dotNet = false; env.xsd = SoapSerializationEnvelope.XSD; env.enc = SoapSerializationEnvelope.ENC; SoapObject request = new SoapObject(NAMESPACE, "login"); request.addProperty("username", "&lt;urSOAP/XML username&gt;"); request.addProperty("apiKey", "&lt;yourAPIKey&gt;"); env.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call("", env); result = env.getResponse(); } catch (Exception e) { e.printStackTrace(); } return result.toString(); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); Log.d("sessionId", s.toString()); Toast.makeText(MainActivity.this, "Session ID: "+s, Toast.LENGTH_LONG).show(); } } </code></pre>
4,527,286
0
How to Implement a ListBox of Checkboxes in WPF? <p>Although somewhat experienced with writing Winforms applications, the... "vagueness" of WPF still eludes me in terms of best practices and design patterns.</p> <p>Despite populating my list at runtime, my listbox appears empty.</p> <p>I have followed the simple instructions from <a href="http://merill.net/2009/10/wpf-checked-listbox/">this helpful article</a> to no avail. I suspect that I'm missing some sort of <code>DataBind()</code> method where I tell the listbox that I'm done modifying the underlying list.</p> <p>In my MainWindow.xaml, I have:</p> <pre><code> &lt;ListBox ItemsSource="{Binding TopicList}" Height="177" HorizontalAlignment="Left" Margin="15,173,0,0" Name="listTopics" VerticalAlignment="Top" Width="236" Background="#0B000000"&gt; &lt;ListBox.ItemTemplate&gt; &lt;HierarchicalDataTemplate&gt; &lt;CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}"/&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>In my code-behind, I have:</p> <pre><code> private void InitializeTopicList( MyDataContext context ) { List&lt;Topic&gt; topicList = ( from topic in context.Topics select topic ).ToList(); foreach ( Topic topic in topicList ) { CheckedListItem item = new CheckedListItem(); item.Name = topic.DisplayName; item.ID = topic.ID; TopicList.Add( item ); } } </code></pre> <p>Which, by tracing through, I know is being populated with four items.</p> <p><b>EDIT</b></p> <p>I have changed <code>TopicList</code> to an <code>ObservableCollection</code>. It still doesn't work.</p> <pre><code> public ObservableCollection&lt;CheckedListItem&gt; TopicList; </code></pre> <p><b>EDIT #2</b></p> <p>I have made two changes that help:</p> <p>In the .xaml file:</p> <pre><code>ListBox ItemsSource="{Binding}" </code></pre> <p>In the source code after I populate the list:</p> <pre><code>listTopics.DataContext = TopicList; </code></pre> <p>I'm getting a list, but it's not automagically updating the checkbox states when I refresh those. I suspect a little further reading on my part will resolve this.</p>
22,484,620
0
Autos window doesn't show return value when expected <p>Given the following lines of code:</p> <pre><code>using System; struct MyIntPtr { private unsafe void* m_value; } class Program { static IntPtr GetIntPtr() { return new IntPtr(); } static MyIntPtr GetMyIntPtr() { return new MyIntPtr(); } static void Main() { var ptr1 = GetIntPtr(); var ptr2 = GetMyIntPtr(); } } </code></pre> <p>I expected both method calls in Program.Main to show return values in the Autos window. For some reason that I can't quite understand, only the first line behaves that way:</p> <p>(+ Program.GetIntPtr returned 0 System.IntPtr).</p> <p>My understanding, according to <a href="http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx" rel="nofollow">http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx</a>, is that function return values that return value types the size of pointers should indeed show the return values when called in the Autos window. What am I doing wrong?</p>
17,697,166
0
By default which techniques is used by JAVA to handle hashcode collision <p>By default which techniques is used by JAVA to handle hashcode collision ? Is it separate chaining or does it depend on the JVM implementation for different platform?</p>
11,369,249
0
<p>You cannot directly tell it to call the <code>super</code> method. <code>target</code> is only a pointer to an object, <code>super</code> does not have a separate pointer address from your <code>self</code> instance. </p> <p>Also by assigning the <code>target</code> to <code>self.superclass</code> you are telling the <code>target</code> to be the class. Therefore your trying call a class method rather than an instance method which is not what you want to do. </p> <p>The only way to do this would be to assign target to <code>self</code> and have a separate method such as:</p> <pre><code>- (void)callSuperMethod { [super playNarrationForPage:[NSNumber numberWithInt:1]]; } </code></pre>
37,905,075
0
<p>What is it that requires the environment variable be set? </p> <p>I would try to use a different approach if possible. If you are expecting to act on the environment variable in ansible, you could instead set the value in an inventory group_vars file which would only be in effect for local provisioning vagrant. Other environments could use different values for the same variable by updating the appropriate inventory group_vars file.</p>
16,467,227
0
<p>I think this is what you want to do... </p> <pre><code>use warnings; use strict; use File::Copy; my $target_file = "testfile"; my $tmp_file = "$target_file.new"; my $str = "some string with stuff"; open my $fh, "&lt;", "testfile"; open my $w_fh, "&gt;&gt;", "testfile.new"; # loop over your current file, one line at a time while( my $line = &lt;$fh&gt; ){ # remove the '\n' so we can add to the existing line chomp $line; # add what you'd like, plus the '\n' my $full_line = "$line $str\n"; # and print this to a tmp file print $w_fh $full_line; } close $fh; close $w_fh; unlink $target_file or die "unable to delete $target_file: $!"; # use the File::Copy sub 'move' # to rename the tmp file to the original name move($tmp_file, $target_file); </code></pre> <p>Running the code:</p> <pre><code>$ cat testfile this is three this is three this is three $ test.pl $ cat testfile this is three some string with stuff this is three some string with stuff this is three some string with stuff </code></pre>
18,576,168
0
<p>you need to initialize <code>pNext</code> properly by setting it to <code>nullptr</code> explicitly in <code>node</code>'s constructor. <code>0xCDCDCDCD</code> is always in indicator for accessing uninitialized memory.</p>
24,080,158
1
running a background process in pythonanythere <p>I just want to know that if the following is possible:</p> <p>I want to run a local socket program in background in the pythonanywhere and want to access the socket from django app registered in same pythonanywhere domain. </p> <p>Actually I want to run a machine learning algorithm as a socket program which i want to access by the web client. I want to run a single process for any number of client because I dont think its wise to train the algorithm every time a new client gets connected. Can I do that.</p> <p>for being more clear:</p> <p>I want the trained machine learning program to be launched only once in the server and the web portal should receive the inputs parameters from clients and send back the prediction after interacting with the program . All the client has to be served by this single instance of machine learning program so that the main program has to be trained only once.</p> <p>Please suggest any other way to perform this if any.. Thanks in advance..</p>
2,753,572
0
<p>If I don't need a copy of the original value, I don't declare a new variable. </p> <p>IMO I don't think mutating the parameter values is a bad practice in general,<br> it depends on how you're going to use it in your code.</p>
39,340,612
0
Android: Can't set an image once a button is clicked (NullpointerException/IllegalStateException) <p>I'm getting an IllegalStateException and a NullPointerException once the imageview is clicked (App crashes). It is supposed to pass the imageview's image to another imageview. I am also using a fragment for my tabbed activity.</p> <p>onCreate() and variables</p> <pre><code>private SectionsPagerAdapter mSectionsPagerAdapter; private ViewPager mViewPager; PhotoViewAttacher xAttach; ImageView tessst; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_whole_details); tessst = (ImageView) findViewById(R.id.fillZoom); what = (ImageView) findViewById(R.id.img1); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); } </code></pre> <p>the Imageview click class</p> <pre><code> public void clickZoom(View v){ if(v.getId() == R.id.img1){ Drawable bb = getResources().getDrawable(R.drawable.maincolor_btn); tessst.setImageDrawable(bb); xAttach = new PhotoViewAttacher(tessst); } } </code></pre> <p>the logcat</p> <pre><code>09-06 13:12:45.436 31388-31388/com.example.testapp.coloranalysis E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.testapp.coloranalysis, PID: 31388 java.lang.IllegalStateException: Could not execute method for android:onClick at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293) at android.view.View.performClick(View.java:4463) at android.view.View$PerformClick.run(View.java:18770) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5323) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) at android.view.View.performClick(View.java:4463) at android.view.View$PerformClick.run(View.java:18770) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5323) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.example.testapp.coloranalysis.WholeDetails.clickZoom(WholeDetails.java:59) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) at android.view.View.performClick(View.java:4463) at android.view.View$PerformClick.run(View.java:18770) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5323) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) at dalvik.system.NativeStart.main(Native Method) </code></pre>
38,792,846
0
Akka Http Client Set Cookie on a HttpRequest <p>I am trying to make a GET request to a REST web service using Akka Http Client.</p> <p>I am not able to figure out how do I set a cookie on the request before I make the GET.</p> <p>I searched the web and I found ways to read the cookie on the server side. but I could not find anything which showed me how to set the cookie on the client side request.</p> <p>Based on my own research I tried the following approach to set a cookie on http request</p> <pre><code>import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.model._ import akka.http.scaladsl.unmarshalling.Unmarshal import akka.stream.scaladsl.{Sink, Source} import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import akka.http.scaladsl.model.headers.HttpCookie import akka.stream.ActorMaterializer import spray.json._ import scala.util.{Failure, Success} case class Post(postId: Int, id: Int, name: String, email: String, body: String) trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol { implicit val postFormat = jsonFormat5(Post.apply) } object AkkaHttpClient extends JsonSupport{ def main(args: Array[String]) : Unit = { val cookie = headers.`Set-Cookie`(HttpCookie(name="foo", value="bar")) implicit val system = ActorSystem("my-Actor") implicit val actorMaterializer = ActorMaterializer() implicit val executionContext = system.dispatcher val mycookie = HttpCookie(name="foo", value="bar") val httpClient = Http().outgoingConnection(host = "jsonplaceholder.typicode.com") val request = HttpRequest(uri = Uri("/comments"), headers = List(cookie)) val flow = Source.single(request) .via(httpClient) .mapAsync(1)(r =&gt; Unmarshal(r.entity).to[List[Post]]) .runWith(Sink.head) flow.andThen { case Success(list) =&gt; println(s"request succeded ${list.size}") case Failure(_) =&gt; println("request failed") }.andThen { case _ =&gt; system.terminate() } } } </code></pre> <p>But this gives an error</p> <pre><code>[WARN] [08/05/2016 10:50:11.134] [my-Actor-akka.actor.default-dispatcher-3] [akka.actor.ActorSystemImpl(my-Actor)] HTTP header 'Set-Cookie: foo=bar' is not allowed in requests </code></pre>
19,108,670
0
fetching data from indexed database in HTML 5 and binding to gridview <p>I am fetching data from the indexed database in HTML 5, I am able to successfully get the values but I want it to bind it to some data-grid view of ASP.NET<br> The code which I am using to get the values from the indexed database is </p> <pre><code>if(currentDatabase) { var objectStore = currentDatabase.transaction([objStore]).objectStore(objStore); var traveller = []; objectStore.openCursor().onsuccess = function(event) { var cursor = event.target.result; if(cursor) { var v = cursor.value; traveller.push("id ="+v.id); traveller.push("Name ="+v.traveler); traveller.push("Destination ="+v.destination); traveller.push("Transportation ="+v.transportation); cursor.continue(); } </code></pre> <p>this allows me to store the data in the array, how can I bind it to datagrid view, </p>
13,077,338
0
<p>probably better off using one of the TEXT datatypes. </p> <pre><code>TINYTEXT 256 bytes TEXT 65,535 bytes ~64kb MEDIUMTEXT 16,777,215 bytes ~16MB LONGTEXT 4,294,967,295 bytes ~4GB </code></pre> <p>It also depends on your version of MySQL. </p> <p>see: <a href="http://stackoverflow.com/questions/1303476/is-a-varchar20000-valid-in-mysql">Is a VARCHAR(20000) valid in MySQL?</a></p>
3,259,625
0
Struct initialisation through macro overuse <p>I've got some structs to initialise, which would be tedious to do manually. I'd like to create a macro that will help me with it... but I'm not sure the <strong>C</strong> preprocessor is good enough for this.</p> <p>I've got structs which represent menus. They consist of function pointers only:</p> <pre><code>typedef uint8_t (*button_handler) (uint8_t); typedef void (*pedal_handler) (void); typedef void (*display_handler) (void); typedef void (*menu_switch_handler) (void); #define ON_BUTTON(x) uint8_t menu_frame_##x##_button (uint8_t button) #define ON_PEDAL(x) void menu_frame_##x##_pedal (void) #define ON_DISPLAY(x) void menu_frame_##x##_display (void) #define ON_SWITCH(x) void menu_frame_##x##_switch (void) typedef struct menu_frame { button_handler on_button; pedal_handler on_pedal; display_handler on_display; menu_switch_handler on_switch; } menu_frame; </code></pre> <p>That allows me to write the functions and separate functions as (.c file):</p> <pre><code>ON_BUTTON(blah) { ... } </code></pre> <p>and menus as (.h file):</p> <pre><code>ON_BUTTON(blah); ON_DISPLAY(blah); menu_frame menu_frame_blah = { menu_frame_blah_button, NULL, menu_frame_blah_display, NULL }; </code></pre> <p>Is there any way I can fold the menu definition into one define? I could do something that expands <code>MENU(blah, menu_frame_blah_button, NULL, menu_frame_blah_display, NULL)</code> of course, but is there any way to:</p> <ul> <li>make it shorter (NULL or some name)</li> <li>remove the need of <code>ON_BUTTON(...);</code> from before the struct</li> </ul> <p>Ideally, I'd like <code>MENU(blah, button, NULL, display, NULL)</code> to both define the handlers and the menu struct itself. I don't know for example how to prevent expanding the last term into <code>ON_SWITCH(NULL)</code>.</p> <p>Or maybe I should approach it from some other way?</p>
21,218,932
0
<p>"Auto-increment" is always a problem when working with a distributed system, as it creates a bottle-neck: Each new increment needs to read the previous data .. like some other parallel requests.</p> <p>Generally speaking, "auto-increment" restricts parallelism, specially on distributed systems.</p>
14,306,822
0
How to get uwsgi container to restart with AWS EC2 reboot <p>I have nginx and uwsgi installed on my CentOS EC2 instance.</p> <p>Nginx restarts successfully when I do a reboot of the machine from the AWS control panel.</p> <p>Uwsgi does not. </p> <p>I have to log in and restart it with 'sudo /etc/init.d/uwsgi start' and then everything is fine. And then of course I can log out as it is running as a service.</p> <p>Having to log-in in order to finish the reboot process is clearly suboptimal.</p> <p>But I think I have the config done properly.</p> <p>When I do chkconfig I see:</p> <pre><code>uwsgi 0:off 1:off 2:on 3:on 4:on 5:on 6:off </code></pre> <p>If I look in the file in /etc/init.d/uwsgi the top of the file reads:</p> <pre><code>#!/bin/bash # uwsgi - Use uwsgi to run python and wsgi web apps. # # chkconfig: 2345 85 15 # description: Use uwsgi to run python and wsgi web apps. # processname: uwsgi </code></pre> <p>Thank you for your help.</p>
12,935,550
0
Quotes & escaping in Javascript <p>is there a smart way in js to insert mixedsingle and double quotes, like python </p> <blockquote> <p>"""string"""</p> </blockquote> <p>syntax? Or similar stuff, which I believe is present in Perl or PHP.</p>
20,118,681
0
<p>In my keyboard (Swedish) it´s the key to the right of "ä": "*".</p> <p><kbd>ctrl</kbd>+<kbd>*</kbd></p>
19,018,984
0
<p>Just create one view for that and use <code>&lt;include ... /&gt;</code> to include that view to your Activity's layout. In each Activity you have to modify it independently.</p>
36,084,927
0
Select range cells with blank rows <p>I've been having difficulties with figuring out how to code this select range macro to include blank rows. The worksheet is a chart with variable number of columns and rows. This is what I have so far:</p> <pre><code>Sub Macro1() Range("A5").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy End Sub </code></pre> <p>The selection step in the macro will only go so far as that blank row and won't go any further (obviously because it's blank hehe). For that reason, I tried adapting this discontiguous type of code but with no luck:</p> <pre><code>Sub SelectRangeDown_Discontiguous() Range("A5", Range("A65536").End(xlUp)).Select End Sub </code></pre> <p>I was hoping someone could help me figure out the best way of writing this code? Am I on the right path?</p>
23,180,307
0
How I can access to a returned data of a function with use the reflect package? <p>I have a function of the IndexController type:</p> <pre><code>func (this IndexController) ActionIndex() map[string]string { return map[string]string{"Name": "Hello from the actionIndex()!"} } </code></pre> <p>It is used so:</p> <pre><code>routerInstance := router.Constructor(request) controllerObject := controllers[routerInstance.GetRequestController(true)] outputData := reflect.ValueOf(controllerObject).MethodByName(routerInstance.GetRequestAction(true)).Call([]reflect.Value{}) fmt.Println(outputData) </code></pre> <p>Now for example, how to show the <strong>Name</strong> element of <strong>outputData</strong>? I try to print so:</p> <pre><code>fmt.Println(outputData["Name"]) </code></pre> <p>But program will exit with error:</p> <pre><code># command-line-arguments ./server.go:28: non-integer array index "Name" </code></pre> <p>I will be thankful!</p>
17,475,504
0
<p>Unfortunately, teh CategoryAxis doesn't seem to have a renderer and therefore canDropLabels and canStagger cannot be set for it.</p>
37,744,699
0
<p>Try this:</p> <pre><code>from ts in Db.Tasks join prt in Db.ProjectTasks on ts.Id equals prt.TaskId from tl in Db.Timeline.Where(x =&gt; (x.TypeId == ts.Id) &amp;&amp; (x.Type == (int)Provider.EntityType.TASK)) .DefaultIfEmpty() from dur in Db.Duration.Where(x =&gt; (x.TypeId == ts.Id) &amp;&amp; (x.Type == (int)Provider.EntityType.TASK)) .DefaultIfEmpty() where (prt.ProjectId == ProjectId) select new { Id = "T" + ts.Id, ts.Name, ts.Description, //... prt.ProjectId, tl.StartDate, tl.EndDate, tl.LatestEndDate, //... dur.ActualDuration, dur.ActualDurationPlanned } </code></pre> <p><code>from x in y.DefaultIfEmpty()</code> is a simple way to create a <code>LEFT JOIN</code>.</p> <p><strong>EDIT:</strong> Changed <code>.Where()</code> in left joins.</p>
7,018,489
0
How can I send a REST XML POST request via curl? <p>Basically, I have a project set up in Restlet which uses JAXRS for mapping resources to paths and uses JAXB for serializing and deserializing XML to/from Java types. I'm currently trying to send a POST request in order to test whether it works, and I'm running into a bit of trouble. Here's my resource:</p> <pre><code>@Path("stream") public class StreamResource { @POST @Consumes("text/xml") @Produces("text/xml") public Stream save(Stream value) { logger.debug("saving new stream..."); return (Stream)this.streamPersistence.save(value); } } </code></pre> <p>Here's my <code>Stream</code> class:</p> <pre><code>@XmlRootElement(name="stream") @XmlType(propOrder={"id", "streamName", "title", "description", fileSystemPath"}) public class Stream { private Long id; private String streamName; private String fileSystemPath; private String title; private String description; // getters/setters omitted for brevity } </code></pre> <p>And here's how I'm invoking <code>curl</code>:</p> <pre><code>curl -X POST -d '&lt;stream&gt;&lt;streamName&gt;helloWorld.flv&lt;/streamName&gt;&lt;title&gt;Amazing Stuff, Dude!&lt;/title&gt;&lt;description&gt;This stream is awesome-cool.&lt;/description&gt;&lt;fileSystemPath&gt;/home/rfkrocktk/Desktop/helloWorld.flv&lt;/fileSystemPath&gt;&lt;/stream&gt;' --header 'Content-Type:"text/xml"' http://localhost:8888/stream </code></pre> <p>Here's the error I'm getting from <code>curl</code>:</p> <pre><code>The given resource variant is not supported. </code></pre> <p>...and here's the error in Restlet:</p> <pre><code>15:02:25.809 [Restlet-961410881] WARN org.restlet.Component.Server - Error while parsing entity headers java.lang.IllegalArgumentException: Illegal token: "text at org.restlet.data.MediaType.normalizeToken(MediaType.java:647) at org.restlet.data.MediaType.normalizeType(MediaType.java:686) at org.restlet.data.MediaType.&lt;init&gt;(MediaType.java:795) at org.restlet.data.MediaType.&lt;init&gt;(MediaType.java:767) at org.restlet.engine.http.header.ContentTypeReader.createContentType(ContentTypeReader.java:84) at org.restlet.engine.http.header.ContentTypeReader.readValue(ContentTypeReader.java:112) at org.restlet.engine.http.header.ContentType.&lt;init&gt;(ContentType.java:99) at org.restlet.engine.http.header.HeaderUtils.extractEntityHeaders(HeaderUtils.java:664) at org.restlet.engine.http.connector.Connection.createInboundEntity(Connection.java:313) at org.restlet.engine.http.connector.ServerConnection.createRequest(ServerConnection.java:136) at org.restlet.engine.http.connector.ServerConnection.readMessage(ServerConnection.java:229) at org.restlet.engine.http.connector.Connection.readMessages(Connection.java:673) at org.restlet.engine.http.connector.Controller$2.run(Controller.java:95) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679) </code></pre> <p>What am I doing wrong here? This seems pretty straightforward, right? </p>
40,700,224
0
How do I implement this parallel pattern in C#? <p>What I'm ultimately trying to accomplish is to get the HTML from an unknown but limited number of webpages where <code>GetPage(i)</code> returns the HTML for page <code>i</code> and I want to stop as soon as I found a non-page.</p> <p>The exact pattern I'm going for is like this: </p> <ul> <li>Start <code>N</code> parallel tasks that are <code>GetPage(0)</code>, ..., <code>GetPage(N-1)</code>. </li> <li>As soon as a task <code>GetPage(i)</code> completes, if the task was able to get the page, add it to a collection of pages and try to get the next largest page that hasn't tried to be processed yet; or if the task was not able to get the page, cancel all tasks <code>GetPage(j)</code> where <code>j&gt;i</code>.</li> </ul> <p>So my attempted implementation is like </p> <pre><code> var docs = new LinkedList&lt;HtmlDocument&gt;(); int tlimit = 20; var tasks = new Task&lt;HtmlDocument&gt;[tlimit]; for(int i = 0; i &lt; tlimit; ++i) { tasks[i] = Task&lt;HtmlDocument&gt;.Factory.StartNew(() =&gt; BoardScanner.GetBoardPage(i)); } /// ??? </code></pre>
23,425,527
0
<p>There might be a more straightforward way but if you've got the <code>EllipticCurve</code> object, you can always just substitute the coordinates of your point into the equation of the curve.</p>
13,728,369
0
FindMeIn Gem or output file name <p>i was wondering if exist a gem which in development env display render path of file (layout, view, partials..) at the top of each html</p> <p>example:</p> <blockquote> <p>find me in /posts/show.html.erb</p> </blockquote> <p>i'm working co-op with a designer (with 0 rails skills) and it's our first project</p> <p>if not exist a gem like this, how can display the path of each file?</p>
33,731,920
0
<blockquote> <p>Do all of the call stacks necessary for an application (if this is even possible to know) get allocated when the application gets launched?</p> </blockquote> <p>No. Typically, each thread's stack is allocated when that thread is created.</p> <blockquote> <p>Or do call stacks get allocated/de-allocated dynamically as applications spin off new threads?</p> </blockquote> <p>Yes.</p> <blockquote> <p>And if that is the case, (I know stacks have a fixed size), do the new stacks just get allocated right below the previous stacks-- So you would end up with a stack of stacks in the top addresses of memory? Or am I just fundamentally misunderstanding how call stacks are being created/used?</p> </blockquote> <p>It varies. But the stack just has to be at the top of a large enough chunk of available address space in the memory map for that particular process. It doesn't have to be at the very top. If you need 1MB for the stack, and you have 1MB, you can just reserve that 1MB and have the stack start at the top of it.</p> <blockquote> <p>How does the sp register work if there are multiple call stacks? Is it only used for the main call stack?</p> </blockquote> <p>A CPU has as many register sets as threads that can run at a time. When the running thread is switched, the leaving thread's stack pointer is saved and the new thread's stack pointer is restored -- just like all other registers.</p> <p>There is no "main thread of the OS". There are some kernel threads that do only kernel tasks, but also user-space threads also run in kernel space to run the OS code. Pure kernel threads have their own stacks somewhere in kernel memory. But just like normal threads, it doesn't have to be at the very top, the stack pointer just has to start at the highest address in the chunk used for that stack.</p>
13,959,460
0
WebView fading edge is a solid block <p>I am trying to get fading edges working for Android 4.1. I've figured out I need "android:requiresFadingEdge", but now instead of a fade, I get a solid block that appears on the top/bottom when I'm scrolling.</p> <pre><code>&lt;WebView android:layout_width="fill_parent" android:layout_height="fill_parent" android:fadingEdge="vertical" android:fadingEdgeLength="20dp" android:overScrollMode="never" android:requiresFadingEdge="vertical" /&gt; </code></pre> <p>Has anyone seen this before?</p>
29,916,842
0
<p>Change this </p> <pre><code>Integer i = (Integer) spinner_snooze.getSelectedItem(); </code></pre> <p>to</p> <pre><code>Integer i = (Integer) parent.getSelectedItem(); </code></pre> <p>Plus add any default value as first item.Check if first item is selected,than do not do anything.</p> <p>insert a default value like " -- " and compare it by using </p> <pre><code>if(parent.getSelectedItem().compareTo(" -- ")== 0 { //Do Nothing } else { //Do your stuff here AlarmManager mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Integer i = (Integer) spinner_snooze.getSelectedItem(); snoozeAlarm(i, mAlarmManager, context); // Toast.makeText(getApplicationContext(), x, Toast.LENGTH_LONG).show(); finish(); } </code></pre>
3,157,585
0
<p>You <strong>can</strong> select it outside, but not <em>yet</em>, that <code>$.get()</code> callback takes some time to run (it has to get the data from the server, the callback happens <em>later</em>, when that finishes), so when you do this:</p> <pre><code>$('#newElement').css('background','black'); </code></pre> <p>That element isn't there <em>yet</em> (and so the selector doesn't find anything...it's running <em>before</em> that callback creating it does), you need to wait until the callback finishes before continuing any code that needs elements created by it. Like this:</p> <pre><code>$.get('menu.xml',function(data){ //create a new element with an ID called "#newElement" //kick off stuff that uses "#newElement" $('#newElement').css('background','black'); }); </code></pre>