pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
20,180,248
0
<p>You also have to initialise the ArrayList</p> <pre><code>ArrayList&lt;CheckBox&gt; ethChecks = new ArrayList&lt;CheckBox&gt;(); </code></pre>
39,248,199
0
Accessing the Auth object in AngularFire2 <p>I am trying to access the auth object in angular2 using firebase but I have become confused. I can see the user auth credentials in the console but the auth variable seems to be null.</p> <p><strong>app.component.ts</strong></p> <pre><code>import { Component } from '@angular/core'; import { AngularFire, FirebaseListObservable } from 'angularfire2'; import { AuthProviders, AuthMethods } from 'angularfire2'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app works!'; constructor(public af: AngularFire) { this.af.auth.subscribe(auth =&gt; console.log(auth)); //nothing in the console console.log(this.af.auth); // shows AngularFireAuth object with user credentials but says it is private } login() { console.log("logging in..."); this.af.auth.login({ provider: AuthProviders.Google, method: AuthMethods.Popup, }); } } </code></pre> <p><strong>app.component.html</strong></p> <pre><code>&lt;div *ngIf="auth"&gt;You are logged in&lt;/div&gt; &lt;div *ngIf="!auth"&gt;Please log in&lt;/div&gt; </code></pre> <p>The <code>auth</code> variable appears to be null even though <code>console.log(this.af.auth);</code> is showing the user credentials and therefore only <code>Please log in</code> is displayed in the html.</p>
29,207,816
0
<p>You start by adding a method to your controller</p> <pre><code>def update_fname # get the parameters fname = params[:fname] # get the employee ID id = params[:id] # find the employee @employee = Employee.find(id) # update the employee employee.update_attributes(fname: fname) redirect_to @employee end </code></pre> <p>Then, in your route, you add:</p> <pre><code>resources :employees do get 'update_fname' end </code></pre> <p>And you call the route, who should be <code>http://localhost:3000/employees/{:id}/update_fname?fname={your_fname}</code></p>
38,971,737
0
How to catch "Nrpe unable to read output" when occured? <p>I'm trying to catch "nrpe unable to read output" output from plugin and send an email when this one occurs and I'm a little bit stuck :) . Thing is there are different return codes when this error occurs on different plugin: </p> <p>Return code Service status</p> <p>0 OK</p> <p>1 WARNING</p> <p>2 CRITICAL</p> <p>3 UNKNOWN</p> <p>Is there a way either to unify return codes of all plugins I use(that there always will be 2[CRITICAL] when this problem occurs), or any other way to catch those alerts? I want to keep return codes for different situations as is(i.e. filesystem /home will be warning(return code 1) for 95% and critical(return code 2) for 98%</p>
8,709,184
0
trouble with ProcessBuilder <pre><code>// following code works fine n open notepad... class demo { public static void main(String args[]) { try{ ProcessBuilder pb=new ProcessBuilder("notepad"); pb.start(); }catch(Exception e) {System.out.print(e);} } } //however the above code throws an exception when any other system program is executed class demo { public static void main(String args[]) { try{ ProcessBuilder pb=new ProcessBuilder("calculator"); pb.start(); }catch(Exception e) {System.out.print(e);} } } </code></pre> <p>the above program throws following exception:</p> <pre><code>java.io.IOException: Cannot run program "Calculator": CreateProcess error=2, The system cannot find the file specified </code></pre>
27,996,818
0
img Inside a foreignObject Inside an svg Inside an img <p>Here is my test case.</p> <p><a href="http://tobeythorn.com/isi/dummy2.svg" rel="nofollow">http://tobeythorn.com/isi/dummy2.svg</a></p> <p><a href="http://tobeythorn.com/isi/isitest.html" rel="nofollow">http://tobeythorn.com/isi/isitest.html</a></p> <ul> <li><p>If I just open the svg by itself, the inner img is rendered fine.</p></li> <li><p>But when I make this svg the src of an img, the inner img is not rendered. I receive no errors.</p></li> <li><p>If I make the inner img a data-url, it gets rendered. If possible, I would like to avoid data-urls, as they complicate things, have size limitations, and cannot be cached.</p></li> <li><p>The same thing happens in FF, Chrome, Opera, and Safari.</p></li> </ul> <p>I can't find a solution, but possibly related: <a href="http://stackoverflow.com/questions/15971905/foreignobject-inside-second-svg-element-for-chrome">foreignObject inside second SVG element for Chrome</a></p> <p>Cross-origin issue?</p> <p>Limitation of the spec?</p> <p>Browser bug?</p>
13,417,624
0
Why PhpStorm inspection says `Exception` is undefined? <p><code>PhpStorm</code> doesn't recognize <code>Exception</code> from some reason. The code executes fine, but I cannot "go to" code (which should send me to <code>Core_c.php</code>):</p> <p><img src="https://i.stack.imgur.com/JkxXd.png" alt="enter image description here"></p>
22,434,183
0
Displaying image from db to picturebox winforms c# <p>Iam doing a winforms application to insert an image to a database(sql server 2008)and retrieve an image from database into a picture box.The code for inserting works perfectly.While the code for retrieving show's up an error parameter not Valid.I was trying various solutions found by goggling but none of them succeeded.</p> <p>Here is my code for retrieving</p> <pre><code> private void button2_Click(object sender, EventArgs e) { FileStream fs1 = new FileStream("D:\\4usdata.txt", FileMode.OpenOrCreate,FileAccess.Read); StreamReader reader = new StreamReader(fs1); string id = reader.ReadToEnd(); reader.Close(); int ide = int.Parse(id); con.Open(); SqlCommand cmd = new SqlCommand("select img from tempdb where id='" + id + "'", con); //cmd.CommandType = CommandType.Text; //object ima = cmd.ExecuteScalar(); //Stream str = new MemoryStream((byte[])ima); //pictureBox1.Image = Bitmap.FromStream(str); SqlDataAdapter dp = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); dp.Fill(ds); int c = ds.Tables[0].Rows.Count; if (c ==1) { Byte[] MyData = new byte[0]; MyData = (Byte[])ds.Tables[0].Rows[0]["img"]; MemoryStream stream = new MemoryStream(MyData); stream.Position = 0; pictureBox1.Image = Image.FromStream(stream); } } </code></pre>
35,412,449
0
Why did Go add panic and recover in addition to error handling? <p>Why did Go end up adopting exception handling with panic/recover, when the language is so idiomatic and a strong advocate of error codes? What scenarios did the designers of Go envision not handled by error codes and necessitate panic/recover?</p> <p>I understand convention says limit panic/recover, but does the runtime also limit them in ways that they can't be used as general throw/catch in C++?</p>
36,988,817
0
<p>In what I say below, KAAZING_GATEWAY_HOME represents the directory in which you installed the Kaazing JMS Gateway.</p> <p>There are several moving parts - the client, the Kaazing JMS Gateway, and the EMS back-end. The problem could be the Kaazing JMS Gateway connecting to EMS on the back end, or there could be an issue with the client trying to connect to the Kaazing JMS Gateway. There is not much detail yet. In order for us to troubleshoot, one way to provide more detail is to make the logging on the Kaazing JMS Gateway more verbose.</p> <p>The log is by default written to KAAZING_GATEWAY_HOME/log/. There are several there but the main log is error.log. Its default LOG4J configuration is in KAAZING_GATEWAY_HOME/conf/log4j-config.xml. You can get more diagnostics for the connection issues on both ends by replacing the contents of that file with the following (you can make a backup copy to restore the default log configuration later):</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt; &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt; &lt;appender name="ErrorFile" class="org.apache.log4j.RollingFileAppender"&gt; &lt;param name="File" value="${GATEWAY_LOG_DIRECTORY}/error.log"/&gt; &lt;param name="Append" value="false"/&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="%d [%t] %-5p %m%n"/&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="%d [%t] %-5p %m%n"/&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;logger name="transport"&gt; &lt;level value="trace"/&gt; &lt;/logger&gt; &lt;logger name="com.kaazing.gateway.jms"&gt; &lt;level value="trace"/&gt; &lt;/logger&gt; &lt;logger name= "service.stomp.jms"&gt; &lt;level value="trace"/&gt; &lt;/logger&gt; &lt;logger name= "service.jms"&gt; &lt;level value="trace"/&gt; &lt;/logger&gt; &lt;root&gt; &lt;priority value="info"/&gt; &lt;appender-ref ref="ErrorFile"/&gt; &lt;appender-ref ref="STDOUT"/&gt; &lt;/root&gt; &lt;/log4j:configuration&gt; </code></pre> <p>Once you have copied that in place, try connecting again. If you see no logging in the gateway for the connection attempts from your client, it means there is an issue in the client code or configuration, between the client and the gateway, or on the client machine itself. Otherwise, please share the results of updating this. The results should be time-stamped so you can tell which log entries correspond to your attempts to connect.</p> <p>You can share your logs here, or directly to me at the address below.</p> <p>Please keep us posted. Best regards, Dan Smith, Kaazing Global Support [email protected]</p>
17,866,798
0
How to keep decimal rounded to two places? <p>So All of my decimals are rounded to two places. However when I click on "keyboard or mouse" image the decimal place is roughly ten digits long( for example:36.900000000000006). How do I stop this. I've tried using ".toFixed(), and .toPrecision().</p> <p>here is a link to the page... much easier to do this than create a fiddle.</p> <p><a href="http://www.ootpik.info/lauren/ootpik5/gethardware.html" rel="nofollow">http://www.ootpik.info/lauren/ootpik5/gethardware.html</a></p> <p>I've added a fiddle: <a href="http://jsfiddle.net/lolsen7/8uwGH/3/" rel="nofollow">http://jsfiddle.net/lolsen7/8uwGH/3/</a></p> <p>script</p> <pre><code>$(document).ready(function() { $(".part,.extra").mouseover(function() { if(this.className !== 'part selected') { $(this).attr('src', 'images/placeholder/get_hardware/' + this.id + '.png'); } $(this).mouseout(function(){ if(this.className !== 'part selected') { $(this).attr('src', 'images/placeholder/get_hardware/' + this.id + '_grey.png'); } }); }); var list = document.getElementById("list"); var summaryTotal = document.getElementById("summaryTotal"); var touchtotal = 13.89; var minitotal = 19.47; var constant = touchtotal + minitotal; $('#finaltotal').text(constant); //station one var keyboard2 = 59; var mouse2 = 59; var printer = 345; var scale2 = 530; var display = 175; var single = 132; var multi = 260; var scannerTotal = 0; var cash = 100; var storage = 125; var registerTotal = 0; //extras var ipad = 349; var ipadTotal = 0; var mobilePrinter = 570; var mobileTotal = 0; var printer2 = 345; var printer2Total = 0; $(".part").click(function(){ var name = this.id; var liname = this.alt; var total = parseFloat((eval(name) * 1.2) /40); if(this.className != 'part selected') { $(this).attr('src','images/placeholder/get_hardware/' + name + '.png'); if(name !== 'multiBar' &amp;&amp; name !== 'singleBar' &amp;&amp; name !== 'storageDrawer' &amp;&amp; name !== 'cashDrawer' ) { //generate list items var li = document.createElement("li"); li.setAttribute("id",name + "_li"); li.appendChild(document.createTextNode(liname)); list.appendChild(li); //touchscreen and mac mini pricing constant = constant + total; $('#finaltotal').text(constant); } //Scanners if clicked on else if(name == "multiBar" || name == "singleBar"){ $(".tooltip").show(); $("input").change(function(e){ if($(this).attr("checked", "true")) { if(this.value == "one") { // hide and show images based on radio selection $('#singleBar').attr('src','images/placeholder/get_hardware/singleBar.png'); $('#singleBar').show(); $('#singleBar').toggleClass('selected'); $('#multiBar').hide(); //list item if($('#single_li').length &gt; 0) { $('#single_li').remove(); } if($('#multi_li').length &gt; 0) { $('#multi_li').remove(); } li = document.createElement("li"); li.setAttribute("id","single_li"); li.appendChild(document.createTextNode("Single-line Barcode Scanner")); list.appendChild(li); //pricing if(scannerTotal !== 0) { constant = constant - scannerTotal; } scannerTotal = (single * 1.2) /40; constant = constant + scannerTotal; $('#finaltotal').text(constant); }else if(this.value == "two") { //hide and show images based on radio selection $('#multiBar').attr('src','images/placeholder/get_hardware/multiBar.png'); $('#multiBar').show(); $('#singleBar').hide(); //list item if($('#multi_li').length &gt; 0){ $('#multi_li').remove(); } if($('#single_li').length &gt; 0){ $('#single_li').remove(); } li = document.createElement("li"); li.setAttribute("id","multi_li"); li.appendChild(document.createTextNode("Multi-line Barcode Scanner")); list.appendChild(li); if(scannerTotal !== 0){ constant = constant - scannerTotal; } scannerTotal = (multi * 1.2) /40; constant = constant + scannerTotal; $('#finaltotal').text(constant); } } }); } //if register is clicke on else if(name =="storageDrawer" || name == "cashDrawer"){ $('.tooltip2').show(); $('input').change(function(){ if($(this).attr("checked","true")) { if(this.value == "three") { //hide and show images based on radio button selection $('#cashDrawer').attr('src','images/placeholder/get_hardware/cashDrawer.png'); $('#cashDrawer').show(); $("#storageDrawer").hide(); //list items if($('#cash_li').length &gt; 0){ $('#cash_li').remove(); } if($('#storage_li').length &gt; 0){ $('#storage_li').remove(); } li = document.createElement("li"); li.setAttribute('id','cash_li'); li.appendChild(document.createTextNode("Cash Drawer")); list.appendChild(li); //pricing if(registerTotal !== 0){ constant = constant - registerTotal; } registerTotal = (cash * 1.2)/40; constant = constant + registerTotal; $('#finaltotal').text(constant); }else if(this.value == "four") { $('#storageDrawer').attr('src','images/placeholder/get_hardware/storageDrawer.png'); $('#storageDrawer').show(); $('#cashDrawer').hide(); //list items if($('#storage_li').length &gt; 0){ $('#storage_li').remove(); } if($('#cash_li').length &gt; 0){ $('#cash_li').remove(); } li = document.createElement('li'); li.setAttribute('id','storage_li'); li.appendChild(document.createTextNode("Premium Cash Drawer")); list.appendChild(li); //pricing if(registerTotal !== 0){ constant = constant - registerTotal; } registerTotal = (storage * 1.2)/40; constant = constant + registerTotal; $('#finaltotal').text(constant); } } }); } $(this).toggleClass('selected'); } else if (this.className == 'part selected') { $(this).attr('src','images/placeholder/get_hardware/' + name + '_grey.png'); if(name !== 'multiBar' &amp;&amp; name !== 'singleBar' &amp;&amp; name !== 'storageDrawer' &amp;&amp; name !== 'cashDrawer') { constant = constant - total; $('#finaltotal').text(constant); $("#" + name + "_li").remove(); } //Scanners else if(name == 'multiBar' || name == 'singleBar') { //Hides Tooltip when de-selecting item $(".tooltip").hide(); // removes pricing console.log(scannerTotal); constant = constant - scannerTotal; scannerTotal = 0; $('#finaltotal').text(constant); //Removes any List items if($('#multi_li').length &gt; 0) { $('#multi_li').remove(); } if($('#single_li').length &gt; 0) { $('#single_li').remove(); } //Sets Inputs to deselected $("input[name='group1']").attr("checked",false); } //cash drawers || registers else if(name == 'storageDrawer' || name == 'cashDrawer') { $('.tooltip2').hide(); //removes pricing console.log(registerTotal); constant = constant - registerTotal; registerTotal = 0; $('#finaltotal').text(constant); //remove any list items if($('#storage_li').length &gt; 0) { $('#storage_li').remove(); } if($('#cash_li').length &gt; 0) { $('#cash_li').remove(); } //Sets Inputs to deselected $("input[name='group2']").attr("checked",false); } $(this).toggleClass('selected'); } }); $(".numbers-row").append('&lt;div class="inc buttons"&gt;+&lt;/div&gt;&lt;div class="dec buttons"&gt;-&lt;/div&gt;'); $(".buttons").on("click", function() { var $buttons = $(this); var oldValue = $buttons.parent().find("input").val(); if ($buttons.text() == "+") { var newVal = parseFloat(oldValue) + 1; if(newVal &gt; 2 ){ return; } } else { // Don't allow decrementing below zero if (oldValue &gt; 0) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 0; } } $buttons.parent().find("input").val(newVal); if($buttons.parent().attr('class') == 'numbers-row ipad'){ if($('#ipad_mini_extra').length &gt; 0){ $('#list').children('#ipad_mini_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - ipadTotal; console.log(ipadTotal); $('#finaltotal').text(constant); } } if(newVal !== 0){ $('#ipad').attr('src',"images/placeholder/get_hardware/ipad.png"); $('#list').append('&lt;li id="ipad_mini_extra"&gt;' + newVal + ' iPad mini(s) &lt;/li&gt;'); //add pricing if(ipadTotal !== 0){ constant = constant - ipadTotal; } if(newVal == 1){ ipadTotal = (ipad * 1.2) /40; console.log(ipadTotal); constant = constant + ipadTotal; $('#finaltotal').text(constant); } if(newVal == 2){ ipadTotal = ((ipad * 2) * 1.2)/40; console.log(ipadTotal) constant =constant + ipadTotal; $('#finaltotal').text(constant); } } else{ $('#ipad').attr('src',"images/placeholder/get_hardware/ipad_grey.png"); } } if($buttons.parent().attr('class') == 'numbers-row mobile') { if($('#mobile_extra').length &gt; 0) { $('#list').children('#mobile_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - mobileTotal; console.log(mobileTotal); $('#finaltotal').text(constant); } } if(newVal !== 0) { $('#mobilePrinter').attr('src',"images/placeholder/get_hardware/mobilePrinter.png"); $('#list').append('&lt;li id="mobile_extra"&gt;' + newVal + ' Mobile Printer(s) &lt;/li&gt;'); //add pricing if(mobileTotal !== 0){ constant = constant - mobileTotal; } if(newVal == 1){ mobileTotal = (mobilePrinter * 1.2) /40; console.log(mobileTotal); constant = constant + mobileTotal; $('#finaltotal').text(constant); } if(newVal == 2){ mobileTotal = ((mobilePrinter * 2) * 1.2)/40; console.log(mobileTotal) constant =constant + mobileTotal; $('#finaltotal').text(constant); } } else { $('#mobilePrinter').attr('src',"images/placeholder/get_hardware/mobilePrinter_grey.png"); } } if($buttons.parent().attr('class') == 'numbers-row printer2') { if($('#printer2_extra').length &gt; 0) { $('#list').children('#printer2_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - printer2Total; console.log(printer2Total); $('#finaltotal').text(constant); } } if(newVal !== 0) { $('#printer2').attr('src',"images/placeholder/get_hardware/printer2.png"); $('#list').append('&lt;li id="printer2_extra"&gt; ' + newVal + ' Kitchen/Bar/Expo Printer(s) &lt;/li&gt;'); //add pricing if(printer2Total !== 0){ constant = constant - printer2Total; } if(newVal == 1){ printer2Total = (printer2 * 1.2) /40; console.log(printer2Total); constant = constant + printer2Total; $('#finaltotal').text(constant); } if(newVal == 2){ printer2Total = ((printer2 * 2) * 1.2)/40; console.log(printer2Total) constant =constant + printer2Total; $('#finaltotal').text(constant); } } else { $('#printer2').attr('src',"images/placeholder/get_hardware/printer2_grey.png"); } } }); }); </code></pre>
7,475,390
0
<p>You tagged your question <code>mysql</code> but the special outer join syntax you're using is a proprietary invention of Oracle. </p> <p>MySQL does not support the <code>(+)</code> join modifier syntax in any position.</p> <p>Why not use ANSI SQL-92 syntax for <code>LEFT OUTER JOIN</code> and <code>RIGHT OUTER JOIN</code>? Then your queries would be clear, and would work in both Oracle and MySQL.</p> <pre><code>SELECT emp_no, emp_name, emp.dept_no, dept_name, loc FROM emp LEFT OUTER JOIN dept ON emp.dept = dept.dept_no </code></pre>
13,982,326
0
mongodb sparse indexes and shard key <p>I looked through the docs, and couldn't find a clear answer</p> <p>Say I have a sparse index on [a,b,c] </p> <ol> <li><p>Will documents with "a" "b" fields but not "c" be inserted to the index? </p></li> <li><p>Is having the shard key indexed obligatory in the latest mongodb version ? </p></li> <li><p>If so, is it possible to shard on [a] using the above compound sparse index? (say a,b will always exist)</p></li> </ol>
1,728,706
0
<p>The <code>start</code> event is a tricksy faux one. What you need to do is attach your code to cancel event bubbling directly to the <code>mousedown</code> event of the <code>ul</code> itself, and make sure your event handler is executed first.</p> <p>You'll see in the jQuery docs for <code>event.stopPropagation</code> this little line:</p> <blockquote> <p>Note that this will not prevent other handlers on the same element from running.</p> </blockquote> <p>So, whilst <code>event.stopPropagation</code> will stop the event bubbling any further up the DOM, it won't stop the other event handlers attach to the <code>ul</code> being called. For that you need <code>event.stopImmediatePropagation</code> to stop the <code>selectable</code> event handler getting called.</p> <p>Based on the <a href="http://jqueryui.com/demos/selectable/" rel="nofollow noreferrer">selectable demo page</a>, this code snippet successfully cancels the bubble:</p> <pre><code>$(function() { $("#selectable").mousedown(function (evt) { evt.stopImmediatePropagation(); return false; }); $("#selectable").selectable(); }); </code></pre> <p>Note that you must add your event handler to the <code>ul</code> object <em>before</em> you execute the <code>.selectable()</code> setup function in order to sneak in and pop the event bubble first.</p>
40,599,246
0
ArrayList not updating after using .clear() <p>I'm new to Android development, so please bear with me.</p> <p>I have a custom ArrayAdapter which I want to update by swiping down to refresh.</p> <p>I understand that in order to do this I need to:</p> <ul> <li>clear the ArrayList that holds my data (with .clear())</li> <li>Update the ArrayList with the new data (using the getAbsentTeachers() method)</li> <li>use notifyDataSetChanged() on the ArrayAdapter</li> </ul> <p>After I clear the ArrayList, call getAbsentTeachers() and notifyDataSetChanged() the ArrayList appears to remain empty even though getAbsentTeachers() is beeing called. I know this because nothing is displayed in my ListView. </p> <p>getAbsentTeachers() populates the ArrayList fine when my app is first launched however it doesn't seem to work when I call it again to update the ArrayList.</p> <p>Any ideas as to why the array is not beeing updated?</p> <p><strong>MainActivity.java:</strong> package uk.co.bobsmith.drawview.drawviewtest;</p> <pre><code>public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private ArrayList&lt;Absent&gt; absences = new ArrayList&lt;&gt;(); private SwipeRefreshLayout swipeContainer; @Override protected void onCreate(Bundle savedInstanceState) { //---------------------INITIALISING PARSE------------------------------- Parse.enableLocalDatastore(this); // Add your initialization code here Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) //Information obscured for privacy - tested and working though. .applicationId("") .clientKey(null) .server("") .build() ); ParseUser.enableAutomaticUser(); ParseACL defaultACL = new ParseACL(); // Optionally enable public read access. // defaultACL.setPublicReadAccess(true); ParseACL.setDefaultACL(defaultACL, true); ParseInstallation.getCurrentInstallation().saveInBackground(); ParsePush.subscribeInBackground("Absent"); //-----------------------CREATE ADAPTER OBJECT-------------------------------- getAbsentTeachers(); final ListView lv = (ListView)findViewById(R.id.listView); final ArrayAdapter&lt;Absent&gt; adapter = new absenceArrayAdapter(this, 0, absences); lv.setAdapter(adapter); swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); // Setup refresh listener which triggers new data loading swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // Code to refresh the list. absences.clear(); getAbsentTeachers(); adapter.notifyDataSetChanged(); swipeContainer.setRefreshing(false); // Call swipeContainer.setRefreshing(false) when finished. } }); } // Populates absences ArrayList with absence data public void getAbsentTeachers() { ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("Absences"); query.findInBackground(new FindCallback&lt;ParseObject&gt;() { @Override public void done(List&lt;ParseObject&gt; objects, ParseException e) { if(e == null){ for(ParseObject object : objects){ String name = String.valueOf(object.get("name")); Log.i("Name", name); String desc = String.valueOf(object.get("description")); Log.i("Description", desc); absences.add(new Absent(name, desc, "employees")); } } else { Log.i("Get data from parse", "There was an error getting data!"); e.printStackTrace(); } } }); } //custom ArrayAdapter class absenceArrayAdapter extends ArrayAdapter&lt;Absent&gt; { private Context context; private List&lt;Absent&gt; absencesList; public absenceArrayAdapter(Context context, int resource, ArrayList&lt;Absent&gt; objects) { super(context, resource, objects); this.context = context; this.absencesList = objects; } public View getView(int position, View convertView, ViewGroup parent) { //get the property we are displaying Absent teacher = absencesList.get(position); //get the inflater and inflate the XML layout for each item LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.custom_listview, null); TextView name = (TextView) view.findViewById(R.id.name); TextView description = (TextView) view.findViewById(R.id.description); ImageView teacherImage = (ImageView) view.findViewById(R.id.imageView); String teacherName = teacher.getTeacherName(); name.setText(teacherName); int descriptionLength = teacher.getDescription().length(); if(descriptionLength &gt;= 75){ String descriptionTrim = teacher.getDescription().substring(0, 75) + "..."; description.setText(descriptionTrim); }else{ description.setText(teacher.getDescription()); } return view; } } } </code></pre>
38,094,163
0
<p>What i did was </p> <p>1st. i go to manifest.xml and add android:configChanges to my playerActivity</p> <pre><code> &lt;activity android:name=".Activities.YoutubePlayerActivity" android:configChanges="orientation|keyboardHidden|screenSize"&gt;&lt;/activity&gt; </code></pre> <p>2nd. i override the configurationChanged </p> <pre><code>@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { if (player.getFullscreenControlFlags() == player.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE) { player.setFullscreen(true); player.play(); } } } </code></pre> <p>and you're done. Basically on the configurationChange i check if the the screen goes to landscape mode and the youtubePlayer will set to fullscreen first, then play. otherwise you'll get a short pause before it resume the video</p>
15,397,401
0
Pathing using ./, ../, .. - what do they exactly mean for my view files? <p>I always worry about pathing issues when I move my website into subfolders because I don't know how to handle it with PHP.</p> <p>I want to learn this with an example because I can easily learn it by looking at examples.</p> <p>Let's say I have a website running at this directory: <code>httpdocs/development/subfolder/myWebsite/index.php</code></p> <p>By default, PHP would run <code>httpdocs/index.php</code>, so it is the root path but my website runs in a subfolder.</p> <p>In my website's index.php, (so we're in a subfolder) how can I ensure I point correct folders?</p> <pre><code>&lt;img src="images/1.jpg"&gt; // Does no dot means root path? &lt;img src="./images/1.jpg"&gt; //Does ./ means which_directory_our_php_page_currently_in/images? &lt;a href="./"&gt; // Points /subfolder/myWebsite/ or httpdocs/ ? &lt;a href=".."&gt; //Same as above, but no front slash. &lt;a href=""&gt; //Same as above </code></pre> <p>I don't want to make a definition or a const to track it with PHP and change it whenever I move my files. Like:</p> <pre><code>define('SITE_PATH', './development/subfolder/myWebsite/'); </code></pre> <p>Especially when it comes into <code>DIRECTORY_SEPARATOR</code>, things only get more confusing.</p> <p>I would like to know how to handle it with PHP professionally; what is the difference between <code></code> and <code>./</code>; lastly what does <code>..</code> mean without forward slash.</p> <p>Thank you.</p>
18,509,625
0
<p>You can do this without <code>LINQ</code>, but I want to use <code>LINQ</code> here:</p> <pre><code>public IEnumerable&lt;Control&gt; GetControls(Control c){ return new []{c}.Concat(c.Controls.OfType&lt;Control&gt;() .SelectMany(x =&gt; GetControls(x))); } foreach(Control c in GetControls(splitContainer.Panel2).Where(x=&gt;x is Label || x is Button)) MessageBox.Show("Name: " + c.Name + " Back Color: " + c.BackColor); </code></pre>
19,934,143
0
<p>regarding pointer type: the idea here is that in order to reduce both loop and copy overhead, you want to copy using the largest data "chunks" (say 32bit) possible. So you try to copy as much as possible using 32bit words. The remainder then needs to be copied in smaller 8bit "chunks". For example, if you want to copy 13 bytes, you would do 3 iterations copying 32bit word + 1 iteration copying a single byte. This is preferable to doing 13 iterations of single byte copy. You could convert to uint32_t*, but then you'll have to convert back to uint8_t* to do the remainder.</p> <p>Regarding the second issue - this implementation will not work properly in case the destination address overlapps the source buffer. Assuming you want to support this kind of memcpy as well - it is a bug. This is a popular interview question pitfall ;).</p>
14,644,532
0
<p>Starting with Steve B's comment and later finding this <a href="http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/67c417e8-cf39-4ae2-928c-2b4f709b146d" rel="nofollow">article</a>, I solved my problem doing the following:</p> <ol> <li>On the user machine, the database is copied into the <code>%AppData%</code> directory.</li> <li>The <code>|DataDirectory|</code> is dynamically changed between Debug and Release mode.</li> </ol> <p>This allows not to change the connection string.</p> <p>In the meantime, I opted for a MS Access *.accdb database, but here is my code anyway.</p> <pre><code>Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load #If (Not Debug) Then pathMyAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) &amp; "\MyApp" '"DataDirectory" is used in the Connection String AppDomain.CurrentDomain.SetData("DataDirectory", pathMyAppData) 'The application closes if no database is found If Not File.Exists(pathMyAppData &amp; "\MyDB.accdb) Then MsgBox("Database not found. Program closes.", MsgBoxStyle.Critical, "Error") Me.Close() End If #End If </code></pre>
38,946,221
0
<p>What happens if you change $URLPath from</p> <pre><code>$URLPath = "http://localhost/~matthew/"; </code></pre> <p>to </p> <pre><code>$URLPath = $_SERVER['DOCUMENT_ROOT'] . "/~matthew/"; </code></pre>
32,048,928
0
<p>Use the while statement:</p> <pre><code>while($row = $result-&gt;fetch_assoc()) { echo "First name:" . $row['fname']; echo " last name:" . $row['lname']; echo " Email:" . $row['email']; echo " Website:" . $row['website']; echo " comment:" . $row['comment']; } </code></pre>
40,954,313
0
<p>This will not work as:</p> <pre><code>typeof null === 'object'; </code></pre> <p>So it will always return an object and hence your code will not work.</p> <p>Rather you can try:</p> <pre><code>if (myNull == null){ // your code here. } </code></pre> <p>Also can try as suggested by Scott, but the if else would be the other way round:</p> <pre><code>if (myNull){} </code></pre>
22,097,081
0
<pre><code>convert string to date format, and this is easy for validating public class DateUtil { // List of all date formats that we want to parse. // Add your own format here. //u can use anyone format private static List&lt;SimpleDateFormat&gt;; dateFormats = new ArrayList&lt;SimpleDateFormat&gt;() {{ add(new SimpleDateFormat("M/dd/yyyy")); add(new SimpleDateFormat("dd.M.yyyy")); add(new SimpleDateFormat("dd.M.yyyy hh:mm:ss a")); add(new SimpleDateFormat("dd.MMM.yyyy")); add(new SimpleDateFormat("dd-MMM-yyyy")); } }; /** * Convert String with various formats into java.util.Date * * @param input * Date as a string * @return java.util.Date object if input string is parsed * successfully else returns null */ public static Date convertToDate(String input) { Date date = null; if(null == input) { return null; } for (SimpleDateFormat format : dateFormats) { try { format.setLenient(false); date = format.parse(input); } catch (ParseException e) { //Shhh.. try other formats } if (date != null) { break; } } return date; } } </code></pre>
35,503,164
0
Fiori Launchpad : could not run custom App -Found negative cache <p>i deployed an application on SAPUI5 Repository, when i added it to Fiori launchpad the app could not start and it's giving me the following error while debugging :</p> <pre><code>Uncaught Error: found in negative cache: 'com/emi/Component.js' from sap/bc/ui5_ui5/sap/zstatic/Component.js: 404 - NOT FOUND </code></pre> <p>com.emi is my sapui5 Component specified in LPD_CUST </p> <p>zstatic is the name of my app</p> <p>Does anyone have any information about the cause of this ? thank you</p>
40,507,272
0
<p>Maven's first request is indeed anonymous, this is a common practice done for security reasons - not disclosing your credentials to the server if not needed to.<p> At this point Artifactory identifies that this is an anonymous request and that there are insufficient permissions and therefor returns a 401 status.<p> When receiving the 401, Maven should respond to the challenge and resend the request with the proper credentials. This is the step that I assume is not working properly.<br> Running Maven with a debug information might reveal more details.</p>
14,517,686
0
Integrating Elasticsearch with Activerecord <p>In Java when using Hibernate Search for instance you bind JPA insertion, removal and update events to the search engine so that it automatically insert, updates and removes elements from the search engine index at the same time inserting, updating or removing it from the database. Is the same possible in Ruby and when using active record? Or do you manually have to register observers?</p>
38,837,668
1
QT QFileSystemWatcher <p>It seems simple but it doesn't work. I have usbautomount installed.</p> <pre><code>#Watch the media directory and connect to enable save csv pb self.usb_watcher = QFileSystemWatcher() self.usb_watcher.addPaths(["/media/usb0"]) self.usb_watcher.directoryChanged.connect(self.enable_save_csv_pb) self.usb_watcher.fileChanged.connect(self.enable_save_csv_pb) </code></pre> <p>I think it has to do with addpath. If I don't put in the square brackets I get this error message:</p> <pre><code>QFileSystemWatcher: failed to add paths: m, e, d, i, a, /, u, s, b, 0 </code></pre> <p>But I've seen examples without the square brackets.</p>
8,241,520
0
android play wave stream through tcp socket <p>I don't know how to play live wave audio stream through socket. Now I have got the socket audio stream. the stream format : </p> <pre><code>wav format header +pcm data wav format header +pcm data wav format header +pcm data </code></pre> <p>So how do i parse the live audio stream to play in the AudioTrack class in android. Thanks. Here is my code :</p> <pre><code>private void PlayAudio(int mode) { if(AudioTrack.MODE_STATIC != mode &amp;&amp; AudioTrack.MODE_STREAM != mode) throw new InvalidParameterException(); long bytesWritten = 0; int bytesRead = 0; int bufferSize = 0; byte[] buffer; AudioTrack track; Socket socket=null; DataInputStream dIn=null; bufferSize = 55584; // i donnt know how much the buffer size should be. 55584 is the size that i got first from the socket stream. maybe the buffer size is setted wrong. //sample rate 16khz,channel: mono sample bits:16 bits channel:1 bufferSize = AudioTrack.getMinBufferSize(16000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); buffer = new byte[bufferSize]; track = new AudioTrack(AudioManager.STREAM_MUSIC, 16000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize, mode); // in stream mode, // 1. start track playback // 2. write data to track if(AudioTrack.MODE_STREAM == mode) track.play(); try { socket = new Socket("192.168.11.123", 8081); dIn = new DataInputStream(socket.getInputStream()); // dIn.skipBytes(44); } catch (Exception e) { e.printStackTrace(); } try { do { long t0 = SystemClock.elapsedRealtime(); try { bytesRead = dIn.read(buffer, 0, buffer.length); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); } bytesWritten += track.write(buffer, 0, bytesRead); Log.e("debug", "WritesBytes "+bytesRead); } while (dIn.read() != -1); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre> <p>I got mute when i running an activity, but i can hear some music intermittently in debug mode but it is noisy. Could you please help me ? the server send the stream 100ms interval: audio format : //sample rate 16khz,channel: mono sample bits:16 bits channel:1</p>
3,913,858
0
<p>A vector is a line, that is a sequence of points but that it can be represented by two points, the starting and the ending point.</p> <p>If you take the origin as the starting point, then you can describe your vector giving only the ending point. </p>
12,809,424
0
<p>The following article explains how you can make the Web Service Reference dynamic by changing the reference properties, adding a key to the web.config file and referencing this key on the application code: </p> <p><a href="http://www.codeproject.com/Articles/12317/How-to-make-your-Web-Reference-proxy-URL-dynamic" rel="nofollow">Article Link</a></p> <p>Basically you will have 2 versions of web.config file, production and staging with different URLs defined. While the code will point to a unique location.</p> <p><strong>UPDATE:</strong></p> <p>Now, before the following line, you have to alter the service.URL according to what stands in the web.config.</p> <pre><code>Dim response As Swan.MagellanLeadSheetResponse = service.Foo(stuffToSendToService) </code></pre>
18,598,668
0
Specifying a subdomain in the route definition in Express <p>I'm new to ExpressJS and NodeJS in general, so I need directions on how to achieve this effect: </p> <pre><code>app.get('/', 'sub1.domain.com', function(req, res) { res.send("this is sub1 response!"); }); app.get('/', 'sub2.domain.com', function(req, res) { res.send("this is sub2 response!"); } </code></pre> <p>So that when I request <code>sub1.domain.com</code> the first handler reacts and on <code>sub2.domain.com</code> I get response from second handler. I've read some questions on SO about using vhost for this purpose, but I'd be more happy if what I described above worked rather than creating multiple server instances like in vhost. </p>
5,587,511
0
Dynamic Scalar Sub Queries <p>How to generate Scalar Sub Queries dynamically at run time using Java. Please suggest any api if available?</p> <p>Scalar sub query example:</p> <pre><code>SELECT d.deptno, d.dname, (SELECT count(*) FROM emp e WHERE e.deptno = d.deptno) AS "Num Dept" FROM dept d; </code></pre> <p>For example take hotel reservation application. user can search on different criteria. I want to construct scalar subquery based on this criteria.</p> <p>Can we do this in Hibernate Criteria API or JPA 2.0 Criteria API. But I want to use native SQL in my DAO....</p>
32,188,957
0
<p>As documented, the item's transformations are mathematically applied in a certain order - this is the order you'd be multiplying the transform matrices in and is, conceptually, the <em>reverse</em> of the order you'd normally think of.</p> <ol> <li>The <code>transform</code> is applied. The origin point must be included in the transform itself, by applying translations during the transform.</li> <li>The <code>transformations</code> are applied - each of them can specify its own center.</li> <li><code>rotation</code> then <code>scale</code> are applied, both relative to <code>transformOriginPoint</code>.</li> </ol> <p>When you set <code>transform</code> to scaling, and set <code>rotation</code>, the rotation is performed before scaling. The scaling applies to the rotated result - it simply stretches the rotated version horizontally in your case.</p> <p>You need to somehow enforce the reverse order of operations. The only two ways to do that are:</p> <ol> <li><p>Stack the transforms in correct order and pass them to <code>transform</code>, or.</p></li> <li><p>Pass a list of correct transformations to <code>transformations</code>.</p></li> </ol> <p>I'll demonstrate how to do it either way, in an interactive fashion where you can adjust the transform parameters using sliders.</p> <p>To obtain the correct result using <code>transform</code>:</p> <pre><code>QGraphicsItem * item = ....; QTransform t; QPointF xlate = item-&gt;boundingRect().center(); t.translate(xlate.x(), xlate.y()); t.rotate(angle); t.scale(xScale, yScale); t.translate(-xlate.x(), -xlate.y()); item-&gt;setTransform(t); </code></pre> <p>To obtain the correct result using <code>transformations</code>:</p> <pre><code>QGraphicsItem * item = ....; QGraphicsRotation rot; QGraphicsScale scale; auto center = item-&gt;boundingRect().center(); rot.setOrigin(QVector3D(center)); scale.setOrigin(QVector3D(center())); item-&gt;setTransformations(QList&lt;QGraphicsTransform*&gt;() &lt;&lt; &amp;rot &lt;&lt; &amp;scale); </code></pre> <p>Finally, the example:</p> <p><img src="https://i.stack.imgur.com/wyppC.png" alt="screenshot"></p> <pre><code>#include &lt;QtWidgets&gt; struct Controller { public: QSlider angle, xScale, yScale; Controller(QGridLayout &amp; grid, int col) { angle.setRange(-180, 180); xScale.setRange(1, 10); yScale.setRange(1, 10); grid.addWidget(&amp;angle, 0, col + 0); grid.addWidget(&amp;xScale, 0, col + 1); grid.addWidget(&amp;yScale, 0, col + 2); } template &lt;typename F&gt; void connect(F f) { connect(f, f, std::move(f)); } template &lt;typename Fa, typename Fx, typename Fy&gt; void connect(Fa &amp;&amp; a, Fx &amp;&amp; x, Fy &amp;&amp; y) { QObject::connect(&amp;angle, &amp;QSlider::valueChanged, std::move(a)); QObject::connect(&amp;xScale, &amp;QSlider::valueChanged, std::move(x)); QObject::connect(&amp;yScale, &amp;QSlider::valueChanged, std::move(y)); } QTransform xform(QPointF xlate) { QTransform t; t.translate(xlate.x(), xlate.y()); t.rotate(angle.value()); t.scale(xScale.value(), yScale.value()); t.translate(-xlate.x(), -xlate.y()); return t; } }; int main(int argc, char **argv) { auto text = QStringLiteral("Hello, World!"); QApplication app(argc, argv); QGraphicsScene scene; QWidget w; QGridLayout layout(&amp;w); QGraphicsView view(&amp;scene); Controller left(layout, 0), right(layout, 4); layout.addWidget(&amp;view, 0, 3); auto ref = new QGraphicsTextItem(text); // a reference, not resized ref-&gt;setDefaultTextColor(Qt::red); ref-&gt;setTransformOriginPoint(ref-&gt;boundingRect().center()); ref-&gt;setRotation(45); scene.addItem(ref); auto leftItem = new QGraphicsTextItem(text); // controlled from the left leftItem-&gt;setDefaultTextColor(Qt::green); scene.addItem(leftItem); auto rightItem = new QGraphicsTextItem(text); // controlled from the right rightItem-&gt;setDefaultTextColor(Qt::blue); scene.addItem(rightItem); QGraphicsRotation rot; QGraphicsScale scale; rightItem-&gt;setTransformations(QList&lt;QGraphicsTransform*&gt;() &lt;&lt; &amp;rot &lt;&lt; &amp;scale); rot.setOrigin(QVector3D(rightItem-&gt;boundingRect().center())); scale.setOrigin(QVector3D(rightItem-&gt;boundingRect().center())); left.connect([leftItem, &amp;left]{ leftItem-&gt;setTransform(left.xform(leftItem-&gt;boundingRect().center()));}); right.connect([&amp;rot](int a){ rot.setAngle(a); }, [&amp;scale](int s){ scale.setXScale(s); }, [&amp;scale](int s){ scale.setYScale(s); }); right.angle.setValue(45); right.xScale.setValue(3); right.yScale.setValue(1); view.ensureVisible(scene.sceneRect()); w.show(); return app.exec(); } </code></pre>
37,221,100
0
<pre><code>public void changeWidth(final Pane/*Region*/ node, double width) {//its a Pane or Regions this.node = node; this.timeline = TimelineBuilder.create() .keyFrames( new KeyFrame(Duration.millis(20), new KeyValue( going here? , width, WEB_EASE) ) ) .build(); setCycleDuration(Duration.seconds(5)); setDelay(Duration.seconds(0)); </code></pre> <p>}</p> <blockquote> <p>In this case my node is a "AnchorPane".</p> </blockquote> <p>your <code>AnchorPane</code> is a subclass or <code>Pane</code>, let your wrappers or methods take in <code>Pane</code> or their respective class</p>
35,709,497
1
Anaconda Python: where are the virtual environments stored? <p>I am new to Anaconda Python and I am setting up a project in Sublime Text 3. I have installed Anaconda and created a virtual environment using:</p> <pre><code>conda create -n python27 python=2.7 anaconda conda create -n python35 python=3.5 anaconda </code></pre> <p>i am having trouble setting up the Virtualenvs plugin for SublimeText 3. when i try, it asks me for a virtualenvs path which i give <code>~/users/../anaconda/envs/python27</code>, then it asks for what I'm assuming is a path to an python distribution because it lists file paths for the system versions of python--but not the anaconda install. </p> <p>i have no real desire to use the plug in, I just want to be able to use both versions of python. could i use a project settings file to set the version of python instead?</p>
17,988,847
0
<p>You querying a list of strings from your database and this is what the service returns.</p> <p>Their are multiple ways to achieve your goal.</p> <p>Pure JPA</p> <ol> <li><p>Using @JsonIgnore to tell Jackson not to serialize an attribute</p> <pre><code>class Application { String name; @JsonIgnore String address; } </code></pre></li> <li><p>Create a new Entity class that only contains the attributes you would like to share</p> <pre><code>class ApplicationName { String name; } </code></pre></li> </ol> <p>Alternatively you could introduce a separate class that only contains the attributes you would like to share and convert the results from the query into this class and return than the list of this converted values.</p>
40,711,193
1
Python typeerror int object not iterable, sum function issue (I think) <p>The object of the program is to ask the user how many articles of clothing they collected on each day of a 3 day (weekend) clothes drive, average them, do it again for the second weekend, then average the two weekends (clothes per day). </p> <p>Here is my code: </p> <pre><code>import math num_clothes = int() weekend_total = int() weekend_avg = float() total_clothes = int() total_avg = float() index = int() index = 1 while index &lt;= 2: index = 1 while index &lt;= 3: num_clothes = int(input("How many articles of clothing did you collect today? ")) index = index + 1 weekend_total = sum(num_clothes) weekend_avg = weekend_total / 3 print("Total Collected:\t", weekend_total) print("Weekend Average:\t", weekend_avg) index = index + 1`1 total_clothes = sum(weekend_total) total_avg = total_clothes / 6 print("Total Number of Clothing Collected:\t", total_clothes) print("Average Collected:\t", total_avg) </code></pre> <p>And here is the error i keep getting: </p> <pre><code>Traceback (most recent call last): File "G:\ITCS 1140\labs\python\lab 9.py", line 17, in &lt;module&gt; weekend_total = sum(num_clothes) TypeError: 'int' object is not iterable </code></pre> <p>I am trying to make num_clothes into a list and add all the values of it with sum(num_clothes).</p>
8,474,620
0
Errors with a shell-script <p>i found some freaky error. I want to increment a counter, but the variable isnt visible outside the while do.</p> <p>The script as follows:</p> <pre><code> ## $1 - The file which should be examined ## $2 - The time passed between the checks. If $2 is 5 then all lines from the last 5 minutes are taken ## $3 - The Errormessage to search for outputOK="OK - nothing happened" output_logcheck=0; errlines=""; cat $1 | grep "$3" | while read line do linedate=`date -d "$(echo $line | cut -d " " -f 2)" '+%s'` nowdate=`date '+%s'` if [ $(( $nowdate - (60 * $2) )) -le $linedate ] then $output_logcheck=$[$output_logcheck+1] $errlines="${errlines} -- ${line}" fi done; if [ $output_logcheck -eq 0 ] then echo $outputOK else echo "CRITICAL - There are -= ${output_logcheck} =- $3 -- Lines: $errlines" fi </code></pre> <p>So i dont know what else to try. Thanks in advance.</p>
1,351,931
0
<p>Mod just means you take the remainder after performing the division. Since 4 goes into 2 zero times, you end up with a remainder of 2.</p>
13,882,206
0
Changing the Twitter Bootstrap stock Navbar to Transparent <p>I've seen a number of questions and answers about changing the background color of the default Twitter Bootstrap Primary Navbar, but they seem to deal with the top-most layer (the navbar-inner class), masking a number of other colors and options underneath.</p> <p>I'm looking to create a transparent navbar, and after adding "background-color:transparent;" to each layer I can find, I still have a stock white bar across the top of my screen. Currently my app.css has these few lines:</p> <pre><code>.navbar-inner{ background-color:transparent; } .navbar-inner container{ background-color:transparent; } .navbar{ background-color:transparent; } #nav-main{ background-color:transparent; } #banner{ background-color:transparent; } </code></pre> <p>I'm running out of guesses here, and my scatter-shot method seems to be failing me. Is there a rule I just haven't seen (and modified) yet, or am I going about this the wrong way altogether?</p>
10,030,380
0
<p>Found it.</p> <p>No masks involved.</p> <p>I took the <code>Path</code> and wrapped a <code>Group</code> around it:</p> <pre><code>&lt;s:Group blendMode="layer"&gt; &lt;s:Path id="connector" ... /&gt; &lt;s:Ellipse id="hole" blendMode="erase"&gt; </code></pre> <p>I set the <code>blendMode</code> to "layer" and added an ellipse <em>after</em> the path with blendMode <code>erase</code></p>
4,301,580
0
<p>Did you try some:</p> <pre><code>pid_t pid = getpid(); </code></pre> <p>and try to use gdb to print pid value? Nevertheless, your pid should print. What if you try :</p> <pre><code>printf("pid = %ld\n", getpid()); </code></pre>
18,338,463
0
Javascript hide show object <p>This code doesn't work, why?</p> <pre><code>&lt;script&gt; function color(color_type){ if (color_type == 'blue'){ document.getElementById('blue').style.display = 'block'; document.getElementById('red').style.display = 'none'; } else{ document.getElementById('blue').style.display = 'none'; document.getElementById('red').style.display = 'block'; } } &lt;/script&gt; &lt;select onchange="color(this.value)"&gt; &lt;option name="choice1" value="red" &gt;red&lt;/option&gt; &lt;option name="choice2" value="blue" &gt;blue&lt;/option&gt; &lt;/select&gt; &lt;div id="red" style="display:none;"&gt; &lt;? // echo "&lt;tr&gt; &lt;td width='100' class='tbl'&gt;Just ask&lt;/td&gt; &lt;td width='80%' class='tbl'&gt;&lt;input type='text' name='1' value='$n1' class='textbox' style='width: 250px'&gt;&lt;/td&gt; &lt;/tr&gt;"; // ?&gt; &lt;/div&gt; &lt;div id="blue" style="display:none;"&gt; &lt;? // echo "&lt;tr&gt; &lt;td width='100' class='tbl'&gt;Just ask blue&lt;/td&gt; &lt;td width='80%' class='tbl'&gt;&lt;input type='text' name='2' value='$n2' class='textbox' style='width: 250px'&gt;&lt;/td&gt; &lt;/tr&gt;"; // ?&gt; &lt;/div&gt; </code></pre> <p>Td table doesn't hidden, every time show this table. I need that when I chose blue or red show only "Just ask blue" or "Just ask" table.</p> <p>P.S sorry for my bad english language </p>
7,191,918
0
jQuery image/window resize--max resize constraint <p>I currently have a page where I have fixed-size divs that load pages as a user scrolls down (similar to Infinite Scroll) and am currently working on functionality to have the loaded images and containers dynamically resize along with the browser window. My current issue is that I'm currently using <code>$(window).width</code> and <code>$(window).height</code>, which naturally causes the images to resize to the window width.</p> <p>I was wondering what I can set <code>maxWidth</code> and <code>maxHeight</code> to so that the images don't get resized any greater than their original size? I've been using <code>$(window)</code> just to test the function, but I basically don't want the images to become any larger than their original size. I've tried <code>$(this)</code>, but it causes the ratio to be equal to 1, resulting in no resize.</p> <pre><code> $(window).resize(function () { imageResize(); }); function imageResize() { $(".added").each(function () { var maxWidth = $(window).width(); var maxHeight = $(window).height(); var ratio = 0; var width = $(this).width(); var height = $(this).height(); if (width &gt; maxWidth) { ratio = (maxWidth / width); $(this).width(maxWidth); $(this).height(height * ratio); $(this).parent().height(height * ratio); $(this).parent().width(maxWidth); } else { ratio = (maxWidth / width); $(this).width(maxWidth); $(this).height(height * ratio); $(this).parent().height(height * ratio); $(this).parent().width(maxWidth); } }); } </code></pre>
8,854,636
0
<p>After testing and searching.. the answer is no. The only version that supports "non-broadcast" command is 5.0 The newer versions of cisco packet tracer only support defining networks as "point-to-point" or "broadcast". Though, non have the same characteristics. </p>
2,461,311
0
<pre><code>let Tlist_WinWidth = somenumber </code></pre>
32,450,553
0
<p>There's a different behaviour for push notifications when the app is in the foreground/background and when the app isn't running at all. When the app is running, whether in the foreground, you'll receive a call to <code>didReceiveRemoteNotification:</code> and you'll be responsible for handling the notification's display (the operating system won't do it for you).</p> <p>When the app is in the background, you'll receive a call to <code>didReceiveRemoteNotification:</code> only if/when the user presses the notification banner/alert displayed to him/her by the operating system. If the user chooses not to interact with the notification, your app won't even know about it.</p> <p>If the app isn't running at all, the behaviour will be similar to when the app is in the background, only you'll receive the push notification indication and data in the userInfo dictionary of <code>application:didFinishLaunchingWithOptions:</code></p> <p>So, if your question refers to cases in which the app is in the foreground, that shouldn't be a problem and you can do anything you want with the alert field before displaying it to the user. Otherwise, it's the operating system's responsibility to show the alert so that makes it a bit more complicated. Try using the tools available to you for localizing the alerts, as described here: <a href="http://stackoverflow.com/questions/18609923/change-language-of-alert-in-banner-of-push-notification">Change language of alert in banner of Push Notification</a>. Hopefully, it will help. Good luck.</p>
13,636,694
0
<p>If I've understood it correctly you don't have any problems of library versions and isolation, so independently of if a library is used by all the war archives or not, you can place them all inside the ear's lib directory (you could even consider placing the libraries in the jboss instance lib directory, and removing them from the ear/wars!). This way the ear file will have the smallest size possible.</p> <p>Don't worry about the memory used, the JBoss classloader will just load once the libraries, so they will be shared by all the wars that need them (another case would be if you need a different version of the same library for each war).</p> <p>On the other hand, if any of the libraries is just used by one of the war file, it will also be optimal if you place the library inside this war's lib directory.</p> <p>So your first approach is right, I don't think you need to change it.</p>
5,160,906
0
<p>When doing performance tests like this, you should always allow for "warmup period". So you shouldn't start measuring before having run the calculations a couple of hundred or thounsand times. This way the Java Hotspot compiler will have compiled what it considers being frequently executed code, and the native binary will have put its most frequently used variables in processor registers.</p> <p>My guess is that close to 100% of the difference in your result is due to the slow startup time of the JVM. Java uses ages to start compared to a natively compiled program.</p> <p>It would be interesting to see a measurement actually done in code, after a "warmup period".</p>
3,109,928
0
<p>StringBuffer has a reverse: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html#reverse()" rel="nofollow noreferrer">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html#reverse()</a></p> <p>BTW, I assume you meant O(n) because O(1) (as other people have mentioned) is obviously impossible.</p>
17,006,619
0
<p>The type inference is just a shortcut for an unnecessarily long way of instantiating paremeterized types. Generics are still implemented by type-erasure, so your bytecode will only have the raw types.</p>
957,432
0
<p>For the Microsoft .NET folks</p> <p>I think Silverlight is going to be HUGE for the next few and perhaps many years.</p>
7,985,713
0
<p>I had to figure this out one time, so I'm referring to my notes on the matter.</p> <p>The following query:</p> <pre><code>INSERT INTO table ... ON DUPLICATE KEY UPDATE ..., id = LAST_INSERT_ID( id) </code></pre> <p>Where 'id' is the primary key on the table, allows you to call <a href="http://us2.php.net/mysqli_affected_rows" rel="nofollow">mysqli_affected_rows()</a>, which will return:</p> <ol> <li>0 - Row existed, nothing updated</li> <li>1 - No row existed, inserted</li> <li>2 - Row existed, something updated</li> </ol>
25,092,906
0
MySQL join, even when 0 <p>Im doing the follwing, to create an user report</p> <pre><code>SELECT b.username, b.name, b.permissiontoedit, a.total, a.user FROM (SELECT user, Count( * ) AS total FROM products GROUP BY user)a JOIN user b ON a.user = b.username </code></pre> <p>This should give a table with the username, full name, permision (1/0) and the total of entries.</p> <p>Sadly, the query does only list users, which made more 1 or more entries in the table <code>products</code>. But i want all users, and if the have not made any entries in <code>products</code> it should display 0 or nothing. </p> <p>where do i made a mistake? </p>
30,918,130
0
<p>We're doing this:</p> <pre><code>$(document).on("pagecontainershow", function() { var activePage = $.mobile.pageContainer.pagecontainer("getActivePage"); var activePageId = activePage[0].id; if(activePageId != 'splashPage') { //fix rotation splash flash bug $("#splashPage").hide(); } else { $("#splashPage").show(); } switch(activePageId) { case 'loginPage': loginPageShow(); break; case 'notificationPage': notificationPageShow(); break; case 'postPage': postPageShow(); break; case 'profilePage': profilePageShow(); break; case 'splashPage': splashPageShow(); break; case 'timelinePage': timelinePageShow(); break; default: break; } }); </code></pre> <p>And navigation works like this:</p> <pre><code> $.mobile.loading('hide'); $(":mobile-pagecontainer").pagecontainer("change", "#timelinePage", { transition: 'none' }); </code></pre>
4,283,861
0
<p>Have you tried this?</p> <pre><code>usort($array, array($this, 'compare')) </code></pre> <p><a href="http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback" rel="nofollow">See PHP's documentation on the callback type</a>.</p>
15,606,436
0
<p>Here is a very basic attempt in Python:</p> <pre><code>import pylab as pl data = pl.array([[1,2],[2,3],[1,3],[2,1],[5,3],[3,2],[3,2],[1,1]]) first = data[:,0] second = data[:,1] xs = [] ys = [] for r in data: ys += list(r) ys.append(None) xs += [1.3,1.7] xs.append(None) pl.plot([1.3]*len(first),first,'o',[1.7]*len(second),second,'o',xs,ys) pl.boxplot(data) pl.ylim([min(min(first),min(second))-.5,max(max(first),max(second))+.5]) labels = ("first", "second") pl.xticks([1,2],labels) pl.show() </code></pre> <p>will result in: <img src="https://i.stack.imgur.com/igpyG.png" alt="enter image description here"></p>
2,508,815
0
<p>Though as with any operating system, you don't really learn to get truly comfortable with it unless you actually start using it on a daily basis. You can learn the basics from books and online tutorials, but if you want it to feel "natural" you'll have to jump right in and start actually using it regulary.</p> <p>A nice way to "wet your feet", if you don't want to convert from windows, is by installing Cygwin (<a href="http://www.cygwin.com" rel="nofollow noreferrer">www.cygwin.com</a>) on your windows machine and start to use it regulary (some discipline is required here, and it's not the best way to learn - but it's useful now and then). This also has the added benefit of automatically getting all nice *NIX utilities that can be a lifesaver when you're a programmer (awk, sed, bash, grep, tail, emacs, the list goes on...).</p>
38,899,934
0
<p>Issue was with JTDS driver as soon as I switched to JConnect driver everything began to work as expected. </p>
334,330
0
<p>There is such a thing as "too much" processing, and catching all exceptions kindof defeats the point. Specifically for C++, the catch(...) statement does catch all exceptions but you can't process the contents of that exception because you don't know the type of the exception (and it could be anything).</p> <p>You should catch the exceptions you can handle fully or partially, rethrowing the partial exceptions. You should not catch any exceptions that you can't handle, because that will just obfuscate errors that may (or rather, will) bite you later on.</p>
1,493,844
0
<p>If you need relational properties, <strong>look for non-Notes solutions</strong>. It is possible to get some relational behavior using document UNIDs and update agents, but it will be harder than with a proper relational backend.</p> <p>Your specific problem with referencing to a piece of text that might change can to some extent be resolved by using <strong>aliases</strong> in the choice fields. If a dialog list contains values on the form...</p> <pre><code>Foo|id1 Bar|id2 </code></pre> <p>...the form will display <strong>Foo</strong> but the back-end document will store the value <strong>id1</strong> - (and this is what you will be able to show in standard views - although <a href="http://www.lotus911.com/nathan/escape.nsf/d6plinks/NTFN-7FRG79" rel="nofollow noreferrer">xpages</a> could solve that). Using the <code>@DocumentUniqueID</code> for alias can be a good idea under some circumstances. </p>
31,462,287
0
What could be causing this JavaScript error? <p>I'm modifying an ASP.NET webform that loads a user control. In the user control there is JavaScript that is generating an error. The error is:</p> <blockquote> <p>JavaScript runtime error: The value of the property 'GetFirstItineraryObjects' is null or undefined, not a Function object</p> </blockquote> <p>This is a call in a list of function calls containing:</p> <pre><code>GetFirstItineraryObjects(); </code></pre> <p>And yes, when I examine the page source when it renders (after blowing past the JS error), this function is indeed there. I did wonder if the one line in this function that I modified might be causing the problem, so I commented it out. But the error still occurs.</p> <p>What can cause a JavaScript runtime error of this nature?</p> <p>I don't think this will help much, but here's the code which adds the JavaScript. Note that the entire page is rendered and sent to the browser before the browser can possibly execute any JavaScript in the page (this is for @Arwind).</p> <pre><code>clientScriptKey = "SetOriginalMileageObjectValues"; clientScriptText = string.Empty; if (!clientScript.IsClientScriptBlockRegistered(clientScriptType, clientScriptKey)) { clientScriptText = "function GetFirstItineraryObjects()" + Environment.NewLine; clientScriptText += " {" + Environment.NewLine; // a bunch of code clientScriptText += " }" + Environment.NewLine + Environment.NewLine; clientScript.RegisterClientScriptBlock(clientScriptType, clientScriptKey, clientScriptText, true); } clientScriptKey = "CreateMileageDataOldValues"; clientScriptText = string.Empty; if (!clientScript.IsClientScriptBlockRegistered(clientScriptType, clientScriptKey)) { clientScriptText = "GetFirstItineraryObjects();" + Environment.NewLine; clientScriptText += "GetFromLocationOldValues();" + Environment.NewLine; clientScriptText += "GetToLocationOldValues();" + Environment.NewLine; clientScriptText += "GetStartDateOldValues();" + Environment.NewLine; clientScript.RegisterStartupScript(clientScriptType, clientScriptKey, clientScriptText, true); } </code></pre> <p>Upon further examination, all four of those function calls (not just GetFirstItineraryObjects) throw the same JavaScript error, AND the functions do exist at runtime.</p>
10,291,342
0
<p>It's the opposite. There wasn't one out of the box in 1.3, and you had to download one from the gallery, whereas it's built-in 1.4.</p>
40,665,116
1
How to open a .txt file, analyze each individual date, determine how many time a day of the week appeared, in Python? <p>I am working on a project that I was able to do manually by hand, but am troubled when trying to write it in Python. I'm a new programmer in college.</p> <p>I have a .txt file that looks like so (for the sake of space I will only paste a bit, but there is 134 rows, not including the Date, Event #, Time, etc.)</p> <pre><code>Date Event # TIME Victim Name V R/G V Age 150101 0685 2:03 Anderson, Kedral BM 26 150103 0816 5:57 Shines, Kathryn WF 54 150106 4417 22:06 Norton, Noella HF 46 150107 4655 23:27 Speidel, Steven WM 41 150110 1100 8:35 Orozco, Jose HM 53 140813 2059 14:53 Liu, Kim Chunng AF 74 </code></pre> <p>I then need to collect the data, analyze it, and determine:</p> <ul> <li><p>The day of the week each homicide occurred on.</p></li> <li><p>A count of the number of homicides that occurred on each day of the week.</p></li> <li><p>A count of the number of homicides that fall within each hour block of the 24 hour time clock.</p></li> <li><p>A percentage of each racial/gender category for the 2015 homicides.</p></li> <li><p>A count of the number of homicide victims falling in each age category (0-10,11-20,21-30,31-40,41-50,51-60, etc.)</p></li> <li><p>Then take that data and put it in to a series of plots which I have the code for and know how to do.</p></li> </ul> <p>Here is the help I need:</p> <ol> <li><p>I need help with taking each "150101" and using Zeller's congruence to determine the date and put them in a list I believe.</p></li> <li><p>I have a very good idea of what I need to do, I just don't know how exactly to go about it</p></li> </ol> <p>Here is what I have so far:</p> <pre><code>fd = open("2015HomicideLog.txt",'r') bd = {} skipline = fd.readline() for line in fd: bd.append(line.split()[0] </code></pre> <p>Here is my code for zellers:</p> <pre><code>def zeller(day, month, year): if month == 1: A = 11 year = year - 1 elif month == 2: A = 12 year = year - 1 elif month == 3: A = 1 year = year elif month == 4: A = 2 year = year elif month == 5: A = 3 year = year elif month == 6: A = 4 year = year elif month == 7: A = 5 year = year elif month == 8: A = 6 year = year elif month == 9: A = 7 year = year elif month == 10: A = 8 year = year elif month == 11: A = 9 year = year elif month == 12: A = 10 year = year yearlist = list(str(year)) twodigityear = yearlist[2] + yearlist[3] twodigitcentury = yearlist[0] + yearlist[1] B = day C = int(twodigityear) D = int(twodigitcentury) W = (13 * int(A) - 1) / 5 X = int(C) / 4 Y = int(D) / 4 Z = int(W) + int(X) + int(Y) + int(B) + int(C) - (2 * int(D)) R = Z % 7 if R == 0: print("Sunday") elif R == 1: print("Monday") elif R == 2: print("Tuesday") elif R == 3: print("Wednesday") elif R == 4: print("Thursday") elif R == 5: print("Friday") elif R == 6: print("Saturday") </code></pre>
29,492,810
0
<p>You could store this information to a map while import. As it grows really big I suggest using a preallocated long-array with as many entries as there are edges. E.g. use a custom encoder:</p> <pre><code>CarFlagEncoder carEncoder = new CarFlagEncoder(5, 5, 3) { @Override public void applyWayTags(OSMWay way, EdgeIteratorState edge) { ghEdgeIdToOSMWayIdMap[edge.getEdge()] = way.getId(); super.applyWayTags(way, edge); } }; setEncodingManager(new EncodingManager(carEncoder, ...)); </code></pre>
29,390,740
0
Kafka Spout fails to acknowledge message in storm while setting multiple workers <p>I have a storm topology that subscribes events from Kafaka queue. The topology works fine while the number of workers config.setNumWorkers is set to 1. When I update the number of workers to more than one or 2, the KafkaSpout fails to acknowledge the messages while looking at storm UI. What might be the possible cause, I am not able to figure out, the exactness of problem. </p> <p>I have a 3 node cluster running one nimbus and 2 supervisors. </p>
16,488,939
0
<p>You can add the footer at the end:</p> <pre><code>%body = render :partial =&gt; "landing/landingmenu" - if devise_controller? #login .span4.offset4 = yield - else = yield = render :partial =&gt; "landing/footer" .footer </code></pre>
16,418,755
0
<p>The entire difference is like you said, in texture caching. So choosing between either of these methods depends on whether or not you will want to exploit texture caching in your visualization. Lets look at some common cases:</p> <p>a) If you want to calculate how a surface is deformed (for example the surface of water, or maybe some elastic deformation) and you need to know the new vertices for the surface's polygonal mesh then you would typically use Buffers (Number one), except you wouldn't need to copy to an OpenGL texture here. In fact there would be no copying involved here, you would just reference the buffer in CUDA and use it as a gl buffer.</p> <p>b) If you have a particle simulation and need to know the updated particle's position, you would also just use a buffer as in the above case.</p> <p>c) If you have a finite element grid simulation, where each fixed volume cell in space would gain a new value and you need to visualize it via volume rendering or isosurface, here you would want to use a texture object (2D or 3D depending on the dimensionality of your simulation), because when you're casting rays, or even generating streamlines you will almost always be needing to immediately have the neighboring texels cached. And you can avoid doing any copying here, as in the above method you could also directly reference some CUDA texture memory (cudaArray) from OpenGL. You would use these calls to do that:</p> <pre><code>cudaGraphicsGLRegisterImage( &amp;myCudaGraphicsResource, textureNameFromGL, GL_TEXTURE_3D,...) ... cudaGraphicsMapResources(1, myCudaGraphicsResource) cudaGraphicsSubResourceGetMappedArray(&amp;mycudaArray, myCudaGraphicsResource, 0, 0) cudaGraphicsUnMapResources(1, myCudaGraphicsResource) </code></pre> <p>and so this texture data in CUDA can be referenced by mycudaArray while this same memory in OpenGL can referenced by textureNameFromGL.</p> <p>Copying from a buffer into a texture is a bad idea because if you need this data for texture caching you will be doing the additional copy. This was more popular in the earlier versions of CUDA before texture interop was supported</p> <p>You could also use textures in the a) and b) use cases as well. With some hardware it might even work faster, but this is very hardware dependent. Keep in mind also that texture reading also applies minification and magnification filters which is extra work if all you're looking for is an exact value stored in a buffer.</p> <p>For sharing textures resources with CUDA and OpenGL please refer to this sample</p> <p><a href="https://github.com/nvpro-samples/gl_cuda_interop_pingpong_st" rel="nofollow">https://github.com/nvpro-samples/gl_cuda_interop_pingpong_st</a></p>
22,447,871
0
Implement Equivalent Elasticsearch titan query using Elasticsearch java driver <p>I asked question related to pagination in Elastic Search result fetched by titan here</p> <p><a href="http://stackoverflow.com/questions/22436106/pagination-with-elastic-search-in-titan/22439442?noredirect=1#22439442">Pagination with Elastic Search in Titan</a></p> <p>and concluded that its not supporting right now so to get it I decided to search <code>Titan</code> index directly using ES java client.</p> <p>Here is ths Titan way of fetching ES records:</p> <pre><code>Iterable&lt;Result&lt;Vertex&gt;&gt; vertices = g.indexQuery("search","v.testTitle:(mytext)") .addParameter(new Parameter("from", 0)) .addParameter(new Parameter("size", 2)).vertices(); for (Result&lt;Vertex&gt; result : vertices) { Vertex tv = result.getElement(); System.out.println(tv.getProperty("testTitle")+ ": " + result.getScore()); } </code></pre> <p>Its return 1 record.</p> <p>but addParameter() is not supported so pagination is not allowed. So i wanted to do same thing directly from ES java client as below:</p> <pre><code>Node node = nodeBuilder().node(); Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300)); SearchResponse response = client.prepareSearch("titan") .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(QueryBuilders.fieldQuery("testTitle", "mytext")) // Query .execute() .actionGet(); System.out.println(response.getHits().totalHits()); node.close(); </code></pre> <p>Its printing zero in my case. but the same query in Titan code (above) return 1 record. Am I missing some <code>Titan</code> specific parameters or options in this ES java code????</p>
22,369,940
0
<p>Its just a mathematical calculation which can done using javascript alone. There is no need of AJAX as I guess. You get the input and calculate and display it with drawing even using canvas.</p> <p>What you need is formulas as in the link you need <code>A = π * (r * r)</code> for circle</p> <p>and for square <code>A = a * a</code> where a is the length of a side.</p> <p>Using keyup call backs you can easily make it without using a button. See a example <a href="http://jsfiddle.net/U9reT/" rel="nofollow">here</a></p> <p>HTML</p> <pre><code>&lt;input type="text" id="radius" /&gt; &lt;div id="res"&gt; Area is &lt;span&gt; 0 &lt;/span&gt; &lt;/div&gt; </code></pre> <p>jquery</p> <pre><code>$(document).ready(function() { $("#radius").keyup(function(e) { e.preventDefault(); var r = parseInt($(this).val(),10); var a = (r*r) * 3.142; $("#res span").html(a); }); }); </code></pre> <p>javascript</p> <pre><code>var rad = document.getElementById("radius"); rad.addEventListener("keyup", function() { var r = parseInt(this.value, 10); var a = (r*r) * 3.142; alert(a);// display it in a element instead of alert }, false); </code></pre>
24,315,937
0
<p>You could install Visual studio on build server, and run devenv.exe from a commandline build runner in TeamCity. It doesn't feel right, but I think it will work. See <a href="http://www.tandisoft.com/2011/08/building-visual-studio-setup-projects.html" rel="nofollow">this link</a>.</p>
21,793,009
0
<p>Most uses of <code>after_initialize</code> can be (and SHOULD be) replaced with defaults on the corresponding database columns. If you're setting the property to a constant value, you may want to look into this as an alternative.</p> <p>EDIT: if the value isn't constant, a call to <code>has_attribute?(:name)</code> will guard against this error - <a href="http://stackoverflow.com/questions/6820156/activemodelmissingattributeerror-occurs-after-deploying-and-then-goes-away-aft">ActiveModel::MissingAttributeError occurs after deploying and then goes away after a while</a></p>
24,652,309
0
<p>The function <code>OnePlusNumber(x);</code> return a Integer.</p> <p>Replace it with <code>x = OnePlusNumber(x);</code> </p>
31,850,691
0
<p>You library must support all the frameworks that you web project it targeting. This is why the default Class Library project in VS15 targeting dotnet, which is supporting the widest ranges of frameworks. </p>
37,843,609
0
Angular 2 testcomponentbuilder does not work with several directives from third party libraries <p>I am writing unit tests for my angular 2 component with Jasmine framework and somehow Jasmine always skips my spec if I include directives not from the angular original module (in my case the test only works with directives for example from angular/core and angular/common). This is my app component:</p> <pre><code>import {Component, Input, OnInit} from '@angular/core'; import {NgStyle} from '@angular/common'; import { CollapseDirective } from 'ng2-bootstrap/components/collapse'; import {MdButton} from '@angular2-material/button'; import { MdDataTable } from 'ng2-material'; import { EntityFilterPipe } from './entity-filter.pipe'; import { NgFor } from '@angular/common'; @Component({ selector: 'test', templateUrl: 'app/entity.html', pipes: [EntityFilterPipe], directives: [NgStyle, NgFor, CollapseDirective] }) export class EntityTestComponent implements OnInit { public title = 'Entities'; @Input() name:string; showSearch: boolean = true; listFilter:string; toggleSearch(): void { this.showSearch = !this.showSearch; } ngOnInit() { console.log("printed"); } } </code></pre> <p>And this is my spec:</p> <pre><code>import {describe, it, beforeEach, inject, expect, beforeEachProviders } from '@angular/core/testing'; import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing'; import { EntityTestComponent } from './entity-test.component'; export function main() { describe('Entity component', () =&gt; { let tcb: TestComponentBuilder; beforeEachProviders(() =&gt; [TestComponentBuilder, EntityTestComponent]); beforeEach(inject([TestComponentBuilder], (_tcb: TestComponentBuilder) =&gt; { tcb = _tcb })); it('should display no item found when item is not on the list', done =&gt; { //expect(true).toBe(true); tcb.createAsync(EntityTestComponent).then(fixture =&gt; { let property = fixture.componentInstance; expect(property.showSearch).toBe(true); done(); }) .catch(e =&gt; done.fail(e)); }); </code></pre> <p>The spec is run if I only include NgStyle and NgFor in my list directives. When I tried including anything from different libraries, such as CollapseDirective or MdDataTable, the spec is skipped -- jasmine test does not show success or failure. Any suggestion is much appreciated! Thanks</p>
23,405,271
0
Change the PegMan position on a Google map <p>I've succeeded in moving all other controls on a Google map with the following small screen css:</p> <pre><code>div.gmnoprint, div.gmnoprint:nth-child(8) &gt; div:nth-child(2) &gt; div:nth-child(4) &gt; img:nth-child(1) { padding-top: 130px; } </code></pre> <p>This is needed to move the map controls below a logo on a mobile/small screen version of a site. The pan, zoom and map type controls all move correctly but the Peg Man stays in its original position which is behind the site logo (which I can't move easily).</p> <p>The element identifier used in the above css is what the Firefox inspector claims is the Peg Man image but I've also tried removing weekend from the end of that identifier to modify the div tags rather than the image - the Peg Man just won't move!</p> <p>You can see the problem at <a href="http://www.BlueBadgeParking.com" rel="nofollow">http://www.BlueBadgeParking.com</a> on device with a screen size of less than 400px.</p>
7,358,483
0
<p>As I suppos the main reason was compiler settings, I make some modifications in <strong><em>makefile</em></strong> and my .a archive linked to shared library, here are modifications.</p> <pre><code>GCC := C:\Tools\ndk-toolchain\ndk-standalone\bin\arm-linux-androideabi-gcc.exe GPP := C:\Tools\ndk-toolchain\ndk-standalone\bin\arm-linux-androideabi-g++.exe AR := C:\Tools\ndk-toolchain\ndk-standalone\bin\arm-linux-androideabi-ar.exe OPTIONS :=\ -fpic \ -ffunction-sections \ -funwind-tables \ -fstack-protector \ -D__ARM_ARCH_5__ \ -D__ARM_ARCH_5T__ \ -D__ARM_ARCH_5E__ \ -D__ARM_ARCH_5TE__ \ -Wno-psabi \ -march=armv5te \ -mtune=xscale \ -msoft-float \ -mthumb \ -Os \ -fomit-frame-pointer \ -fno-strict-aliasing \ -finline-limit=64 \ -DANDROID \ -Wa, \ -O2 \ -DNDEBUG \ -g \ default: all all: obj $(AR) r libtestlibrary.a *.o obj: $(GCC) $(OPTIONS) -c *.c </code></pre>
28,367,660
0
Filter out events <p>I have a TellstickDuo, a small device capable of sending signals to my lamps at home to turn them on or off based on a schedule. This device sends around 3-5 "on-signals" and "off-signals" every time i press the remote control button (to make sure at least one signal is sent correctly i guess!?). I also have a Raspberry Pi that listens for these signals and starts a script when a specific signal is found (based on the lamp-devices id´s).</p> <p>The problem is that everytime when it sends 3-5 signals my script runs the same amount of times but i only want it to run once. Is there any way to capture these signals and with bash (.sh) ignore everyone but one ?</p> <p>Code sent from device:</p> <pre><code>...RUNNING /usr/bin/php /var/www/autosys/python_to_raw.php "class:command;protocol:arctech;model:selflearning;house:13741542;unit:10;group:0;method:turnon;" ...RUNNING /usr/bin/php /var/www/autosys/python_to_raw.php "class:command;protocol:arctech;model:selflearning;house:13741542;unit:10;group:0;method:turnon;" ...RUNNING /usr/bin/php /var/www/autosys/python_to_raw.php "class:command;protocol:arctech;model:selflearning;house:13741542;unit:10;group:0;method:turnon;" ...RUNNING /usr/bin/php /var/www/autosys/python_to_raw.php "class:command;protocol:arctech;model:selflearning;house:13741542;unit:10;group:0;method:turnon;" </code></pre> <p>and my script is:</p> <pre><code>#!/bin/bash if [[ ( "${RAWDATA}" == *13741542* ) &amp;&amp; ( "${RAWDATA}" == *turnon* ) ]]; then # Something will be done here, like turn on a lamp, send an email or something else fi </code></pre> <p>(Some explanation to the RAWDATA code can be found here: <a href="http://developer.telldus.com/blog/2012/11/new-ways-to-script-execution-from-signals" rel="nofollow">http://developer.telldus.com/blog/2012/11/new-ways-to-script-execution-from-signals</a>)</p> <p>If i set my bash-script to send an email i get 4 emails, if i set it to update a counter at my local webpage it updates it 4 times. There is no way to controll how many signals the device will send, but can i only capture it once somehow? Maybe some way to "run script on first signal and drop everything else for 5 seconds"</p>
13,856,259
0
<p>It might be a formatting issue. If Philip A Barnes suggestions are not enough (or if you want an automated solution), check the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=21649" rel="nofollow">Microsoft Excel Excess Formatting Cleaner Add-in</a></p>
36,385,105
0
<p>I think you shouldn't be touching to the gradle/index.[android¦ios].js files when you change the root directory ; the paths are relatives meaning as long as you don't change your folder hierarchy it will keep working.</p> <p>The best way to add react-native to an existing projet is to first add it via <code>npm</code> :<br> <code>npm install --save react react-native</code></p> <p>Then, copy your <code>android</code>, <code>ios</code> folders and your <code>js</code> files to the root of your project.<br> Copying/merging <code>.flowconfig</code> and <code>.gitignore</code> files is recommended (if you use git and/or flow).</p> <p>You should be able then to start your project using react-native run-android.</p> <p>I think your problem there is that you didn't install the npm packages in the new project (or maybe I am totally wrong)</p>
19,011,024
0
<p>Use this function in your c program</p> <pre><code>int Add(int a, int b) { while (b) { // carry now contains common set bits of "a" and "b" int carry = a &amp; b; // Sum of bits of "a" and "b" where at least one of the bits is not set a = a ^ b; // Carry is shifted by one so that adding it to "a" gives the required sum b = carry &lt;&lt; 1; } return a; } </code></pre>
26,934,550
0
<p>A more-succint version of the same logic:</p> <pre><code>^(\d{2,4}|\d{6})$ </code></pre>
23,311,015
0
Include jQuery files in Node app's DOM on localhost <p>So I got jQuery to work in my Node app. Let's say I have the following code:</p> <pre><code>var body = '&lt;html&gt;'+ '&lt;head&gt;'+ '&lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;'+ '&lt;/head&gt;'+ '&lt;body&gt;'+ '&lt;script type="text/javascript"&gt;'+ '$(document).ready(function(){ alert('hey'); }); '+ '&lt;/script&gt;'+ '&lt;/body&gt;'+ '&lt;/html&gt;'; response.writeHead(200, {"Content-Type": "text/html"}); response.write(body); response.end(); </code></pre> <p>This works fine. However when I want to try and include a JS file like this (in the head):</p> <pre><code> '&lt;script type="text/javascript" src="scripts/main.js"&gt;&lt;/script&gt;' </code></pre> <p>I get a 404 error even though the script is in the right place (and the 8888 port is also the correct port) This is the error I get:</p> <pre><code> GET http://localhost:8888/scripts/main.js 404 (Not Found) </code></pre> <p>Any idea what I'm doing wrong? I'm pretty new to node.</p>
634,942
0
<p>If your projects are separated in a different file from ccnet.config, then you need to restart the service unless you touch the actual ccnet.config. </p> <p>We use ENTITY with SYSTEM file reference in ccnet.config for our projects, so we're in the same boat. I'm happy to pay the price for easier project maintenance, as it's easy to script a restart:</p> <pre><code>net stop CCService net start CCService IISRESET </code></pre> <p>If you wanted to completely automate this, and had your projects under source control, then you could trigger an update and restart whenever your project files are touched.</p>
36,344,126
0
Cleaning a segmented image in Opencv <p>I have this original:</p> <p><a href="https://i.stack.imgur.com/BFvgZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BFvgZ.jpg" alt="enter image description here"></a></p> <p>After segmentation I obtained this image:</p> <p><a href="https://i.stack.imgur.com/91A9h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/91A9h.jpg" alt="enter image description here"></a></p> <p>As you can see it is still not perfectly segmented. Any suggestions on how to further "clean" this segmented image? Here is my code:</p> <pre><code>using namespace cv; using namespace std; Mat COLOR_MAX(Scalar(65, 255, 255)); Mat COLOR_MIN(Scalar(15, 45, 45)); int main(int argc, char** argv){ Mat src,src2,hsv_img,mask,gray_img,initial_thresh,second_thresh,add_res,and_thresh,xor_thresh,result_thresh,rr_thresh,final_thresh; // Load source Image src = imread("banana2.jpg"); src2 = imread("Balanced_Image1.jpg"); imshow("Original Image", src); cvtColor(src,hsv_img,CV_BGR2HSV); imshow("HSV Image",hsv_img); //imwrite("HSV Image.jpg", hsv_img); inRange(hsv_img,COLOR_MIN,COLOR_MAX, mask); imshow("Mask Image",mask); cvtColor(src,gray_img,CV_BGR2GRAY); adaptiveThreshold(gray_img, initial_thresh, 255,ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY_INV,257,2); imshow("AdaptiveThresh Image", initial_thresh); add(mask,initial_thresh,add_res); erode(add_res, add_res, Mat(), Point(-1, -1), 1); dilate(add_res, add_res, Mat(), Point(-1, -1), 5); imshow("Bitwise Res",add_res); threshold(gray_img,second_thresh,150,255,CV_THRESH_BINARY_INV | CV_THRESH_OTSU); imshow("TreshImge", second_thresh); bitwise_and(add_res,second_thresh,and_thresh); imshow("andthresh",and_thresh); bitwise_xor(add_res, second_thresh, xor_thresh); imshow("xorthresh",xor_thresh); bitwise_or(and_thresh,xor_thresh,result_thresh); imshow("Result image", result_thresh); bitwise_and(add_res,result_thresh,final_thresh); imshow("Final Thresh",final_thresh); erode(final_thresh, final_thresh, Mat(), Point(-1,-1),6); bitwise_or(src,src,rr_thresh,final_thresh); imshow("Segmented Image", rr_thresh); imwrite("Segmented Image.jpg", rr_thresh); waitKey(0); return 1; }` </code></pre>
7,169,872
0
<p>You override the global language setting in your user defaults by calling</p> <pre><code>[[NSUserDefaults standardUserDefaults] setObject:@"YOURCOUNTRY" forKey:@"AppleLanguages"]; </code></pre> <p>However by doing this your user will have to restart the application unless you call this in the <code>main()</code> method before <code>UIApplicationMain()</code> is called</p> <p>Edit: look <a href="http://blog.federicomestrone.com/2010/09/15/iphone-apps-and-device-language-setting/" rel="nofollow">here</a> for an example on how to do this.</p>
40,480,433
0
<p>Removing this line of code worked.</p> <pre><code>let testArray: NSMutableArray = [] </code></pre>
9,293,991
0
How to get the data via ajax in servlet? <p>I would like to send some data on the page to servlet</p> <p>so I have written following jquery to do this</p> <p>I use all data to build a json string, and directly send it to servlet</p> <p>but I don't know how to get the whole data from the ajax in servlet</p> <pre><code>$("#save").click ( function() { $.ajax ( { url:'/WebApplication1/Controller', data:'{"name":"abc","address":"cde"}', type:'post', cache:false, success:function(data){alert(data);}, error:function(){alert('error');} } ); } ); </code></pre> <p>if see the the Form Data segment of request headers from chrome</p> <p>you will see the whole json string is the key.</p> <pre><code>Request URL:http://192.168.0.13/WebApplication1/Controller Request Method:POST Status Code:404 Not Found Request Headersview source Accept:*/* Accept-Charset:Big5,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4 Connection:keep-alive Content-Length:112 Content-Type:application/x-www-form-urlencoded Host:192.168.0.13 Origin:http://192.168.0.13 Referer:http://192.168.0.13/system_admin/building.html User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.910.0 Safari/535.7 X-Requested-With:XMLHttpRequest Form Dataview URL encoded {"name":"abc","address":"cde"}: Response Headersview source Accept-Ranges:bytes Connection:Keep-Alive Content-Language:en Content-Type:text/html; charset=iso-8859-1 Date:Wed, 15 Feb 2012 12:37:24 GMT Keep-Alive:timeout=5, max=100 Server:Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 Transfer-Encoding:chunked Vary:accept-language,accept-charset </code></pre>
8,584,821
0
<ul> <li>Are the requirement dependencies in C.lua correct? Can this be done or is it circular? <ul> <li>What you have looks fine to me.</li> </ul></li> <li>Can I overload mycalc(a,b) so it is same function name in both A and B? <ul> <li>I don't think that would make sense without another change, which would be to scope the definitions in A and B and return a table from each. That would look like this:</li> </ul></li> </ul> <p>B.lua (and A.lua similarly):</p> <pre><code>require 'mycalculator' local a=1; local b=2; local X=50; local function mycalcB(a,b) return myadd(a,b)+50; end B = { mycalc = mycalcB } return B </code></pre> <p>C.lua:</p> <pre><code>require 'A' require 'B' print(B.mycalc(1,2)) print(A.mycalc(1,2)) </code></pre>
21,096,612
0
<p>Came across this and remembered that I recently found a way that works.<br /> Basically iterating over all fields removing and re-adding them with merged options.<br /> Take this example below.</p> <pre><code>public function buildForm(FormBuilder $builder, array $options) { $builder -&gt;add('name_short') -&gt;add('name_long') -&gt;add('profile_education') -&gt;add('profile_work') -&gt;add('profile_political') -&gt;add('twitter') -&gt;add('facebook') -&gt;add('website') ; $commonOptions = array('attr' =&gt; array('class' =&gt; 'rtl')); foreach($builder-&gt;all() as $key =&gt; $field) { $options = $field-&gt;getOptions(); $options = array_merge_recursive($options, $commonOptions); $builder-&gt;remove($key); $builder-&gt;add($key, $field-&gt;getName(), $options); } } </code></pre>
35,755,334
0
Android Gridview with ImageButtons and TextViews. Items in gridview not lining up <p>I've got a view that has a GridView with Image Buttons and Textviews but whenever the textviews that are multi line the items are not lining up as shown below. I could set the TextView as </p> <pre><code>android:singleLine="true" </code></pre> <p>But I prefer not to. </p> <p><a href="https://i.stack.imgur.com/1DZzz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1DZzz.png" alt="enter image description here"></a></p> <p>GridView code :</p> <pre><code> &lt;GridView android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="match_parent" android:columnWidth="90dp" android:numColumns="auto_fit" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="columnWidth" android:gravity="center" android:layout_weight="1" /&gt; </code></pre> <p>Template for ImageButton and TextView called by BaseAdapter : </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:id="@+id/MainMenuImageButton" android:layout_alignParentRight="true" android:scaleType="fitCenter" /&gt; &lt;TextView android:id="@+id/MainMenuTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="trebuchet" android:layout_marginLeft="10dp" android:textColor="@android:color/black" android:singleLine="true" android:textSize="15sp" android:textStyle="bold" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>If you have a suggestion I'd appreciate it. Thank you.</p>
36,654,062
0
<p>I've come up to inflate a layout and it's been way faster.</p> <pre><code> View v = inflater.inflate(R.layout.choose_activity_dialog_view, container, false); int count = 1; TableRow row = new TableRow(getContext()); TableLayout mainLayout = (TableLayout) v.findViewById(R.id.choose_activity_dialog_table_layout); for(UserActivity ua : HomeActivity.userActivityStore.getUserActivities()){ Activity currentActivity = HomeActivity.activityStore.findByActivityId(ua.getActivityId()); if(currentActivity == null) continue; View chooseActivityView = inflater.inflate(R.layout.choose_activity_item, (ViewGroup) row, false); RelativeLayout relativeLayout = (RelativeLayout) chooseActivityView.findViewWithTag("relative_layout"); row.addView(relativeLayout); if(count % 3 == 0){ count = 0; mainLayout.addView(row); row = new TableRow(getContext()); } count++; </code></pre> <p>My layout looks like this :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!-- ACTIVITY TYPE --&gt; &lt;RelativeLayout android:layout_weight="1" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_gravity="start" android:tag="relative_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_marginBottom="25dip"&gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="40dp" android:src="@drawable/pct_amhe_white" android:layout_gravity="center_horizontal" android:scaleType="centerInside" /&gt; &lt;TextView android:layout_marginTop="50dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:gravity="center" android:textColor="@color/white" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I'd advise people looking for a solution to their problem that the second argument of inflate changes a lot about the render.</p>
23,628,416
0
<p>This is how I did it, when I had such a requirement</p> <pre><code>public class Schedule { public Schedule()throws Exception{ SchedulerFactory sf=new StdSchedulerFactory(); Scheduler sched=sf.getScheduler(); sched.start(); JobDetail jd=new JobDetailImpl("myjob",sched.DEFAULT_GROUP,QuartzJob.class); SimpleTrigger st=new SimpleTriggerImpl("mytrigger",sched.DEFAULT_GROUP,new Date(), null,SimpleTrigger.REPEAT_INDEFINITELY,60L*1000L); sched.scheduleJob(jd, st); } public static void main(String args[]){ try{ new Schedule(); }catch(Exception e){} } } </code></pre> <p>==================================</p> <pre><code>public class QuartzJob implements Job{ @Override public void execute(JobExecutionContext arg0) throws JobExecutionException { String[] springConfig = { "resources\\spring-batch.xml" ,"SPRING_BATCH_JOB_NAME" }; CommandLineJobRunner.main( springConfig ); System.out.println("Done"); } } </code></pre>
5,549,350
0
<p>With whichever of the two languages you'll be using to determine whether the user is logged in, create a conditional statement that adds a html class to the input field that alters it's width say .input-full and .input-partial</p> <pre><code>IF user is logged in SET class to input-full ELSE SET class to input-partial ENDIF </code></pre> <p>sorry for the psedo code, then have appropriate CSS for each.</p> <p>oooh, didn't see the CSS only, sorry. Without CSS3 and a disregard for IE I don't think you can do this with straight CSS.</p>
35,758,255
0
Creating a JSONPATH Query Talend <p>I am using CurrencyLayer to convert the following format in Talend. This is what the format looks like:</p> <pre><code>{ "success":true, "terms":"https:\/\/currencylayer.com\/terms", "privacy":"https:\/\/currencylayer.com\/privacy", "timestamp":1456950010, "source":"GBP", "quotes":{ "GBPUSD":1.406921, "GBPCAD":1.889923 } } { "success":true, "terms":"https:\/\/currencylayer.com\/terms", "privacy":"https:\/\/currencylayer.com\/privacy", "timestamp":1456950010, "source":"EUR", "quotes":{ "EURUSD":1.08665, "EURCAD":1.459701 } } { "success":true, "terms":"https:\/\/currencylayer.com\/terms", "privacy":"https:\/\/currencylayer.com\/privacy", "timestamp":1456950010, "source":"USD", "quotes":{ "USDCAD":1.343305 } } { "success":true, "terms":"https:\/\/currencylayer.com\/terms", "privacy":"https:\/\/currencylayer.com\/privacy", "timestamp":1456950010, "source":"CAD", "quotes":{ "CADUSD":0.744433 } } </code></pre> <p>Each will be a seperate API call. </p> <p>My database format looks like the following: CurrFrom, CurrTo, Rate, Date.</p> <p>Within Talend, I have created the FileInput using this URl and I can parse the timestamp, source. But how would I get the USD, CAD, and their respective rates and how would that be mapped to input into the database itself. </p> <p>help would be appreciated. </p>
1,108,336
0
<p>I guess you are running PHP without <a href="http://pl2.php.net/manual/en/ini.core.php" rel="nofollow noreferrer"><code>register_globals</code></a> option which is safe. That's why you need to access the submitted values using <code>$_POST['user']</code> and similar...</p> <p>How about adding:</p> <pre><code> $user = $_POST['user'] $email = $_POST['email'] // etc... </code></pre>
32,135,853
0
<p>Try this:</p> <pre><code>&lt;field name="organization_type_id" domain="[('id', 'in', parent_id.organization_type_id.allowed_children_ids.ids)]" /&gt; </code></pre> <p>While <code>allowed_children_ids</code> is a set of records, <code>allowed_children_ids.ids</code> is a list of ids of those records.</p> <p>You can also approach this from the other side. This should work and be event faster:</p> <pre><code>&lt;field name="organization_type_id" domain="[('allowed_parent_type_ids', '=', parent_id.organization_type_id)]" /&gt; </code></pre>
15,020,791
0
Weird thing is happening on Live Server <p>I am facing a weird thing when i move the file to live server. Actually i have an XML file. It is read from Jquery and the contents are displayed in the HTML Page. Yesterday i made some changes in the XML file and updated in the Live server. It works perfectly in the local. But in Live server it is returning old XML file values only. I totally removed the file and moved the new file.</p> <p>I thought it is referring from somewhere else. So i deleted the file and checked. But it shows error on that time. So it refers the same file only. I opened the file in the live server itself. Everything is perfect. But it still shows old content. I don't know what is the problem happening on live server.</p> <p>Can anyone help me to figure out?</p>
24,581,082
0
<p>I am using Android Studio 0.8.1. I have a project's gradle file like below:</p> <pre><code>android { compileSdkVersion 19 buildToolsVersion "20.0.0" defaultConfig { applicationId "com.omersonmez.widgets.hotspot" minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } </code></pre> <p>My emulator was android 4.0. So i modified my emulator and made api level 4.0.3(apilevel 15). It worked. </p>