title
stringlengths
10
150
body
stringlengths
17
64.2k
label
int64
0
3
How to get current module object from model in Yii2
<p>I have module <code>ticket</code>.</p> <p>Module class has propery <code>UserClassName</code> (string).</p> <p>In this module I have model called <code>Dialog</code>.</p> <p>Within this model, I want to get access to the module property <code>UserClassName</code>.</p> <p>How I can get module object from my model <code>Dialog</code>?</p> <p>P.S. From controllers I can do next: <code>$this-&gt;module</code>.</p>
0
how to install php 5.4 with ubuntu 16??
<p>I have install LAMP stack on ubuntu 16, I got php 7. </p> <p>I want to downgrade it to php 5.4 . what command should I use to remove php 7 and install php 5.4 in my ubuntu 16?</p>
0
Generating PDF files with JavaScript
<p>I’m trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within JavaScript. I need to be able to draw text, images and simple shapes. I would love to be able to do this entirely in the browser.</p>
0
Remove Product Categories title from woocommerce pages
<p>Does anybody know how to remove (or hide) the Product Categories title on woocommerce pages? </p> <p>It's using the h4 font settings in theme.php, these are also used for other element titles that I do not want to hide/remove. Any ideas? </p> <p>Thanks so much!</p>
0
Save and Load .bat game
<p>I'm making a text game written in bat, and the game has been done, (or more, a good part of it, such as the commands, and at the stage where you can play it); however, I want to add the power to save your game, and load it again.</p> <p>I think one could do this by having the .bat file write the variables which need to be saved (such as the item variables); however, I don't know how to do this. Any help would be appreciated, thanks.</p> <p>I should have said, I can make it load, by use of:</p> <pre><code> for /f "delims=" %%x in (config.txt) do (set "%%x") </code></pre> <p>However, I don't know how to make the .bat write to the file and so "save".</p>
0
How to use Firebase Realtime Database for Android Google Map app?
<p>I'm trying to work on Firebase <code>Realtime Dataase</code> access to my map's Markers which includes <code>dob</code>, <code>dod</code>, <code>name</code>, <code>latitude</code> , <code>longitude</code>, etc. And I want to use Full name as the title of marker, as well as dob and dod for the snippet of marker. </p> <p>My problem is don't kown how to get the value of <code>latitude</code> , <code>longitude</code> as the position of Marker and also <code>firstname</code> and <code>lastname</code> as the title ...</p> <p>Here is my <code>Realtime Dataase</code></p> <p><code>Profile</code></p> <pre><code>0 dob: "24/12/1940" dod: "02/07/2016" firstname:"Lincon" lastname:"Hall" latitude: -34.506081 longitude:150.88104 1 dob: "05/06/1949" dod: "08/08/2016" firstname:"Ben" lastname:"Roberts" latitude:-34.50609 longitude:150.8811 </code></pre> <p>The code of my map app:</p> <pre><code>public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, OnMarkerClickListener { private Marker myMarker; FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); DatabaseReference mProfileRef = firebaseDatabase.getReference(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override protected void onStart(){ super.onStart(); mProfileRef.child("Profile").addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { } @Override public void onChildChanged(DataSnapshot dataSnapshot, String s) { for (DataSnapshot child : dataSnapshot.child("0").getChildren()){ String dob = child.child("dob").getValue().toString(); String dod = child.child("dod").getValue().toString(); String latitude = child.child("latitude").getValue().toString(); String longitude = child.child("longitude").getValue().toString(); String firstname = child.child("firstname").getValue().toString(); String lastname = child.child("lastname").getValue().toString(); LatLng location = new LatLng(latitude,longitude); googleMap.addMarker(new MarkerOptions().position(location).title(firstname,lastname).snippet(dob,dod)); } } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public void onCancelled(DatabaseError databaseError) { } }); } @Override public void onMapReady(GoogleMap googleMap) { googleMap.setOnMarkerClickListener(this); LatLng wollongong = new LatLng(-34.404336, 150.881632); myMarker = googleMap.addMarker(new MarkerOptions() .position(wollongong) .title("Ben Roberts") .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)) .snippet("05/06/1949 - 08/08/2016") .anchor(0.0f,1.0f ) ); LatLng test2 = new LatLng(-34.404464, 150.881892); googleMap.addMarker(new MarkerOptions() .position(test2) .title("Graveyard") .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)) .snippet("This is a test graveyard too") .anchor(0.0f,1.0f ) ); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(wollongong, 18)); googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } googleMap.setMyLocationEnabled(true); } @Override public boolean onMarkerClick(Marker marker) { if (marker.equals(myMarker)) { Intent intent = new Intent(MapsActivity.this,Info_window.class); startActivity(intent); } else { Intent intent = new Intent(MapsActivity.this,Info_window.class); startActivity(intent); } return false; } </code></pre> <p>}</p> <p>Can anyone help me with that? Thanks a lot!</p> <p>The value of Dob and dod is null.</p> <p><a href="http://i.stack.imgur.com/bSMR4.jpg" rel="nofollow">map</a></p>
0
Change hotkey for autocomplete selection
<p>In Eclipse, I find it pretty annoying that Enter is the hotkey that selects an item from the Content Assist/Autocomplete list. Especially in PyDev where there is no end-of-line semicolon, pressing enter for a new line will instead give me whatever is selected in the Autocomplete list.</p> <p>Tab is a much better selection hotkey since I'm not likely to want a tab mid-line.</p> <p>Any chance of changing this in Eclipse?</p> <p>Using CDT, PDT, and PyDev, but interested in any solution related to Eclipse.</p>
0
How can I get the final redirect URL when using urllib2.urlopen?
<p>I'm using the <code>urllib2.urlopen</code> method to open a URL and fetch the markup of a webpage. Some of these sites redirect me using the 301/302 redirects. I would like to know the final URL that I've been redirected to. How can I get this?</p>
0
Get "Missing expression after unary operator '-'" when I try to run a Powershell script
<p>When I try to run following command</p> <pre><code>C:\Documents and Settings\BURE\My Documents\ibos\script&gt;powershell.exe -NoProfile -WindowStyle Hidden &amp; 'C:\Documents and Settings\BURE\My Documents\ibos\script\files_from_nomad.ps1' 1 </code></pre> <p>I get following error</p> <pre><code>Missing expression after unary operator '-'. At line:1 char:2 + - &lt;&lt;&lt;&lt; WindowStyle Hidden The filename, directory name, or volume label syntax is incorrect. </code></pre> <p>It works before, but not now? Why?</p> <p>What I try to do is to schadular a script:</p> <pre><code>schtasks /CREATE /RU BURE /SC MINUTE /TN files_to_nomad /TR "powershell.exe -NoProfile -WindowStyle Hidden &amp; 'C:\Documents and Settings\BURE\My Documents\ibos\script\files_to_nomad.ps1' 1" </code></pre> <p>I have exact the same schedular on another computer.</p>
0
Iterating over arrays by reflection
<p>I am doing some reflection work and go to a little problem.</p> <p>I am trying to print objects to some GUI tree and have problem detecting arrays in a generic way.</p> <p>I suggested that :</p> <blockquote> <p>object instanceof Iterable</p> </blockquote> <p>Would make the job ,but it does not, (obviously applies only to Lists and Set and whoever implements it.)</p> <p>So how is that i would recognice an Array Some <code>Object[]</code> , Or <code>long[]</code> or <code>Long[]</code> .. ?</p> <p>Thanks </p>
0
GET xmlHTTPrequest not working
<p>i am trying to make an ajax commenting system where if a new comment is posted, the document title changes to (1) website title (like twitter)</p> <p>my code is here </p> <p>The xmlHTTPrequest</p> <pre><code> function loadXMLDoc7(url) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET",url,false); xmlhttp.send(null); document.getElementById('newcomments').innerHTML=xmlhttp.responseText; } </code></pre> <p>The PHP</p> <pre><code> echo "&lt;script type='text/javascript'&gt; function auto2comments() { var MyDiv1 = document.getElementById('uiuiui');"; echo "loadXMLDoc7(MyDiv1.innerHTML)"; echo "}"; echo "setInterval(\"auto2comments()\",15000);&lt;/script&gt;"; } </code></pre> <p>The DIV uiuiui contains /newcommentingi.php?show=0&amp;id=username The problem is when the Newcomments DIV gets filled, it shows<br> ID =<br> Show = 0<br> why?</p>
0
How can I generate a random number within a range in Rust?
<blockquote> <p>Editor's note: This code example is from a version of Rust prior to 1.0 and is not syntactically valid Rust 1.0 code. Updated versions of this code produce different errors, but the answers still contain valuable information.</p> </blockquote> <p>I came across the following example of how to generate a random number using Rust, but it doesn't appear to work. The example doesn't show which version of Rust it applies to, so perhaps it is out-of-date, or perhaps I got something wrong.</p> <pre><code>// http://static.rust-lang.org/doc/master/std/rand/trait.Rng.html use std::rand; use std::rand::Rng; fn main() { let mut rng = rand::task_rng(); let n: uint = rng.gen_range(0u, 10); println!("{}", n); let m: float = rng.gen_range(-40.0, 1.3e5); println!("{}", m); } </code></pre> <p>When I attempt to compile this, the following error results:</p> <pre class="lang-none prettyprint-override"><code>test_rand002.rs:6:17: 6:39 error: type `@mut std::rand::IsaacRng` does not implement any method in scope named `gen_range` test_rand002.rs:6 let n: uint = rng.gen_range(0u, 10); ^~~~~~~~~~~~~~~~~~~~~~ test_rand002.rs:8:18: 8:46 error: type `@mut std::rand::IsaacRng` does not implement any method in scope named `gen_range` test_rand002.rs:8 let m: float = rng.gen_range(-40.0, 1.3e5); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ </code></pre> <p>There is another example (as follows) on the same page (above) that does work. However, it doesn't do exactly what I want, although I could adapt it.</p> <pre><code>use std::rand; use std::rand::Rng; fn main() { let mut rng = rand::task_rng(); let x: uint = rng.gen(); println!("{}", x); println!("{:?}", rng.gen::&lt;(f64, bool)&gt;()); } </code></pre> <p>How can I generate a "simple" random number using Rust (e.g.: <code>i64</code>) within a given range (e.g.: 0 to n)?</p>
0
JPA Updating Bidirectional Association
<p>Lets assume we have the following Entities: </p> <pre><code> @Entity public class Department { @OneToMany(mappedBy="department") private List&lt;Employee&gt; employees; } @Entity public class Employee { @ManyToOne private Department department } </code></pre> <p>It is understandable on an update that we need to maintain both sides of the relationship as follows:</p> <pre><code>Employee emp = new Employee(); Department dep = new Department(); emp.setDepartment(dep); dep.getEmployees().add(emp); </code></pre> <p>All good up till now. The question is should I apply merge on both sides as follows, and an I avoid the second merge with a cascade?</p> <pre><code>entityManager.merge(emp); entityManager.merge(dep); </code></pre> <p>Or is merging the owning side enough? Also should these merges happen inside a Transaction or EJB? Or doing it on a simple controller method with detached entities is enough?</p>
0
Starting async method as Thread or as Task
<p>I'm new to <code>C#</code>s <code>await/async</code> and currently playing around a bit.</p> <p>In my scenario I have a simple client-object which has a <code>WebRequest</code> property. The client should send periodically alive-messages over the <code>WebRequest</code>s <code>RequestStream</code>. This is the constructor of the client-object:</p> <pre><code>public Client() { _webRequest = WebRequest.Create("some url"); _webRequest.Method = "POST"; IsRunning = true; // --&gt; how to start the 'async' method (see below) } </code></pre> <p>and the async alive-sender method</p> <pre><code>private async void SendAliveMessageAsync() { const string keepAliveMessage = "{\"message\": {\"type\": \"keepalive\"}}"; var seconds = 0; while (IsRunning) { if (seconds % 10 == 0) { await new StreamWriter(_webRequest.GetRequestStream()).WriteLineAsync(keepAliveMessage); } await Task.Delay(1000); seconds++; } } </code></pre> <p>How should the method be started?</p> <blockquote> <p>new Thread(SendAliveMessageAsync).Start();</p> </blockquote> <p>or</p> <blockquote> <p>Task.Run(SendAliveMessageAsync); // changing the returning type to Task</p> </blockquote> <p>or</p> <blockquote> <p>await SendAliveMessageAsync(); // fails as of the constructor is not async</p> </blockquote> <p>My question is more about my personal understanding of <code>await/async</code> which I guess may be wrong in some points.</p> <p>The third option is throwing</p> <pre><code>The 'await' operator can only be used in a method or lambda marked with the 'async' modifier </code></pre>
0
How to sum up an array of integers in C#
<p>Is there a <strike>better</strike> shorter way than iterating over the array?</p> <pre><code>int[] arr = new int[] { 1, 2, 3 }; int sum = 0; for (int i = 0; i &lt; arr.Length; i++) { sum += arr[i]; } </code></pre> <hr> <p>clarification:</p> <p>Better primary means cleaner code but hints on performance improvement are also welcome. (Like already mentioned: splitting large arrays).</p> <hr> <p>It's not like I was looking for killer performance improvement - I just wondered if this very kind of <strong>syntactic sugar</strong> wasn't already available: "There's String.Join - what the heck about int[]?".</p>
0
HTML/CSS show/hide multiple elements?
<p>I'm looking for an HTML/CSS solution to this challenge: I have multiple elements with the same class or same id, and I want to show/hide them all at the same time, using a button or toggle switch. So I then have a click event, when I click that class or ID representing all those elements, they all hide. When I click again, they must show again.</p> <p>I would appreciate</p> <p>Thanks</p>
0
CMake Custom Command copy multiple files
<p>I am attempting to copy multiple files using the <code>${CMAKE_COMMAND} -E copy &lt;from&gt; &lt;to&gt;</code> format, but I was wondering if there was a way to provide a number of files to copy to a specific directory. It seems the cmake copy only allows for one file to be copied at a time. I really don't want to use the copy command repeatedly when I would rather provide a list of files to copy as the first argument.</p> <p>I'm thinking the easiest solution is to use the platform dependent "cp" command. While this definitely is not good for portability, our system is guaranteed to be built on Linux. A simple, platform independent solution would be better.</p>
0
Error Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] while saving timestamp into databse
<pre><code>SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss a z"); sdf.setTimeZone(TimeZone.getTimeZone("US/Eastern")); String DateToStoreInDataBase= sdf.format(obj1.getSomeDate().toGregorianCalendar().getTime()); System.out.println(emprSubDte); Timestamp ts = Timestamp.valueOf(emprSubDte); preparedStatement.setTimestamp(72,ts); </code></pre> <p>sysout of DateToStoreInDataBase is = " 2014-19-13 12:19:59 PM EDT" when i am trying to save this result into database in am getting error Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff].</p> <p>I have the same format but still i am reciving the error.</p>
0
Angular 6 iframe binding
<p>There is a variable that stores iframe code. I want to bind this in a div, but nothing work.</p> <p>html: </p> <pre><code>&lt;div class="top-image" [innerHTML]="yt"&gt;&lt;/div&gt; </code></pre> <p>ts:</p> <pre><code>yt = '&lt;iframe class="w-100" src="https://www.youtube.com/embed/KS76EghdCcY?rel=0&amp;amp;controls=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen&gt;&lt;/iframe&gt;'; </code></pre> <p>What is the solution?</p>
0
Getting "Caused by: java.lang.VerifyError:"
<p>I created an android application which is used as library in another android application. I used some third party jars in the android app which acts as a library. When I link this library in my android application and run it, I am getting the verify error when it tries to access the class present in the library. May I know what is the issue blocking here for me ? Any help greatly appreciated..</p> <p>I attached the log here and Parser1 is the class inside the library. I am getting the error in the line when i try to create the object for Parser1 class.</p> <pre><code>06-06 10:05:43.742: WARN/dalvikvm(224): VFY: unable to resolve static method 3084: Lorg/codehaus/jackson/JsonToken;.values ()[Lorg/codehaus/jackson/JsonToken; 06-06 10:05:43.742: DEBUG/dalvikvm(224): VFY: replacing opcode 0x71 at 0x0005 06-06 10:05:43.742: DEBUG/dalvikvm(224): Making a copy of Lcom/support/utils/Parser1;.$SWITCH_TABLE$org$codehaus$jackson$JsonToken code (522 bytes) 06-06 10:05:43.752: WARN/dalvikvm(224): VFY: unable to find class referenced in signature (Lorg/codehaus/jackson/JsonParser;) 06-06 10:05:43.752: INFO/dalvikvm(224): Could not find method org.codehaus.jackson.JsonParser.getCurrentToken, referenced from method com.support.utils.Parser1.addSectionContentData 06-06 10:05:43.761: WARN/dalvikvm(224): VFY: unable to resolve virtual method 3077: Lorg/codehaus/jackson/JsonParser;.getCurrentToken ()Lorg/codehaus/jackson/JsonToken; 06-06 10:05:43.761: DEBUG/dalvikvm(224): VFY: replacing opcode 0x74 at 0x0002 06-06 10:05:43.761: DEBUG/dalvikvm(224): Making a copy of Lcom/support/utils/Parser1;.addSectionContentData code (2421 bytes) 06-06 10:05:43.761: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;) 06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;) 06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;) 06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to find exception handler at addr 0x19b 06-06 10:05:43.771: WARN/dalvikvm(224): VFY: rejected Lcom/support/utils/Parser1;.addSectionContentData (Lorg/codehaus/jackson/JsonParser;Ljava/util/List;Lcom/support/ModelClasses/SectionContent;Lcom/support/ModelClasses/FeatureInfo;ZZLjava/lang/String;)Ljava/util/List; 06-06 10:05:43.781: WARN/dalvikvm(224): VFY: rejecting opcode 0x0d at 0x019b 06-06 10:05:43.781: WARN/dalvikvm(224): VFY: rejected Lcom/support/utils/Parser1;.addSectionContentData (Lorg/codehaus/jackson/JsonParser;Ljava/util/List;Lcom/support/ModelClasses/SectionContent;Lcom/support/ModelClasses/FeatureInfo;ZZLjava/lang/String;)Ljava/util/List; 06-06 10:05:43.781: WARN/dalvikvm(224): Verifier rejected class Lcom/support/utils/Parser1; 06-06 10:05:43.793: WARN/dalvikvm(224): threadid=15: thread exiting with uncaught exception (group=0x4001b188) 06-06 10:05:43.793: ERROR/AndroidRuntime(224): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception 06-06 10:05:43.812: ERROR/AndroidRuntime(224): java.lang.RuntimeException: An error occured while executing doInBackground() 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at android.os.AsyncTask$3.done(AsyncTask.java:200) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.lang.Thread.run(Thread.java:1096) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): Caused by: java.lang.VerifyError: com.support.utils.Parser1 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample.checkforversioning(Sample.java:652) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample$checkVersionThread.doInBackground(Sample.java:682) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample$checkVersionThread.doInBackground(Sample.java:1) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at android.os.AsyncTask$2.call(AsyncTask.java:185) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 06-06 10:05:43.812: ERROR/AndroidRuntime(224): ... 4 more 06-06 10:05:43.832: INFO/Process(52): Sending signal. PID: 224 SIG: 3 </code></pre> <p>Thanks, Senthil.M</p>
0
The requested operation cannot be completed due to security restrictions
<p>I have created new add-on as like as survey add-on. Module consist 3 level of groups,</p> <ol> <li>Head Manager(admin)</li> <li>Manager</li> <li>User</li> </ol> <p>If i am logged in as a manager and print the report, i am getting below warning,</p> <pre><code>"AccessError: ('AccessError', u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: res.partner, Operation: read)') " </code></pre> <p>My rules are:</p> <h2>Manager:</h2> <pre><code>&lt;record model="res.groups" id="base.group_survey_manager"&gt; &lt;field name="name"&gt;Custom Survey Manager&lt;/field&gt; &lt;field name="implied_ids" eval="[(4, ref('base.group_survey_user'))]"/&gt; &lt;field name="users" eval="[(4, ref('base.user_root'))]"/&gt; &lt;/record&gt; </code></pre> <hr> <pre><code>&lt;record id="project_survey_manager_access" model="ir.rule"&gt; &lt;field name="name"&gt;Survey Manager access rights&lt;/field&gt; &lt;field name="model_id" ref="custom_survey.model_custom_project_survey"/&gt; &lt;field name="domain_force"&gt;[(1, '=', 1)]&lt;/field&gt; &lt;field name="groups" eval="[(4, ref('base.group_survey_manager'))]"/&gt; &lt;field eval="1" name="perm_unlink"/&gt; &lt;field eval="1" name="perm_write"/&gt; &lt;field eval="1" name="perm_read"/&gt; &lt;field eval="1" name="perm_create"/&gt; &lt;/record&gt; </code></pre> <h2>Partner Form Security:</h2> <pre><code>&lt;record id="partner_list_access" model="ir.rule"&gt; &lt;field name="name"&gt;Access to the manager to list related partners&lt;/field&gt; &lt;field name="model_id" ref="base.model_res_partner"/&gt; &lt;field name="domain_force"&gt;[('create_uid', '=', user.id)]&lt;/field&gt; &lt;field name="groups" eval="[(4, ref('base.group_survey_manager'))]"/&gt; &lt;/record&gt; </code></pre> <p>If the manager is logged-in, i would like to list the partner who is created by the current manager. That's why i added the partner rule.</p> <p>How to solve this issue?</p>
0
Move ImageView from its current position to fixed position using translate animation
<p>I want to move my image view from its current position to some fixed position on screen using translate animation. Also I want to know how translate animation works and what parameters it accepts exactly?</p> <p>My piece of code is...</p> <pre><code> RelativeLayout.LayoutParams lParams = (LayoutParams) spreadImage .getLayoutParams(); TranslateAnimation ta ta = new TranslateAnimation(lParams.leftMargin, randomLeftMarginsList.get(currentSpreadIndex), lParams.topMargin, ta.setAnimationListener(this); ta.setDuration(ApplicationConstant.PUZZLE_GAME_IMAGE_SPREADING_TIME); spreadImage.startAnimation(ta); </code></pre> <p>Thanks in advance.</p>
0
Convert .pem and .pub to .pfx file
<p>I have a .pem file and a .pub file, I used following commands to create them</p> <pre><code>openssl genrsa -out temp.pem 1024 openssl rsa -in temp.pem -pubout -out temp.pub </code></pre> <p>Now I want to make them to a one .pfx file which is binary and contains both private and public key. Is it possible? how? (I have tested som openssl commands but the file was empty).</p> <p>I used this command </p> <pre><code> openssl pkcs12 -export -in temp.pem -inkey temp.pub -out temp.pfx -name "Temp Certificate" </code></pre> <p>it generates this error: </p> <p>unable to load private key 17880:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_li b.c:703:Expecting: ANY PRIVATE KEY</p>
0
How to use SQL Variables inside a query ( SQL Server )?
<p>I have written the following SQL Stored Procedure, and it keeps giving me the error at <code>@pid = SELECT MAX(...</code> The whole procedure is:</p> <pre><code>Alter PROCEDURE insert_partyco @pname varchar(200) AS BEGIN DECLARE @pid varchar(200); @pid = SELECT MAX(party_id)+1 FROM PARTY; INSERT INTO party(party_id, name) VALUES(@pid, @pname) SELECT SCOPE_IDENTITY() as PARTY_ID END GO </code></pre> <p>Can anyone please tell me what I'm doing wrong here?</p>
0
How can I install package of Latex use Texmarker
<p>I 'm new to use Latex. I have installed <strong><em>MiKTex</em></strong> and <strong><em>Texmarker</em></strong>. I opened my file <strong><em>"test.tex"</em></strong>. Program need to install one package, I choose "yes". But after this , i still got error , file <strong><em>"...sty"</em></strong> not found. Can anyone help me.</p> <p>Thanks in advance!</p> <p>P/S: I'm using Windows:)</p>
0
Reason for java.sql.SQLException "database in auto-commit mode"
<p>I use <code>sqlite</code> database and <code>java.sql</code> classes in servlet application to batch-insert some data into database. There are consecutive four inserts of different kinds of data. Each one looks like this:</p> <pre><code>PreparedStatement statement = conn .prepareStatement("insert or ignore into nodes(name,jid,available,reachable,responsive) values(?,?,?,?,?);"); for (NodeInfo n : nodes) { statement.setString(1, n.name); statement.setString(2, n.jid); statement.setBoolean(3, n.available); statement.setBoolean(4, n.reachable); statement.setBoolean(5, n.responsive); statement.addBatch(); } conn.setAutoCommit(false); statement.executeBatch(); conn.commit(); conn.setAutoCommit(true); statement.close(); </code></pre> <p>But sometimes I get the </p> <pre><code>java.sql.SQLException: database in auto-commit mode </code></pre> <p>I found in source code of <code>java.sql.Connection</code> that this exception is thrown when calling <code>commit()</code> while database is in autocommit mode. But I turn autocommit off before and I can't see any place for some parallel execution related issues as for now application is only turned on once. </p> <p>Do you have any idea how to debug this issue? Maybe there's some other reason for this error (because I just found that exception about database not found or not well configured can be thrown when inserting <code>null</code> into non-null field)?.</p>
0
select records from postgres where timestamp is in certain range
<p>I have arrival column of type timestamp in table reservations ( I'm using postgres ). How would I select all dates within this year for example?</p> <p>I know I could do something like this:</p> <pre><code>select * FROM reservations WHERE extract(year from arrival) = 2012; </code></pre> <p>But I've ran <strong>analyze</strong> and it looks like it require a sequence scan. Is there a better option?</p> <p><strong>P.S. 1 Hmm. both ways seem to require seq. scan. But the one by wildplasser produces results faster - why?</strong></p> <pre><code>cmm=# EXPLAIN ANALYZE select * FROM reservations WHERE extract(year from arrival) = 2010; QUERY PLAN --------------------------------------------------------------------------------------------------------------- Seq Scan on vrreservations (cost=0.00..165.78 rows=14 width=4960) (actual time=0.213..4.509 rows=49 loops=1) Filter: (date_part('year'::text, arrival) = 2010::double precision) Total runtime: 5.615 ms (3 rows) cmm=# EXPLAIN ANALYZE SELECT * from reservations WHERE arrival &gt; '2010-01-01 00:00:00' AND arrival &lt; '2011-01-01 00:00:00'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on reservations (cost=0.00..165.78 rows=51 width=4960) (actual time=0.126..2.491 rows=49 loops=1) Filter: ((arrival &gt; '2010-01-01 00:00:00'::timestamp without time zone) AND (arrival &lt; '2011-01-01 00:00:00'::timestamp without time zone)) Total runtime: 3.144 ms (3 rows) </code></pre> <p>** P.S. 2 - After I have created index on arrival column second way got even faster - since it looks like query uses index. Mkey - I guess I'll stik with this one. **</p> <pre><code> QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- Bitmap Heap Scan on reservations (cost=4.77..101.27 rows=51 width=4960) (actual time=0.359..0.791 rows=49 loops=1) Recheck Cond: ((arrival &gt; '2010-01-01 00:00:00'::timestamp without time zone) AND (arrival &lt; '2011-01-01 00:00:00'::timestamp without time zone)) -&gt; Bitmap Index Scan on arrival_idx (cost=0.00..4.76 rows=51 width=0) (actual time=0.177..0.177 rows=49 loops=1) Index Cond: ((arrival &gt; '2010-01-01 00:00:00'::timestamp without time zone) AND (arrival &lt; '2011-01-01 00:00:00'::timestamp without time zone)) Total runtime: 1.265 ms </code></pre>
0
SqlBulkCopy Insert with Identity Column
<p>I am using the <code>SqlBulkCopy</code> object to insert a couple million generated rows into a database. The only problem is that the table I am inserting to has an identity column. I have tried setting the <code>SqlBulkCopyOptions</code> to <code>SqlBulkCopyOptions.KeepIdentity</code> and setting the identity column to <code>0</code>'s, <code>DbNull.Value</code> and <code>null</code>. None of which have worked. I feel like I am missing something pretty simple, if someone could enlighten me that would be fantastic. Thanks!</p> <p><em>edit</em> To clarify, I do not have the identity values set in the <code>DataTable</code> I am importing. I want them to be generated as part of the import.</p> <p><em>edit 2</em> Here is the code I use to create the base <code>SqlBulkCopy</code> object.</p> <pre><code>SqlBulkCopy sbc = GetBulkCopy(SqlBulkCopyOptions.KeepIdentity); sbc.DestinationTableName = LOOKUP_TABLE; private static SqlBulkCopy GetBulkCopy(SqlBulkCopyOptions options = SqlBulkCopyOptions.Default) { Configuration cfg = WebConfigurationManager.OpenWebConfiguration("/RSWifi"); string connString = cfg.ConnectionStrings.ConnectionStrings["WifiData"].ConnectionString; return new SqlBulkCopy(connString, options); } </code></pre>
0
Synonym for a Sequence in Oracle
<p>I want to create a synonym for a sequence in oracle and fetch <code>currval</code> from it.</p> <p>I created a synonym using this statement.</p> <pre><code>CREATE SYNONYM NUMGEN FOR MY_SEQ; </code></pre> <p>when I fetch the <code>currval</code> or <code>extval</code> from <code>NUMGEN</code> it generate error, synonym doesn't exist.</p> <pre><code>SELECT NUMGEN.currval FROM dual; </code></pre> <p>Can anyone help me to fetch <code>currval</code> from synonym.</p>
0
Open rar files and read csv files using python
<p>I need to write a program which opens some rar files that contain csv files and read them. I know that there are external libraries for this purpose but what is the best way or library to achieve such a task ?</p>
0
Node.js: How to attach to a running process and to debug the server with a console?
<p>I use 'forever' to run my application. I want to attach to the running environment to inspect my application. So what can I do? </p>
0
How to populate a sub-document in mongoose after creating it?
<p>I am adding a comment to an item.comments list. I need to get the comment.created_by user data before I output it in the response. How should I do this?</p> <pre><code> Item.findById(req.param('itemid'), function(err, item){ var comment = item.comments.create({ body: req.body.body , created_by: logged_in_user }); item.comments.push(comment); item.save(function(err, item){ res.json({ status: 'success', message: "You have commented on this item", //how do i populate comment.created_by here??? comment: item.comments.id(comment._id) }); }); //end item.save }); //end item.find </code></pre> <p>I need to populate the comment.created_by field here in my res.json output:</p> <pre><code> comment: item.comments.id(comment._id) </code></pre> <p>comment.created_by is a user reference in my mongoose CommentSchema. It currently is only giving me a user id, I need it populated with all the user data, except for password and salt fields.</p> <p>Here is the schema as people have asked:</p> <pre><code>var CommentSchema = new Schema({ body : { type: String, required: true } , created_by : { type: Schema.ObjectId, ref: 'User', index: true } , created_at : { type: Date } , updated_at : { type: Date } }); var ItemSchema = new Schema({ name : { type: String, required: true, trim: true } , created_by : { type: Schema.ObjectId, ref: 'User', index: true } , comments : [CommentSchema] }); </code></pre>
0
How to rewrite urls of images in vendor CSS files using Grunt
<p>I am trying to move frontend dependencies out of the version control system. A combination of Bower.io and Grunt should be able to do this.</p> <p>A problem however occurs that I am yet unable to solve with bundling multiple vendor libraries. For example assume I have the following directory structure where the <em>components</em> directory is the directory that Bower.io saves the dependencies in:</p> <pre><code>β”œβ”€β”€ assets └── components β”œβ”€β”€ bootstrap β”‚Β Β  β”œβ”€β”€ img β”‚Β Β  β”‚Β Β  └── glyhs.gif β”‚Β Β  └── less β”‚Β Β  └── bootstrap.css └── jquery-ui β”œβ”€β”€ css β”‚Β Β  └── style.css └── images β”œβ”€β”€ next.gif └── prev.gif </code></pre> <p>Now assume I want to bundle both jQuery's <strong>style.css</strong> and Bootstrap' <strong>bootstrap.css</strong>. I will save this bundled file in <strong>assets/bundled.css</strong>. </p> <p>However in this file the references to the original images (../images/next.gif and ../img/glyhs.gif) are incorrect. They will have to be rewritten in order to work (so ../images/next.gif => ../components/jquery-ui/images/next.gif). I believe(d) this rewriting of URLs is something Grunt should be able to do. <strong>But I can not seem to get this to work using the cssmin/less/copy tasks</strong>. For example the following Grunt setup (only moving 1 file) fails to work:</p> <pre><code>module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), less: { options: { compile: false, relativeUrls: true }, bootstrap: { src: 'components/bootstrap/less/bootstrap.less', dest: 'assets/bootstrap.css' } } }); grunt.loadNpmTasks('grunt-contrib-less'); grunt.registerTask('dist-css', ['less']); }; </code></pre> <p>Either:</p> <ul> <li><p>Have I misconfigured Grunt or done something wrong? </p></li> <li><p>Or is the workflow I am describing simply not the right one and should I use another one instead.</p></li> </ul> <p>Thanks!</p>
0
Printing Linked List in C++
<p>My following code print just only first element. In <code>print_list()</code> function, it stops after printing first element. It says after first element, <code>head-&gt;next</code> is <code>0</code>. Shouldn't point towards second element? </p> <p>I want to simply print whole list.</p> <pre><code>#include&lt;iostream&gt; #include&lt;cstdlib&gt; using namespace std; struct node { int x; node *next; }; node* add_element(node*); bool is_empty(node*); void print_list(node*); node* search(node*); int main() { node *head; head=NULL; node* current=head; for(int i=0;i&lt;5;i=i+1) { if (current==NULL) { current=add_element(current); head=current; } else{ current=add_element(current); } } cout&lt;&lt;head-&gt;next&lt;&lt;endl; // DOUBT: head-&gt;next gives NULL value. It should give me pointer to 2nd node print_list(head); } node* add_element(node* current) { node* temp; temp=new node; temp-&gt;next=NULL; cout&lt;&lt;"enter element"&lt;&lt;endl; cin&gt;&gt;temp-&gt;x; current=temp; return current; } bool is_empty(node* temp) { return temp==NULL; } void print_list(node* temp) { if (is_empty(temp)==false) { cout&lt;&lt;"here temp(head)"&lt;&lt;temp-&gt;next&lt;&lt;endl; while(temp!=NULL) { cout&lt;&lt;temp-&gt;x&lt;&lt;endl; temp = temp-&gt;next; } } } </code></pre>
0
BigInteger Conversion from int to BigInteger
<p>I'm having trouble working with BigIntegers. I'm having trouble with the <code>add</code> method in the Rational class. In the <code>Rational(int x, int y)</code> constructor I'm trying to convert the parameters datatype <code>int</code> into the instance variable datatype of <code>BigInteger</code> though the use of the<code>toString(int n)</code> method. <br/></p> <ol> <li>Am I doing the conversion correctly inside the <code>Rational(int x, int y)</code> constructor? </li> <li>They way the <code>add</code> method is written I'm getting an error under all of n.num and n.den. I don't understand why I'm getting that error. Am I not correctly using the <code>add</code> method from the BigInteger class? <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html" rel="nofollow">http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html</a> <br/><br/></li> </ol> <p>Suppose one class has the following</p> <pre><code>Rational a = new Rational(1,2); Rational b = new Rational(1,3); Rational c = new Rational(1,6); Rational sum = a.add(b).add(c); println(sum); </code></pre> <p>and the Rational class includes </p> <pre><code>import acm.program.*; import java.math.*; public class Rational{ public Rational(int x, int y) { num = new BigInteger(toString(x)); den = new BigInteger(toString(y)); } public toString(int n) { return toString(n); } public BigInteger add(BigInteger n) { return new BigInteger(this.num * n.den + n.num * this.den, this.den * n.den) } /* private instance variables */ private BigInteger num; private BigInteger den; } </code></pre>
0
How to convert HTML page to PDF then download it?
<p>This is my web page designed with HTML and CSS:</p> <p><a href="https://i.stack.imgur.com/aPT1a.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/aPT1a.jpg" alt=""></a></p> <p>How can I download the same web page as PDF? I was trying many solutions but I am getting only content on PDF file but not with CSS style.</p> <p>Any solutions?</p>
0
How to find the count of substring in java
<p>I am trying to find the count of the substring in a big string of length 10000 characters. Finally I need to remove all the substring in it. example <code>s = abacacac, substr = ac</code>, <code>num of occurrence = 3</code> and final string is <code>s = ab</code>. My code is below, its not efficient for data of length 10000 characters. </p> <pre><code>int count =0; while(s.contains(substr)) { s= s.replaceFirst(substr,""); count++; } </code></pre>
0
AES Encryption -Key Generation with OpenSSL
<p>As a reference and as continuation to the post: <a href="https://stackoverflow.com/questions/5136279/how-to-use-openssl-to-decrypt-java-aes-encrypted-data">how to use OpenSSL to decrypt Java AES-encrypted data?</a></p> <p>I have the following questions.</p> <p>I am using OpenSSL libs and programming in C for encrypting data in aes-cbc-128. I am given any input binary data and I have to encrypt this.</p> <p>I learn that Java has a CipherParameters interface to set IV and KeyParameters too.</p> <p>Is there a way to generate IV and a key using openSSL? In short how could one use in a C program to call the random generator of openSSL for these purposes. Can any of you provide some docs/examples/links on this?</p> <p>Thanks</p>
0
MySQL load data: This command is not supported in the prepared statement protocol yet
<p>I'm trying to write a MySQL script to import data into a table for my Linux server. Here is the script named <code>update.sql</code>:<br></p> <pre><code>SET @query = CONCAT("LOAD DATA LOCAL INFILE '", @spaceName, "' INTO TABLE tmp FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';"); PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt; </code></pre> <p>And also, I write a bash script named <code>main.sh</code>:<br></p> <pre><code>mysql -h "localhost" -u "root" "-pmypassword" "mydb" -e "set @spaceName=\"$1\";source update.sql;" </code></pre> <p>Then I execute <code>./main.sh France.list</code>. The <code>France.list</code> is the data file that I'm trying to import into my database.<br></p> <p>However I get an error:<br></p> <blockquote> <p>ERROR 1295 (HY000) at line 2 in file: 'update.sql': This command is not supported in the prepared statement protocol yet</p> </blockquote> <p>I've found this question:<br> <a href="https://stackoverflow.com/questions/25380903/mysql-load-data-infile-with-variable-path">MySQL - Load Data Infile with variable path</a></p> <p>So, does it mean that there is no way to pass arguments to <code>LOAD DATA</code> query?</p>
0
How to do import/export a class in Vanilla JavaScript (JS)
<p>I'm using Vanilla JavaScript (JS) and trying to leverage the concept of <code>class</code> and <code>module</code> import/export which came as part of ECMA-2015(ECMA-6) release.</p> <p>Please see the code snippet below:</p> <p><code>rectangle.js</code> file -</p> <pre><code>export default class Rectangle{ constructor(height, width) { this.height = height; this.width = width; } } </code></pre> <p><code>myHifiRectangle.js</code> file -</p> <pre><code>import Rectangle from 'rectangle.js'; class MyHiFiRectangle extends Rectangle { constructor(height, width) { super(height,width); this.foo= &quot;bar&quot;; } } </code></pre> <p>I'm trying to use above *.js files in an HTML web page <code>test.html</code> as shown below:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang = "en"&gt; &lt;head&gt; &lt;meta charset = "UTF-8"&gt; &lt;title&gt;Javascipt by Rasik Bihari Tiwari&lt;/title&gt; &lt;script src="Scripts/rectangle.js"&gt;&lt;/script&gt; &lt;script src="Scripts/myHiFiRectangle.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var v = new MyHiFiRectangle(2,4); console.debug(v.foo); &lt;/script&gt; &lt;/head&gt; &lt;body &gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>Then, I tried browsing <code>test.html</code> file in browser. Result of browsing for of the browsers is as below:</p> <p>On Google Chrome I get below error:</p> <blockquote> <p>Uncaught SyntaxError: Unexpected token export</p> </blockquote> <p>On Mozilla firefox I get below error:</p> <blockquote> <p>SyntaxError: export declarations may only appear at top level of a module</p> <p>SyntaxError: import declarations may only appear at top level of a module</p> <p>ReferenceError: MyHiFiRectangle is not defined[Learn More]</p> </blockquote> <p>I tried reordering the JS files which are referred in the head tag of the HTML file but it makes no difference.</p> <p><strong>P.S.</strong> I'm not using any transpilers like Babel. I'm trying to see the working of native support of <code>class</code> and <code>module</code> export/import construct in JS (ECMA-2015 release aka ECMA-6) and how it works.</p>
0
Datetime strptime in Python pandas : what's wrong?
<pre><code>import datetime as datetime datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S') </code></pre> <p>produces </p> <blockquote> <p>AttributeError Traceback (most recent call last) in () 1 import datetime as datetime ----> 2 datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S') 3 z = minidf['Dates'] 4 z</p> <p>AttributeError: 'module' object has no attribute 'strptime'</p> </blockquote> <p>my goal is to convert a pandas dataframe column whose format is still a data object</p> <pre><code>import datetime as datetime #datetime.strptime('2013-01-01 09:10:12', '%Y-%m-%d %H:%M:%S') z = minidf['Dates'] 0 2015-05-13 23:53:00 1 2015-05-13 23:53:00 2 2015-05-13 23:33:00 3 2015-05-13 23:30:00 4 2015-05-13 23:30:00 5 2015-05-13 23:30:00 6 2015-05-13 23:30:00 7 2015-05-13 23:30:00 8 2015-05-13 23:00:00 9 2015-05-13 23:00:00 10 2015-05-13 22:58:00 Name: Dates, dtype: object </code></pre> <p>the bonus question is, i got this column using <code>pd.read_csv</code> function from a larger file with more columns. Is it possible to pass parameters such that <code>pd.read_csv</code> directly converts this to <code>dtype: datetime64[ns]</code> format</p>
0
C# Checkedlistbox if checked
<p>Is it possible to apply .Checked== to checkedlistbox as in checkbox?</p> <p>If to do it in a way as with checkbox it not works</p> <pre><code>if(checkedListBox1.Items[2].Checked==true) { } </code></pre>
0
Valid characters for Excel sheet names
<p>In Java, we're using the following package to programmatically create excel documents:</p> <pre><code>org.apache.poi.hssf </code></pre> <p>If you attempt to set a sheet's name (NOT file, but internal Excel sheet), you will get an error if:</p> <ul> <li>The name is over 31 characters</li> <li>The name contains any of the following characters: / \ * ? [ ]</li> </ul> <p>However, after creating a document with a sheet name of:</p> <blockquote class="spoiler"> <p>@#$%&amp;()+~`"':;,.|</p> </blockquote> <p>No error is output, and everything seems fine in Java. When you open the excel file in Office 2003, it will give you an error saying that the sheet name was invalid and that it renamed it to something generic like "Sheet 1".</p> <p>I don't know much about the previously stated package that we're using, but it looks like it's not correctly filtering invalid Excel sheet names. Any idea of how I can filter out all known invalid characters? I'm hesitant to simply filter out all non-word characters.</p>
0
jQuery Menu and ASP.NET Sitemap
<p>Is it possible to use an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="noreferrer">ASP.NET</a> web.sitemap with a jQuery <a href="http://users.tpg.com.au/j_birch/plugins/superfish/" rel="noreferrer">Superfish</a> menu? </p> <p>If not, are there any standards based browser agnostic plugins available that work with the web.sitemap file?</p>
0
Devise routing error on Forgot password
<p>When I click on <code>&lt;%= link_to "Forgot your password?", new_password_path(resource_name) %&gt;</code></p> <p>It takes me to</p> <p><a href="http://0.0.0.0:3000/users/password/new">http://0.0.0.0:3000/users/password/new</a></p> <p>with the routing error</p> <pre><code>ActionController::RoutingError in Devise/passwords#new Showing app/views/devise/passwords/new.html.erb where line #3 raised: No route matches {:controller=&gt;"users", :action=&gt;"password", :id=&gt;:user} </code></pre> <p><strong>Edit:</strong></p> <p><strong>new.html.erb Error on this line</strong></p> <pre><code>&lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; password_path(resource_name), :html =&gt; { :method =&gt; :post }) do |f| %&gt; </code></pre> <p><strong>Passwords_controller.rb</strong></p> <pre><code>class Devise::PasswordsController &lt; ApplicationController #prepend_before_filter :require_no_authentication include Devise::Controllers::InternalHelpers access_control do allow all end # GET /resource/password/new def new build_resource({}) render_with_scope :new end # POST /resource/password def create self.resource = resource_class.send_reset_password_instructions(params[resource_name]) if successful_and_sane?(resource) set_flash_message(:notice, :send_instructions) if is_navigational_format? respond_with({}, :location =&gt; after_sending_reset_password_instructions_path_for(resource_name)) else respond_with_navigational(resource){ render_with_scope :new } end end # GET /resource/password/edit?reset_password_token=abcdef def edit self.resource = resource_class.new resource.reset_password_token = params[:reset_password_token] render_with_scope :edit end # PUT /resource/password def update self.resource = resource_class.reset_password_by_token(params[resource_name]) if resource.errors.empty? set_flash_message(:notice, :updated) if is_navigational_format? sign_in(resource_name, resource) respond_with resource, :location =&gt; redirect_location(resource_name, resource) else respond_with_navigational(resource){ render_with_scope :edit } end end protected # The path used after sending reset password instructions def after_sending_reset_password_instructions_path_for(resource_name) new_session_path(resource_name) end end </code></pre>
0
Running a java applet from netbeans?
<p>I am trying to run a Java applet from NetBeans, and in trying to run it, I get a 'main class not found' error. I can avoid this by doing SHIFT+F6, but that'll only work if I am currently writing in the main class. I will be working on a somewhat large project, and it's going to have multiple files, and eventually it will be quite cumbersome to always navigate back to the main class to the 'main' file and run it from there. Is there any sort of configurations I can edit to tell NetBeans that I want to run my project (not the individual file) as an applet? I have NetBeans set up from <a href="http://blogs.oracle.com/pc/entry/how_to_create_applet_with" rel="noreferrer">this tutorial</a>.</p>
0
CSS class and id with the same name
<p>Is there anything wrong with having a css class and id with the same name? Like .footer for the article/post's footer and #footer for the page footer.</p>
0
Ruby File::directory? Issues
<p>I am quite new to ruby but enjoying it so far quite immensely. There are some things that have given me some trouble and the following is no exception.</p> <p>What I am trying to do here is create a sort of 'super-directory' by sub-classing 'Dir'. I've added a method called 'subdirs' that is designed to list the directory object's files and push them into an array if the file is a directory itself. The issue is, the results from my test (File.directory?) is strange - here is my method code:</p> <pre><code> def subdirs subdirs = Array.new self.each do |x| puts "Evaluating file: #{x}" if File.directory?(x) puts "This file (#{x}) was considered a directory by File.directory?" subdirs.push(x) #yield(x) if block_given? end end return subdirs end </code></pre> <p>And strangely, even though there are plenty of directories in the directory I've chosen ("/tmp") - the result of this call only lists "." and ".."</p> <pre><code>puts "Testing new Directory custom class: FileOps/DirClass" nd = Directory.new("/tmp") subs = nd.subdirs </code></pre> <p>And the results:</p> <pre><code>Evaluating file: mapping-root Evaluating file: orbit-jvxml Evaluating file: custom-directory Evaluating file: keyring-9x4JhZ Evaluating file: orbit-root Evaluating file: . This file (.) was considered a directory by File.directory? Evaluating file: .gdmFDB11U Evaluating file: .X0-lock Evaluating file: hsperfdata_mishii Evaluating file: .X11-unix Evaluating file: .gdm_socket Evaluating file: .. This file (..) was considered a directory by File.directory? Evaluating file: .font-unix Evaluating file: .ICE-unix Evaluating file: ssh-eqOnXK2441 Evaluating file: vesystems-package Evaluating file: mapping-jvxml Evaluating file: hsperfdata_tomcat </code></pre>
0
Why doesn't my <script> tag work from php file? (jQuery involved here too)
<p>Here is what I am trying to accomplish. I have a form that uses jQuery to make an AJAX call to a PHP file. The PHP file interacts with a database, and then creates the page content to return as the AJAX response; i.e. this page content is written to a new window in the success function for the <code>$.ajax</code> call. As part of the page content returned by the PHP file, I have a straightforward HTML script tag that has a JavaScript file. Specifically:</p> <pre><code>&lt;script type="text/javascript" src="pageControl.js"&gt;&lt;/script&gt; </code></pre> <p>This is not echoed in the php (although I have tried that), it is just html. The pageControl.js is in the same directory as my php file that generates the content.</p> <p>No matter what I try, I can't seem to get the <code>pageControl.js</code> file included or working in the resulting new window created in response to success in the AJAX call. I end up with errors like "Object expected" or variable not defined, leading me to believe the file is not getting included. If I copy the JavaScript directly into the PHPfile, rather than using the script tag with src, I can get it working.</p> <p>Is there something I am missing here about scope resolution between calling file, php, and the jQuery AJAX? I am going to want to include javascript files this way in the future and would like to understand what I am doing wrong.</p> <hr> <p>Hello again:</p> <p>I have worked away at this issue, and still no luck. I am going to try and clarify what I am doing, and maybe that will bring something to mind. I am including some code as requested to help clarify things a bit.</p> <p>Here is the sequence:</p> <ol> <li>User selects some options, and clicks submit button on form.</li> <li><p>The form button click is handled by jQuery code that looks like this:</p> <pre><code>$(document).ready(function() { $("#runReport").click(function() { var report = $("#report").val(); var program = $("#program").val(); var session = $("#session").val(); var students = $("#students").val(); var dataString = 'report=' +report+ '&amp;program=' +program+ '&amp;session=' +session+ '&amp;students=' +students; $.ajax({ type: "POST", url: "process_report_request.php", cache: false, data: dataString, success: function(pageContent) { if (pageContent) { $("#result_msg").addClass("successMsg") .text("Report created."); var windowFeatures = "width=800,menubar=yes,scrollbars=1,resizable=1,status=yes"; // open a new report window var reportWindow = window.open("", "newReportWindow", windowFeatures); // add the report data itself returned from the AJAX call reportWindow.document.write(pageContent); reportWindow.document.close(); } else { $("#result_msg").addClass("failedMsg") .text("Report creation failed."); } } }); // end ajax call // return false from click function to prevent normal submit handling return false; }); // end click call }); // end ready call </code></pre></li> </ol> <p>This code performs an AJAX call to a PHP file (<code>process_report_request.php</code>) that creates the page content for the new window. This content is taken from a database and HTML. In the PHP file I want to include another javascript file in the head with javascript used in the new window. I am trying to include it as follows</p> <pre><code>&lt;script src="/folder1/folder2/folder3/pageControl.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Changed path folder names to protect the innocent :) </p> <p>The pageControl.js file is actually in the same folder as the jQuery code file and the php file, but I am trying the full path just to be safe. <strong>I am also able to access the js file using the URL in the browser, and I can successfully include it in a static html test page using the script src tag.</strong></p> <p>After the javascript file is included in the php file, I have a call to one of its functions as follows (echo from php):</p> <pre><code> echo '&lt;script type="text/javascript" language="javascript"&gt;writePageControls();&lt;/script&gt;'; </code></pre> <p>So, once the php file sends all the page content back to the AJAX call, then the new window is opened, and the returned content is written to it by the jQuery code above.</p> <p><em>The <code>writePageControls</code> line is where I get the error "Error: Object expected" when I run the page.</em> However, since the JavaScript works fine in both the static HTML page and when included "inline" in the PHP file, it is leading me to think this is a path issue of some kind.</p> <p>Again, no matter what I try, my calls to the functions in the pageControls.js file do not work. <strong><em>If I put the contents of the pageControl.js file in the php file between script tags and change nothing else, it works as expected.</em></strong></p> <p>Based on what some of you have already said, I am wondering if the path resolution to the newly opened window is not correct. But I don't understand why because I am using the full path. Also to confuse matters even more, my linked stylesheet works just fine from the PHP file.</p> <p>Apologies for how long this is, but if anyone has the time to look at this further, I would greatly appreciate it. I am stumped. <strong>I am a novice when it comes to a lot of this</strong>, so if there is just a better way to do this and avoid this problem, I am all ears (or eyes I suppose...)</p>
0
How to compare user input with my database in java
<p>As shown on the title, I have tried so hard to compare the user input with my database and it works with a true input. However, when the input is not exist on my database I don't know what is wrong in my below code, please help.</p> <pre><code>private class da implements ActionListener{ public void actionPerformed(ActionEvent e){ Connection con = null; String url = "jdbc:mysql://localhost:3306/Ψ§Ω„Ω…ΩƒΨͺΨ¨Ψ©"; String unicode = "?useUnicode=yes&amp;characterEncoding=UTF-8"; try{ con = DriverManager.getConnection(url+unicode,"root",""); PreparedStatement upd = con.prepareStatement("SELECT * FROM library WHERE author =?'"); upd.setString(1,name.getText()); ResultSet rs = upd.executeQuery(); while(rs.next()){ String authorname = rs.getString("author"); String bookname = rs.getString("bookname"); String categort = rs.getString("category"); int isbn = Integer.parseInt(rs.getString("ISBN")); String data = "Ψ§Ψ³Ω… الم؀لف: "+authorname+"\n"+"Ψ§Ψ³Ω… Ψ§Ω„ΩƒΨͺΨ§Ψ¨: "+bookname+"\n"+"Ψ§Ω„ΨͺΨ΅Ω†ΩŠΩ: "+categort+"\n"+"ISBN: "+isbn; if(name.getText().equals(authorname)) txt.setText(data); else txt.setText("no matches"); </code></pre>
0
How to get Property Value from MemberExpression without .Compile()?
<p>I'm having issues trying to get the value of an object out of the Expression Tree without using .Compile()</p> <p>The object is quite simple.</p> <pre><code>var userModel = new UserModel { Email = "[email protected]"}; </code></pre> <p>The method giving me issues looks like this.</p> <pre><code>private void VisitMemberAccess(MemberExpression expression, MemberExpression left) { var key = left != null ? left.Member.Name : expression.Member.Name; if (expression.Expression.NodeType.ToString() == "Parameter") { // add the string key _strings.Add(string.Format("[{0}]", key)); } else { // add the string parameter _strings.Add(string.Format("@{0}", key)); // Potential NullReferenceException var val = (expression.Member as FieldInfo).GetValue((expression.Expression as ConstantExpression).Value); // add parameter value Parameters.Add("@" + key, val); } } </code></pre> <p>The tests I'm running are quite simple</p> <pre><code>[Test] // PASS public void ShouldVisitExpressionByGuidObject () { // Setup var id = new Guid( "CCAF57D9-88A4-4DCD-87C7-DB875E0D4E66" ); const string expectedString = "[Id] = @Id"; var expectedParameters = new Dictionary&lt;string, object&gt; { { "@Id", id } }; // Execute var actualExpression = TestExpression&lt;UserModel&gt;( u =&gt; u.Id == id ); var actualParameters = actualExpression.Parameters; var actualString = actualExpression.WhereExpression; // Test Assert.AreEqual( expectedString, actualString ); CollectionAssert.AreEquivalent( expectedParameters, actualParameters ); } </code></pre> <pre><code>[Test] // FAIL [System.NullReferenceException : Object reference not set to an instance of an object.] public void ShouldVisitExpressionByStringObject () { // Setup var expectedUser = new UserModel {Email = "[email protected]"}; const string expectedString = "[Email] = @Email"; var expectedParameters = new Dictionary&lt;string, object&gt; { { "@Email", expectedUser.Email } }; // Execute var actualExpression = TestExpression&lt;UserModel&gt;( u =&gt; u.Email == expectedUser.Email ); var actualParameters = actualExpression.Parameters; var actualString = actualExpression.WhereExpression; // Assert Assert.AreEqual( expectedString, actualString ); CollectionAssert.AreEquivalent( expectedParameters, actualParameters ); } </code></pre> <hr> <p>I should note that changing</p> <pre><code>var val = (expression.Member as FieldInfo).GetValue((expression.Expression as ConstantExpression).Value); </code></pre> <p>to</p> <pre><code>var val = Expression.Lambda( expression ).Compile().DynamicInvoke().ToString(); </code></pre> <p>will allow the test to pass, however this code needs to run on iOS, and therefore can't use <code>.Compile()</code></p>
0
What is session invalidation?
<p>Session invalidation means session destroying.So if session is destroyed,it indicates that server cant identify the client which has visited in previous.So now it creates a new session id for that client.</p> <p>Is this right?If wrong tell me the correct procedure.</p>
0
Mapping a SQL View with no Primary Key to JPA Entity
<p>In my Java App I want to get information that is stored in my Oracle Database, using JPA. In my Database I have a View, with a set of columns that I got from some other tables. I want to map that View. However, my <strong>View doesn't have a Primary Key</strong>, so I can't create a JPA Entity. I thought about <strong>use 2 columns as Foreign Keys</strong>.</p> <p>What's the best way of implementing that? I've seen so many different approaches, that I can't decide which is the best for this case.</p>
0
how to dynamically add swt widgets to a composite?
<p>I'm trying to add widgets like text boxes, buttons to a composite on click of a button. I've tried , but i could only add these widgets dynamically only up to the size of the composite. My jface dialog is such that, it has a scrolled composite in which it holds a composite. In the main composite i have 3 other composites where i have to achieve this functionality, so if i add dynamic widgets to a composite it might expand, but it should not overlap existing composites down to it, rather it should adjust other composites accordingly and also i should be able to dispose those widgets on a button click. Did any one try this dynamic addition and removal of widgets before, I'm new to swt, jface . So, could any one share their experience here, I'm posting the code i've tried.</p> <pre><code>import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class DynamicDialog extends Dialog { private Text text; private Text text_1; private Composite composite; /** * Create the dialog. * @param parentShell */ public DynamicDialog(Shell parentShell) { super(parentShell); } /** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new FillLayout(SWT.HORIZONTAL)); ScrolledComposite scrolledComposite = new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); composite = new Composite(scrolledComposite, SWT.NONE); composite.setLayout(new FormLayout()); scrolledComposite.setContent(composite); scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); final Composite composite_1 = new Composite(composite, SWT.NONE); composite_1.setLayout(new GridLayout(4, false)); final FormData fd_composite_1 = new FormData(); fd_composite_1.top = new FormAttachment(0); fd_composite_1.left = new FormAttachment(0, 10); fd_composite_1.bottom = new FormAttachment(0, 85); fd_composite_1.right = new FormAttachment(0, 430); composite_1.setLayoutData(fd_composite_1); Label label = new Label(composite_1, SWT.NONE); label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); label.setText("1"); text_1 = new Text(composite_1, SWT.BORDER); text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); text = new Text(composite_1, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnDelete = new Button(composite_1, SWT.NONE); btnDelete.setText("delete"); final Composite composite_2 = new Composite(composite, SWT.NONE); composite_2.setLayout(new GridLayout(2, false)); final FormData fd_composite_2 = new FormData(); fd_composite_2.bottom = new FormAttachment(100, -91); fd_composite_2.top = new FormAttachment(0, 91); fd_composite_2.right = new FormAttachment(100, -10); fd_composite_2.left = new FormAttachment(100, -74); composite_2.setLayoutData(fd_composite_2); new Label(composite_2, SWT.NONE); Button btnAdd = new Button(composite_2, SWT.NONE); btnAdd.setText("ADD"); btnAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Label label2 = new Label(composite_1, SWT.NONE); label2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); label2.setText("1"); Text text_12 = new Text(composite_1, SWT.BORDER); text_12.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Text text13 = new Text(composite_1, SWT.BORDER); text13.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnDelete = new Button(composite_1, SWT.NONE); btnDelete.setText("delete"); //Point p0 = composite_1.getSize(); //composite_1.setSize(SWT.DEFAULT,SWT.DEFAULT); composite_1.layout(); //Point p = composite.getSize(); //composite.setSize(SWT.DEFAULT,SWT.DEFAULT); //composite.setSize(p); // composite.layout(); } }); return container; } /** * Create contents of the button bar. * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } /** * Return the initial size of the dialog. */ @Override protected Point getInitialSize() { return new Point(450, 300); } public static void main(String[] args){ Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); DynamicDialog dd = new DynamicDialog(shell); dd.open(); } } </code></pre>
0
preg_replace http with https
<p>Put simply, I need to check if the string in the variable $url is a simple http, if so, replace it with https - but I can't get it to work - any ideas:</p> <pre><code>$url="http://www.google.com"; // example http url ## $url_replaced = preg_replace( '#^http://#','https://', $url ); // replace http with https ## </code></pre> <p>Cheers!</p>
0
FancyBox 'Uncaught TypeError: Cannot call method 'hide' of undefined'
<p>I've been screwing around with fancybox. I work in the CakePHP Framework and I made an admin panel. This panel has a few options which I load via AJAX into an Div over the page itself.</p> <p>Now when I put an image in this div and try to use Fancybox I get this error when I click on a image (to enlarge it):</p> <pre><code>Uncaught TypeError: Cannot call method 'hide' of undefined N I b.fn.fancybox f.event.dispatch f.event.add.h.handle.i </code></pre> <p>Now this is my ajax loader (functions.js) </p> <pre><code>$(".cmsPage").click(function() { var url = $(this).attr("href"); $.ajax({ url: url, success: function(data){ $("#admin_wrapper").fadeIn('slow'); $("#admin_content").fadeIn('slow'); $("#admin_close").fadeIn('slow'); $("#admin_content").html(data); } }); return false; }); </code></pre> <p>admin_content is where the images are displayed:</p> <pre><code>#admin_content{ display:none; position:absolute; z-index:10; background-color:#fff; opacity:1; width:1000px; min-height:500px; top:1%; color:black; padding:10px; margin:10px; border:solid black 1px; border-radius:5px; } </code></pre> <p>But if I go to the page itself (without using ajax) it works perfectly fine.</p> <p>Is there something that overrules fancybox? The error is not that clear to me. I tried everything <a href="http://groups.google.com/group/fancybox/tree/browse_frm/month/2010-08/c43fd9a7b7ff8774?rnum=141&amp;_done=%2Fgroup%2Ffancybox%2Fbrowse_frm%2Fmonth%2F2010-08%3Ffwc%3D1%26" rel="nofollow noreferrer">in here</a> But I am not using wordpress.</p>
0
GCC: why constant variables not placed in .rodata
<p>I've always believed that GCC would place a <code>static const</code> variable to <code>.rodata</code> segments (or to <code>.text</code> segments for optimizations) of an ELF or such file. But it seems not that case.</p> <p>I'm currently using <code>gcc (GCC) 4.7.0 20120505 (prerelease)</code> on a laptop with GNU/Linux. And it does place a static constant variable to <code>.bss</code> segment:</p> <pre><code>/* * this is a.c, and in its generated asm file a.s, the following line gives: * .comm a,4,4 * which would place variable a in .bss but not .rodata(or .text) */ static const int a; int main() { int *p = (int*)&amp;a; *p = 0; /* since a is in .data, write access to that region */ /* won't trigger an exception */ return 0; } </code></pre> <p>So, is this a bug or a feature? I've decided to file this as a bug to bugzilla but it might be better to ask for help first.</p> <p>Are there any reasons that GCC can't place a const variable in <code>.rodata</code>?</p> <p><strong>UPDATED:</strong></p> <p>As tested, a constant variable with an explicit initialization(like <code>const int a = 0;</code>) would be placed into <code>.rodata</code> by GCC, while I left the variable uninitialized. Thus this question might be closed later -- I didn't present a correct question maybe.</p> <p>Also, in my previous words I wrote that the variable a is placed in '.data' section, which is incorrect. It's actually placed into <code>.bss</code> section since not initialized. Text above now is corrected.</p>
0
_M_ construct null not valid error when trying to implement multi threaded queue
<p>I am trying to implement a priority queue using using a simple linear approach as explained in <a href="https://rads.stackoverflow.com/amzn/click/com/B008CYT5TS" rel="nofollow noreferrer" rel="nofollow noreferrer">Art of Multiprocessor programming</a>. I'm new to c++ and have difficulty troubleshooting.</p> <p>I've implemented two template classes and am testing them using a simple test method. As I'm not able to pin point the error, I'm pasting all the three classes below for reference.</p> <p>I know that <code>_M_ construct null not valid</code> comes when trying to construct a string using <code>nullptr</code>, but am not sure where I'm doing that.</p> <p>The three classes created are given below:</p> <h1>bin.h</h1> <pre><code>#include &lt;mutex&gt; #include &lt;deque&gt; #include &lt;memory&gt; #include &lt;iostream&gt; using namespace std; namespace priority { template&lt;typename T&gt; class Bin { private: std::deque&lt;T&gt; v; std::mutex m; public: Bin() { } Bin(const Bin &amp;o) { } const Bin &amp;operator=(const Bin &amp;other) { return *this; } void put(T item) { std::lock_guard&lt;std::mutex&gt; lock(m); v.push_back(item); } T *get() { std::lock_guard&lt;std::mutex&gt; lock(m); if (v.size() == 0) { return nullptr; } else { T val = v.front(); T *ptr_val = &amp;(val); v.pop_front(); return ptr_val; } } bool isEmpty() { std::lock_guard&lt;std::mutex&gt; lock(m); return v.size() == 0; } }; } </code></pre> <h1>SimpleLinear.h</h1> <pre><code>#include &lt;mutex&gt; #include &lt;vector&gt; #include &lt;memory&gt; #include &quot;Bin.h&quot; namespace priority { template&lt;typename T&gt; class SimpleLinear { private: int range; std::vector&lt;Bin&lt;T&gt;&gt; pqueue; public: SimpleLinear(int range){ this-&gt;range = range; for (int i = 0; i &lt; range; i++) { pqueue.push_back(Bin&lt;T&gt;()); } } void add(T item, int key) { pqueue[key].put(item); } T removeMin() { for (int i = 0; i &lt; range; i++) { T *item = pqueue[i].get(); if (item != nullptr) { return *item; } } return nullptr; } }; } </code></pre> <h1>test.cpp</h1> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;thread&gt; #include &lt;algorithm&gt; #include &quot;SimpleLinear.h&quot; using namespace std; using namespace priority; void te(SimpleLinear&lt;string&gt; s, int thread_id) { s.add(&quot;sundar&quot;+to_string(thread_id), thread_id); s.add(&quot;akshaya&quot;+to_string(thread_id), 3); s.add(&quot;anirudh&quot;+to_string(thread_id), 1); s.add(&quot;aaditya&quot;+to_string(thread_id), 5); cout &lt;&lt; s.removeMin() &lt;&lt; endl; cout &lt;&lt; s.removeMin() &lt;&lt; endl; cout &lt;&lt; s.removeMin() &lt;&lt; endl; } int main(int argc, char const *argv[]) { SimpleLinear&lt;string&gt; s(100); std::vector&lt;std::thread&gt; v; for (int i = 0; i &lt; 100; i++) { // if (i % 2 == 0) v.push_back(thread(te, std::ref(s), i)); // else // v.push_back(thread(t, std::ref(s), i)); } for_each(v.begin(), v.end(), std::mem_fn(&amp;std::thread::join)); return 0; } </code></pre> <p>I'm getting the error:</p> <pre><code>terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid terminate called recursively terminate called recursively terminate called recursively Aborted (core dumped) </code></pre>
0
Yii2 REST query
<p>Hy. I have a ProductController which extends the yii\rest\ActiveController. Question is that how can i make querys via HTTP GET request.</p> <p>Like: <a href="http://api.test.loc/v1/products/search?name=iphone" rel="noreferrer">http://api.test.loc/v1/products/search?name=iphone</a></p> <p>And the return object will contains all products with name iphone.</p>
0
Downloading Xcode with wget or curl
<p>I am trying to download Xcode from the Apple Developer site using just wget or curl. I think I am successfully storing the cookie I need to download the .dmg file, but I am not completely sure.</p> <p>When I run this command:</p> <pre><code>wget \ --post-data="theAccountName=USERNAME&amp;theAccountPW=PASSWORD" \ --cookies=on \ --keep-session-cookies \ --save-cookies=cookies.txt \ -O - \ https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg &gt; /dev/null </code></pre> <p>A file called <code>cookies.txt</code> is created and contains something like this:</p> <pre><code>developer.apple.com FALSE / FALSE 0 XXXXXXXXXXXXXXXX XXXXXXXXXXXX developer.apple.com FALSE / FALSE 0 developer.sessionToken </code></pre> <p>I'm not completely certain, but I think there should be more to it than that (specifically, an alphanumeric string after <code>sessionToken</code>).</p> <p>When I try to do the same thing with curl using this:</p> <pre><code>curl \ -d "theAccountName=USERNAME&amp;theAccountPW=PASSWORD" \ -c xcode-cookie \ -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" \ https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg </code></pre> <p>I get a file called <code>xcode-cookie</code> that contains the same information as the <code>cookies.txt</code> file wget gives me, except that the lines are reversed.</p> <p>I then tried to download the .dmg file.</p> <p>Using wget:</p> <pre><code>wget \ --cookies=on \ --load-cookies=cookies.txt \ --keep-session-cookies \ http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg </code></pre> <p>This gives me a file called <code>login?appIdKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&amp;path=%2F%2Fios%2Fdownload.action?path=%2Fios%2Fios_sdk_4.1__final%2Fxcode_3.2.4_and_ios_sdk_4.1.dmg </code>, which is just an HTML page containing the login form for the developer site.</p> <p>Using curl:</p> <pre><code>curl \ -b xcode-cookie \ -c xcode-cookie \ -O -v \ -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" \ https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg </code></pre> <p>Which prints basically the same thing as wget (minus the HTML).</p> <p>I want to say it has to do with the sessionToken not being in the cookie, but like I said before I am not sure. I even tried exporting the cookies from my browser and following the instructions in the blog post I linked below and several other sites I found while searching for help.</p> <p>I must be doing something wrong, unless Apple has changed something since Oct. 10 <a href="http://greendesignhq.com/blog/2010/10/downloading-xcode-builds-with-wget-or-curl/" rel="noreferrer">because this guy seems to be to do something right</a>.</p> <p>Thanks in advance!</p>
0
T-SQL round to decimal places
<p>How do I round the result of matchpercent to two decimal places (%)? I'm using the following to return some results:</p> <pre><code>DECLARE @topRank int set @topRank=(SELECT MAX(RANK) FROM FREETEXTTABLE(titles, notes, 'recipe cuisine', 1)) SELECT ftt.RANK, (CAST(ftt.RANK as DECIMAL)/@topRank) as matchpercent, --Round this titles.title_id, titles.title FROM Titles INNER JOIN FREETEXTTABLE(titles, notes, 'recipe cuisine') as ftt ON ftt.[KEY]=titles.title_id ORDER BY ftt.RANK DESC </code></pre>
0
No log4j2 configuration file found. Using default configuration: logging only errors to the console
<pre><code>$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar </code></pre> <p>Written to the console, you get</p> <pre><code>ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. </code></pre> <p>But, it also looks like the configuration file has been found and was not parsable:</p> <pre><code> log4j:WARN Continuable parsing error 2 and column 31 log4j:WARN Document root element "Configuration", must match DOCTYPE root "null". log4j:WARN Continuable parsing error 2 and column 31 log4j:WARN Document is invalid: no grammar found. log4j:ERROR DOM element is - not a &lt;log4j:configuration&gt; element. log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. </code></pre>
0
How to sort alphabetically rows of a data frame?
<p>I am tring to sort <code>c</code> alphabetically <code>if x[i]== x[i+1]</code>. I used <code>order()</code> function but it changes the <code>x</code> column as well. I want to order the entire row:</p> <pre><code> best &lt;- function(state){ HospitalName&lt;-vector() StateName&lt;-vector() HeartAttack&lt;-vector() k&lt;-1 outcome&lt;-read.csv("outcome-of-care-measures.csv",colClasses= "character") temp&lt;-(outcome[,c(2,7,11,17,23)]) for (i in 1:nrow(temp)){ if(identical(state,temp[i,2])==TRUE){ HospitalName[k]&lt;-temp[i,1] StateName[k]&lt;-temp[i,2] HeartAttack[k]&lt;-as.numeric(temp[i,4]) k&lt;-k+1 }} frame&lt;-data.frame(cbind(HospitalName,StateName,HeartAttack)) library(dplyr) frame %&gt;% group_by(as.numeric(as.character(frame[,3]))) %&gt;% arrange(frame[,1]) } Output: HospitalName StateName HeartAttack 1 FORT DUNCAN MEDICAL CENTER TX 8.1 2 TOMBALL REGIONAL MEDICAL CENTER TX 8.5 3 CYPRESS FAIRBANKS MEDICAL CENTER TX 8.7 4 DETAR HOSPITAL NAVARRO TX 8.7 5 METHODIST HOSPITAL,THE TX 8.8 6 MISSION REGIONAL MEDICAL CENTER TX 8.8 7 BAYLOR ALL SAINTS MEDICAL CENTER AT FW TX 8.9 8 SCOTT &amp; WHITE HOSPITAL-ROUND ROCK TX 8.9 9 THE HEART HOSPITAL BAYLOR PLANO TX 9 10 UT SOUTHWESTERN UNIVERSITY HOSPITAL TX 9 .. ... ... ... Variables not shown: as.numeric(as.character(frame[, 3])) (dbl) </code></pre> <p>Output does not contain the HeartAttack Column and I do not understand why?</p>
0
Bootstrap 3 full width div's in container-fluid
<p>I'm trying to create some "horizontal bands" in a Bootstrap 3 CSS layout, extending to the whole size of the browser's window, and thus outside of the content class margins. Here is a Plunker: <a href="http://plnkr.co/edit/6SlNU0ZgFehrBD64r9FG" rel="nofollow">http://plnkr.co/edit/6SlNU0ZgFehrBD64r9FG</a> . I found that I can accomplish this by using a <code>container-fluid</code> class: this implies having a div with that class including other div's, some representing my "bands", and others just using the <code>container</code> class. Thus, my relevant CSS is:</p> <pre><code>div.band { width: 100% !important; background-color: #D7EAD8; color: #323F3F; } </code></pre> <p>and my HTML:</p> <pre><code>&lt;div class="container-fluid"&gt; &lt;div class="row band"&gt;Hello band&lt;/div&gt; &lt;div class="container"&gt; &lt;div class="row"&gt;...&lt;/div&gt; &lt;/div&gt; &lt;div class="row band"&gt;Another band&lt;/div&gt; &lt;div class="container"&gt; &lt;div class="row"&gt;...&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Yet, this does not fully work as I keep getting some white margin at the right edge of the "band" div. I don't know Bootstrap internals and surely I'm doing something wrong, could anyone suggest a solution to make the "band" full-width?</p>
0
React Material UI Multiple Collapse
<p>Currently my list all have collapses but they are linked to one state for "open" so if I open one list, all the other lists open. What is the best way to keep the collapses separate from each other without having a lot of states for each list.</p> <p>EDIT: The app is going through an infinite loop</p> <p><strong>App.tsx</strong></p> <pre><code>interface IState { error: any, intro: any, threads: any[], title: any, } export default class App extends React.Component&lt;{}, IState&gt; { constructor (props : any) { super (props); this.state = { error: "", intro: "Welcome to RedQuick", threads: [], title: "" }; this.getRedditPost = this.getRedditPost.bind(this) this.handleClick = this.handleClick.bind(this) } public getRedditPost = async (e : any) =&gt; { e.preventDefault(); const subreddit = e.target.elements.subreddit.value; const redditAPI = await fetch('https://www.reddit.com/r/'+ subreddit +'.json'); const data = await redditAPI.json(); console.log(data); if (data.kind) { this.setState({ error: undefined, intro: undefined, threads: data.data.children, title: data.data.children[0].data.subreddit.toUpperCase() }); } else { this.setState({ error: "Please enter a valid subreddit name", intro: undefined, threads: [], title: undefined }); } } public handleClick = (index : any) =&gt; { this.setState({ [index]: true }); } public render() { return ( &lt;div&gt; &lt;Header getRedditPost={this.getRedditPost} /&gt; &lt;p className="app__intro"&gt;{this.state.intro}&lt;/p&gt; { this.state.error === "" &amp;&amp; this.state.title.length &gt; 0 ? &lt;LinearProgress /&gt;: &lt;ThreadList error={this.state.error} handleClick={this.handleClick} threads={this.state.threads} title={this.state.title} /&gt; } &lt;/div&gt; ); } } </code></pre> <p><strong>Threadlist.tsx</strong></p> <pre><code>&lt;div className="threadlist__subreddit_threadlist"&gt; &lt;List&gt; { props.threads.map((thread : any, index : any) =&gt; &lt;div key={index} className="threadlist__subreddit_thread"&gt; &lt;Divider /&gt; &lt;ListItem button={true} onClick={props.handleClick(index)}/* component="a" href={thread.data.url}*/ &gt; &lt;ListItemText primary={thread.data.title} secondary={&lt;p&gt;&lt;b&gt;Author: &lt;/b&gt;{thread.data.author}&lt;/p&gt;} /&gt; {props[index] ? &lt;ExpandLess /&gt; : &lt;ExpandMore /&gt;} &lt;/ListItem&gt; &lt;Collapse in={props[index]} timeout="auto" unmountOnExit={true}&gt; &lt;p&gt;POOP&lt;/p&gt; &lt;/Collapse&gt; &lt;Divider /&gt; &lt;/div&gt; ) } &lt;/List&gt; &lt;/div&gt; </code></pre>
0
'txtName' is not declared. It may be inaccessible due to its protection level
<p>After putting a textbox on my page when I compile it I get the above error:</p> <p>'txtName' is not declared. It may be inaccessible due to its protection level.</p> <p>This is happening when I try to read the value of the textbox in the codebehind page.</p> <p>I'm not sure what's causing this...any ideas?</p> <p>In the aspx file I have:</p> <pre><code>&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="signup.aspx.vb" Inherits="signup" %&gt; </code></pre> <p>In the codebehind aspx.vb file I have:</p> <pre><code>Imports System.Data.SqlClient Partial Class signup Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click </code></pre>
0
Validate in merge function pandas
<p>Today I was trying to go a little deeper in the <code>merge()</code> function of pandas, and I found the option <code>validate</code>, which, as reported in the documentation, can be:</p> <blockquote> <p>validate : string, default None</p> <p>If specified, checks if merge is of specified type.</p> <p>β€œone_to_one” or β€œ1:1”: check if merge keys are unique in both left and right datasets. β€œone_to_many” or β€œ1:m”: check if merge keys are unique in left dataset. β€œmany_to_one” or β€œm:1”: check if merge keys are unique in right dataset. &quot;many_to_many” or β€œm:m”: allowed, but does not result in checks.</p> </blockquote> <p>I have looked around to find a working example on where and how to use this function, but I couldn't find any. Moreover when I tried to apply it to a group of <code>DataFrame</code>'s I was merging, it didn't seem to change the output. Can anyone give me a working example, to make me understand it better?</p> <p>Thanks in advance,</p> <p>Mattia</p>
0
Tomcat starts without errors but not listening on 8080
<p>I am running tomcat 6 on Centos 6.4 and have started it sucessfully. There were no errors on start. catalina.log reads:</p> <pre><code>2012-08-11 14:23:42,941 | INFO | main | o.a.c.http11.Http11NioProtocol | Starting Coyote HTTP/1.1 on http-xx.xx.xx.xx-8080 2012-08-11 14:23:42,960 | INFO | main | o.a.catalina.startup.Catalina | Server startup in 121483 ms </code></pre> <p>And <code>ps -x</code> shows it as running. </p> <p>Unfortunately it is not responding on port 8080 however and <code>netstat -atnp | grep LISTEN</code> does not list it.</p> <p>Any ideas of what could cause this?</p>
0
Preview layout with merge root tag in Intellij IDEA/Android Studio
<p>Let's imagine we are developing compound component based on LinearLayout. So, we create class like this:</p> <pre><code>public class SomeView extends LinearLayout { public SomeView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); View.inflate(context, R.layout.somelayout, this); } } </code></pre> <p>If we'll use <code>LinearLayout</code> as a root of <code>somelayout.xml</code>, we'll have extra view level, so we use merge tag:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Some text" android:textSize="20sp"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Some other text"/&gt; &lt;/merge&gt; </code></pre> <p>But in Preview tab in IDE merge always acts as FrameLayout, and we'll see something like that: <img src="https://i.stack.imgur.com/V9wpb.png" alt="Preview with merge"></p> <p>(It is Android Studio, Intellij IDEA is just the same, about Eclipse I don't know)</p> <p>Preview speed up developing layouts a lot, it's sad lose such a great help even for some layouts. May be there is a way to specify, how Preview should interpret <code>merge</code> tag in particular layout?</p>
0
Global variable on servlet. is global for all sessions, or only for the current session?
<p>I need to share information while the applicaiton is running; if I have:</p> <pre><code>public class example extends HttpServlet { Object globalObject; doGet... doPost.... } </code></pre> <p>A user is using the aplication through server and the object globalObject; if another user use the application, will share the object with the first user? </p>
0
how do i animate a specific height to 100% in jquery
<p>i want to have a little "preview" of the content in the div, so i made it so small that only only the first line is shown. now i want to animate it that when you click the title, the div will have the height of 100%, but when i use animate(height:"100%") there is no nice sliding.</p> <pre><code>&lt;a href="javascript:void(0);" class="show_it"&gt;title:&lt;/a&gt; &lt;div&gt; content&lt;br&gt; content_hidden &lt;/div&gt; &lt;script&gt; $('.show_it').click(function() { $(this).next("div").animate({ height: 'auto' }, 1000, function() { }); }); &lt;/script&gt; &lt;style&gt; div{ height:20px; overflow:hidden; } &lt;/style&gt; </code></pre>
0
How can I install Perl on Windows 8?
<p>I want to use Perl for web development. I have tried to find out how to install it but when I tried to get ActivePerl it wouldn't install on Windows 8. Can anyone tell me how to install Perl on Windows 8? I can go for ActivePerl, Strawberry Perl, or any other Perl release as long as it will work on Windows 8.</p>
0
Getting an object from a dictionary of objects
<p>I'm trying to pull an object from a dictionary of objects, and return said object however I'm having a bit of a problem with types. The class in question looks something like this, I'm wondering how I go about returning the actual object rather than the variable (which I assume is a string by default).</p> <pre><code> public Object GetObject(string foo){ if(someDict.ContainsKey(foo)) { var pulledObject = someDict[foo]; } return pulledObject; } </code></pre> <p>I had thought boxing was needed, something like</p> <pre><code> object pulledObject = someDict[foo]; </code></pre> <p>But that doesn't seem to work, any advice that could point me in the right direction.</p>
0
Swift equivalent of Java toString()
<p>What is the Swift equivalent of Java <code>toString()</code> to print the state of a class instance?</p>
0
Why doesn't this coffee-script print out?
<p>So when the index is 0, I want to print it out:</p> <pre><code>a = [ 1, 2, 3 ] for i of a if i == 0 console.log a[i] </code></pre> <p>But there is no output.</p> <p><code>i == 0</code> is never true...</p>
0
VBS Creating CSV file then adding extra rows to it
<p>Below is my VBS code. I will admit, I am extremely new to this since I was give this as a job at work. I need to create a logon/logoff script that will capture certain information and store it in a csv file. I am able to get the information and store it in the csv file, but when I try to do it again, I want it to create another row and store the updated information there. I keep getting these asian characters. What seems to be the problem. </p> <p>This is what I get on the second time I click my log off script: ਍潙牡琠η‘₯⁴潧η₯ζ  η‰₯βΉ₯਍</p> <pre><code>' ******************** Log Off Script ********************************** 'Script to write Logoff Data Username, Computername to eventlog. Dim objShell, WshNetwork, PCName, UserName, strMessage, strContents, logDate, logTime Dim strQuery, objWMIService, colItems, strIP, rowCount ' Constants for type of event log entry const EVENTLOG_AUDIT_SUCCESS = 8 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") logDate = Date() logTime = Time() PCName = WshNetwork.ComputerName UserName = WshNetwork.UserName strMessage = "Logoff Event Data" &amp; "PC Name: " &amp; PCName &amp; "Username: " &amp; UserName &amp; "Date: " &amp; logDate &amp; "Time: " &amp; logTime If (objFSO.FileExists("test.csv")) Then WScript.Echo("File exists!") dim filesys, filetxt Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set filesys = CreateObject("Scripting.FileSystemObject") Set filetxt = filesys.OpenTextFile("test.csv", ForAppending, True) filetxt.WriteLine(vbNewline &amp; "Your text goes here.") filetxt.Close Else rowCount = rowCount + 1 WScript.Echo("File does not exist! File Created!") Set csvFile = objFSO.CreateTextFile("test.csv", _ ForWriting, True) objShell.LogEvent EVENTLOG_AUDIT_SUCCESS, strMessage csvFile.Write strMessage csvFile.Writeline End If WScript.Quit </code></pre>
0
session_start(): Session data file is not created by your uid
<p>I want to store the created sessions in a directory above the root, except when I use any of the following:</p> <pre><code> session_save_path($_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions'); session_save_path($_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions/'); // With an extra slash at the end ini_set('session.save_path', $_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions'); ini_set('session.save_path', $_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions/'); // Again with the extra slash </code></pre> <p>and not one of these methods work, whenever I load the page I get the following errors:</p> <blockquote> <p>Warning: session_start(): Session data file is not created by your uid in /var/www/bootstrap/bootstrap.php on line 25</p> <p>Warning: session_start(): Failed to read session data: files (path: /var/www/public/../storage/sessions/) in /var/www/bootstrap/bootstrap.php on line 25</p> </blockquote> <p>Can anyone help me?</p> <p><strong>Edit:</strong> My server runs on PHP 7.1</p>
0
C# "as" cast vs classic cast
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr">Casting vs using the β€˜as’ keyword in the CLR</a> </p> </blockquote> <p>I recently learned about a different way to cast. Rather than using</p> <pre><code>SomeClass someObject = (SomeClass) obj; </code></pre> <p>one can use this syntax:</p> <pre><code>SomeClass someObject = obj as SomeClass; </code></pre> <p>which seems to return null if obj isn't a SomeClass, rather than throwing a class cast exception.</p> <p>I see that this can lead to a NullReferenceException if the cast failed and I try to access the someObject variable. So I'm wondering what's the rationale behind this method? Why should one use this way of casting rather than the (old) one - it only seems to move the problem of a failed cast "deeper" into the code.</p>
0
Visual C++ template syntax errors
<p>I have a header file...</p> <pre><code>#include &lt;SFML\Graphics.hpp&gt; #include &lt;SFML\Graphics\Drawable.hpp&gt; #include &lt;SFML\System.hpp&gt; #include &lt;iostream&gt; #ifndef _SPRITE_H_ #define _SPRITE_H_ namespace Engine { template &lt;class T&gt; class Sprite { sf::Vector2&lt;T&gt; * vector; sf::Sprite * sprite; public: Sprite(sf::Vector2&lt;T&gt; vect, sf::Sprite spr) { this-&gt;sprite = spr; this-&gt;vector = vect; } ~Sprite(); bool Draw(T x, T y, T rotate = 0); sf::Image GetImage() { return this-&gt;sprite-&gt;GetImage(); } }; }; #endif _SPRITE_H_ </code></pre> <p>And a source file...</p> <pre><code>#include &lt;SFML/Graphics.hpp&gt; #include &lt;SFML/Config.hpp&gt; #include "sprite.h" template &lt;typename T&gt; Sprite(sf::Vector2&lt;T&gt; vector, sf::Sprite sprite) { this-&gt;sprite = sprite; this-&gt;vector = vector; } template &lt;typename T&gt; bool Draw(T x, T y, T rotate) { return false; } </code></pre> <p>In VS 2010, when I compile VC++ I get the following errors:</p> <pre><code>Error 2 error C2143: syntax error : missing ';' before '&lt;' c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 7 1 Engine2 Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 7 1 Engine2 Error 4 error C2988: unrecognizable template declaration/definition c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 7 1 Engine2 Error 5 error C2059: syntax error : '&lt;' c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 7 1 Engine2 Error 6 error C2059: syntax error : ')' c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 7 1 Engine2 Error 7 error C2143: syntax error : missing ';' before '{' c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 15 1 Engine2 Error 8 error C2447: '{' : missing function header (old-style formal list?) c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 15 1 Engine2 </code></pre> <p>I am a total noob to C++ (coming from C#), and have been having issues compiling this simple file as a means to at least learn the syntax before I continue on. As you can see, all I'm trying to do is reference a template from a header file to a source file, so that template reference effects all of my methods.</p> <p>What am I doing wrong? I've tried to understand these compiler messages, but I'm having trouble decrypting them.</p> <p><strong>Update</strong></p> <p>Followed suggestion: took care of almost everything, except for this:</p> <pre><code>Error 1 error C2995: 'Engine::Sprite&lt;T&gt;::Sprite(sf::Vector2&lt;T&gt;,sf::Sprite)' : function template has already been defined c:\users\owner\documents\visual studio 2010\projects\engine2\engine2\sprite.cpp 12 1 Engine2 </code></pre>
0
How to execute a stored procedure using OCI8 in PHP
<p>Can someone help me on how to call the stored procedure in oracle by php? I have the sample of stored procedure</p> <pre><code>CREATE OR REPLACE PROCEDURE view_institution( c_dbuser OUT SYS_REFCURSOR) IS BEGIN OPEN c_dbuser FOR SELECT * FROM institution; END; </code></pre> <p>the above stored procedure named view_instituion used to display all record on table institution. Can someone teach me to call the above stored procedure in php. Im new on playing with stored procedure</p> <p>thanks</p>
0
What are the best blogs for staying up to date on C#, ASP.NET, LINQ, SQL, C++, Ruby, Java, Python?
<p>Apologies if this repeats another - but I couldn't fine one like it.</p> <p>My day to day programming spans a fair number of technologies: C#, ASP.NET, LINQ / SQL, C++, Ruby, Java, Python in approximately that order.</p> <p>It's a struggle to keep up to date on any of best practices, new ideas, innovation and improvements, let alone all.</p> <p>Therefore, what would your top 1 blog be in each of these technologies and which technology do you find easiest to stay up to date with? I'd have a bias towards blogs with broad and high level rather than narrow and detailed content / solutions / examples.</p>
0
How to set MySQL to use GMT in Windows and Linux
<p>I'm just trying to get MySQL to store time in GMT...</p> <p>I've read the documentation here: <a href="http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html</a></p> <p>It says to set: default-time-zone='timezone' in an option file.</p> <p>However, I've googled for several different terms and cannot find possible values "timezone" is supposed to be. I also don't know where in my.ini (and in Linux, my.cnf) to put this directive. Below [msyqld] ?</p>
0
Should I Always Fully Qualify Column Names In SQL?
<p>Out of interest when working with SQL statements should I always use the fully qualifed column name (tablename.columnname) even if only working with one table e.g.</p> <pre><code>SELECT table.column1, table.column2 FROM table </code></pre>
0
How to connect a database in Atom Editor?
<p>I want to connect my database in atom and execute directly from the editor. How can I do that?</p>
0
pause/resume a python script in middle
<p>Can I have a running python script(under Windows)being paused in the middle by user , and resume again when user decides ? </p> <p>There is a main manager program which generates,loads and runs other python scripts (by calling python script.py from console).I don't have GUI and user can interact via console.I want my main program be able to respond to user pause/resume command for the running script.Should I define a thread? Whats the approach ?</p> <p>Edit/Update :</p> <p>Let's say I have a small python application with frontend which has various functions. I have a RUN command which runs python scripts in background .I want to implement a PAUSE feature which would pause the running python script . When the user commands RUN again then the python script should resume running . using raw_input() or print() forces user to issue command.But in this case, we don't know when user want to interrupt/pause/issue a command.So usual input/print is not usable.</p>
0
Mocking service in a component - mock ignored
<p>This time I'm trying to mock a service (that does http calls) to test a component.</p> <pre><code>@Component({ selector: 'ub-funding-plan', templateUrl: './funding-plan.component.html', styleUrls: ['./funding-plan.component.css'], providers: [FundingPlanService] }) export class FundingPlanComponent implements OnInit { constructor(private fundingPlanService: FundingPlanService) { } ngOnInit() { this.reloadFundingPlans(); } reloadFundingPlans() { this.fundingPlanService.getFundingPlans().subscribe((fundingPlans: FundingPlan[]) =&gt; { this.fundingPlans = fundingPlans; }, (error) =&gt; { console.log(error); }); } } </code></pre> <p>The <a href="https://angular.io/docs/ts/latest/guide/testing.html#!#component-with-dependency" rel="noreferrer">documentation</a> (version 2.0.0) explains that you should mock the service. Using the same <code>TestBed</code> configuration:</p> <pre><code>describe('Component: FundingPlan', () =&gt; { class FundingPlanServiceMock { getFundingPlans(): Observable&lt;FundingPlan&gt; { return Observable.of(testFundingPlans) } } beforeEach(() =&gt; { TestBed.configureTestingModule({ declarations: [FundingPlanComponent], providers: [ { provide: FundingPlanService, useClass: FundingPlanServiceMock }, ] }); fixture = TestBed.createComponent(FundingPlanComponent); component = fixture.componentInstance; }); fit('should display a title', () =&gt; { fixture.detectChanges(); expect(titleElement.nativeElement.textContent).toContain('Funding Plans'); }); }); </code></pre> <p>When I run the test, I get:</p> <pre><code>Error: No provider for AuthHttp! </code></pre> <p>that is indeedused by the actual service, but not by the mock. So for some reason, the mock is not injected or used.</p> <p>Any advise? Thanks!</p>
0
c# How to retrieve Json data into an array
<p>I have found different libraries that can parse Json data, but i did not find any documentation on how to get the data into an C# array or list.</p> <p>I got this Json data:</p> <p>{"001":{"Name":"John", "Phone":["Mob - 98837374","Mob - 98363627"]}, "002":{"Name":"Tom", "Phone":["Mob - 49858857"]}}</p> <p>Anybody got a clue? :)</p> <p><strong>Edit</strong>:</p> <p><em>Useful details posted by OP as comments re-posted as question edit by AnthonyWJones</em></p> <p>My code using JSON.NET:</p> <pre><code>StringBuilder sb = new StringBuilder(); List&lt;string&gt; entities = (List&lt;string&gt;)JsonConvert.DeserializeObject(responseFromServer, typeof(List&lt;string&gt;)); foreach (string items in entities) { sb.Append(items); } </code></pre> <p>But i always get an error when i debug:</p> <blockquote> <blockquote> <p>Warning 1 Reference to type 'System.DateTimeOffset' claims it is defined in 'c:\Program >> Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll', but it could not >> be found c:\Div\Json dot net\Bin\Newtonsoft.Json.dll"</p> </blockquote> </blockquote>
0
jQuery Accordion - Need index of currently selected content part
<p>I have a simple menu on a web page, based on the jQuery Accordion. I have simplified the code somewhat, and it looks like this;</p> <pre><code>&lt;div id="menu_div" class="nt-tab-outer nt-width-150px"&gt; &lt;h3 class="nt-tab-title"&gt;&lt;a href="#"&gt;Menu A&lt;/a&gt;&lt;/h3&gt; &lt;div id="menu_1_div"&gt; &lt;a href="itemA1"&gt;Item A1&lt;/a&gt;&lt;br /&gt; &lt;a href="itemA2"&gt;Item A2&lt;/a&gt;&lt;br /&gt; &lt;/div&gt; &lt;h3 class="nt-tab-title"&gt;&lt;a href="#"&gt;Menu B&lt;/a&gt;&lt;/h3&gt; &lt;div id="menu_2_div"&gt; &lt;a href="fTabsDyn"&gt;Item B1&lt;/a&gt;&lt;br /&gt; &lt;a href="fPlainDyn"&gt;Item B2&lt;/a&gt;&lt;br /&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; jQuery(function() { jQuery("#menu_div").accordion({ active: 1, change: function(event, ui) { alert('bob'); }}) }); &lt;/script&gt; </code></pre> <p>This sets the 2nd "part" of the accordion open when the page opens. (active:1) and if either of the headers is clicked a simple alert "bob" pops up. So far so good.</p> <p>Now I'd like to replace "bob" with the index of the header. So the "read" version of "active". ie, when the first accordion header is clicked I get 0, and if the second header is clicked I get a 1.</p> <p>(Aside, of course I don't really want to do an Alert, I want to make an Ajax call to the server with the value, so the server knows which menu is open at the client. That part I can do, but I'm struggling to get the right value to send. If the index is not available then feel free to offer alternate suggestions).</p> <p>Thanks!</p>
0
How to disable open browser in CRA?
<p>I've created a React app using <code>create-react-app</code> but whenever I start the dev server (using <code>npm start</code>), it opens up my browser. I want to make it so that it doesn't open my browser whenever I start my dev server.</p> <p>How can I accomplish this?</p>
0
resample audio buffer from 44100 to 16000
<p>I have audio data in format of data-uri, then I converted this data-uri into a buffer now I need this buffer data in new samplerate, currently audio data is in 44.1khz and I need data in 16khz, and If I recorded the audio using RecordRTC API and if I record audio in low sample rate then I got distorted audio voice, So I am not getting how to resample my audio buffer, </p> <p>If any of you any idea regarding this then please help me out.</p> <p>Thanks in advance :)</p>
0
JSF h:selectOneMenu trouble: java.lang.IllegalArgumentException Cannot convert "string" of type class java.lang.String to interface java.util.List
<p>I have some JSF-trouble using h:selectOneMenu with a list from my backend bean: My xhtml file looks like this:</p> <pre><code> &lt;f:view&gt; &lt;h:form id="serverOptions"&gt; &lt;h:selectOneMenu id="preset" value="#{overview.pdfPresets}" &gt; &lt;f:selectItems value="#{overview.pdfPresets}" /&gt; &lt;/h:selectOneMenu&gt; &lt;h:commandButton action="submit" value="Submit" /&gt; &lt;/h:form&gt; &lt;/f:view&gt; </code></pre> <p>where the corresponding managing bean looks like this:</p> <pre><code>private List&lt;String&gt; pdfPresets; private String pdfPreset; /** * Returns a list of pdfPresets * @return a List&lt;String&gt; of pdf preset names */ public final List&lt;String&gt; getPdfPresets() { return pdfPresets; } /** * Sets the name of the selected pdfPreset * (trying to overload setPdfPresets here) * @param presetName * @see setPdfPreset */ public final void setPdfPresets(String presetName) { // write preset name somehwere else this.presetName = presetName; } /** * Sets the pdfPresets * @param list */ public final void setPdfPresets(List&lt;String&gt; list) { pdfPresets = list; } </code></pre> <p>The problem occurs on submitting the form in my browser, the full error stack looks like this:</p> <pre><code>EVERE: An exception occurred javax.faces.component.UpdateModelException: java.lang.IllegalArgumentException: Cannot convert screen_druckbogen of type class java.lang.String to interface java.util.List at javax.faces.component.UIInput.updateModel(UIInput.java:398) at javax.faces.component.UIInput.processUpdates(UIInput.java:299) at javax.faces.component.UIForm.processUpdates(UIForm.java:187) at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1258) at javax.faces.component.UIViewRoot._processUpdatesDefault(UIViewRoot.java:1317) at javax.faces.component.UIViewRoot.access$600(UIViewRoot.java:75) at javax.faces.component.UIViewRoot$UpdateModelPhaseProcessor.process(UIViewRoot.java:1419) at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1278) at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:761) at org.apache.myfaces.lifecycle.UpdateModelValuesExecutor.execute(UpdateModelValuesExecutor.java:34) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: java.lang.IllegalArgumentException: Cannot convert screen_druckbogen of type class java.lang.String to interface java.util.List at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:397) at com.sun.el.parser.AstValue.setValue(AstValue.java:164) at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:273) at org.apache.myfaces.view.facelets.el.TagValueExpression.setValue(TagValueExpression.java:117) at javax.faces.component.UIInput.updateModel(UIInput.java:380) ... 29 more </code></pre>
0
Facebook Graph API get all likes from a post
<p>I am very new to facebook graph api, actually I just started today so I might use some help.</p> <p>My code is working perfectly, I've written a simple algorithm to list people who like a certain post, but the problem is this. Here is the JSON reply I get from graph api:</p> <pre><code>&lt;br/&gt; {&lt;br/&gt; "likes": {&lt;br/&gt; "data": [&lt;br/&gt; {&lt;br/&gt; "name": "NAME",&lt;br/&gt; "id": "ID"&lt;br/&gt; },&lt;br/&gt; {&lt;br/&gt; "name": "NAME",&lt;br/&gt; "id": "ID"&lt;br/&gt; },&lt;br/&gt; {&lt;br/&gt; "name": "NAME",&lt;br/&gt; "id": "ID"&lt;br/&gt; },&lt;br/&gt; {&lt;br/&gt; "name": "NAME",&lt;br/&gt; "id": "ID"&lt;br/&gt; }&lt;br/&gt; ],&lt;br/&gt; "count": 22&lt;br/&gt; },&lt;br/&gt; "id": "POST ID",&lt;br/&gt; "created_time": "DATE CREATED"&lt;br/&gt; }&lt;br/&gt; </code></pre> <p>so even though there are COUNT:22 Likes, the server returns only 4 names. Is it possible to get all the names? if so, how?</p>
0
Objective-C UILabel as HyperLink
<p>I am trying to make a <code>UILabel</code> a link for a <code>UIWebView</code>. How can I make a <code>UILabel</code> to work as hyperlink?</p>
0
VBA Excel - Compile Error Object Required
<p><strong>Disclosure: I'm fairly inexperienced at coding of most sorts but have a reasonable understanding of the logic behind it and quite often just need a little push with getting syntax's right etc.</strong></p> <p><strong>I posted the same code earlier but with a different problem and have no discovered this issue so I thought it best to create a new question for it</strong></p> <p><strong>Objective:</strong> What I'm trying to do is create a spreadsheet where across the top row is a list of consecutive dates. In the first few columns is data for bills etc. What I want my macro to do is look at the amount of a bill, the start and end dates and the frequency of the bill (weekly/monthly etc) and then populate the cells in that same row in the columns of the dates where the bill is due. I've spent the last day coming up with this code and I was pretty happy with it until I went to run it. I've already got rid of a few bugs where I was using a variable.Value which apparently doesn't exist and I had messed up the syntax for Cells(row, column).</p> <p>The problem that I'm coming up against now is Compile Error: Object Required on this line: </p> <pre><code>Set dateAddress = Range("J1:AAI1").Find(currentDate, LookIn:=xlValues).Address 'find the current date within the range of dates in row 1 </code></pre> <p>What that line is supposed to be doing is searching across all the dates in the first row for that 'currentDate' and then storing that as dateAddress so that I can then use the dateAddress.Column in the next line of code along with the currentRow, to find the right cell that is to be populated with the bill amount.</p> <p>Am I being clear enough? My code is below.</p> <p>My Code: </p> <pre><code>Private Sub CommandButton1_Click() Dim currentDate As Date Dim currentRow As Integer Dim repeatuntilDate As Date Dim repeatuntilRow As Integer Dim dateAddress As Date currentRow = 3 'First row of entries repeatuntilRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row 'Last row of entries While currentRow &lt; repeatuntilRow 'Loop from first row until last row of entries currentDate = Cells(currentRow, "G").Value 'Set Start Date repeatuntilDate = Cells(currentRow, "H").Value 'Set End Date While currentDate &lt;= repeatuntilDate 'Loop from Start Date until End Date Set dateAddress = Range("J1:AAI1").Find(currentDate, LookIn:=xlValues).Address 'find the current date within the range of dates in row 1 Cells("dateAddress.Column,currentRow").Value = Cells("D,currentRow").Value 'Populate cell with amount 'Increment the currentDate by the chosen frequency If Cells(currentRow, "E").Value = "Weekly" Then currentDate = DateAdd("ww", 1, currentDate) ElseIf Cells(currentRow, "E").Value = "Fortnightly" Then currentDate = DateAdd("ww", 2, currentDate) ElseIf Cells(currentRow, "E").Value = "Monthly" Then currentDate = DateAdd("m", 1, currentDate) ElseIf Cells(currentRow, "E").Value = "Quarterly" Then currentDate = DateAdd("q", 1, currentDatee) ElseIf Cells(currentRow, "E").Value = "6 Monthly" Then currentDate = DateAdd("m", 6, currentDate) ElseIf Cells(currentRow, "E").Value = "Annually" Then currentDate = DateAdd("y", 1, currentDate) ' ElseIf Cells(currentRow,"E").Value = "Once off" Then ' Exit While End If Wend currentRow = currentRow + 1 'Once row is complete, increment to next row down Wend End Sub </code></pre>
0
Can any one explain Screenshot in Selenium?
<pre><code>WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com/"); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhere FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png")); </code></pre> <p>Can any tell me that </p> <pre><code>File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE) </code></pre> <p><code>getScreenShotAs</code> is the method in the <code>TakesScreenshot</code> Interface......</p> <p><code>(TakesScreenshot)driver</code>, What it refers to??? can you please explain little bit?</p>
0
Reactive Spring does not support HttpServletRequest as parameter in REST endpoint?
<p>I created a RestController which look like this : </p> <pre><code>@RestController public class GreetingController { @RequestMapping(value = "/greetings", method = RequestMethod.GET) public Mono&lt;Greeting&gt; greeting(HttpServletRequest request) { return Mono.just(new Greeting("Hello..." + request.toString())); } } </code></pre> <p>Unfortunately when I try to hit the "greetings" endpoint I get an exception :</p> <blockquote> <p>java.lang.IllegalStateException: No resolver for argument [0] of type [org.apache.catalina.servlet4preview.http.HttpServletRequest]</p> </blockquote> <p>I am using </p> <blockquote> <pre><code>compile('org.springframework.boot.experimental:spring-boot-starter-web-reactive') </code></pre> </blockquote> <p>How to fix this ?</p> <p><a href="http://pastebin.com/heybvCeK" rel="noreferrer">Link</a> to full stack-trace. <a href="http://pastebin.com/U9t60NUw" rel="noreferrer">Link</a> to build.gradle</p> <p><strong>----------EDIT----------</strong></p> <p>Using the interface. Now getting : </p> <blockquote> <p>java.lang.IllegalStateException: No resolver for argument [0] of type [javax.servlet.http.HttpServletRequest] on method (rest is same)</p> </blockquote>
0
JavaScript access string chars as array
<p>Is it ok to do this:</p> <pre><code>var myString="Hello!"; alert(myString[0]); // shows "H" in an alert window </code></pre> <p>Or should it be done with either charAt(0) or substr(0,1)? By "is it ok" I mean will it work on most browsers, is there a best practice recommandation that says otherwise etc.</p> <p>Thank you.</p>
0
How would i use Sevenzipsharp with this code?
<p>iv tried numerous different ways to get this to work and i got it to basicly work but i cant get the WaitForExit(); 's to work like they do here... so how would i convert this to work with sevenzip? cause i cant get it to work, and also i the SFX's are passworded so that they cannot be accessed except by the use of the program and as for adding the 7z.DLL i cant add it in because i get the error:</p> <blockquote> <p>A reference to 7za.dll could not be added. please make sure that the file is accessible, and that it is a valid assembly or COM component.</p> </blockquote> <pre><code>string tempFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); System.Diagnostics.Process defrag1 = System.Diagnostics.Process.Start(@"AusLogics_Defrag.exe", string.Format(" -o{0} -y -Pthisisthepass", tempFolder)); defrag1.WaitForExit(); string executableDirectoryName = Path.GetDirectoryName(Application.ExecutablePath); System.Diagnostics.Process defrag2 = System.Diagnostics.Process.Start(tempFolder + "\\" + "AusLogics_Defrag" + "\\" + "DiskDefrag.exe", ""); defrag2.WaitForExit(); System.IO.Directory.Delete(tempFolder + "\\" + "AusLogics_Defrag", true); </code></pre> <p>new: ok well this is what i have so far but im getting that error "Can not load 7-zip library or internal COM error! Message: failed to load library"</p> <pre><code>SevenZipExtractor.SetLibraryPath("7z.dll"); //no idea of this is needed or not SevenZipCompressor.SetLibraryPath("7z.dll"); //no idea of this is needed or not string tempFolder = Environment.GerFolderPath(Environment.SpecialFolder.ApplicationData); SevenZipExtractor defrag = new SevenZipExtractor(@"Programs\Optimize\Auslogics_Defrag.7z"); defrag.ExtracArchive(string.Format("-o{0} -y -PThisisthepass", tempFolder)); </code></pre>
0
How to change a button's size
<pre><code>int width, height; width = this.Size.Width; height = this.Size.Height; width /= 3; height /= 3; btn_1.Size = new Size(width, height); </code></pre> <p>I am trying to make a button's size and location change when the user resizes a form.</p> <p>How can I assigning a size to a button?</p> <p>I tried to make it with changing width and height separately. I know that I can make it by anchoring it, but I would like to make it with pure coding.<br> Also refreshing the form did not work. I can set the locations of buttons easily with the <code>Location</code> property, but the size property does not work. I couldn't find the difference...</p> <p>Here is the full code which works for changing the positions of objects, but does not work for changing the size:</p> <pre><code>private void form_counterMain_Resize(object sender, EventArgs e) { int width, height; Point templocation; templocation = new Point(0, 0); width = this.Size.Width; height = this.Size.Height; width /= 3; height /= 3; //:::location::: btn_1.Location = templocation; templocation.X = width; btn_2.Location = templocation; templocation.X = width * 2; btn_3.Location = templocation; templocation.X = 0; templocation.Y = height; btn_4.Location = templocation; templocation.X = width; btn_5.Location = templocation; templocation.X = width * 2; btn_6.Location = templocation; templocation.Y = height * 2; templocation.X = 0; btn_7.Location = templocation; templocation.X = width; btn_8.Location = templocation; templocation.X = width * 2; btn_9.Location = templocation; //:::size::: btn_1.Size = new Size(width, height); this.Refresh(); </code></pre>
0
Java - JPA - @Version annotation
<p>How does <code>@Version</code> annotation work in JPA?</p> <p>I found various answers whose extract is as follows:</p> <blockquote> <p>JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same record, it throws an exception to the transaction attempting to commit last.</p> </blockquote> <p>But I am still not sure how it works.</p> <hr> <p>Also as from the following lines:</p> <blockquote> <p>You should consider version fields immutable. Changing the field value has undefined results. </p> </blockquote> <p>Does it mean that we should declare our version field as <code>final</code>?</p>
0