pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
12,781,125
0
<p>It looks like you are trying to make a pretty generic search stored procedure with paging. These are difficult to implement properly in t-sql only, and can become maintenance headaches down the road due to the branching logic, or additional supporting stored procedures you need to add...</p> <p>I would start to look at other options outside of a pure sql approach. Using an orm, or micro orm could help a lot. Actually, take a look at what Sam Saffron came up with...</p> <p><a href="http://samsaffron.com/archive/2011/09/05/Digging+ourselves+out+of+the+mess+Linq-2-SQL+created" rel="nofollow">http://samsaffron.com/archive/2011/09/05/Digging+ourselves+out+of+the+mess+Linq-2-SQL+created</a></p>
7,627,649
0
<p><a href="https://github.com/dwelch67" rel="nofollow">https://github.com/dwelch67</a></p> <p>I have a number of lpc based examples. You are looking for the IODIR register, depending on the port and flavor of LPC, there are now what they call fast I/O registers. a one in a bit location means that pin is an output, a zero an input.</p>
8,664,952
0
<p>Apache, mod_rewrite would be much better for this.</p>
31,803,222
1
Getting json data from imgur.com <p>I was trying to get json data from imgur.com</p> <p>To get it one has to hit this link : </p> <pre><code>http://imgur.com/user/{Username}/index/newest/page/{pagecount}/hit.json?scrolling </code></pre> <p>Where Username and pagecount may change. So i did something like this :</p> <pre><code>import urllib2, json Username="Tighe" count = 0 url = "http://imgur.com/user/"+arg+"/index/newest/page/"+str(count)+"/hit.json?scrolling" print("URL " +url) response = urllib2.urlopen(url) data = response.read() </code></pre> <p>I get the data but now to convert it to json format I did something like this : </p> <pre><code>jsonData = json.loads(data) </code></pre> <p>Now , it give error</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "imgur_battle.py", line 8, in battle response = urllib2.urlopen(url) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 404, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 422, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1214, in http_open return self.do_open(httplib.HTTPConnection, req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1187, in do_open r = h.getresponse(buffering=True) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1045, in getresponse response.begin() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 409, in begin version, status, reason = self._read_status() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 373, in _read_status raise BadStatusLine(line) httplib.BadStatusLine: '' </code></pre>
22,102,142
0
<pre><code> $(document).ready(function(){ $('input[name=subdomain]').keyup(subdomain_check); $('input[name=password]').keyup(password_strenght); $('input[name=c_password]').keyup(password_check); $('input[name=email]').keyup(email_check); function subdomain_check (e) { // these functions should set a global variable to false if validation fails } function password_strenght (e) { // these functions should set a global variable to false if validation fails } function password_check (e) { // these functions should set a global variable to false if validation fails } function email_check (e) { // these functions should set a global variable to false if validation fails } $(document).submit(function(e){ return global_var; // where global_var is the variable set by the validating functions } }); </code></pre>
30,752,451
0
<p>The javascript in nodejs is single threaded. It works off an event queue where an event is popped off the queue, some callback is called to serve that event and the code behind that callback runs to completion, then the next event is pulled off the event queue and the process is repeated.</p> <p>As such, there is no real "background processing". If your JS thread is executing, then nothing else can run at that time until that JS thread finishes and allows the next event in the event queue to be processed.</p> <p>To truly run something else in parallel where both your task and other nodejs code can literally run at the same time, you would have to create a new process and let the new process carry out your task. This new process could be any type of process (some pre-built program running a task or another custom nodejs process).</p> <p>"Running in the background" can sometimes be simulated by time slicing your "background" process work such that it does small amounts of work on timer ticks and the pauses between timer ticks allow other nodejs JS events to be processed and their code to run. But, to do this type of simulated "background", you have to write your task to execute in small chunks. It's a different (and often more cumbersome) way of writing code.</p>
5,782,559
0
<p>If what you mean is to run the html in a browser inside the app that LOOKS LIKE Safari, you can use a UIWebView and call </p> <pre><code> loadHTMLString:baseURL </code></pre> <p>You can create your file URL like this:</p> <pre><code> NSURL *myFileURL = [NSURL fileURLWithPath: pathToMyFile]; </code></pre> <p>But like everyone else says, you can't access an app's file from any other app (without jailbreaking).</p>
33,837,384
0
<p>Use one of these: </p> <pre><code>match += request + "\r\n"; </code></pre> <p>Use an string literal:</p> <pre><code>match += request + @" "; </code></pre> <p>OR only at runtime will this resolve:</p> <pre><code>match += request + System.Environment.NewLine; </code></pre> <p>On Unix <code>"\n"</code></p>
11,364,896
0
JavaFX 2 multispan cell table like MS Excel <p>I hope someone will be able to help to resolve my problem. I need the table like MS Excel with a fast scrolling. I use JavaFX 2 and can't find any example or solution. There are several examples on Swing, but I really need JavaFX 2. I've already tested TableView, GridPane but they work very slow with huge amount of data.</p> <pre><code> package test import javafx.stage.Stage import javafx.scene.{Group, Scene} import javafx.scene.control.cell.PropertyValueFactory import javafx.collections.{FXCollections} import javafx.application.Application import javafx.util.Callback import javafx.scene.control._ import javafx.scene.layout.{GridPane} class TableTest extends Application { override def start(stage: Stage) = { val root = new Group val scene = new Scene(root, 1000, 700) val table = new TableView[Data] table.setPrefWidth(1000) table.setPrefHeight(700) val data = FXCollections.observableArrayList[Data] for(i &lt;- 0 until 100) data.add(new Data) for(j &lt;- 0 until 100) table.getColumns().add(createTextColumn(j.toString)) table.setItems(data) root.getChildren().add(table) stage.setTitle("Table View Test JavaFX &amp; Scala") stage.setWidth(1024) stage.setHeight(768) stage.setScene(scene) stage.show } def createTextColumn(index:String):TableColumn[Data, AnyRef] = { val activeCol = new TableColumn[Data, AnyRef](index) activeCol.setPrefWidth(128) activeCol.setCellValueFactory(new PropertyValueFactory[Data, AnyRef]("text")) val call = new Callback[TableColumn[Data, AnyRef], TableCell[Data, AnyRef]] { override def call(p1: TableColumn[Data, AnyRef]) : TableCell[Data, AnyRef] = { new TableCell[Data, AnyRef] { val grid = new GridPane val label = new Label grid.add(label, 0, 0) setGraphic(grid) override def updateItem(value: AnyRef, empty: Boolean) = { val row = getTableRow if (row != null &amp;&amp; value != null) { label.setText(value.toString) } } } } } activeCol.setCellFactory(call) return activeCol } } package test import javafx.beans.property.{SimpleLongProperty, SimpleStringProperty} class Data { val text = new SimpleStringProperty("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet velit leo, in sodales lorem. Donec vel nisl tellus sed. ") def textProperty = text def getText : String = text.get def setText(value: String) = text.set(value) } </code></pre> <p>I tested this code with Data class with only one string (128 bytes). But really it should be more than now. So, the question is: can I get something like MS Excel table with the same functionallity using JavaFX 2? P.S.: I also tested this code with pure Java but got the same result :(</p>
19,552,062
0
<p>You can try this regex:</p> <pre><code>^(?=.*?[a-zA-Z])(?=.*?[0-9])[\w@#$%^?~-]{5,30}$ </code></pre> <h3>Live Demo &amp; Examples: <a href="http://www.rubular.com/r/EXHHCoq0WC" rel="nofollow">http://www.rubular.com/r/EXHHCoq0WC</a></h3> <p><strong>Explanation:</strong></p> <ul> <li><code>^</code> is line start</li> <li><code>(?=.*?[a-zA-Z])</code> is a positive lookahead that will make sure there is atleast one alphabet</li> <li><code>(?=.*?[0-9])</code> is a positive lookahead that will make sure there is atleast one digit</li> <li><code>[\w@#$%^?~-]{5,30}</code> is using character class for 5 to 30 characters specified inside square brackets</li> <li><code>$</code> is line end</li> </ul> <h3>Lookaround Reference: <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">www.regular-expressions.info/lookaround.html</a></h3>
7,350,480
0
Understanding a negative offset of a registry data reference to a dll file <p>I almost have an answer to <a href="http://stackoverflow.com/questions/7337343/windows-7-firewall-modify-group-items-from-command-line">my last question</a>, but I need help.</p> <p>The Windows Firewall Rules (Vista and up) are stored in the Registry <code>HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules</code></p> <p>Example rule: <code>v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Domain|RPort=5722|App=%SystemRoot%\system32\dfsr.exe|Svc=Dfsr|[email protected],-32257|[email protected],-32260|[email protected],-32252|Edge=FALSE|</code></p> <p>The field I need to decode is <code>[email protected],-32252</code></p> <p>I think it references <code>C:\WINDOWS\System32\FirewallAPI.dll</code>, but I can't figure out how the number works. The file is ~400KB depending.</p> <p>I tried a few variations like pretending it was an unsigned <code>short</code>, pretending it was not negative, pretending it was offset from the end, but they did not look right when I arrived at the location with my hex editor.</p> <p>Could somebody give me their ideas? What this number might mean? I hardly know anything about DLL files. It could even be a section number for all I know.</p> <p>I also tried searching the text for the expected output, but it seems it is neither byte per character, nor is it UTF-16, either that or I am doing something wrong.</p>
1,964,757
0
Using performSelectorInBackground to load UITableViewCell image in background, performance <p>I have a method for loading images for UITableViewCell in the background. I use performSelectorInBackground. The problem is these threads are finishing and loading images even though they may not be on the screen anymore. This can be taxing on resources, especially when the use scrolls quickly and lots of cells are created. The images are fairly small and being loaded from the disk (sqlite db), not from a URL.</p> <p>I've put code in the cell to check to see if it's the most recently displayed cell and I don't load the image if it's not. This works, but it's still creating the threads even though the "expensive" work of loading the image from disk isn't being executed unless it's the most recent cell.</p> <p>The question is, what's the best way to deal with this? Should I kill existing threads each time the UITableViewCell is reused? How do I go about killing threads invoked by performSelectorInBackground?</p> <p>Any other suggestions on how to handle this are appreciated.</p>
37,841,584
0
Invalid Objects and What issue they can cause in application? <p>I just wanted to know about some invalid objects which are from Oracle ebs 12.1.3. The list is </p> <ol> <li>CST_LAYER_ACTUAL_COST_DTLS_V </li> <li>IGW_BUDGET_CATEGORY_V</li> <li>IGW_REPORT_PROCESSING </li> <li>FV_FACTS_TBAL_TRX</li> <li>FV_FACTS_TRX_REGISTER</li> <li>FV_SF133_ONEYEAR</li> <li>FV_SF133_NOYEAR</li> <li>FV_FACTS_TRANSACTIONS</li> <li>FV_FACTS_TBAL_TRANSACTIONS</li> <li>ENI_DBI_CO_OBJIDS_MV</li> <li>PJI_TIME_PA_RPT_STR_MV</li> <li>POA_MID_BS_J_MV</li> <li>POA_IDL_BS_J_MV</li> <li>POA_ITEMS_MV</li> <li>GL_ACCESS_SET_LEDGERS</li> <li>LNS_LOAN_DTLS_ALL_MV</li> <li>OZF_CUST_FUND_SUMMARY_MV</li> <li>FV_SLA_FV_PROCESSING_PKG</li> <li>OE_ITEMS_MV</li> <li>PA_DEDUCTIONS_W</li> <li>PA_DEDUCTIONS_PUB</li> <li>PA_DEDUCTIONS_PUB</li> <li>PA_DEDUCTIONS_W</li> <li>PA_DCTN_APRV_NOTIFICATION</li> </ol> <p>--object types--</p> <pre><code>CST_LAYER_ACTUAL_COST_DTLS_V VIEW IGW_BUDGET_CATEGORY_V VIEW IGW_REPORT_PROCESSING PACKAGE BODY FV_FACTS_TBAL_TRX PACKAGE BODY FV_FACTS_TRX_REGISTER PACKAGE BODY FV_SF133_ONEYEAR PACKAGE BODY FV_SF133_NOYEAR PACKAGE BODY FV_FACTS_TRANSACTIONS PACKAGE BODY FV_FACTS_TBAL_TRANSACTIONS PACKAGE BODY ENI_DBI_CO_OBJIDS_MV MATERIALIZED VIEW PJI_TIME_PA_RPT_STR_MV MATERIALIZED VIEW POA_MID_BS_J_MV MATERIALIZED VIEW POA_IDL_BS_J_MV MATERIALIZED VIEW POA_ITEMS_MV MATERIALIZED VIEW GL_ACCESS_SET_LEDGERS MATERIALIZED VIEW LNS_LOAN_DTLS_ALL_MV MATERIALIZED VIEW OZF_CUST_FUND_SUMMARY_MV MATERIALIZED VIEW FV_SLA_FV_PROCESSING_PKG PACKAGE BODY NIB_MV_TB MATERIALIZED VIEW OE_ITEMS_MV MATERIALIZED VIEW PA_DEDUCTIONS_W PACKAGE PA_DEDUCTIONS_PUB PACKAGE PA_DEDUCTIONS_PUB PACKAGE BODY PA_DEDUCTIONS_W PACKAGE BODY PA_DCTN_APRV_NOTIFICATION PACKAGE BODY </code></pre> <p>So I wanted to know that If I keep them invalid what problem they can cause?</p> <p>Steps I took to know myself:-</p> <p>I have searched over Oracle support and google by object name but the only thing i get there is patch no to resolve the issue or in some case that ignore these objects they will do nothing.</p> <p>If anyone have information about these object and what problem they can cause in application. Please do share.</p> <p>Thanks in Advance!!!</p>
34,912,480
0
<p>if you are using XAMPP then first ("stop") MySQL Then go to C:\xampp\mysql\data\dnb where in my case dnb is my database name folder. so then open it and delete .ibd file hence you can only delete it when you already stop MYsql . then go to phpmyadmin 1 click on phpmyadmin . 2 click on databases that appear below (server.127.0.0.1 in your case my be change) 3 then check your database which you want to drop,and click on drop. 4 then you can create database with same name and import your database successfully .<a href="http://i.stack.imgur.com/kd9Rx.png" rel="nofollow">here you can see how you drop database from phpmyadmin</a></p>
11,865,844
0
<p>even if your app is in paused/stopped state, log cat will still be working as long as device is connected. make sure you selected all logs options in windows > devices > all logs instead of windows > devices > com.your.project . so when you will try to relaunch crash must be recorded in logCat</p> <p>if still have any issue, install logcat app from market and refer it for logs.</p>
3,707,600
0
<p>Don't. Pass the PersistenceManager to your class as part of the context, instead. Relying on statics or globals is usually a bad idea, especially in a multithreaded environment like a Java servlet.</p>
17,881,937
0
<p><strong>Javascript dont have classes</strong></p> <p>But you can systemise your code.Javascript inheritance is totally different from that of othe oop languages.</p> <p>Here,We use prototypes and constructors.</p> <p>*<em>prototype==></em>*In simple words,I am used for extension purpose</p> <p>*<em>constructors==></em>*I am used for creating multiple instances.Any function can be used as a constructor by using the new keyword.</p> <p>Just sample codes for understanding.</p> <p><strong>SAMPLE 1:BY USING OBJECT LITERAL</strong></p> <pre><code>var Myobject = { Function_one: function() { //some code Myobject.function_three(); }, Function_two: function() { //some code Myobject.function_three();//lets say i want to execute a functin in my object ,i do it this way... }, Function_three: function() { //some code } }; window.onload = Myobject.Function_one //this is how you call a function which is in an object </code></pre> <p><strong>SAMPLE 2:BY USING PROTOTYPE</strong> </p> <pre><code>function function_declareVariable() { this.a= 10; //i declare all my variable inside this function this.b= 20; } function_declareVariable.prototype.Function_one = function() { //some code Myobject.Function_three(); }; function_declareVariable.prototype.Function_two = function() { Myobject.Function_three(); }; function_declareVariable.prototype.Function_three = function() { alert(Myobject.a or Myobject.b) //some code }; var Myobject = new function_declareVariable();//this is how i instantiate </code></pre> <p><a href="http://stackoverflow.com/questions/16835451/javascript-prototypes-objects-constructori-am-confused">REFER 1:what are constructors ,prototypes</a></p> <p><a href="http://stackoverflow.com/questions/12201082/prototypal-inheritance-concept-in-javascript-as-a-prototype-based-language">REFER 2:prototypal inheritance</a></p>
13,210,944
0
<p>Try something like this. It simply appends to the list instead of directly stating an index point. If you need to specify an index point, that is what dictionaries are for, so you should be using that instead of an array.</p> <pre><code>var aMainNav = ['b1', 'b2', 'b3']; var i = 0; while(i &lt; aMainNav.length){ var j = ++i; var item = $('.mainNav li:nth-child('+j+')')); aMainNav.push(item); i++; } </code></pre>
34,678,230
0
<p><strong>ROUTES</strong></p> <p>replace this </p> <pre><code>match "/users?q=" =&gt; "users#show", :via =&gt; [:get] </code></pre> <p>to this</p> <pre><code>get "users" =&gt; "users#show" get "users/:q" =&gt; "users#show" </code></pre> <p>and</p> <p><strong>CONTROLLER</strong></p> <pre><code>def set_user @user ||= EvercamUser.find(:all, :conditions =&gt; ["id = ? or email = ?", params[:q], params[:q]]) end </code></pre>
25,217,360
0
Grooveshark is an online music streaming service with search engine and recommendation application.
22,852,207
0
Javascript show div when button is clicked <p>I realize that this is a common question and I have searched for solutions and the one that I'm trying to use (it works in jsfiddle) but when I tried to use it in my website it just won't work. I'm trying to show a div when a button is clicked. Am I doing something wrong? Maybe there's something wrong with the javascript? Or could it be I need to include a jquery js file? Thanks for your help in advance.</p> <p>Here is the code I'm trying to use:</p> <pre><code>&lt;script type="text/javascript"&gt; $("#seeAnswer").click(function() { $('#subtext').html($(this).next().html()); }); &lt;/script&gt; </code></pre> <p>And I'm trying to use it with this:</p> <pre><code>&lt;div class="back_button"&gt; &lt;button id="seeAnswer"&gt;See Answer&lt;/button&gt; &lt;/div&gt; &lt;span&gt; &lt;?php /* foreach($row2 as $ans) { $answer = $ans['answer']; } echo $answer; echo "hi"; */ ?&gt; &lt;?php foreach ($row2 as $ans) : ?&gt; &lt;p&gt;&lt;?php htmlspecialchars($ans['answer']) ?&gt;&lt;/p&gt; &lt;?php endforeach ?&gt; &lt;p&gt;hi there&lt;/p&gt; &lt;/span&gt; &lt;div id="subtext"&gt; &lt;/div&gt; </code></pre>
20,173,971
0
<p>Try to write simple programs first. The more you write code, the better you understand it. No one can learn programming just by reading books or written codes. Programming looks hard at first but eventually it becomes a second nature. Never memorize code. Nothing good ever comes out of it. Just understand what a particular class do and IDe will help you in writing methods and properties. Almost any IDE these days has an Auto-complete feature. Don't fret by the amount of code you see in an application. Lots of them are generated automatically by game engine, though you should understand what they mean and do. To give an example this is the source code of a simple converter application I made. You can see how much code is here but with Netbeans IDE I have just written two lines of that, all other are auto generated.</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Home; /** * * @author Windows8 */ public class CelsiusConverterGUI extends javax.swing.JFrame { /** * Creates new form CelsiusConverterGUI */ public CelsiusConverterGUI() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { tempTextField = new javax.swing.JTextField(); celsiusLabel = new javax.swing.JLabel(); convertButton = new javax.swing.JButton(); fahrenheitLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Celsius Converter"); celsiusLabel.setText("Celsius"); convertButton.setText("Convert"); convertButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { convertButtonActionPerformed(evt); } }); fahrenheitLabel.setText("Fahrenheit"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(tempTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(celsiusLabel)) .addGroup(layout.createSequentialGroup() .addComponent(convertButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(fahrenheitLabel))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {convertButton, tempTextField}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tempTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(celsiusLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(convertButton) .addComponent(fahrenheitLabel)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// &lt;/editor-fold&gt; private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //Parse the celsius input into double int tmpFah = (int) ((Double.parseDouble(tempTextField.getText())) * 1.8 + 32); fahrenheitLabel.setText(tmpFah + " Fahrenheit"); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //&lt;editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "&gt; /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //&lt;/editor-fold&gt; /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CelsiusConverterGUI().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JLabel celsiusLabel; private javax.swing.JButton convertButton; private javax.swing.JLabel fahrenheitLabel; private javax.swing.JTextField tempTextField; // End of variables declaration } </code></pre>
9,111,719
0
Word Art effect in Flash Design Studio using ActionScript <p>How can I develope word Art effect functinality for run time added test (Like Blue Cotton)? Please see the given below example <a href="http://www.bluecotton.com/studio.html" rel="nofollow">Click Here For Example</a></p> <ol> <li>click on the example link</li> <li>After loading add the Text on T-shirt</li> <li>Write Some Text in side teh added teztfield and make it done. </li> <li>you will find out the Text Effect Popup window in the application</li> <li>click on the Shape, new popup window will come out and it will contain some Word Art effect options,</li> <li>Please select and check the output.</li> </ol> <p>I want to this type effect all / some of them.</p> <p>Can you help me to get it done?</p>
10,649,994
0
<p>Tricky but possible for DLL's. Your DLL should implement <code>wrap_symbol</code> and link with a <code>.DEF</code> file which renames it to <code>symbol</code>. You can call the original function from within your DLL as just <code>symbol()</code>, as the renaming of <code>wrap_symbol</code> happens later.</p>
37,532,995
0
<p>Sounds like you might want to just partake in the routing lifecycle</p> <p>If you are navigating to a module you can create an <code>activate</code> method on the view model which will be called when routing starts.</p> <p>In this method you can return a promise (while you fetch data) and redirect if the fetch fails</p> <p>In fact if the promise is rejected, the routing will be cancelled</p> <p>If successful you can use whatever method you need to load in your module (assuming it can't just be part of the module that is being loaded since routing won't be cancelled)</p> <p>Something like</p> <pre><code>activate(args, config) { this.http.get(URL).then(resp =&gt; { if (resp.isOk) { // Do stuff } else { // Redirect } }); } </code></pre>
13,718,438
0
<p>Some people might suggest a (jQuery) function that creates a temporary <code>div</code>, places the text in there, then gets the content of the <code>div</code>, to decode the string.</p> <p>Although the implementation of it is simple, it is rather unsafe, since you'd pretty much be asking for users to put all kinds of html tags in the string.</p> <p><a href="http://phpjs.org/functions/html_entity_decode/" rel="nofollow">I'd suggest using these functions</a><br> (<a href="http://phpjs.org/functions/get_html_translation_table/" rel="nofollow">Requires a second function</a>)</p> <p>These are safer than the <code>div</code> alternative.</p>
8,262,410
0
How to set Content-Length when sending POST request in NodeJS? <pre><code>var https = require('https'); var p = '/api/username/FA/AA?ZOHO_ACTION=EXPORT&amp;ZOHO_OUTPUT_FORMAT=JSON&amp;ZOHO_ERROR_FORMAT=JSON&amp;ZOHO_API_KEY=dummy1234&amp;ticket=dummy9876&amp;ZOHO_API_VERSION=1.0'; var https = require('https'); var options = { host: 'reportsapi.zoho.com', port: 443, path: p, method: 'POST' }; var req = https.request(options, function(res) { console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers); res.on('data', function(d) { process.stdout.write(d); }); }); req.end(); req.on('error', function(e) { console.error(e); }); </code></pre> <p>When i run the above code i am getting below error. </p> <p><strong>error message:</strong> </p> <pre><code>statusCode: 411 headers: { 'content-type': 'text/html', 'content-length': '357', connection: 'close', date: 'Thu, 24 Nov 2011 19:58:51 GMT', server: 'ZGS', 'strict-transport-security': 'max-age=604800' } "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 411 - Length Required </code></pre> <p>How to fix the abobe error?<br> I have tried doing below </p> <pre><code>var qs = 'ZOHO_ACTION=EXPORT&amp;ZOHO_OUTPUT_FORMAT=JSON&amp;ZOHO_ERROR_FORMAT=JSON&amp;ZOHO_API_KEY=dummy1234&amp;ticket=dummy9876&amp;ZOHO_API_VERSION=1.0'; ' options.headers = {'Content-Length': qs.length} </code></pre> <p>But if I try this way I am getting below error: </p> <pre><code>{ stack: [Getter/Setter], arguments: undefined, type: undefined, message: 'socket hang up' } </code></pre> <p>Can anybody help me on this? </p> <p>Thanks<br> koti </p> <p>PS:If I enter the whole url into browser address bar and hit enter I am getting JSON response as expected. </p>
481,149
0
<p>Check whether your STL map is empty() before doing a find(). Some STL implementations are buggy when executing a find() on an empty STL map.</p>
38,451,749
0
<p>I would use GCD for this purpose, please refer to this tutorial or to apple documentation : <a href="https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1" rel="nofollow">https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1</a></p> <p>This would optimize the number of threads according to the device capabilibilities and eliminate unnecessary thread allocations. You would need Concurrent queue. The simplest(not the most optimized way) is: </p> <pre><code> dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // do your task here }); </code></pre> <p>For more information check the previously mentioned article.</p>
2,168,309
0
<p>You can also check if the device can invoke the SMS app with</p> <pre><code>[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:stringURL]] </code></pre>
29,046,415
0
<p>Currently your query is returning 4 rows:</p> <pre><code>[ { name: 'john', baggageno: 5, destination: 'toronto', 'max(ts)': 'Sat Mar 14 2015 02:25:03 GMT-0400' }, { name: 'jill', baggageno: 1, destination: 'karachi', 'max(ts)': 'Sat Mar 14 2015 02:25:03 GMT-0400' }, { name: 'jane', baggageno: 2, destination: 'new york', 'max(ts)': 'Sat Mar 14 2015 02:25:03 GMT-0400' }, { name: 'jim', baggageno: 5, destination: 'glasgow', 'max(ts)': 'Sat Mar 14 2015 02:25:03 GMT-0400' }, ] </code></pre> <p>and you're picking the first row out of that result set, so that is why you're seeing what you're seeing (although the ordering of the rows is up to the server because you did not request a specific ordering).</p> <p>You need to add some kind of filter if you're trying to find the record(s) with the latest <code>ts</code> value. For example, using a join might look something like:</p> <pre class="lang-sql prettyprint-override"><code>SELECT map.* FROM map LEFT JOIN map map2 ON map.name = map2.name AND map.baggageno = map2.baggageno AND map.destination = map2.destination AND map.ts &lt; map2.ts WHERE map2.name IS NULL </code></pre> <p>You can also do something similar except using an inner join, if you want to do it that way.</p>
1,145,668
0
<p>Make sure that your self-signed certificate matches your site URL. If it does not, you will continue to get a certificate error even after explicitly trusting the certificate in Internet Explorer 8 (I don't have Internet Explorer 7, but Firefox will trust the certificate regardless of a URL mismatch).</p> <p>If this is the problem, the red "Certificate Error" box in Internet Explorer 8 will show "Mismatched Address" as the error after you add your certificate. Also, "View Certificates" has an <strong>Issued to:</strong> label which shows what URL the certificate is valid against.</p>
10,495,410
0
Drupal : How to remove the <p> and <br> tag from content when using syntaxhighlighter <p><strong>Used Version 7.14</strong></p> <p>I am using <a href="http://drupal.org/project/syntaxhighlighter" rel="nofollow noreferrer">syntaxhighlighter</a> for my website. But when I insert some code samples it always producing output with more <p> and <br> also content in single line as well .</p> <p>I am done just copy paste the code from zend studio editor inside the syntaxhighlighter tag</p> <p>I've searched over many forums and druapl site itself, but nothing works for me. Please advise me on this</p> <p>See the picture below for more</p> <p><img src="https://i.stack.imgur.com/YCxz9.jpg" alt="enter image description here"></p>
34,057,137
0
How to program a game loop with pausing? <p>To begin with I'm programming a simple Snake recreation in Java and I need your advice on how to go about gameloop/pausing in the game. Right now the game is fully working but I've used a Timer class in my code and I'm not sure if it's the right way. My questions are what is the best way to code game loop and pausing the game, and how to go about speeding up the snake (I want to have 4 different levels) ? I attach my current "gameloop".</p> <p>Here's an initialization of timer:</p> <pre><code> level = model.getLevelTime(); gameTimer = new Timer(level,this); gameTimer.start(); </code></pre> <p>Here's a loop.</p> <pre><code>public void actionPerformed(ActionEvent event) { gameLoop(); } public void gameLoop() { view.passArrays(model.snake.getPosX(), model.snake.getPosY()); view.snakePanel.updateMoveDirection(model.snake.getUp(), model.snake.getDown(), model.snake.getRight(), model.snake.getLeft()); if(model.snake.getGrown()) model.snake.addBodyPart(); model.snake.moveSnake(); model.fruit.checkIfEaten(model.snake.getXPos(), model.snake.getYPos()); view.passApplePos(model.fruit.getAppleXPos(), model.fruit.getAppleYPos()); view.snakePanel.setScore(model.getScore()); refresh(); checkGameOver(); defineActions(); } </code></pre>
14,738,538
0
One-line copy command when source and dest path are the same <p>I want to backup a file in some-other sub-directory different from my current directory like this:</p> <pre><code>cp /aaa/bbb/ccc/ddd/eeee/file.sh /aaa/bbb/ccc/ddd/eeee/file.sh.old </code></pre> <p>As you see both source and dest dir are the same, so common convention would be to change to the common directory, perform the copy im <code>./</code>, then change back to the original directory.</p> <p>Is there a single-line command to accomplish the copy in this situation?</p>
8,414,764
0
<p>Under Windows 7 on present generation processors, this is a reliable high precision (nanosecond) timer inside the CPU (HPET).</p> <p>Under previous versions and on previous generations of processors, it is "something", which can mean pretty much <em>anything</em>. Most commonly, it is the value returned by the RDTSC instruction (or an equivalent, on non-x86), which may or may not be reliable and clock-independent. Note that RDTSC (originally, by definition, but not any more now) does not measure <em>time</em>, it measures <em>cycles</em>.</p> <p>On current-and-previous-generation CPUs, RDTSC is usually reliable and clock-independent (i.e. it is now <em>really</em> measuring time), on <em>pre</em>-previous generation, especially on mobile or some multi-cpu rigs it is not. The "timer" may accelerate and decelerate, and even be different on different CPUs, causing "time travel".</p> <p><strong>Edit:</strong> The <code>constant tsc</code> flag in cpuid(0x80000007) can be used to tell whether RDTSC is reliable or not (though this does not really solve the problem, because what to do if it isn't, if there is no alternative...).</p> <p>On yet older systems (like, 8-10 years old), some other timers may be used for QueryPerformanceCounter. Those may neither have high resolution at all, nor be terribly accurate.</p>
686,474
0
<p>On some systems (Windows with VC springs to mind, currently), <code>RAND_MAX</code> is ridiculously small, i. e. only 15 bit. When dividing by <code>RAND_MAX</code> you are only generating a mantissa of 15 bit instead of the 23 possible bits. This may or may not be a problem for you, but you're missing out some values in that case.</p> <p>Oh, just noticed that there was already a comment for that problem. Anyway, here's some code that might solve this for you:</p> <pre><code>float r = (float)((rand() &lt;&lt; 15 + rand()) &amp; ((1 &lt;&lt; 24) - 1)) / (1 &lt;&lt; 24); </code></pre> <p>Untested, but might work :-)</p>
13,746,855
0
<p>In the apps I work on we have a array of all items and a copy which is the one the datasource refers to. When a filter is applied it replaces the copy but is based on the original array. So I guess #2.</p>
15,007,277
0
IE10 rendering artifacts <p>I'm testing <a href="http://www.raditaz.com" rel="nofollow noreferrer">my website</a> in IE10 on Windows 8 and I keep getting a bunch of rendering artifacts around or above certain elements. Here's a screenshot (note the black bar):</p> <p><img src="https://i.stack.imgur.com/5ZxHv.png" alt="enter image description here"></p> <p>The artifacts appear inconsistently – they'll flicker on and off as I interact with the page – but always in the same places, across refreshes.</p> <p>I'm running Windows 8 in Parallels on a Mac, so my initial hunch was that it was a video card driver issue, but no other browser in Windows 8 exhibits these artifacts. Wouldn't a driver issue affect all browsers the same way?</p>
21,756,156
0
<p>Old question, but I found that the existing answers do not completely convert the text to plain. They seem to set the font to Helvetica and the size to 12.</p> <p>However, you can pipe <a href="https://developer.apple.com/library/mac/documentation/darwin/reference/manpages/man1/pbcopy.1.html" rel="nofollow">pbcopy and pbpaste</a> to really remove formatting.</p> <p>In the Terminal:</p> <pre><code>$ pbpaste | pbcopy </code></pre> <p>As an AppleScript:</p> <pre><code>do shell script "pbpaste | pbcopy" </code></pre> <p>That's it.</p>
18,231,867
0
<p>No, CDH4 is not meant mainly for YARN. CDH5, on the other hand, will be.</p> <p>I'm not sure how you went about setting up your CDH cluster, but it's rather easy to add the MapReducev1 service, as opposed to YARN, using Cloudera Manager.</p> <p>Very few companies use YARN in production, Yahoo being the most notable.</p> <p>CDH4 is not YARN-centric. Cloudera includes YARN so people can have the most recent Hadoop bits accessible to them - but it's very clear on Cloudera's website that they do not recommend YARN for production.</p> <p>One of the big things that CDH4 brought to the table last year was HDFSv2, and they made MRv1 compatible with it.</p> <p>To install CDH4 with MRv1, see <a href="http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/4.2.0/CDH4-Installation-Guide/cdh4ig_topic_11_3.html?scroll=topic_11_3" rel="nofollow">here</a>.</p>
39,690,045
0
<p>I assume that you're using the <a href="http://wso2.com/library/tutorials/develop-osgi-bundles-using-maven-bundle-plugin" rel="nofollow">maven-bundle-plugin</a> to build the bundle. If so, in your extension project pom file, recheck maven-bundle-plugin configurations. </p> <p>Check whether the <code>Bundle-SymbolicName</code> has being provided to the plugin. You may refer to <a href="https://github.com/wso2-extensions/siddhi-window-unique-time/blob/master/pom.xml#L64" rel="nofollow">this example of another extension, being written to Siddhi</a>.</p> <p><a href="https://github.com/wso2/carbon-kernel/blob/v4.4.3/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/extensions/DropinsBundleDeployer.java#L107" rel="nofollow">According to the source code</a> (the source of Carbon 4.4.3 DropinsBundleDeployer which deploys the bundles we put into the dropins folder), this error could occur:</p> <ol> <li>when the <code>Bundle-SymbolicName</code> has not being given or </li> <li>when the <code>Bundle-Version</code> has not being given.</li> </ol> <p>So in case, putting the <code>Bundle-SymbolicName</code> in to the config didn't make a difference, I would try adding the <code>Bundle-Version</code> as well. You can find a sample config in this <a href="http://wso2.com/library/tutorials/develop-osgi-bundles-using-maven-bundle-plugin" rel="nofollow">maven-bundle-plugin tutorial</a>.</p>
19,828,552
0
<p>Try (untested):</p> <pre><code>$duration = preg_replace("#duration\s*:\s*(\d{2}:\d{2}:\d{2}.\d+)#i", "$1", $input) $datasize = preg_replace("#datasize\s*:\s*(\d+)#i" , "$1", $input) $audiobitrate = preg_replace("#audio\s*:.*,\s*(\d+)\s*kb/s#i" , "$1", $input) </code></pre> <p>The same thing I did with "datasize" should work for every information you'd like to get, despite the ones having a different format (like duration and the stream info with the audio bitrate inside)</p>
6,914,031
0
<p>If you look at the contents of <code>Cygwin.bat</code>, you'll see it calls the <code>bash.exe</code> binary:</p> <pre><code>@echo off C: chdir C:\cygwin\bin bash --login -i </code></pre> <p>Command binaries usually have a <code>help</code> argument. In this case, bash most certainly does:</p> <pre><code>bash --help GNU bash, version 3.2.49(23)-release-(i686-pc-cygwin) Usage: bash [GNU long option] [option] ... bash [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Type `bash -c "help set"' for more information about shell options. Type `bash -c help' for more information about shell builtin commands. Use the `bashbug' command to report bugs. </code></pre> <p>Now that we know what options it takes, your Java application can call bash directly:</p> <pre><code>String commandString = "help"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec("C:\\cygwin\\bin\\bash -c " + commandString); </code></pre> <p>Remember to replace <code>commandString</code> with the value from your Swing component.</p>
5,701,333
0
<p>As your error log shows "open_basedir restriction in effect." you can't really include anything outside from your basedir or outside from webroot in this server without changing the php configuration open_basedir variable</p>
36,586,678
0
How do i open a ,exe on chrome box <p>How do I open a .exe on chrome box? I tried to use Google OAuth. program but it doesn't seem to do anything . I'm trying to run a recording of a class on Wiziq. Please help! Thanks!</p>
23,387,413
0
pywinauto batch file running error <p>Im a biologist and new to pywinauto, i wrote a code to open an input file in HYPHY application using pywinauto, when i run my code line by line in command line it works fine but when i run the code as a batch file it gives the following error.</p> <pre><code>Traceback (most recent call last): File "C:\Users\Masyh\Desktop\autowin_test.py", line 8, in &lt;module&gt; w_handle = pywinauto.findwindows.find_windows(title=u' Please select a batch file to run:', class_name='#32770')[0] IndexError: list index out of range </code></pre> <p>the code is:</p> <pre><code>import pywinauto pwa_app = pywinauto.application.Application() w_handle = pywinauto.findwindows.find_windows(title=u'HYPHY Console', class_name='HYPHY')[0] window = pwa_app.window_(handle=w_handle) window.SetFocus() window.MenuItem(u'&amp;File-&gt;&amp;Open-&gt;Open &amp;Batch File\tCtrl+O').Click() w_handle = pywinauto.findwindows.find_windows(title=u' Please select a batch file to run:', class_name='#32770')[0] window = pwa_app.window_(handle=w_handle) window.SetFocus() ctrl = window['Edit'] ctrl.Click() ctrl.TypeKeys('brown.nuc') ctrl=window['&amp;open'] ctrl.Click() </code></pre> <p>i guess the problem is that the window which gets the input(#'please select a batch file menue') is not open at the beginning and the first part of the code opens it but python looks for it from the beginning and cant find it. i really appreciate any suggestions how to solve this.</p>
2,137,251
0
<p>Since you are using a Mac, I assume you have Ruby installed.</p> <p>What you are talking about sounds like you want a thread to sleep for 30 seconds and then execute a script in the background.</p> <p>You should put <code>… do some stuff</code> in a script named dostuff.scpt and place it in your Desktop.</p> <p>Then change your current script to the following code:</p> <pre><code>using terms from application "iChat" on logout finished do shell script "ruby -e 'Thread.new {`sleep 30 &amp;&amp; osascript ~/Desktop/dostuff.scpt`}' &amp;&gt; /dev/null" end logout finished end using terms from </code></pre> <p>A code breakdown: do shell script (executes something from the command line)</p> <p>ruby -e (executes ruby code from the command line)</p> <p>Thread.new (makes a new thread to hide in the background)</p> <p>` (Everything in the backtick is a shell command in ruby)</p> <p>osascript (Executes an applescript from the command line)</p> <p>~/Desktop/dostuff.scpt (Points the pathname to your file, the tilde substitutes to your home directory, and I assume you put dostuff.scpt on the Desktop)</p> <p>&amp;> /dev/null (<a href="http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html" rel="nofollow noreferrer">Tells Applescript to not look for output and immediately go to the next code line</a>)</p> <p>I tried doing this without Ruby, however, I had no luck. Let me know if this works for you!</p>
246,980
0
<p>The counter i optimized works like this:</p> <pre><code>UPDATE page_views SET counter = counter + 1 WHERE page_id = x if (affected_rows == 0 ) { INSERT INTO page_views (page_id, counter) VALUES (x, 1) } </code></pre> <p>This way you run 2 query for the first view, the other views require only 1 query.</p>
36,562,428
0
Extract Skin pixels in face using scale space filtering method <p>I'm trying to implement color constancy method in this paper.'<a href="http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=6701394" rel="nofollow">http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=6701394</a>'. In this paper , the skin pixels are detected using scale space filtering method. I'm unable to go forward after forming a scale space image for the histogram of skin pixels extracted from face regions. please help me out. thanks in advance.</p> <pre><code>close all; clear all; clc; a = imread('Input.jpg'); %subplot(2,2,1); imshow(a); [row col dim] = size(a); hsv = rgb2hsv(a); % convert rgb to hsv h = hsv(:,:,1); h=h(:); s = hsv(:,:,2); v = hsv(:,:,3); [Hi,x]=hist(h,200); % forming an histogram with 200 bins plot(x,Hi); N=sum(Hi); Hist=Hi./N; % Normalize the histogram P=[]; figure;plot(Hist); sigma=2:2:50; % range of sigma values taken for forming scale space count=length(sigma); for i=1:count f1 = normpdf(-20:20,0,sigma(i)); % &lt;== f(x) gaussian distribution p1 = conv(Hist,f1,'same'); P=[P; p1]; subplot(count,1,i); plot(p1);%title('smoothed signal with sigma='num2str(sigma)); end % Here P is tha scale space image mask=[1 -2 1]; for j=1:count P_derv(j,:)=conv(P(j,:),mask,'same'); %figure; subplot(count,1,j); end %P_derv is the 2nd derivative of the scale space image. </code></pre> <p>Now , I have to found the zero contour and interval tree to identify the peak in histogram. The scale space filtering method is found in this paper. <a href="http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=1172729" rel="nofollow">http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=1172729</a></p>
19,454,546
0
Setup TinyMce editor in C# MVC 4 - Visual Studio 2012 <p>Always get this error:</p> <p>get: 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'tinymce'</p> <p>By Nuget: PM> Install-Package TinyMCE.MVC.JQuery newest version</p> <p>Model Class:</p> <pre><code>using System.Web.Mvc; using System.ComponentModel.DataAnnotations; namespace Familytree.Models { public class TinyMCEModelJQuery { [AllowHtml] [UIHint("tinymce_jquery_full")] public string Content { get; set; } } } </code></pre> <p>Controller:</p> <pre><code>using System.Web.Mvc; namespace Familytree.Controllers { public class TinyMCESampleJQueryController : Controller { // // GET: /TinyMCESampleJQuery/ [ValidateInput(false)] public ActionResult Index() { return View(); } } } </code></pre> <p>View:</p> <pre><code> @model Familytree.Models.TinyMCEModelJQuery &lt;h2&gt;Index&lt;/h2&gt; @using (Html.BeginForm()) { &lt;fieldset&gt; &lt;legend&gt;TinyMCEModel&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Content) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Content) @Html.ValidationMessageFor(model =&gt; model.Content) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } </code></pre> <p>tinymce_jquery_full under Shared folder and Editor Template</p> <p>@* Don't forget to reference the JQuery Library here, inside your view or layout.</p> <p>*@</p> (function(){ $(function() { $('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({ // Location of TinyMCE script script_url: '@Url.Content("~/Scripts/tinymce/tiny_mce.js")', theme: "advanced", height: "500", width: "790", verify_html : false, plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,codehighlighting,netadvimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : false, // Example content CSS (should be your site CSS) content_css : "@Url.Content("~/Scripts/tinymce/css/content.css")", convert_urls : false, // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js" }); }); })(); <p>@Html.TextArea(string.Empty, /* Name suffix <em>/ ViewData.TemplateInfo.FormattedModelValue /</em> Initial value */ )</p> <p>Do I change this last line to @Html.EditorFor(string.Empty, /* Name suffix <em>/ ViewData.TemplateInfo.FormattedModelValue /</em> Initial value */ ) Using EditorFor in the Index view</p>
5,438,192
0
Problems connecting to database in VB.NET <pre><code>Dim con As New System.Data.SqlClient.SqlConnection con.ConnectionString = "Server=iraq\\sqlexpress ; Database=stats ; Trusted_Connection=True ;" Dim com As New System.Data.SqlClient.SqlCommand com.CommandText = "insert into users values('" &amp; TextBox1.Text &amp; "','" &amp; TextBox2.Text &amp; "','" &amp; TextBox3.Text &amp; "')" com.Connection = con con.Open() com.ExecuteNonQuery() con.Close () </code></pre> <p>There are new events happen when i adjust the connection string</p> <pre><code>con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\WebSite2\App_Data\stats.mdf;Integrated Security=True;User Instance=True" </code></pre> <p>show me error with com.ExecuteNonQuery() </p> <p>any suggestion ? </p>
7,482,647
0
<p>Try using the CURLOPT_RETURNTRANSFER option:</p> <pre><code> $ch = curl_init(); $url = complete url of get request that works when directly placed into adress bar curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $data = curl_exec ($ch); curl_close ($ch); echo $data; </code></pre>
8,021,261
0
jQuery 1.7 is *still* returning the event.layerX and event.layerY error in Chrome <p>What am I doing wrong? Am I misunderstanding the problem or is it something else entirely?</p> <p>On my page I was using jQuery 1.6.4 from the Google CDN. This would, of course, generate the error:</p> <blockquote> <p>event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.</p> </blockquote> <p><a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/" rel="nofollow">I read here</a> that jQuery 1.7 removed this issue. However, after updating my application to 1.7, I'm still seeing it. I'm using the Microsoft CDN until Google put the link up.</p> <p>Things I've tried before posting this:</p> <ul> <li>Clearing the browser cache</li> <li>Changing back to jQuery 1.6.4 (still happens - obviously)</li> <li>Using jQuery 1.7-specific code to make sure 1.7 is actually being loaded - <code>.on()</code> works fine when I use 1.7 but obviously gives undefined errors with 1.6.4 - I thought this should prove 1.7 is actually running</li> <li>Commenting out and removing all other Javascript from my application - everything except for jQuery 1.7. Still triggers the error.</li> </ul> <p>Any ideas?</p>
18,342,185
0
<p>Pass by reference:</p> <pre><code>foreach ($posts as $post =&gt; &amp; $content) { $find = array('~\[image="(https?://.*?\.(?:jpg|jpeg|gif|png|bmp))"\](.*?)\[/image\]~s'); $replace = array('&lt;img src="$1" alt="" /&gt;&lt;p&gt;$2&lt;/p&gt;'); $content = preg_replace($find, $replace, $content); } </code></pre>
40,120,468
0
Graph 2 files using gnuplot <p>I am trying to create a graph on gnuplot for 2 different files. When I run the script I get the graph just for the first file: In this case "graph1.dat". At this point I try with plot and replot but I have tried some solutions but they did not work.</p> <p>For example:</p> <p>plot "./plot/graf-1.dat" using 1:2 with linespoint title "graph1" , "./plot/graf-2.dat" using 1:2 with lines title "graph2".</p> <p>Both files are in the folder ./plot.</p> <p>The files have the information like the following:</p> <p>012016 14498 </p> <p>022016 7135 </p> <p>032016 10500 </p> <p>042016 16695 </p> <p>052016 16245 </p> <p>062016 13416 </p> <p>This is the script I used:</p> <pre><code> set xdata time set timefmt '%m' set xrange ["012016" : "062016" ] set format x '%m' set terminal png set title "graph1 and graph2 2016" set ylabel "Values" set output 'graf.png' plot "./plot/graf-1.dat" using 1:2 with linespoint title "graph1" replot "./plot/graf-2.dat" using 1:2 with lines title "graph2" </code></pre> <p>Any help is very appreciated.</p>
26,050,930
0
<p>Let's define a term: <code>operation = command or query</code> from a domain perspective, for example <code>ChangeTaskDueDate(int taskId, DateTime date)</code> is an operation.</p> <p>By REST you can map operations to resource and method pairs. So calling an operation means applying a method on a resource. The resources are identified by URIs and are described by nouns, like task or date, etc... The methods are defined in the HTTP standard and are verbs, like get, post, put, etc... The URI structure does not really mean anything to a REST client, since the client is concerned with machine readable stuff, but for developers it makes easier to implement the router, the link generation, and you can use it to verify whether you bound URIs to resources and not to operations like RPC does.<br> So by our current example <code>ChangeTaskDueDate(int taskId, DateTime date)</code> the verb will be <code>change</code> and the nouns are <code>task, due-date</code>. So you can use the following solutions:</p> <ul> <li><code>PUT /api{/tasks,id}/due-date "2014-12-20 00:00:00"</code> or you can use </li> <li><code>PATCH /api{/tasks,id} {"dueDate": "2014-12-20 00:00:00"}</code>. </li> </ul> <p>the difference that patch is for partial updates and it is not necessary idempotent.</p> <p>Now this was a very easy example, because it is plain CRUD. By non CRUD operations you have to find the proper verb and probably define a new resource. This is why you can map resources to entities only by CRUD operations.</p> <blockquote> <p>Going back to the REST Service, the way I see it there are 3 options:</p> <ol> <li>Make RPC style urls e.g. <a href="http://example.com/api/tasks/" rel="nofollow">http://example.com/api/tasks/</a>{taskid}/changeduedate</li> <li>Allow for many commands to be sent to a single endpoint e.g.: <ul> <li>URL: <a href="http://example.com/api/tasks/" rel="nofollow">http://example.com/api/tasks/</a>{taskid}/commands</li> <li>This will accept a list of commands so I could send the following in the same request: <ul> <li>ChangeDueDate command</li> <li>ChangeDescription command</li> </ul></li> </ul></li> <li>Make a truly restful verb available and I create domain logic to extract changes from a dto and in turn translate into the relevant events required e.g.: <ul> <li>URL: <a href="http://example.com/api/tasks/" rel="nofollow">http://example.com/api/tasks/</a>{taskid}</li> <li>I would use the PUT verb to send a DTO representation of a task</li> <li>Once received I may give the DTO to the actual Task Domain Object through a method maybe called, UpdateStateFromDto</li> <li>This would then analyse the dto and compare the matching properties to its fields to find differences and could have the relevant event which needs to be fired when it finds a difference with a particular property is found.</li> </ul></li> </ol> </blockquote> <ol> <li><p>The URI structure does not mean anything. We can talk about semantics, but REST is very different from RPC. <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm" rel="nofollow">It has some very specific constraints, which you have to read before doing anything.</a></p></li> <li><p>This has the same problem as your first answer. You have to map operations to HTTP methods and URIs. They cannot travel in the message body.</p></li> <li><p>This is a good beginning, but you don't want to apply REST operations on your entities directly. You need an interface to decouple the domain logic from the REST service. That interface can consist of commands and queries. So REST requests can be transformed into those commands and queries which can be handled by the domain logic.</p></li> </ol>
35,132,866
0
How to configure VNC to view xvfb? <p>How do I configure my VNC server and viewer to remotely view an xvfb (X virtual frame buffer) on a Linux machine?</p>
32,270,495
0
How to ignore properties with empty values during deserialization from JSON <p>I'm trying to deserialize a JSON string into a ConcurrentHashMap object and I'm getting errors because my JSON contains properties with null values, but ConcurrentHashMap does not accept null values. Here is the fragment of code: </p> <pre><code>ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(jsonString, ConcurrentHashMap.class); </code></pre> <p>Is there a way to ignore properties with null values during deserialization? I know that we can ignore these properties during serialization:</p> <pre><code>mapper.setSerializationInclusion(JsonInclude.NON_NULL); </code></pre> <p>But what about deserialization process?</p>
22,081,203
0
<p>I suppose you are encountering what is called platform default encoding. For example, when converting bytes into String using new String(byte[]), the default encoding is used to convert bytes to String. Different servers may have different setup that have a different default platform encoding.</p> <p>To prevent different behaviour of the servers due to different default encoding, specify the encoding to use when converting bytes[] to String. If you don't know the encoding to use, that is another matter but at least you get consistent results for the same byte stream.</p> <p>For example, to convert String to UTF-8 byte stream use getBytes("UTF-8") and to get back the String, use String(byte[],"UTF-8");</p>
9,059,382
0
<p>TOAD does it in my case. I am using advantage 8.1 so TOAD will support it. </p>
1,853,306
0
<p>Could you use a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.aspx" rel="nofollow noreferrer">HyperLink</a> control rather than a LinkButton?</p> <p>eg</p> <pre><code>&lt;asp:HyperLink id="hyperlink1" NavigateUrl="&lt;%#Eval('name')%&gt;" Text="&lt;%#Eval('name')%&gt;" Target="_blank" runat="server"/&gt; </code></pre>
25,415,317
0
<p>You can change the Find navigator from searching for text to search for regular expressions, then you can be as detailed as you like.</p> <p>Searching for the regex "myMethodWithParameter.*some" would return all instance of the first and not the second</p> <p>On a side not Bamsworld's answer is good too, I had often wondered what those other options were for in the assistant editor. TIL</p>
20,256,480
0
Prevent eclipse from building the projects before run an Ant task <p>I want to prevent the project from compiling when I run an Ant task, how is this done? </p> <p>Eclipse build setting is not automatic but the build still remains running before any ant task be launched.</p>
7,794,199
0
<p>You should look into the UIAppearance proxy in iOS 5. For earlier versions the singleton approach seems fine, you request an appearance change to the singleton which changes its various images, then either sends a notification (NSNotification) to inform any interested parties who would want to update their interface accordingly. Or you can set key value observers (KVO) on the singleton properties so they are automatically informed when one of them changes.</p> <p><a href="http://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like">This post</a> shows you how to implement a singleton. It's just a way to be able to access the same instance of a class from anywhere. <a href="http://www.makebetterthings.com/blogs/iphone/singleton-design-pattern-for-objective-c/" rel="nofollow">Here</a> is a link to a discussion about the singleton design pattern along with a more involved "pure" singleton implementation.</p>
38,176,409
0
<p>How about adding one extra decimal that is to be rounded and then discarded:</p> <pre><code>var d = 0.241534545765; var result1 = d.ToString("0.###%"); var result2 = result1.Remove(result1.Length - 1); </code></pre>
6,050,805
0
getting the raw source from Firefox with javascript <p>I am writing a program to validate web pages on a remote server. It uses selenium RC to run Firefox with a battery of tests, so I can call arbitrary javascript. When there is a failure I would like to log the page's generated HTML. Now getting access to the DOM HTML is easy, But I am having real trouble finding a way to get at the source. Thanks.</p> <p>I should reiterate that I am not looking for the DOM, but the original unmodified source code. As can be seen through Right click -> view page source. Specifically if <code>&lt;Html&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; fear the table data &lt;/td&gt; &lt;/table&gt;</code></p> <p> is the real HTML. Calls to <code>document.documentElement.outerHTML || document.documentElement.innerHTML</code> and <code>selenium.getHTMLSource()</code> will result in <code>&lt;head&gt; &lt;/head&gt;&lt;body&gt; &lt;table&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt; fear the table data &lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;/body&gt;</code></p>
33,014,919
0
How do you create an array with custom indexes? <p>For some reason I can't create an array with custom indexes in <code>Javascript</code> or <code>PHP</code>. I have searched on Google, but I can't find anything when searching on <em>creating array with custom indexes</em>. I could swear the code below was working before. So was the code below working before or am I doing something wrong? And if the code below was working before then what is the new way of creating an array with custom indexes?</p> <p><strong>PHP</strong></p> <pre><code>&lt;?php $foo = ['bar' =&gt; 'baz']; ?&gt; </code></pre> <blockquote> <p>Error: Array to string conversion</p> </blockquote> <p><strong>Javascript</strong></p> <pre><code>var foo = ['bar' =&gt; 'baz']; </code></pre> <blockquote> <p>Error: Uncaught SyntaxError: Unexpected string</p> </blockquote>
22,040,589
0
<p>There is no immediate way to do this. I suggest you append each substring to a <code>List</code> or even to a <code>Stack</code>, and pop whatever you don't need out of your data structure. When you are totally sure about what to present in your <code>StringBuilder</code>, start appending to it by running through your <code>Collection</code> and putting each substring into your final <code>StringBuilder</code>.</p>
23,541,019
0
<pre><code>SELECT *, 'table_1' as tablename FROM table_1 WHERE text ='Hello' union all SELECT *, 'table_2' as tablename FROM table_2 WHERE text ='Hello' union all SELECT *, 'table_3' as tablename FROM table_3 WHERE text ='Hello' </code></pre>
26,662,921
0
<p>As you give no code it's hard to suggest actual code... However, the customary way to make text invisible is to use the text render mode. All text in PDF has such a text render mode and it determines whether the text is rendered as filled text (normal), stroked text, filled and stroked... And one of the possibilities is "invisible" which makes sure the text isn't shown.</p> <p>When parsing text on a page iText amongst other things allows you to filter the text that is returned - see the FilteredRenderListener for example. During filtering you can then determine whether you're interested in the text or not. There is a lot of information about the text you can inspect using the TextRenderInfo object. This object has a method called "getTextRenderMode" that will return the above text render mode. If that call returns "3", you know the text is rendered invisibly.</p> <p>Now, if you want to know for sure whether this text is indeed rendered invisibly (and not using one of the other nasty tricks @jongware suggests in his comment, you'll have to inspect the PDF or share an example with us so that we can take a look.</p>
25,399,483
0
<pre><code>$array = [1, 6, 2]; array_unshift($array, array_pop($array)); </code></pre> <p>Or possibly:</p> <pre><code>$array = [1, 6, 2]; $tmp = array_splice($array, 2, 1); array_unshift($array, $tmp[0]); </code></pre> <p>You're not really looking for <em>sorting on values</em>, you just want to swap indices.<br> If you want to insert the value somewhere other than the front of the array, splice it back in with <a href="http://php.net/array_splice" rel="nofollow"><code>array_splice</code></a>.</p> <p>If you have more keys that you need to change around, then sorting may after all become the simplest solution:</p> <pre><code>uksort($array, function ($a, $b) { static $keyOrder = [2 =&gt; 0, 0 =&gt; 1, 1 =&gt; 2]; return $keyOrder[$b] - $keyOrder[$a]; }); </code></pre>
29,469,195
0
How to refactor code to avoid multiple if-s [from interview]? <p>On interview I was asked the following question:</p> <p>I have following method:</p> <pre><code>public void foo(SomeObject o){ if(o.matches(constant1)){ doSomething1(); }else if(o.matches(constant2)){ doSomething2(); }else if(o.matches(constant3)){ doSomething3(); } .... } </code></pre> <p>question was: <code>you should refactor method above. What will you do?</code></p> <p>On interview I didn't grasp how to make it.</p> <p>Now I think that <code>state</code> design pattern is suitable for this task ?</p> <p>Am I right? What do you think?</p> <h2>P.S.</h2> <p>I negotiated with my colleague. he thinks that <code>strategy</code> design pattern is more suitable.</p> <h2>P.S.</h2> <p>Another expert thinks that <code>chain of responsibility</code> design pattern is more suitable.</p>
22,544,161
0
Rails db query uniq column value and max value <p>I need to query db unique values and maximum value of another column.</p> <p>For example:</p> <pre><code>:name =&gt; "some_name_1", :version =&gt; 10, :other_columns... :name =&gt; "some_name_1", :version =&gt; 11, :other_columns... :name =&gt; "some_name_2", :version =&gt; 15, :other_columns... :name =&gt; "some_name_3", :version =&gt; 18, :other_columns... </code></pre> <p>What I would need is if the name show up multiple times the query should return only the one with the last version ( higher version number )</p> <p>So it should look like this : </p> <pre><code>:name =&gt; "some_name_1", :version =&gt; 11, :other_columns... :name =&gt; "some_name_2", :version =&gt; 15, :other_columns... :name =&gt; "some_name_3", :version =&gt; 18, :other_columns... </code></pre> <p>note that <code>:name =&gt; "some_name_1", :version =&gt; 10, :other_columns...</code> those not show in the query because a record with the same name already exist with a hither version number.</p> <p>Any idea? </p>
16,642,405
0
<p>The following contrived examples do not have a unique solution. You need to decide what happens in these cases:</p> <pre><code>0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // first item move to end 2, 1, 3, 4, 5, 6, 7, 8, 9, 0 // adjacent items swapped </code></pre> <p>For all other cases, luckily the telling trait is that the "out-of-order" item will be more than 1 away from <strong><em>both</em></strong> its neighbors (because #2 above).</p> <pre><code>for (i = 0; i &lt; arr.length; i++) { int priorIndex = (i-1) % arr.length; int nextIndex = (i+1) % arr.length; int diffToPriorValue = abs(arr[i] - arr[priorIndex]); int diffToNextValue = abs(arr[i] - arr[nextIndex]); if (diffToPriorValue &gt; arr.length/2) diffToPriorValue = arr.length - diffToPriorValue; // wrap-around if (diffToNextValue &gt; arr.length/2) diffToNextValue = arr.length - diffToNextValue; // wrap-around if (diffToPriorValue != 1 &amp;&amp; diffToNextValue != 1) return i; return -1; </code></pre>
20,154,840
0
<p>The first error is strictly a client-side javascript error. The error description means exactly what it says. You should update your js appropriately.</p> <p>The second set of error message probably related to the fact you are making a cross-domain request for a javascript file which is not subject to your headers being sent by PHP. You would need to configure CORS on webserver for such endpoint</p>
37,428,630
0
<p>That error is thrown if the second dimension does not exist. My money would go on that as your problem.</p> <p>Here's an example of an array of jagged arrays, the last being empty. The last line will throw a Type Mismatch error because there is no second dimension.</p> <pre><code>Dim mainArray(0 To 3) As Variant Dim subArray As Variant subArray = Array("A", "B", "C") mainArray(0) = subArray Debug.Print mainArray(0)(0) 'prints A subArray = Array(1, 2, 3, 4) mainArray(1) = subArray Debug.Print mainArray(1)(0) 'prints 1 subArray = Split("HELLO|WORLD", "|") mainArray(2) = subArray Debug.Print mainArray(2)(0) 'prints HELLO mainArray(3) = Empty Debug.Print mainArray(3)(0) 'Type mismatch </code></pre> <p>Have a look in your Locals Window and test if your arrays are correct.</p> <p>As noted in the comments, that <code>ReDim</code> without <code>Preserve</code> looks suspicious - I think you may be clearing your old arrays.</p>
8,378,524
0
fast intersection, complement and union of tab-delimited text files? <p>Can someone recommend a fast unix-based utility (ideally written in C) for getting efficient, streaming intersection/union of tab-delimited text files? For example, allow queries such as "give me the all the entries that in file A that have a column value K that does not appear in any column K of file B".</p> <p>e.g., if file A is:</p> <pre><code>bob sally sue bob mary john </code></pre> <p>and file B is:</p> <pre><code>john sally sue foo bar quux </code></pre> <p>then complement of file A relative to B on column 2 would return "bob mary john", since that's the only in file B that has a value in column 2 that does not appear in file B. </p> <p>I'd prefer not to use a database, but would like a command line based utility. Is awk the answer or is there something simpler? thanks.</p>
2,033,629
0
<p>Some things to check:</p> <ul> <li><p>Does MinGW actually find the <code>winsock</code> library? (It seems so, since there's no explicit error saying otherwise.) If it does not, try to supply an additional library search path using <code>-L</code>.</p></li> <li><p>Did you compile the <code>winsock</code> library source yourself, also with MinGW? If the answer is "no", and the source code is available, that's what you might have to do, so that MinGW will recognise the exported symbols in the library object file.</p></li> </ul>
35,188,317
0
<p>No, you don't need to create a service to access a database on a server. What you are actually asking is how to read from (write to) database on C#. As I understand you already have an access to the database (user account with granted access and password). You will need to use ADO.NET - it's a technology for data access.</p> <p>You will utilize SqlConnection, SqlDataReader and SqlCommand classes. check for example this example: <a href="http://stackoverflow.com/questions/6003480/reading-values-from-sql-database-in-c-sharp">Reading values from SQL database in C#</a></p> <p>There is a newer technology from Microsoft called Entity Framework. It provides better solution for working with databases. Use it if you need to work with many tables and complicated queries.</p>
38,379,066
0
<p>Missed Iops, This is working now</p> <pre><code>{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "MyDB" : { "Type": "AWS::RDS::DBInstance", "Properties": { "DBInstanceClass" : "db.t2.medium", "AllocatedStorage" : "400", "MasterUsername" : "xxxxxxxxxxxx", "MasterUserPassword" : "xxxxxxxxxxxx", "DBSnapshotIdentifier" : "xxxxxxxxxxxx-2016-07-13-1700", "Iops":"2000", "StorageType":"io1" } } } } </code></pre>
31,963,263
0
Visual Studio unable to get developer license <p><a href="https://i.stack.imgur.com/4MbjP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4MbjP.png" alt="Error 0x80072F8F"></a></p> <p>This error is obtained when trying to obtain developer license from Visual Studio 2015. How to resolve?</p>
22,265,971
0
<p><code>PHPrunner</code> uses inbuilt server to preview your generated application. So quite obvious when you close Runner it will close the inbuilt server connection as well. You will have to move the <code>output</code> folder to <code>root folder</code> of your web server. If you look inside your project folder, you will find a folder named <code>output</code>, move this folder to the <code>root folder</code> of your web server, it should work fine.</p> <p>Make sure your web server is powered to use PHP and other drivers related to your project.</p>
34,099,604
0
<p>Add: <code>import Foundation</code></p> <p>Then add an outlet:</p> <p><code>class ViewController: UIViewController { @IBOutlet weak var topConstraint: NSLayoutConstraint! ... } </code> Then change the value to 0 when the view disappears and then to 20 when it will appear:</p> <pre><code>override func viewWillAppear(animated: Bool) { topConstraint.constant = 20.0 } override func viewWillDisappear(animated: Bool) { topConstraint.constant = 0.0 } </code></pre> <p>Full code (make sure to remember to connect the constraint to the outlet):</p> <pre><code>import UIKit import Foundation class ViewController: UIViewController { @IBOutlet weak var topConstraint: NSLayoutConstraint! let controllerTransition = InteractiveControllerTransition(gestureType: .Pan) let controllerTransitionDelegate = ViewController2Transition() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. controllerTransition.delegate = controllerTransitionDelegate controllerTransition.edge = .Bottom } override func viewWillAppear(animated: Bool) { topConstraint.constant = 20.0 } override func viewWillDisappear(animated: Bool) { topConstraint.constant = 0.0 } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func unwindToViewController(sender: UIStoryboardSegue) { } override func prefersStatusBarHidden() -&gt; Bool { return false } @IBAction func helloButtonAction(sender: UIButton) { // let storyBoard = UIStoryboard(name: "Main", bundle: nil) // let vc = storyBoard.instantiateViewControllerWithIdentifier("ViewController2") as! ViewController2 // // vc.transitioningDelegate = controllerTransition // controllerTransition.toViewController = vc // // self.presentViewController(vc, animated: true, completion: nil) let storyBoard = UIStoryboard(name: "Main", bundle: nil) // let nvc = storyBoard.instantiateViewControllerWithIdentifier("NavigationViewController2") as! UINavigationController // let vc = nvc.topViewController as! ViewController2 let vc = storyBoard.instantiateViewControllerWithIdentifier("ViewController2") as! ViewController2 // nvc.transitioningDelegate = controllerTransition vc.transitioningDelegate = controllerTransition controllerTransition.toViewController = vc // self.presentViewController(nvc, animated: true, completion: nil) self.presentViewController(vc, animated: true, completion: nil) } } </code></pre>
32,615,828
0
Can't make transaction in class <p>I have Main activity:</p> <pre><code>public class GeneralActivity extends ActionBarActivity { ... } </code></pre> <p>I have another class in which I create a drawer, I bring to the required parameters. But when I want to move to a different fragment when you click on the menu item, then IDE writes that there is no method getSupportFragmentManager ().</p> <pre><code>public class DrawerClass { public static void drawer(final Activity activity, Toolbar toolbar) { ... result.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) { Log.d("POSITION", "position = " + i); switch (i) { .... case 5: Toast.makeText(activity, R.string.drawer_item_journal, Toast.LENGTH_SHORT).show(); JournalFragment journalFragment = new JournalFragment(); FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.profile_fragment_layout, journalFragment); transaction.commit(); break; } return false; } }); </code></pre> <p>I have an error on the line <code>FragmentTransaction transaction = getSupportFragmentManager()</code> And I don't know how fix it. <br> I use this drawer in several classes, so I created a separate class in order to avoid duplication of code</p>
928,463
0
<p>Universal Business Language and dozens of others are documented at <a href="http://www.oasis-open.org" rel="nofollow noreferrer" title="OASIS">OASIS</a>. UBL is widely accepted as an invoicing standard, at least, and some countries (at least Denmark) make UBL a legal requirement for invoicing public organisations.</p>
15,797,505
0
<p>Without more detail on your situation, here are some helpful resources.</p> <p>For time zones on Rails, have a look here for the various options you can use: <a href="http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html" rel="nofollow">http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html</a></p> <p>To format for your users, look into strftime. Docs: <a href="http://apidock.com/ruby/Time/strftime" rel="nofollow">http://apidock.com/ruby/Time/strftime</a></p> <p>A site that helps you generate strftime code: <a href="http://strftime.net/" rel="nofollow">http://strftime.net/</a></p> <p>A guide to I18n / internationalization: guides.rubyonrails.org/i18n.html (thanks @house9)</p>
27,870,266
1
Regex to split up message_txt over 160 characters <p>I am trying to split message text for a messaging system up into at most 160 character long sequences that end in spaces, unless it is the very last sequence, then it can end in anything as long as it is equal to or less than 160 characters.</p> <p>this re expression '.{1,160}\s' almost works however it cuts of the last word of a message because generally the last character of a message is not a space.</p> <p>I also tried '.{1,160}\s|.{1,160}' but this does not work because the final sequence is just the remaining text after the last space. Does anyone have an idea on how to do this?</p> <p>EXAMPLE:</p> <pre><code>two_cities = ("It was the best of times, it was the worst of times, it was " + "the age of wisdom, it was the age of foolishness, it was the " + "epoch of belief, it was the epoch of incredulity, it was the " + "season of Light, it was the season of Darkness, it was the " + "spring of hope, it was the winter of despair, we had " + "everything before us, we had nothing before us, we were all " + "going direct to Heaven, we were all going direct the other " + "way-- in short, the period was so far like the present period," + " that some of its noisiest authorities insisted on its being " + "received, for good or for evil, in the superlative degree of " + "comparison only.") chunks = re.findall('.{1,160}\s|.{1,160}', two_cities) print(chunks) </code></pre> <p>will return </p> <p>['It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of ', 'incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we ', 'had nothing before us, we were all going direct to Heaven, we were all going direct the other way-- in short, the period was so far like the present period, ', 'that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison ', 'only.']</p> <p>where the final element of the list should be </p> <p>'that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.'</p> <p>not 'only.'</p>
10,438,715
0
Why do many addresses on the stack point to the EXACT location of functions in the .map file? <p>I am debugging a runtime crash, with a stack trace that seems corrupted (see a related question from yesterday: <a href="http://stackoverflow.com/questions/10420325/is-the-stack-corrupted-if-the-ebp-frame-pointer-is-null">Is the stack corrupted if the EBP frame pointer is NULL?</a>).</p> <p>Despite the corruption of the stack, I see many values on the stack that point to the <strong>exact</strong> locations of functions in the corresponding .map file. Furthermore, these functions are (for the most part, if not entirely) the expected functions that should appear on the stack in this case.</p> <p>As one example (there are many), here is the stack value, and corresponding .map entry value:</p> <pre><code>0588fe5c: 005caa30 (stack address / value at that address) 0001:001c9a30 __ehhandler$?ProcessTAFRequest@TQueryThread@@UAEXXZ 005caa30 f portable_source:UQueryThread.obj (.map file entry indicating that address 005caa30 is the starting location of the function noted) </code></pre> <p>Assuming (likely incorrectly) that the stack is <em>not</em> corrupted except near the top, and that the function addresses I see somehow do correspond to the stack frames and corresponding EIP (return address) pointers, then my question is this: Why do I consistently see the <em>exact</em> value of the location of the functions in the .map file corresponding to the stack? In the past, a number of times I have walked through an uncorrupted stack trace, and always, the EIP pointers in the stack frames point <strong>near</strong>, but not <strong>at</strong>, the location of the corresponding functions listed in the .map file. (This makes sense, since the return address will typically be in the middle of a function, not at the start).</p> <p>Can somebody please shed light?</p>
33,361,792
0
Getting client static IP address <p>I am deplyong a web application in the Internet and I am checking whether the user's login is valid by checking its client IP address (e.g. <em>192.168.2.XXX</em>). Actually, I have found a working code (below). This code was completely working before, but after some time, its output is not the same anymore. Now, this code only gives me 1 IP address which is the server's IP address. What is wrong with my code? How can I get the client's static IP address rather than the server's IP address? I have also tried other solutions such as <code>getRemoteAddr()</code> and <code>request.getHeader("PROXY-CLIENT-IP")</code> but it is not working.</p> <p>Java:</p> <pre><code>String ipAddress = request.getHeader("X-FORWARDED-FOR"); if(ipAddress == null) ipAddress = InetAddress.getLocalHost().getHostAddress(); </code></pre>
19,023,604
0
<p>IMHO, single producer accessed by multi threads with lock won't resolve your problem, because it simply shift the locking from the disruptor side to your own program.</p> <p>The solution to your problem varies from the type of event model you need. I.e. do you need the events to be consumed chronologically; merged; or any special requirement. Since you are dealing with disruptor and multi producers, that sounds to me very much like FX trading systems :-) Anyway, based on my experience, assuming you need chronological order per producer but don't care about mixing events between producers, I would recommend you to do a queue merging thread. The structure is</p> <ul> <li>Each producer produces data and put them into its own named queue</li> <li>A worker thread constantly examine the queues. For each queue it remove one or several items and put it to the single producer of your single producer disruptor.</li> </ul> <p>Note that in the above scenario,</p> <ul> <li>Each producer queue is a single producer single consumer queue.</li> <li>The disruptor is a single producer multi consumer disruptor.</li> <li>Depends on your need, to avoid a forever running thread, if the thread examine for, say, 100 runs and all queues are empty, it can set some variable and go wait() and the event producers can yield() it when seeing it's waiting.</li> </ul> <p>I think this resolve your problem. If not please post your need of event processing pattern and let's see.</p>
7,725,485
0
<p>this would probably do the trick</p> <pre><code> success: function (data) { response($.map(data, function (item) { return { label: item.First, value: item.First} })) }); </code></pre>
14,641,357
0
<p><code>attrgetter</code> can be used to pull out attributes of objects that you may want to key a sort by.</p> <pre><code>from operator import attrgetter results = [] results.extend(list(AudioItem.objects.filter(...))) results.extend(list(VideoItem.objects.filter(...))) results.extend(list(ImageItem.objects.filter(...)) results.sort(key=attrgetter("upload_date") </code></pre>
27,750,509
0
NumberFormatException when form is submited to spring controller <p>In my current spring project, when I try submit this form:</p> <pre><code> &lt;form role="form" class="form" action="/Destaque/cadastra" method="post" enctype="multipart/form-data"&gt; &lt;field-box&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;label&gt;Produto&lt;/label&gt;&lt;select class="form-control" name="listaDeProdutos[]" multiple="multiple" rows="7"&gt;&lt;option value="1"&gt;one&lt;/option&gt;&lt;option value="2"&gt;two&lt;/option&gt;&lt;option value="3"&gt;three&lt;/option&gt;&lt;option value="4"&gt;four&lt;/option&gt;&lt;option value="5"&gt;five&lt;/option&gt;&lt;option value="6"&gt;six&lt;/option&gt;&lt;option value="7"&gt;seven&lt;/option&gt;&lt;option value="8"&gt;eight&lt;/option&gt;&lt;option value="9"&gt;nine&lt;/option&gt;&lt;option value="10"&gt;ten&lt;/option&gt;&lt;option value="11"&gt;eleven&lt;/option&gt;&lt;option value="12"&gt;twelve&lt;/option&gt;&lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Titulo&lt;/label&gt;&lt;input type="text" class="form-control" name="titulo" /&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Resumo&lt;/label&gt;&lt;input type="text" class="form-control" name="resumo" /&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Valor&lt;/label&gt;&lt;input type="text" class="form-control valida" pattern="[0-9]{2}.[0-9]{2}" name="valor" /&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Descrição&lt;/label&gt;&lt;textarea class="summernote" name="descricao"&gt;&lt;/textarea&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Capa do destaque&lt;/label&gt;&lt;input type="file" class="form-control" name="icone" /&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;Validade&lt;/label&gt;&lt;input type="text" class="form-control valida" pattern="[0-9]{2}/[0-9]{2}/[0-9]{4}" name="validade" /&gt; &lt;/field-box&gt; &lt;field-box&gt; &lt;label&gt;destaque ativo&lt;/label&gt;&lt;input type="checkbox" name="ativo" /&gt; &lt;/field-box&gt; &lt;button type="submit" class="btn btn-default"&gt;Cadastrar&lt;/button&gt; &lt;div id="yes" class="alert alert-success" role="alert" style="display: none;"&gt; &lt;button type="button" class="close" data-hide="alert"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt; &lt;span class="text"&gt;Cadastro efetuado com sucesso&lt;/span&gt; &lt;/div&gt; &lt;div id="not" class="alert alert-danger" role="alert" style="display: none;"&gt; &lt;button type="button" class="close" data-hide="alert"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt; &lt;span class="text"&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p></p> <p>to this entity class:</p> <pre><code>@Entity @Form @FormPublic @Order(value = 5) public class Destaque extends Model { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Order(value = 1) private Integer id; @ManyToMany @JoinTable(name="listaDeProdutosEmDestaque", joinColumns={@JoinColumn(name="fk_destaque")}, inverseJoinColumns={@JoinColumn(name="fk_produto")}) @LazyCollection(LazyCollectionOption.FALSE) @Order(value = 2) @Select(label = "Produto", classe=Produto.class) private List&lt;Produto&gt; listaDeProdutos; @Order(value = 3) @Input(label = "Titulo") @Column(length = 100) private String titulo; @Order(value = 4) @Input(label = "Resumo") @Column(length = 100) private String resumo; @Order(value = 5) @Input(label = "Valor", pattern = "[0-9]{2}.[0-9]{2}") private Float valor; @Order(value = 6) @Textarea(label = "Descrição") @Column(length = 131072) private String descricao; @OneToOne @JoinColumn(name = "banner") @Order(value = 7) @Input(label = "Capa do destaque", type="file") private Picture icone; @Order(value = 8) @Input(label = "Validade", pattern = "[0-9]{2}/[0-9]{2}/[0-9]{4}") private Date validade; @Order(value = 9) @Checkbox(label = "destaque ativo") private Boolean ativo; } </code></pre> <p>I am getting this error:</p> <pre><code>java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:504) at java.lang.Integer.parseInt(Integer.java:527) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:993) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:926) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:749) at org.springframework.validation.DataBinder.doBind(DataBinder.java:645) at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:189) at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:106) at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:150) at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:110) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) </code></pre> <p>ANyone can see what's wrong here?</p> <p>ps.: the submission is handled by this method:</p> <p>controller:</p> <pre><code> @RequestMapping(value = "cadastra", method=RequestMethod.POST) @ResponseBody public void cadastra(@ModelAttribute("object") E object, BindingResult result, @RequestParam(value="icone", required=false) MultipartFile icone, @RequestParam(value="fotos", required=false) MultipartFile fotos[], @RequestParam(value="arquivo", required=false) MultipartFile arquivo[]) throws Exception { serv.cadastra(object); serv.upload(object, icone); serv.upload_multiplo(object, fotos); serv.upload_jar(object, arquivo); } </code></pre> <p>service</p> <pre><code> @PreAuthorize("hasPermission(#user, 'cadastra_'+#this.this.name)") @Transactional public void cadastra(E object) { dao.insert(object); } </code></pre> <p>dao class:</p> <pre><code>public void insert(E object) { EntityManager entityManager = getEntityManager(); entityManager.getTransaction().begin(); entityManager.persist(object); entityManager.getTransaction().commit(); entityManager.close(); } </code></pre>
40,267,446
0
<p>Try this:</p> <p>// SQL Server 2008 R2</p> <pre><code>SqlConnection connection = null; var runBatch = false; try { connection = new SqlConnection(connectionString); connection.Open(); var command = connection.CreateCommand(); // 1st batch command.CommandText = "BEGIN TRANSACTION"; command.ExecuteNonQuery(); // 2nd batch command.CommandText = "UPDATE MyTable SET MyColumn = 'foo' WHERE Name = @name"; command.Parameters.AddWithValue("name", "bar"); command.ExecuteNonQuery(); // 3rd batch command.CommandText = "COMMIT TRANSACTION"; command.Parameters.Clear(); command.ExecuteNonQuery(); } finally { if (connection != null) { connection.Close(); } } </code></pre>
17,180,066
0
100% height input-field and align text vertically <p>Maybe a duplicate but I did not found a question with a similar problem.</p> <p>Ok, I've to create a <code>100%</code> height input field that centers the text vertically and horizontally. The problem is that if I set the <code>line-height</code> to <code>window</code>-width the <strong>cursor</strong> gets the same size in Chrome.</p> <p>Any ideas how to center the text without <code>line-height</code>?</p> <pre><code>input { position: absolute; top: 0; left 0; margin: 0; padding: 0; width: 100%; height: 100%; text-align: center; border: 0; outline: 0 } </code></pre> <p>Just to set the <code>line-height</code>:</p> <pre><code>$('input').css({ lineHeight: $(window).height() + 'px' }); </code></pre> <p><a href="http://fiddle.jshell.net/G9uVw/" rel="nofollow">http://fiddle.jshell.net/G9uVw/</a></p> <p><strong>Update</strong></p> <p>It seems that the question needs to be changed. The problem is that <strong>oldIE</strong> doesn't center the text, but all other browsers do. So the new question is, how can we check if a browser supports this <code>auto-center</code>-<code>feature?! (Since we know that</code>ua`-sniffing is evil, I don't want to check for a particular browser...)</p> <p><strong>Update2</strong></p> <p>It seems that this is a bug in webkit: <a href="https://code.google.com/p/chromium/issues/detail?id=47284" rel="nofollow">https://code.google.com/p/chromium/issues/detail?id=47284</a></p>
14,232,162
0
<p>This Code Should Help You May Be </p> <pre><code> bool SortDateAsc = true; private void Date_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (SortDateAsc) { ObservableCollection&lt;InvoicesDTO&gt; a = new ObservableCollection&lt;InvoicesDTO&gt;(((ResolutionVM)this.DataContext).MainInvoiceList.OrderBy(oc =&gt; oc.FC_AGE)); ((ResolutionVM)this.DataContext).MainInvoiceList = a; InvoiceGrid.ItemsSource = ((ResolutionVM)this.DataContext).MainInvoiceList.ToList(); SortDateAsc = false; ((ResolutionVM)this.DataContext).RefreshSelctedInvoice(); } else { ObservableCollection&lt;InvoicesDTO&gt; a = new ObservableCollection&lt;InvoicesDTO&gt;(((ResolutionVM)this.DataContext).MainInvoiceList.OrderByDescending(oc =&gt; oc.FC_AGE)); ((ResolutionVM)this.DataContext).MainInvoiceList = a; InvoiceGrid.ItemsSource = ((ResolutionVM)this.DataContext).MainInvoiceList.ToList(); SortDateAsc = true; ((ResolutionVM)this.DataContext).RefreshSelctedInvoice(); } } </code></pre>
36,644,898
0
<p>I think that your initial idea is pretty good and can be made to work with not too much code. It will require some tinkering in order to decouple "is a <code>Runnable</code> for this value already running" from "execute this <code>Runnable</code>", but here's a rough illustration that doesn't take care about that:</p> <ul> <li>Implement <code>equals()</code> and <code>hashCode()</code> in <code>Process</code>, so that instances can safely be used in unordered sets and maps.</li> <li>Create a <code>ConcurrentMap&lt;Process, Boolean&gt;</code> <ul> <li>You won't be using <code>Collections.newSetFromMap(new ConcurrentHashMap&lt;Process, Boolean&gt;)</code> because you'd want to use the map's <code>putIfAbsent()</code> method.</li> </ul></li> <li>Try to add in it using <code>putIfAbsent()</code> each <code>Process</code> that you will be submitting and bail if the returned value is not <code>null</code>. <ul> <li>A non-<code>null</code> return value means that there's already an equivalent <code>Process</code> in the map (and therefore being processed).</li> <li>The trivial and not very clean solution will be to inject a reference to the map in each <code>Process</code> instance and have <code>putIfAbsent(this, true)</code> as the first thing you do in your <code>run()</code> method.</li> </ul></li> <li>Remove from it each <code>Process</code> that has finished processing. <ul> <li>The trivial and not very clean solution will be inject a reference to the map in each <code>Process</code> instance and have <code>remove(this)</code> as the last thing you do in your <code>run()</code> method.</li> <li>Other solutions can have <code>Process</code> implement <code>Callable</code> and return its unique value as a result, so that it can be removed from the map, or use <code>CompletableFuture</code> and its <code>thenAccept()</code> callback.</li> </ul></li> </ul> <p><a href="http://pastebin.com/kfYr9Sjm" rel="nofollow">Here's</a> a sample that illustrates the trivial and not very clean solution described above (code too long to paste directly here).</p>
29,084,122
0
<p>Good questions. </p> <p>The data limit is based on the size of data sent to the Power BI service. If you send us a workbook the size of the workbook is counted against your quota. If you send us data rows, the size of the uncompressed data rows is counted against your quota. Our service is in preview right now so there might be tweaks to the above as we move forward. You can keep up to date on the latest guidelines by referring to this page: <a href="https://www.powerbi.com/dashboards/pricing/" rel="nofollow">https://www.powerbi.com/dashboards/pricing/</a> </p> <p>The limits apply to any caller of the Power BI API. The details on the limits are listed at the bottom of this article: <a href="https://msdn.microsoft.com/en-US/library/dn950053.aspx" rel="nofollow">https://msdn.microsoft.com/en-US/library/dn950053.aspx</a>. The usage is additive in that if you posted 5K rows, then you'd be able to post an addition 5K rows within the hour. </p> <p>Appreciate your using Power BI.</p> <p>Lukasz P.</p> <p>Power BI Team, Microsoft</p> <p>Get started using Power BI APIs on the Power BI Developer Center - <a href="http://dev.powerbi.com" rel="nofollow">http://dev.powerbi.com</a>. Keep up to date with the Power BI Developer Blog - <a href="http://blogs.msdn.com/b/powerbidev/" rel="nofollow">http://blogs.msdn.com/b/powerbidev/</a>.</p>
33,824,476
0
<p>Thanks guys for your comments.</p> <p>I have reinstalled spark 1.5.2 and it works for me. Earlier the problem was with the spark-1.5.2.tar file. So I downloaded the fresh tar file of spark 1.5.2 and reinstall spark and now it works properly.</p>