title
stringlengths
10
150
body
stringlengths
17
64.2k
label
int64
0
3
100% height div between header and footer
<p>I am trying to create a webpage layout with a header/footer (100% width, 145px height), a 'main area' between the header/footer (100% width, dynamic height), and a container around the content that is a unique background color (860px width, dynamic height but is always 'flush' against the footer). </p> <p><strong>(<a href="http://jsfiddle.net/qC8z5/164/">See Example for a visual</a>)</strong> </p> <p>The problem I am having is I can't seem to have the 'content container' always be flush with the footer when there is minimal content. Using a setup like the <strong>(<a href="http://jsfiddle.net/qC8z5/164/">original example</a>)</strong> results in the footer floating over the content if there is a respectable/'normal' amount of content or if the window is resized.</p> <p>And the Following CSS results in a gap between the content and the footer.</p> <pre><code>html,body{ margin:0; padding:0; height:100%; background:yellow; } .wrap{ min-height:100%; position:relative; } header{ background:blue; padding:10px; } #content{ height:100%; width: 400px; margin:0 auto; background:orange; padding:30px; } footer{ background:blue; position:absolute; bottom:0; width:100%; height:60px; } </code></pre> <p>How can I make the content container be the full height of the screen when content is minimal and have the footer 'stick' to the bottom of the page, while also being dynamic to resize appropriately if there is a normal amount of content (footer is always at the bottom of the content)?</p> <p>Thank you!</p>
0
javax.net.ssl.SSLHandshakeException:No appropriate protocol. How to force Java to use TLSv1.2 for sending mail?
<p>I am trying to use JavaMailSender to send mails in spring boot, but I am getting this error:</p> <pre><code>javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate). Failed messages: javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) </code></pre> <p>After doing some reading, I found it is because we are using TLSv1 or TLSv1.1 which is outdated, and we should use v1.2 or higher. I tried to add ssl.protocols property in application.yml with value TLSv1.2, but it does not seem to work. Here is my application.yml:</p> <pre><code>spring: mail: host: smtp.gmail.com port: 587 username: ******@gmail.com password: ******* protocol: smtp tls: true properties.mail.smtp: auth: true ssl.trust: smtp.gmail.com starttls.required: true starttls.enabled: true ssl.protocols: TLSv1.2 </code></pre> <p>and here is the method that sends the mail:</p> <pre><code>public void sendEmail(String to, String subject, String body) { logger.info(&quot;Sending mail to : &quot; + to); SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(to); mail.setSubject(subject); mail.setText(body); try { javaMailSender.send(mail); logger.info(&quot;Mail sent to &quot; + to); } catch (Exception e) { logger.error(&quot;Could not send mail to &quot; + to + &quot;. Exception : &quot; + e.getMessage()); } } </code></pre> <p>I updated JavaMailSender version but it didn't fix the issue. The only thing that worked was removing TLSv1 and TLSv1.1 from jdk.tls.disabledAlgorithms as suggested in <a href="https://stackoverflow.com/a/68238768/8198017">this answer</a>, but it is only a temporary fix. How can make the mail sender use TLSv1.2 or higher? Is there anything wrong in the way I am defining the ssl.protocols property in application.yml?</p> <p>This is the java version I am using:</p> <pre><code>openjdk version &quot;1.8.0_292&quot; OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode) </code></pre> <p>and the spring boot starter mail version:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-mail&lt;/artifactId&gt; &lt;version&gt;2.5.3&lt;/version&gt; &lt;/dependency&gt; </code></pre>
0
AngularJS: Scroll to end of element after applying DOM changes
<p>I have a simple list of items. I want to be able to scroll to the bottom of the element displaying the items whenever I add more items. I understood there is no way of hooking to the end of the <code>$apply()</code> function, so what might be my solution?</p> <p>Here is a <a href="http://jsfiddle.net/gNBnq/2/" rel="noreferrer">jsfiddle</a> to illustrate my problem. after adding enough items, the ul element doesn't scroll to the bottom...</p>
0
COBOL Program to read a flat file sequentially and write it to an output file, not able to read at all loop is going infinite
<p>I'm trying to write COBOL Program to read a flat file sequentially and write it to an output file, I'm able to read only one record at a time, not able to read next record what should I do?</p> <p>Here is my code:</p> <pre><code>PROCEDURE DIVISION. OPEN INPUT FILEX. PERFORM READ-PARA THRU END-PARA UNTIL END-OF-FILE = 'Y'. CLOSE FILEX. STOP RUN. READ-PARA. READ FILEX AT END MOVE 'Y' TO END-OF-FILE DISPLAY OFFCODE1 DISPLAY AGCODE1 DISPLAY POLNO1 DISPLAY EFFDATE1 DISPLAY EXPDATE DISPLAY REPCODE DISPLAY POLHOLDER1 DISPLAY LOCATION1 GO TO END-PARA. END-PARA. </code></pre> <p>i, ve tried using the scope terminator, still not able to loop 'm getting S001 ABEND here is my code :</p> <pre><code>IDENTIFICATION DIVISION. PROGRAM-ID. SIMPLE. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILEX ASSIGN TO SYSUT1 FILE STATUS IS FS. DATA DIVISION. FILE SECTION. FD FILEX. 01 FILEXREC. 02 OFFCODE1 PIC X(3). 02 FILLER PIC X. 02 AGCODE1 PIC X(3). 02 FILLER PIC X. 02 POLNO1 PIC X(6). 02 FILLER PIC X. 02 EFFDATE1 PIC X(8). 02 FILLER PIC X. 02 EXPDATE PIC X(8). 02 FILLER PIC X. 02 REPCODE PIC X(1) 02 FILLER PIC X. 02 POLHOLDER1 PIC X(8). 02 FILLER PIC X. 02 LOCATION1 PIC X(9). 02 FILLER PIC X(87). WORKING-STORAGE SECTION. 77 FS PIC 9(2). 01 WS-INDICATORS. 10 WS-EOF-IND PIC X(01) VALUE 'N'. 88 WS-END-OF-FILE VALUE 'Y'. PROCEDURE DIVISION. OPEN INPUT FILEX. PERFORM READ-PARA THRU END-PARA UNTIL WS-END-OF-FILE. CLOSE FILEX. STOP RUN. READ-PARA. READ FILEX AT END MOVE 'Y' TO WS-EOF-IND. DISPLAY OFFCODE1 DISPLAY AGCODE1 DISPLAY POLNO1 DISPLAY EFFDATE1 DISPLAY EXPDATE DISPLAY REPCODE DISPLAY POLHOLDER1 DISPLAY LOCATION1 IF WS-END-OF-FILE GO TO END-PARA. END-PARA. EXIT. </code></pre> <p>one more method i tried even in this works for only one record, again getting S001 ABEND while running the code. Here is the code:</p> <pre><code> IDENTIFICATION DIVISION. PROGRAM-ID. ASSIGNMENT. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILEX ASSIGN TO SYSUT1 DATA DIVISION. FILE SECTION. FD FILEX. LABEL RECORDS ARE STANDARD RECORD CONTAINS 140 CHARACTERS BLOCK CONTAINS 00 RECORDS. 01 FILEXREC. 02 OFFCODE1 PIC 9(3). 02 FILLER PIC X. 02 AGCODE1 PIC X(3). 02 FILLER PIC X. 02 POLNO1 PIC X(6). 02 FILLER PIC X. 02 EFFDATE1 PIC X(8). 02 FILLER PIC X. 02 EXPDATE1 PIC X(8). 02 FILLER PIC X. 02 REPCODE1 PIC X(1). 02 FILLER PIC X. 02 POLHOLDER1 PIC X(8). 02 FILLER PIC X. 02 LOCATION1 PIC X(9). 02 FILLER PIC X(26). WORKING-STORAGE SECTION. 01 WS-INDICATORS. 10 WS-EOF-IND PIC X(01) VALUE 'N'. 88 WS-END-OF-FILE VALUE 'Y'. 01 TEMP1. 02 OFFCODE2 PIC 9(3). 02 FILLER PIC X. 02 AGCODE2 PIC X(3). 02 FILLER PIC X. 02 POLNO2 PIC X(6). 02 FILLER PIC X. 02 EFFDATE2 PIC X(8). 02 FILLER PIC X. 02 EXPDATE2 PIC X(8). 02 FILLER PIC X. 02 REPCODE2 PIC X(1). 02 FILLER PIC X. 02 POLHOLDER2 PIC X(8). 02 FILLER PIC X. 02 LOCATION2 PIC X(9). 02 FILLER PIC X(26). PROCEDURE DIVISION. OPEN INPUT FILEX. PERFORM READ-PARA THRU END-PARA UNTIL WS-END-OF-FILE. CLOSE FILEX. STOP RUN. READ-PARA. READ FILEX INTO TEMP1 AT END MOVE 'Y' TO WS-EOF-IND. DISPLAY OFFCODE1 DISPLAY AGCODE1 DISPLAY POLNO1 DISPLAY EFFDATE1 DISPLAY EXPDATE1 DISPLAY REPCODE1 DISPLAY POLHOLDER1 DISPLAY LOCATION1 IF WS-END-OF-FILE GO TO END-PARA. END-PARA. EXIT. </code></pre>
0
Getting "illegal access to loading collection" error
<p>When I execute my program without implementing <code>hashcode()</code> and <code>toString()</code> then it works fine. But as soon as I include <code>hashcode()</code> and <code>toString()</code> then I get this "illegal access to loading collection" error.</p> <p>My hbm files are </p> <p><strong>1) booking.hbm.xml</strong></p> <pre><code>&lt;many-to-one name="userId" class="User" column="user_id" insert="true" update="true" cascade="save-update" &gt; &lt;/many-to-one&gt; &lt;many-to-one name="flightId" class="FlightSchedule" column="flight_id" cascade="all" not-null="true"&gt; &lt;/many-to-one&gt; &lt;set name="passenger" table="passenger79215" lazy="false" inverse="true" cascade="save-update"&gt; &lt;key column="reference_id" /&gt; &lt;one-to-many class="Passenger" /&gt; &lt;/set&gt; </code></pre> <p><strong>2) Passenger.hbm.xml</strong></p> <pre><code>&lt;many-to-one name="referenceid" class="Booking" lazy="false" insert="true" update="true" column="reference_id " cascade="save-update"&gt; &lt;/many-to-one&gt; </code></pre> <p><strong>3) User.hbm.xml</strong></p> <pre><code>&lt;set name="booking" table="bookings79215" lazy="true" inverse="false" cascade="save-update"&gt; &lt;key column="user_id" /&gt; &lt;one-to-many class="Booking" /&gt; &lt;/set&gt; </code></pre> <p>Can anyone explain the error?</p>
0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
<p>When I upgrade flutter, I came across with below error message.</p> <blockquote> <p>curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54</p> </blockquote> <pre><code>Failed to retrieve the Dart SDK from: https://storage.googleapis.com/flutter_infra/flutter/4737fc5cd89b8f0136e927b00f2e159444b95a73/dart-sdk-darwin-x64.zip If you're located in China, please see this page: https://flutter.io/community/china Flutter 1.3.8 • channel beta • https://github.com/flutter/flutter.git Framework • revision e5b1ed7a7f (6 weeks ago) • 2019-04-11 14:01:46 -0700 Engine • revision 4737fc5cd8 Tools • Dart 2.2.1 (build 2.2.1-dev.0.0 571ea80e11) Running flutter doctor... Downloading Dart SDK from Flutter engine 4737fc5cd89b8f0136e927b00f2e159444b95a73... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed </code></pre> <p>What is this? what is the the problems?</p>
0
Upgrade .Net Framework 2.0 To 4.5
<p>I have upgraded my asp.net 2.0 project to 4.5 by using Visual Studio 2012. It is building fine, but will I have to test each webform in the browser or will it be converted 100% automatically? Without the .Net Framework 2.0, will the converted project work fine?</p>
0
How to provide a password for PostgreSQL's createdb non-interactively?
<p>I have a task in phing where before tests I drop the database if exists and create it. This is run on Jenkins. I want to do it with createdb like this:</p> <pre><code>&lt;exec command="createdb my_database" /&gt; </code></pre> <p>The thing is that the createdb is asking me to authenticate and adding -Umy_user parameter is not a problem - the issue is that I cannot specify a password in the createdb command. And I don't want to create a role for the system user ("jenkins" in this case). Is there a solution for that ? </p>
0
How to run Git server on Windows?
<p>How can I share a Git repo on Windows? The "correct" ways appear to be to run "git-daemon" (unix specific) or run ssh (unix specific) or run an http front end for Git. If I just have two Windows boxes and don't feel like installing Unix just to run Git, what is the optimal way to share the repos between the two boxes?</p>
0
Is there a way to create transparent windows with Tkinter?
<p>I'm trying, ultimately, to create "oddly-shaped windows" with Python using the Tkinter module. But for now I will settle for being able to make the background transparent while keeping child widgets fully-visible.</p> <p>I'm aware this is done with wxPython and some other modules, but I'm inquiring as to the limits of Tkinter.</p> <p>Can Tkinter create a clear Canvas or Frame? Can it pack UI elements without a canvas or frame? Can individual UI elements be transparent?</p> <p>Can it pass mouse-click locations back to the system for processing any windows below it in the Z stack?</p>
0
How to truncate date in PostgreSQL?
<p>I'm trying to select all transactions in PostgreSQL 9 that happened earlier than the end of the last week. Which date function I should use to build such an interval?</p>
0
How to get the error string in openssl?
<p>I am using openssl to establish the TLS connection with the remote server.</p> <p>Here are the code snippets:</p> <pre class="lang-c prettyprint-override"><code>if ((ret = SSL_connect(c-&gt;ssl)) &lt;= 0) { ret = SSL_get_error(c-&gt;ssl, ret); if((err = ERR_get_error())) { SSL_load_error_strings(); ERR_load_crypto_strings(); CRERROR(LOGSSLUTILS, "SSL connect err code:[%lu](%s)\n", err, ERR_error_string(err, NULL)); CRERROR(LOGSSLUTILS, "Error is %s \n",ERR_reason_error_string(err)); } } </code></pre> <p>for some unknown reason, the ssl_connect failed and I just want to identify the reason by using the ERR_error_string, the outputs are:</p> <pre><code>SSL connect err code:[336077172] (error:14082174:lib(20):func(130):reason(372)) Error: cmrSSLlInit:174 Error is (null) </code></pre> <p>As you can see, I can only get the error code but cannot get the readable error string.</p> <p>How how can I get the readable error string ?</p>
0
ExecuteReader returns no results, when inspected query does
<p>Consider the following code:</p> <pre><code> StringBuilder textResults = new StringBuilder(); using(SqlConnection connection = new SqlConnection(GetEntityConnectionString())) { connection.Open(); m.Connection = connection; SqlDataReader results = m.ExecuteReader(); while (results.Read()) { textResults.Append(String.Format("{0}", results[0])); } } </code></pre> <p>I used Activity Monitor within Sql Server Mgmt Studio on the database to inspect the exact query that was being sent. I then copied that query text to a query editor window within SSMS, and the query returned the expected results. However, <code>SqlDataReader results</code> is always empty, indicating "The enumeration returned no results."</p> <p>My suspicion is that somehow the results are not being returned correctly, which makes me think there's something wrong with the code above, and not the query itself being passed.</p> <p>Is there anything that would cause this in the code above? Or something I've overlooked?</p> <p><strong>EDIT:</strong></p> <p>Here is the query as indicated by the SQLCommand object:</p> <pre><code>SELECT DISTINCT StandardId,Number FROM vStandardsAndRequirements WHERE StandardId IN ('@param1','@param2','@param3') ORDER BY StandardId </code></pre> <p>Here is the query as it appears in Activity Monitor:</p> <pre><code>SELECT DISTINCT StandardId,Number FROM vStandardsAndRequirements WHERE StandardId IN ('ABC-001-0','ABC-001-0.1','ABC-001-0') ORDER BY StandardId </code></pre> <p>The query is working against a single view.</p> <p>When I ran the second query against the database, it returned 3 rows.</p> <p>The SqlDataReader indicates 0 rows.</p>
0
Redraw/Resize highcharts when printing website
<p>When I'm printing the bottom right frame the text <code>some text</code> is partly covered by the highcharts because they don't resize before printing. Is there a solution to configure a printing layout with <code>@media print</code> for the website and force highcharts to redraw/resize to container size when website is printed?</p> <p>HTML</p> <pre><code>&lt;script src="http://code.highcharts.com/highcharts.js"&gt;&lt;/script&gt; &lt;script src="http://code.highcharts.com/modules/exporting.js"&gt;&lt;/script&gt; &lt;div id="container" style="height: 400px"&gt;&lt;/div&gt; &lt;div id="container" style="height: 400px"&gt;&lt;/div&gt; </code></pre> <p>JavaScript</p> <pre><code>$(function () { Highcharts.setOptions({ // Apply to all charts chart: { events: { beforePrint: function () { this.oldhasUserSize = this.hasUserSize; this.resetParams = [this.chartWidth, this.chartHeight, false]; this.setSize(600, 400, false); }, afterPrint: function () { this.setSize.apply(this, this.resetParams); this.hasUserSize = this.oldhasUserSize; } } } }); $('#container').highcharts({ title: { text: 'Rescale to print' }, subtitle: { text: 'Click the context menu and choose "Print chart".&lt;br&gt;The chart size is set to 600x400 and restored after print.' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] }); }); </code></pre> <p><a href="https://jsfiddle.net/kscvce93/" rel="noreferrer">JSFiddle</a></p>
0
SQL Server: Error converting data type varchar to float
<p>I have the following <code>SELECT</code> statement to calculate <code>RADIANS</code> and <code>COS</code>. </p> <pre><code>SELECT COS(RADIANS(latitude)) as Lat FROM tbl_geometry; </code></pre> <p>But I'm getting an error:</p> <blockquote> <p>Error converting data type varchar to float.</p> </blockquote> <p>My attempts:</p> <p><strong>Attempt #1</strong>:</p> <pre><code>select Cos(convert(float, (Radians(convert(float, latitude))))) as Lat from tbl_geometry; </code></pre> <p><strong>Attempt #2</strong>.</p> <pre><code>select Cos(Radians(convert(float, latitude))) as Lat from tbl_geometry; </code></pre> <p>Both attempts result in the same error.</p> <p><strong>Note</strong>: column <code>Latitude</code> is of type <code>varchar</code>.</p>
0
PHP - Get key name of array value
<p>I have an array as the following:</p> <pre><code>function example() { /* some stuff here that pushes items with dynamically created key strings into an array */ return array( // now lets pretend it returns the created array 'firstStringName' =&gt; $whatEver, 'secondStringName' =&gt; $somethingElse ); } $arr = example(); // now I know that $arr contains $arr['firstStringName']; </code></pre> <p>I need to find out the index of <code>$arr['firstStringName']</code> so that I am able to loop through <code>array_keys($arr)</code> and return the key string <code>'firstStringName'</code> by its index. How can I do that?</p>
0
pandas drops index index on merge in Python?
<p>I am merging two dataframes using <code>merge(..., how='left')</code> since I want to retain only entries that match up with the "left" dataframe. The problem is that the merge operation seems to drop the index of my leftmost dataframe, shown here:</p> <pre><code>import pandas df1 = pandas.DataFrame([{"id": 1, "name": "bob"}, {"id": 10, "name": "sally"}]) df1 = df1.set_index("id") df2 = pandas.DataFrame([{"name": "bob", "age": 10}, {"name": "sally", "age": 11}]) print "df1 premerge: " print df1 df1 = df1.merge(df2, on=["name"], how="left") print "merged: " print df1 # This is not "id" print df1.index # And there's no "id" field assert ("id" in df1.columns) == False </code></pre> <p>Before the merge, <code>df1</code> was indexed by <code>id</code>. After the merge operation, there's just the default numeric index for the merged dataframe and the <code>id</code> field was dropped. How can I do this kind of merge operation but retain the index of the leftmost dataframe? </p> <p>To clarify: I want all the columns of <code>df2</code> to be added to every entry in <code>df1</code> that has the matching <code>id</code> value. If an entry in <code>df2</code> has an <code>id</code> value not in <code>df1</code>, then that shouldn't be merged in (hence the <code>how='left'</code>).</p> <p><strong>edit</strong>: I could as a hack do: <code>df1.reset_index()</code> but merging and then set the index again, but I prefer not to if possible, it seems like merge shouldn't have to drop the index. thanks.</p>
0
Mongoose: Cast to ObjectId failed for value
<p>I'm trying to specify the schema of my db in mongoose. At the moment I do this:</p> <pre><code>var Schema = mongoose.Schema; var today = new Date(2011, 11, 12, 0, 0, 0, 0); var personSchema = new Schema({ _id : Number, name: { type: String, required: true }, tel: { type: String, required: true }, email: { type: String, required: true }, newsitems: [{ type: Schema.Types.ObjectId, ref:'NewsItem'}] }); var taskSchema = new Schema({ _id: Number, description: { type: String, required: true }, startDate: { type: Date, required: true }, newsitems: [{ type: Schema.Types.ObjectId, ref:'NewsItem'}] }); var newsSchema = new Schema({ _id: Number, creator : { type: Schema.Types.ObjectId, ref: 'Person' }, task : { type: Schema.Types.ObjectId, ref: 'Task' }, date: { type: Date, required:true }, loc: {type: String, required: true } }); var NewsItem = mongoose.model('NewsItem', newsSchema); var Person = mongoose.model('Person', personSchema); var Task = mongoose.model('Task', taskSchema); var tony = new Person({_id:0, name: "Tony Stark", tel:"234234234", email:"tony@starkindustries.com" }); var firstTask = new Task({_id:0, description:"Get an interview with the president", startDate:today}); var newsItem1 = new NewsItem({_id:0, creator: tony.id, task: firstTask.id, date: today, loc: "NY"}); newsItem1.save(function (err) { if (err) console.log(err); firstTask.save(function (err) { if (err) console.log(err); }); tony.save(function (err) { if (err) console.log(err); }); }); NewsItem .findOne({ loc: "NY" }) .populate('creator') .populate('task') .exec(function (err, newsitem) { if (err) console.log(err) console.log('The creator is %s', newsitem.creator.name); }) </code></pre> <p>I create the schemas and try to save some data. </p> <p>The error:</p> <pre><code>{ message: 'Cast to ObjectId failed for value "0" at path "creator"', name: 'CastError', type: 'ObjectId', value: '0', path: 'creator' } </code></pre> <p>I wrote this code based on : <a href="http://mongoosejs.com/docs/populate.html#gsc.tab=0" rel="nofollow noreferrer">http://mongoosejs.com/docs/populate.html#gsc.tab=0</a></p> <p>The db I try to create looks like this: <a href="https://stackoverflow.com/questions/15747130/specify-schema-in-mongoose">Specify schema in mongoose</a> .</p> <p>How can I fix this?</p>
0
Right way to format date with strings like today, yesterday, tomorrow etc
<p>I have a date textview. And my textview holds a date string like 2011.09.17. Well I still do want to have that but I also want to add some more user friendly info for some specific dates like today or yesterday. For example if today is 2011.09.17 I want my textview to have value of yesterday instead 2011.09.16 and today instead 2011.09.17.</p> <p>well I already managed to do this :), but in the ugly way :(. I do this with a lot of 'if->than' which is really uglly and what ever I want to add some new rule like if the date is older than one year I want to put string like last year or so.... I really need to add ugly logic.</p> <p>My question is is there a nicer way to do this ? is there something like design pattern for this ? What is the recommended way to do this ? I am sure that many people have encounter this kind of problems</p> <p>if there some bather approach than thousand of ifs ? if not thanks any way at least I will stop searching for bather solution</p> <p>any suggestions , snippet or so will be appreciated</p> <p>Thanks </p>
0
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly
<p>I have a problem to generate the locales on the serveur herbert and homer . I run mongo I get the warning </p> <pre><code>Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly. </code></pre> <p>When I run </p> <p><code>dpkg-reconfigure locales</code></p> <p>mongo start successful , then When reboot the server and run mongo i have the same problem. </p> <p>Thank for help </p>
0
Qt: How to resize a window to its new content
<p>I have a window containing a <code>QScrollArea</code> with a couple widgets in it.</p> <p>Until now, I was creating the <code>QScrollArea</code> and its child widgets in the constructor of my window, and then I was resizing the window vertically to fit its content using <code>resize(400, sizeHint().height())</code>. So far, so good.</p> <p>Now, I'm adding or removing widgets in the <code>QScrollArea</code> at runtime. What should I do, after having added or removed widgets, to make the window fits its content vertically? Should I call <code>adjustSize()</code>? <code>resize(sizeHint())</code>? Should there be a call to <code>layout-&gt;activate()</code> or maybe <code>updateGeometry()</code> first? Which size policies actually matter in this case? The ones of the window, or of the scroll area, or both? I tried to set them all to <code>Expanding</code>.</p> <p>I'm using Qt 4.6 on Windows.</p>
0
Setting near plane in OpenGL
<p>i have implemented first person camera in OpenGL, but when i get closer to an object it starts to disappear, so i want to set near plane close to zero so i could get closer to the objects. So if anybody can tell me what is the best way to do that. Thank you. </p>
0
Connecting to telnet server and send/recieve data
<p>So I am trying to connect to my telnet server, which works. It recives the first lot of data from the server which is us being asked to enter password to connect. But when I type in the password it does nothing and nothing that is recieved is printed to my console.</p> <p>An example of the output is as follows:</p> <pre><code>Connected to server. Please enter password: Response: MYPASSHERE __BLANK RESPONSE FROM SERVER__ Response: </code></pre> <p><img src="https://puu.sh/flM2h/260ca960cd.png" alt="enter image description here"></p> <p>I am currently using this code</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Sockets; using System.Threading; namespace _7DaysServerManager { public class ServerSocket { private TcpClient client; private Thread readWriteThread; private NetworkStream networkStream; private string password; public ServerSocket(string ip, int port) { try { client = new TcpClient(ip, port); Console.WriteLine("Connected to server."); } catch (SocketException) { Console.WriteLine("Failed to connect to server"); return; } //Assign networkstream networkStream = client.GetStream(); //start socket read/write thread readWriteThread = new Thread(readWrite); readWriteThread.Start(); } private void readWrite() { string command, recieved; //Read first thing givent o us recieved = read(); Console.WriteLine(recieved); //Set up connection loop while (true) { Console.Write("Response: "); command = Console.ReadLine(); if (command == "exit") break; write(command); recieved = read(); Console.WriteLine(recieved); } Console.WriteLine("Disconnected from server"); networkStream.Close(); client.Close(); } public void write(string message) { networkStream.Write(Encoding.ASCII.GetBytes(message), 0, message.Length); networkStream.Flush(); } public string read() { byte[] data = new byte[1024]; string recieved = ""; int size = networkStream.Read(data, 0, data.Length); recieved = Encoding.ASCII.GetString(data, 0, size); return recieved; } } } </code></pre>
0
Using std::ostream as argument to a print function
<p>I have always used <code>cout</code> to print the statement but now I want learn printing by <code>passing the stream</code>, something like <code>void print(std::ostream&amp;) const;</code> my current print function looks like</p> <pre><code>template &lt;class T&gt; void Mystack&lt;T&gt;::print() { for (int i = 0; i &lt;= top; i++) { std::cout &lt;&lt; input[i] &lt;&lt; " "; } } </code></pre> <p>I have 2 questions:</p> <ol> <li>What is the benefit of switching from normal print function that I implemented above to the print function using <code>ostream</code>.</li> <li>How can I implement <code>ostream</code> in my function. I tried to understand <code>ostream</code> from internet source but could not understand. Please help. </li> </ol> <p>Below is the complete running code:</p> <pre><code>//*************STACK CODE***************// //VERY GOOD EXAMPLE TO UNDERSTAND RULE OF THREE FOR BEGINEERS http://www.drdobbs.com/c-made-easier-the-rule-of-three/184401400 //RULE OF THREE : Video : https://www.youtube.com/watch?v=F-7Rpt2D-zo //Thumb Rule : Whenever we have class which has members pointing to heap space we should implement Rule of three. //Concepts : Shallow Copy and Deep Copy #include &lt;iostream&gt; template &lt;class T&gt; class Mystack { private: T *input; int top; int capacity; public: Mystack(); ~Mystack(); void push(T const&amp; x); void pop(); T&amp; topElement() const; bool isEmpty() const; void print(); }; template &lt;class T&gt; Mystack&lt;T&gt;::Mystack() { top = -1; capacity = 5; input = new T[capacity]; } template &lt;class T&gt; Mystack&lt;T&gt;::~Mystack() //Since we are using destructor explictly we need to apply Rule of 3 { delete [] input; } template &lt;class T&gt; void Mystack&lt;T&gt;::push(T const&amp; x) //Passing x by Const Reference // Valus of x cannot be changed now in the function! { if (top + 1 == capacity) { T *vec = new T[capacity * 2]; for (int i = 0; i &lt;= top; i++) { vec[i] = input[i]; } delete []input; // Avoiding Memory Leak. input = vec; capacity *= capacity; } top++; std::cout &lt;&lt; x; std::cout &lt;&lt; &amp;x; input[top] = x; } template &lt;class T&gt; void Mystack&lt;T&gt;::pop() { if (isEmpty()) { throw std::out_of_range("Stack Underflow"); } else { std::cout &lt;&lt; "The popped element is" &lt;&lt; input[top--]; } } template &lt;class T&gt; bool Mystack&lt;T&gt;::isEmpty() const { if (top == -1) { std::cout &lt;&lt; "Is Empty" &lt;&lt; std::endl; return true; } else { std::cout &lt;&lt; "Not Empty" &lt;&lt; std::endl; return false; } } template &lt;class T&gt; T&amp; Mystack&lt;T&gt;::topElement() const { if (top == -1) { throw std::out_of_range("No Element to Display"); } else { std::cout &lt;&lt; "The top element is : " &lt;&lt; input[top]; return input[top]; } } template &lt;class T&gt; void Mystack&lt;T&gt;::print() { for (int i = 0; i &lt;= top; i++) { std::cout &lt;&lt; input[i] &lt;&lt; " "; } } int main() { Mystack&lt;int&gt; s1; Mystack&lt;float&gt; s2; Mystack&lt;char&gt; s3; int choice; int int_elem; float float_elem; char char_elem; std::cout &lt;&lt; "Enter the type of stack" &lt;&lt; std::endl; std::cout &lt;&lt; "1. int "; std::cout &lt;&lt; "2. float "; std::cout &lt;&lt; "3. Char"&lt;&lt; std::endl; std::cin &gt;&gt; choice; if (choice == 1) { int ch = 1; while (ch &gt; 0) { std::cout &lt;&lt; "\n1. Push "; std::cout &lt;&lt; "2. Top "; std::cout &lt;&lt; "3. IsEmpty "; std::cout &lt;&lt; "4. Pop "; std::cout &lt;&lt; "5. Exit "; std::cout &lt;&lt; "6. Print"&lt;&lt;std::endl; std::cout &lt;&lt; "Enter the choice" &lt;&lt; std::endl; std::cin &gt;&gt; ch; switch (ch) { case 1: std::cout &lt;&lt; "Enter the number to be pushed" &lt;&lt; std::endl; std::cin &gt;&gt; int_elem; s1.push(int_elem); break; case 2: std::cout &lt;&lt; "Get the TOP Element" &lt;&lt; std::endl; try { s1.topElement(); } catch (std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error:" &lt;&lt; oor.what() &lt;&lt; std::endl; } break; case 3: std::cout &lt;&lt; "Check Empty" &lt;&lt; std::endl; s1.isEmpty(); break; case 4: std::cout &lt;&lt; "POP the element" &lt;&lt; std::endl; try { s1.pop(); } catch (const std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error: " &lt;&lt; oor.what() &lt;&lt; '\n'; } break; case 5: exit(0); case 6: s1.print(); break; default: std::cout &lt;&lt; "Enter a valid input"; break; } } } else if (choice == 2) { int ch = 1; while (ch &gt; 0) { std::cout &lt;&lt; "\n1. PUSH" &lt;&lt; std::endl; std::cout &lt;&lt; "2. TOP" &lt;&lt; std::endl; std::cout &lt;&lt; "3. IsEmpty" &lt;&lt; std::endl; std::cout &lt;&lt; "4. POP" &lt;&lt; std::endl; std::cout &lt;&lt; "5. EXIT" &lt;&lt; std::endl; std::cout &lt;&lt; "6. Print" &lt;&lt; std::endl; std::cout &lt;&lt; "Enter the choice" &lt;&lt; std::endl; std::cin &gt;&gt; ch; switch (ch) { case 1: std::cout &lt;&lt; "Enter the number to be pushed" &lt;&lt; std::endl; std::cin &gt;&gt; float_elem; s2.push(float_elem); break; case 2: std::cout &lt;&lt; "Get the TOP Element" &lt;&lt; std::endl; try { s2.topElement(); } catch (std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error:" &lt;&lt; oor.what() &lt;&lt; std::endl; } break; case 3: std::cout &lt;&lt; "Check Empty" &lt;&lt; std::endl; s2.isEmpty(); break; case 4: std::cout &lt;&lt; "POP the element" &lt;&lt; std::endl; try { s2.pop(); } catch (const std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error: " &lt;&lt; oor.what() &lt;&lt; '\n'; } break; case 5: exit(0); case 6: s2.print(); break; default: std::cout &lt;&lt; "Enter a valid input"; break; } } } else if (choice == 3) { int ch = 1; while (ch &gt; 0) { std::cout &lt;&lt; "\n1. PUSH" &lt;&lt; std::endl; std::cout &lt;&lt; "2. TOP" &lt;&lt; std::endl; std::cout &lt;&lt; "3. IsEmpty" &lt;&lt; std::endl; std::cout &lt;&lt; "4. POP" &lt;&lt; std::endl; std::cout &lt;&lt; "5. EXIT" &lt;&lt; std::endl; std::cout &lt;&lt; "6. Print" &lt;&lt; std::endl; std::cout &lt;&lt; "Enter the choice" &lt;&lt; std::endl; std::cin &gt;&gt; ch; switch (ch) { case 1: std::cout &lt;&lt; "Enter the number to be pushed" &lt;&lt; std::endl; std::cin &gt;&gt; char_elem; s3.push(char_elem); break; case 2: std::cout &lt;&lt; "Get the TOP Element" &lt;&lt; std::endl; try { s3.topElement(); } catch (std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error:" &lt;&lt; oor.what() &lt;&lt; std::endl; } break; case 3: std::cout &lt;&lt; "Check Empty" &lt;&lt; std::endl; s3.isEmpty(); break; case 4: std::cout &lt;&lt; "POP the element" &lt;&lt; std::endl; try { s3.pop(); } catch (const std::out_of_range &amp;oor) { std::cerr &lt;&lt; "Out of Range error: " &lt;&lt; oor.what() &lt;&lt; '\n'; } break; case 5: exit(0); case 6: s3.print(); break; default: std::cout &lt;&lt; "Enter a valid input"; break; } } } else std::cout &lt;&lt; "Invalid Choice"; std::cin.get(); } </code></pre>
0
How to read from a text file compressed with 7z?
<p>I would like to read (in Python 2.7), line by line, from a csv (text) file, which is 7z compressed. I don't want to decompress the entire (large) file, but to stream the lines.</p> <p>I tried <code>pylzma.decompressobj()</code> unsuccessfully. I get a data error. Note that this code doesn't yet read line by line:</p> <pre><code>input_filename = r"testing.csv.7z" with open(input_filename, 'rb') as infile: obj = pylzma.decompressobj() o = open('decompressed.raw', 'wb') obj = pylzma.decompressobj() while True: tmp = infile.read(1) if not tmp: break o.write(obj.decompress(tmp)) o.close() </code></pre> <p>Output:</p> <pre class="lang-none prettyprint-override"><code> o.write(obj.decompress(tmp)) ValueError: data error during decompression </code></pre>
0
Codeigniter Pagination From Database limit, offset
<p>I started a web application in CI 3.0, everything working smooth, I got my pagination working, but there is a problem wich I cannot figure out...</p> <p>For example, I have the following URL: <strong>localhost/statistics/api_based</strong> When navigate, $query results are displayed, links are generated, OK. But, when I navigate to <strong>page 2</strong> for example, the URL will become: <strong>localhost/statistics/dll_based/index/2</strong> and <strong>page 3</strong> will become <strong>localhost/statistics/api_based/index/3</strong> , so therefore I am using segments. Now the problem is the query that is generated:</p> <pre><code>SELECT * FROM `shield_api` ORDER BY `id` ASC limit 20 offset 2 </code></pre> <p><strong>offset 2</strong> - is the page number 2, and it should be 20, if I am correct. I am displaying 20 results per page, so first page is correctly showing results from 1 - 20, but then page 2 will display results from 2 - 21, so you get my point, it`s not OK...</p> <p>Here is my controller:</p> <pre><code>function index($offset = 0) { // Enable SSL? maintain_ssl ( $this-&gt;config-&gt;item ( "ssl_enabled" ) ); // Redirect unauthenticated users to signin page if (! $this-&gt;authentication-&gt;is_signed_in ()) { redirect ( 'account/sign_in/?continue=' . urlencode ( base_url () . 'statistics/api_based' ) ); } if ($this-&gt;authentication-&gt;is_signed_in ()) { $data ['account'] = $this-&gt;account_model-&gt;get_by_id ( $this-&gt;session-&gt;userdata ( 'account_id' ) ); } $per_page = 20; $qry = "SELECT * FROM `shield_api` ORDER BY `id` ASC"; //$offset = ($this-&gt;uri-&gt;segment ( 4 ) != '' ? $this-&gt;uri-&gt;segment ( 4 ) : 0); $config ['total_rows'] = $this-&gt;db-&gt;query ( $qry )-&gt;num_rows (); $config ['per_page'] = $per_page; $config ['uri_segment'] = 4; $config ['base_url'] = base_url () . '/statistics/api_based/index'; $config ['use_page_numbers'] = TRUE; $config ['page_query_string'] = FALSE; $config ['full_tag_open'] = '&lt;ul class="pagination"&gt;'; $config ['full_tag_close'] = '&lt;/ul&gt;'; $config ['prev_link'] = '&amp;laquo;'; $config ['prev_tag_open'] = '&lt;li&gt;'; $config ['prev_tag_close'] = '&lt;/li&gt;'; $config ['next_link'] = '&amp;raquo;'; $config ['next_tag_open'] = '&lt;li&gt;'; $config ['next_tag_close'] = '&lt;/li&gt;'; $config ['cur_tag_open'] = '&lt;li class="active"&gt;&lt;a href="#"&gt;'; $config ['cur_tag_close'] = '&lt;/a&gt;&lt;/li&gt;'; $config ['num_tag_open'] = '&lt;li&gt;'; $config ['num_tag_close'] = '&lt;/li&gt;'; $config ["num_links"] = round ( $config ["total_rows"] / $config ["per_page"] ); $this-&gt;pagination-&gt;initialize ( $config ); $data ['pagination_links'] = $this-&gt;pagination-&gt;create_links (); //$data ['per_page'] = $this-&gt;uri-&gt;segment ( 4 ); $data ['offset'] = $offset; $qry .= " limit {$per_page} offset {$offset} "; if ($data ['pagination_links'] != '') { $data ['pagermessage'] = 'Showing ' . ((($this-&gt;pagination-&gt;cur_page - 1) * $this-&gt;pagination-&gt;per_page) + 1) . ' to ' . ($this-&gt;pagination-&gt;cur_page * $this-&gt;pagination-&gt;per_page) . ' results, of ' . $this-&gt;pagination-&gt;total_rows; } $data ['result'] = $this-&gt;db-&gt;query ( $qry )-&gt;result_array (); $this-&gt;load-&gt;view ( 'statistics/api_based', isset ( $data ) ? $data : NULL ); } </code></pre> <p>Can someone point me to my problem ? Any help is apreciated.</p>
0
Reaver hanged up on waiting for beacon
<p>These are the commands I put into the terminal on my laptop.</p> <p><code> root@ubuntu:~# reaver -i mon0 -b F8:7B:7A:69:9F</code></p> <pre><code>Reaver v1.4 WiFi Protected Setup Attack Tool </code></pre> <p><code>Copyright (c) 2011, Tactical Network Solutions, Craig Heffner &lt;cheffner@tacnetsol.com&gt; </code></p> <pre><code>[+] Waiting for beacon from F8:7B:7A:69:9F:0F root@ubuntu:~# </code></pre> <p>This is what it says after brute forcing it</p> <p>F8:7B:7A:69:9F:0F -43 7 0 0 6 54 WPA2 CCMP PSK p</p> <p>Edit: It's been almost 5 years since this question was asked.</p> <h2>Question</h2> <p>What causes Reaver to be hanged up on beacon? Could it be a software problem with Linux itself? Can it be the security used in the network? What is it?</p>
0
Using .tupled method when companion object is in class
<p>I am in the process of migrating from Slick to Slick 2, and in Slick 2 you are meant to use the <code>tupled</code> method when projecting onto a case class (as shown here <a href="http://slick.typesafe.com/doc/2.0.0-RC1/migration.html" rel="nofollow noreferrer">http://slick.typesafe.com/doc/2.0.0-RC1/migration.html</a>)</p> <p>The problem is when the case class has a companion object, i.e. if you have something like this</p> <pre><code>case class Person(firstName:String, lastName:String) { } </code></pre> <p>Along with a companion object</p> <pre><code>object Person { def something = &quot;rawr&quot; } </code></pre> <p>In the same scope, the <code>tupled</code> method no longer works, because its trying to run <code>tupled</code> on the <code>object</code>, instead of the <code>case class</code>.</p> <p>Is there a way to retrieve the <code>case class</code> of <code>Person</code> rather than the <code>object</code>, so you can call <code>tupled</code> properly?</p>
0
JQuery DatePicker: How to add a custom class
<p>I need to apply a custom style to my datepicker but can't work out how to add a custom class to the datepicker. I am defining my date picker as follows:</p> <pre><code> $("#From").datepicker({ showOn: 'button', buttonImage: '/Content/images/icon-calendar.gif', buttonImageOnly: true }, $.datepicker.regional['en-GB']); </code></pre> <p>How do I add a custom class to the datepicker div?</p> <pre><code>&lt;div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible MY_CLASS_GOES_HERE" id="ui-datepicker-div" style="position: absolute; top: 154px; left: 499px; z-index: 1; display: none;"&gt; </code></pre> <p>I know I can write:</p> <p><code>$("#ui-datepicker-div).addClass("MY_CLASS_GOES_HERE")</code> </p> <p>..but can I rely on the datepicker always having an ID of "ui-datepicker-div"?? Is their a more elegant way of doing this?</p> <p>Thanks in advance.</p>
0
U2U Caml Query Builder no longer available?
<p>I'm trying to download the fantastic U2U Caml Query Builder but all the links I'm finding are dead and I can't find any references to it on the u2u site. Has it been end-of-lifed? Does anyone know of a location where it is still available from?</p> <p>Dead link - <a href="http://www.u2u.be/res/tools/camlquerybuilder.aspx" rel="nofollow">http://www.u2u.be/res/tools/camlquerybuilder.aspx</a></p> <p>new link: <a href="http://www.u2u.be/Software" rel="nofollow">http://www.u2u.be/Software</a></p>
0
Google Chart arrayToDataTable formatted value not working
<p>I am followinf the google Chart documentation for <a href="https://google-developers.appspot.com/chart/interactive/docs/datatables_dataviews?hl=en#arraytodatatable" rel="nofollow">arrayToDataTable</a> and the example states that I can use formatted values, like that:</p> <pre><code>var data = google.visualization.arrayToDataTable([ ['Employee Name', 'Salary'], ['Mike', {v:22500, f:'18,500'}], ... </code></pre> <p>where <strong>f:'18,500</strong> is the formatted value to show. My code looks identical:</p> <pre><code>var data = google.visualization.arrayToDataTable([ ['Category', 'Amount'], ['Food', {v:5595.819984, f:'5.595,82'}], ['Home', {v:1890.530002, f:'1.890,53'}], ['Mail', {v:8.380000, f:'8,38'}], ['Train', {v:564.899998, f:'564,90'}], ['Photo', {v:959.119995, f:'959,12'}], ['Lego', {v:428.760004, f:'428,76'}], ... </code></pre> <p>but the chart does not even shows, crashing. If I take out the formatted data, it works perfectly. What I am doing wrong? How can I use a better looking version to show the values on the chart? </p>
0
MSB3411 Could not load Visual C++ component
<p>I have MS Visual Studio 2012 Ultimate and OS is Windows 7, and have nodeJs installed.I wanted to install socket.io using npm,but I get the following error.</p> <pre><code>C:\Users\NEW&gt;npm install socket.io npm http GET https://registry.npmjs.org/socket.io npm http 304 https://registry.npmjs.org/socket.io npm http GET https://registry.npmjs.org/socket.io-client/0.9.11 npm http GET https://registry.npmjs.org/policyfile/0.0.4 npm http GET https://registry.npmjs.org/base64id/0.1.0 npm http GET https://registry.npmjs.org/redis/0.7.3 npm http 304 https://registry.npmjs.org/socket.io-client/0.9.11 npm http 304 https://registry.npmjs.org/base64id/0.1.0 npm http 304 https://registry.npmjs.org/policyfile/0.0.4 npm http 304 https://registry.npmjs.org/redis/0.7.3 npm http GET https://registry.npmjs.org/uglify-js/1.2.5 npm http GET https://registry.npmjs.org/ws npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2 npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1 npm http 304 https://registry.npmjs.org/ws npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2 npm http 304 https://registry.npmjs.org/uglify-js/1.2.5 npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1 npm http GET https://registry.npmjs.org/zeparser/0.0.5 npm http GET https://registry.npmjs.org/tinycolor npm http GET https://registry.npmjs.org/commander npm http GET https://registry.npmjs.org/options npm http 304 https://registry.npmjs.org/zeparser/0.0.5 npm http 304 https://registry.npmjs.org/commander npm http 304 https://registry.npmjs.org/tinycolor npm http 304 https://registry.npmjs.org/options &gt; ws@0.4.25 install C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-c lient\node_modules\ws &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0) C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-client\node_modules\w s&gt;node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo dules\node-gyp\bin\node-gyp.js" rebuild Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008. [C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-clie nt\node_modules\ws\build\binding.sln] MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008. [C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-clie nt\node_modules\ws\build\binding.sln] socket.io@0.9.13 node_modules\socket.io ├── base64id@0.1.0 ├── policyfile@0.0.4 ├── redis@0.7.3 └── socket.io-client@0.9.11 (xmlhttprequest@1.4.2, uglify-js@1.2.5, active-x-obf uscator@0.0.1, ws@0.4.25) </code></pre> <p>What might be the issue?How can I fix it? </p>
0
Class Based Views VS Function Based Views
<p>I always use FBVs (Function Based Views) when creating a django app because it's very easy to handle. But most developers said that it's better to use CBVs (Class Based Views) and use only FBVs if it is complicated views that would be a pain to implement with CBVs. </p> <p>Why? What are the advantages of using CBVs? </p>
0
kubectl port forwarding timeout issue
<p>While using kubectl port-forward function I was able to succeed in port forwarding a local port to a remote port. However it seems that after a few minutes idling the connection is dropped. Not sure why that is so.</p> <p>Here is the command used to portforward:</p> <pre><code>kubectl --namespace somenamespace port-forward somepodname 50051:50051 </code></pre> <p>Error message:</p> <pre><code>Forwarding from 127.0.0.1:50051 -&gt; 50051 Forwarding from [::1]:50051 -&gt; 50051 E1125 17:18:55.723715 9940 portforward.go:178] lost connection to pod </code></pre> <p>Was hoping to be able to keep the connection up</p>
0
when i wrote in my "npm cache clean" this error is occurring "npm ERR! Windows_NT 6.3.9600 npm ERR! argv
<p>when i wrote in my "npm cache clean" this error is occurring "npm ERR! Windows_NT 6.3.9600 npm ERR! argv</p> <pre><code>C:\iaAC&gt;npm cache clean npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs \\node_modules\\npm\\bin\\npm-cli.js" "cache" "clean" npm ERR! node v0.12.3 npm ERR! npm v2.9.1 npm ERR! path C:\Users\AKASH\AppData\Roaming\npm-cache npm ERR! code EPERM npm ERR! errno -4048 npm ERR! Error: EPERM, rmdir 'C:\Users\AKASH\AppData\Roaming\npm-cache' npm ERR! at Error (native) npm ERR! { [Error: EPERM, rmdir 'C:\Users\AKASH\AppData\Roaming\npm-cache'] npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! path: 'C:\\Users\\AKASH\\AppData\\Roaming\\npm-cache' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! C:\iaAC\npm-debug.log </code></pre> <p>Edit: Cleanup</p>
0
Choose camera in file upload in cordova application on android without using cordova camera
<p>So i made a cordova app, i added android platform and made a simple html with an imput field</p> <pre><code>&lt;input type="file" capture="camera" accept="image/*" id="takePictureField"&gt; </code></pre> <p>I have added </p> <pre><code>&lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt; &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt; &lt;feature name="http://api.phonegap.com/1.0/camera" /&gt; </code></pre> <p>to the manifest file.</p> <p>but when i press the button I cannot choose to take a new picture with the camera. are there any permission i miss, or anything else ??</p> <p>I cannot use the cordova take picture functions, it has to be done in pure html.</p>
0
Encode String to UTF-8
<p>I have a String with a "ñ" character and I have some problems with it. I need to encode this String to UTF-8 encoding. I have tried it by this way, but it doesn't work:</p> <pre><code>byte ptext[] = myString.getBytes(); String value = new String(ptext, "UTF-8"); </code></pre> <p>How do I encode that string to utf-8?</p>
0
docker compose variable substitution
<p>It seems that I am not understanding something about variable substitution in the following page (my variable <code>NUM</code> is not registering): <a href="https://github.com/compose-spec/compose-spec/blob/master/spec.md#Interpolation" rel="nofollow noreferrer">https://github.com/compose-spec/compose-spec/blob/master/spec.md#Interpolation</a></p> <p>See screenshot below. Running this on mac OSX.</p> <p><a href="https://i.stack.imgur.com/WDS8J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WDS8J.png" alt="docker-compose up" /></a></p>
0
Using Twitter Bootstrap together with Wordpress
<p>How do I use Wordpress together with Twitter Bootstrap? I know how to set up a Wordpress page and I've already worked with Bootstrap, but now I want to use these two together for the first time.</p> <p>For my Wordpress projects I normally just installed Wordpress and started from scratch with creating a new theme. For my Bootstrap projects I always used Initializr to build a template.</p> <p>Now using Google I found various "Bootstrap themes" and plugins , do I need one of those? I want to customize the bootstrap look with my own colors etc. using LESS, that's why I am asking. I am just having trouble to understand how these two will work together and I haven't found any good resource for it.</p>
0
java packages: cannot find symbol
<p>I'm having a strange error. I have 2 classes in the same package but they can't find each other. From what I remember, as long as the classes are in the same package, they should be able to call each other's methods. </p> <p>My code looks similar to this:</p> <p>in A.java:</p> <pre><code>package com.mypackage; public class A{ public static int read(){ //some code } } </code></pre> <p>in B.java:</p> <pre><code>package com.mypackage; public class B{ public static void main(String args[]){ int x = A.read(); } } </code></pre> <p>and it's giving me a <code>cannot find symbol variable A</code> error.</p> <p>Both of these classes depend on some <code>.jar</code> files, but I've already included the path of those jars to <code>CLASSPATH</code> and <code>A.java</code> compiled fine, but B can't find A for some reasons...</p> <p>When I remove the <code>package com.mypackage;</code> in both classes then they compile fine. </p>
0
SparseCheckout in Jenkinsfile pipeline
<p>In a jenkinsfile, I have specified the folderName through <strong>SparseCheckoutPaths</strong> which I want to checkout. But I am getting a whole branch checkout instead.</p> <pre><code> checkout([$class: 'GitSCM', branches: [[name: '*/branchName']], extensions: [[$class: 'SparseCheckoutPaths', path: 'FolderName']], userRemoteConfigs: [[credentialsId: 'someID', url: 'git@link.git']]]) </code></pre>
0
Remove multiple items from list in Python
<p>So, for example, I got a list: <code>myList=["asdf","ghjk","qwer","tyui"]</code><br> I also have a list of index numbers of the items I want to remove: <code>removeIndexList=[1,3]</code> (I want to remove items 1 and 3 from the list above)</p> <p>What would be the best way to do this?</p>
0
How to use TLS 1.2 in Java 6
<p>It seems that Java 6 supports TLS up to v1.0, is there any way to use TLS 1.2 in Java 6?</p> <p>Maybe a patch or a particular update of Java 6 will have support for it?</p>
0
Flutter - Container width and height fit parent
<p>I have a <code>Card</code> widget which includes <code>Column</code> with several other Widgets. One of them is <code>Container</code>.</p> <pre><code>Widget _renderWidget() { return Column( children: &lt;Widget&gt;[ Visibility( visible: _isVisible, child: Container( width: 300, height: 200, decoration: BoxDecoration(border: Border.all(color: Colors.grey)), child: ListView.builder( itemCount: titles.length, itemBuilder: (context, index) { return Card( child: ListTile( leading: Icon(icons[index]), title: Text(titles[index]), ), ); }, )), ), ], ); } </code></pre> <p>Here, if I don't specify <code>width</code> and <code>height</code> I get error. But, is there a way to make them to fit parent element?</p> <p><strong>EDIT</strong></p> <p>Full code:</p> <pre><code>return ListView( children: &lt;Widget&gt;[ Center( child: Container( child: Card( margin: new EdgeInsets.all(20.0), child: new Container( margin: EdgeInsets.all(20.0), width: double.infinity, child: Column( children: &lt;Widget&gt;[ FormBuilder( key: _fbKey, autovalidate: true, child: Column( children: &lt;Widget&gt;[ FormBuilderDropdown( onChanged: (t) { setState(() { text = t.vrsta; }); }, validators: [FormBuilderValidators.required()], items: user.map((v) { return DropdownMenuItem( value: v, child: ListTile( leading: Image.asset( 'assets/img/car.png', width: 50, height: 50, ), title: Text("${v.vrsta}"), )); }).toList(), ), ], ), ), Container(child: _renderWidget()), text.isEmpty ? Container() : RaisedButton( child: Text("Submit"), onPressed: () { _fbKey.currentState.save(); if (_fbKey.currentState.validate()) { print(_fbKey.currentState.value.toString()); print(formData.startLocation); getAutocomplete(); } }, ) ], ), )), ), ), ], ); } </code></pre>
0
Get the number of digits in an int
<p>How do I detect the length of an integer? In case I had le: int test(234567545);</p> <p>How do I know how long the int is? Like telling me there is 9 numbers inside it??? </p> <p>*I have tried:**</p> <pre><code>char buffer_length[100]; // assign directly to a string. sprintf(buffer_length, "%d\n", 234567545); string sf = buffer_length; cout &lt;&lt;sf.length()-1 &lt;&lt; endl; </code></pre> <p>But there must be a simpler way of doing it or more clean...</p>
0
How to move a marker in Google Maps API
<p>I'm using the Google Maps API V3 and I'm trying to make a marker move across the screen. Here's what I have:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt; &lt;style type="text/css"&gt; html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } &lt;/style&gt; &lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; function initialize() { var myLatLng = new google.maps.LatLng(50,50); var myOptions = { zoom: 4, center: myLatLng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); image = 'bus.gif'; marker = new google.maps.Marker({position: myLatLng, map: map, icon: image}); marker.setMap(map); } function moveBus() { // Move Bus } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()"&gt; &lt;script type="text/javascript"&gt; moveBus(); &lt;/script&gt; &lt;div id="map_canvas" style="height: 500px; width: 500px;"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now what I've tried is replacing // Move Bus with</p> <pre><code>marker.setPosition(new google.maps.LatLng(0,0)); </code></pre> <p>But that didn't do anything. That's the command I saw on the API reference. I'm also relatively new to Javascript, so it might be a JS error on my part.</p>
0
Cannot disable transition animation when back button is clicked
<p>When I click the back button to go back to previous activity, the transition slide still occur even though I have added overridePendingTransition. What is wrong with my code?</p> <p>I want to disable all transition between the activities. There is no animation on transition when going to new activity but slide out when back button is pressed.</p> <pre><code>Activity act; Intent intent = new Intent(act, newactivity.class); intent.setFlags(65536); act.startActivity(intent); act.overridePendingTransition(0, 0); </code></pre>
0
How to validate TextBox value is string in C# Windows Form application
<p>I'm using a TextBox to enter user's name, here I want to <strong>validate that box only having alphabets</strong> which is starting with capital and continues with simple letters. For that I use the following code, even though its validating but if I enter a number after some alphabates it is not identifying that, please some one help me to find the problem.</p> <pre><code>if (!Regex.IsMatch(textBox3.Text, @"[a-zA-Z]")) { errorProvider2.SetError(textBox3, "Only use alphabates"); } </code></pre>
0
Figure out if a table has a DELETE on CASCADE
<p>Can I know if a database have <code>DELETE ON CASCADE</code> with a query?</p>
0
Change iOS view / view controller using swipe gesture
<p>How can I implement a swipe gesture to change view to and fro?</p> <p>The best example I've seen so far is the Soundcloud application but I couldn't figure out how to make it work.</p>
0
invokedynamic requires --min-sdk-version >= 26
<p>Today downloaded the studio 3.0 beta 2.0 version, after that tried to open an existing project in it and faced some difficulties, most of them I could solve with the help of Google and Stack Overflow, but this one I can not. </p> <pre><code>Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'. &gt; com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version &gt;= 26) </code></pre> <p>Also posting my app gradle </p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.intersoft.snappy" minSdkVersion 19 targetSdkVersion 22 multiDexEnabled true versionCode 1 versionName "1.0" } buildTypeMatching 'dev', 'debug' buildTypeMatching 'qa', 'debug' buildTypeMatching 'rc', 'release' buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } } packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1' } } repositories { mavenCentral() mavenLocal() jcenter() maven { url "https://plugins.gradle.org/m2/" } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } maven { url "https://jitpack.io" } maven { url 'https://dl.bintray.com/ashokslsk/CheckableView' } maven { url "https://maven.google.com" } } android { useLibrary 'org.apache.http.legacy' } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:26.0.1' implementation 'com.github.mrengineer13:snackbar:1.2.0' implementation 'com.android.support:recyclerview-v7:26.0.1' implementation 'com.android.support:cardview-v7:26.0.1' implementation 'com.android.support:design:26.0.1' implementation 'com.android.support:percent:26.0.1' implementation 'dev.dworks.libs:volleyplus:+' implementation 'com.google.guava:guava:21.0' implementation 'com.facebook.fresco:fresco:1.0.1' implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'com.wdullaer:materialdatetimepicker:3.1.1' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.github.stfalcon:frescoimageviewer:0.4.0' implementation 'com.github.piotrek1543:CustomSpinner:0.1' implementation 'com.android.support:multidex:1.0.2' implementation 'com.github.satyan:sugar:1.4' implementation 'com.hedgehog.ratingbar:app:1.1.2' implementation project(':sandriosCamera') implementation('org.apache.httpcomponents:httpmime:4.2.6') { exclude module: 'httpclient' } implementation 'com.googlecode.json-simple:json-simple:1.1' } afterEvaluate { tasks.matching { it.name.startsWith('dex') }.each { dx -&gt; if (dx.additionalParameters == null) { dx.additionalParameters = ['--multi-dex'] } else { dx.additionalParameters += '--multi-dex' } } } subprojects { project.plugins.whenPluginAdded { plugin -&gt; if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) { project.android.dexOptions.preDexLibraries = false } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { project.android.dexOptions.preDexLibraries = false } } } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' } } apply plugin: 'com.jakewharton.hugo' </code></pre> <p>also my another module gradle</p> <pre><code>apply plugin: 'com.android.library' apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.dcendents.android-maven' buildscript { repositories { jcenter() jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' } } group = 'com.sandrios.android' version = '1.0.8' ext { PUBLISH_GROUP_ID = 'com.sandrios.android' PUBLISH_ARTIFACT_ID = 'sandriosCamera' PUBLISH_VERSION = '1.0.8' PUBLISH_CODE = 9 } android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { minSdkVersion 19 targetSdkVersion 25 versionCode PUBLISH_CODE versionName PUBLISH_VERSION } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError false } } task generateSourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier 'sources' } task generateJavadocs(type: Javadoc) { failOnError false source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath() .join(File.pathSeparator)) } task generateJavadocsJar(type: Jar) { from generateJavadocs.destinationDir classifier 'javadoc' } generateJavadocsJar.dependsOn generateJavadocs artifacts { archives generateSourcesJar archives generateJavadocsJar } install { repositories.mavenInstaller { pom.project { name PUBLISH_GROUP_ID description 'Simple integration of universal camera in android for easy image and video capture.' url 'https://github.com/sandrios/sandriosCamera' inceptionYear '2016' packaging 'aar' version PUBLISH_VERSION scm { connection 'https://github.com/sandrios/sandriosCamera.git' url 'https://github.com/sandrios/sandriosCamera' } developers { developer { name 'arpitgandhi9' } } } } } bintray { Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) user = properties.getProperty('bintray.user') key = properties.getProperty('bintray.apikey') configurations = ['archives'] pkg { repo = 'android' name = 'sandriosCamera' userOrg = 'sandriosstudios' desc = 'Android solution to simplify work with different camera apis.' licenses = ['MIT'] labels = ['android', 'camera', 'photo', 'video'] websiteUrl = 'https://github.com/sandrios/sandriosCamera' issueTrackerUrl = 'https://github.com/sandrios/sandriosCamera/issues' vcsUrl = 'https://github.com/sandrios/sandriosCamera.git' version { name = PUBLISH_VERSION vcsTag = PUBLISH_VERSION desc = 'Minor fixes.' released = new Date() } } } repositories { jcenter() } dependencies { implementation 'com.android.support:support-v4:26.0.0' implementation 'com.android.support:appcompat-v7:26.0.0' implementation 'com.android.support:recyclerview-v7:26.0.0' implementation 'com.github.bumptech.glide:glide:3.6.1' implementation 'com.yalantis:ucrop:2.2.0' implementation 'gun0912.ted:tedpermission:1.0.2' } </code></pre> <p>and also project level gradle</p> <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } </code></pre> <p>please help me to get rid of this error</p>
0
Set result format of Facebook Graph API to XML instead of JSON
<p>I'm trying to change the format of the result i get from the facebook graph api to XML.</p> <p>I use the format=xml parameter but that don't seem to work for me.</p> <p><a href="https://graph.facebook.com/me&amp;access_token=xxxxxxxxxxxx&amp;format=xml" rel="nofollow">https://graph.facebook.com/me&amp;access_token=xxxxxxxxxxxx&amp;format=xml</a></p> <p>The result is shown in Json format :(</p> <p>Is it still posible to use the xml format?</p>
0
Check if PID exists in Bash
<p>I want to stall the execution of my BASH script until a process is closed (I have the PID stored in a variable). I'm thinking</p> <pre><code>while [PID IS RUNNING]; do sleep 500 done </code></pre> <p>Most of the examples I have seen use /dev/null which seems to require root. Is there a way to do this without requiring root?</p> <p>Thank you very much in advance!</p>
0
sed script to print the first three words in each line
<p>I wonder how can I do the following thing with sed: I need to keep only the first three words in each line. For example, the following text:</p> <pre><code>the quick brown fox jumps over the lazy bear the blue lion is hungry </code></pre> <p>will be transformed in:</p> <pre><code>the quick brown the blue lion </code></pre>
0
python - webdriver and asyncio
<p>Is it possible open browser for each task firstly, and load links after that ? This code raises an error </p> <pre><code>import asyncio from selenium import webdriver async def get_html(url): driver = await webdriver.Chrome() response = await driver.get(url) </code></pre> <p>TypeError: object WebDriver can't be used in 'await' expression</p>
0
Cannot understand numpy argpartition output
<p>I am trying to use arpgpartition from numpy, but it seems there is something going wrong and I cannot seem to figure it out. Here is what's happening:</p> <p>These are first 5 elements of the sorted array <code>norms</code></p> <pre><code>np.sort(norms)[:5] array([ 53.64759445, 54.91434479, 60.11617279, 64.09630585, 64.75318909], dtype=float32) </code></pre> <p>But when I use <code>indices_sorted = np.argpartition(norms, 5)[:5]</code></p> <pre><code>norms[indices_sorted] array([ 60.11617279, 64.09630585, 53.64759445, 54.91434479, 64.75318909], dtype=float32) </code></pre> <p>When I think I should get the same result as the sorted array?</p> <p>It works just fine when I use 3 as the parameter <code>indices_sorted = np.argpartition(norms, 3)[:3]</code></p> <pre><code>norms[indices_sorted] array([ 53.64759445, 54.91434479, 60.11617279], dtype=float32) </code></pre> <p>This isn't making much sense to me, hoping someone can offer some insight?</p> <p>EDIT: Rephrasing this question as whether argpartition preserves order of the k partitioned elements makes more sense.</p>
0
Better way for Getting id of the clicked Object in JavaFX controller
<p>I`m looking for a better way for getting the id of the clicked object inside the event handler for this object.</p> <p>I already found this:</p> <p><a href="https://stackoverflow.com/questions/14085076/javafx-pass-fxid-to-controller-or-parameter-in-fxml-onaction-method">javafx pass fx:id to controller or parameter in fxml onAction method</a></p> <p>But that did not work for me.</p> <p>Now I'm using the getId() function of the node class like this:</p> <pre><code>Button btn = (Button) event.getSource(); String id = btn.getId(); </code></pre> <p>But i want to use this method not only for buttons.</p>
0
Nginx variable for subdomain?
<p>I need a Guru's advice.</p> <p>On Nginx's <code>conf</code> file, I would like to get the subdomain as a variable in order to redirect accesses as follow.</p> <ul> <li>ACCESS: <code>http://userX.example.com/?hoo=bar</code></li> <li>REDIRECT: <code>http://example.com/userX/?hoo=bar</code></li> </ul> <p>But I get</p> <ul> <li>REDIRECT: <code>http://example.com/userX.example.com/?hoo=bar</code></li> </ul> <p>My current <code>_http.conf</code> settings are like below. So obviously it works so.</p> <pre><code>## default HTTP server { listen 80; server_name default_server; return 301 http://example.com/$host$request_uri; } </code></pre> <p>Are there any vaiables or ways to do like below?</p> <pre><code>## default HTTP server { listen 80; server_name default_server; return 301 http://example.com/$subdomain$request_uri; } </code></pre> <p>I know if the subdomain part is limited it can be redirected, but I have to add them each time and I want it to keep as simple as possible.</p> <p>Is there any simple way to do so?</p> <p><strong>[ENV]</strong>: CentOS:7.3.1611, nginx: nginx/1.13.3, *.example.com is targetted to the same server in NS settings.</p> <hr> <h3>Conclusion (2017/12/13)</h3> <p>Use a regular expression:</p> <pre><code>server { listen 80; server_name ~^(?&lt;subdomain&gt;.+)\.example\.com$; return 301 http://example.com/$subdomain$request_uri; } </code></pre> <p>Ref: <a href="https://stackoverflow.com/questions/45318758/nginx-variable-for-subdomain/45321927#45321927">Comment</a>, <a href="http://nginx.org/en/docs/http/server_names.html#regex_names" rel="noreferrer">Document</a></p>
0
How To Select multiple cells in DataGridView
<p>I have a DataGridView in my Form. The Functionality is as below.</p> <ul> <li>Clicking on header selects the whole column.</li> <li>Clicking on any cell other than the column header selects the entire row</li> </ul> <p>I have set multiselect to true. I am able to select multiple cells by using the mouse. but I want to do it programmatically.</p>
0
Why is the first item in select menu always empty?
<p>Using CakePHP, I created select-option form element with:</p> <pre><code>echo $form-&gt;select('items', $numeration , array('selected' =&gt; 0)); </code></pre> <p>It creates selection box, but the first option is always empty.</p> <p>How can I get rid of that empty option? I did not manage to do anything with <code>showEmpty</code> option...</p> <p>please help.... :-((</p> <p>UPDATED: </p> <p>cakephp code </p> <pre><code>echo $form-&gt;select('myOptions', array(1 =&gt; 'a', 2 =&gt; 'b', 3 =&gt; 'c'), array('empty'=&gt;false)); </code></pre> <p>creates next html:</p> <pre><code>&lt;select id="myOptions" name="data[myOptions]"&gt; &lt;option selected="selected" value=""&gt;&lt;/option&gt; &lt;option value="1"&gt;a&lt;/option&gt; &lt;option value="2"&gt;b&lt;/option&gt; &lt;option value="3"&gt;c&lt;/option&gt; &lt;/select&gt; </code></pre> <p>what is wrong, and why do i have empty element?!</p>
0
Python slice how-to, I know the Python slice but how can I use built-in slice object for it?
<p>What's the use of built-in function <code>slice</code> and how can I use it?<br> The direct way of Pythonic slicing I know - <code>l1[start:stop:step]</code>. I want to know if I have a slice object, then how do I use it?</p>
0
How can I get a Unicode character's code?
<p>Let's say I have this:</p> <pre><code>char registered = '®'; </code></pre> <p>or an <code>umlaut</code>, or whatever unicode character. How could I get its code?</p>
0
Dialog Box like JOptionPane in JavaFX
<p>I found this article <a href="http://code.makery.ch/blog/javafx-2-dialogs/" rel="nofollow noreferrer">JavaFX 2 Dialogs</a> and I am using it. But this dialog accepts only Stage Object. Is there any option to display dialog box which will accept AnchorPane as its parent. That Is similar to JoptionPane where we can pass any object which are derived from Component for example JPanel, JTitlePane, etc. And the dialog box I am using it is bieng display on task bar of windows also (passing null as parent). I want show a message like this </p> <p><img src="https://i.stack.imgur.com/sd1vR.png" alt="enter image description here"></p> <p>Is it possible to display an AnchorPane to the top of the other AnchorPane or TableView like the attached picture which will be modal as well?</p>
0
$http request before AngularJS app initialises?
<p>In order to determine if a user's session is authenticated, I need to make a $http request to the server before the first route is loaded. Before each route is loaded, an authentication service checks the status of the user and the access level required by the route, and if the user isn't authenticated for that route, it redirects to a login page. When the app is first loaded however, it has no knowledge of the user, so even if they have an authenticated session it will always redirect to the login page. So to fix this I'm trying to make a request to the server for the users status as a part of the app initialisation. The issue is that obviously $http calls are asynchronous, so how would I stop the app running until the request has finished?</p> <p>I'm very new to Angular and front-end development in general, so my issue maybe a misunderstanding of javascript rather than of Angular. </p>
0
Removing double quotes from a string in Java
<p>How would I remove double quotes from a String?</p> <p>For example: I would expect <code>"abd</code> to produce <code>abd</code>, without the double quote.</p> <p>Here's the code I've tried:</p> <pre><code>line1 = line1.replaceAll("\"(\\b[^\"]+|\\s+)?\"(\\b[^\"]+\\b)?\"([^\"]+\\b|\\s+)?\"","\"$1$2$3\""); </code></pre>
0
How to handle Visual Studio 2010 Not Responding?
<p>First of all, I am not asking the same question here. ( This may be a duplicate post on Stack Overflow.) I have searched other solutions on <strong>MSDN</strong>, <strong>ASP .NET Forum</strong>, <strong>Stack Overflow</strong>, <strong>Code Project</strong> and everywhere on internet. But none of them solved my problem. These are the links that I found:</p> <p><a href="http://blogs.msdn.com/b/kirillosenkov/archive/2012/01/11/vs-hangs-for-1-minute-on-start-debugging-check-for-dead-symbol-paths.aspx" rel="noreferrer">http://blogs.msdn.com/b/kirillosenkov/archive/2012/01/11/vs-hangs-for-1-minute-on-start-debugging-check-for-dead-symbol-paths.aspx</a></p> <p><a href="http://www.codeproject.com/Questions/272109/Visual-Studio-2010-Hangs-When-Debugging-App" rel="noreferrer">http://www.codeproject.com/Questions/272109/Visual-Studio-2010-Hangs-When-Debugging-App</a></p> <p>And a lot more...</p> <p>My <strong>CPU</strong> is 4th Generation Intel Core i7 and <strong>memory</strong> capacity is 8 GB. I think it is more than recommended hardware requirements.</p> <p><strong>Problem:</strong> My visual studio hangs on these situations.</p> <ol> <li>Opening a solution (Hangs for a minute when I open a file from solution explorer)</li> <li>Running the debugging (Freezes consistently when I click on debug button) and</li> <li>Stopping the debugging (Freezes immediately after the UI returns to the Developer layout after debugging)</li> </ol> <p><strong>I have tried the following steps</strong>:</p> <ol> <li>I ensured that I deleted all the breakpoints in the solution.</li> <li>I ensured that I am not using any resources from network drive. </li> <li>I ensured Step over properties is enabled.</li> <li>I ensured Enable .NET Framework source stepping is NOT enabled.</li> <li>I start visual studio with <code>SafeMode</code> to suppress extensions</li> <li>I cleared watch window.</li> <li>I cleaned and rebuilt the solution.</li> </ol> <p>Before I encounter this problem, I installed "Install Web Components" Visual Studio Add-In a few weeks ago. May be because of extensions and add-ins?</p> <p>How can I do it to solve my problem?</p>
0
RTSP with iOS 8
<p>My partner and I are developing an app for a client where they have a camera that connects to the app. Currently it is running in http but we want to use RTSP. We scraped the internet today to look for possible ideas, but they all seem outdated. </p> <p>We tried incorporating <a href="https://github.com/durfu/DFURTSPPlayer" rel="nofollow">DFURTSPPlayer</a> but kept getting compile errors that were related to the actual SDK.</p> <p>We want to use something like <a href="http://www.videostreamsdk.com/" rel="nofollow">VideoStreamSDK</a>.</p> <p>Does anyone have any ways they can point us towards?</p> <p>Thanks!</p>
0
how to represent enter key as char in c Language?
<p>I have tried this :</p> <pre><code>switch(c) case 13 : {printf("enter pressed");break;} </code></pre> <p>and this :</p> <pre><code>switch(c) case '\n' : {printf("enter pressed");break;} </code></pre> <p>but It didn't work out </p>
0
select distinct and one another column of the id
<p>I have a table with multiple columns but I need only 2.</p> <pre class="lang-sql prettyprint-override"><code>select id, department from tbl </code></pre> <p>If I want to use <code>distinct</code>, how do I do that? This is not working:</p> <pre class="lang-sql prettyprint-override"><code>select id, distinct department from tbl </code></pre>
0
Redirect C++ std::clog to syslog on Unix
<p>I work on Unix on a C++ program that send messages to syslog.</p> <p>The current code uses the <strong>syslog</strong> system call that works like printf.</p> <p>Now I would prefer to use a stream for that purpose instead, typically the built-in <strong>std::clog</strong>. But clog merely redirect output to stderr, not to syslog and that is useless for me as I also use stderr and stdout for other purposes.</p> <p>I've seen in <a href="https://stackoverflow.com/questions/665509/redirecting-standard-output-to-syslog">another answer</a> that it's quite easy to redirect it to a file using rdbuf() but I see no way to apply that method to call syslog as openlog does not return a file handler I could use to tie a stream on it.</p> <p>Is there another method to do that ? (looks pretty basic for unix programming) ? </p> <p><strong>Edit:</strong> I'm looking for a solution that does not use external library. What @Chris is proposing could be a good start but is still a bit vague to become the accepted answer.</p> <p><strong>Edit</strong>: using Boost.IOStreams is OK as my project already use Boost anyway.</p> <p>Linking with external library is possible but is also a concern as it's GPL code. Dependencies are also a burden as they may conflict with other components, not be available on my Linux distribution, introduce third-party bugs, etc. If this is the only solution I may consider completely avoiding streams... (a pity).</p>
0
How to define a connection string to a SQL Server 2008 database?
<p>I'm using MS Visual Studio 2010 to create an application with SQL Server 2008 database access, but what I did to create the database was add a new "SQL Server 2008 Database Project", it added it, and shows me everything on my Solution Explorer, but how do I write the connection string to connect to it, because I wrote this one, and it didn't work.</p> <pre><code>SqlConnection cnTrupp = new SqlConnection("Initial Catalog = Database;Data Source = localhost;Persist Security Info=True;"); </code></pre> <p>update:</p> <p>I used this one:</p> <pre><code>cnTrupp = new SqlConnection("database=DB_Trupp;server=.\\SQLExpress;Persist Security Info=True;integrated security=SSPI"); </code></pre> <p>But when I use the <code>cnTrupp.Open()</code> it tells me that the login failed.</p>
0
Android SkImageDecoder::Factory returned null Error
<p>I'm trying to load an image from URL to an ImageView but the error occurs: SkImageDecoder::Factory returned null. How can I fix it?</p> <p>here is my code :</p> <pre><code>private class LoadImageFromURL extends AsyncTask&lt;String, Void, Bitmap&gt;{ ImageView bitmapImgView; public LoadImageFromURL(ImageView bmImgView){ bitmapImgView = bmImgView; } @Override protected Bitmap doInBackground(String... params) { // TODO Auto-generated method stub String urlStr = params[0]; Bitmap img = null; try { URL url = new URL(urlStr); InputStream inputStream = url.openConnection().getInputStream(); //Options bmFactoryOpt = new Options(); //bmFactoryOpt.inJustDecodeBounds = false; img = BitmapFactory.decodeStream(inputStream); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return img; } @Override protected void onPostExecute(Bitmap bitmap){ bitmapImgView.setImageBitmap(bitmap); } } </code></pre>
0
How do I click depending on state of toggle switch?
<p>I have a toggle switch I want to click depending on what the switch state is.</p> <p>If it is "span.switch-right" I want to do:</p> <pre><code>findElement(By.cssSelector("span.switch-left")).click(); </code></pre> <p>If it is "span.switch-left" I want to do:</p> <pre><code>findElement(By.cssSelector("span.switch-right")).click(); </code></pre> <p>HTML:</p> <pre><code>&lt;div tabindex="0" class="has-switch switch-on switch-animate"&gt; &lt;div&gt; &lt;span class="switch-left"&gt;ON&lt;/span&gt; &lt;label for="profile_isProfileSharedWithNearby"&gt;&amp;nbsp;&lt;/label&gt; &lt;span class="switch-right"&gt;OFF&lt;/span&gt; &lt;input id="profile_isProfileSharedWithNearby" name="profile[isProfileSharedWithNearby]" class="form-control-borderless hide" value="1" checked="checked" type="checkbox"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
0
What is the logic behind the TypeScript error "The operand of a 'delete' operator must be optional"?
<p>This is the new error that is coming in typescript code.</p> <p>I am not able to realize the logic behind it<br/> <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#operands-for-delete-must-be-optional" rel="noreferrer">Documentation</a></p> <pre><code>/*When using the delete operator in strictNullChecks, the operand must now be any, unknown, never, or be optional (in that it contains undefined in the type). Otherwise, use of the delete operator is an error.*/ interface Thing { prop: string; } function f(x: Thing) { delete x.prop; // throws error = The operand of a 'delete' operator must be optional. } </code></pre>
0
start/play embedded (iframe) youtube-video on click of an image
<p>I'm trying to start playing an embedded youtube video by clicking an image. The idea is to have an image on top of a video, and when the image is clicked it fades out and starts playing the video.</p> <p>I'm using jquery to fade the image, and was hoping to find a way to play or click the video using jquery as well. </p> <p>The fading is working fine, but I can't figure out how to trigger the video to play. I got it to work on a couple of browsers by setting the video to autoplay and hide it, and then fade in the video when the image was clicked. On most browsers the video would autoplay when faded in, but in chrome it started to autoplay even when it was hidden. It didn't work well in iOS either.</p> <p>Since I'm pretty new at this, I'm not even sure if I'm writing it 100% correct, but I've tried something like this without success:</p> <pre><code> $('#IMAGE').click(function() { $('#VIDEO').play(); }); </code></pre> <p>So, how would I go about to make the video play on an image click? Is there a way to play the video when the image is clicked, just using jquery?</p> <p>Thank you in advance.</p>
0
ios UTF8 encoding from nsstring
<p>I am receiving a nsstring that is not properly encoded like "mystring%201, where must be "mystring 1". How could I replace all characters that could be interpreted as UTF8? I read a lot of posts but not a full solution. Please note that nsstring is already encoded wrong and I am not asking about how to encode char sequence. Thank you.</p>
0
Get random boolean in Java
<p>Okay, I implemented this SO question to my code: <a href="https://stackoverflow.com/questions/8878015/return-true-or-false-randomly">Return True or False Randomly</a></p> <p>But, I have strange behavior: I need to run ten instances simultaneously, where every instance returns true or false just once per run. And surprisingly, no matter what I do, every time i get just <code>false</code></p> <p>Is there something to improve the method so I can have at least roughly 50% chance to get <code>true</code>?</p> <hr> <p>To make it more understandable: I have my application builded to JAR file which is then run via batch command</p> <pre><code> java -jar my-program.jar pause </code></pre> <p>Content of the program - to make it as simple as possible:</p> <pre><code>public class myProgram{ public static boolean getRandomBoolean() { return Math.random() &lt; 0.5; // I tried another approaches here, still the same result } public static void main(String[] args) { System.out.println(getRandomBoolean()); } } </code></pre> <p>If I open 10 command lines and run it, I get <code>false</code> as result every time...</p>
0
how to make no limit on maxBufferSize and maxReceivedMessageSize
<p>I have an ASP.NET (C#) 4.0 WCF application. I got message error:</p> <blockquote> <p>Error : The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</p> </blockquote> <p>I have increased it into </p> <pre><code>maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152" </code></pre> <p>it works fine. But I am afraid that next time may be it will be over the quota again.</p> <p>Can I set this <code>maxBufferSize</code> and <code>maxReceivedMessageSize</code> with no limit ?</p> <p>thanks you in advance</p>
0
Change default button label of <p:fileUpload mode="simple">
<p>I am using <code>&lt;p:fileUpload mode="simple"&gt;</code>. The button label shows differently in Chrome and Firefox. I would like it to be the same across browsers. I tried changing it by setting the <code>label</code> attribute as follows:</p> <pre><code>&lt;p:fileUpload label="Browse" ... mode="simple" /&gt; </code></pre> <p>However, it had no effect. How can I achieve this?</p>
0
How does the @property decorator work in Python?
<p>I would like to understand how the built-in function <code>property</code> works. What confuses me is that <code>property</code> can also be used as a decorator, but it only takes arguments when used as a built-in function and not when used as a decorator.</p> <p>This example is from the <a href="http://docs.python.org/3/library/functions.html#property" rel="noreferrer">documentation</a>:</p> <pre><code>class C: def __init__(self): self._x = None def getx(self): return self._x def setx(self, value): self._x = value def delx(self): del self._x x = property(getx, setx, delx, &quot;I'm the 'x' property.&quot;) </code></pre> <p><code>property</code>'s arguments are <code>getx</code>, <code>setx</code>, <code>delx</code> and a doc string.</p> <p>In the code below <code>property</code> is used as a decorator. The object of it is the <code>x</code> function, but in the code above there is no place for an object function in the arguments.</p> <pre><code>class C: def __init__(self): self._x = None @property def x(self): &quot;&quot;&quot;I'm the 'x' property.&quot;&quot;&quot; return self._x @x.setter def x(self, value): self._x = value @x.deleter def x(self): del self._x </code></pre> <p>How are the <code>x.setter</code> and <code>x.deleter</code> decorators created in this case?</p>
0
How Should VSCode Be Configured To Support A Lerna Monorepo?
<p>I have a <a href="https://github.com/lerna/lerna" rel="noreferrer">lerna</a> monorepo containing lots of packages.</p> <p>I'm trying to achieve the following:</p> <ol> <li>Ensure that VSCode provides the correct import suggestions (based on package names, not on relative paths) from one package to another.</li> <li>Ensure that I can 'Open Definition' of one of these imports and be taken to the src of that file.</li> </ol> <p>For 1. I mean that if I am navigating code within package-a and I start to type a function exported by package-b, I get a suggestion that will trigger the adding of an import: `import { example } from 'package-b'.</p> <p>For 2. I mean that if I alt/click on the name of a function exported by 'package-b' while navigating the file from a different package that has imported it, I am taken to '/packages/namespace/package/b/src/file-that-contains-function.js',</p> <p>My (lerna) monorepo is structured as standard, for example here is a 'components' package that is published as <code>@namespace/components</code>.</p> <pre><code>- packages - components - package.json - node_modules - src - index.js - components - Button - index.js - Button.js - es - index.js - components - Button - index.js - Button.js </code></pre> <p>Note that each component is represented by a directory so that it can contain other components if necessary. In this example, <code>packages/components/index</code> exports <code>Button</code> as a named export. Files are transpiled to the package's <code>/es/</code> directory.</p> <p>By default, VSCode provides autosuggestions for imports, but it is confused by this structure and, for if a different package in the monorepo needs to use <code>Button</code> for example, will autosuggest all of the following import paths:</p> <ul> <li><code>packages/components/src/index.js</code></li> <li><code>packages/components/src/Button/index.js</code></li> <li><code>packages/components/src/Button/Button.js</code></li> <li><code>packages/components/es/index.js</code></li> <li><code>packages/components/es/Button/index.js</code></li> <li><code>packages/components/es/Button/Button.js</code></li> </ul> <p>However none of these are the appropriate, because they will be rendered as relative paths from the importing file to the imported file. In this case, the following import is the correct import:</p> <pre><code>import { Button } from '@namespace/components' </code></pre> <p>Adding excludes to the project's <code>jsconfig.json</code> has no effect on the suggested paths, and doesn't even remove the suggestions at <code>/es/*</code>:</p> <pre><code>{ "compilerOptions": { "target": "es6", }, "exclude": [ "**/dist/*", "**/coverage/*", "**/lib/*", "**/public/*", "**/es/*" ] } </code></pre> <p>Explicitly adding paths using the "compilerOptions" also fails to set up the correct relationship between the files:</p> <pre><code>{ "compilerOptions": { "target": "es6", "baseUrl": ".", "paths": { "@namespace/components/*": [ "./packages/namespace-components/src/*.js" ] } }, } </code></pre> <p>At present Cmd/Clicking on an import from a different package fails to open anything (no definition is found).</p> <p><strong>How should I configure VSCode so that:</strong></p> <ol> <li><strong>VSCode autosuggests imports from other packages in the monorepo using the namespaced package as the import value.</strong></li> <li><strong>Using 'Open Definition' takes me to the src of that file.</strong></li> </ol> <p>As requested, I have a single babel config in the root:</p> <pre><code>const { extendBabelConfig } = require(`./packages/example/src`) const config = extendBabelConfig({ // Allow local .babelrc.js files to be loaded first as overrides babelrcRoots: [`packages/*`], }) module.exports = config </code></pre> <p>Which extends:</p> <pre><code>const presets = [ [ `@babel/preset-env`, { loose: true, modules: false, useBuiltIns: `entry`, shippedProposals: true, targets: { browsers: [`&gt;0.25%`, `not dead`], }, }, ], [ `@babel/preset-react`, { useBuiltIns: true, modules: false, pragma: `React.createElement`, }, ], ] const plugins = [ `@babel/plugin-transform-object-assign`, [ `babel-plugin-styled-components`, { displayName: true, }, ], [ `@babel/plugin-proposal-class-properties`, { loose: true, }, ], `@babel/plugin-syntax-dynamic-import`, [ `@babel/plugin-transform-runtime`, { helpers: true, regenerator: true, }, ], ] // By default we build without transpiling modules so that Webpack can perform // tree shaking. However Jest cannot handle ES6 imports becuase it runs on // babel, so we need to transpile imports when running with jest. if (process.env.UNDER_TEST === `1`) { // eslint-disable-next-line no-console console.log(`Running under test, so transpiling imports`) plugins.push(`@babel/plugin-transform-modules-commonjs`) } const config = { presets, plugins, } module.exports = config </code></pre>
0
Google Docs viewer disable download
<p>Please take a look at this link</p> <p><a href="http://jsfiddle.net/C7Py6/3/" rel="noreferrer">http://jsfiddle.net/C7Py6/3/</a></p> <p>The last icon on google viewer's toolbar - <img src="https://i.stack.imgur.com/ztBWQ.png" alt="enter image description here"> enables user to view on new browser window and download PDF. The question is, how can I make it view only and disable download (At least disable this toolbar item). Is that possible with google viewer? or is there any other viewer that works like Google Viewer but view-only?</p>
0
React on Github Pages: gh-pages package not working
<h1>Problem</h1> <p>I am trying to put my React app on github pages. However, I can't even deploy the app to GitHub pages.</p> <h1>My Setup</h1> <p>I am using Visual Studio Code on my Windows 10 machine. I created my React app with <em>create-react-app</em>. I followed <a href="https://github.com/gitname/react-gh-pages" rel="noreferrer">this tutorial to set up my app for Github Pages</a>. This is my <em>package.json</em>:</p> <pre><code>{ "homepage": "https://MisturDust319.github.io/ign_code_foo", "name": "ign_code_foo", "version": "0.1.0", "private": true, "dependencies": { "axios": "^0.18.0", "bootstrap": "^4.1.0", "gh-pages": "^1.1.0", "react": "^16.3.1", "react-dom": "^16.3.1", "react-scripts": "1.1.4", "reactstrap": "^5.0.0-beta.3" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "predeploy": "npm run build", "deploy:": "gh-pages -d build" }, "devDependencies": {} } </code></pre> <p>The full source is available <a href="https://github.com/MisturDust319/ign_code_foo" rel="noreferrer">here</a></p> <h1>What I've Done</h1> <p>To deploy, you are supposed to just run</p> <pre><code>npm run deploy </code></pre> <p>However, when I enter that command, from Windows PowerShell, Git Bash, and the Command Prompt, I just get several variations of "command not found".</p> <p>In response, I uninstalled <em>gh-pages</em> from dev-dependencies and reinstalled it as a normal dependency. No change. At this point, I've exhausted all solutions I can think of, and Google has only pulled up people who didn't include the <em>deploy</em> command in package.json.</p>
0
Download iOS 6 simulator
<p>I have xcode 4.5.2 installed. I want to test my app in iOS 6. I went to <code>Xcode/Preferences/Downloads</code>, but I don't see iOS 6 simulator in the list. How should I download it? </p>
0
Getting children children in sitecore
<p>I'm trying to list items which have a set template on the parent page in Sitecore. So far I can do it for the children but I also want to include the children's children, i.e. anything under the parent if it has the chosen template it will work, this is my code in the c# file:</p> <pre><code>lvThing.DataSource = context.Children.Where(x =&gt; x.TemplateName == "cool template").ToList&lt;Item&gt;(); lvThing.DataBind(); </code></pre>
0
Sum of two variables in RobotFramework
<p>I have two variables:</p> <pre><code>${calculatedTotalPrice} = 42,42 ${productPrice1} = 43,15 </code></pre> <p>I executed</p> <pre><code>${calculatedTotalPrice} Evaluate ${calculatedTotalPrice}+${productPrice1} </code></pre> <p>I got</p> <pre><code>42,85,15 </code></pre> <p>How can I resolve it?</p>
0
Bootstrap 4 navbar appearing vertically not horizontally
<p>I have built a Navbar exactly how it has been done on a tutorial yet somehow my navbar appears vertically when it should appear horizontally. Any ideas on how to fix this problem? Thanks in advance</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;nav class="navbar navbar-fixed-top navbar-light bg-faded"&gt; &lt;div class='container'&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li class='nav-item'&gt; &lt;a class='nav-link' routerLink="/home" routerLinkActive="active"&gt;Home&lt;/a&gt; &lt;/li&gt; &lt;li class='nav-item'&gt; &lt;a class='nav-link' routerLink="/documents" routerLinkActive="active"&gt;Docs&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item dropdown"&gt; &lt;div ngbDropdown class="d-inline-block dropdown-links"&gt; &lt;button class="btn btn-outline-primary" id="proposalDropdown" ngbDropdownToggle&gt; Proposals &lt;/button&gt; &lt;div class="dropdown-menu" aria-labelledby="proposalDropdown"&gt; &lt;a class="dropdown-item" routerLink="/proposals" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true}"&gt;Proposals&lt;/a&gt; &lt;a class="dropdown-item" routerLink="/proposals/new" routerLinkActive="active"&gt;New Proposal&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/nav&gt;</code></pre> </div> </div> </p>
0
What is body-content class in bootstrap
<p>I am doing <a href="https://docs.microsoft.com/en-us/aspnet/core/client-side/bootstrap" rel="noreferrer">this</a> but I dont get what <strong>body-content</strong> class does. I am aware of <strong>container</strong> and <strong>container-fluid</strong>. Can someone explain or point me to bootstrap documentation for this. Googling did not help me.</p>
0
How to use like condition with multiple values in sql server 2005?
<p>I need to filter out records based on some text matching in nvarchar(1000) column. Table has more than 400 thousands records and growing. For now, I am using Like condition:-</p> <pre><code>SELECT * FROM table_01 WHERE Text like '%A1%' OR Text like '%B1%' OR Text like '%C1%' OR Text like '%D1%' </code></pre> <p>Is there any preferred work around? </p>
0
How can I find MAX with relational algebra?
<p>Working with databases, how can I find MAX using relational algebra?</p>
0
Jenkins store workspace outside docker container
<p>So I have a Jenkins Master-Slave setup, where the master spins up a docker container (on the slave VM) and builds the job inside that container then it destroys the container after it's done. This is all done via the Jenkins' Docker <a href="https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin" rel="nofollow noreferrer">plugin</a>.</p> <p>Everything is running smoothly, however the only problem is that, after the job is done (failed job) I cannot view the workspace (because the container is gone). I get the following error:</p> <p><a href="https://i.stack.imgur.com/zjpv0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zjpv0.png" alt="No Workspace Error"></a></p> <p>I've tried attaching a "volume" from the host (slave VM) to the container to store the files outside also (which works because, as shown below, I can see files on the host) and then tried mapping it to the master VM:</p> <p><a href="https://i.stack.imgur.com/QLuFz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLuFz.png" alt="Host files"></a></p> <p>Here's my settings for that particular docker image template:</p> <p><a href="https://i.stack.imgur.com/S9gXZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S9gXZ.png" alt="Docker template"></a></p> <p>Any help is greatly appreciated!</p> <p>EDIT: I've managed to successfully get the workspace to store on the host.. However, when the build is done I still get the same error (Error: no workspace). I have no idea how to make Jenkins look for the files that are on the host rather than the container.</p>
0
How do you read from a memory buffer c++
<p>I am fairly new at C++ and am trying to understand how memory manipulation works. I am used to Java and Python and haven't really been exposed to this. </p> <p>I am working on a project that has the following structure that doesn't quite make sense to me. </p> <pre><code>typedef struct { size_t size; char *data; } data_buffer; </code></pre> <p>This structure basically acts as a buffer, with a pointer to the data stored within the buffer and the size of the buffer to allow the program to know how large the buffer is when reading from it.</p> <p>An example of how the program uses the buffer:</p> <pre><code>data_buffer buffer = {0}; //Manipulate data here so it contains pertinent information CFile oFile; oFile.Write(buffer.data, buffer.size); </code></pre> <p>The program mostly uses 3rd party code to read the data found within the buffer, so I am having trouble finding an example of how this is done. My main question is <strong>how do I read the contents of the buffer, given only a pointer to a character and a size?</strong> However, I would also like to understand how this actually works. From what I understand, memory is written to, with a pointer to where it starts and the size of the memory, so I should be able to just iterate through the memory locations, grabbing each character from memory and tagging it onto whatever structure I choose to use, like a CString or a string. Yet, I don't understand how to iterate through memory. Can someone help me understand this better? Thanks.</p>
0
Calling a function within PowerShell ISE
<p>Could someone tell me why I can not call a function within a PowerShell script? See below my code:</p> <pre><code>Write-Host "Before calling Function." testFunction function testFunction() { Write-Host "Function has been called" } </code></pre> <p>When I run the above code I get the following error message:</p> <pre>testFunction : The term 'testFunction' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\andrew.short\Documents\Powershell\Backups\functionTest.ps1:3 char:1 + testFunction + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (testFunction:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException</pre> <p>I'm sure that it must be possible to call functions within the same PowerShell script. Can somebody please help?</p>
0
Core Data VS Sqlite or FMDB....?
<p>Now this might look like a duplicate thread, but my question is that I have read a lot of questions like.. <a href="https://stackoverflow.com/questions/523482/core-data-vs-sqlite-3">Core Data vs SQLite 3</a> and others but these are 2-3 years old. I have also read that FMDB was developed as core data was not supported on iOS, So it should not be used any more. And on the other hand I have read that one should not use core data as a database. </p> <p><strong>So I am seriously confused,whether I should use core data for object storage or not</strong>. I mean on what basis I should decide which to use? Are there any guidelines provided by apple or someone else.. or is it something that will come to me with time.?</p>
0
What is the most pythonic way to check if multiple variables are not None?
<p>If I have a construct like this:</p> <pre><code>def foo(): a=None b=None c=None #...loop over a config file or command line options... if a is not None and b is not None and c is not None: doSomething(a,b,c) else: print "A config parameter is missing..." </code></pre> <p>What is the preferred syntax in python to check if all variables are set to useful values? Is it as I have written, or another better way?</p> <p>This is different from this question: <a href="https://stackoverflow.com/questions/3965104/not-none-test-in-python">not None test in Python</a> ... I am looking for the preferred method for checking if many conditions are not None. The option I have typed seems very long and non-pythonic.</p>
0
Styling of Select2 dropdown select boxes
<p>I'm using Select2 in a project to style some select boxes in a search form. I managed to change the gradient background of the arrow container to a black gradient:</p> <pre class="lang-css prettyprint-override"><code>.select2-container .select2-choice .select2-arrow { background-image: -khtml-gradient(linear, left top, left bottom, from(#424242), to(#030303)); background-image: -moz-linear-gradient(top, #424242, #030303); background-image: -ms-linear-gradient(top, #424242, #030303); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #424242), color-stop(100%, #030303)); background-image: -webkit-linear-gradient(top, #424242, #030303); background-image: -o-linear-gradient(top, #424242, #030303); background-image: linear-gradient(#424242, #030303); } </code></pre> <p>I would like the arrow to be white, but unfortunately Select2 is using a background image for the different icons instead of font-awesome or something similar, so there's no way to just change the color with CSS.</p> <p>What would be the easiest way to make the arrow white instead of the default grey? Do I really have to replace the background png (select2.png and select2x2.png) with my own? Or is there an easier method?</p> <p>Another question I have is how to change the height of the select boxes. I know how to change the height of the dropdown box in opened state, but I want to change the height of the selectbox in closed state. Any ideas?</p>
0
axios post data format
<p>I want axios to post data like the following format(use jquery ajax.post)</p> <p><a href="https://i.stack.imgur.com/SwKuS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SwKuS.jpg" alt="enter image description here"></a></p> <pre><code>var data = {}; data.params = querystring.stringify({'cmd': 'getUnreadCount', 'isNewAdmin':''}); data = querystring.stringify(data); axios.post(url, data); </code></pre> <p>But actually it was posted like this. How to change params to object like above.</p> <h2><a href="https://i.stack.imgur.com/SuCeu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SuCeu.jpg" alt="enter image description here"></a></h2>
0
Using the AND and NOT Operator in Python
<p>Here is my custom class that I have that represents a triangle. I'm trying to write code that checks to see if <code>self.a</code>, <code>self.b</code>, and <code>self.c</code> are greater than 0, which would mean that I have Angle, Angle, Angle. </p> <p>Below you will see the code that checks for A and B, however when I use just <code>self.a != 0</code> then it works fine. I believe I'm not using <code>&amp;</code> correctly. Any ideas? Here is how I am calling it: <code>print myTri.detType()</code></p> <pre><code>class Triangle: # Angle A To Angle C Connects Side F # Angle C to Angle B Connects Side D # Angle B to Angle A Connects Side E def __init__(self, a, b, c, d, e, f): self.a = a self.b = b self.c = c self.d = d self.e = e self.f = f def detType(self): #Triangle Type AAA if self.a != 0 &amp; self.b != 0: return self.a #If self.a &gt; 10: #return AAA #Triangle Type AAS #elif self.a = 0: #return AAS #Triangle Type ASA #Triangle Type SAS #Triangle Type SSS #else: #return unknown </code></pre>
0
Regex to match values not surrounded by another char?
<p>This is one of the toughest things I have ever tried to do. Over the years I have searched but I just can&rsquo;t find a way to do this &mdash; match a string not surrounded by a given char, like quotes or greater/less than symbols.</p> <p>A regex like this could match URLs not in HTML links, SQL table.column values not in quotes, and lots of other things.</p> <pre><code>Example with quotes: Match [THIS] and "something with [NOT THIS] followed by" or even [THIS]. Example with &lt;,&gt;, &amp; " Match [URL] and &lt;a href="[NOT URL]"&gt;or [NOT URL]&lt;/a&gt; Example with single quotes: WHERE [THIS] LIKE '%[NOT THIS]' </code></pre> <p>Basically, how do you match a string (THIS) when it is not surrounded by a given char?</p> <pre><code>\b(?:[^"'])([^"']+)(?:[^"'])\b </code></pre> <p>Here is a test pattern: a regex like what I am thinking of would match only the first "quote".</p> <blockquote> <p>To quote, "quote me not lest I quote you!"</p> </blockquote>
0
jQuery load Wordpress pages via ajax
<p>I'm trying to setup a Wordpress theme which loads pages (not posts) with AJAX. I was following <a href="http://www.emanueleferonato.com/2010/04/01/loading-wordpress-posts-with-ajax-and-jquery/" rel="noreferrer">this guide</a> but haven't been able to get the correct pages to load.</p> <p>The links to the posts are being generated with the post slug</p> <pre><code>http://local.example.com/slug/ </code></pre> <p>So I adjusted </p> <pre><code> jQuery(document).ready(function($){ $.ajaxSetup({cache:false}); $("a.bar").click(function(e){ $('page-loader').show(); var that = $(this).parent(); $('.column').not($(this).parent()).animate({width: 'toggle',opacity:'0.75'}, 700, function() { }); var post_id = $(this).attr("href"); $("#page-container").load("http://&lt;?php echo $_SERVER[HTTP_HOST]; ?&gt;" + post_id,{id:post_id}); return false; }); }); </code></pre> <p>The URL is correct but it doesn't load anything..</p> <hr> <pre><code>&lt;?php /* Template Name: Triqui Ajax Post */ ?&gt; &lt;?php $post = get_post($_POST['id']); ?&gt; &lt;?php if ($post) : ?&gt; &lt;?php setup_postdata($post); ?&gt; &lt;div &lt;?php post_class() ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;small&gt;&lt;?php the_time('F jS, Y') ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt; &lt;div class="entry"&gt; &lt;?php the_content('Read the rest of this entry &amp;raquo;'); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endif; ?&gt; </code></pre>
0