pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
13,717,747 | 0 | <p>I got this problem and I think the easier way is the same with the second way that hvgotcodes gave.</p> <blockquote> <p>Or you can copy all the ones you want to keep into a new list as you iterate, and then discard the old list when done.</p> </blockquote> <pre><code>@Test public void testListCur(){ List<String> li=new ArrayList<String>(); for(int i=0;i<10;i++){ li.add("str"+i); } List<String> finalLi = new ArrayList<String>(); for(String st:li){ if(st.equalsIgnoreCase("str3")){ // Do nothing } else { finalLi.add(st); } } System.out.println(finalLi); } </code></pre> |
37,290,612 | 0 | sequencial numbers in mapreduce <p>I have written a Java code to create RowId in Java. But I need to convert it into mapreduce. I am new to MapReduce and need your help.</p> <p>Input is a file in local</p> <pre><code>example: Alex 23 M NY Alex 19 M NJ Alex 29 M DC Michael 20 M NY Michael 24 M DC </code></pre> <p>Count file providing as secondary input Example:</p> <pre><code>Alex 3 Michael 2 Desired Output: 1 Alex 23 M NY 2 Alex 19 M NJ 3 Alex 29 M DC 1 Michael 20 M NY 2 Michael 24 M DC </code></pre> <p>My code in Java is here:</p> <pre><code>public class RowId { public static void main( String [] args) throws IOException { BufferReader in = null; BufferReader cnt = null; BufferWriter out = null; String in_line; String out_line; int frst_row_ind=1; int row_cnt=0; int new_col=0; try{ in= BufferReader(new FileReader ("file path in local"); File out_file = new File("o/p path in local"); if(!out_file.exists()){ out_file.createNewFile(); } FileWriter fw = new FileWriter(out_file); out = new BufferWriter(fw); while((in_line = in.readLine())! = null) { if (in_line!=null) { String[] splitData = in_line.split("\\t"); cnt = new BufferReader(new FileReader("file path of countFile") while((cnt_line=cnt.readLine()) != null ) { String[] splitCount = cnt_line.split("\\t"); if ((splitCount[0]).equalsIgnoreCase(splitData[0])) { if (frst_row_ind==1) { row_cnt = Integer.parseInt(splitCount[1]); } new_col++ out.write(String.valueOf(new_col)); out.write("\\t"); for(int i= 0; i <splitData.length; i++) { if (!(splitData[i] == null) || (splitData[i].length()== 0)) { out.write(splitData[i].trim()); if (i!=splitData.length-1) { out.write("\\t"); } } } row_cnt--; out.write("\r\n"); if(row_cnt==0) { frst_row_ind=1; new_col=0; } else{ frst_row_ind=0; } out.flush(); break; } } } } } catch (IOException e) { e.printStrackTrace(); } finally { try{ if(in!=null) in.close(); if(cnt !=null) cnt.close(); } catch (IOException e) { e.printStrackTrace(); } } } } </code></pre> <p>Please do revert with your idea(s).</p> |
15,913,387 | 0 | <p><a href="http://unix.stackexchange.com/questions/26946/disabling-caps-lock-by-setxkbmap-makes-it-shift-key-in-emacs">This</a> question is probably relevant, basically just use xmodmap to set the keys directly. It worked for me when I had caps lock set to control and I think I was using gnome3 classic (which Cinammon is based on) at the time.</p> <p>On a related note I'd also recommend having a look at <a href="https://github.com/r0adrunner/Space2Ctrl" rel="nofollow">space2ctrl</a>, I found that reaching for caps lock all the time still hurt my fingers.</p> |
28,198,941 | 0 | <p>Re: I cannot work out how to make the VBA code select that Outlook Data File Inbox...</p> <pre><code>Private Sub ProcessPST() Dim objNs As Namespace Dim pstFolder As folder Dim objItem As Object Dim i As Long Set objNs = GetNamespace("MAPI") Set pstFolder = objNs.Folders("Test") ' <--- Test is the name of the pst For i = 1 To pstFolder.Items.count Set objItem = pstFolder.Items(i) Debug.Print objItem.Subject Next i ExitRoutine: Set objNs = Nothing Set pstFolder = Nothing Set objItem = Nothing End Sub </code></pre> |
8,899,548 | 0 | <p>Qt APIs for DVB-H do not exist. JSR-272 is the only option on Symbian. </p> |
5,984,518 | 0 | Create bindings of ListView items programmatically <p>I have the following wpf control added to xaml:</p> <pre class="lang-xml prettyprint-override"><code><ListView Margin="22,80,271,12" Name="listView1" ItemsSource="{Binding}" /> </code></pre> <p>I know how to create a ListView object programmatically. The only thing that I am missing is how could I add the property </p> <pre class="lang-xml prettyprint-override"><code>ItemsSource="{Binding}" </code></pre> <p>with code to that object. I have already managed to add the columns and gridview with c#. The only thing that I am missing is to add that property ItemsSource="{Binding}" </p> <p>I have tried looking for an answer <a href="http://stackoverflow.com/questions/3874218/what-does-itemssource-binding-mean/3874319#3874319">here</a>.</p> |
30,657,991 | 0 | Lightswitch nested autocomplete boxes <p>I have Lightswitch 2013 and need to have nested autocomplete boxes. All the examples on the Internet are for older versions of Lightswitch and there are just a few differences in their examples from my version. Example: When adding Data Item for Local Property, Type "someTable" (Entity) doesn't come up as a choice. Also, if I click on one of my tables, then when I drag this Local Property to the screen is doesn't create an autocomplete box. Seems simple, but frustrating when I've tried many different ways. Please provide specific example using Lightswitch 2013. Thanks in advance. Steve</p> |
26,143,255 | 0 | Nginx rewrite POST as GET, and redirect <p>Is it possible for a <code>POST</code> request to <code>http://me.com</code></p> <p>to be converted to a <code>GET</code> request such as <code>http://me.com/api.php?some_static_param=yippee;<rest of post data as get request></code> using Nginx?</p> |
39,037,943 | 0 | <p>Check if <code>remoteMessage.getNotification()</code> is not NULL. I think it is NULL because you are not sending the param 'notification' in your <code>$fields</code> array of your PHP code. You are sending 'data'. So, when you send the parameter 'data' you have to get that parameter with <code>remoteMessage.getData()</code>. </p> <p>Try to print the content of <code>remoteMessage.getData().toString()</code> in your onMessageReceived method. It should print the data you are sending in the notification.</p> <p>Hope this helps.</p> |
27,187,365 | 0 | <p>If you have a CustomCell, you must have a CustomCell.m (implementation file). In this file add this, to me is the easy way: </p> <pre><code>-(void)setHighlighted:(BOOL)highlighted { if (highlighted) { self.layer.opacity = 0.6; // Here what do you want. } else{ self.layer.opacity = 1.0; // Here all change need go back } } </code></pre> |
35,871,296 | 0 | Appending or adding new text next to current tooltip text JQuery <p>I was wondering whether its possible to add new text next to or append text to existing text already on tooltip. </p> <p>For example, I have a div tag containing tooltip text like so;</p> <pre><code><div id="myDiv1" class="myDiv" title="This is Tooltip">body text </div> </code></pre> <p>As shown above, the current tooltip text is: <code>This is Tooltip</code></p> <p>What I want to do is using jquery, appned / add more text to this. For example,</p> <pre><code>This is toopltip for myDiv1 </code></pre> <p>I have tried, but these don't seem to work and most don't return anything some return undefined, please help;</p> <pre><code>$('#myDiv1').attr("title", $('#myDiv1').tooltip + "" + "\nSome new text to append"); $('#myDiv1').prop("tooltipText", $('#myDiv1').tooltipText + "" + "\nSome new text to append"); $('#myDiv1').attr("data-original-title", $('#myDiv1').tooltipText + "" + "\nSome new text to append"); </code></pre> <p>Any help is welcomed :)</p> |
6,956,521 | 0 | <p>The Delete request isn't a full on true delete request. It's actually faked, much like the put request is when you use the form_for on a saved object. As far as I know, there's no reason why not use the REST convention provided. </p> <p>On another note, is that your own code in the snippet, or an example? Kind of curious why you would check to see if the record you are deleting is associated to parent. I guess there's always the possibility that in between the time you clicked on the delete, and it got to the request, that someone changed its parent somewhere else.</p> <p>Edit, here's the header information when i click on the delete link in a rails 3 scaffold app:</p> <pre><code>Request URL:http://phone_qa.dev/sites/2 Request Method:POST Status Code:302 Moved Temporarily Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Content-Length:86 Content-Type:application/x-www-form-urlencoded Cookie: _phone_qa_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTg4Y2Q4ZTgyOGYwM2IyMWI1N2Y4MjYyMTcwMzJiMzMwBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMVY0QkFIOXdzRFZXZi9yYnlkODJCUEdLTisvT2V6dVpkVDYyckkyR3JQSzg9BjsARg%3D%3D--e8244fd59e5fc34b37a93c2e768ace7a3bfffe44 Host:phone_qa.dev Origin:http://phone_qa.dev Referer:http://phone_qa.dev/sites User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1 Form Dataview URL encoded _method:delete authenticity_token:V4BAH9wsDVWf/rbyd82BPGKN /OezuZdT62rI2GrPK8= </code></pre> <p>You can see how it's actually a post request, but under the form data, there's a variable called _method with the value delete.</p> |
16,536,715 | 0 | PHP generated XML parsing failed <p>In my CodeIgniter 2.x project with PHP 5.3.x I use following function to render Dom Document as XML response. Every things are goes fine. But generated XML parsing failed due to some malformed unexpected text (non-whitespace text outside root element).</p> <pre><code>function renderDOMAsXML(DOMDocument &$dom, $format = true, $status = 200){ $dom->formatOutput = $format; $controller = &get_instance(); $controller->output->set_status_header($status); $controller->output->set_header('Content-type: application/xml; charset=utf-8'); $controller->output->set_output($dom->saveXML()); } </code></pre> <p>for my curiosity I decoded the malformed unexpected text (non-whitespace text outside root element) as hexadecimal format as following.</p> <pre><code>\x00ef\x00bb\x00bf\x00ef\x00bb\x00bf\x00ef\x00bb\x00bf\x00ef\x00bb\x00bf\x00ef\x00bb\x00bf </code></pre> <p>or </p> <pre><code>\x{00ef}\x{00bb}\x{00bf}\x{00ef}\x{00bb}\x{00bf}\x{00ef}\x{00bb}\x{00bf}\x{00ef}\x{00bb}\x{00bf}\x{00ef}\x{00bb}\x{00bf} </code></pre> <p>or like this</p> <pre><code> </code></pre> <p>I could not realize what's the wrong. What are the malformed unexpected text (non-whitespace text outside root element)? are they any header information? How do I could skip them as I want to render it as XML response for browser.</p> |
13,046,003 | 0 | <p><strong>yes</strong>. Don't see any point not to support it, documentation <a href="http://developer.android.com/guide/topics/resources/providing-resources.html" rel="nofollow">here</a> provides no restrictions on it (I myself at least have used -land qualifier)</p> |
11,118,569 | 0 | How do I keep a frame always on top within the application but put it to background when using other applications in Java? <p>My Java application has multiple frames. Some of them are set to be always on top. However, when the user opens another program (let's say a web browser), I want the always-on-top frames to move to the background, making way for the other application to fully show on screen. </p> |
10,992,697 | 0 | <p>Change this</p> <pre><code>onclick= "SaveData();" </code></pre> <p>to </p> <pre><code>onclick= "SaveData(this);" </code></pre> <p>Then change the <code>saveData</code> function to</p> <pre><code>function SaveData(elem) { localStorage["LessonID"] = $(elem).attr('LessonID'); localStorage["SubjectName"] = $(elem).find('.lesson_subject').text(); } </code></pre> <p>Or even better, you can use <code>$.on</code> like @James Allardice showed in his answer.</p> |
35,840,525 | 0 | <p>You could just simplify your query to:</p> <pre><code>WITH MyQueryAlias1 AS (30 minutes sql query here) SELECT q1.field1 FROM MyQueryAlias1 q1 JOIN MyQueryAlias1 q2 ON q1.field2 = q2.field3 </code></pre> <p>Which will get rid of the second sub-query factoring clause.</p> <p>This might also work:</p> <pre><code>WITH MyQueryAlias1 AS (30 minutes sql query here) SELECT field1 FROM MyQueryAlias1 WHERE LEVEL = 1 AND ( field2 = field3 OR CONNECT_BY_ISLEAF = 0 ) CONNECT BY NOCYCLE PRIOR field2 = field3 AND LEVEL = 2; </code></pre> |
35,385,953 | 0 | <p>Firstly, it's the <em>view</em> rather than the <em>template</em> that you want to control HTTP caching on.</p> <p>The template is just a chunk of HTML that can be rendered by any view, the view is what sends an HTTP Response to the web browser.</p> <p>Django comes with some handy view decorators for controlling the HTTP headers returned by a view:<br> <a href="https://docs.djangoproject.com/en/1.9/topics/cache/#controlling-cache-using-other-headers" rel="nofollow">https://docs.djangoproject.com/en/1.9/topics/cache/#controlling-cache-using-other-headers</a></p> <p>You can find this simple example in the docs:</p> <pre><code>from django.views.decorators.cache import never_cache @never_cache def myview(request): # ... </code></pre> <p>If you are using 'class-based' views rather than simple functions then there's a <a href="https://gist.github.com/cyberdelia/1231560" rel="nofollow">gist here</a> with an example of how to convert this decorator into a view Mixin class:</p> <pre><code>from django.utils.decorators import method_decorator from django.views.decorators.cache import never_cache class NeverCacheMixin(object): @method_decorator(never_cache) def dispatch(self, *args, **kwargs): return super(NeverCacheMixin, self).dispatch(*args, **kwargs) </code></pre> <p>...which you'd use in your project like:</p> <pre><code>from django.views.generic.detail import DetailView class ArticleView(NeverCacheMixin, DetailView): template_name = "article_detail.html" queryset = Article.objects.articles() context_object_name = "article" </code></pre> |
39,969,247 | 0 | <p>You have to answer twice, about where to install Java. If you want to use your own directories, instead of Windows's, you have to set a separate directory for the JRE, which is what it wants to know, on the second ask. ORACLE's installer should have been done a little less ambiguously.</p> <p>If you try and answer the same directory, for the jre, as for the jdk, you won't have your jar.exe, or your src.zip folder. They are installed there, until it asks for the destination for the JRE. It might overwrite (remove all) the files in the root directory of the jre folder. In other words, that's the JRE1.8.0_102's bin folder in the root folder of your JDK, now, thanks to the installer.</p> |
28,991,120 | 0 | <pre><code> #messydata.txt : created by copying/pasting the line above into a textfile. #Load Table into R data1 <- read.table("messydata.txt", header=FALSE,sep=",", nrows=2, col.names=paste0("C", 1:16) ) #In col.names you can create the column names you want C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 1 48.25 4.25 19890000 2.60 5.89 1.28 0.02 0 0 0.42 3575 0 -0.40 2.60 2.57 6.48 2 50.00 6.00 19890000 3.55 5.42 2.31 0.42 0 0 0.15 2420 0 0.27 3.55 2.00 7.80 #Option 1- Bind your two tables cbind(data1, icp) #option 2- Join tables if you have a key Variable "ID" require(plyr) newdata<- join(x=data1, y=icp, by = "ID") #The ID can have a different name in x and y. </code></pre> |
19,429,905 | 0 | <p><code>{username:kavi}</code> is not JSON. Strings must be quoted with <code>"</code> characters. <a href="http://jsonlint.com/" rel="nofollow">Test</a> your JSON (better yet: don't handcraft it in the first place).</p> |
6,304,763 | 0 | <p>With this information, I say this structure looks fine.</p> <p>You might also consider creating a separate ServiceModel assembly to store all your custom behavior and WCF. They could then be reused for other projects</p> |
18,249,117 | 0 | How to deploy web project on remote tomcat server outside Eclipse with .jar files in it <p>I have Rest <strong>API Project A</strong> which uses Project B and Project C for Database retrieval</p> <p><strong>Project B</strong>, <strong>Project c</strong> In which JPA is used for DB. Project A is working in Eclipse as i have added Project B and Project C's dependency at following places: </p> <ol> <li>Properties -> <strong>Deployment Assembly</strong>--> Add -> Project B and C</li> <li><strong>Debug Configurations</strong> -> Classpath -->User Entries --> Add Projects B and C which includes all .jars of B and C automatically</li> <li>Added project B and C to <strong>Projects--> Properties</strong></li> </ol> <p>Now i want my web project to run on <strong>Localhost without Eclipse.</strong></p> <p>I made ProjectA.war file and put it in tomcate's webapps folder and run tomcat.</p> <p>It performs normal function like if i want to print Hello. it does..</p> <p>But when i try to run any function which in turn call project B and C's function which has query to Database JPA its Not working.It doesn't return any data.</p> <p>After Deploying .war in tomcat In Project A <code>webapps\ProjectA\WEB-INF\lib</code> only .jar which i added in <code>Properties -> Deployment Assembly--> Add -> Project B and C</code> Appears.</p> <p>How can i make it work to use project B and C also. Please Help what .jars or dependencies should i also need to include and where??</p> |
7,871,219 | 0 | <h3>Header Authentication</h3> <p>there are three ways to do it</p> <ol> <li>HTTP Basic Authentication</li> <li>HTTP Digest Authentication</li> <li>Roll our own using custom HTTP headers</li> </ol> <p>You can read more from <a href="http://php.net/manual/en/features.http-auth.php" rel="nofollow">PHP Manual</a></p> <p>Restler 1.0 had a Digest Authentication example. I've modified to make it work with Restler 2.0</p> <pre><code>class DigestAuthentication implements iAuthenticate { public $realm = 'Restricted API'; public static $user; public $restler; public function __isAuthenticated() { //user => password hardcoded for convenience $users = array('admin' => 'mypass', 'guest' => 'guest'); if (empty($_SERVER['PHP_AUTH_DIGEST'])) { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Digest realm="'.$this->realm.'",qop="auth",nonce="'. uniqid().'",opaque="'.md5($this->realm).'"'); throw new RestException(401, 'Digest Authentication Required'); } // analyze the PHP_AUTH_DIGEST variable if (!($data = DigestAuthentication::http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) { throw new RestException(401, 'Wrong Credentials!'); } // generate the valid response $A1 = md5($data['username'] . ':' . $this->realm . ':' . $users[$data['username']]); $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); if ($data['response'] != $valid_response) { throw new RestException(401, 'Wrong Credentials!'); } // ok, valid username & password DigestAuthentication::$user=$data['username']; return true; } /** * Logs user out of the digest authentication by bringing the login dialog again * ignore the dialog to logout * * @url GET /user/login * @url GET /user/logout */ public function logout() { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Digest realm="'.$this->realm.'",qop="auth",nonce="'. uniqid().'",opaque="'.md5($this->realm).'"'); die('Digest Authorisation Required'); } // function to parse the http auth header private function http_digest_parse($txt) { // protect against missing data $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); $data = array(); $keys = implode('|', array_keys($needed_parts)); preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); foreach ($matches as $m) { $data[$m[1]] = $m[3] ? $m[3] : $m[4]; unset($needed_parts[$m[1]]); } return $needed_parts ? false : $data; } } </code></pre> |
3,864,427 | 0 | Variables scope <p>I have two javascript files included at the header of my website. Both files contains almost same variables. </p> <p>If I have header like this </p> <pre><code> <head> <script src="http://127.0.0.1/js/file1.js" type="text/javascript"></script> <script src="http://127.0.0.1/js/file2.js" type="text/javascript"></script> </head> </code></pre> <p>Is it possible to access vars defined in file1.js from file2.js ?</p> <p>This is what i`m trying</p> <pre><code> file1 $(function() { var x = 1; }); file2 $(function() { console.log(x); //This dosen`t work. Can`t access var }); </code></pre> |
35,380,050 | 0 | <pre><code>#app/models/notification.rb class Notification < ActiveRecord::Base belongs_to :device, foreign_key: :registration_id, primary_key: :token delegate :user, to: :device #-> notification.user.name end #app/models/device.rb class Device < ActiveRecord::Base belongs_to :user has_many :notifications, foreign_key: :registration_id, primary_key: :token end #app/models/user.rb class User < ActiveRecord::Base has_many :devices has_many :notifications, through: :devices end </code></pre> <p>The above is how I would perceive it to be set up.</p> <p>You'll be able to call:</p> <pre><code>@notification = Notification.find params[:id] @notification.device.user.name #-> "name" of associated "user" model @notification.user.name #-> delegate to "user" model directly </code></pre> <hr> <p>The <a href="http://apidock.com/rails/Module/delegate" rel="nofollow"><code>delegate</code></a> method is a trick to circumvent the <a href="https://en.wikipedia.org/wiki/Law_of_Demeter" rel="nofollow"><code>law of demeter</code></a> issue (calling an object several levels "away" from the parent).</p> |
38,287,494 | 0 | <p>Because python uses references for arrays, objects, etc. If you want a copy of the array use <code>copy</code>:</p> <pre><code>import copy b = copy.copy(a) </code></pre> |
10,368,214 | 0 | <p>It's pretty late, but I got around a similar problem using masking</p> <p><a href="http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/" rel="nofollow">http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/</a></p> <p>cheers.</p> |
3,446,579 | 0 | How to use Windows Biometric Framework (WBF) in WPF application? <p>I'm working on WPF application which should identify user using Fingerprint Reader. </p> <p>It seems Windows Biometric Framework (WBF) is good enough for this task but I can't found examples where I can see how it can be used in my WPF application. Couple found examples use WBF to verify user currently logged in.<br> But my application should work with custom users and windows authentication is not acceptable.<br> I found also small MSDN article where described three sensor pools, one of them should be used in my situation. It is not clear how I can move Fingerprint Reader device between pools, where to get C# wrapper for Biometric API and how all of these things can be used together.</p> <p>I'm using UPEK Eikon as fingerprint reader device and Windows7 based tablet PC where my application should run.</p> <p>Could you please help and give me examples and links on useful resources? Thanks Dmitry</p> |
30,753,782 | 0 | <h2>CSS</h2> <p>This is due to the border having to fit in with whatever the triangles height is. Just change with the width in <code>.triangle-left</code> and you will see the responsiveness.</p> <p>It will only resize up to 500px high though but this should be more than adequate.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.contain { width: 100%; } /*Left pointing*/ .triangle-left { width: 5%; height: 0; padding-top: 5%; padding-bottom: 5%; overflow: hidden; } .triangle-left:after { content: ""; display: block; width: 0; height: 0; margin-top:-500px; border-top: 500px solid transparent; border-bottom: 500px solid transparent; border-right: 500px solid #4679BD; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><div class="contain"> <div class="triangle-left"></div> </div> </code></pre> </div> </div> </p> <h2>SVG</h2> <p>The SVG version just requires positioning.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.contain { height: 30px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><div class="contain"> <svg width="100%" height="100%" viewBox="0 0 500 500"> <polygon points="0,250 500,0 500,500" style="fill:red;stroke:black;stroke-width:2" /> </svg> </div></code></pre> </div> </div> </p> |
23,642,620 | 0 | <p>Yes. Something like this:</p> <pre><code>function whereami(elem) { var par = elem.parentNode, sibs = par.children, l = sibs.length, i; for( i=0; i<l; i++) { if( sibs[i] === elem) return i; } throw "I am invisible!"; } </code></pre> |
27,018,254 | 0 | <p>In <code>SwipListView.java</code> change</p> <pre><code> case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: log("============ACTION_UP"); clearPressedState(); if (mIsShown) { hiddenRight(mPreItemView); } </code></pre> <p>to</p> <pre><code> case MotionEvent.ACTION_UP: showRight(mCurrentItemView); case MotionEvent.ACTION_CANCEL: log("============ACTION_UP"); clearPressedState(); if (mIsShown) { if ( mPreItemView != null) hiddenRight(mPreItemView); } </code></pre> |
20,116,912 | 0 | <p>A very simple GUI application is possible sticking with C and Windows API only.</p> <p>In short, you have to register your own Window class (<code>RegisterClassEx</code>), then create the window (<code>CreateWindowEx</code>). Note that your window class main element is its (<code>WindowProc</code>) that receive the messages and that you have to implement to act as you want. After that, your C program should run the message pump (<code>PeekMessage</code> and <code>DispatchMessage</code>) for Windows to do its stuff and allow interacting with your window.</p> <p>See the MSDN documentation for these functions to get help and examples.</p> |
31,843,347 | 0 | Dynamically update position on Angular-Google-Maps-Native <p>Using the Angular-Google-Maps-Native plugin, when I change the information in JavaScript, my map is not updating. I believe my problem is the $scope for the map, versus the controller I am running.</p> <p><a href="https://i.stack.imgur.com/C2Rrp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C2Rrp.png" alt="Missing Title that is Hard Coded"></a></p> <p>Sub Sample of HTML</p> <pre><code><md-content flex id="content" class="md-whiteframe-z2"> <div ng-init="coords={latitude: false, longitude: false}"> <gm-map options="{center: [{{ScheduleCard.Latitude}}, {{ScheduleCard.Longtitude}}], zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP}"> <gm-marker options="{position: [{{ScheduleCard.Latitude}}, {{ScheduleCard.Longtitude}}], draggable: false}"> <gm-infowindow options="{content: '{{ScheduleCard.VenueName}}'}"></gm-infowindow> </gm-marker> </gm-map> </div> </md-content> </code></pre> <p>Sample of JavaScript controller</p> <pre><code>angular.module('MyApp').controller('ScheduleCtrl', ["$scope", ... function($scope, ...) { //code here to load from Firebase $scope.ScheduleCard = {}; $scope.ScheduleCard.VenueName = ''; $scope.ScheduleCard.Latitude = 43.630; // Initial Area $scope.ScheduleCard.Longtitude = -79.699; // reposition map based on this data $scope.LoadScheduleCard = function(ScheduleInfo) { $scope.ScheduleCard.VenueName = ScheduleInfo.VenueName; $scope.ScheduleCard.Latitude = ScheduleInfo.Latitude; $scope.ScheduleCard.Longtitude = ScheduleInfo.Longtitude; }; </code></pre> <p>Aditional side menu code for LoadScheduleCard()</p> <pre><code><!-- Container #3 --> <md-sidenav md-is-locked-open="true" class="md-whiteframe-z2"> <md-list> <md-list-item class="md-3-line" ng-repeat="schedule in Schedules" md-ink-ripple layout="row" layout-align="start center"> <md-item-content> <div class="inset" ng-click="LoadScheduleCard(schedule)"> <ng-md-icon icon="today"></ng-md-icon> <b class="md-subhead"> {{schedule.GameDate | SLS_Date}} @ {{schedule.GameTime | SLS_Time:'hh:mm'}}<br /> <ng-md-icon icon="place"></ng-md-icon> {{schedule.VenueName}}<br /> <ng-md-icon icon="games"></ng-md-icon> {{schedule.HomeTeamName}} vs. {{schedule.AwayTeamName}}<br /> <ng-md-icon icon="thumb_up" ng-show="schedule.Wins > 0"></ng-md-icon> <ng-md-icon icon="thumb_down" ng-show="schedule.Losses > 0"></ng-md-icon> <ng-md-icon icon="thumbs_up_down" ng-show="schedule.Ties > 0"></ng-md-icon> </b> </div> </md-item-content> <md-divider></md-divider> </md-list-item> </md-list> </md-sidenav> </code></pre> |
10,729,025 | 0 | <p>edit or create a .profile in your home directory and add:</p> <pre><code>export PATH=/usr/local/mysql/bin:$PATH </code></pre> <p>Open a new terminal window for the changes to take effect.</p> <p>In general you shouldn't use root. You can change the username in MySQL 5.02 or higher:</p> <pre><code>mysql> RENAME USER root TO new_user; </code></pre> <p>To delete a user:</p> <pre><code>mysql> DROP USER user; </code></pre> |
6,054,281 | 0 | Javascript alert() after Response.Redirect <p>I am calling this in my code behind: </p> <pre><code>(test.aspx) Response.Redirect("~/Default.aspx"); </code></pre> <p>I want to include a javascript alert after/before being redirected to Default.aspx, is it possible? I'm doing this because I'm passing a value to another page (test.aspx) and that page checks the db, if reader HasRow(), then redirect to Default.aspx. </p> |
34,961,752 | 0 | How do i programmatically click a button with C# in IE by classname? <p>So i'm trying to create a code which will automatically click buttons for me in my <code>webBroswer1</code> object in my visual studio C# Windows form application.</p> <p>However, the buttons in the website i would want to click do not have IDs, therefore it'd need to be my href/classname</p> <p>The tag of the buttons is <code><a></code>and the href is <code>javascript:void(0)</code>, could someone assist me please?</p> |
13,900,558 | 0 | <p>You call a class method by appending the class name likewise:</p> <pre><code>class.method </code></pre> <p>In your code something like this should suffice:</p> <pre><code>Test.static_init() </code></pre> <p>You could also do this:</p> <pre><code>static_init(Test) </code></pre> <p><strong>To call it inside your class</strong>, have your code do this:</p> <pre><code>Test.static_init() </code></pre> <p><strong>My working code:</strong></p> <pre><code>class Test(object): @classmethod def static_method(cls): print("Hello") def another_method(self): Test.static_method() </code></pre> <p>and <code>Test().another_method()</code> returns <code>Hello</code></p> |
10,390,148 | 0 | <p>I asked this very question during a Hangout with the guys from Google. They said they weren't aware of any limit.</p> <p>My company has going on for nearly 300 apps now.</p> |
27,919,713 | 0 | <p><strong>To reflect the status as of 2015:</strong></p> <p>Behaviorally both 400 and 422 response codes will be treated the same by clients and intermediaries, so it actually doesn't make a <em>concrete</em> difference which you use.</p> <p>However I'd expect to see 400 currently used more widely, and furthermore the clarifications that the <a href="http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-26#section-6.5.1">HTTPbis spec</a> provides make it the more appropriate of the two status codes:</p> <ul> <li>The HTTPbis spec clarifies the intent of 400 to not be solely for syntax errors. The broader phrase "indicates that the server cannot or will not process the request due to something which is perceived to be a client error" is now used.</li> <li>422 Is specifically a WebDAV extension, and is not referenced in RFC 2616 or in the newer <a href="http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-26#section-6.5.1">HTTPbis specification</a>.</li> </ul> <p>For context, HTTPbis is a revision of the HTTP/1.1 spec that attempts to clarify areas that where unclear or inconsistent. Once it has reached approved status it will supersede RFC2616.</p> |
5,076,705 | 0 | Is it possible to upload files to Rackspace Files Cloud from browser? <p>Is it possible to upload files to Rackspace Files Cloud from browser like in Amazon S3?</p> |
21,246,542 | 0 | <p>Really no need to put the number of searches. And, actually this could be done<br> with a single regex. I can't remember if Dot-Net supports the <code>\G</code> anchor,<br> but this is really not necessary anyway. I left it in. </p> <p>Each Match:<br> Finds a new key.<br> Captures the keys sub-string matches at the end.<br> Advances the search position by just the key. </p> <p>So, sit in a Find loop.<br> On each match print the 'Key' capture buffer,<br> then print the capture collection 'Values' count. </p> <p>Thats all there is to it. </p> <p>The regex will search for overlapping keys. To change it to exclusive keys,<br> change the <code>=</code> to <code>:</code> as shown in the comments. </p> <p>You can also make it a little more specific. For example, change all the <code>\w</code>'s to <code>[A-Z]</code>, etc... </p> <p>The regex: </p> <pre><code> (?: ^ [ \d]* | \G ) (?<Key> \w+ ) #_(1) [ ]+ (?= (?: \w+ [ ]+ )* (?= \w ) (?: (?= # <- Change the = to : to get non-overlapped matches (?<Values> \1 ) #_(2) ) | . )* $ ) </code></pre> <p>This is a perl test case </p> <pre><code> # $str = '2 6 AA TT PP AAATTCGAA'; # $count = 0; # # while ( $str =~ /(?:^[ \d]*|\G)(\w+)[ ]+(?=(?:\w+[ ]+)*(?=\w)(?:(?=(\1)(?{ $count++ }))|.)*$)/g ) # { # print "search = '$1'\n"; # print "found = '$count'\n"; # $count = 0; # # } # # Output >> # # search = 'AA' # found = '3' # search = 'TT' # found = '1' # search = 'PP' # found = '0' # # </code></pre> |
13,282,015 | 0 | <p>The right way to do it might be:</p> <pre><code>(defun my-grep-select(&optional beg end) (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list <wordbegin> <wordend>))) ...) </code></pre> |
6,574,123 | 0 | <p>If you use jquery datatables you can do something like this in your click event:</p> <pre><code>var columnIndexToSort = 0, sortAcending = true; $("#table").fnSort([[columnIndexToSort, sortAcending ? 'asc' : 'desc']]); </code></pre> <p>This will cause jquery datatables to sort and redraw the table for you. The jquery datatables plugin is very powerful and I find it harder to find something it can't do rather than something it can.</p> |
10,569,200 | 0 | How to reset to default button BackColor? <p>I was experimenting with different options for the button background color and ended up changing the <code>BackColor</code> property in the Appearance category. I then changed it back to what it is by default which is <code>Control</code>, but it still looks different from other buttons:</p> <p><img src="https://i.imgur.com/NuiXW.png" alt="Screenshot of buttons"></p> <p>I've tried building the project and restarting Visual Studio, but it did not help.</p> <p>I know I can just drag another button and copy/paste code, but what causes this in the first place and how do I properly fix it?</p> |
7,515,088 | 0 | <p>All normal Bluetooth keyboards implement the HID profile, which requires an L2CAP connection. Android so far only provides the ability to use RFCOMM connections. You would need to use the Native Development Kit and write your keyboard code in C to using bluez to achieve your goal. Have a look at apps that use the Nintendo WiiMote. The WiiMote also implements the HID profile.</p> |
13,777,138 | 0 | <p>When passing parameters into a macro, you should only need to access them with <code>@Parameter</code>. So in this case it would be <code>@Parameter.videoUrl</code>.</p> <p>Also, don't forget that you will need to add the parameter to the macro definition in Umbraco itself in the <em>Developers > Macros</em> section.</p> |
22,255,931 | 0 | Are git branch deletions permanent? <p>Just wondering if there's a way to recover them after they've been deleted. I'm assuming here that I've deleted it both locally and remotely.</p> |
1,467,979 | 0 | <p>Thanks for the answers -- I've now decided to take the easy route and put all my web files in a TrueCrypt volume that I'll mount whenever I need to work on any local web sites, together with any database data. This is definitely the safest as far as I can see.</p> |
25,165,198 | 0 | <p>i am using date() easy to handle and formating</p> <pre><code>$date = date('Y-m-d H:i',strtotime('2014-08-29')); echo "<option value='".$date."'>" . $date . "</option>"; </code></pre> |
19,228,211 | 0 | <p>Take a look on that script: <a href="https://github.com/CardinalPath/gas/blob/master/src/plugins/max_scroll.js" rel="nofollow">https://github.com/CardinalPath/gas/blob/master/src/plugins/max_scroll.js</a> Regards</p> |
26,956,926 | 0 | matplotlib not share axis x with many sub plots <p>I want to draw a chart with several sub-charts. The axes X have different lengths. The shape will be like:<br> subchart 1: ---------<br> subchart 2: --------------<br> subchart 3: ------------------ </p> <p>But i don't know how.</p> |
15,338,972 | 0 | erlang distributed programming <p>I have an application which has the following requirement.</p> <p>During the running of my Erlang App. on the fly I need to start one or more remote nodes either on the local host or a remote host.</p> <p>I have looked at the following options</p> <p>1) For starting a remote node on the local host either use the slave module or the net_kernel:start() API. However with the latter , there seems to be no way to specify options like boot script file name etc.</p> <p>2) In any case I don't need the slave configuration as I need to mimic similar behaviour of nodes spawned on local as well as remote hosts. In my current setup, I dont have permissions to rsh to the remote host. The workaround i can think of is to have a default node running on the remote host so as to enable remote node creation either through spawn or rpc:async_call and os:cmd combination</p> <p>Is there any other API interface to start erl ?</p> <p>I am not sure this is the best or the cleanest way to solve this problem and I would like to know the Erlang approach to the same?</p> <p>Thanks in advance</p> |
18,228,542 | 0 | <p>Looks fine too me. Why don't you try to use a DURATION (<a href="http://tools.ietf.org/html/rfc5545#section-3.8.2.5" rel="nofollow">RFC5545#section-3.8.2.5</a>) instead of a DTEND, e.g.</p> <pre><code>DURATION:PT1H </code></pre> <p>for a 1 hour event.</p> |
13,935,816 | 0 | UIActivityViewController change shared via iOS <p>I have simple sharing features in my app by using iOS 6 UIActivityView controller.</p> <p>When sharing in Facebook or Twitter there is a "shared via iOS"</p> <p>the code is:</p> <pre><code>NSString *textToShare = @"Test string to share"; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObject:textToShare] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:nil]; </code></pre> <p>is there any way to change "Shared via iOS" to my app name or anything else?</p> <p><img src="https://i.stack.imgur.com/ClWbg.png" alt="shareviaios"></p> <p>Thanks, Bill.</p> |
18,304,309 | 0 | <p>The problem is that the <code>InPageAppender</code> relies on log4javascript's own page load handling code to know whether it can start drawing itself. When loaded via RequireJS, the page is already loaded and log4javascript's page load handling code never runs.</p> <p>You can get around this by calling <code>log4javascript.setDocumentReady()</code>. The most sensible place to do this would seem to be in the shim <code>init()</code> function, but I'm no expert in RequireJS so there may be a better way:</p> <pre><code>requirejs.config({ shim: { 'log4javascript': { exports: 'log4javascript', init: function() { log4javascript.setDocumentReady(); } } } }); </code></pre> |
30,979,260 | 0 | <p>In ANSI standard SQL, you can do:</p> <pre><code>select (extract(year from col)*100000 + extract(month from col)*100 + extract(day from col)*1 + (extract(hour from col)*3600 + extract(minute from col)*60 + extract(second from col)) / (24.0*60*60) ) </code></pre> |
7,271,552 | 0 | How to store the cookie info when android killed my app <p>I have an app need login, I use a singleton http client to do everything, so it can track the cookies for me.</p> <p>But when I launch a browser intent in my app to view some html pages, the app sometimes be killed by low memory, when user come back from the browser, my app activity would be recreated, but the new http client would not contains that login session id.</p> <p>So I think what I need is to cache the cookies when my app get killed, and then restore it back when the app got recreated. I know there is a CookieSyncManager, but I do not have a full picture of how to use that.</p> <p>(1) So How can I do that? is Cookie seralizable, I just thought to cache it in the sdcard, maybe a bad idea.</p> <p>Another more general question maybe: </p> <p>(2) How to share httpclient with webview/system browser? Not just pass cookies from httpclient to webiew/browser, but also get the cookies when initialize the cookies, How to make the http client and webview/browser share just <em>ONE</em> copy of cookie store in any time?</p> |
24,283,752 | 0 | <p>I believe I've seen this issue upon trying to playback via the simulator vs. on an actual device. Similar to the following <a href="http://stackoverflow.com/questions/22569013/rtcreporting-pancake-apple-com-errors">post</a></p> |
26,246,159 | 0 | Panorama 360 viewer with phonegap <p>I read a lot of answers but i dont know wich is correct. Almost mobile browsers doesn support WEBGL, only newest. Almost script, libraries or plugins works with FLASH or WEBGL. I see and read a lot of your documentations and i dont know what to do. I need compatibility with almost smartphones in android and ios. I wanna use PHONEGAP platform to buil the app. Can you guide me? Thanks a lot</p> |
26,323,531 | 0 | <p>i just add class ="draggable" to my clones. you have to learn more about clones. But I hate clones. I use to copy html contents. You have to practice manipulation of object more deeply concerning clones. the best way to use anythings about jquery is var element = $('#element'). Thats it. Simple, fast copy. </p> |
34,101,905 | 0 | Span acting like div <p>I have this code, where I planned to have three spans side by side displaying the step a person is at signing up for my website. However, the spans are acting like divs and going onto the next line. I have no idea why this is happening. To my understanding, the spans should only take up the width they need, not an entire line</p> <pre><code> <div class="row stepRow"> <div class="col-12-md "> <div id="stepDisplay"> <span class="stepBlock"> <h3 class="headerStep">Step 1</h3> <p class="descStep">Basic Details</p> </span> <span class="stepBlock"> <h3 class="headerStep">Step 2</h3> <p class="descStep">More Details</p> </span> <span class="stepBlock"> <h3 class="headerStep">Step 3</h3> <p class="descStep">Payment Details</p> </span> </div> </div> </div> </code></pre> <p>//in seperate css file</p> <pre><code>.stepBlock { display: display; text-align: center; } .headerStep .descStep { display: inline; } </code></pre> |
12,699,884 | 0 | <p>Use the correct character set.</p> <pre><code>3>> print(bytes((219,)).decode('cp437')) █ 3>> ord(bytes((219,)).decode('cp437')) 9608 3>> hex(9608) '0x2588' 3>> print('\u2588') █ </code></pre> <p><a href="http://www.fileformat.info/info/unicode/char/2588/index.htm" rel="nofollow">Unicode Character 'FULL BLOCK' (U+2588)</a></p> |
3,312,122 | 0 | <p>Well it depends how, or what your trying to accomplish, one way would be: </p> <pre><code>android:layout_height </code></pre> <p>But if you mean programmatically, check this:</p> <p><a href="http://stackoverflow.com/questions/2963152/android-how-to-resize-a-custom-view-programmatically">Android: How to resize a custom view programmatically?</a></p> <p>That talks about resizing, but it should be the same concept.</p> |
29,057,648 | 0 | Nginx always returning a 404 for non index pages <p>I was able to deploy a site (<a href="http://taiga.market" rel="nofollow">http://taiga.market</a>) and it appears that Nginx works on the index page. If you click a link to go to another page (<a href="http://taiga.market/login" rel="nofollow">http://taiga.market/login</a>) Nginx responds with a 404. It does this for every page except the index and I have no idea why.</p> <p>I thought it was SSL, but it turns out that non-protected pages also do not render.</p> <p>I'm not really sure what's happening. The nginx configuration is as so:</p> <pre><code>server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; index index.html index.htm; server_name taiga.market; passenger_enabled on; rails_env production; root /home/deploy/taiga/current/public; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } </code></pre> <p>There was nothing logged in production.log or nginx's error.log, but there was information inside of the access.log:</p> <pre><code>24.85.70.29 - - [15/Mar/2015:01:51:01 -0400] "GET / HTTP/1.1" 200 1613 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36" 24.85.70.29 - - [15/Mar/2015:01:51:04 -0400] "GET /user/spree_user/sign_in HTTP/1.1" 404 715 "http://taiga.market/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36" 24.85.70.29 - - [15/Mar/2015:01:51:04 -0400] "GET /user/spree_user/sign_in HTTP/1.1" 404 715 "http://taiga.market/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36" </code></pre> |
16,718,003 | 0 | Query version info from jsf application <p>I just stumbled upon a <a href="http://www.cigital.com/papers/download/dissecting_jsf_pt_aks_kr.pdf" rel="nofollow">paper</a> on JSF security containing the following statement:</p> <blockquote> <p>In Suns RI JSF implementation, the "com.sun.faces.disableVersionTracking" conguration parameter is defined explicitly. By default, it is set to false which means application running on the web server will throw the JSF version into the response headers when the web client queries for it</p> </blockquote> <p>But I don't understand how the web client is supposed to query for it? Is there a way to put extra (header) parameters to a request which makes JSF more chatty? I'm using MyFaces as the JSF implementation.</p> |
15,884,068 | 0 | <p>It looks like you can remove the transform on the second image and it will go back behind the first one. So in other words, on image click I would probably first remove all occurrences of the transform property before applying to the clicked image. </p> <p>Or you could also set both images to position:relative and then on click set the z-index to something like 5 and set all other images to something below it such as 3. But again, you'll need to clear these inline styles so that when another image is clicked there are remnants from before that give you un-clear results. </p> |
5,980,761 | 0 | <p>You will need to setup:</p> <ul> <li>A DNS entry pointing the DNS entry healthApp.name.com to your webserver</li> <li>A VirtualHost entry on the server to handle this new host name</li> <li>Set the DocumentRoot of the new vHost to the healthApp directory</li> <li>Check any configuration of your web application so it knows it's running from the new location</li> </ul> |
524,666 | 0 | HTTP POST Though C# <p>I want to code an auto bot for an online game (tribalwars.net). I'm learning C# in school, but haven't covered networking yet. </p> <p>Is it possible to make HTTP POSTs though C#? Can anyone provide an example?</p> |
31,810,030 | 0 | <p>As the help states:</p> <pre><code>/trait "name=value" : only run tests with matching name/value traits : <b>if specified more than once, acts as an OR operation</b> </code></pre> <p>You have to add multiple <code>/trait</code> entries.</p> |
4,324,726 | 0 | Wrong encoding when getting response from Google's translate API? <p>I am using google translate API to translate text from English to German. The code i am using is:</p> <pre><code>string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", TxtEnglish.Text, Constants.LanguagePair); WebClient webClient = new WebClient(); webClient.Encoding = System.Text.Encoding.UTF8; webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(TextTranslation_DownloadStringCompleted); webClient.DownloadStringAsync(new Uri(url)); </code></pre> <p>On receiving the response in <code>e.Result</code>....... Original text: Can you help me?</p> <p>Translated german text on translator page: <code>können Sie mir helfen</code></p> <p>Result in <code>e.Result</code>: <code>k�nnen Sie mir helfen</code></p> <p>So, plz help me know why this "�" special character is coming and how can i fix this issue?? </p> |
1,923,825 | 0 | <p>See the <a href="http://lftp.yar.ru/lftp-man.html" rel="nofollow noreferrer">lftp docs</a> for proper usage of the ftp:sync-mode setting. (You want <code>true</code>.)</p> |
32,453,502 | 0 | <p>As far as I can see you're want to display list of entities, then provide an UI for selecting one of these entitites (via gridcontrol) and edit the selected entity properties in separate view (via text editors).</p> <p>So, I suggest you to use the MVVM approach. And, since you are already using DevExpress controls, I suggest you use the <a href="https://documentation.devexpress.com/#WPF/CustomDocument15112" rel="nofollow">DevExpress MVVM Framework</a> to make your MVVM as easy as it possible.</p> <p>Step 1: Define a ViewModel class that contains your entities collection available via the <code>Entities</code> property (you can load these entities in way as it needed, from it needed and when it needed) and provide the <code>SelectedEntity</code> property:</p> <pre><code>public class EntitiesViewModel { public EntitiesViewModel() { LoadEntities(); } void LoadEntities() { Entities = new ObservableCollection<Entity> { new Entity(){ Item1="A", Item2="A0", Item3="A00"}, new Entity(){ Item1="B", Item2="B0", Item3="B00"}, new Entity(){ Item1="C", Item2="C0", Item3="C00"}, }; } public ObservableCollection<Entity> Entities { get; private set; } public virtual Entity SelectedEntity { get; set; } // Bindable property } public class Entity { public string Item1 { get; set; } public string Item2 { get; set; } public string Item3 { get; set; } } </code></pre> <p>Step 2: Define a View layout as follows:</p> <pre><code>... xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DXApplication1" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" ... <Grid Margin="12"> <Grid.DataContext> <dxmvvm:ViewModelSource Type="{x:Type local:EntitiesViewModel}"/> </Grid.DataContext> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid Grid.Row="0" Margin="0,0,0,8"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="8"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Label Content="Item1" Grid.Row="0" VerticalAlignment="Center"/> <Label Content="Item2" Grid.Row="1" VerticalAlignment="Center"/> <Label Content="Item3" Grid.Row="2" VerticalAlignment="Center"/> <dxe:TextEdit Text="{Binding SelectedEntity.Item1}" Grid.Row="0" Grid.Column="2"/> <dxe:TextEdit Text="{Binding SelectedEntity.Item2}" Grid.Row="1" Grid.Column="2"/> <dxe:TextEdit Text="{Binding SelectedEntity.Item3}" Grid.Row="2" Grid.Column="2"/> </Grid> <dxg:GridControl Grid.Row="1" AutoGenerateColumns="None" ItemsSource="{Binding Entities}" SelectedItem="{Binding SelectedEntity}"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="Item1"/> <dxg:GridColumn FieldName="Item2"/> <dxg:GridColumn FieldName="Item3"/> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView ShowTotalSummary="True" AllowEditing="False"/> </dxg:GridControl.View> </dxg:GridControl> </Grid> </code></pre> <p>*The main points-of-interest and tricks are:<br> 1) creating the <code>EntitiesViewModel</code> instance via the ViewModelSource. This way allows you do not implement the <code>INotifyPropertyChanged</code> interface at the ViewModel's level - you can just declare the <code>SelectedEntity</code> property as <code>virtual</code> and delegate all the dirty-work to the <a href="https://documentation.devexpress.com/#WPF/CustomDocument17352" rel="nofollow">POCO mechanism</a>:</p> <pre><code><dxmvvm:ViewModelSource Type="{x:Type local:EntitiesViewModel}"/> </code></pre> <p>2) all View' controls bindings are "looks" into the DataContext (which contains our ViewModel):</p> <pre><code>... Text="{Binding SelectedEntity.Item1}" ... ItemsSource="{Binding Entities}" SelectedItem="{Binding SelectedEntity}"> </code></pre> <p>This way allows you to decouple all UI-controls from each other and modify the View with easy.</p> |
13,500,863 | 0 | <p>Recently, I was looking for that too. I think I got pointed to the solution here on SO, but I only have the final url at hand. This is what I do:</p> <pre><code># http://plumberjack.blogspot.de/2010/10/supporting-alternative-formatting.html class BraceMessage(object): def __init__(self, fmt, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs def __str__(self): return self.fmt.format(*self.args, **self.kwargs) _F = BraceMessage </code></pre> <p>Can be used like this:</p> <pre><code>logger.debug(_F("foo {0} {quux}", bar, quux=baz)) </code></pre> <p>The formatting will only take place in the very moment the message is evaluated, so you don't lose lots of performance if a log level is disabled. The author of that snippet above made this (and some other utilities) available as a package: <a href="http://pypi.python.org/pypi/logutils/" rel="nofollow"><code>logutils</code></a>.</p> |
15,959,591 | 0 | <p>I have modified this file : /opt/metasploit/ruby/lib/ruby/1.9.1/i686-linux/rbconfig.rb</p> <p>changed the line => CONFIG["LIBRUBYARG_STATIC"] = "-Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static" by => CONFIG["LIBRUBYARG_STATIC"] = "-Wl,-R -Wl,$(libdir) -L$(libdir) "</p> <p>go to /opt/metasploit/msf3 and run /opt/metasploit/ruby/bin/bundle install</p> <p>CREDIT -- <a href="http://top-hat-sec.com/forum/index.php?topic=2668.0" rel="nofollow">http://top-hat-sec.com/forum/index.php?topic=2668.0</a> -- BOBBY</p> |
16,460,994 | 0 | Perform action in series <p>i am trying to perform action in series but here in my code alert message is printed firat though i have written it after some action.</p> <p>This is Fiddle i have Tried . <a href="http://jsfiddle.net/wggua/635/" rel="nofollow">http://jsfiddle.net/wggua/635/</a></p> <pre><code> $(document).ready(function() { var a=1; setTimeout(function() { $('#dvData').fadeOut(); }, 2000); if(a==1) { alert("value i s 1"); } else { alert("value is 0"); } }); </code></pre> <p>Please help,</p> |
14,705,767 | 0 | Change an AbstractAction name <p>I have a JMenuItem bounded to an Action that I can get using <code>item.getAction()</code>. The action name is set when constructing the Action, e.g. using anonymous <code>new AbstractAction(String text, ...)</code>. The text field is set according to a ResourceBundle and localization information. Now if I want to change localization, I would like to change the Action.NAME field so that it displays the proper localized name. I can only get the name, e.g. using <code>item.getAction().NAME</code> but cannot change the field as it is final. </p> <p>How could I change it's name?</p> |
17,354,829 | 0 | <p>You'll need to create your own binder function to do that. The main reason for having <code>.bind()</code> was to deal with the non-lexically defined <code>this</code>. As such, they didn't provide any way to use it without setting <code>this</code>.</p> <p>Here's a simple example you could use:</p> <pre><code>Function.prototype.argBind = function() { var fn = this; var args = Array.prototype.slice.call(arguments); return function() { return fn.apply(this, args.concat(Array.prototype.slice.call(arguments))); }; }; </code></pre> <p>This is pretty bare-bones, and doesn't deal with the function being invoked as a constructor, but you can add that support if desired.</p> <hr> <p>You could also enhance it to behave like the native <code>.bind()</code> unless <code>null</code> or <code>undefined</code> are passed as the first argument.</p> <pre><code>Function.prototype.argBind = function(thisArg) { // If `null` or `undefined` are passed as the first argument, use `.bind()` if (thisArg != null) { return this.bind.apply(this, arguments); } var fn = this; var args = Array.prototype.slice.call(arguments); return function() { return fn.apply(this, args.concat(Array.prototype.slice.call(arguments))); }; }; </code></pre> |
24,722,350 | 0 | <p>First of all,you're never reading your input in a variable!and then you're trying to check equality between the "scan" object which is of type Scanner.Instead read input "scan.nextLine();" in a variable say "var" and then call var.equals(password).Please also check that your String "Fish" is null initially which will give you a NullPointerException!</p> |
14,469,684 | 0 | <p>This just happened to me... exactly. I needed to change it to <code>\\n</code> instead of <code>\n</code>.</p> <pre><code>alert("Hello again! This is how we"+"\\n"+"add line breaks to an alert box!"); </code></pre> |
39,813,331 | 0 | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>column: name: , while compiling: SELECT name, address, number FROM form</code></pre> </div> </div> Try looking these part. Are these correct?</p> <p>Try to fit this code if it doesnt go to your TextView.</p> |
16,935,138 | 0 | <p>This might work for you (GNU sed):</p> <pre><code>sed 's/.*_//' <<<"abc_def_ghi jkl_lmn_opq" </code></pre> |
26,089,782 | 0 | <p>You can use replace() to do what yo want it to. Use it in this format</p> <pre><code>value = value.replace(" ", ","); //First param is the char you want to replace; The second is the one you want to replace the first param with </code></pre> |
5,621,324 | 0 | jQuery val() and checkboxes <p>Is there some rationale for <code>val()</code> being useless for checkbox controls, whereas it is useful for getting input data consistently across every other input control?</p> <p>e.g. for checkboxes, at appears to <em>always return "on" regardless of the checkbox state.</em> For other input controls that don't actually have a "value" attribute, e.g. select and textarea, it behaves as you would expect. See:</p> <p><a href="http://jsfiddle.net/jamietre/sdF2h/4/">http://jsfiddle.net/jamietre/sdF2h/4/</a></p> <p>I can't think of a good reason why it wouldn't return <code>true</code> or <code>false</code>. Failing that, at least return "on" only when checked, and an empty string when not. Failing that, at least always return an empty string, given that checkboxes have no <code>value</code> attribute!</p> <p>Obviously I know how to get the value using <code>attr</code>, but here's the situation. I am developing a simple (so far anyway) C# jQuery implementation to do HTML parsing on the server, and I am trying to be completely faithful to jQuery's implementation so it behaves consistently on either the client or server against the same DOM. But this just seems stupid and I'm having a hard time getting myself to actually code "value" to return "ON" for a checkbox no matter what. But if I don't, it won't be consistent. So I'm trying to understand, is there some reason for doing this? Does it serve some purpose, or is it simply an artifact of some kind? Would anyone ever use the <code>val()</code> method against a checkbox, if so, why? If not, why did the jQuery architects decide on this approach to make it not useful?</p> |
28,313,486 | 0 | <p>Here is a query. This will make sure in each column(any) any of the 1,2,3,4,5 number exists i.e. 5 columns have a different number in them</p> <pre><code>select *, ((LENGTH(concat(cola,colb,colc,cold,cole))) - LENGTH(REPLACE(concat(cola,colb,colc,cold,cole), '1', ''))) as one, ((LENGTH(concat(cola,colb,colc,cold,cole))) - LENGTH(REPLACE(concat(cola,colb,colc,cold,cole), '2', ''))) as two, ((LENGTH(concat(cola,colb,colc,cold,cole))) - LENGTH(REPLACE(concat(cola,colb,colc,cold,cole), '3', ''))) as three, ((LENGTH(concat(cola,colb,colc,cold,cole))) - LENGTH(REPLACE(concat(cola,colb,colc,cold,cole), '4', ''))) as four, ((LENGTH(concat(cola,colb,colc,cold,cole))) - LENGTH(REPLACE(concat(cola,colb,colc,cold,cole), '5', ''))) as five from tests having one = 1 AND two = 1 AND three = 1 AND four = 1 AND five = 1 </code></pre> |
39,569,406 | 0 | <p>ArrayAdapter.java:401, is what is throwing this error. Check the values added in the object passed to this method. Probably one of those is null. android.os.Looper.loop(Looper.java:148)</p> |
11,633,469 | 0 | Are multiple Many-Many relationships evidence of bad design? <p>Good day all,</p> <p>I have been learning about databases and database design and I find I am still reaching a question I cannnot answer myself. So I pose the question to the community in hopes that someone with more knowledge/experience than I can answer it.</p> <p>I have been tasked with working on a database which tracks stock levels accross a fleet of ships.</p> <p>The current design has a table for each ship with a list of all possible parts (Machinery Type, Part Number, Make, Serial No etc.)</p> <p>This means that the details of a piece of machinery or part can be duplicated many times (as many times as there are ships in fact).</p> <p>I have been experimenting with a redesign based on what I have learnt myself, and I would propose a design along the following lines:</p> <pre><code>[SHIP] ID, Name, Class, Tonnage, Fleet, Superintendent etc. [Machinery] ID, Type, Make, Model etc. (Can have separate table for manufacturers and types if required) [Part] ID, Part number, Description, etc. </code></pre> <p>The above would be the three main tables now is where it starts to get difficult. </p> <p>Each ship can have multiple items of machinery and each machinery item could be present on multiple ships (requires a junction table)</p> <p>Each machinery item can have multiple parts and each part could belong to multiple machinery items (another junction table)</p> <p>There could be well into hundreds of thousands of parts which would make the junction tables huge.</p> <p>Additionally as soon as you want to keep track of stock you are looking at another junction table</p> <pre><code>[Stock Level] ShipID, PartID, Stock Level </code></pre> <p>Also if you wanted a minimum stock (Could be combined with Stock Level?)</p> <pre><code>[Min Stock] ShipID, PartID, Min Stock </code></pre> <p>And finally if you were looking to have normalised database (i.e no Part No.1 , Part No.2 or Serial No.1, Serial No.2)</p> <p>You would need to have a few extra tables</p> <pre><code>[Serial Numbers] ShipID, MachineryID, Serial No [Part Numbers] PartID, Part Number </code></pre> <p>Serial numbers is probably going to be fairly standard and no problem however [part numbers] will require at least as many records as are in the [Parts] table.</p> <p>Map (As best as I can represent without a picture, junctions omitted for simplicity)</p> <pre><code> <>V represent many -| represent one -----< Serial Numbers | V | | Ship >---< Machinery >---< Parts ---< Part Numbers V V | | ------ Stock Level ------- </code></pre> <p>Now the real question is am I missing something in the basic design principles that would eliminate such huge junction tables or is this to be expected with this kind of database.</p> <p>Also in cases like with part numbers where normalisation requires an additional table with at least the same number of records rather than extra columns in the original table is this the kind of thing that you would later denormalise to improve query speed?</p> <p>Any hints, tips or pointers to external resources (including other forums, tutorials, books) would be greatly appreciated.</p> <p>All answers welcome, thank you in advance for any help you provide.</p> <p>Dave</p> |
18,729,850 | 0 | <p>This</p> <pre><code> R.id.enterHours </code></pre> <p>returns an <code>int</code>. That's why when you initialize a <code>View</code> you do it like</p> <pre><code>TextView mTextView = (TextView) findViewById(R.id.newHours_Value); </code></pre> <p>The <code>(TextView)</code> casts it to a <code>TextView</code> so you can call its methods on it like <code>getText().toString()</code>. So what you probably want is</p> <pre><code>TextView hourValueTV = (TextView) findViewById*R.id.enterHours); //assuming its a TextView and not EditText String hourValue = hourValueTV.getText().toString(); </code></pre> |
20,872,591 | 0 | <p><code>sprintf</code> is indeed defined by the C standard. I would not look past that function to solve your problem.</p> |
30,166,384 | 0 | Sox - Piping output in windows <p>So I am emulating a RP2A03 chip using C++, using SoX to resample and output the audio.</p> <p>I can confirm that the APU itself and input pipe is working as a charm with the command following command:</p> <pre><code>FILE* fp = popen(".\\sox\\sox.exe -t raw -c1 -e signed-integer -b 16 -r1789800 - -t wav -c2 -r 48000 wav.wav", "wb"); ... fputc(sample, fp); fputc(sample/256, fp); </code></pre> <p>Which outputs a beautiful chiptune as wav.wav, playable in MS-media player, VLC and alike.</p> <p>But when I try to pipe the music to ffplay using:</p> <pre><code>FILE* fp = popen(".\\sox\\sox.exe -t raw -c1 -e signed-integer -b 16 -r1789800 - -t raw -c2 -r 48000 - | .\\sox\\ffplay.exe -acodec pcm_s16le -", "wb"); </code></pre> <p>I get an error reading:</p> <pre><code>FAIL sox: `-' error writing output file: Invalid argument </code></pre> <p>I've been hard at google for hours with no luck...</p> <p>I've been stuck at this for hours, since yesterday actually, and it seems like there is something crucial (or trivial?) I am overlooking, as all the examples I find use the same, or even easier methods, to write the output to stdout.</p> <p>As I can actually output it to a wav with no problems what so ever, I can't help but feel a bit taunted by the software...</p> <p>If anyone have any suggestions that might help, then please, please share!</p> <p>Thanks!</p> |
22,387,098 | 0 | <p>As follow up from comments, next formulas works in <code>F2</code> and copied down:</p> <pre><code>=IF(D2="YES",B2*E2,0) </code></pre> <p>or</p> <pre><code>=B2*E2*(D2="YES") </code></pre> |
20,395,607 | 0 | How to split a comma separated string into groups of 2 each and then convert all these groups to an array <p>I have a string which is like <code>1,2,2,3,3,4</code> etc. First of all, I want to make them into groups of strings like <code>(1,2),(2,3),(3,4)</code>. Then how I can make this string to array like<code>{(1,2) (2,3) (3,4)}</code>. Why I want this is because I have a array full of these 1,2 etc values and I've put those values in a <code>$_SERVER['query_string']="&exp=".$exp</code>. So Please give me any idea to overcome this issue or solve.Currently this is to create a group of strings but again how to make this array.</p> <pre><code>function x($value) { $buffer = explode(',', $value); $result = array(); while(count($buffer)) { $result[] = sprintf('%d,%d', array_shift($buffer), array_shift($buffer)); } return implode(',', $result); } $result = x($expr); </code></pre> <p>but its not working towards my expectations</p> |
29,520,907 | 0 | <p>to let <code>p-q</code> make sense,p and q should point to the same array.<br>but <code>p-q</code> in your code is Undefined</p> |
10,821,233 | 0 | <p>Adding to Ansari's answer, the <code>diagDominantFlag</code> can be calculated by:</p> <pre><code>diagDominantFlag = all(diag(A) >= (sum(A, 2) - diag(A))); </code></pre> <p>Thus replacing your double <code>for</code> loop with a one-liner.</p> |
37,996,425 | 0 | Resize CGSize to the maximum with keeping the aspect-ratio <p>I have a <code>CGSize</code> objects that I need to send to my server. The maximum size I can send to the server is 900*900 (900 width/900 height).</p> <p>There are some objects that are larger the 900*900 and I want to write a function that resizes them to the maximum (as I already say, the maximum is 900*900) but to keep the aspect ratio.</p> <p>For example: if I have an object that is 1,000px width and 1,000px height I want the function to return a 900*900 object. If I have an object that is 1920px width and 1080px height I want it to return the maximum size possible with keeping the ratio.</p> <p>Anyone have any idea how can I do that?</p> <p>Thank you!</p> <p><strong>OriginalUser2 answer:</strong></p> <p>I've tried this code:</p> <pre><code>let aspect = CGSizeMake(900, 900) let rect = CGRectMake(0, 0, 1920, 1080) let final = AVMakeRectWithAspectRatioInsideRect(aspect, rect) </code></pre> <p><code>final</code> is <code>{x 420 y 0 w 1,080 h 1,080}</code>, I can't understand why the <code>x = 420</code>, but anyway <code>1080*1080</code> is not in the same aspect ratio as <code>1920*1080</code> and it's bigger than <code>900*900</code>.</p> <p>Can you explain a bit more?</p> |
19,281,269 | 0 | <p>There are not built-in facilities for this in Lua. Try <a href="http://luasocket.luaforge.net/" rel="nofollow">LuaSocket</a>.</p> |
6,779,371 | 0 | <p>HTTP is a pretty simple protocol, the following should get the status code out pretty reliably (updated to be a tad more robust):</p> <pre><code>int statusCodeStart = httpString.IndexOf(' ') + 1; int statusCodeEnd = httpString.IndexOf(' ', statusCodeStart); return httpString.Substring(statusCodeStart, statusCodeEnd - statusCodeStart); </code></pre> <p>If you really wanted to you could add a sanity check to make sure that the string starts with "HTTP", but then if you wanted robustness you could also just implement a HTTP parser.</p> <p>To be honest this would probably do! :-)</p> <pre><code>httpString.Substring(9, 3); </code></pre> |
5,416,251 | 0 | <p>Well you could certainly remove the <code>ToList</code> call - that's not helping you at all.</p> <p>You could make the calling code simpler like this:</p> <pre><code>var dictionary = allDays.Where(n => n.Value.IsRequested || n.Value.IsApproved) .ToDictionary(x => x.Key, x => x.Value); var mostDays = new SortedList<DateTime, CalendarDay>(dictionary); </code></pre> <p>... but that's going to build an intermediate <code>Dictionary<,></code>, so it's hardly efficient.</p> <p>Another option is that you could write your own <code>ToSortedList</code> extension method, e.g.</p> <pre><code>public static SortedList<TKey, TValue> ToSortedList<TSource, TKey, TValue> (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector) { // TODO: Argument validation var ret = new SortedList<TKey, TValue>(); foreach (var element in source) { ret.Add(keySelector(element), valueSelector(element)); } return ret; } </code></pre> <p>Then the calling code will just be:</p> <pre><code>var mostDays = allDays.Where(n => n.Value.IsRequested || n.Value.IsApproved) .ToSortedList(x => x.Key, x => x.Value); </code></pre> <p>I suspect this should be reasonably efficient, as it will always be adding values to the <em>end</em> of the list during construction.</p> <p>(For a complete job you'd want to add overloads accepting custom key comparers etc... see <code>ToDictionary</code>.)</p> |
32,461,397 | 0 | <p>the second <code>r.index('something')</code> will find the first one. You need something like:</p> <pre><code>a = str(r[r.index('word001'):r.index('#something')]) b = str(r[r.index('word002'):r.index('#something', start=r.index('#something')+1)]) </code></pre> <p>This will find the first <code>#something</code> and continue searching after that one.</p> <p>But that is not very good if you have more <code>word</code> patterns you need to find. Maybe better would be:</p> <pre><code>import re re.findall("(word\\d+%20)", "word001%20#something=637448word002%20#something=278364") # this returns word0001%20 and word002%20 </code></pre> |
33,442,910 | 0 | <p>Setting HISTFILE=/dev/null is disabled in development version of Tramp, because there is a bug in bash which corrupts /dev/null then. Likely, the security department of your company is concerned about this.</p> <p>If you have a recent Tramp (say the one bundled with Emacs 24.5), setting HISTFILE=/dev/null is hardwired in tramp-sh.el. You would need to patch it there.</p> <p>If you install a newer Tramp version like 2.2.12 (see the Tramp manual how to do this), you could use the variable <code>tramp-histfile-override</code> to set your own value. Per default it is set to ".tramp_history", but there are also other possibilities. See the docstring of that variable.</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.