pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
2,422,364
0
<p>if you want to remove lines that contains words in that blacklist</p> <pre><code>grep -v -f blacklist.txt inputfile &gt; filtered_file.txt </code></pre> <p>if you want to remove just the words alone</p> <pre><code>awk 'FNR==NR{ blacklist[$0] next } { for(i=1;i&lt;=NF;i++){ if ($i in blacklist){ $i="" } } }1' blacklist inputfile &gt; filtered_file.txt </code></pre>
38,911,583
0
<p>If your number is sms capable and still you are getting the 21606 error, then check 'Active Numbers' tab under 'Manage Numbers'. It should show your number '+43720881723' as an active number.</p>
38,142,956
0
Bootstrap responsive audio player <p>I need help. When I'm using an audio in the container (bootstrap) I have 4 player in 1 row - that's fine (col-lg-3), but when I'm resizing my window (from col-md-4 to col-xs-6) then magic happens... players are in different places :/ you can look at this here:</p> <p><a href="https://i.stack.imgur.com/WxQRb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WxQRb.jpg" alt="enter image description here"></a></p> <pre><code>&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="col-lg-3 col-md-3 col-sm-4 col-xs-6"&gt; &lt;p class="titles"&gt;Bird Wings&lt;/p&gt; &lt;audio class="audio controls"&gt; &lt;source src="http://audiosoundclips.com/wp-content/uploads/2011/12/Dogbark.mp3" type="audio/mpeg"&gt; Your browser does not support the audio element. &lt;/audio&gt; &lt;/div&gt; &lt;div class="col-lg-3 col-md-3 col-sm-4 col-xs-6"&gt; &lt;p class="titles"&gt;Bird Wings&lt;/p&gt; &lt;audio class="audio controls"&gt; &lt;source src="http://audiosoundclips.com/wp-content/uploads/2011/12/Dogbark.mp3" type="audio/mpeg"&gt; Your browser does not support the audio element. &lt;/audio&gt; &lt;/div&gt; &lt;div class="col-lg-3 col-md-3 col-sm-4 col-xs-6"&gt; &lt;p class="titles"&gt;Bird Wings&lt;/p&gt; &lt;audio class="audio controls"&gt; &lt;source src="http://audiosoundclips.com/wp-content/uploads/2011/12/Dogbark.mp3" type="audio/mpeg"&gt; Your browser does not support the audio element. &lt;/audio&gt; &lt;/div&gt; &lt;div class="col-lg-3 col-md-3 col-sm-4 col-xs-6"&gt; &lt;p class="titles"&gt;Bird Wings&lt;/p&gt; &lt;audio class="audio controls"&gt; &lt;source src="http://audiosoundclips.com/wp-content/uploads/2011/12/Dogbark.mp3" type="audio/mpeg"&gt; Your browser does not support the audio element. &lt;/audio&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
14,733,858
0
<p>Highly variant write latency is a common attribute of SSDs (especially consumer models). There is a pretty good explanation of why in this <a href="http://www.anandtech.com/show/6432/the-intel-ssd-dc-s3700-intels-3rd-generation-controller-analyzed" rel="nofollow">AnandTech review</a> . </p> <p>Summary is that the SSD write performance worsens overtime as the wear leveling overhead increases. As the number of free pages on the drive decreases the NAND controller must start defragmenting pages, which contributes to latency. The NAND also must build an LBA to block map to track the random distribution of data across various NAND blocks. As this map grows, operations on the map (inserts, deletions) will get slower.</p> <p>You aren't going to be able to solve a low level HW issue with a SW approach, you are going to need to either move up to an enterprise level SSD or relax your latency requirements.</p>
11,482,582
0
<p>It's not clear what you want do do, but if you're using POST to send it to PHP then you can check if the value is empty like this</p> <pre><code>&lt;?php if(empty($_POST['value_name'])) { echo 'value is required'; } else { // OK } </code></pre>
37,503,493
0
<p>Here is how you can make the function work as described:</p> <pre><code>bag_sword = [] def equip(x): global bag_sword if x == "iron sword": if "iron sword" in bag_sword: print "You can't have 2 weapons equipped!" else: bag_sword.append("iron sword") print bag_sword # Prints "[]". equip("iron sword") # Prints nothing. Puts the string "iron sword" in bag_sword. print bag_sword # Prints "['iron sword']". equip("iron sword") # Prints "You can't have 2 weapons equipped!". bag_sword is unchanged. </code></pre>
11,664,673
0
<p>Use <code>setFieldChangeListener</code> will do for all action.</p> <pre><code> if (position != 0) { title = new Custom_LabelField(Config_GlobalFunction.maintitle, DrawStyle.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER | Field.FOCUSABLE | ButtonField.CONSUME_CLICK, Color.WHITE) { protected boolean navigationClick(int status, int time) { Main.getUiApplication().pushScreen( new Custom_LoadingScreen(1)); Main.getUiApplication().invokeLater(new Runnable() { public void run() { Main.getUiApplication().pushScreen( new Main_AllLatestNews()); } }, 1 * 1000, false); return true; } }; } else { title = new Custom_LabelField(Config_GlobalFunction.maintitle, DrawStyle.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER, Color.WHITE); } title.setFont(Font.getDefault().derive(Font.BOLD, fontsize)); add(title); if (left == 1) { newsbtn = new Custom_ButtonField(news, newsactive, newsactive); newsbtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { Main.getUiApplication().pushScreen( new Menu_PopupMenu(position)); } }); add(newsbtn); } else if (left == 2) { backbtn = new Custom_ButtonField(back, backctive, backctive); backbtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { Main.getUiApplication().popScreen(mainscreen); } }); add(backbtn); } if (right == 1) { downloadbtn = new Custom_ButtonField(download, downloadactive, downloadactive); downloadbtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { if (Config_GlobalFunction .Dialog(Config_GlobalFunction.alertdownload)) { if (Config_GlobalFunction.isConnected()) { webservice.UpdateAllCatNews(); } else Config_GlobalFunction.Message( Config_GlobalFunction.nowifi, 1); } else Config_GlobalFunction.CloseDialog(); } }); add(downloadbtn); } else if (right == 2) { refreshbtn = new Custom_ButtonField(refresh, refreshactive, refreshactive); refreshbtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { if (Config_GlobalFunction.isConnected()) { Config_GlobalFunction.Message( Config_GlobalFunction.refreshing, 1); webservice.UpdateMoreCatNews(catsid, position, header); } else Config_GlobalFunction.Message( Config_GlobalFunction.nowifi, 1); } }); add(refreshbtn); } } </code></pre> <p>However, there is a bad thing which is when you click or use trackwheel to click the button, it will appear blue color.</p>
27,268,554
0
<p>Where is the file InpData.txt?</p> <p>Place a breakpoint and debug <code>new File(fileName).getAbsolutePath()</code> to see where it should be. Place your file there.</p> <p>Don't hard-code the path if you want the code to be portable (if it is being executed on another machine).</p>
18,317,328
0
angularjs same directive (outside click) for multiple elements <p>So I have 2 elements with the same directive: (coffeescript)</p> <pre><code>myApp.directive "clickOutside", ["$document", ($document) -&gt; restrict: "A" link: (scope, elem, attr, ctrl) -&gt; elem.bind "click", (e) -&gt; e.stopPropagation() $document.bind "click", -&gt; scope.$apply attr.clickOutside ] </code></pre> <p>and the HTML:</p> <pre><code>&lt;div class="filter-box" click-outside="showFilterList=false"&gt; &lt;div class="filter-title" ng-click="showFilterList=!showFilterList;"&gt;Open&lt;/div&gt; &lt;ul class="filter-list" ng-class="{show:datePickerModel.showFilterList}"&gt; &lt;li&gt;&lt;/li&gt; ... ... &lt;/ul&gt; &lt;/div&gt; &lt;div class="filter-box" click-outside="showFilterList=false"&gt; &lt;div class="filter-title" ng-click="showFilterList=!showFilterList;"&gt;Open&lt;/div&gt; &lt;ul class="filter-list" ng-class="{show:datePickerModel.showFilterList}"&gt; &lt;li&gt;&lt;/li&gt; ... ... &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I have 2 DIV's that click on the filter-title will change the showFilterList to true and by that the filter-list gets the 'show' class. clicking outside the element will set the showFilterList to false and filter-list is hidden again. Everything is working fine expect for one scenario: clicking on the first element filter-title and show the filter-list. clicking on the second element filter-title will show itself filter-list but won't set to false the first element that was already clicked.</p> <p>How can I do it so each directive will have it's own scope when triggered?</p> <p>Thanks!</p>
33,687,524
0
Bottom up merge sort on Linked List <p>Bottom up merge sort treats a list each element of size 1, and iteratively merge the sub-lists back and forth until they are in sorted order. This makes it very attractive to use bottom up merge sort to sort linked list as they are already "separated".</p> <p>I'm trying to implement bottom up merge sort in C language, and realised that there are various approach to implement bottom up merge sort; in particular, I'm using this approach: </p> <ol> <li>Insert single lists into a queue</li> <li>Dequeue first two lists and merge them</li> <li>Enqueue merged lists (merged items go to the end)</li> <li>Repeat step 1-3 until they are in sorted order</li> </ol> <p>However, I'm struggling to implement the following:</p> <ul> <li>Merge linked-lists without using extra O(n) space (if possible)</li> </ul> <p>Hence, my questions are: </p> <ul> <li><strong><em>How would one implement</em></strong> this correctly in C language? (in particular: the handling of repeating the <strong><em>dequeue and enqueue process until it's fully sorted</em></strong>) How would one know if the entire queue is in sorted order? I'm thinking of keeping track of the *head pointer(s) in a list.</li> <li><strong><em>Is merge sort stable in this case? Why?</em></strong> </li> <li>The running time of bottom-up merge sort is still O(nlogn). However, <strong><em>does this bottom up merge sort use O(n) space</em></strong>? Suppose the linked-list we implement is already a queue. </li> <li>Extra question: is there a better alternative to implement bottom-up merge sort on linked list? </li> </ul> <p>I suppose this is one of the advantage of using bottom-up merge sort on linked list, as it is more space efficient than using bottom-up merge sort on arrays. Correct me if I'm wrong.</p>
32,293,575
0
<p>Thanks @Bjoerg, Your solution works.</p> <p>I did the remote configuration for my cordova app not in the "Options->Cross Platform->C++->iOS" section, but in "Options-Tools for Apache Cordova->Remote Agent Configuration" and it worked like a charm</p> <p>Regards </p>
17,204,834
0
How to make a fancy mysql join that can join three tables and detect if one table DOESNT have my item <p>php mysql query I have multiple linked tables - I also have a table that only creates and entry if certian conditions exist so I would like to add that into my query to avoid having to go through thousands of query searches looking for this special case</p> <p>here is my current query</p> <pre><code>$query = "SELECT a.UUID FROM contract a INNER JOIN geoPoint b ON a.customer_UUID = b.customerUUID WHERE b.garcom_UUID = '$garbCom' AND b.city_UUID = '$city'"; </code></pre> <p>I then go through each item that was returned (in the thousands)</p> <pre><code>while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $sentdata = getothertable($row['UUID']); //checks if the item is in the table $sent = $sentdata ['senttoGarcom']; if($sent == 0) //if it wasn't found add it to my list { array_push($Contracts,$row['UUID']); } } </code></pre> <p>instead of all that I would like to just make it one query - pseduo code something like this</p> <pre><code> $query = "SELECT a.UUID FROM contract a INNER JOIN geoPoint b ON a.customer_UUID = b.customerUUID INNER JOIN contract_sales c ON a.UUID = c.contractUUID WHERE b.garcom_UUID = '$garbCom' AND b.city_UUID = '$city' AND c.DOESNOTEXIST"; </code></pre> <p>this way I dont have to return thousands I will only be returned the few that are not yet in the contract_sales table and I can go about my business...</p> <p>Appreciate any help!</p>
35,720,472
0
<p>I just want to extend the answer from <a href="http://stackoverflow.com/users/2190416/arnaud-t">Amaud T</a>:</p> <p>I faced the same issue and I used the above answer, with some small modifications:</p> <pre><code>&lt;style type="text/css"&gt; #chartComponentId table.jqplot-table-legend { width: auto !important;} &lt;/style&gt; &lt;div id="chartComponentId" class="chartComponent"&gt; ... &lt;/div&gt; </code></pre> <p>Due to the need of use <em>!important</em>, binding this stylesheet on a particular div objects prevents any side effects to other elements.</p>
28,616,911
0
How to set an ImageView to match_parent and horizontally scale accordingly? <p>I have a RelativeLayout in a section of my activity that includes a button and an ImageView. The size of the RelativeLayout is ListPreferredItemHeight and what I would like to do is have the ImageView span from top to bottom of that layout and be scaled accordingly.</p> <p>Currently, without implementing any scaling attributes, I have this image:</p> <p><img src="https://i.stack.imgur.com/ZCGxs.png" alt="enter image description here"></p> <p>I achieve this with the following xml code:</p> <pre><code>&lt;RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"&gt; &lt;Button android:id="@+id/newPrescription_Medication" android:gravity="center" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_toLeftOf="@+id/newPrescription_AddMedication" android:layout_toStartOf="@id/newPrescription_AddMedication" android:text="@string/select_medication"/&gt; &lt;ImageView android:id="@+id/newPrescription_AddMedication" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:src="@drawable/add_icon"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Now, to try and fill the space with the button, I added the following to the ImageView tag:</p> <pre><code>android:adjustViewBounds="true" android:scaleType="centerInside" </code></pre> <p><img src="https://i.stack.imgur.com/SZjzS.png" alt="enter image description here"></p> <p>How can I get the entire image to appear, while maintaining its position on the right side of the layout and filling the rest with the button?</p>
2,188,447
0
<p>Correct. You must transform your attribute into an <code>NSData</code> object. You would need to serialize an <code>NSURL</code> to <code>NSData</code> -- and the default <code>NSKeyedUnarchiveFromDataTransformerName</code> transformer will do this for you.</p> <p>Another approach, and the one that I use for URLs, is to maintain two parallel properties. One transient property of undefined type for the URL, and a second persistent property of string type for the backing store. I lazily construct the URL from the string the first time it's requested, and I update the string property whenever the URL is changed.</p> <p>There's no way to enforce it, but you really don't want to use the string property from outside your entity's class. I generally make the <code>@property</code> definition for the string attribute private to remind myself not to use it.</p>
18,737,412
0
<p>By submitting the form in HTML you basically tell the browser to generate a normal HTTP request, usually POST or GET, for an URL defined in tag with form fields attached according to the specified method either appended to the URL or included in the request data. </p> <p>There is nothing really special or different from a "normal" HTTP request, in fact you can manually "submit a form" by appending form keys and values to the URL in your browser and navigating to it in case of GET method.</p> <p>Summarizing:</p> <p>1) Yes, you are right.</p> <p>2) From what I've just read (never used REST personally) a REST application is implemented by a servlet mechanism and uses HTTP protocol, so it should be possible to write a REST application for processing HTML forms if the form points to this application's URL.</p>
24,807,178
0
<p>You need to do something like this:</p> <pre><code>//define base layers var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var normalView = L.tileLayer(osmUrl, {styleId: 997, attribution: osmAttributes, maxZoom: 18 }); ... //define overlay layers var markersLayer = new L.layerGroup(); var linesLayer = new L.layerGroup(); ... //create MAP with default base and overlay layers var map = L.map('map', { layers: [normalView, markersLayer] }).setView([45.2516700, 19.8369400], 12); //add layers to the base and overlay var baseMaps = { "Normal view": normalView, "Night view": nightView, "MapQuest layer": mapQuest }; var overlayMaps = { "Markers": markersLayer, "Lines": linesLayer, "3D layer": osmbView }; //add layer control to the map L.control.layers(baseMaps, overlayMaps).addTo(map); </code></pre>
20,326,482
0
How to get data from a custom table into a block in magento <p>I have followed the steps mentioned in the link below to create a custom module in magento 1.7. <a href="http://www.webspeaks.in/2010/07/create-your-first-magento-module.html#comment-form" rel="nofollow">http://www.webspeaks.in/2010/07/create-your-first-magento-module.html#comment-form</a></p> <p>I did not create a web table, instead I have created 2 tables chefdetail and chefproduct, and have created the Block and phtml file for the same.</p> <p>My Chefdetail block looks like:</p> <pre><code>class TruffleStreet_Web_Block_ChefDetail extends Mage_Core_Block_Template { public function _prepareLayout() { return parent::_prepareLayout(); } public function getChefDetail() { if (!$this-&gt;hasData('chefdetail')) { $this-&gt;setData('chefdetail', Mage::registry('chefdetail')); } return $this-&gt;getData('chefdetail'); } } </code></pre> <p>How do I modify it to load all the data from the chefdetail table in the database? There is data in this table, but I am not able to access it. My chefdetail.phtml file looks like:</p> <pre><code>$_chefblockData = $this-&gt;getLayout()-&gt;createBlock('web/chefdetail')-&gt;getChefDetail(); echo "Count Chef = " . count($_chefblockData) ; </code></pre> <p>Please advice how I can fix this issue?</p> <p>Thanks, Neet</p>
39,704,710
0
<p>The problem is that when you work in 'mode' 'no-cors', the Headers become an immutable and you will not be able to change some of its entries. One of the heads you can't change is the Content-Type. When you set 'mode' to 'no-cors' you will be able to change only these headers:</p> <ul> <li><code>Accept</code></li> <li><code>Accept-Language</code></li> <li><code>Content-Language</code></li> <li><code>Content-Type</code> and whose value, once parsed, has a MIME type (ignoring parameters) that is <code>application/x-www-form-urlencoded</code>, <code>multipart/form-data</code>, or <code>text/plain</code></li> </ul> <p>In another words, in 'mode' '-no-'cors' you can only set <code>application/x-www-form-urlencoded</code>, <code>multipart/form-data</code>, or <code>text/plain</code> to the <code>Content-Type</code>.</p> <p>So the solution is stop using fetch or changing it to 'cors' 'mode'. Of course this will only works if your server also accepts 'cors' requests.</p> <p>Here is an example of how you could enable CORS in an Apache Server</p> <pre><code>SetEnvIfNoCase Access-Control-Request-Method "(GET|POST|PUT|DELETE|OPTIONS)" IsPreflight=1 SetEnvIfNoCase Origin ".*" AccessControlAllowOrigin=$0 SetEnvIfNoCase Origin "https://(url1.com|url2.com)$" AccessControlAllowOrigin=$0 Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" env=IsPreflight Header always set Access-Control-Allow-Headers "Content-Type, Authorization, Accept, Accept-Language" env=IsPreflight Header always set Access-Control-Max-Age "7200" env=IsPreflight RewriteCond %{REQUEST_METHOD} OPTIONS RewriteCond %{ENV:IsPreflight} 1 RewriteRule ^(.*)$ $1 [R=204,L] </code></pre> <p>The above code will inject the CORS headers in the response when its necessary. With this code your server will allow CORS only from the the domains "url1.com" or "url2.com".</p> <p>Here are some references</p> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Request/mode" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/Request/mode</a></li> <li><a href="https://fetch.spec.whatwg.org/#simple-header" rel="nofollow">https://fetch.spec.whatwg.org/#simple-header</a></li> </ul>
28,735,408
0
<p>I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.</p>
21,057,197
0
<p>When you would like to change the <code>$n</code>. character to <code>$something</code>:</p> <pre><code>$_SESSION['b1'][$n] = $something; </code></pre> <p>In your case:</p> <pre><code>$_SESSION['b1'][1] = $_SESSION['word'][0]; </code></pre> <p>Details:</p> <p><a href="http://www.php.net/manual/en/language.types.string.php#language.types.string.substr" rel="nofollow">http://www.php.net/manual/en/language.types.string.php#language.types.string.substr</a></p>
39,480,810
0
<p>Technically the copy constructor gets invoked in the following cases:</p> <ol> <li>explicit copy construction</li> <li>call by value</li> <li>return by value</li> </ol> <p>The assignment operator is implemented to obliterate an exiting instance's old contents with new ones. As you showcase an example:</p> <pre><code>myClass newInstant; newInstant = oldInstant;//assignment operator </code></pre> <p>Keep in mind that they work differently. Copy-swap involves in the assignment operator. </p> <p>Regarding your last question, modern compilers apply copy constructor elision to elide unnecessary copy constructor call. </p>
4,464,489
0
<p>I'm not 100% on the problems with the canvas element in IE but you can update the onclick handler of the <code>canvas</code> element, changing the window location to where you want.</p> <pre><code>document.getElementById("mycanvas").onclick = function(e){ window.location.href = 'http://www.google.com'; }; </code></pre> <p>Example: <a href="http://jsfiddle.net/jonathon/HtmVS/">http://jsfiddle.net/jonathon/HtmVS/</a></p> <p>You could handle other events (like the mousein/mouseout) to set the cursor, if you wanted.</p>
13,983,583
0
<p>Unless you want to dig into the internals of one or more sparse matrix types, you should use CSR format for your matrix and:</p> <ul> <li>Calculate the length (L2 norm) of each matrix row; in other words: <code>sum(multiply(M, M), 2)</code></li> <li>Normalize r to (L2) length 1</li> <li>Matrix multiply <code>M*r</code> (where r is treated as a column vector)</li> </ul> <p>If an entry of <code>M*r</code> matches the length of the corresponding row, then you have a match.</p> <p>Note that the default <code>ord</code> for <code>numpy.linalg.norm</code> is L2 norm.</p>
10,664,254
1
The right way to check of a string has hebrew chars <p>The Hebrew language has unicode representation between 1424 and 1514 (or hex 0590 to 05EA).</p> <p>I'm looking for the right, most efficient and most pythonic way to achieve this.</p> <p>First I came up with this:</p> <pre><code>for c in s: if ord(c) &gt;= 1424 and ord(c) &lt;= 1514: return True return False </code></pre> <p>Then I came with a more elegent implementation:</p> <pre><code>return any(map(lambda c: (ord(c) &gt;= 1424 and ord(c) &lt;= 1514), s)) </code></pre> <p>And maybe:</p> <pre><code>return any([(ord(c) &gt;= 1424 and ord(c) &lt;= 1514) for c in s]) </code></pre> <p>Which of these are the best? Or i should do it differently?</p>
26,426,280
0
receiving post variables from an external source in zendframework 2 <p>i am working on a zendframework 2 project and want to receive post variables from an external source.</p> <p>the source where the values will come from is a payment site (i.e world pay and paypal). i.e the return values of a payment confirming that payment has been made.</p> <p>on the external site, i simply gave the URL of the web page that i want the information to be returned to: </p> <pre><code>http://example-site.com/payments/payment-made </code></pre> <p>then in action function on the controller page i did the following; </p> <pre><code>public function paymentMadeAction() { $contents = file_get_contents('php://input'); // read request contents $data = explode('&amp;', $contents); if ($contents) { foreach($data as &amp;$entry) { $entry = explode('=', $entry); $entry[1] = urldecode($entry[1]); } unset($entry); } print_r($data); } </code></pre> <p>nothing happens though. i mean, i tested it but the values are not being received. when i went to the external source to check if my site received the information it confirmed that the information had been successfully sent</p> <p>is there a special procedure that needs to be followed when receiving information from an external source in zend framework 2</p> <p>would really appreciate any guidance or advise.</p> <p><strong>update:</strong></p> <p>below is a sample of the post variable that should be returned to the site; its a simply http object</p> <pre><code> POST /fail?installation=XXXXXX&amp;msgType=authResult HTTP/1.0 Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Host: www.worldpay.com Content-Length: 973 User-Agent: WJHRO/1.0 (worldPay Java HTTP Request Object) region=new+format+region&amp;authAmountString=%26%23163%3B10.00&amp;_SP.charEnc=UTF8&amp;desc=&amp;tel=&amp;address1=new+format+address1) </code></pre>
37,460,580
0
<p>I had this issue recently with another group of plugins recently. One wouldn't allow me to disable it because it dependeded on the other, but the other was disabled and wouldn't allow me to enable it because of the dependency. </p> <p>All you have to do to fix this is go to your jenkins installation, and under the plugins directory look for the plugin_name.jpi file. For the disabled plugin, you should see a file called plugin_name.jpi.disabled. Just delete the disabled file and then you should be able to enable / disable the plugins through the UI.</p> <p>Note: you can also manually disable plugins by creating a disabled plugin file using the naming convention above.</p>
35,868,533
0
<p>Thanks for the heads up about the bug report and fix. I feel the need to give an answer to this question though, just in case you haven't ditched PHP and Slim framework altogether. Hopefully, it will be of help to someone else.</p> <p>My approach to this would be:</p> <pre><code>&lt;?php use Slim\Http\Request; use Slim\Http\Response; class AuthenticationMiddleware { public function isAuthenticated($userid, $authorization) { //do data validation here return false; } public function createErrorResponse($code, $msg, Response $response) { return $response-&gt;withStatus($code) -&gt;withHeader('Content-Type', 'application/json;charset=utf-8') -&gt;withJson($msg); } public function __invoke(Request $request, Response $response, $next) { $userid = $request-&gt;getHeaderLine('userid'); $authorization = $request-&gt;getHeaderLine('Authorization'); if(!$this-&gt;isAuthenticated($userid, $authorization)) { $msg = 'You are unauthenticated. Please login again'; $code = 400; $this-&gt;createErrorResponse($code, $msg, $response); } else { $response = $next($request, $response); } return $response; } } </code></pre> <p>Let me just say this. I would abstract a few stuff here in this code so I don't end up repeating myself. I see you repeating:</p> <pre><code>public function createErrorResponse($code, $msg, Response $response) { return $response-&gt;withStatus($code) -&gt;withHeader('Content-Type', 'application/json;charset=utf-8') -&gt;withJson($msg); } </code></pre> <p>In all your middleware and perhaps, in your routes. Hope this sets someone on the right track.</p>
31,817,366
0
<p>As other folks have mentioned, Java, ActiveX, Silverlight, Browser Helper Objects (BHOs) and other plugins are not supported in Microsoft Edge. Most modern browsers are moving away from plugins and toward standard HTML5 controls and technologies. </p> <p>If you must continue to use the Java plugin in a corporate web app, consider adding the site to an <a href="https://technet.microsoft.com/en-us/library/mt270205.aspx">Enterprise Mode site list</a>. This will automatically prompt the user to open in IE.</p>
7,109,507
0
<p>If <strong>all values</strong> end up at <code>star0.png</code>, then you <em>are</em> cycling through the list. The fact that the <code>else</code> statement is the only code being executed for each element suggests a logical error -- did you perhaps mean to do something like this?</p> <pre><code>string serviceCode = ReviewList[i].SERVICE.SERVICE_CODE; </code></pre>
22,939,473
0
<p>I ran into an issue with the nice Joonas Pulakka's answer because the "UIManager lookandFeel" was ignored.</p> <p>I found the nice trick below on <a href="http://tips4java.wordpress.com/2010/09/12/keeping-menus-open/" rel="nofollow">http://tips4java.wordpress.com/2010/09/12/keeping-menus-open/</a> </p> <p>The point is to reopen immediatly the menu after it has been closed, it's invisible and keep the application look and feel and behavior.</p> <pre><code>public class StayOpenCBItem extends JCheckBoxMenuItem { private static MenuElement[] path; { getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (getModel().isArmed() &amp;&amp; isShowing()) { path = MenuSelectionManager.defaultManager().getSelectedPath(); } } }); } public StayOpenCBItem(String text) { super(text); } @Override public void doClick(int pressTime) { super.doClick(pressTime); MenuSelectionManager.defaultManager().setSelectedPath(path); } } </code></pre>
21,367,584
0
<p>Jquery POST data could be sent as</p> <pre><code>data: { email_one: email_one , email_two: email_two,ebankpin:ebankpin,eusername:eusername} </code></pre>
40,708,900
0
<p>Based on this previous <a href="http://stackoverflow.com/questions/40698572/ruby-extract-elements-from-deeply-nested-json-structure-based-on-criteria/40698808?noredirect=1#comment68644516_40698808">answer</a>, you just need to add a select on eventNodes :</p> <pre><code>require 'json' json = File.read('data.json') hash = JSON.parse(json) moneyline_market_ids = hash["eventTypes"].map{|type| type["eventNodes"].select{|event_node| ['US', 'GB'].include?(event_node["event"]["countryCode"]) || event_node["event"]["eventName"].include?(' @ ') }.map{|event| event["marketNodes"].select{|market| market["description"]["marketName"] == 'Moneyline' }.map{|market| market["marketId"] } } }.flatten puts moneyline_market_ids.join(', ') #=&gt; 1.128255531, 1.128272164, 1.128255516, 1.128272159, 1.128278718, 1.128272176, 1.128272174, 1.128272169, 1.128272148, 1.128272146, 1.128255464, 1.128255448, 1.128272157, 1.128272155, 1.128255499, 1.128272153, 1.128255484, 1.128272150, 1.128255748, 1.128272185, 1.128278720, 1.128272183, 1.128272178, 1.128255729, 1.128360712, 1.128255371, 1.128255433, 1.128255418, 1.128255403, 1.128255387 </code></pre> <p>If you want to keep the country code and name information with the id:</p> <pre><code>moneyline_market_ids = hash["eventTypes"].map{|type| type["eventNodes"].map{|event_node| [event_node, event_node["event"]["countryCode"], event_node["event"]["eventName"]] }.select{|_, country, event_name| ['US', 'GB'].include?(country) || event_name.include?(' @ ') }.map{|event, country, event_name| event["marketNodes"].select{|market| market["description"]["marketName"] == 'Moneyline' }.map{|market| [market["marketId"],country,event_name] } } }.flatten(2) require 'pp' pp moneyline_market_ids #=&gt; [["1.128255531", "US", "Philadelphia @ Seattle"], # ["1.128272164", "US", "Arkansas @ Mississippi State"], # ["1.128255516", "US", "New England @ San Francisco"], # ["1.128272159", "US", "Indiana @ Michigan"], # ["1.128278718", "CA", "Edmonton @ Ottawa"], # ["1.128272176", "US", "Arizona State @ Washington"], # ["1.128272174", "US", "Alabama A&amp;M @ Auburn"], # ... </code></pre>
19,178,374
0
Two divs in the same row (in a arrow shaped parent div) with text in one div getting clipped based on the width of second div <p>Here is a <a href="http://jsfiddle.net/SxZGE/" rel="nofollow">jsfiddle link of my issue</a></p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="Right green"&gt; &lt;h2&gt; &lt;div class="number colorV"&gt; 8.123456 &lt;/div&gt; &lt;div id="text"&gt; huh-fjiuetie&lt;/div&gt; &lt;/h2&gt; &lt;div class="Right-after green-after"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Conditions are:</p> <ol> <li>The two <code>div</code>'s inside the <code>h2</code> tag have to be on the same line.</li> <li>The div with the class `.number. must be flexible, its content is variable.</li> <li>The content in the <code>.text</code> div gets clipped based on the content in the number div (widths cannot be fixed as the content in the number div is dynamically generated)</li> <li>The background color is also not fixed (hence we cannot fix background-color to the number div in order to do as required)</li> </ol> <p>Any suggestion would be appreciated.</p>
27,237,732
0
concatenating .txt files into a csv file with a tab delimiter <p>I am trying to concatenate a set of .txt files using windows command line, into a csv file.</p> <p>so i use</p> <pre><code>type *.txt &gt; me_new_file.csv </code></pre> <p>but a the fields of a given row, which is tab delimited, ends up in one column. How do I take advantage of tab separation in the original text file to create a csv file such that fields are aligned in columns correctly, using one or more command lines? I am thinking there might be something like...</p> <pre><code>type *.txt &gt; me_new_file.csv delim= ' ' </code></pre> <p>but haven't been able to find anything yet. Thank You for your help. Would also appreciate if someone could direct me to a related answer. </p>
24,104,158
0
<p>OK..</p> <p>Are you asking for something like that?</p> <pre><code>&lt;div id="sample"&gt; &lt;a class="uploadedfiles" href="www.google.com"&gt;File&lt;/a&gt; &lt;div class="diagram"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>.diagram { width:100px;height:100px;border:1px solid #000000;} </code></pre> <p>JS</p> <pre><code>$(document).ready(function(){ var url = $('.uploadedfiles').attr('href'); $('.diagram').append('&lt;a href="'+url+'"&gt;File&lt;/a&gt;'); $('.uploadedfiles').remove(); }); </code></pre> <p>Fiddle:</p> <p><a href="http://jsfiddle.net/dVLjU/1/" rel="nofollow">Check this</a></p>
19,706,582
0
Keep alive Service in background? <p>For a demo I print a Toast after Evert 10 sec. using <code>Service</code> class. </p> <p>It works fine, I'm getting the Toast after every 10 sec if I am on the Activity when I leave the app, Service is not giving the o/p.</p> <p><strong>But I want to that toast either I'll kill the App or back press</strong> Here is code snippet :</p> <p><em>ServiceDemo.java</em></p> <pre><code>public class ServiceDemo extends Activity { private Handler myHandler = new Handler(); private Runnable drawRunnable = new Runnable() { @Override public void run() { as(); myHandler.postDelayed(this, 10000); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_service_demo); myHandler.postDelayed(drawRunnable, 10000); startService(new Intent(this, MyService.class)); } public void as(){ startService(new Intent(this, MyService.class)); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); } } </code></pre> <p><em>Service.java</em></p> <pre><code>public class MyService extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { Toast.makeText(this, "HOHO Service Created...", Toast.LENGTH_LONG).show(); } @Override public void onDestroy() { } @Override public void onStart(Intent intent, int startid) { Toast.makeText(this, "Service Started...", Toast.LENGTH_LONG).show(); } } </code></pre> <p><strong>Edit 1</strong></p> <pre><code> moveTaskToBack(true); </code></pre> <p>I put this into the onBackPressed method I Service give the o/p if I am not on the screen but When I kill the App, <code>Service not responding</code></p>
2,353,460
0
<p>You can use the ANSI colour codes. Here's an example program:</p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char *argv[]) { printf("%c[1;31mHello, world!\n", 27); // red printf("%c[1;32mHello, world!\n", 27); // green printf("%c[1;33mHello, world!\n", 27); // yellow printf("%c[1;34mHello, world!\n", 27); // blue return 0; } </code></pre> <p>The <code>27</code> is the <code>escape</code> character. You can use <code>\e</code> if you prefer.</p> <p>There are lists of all the codes all over the web. <a href="http://wiki.archlinux.org/index.php/Color_Bash_Prompt" rel="nofollow noreferrer">Here is one</a>.</p>
18,360,869
0
<p>Just put name of the parent class at the end of new, for example</p> <p><code>public class YellowTextView extends TextView ...</code></p> <p>And let IDE do other work like Content Assist, etc.</p>
7,952,983
0
<p>rails integration tests should be written so that the on case tests the one single request - response cycle. we can check redirects. but if you have to do something like</p> <p>get '/something', {:status=>'any_other'}, @header </p> <p>get '/something', {:status=>'ok'}, @header</p> <p>You should write two different cases for this. </p>
2,902,726
0
Trying to set PC clock programmatically just before Daylight Saving Time ends <p>To reproduce :</p> <p>1) Add Microsoft.VisualBasic assembly to your project reference</p> <p>2) Change PC timezone to : (GMT+10:00) Canberra, Melbourne, Sydney . Ensure PC is set to automatically adjust clock for daylight savings time. (For this timezone, daylight savings time ends at 3am on 4 Apr 2010.)</p> <p>3) add following code : </p> <pre><code> public void SetNewDateTime(DateTime dt) { Microsoft.VisualBasic.DateAndTime.Today = dt; // ignores time component Microsoft.VisualBasic.DateAndTime.TimeOfDay = dt; // ignores date component } private void button1_Click(object sender, EventArgs e) { DateTime dt = new DateTime(2010, 4, 5, 5, 0, 0); // XX SetNewDateTime(dt); // XX System.Threading.Thread.Sleep(500); DateTime dt2 = new DateTime(2010, 4, 4, 1, 0, 0); SetNewDateTime(dt2); } </code></pre> <p>4) When button 1 is clicked, the PC clock eventually shows 2am, whereas 1 am was expected. (If code marked at "XX" is removed, the clock sometimes shows the correct time of 1 am).</p> <p>Any idea what is happening ? (Or is there a more reliable way of setting the PC clock from C# code ?)</p> <p>TIA.</p> <p><strong>EDIT</strong> :</p> <p>In response to David M, I tried some modified code :</p> <pre><code> private void button1_Click(object sender, EventArgs e) { DateTime dt = new DateTime(2010, 4, 5, 5,0,0, DateTimeKind.Unspecified); SetNewDateTime(dt); System.Threading.Thread.Sleep(500); // type : 2010-04-04T01:00:00 into textBox1 DateTime dt2 = System.Xml.XmlConvert.ToDateTime(textBox1.Text, System.Xml.XmlDateTimeSerializationMode.Unspecified); SetNewDateTime(dt2); } </code></pre> <p>This gets the DateTime input from a textBox. The result was the same.</p>
29,860,773
0
<p>Replace</p> <pre><code>private ArrayList&lt;Player&gt; playerSummaries = new ArrayList&lt;Player&gt;(); </code></pre> <p>with</p> <pre><code>private ArrayList&lt;Player&gt; players = new ArrayList&lt;Player&gt;(); </code></pre> <p>GSON uses reflection to look up which field it should populate. In your case it is looking up whether you have a field named <code>players</code> which you do not. </p> <p>You also do not need to instantiate the field, GSON will do that for you.</p> <p><strong>EDIT:</strong></p> <p>You also need a wrapper class around your top-level object. So</p> <pre><code>class MyObject { public Response response; } MyObject myObject = gson.fromJson(jsonData, MyObject.class); </code></pre>
13,064,522
0
<p>This is normal behaviour. The Javascript context is specific to a page. If you reload the page, even if some of the HTML markup is the same, its Javascript-set attributes will be reset.</p> <p>You can achieve persistent element highlighting using cookies or server-side code (sessions).</p> <p>You can set a cookie <a href="http://www.electrictoolbox.com/jquery-cookies/" rel="nofollow">like this</a>, if you use the <a href="https://github.com/carhartl/jquery-cookie" rel="nofollow">jquery-cookie plugin</a> :</p> <pre><code> $("#nav-container&gt;li").click(function(){ $(this).addClass('selected') .siblings() .removeClass('selected'); $.cookie("selected", $(this).attr('id'), { path: '/' }) }); $(document).ready(function() { $("#" + $.cookie("selected")).addClass('selected') }); </code></pre> <p>Note: didn't test this code, but it should work. Of course, the user needs to have cookies enabled to use this.</p>
144,649
0
<p>Basically what the developers at Monster.ca are doing, is emulating a select-control using a div-element with scrollable content.</p> <p>Take a look at the <a href="http://www.w3schools.com/Css/pr_pos_overflow.asp" rel="nofollow noreferrer">"overflow" CSS-property</a>.</p>
3,236,030
0
<p>To find people to work with you on a new project, you have :</p> <ul> <li>to go where they are</li> <li>to convince them to work with you</li> </ul> <p>Programming folks can be met directly on IRC. Go to a channel corresponding to the computing language you like, and you'll met great people, knowing your language and wasting their time on IRC. You have then to convince them to stop wasting time saying nothing on IRC and to go with you on a new project.</p> <p>Summer is already well started, so you should choose a small project that can be useful to anybody. People will work with you if the project you propose them is interesting enough for them. Here is an idea of a useful tool that does not exist yet :</p> <p><a href="http://ha.ckers.org/blog/20100613/web-server-log-forensics-app-wanted/" rel="nofollow noreferrer">http://ha.ckers.org/blog/20100613/web-server-log-forensics-app-wanted/</a></p>
19,165,744
0
Access my class returned list collection in code behind <p>I have a list collection in my class library that uses a sql datareader to returns a list of family details</p> <pre><code>public class Dataops { public List&lt;Details&gt; getFamilyMembers(int id) { some of the database code.. List&lt;Details&gt; fammemdetails = new List&lt;Details&gt;(); Details fammember; while (reader.Read()) { fammemdetails = new Details(( reader.GetString(reader.GetOrdinal("PHOTO"))); fammemdetails.add(fammember); } return fammemdetails; } } </code></pre> <p>So i reference the dll to my project and would like to bind an image to one of my datareader values.</p> <p>MyProject</p> <pre><code>DataOps ops = new DataOps(); myimage.ImageUrl = ??? (how do i access the list collections return image value here? </code></pre> <p>I am able to bind a datasource to the entire method like so</p> <pre><code>dropdownlistFamily.DataSource = mdb.GetFamilyMembers(id); </code></pre> <p>But cant figure out how to just grab a single value from there</p>
37,857,783
0
Logging in via modal using AJAX and PHP <p>to be fair, I'm fairly new in the AJAX area (newbie to be more precise) and i think that i took quite a large bite entering that field.So, I'm struggling for a several days now trying to implement AJAX with my PHP script. Before you flag this question as duplicate please consider that I've tried every posted question from this site and not one solution pop out. That being said, here is what I want to achieve: I want to show some sort of message after PHP script was successful or unsuccessful, something like picture below:</p> <p><a href="https://i.stack.imgur.com/z9lza.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z9lza.png" alt="enter image description here"></a></p> <p>If there was successful show me msg, and redirect me (after 2 sec) to admin site, and if not show me error!</p> <p>So, here is code for modal form:</p> <pre><code>&lt;div class="modal fade" id="test" role="dialog"&gt; &lt;div class="modal-dialog"&gt; &lt;!-- Modal content--&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt; &lt;h4 class="modal-title"&gt;test&lt;/h4&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;form id="myform" method="POST" role="form"&gt; &lt;div class="form-group"&gt; &lt;label for="user"&gt;User:&lt;/label&gt; &lt;input name="user" type="text" class="form-control" placeholder="Unesi korisnika"&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="pass"&gt;Password:&lt;/label&gt; &lt;input name="pass" type="password" class="form-control" placeholder="Unesi lozinku"&gt; &lt;/div&gt; &lt;div id="error"&gt; &lt;div class="alert alert-danger"&gt; &lt;strong&gt;Error, try again!&lt;/strong&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="thanks"&gt; &lt;div class="alert alert-success"&gt; &lt;strong&gt;Logging in..&lt;/strong&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button type="button" class="btn btn-default" id="reset" data-dismiss="modal"&gt;Close&lt;/button&gt; &lt;button type="submit" class="btn btn-success" id="submitForm"&gt;Login!&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p></p> <p>Here is my javascript block of code: Here I tried loging in using my php script but nothing happens, it's only showing me <strong>#thanks</strong> div when I start typing</p> <pre><code>$('#test').on('hidden.bs.modal', function () { $(this).removeData('bs.modal'); $(':input', '#myform').val(""); }); $("#thanks").hide(); $("#error").hide(); $("#myform").click(function (e) { var url = "login.php"; $.ajax({ type: "POST", url: url, data: $('#myform').serialize(), success: $("#thanks").show(), error: function () { $("#error").show(); } }); e.preventDefault(); }); </code></pre> <p>Here is my PHP <strong>doLogin()</strong> function inside myAuth class:</p> <pre><code>static function doLogin() { if( !empty($_POST['user']) &amp;&amp; !empty($_POST['pass']) ) { if(!session_id()) session_start(); // check and retrive user with sended pass $user = self::_fetchUserWithPassDB(); // if user found log in if($user) { // security $token = md5(rand(100000,999999)); // save token in session $_SESSION["auth"] = $token; // save user in session $_SESSION["user"] = $user[0]["user"]; // save role in session $_SESSION["role"] = $user[0]["role"]; // postavi validity and token in cookie, session in base self::_setCookieSessionDBTokenValidity(); // redirect on admin.php header( "refresh:2;url=admin.php" ); } else { header('Location:index.php'); } if(!$user) { header("refresh:1;url=index.php" ); } } // od if POST </code></pre> <p>and finally here is my <strong>login.php</strong></p> <pre><code>&lt;?php // login.php require_once('init.php'); myAuth::doLogin(); ?&gt; </code></pre> <p>Is it problem in in <strong>doLogin</strong>() function or is there problem with javascript, I really don't know? If there is any help, when I use this script without AJAX it works normal without any problems.</p> <p>Like this:</p> <pre><code>&lt;form action="login.php" id="myform" method="POST" role="form"&gt; ....&lt;!--rest of the modal form--&gt; </code></pre> <h2><strong>UPDATE 1.</strong></h2> <p>I've tried something like this, but it does not work. Also, I've removed redirect from doLogin () and added in AJAX call but without any luck</p> <pre><code>$("#myform").submit(function(e) { var url = "login.php"; $.ajax({ type: "POST", url: url, data: $('#myform').serialize(), success: function() { $("#thanks").show(), setTimeout(function() { window.location.href = "admin.php"; }, 2000); }, error: function() { $("#error").show(); } }); e.preventDefault(); }); </code></pre>
36,210,994
0
<p>According to node-webkit's wiki, you can <a href="https://github.com/nwjs/nw.js/wiki/file-dialogs#how-to-open-a-file-dialog" rel="nofollow">open a dialog programmatically</a> by simulating a click on a <a href="https://github.com/nwjs/nw.js/wiki/file-dialogs#save-file" rel="nofollow">specially configured html input field</a>.</p> <p>So for example you would insert</p> <pre class="lang-html prettyprint-override"><code>&lt;input type="file" id="fileDialog" nwsaveas /&gt; &lt;!-- or specify a default filename: --&gt; &lt;input type="file" id="fileDialog" nwsaveas="myfile.txt" /&gt; </code></pre> <p>and use something like this to optionally programmatically trigger the dialog and get the entered path:</p> <pre class="lang-javascript prettyprint-override"><code>function chooseFile(name) { var chooser = document.querySelector(name); chooser.addEventListener("change", function(evt) { console.log(this.value); }, false); chooser.click(); } chooseFile('#fileDialog'); </code></pre>
13,802,625
0
<p>The problem seems to lie in that all your "content-pad" classes doesnt have the width of the page.</p> <p>As soon as i give it a width it works fine.</p>
20,543,929
0
<p>Finally am able to find the actual cause of above issue.</p> <p>I am using the gem <a href="https://github.com/wildbit/postmark-rails" rel="nofollow">postmark-rails</a>, previously postmark was not supporting the email-attachments, so recently they had enhanced gem to support attachments and unfortunately i was using the old version of it, so i need to update gem version to latest as they have mentioned in one of their issues: <a href="https://github.com/wildbit/postmark-rails/issues/25" rel="nofollow">attachment-issue</a></p> <p>also i was trying to send url of file saved on S3, so instead of that i need to read that file from url and then send it as attachment</p> <pre><code> require "open-uri" def send_refer_pt_request(params, attachment) if attachment.present? mime_type = MIME::Types.type_for(attachment).first url_data = open(attachment).read() attachments["#{attachment.split('/').last}"] = { mime_type: mime_type, content: url_data } end mail( to: &lt;some_email&gt;, subject: "Refer Request", tag: "refer_request") end </code></pre>
19,224,214
0
<p>You are using CodeIgniter so why are you trying to load anything directly?</p> <p>Call the page as you would normally and add a controller method to do what is required in this situation. So:</p> <p>Assuming you have a controller called 'Search' create a method called something relevant lets say 'special_case' and call that with any parameters it requires like so</p> <pre><code>&lt;?php class Search extends Controller { function index() { // I assume this is what it is currently doing } function special_case() { // Make this do whatever is required in this case. } </code></pre> <p>Then call it from your Javascript using the standard CodeIgniter controller/method/param1/param2 ...... mechanism.</p>
22,845,097
0
<p>Ok this works in SqlServer not sure about MySQL, but perhaps it will help you get on the right track.</p> <pre><code>Select Top 1 Parent.Title, Descriptions.Description From Reviews Parent inner join Reviews Child on Parent.Id = Child.Parent inner join Descriptions on Child.Id = Descriptions.review_id Where Parent.Id = 1 Order By Child.[Views] desc </code></pre> <p>Fiddle: <a href="http://sqlfiddle.com/#!6/89a76/1" rel="nofollow">http://sqlfiddle.com/#!6/89a76/1</a></p> <p>Psuedo Code without Table Names as Requested</p> <blockquote> <pre><code>Select Take the Top 1 Parent.Title, Descriptions.Description From Table1 (The Parent) inner join Table1 Back onto itself (The Child) linking The parents Id to the Child's Parent inner join Table2 onto the Child Linking Child's Id to the Descriptions' review_id Where the parents Id is 1 (or the Passed in value) Order By The number of views the child had desc </code></pre> </blockquote>
34,455,880
0
<p>in WordPress you need to specify an <code>action</code>. This should work:</p> <pre><code>action="&lt;?php echo get_permalink(); ?&gt; </code></pre>
23,952,149
0
DTMF Tone Detection during incoming oncall in Blackberrry java <p>I would like to know whether we could receive the DTMF tones in blackberry java.Suppose,i am getting a call,and once i accept the call,is it possible to detect the keys that the other person is pressing during our call. I want to know any possiblity is available in bb java.</p>
31,068,147
0
<p>Sounds like an issue with the way iTunes connect is set up, check you leaderboard setting and make sure 'Score Submission Type' is set to 'Best Score' and 'Sort Order' is set to 'High To Low'</p>
8,492,014
0
<p>In WordPress 3.2.1 the capability is <code>edit_theme_options</code>. <code>switch_themes</code> will do nothing more than allow you to activate a different theme from the available ones.</p>
40,916
0
<p>Just an idea, but couldn't you use Regex to quickly strip out the characters and then compare against that like @Matt Hamilton suggested?</p> <p>Maybe even set up a view (not sure of mysql on views) that would hold all phone numbers stripped by regex to a plain phone number?</p>
17,276,580
0
looping through XML file using VB.NET <p>I am having a problem processing an XMl file. I want to loop through (using VB.NET) the file and extract all the values of the OrderID element. </p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;ListOrdersResponse xmlns="https://xxx.xxxxxx.com/Orders/999uuu777"&gt; &lt;ListOrdersResult&gt; &lt;NextToken&gt;XXXXXXXXXX&lt;/NextToken&gt; &lt;Orders&gt; &lt;Order&gt; &lt;ShipmentServiceLevelCategory&gt;Standard&lt;/ShipmentServiceLevelCategory&gt; &lt;OrderId&gt;ooooooooo&lt;/OrderId&gt; &lt;/Order&gt; &lt;Order&gt; &lt;ShipmentServiceLevelCategory&gt;Standard&lt;/ShipmentServiceLevelCategory&gt; &lt;OrderId&gt;ujuujujuj&lt;/OrderId&gt; &lt;/Order&gt; &lt;/Orders&gt; &lt;CreatedBefore&gt;2013-06-19T09:10:47Z&lt;/CreatedBefore&gt; &lt;/ListOrdersResult&gt; &lt;ResponseMetadata&gt; &lt;RequestId&gt;8e34f7d9-3af7-4490-801b-cccc7777yu&lt;/RequestId&gt; &lt;/ResponseMetadata&gt; &lt;/ListOrdersResponse&gt; </code></pre> <p>Here is the code I am trying but it does not loop through each order</p> <pre class="lang-vb prettyprint-override"><code>Dim doc As New XmlDocument() doc.Load(file) Dim nodelist As XmlNodeList = doc.SelectNodes(".//Orders/Order") For Each node As XmlElement In nodelist console.writeline(node.SelectSingleNode("OrderID").InnerText) Next </code></pre> <p>Any help would be gratefully appreciated.</p>
4,380,988
0
XMl Schema: Unique key values within parent <p>I have the following XML:</p> <pre><code> &lt;enumTypes xmlns="tempURI"&gt; &lt;enumType id="1"&gt; &lt;enumValue id="1" value="Item1"/&gt; &lt;enumValue id="2" value="Item2"/&gt; &lt;enumValue id="3" value="Item3"/&gt; &lt;/enumType&gt; &lt;enumType id="2"&gt; &lt;enumValue id="1" value="Item1"/&gt; &lt;enumValue id="2" value="Item2"/&gt; &lt;/enumType&gt; &lt;/enumTypes&gt; </code></pre> <p>I also have the following schema:</p> <pre><code> &lt;xs:element name="enumTypes"&gt; &lt;xs:complexType&gt; &lt;xs:sequence minOccurs="1" maxOccurs="unbounded"&gt; &lt;xs:element name="enumType"&gt; &lt;xs:complexType&gt; &lt;xs:sequence minOccurs="1" maxOccurs="unbounded"&gt; &lt;xs:element name="enumValue"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="id" type="xs:string" use="required"/&gt; &lt;xs:attribute name="value" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="id" type="xs:string"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:key name="enumTypeKey"&gt; &lt;xs:selector xpath="enumTypes/enumType"/&gt; &lt;xs:field xpath="@id"/&gt; &lt;/xs:key&gt; &lt;xs:key name="enumValueKey"&gt; &lt;xs:selector xpath="enumTypes/enumType/enumValue"/&gt; &lt;xs:field xpath="@id"/&gt; &lt;/xs:key&gt; </code></pre> <p>I'm trying to force the enumValue ID's to be unique WITHIN a enumType, but so far I can only get it to force them to be unique across ALL enumTypes.</p> <p>I'm guessing there's a problem with my selector XPath but I can't seem to get it sorted out.</p> <p>Any help would be appreciated!</p>
17,634,286
0
Detect which layout is in use in an activity with two layouts <p>I have an activity called MainActivity that has two layouts.The previous activity has two buttons to choose which layout to be set.I need the button in MainActivity to act differently according to the layout in use, This is my code:</p> <pre><code> public class MainActivity extends Activity implements OnClickListener { Button shoot; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); if (extras != null) { int btnNumber = extras.getInt("button"); switch(btnNumber) { case 1 : setContentView(R.layout.first_layout); break; case 2 : setContentView(R.layout.second_layout); break; } } shoot=(Button)findViewById(R.id.button1); shoot.setOnClickListener(this); public void onClick(View arg0) { // TODO Auto-generated method stub switch(arg0.getId()) { case R.id.button1: // WHAT SHOULD THE CODE BE HERE break; } } </code></pre>
3,894,791
0
<p>jQueryUI extends the animate class for this reason specifically. You can leave off the original parameter to append a new class to your object.</p> <pre><code>$(".class1").switchClass("", "class2", 1000); </code></pre> <p><a href="http://jsfiddle.net/m7dAQ/">Sample here.</a></p>
30,193,477
0
<pre><code>&lt;meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"&gt; </code></pre>
10,728,042
1
Break multiple lines in a text file into a list of lists <p>I am working with a text file ex:</p> <pre><code>blahblahblahblahblahblahblah blahblahblahblahblahblahblah start important1a important1b important2a important2b end blahblahblahblahblahblahblah </code></pre> <p>What I want is to get an output like</p> <pre><code>["'important1a', 'important1b'", "'important2a', 'important2b'"] </code></pre> <p>Where each important line is split into individual elements, but they are grouped together by line in one list.</p> <p>I have gotten close with this:</p> <pre><code>import shlex useful = [] with open('test.txt', 'r') as myfile: for line in myfile: if "start" in line: break for line in myfile: if "end" in line: break useful.append(line) data = "".join(useful) split_data = shlex.split(data) print split_data </code></pre> <p>This outputs:</p> <pre><code>['important1a', 'important1b', 'important2a', 'important2b'] </code></pre> <p>There is no distinction between lines.</p> <p>How can I modify this to distinguish each line? Thanks!</p>
5,388,506
0
<p>How are you hosting your service?</p> <p>If your service is hosted in IIS, it is possible that the application was recycled between the 2 calls. In this case the app domain is recreated and the static members loose their values.</p>
19,985,933
0
<p>Hmmm... What happens if you move the line where you assign to <code>scrn(CONV_INTEGER(X),CONV_INTEGER(Y)) &lt;= "00111000" when X = 1 else ...</code> to somewhere inside your process?</p> <p>Also there is no need to use binary literals in your code (e.g., <code>if (X = "1100100000")</code>). Just use integer literals, or decimal bit-string literals. Better yet, define all your numeric values as integers or naturals. As a bonus, your code will be cleaner because you won't need all those conversion functions.</p>
3,642,269
0
Reusable Page_PreRender function in asp.net <p>I have a function which sets my linkbutton as the default button for a panel.</p> <pre><code>protected void Page_PreRender(object sender, EventArgs e) { string addClickFunctionScript = @"function addClickFunction(id) { var b = document.getElementById(id); if (b &amp;&amp; typeof(b.click) == 'undefined') b.click = function() { var result = true; if (b.onclick) result = b.onclick(); if (typeof(result) == 'undefined' || result) eval(b.getAttribute('href')); } };"; string clickScript = String.Format("addClickFunction('{0}');", lbHello.ClientID); Page.ClientScript.RegisterStartupScript(this.GetType(), "addClickFunctionScript", addClickFunctionScript, true); Page.ClientScript.RegisterStartupScript(this.GetType(), "click_" + lbHello.ClientID, clickScript, true); } </code></pre> <p>This works fine. How to make this reusable to all my pages of my application. One page can have multiple linkbuttons and multiple panels.... Any suggestion...</p>
36,586,376
0
How can I pass the results returned by a method from controller to the view <p>I want to use the results returned by a method (cursor in my case) from the controller in my view, in order to draw a graph from the data returned. I wrote a piece of code but I have not found how to pass data to the view. </p> <pre><code> //controller [HttpPost] public async System.Threading.Tasks.Task&lt;ActionResult&gt; drawgraph(Inputmodel m) { List&lt;Client&gt; client = new List&lt;Client&gt;(); var collection = db.GetCollection&lt;Client&gt;("Client"); var builder = Builders&lt;Client&gt;.Filter; var beginDate = Convert.ToDateTime(m.date_begin).Date; var endDate = Convert.ToDateTime(m.date_end).Date; var filter = builder.Gte("date", beginDate) &amp; builder.Lt("date", endDate.AddDays(1)) &amp; builder.Eq("field2", m.taux); var cursor = await collection.DistinctAsync&lt;double&gt;("field2",filter); return View(cursor); } </code></pre> <hr> <pre><code>//view @{ var myChart = new Chart(width:600,height: 400) .AddTitle("graphique") .AddSeries(chartType: "Line") .DataBindTable(dataSource: cursor, xField: "date", yField:"field2") //here I want to use the returnet result by drawgraph in the controller .Write(); } </code></pre>
29,663,006
0
<p>Registry cleaner (System Mechanic 14.5) did it to me (caused the Oracle listener service to be removed from Windows 7). Still had the listener.ora read somewhere else that using lsntrctl start will fix the problem in this circumstance (where there is a valid listener.ora but no service) by adding the service back in. </p>
5,780,014
0
<blockquote> <p>SilentManager.mAlarmManager.cancel(SilentManager.pi); is the thing that keeps crashing if you leave the app and come back.</p> </blockquote> <p>Use <code>adb logcat</code>, DDMS, or the DDMS perspective in Eclipse to examine LogCat and look at the stack trace associated with your "crash". Most likely, you will find that it is a <code>NullPointerException</code>, because your process has been terminated and therefore your static <code>pi</code> data member is <code>null</code>.</p> <p>If this is your error, the solution is:</p> <p>Step #1: Get rid of the <code>pi</code> static data member.</p> <p>Step #2: When you <code>cancel()</code>, create a <code>PendingIntent</code> on an equivalent <code>Intent</code> to the one you used to create the alarm in the first place.</p>
30,599,051
0
<p><strong>Answering my own question.</strong></p> <p>Actually, I followed the idea of sbabbi using a list of intervals coming from <code>boost/numeric/interval</code>, representing the union of intervals.</p> <p>Here is an example :</p> <pre><code>typedef boost::numeric::interval_lib::rounded_math&lt;double&gt; RoundedPolicy; typedef boost::numeric::interval_lib::checking_base&lt;double&gt; CheckingPolicy; typedef boost::numeric::interval_lib::policies&lt;RoundedPolicy,CheckingPolicy&gt; IntervalPolicies; typedef boost::numeric::interval&lt;double,IntervalPolicies&gt; interval; //... bool is_interval_empty(const interval&amp; inter) { return boost::numeric::empty(inter); } void restrict(interval&amp; domain, const interval&amp; inter) { for(std::list&lt;interval&gt;::iterator it = domain.begin(); it != domain.end(); ++it) *it = boost::numeric::intersect(*it, inter); domain.remove_if(is_interval_empty); } void restrict(interval&amp; domain, const interval&amp; inter1, const interval&amp; inter2) { for(std::list&lt;interval&gt;::iterator it = domain.begin(); it != domain.end(); ++it) { domain.push_front(boost::numeric::intersect(*it, inter1)); *it = boost::numeric::intersect(*it, inter2); } domain.remove_if(is_interval_empty); } //... std::list&lt;interval&gt; domain; for(unsigned long int i = 0; i &lt; constraints.size(); ++i) { if(constraints[i].is_lower_bound()) { interval restriction(constraints[i].get_lower_bound(), std::numeric_limits&lt;double&gt;::infinity()); restrict(domain, restriction); } else if(constraints[i].is_upper_bound()) { interval restriction(-std::numeric_limits&lt;double&gt;::infinity(), constraints[i].get_upper_bound()); restrict(domain, restriction); } else if(constraints[i].is_forbidden_range()) { interval restriction1(-std::numeric_limits&lt;double&gt;::infinity(), constraints[i].get_lower_bound()); interval restriction2(constraints[i].get_upper_bound(), std::numeric_limits&lt;double&gt;::infinity()); restrict(domain, restriction1, restriction2); } } if(domain.size() == 0) std::cout &lt;&lt; "empty domain" &lt;&lt; std::endl; else std::cout &lt;&lt; "the domain exists" &lt;&lt; std::endl; </code></pre>
8,772,229
0
<p>Fixed, here's the solution <a href="http://stackoverflow.com/a/8550870/106616">http://stackoverflow.com/a/8550870/106616</a></p>
40,177,004
0
<p>Since the Anniversary update, it is now possible to run background tasks from within the same process as the main app. Both the background task and the main app share the same memory. See <a href="https://msdn.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-a-singleprocess-background-task" rel="nofollow">Create and register a single-process background task</a> for information on how to do this.</p> <p>If you want to keep the background task in a separate process to the main app, then you can use a named <a href="https://msdn.microsoft.com/en-us/library/41acw8ct.aspx" rel="nofollow">EventWaitHandle</a>:</p> <p><strong>Foreground app code</strong></p> <pre><code>// Keep this handle alive for the duration of your app eventHandle = new EventWaitHandle(true, EventResetMode.ManualReset, "MyApp"); </code></pre> <p><strong>Background app code</strong></p> <pre><code>EventWaitHandle handle; if (EventWaitHandle.TryOpenExisting("MyApp", out handle)) { // Foreground app is running } else { // Foreground app is not running } </code></pre> <p>You need to be mindful of possible race conditions here (if that is a problem for your situation). You could probably make better use of the EventWaitHandle to synchronize whatever file task it is both processes need to do.</p>
1,651,679
0
<p>I'm going to hazard a guess that your statement that the code is "slightly modified to work" means that this code:</p> <pre><code>newlistitem.Value = options[j][valuefield].ToString() + ((options[j]["pdprice"].ToString().Length &gt; 0 ) ? "/" + options[j]["pdprice"].ToString() : "" ); </code></pre> <p>actually looked like this:</p> <pre><code>newlistitem.Value = options[j][valuefield].ToString() + options[j]["pdprice"].ToString().Length &gt; 0 ? "/" + options[j]["pdprice"].ToString() : ""; </code></pre> <p>(note the missing parenthesis)</p> <p>The reason that <em>this</em> code will produce this error is that due to operator precedence, what will get evaluated is this:</p> <pre><code>String a = options[j][valuefield].ToString(); Int32 b = options[j]["pdprice"].ToString().Length; String c = a + b; Boolean d = c &gt; 0; String e = "/" + options[j]["pdprice"].ToString(); String f = ""; newlistitem.value = d ? e : f; </code></pre> <p>With this way of looking at it, <code>a+b</code> will produce a new string, since adding something to a string will convert that something to a string for concatenation. Basically, "xyz" + 3 gives "xyz3".</p> <p>By adding the parenthesis, your "slight modification", you've essentially rewritten the code to do this:</p> <pre><code>String a = options[j][valuefield].ToString(); String b = options[j]["pdprice"].ToString().Length; Boolean c = b &gt; 0; &lt;-- this is different String d = "/" + options[j]["pdprice"].ToString(); String e = ""; String f = c ? d : e; String g = a + f; &lt;-- and this newlistitem.value = g; </code></pre> <p>Notice the difference between <code>d</code> in the first code and <code>c</code> in the second code. You've moved the concatenation of the string out where it belongs, together with the other strings.</p> <p>So your slight modification works since it is the correct way of doing it, <strong>if you want to keep those expressions</strong>.</p> <p><a href="http://stackoverflow.com/questions/1651490/in-c-checking-string-length-greater-than-zero-produces-error/1651509#1651509">The accepted answer</a> is a much better alternative. My goal was to give you an explanation as to the reason of the exception.</p>
27,722,636
0
node.js mongodb projection ignored when there is a criterion <p>I am writing a node.js application using express, mongodb, and monk. </p> <p>When I do a find with criteria only or with projections only, I get the expected result, but when I do a find with both, the full documents are returned, i.e., the projection is not performed. My code looks like this: </p> <pre><code>var collection = db.get('myDB'); collection.find({field1: "value"},{field2: 1, _id: 0},function(e,docs) { ...do stuff with docs... }); </code></pre> <p>It returns not just <code>field2</code> but all fields of all the docs matching the criterion on <code>field1</code>. I can get <code>field2</code> from this, but I don't like the inefficiency of it.</p> <p>Is there a way to use both criteria and projections?</p>
1,664,334
0
C Network Programming - Winsock <p>I have been learning C over the last two weeks, managed to get my head around pointers, arrays and structures.</p> <p>I am looking to do a bit of socket programming on windows and was wondering if anyone has any websites with tutorials and examples or suggest books that teach network programming with winsock?</p> <p>I have tried looking for some but all seem to be aimed at towards linux/unix.</p> <p>Cheers</p> <p>Eef</p>
8,764,327
0
<p>This is in addition to my comments: </p> <p>Check out the SDK listed in the link I gave with the comments. They have a sample RoR app laid out which should tell you pretty much exactly how to do each kind of adaptive payment with Rails. Just beware that there are <b>many</b> errors in this application. Look at James' answer on this question to fix them:</p> <p><a href="http://stackoverflow.com/questions/2717735/is-anyone-using-paypals-adaptive-payments-api-with-ruby">Is anyone using Paypal&#39;s Adaptive Payments API with Ruby?</a></p> <p>Also, thanks for the heads up on the paypal_adaptive gem.</p> <p>EDIT: Here's the SDK link just in case. <a href="https://www.x.com/developers/paypal/documentation-tools/sdk" rel="nofollow">https://www.x.com/developers/paypal/documentation-tools/sdk</a></p>
3,130,941
0
j2me code for blackberry application to display battery level <p>How can I make a Blackberry application display the battery level using J2ME?</p>
712,004
0
Does Java have methods to get the various byte order marks? <p>I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like:</p> <pre><code>byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark(); </code></pre> <p>Where <code>CharEncoding</code> comes from Apache Commons.</p>
2,483,795
0
<p>The <a href="http://en.wikipedia.org/wiki/Canvas_element" rel="nofollow noreferrer">Canvas element</a> is essentially a drawing canvas that can be painted on programmatically; a sort of scriptable bitmap drawing tool for the web.</p> <p>I suppose the "amazing" thing about it, apart from the fact that we can now all create web-based MS Paint clones with ease, is that you have a much richer, completely free-form area for creating complex graphics client-side and on-the-fly. You can draw pretty graphs, or do things with photos. Allegedly, you can also do animation!</p> <p><a href="https://developer.mozilla.org/en/Canvas_tutorial" rel="nofollow noreferrer">Mozilla's Developer Center has a reasonable tutorial</a> if you want to try it out.</p>
1,965,618
0
<p>You should take it as more of a symptom than part of the actual problem when you are stuck in system all the time. </p> <p>Memory fragmentation and paging out is the usual suspect, but it could be a myriad of things.</p> <p>In my experience performance problems are seldom something obvious like you are calling something specifically. Optimizing like commonly suggested is usually useless at a really low level. It catches things that amount to bugs that are correct but usually unintended like allocating something and deleting it over and over but for things like this you often need to have a deep understanding of everything happening to figure out exactly where the issue is (but like I said, surprisingly often it's memory management related if you are stuck in system calls a lot).</p>
3,637,786
0
<p>By default maven checks dependencies in your local repository first, then on external repositories. The only case which will make maven check external repositories, is the use of snapshots.</p> <p>If you use snapshots, you can use the <code>&lt;updatePolicy&gt;</code> markup to change when your external repository will be checked.</p> <p>If you wan to work in offline mode you can either set a temporary offline option on your mvn command with the "-o" option, or you can set it up in your "~/.m2/settings.xml" with <code>&lt;offline&gt;true&lt;/offline&gt;</code>.</p> <hr> <p>Before you do so, remember to use the <code>dependecy:go-offline</code> mojo to download your dependency once before you really activate the offline mode.</p> <hr> <p><strong>Resources :</strong></p> <ul> <li><a href="http://maven.apache.org/settings.html#Repositories" rel="nofollow noreferrer">Maven - Repositories</a></li> <li><a href="http://maven.apache.org/settings.html#Simple_Values" rel="nofollow noreferrer">Maven - simple settings values</a></li> <li><a href="http://maven.apache.org/plugins/maven-dependency-plugin/go-offline-mojo.html" rel="nofollow noreferrer">Maven - dependecy:go-offline</a></li> </ul>
21,285,838
0
<p>May Issue: You need to call jquery functionality after <code>ready event fired</code> from JQuery. size and maxlength it works as we expected.maxlength how many char user can type and Size determine visible width, in characters.</p> <pre><code> &lt;h2&gt;Aufgaben:&lt;/h2&gt; &lt;div data-role="fieldcontain"&gt; &lt;ul id="exercise-list" data-role="listview" data-inset="true"&gt; &lt;li id="addExercise"&gt;Aufgabenname: &lt;input type="text" name="aufgabenname" id="aufgabenname" size="20" maxlength="20"&gt;&lt;/input&gt; Maximalpunktzahl: &lt;input type="text" name="maxPunkte" id="maxPunkte" size="2" maxlength="2"&gt;&lt;/input&gt;&lt;div style="float:right;"&gt;&lt;button id="add" data-icon="plus" data-iconpos="notext"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;script&gt; $(document).ready(function() { $("#add").on("click", function() { var aufgabenname = $("#aufgabenname").val(); var maxPunkte = $("#maxPunkte").val(); $("#addExercise").prepend("&lt;li&gt;Aufgabe: "+aufgabenname+", Maximalpunktzahl: "+maxPunkte+" &lt;div style=\"float:right;\"&gt;&lt;button class=\"delete\" data-icon=\"delete\" data-iconpos=\"notext\"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/li&gt;"); }); }); &lt;/script&gt; </code></pre> <p><a href="http://jsfiddle.net/ehyZL/" rel="nofollow">Fiddle Demo</a></p>
39,086,782
0
Creating Linked List dynamically in C <p>I'm trying to create a linked list dynamically in <code>c</code> using structures and print it. But my below code is throwing runtime error can anybody tell me why I am getting this error. Here is my code.</p> <pre><code>#include &lt;stdio.h&gt; struct cnode { int value; struct cnode *next; }; void print_list(struct cnode* start) { while(start-&gt;next != NULL) { printf("%d-&gt;", start-&gt;value); start = start-&gt;next; } } int main(void) { int i,n,val; //List length scanf("%d", &amp;n); //Head struct cnode* start; scanf("%d", &amp;val); start-&gt;value = val; struct cnode* temp = start; for (i=1; i&lt;=n-1; i++) { struct cnode* node; scanf("%d", &amp;val); node-&gt;value = val; temp-&gt;next = node; temp = node; } temp-&gt;next = NULL; print_list(start); return 0; } </code></pre>
18,919,079
0
<p>As an additional idea, the problem of GarethD's method is, that it requires more or an equal number of rows in the second table as in the first table.</p> <p>So you can just do a cross join of the second table with the first one, and limit the results to the number of rows in the first table.</p> <pre><code>WITH PatientCTE AS ( SELECT PatientID ,pat_FirstName ,pat_LastName ,pat_StreetName ,pat_PostalCode ,pat_City ,pat_DateOfBirth ,rn = ROW_NUMBER() OVER(ORDER BY NEWID()) FROM Patients ) , SampleData AS ( SELECT TOP (SELECT COUNT(*) FROM PatientCTE ) GivenName ,SurName ,StreetAddress ,ZipCode ,City ,Birthday ,rn = ROW_NUMBER() OVER(ORDER BY NEWID()) FROM FakeNameGenerator CROSS JOIN PatientCTE ) UPDATE p SET p.pat_FirstName = fn.GivenName ,p.pat_LastName = fn.SurName ,p.pat_StreetName = fn.StreetAddress ,p.pat_PostalCode = fn.ZipCode ,p.pat_City = fn.City ,p.pat_DateOfBirth = fn.BirthDay FROM PatientCTE AS p INNER JOIN SampleData AS fn ON fn.rn = p.rn </code></pre>
18,025,599
0
How to reset a variable <p>I'm not sure if I'm missing something obvious or whether this is actually something I don't know how to do, but I'd like to be able to reset some variables (<code>integers</code>). I have a method that increments them, and they're saved in <code>SharedPreferences</code>. I'd like to be able to reset these to 0 on a button click.</p> <p>I can clear <code>SharedPreferences</code> using the clear(); command, but the ints stay the same so as soon as they are called again they are back to what they were before the reset. I've also tried setting them equal to 0, but then I can't increment them any more. Is there a way to just reset or delete variables?</p> <p>Or, if that's not possible/too difficult, is there another way I can completely reset these ints?</p> <p>Thanks</p> <p>This is part of the incrementing code. This works. I can also clear <code>SharedPreferences</code>; that part is fine too. <em>The only part that doesn't work is resetting the int to 0, but keeping it incrementable</em>.</p> <pre><code>Button PlusOneButton = ((Button)findViewById(R.id.plusonebutton)); PlusOneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { intName++; }}); </code></pre> <p>EDIT: the final code that works</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class ThirdScreenActivity extends Activity { public int myIntPlusOne; public static final String PREFS = "MyPrefsFile"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen2); SharedPreferences sharedPrefs = getApplicationContext().getSharedPreferences("PREFS", 0); myIntPlusOne = sharedPrefs.getInt("myIntPlusOneSaved", 0); if ("ListView Item 1".equals(position)) { myIntPlusOne = sharedPrefs.getInt("myIntPlusOneSaved", 0); TextView PlusOne = ((TextView)findViewById(R.id.plusonetextview)); PlusOne.setText(String.valueOf(myIntPlusOne)); Button PlusOneButton = ((Button)findViewById(R.id.plusonebutton)); PlusOneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { myIntPlusOne++; TextView PlusOne = ((TextView)findViewById(R.id.plusonetextview)); PlusOne.setText((myIntPlusOne)+""); SharedPreferences sharedPrefs = getApplicationContext().getSharedPreferences("PREFS", 0); Editor editor = sharedPrefs.edit(); editor.putInt("myIntPlusOneSaved", myIntPlusOne); editor.commit(); } }); } else if... } Button btnClear = (Button) findViewById(R.id.clearbtn); btnClear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myIntPlusOne=0; TextView PlusOne = ((TextView)findViewById(R.id.plusonetextview)); PlusOne.setText("0"); } }); } public void onPause() { super.onPause(); SharedPreferences sharedPrefs = getApplicationContext().getSharedPreferences("PREFS", 0); Editor editor = sharedPrefs.edit(); editor.putInt("myIntPlusOneSaved", myIntPlusOne); editor.commit(); } } </code></pre>
29,270,122
0
<p>This function could probably be improved upon. Tip of the hat to @thelatemail.</p> <pre><code>lm.3Trans = function(y, x1, x2, transformations = c(log,sqrt,pwer)){ pwer = function(x, p = 2) poly(x,p) res = lapply(transformations, function(f) lm(y ~ f(x1) + x2)) res } </code></pre> <p>This will output your models into a list to which you could then do something like:</p> <pre><code>lapply(lm.3Trans(y,x,x1), summary) </code></pre> <p>To get more detailed summaries</p> <p>It might be worth expanding this function to take a formula, and perhaps another arguement to identify which predictor should be transformed. Please let me know if that is useful. </p>
25,494,742
0
<p>I experienced the same problem.</p> <p>Downloaded and installed SQL Server 2012 SP2 and that seemed to have fixed the problem.</p> <p>Hope this helps!!</p>
7,359,193
0
<p>For Ubuntu packages, it may not be the latest version for 2 reasons:</p> <ol> <li><strong>dependencies availability</strong>: the dependencies version required is not available in Ubuntu yet</li> <li><strong>stability</strong>: latest version may not be the most stable version, therefore the most stable version is picked by Ubuntu</li> </ol> <p>To manually update certain package to your desired version ( either upgrade / downgrade ), remove the version that comes along with Ubuntu, and download from developer. Follow the instructions to install the package. However, through this method, the package cannot update through <code>apt-get</code>.</p>
17,848,428
0
<p>The error about the <code>/</code> operator usually indicates that PowerShell is not treating the command as a command line; prefix a <code>&amp;</code> to force it to do so. Note you'll also need to use <code>.\cspack</code> if <code>cspack</code> is in the current directory. PowerShell will also treat semicolons as statement terminators, so you'll want to surround each parameter with quotes to prevent that.</p> <pre><code>&amp; cspack "$a/ServiceDefinition.csdef" "/role:$b;$c" "/rolePropertiesFile:$a.$b;c$" "/sites:$a;$b;$c" "/out:$out" </code></pre>
22,495,450
0
<p>Instead of writing your own recursive code, maybe you can just treat this like a LAF change and just invoke:</p> <pre><code>SwingUtilities.updateComponentTreeUI(frame); </code></pre> <p>See the section from the Swing tutorial on <a href="http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html#dynamic" rel="nofollow">Changing the LAF</a>.</p> <p>Also, there is no need to invoke revalidate() and repaint() in your code. The setFont(...) method will invoke those methods automatically. </p>
14,250,255
0
<p>Access to s3 can be secured in a variety of ways, but frequently people want to host these files directly out of s3, so they provide public access. You must have setup access to your bucket/objects so that they are public.</p> <p>You can also set the bucket name to be a domain of your choosing ala files.yourdomain.com, add a CNAME pointing to s3, and they will automatically determine that the files should come from your public bucket, using a little bit of internal rewriting. </p>
29,711,664
0
<ol> <li>Delete the blue folder where the image is. </li> <li>Import again and select "Copy items if needed". </li> <li>Select "Create Groups" NOT folders</li> </ol>
4,382,669
0
Checking for null and missing query string parameters in PHP <p>I want to be able to distinguish between existing query string parameters set to null, and missing parameters. So the parts of the question are:</p> <ul> <li>How do I check if a parameter <em>exists</em> in the query string </li> <li>What's the established method for passing a null value in a query string? (e.g. param=null or param=(nothing) )</li> </ul> <p>Thanks</p>
29,739,126
0
<p>I think I see what's going on here. It's actually impossible for the <code>Fragment</code> to be duplicated with only one view container.</p> <p>I suspect that the items in your <code>ListFragment</code> are getting duplicated due to the call to <code>populateList()</code> in <code>onActivityCreated()</code>.</p> <p>Because<code>onActivityCreated()</code> is called every time you click the back button to return to <code>ColorListFragment</code> from <code>SaturationListFragment</code>, it is calling <code>populateList()</code> every time. See <a href="http://developer.android.com/reference/android/app/Fragment.html#onActivityCreated(android.os.Bundle)" rel="nofollow">documentation here</a></p> <p>In order to fix your issue, just move the call to <code>populateList()</code> to <code>onCreate()</code>, which is only called the first time the <code>ListFragment</code> is initialized:</p> <pre><code>public class ColorListFragment extends ListFragment { private List&lt;ColorGD&gt; mDrawableList = null; private ColorAdapter mAdapter = null; //add the onCreate() override @Override public void onCreate(Bundle savedInstance){ super.onCreate(savedInstance); populateList(); //add this here } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_color_list, container, false); } @Override public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); //populateList(); //remove this //.................. </code></pre>
6,841,209
0
Join two rows from the same table <p>I currently have this query set-up:</p> <pre><code>SELECT topic.content_id, topic.title, image.location FROM mps_contents AS topic INNER JOIN mps_contents as image ON topic.content_id = image.page_id WHERE topic.page_id = (SELECT page_id FROM mps_pages WHERE page_short_name = 'foo' ) AND image.display_order = '1' </code></pre> <p>This is because I want to merge two rows from the same table in one row. This is a simplified setup of the table</p> <pre><code>----------------------------------------------------------- | page_id | content_id | title | location | display_order | ----------------------------------------------------------- | 1 | 200 | Foo | NULL | 200 | | 200 | 201 | Bar | jpg.jpg | 1 | ----------------------------------------------------------- </code></pre> <p>And basically I want this result</p> <pre><code>--------------------------------- | content_id | title | location | --------------------------------- | 200 | Foo | jpg.jpg | --------------------------------- </code></pre> <p>So <code>Foo</code> is the 200th topic on page 1 (<code>Foo</code> is treated as a subpage and all its contents are stored in the same table) and <code>Bar</code> is its featured image (featured only because it is the 1st image)</p> <p>The query above effectively joins the two rows (it returns my desired result) but it also returns an extra row corresponding to the original row for <code>Foo</code>, that is, the location is NULL.</p> <p>I hope someone could help me prevent the query from returning that extra row.</p>
34,275,873
0
Reducing Server Response Time Where Loads Many Resources <p>I have a two PHP scripts that are loading many variable resources from APIs, causing the response times to as long as 2.2 seconds to 4 seconds. Any suggestions on how to decrease response times and increase efficiency would be very appreciated?</p> <p><strong>FIRST SCRIPT</strong> </p> <pre><code>require('path/to/local/API_2'); //Check if user has put a query and that it's not empty if (isset($_GET['query']) &amp;&amp; !empty($_GET['query'])) { //$query is user input $query = str_replace(" ", "+", $_GET['query']); $query = addslashes($query); //HTTP Request to API_1 //Based on $query //Max Variable is ammount of results I want to get back in JSON format $varlist = file_get_contents("http://ADRESS_OF_API_1.com?$query&amp;max=10"); //Convert JSON to Array() $varlist = json_decode($varlist, true); //Initializing connection to API_2 $myAPIKey = 'KEY'; $client = new APIClient($myAPIKey, 'http://ADRESS_OF_API_2.com'); $Api = new API_FUNCTION($client); $queries = 7; //Go through $varlist and get data for each element in array then use it in HTML //Proccess all 8 results from $varlist array() for ($i = 0; $i &lt;= $queries; ++$i) { //Get info from API based on ID included in first API data //I don't use all info, but I can't control what I get back. $ALL_INFO = $Api-&gt;GET_FUNCTION_1($varlist[$i]['id']); //Seperate $ALL_INFO into info I use $varlist[$i]['INFO_1'] = $ALL_INFO['PATH_TO_INFO_1']; $varlist[$i]['INFO_2'] = $ALL_INFO['PATH_TO_INFO_2']; //Check if info exists if($varlist[$i]['INFO_1']) { //Concatenate information into HTML $result.=' &lt;div class="result"&gt; &lt;h3&gt;'.$varlist[$i]['id'].'&lt;/h3&gt; &lt;p&gt;'.$varlist[$i]['INFO_1'].'&lt;/p&gt; &lt;p&gt;'.$varlist[$i]['INFO_2'].'&lt;/p&gt; &lt;/div&gt;'; } else { //In case of no result for specific Info ID increase //Allows for 3 empty responses ++$queries; } } } else { //If user didn't enter a query, relocates them back to main page to enter one. header("Location: http://websitename.com"); die(); }` </code></pre> <blockquote> <p>NOTE: $result equals HTML information from each time arround the loop.</p> <p>NOTE: Almost all time is spent in the <code>for ($i = 0; $i &lt;= 7; ++$i)</code> loop.</p> </blockquote> <p><strong>SECOND SCRIPT</strong> </p> <pre><code>//Same API as before require('path/to/local/API_2'); //Check if query is set and not empty if (isset($_GET['query']) &amp;&amp; !empty($_GET['query'])) { //$query is specific $varlist[$i]['id'] for more information on that data $query['id'] = str_replace(" ", "+", $_GET['query']); $query['id'] = addslashes($query['id']); //Initializing connection to only API used in this script $myAPIKey = 'KEY'; $client = new APIClient($myAPIKey, 'http://ADRESS_OF_API_2.com'); $Api = new API_FUNCTION($client); $ALL_INFO_1 = $Api-&gt;GET_FUNCTION_1($query['id']); $query['INFO_ADRESS_1.1'] = $ALL_INFO_1['INFO_ADRESS_1']; $query['INFO_ADRESS_1.2'] = $ALL_INFO_2['INFO_ADRESS_2']; $ALL_INFO_2 = $Api-&gt;GET_FUNCTION_2($query['id']); $query['INFO_ADRESS_2.1'] = $ALL_INFO_3['INFO_ADRESS_3']; $ALL_INFO_3 = $Api-&gt;GET_FUNCTION_3($query['id']); $query['INFO_ADRESS_3.1'] = $ALL_INFO_4['INFO_ADRESS_4']; $ALL_INFO_4 = $Api-&gt;GET_FUNCTION_4($query['id']); $query['INFO_ADRESS_4.1'] = $ALL_INFO_5['INFO_ADRESS_5']; $query['INFO_ADRESS_4.2'] = $ALL_INFO_6['INFO_ADRESS_6']; $ALL_INFO_5 = $Api-&gt;GET_FUNCTION_5($query['id']); $query['INFO_ADRESS_5.1'] = $ALL_INFO_7['INFO_ADRESS_7']; } $result = All of the $query data from the API; } else { //If no query relocates them back to first PHP script page to enter one. header("Location: http://websitename.com/search"); die(); }` </code></pre> <blockquote> <p>NOTE: Similiarly to the first script, most time is spent getting info from the secondary API.</p> <p>NOTE: In the second script, the first API is replaced by a single specific variable from the first script page,so $varlist[$i]['id'] = $query['id'].</p> <p>NOTE: Again, $result is the HTML data.</p> </blockquote>
19,373,415
0
<p>To go back to original app you can use telprompt:// instead of tel:// - The tell prompt will prompt the user first, but when the call is finished it will go back to your app:</p> <pre><code>NSString *phoneNumber = [@"telprompt://" stringByAppendingString:mymobileNO.titleLabel.text]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]]; </code></pre> <p>just an update on above answer.</p>
7,667,780
0
<p>I was having the same problem when upgrading my server from glassfish v3.0.1 to glassfish v3.1.1. Seems like there is a bug in the jaxb-osgi.jar in v3.1.1. <a href="http://java.net/jira/browse/JAXB-860" rel="nofollow">http://java.net/jira/browse/JAXB-860</a> shows that the fix will be included in glassfish v3.1.2. But at the meantime, I replaced the jaxb-osgi.jar in glassfish v3.1.1 with the jar from glassfifh v3.0.1 and the problem is solved. You should be able to get a newer version of jaxb-osgi.jar that has the fix in as well.</p>
15,424,129
0
Express.io, socket.io.js not found <p>I got an issue with Express.io, I try to create a simple tchat. But I'm not be able to include the socket.io.js, I got an error...</p> <p>I just installed Express.io on my new Express project.</p> <p>My errors : </p> <ol> <li>GET http://<strong><em>*</em>**</strong>/socket.io/socket.io.js 404 (Not Found)</li> <li>localhost:1 Uncaught ReferenceError: io is not defined</li> </ol> <p><strong>Index.jade</strong></p> <pre><code>doctype 5 html head title= title link(rel='stylesheet', href='/stylesheets/style.css') body block content script(src="http://localhost:3000/socket.io/socket.io.js") script(src="/javascripts/user.js") </code></pre> <p><strong>app.js</strong></p> <pre><code>/** * Module dependencies. */ var express = require('express.io') , index = require('./routes/index.js') , http = require('http') , path = require('path'); var app = express(); app.http().io(); app.configure(function(){ app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); }); app.configure('development', function(){ app.use(express.errorHandler()); }); app.get('/', index.index); app.io.route('ready', function(req) { req.io.emit('talk', { message: 'io event from an io route on the server' }); }); http.createServer(app).listen(app.get('port'), function(){ console.log("Express server listening on port " + app.get('port')); }); </code></pre> <p><strong>index.js (route)</strong></p> <pre><code>exports.index = function(req, res){ res.render('index', { title: 'TCHAT' }); }; </code></pre> <p><strong>user.js</strong></p> <pre><code>io = io.connect(); // Emit ready event. io.emit('ready'); // Listen for the talk event. io.on('talk', function(data) { alert(data.message); }); </code></pre> <p><strong>New error</strong></p> <p>Failed to load resource: the server responded with a status of 404 (Not Found) http://<strong>*</strong>:3000/socket.io.js Uncaught ReferenceError: io is not defined </p>
4,125,245
0
<pre><code>SELECT * FROM ( SELECT * FROM _A WHERE level = "1" UNION ALL SELECT * FROM _B WHERE level = "1" UNION ALL SELECT * FROM _C WHERE level = "1" ) ORDER BY RANDOM() LIMIT 1 </code></pre>