pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
39,513,338 | 0 | <p>The <a href="https://en.wikipedia.org/wiki/List_of_HTTP_header_fields" rel="nofollow">content type</a> in a request header is the content of what you're <em>sending</em>. You're not sending an Excel file, you're requesting an excel file.</p> <p>When you send the <code>"application/x-www-form-urlencoded"</code> content type header, you're telling the server that your parameters must be read in the URL (<a href="https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1" rel="nofollow">this is the standard way</a>).</p> |
40,774,613 | 0 | Finding nearest College via API <p>I am working on an app that wants to detect the nearest college to the user's current location. I've been trying to figure out how to do it and came across this post (<a href="http://stackoverflow.com/questions/16561296/finding-nearest-locations-using-google-map-api">Finding nearest locations using Google Map api</a> )</p> <p>However, I am trying to think of a more efficient way to do this. They suggest storing all the geopoints and looping through and finding the shortest ones. However, when there are thousands of colleges, that seems like sorta hefyty to be running everysingle time I load the app.</p> <p>Is there anything out there that given my longitude and latitude would just tell me the closest one? I just think this seems like a lot of processing for the app to do every single time it is opened...</p> |
5,805,173 | 0 | <p>All the qt widget classes can be styled via <a href="http://doc.qt.nokia.com/latest/stylesheet-reference.html" rel="nofollow">stylesheets</a>, depending where create your popup (designer, or in code) assign it a stylesheet with the look that you want it to have. You can test stylesheets in designer by assigning a style to a widget using the context menu of the widget</p> <p>After further review, the <code>QSystemTrayIcon::showMessage()</code> call puts up a <em>system</em> notification. Which I don't know if it can be styled. The <code>qsystemtrayicon_win.cpp</code> file in the qt distribution shows a workaround and shows a way of how to find the location of the icon in the tray (see <code>QSystemTrayIconSys::findIconGeometry</code>). Once you have the location you could pop up your own window at that location. I did not look to deep, I don't know if you can get to the location for the icon with the information that you have on the public side of Qt. You might have to go all windows with that.</p> |
31,572,280 | 0 | <p>It is not ideal to use $_GET with passwords as anyone can see it in the browser, anyway it's very easy to do. All you have to do is change your form tag to the following:</p> <pre><code><form action="login.php" method="get"> </code></pre> <p>As you can see method is now get instead of post. In your php just use <code>$_GET</code> instead of <code>$_POST</code></p> <p>If you'd rather the options of your php script to use POST or GET you can always check if GET is set, if so use GET otherwise check if there is a POST. Therefore using the form will use POST (more secure) and in the url it will use GET. Try the following code:</p> <pre><code><?php if(isset($_GET['username']) && isset($_GET['password'])){ $username = $_GET['username']; $password = $_GET['password']; $submitted = true; } else if(isset($_POST['username']) && isset($_POST['password'])){ $username = $_POST['username']; $password = $_POST['password']; $submitted = true; } if($submitted){ // Do your code here.. // $username will give the username and $password will give the password. } ?> </code></pre> <p>Hope it helps!</p> |
32,588,491 | 0 | <pre><code>DECLARE @StartDate DATETIME, @EndDate DATETIME SET @StartDate = dateadd(mm, -1, getdate()) SET @StartDate = dateadd(dd, datepart(dd, getdate())*-1, @StartDate) SET @EndDate = dateadd(mm, 1, @StartDate) set @StartDate = DATEADD(dd, 1 , @StartDate) </code></pre> |
34,689,702 | 0 | <p>Your need tells that your strategy is not correct. And even if it worked, your code readability and maintenability will not be good! Anyway, I suggest that you create a function instead of your procedure, which you may call whenever needed and replace the original variable with the output.</p> <p>An Example: </p> <pre><code>Function doStuff ($input){ treat_input; Return output; } $x = doStuff ($×); .... </code></pre> <p>Well, I know you will need to call this function as many times as number of variables you have. But trust me, this is the way that you have to go according to long experience in maintaining scripts.</p> |
1,713,835 | 0 | <p>This is covered in the <a href="https://jax-ws.java.net/2.2.10/docs/ch05.html#section-jaxws-faq6" rel="nofollow noreferrer">FAQ</a> of JAX-WS:</p> <blockquote> <p><strong>Q. How can I change the Web Service address dynamically for a request ?</strong></p> <pre><code>((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "..."); </code></pre> </blockquote> |
22,470,626 | 0 | How to correctly configure Facebook Connect for PhoneGap Build version 3.3? <p>I’m not finding any recent documentation on how to correctly install Facebook Connect on Android for PhoneGap Build version 3.3. Each time I try to authenticate a user on an android emulator nothing happens. I’m not even sure I am doing the process right. My question is, where in the process am I going wrong?</p> <p>On PhoneGap’s plugins page for Facebook Connect, it states that you place the plugin XML into your config.xml. I have done so. I have already created an app on Facebook’s developer site and added the Android hash to Facebook.</p> <p>Originally it seemed that you also needed to include the JavaScript SDK in index.html, but that is not activating the sign in either when I call FB.login().</p> <p>I have the Facebook app installed on my emulator. <a href="https://github.com/phonegap-build/FacebookConnect/blob/962eb0a1c07935ff813e28aa9eaa5581f2e10416/README.md" rel="nofollow">These are the instructions that I have been following:</a></p> <p>What is the correct way to install Facebook connect for PhoneGap Build version 3.3?</p> |
36,777,279 | 0 | Trie implementation runtime error <p>I'm trying to implement a Trie in C++ but I'm getting runtime error... </p> <p>Here is my code:</p> <pre><code>#include <bits/stdc++.h> using namespace std; struct trie{ bool word = false; trie* adj [26]; trie(){} void add(char* s){ trie* t = this; while(s){ if(t->adj[s[0] - 'a'] == NULL){ trie nova = create(s); t->adj[s[0] - 'a'] = &nova; return; } else{ t = t->adj[s[0] - 'a']; } s++; } } trie create(char* s){ trie t; trie* point = &t; while(s){ point->adj[s[0] - 'a'] = new trie(); point = point->adj[s[0] - 'a']; s++; } point->word = true; return t; } void seek(){ trie* t = this; run(t, ""); } void run(trie* t, string s){ if(t->word){ cout<<s<<"\n"; } for(int i = 0; i < 26; i++){ if(t->adj[i] != NULL){ run(t->adj[i], s + char('a' + i)); } } } }; int main(){ trie t; t.add("ball"); t.add("balloon"); t.add("cluster"); t.seek(); } </code></pre> <p>It works like that:</p> <ul> <li><p>suppose I'm adding a word;</p></li> <li><p>if the letter of the word isn't in the trie </p> <pre><code> if(t->adj[s[0] - 'a'] == NULL) </code></pre> <ul> <li>make new trie with void create and set t->adj[s[0] - 'a'] to that new trie</li> </ul></li> <li><p>else just go to the next letter and repeat the proccess</p> <pre><code> t = t->adj[s[0] - 'a']; </code></pre></li> </ul> <p>What am I doing wrong? I'm <em>new</em> at using pointers and I think I must have used one (or more) of them mistakenly... What is it wrong?</p> |
39,735,605 | 0 | <p>The code you have isn't for the Arduino but is written in a language called Processing. It will run on your PC and collect the data from the Arduino to be saved to a file. You need to download the <a href="https://processing.org/download/" rel="nofollow">Processing IDE</a> to compile the code and run it.</p> |
2,792,619 | 0 | <p>It's platform-specific. But you can cast it to a known type.</p> <pre><code>printf("%lld\n", (long long) time(NULL)); </code></pre> |
27,573,722 | 0 | <p>I had a similar problem, here is what i did:</p> <pre><code>{{ longString | limitTo: 20 }} {{longString.length < 20 ? '' : '...'}} </code></pre> |
39,013,435 | 0 | Android SMSManager sendTextMessage saves messages as draft sometimes <p>i am glad to be able to send SMS from an Android App using</p> <pre><code> SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(strNum, null, strTxt, null, null); </code></pre> <p>But in some cases, it saves the message as draft, instead of sending immidiately - why? some ideas? Or does somebody know - as a workaround - how can i send all SMS drafts?</p> |
7,159,655 | 0 | <p>It Seems that DataAvailable callback is getting called even when buffer is null.</p> <p>I modified a function in <code>WaveIn.cs</code> file and its working fine now. I am not sure if this is correct, but for now, this is working for me.</p> <pre><code>private void Callback(IntPtr waveInHandle, WaveInterop.WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved) { if (message == WaveInterop.WaveMessage.WaveInData) { GCHandle hBuffer = (GCHandle)waveHeader.userData; WaveInBuffer buffer = (WaveInBuffer)hBuffer.Target; if (buffer != null) { if (DataAvailable != null) { DataAvailable(this, new WaveInEventArgs(buffer.Data, buffer.BytesRecorded)); } if (recording) { buffer.Reuse(); } } else { if (RecordingStopped != null) { RecordingStopped(this, EventArgs.Empty); } } } </code></pre> <p>}</p> |
36,411,766 | 0 | <p>You should set the Adapter before adding the layoutManager </p> <pre><code> updateUI(); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); </code></pre> |
21,833,035 | 0 | How can I get a TCP server to send a message back to the client? <p>I'm at a complete loss as to how I can get my server app to send a message back to the client after the client sent a message. My goal is the client sends a message say "Hello" to the server the server receives the message then sends back to the client "hello to you"</p> <p>my question How do set up the part of the server sending a message and the client receiving the message?</p> <p>my server</p> <pre><code>public class MainActivity extends Activity { private ServerSocket serverSocket; Handler updateConversationHandler; Thread serverThread = null; public String serverIP = "127.0.0.1"; private InetAddress serverAddr; public static final int SERVERPORT = 4444; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); updateConversationHandler = new Handler(); this.serverThread = new Thread(new ServerThread()); this.serverThread.start(); } class ServerThread implements Runnable { public void run() { Socket socket = null; try { serverSocket = new ServerSocket(SERVERPORT); } catch (IOException e) { e.printStackTrace(); } while (!Thread.currentThread().isInterrupted()) { try { socket = serverSocket.accept(); CommunicationThread commThread = new CommunicationThread(socket); new Thread(commThread).start(); } catch (IOException e) { e.printStackTrace(); } } } } class CommunicationThread implements Runnable { private Socket clientSocket; private BufferedReader input; public CommunicationThread(Socket clientSocket) { this.clientSocket = clientSocket; try { this.input = new BufferedReader(new InputStreamReader(this.clientSocket.getInputStream())); } catch (IOException e) { e.printStackTrace(); } } public void run() { while (!Thread.currentThread().isInterrupted()) { try { String read = input.readLine(); updateConversationHandler.post(new updateUIThread(read)); } catch (IOException e) { e.printStackTrace(); } } } } class updateUIThread implements Runnable { private String msg; public updateUIThread(String str) { this.msg = str; } @Override public void run() { recieved.setText(""); if (msg != null){ recieved.setText(recieved.getText().toString()+"message recieved: "+ msg + “\n”); /* SEND MESSAGE */ } } } } </code></pre> <p>my client</p> <pre><code>public class MainActivity extends Activity { private Socket socket; private static final int SERVERPORT = 4444; public String serverIP= "127.0.0.1"; private InetAddress serverAddr; private Timer myTimer; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setServerIP(); setContentView(R.layout.main); new Thread(new ClientThread()).start(); } public void sendVerifiedMessage(byte message) throws IOException { PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true); out.println(message); /* receive message from client */ } public void run() { sendVerifiedMessage(“hello”); } } class ClientThread implements Runnable { @Override public void run() { try { InetAddress serverAddr = InetAddress.getByName(serverIP); socket = new Socket(serverAddr, SERVERPORT); connected = true; } catch (UnknownHostException e1) { e1.printStackTrace(); connected = false; } catch (IOException e1) { connected = false; e1.printStackTrace(); } } } } </code></pre> |
13,075,769 | 0 | lightbox for images not getting applied <p>i have some issue regarding LightBox for images</p> <p>issue is when i load images from external php file it is not showing the images in lightbox.</p> <pre><code> <script type="text/javascript"> $(document).ready(function(){ //Display Loading Image function Display_Load() { $("#loading").fadeIn(900,0); $("#loading").html("<img src='../images/lightbox-ico-loading.gif' />"); } //Hide Loading Image function Hide_Load() { $("#loading").fadeOut('slow'); }; //Default Starting Page Results Display_Load(); $("#content").load("images.php?page=1&uid=28", Hide_Load(), lightBox()); //Pagination Click $("#pagination li").click(function(){ Display_Load(); //Loading Data var pageNum = this.id; var uid = 1; uid = "<?php echo $id; ?>"; $("#content").load("images.php?page=" + pageNum + "&uid=" + uid, Hide_Load()); }); }); </script> </code></pre> <p>it loads all the images in below box but does not have any lightbox effect.</p> <pre><code><center><div id="loading" ></div> <div id="content"></div> </center> </code></pre> <p>normally to display images in lightbox we will do something like below and it is working fine at all other places then only above code is having problem.</p> <pre><code> <script type="text/javascript"> $(function() { $('#gallery a').lightBox(); }); </script> </code></pre> <p>can any one please share some tips about it.</p> <p>thank you advance.</p> |
15,020,505 | 0 | <p>The events in a DOM start somewhere in your tree going down to the element (capturing phase) and then they bubble up the DOM (bubbling phase).</p> <p>You can catch the event and stop it from propagating. It wont be propageted further then and wont call other event handlers (like your second function) which are attached to e.g. wrapping elements.</p> <p>In the event handler of the autocomplete you should call <code>stopPropagation()</code> on the event. Altough this doesnt work in all browsers. In IE prior to IE9 the method is called <code>cancelBubble(true)</code>.</p> <p>In order to prevent a browsers default behaviour you can do <code>event.preventDefault()</code></p> <p>You can read more on this by searching "Event Cancellation" or "Event Propagation", as this is a tricky topic in JavaScript</p> |
4,544,724 | 0 | <p>You'd have to cast to decimal for smaller numbers</p> <pre><code> select cast(power(cast(101 as float),50) as decimal(38,0)) % 221 </code></pre> <p>or</p> <pre><code> select power(cast(101 as decimal(38,0)),50) % 221 </code></pre> <p>This fails though with such a large number</p> <p>But then it makes no sense anyway for larger numbers.</p> <ul> <li>float is accurate to 15 signficant figures.</li> <li>101 ^ 50 = 1.64463182184388E+100</li> <li>the margin of error (float approximation) is about 82 orders of magnitude (1E+82) higher than your modulo 221</li> </ul> <p>Any answer from the modulo is utter rubbish</p> <p>Edit:</p> <p>Decimal goes to around 10^38</p> <p>Take a float number at 10^39, or 1E+39, then you are accurate to around 1E24 (15 signficant figures).</p> <p>Your modulo is 221 = 2.2E+2</p> <p>You margin of error ie 1E+24/2.2E+2 = 4.4E+21</p> <p>Just to be 100% clear, your accuracy is 4,400,000,000,000,000,000,000,000 times greater than your modulo.</p> <p>It isn't even approximate: it's <strong>rubbish</strong></p> |
25,130,034 | 0 | <p>For future reference,</p> <p>You should be using a WebService (ASMX) file to process and return your JSON. Remember that the javascript success block will only be called with a returned http 200 status code.</p> <p>If you ever get to using the MVC framework its even easier by just returning a JSON result type.</p> <p>If you wanted to keep the aspx hack, you can call the following to remove the HTML</p> <pre><code>response.clear(); response.write(yourJSON); response.end(); </code></pre> <p>But again i would discourage from doing this and recommend the dedicated service.</p> |
40,655,961 | 0 | <p>You can check <a href="https://github.com/baskerville/xdo" rel="nofollow noreferrer">xdo</a> which can do a decent job with minimal ressources.</p> |
10,039,596 | 0 | <p>Yep, jQuery has a <a href="http://api.jquery.com/checked-selector/" rel="nofollow">Checked Selector</a>:</p> <pre><code>var checkedBoxIds = $("input:checked").id(); </code></pre> |
19,257,166 | 0 | <p>Correct...and to launch you even further, check out this modification. </p> <p><a href="http://jsfiddle.net/Fv27b/2/" rel="nofollow">http://jsfiddle.net/Fv27b/2/</a></p> <p>Here, you'll see that not only are we combining the options, but we're creating our own binding entirely...which results in a much more portable extension of not just this view model, but any view model you may have in your project...so you'll only need to write this one once!</p> <pre><code>ko.bindingHandlers.colorAndTrans = { update: function(element, valAccessor) { var valdata = valAccessor(); var cssString = valdata.color(); if (valdata.transValue() < 10) cssString += " translucent"; element.className = cssString; } } </code></pre> <p>To invoke this, you just use it as a new data-bind property and can include as many (or as few) options as possible. Under this specific condition, I might have just provided $data, however if you're wanting a reusable option you need to be more specific as to what data types you need as parameters and not all view models may have the same properties.</p> <pre><code>data-bind="colorAndTrans: { color: color, transValue: number }" </code></pre> <p>Hope this does more than answer your question!</p> |
30,422,396 | 0 | <p>Try this and put profile image </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('img').on('click', function() { $('.hoverelement').toggle(); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.hoverelement { display: none; border: solid 1px; width: 200px; text-align: left; position: absolute; z-index: 999; top: 100px; } .container { position: relative; top: 45px; float: right; text-align: right; } img { width: 100px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container"> <img src="http://upload.wikimedia.org/wikipedia/commons/3/33/Vanamo_Logo.png" alt=""/> <div class="hoverelement"> <h1>your content here</h1> <p>put some content here</p> </div> </div></code></pre> </div> </div> </p> |
28,330,265 | 0 | iOS objective C NSData to NSString return nil <p><code>data</code> is downloaded from website, </p> <pre><code>NSString * html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; </code></pre> <p><code>html</code> is <code>nil</code>, but </p> <pre><code>NSString * html = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; </code></pre> <p>will have the content. Since the website contains Chinese characters, if using Ascii, the Chinese cannot be displayed. I guess there are some invalid UTF-8 in the website, so that make the first code not working.</p> <p>Is there any methods can keep using UTF-8 but ignore some invalid error?</p> |
7,046,328 | 0 | <pre><code>/*! * reads binary data into the string. * @status : OK. */ class UReadBinaryString { static std::string read(std::istream &is, uint32_t size) { std::string returnStr; if(size > 0) { CWrapPtr<char> buff(new char[size]); // custom smart pointer is.read(reinterpret_cast<char*>(buff.m_obj), size); returnStr.assign(buff.m_obj, size); } return returnStr; } }; class objHeader { public: std::string m_ID; // serialize std::ostream &operator << (std::ostream &os) { uint32_t size = (m_ID.length()); os.write(reinterpret_cast<char*>(&size), sizeof(uint32_t)); os.write(m_ID.c_str(), size); return os; } // de-serialize std::istream &operator >> (std::istream &is) { uint32_t size; is.read(reinterpret_cast<char*>(&size), sizeof(uint32_t)); m_ID = UReadBinaryString::read(is, size); return is; } }; </code></pre> |
26,172,961 | 0 | <p><a href="http://jsfiddle.net/9uppsLqa/5/" rel="nofollow">http://jsfiddle.net/9uppsLqa/5/</a></p> <pre><code>.arrow_box { border-radius: .1875em; z-index: 99; position: relative; box-shadow: 0 0 0 1px rgba(0,0,0,0.15),inset 0 0 0 1px rgba(255,255,255,0.6), 0 4px 2px -2px rgba(0,0,0,0.2),0 0 1px 1px rgba(0,0,0,0.15); background-repeat: repeat-x; background-position: 0 0; background-image: linear-gradient(to bottom,rgba(255,255,255,0.7) 0,rgba(255,255,255,0) 100%); background-color: #e1e1e1; margin-top: 3em; margin-left: .75em; margin-right: .75em; padding-left: 0; padding-bottom: 0; padding-right: 0; padding-top: 0; width: 340px; height: 160px; } .arrow_box:after, .arrow_box:before { border: 13px solid transparent; position: absolute; content: ''; left: 90%; bottom:100%; } .arrow_box:after { border-bottom-color: #fafafa; border-width: 14px; margin-left: -24px; } .arrow_box:before { border-bottom-color: #999; border-width: 15px; margin-left: -25px; } </code></pre> |
8,659,428 | 0 | <p>I know how.</p> <p>Let's say you have a <code>DataList</code> name myDataList, and a <code>TextBox</code> in it named by myTextBox.</p> <pre><code>foreach (DataListItem item in myDataList.Items) { TextBox myTextBox = (TextBox)item.FindControl("myTextBox"); string text = myTextBox.text; // Do whatever you need with that string value here } </code></pre> <p>This loops through all of the items in your <code>DataList</code> and places the value of your <code>TextBox</code> into a local string variable named "text". From there, you can do whatever else needs to be done.</p> |
19,816,451 | 0 | How to float text next to iframe <p>I'm trying to float text left of an iframe. I have the below, though it will not float. What needs to be changed? Canvas width is 800px</p> <pre><code><p class="float-left"></p> <iframe class="float-right" width="420" height="315" src="//www.youtube.com/embed/" frameborder="0" allowfullscreen></iframe> <div class="clear"></div> .float-left { position: relative; float: left; margin: 0px 0px 50px; width: 250; height: 100%; } .float-right { float: right; width: 65%; } </code></pre> |
33,955,850 | 0 | <p>In Excel, you can do it using an array formula to search for the next frequency which is in range:-</p> <pre><code>=MATCH(1,(B2:B$10>=49)*(B2:B$10<=51),0)-1 </code></pre> <p>if your frequencies start in B2.</p> <p>Must be entered in C2 with <kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>Enter</kbd></p> <p>Here is a modified version which allows for the case where the last frequency is out of range, assuming there are no blanks between frequency values and one or more blanks at the end:-</p> <pre><code>=MATCH(1,(B2:B$10>=49)*(B2:B$10<=51)+(B2:B$10=""),0)-1 </code></pre> <p><a href="https://i.stack.imgur.com/7SXYe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7SXYe.png" alt="enter image description here"></a></p> |
2,996,662 | 0 | ASP.net - Does a return statement in function stop the function? <p>Given the function</p> <pre><code>'Returns true if no cell is > 1 Function isSolutionValid() As Boolean Dim rLoop As Integer Dim cLoop As Integer For cLoop = 0 To canvasCols - 1 For rLoop = 0 To canvasRows - 1 If canvas(cLoop, rLoop) > 1 Then Return False End If Next Next Return True End Function </code></pre> <p>When 'return false' is fired, I'm assuming that the function is stopped at that point and there's no need for exit fors and things like that?</p> |
16,474,110 | 0 | <p>With PowerShell you're likely to find many different ways to do the same thing. Here's a way to do this as one-liner:</p> <pre><code>PS> 'Tom1Jerry02','abcd0asdf001','qwerty1' | Foreach {if ($_ -match '(\d+)$') {$matches[1]}} 02 001 1 </code></pre> |
28,206,222 | 0 | <p>If you want to specify a literal color value in a geom_segment, you should not include it in the <code>aes()</code>. For example using this test data</p> <pre><code>DF_for_plotting <- data.frame( variable=rep("StrpCnCor",4), value=c(0, 50.79330935, 81.127731, 100) ) </code></pre> <p>you can do</p> <pre><code>ggplot() + geom_segment(data=DF_for_plotting, aes(x=value[1], xend=value[2]-0.001, y=1, yend=1), colour="green", size=10) + geom_segment(data=DF_for_plotting, aes(x=value[2], xend=value[3]-0.001, y=1, yend=1), colour="blue", size=10) + geom_segment(data=DF_for_plotting, aes(x=value[3], xend=value[4]-0.001, y=1, yend=1), colour="red", size=10) </code></pre> <p><img src="https://i.stack.imgur.com/IX6yc.png" alt="enter image description here"></p> <p>or with hex colors</p> <pre><code>ggplot() + geom_segment(data=DF_for_plotting, aes(x=value[1], xend=value[2]-0.001, y=1, yend=1), colour="#9999CC", size=10) + geom_segment(data=DF_for_plotting, aes(x=value[2], xend=value[3]-0.001, y=1, yend=1), colour="#66CC99", size=10) + geom_segment(data=DF_for_plotting, aes(x=value[3], xend=value[4]-0.001, y=1, yend=1), colour="#CC6666", size=10) </code></pre> <p><img src="https://i.stack.imgur.com/OBrPF.png" alt="enter image description here"></p> <p>Although because you're not mapping anything to the color aesthetic, no legend will be provided.</p> <p>When you put it in the <code>aes()</code>, you're not specifying a literal value, you are just specifying a literal value to associate with a color it doesn't matter if you use <code>aes(color="red")</code> or <code>aes(color="determination")</code>; it just treats it as a literal character value and will use it's own color palate to assign a color to that character value. You can specify your own colors with <code>scale_fill_manual</code> For example</p> <pre><code>ggplot() + geom_segment(data=DF_for_plotting, aes(x=value[1], xend=value[2]-0.001, y=1, yend=1, colour="a"), , size=10) + geom_segment(data=DF_for_plotting, aes(x=value[2], xend=value[3]-0.001, y=1, yend=1, colour="b"), , size=10) + geom_segment(data=DF_for_plotting, aes(x=value[3], xend=value[4]-0.001, y=1, yend=1, colour="c"), size=10) + scale_color_manual(values=c(a="green",b="blue",c="red")) </code></pre> <p><img src="https://i.stack.imgur.com/TFmmf.png" alt="enter image description here"></p> <pre><code>ggplot() + geom_segment(data=DF_for_plotting, aes(x=value[1], xend=value[2]-0.001, y=1, yend=1, colour="a"), , size=10) + geom_segment(data=DF_for_plotting, aes(x=value[2], xend=value[3]-0.001, y=1, yend=1, colour="b"), , size=10) + geom_segment(data=DF_for_plotting, aes(x=value[3], xend=value[4]-0.001, y=1, yend=1, colour="c"), size=10) + scale_color_manual(values=c(a="#9999CC",b="#66CC99",c="#CC6666")) </code></pre> <p><img src="https://i.stack.imgur.com/F5s4o.png" alt="enter image description here"></p> <p>Here i called the three groups "a", "b", and "c" but you could also call then "green","blue","red" if you want -- it just seems odd to have a legend that tells you what color is green.</p> |
25,026,161 | 0 | <blockquote> <p>How do I read json with bash?</p> </blockquote> <p>You can use <a href="http://stedolan.github.io/jq/" rel="nofollow"><code>jq</code></a> for that. First thing you have to do is extract the list of hostnames and save it to a bash array. Running a loop on that array you would then run again a query for each hostname to extract each element based on them and save the data through redirection with the filename based on them as well.</p> |
5,917,442 | 0 | Getting the data of Ancestor node + XQuery-Sql <p>This is how my XML looks like : </p> <pre><code> <Product sequence_number="1" number="1543448904" id="S1" unit_number="1"> <consumer_narrative name="GLENN,GREGORY" date_filed="02/13/2009"> <message type="Consumer Comments">THE CONSUMER STATES THIS WAS NOT </message> <message type="Consumer Comments">THE PRODUCT REQUESTED.</message> </consumer_narrative></Product> <Product sequence_number="2" number="1543448905" id="S1" unit_number="1"> <consumer_narrative name="JOHN,GORDON" date_filed="08/23/2009"> <message type="Consumer Comments">THE CONSUMER STATES THAT</message> <message type="Consumer Comments">WRONG PRODUCT WAS SENT.</message> </consumer_narrative> </Product> </code></pre> <p>My Query : </p> <pre><code>SELECT tab.col.value('../@number', 'varchar(30)') [Claim Number], tab.col.value('../@name', 'varchar(30)') [Name], tab.col.value('../@date_filed', 'varchar(30)') [DateField], tab.col.value('@type', 'varchar(50)') [Type], tab.col.value('.', 'varchar(250)') [CustomerComments] FROM XMLTABLE AS B CROSS APPLY xmldocument.nodes('//Product/consumer_narrative/message') tab(col) WHERE B.XMLId = 123 </code></pre> <p>Gives me "null" for Claim Number. What should I have in the place of ../@number to get the claim number.</p> |
22,675,938 | 0 | <p>There's nothing special here about it being main(). The same will happen if you do this for any function. Consider this example:</p> <p>file1.cpp:</p> <pre><code>#include <cstdio> void stuff(void) { puts("hello there."); } void (*func)(void) = stuff; </code></pre> <p>file2.cpp:</p> <pre><code>extern "C" {void func(void);} int main(int argc, char**argv) { func(); } </code></pre> <p>This will also compile, and then segfault. It is essentially doing the same thing for the function func, but because the coding is explicit it now more apparently looks wrong. main() is a plain C type function with no name mangling, and just appears as a name in the symbol table. If you make it something other than a function, you get a segfault when it executes a pointer. </p> <p>I guess the interesting part is that the compiler will allow you to define a symbol called main when it is already implicitly declared with a different type. </p> |
10,616,506 | 0 | <p>If you use XIBs make mask for your subviews as shown here:</p> <p><img src="https://i.stack.imgur.com/Av5v6.png" alt="Center without resizing of subviews"></p> <p>or here:</p> <p><img src="https://i.stack.imgur.com/xOduO.png" alt="Center with resizing of subview"></p> <p>If you prefer to use code use posted one by @adali.</p> |
38,145,574 | 0 | <p>You can use the layout and code below to achieve the desired effect. <a href="https://gist.github.com/trivalent/00526294fa38072a6034f5dc5910824a" rel="nofollow">Source code gist</a></p> <p>What I have used is get the width of the text + the time layout and check if this exceeds the container layout width, and adjust the height of the container accordingly. We have to extend from FrameLayout since this is the one which allows overlapping of two child views. </p> <p>This is tested to be working on English locale. Suggestions and improvements are always welcome :)</p> <p>Hope I've helped someone looking for the same solution.</p> |
15,024,854 | 0 | <p>This isn't possible. There's no way to know with certainty that <code>"11/4/2012 1:04:28 AM"</code> is PST and not actually an observation between <code>"11/4/2012 12:51:20 AM"</code> and <code>"11/4/2012 1:13:08 AM"</code> PDT.</p> <p>If you're certain the observations are ordered in the file, you could convert them to <code>POSIXt</code> and take the <code>diff</code> of the vector. Any negative values will be DST changes. You may miss some, however, if the time between observations across a DST change is greater than 1 hour.</p> <pre><code>Lines <- "11/4/2012 12:51:20 AM 11/4/2012 01:13:08 AM 11/4/2012 01:24:58 AM 11/4/2012 01:40:28 AM 11/4/2012 01:48:08 AM 11/4/2012 01:54:08 AM 11/4/2012 01:56:58 AM 11/4/2012 01:04:28 AM 11/4/2012 01:05:48 AM 11/4/2012 01:07:18 AM 11/4/2012 01:15:00 AM 11/4/2012 01:39:08 AM 11/4/2012 02:05:38 AM" x <- scan(con <- textConnection(Lines), what="", sep="\n") close(con) diff(strptime(x, format="%m/%d/%Y %I:%M:%S %p")) # Time differences in mins # [1] 21.800000 11.833333 15.500000 7.666667 6.000000 2.833333 # [7] -52.500000 1.333333 1.500000 7.700000 24.133333 86.500000 </code></pre> |
23,989,955 | 0 | <p>It's not one json string but an array of json strings. You have to first loop thru the array, parse the json and show the variables that you want in your html with jQuery.</p> <p>You can find a lot of info on the internet and stackoverflow on this subject.</p> |
5,180,309 | 0 | <p>I would use <a href="http://www.clutter-project.org/" rel="nofollow">clutter</a>, for details use the clutter examples, they are pretty nice.</p> <p><strong>Edit:</strong></p> <p>If you can not use clutter, you may have a look at <a href="http://cairographics.org/" rel="nofollow">cairo</a> which also has some neat examples on the given homepage</p> |
12,572,211 | 0 | <p>So apparently, you can't just take any temporary key and sign the APPX with it. In particular the certificate subject lines must match(the "publisher name"). I do not know of a better way of determining what the subject line much actually be so bare with me. First, try to use signtool and sign the APPX file with any temporary key. Now go to Event Viewer. Then to Applications and Services and then Microsoft and then Windows and then AppxPackaging and finally Microsoft-Windows-AppxPackages/Operational. There should be an error event that just happened from that build. Check it. It should say something like</p> <pre><code>Error 0x800700B: The app manifest publisher name (CN=random-hex-number) must match the subject name of the signing certificate (CN=MyWrongName) </code></pre> <p>So, now make sure to hang on to that random-hex-number. That needs to be the subject line of the certificate and is the cause of the error. To generate a working certificate:</p> <pre><code>makecert.exe mycert.cer -r -n "CN=random-hex-number" -$ individual -sv private.pkv -pe -cy end pvk2pfx -pvk private.pkv -spc mycert.cer -pfx mytemporarykey.pfx </code></pre> <p>Now finally, you should have a temporary key that will work with signtool!</p> <p>Hopefully this answers serves other people well. </p> |
32,024,168 | 0 | <p>Let's take an specific example and figure out what it does in the kernel 4.1, e.g. <code>IHEX</code>.</p> <p><strong>Find what a code does</strong></p> <p>Just run:</p> <pre><code>make SHELL='sh -x' </code></pre> <p>How that works: <a href="http://stackoverflow.com/a/32010960/895245">http://stackoverflow.com/a/32010960/895245</a></p> <p>If we grep the output for <code>IHEX</code>, we find the lines:</p> <pre><code>+ echo IHEX firmware/e100/d101s_ucode.bin IHEX firmware/e100/d101s_ucode.bin + objcopy -Iihex -Obinary /home/ciro/git/kernel/src/firmware/e100/d101s_ucode.bin.ihex firmware/e100/d101s_ucode.bin </code></pre> <p>so we conclude that <code>IHEX</code> does a <code>objcopy -Iihex</code>.</p> <p><strong>Find where a code is defined</strong></p> <p>Every kernel command must be defined with something like:</p> <pre><code>quiet_cmd_ihex = IHEX $@ cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ $(obj)/%: $(obj)/%.ihex $(call cmd,ihex) </code></pre> <p>for the verbosity settings (e.g. <code>V=1</code> and <code>make -s</code>) to work.</p> <p>So in general, you just have to</p> <pre><code>git grep 'cmd.* = CODE' </code></pre> <p>to find <code>CODE</code>.</p> <p>I have explained in detail how this system works at: <a href="http://stackoverflow.com/a/32023861/895245">http://stackoverflow.com/a/32023861/895245</a></p> <p><strong>Get the list of all codes</strong></p> <pre><code>make | grep -E '^ ' | sort -uk1,1 </code></pre> <p><strong>CC and CC [M]</strong></p> <p>Defined in <code>scripts/Makefile.build</code>:</p> <pre><code>quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< </code></pre> <p>and the <code>[M]</code> comes from the <a href="http://stackoverflow.com/questions/32023711/what-is-the-meaning-of-a-variable-defined-on-the-same-line-of-a-rule-targets-pre">target specific variables</a>:</p> <pre><code>$(real-objs-m) : quiet_modtag := [M] $(real-objs-m:.o=.i) : quiet_modtag := [M] $(real-objs-m:.o=.s) : quiet_modtag := [M] $(real-objs-m:.o=.lst): quiet_modtag := [M] $(obj-m) : quiet_modtag := [M] </code></pre> <p>It is then called through:</p> <pre><code>$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE [...] $(call if_changed_rule,cc_o_c) define rule_cc_o_c [...] $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ </code></pre> <p>where <code>if_changed_rule</code> is defined in <code>scripts/Kbuild.include</code> as:</p> <pre><code>if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ $(rule_$(1))) </code></pre> <p>and <code>Kbuild.include</code> gets included on the top level Makefile.</p> <p><strong>LD</strong></p> <p>There are a few versions, but the simplest seems to be:</p> <pre><code>quiet_cmd_link_o_target = LD $@ cmd_link_o_target = $(if $(strip $(obj-y)),\ $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ $(cmd_secanalysis),\ rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) $(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target) </code></pre> <p>and in <code>scripts/Kbuild.include</code>:</p> <pre><code># Execute command if command has changed or prerequisite(s) are updated. # if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) </code></pre> |
11,910,787 | 0 | <p>It was most likely an issue of permissions, but I never got it to work on its own (might've been something to do with using a Windows server). Anyway, my co-worker tried a different Linux server and got it to run fine. Thanks for the feedback still, CBroe.</p> |
30,281,143 | 0 | React.js creating a table with a dynamic amount of rows with an editable column <p>I am trying to create a react.js table that syncs with a leaflet map. I have this data and I am able to get the data properly, but I cannot create a table correctly. I am able to see the headers because they are hardcoded, but I am not able to see the rows. I also have a picture to explain the data at the console.log() points in the code. Here is the code:</p> <pre><code>/* Table React Component */ var TABLE_CONFIG = { sort: { column: "Zone", order: "desc" }, columns: { col1: { name: "Zone", filterText: "", defaultSortOrder: "desc" }, col2: { name: "Population", filterText: "", defaultSortOrder: "desc" } } }; var Table = React.createClass({ getInitialState: function() { var tabledata = []; var length = _.size(testJSON.zones); for(i = 0; i < length; i++) { var name = _.keys(testJSON.zones)[i]; var population = testJSON.zones[name].population.value; if(name == "default") { population = testJSON.zones[name].population.default.value; } tabledata[i] = {name, population}; } console.log(tabledata); return {zones: tabledata}; }, render: function() { var rows = []; this.state.zones.forEach(function(zone) { rows.push(<tr Population={zone.population} Zone={zone.name} />); }.bind(this)); console.log(rows); return ( <table> <thead> <tr> <th>Zone</th> <th>Population</th> </tr> </thead> <tbody>{rows}</tbody> </table> ); } }); </code></pre> <p>Here you can see the <code>console.log(tabledata)</code> line in full as well as the first object in <code>console.log(rows)</code></p> <p><img src="https://i.stack.imgur.com/wTkbV.png" alt="Zone name and population"></p> <p>I would like to see something like the picture below. Please note I want to Zone column to not be editable input, but the population to be editable: </p> <p><img src="https://i.stack.imgur.com/0uk4h.png" alt="Desired Table"></p> |
7,345,130 | 0 | Problem while consuming external webservice using WSClient <p>i am using wsclient plugin to consume external web services.</p> <pre><code> proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader) proxy.initialize() result = proxy.CelsiusToFahrenheit(0) println "You are probably freezing at ${result} degrees Farhenheit" </code></pre> <p>when i execute this sample code, i am getting <code>ServiceConstructionException</code> error.</p> <p>Stacktrace as follows:</p> <pre><code>org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve URL "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL" at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.composeUrl(DynamicClientFactory.java:611) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:251) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:196) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:175) at groovyx.net.ws.AbstractCXFWSClient.createClient(AbstractCXFWSClient.java:198) at groovyx.net.ws.WSClient.initialize(WSClient.java:107) at groovyx.net.ws.IWSClient$initialize.call(Unknown Source) at ConsoleScript2.run(ConsoleScript2:5) Caused by: java.net.ConnectException: Connection timed out: connect at org.apache.cxf.resource.URIResolver.tryFileSystem(URIResolver.java:161) at org.apache.cxf.resource.URIResolver.<init>(URIResolver.java:90) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.composeUrl(DynamicClientFactory.java:603) ... 7 more </code></pre> <p>i couldn't find what is wrong. Please help me.</p> |
1,160,590 | 0 | <ul> <li><a href="http://stackoverflow.com/questions/1159956/how-to-convert-powerbasic-types-to-vb6-types/1160183#1160183">Jim's answer</a> looks good. I'd also suggest looking at the <a href="http://vb.mvps.org/tips/vb5dll.asp" rel="nofollow noreferrer">Microsoft advice</a> on writing C DLLs to be called from VB. Originally released with VB5 but still relevant to VB6. It explains the structure packing etc. </li> <li>EDIT. Also worth a look: VB6 guru Karl Peterson <a href="http://vb.mvps.org/articles/ap199911.asp" rel="nofollow noreferrer">discusses</a> how to deal with structures containing pointers in VB6.</li> </ul> |
33,628,226 | 0 | <p><code><jenkins_url>/computer/</code> shows os and architecture for each node:</p> <pre><code>[online] node1 Linux (i386) [online] node2 SunOS (sparcv9) [online] node3 Linux (amd64) [online] node4 Windows Server 2008 R2 (amd64) [online] node5 Windows 7 (x86) </code></pre> <p>If you want to distinguish linux distros - jenkins could not distinguish them - you could put distro in node description and/or labels if you need it</p> |
15,654,296 | 0 | Unable to instantiate service on adding intent.setClassName(context, ProcessIntent.class.getName()); <p>I am developing an application which uses Google Cloud Messaging. I am referring to this link to start making the application. </p> <blockquote> <p><a href="http://developer.android.com/google/gcm/gcm.html" rel="nofollow">http://developer.android.com/google/gcm/gcm.html</a></p> </blockquote> <p>But when I enter the line intent.setClassName(context, ProcessIntent.class.getName()); in ProcessIntent.java class, I get a "Could not instantiate service com.venky.ProcessIntent" error. The java code is below.</p> <pre><code> package com.venky.gcmexample; import android.app.IntentService; import android.content.Context; import android.content.Intent; import android.os.PowerManager; import android.util.Log; import android.widget.Toast; public class ProcessIntent extends IntentService { public ProcessIntent(String name) { super(name); } private static PowerManager.WakeLock sWakeLock; private static final Object LOCK = ProcessIntent.class; private static final String TAG = "ProcessIntent"; @Override protected void onHandleIntent(Intent intent) { try { String action = intent.getAction(); if (action.equals("com.google.android.c2dm.intent.REGISTRATION")) { handleRegistration(intent); } else if (action.equals("com.google.android.c2dm.intent.RECEIVE")) { handleMessage(intent); } } finally { synchronized(LOCK) { sWakeLock.release(); } } } private void handleMessage(Intent intent) { } private void handleRegistration(Intent intent) { String registrationId = intent.getStringExtra("registration_id"); String error = intent.getStringExtra("error"); String unregistered = intent.getStringExtra("unregistered"); // registration succeeded if (registrationId != null) { // store registration ID on shared preferences // notify 3rd-party server about the registered ID Toast.makeText(this, registrationId, Toast.LENGTH_SHORT).show(); Log.d("handleRegistration", "got registration Id"); } // unregistration succeeded if (unregistered != null) { // get old registration ID from shared preferences // notify 3rd-party server about the unregistered ID Toast.makeText(this, registrationId, Toast.LENGTH_SHORT).show(); Log.d("handleRegistration", "un registration Id"); } // last operation (registration or unregistration) returned an error; if (error != null) { if ("SERVICE_NOT_AVAILABLE".equals(error)) { // optionally retry using exponential back-off // (see Advanced Topics) Toast.makeText(this, error, Toast.LENGTH_SHORT).show(); Log.d("handleRegistration", error); } else { // Unrecoverable error, log it Toast.makeText(this, error, Toast.LENGTH_SHORT).show(); Log.d("handleRegistration", error); Log.i(TAG, "Received error: " + error); } } } static void processIntent(Context context, Intent intent){ Toast.makeText(context, "Intent Service started successfully", Toast.LENGTH_SHORT).show(); Log.d("ProcessIntent", "Intent Service started successfully"); synchronized(LOCK) { if (sWakeLock == null) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); sWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "my_wakelock"); } } sWakeLock.acquire(); intent.setClassName(context, ProcessIntent.class.getName()); context.startService(intent); Toast.makeText(context, "reached end of processIntent", Toast.LENGTH_SHORT).show(); } } </code></pre> <p>There are two other java files as shown below and also the manifest. MyBroadcastReceiver.java :</p> <pre><code>package com.venky.gcmexample; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import android.widget.Toast; public class MyBroadcastReceiver extends BroadcastReceiver { @Override public final void onReceive(Context context, Intent intent) { Toast.makeText(context, "Recieved a broadcast intent", Toast.LENGTH_SHORT).show(); Log.d("MyBroadcstReceiver", "Recieved an intent broadcast"); ProcessIntent.processIntent(context, intent); setResult(Activity.RESULT_OK, null, null); } } </code></pre> <p>MainActivity.java</p> <pre><code>package com.venky.gcmexample; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; import android.app.Activity; import android.app.PendingIntent; import android.content.Intent; public class MainActivity extends Activity implements OnClickListener{ Button bReg, bUnreg; String senderID = "369107456320"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bReg = (Button) findViewById(R.id.bReg); bUnreg = (Button) findViewById(R.id.bUnreg); bReg.setOnClickListener(this); bUnreg.setOnClickListener(this); } @Override public void onClick(View v) { switch(v.getId()){ case(R.id.bReg): Intent regIntent = new Intent("com.google.android.c2dm.intent.REGISTER"); regIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); regIntent.putExtra("sender", senderID); Toast.makeText(this, "Registration Started", Toast.LENGTH_SHORT).show(); Log.d("Main Activity bReg", "Registration Started"); startService(regIntent); break; case(R.id.bUnreg): Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER"); unregIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); Toast.makeText(this, "Unregistration Started", Toast.LENGTH_SHORT).show(); Log.d("Main Activity bUnreg", "Unregistration Started"); startService(unregIntent); } } } </code></pre> <p>AndroidManifest.xml</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.venky.gcmexample" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" /> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.GET_ACCOUNTS"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <permission android:name="com.venky.gcmexample.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.venky.gcmexample.permission.C2D_MESSAGE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.venky.gcmexample.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name="com.venky.gcmexample.MyBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.venky.gcmexample" /> </intent-filter> </receiver> <service android:name=".ProcessIntent" /> </application> </manifest> </code></pre> <p>The error log is :</p> <pre><code>03-27 13:24:50.405: D/WindowManagerImpl(20132): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@40793c90 03-27 13:24:55.400: D/View(20132): onTouchEvent: viewFlags: 0x18004001 03-27 13:24:55.400: D/View(20132): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false 03-27 13:24:55.420: D/Main Activity bReg(20132): Registration Started 03-27 13:24:55.450: D/WindowManagerImpl(20132): addView, new view, mViews[1]: android.widget.LinearLayout@4079e3c0 03-27 13:24:57.431: D/WindowManagerImpl(20132): finishRemoveViewLocked, mViews[1]: android.widget.LinearLayout@4079e3c0 03-27 13:24:59.413: D/MyBroadcstReceiver(20132): Recieved an intent broadcast 03-27 13:24:59.423: D/ProcessIntent(20132): Intent Service started successfully 03-27 13:24:59.443: D/WindowManagerImpl(20132): addView, new view, mViews[1]: android.widget.LinearLayout@407a1cb0 03-27 13:24:59.453: D/dalvikvm(20132): newInstance failed: no <init>() 03-27 13:24:59.453: D/AndroidRuntime(20132): Shutting down VM 03-27 13:24:59.453: W/dalvikvm(20132): threadid=1: thread exiting with uncaught exception (group=0x4028f5a0) 03-27 13:24:59.463: E/AndroidRuntime(20132): FATAL EXCEPTION: main 03-27 13:24:59.463: E/AndroidRuntime(20132): java.lang.RuntimeException: Unable to instantiate service com.venky.gcmexample.ProcessIntent: java.lang.InstantiationException: com.venky.gcmexample.ProcessIntent 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2287) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.app.ActivityThread.access$2500(ActivityThread.java:135) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1118) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.os.Handler.dispatchMessage(Handler.java:99) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.os.Looper.loop(Looper.java:150) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.app.ActivityThread.main(ActivityThread.java:4389) 03-27 13:24:59.463: E/AndroidRuntime(20132): at java.lang.reflect.Method.invokeNative(Native Method) 03-27 13:24:59.463: E/AndroidRuntime(20132): at java.lang.reflect.Method.invoke(Method.java:507) 03-27 13:24:59.463: E/AndroidRuntime(20132): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 03-27 13:24:59.463: E/AndroidRuntime(20132): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 03-27 13:24:59.463: E/AndroidRuntime(20132): at dalvik.system.NativeStart.main(Native Method) 03-27 13:24:59.463: E/AndroidRuntime(20132): Caused by: java.lang.InstantiationException: com.venky.gcmexample.ProcessIntent 03-27 13:24:59.463: E/AndroidRuntime(20132): at java.lang.Class.newInstanceImpl(Native Method) 03-27 13:24:59.463: E/AndroidRuntime(20132): at java.lang.Class.newInstance(Class.java:1409) 03-27 13:24:59.463: E/AndroidRuntime(20132): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2284) 03-27 13:24:59.463: E/AndroidRuntime(20132): ... 10 more </code></pre> <p>The error goes away when I comment out the line</p> <blockquote> <p>intent.setClassName(context, ProcessIntent.class.getName());</p> </blockquote> <p>But the application the doesnot show the registration ID toast from the onHandleIntent() method.</p> |
20,134,620 | 0 | <p>The <a href="https://github.com/ServiceStack/ServiceStack/tree/master/tests/ServiceStack.AuthWeb.Tests" rel="nofollow">ServiceStack.AuthWeb.Tests</a> is an ASP.NET WebHost showing <a href="https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.AuthWeb.Tests/AppHost.cs#L78" rel="nofollow">all the ServiceStack AuthProviders</a> working within a single app. </p> <p>Note the <strong>OAuth2</strong> providers use additional configuration specified in the <a href="https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.AuthWeb.Tests/Web.config" rel="nofollow">Web.config</a> which requires that you register your own application to get your Consumer Key and Secret for your app. For testing purposes you can use the ServiceStack Test keys already embedded in the Web.config. </p> <p>The <a href="https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization#oauth-configuration" rel="nofollow">OAuth2 section in the Authentication wiki</a> provides the urls where you can register your application for each provider.</p> |
27,138,430 | 0 | <p>it is possible, however keep in mind that the user will have to have "Allow installation of non-Market-applications/unknown sources" enabled in their settings.</p> |
29,472,625 | 0 | <p>Do you see this behavior when you start Emacs without your init file (<code>emacs -Q</code>)? I doubt it. If not, then recursively bisect your init file to find out what is causing the problem.</p> <p>The minibuffer uses its own keymaps, which are local and which therefore take precedence over global keymap bindings.</p> <p>However, any minor-mode keymaps take precedence over local keymaps. So if, for example, you have a (global) minor mode turned on that binds <code><tab></code> then that will override any binding for that key in the minibuffer keymaps.</p> <p>Another thing you can do is simply bind whatever command you want to <code><tab></code> in the minibuffer keymaps. But again, you should not need to do that, if you want the usual <code><tab></code> behavior for the minibuffer.</p> <p>[Another possible confusion: Some things, such as Isearch, which you might think use the minibuffer do not use it. Isearch uses its own keymap, <code>isearch-mode-map</code>.]</p> <hr> <p><strong>UPDATE after your comment:</strong></p> <p>Assigning a key in the global map, as you have done, should not affect what that key does in the minibuffer, provided it has a different binding in the minibuffer keymaps. <code>TAB</code> is typically bound in all of the minibuffer completion keymaps (but not in the non-completion minibuffer keymaps).</p> <p>See the Elisp manual, nodes <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/Completion-Commands.html" rel="nofollow"><code>Completion Commands</code></a> and <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/Text-from-Minibuffer.html" rel="nofollow"><code>Text from Minibuffer</code></a> for information about the minibuffer keymaps.</p> <p>To see what the current bindings are for a keymap that is associated with a variable (such as <code>minibuffer-local-completion-map</code>), load library <a href="http://www.emacswiki.org/emacs/download/help-fns%2b.el" rel="nofollow"><strong><code>help-fns+.el</code></strong></a> and use <strong><code>C-h M-k</code></strong> followed by the keymap variable's name. (See <a href="http://www.emacswiki.org/emacs/HelpPlus" rel="nofollow"><strong>Help+</strong></a> for more information about the library.)</p> <p>If you do not want <code>TAB</code> to use your global command binding in the non-completion minibuffer maps (<code>minibuffer-local-map</code>, <code>minibuffer-local-ns-map</code>), then just bind it in those maps to whatever command you like. But for the completion maps you should not need to do anything - <code>TAB</code> should already be bound there.</p> <hr> <p>Did you try <code>emacs -Q</code>, to see if something in your init file is interfering? If not, do that first.</p> |
32,902,977 | 0 | play framework test connection refused <p>I have a huge problem with my play 2.4 application. Every time I try to start my application with <code>activator test</code>, I get the following error:</p> <pre><code>java.net.ConnectException: Connection refused: localhost/127.0.0.1:9000, took 0.0 sec [error] at com.ning.http.client.providers.netty.request.NettyConnectListener.onFutureFailure(NettyConnectListener.java:128) [error] at com.ning.http.client.providers.netty.request.NettyConnectListener.operationComplete(NettyConnectListener.java:140) [error] at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:409) [error] at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) [error] at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequestWithNewChannel(NettyRequestSender.java:283) [error] at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequestWithCertainForceConnect(NettyRequestSender.java:140) [error] at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequest(NettyRequestSender.java:115) [error] at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:87) [error] at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:506) [error] at play.libs.ws.ning.NingWSRequest.execute(NingWSRequest.java:509) [error] at play.libs.ws.ning.NingWSRequest.execute(NingWSRequest.java:395) [error] at play.libs.ws.ning.NingWSRequest.post(NingWSRequest.java:322) [error] at controllers.projeckerSystem.LoginController.login(LoginController.java:28) [error] at projeckerSystem.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:504) [error] at projeckerSystem.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:504) [error] at play.core.routing.HandlerInvokerFactory$$anon$5.resultCall(HandlerInvoker.scala:139) [error] at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) [error] at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70) [error] at play.GlobalSettings$1.call(GlobalSettings.java:67) [error] at play.db.jpa.TransactionalAction.lambda$call$5(TransactionalAction.java:19) [error] at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:136) [error] at play.db.jpa.JPA.withTransaction(JPA.java:159) [error] at play.db.jpa.TransactionalAction.call(TransactionalAction.java:16) [error] at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) [error] at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) [error] at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [error] at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [error] at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) [error] at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) [error] at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32) [error] at scala.concurrent.impl.Future$.apply(Future.scala:31) [error] at scala.concurrent.Future$.apply(Future.scala:492) [error] at play.core.j.JavaAction.apply(JavaAction.scala:94) [error] at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) [error] at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) [error] at play.utils.Threads$.withContextClassLoader(Threads.scala:21) [error] at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104) [error] at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103) [error] at scala.Option.map(Option.scala:146) [error] at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103) [error] at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96) [error] at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) [error] at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) [error] at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) [error] at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) [error] at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) [error] at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) [error] at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [error] at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [error] at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [error] at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [error] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [error] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [error] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [error] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [error] Caused by: java.net.ConnectException: Connection refused: localhost/127.0.0.1:9000 [error] at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) [error] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) [error] at org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152) [error] at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105) [error] at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79) [error] at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) [error] at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) [error] at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [error] at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [error] at java.lang.Thread.run(Thread.java:745) </code></pre> <p>When I start a second application with <code>activator run</code> and execute the test again, there is no problem and the test runs through successfully. I suspect that there is something wrong with the configuration, but I can't find the problem. Can anybody help?</p> <p>Edit: Here is some of my code.</p> <pre><code>@Test public void test(){ RequestBuilder requestBuilder = new RequestBuilder() .method(Helpers.POST) .uri("..."); Result result = Helpers.route(request); assertEquals(OK, result.status()); } </code></pre> <p>I start the FakeApplication globally within the <code>BeforeClass</code> method.</p> <pre><code>@BeforeClass public static void startApp(){ app = Helpers.fakeApplication(); Helpers.start(app); } </code></pre> |
13,954,594 | 0 | building website using webservice and SOAP in ASP.NET <p>I am new in web application. I don't know much about web services and SOAP. I am studying. Trying to understand what they are? </p> <p>in parallel i wanted to make a simple demonstration using web service and SOAP protocol. I have a form(default.aspx) in my localhost. Here is the picture: </p> <p><img src="https://i.stack.imgur.com/QyfOR.png" alt="enter image description here"></p> <p>on clicking submit button, data will be passed to another page say, "welcome.aspx". I think this process can be done through a web service and following SOAP protocol. </p> <p>I know, this can be done using nothing and following nothing, but to get a simple concept, i want the simplest practical example to be done. </p> <p>any direction will be great, no code may be needed. Just let me know, at this point, how should i use web services and SOAP.</p> |
11,266,783 | 0 | recv() with MSG_PEEK shows full message but returns 'would block' normally <p>I have a non-blocking winsock socket that is <code>recv</code>'ing data in a loop.</p> <p>I noticed that when connecting with, say, putty and a raw socket, sending messages works just fine. However, when interfacing with this particular client, the packets seem to not be triggering a successful, non-<code>MSG_PEEK</code> call to <code>recv</code>. I recall having a similar issue a few years back and it ended up having to end the packets in <code>\r</code> or something coming from the <em>client</em>, which isn't possible in this case since I cannot modify the client.</p> <p>Wireshark shows the packets coming through just fine; my server program, however, isn't working quite right.</p> <p>How would I fix this?</p> <p><strong>EDIT:</strong> Turning the buffer size down to, say, 8 resulted in a few <em>successful</em> calls to recv without MSG_PEEK.</p> <p>Recv call:</p> <pre><code>iLen = recv(group->clpClients[cell]->_sock, // I normally call without MSG_PEEK group->clpClients[cell]->_cBuff, CAPS_CLIENT_BUFFER_SIZE, MSG_PEEK); if(iLen != SOCKET_ERROR) { ... </code></pre> <p>Socket is <code>AF_INET</code>, <code>SOCK_STREAM</code> and <code>IPPROTO_TCP</code>.</p> |
11,302,941 | 0 | <pre><code>$('a:contains("Link 1"), a:contains("Link 3")', '.navBox').on('click', function(e){ e.preventDefault(); $('.lowerContainer').slideToggle(); }); </code></pre> |
22,493,819 | 0 | <p>This is a job for <code>merge</code>:</p> <pre><code>KEYS <- data.frame(A = AList, B = BList) merge(DATA, KEYS) # A B Value # 1 1 6 9 # 2 3 8 2 </code></pre> <hr> <p><strong>Edit</strong>: after the OP expressed his preference for a logical vector in the comments below, I would suggest one of the following.</p> <p>Use <code>merge</code>:</p> <pre><code>df.in.df <- function(x, y) { common.names <- intersect(names(x), names(y)) idx <- seq_len(nrow(x)) x <- x[common.names] y <- y[common.names] x <- transform(x, .row.idx = idx) idx %in% merge(x, y)$.row.idx } </code></pre> <p>or <code>interaction</code>:</p> <pre><code>df.in.df <- function(x, y) { common.names <- intersect(names(x), names(y)) interaction(x[common.names]) %in% interaction(y[common.names]) } </code></pre> <p>In both cases:</p> <pre><code>df.in.df(DATA, KEYS) # [1] TRUE FALSE TRUE FALSE FALSE FALSE </code></pre> |
5,215,462 | 0 | <p>It seems that you want the column value to match the start of your pattern:</p> <pre><code>SELECT * FROM my_table WHERE 'example.com' LIKE CONCAT(my_table.my_column, '%'); </code></pre> <p>The downside of this is that it isn't going to use any indexes on my_column.</p> |
13,128,464 | 0 | <p>I suspect the problem you're having is related to this issue: <a href="http://stackoverflow.com/questions/8025082/facebook-authentication-in-a-uiwebview-does-not-redirect-back-to-original-page-o">Facebook authentication in a UIWebView does not redirect back to original page on my site asking for auth</a></p> <p>Specifically, the standard Facebook web login process launches a new browser window dialog, and dispatches a message back to the opener to indicate login success for the redirect to occur.</p> <p>Quoting a passage in the linked SO, "UIWebView doesn't support multiple windows so it can't postMessage back to your original page since it's no longer loaded."</p> |
26,736,346 | 0 | <p>Body = e.Value.AlternateViews.GetHtmlView().Body, </p> |
38,640,147 | 0 | <p>try</p> <pre><code>where cast(tbRegistrant.DateEntered as date) >= cast('20150701' as date) and CAST(tbRegistrant.DateEntered) <= cast('20160630' as date) </code></pre> |
2,413,408 | 0 | WebOrb - Serializing an object as a string <p>We have an Adobe Flex client talking to a .NET server using WebORB. Simplifying things, on the .NET side of things we have a struct that wraps a ulong like this:</p> <pre><code>public struct MyStruct { private ulong _val; public override string ToString() { return _val.ToString("x16"); } // Parse method } </code></pre> <p>And a class:</p> <pre><code>public class MyClass { public MyStruct Info { get; set; } } </code></pre> <p>I want the Flex client to treat MyStruct as a string. So that for the following server method:</p> <pre><code>public void DoStuff(int i, MyClass b); </code></pre> <p>It can call it as (C# here as I don't know Flex)</p> <pre><code>MyClass c = new MyClass(); c.Info = "1234567890ABCDEF" DoStuff(1, c) </code></pre> <p>I've tried playing with custom WebORB serializers, but the documentation is a bit scarce. Is this possible? If so how?</p> <p>I think I can work out how to serialize it, but not the other way. Do I need to write a Custom Serializer on the the Flex end as well? </p> |
8,057,676 | 0 | <p>From the install steps you've listed it sounds like you're missing a few steps.</p> <p>Definitely revisit the <a href="http://docs.haystacksearch.org/dev/tutorial.html" rel="nofollow">Haystack setup instructions</a> with a particular eye to looking at the Create a Search Site and Creating Indexes sections.</p> <p>The long and short is you seem to be missing an indexes file. Haystack registers a bunch of stuff from your indexes when it is first included, so that explains why you're getting errors from <code>haystack.__init__</code></p> <p>Add a file called 'search_indexes.py' to your application directory. This file contains a list of the indexes you want to generate for different models. A simple example would be:</p> <pre><code>from haystack.indexes import * from haystack import site from myapp.models import MyModel class MyModelIndex(SearchIndex): text = CharField(document=True, use_template=True) def prepare(self, obj): self.prepared_data = super(MyModelIndex, self).prepare(obj) self.prepared_data['text'] = obj.my_field site.register(MyModel, MyModelIndex) </code></pre> <p>This will add a free text search field called 'text' to your index. When you search for free text without a field to search specified, haystack will search this field by default. The property <code>my_field</code> from the model <code>MyModel</code> is added to this text field and is made searchable. This could, for example, be the name of the model or some appropriate text field. The example is a little naive, but it will do for now to help you get something up and running, and you can then read up a bit and expand it.</p> <p>The call <code>site.register</code> registers this index against the model <code>MyModel</code> so haystack can discover it.</p> <p>You'll also need a file called <code>search_sites.py</code> (Name as per your settings) in your project directory to point to the index files you've just made. Adding the following will make it look through your apps and auto-discover any indexes you've registered.</p> <pre><code>import haystack haystack.autodiscover() </code></pre> |
23,242,909 | 0 | <p>you have to update your html code little bit as follows to store clicked number button's value into textbox. Here, I stored that value in both textboxes. I replaced code little bit of textbox, number's button and added one javascript function instead all code is as it is. Please, give one look.</p> <p>Textboxes: </p> <pre><code><tr> <td width="292" align="center" height="23"> <input type="text" name="num1" id="num1" value="" size="10"> <input type="text" name="num2" id="num2" value="" size="10"></td> </tr> </code></pre> <p>Buttons:</p> <pre><code><input type="button" onclick="storeNumber(this)" value="1" name="1"> <input type="button" onclick="storeNumber(this)" value="2" name="2"> <input type="button" onclick="storeNumber(this)" value="3" name="3"><br> <input type="button" onclick="storeNumber(this)" value="4" name="4"> <input type="button" onclick="storeNumber(this)" value="5" name="5"> <input type="button" onclick="storeNumber(this)" value="6" name="6"><br> <input type="button" onclick="storeNumber(this)" value="7" name="7"> <input type="button" onclick="storeNumber(this)" value="8" name="8"> <input type="button" onclick="storeNumber(this)" value="9" name="9"> <input type="button" onclick="storeNumber(this)" value="0" name="0"> </code></pre> <p>Call Javascript function in head tag </p> <pre><code><script language='javascript'> function storeNumber( obj ) { var previousVal = document.getElementById("num1").value; previousVal = previousVal + obj.value; document.getElementById("num1").value = previousVal; document.getElementById("num2").value = previousVal; } </script> </code></pre> <p>Thanks.</p> |
30,335,543 | 0 | Catching multiple exceptions - Python <p>I have a program that occasionally throws a badStatusLine exception, after catching it we are now getting another error and I can't seem to catch it so the program doesn't stop. Here is what I have, any help would be appreciated.</p> <p>The error:</p> <pre><code>Exception in thread Thread-1: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/Users/mattduhon/trading4.py", line 30, in trade execution.execute_order(event) File "/Users/mattduhon/execution.py", line 33, in execute_order params, headers File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1001, in request self._send_request(method, url, body, headers) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1029, in _send_request self.putrequest(method, url, **skips) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 892, in putrequest raise CannotSendRequest() CannotSendRequest </code></pre> <p>The file responsible for catching the error:</p> <pre><code>import httplib import urllib from httplib import BadStatusLine from httplib import CannotSendRequest class Execution(object): def __init__(self, domain, access_token, account_id): self.domain = domain self.access_token = access_token self.account_id = account_id self.conn = self.obtain_connection() def obtain_connection(self): return httplib.HTTPSConnection(self.domain) def execute_order(self, event): headers = { "Content-Type": "application/x-www-form-urlencoded", "Authorization": "Bearer " + self.access_token} params = urllib.urlencode({ "instrument" : event.instrument, "units" : event.units, "type" : event.order_type, "side" : event.side, "stopLoss" : event.stopLoss, "takeProfit" : event.takeProfit }) self.conn.request( "POST", "/v1/accounts/%s/orders" % str(self.account_id), params, headers) try: response = self.conn.getresponse().read() except BadStatusLine as e: print(e) except CannotSendRequest as a: ######my attempt at catching the error print(a) else: print response </code></pre> |
17,908,875 | 0 | <p>It is very unlikely that the compiler will generate something different from the other. Nearly all modern processors have a <code>greater or equal</code> or <code>less or equal</code> comparison/branch operation, so there should be no reason to make a more complex comparison. </p> <p>The statement</p> <pre><code> if(x == y) if (x < y) break; </code></pre> <p>doesn't make any sense. Either <code>x == y</code> is true, in which case <code>x < y</code> is not true. Or <code>x == y</code> is false, and you don't enter the second if at all. </p> <p>Obviously, if <code>x</code> and <code>y</code> are a class, then the <code>operator<=</code> may be written as:</p> <pre><code>operator<=(const A& x, const A& y) { if (x == y) return true; return x < y; } </code></pre> <p>But that would be rather daft, since it can just as well be written as :</p> <pre><code>operator<=(const A& x, const A& y) { return !(x > y); } </code></pre> |
6,838,902 | 0 | Problem deserializing JSON into KeyValuePair using JSON.NET <p>This is part of a larger problem I am working on. However, I have attempted to break it down to the simplest form possible.</p> <p>I am using JSON.Net, and trying to deserialize several JSON objects into KeyValuePair, but I cannot get even a simple example test to work.</p> <pre><code>var pair = JsonConvert.DeserializeObject<KeyValuePair<string, string>>(@"""the key"": ""the value"""); </code></pre> <p>This throws a JsonReaderException -- <strong>After parsing a value an unexpected character was encountered: :. Line 1, position 10.</strong></p> <p>It seems to choke on the colon character, which I find rather odd. I've used JSON.Net several times before, and never have run into anything like this.</p> |
65,287 | 0 | <p>Not sure about .doc support in any open source library but ImageMagick (and the RMagick gem) can be compiled with pdf support (I think it's on by default)</p> |
40,060,346 | 0 | <p>The combination of <code>kAudioDevicePropertyNominalSampleRate</code> and <code>kAudioObjectPropertyScopeGlobal</code> will get the callback to work correctly. The documentation of this selector (CoreAudio/AudioHardware.h) doesn't tell me what scope to use, though. If anyone finds a source of proof/reason for this, feel free to edit.</p> <p><em>The situation is also confusing because calling <code>AudioObjectSetPropertyData()</code> with <code>kAudioDevicePropertyNominalSampleRate</code> and either <code>kAudioObjectPropertyScopeInput</code> or <code>kAudioObjectPropertyScopeOutput</code> will <strong>also</strong> result in a successful sample rate switch (one could argue this to be erroneous behaviour).</em></p> |
22,748,000 | 0 | Mongodb 2.6.0-rc2 and PHP 1.4.5 - find _id $in <p>A simple query like this:</p> <pre><code>$a = array('_id' => array( '$in' => array_values($ids) ) ); var_dump($a); $cursor2 = $data->find( $a ); </code></pre> <p>works in mongodb 2.4.9, however, in 2.6.0-rc2 returns this:</p> <pre><code>Type: MongoCursorException Code: 17287 Message: Can't canonicalize query: BadValue $in needs an array </code></pre> <p>The output from var_dump:</p> <pre><code>array(1) { ["_id"]=> array(1) { ["$in"]=> array(10) { [0]=> object(MongoId)#57 (1) { ["$id"]=> string(24) "52214d60012f8aab278eacb6" } [1]=> object(MongoId)#58 (1) { ["$id"]=> string(24) "52214d60012f8aab278eaca8" } [2]=> object(MongoId)#59 (1) { ["$id"]=> string(24) "52214d60012f8aab278eaca7" } } } } </code></pre> <p>I wonder if this is a Mongo or PHP related?</p> <p>THanks!</p> |
20,604,200 | 0 | Well Is this facebook app following all the rules(TOS)? <p>Well I found this app (just a demo app for sale) <a href="http://apps.facebook.com/horoscope-demo/" rel="nofollow">http://apps.facebook.com/horoscope-demo/</a></p> <p>But before buying I am confused with: This app</p> <p>Asks to post on wall at first use</p> <p>Shows advertisement dialog at app entry </p> <p>Shows send request dialog at entry</p> <p>and also has auto daily post on the user's wall (after permission)</p> <p>Is there any violations of facebook tos? There were some rules not to show dialog, send request dialog as far as I remember. plus is auto wall posting(even after approval) still possible or allowed by facebook? I didn't test the daily auto post but can it still do it?</p> <p>Thanks for replies Fb app developers. As fb developer these questions are pretty useful.</p> |
11,592,050 | 0 | How to write a query with mysql where I could have some value compaired to multiple values with subquery <p>I've been coding all night so if this question makes no sense I apologize. It's been a while since I've had to write out a query but I thought there was a way where I could do something like...</p> <pre><code>(SELECT COUNT(*) FROM call WHERE upload_id = (SELECT uploadId FROM userUploads where user_id = us.id) and callDate BETWEEN DATE_SUB(now(),INTERVAL 1 WEEK) AND now() AND click = 1) AS weeklyCalls, </code></pre> <p>My question is how would I check the upload_id to multiple ids within the same query. I feel like I should be able to compare it to the sub query running.</p> <p>Everything I'm referring to in the example query is taking place on the second line.</p> |
5,092,845 | 0 | Point to location using compass <p>I am trying to develop a compass for an appliation which has a set of annotations on a map. I would like to be able to choose an annotation and then have the compass point the user to the chosen location.</p> <p>I have calculated the degress from the user's location to the location of the annotation and I have the magnetic heading and the true heading of the iPhone. Also I know how to rotate an image. But I can't figure out what the next step is.</p> <p>The degrees between the user's location and the annotation location is calculated like this:</p> <pre><code> // get user location locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation]; [locationManager startUpdatingHeading]; CLLocation *location = [locationManager location]; CLLocationCoordinate2D coordinate = [location coordinate]; float x1 = coordinate.latitude; float y1 = coordinate.longitude; float x2 = [annLatitude floatValue]; float y2 = [annLongitude floatValue]; float dx = (x2 - x1); float dy = (y2 - y1); if (dx == 0) { if (dy > 0) { result = 90; } else { result = 270; } } else { result = (atan(dy/dx)) * 180 / M_PI; } if (dx < 0) { result = result + 180; } if (result < 0) { result = result + 360; } </code></pre> <p>The true and the magnetic heading is retrieved like this:</p> <pre><code>- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { arrow.transform = CGAffineTransformMakeRotation(newHeading.magneticHeading); // NSLog(@"magnetic heading: %f", newHeading.magneticHeading); // NSLog(@"true heading: %f", newHeading.trueHeading); } </code></pre> <p>Can anyone tell me what I should do now to make the arrow point to the location - even if the iPhone is rotated?</p> |
9,565,503 | 0 | <p>This might work for you:</p> <pre><code>v1="a b c" v2="1 2 3" v3="x y z" parallel --xapply echo {1}{2}{3} ::: $v1 ::: $v2 ::: $v3 a1x b2y c3z </code></pre> |
32,746,238 | 0 | <p>Add to your <code>if</code> validation condition to not validate if a new step is the back one, like this:</p> <pre><code>if (event.getOldStep().contains("part") && !event.getNewStep().equals("model")) { ... } </code></pre> <p>or for the first if</p> <pre><code>if (event.getNewStep().contains("model") { return event.getNewStep(); } </code></pre> |
11,610,856 | 0 | Ubuntu 12.04 and cassandra install - +HeapDumpOnOutOfMemoryError -Xss128k <p>I am following the instructions for installing cassandra at <a href="http://www.datastax.com/docs/1.1/install/install_deb">Install Cassandra</a></p> <p>When I installed, I get the below. How to I fix?</p> <pre><code>service cassandra start xss = -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1001M -Xmx1001M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -Xss128k root@i-157-16647-VM:~# service cassandra status xss = -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1001M -Xmx1001M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -Xss128k * Cassandra is not running </code></pre> <p>I am running on a machine with 2 gigs of RAM. Here is how I install on a bare bones VM.</p> <pre><code>sudo vi /etc/apt/sources.list #add sources.list deb http://debian.datastax.com/community stable main deb http://us.archive.ubuntu.com/ubuntu/ precise main contrib non-free curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add - sudo apt-get update sudo apt-get install python-cql dsc1.1 root@i-157-16647-VM:~# java -version java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode) /var/log/cassandra/output.log Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: i-157-16647-VM: i-157-16647-VM Service exit with a return value of 1 Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: i-157-16647-VM: i-157-16647-VM Service exit with a return value of 1 </code></pre> |
4,779,671 | 0 | <p>You should use a <a href="http://developer.android.com/reference/android/widget/ViewSwitcher.html" rel="nofollow"><code>ViewSwitcher</code></a> and switch the views using a gesturedetector</p> |
40,993,051 | 0 | how to prepare a list of posters presented at conferences, in LaTeX? <p>Does anybody know how to prepare, in LaTeX, a list of oral presentations or poster presented at conferences ? How should I add this to my *.bib file ? </p> |
30,425,701 | 0 | iOS Get timestamp without hours and minutes and seconds <pre><code> NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"dd/MM/yyyy"]; NSString *theDate = [dateFormat stringFromDate:date]; time_t unixTime = (time_t) [date timeIntervalSince1970]; </code></pre> <p>i need unixTime without hours, minutes and seconds</p> |
9,373,944 | 0 | <p>I've had some luck with this, even if it doesn't completely work.</p> <h2>The spinner adapter's get view :</h2> <pre><code>public View getView(int position, View v, ViewGroup parent) { if (v == null) { LayoutInflater mLayoutInflater = mActivity.getLayoutInflater(); v = mLayoutInflater.inflate(R.layout.user_row, null); } View tempParent = (View) parent.getParent().getParent().getParent(); tempParent.setOnTouchListener(new MyOnTouchListener(mActivity)); mActivity.setOpen(true); User getUser = mUsers.get(position); return v; } </code></pre> <h2>The ontouch listener :</h2> <pre><code>public class MyOnTouchListener implements OnTouchListener{ private MyActivity mOverall; public MyTouchListener(MyActivity overall) { mOverall = overall; } public boolean onTouch(View v, MotionEvent event) { if (mOverall.getOpen()) { mOverall.getWindow().setContentView(R.layout.main); //reset your activity screen mOverall.initMainLayout(); //reset any code. most likely what's in your oncreate } return false; } } </code></pre> <h2>The on item selected listener :</h2> <pre><code>public class MySelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { setUser(pos); //or whatever you want to do when the item is selected setOpen(false); } public void onNothingSelected(AdapterView<?> parent) {} } </code></pre> <h2>The activity</h2> <p>Your activity with the spinner should have a global variable mOpen with get and set methods. This is because the ontouch listener tends to stay on even after the list is closed.</p> <h2>The limitations of this method:</h2> <p>It closes if you touch between the spinner and the options or to the side of the options. Touching above the spinner and below the options still won't close it.</p> |
6,939,243 | 0 | TFS Integration Platform: How to map users with the SVN adapter? <p>I want to migrate sourcecode from SVN to TFS2010 using the TFS Integration Platform.</p> <p>I am using the Codeplex Release from March 25th of the TFS Integration Platform.</p> <p>The SVN Adapter basically works. I can get the sourcecode from the SVN repository into TFS, including the full history (all revisions from SVN).</p> <p>However all the checkins into TFS are done as the user that is running the TFS Integration Platform Shell.</p> <p>I was wondering how I can configure a mapping of SVN users to TFS users. My SVN users are not ActiveDirectory of configured as Windows users.</p> <p>I would just like to specify an explicit mapping for each SVN user to an existing TFS user.</p> <p>On the web I found several hints at using a <code><UserMappings></code> element or a <code><ValueMap name="UserMap"></code> or an <code><AliasMappings></code> ... but there seems no concrete example how to configure that with the SVN adapter. All my experiments are failing...</p> <p>Is this supposed to work with the SVN adapter?</p> <p>Could somebody give me a hint or a pointer how to configure this mapping?</p> |
7,774,010 | 0 | <p>Well, having just tried it myself with the C# 4 compiler, I got an internal <em>class</em> called <code><PrivateImplementationDetails>{D1E23401-19BC-4B4E-8CC5-2C6DDEE7B97C}</code> containing a private nested <em>struct</em> called <code>__StaticArrayInitTypeSize=12</code>.</p> <p>The class contained an internal static field of the struct type called <code>$$method0x6000001-1</code>. The field itself was decorated with <code>CompilerGeneratedAttribute</code>.</p> <p>The problem is that <em>all</em> of this is implementation-specific. It could change in future releases, or it could be different from earlier releases too.</p> <p>Any member name containing <code><</code>, <code>></code> or <code>=</code> is an "unspeakable" name which <em>will</em> have been generated by the compiler, so you can view that as a sort of implicit <code>CompilerGenerated</code>, if that's any use. (There are any number of <em>other</em> uses for such generated types though.)</p> |
25,433,843 | 0 | <p>If you are using:</p> <pre><code><%= render 'form', locals: {record: @record} %> </code></pre> <p>then, you will need to use variable <code>record</code> instead of <code>@record</code> in your <code>_form.html.erb</code> as:</p> <pre><code><% unless record.nil? %> </code></pre> <p><strong>Description:</strong></p> <p><code>locals: {record: @record}</code> means, <code>@record</code>'s value will be accessible by using <code>record</code> in the partial being rendered.</p> |
12,550,659 | 0 | Make awk interpret one line at a time from variable <p>I'm a completely new to shell scripting and bash. My question is how do I get awk to interpret a variable which contains linebreaks the same way as awk interpret the data from stdin?</p> <p>Example:</p> <pre><code>fileData=`cat /path/to/file` echo $fileData | awk '{print $1}' </code></pre> <p>The code above results in the following error message: <code>awk: program limit exceeded: maximum number of fields size=32767</code> which obviously means that awk interprets all the lines in <code>$fileData</code> at the same time and not one line at a time.</p> <p>How to make awk interpret one line at a time from a variable?</p> |
16,751,436 | 0 | <p>You should not use MapPath() twice for the same path.</p> <p>Old Code:</p> <pre><code>System.IO.Directory.CreateDirectory(MapPath(path)); //Create directory if it doesn't exist </code></pre> <p>Corrected Code:</p> <pre><code>System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist </code></pre> <p><strong>EDIT:</strong> Also corrected this: </p> <pre><code>string imgPath = path + "/" + imgName; </code></pre> <p>To this:</p> <pre><code>string imgPath = Path.Combine(path, imgName); </code></pre> <p><strong>whole corrected code:</strong></p> <pre><code> //get the file name of the posted image string imgName = image.FileName.ToString(); String path = Server.MapPath("~/ImageStorage");//Path //Check if directory exist if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist } //sets the image path string imgPath = Path.Combine(path, imgName); //get the size in bytes that int imgSize = image.PostedFile.ContentLength; if (image.PostedFile != null) { if (image.PostedFile.ContentLength > 0)//Check if image is greater than 5MB { //Save image to the Folder image.SaveAs(imgPath); } } </code></pre> |
24,076,318 | 0 | My json model in three.js is not working <p><strong>Hello!</strong> I have <a href="http://eliasljunglov.net78.net" rel="nofollow">this website</a> where I post my games. I have imported a json model and it is not rendered correct. Only 50% of the parts are visible. I have not done any textures on it yet. Anyone know this problem?</p> <p><strong>PS: When you get to my website, press on SpaceRun</strong></p> |
28,591,420 | 0 | <p>This really depends on a number of factors but is generally a bad idea and can lead to <a href="http://en.wikipedia.org/wiki/Race_condition" rel="nofollow">race conditions</a>. You can avoid this by locking the value so that reads and writes are all atomic and thus can't collide.</p> |
21,235,619 | 0 | <p>You can try to use <a href="http://api.jquery.com/multiple-attribute-selector/" rel="nofollow">multiple attribute</a> selector:</p> <pre><code>$('tr[:nth-child(odd)][id^="part"]').addClass("alt"); </code></pre> |
15,885,045 | 0 | Text following a JqueryUI button is set as the button title <p>I have the following code:</p> <pre><code>$( ".delete" ).button({ text: false, icons: { primary: "ui-icon-trash" } }); <button id="delete" class="delete" />test </code></pre> <p>The word "test" is being appended to the button as its title, for some reason, instead of appearing after the button. If text is set to false, the button shows with only an icon. If text is not set to false, the word "test" appears within the button. It should just be some text following the button, and I can find no reason as to why the button is nabbing it for a title. I've also tried defining a title, a label...hasn't helped. Thanks.</p> |
30,723,985 | 0 | <p>Your using old SDK tools and goolge play services.Please update your Android SDK tools and Google play services,because latest google play service will provide the inbuilt in google analytic service no need to add libGoogleAnalyticsServices.jar file to your project.Then you will simple use these method and import statemnets. import com.google.android.gms.analytics.GoogleAnalytics; import com.google.android.gms.analytics.HitBuilders; import com.google.android.gms.analytics.Tracker;</p> <p>private Tracker tracker = analytics.newTracker("UA-XXXXXX-X"); tracker.setScreenName(screenName);</p> |
12,815,639 | 0 | <p>You could fetch the employees, store the result in an array and provide this array as the <a href="http://api.jqueryui.com/autocomplete/#option-source" rel="nofollow">option source</a>. </p> |
10,317,360 | 0 | <p>Have you tried creating a derived class of RequiredAttribute and overriding the FormatErrorMessage method? This should work:</p> <pre><code>public class MyRequiredAttribute : System.ComponentModel.DataAnnotations.RequiredAttribute { public override string FormatErrorMessage(string name) { return base.FormatErrorMessage(string.Format("This is my error for {0}", name)); } } </code></pre> |
17,421,790 | 0 | How to replace EclipseLink 2.3.2 with EclipseLink 2.5 in WebLogic Server 12c <p>I currrently try to run Docx4j in WebLogic Server 12c. WebLogic Server 12c comes with EclipseLink 2.3.2. </p> <p>There is a similar <a href="http://stackoverflow.com/questions/16934344/docx4j-bad-content-types-xml-with-weblogic-12c">Post</a> describing the situation which unfortunately yield no answer. </p> <p>Docx4j does not work with the JAXB (MOXy) implementation which is part of EclipseLink 2.3.2. I got Docx4j running standalone with EclipseLink 2.5. So I am very confident that using EclipseLink 2.5 with Weblogic Server 12c will solve the issue with Docx4j.</p> <p>How can I replace the EclipseLink Vesion 2.3.2 the WebLogic Server 12c is running on with EclipseLink Version 2.5? </p> |
9,113,071 | 0 | <p>Have you tried installing the Azure emulator?</p> <p>See <a href="http://connect.microsoft.com/VisualStudio/feedback/details/719329/azure-tools-1-6-fail-to-install-and-show-a-weird-error-unless-azure-emulator-is-installed-first" rel="nofollow">here</a></p> |
18,353,167 | 0 | App design to MVC pattern <p>The answer on this question <a href="http://stackoverflow.com/questions/18317679/swing-how-to-get-container-bind-to-jradiobutton">Swing: how to get container bind to JRadioButton?</a> made me think of MVC in a simple app design. I describe the general idea of an app and my thoughts on MVC pattern for this case.</p> <p><strong>Small app description</strong>:</p> <p>This app lets user to add simple records that consist of name and description. After pressing "add" button, they are added to the panel as two labels and radio button to let edit the record. User can save his list in a profile (serialize to xml, properties or somewhere else).</p> <p><strong>My thoughts on how to apply MVC here</strong>:</p> <p><em>Model</em></p> <ul> <li><p>Record with name and description fields</p></li> <li><p>Profile with serialization mechanism</p></li> </ul> <p><em>View</em></p> <ul> <li>Panel that contains multiple panels (records list) - one for each record (radio button + 2 labels for name and description data)</li> </ul> <p><em>Controller</em></p> <ul> <li><p>2 text boxes with labels and a button to add record</p></li> <li><p>button to edit a record</p></li> </ul> <p>At the moment there's no code samples (I'll provide them a little bit later). I don't want to hurry, I want to understand whether I go in a right MVC direction or something should be changed before implementation.</p> <p><strong>Updated</strong></p> <p>Code sample</p> <pre><code>*MainClass*: public class RecordsControl extends JFrame { private RecordsModel model; private RecordsController controller; private RecordsControlView view; public RecordsControl() { super("Records Control"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); initMVC(); getContentPane().add(view); pack(); setMinimumSize(new Dimension(250, 500)); setLocationRelativeTo(null); setResizable(false); setVisible(true); } private void initMVC() { model = new RecordsModel(); view = new RecordsControlView(controller); controller = new RecordsController(model, view); } } *Model*: public class RecordsModel { //Record class has only two fields String::name and String::description private List<Record> RecordsList; public RecordsModel() { RecordsList = new ArrayList<Record>(); } public void addRecord(String name, String description) { RecordsList.add(new Record(name, description)); } public List<Record> getRecordsList() { return RecordsList; } } *View*: public class RecordsControlView extends JPanel { private final RecordsController controller; private JLabel nameLabel; private JLabel descrLabel; private JTextField nameField; private JTextField descrField; private JButton addButton; private JButton editButton; private JButton deleteButton; private JPanel recordsListPanel; public RecordsControlView(RecordsController controller) { super(); this.controller = controller; achievNameLabel = new JLabel("Name: "); achievDescrLabel = new JLabel("Description: "); achievNameField = new JTextField(15); achievDescrField = new JTextField(15); addButton = new JButton("Add"); initGUI(); initListeners(); } private void initListeners() { addButton.addActionListener(controller); } private void initGUI() { //Main Panel this.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); //name panel //...BoxLayout label + panel //description panel //...BoxLayout label + panel //Records list Panel //...Vertical BoxLayout //Add widgets to GridBagLayout //Name panel constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(5, 5, 2, 2); add(namePanel, constraints); //Description Panel constraints.gridx = 0; constraints.gridy = 1; constraints.insets = new Insets(0, 5, 5, 2); add(descrPanel, constraints); //Add button constraints.gridx = 1; constraints.gridy = 0; constraints.gridheight = 2; constraints.gridwidth = 1; constraints.insets = new Insets(5, 0, 5, 5); constraints.fill = GridBagConstraints.VERTICAL; add(addButton, constraints); //Records List panel constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.gridheight = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(0, 5, 5, 5); add(recordsListPanel, constraints); } public JButton getAddButton() { return addButton; } public void addRecord(JPanel record) { recordsListPanel.add(record); } } public class RecordsView extends JPanel { private static ButtonGroup radioButtons = new ButtonGroup(); private JRadioButton radioButton; private JLabel name; private JLabel description; public RecordsView() { super(); radioButton = new JRadioButton(); name = new JLabel(); description = new JLabel(); initGUI(); } private void initGUI() { radioButtons.add(radioButton); setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; add(radioButton, constraints); constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1.0; constraints.fill = GridBagConstraints.HORIZONTAL; add(name, constraints); constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1.0; constraints.fill = GridBagConstraints.HORIZONTAL; add(description, constraints); } *Controller*: public class RecordsController implements ActionListener{ private final RecordsModel model; private final RecordsControlView view; public RecordsController(RecordsModel model, RecordsControlView view) { this.model = model; this.view = view; } @Override public void actionPerformed(ActionEvent e) { if(e.getSource() == view.getAddButton()) { RecordsView record = new RecordsView(); view.add(record); view.updateUI(); } } } </code></pre> |
33,821,655 | 0 | <p>It seems that your TFS Build Service account has no required permission to access the signingKey.pfx on build agent machine. Make sure you have this file on build agent machine first. </p> <p>Then follow below steps:</p> <ol> <li>Log on the build agent as <strong>your local build service account</strong> (Better have Administrator permission)</li> <li>Open a visual studio command prompt and <strong>navigate to the directory the key is stored in</strong></li> <li>Type command <code>sn –i signingKey.pfx VS_KEY_EFCA4C5B6DFD4B4F</code>(Ensure that you use the key name appearing in the error message)</li> <li><p>When prompted for a password type the password for the pfx file</p></li> <li><p>Then rebuild it</p></li> </ol> <p><strong>Note:</strong> If you are not running Visual Studio as an Administrator try doing that as well.</p> <p>More details you can reference the answer from <em>Brandon Manchester</em> <a href="http://stackoverflow.com/questions/2815366/cannot-import-the-keyfile-blah-pfx-error-the-keyfile-may-be-password-protec">Cannot import the keyfile 'blah.pfx' - error 'The keyfile may be password protected'</a></p> |
27,262,737 | 0 | <p>EDIT: Changed my answer since there is an <code>initial-index</code> attribute which is better. Sorry about that.</p> <p>Use <code>initial-index="2"</code> (or whatever index you like) as an attribute for <code><ons-carousel></code>.</p> <pre><code><ons-carousel initial-index="2"> ... </ons-carousel> </code></pre> <p>Here you can see it in action: <a href="http://codepen.io/argelius/pen/MYaGLK" rel="nofollow">http://codepen.io/argelius/pen/MYaGLK</a></p> |
2,531,620 | 0 | <p>Click the Info button on your xib's main window, and set the Deployment Target to iPhone OS 3.0 or iPhone OS 3.1.</p> <p>Edit: Images!</p> <p><img src="http://derailer.org/images/stackoverflow/ibinfobutton/infobutton.png" alt="Info Button"> <img src="http://derailer.org/images/stackoverflow/ibinfobutton/deploymenttargetpopup.png" alt="Deployment Target Popup"></p> <p>(NB: These are from the 10.5 version of IB, but IIRC the 10.6 version is the same or close to it.)</p> |
19,826,210 | 0 | <p>what you want in your for loop is </p> <pre><code>for(k = deck.length - 1; k >= 0; k--) </code></pre> <p>your indexing is off and it never enters the shuffle algorithm ( I didn't check the correctness of it FYI so you might bump into other problems)</p> |
30,461,485 | 0 | <p>If you really want to use <code>QTableView</code>, then it has special method called <code>setIndexWidget</code> and you need only index where you want to put the widget. Small example.</p> <pre><code> model = QStandardItemModel (4, 4) for row in range(4): for column in range(4): item = QStandardItem("row %d, column %d" % (row, column)) model.setItem(row, column, item) self.tableView.setModel(model) for row in range(4): c = QComboBox() c.addItems(['cell11','cell12','cell13','cell14','cell15',]) i = self.tableView.model().index(row,2) self.tableView.setIndexWidget(i,c) </code></pre> <p>Result is similar to the first answer.</p> |
Subsets and Splits