title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
What is the difference between subprocess.popen and subprocess.run
<p>I'm new to the <code>subprocess</code> module and the documentation leaves me wondering what the difference is between <code>subprocess.popen</code> and <code>subprocess.run</code>. Is there a difference in what the command does? Is one just newer? Which is better to use?</p>
0
Defining a UDF that accepts an Array of objects in a Spark DataFrame?
<p>When working with Spark's DataFrames, User Defined Functions (UDFs) are required for mapping data in columns. UDFs require that argument types are explicitly specified. In my case, I need to manipulate a column that is made up of arrays of objects, and I do not know what type to use. Here's an example:</p> <pre><code>import sqlContext.implicits._ // Start with some data. Each row (here, there's only one row) // is a topic and a bunch of subjects val data = sqlContext.read.json(sc.parallelize(Seq( """ |{ | "topic" : "pets", | "subjects" : [ | {"type" : "cat", "score" : 10}, | {"type" : "dog", "score" : 1} | ] |} """))) </code></pre> <p>It's relatively straightforward to use the built-in <code>org.apache.spark.sql.functions</code> to perform basic operations on the data in the columns</p> <pre><code>import org.apache.spark.sql.functions.size data.select($"topic", size($"subjects")).show +-----+--------------+ |topic|size(subjects)| +-----+--------------+ | pets| 2| +-----+--------------+ </code></pre> <p>and it's generally easy to write custom UDFs to perform arbitrary operations</p> <pre><code>import org.apache.spark.sql.functions.udf val enhance = udf { topic : String =&gt; topic.toUpperCase() } data.select(enhance($"topic"), size($"subjects")).show +----------+--------------+ |UDF(topic)|size(subjects)| +----------+--------------+ | PETS| 2| +----------+--------------+ </code></pre> <p>But what if I want to use a UDF to manipulate the array of objects in the "subjects" column? What type do I use for the argument in the UDF? For example, if I want to reimplement the size function, instead of using the one provided by spark:</p> <pre><code>val my_size = udf { subjects: Array[Something] =&gt; subjects.size } data.select($"topic", my_size($"subjects")).show </code></pre> <p>Clearly <code>Array[Something]</code> does not work... what type should I use!? Should I ditch <code>Array[]</code> altogether? Poking around tells me <code>scala.collection.mutable.WrappedArray</code> may have something to do with it, but still there's another type I need to provide. </p>
0
iOS. How to enable and disable rotation on each UIViewController?
<p>I have an UIViewController, I want to disable or enable rotation of the screen in different scenarios</p> <p>Example: </p> <pre><code>if flag { rotateDevice = false } else { rotateDevice = true } </code></pre> <p>How can I do that?</p>
0
JPA Criteria multiselect with fetch
<p>I have following model:</p> <pre><code>@Entity @Table(name = "SAMPLE_TABLE") @Audited public class SampleModel implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "NAME", nullable = false) @NotEmpty private String name; @Column(name = "SHORT_NAME", nullable = true) private String shortName; @ManyToOne(fetch = FetchType.LAZY, optional = true) @JoinColumn(name = "MENTOR_ID") private User mentor; //other fields here //omitted getters/setters } </code></pre> <p>Now I would like to query only columns: <code>id</code>, <code>name</code>, <code>shortName</code> and <strong><code>mentor</code></strong> which referes to <code>User</code> entity (not complete entity, because it has many other properties and I would like to have best performance).</p> <p>When I write query:</p> <pre><code>CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery&lt;SampleModel&gt; query = builder.createQuery(SampleModel.class); Root&lt;SampleModel&gt; root = query.from(SampleModel.class); query.select(root).distinct(true); root.fetch(SampleModel_.mentor, JoinType.LEFT); query.multiselect(root.get(SampleModel_.id), root.get(SampleModel_.name), root.get(SampleModel_.shortName), root.get(SampleModel_.mentor)); query.orderBy(builder.asc(root.get(SampleModel_.name))); TypedQuery&lt;SampleModel&gt; allQuery = em.createQuery(query); return allQuery.getResultList(); </code></pre> <p>I have following exception:</p> <pre><code>Caused by: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias1,role=com.sample.SampleModel.model.SampleModel.mentor,tableName=USER_,tableAlias=user1_,origin=SampleModel SampleModel0_,columns={SampleModel0_.MENTOR_ID ,className=com.sample.credential.model.User}}] at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:214) at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:991) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:759) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:675) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:311) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:259) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) ... 138 more </code></pre> <p>Query before exception:</p> <pre><code>SELECT DISTINCT NEW com.sample.SampleModel.model.SampleModel(generatedAlias0.id, generatedAlias0.name, generatedAlias0.shortName, generatedAlias0.mentor) FROM com.sample.SampleModel.model.SampleModel AS generatedAlias0 LEFT JOIN FETCH generatedAlias0.mentor AS generatedAlias1 ORDER BY generatedAlias0.name ASC </code></pre> <p>I know that I can replace fetch with join but then I will have N+1 problem. Also I do not have back reference from User to SampleModel and I do not want to have..</p>
0
How to get value from kendo combobox
<p>How can I get from kendo combobox value? I always getting undefined on it.. I've used these variants, but they are not worked for me</p> <pre><code>var selected = $('#typesCombo').data('kendoComboBox').val(); var selected = $('#typesCombo').data('kendoComboBox').value(); var selected = $('#typesCombo').data('kendoComboBox'); </code></pre> <p>And getting error like: <code>Cannot read property 'val' of undefined</code></p> <p>Here's my code: </p> <p>JS:</p> <pre><code>$('#loadContainer').load("@Url.Action("Load", "Home")" + id); var selected = $('#typesCombo').data('kendoComboBox').val(); if (selected == '') { ... } </code></pre> <p>HTML:</p> <pre><code>@(Html.Kendo().ComboBoxFor(x =&gt; x.Types.Name).Name("typesCombo") .DataTextField("Name") .DataValueField("Id") .HtmlAttributes(new { style = "width:100%", id = "typesCombo" }) .BindTo(Model.TypesList)) </code></pre>
0
Kubernetes/Container Engine: TLS handshake timeout
<p>About 7 hours ago i was working with kubectl without problems. Now (after a few hours of sleep, and a reboot of my computer) all kubectl get commands gives me this error:</p> <pre><code>Unable to connect to the server: net/http: TLS handshake timeout </code></pre> <p>I did not do anything since it worked besides shut down my computer.</p> <p>Since I'm new with Kubernetes and GCE i need a few hints on what this could be, and where to look.</p>
0
How to reference and refresh a QueryTable in Excel 2016 in VBA
<p>I'm trying to refresh a query on a cell change, however I can't figure out how to reference the query.</p> <p>My code: <code>Sheets("Roster Query").QueryTables(0).Refresh</code></p> <p>Just errors out with: </p> <blockquote> <p>Run-time error '1004':</p> <p>Application-defined or object-defined error</p> </blockquote> <p>I have a sheet named "Roster Filter" that has query table I want to refresh. How can I get that QueryTable and refresh it?</p> <p>Edit: Also tried:</p> <pre><code>For Each qt In Sheets("Roster Query").QueryTables qt.Refresh Next </code></pre> <p>This does not error out, but the query is not refreshed.</p>
0
Howto upload multiple files with Spring Boot and test it with cURL
<p>I have implemented a Controller to upload multiple files:</p> <pre><code>public class Image implements Serializable { private MultipartFile file; private Ingeger imageNumber; ... } @RequestMapping(value = "/upload", method = RequestMethod.POST) public void handleFileUpload(@RequestBody Set&lt;Image&gt; images) { ... } </code></pre> <p>I correctly checked the code using only <em>one</em> MultipartFile directly in the upload method using this command:</p> <pre><code>curl http://localhost:8080/upload -X POST -F '[email protected];type=image/jpg' -H "Content-Type: multipart/form-data" </code></pre> <p>I need to extend it in three ways but don't know the correct syntax:</p> <ol> <li>POST a collection of JSON items</li> <li>Add the field "imageNumber" for each item</li> <li>Most tricky part: add a file nested to each item</li> </ol>
0
Wamp server Put Online is not working
<p>I did the following steps to setup Wamp, but not able to access the server from different machine in the network. What am I doing wrong?</p> <ol> <li>Installed Wamp 64 Bit Version 3.0.4 this comes with Apache version 2.4.18</li> <li>Started Wamp server, right click on system tray icon, choose <code>Menu item : Online / Offline</code> under <code>Wamp settings</code></li> <li>Click on (left click) system tray icon and chose <code>Put Online</code></li> <li>When I try to access the server from another machine in the network, the server return a error page with error message <code>You don't have permission to access / on this server</code></li> </ol> <p>I directly edited httpd-vhosts.conf file and restarted all the service, still getting the same error. Below is the content of httpd-vhosts.conf file and my system IP</p> <p>httpd-vhosts.conf</p> <pre><code># # Virtual Hosts # &lt;VirtualHost *:80&gt; ServerName localhost DocumentRoot C:/Users/dinesh/Softwares/Wamp64/www &lt;Directory "C:/Users/dinesh/Softwares/Wamp64/www/"&gt; Options +Indexes +FollowSymLinks +MultiViews AllowOverride All Require local Require ip 100.97.67 &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p>System IP</p> <pre><code>mintty&gt; ipconfig | grep IPv4 IPv4 Address. . . . . . . . . . . : 100.97.67.11 mintty&gt; </code></pre>
0
Error while running Java app
<p>The log shows this </p> <pre><code>"error=2, No such file or directory" "Cannot run program /Applications/IntelliJ IDEA.app/Contents/jre/jdk/Contents/Home/bin/java" (in directory "/Users/.. " and a path to a directory that exists. </code></pre> <p>I could replicate the error running a "hello world" app without any type of dependencies and configs (no maven, no spring).</p> <p>I'm using Intellij 2016, and OSX El Capitan</p>
0
How to dispatch an action on page load in react-redux?
<p>I have to display a table with lot of data. There is a pagination button which display 10 record per page. I have one button called "FETCH" on-click of it table is populating. How do load my table on load of the page.</p> <p><strong>action.js</strong></p> <pre><code>import fetch from 'isomorphic-fetch'; export const ADD_BENEFICIARY = 'ADD_BENEFICIARY'; export const REMOVE_BENEFICIARY = 'REMOVE_BENEFICIARY'; export const ADD_PLAN_TO_COMPARE = 'ADD_PLAN_COMPARE'; export const REMOVE_PLAN_FROM_COMPARE = 'REMOVE_PLAN_COMPARE'; export const SHOW_PLAN_COMPARE = 'SHOW_PLAN_COMPARE'; export const NEXT_PAGE_PLAN_LIST = 'NEXT_PAGE_PLAN_LIST'; export const PREV_PAGE_PLAN_LIST = 'PREV_PAGE_PLAN_LIST'; export const REQUEST_PAGE_PLAN_LIST = 'REQUEST_PAGE_PLAN_LIST'; export const RECEIVE_PAGE_PLAN_LIST = 'RECEIVE_PAGE_PLAN_LIST'; export const showNextPageOfPlans = () =&gt; { return { type: NEXT_PAGE_PLAN_LIST } } export const showPreviousPageOfPlans = () =&gt; { return { type: PREV_PAGE_PLAN_LIST } } export const requestPageOfPlans = (startIdx, pageSize) =&gt; { return { type: REQUEST_PAGE_PLAN_LIST, start: startIdx, pageSize: pageSize } } export const receivePageOfPlans = (startIdx, json) =&gt; { return { type: RECEIVE_PAGE_PLAN_LIST, start: startIdx, plans: json } } export const fetchPlans = (startIdx, pageSize) =&gt; { var str = sessionStorage.getItem('formValue'); //JSON.stringify(formValues); return function (dispatch) { dispatch(requestPageOfPlans(startIdx, pageSize)); return fetch('http://172.16.32.57:9090/alternatePlans/plans/list/', {method: 'post', body: str, headers: new Headers({'Content-Type': 'application/json'}) }) .then(response =&gt; response.json()) .then(json =&gt; dispatch(receivePageOfPlans(startIdx, json)) ) } } </code></pre> <p><strong>reducer.js</strong></p> <pre><code>import { REQUEST_PAGE_PLAN_LIST, RECEIVE_PAGE_PLAN_LIST, NEXT_PAGE_PLAN_LIST, PREV_PAGE_PLAN_LIST } from './actions'; const initialPaging = { startIndex: 0, lastIndex: 0, pageSize: 10 } const paging = (state = initialCurrentPage, action) =&gt; { switch (action.type) { case NEXT_PAGE_PLAN_LIST: if (state.startIndex+state.pageSize &lt;= state.lastIndex) { return { ...state, startIndex: state.startIndex+state.pageSize }; } else { return state; } case PREV_PAGE_PLAN_LIST: if (state.startIndex-state.pageSize &gt;= 0) { return { ...state, startIndex: state.startIndex-state.pageSize }; } else { return state; } case REQUEST_PAGE_PLAN_LIST: return { ...state, isFetching: true }; case RECEIVE_PAGE_PLAN_LIST: return { ...state, isFetching: false }; default: return state; } } var initialPlans = []; const plans = (state = initialPlans, action) =&gt; { switch (action.type) { case RECEIVE_PAGE_PLAN_LIST: return action.plans.plans; default: return state; } } const allReducers = (state = {}, action) =&gt; { let items = plans(state.plans, action); return { plans: items, paging: paging({ ...initialPaging, ...state.paging, lastIndex: items.length-1 }, action) } } export default allReducers; </code></pre> <blockquote> <p>P.S. I am new to react-redux. Official Documentation is good but very less explanation is given.</p> </blockquote>
0
EACCES: permission denied in VS Code MAC
<p>When I change any file, the system will deny me access. What's going on? How do I properly set permissions on Mac?</p> <p><a href="https://i.stack.imgur.com/GMJeV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GMJeV.png" alt="enter image description here"></a></p>
0
Why occurs 'no viable alternative at input'?
<p>I wrote the following combined grammar:</p> <pre><code>grammar KeywordGrammar; options{ TokenLabelType = MyToken; } //start rule start: sequence+ EOF; sequence: keyword filter?; filter: simpleFilter | logicalFilter | rangeFilter; logicalFilter: andFilter | orFilter | notFilter; simpleFilter: lessFilter | greatFilter | equalFilter | containsFilter; andFilter: simpleFilter AND? simpleFilter; orFilter: simpleFilter OR simpleFilter; lessFilter: LESS (DIGIT | FLOAT|DATE); notFilter: NOT IN? (STRING|ID); greatFilter: GREATER (DIGIT|FLOAT|DATE); equalFilter: EQUAL (DIGIT|FLOAT|DATE); containsFilter: EQUAL (STRING|ID); rangeFilter: RANGE? DATE DATE? | RANGE? FLOAT FLOAT?; keyword: ID | STRING; DATE: DIGIT DIGIT? SEPARATOR MONTH SEPARATOR DIGIT DIGIT (DIGIT DIGIT)?; MONTH: JAN | FEV | MAR | APR | MAY | JUN | JUL | AUG | SEP | OCT | NOV | DEC ; JAN : 'janeiro'|'jan'|'01'|'1'; FEV : 'fevereiro'|'fev'|'02'|'2'; MAR : 'março'|'mar'|'03'|'3'; APR : 'abril' |'abril'|'04'|'4'; MAY : 'maio'| 'mai'| '05'|'5'; JUN : 'junho'|'jun'|'06'|'6'; JUL : 'julho'|'jul'|'07'|'7'; AUG : 'agosto'|'ago'|'08'|'8'; SEP : 'setembro'|'set'|'09'|'9'; OCT : 'outubro'|'out'|'10'; NOV : 'novembro'|'nov'|'11'; DEC : 'dezembro'|'dez'|'12'; SEPARATOR: '/'|'-'; AND: ('e'|'E'); OR: ('O'|'o')('U'|'u'); NOT: ('N'|'n')('Ã'|'ã')('O'|'o'); IN: ('E'|'e')('M'|'m'); GREATER: '&gt;' | ('m'|'M')('a'|'A')('i'|'I')('o'|'O')('r'|'R') ; LESS: '&lt;' | ('m'|'M')('e'|'E')('n'|'N')('o'|'O')('r'|'R'); EQUAL: '=' | ('i'|'I')('g'|'G')('u'|'U')('a'|'A')('l'|'L'); RANGE: ('e'|'E')('n'|'N')('t'|'T')('r'|'R')('e'|'E'); FLOAT: DIGIT+ | DIGIT+ POINT DIGIT+; ID: (LETTER|DIGIT+ SYMBOL) (LETTER|SYMBOL|DIGIT)*; STRING: '"' ( ESC_SEQ | ~('\\'|'"') )* '"'; DIGIT: [0-9]; WS: (' ' | '\t' | '\r' | '\n') -&gt; skip ; POINT: '.' | ','; fragment LETTER: 'A'..'Z' | 'a'..'z' | '\u00C0'..'\u00D6' | '\u00D8'..'\u00F6' | '\u00F8'..'\u02FF' | '\u0370'..'\u037D' | '\u037F'..'\u1FFF' | '\u200C'..'\u200D' | '\u2070'..'\u218F' | '\u2C00'..'\u2FEF' | '\u3001'..'\uD7FF' | '\uF900'..'\uFDCF' | '\uFDF0'..'\uFFFD' ; fragment SYMBOL: '-' | '_'; fragment HEX_DIGIT: ('0'..'9'|'a'..'f'|'A'..'F'); fragment ESC_SEQ: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | UNICODE_ESC | OCTAL_ESC ; fragment OCTAL_ESC: '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ; fragment UNICODE_ESC: '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; </code></pre> <p>But a <strong>no viable alternative at input</strong> error occurs only trying parse a following type of sentences: <strong><em>keyword OPERATOR DIGIT</em></strong>; for example:</p> <ul> <li>filter = 2</li> <li>filter &lt; 2</li> <li>filter > 2</li> </ul> <p>Zero as a value, it works!!!</p> <p>Where is the error?</p> <p>Thanks by your help,</p> <p>Yenier</p>
0
Template Editor AEM not working as expected
<p>We are using template editor in AEM 6.2 to create templates , and we have followed below steps to create a template-</p> <p>1.Created page template as done in we-retail site. 2.Create empty page template using above page template. 3.Created template using empty page template.</p> <p>Did following modifications on top of we retail page component as per our requirement-</p> <ol> <li><p>As we need to have header and footer as full width parsys i.e 1340 width and body as 940 width-</p> <p> .site-wrapper { width:1340px; } .container { width:940px; } </p></li> </ol> <p>So we did following modifications in /apps//components/structure/page/partials/body.html -</p> <pre><code>&lt;div class="site-wrapper"&gt; &lt;div data-sly-resource="${ @ path='header', resourceType='/apps/&lt;projectname&gt;/components/structure/header'}" data-sly-unwrap&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="container" data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"&gt; &lt;sly data-sly-repeat="${templatedContainer.structureResources}" data-sly-resource="${item.path @ resourceType=item.resourceType, decorationTagName='div'}" /&gt; &lt;/div&gt; &lt;div class="site-wrapper"&gt; &lt;div data-sly-resource="${ @ path='footer', resourceType='/apps/&lt;projectname&gt;/components/structure/footer'}" data-sly-unwrap&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Also we have few more components which will take full width on the page so i have added responsivegrid component under full width div.</p> <p>But i am not able to edit the header and footer component in template as they are not under templateresource.</p> <p>Also even if i add design dialog under header and footer i am not able to edit those components directly on the page in design mode even if they are unlocked.</p> <p>Please let me know if i am doing anything wrong here or we cant customize body.html as in we-retail site.</p> <p>I thought of using different parsys for full width and for body. And i don't want to control using css as i have multiple components which are full width.</p> <p>Regards Ankur</p>
0
Enable raw SQL logging in Entity Framework Core
<p>How do I enable the logging of DbCommand raw SQL queries?</p> <p>I have added the following code to my Startup.cs file, but do not see any log entries from the Entity Framework Core.</p> <pre><code>void ConfigureServices(IServiceCollection services) { services.AddLogging(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(LogLevel.Debug); } </code></pre> <p>I'm expecting to see something like this:</p> <pre><code>Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilder... SELECT [t].[Id], [t].[DateCreated], [t].[Name], [t].[UserName] FROM [Trips] AS [t] </code></pre>
0
get current date and time in groovy?
<p>What is the code to get the current date and time in groovy? I've looked around and can't find an easy way to do this. Essentially I'm looking for linux equivalent of <code>date</code></p> <p>I have :</p> <pre><code>import java.text.SimpleDateFormat def call(){ def date = new Date() sdf = new SimpleDateFormat("MM/dd/yyyy") return sdf.format(date) } </code></pre> <p>but I need to print time as well.</p>
0
Using Dynamic Pivot SQL in a View
<p>Gday All,</p> <p>I've written some code to dynamically Pivot a table like <a href="https://stackoverflow.com/questions/20111418/sql-server-transpose-rows-to-columns">SQL Server : Transpose rows to columns</a></p> <p>The code looks like this</p> <pre><code>DECLARE @cols NVARCHAR(MAX), @sql NVARCHAR(MAX) SET @cols = STUFF((SELECT DISTINCT ',' + QUOTENAME(FieldName) FROM CORE_Items_Extra WHERE Not(FieldName = '') ORDER BY 1 FOR XML PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)'),1,1,'') SET @sql = 'SELECT ItemID, ' + @cols + ' FROM ( SELECT ItemID, FieldValue, FieldName FROM CORE_Items_Extra ) AS SourceTable PIVOT ( MAX(FieldValue) FOR FieldName IN (' + @cols + ') ) AS PivotTable;' EXECUTE(@sql) </code></pre> <p>Which works perfectly BUT I want to use it within a View, I've tried copying the code to a view and it works but wont save as it doesn't like the Declare statements in the view, I've got it working in a Stored Procedure but cant use Stored Procedures in a View, I think I need to have it as a Table-Valued Function but cant use the Execute statement within a TBF. I need to combine this data with another table in a view, and would like to keep it dynamic, so any ideas would be greatly appreciated :) We are using SQL 2008 R2</p>
0
Installing 64 bit PyCharm on Windows 10
<p>I have a Windows 10 Home 64-bit installed on a x64 laptop. I also have Python 3.4.3 Anaconda 2.3.0 (64-bit) (default, Mar 6 2015, 12:06:10) [MSC v.1600 64 bit (AMD64)] installed as well as 64-bit versions of Java, Firefox and Tortoise. </p> <p>For some reason when I run the PyCharm installer it only offers me the option of a 32 bit installation (rather irritatingly it doesn't even allow me to download a 64 bit installer from the website). Of course 32-bit PyCharm can't interact with 64-bit Tortoise.</p> <p>So, how can I force PyCharm to install the 64-bit version or do I have to downgrade Tortoise, Java, Firefox etc. to 32-bit? It really shouldn't be this difficult!</p>
0
caddy.service start request repeated too quickly
<p>I'm using systemd to start a caddy webserver on an ubuntu 16.04 machine. Whenever I run <code>sudo service caddy start</code> and <code>service caddy status</code>, I get this error: </p> <pre><code>● caddy.service - Caddy webserver Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2016-08-29 05:03:02 EDT; 4s ago Docs: https://caddyserver.com/ Process: 1135 ExecStart=/usr/local/bin/caddy -agree -email me@example -pidfile=/var/run/caddy/caddy.pid (code=exited, status Main PID: 1135 (code=exited, status=1/FAILURE) systemd[1]: Started Caddy webserver. caddy[1135]: Activating privacy features... done. caddy[1135]: 2016/08/29 05:03:02 Caddyfile:12 - Parse error: unknown property 'errors' systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE systemd[1]: caddy.service: Unit entered failed state. systemd[1]: caddy.service: Failed with result 'exit-code'. </code></pre>
0
Laravel Check Empty Array
<p>I still have trouble with checking if an array is empty or not in laravel.</p> <p>This is my view:</p> <pre><code>@foreach($restaurantmenue as $daily) @if(empty($daily-&gt;articles)) no article @else @foreach($daily-&gt;articles as $menue) &lt;a class="card-link" href="#"&gt; &lt;h4 class="title"&gt;{{$menue-&gt;title}} &lt;/h4&gt; &lt;/a&gt; @endforeach @endif @endforeach </code></pre> <p>{{dd($daily->articles)}} When I check my views (One with an Article and the other without an article) I get this output:</p> <p>The View with an existing article shows: Collection {#228 ▼ #items: array:1 [▶] }</p> <p>And the view without an article shows: Collection {#227 ▼ #items: [] }</p> <p>I have no idea why the code in the IF STATEMENT is not executed. The "No Article" Message is not displayed. </p>
0
Finding entries containing a substring in a numpy array?
<p>I tried to find entries in an Array containing a substring with np.where and an in condition: </p> <pre><code>import numpy as np foo = "aa" bar = np.array(["aaa", "aab", "aca"]) np.where(foo in bar) </code></pre> <p>this only returns an empty Array.<br> Why is that so?<br> And is there a good alternative solution? </p>
0
JDK path option is not showing while setting jenkins configuration
<p>I am setup Jenkins configuration, but put jdk path option is not showing in configure setting, i have also installed plugin but still getting the same problem.</p>
0
Selenium wait for element to be clickable python
<p>All, I'm needing a little assistance with Selenium waits. I can't seem to figure out how to wait for an element to be ready.</p> <p>The element that I am needing to wait I can locate and click using my script via the code below...</p> <pre><code>CreateJob = driver.find_element_by_xpath(".//*[@id='line']/div[1]/a") </code></pre> <p>or </p> <pre><code>CreateJob = driver.find_element_by_partial_link_text("Create Activity") </code></pre> <p>I'm needing to wait for this element to be on the page and clickable before I try to click on the element. </p> <p>I can use the <code>sleep</code> command, but I have to wait for 5 seconds or more and it seems to be unreliable and errors out 1 out of 8 times or so. </p> <p>I can't seem to find the correct syntax to use. </p> <p>the HTML code for this is below.</p> <pre><code>&lt;document&gt; &lt;html manifest="https://tddf/index.php?m=manifest&amp;a=index"&gt; &lt;head&gt; &lt;body class="my-own-class mozilla mozilla48 mq1280 lt1440 lt1680 lt1920 themered" touch-device="not"&gt; &lt;noscript style="text-align: center; display: block;"&gt;Please enable JavaScript in your browser settings.&lt;/noscript&gt; &lt;div id="wait" style="display: none;"&gt; &lt;div id="processing" class="hidden" style="display: none;"/&gt; &lt;div id="loading" class="hidden" style="display: none;"/&gt; &lt;div id="loadingPartsCatalog" class="hidden"/&gt; &lt;div id="panel"&gt; &lt;div id="top-toolbar" class="hidden" style="display: block;"&gt; &lt;div id="commands-line" class="hidden" style="display: block;"&gt; &lt;div id="line"&gt; &lt;div class="action-link"&gt; &lt;a class="tap-active" href="#m=activity/a=set" action_link_label="create_activity" component_gui="action" component_type="action"&gt;Create Activity&lt;/a&gt; &lt;/div&gt; &lt;div class="action-link"&gt; &lt;div class="action-link"&gt; &lt;div class="action-link"&gt; &lt;/div&gt; &lt;div id="commands-more" style="display: none;"&gt; &lt;div id="commands-list" class="hidden"&gt; &lt;/div&gt; &lt;div id="provider-search-bar" class="hidden center" </code></pre>
0
Unexpected value 'AnyComponent' declared by the module 'AppModule'
<p>I'm using Angular2 and I got this problem when tryng to use two classes in the same Typescript file.</p> <p>At compile time doesn't give me any error but when I try to execute the page the console.log is giving this error:</p> <pre><code>Error: BaseException@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:5116:27 CompileMetadataResolver&lt;/CompileMetadataResolver.prototype.getNgModuleMetadata/&lt;@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:13274:35 CompileMetadataResolver&lt;/CompileMetadataResolver.prototype.getNgModuleMetadata@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:13261:21 RuntimeCompiler&lt;/RuntimeCompiler.prototype._compileComponents@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15845:28 RuntimeCompiler&lt;/RuntimeCompiler.prototype._compileModuleAndComponents@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15769:36 RuntimeCompiler&lt;/RuntimeCompiler.prototype.compileModuleAsync@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15746:20 PlatformRef_&lt;/PlatformRef_.prototype._bootstrapModuleWithZone@http://www.my.app/panel-module/node_modules/@angular/core//bundles/core.umd.js:9991:20 PlatformRef_&lt;/PlatformRef_.prototype.bootstrapModule@http://www.my.app/panel-module/node_modules/@angular/core//bundles/core.umd.js:9984:20 @http://www.my.app/panel-module/app/main.js:4:1 @http://www.my.app/panel-module/app/main.js:1:31 @http://www.my.app/panel-module/app/main.js:1:2 Zone&lt;/ZoneDelegate&lt;/ZoneDelegate.prototype.invoke@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:332:20 Zone&lt;/Zone&lt;/Zone.prototype.run@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:225:25 scheduleResolveOrReject/&lt;@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:586:53 Zone&lt;/ZoneDelegate&lt;/ZoneDelegate.prototype.invokeTask@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:365:24 Zone&lt;/Zone&lt;/Zone.prototype.runTask@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:265:29 drainMicroTaskQueue@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:491:26 F/&lt;/g@http://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:10016 F/&lt;@http://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:10138 a.exports/k@http://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:14293 Evaluating http://www.my.app/panel-module/app/main.js Error loading http://www.my.app/panel-module/app/main.js </code></pre> <p>Below is my component typescript file.</p> <p>// MyComponent.ts</p> <pre><code>import { Component, OnInit } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: '/path/to/view', }) export class MyObject { id: number; } export class MyComponent { obj: MyObject; // unecessary code } </code></pre>
0
How to mute all sounds in chrome webdriver with selenium
<p>I want to write a script in which I use selenium package like this:</p> <pre><code>from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.youtube.com/watch?v=hdw1uKiTI5c") </code></pre> <p>now after getting the desired URL I want to mute the chrome sounds. how could I do this? something like this:</p> <pre><code>driver.mute() </code></pre> <p>is it possible with any other Webdrivers? like Firefox or ...?</p>
0
Django Rest Framework - Getting a model instance after serialization
<p>I've made a serializer, and I'm trying to create a <code>Booking</code> instance from the booking field in the serializer, after I've validated the POST data. However, because the <code>Booking</code> object has foreign keys, I'm getting the error: </p> <blockquote> <p>ValueError: Cannot assign "4": "Booking.activity" must be a "Activity" instance.</p> </blockquote> <p>Here's my view function:</p> <pre><code>@api_view(['POST']) def customer_charge(request): serializer = ChargeCustomerRequestSerializer(data=request.data) serializer.is_valid(raise_exception=True) # trying to create an instance using the ReturnDict from the serializer booking = Booking(**serializer.data['booking']) booking.save() </code></pre> <p>Serializers.py where <code>BookingSerializer</code> is a ModelSerializer</p> <pre><code>class ChargeCustomerRequestSerializer(serializers.Serializer): booking = BookingSerializer() customer = serializers.CharField(max_length=255) class BookingSerializer(serializers.ModelSerializer): class Meta: model = Booking fields = '__all__' # I wanted to view the instances with the nested information available # but this breaks the serializer validation if it's just given a foreign key # depth = 1 </code></pre> <p>What is the correct way to create a model instance from a nested serializer?</p>
0
How to make a CSS transform affect the flow of other elements
<p>I'm using CSS transitions with the <code>transform</code> property to shrinks elements when adding and removing them.</p> <p>However one problem with this is that this property doesn't affect the flow of other elements, so it appears as though the element being deleted shrinks away, and then the rest of the elements jump suddenly.</p> <p>If I were to animate the height property instead of using a transform this would be fine, however in actual usage I am using elements of variable height so I won't know what heights I can animate between.</p> <hr> <p><strong>Edit:</strong> people have suggested animating the <code>height</code> property (which won't work as stated above), or the <code>max-height</code> property. The <code>max-height</code> property will work to some extent, however you cannot align the timings perfectly as the transition will keep adjusting the <code>max-height</code> property past the actual height of the element until the end of the transition time.</p> <p>Another problem with these approaches is that it does not use the smooth animations that you can achieve with the <code>transform</code> property. The object's transform will happen smoothly, however the movement of the following elements will stutter as the browser renders these transitions differently.</p> <hr> <p>Here's a JSFiddle with what I mean (try adding then removing elements, and see the jump when elements are removed):</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-js lang-js prettyprint-override"><code>var button = document.querySelector("button"); var box = document.createElement("div"); box.className = "box"; box.appendChild(document.createTextNode("Click to delete")); button.addEventListener("click", function(e) { var new_box = box.cloneNode(true); new_box.addEventListener("click", function(e) { this.className = "box deleting"; window.setTimeout(function(e) { new_box.remove(); }, 1000); }); this.parentNode.appendChild(new_box); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>button { font-size: 20pt; } .box { font-size: 20pt; margin: 10px; width: 200px; padding: 10px; background: pink; transform: scale(1, 1); transform-origin: top left; } .deleting { transform: scale(1, 0); transition: all 1000ms ease; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button&gt; Add Box &lt;/button&gt;</code></pre> </div> </div> </p>
0
How to remove user from a specified group in Ansible?
<p>Let's assume <code>user01</code> has two groups defined: <code>groupA</code> and <code>groupB</code> (in addition to the primary group).</p> <p>I can add the account to <code>groupC</code> (ensure <code>user01</code> belongs to <code>groupC</code>) using:</p> <pre><code>- user: name=user01 groups=groupC append=yes </code></pre> <p>How can I remove <code>user01</code> from <code>groupB</code> (ensure <code>user01</code> does not belong to <code>groupB</code>) without specifying all the groups the account should belong to?</p>
0
How to generate JWT Token with IdentityModel Extensions for .NET 5
<p>I am using <a href="https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet" rel="noreferrer">IdentityModel Extensions for .NET</a> version 4 to generate JWT token with <em>symmetric key</em> and <em>SHA256</em> as below and it works perfectly:</p> <pre><code>var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims), TokenIssuerName = Issuer, AppliesToAddress = Audience, Lifetime = new Lifetime(now, expirationTime), SigningCredentials = new SigningCredentials( new InMemorySymmetricSecurityKey(symmetricKey), &quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha256&quot;, &quot;http://www.w3.org/2001/04/xmlenc#sha256&quot;), }; var securityToken = tokenHandler.CreateToken(tokenDescriptor); var token = tokenHandler.WriteToken(securitytoken); </code></pre> <p>But when I tried to upgrade to IdentityModel Extensions for .NET 5 as below code:</p> <pre><code>var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims), Issuer = Issuer, Audience = Audience, Expires = expirationTime, SigningCredentials = new SigningCredentials( new SymmetricSecurityKey(symmetricKey), &quot;SHA256&quot;) }; var securityToken = tokenHandler.CreateToken(tokenDescriptor); var token = tokenHandler.WriteToken(stoken); </code></pre> <p>I got exception:</p> <blockquote> <p>IDX10634: Unable to create the SignatureProvider.</p> <p>SignatureAlgorithm: 'SHA256', SecurityKey: 'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey' is not supported.</p> </blockquote> <p>What's wrong with the new code using version 5.</p>
0
fetch - Missing boundary in multipart/form-data POST
<p>I want to send a <code>new FormData()</code> as the <code>body</code> of a <code>POST</code> request using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="nofollow noreferrer">fetch api</a></p> <p>The operation looks something like this:</p> <pre class="lang-js prettyprint-override"><code>var formData = new FormData() formData.append('myfile', file, 'someFileName.csv') fetch('https://api.myapp.com', { method: 'POST', headers: { &quot;Content-Type&quot;: &quot;multipart/form-data&quot; }, body: formData } ) </code></pre> <p>The problem here is that the boundary, something like</p> <pre class="lang-none prettyprint-override"><code>boundary=----WebKitFormBoundaryyEmKNDsBKjB7QEqu </code></pre> <p>never makes it into the <code>Content-Type:</code> header</p> <p>It should look like this:</p> <pre class="lang-none prettyprint-override"><code>Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryyEmKNDsBKjB7QEqu </code></pre> <p>When you try the &quot;same&quot; operation with a <code>new XMLHttpRequest()</code>, like so:</p> <pre class="lang-js prettyprint-override"><code>var request = new XMLHttpRequest() request.open(&quot;POST&quot;, &quot;https://api.mything.com&quot;) request.withCredentials = true request.send(formData) </code></pre> <p>the headers are correctly set</p> <pre class="lang-none prettyprint-override"><code>Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryyEmKNDsBKjB7QEqu </code></pre> <p>So my questions are:</p> <ol> <li>how do I make <code>fetch</code> behave exactly like <code>XMLHttpRequest</code> in this situation?</li> <li>if this is not possible, why?</li> </ol> <p>Thanks everybody! This community is more or less the reason I have professional success.</p>
0
Is .GetAwaiter().GetResult(); safe for general use?
<p>I read in a few places that <code>.GetAwaiter().GetResult();</code> could cause deadlocks and that we should use <code>async</code>/<code>await</code> instead. But I see many code samples where this is used. Is it ok to use it? Which are the cases where it can deadlock? Is there something else I should use, like <code>Task.Wait</code>?</p>
0
How to update controls of FormArray
<p>My form group code is as</p> <pre><code>this.myForm = this._fb.group({ branch_name: ['', [Validators.required]], branch_timing: this._fb.array([ this.initBranchTiming(), ]) }); initBranchTiming() { return this._fb.group({ day: ['', []], open_from: ['00:00:00', []], open_till: ['00:00:00', []] }); } </code></pre> <p>branch_name is updated by this code </p> <pre><code>(&lt;FormControl&gt;this.myForm.controls['branch_name']).updateValue(this.branch_detail.branch_name); </code></pre> <p>Now i have to update the 'day' field of form array. what to do to update the 'day' field of form array branch_timing ?</p>
0
Today's Date in Contact Form 7 date picker
<p>I am new to WordPress and contact form 7. Is there any possibility to get today's date in the contact form 7 datepicker by default? I have this short-code is [date* date-299 min-date:0 first-day:1]. It didn't work for me. Is there any necessity for Hooks/Actions?</p> <p>Help required!!</p> <p>Thanks in advance.</p>
0
Changing background color of the layout on a button click in Android
<p>I am a newbie in Android. So please spare me if I am asking a stupid question.</p> <p>My application contains just one button in a Linear Layout. Requirement is, I have to change the background color of the linear layout of my app on a button click. By default it is <strong>WHITE</strong>, when I press on the button it should change to some random color and when I press the button again, it should change to the default color (white) again.</p> <p><code>button.setBackgroundColor(Color.BLUE)</code> (on the <strong>OnClick()</strong> method), changes the background color to <strong>BLUE</strong>, but how to get back to the default color?</p>
0
Laravel 5.3 Middleware class does not exist
<p>I would like to make some authentication based on middleware.. But unfortunately it returns as the class is not exist</p> <p>Here is my middleware</p> <p>Staff.php</p> <pre><code>&lt;?php namespace App\Http\Middleware; use Closure; use Auth; class Staff { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = Auth::user()-&gt;type; if ($user == 'S'){ return $next($request); } return "no"; } } </code></pre> <p>Here is the kernel.php</p> <pre><code>&lt;?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ // ]; protected $middleware = [ \App\http\Middleware\Staff::class, ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule-&gt;command('inspire') // -&gt;hourly(); } /** * Register the Closure based commands for the application. * * @return void */ protected function commands() { require base_path('routes/console.php'); } } </code></pre> <p>I have tried composer dump-autoload but it doesn't effective.</p> <p>Here is my route:</p> <pre><code>Route::get('/staff', 'StaffController@index')-&gt;middleware('Staff'); </code></pre>
0
How to apply different color in AppBar Title MUI?
<p>I am trying to use my custom color for <code>AppBar</code> header. The <code>AppBar</code> has title 'My AppBar'. I am using white as my primary theme color. It works well for the bar but the 'title' of the <code>AppBar</code> is also using same 'white' color'</p> <p>Here is my code:</p> <pre><code>import React from 'react'; import * as Colors from 'material-ui/styles/colors'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; import AppBar from 'material-ui/AppBar'; import TextField from 'material-ui/TextField'; const muiTheme = getMuiTheme({ palette: { textColor: Colors.darkBlack, primary1Color: Colors.white, primary2Color: Colors.indigo700, accent1Color: Colors.redA200, pickerHeaderColor: Colors.darkBlack, }, appBar: { height: 60, }, }); class Main extends React.Component { render() { // MuiThemeProvider takes the theme as a property and passed it down the hierarchy // using React's context feature. return ( &lt;MuiThemeProvider muiTheme={muiTheme}&gt; &lt;AppBar title=&quot;My AppBar&quot;&gt; &lt;div&gt; &lt; TextField hintText = &quot;username&quot; / &gt; &lt; TextField hintText = &quot;password&quot; / &gt; &lt;/div&gt; &lt;/AppBar&gt; &lt;/MuiThemeProvider&gt; ); } } export default Main; </code></pre> <p>But, the palette styles override the <code>AppBar</code> 'title' color and no title is displaying. Should I include something or I have misplaced any ?</p> <p>And this is my output : <a href="https://i.stack.imgur.com/pX4qX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pX4qX.png" alt="enter image description here" /></a></p>
0
Update Claims values in ASP.NET One Core
<p>I have a Web Application in MVC 6 (Asp.Net One Core), and I'm using Claims based authentication. In the Login method I set the Claims:</p> <pre><code>var claims = new Claim[] { new Claim("Name", content.Name), new Claim("Email", content.Email), new Claim("RoleId", content.RoleId.ToString()), }; var ci = new ClaimsIdentity(claims, "password"); await HttpContext.Authentication.SignInAsync("Cookies", new ClaimsPrincipal(ci)); </code></pre> <p>Now, if the user for example changes the email in the user profile, how can I change the e-mail value for the "Email" Claim? I have to SignOutAsync and SignInAsync again in order to update the cookie? The best solution is to save this into a classic session? There is a better solution? I'm totally wrong?</p> <p>Any suggestions?</p>
0
how to split 'number' to separate columns in pandas DataFrame
<p>I have a dataframe;</p> <pre><code>df=pd.DataFrame({'col1':[100000,100001,100002,100003,100004]}) col1 0 100000 1 100001 2 100002 3 100003 4 100004 </code></pre> <p>I wish I could get the result below;</p> <pre><code> col1 col2 col3 0 10 00 00 1 10 00 01 2 10 00 02 3 10 00 03 4 10 00 04 </code></pre> <p>each rows show the splitted number. I guess the number should be converted to string, but I have no idea next step.... I wanna ask how to split number to separate columns.</p>
0
error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'
<p>Using typescript and react with TSX files with definitely typed type definitions, I am getting the error:</p> <pre><code>error TS2339: Property 'for' does not exist on type 'HTMLProps&lt;HTMLLabelElement&gt;'. </code></pre> <p>When trying to compile a component with the following TSX </p> <pre><code>&lt;label for={this.props.inputId} className="input-label"&gt;{this.props.label}&lt;/label&gt; </code></pre> <p>I have already solved but adding here for the next person since the solution didn't show up anywhere when searching (Google or StackOverflow)</p>
0
open selected rows with pandas using "chunksize" and/or "iterator"
<p>I have a large csv file and I open it with pd.read_csv as it follows:</p> <pre><code>df = pd.read_csv(path//fileName.csv, sep = ' ', header = None) </code></pre> <p>As the file is really large I would like to be able to open it in rows</p> <pre><code>from 0 to 511 from 512 to 1023 from 1024 to 1535 ... from 512*n to 512*(n+1) - 1 </code></pre> <p>Where n = 1, 2, 3 ...</p> <p>If I add chunksize = 512 into the arguments of read_csv</p> <pre><code>df = pd.read_csv(path//fileName.csv, sep = ' ', header = None, chunksize = 512) </code></pre> <p>and I type</p> <pre><code>df.get_chunk(5) </code></pre> <p>Than I am able to open rows from 0 to 5 or I may be able to divide the file in parts of 512 rows using a for loop</p> <pre><code>data = [] for chunks in df: data = data + [chunk] </code></pre> <p>But this is quite useless as still the file has to be completelly opened and takes time. How can I read only rows from 512*n to 512*(n+1).</p> <p>Looking around I often saw that "chunksize" is used together with "iterator" as it follows</p> <pre><code> df = pd.read_csv(path//fileName.csv, sep = ' ', header = None, iterator = True, chunksize = 512) </code></pre> <p>But after many attempts I still don't understand which benefits provide me this boolean variable. Could you explain me it, please?</p>
0
Vue.js unknown custom element
<p>I'm a beginner with Vue.js and I'm trying to create an app that caters my daily tasks and I ran into Vue Components. So below is what I've tried but unfortunately, it gives me this error:</p> <blockquote> <p>vue.js:1023 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.</p> </blockquote> <p>Any ideas, help, please?</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-js lang-js prettyprint-override"><code>new Vue({ el : '#app', data : { tasks : [ { name : "task 1", completed : false}, { name : "task 2", completed : false}, { name : "task 3", completed : true} ] }, methods : { }, computed : { }, ready : function(){ } }); Vue.component('my-task',{ template : '#task-template', data : function(){ return this.tasks }, props : ['task'] });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"&gt;&lt;/script&gt; &lt;div id="app"&gt; &lt;div v-for="task in tasks"&gt; &lt;my-task :task="task"&gt;&lt;/my-task&gt; &lt;/div&gt; &lt;/div&gt; &lt;template id="task-template"&gt; &lt;h1&gt;My tasks&lt;/h1&gt; &lt;div class=""&gt;{{ task.name }}&lt;/div&gt; &lt;/template&gt;</code></pre> </div> </div> </p>
0
Named Pipes in Go for both Windows and Linux
<p>I am new to Go, I want to create Named Pipes implementation in Go which works on both Windows and Linux.</p> <p>I managed to get the code working on Ubuntu, but this one does not work on Windows</p> <p>Isn't there any abstraction in Go which allows you to work with Named Pipes in both environment</p> <p>Below is piece of my code</p> <pre><code>//to create pipe: does not work in windows syscall.Mkfifo("tmpPipe", 0666) // to open pipe to write file, err1 := os.OpenFile("tmpPipe", os.O_RDWR, os.ModeNamedPipe) //to open pipe to read file, err := os.OpenFile("tmpPipe", os.O_RDONLY, os.ModeNamedPipe) </code></pre> <p>Any help or pointers would help a lot. Thanks</p>
0
How to Slant/Skew only the bottom of the div
<p>I have been trying to add a Skew/Slant to the bottom of a div. I have had some success, as you can see below in my JSFiddle, I have managed to apply the skew but it's not completely how I wanted it.</p> <p><a href="https://jsfiddle.net/hcow6kjr/" rel="nofollow noreferrer">https://jsfiddle.net/hcow6kjr/</a></p> <p>Currently the Skew is applied to the top and bottom of the div the image resides in, this skew also seems to be applied to the image itself (if you take the skew off, you will see the image slightly rotate back to normal). I was wondering if it's possible to do the following adjustments, and how I may go about them...</p> <p>1 - Apply the skew to <strong>only the bottom</strong> of the div the image resides in, not both as currently is.</p> <p>2 - Not apply the skew to the image, so that the image sits flat horizontal (if that makes sense).</p> <p><strong>HTML</strong></p> <pre><code>&lt;div&gt; &lt;h1&gt; &lt;img src="http://www.visiontechautomotive.co.uk/visiontech/wordpress/wp-content/uploads/2016/08/visiontech-hero-test-1.jpg"&gt; &lt;/h1&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>div { background-image: green; height: 700px; padding: 20px; margin-top: 100px; -webkit-transform: skewY(-2deg); -moz-transform: skewY(-2deg); -ms-transform: skewY(-2deg); -o-transform: skewY(-2deg); transform: skewY(-2deg); overflow:hidden; } </code></pre> <p>Thanks in advance.</p>
0
In TypeScript an interface can extend a class, what for?
<p>in <a href="https://www.typescriptlang.org/docs/handbook/classes.html" rel="noreferrer">TypeScript Handbook</a> in 'Using a class as an interface' section, there is an example of an interface which extends a class.</p> <p><code>class Point { ... } interface Point3d extends Point {...}</code></p> <p>When can this be useful? Do you have any practical examples of this?</p>
0
Python numpy float16 datatype operations, and float8?
<p>when performing math operations on float16 Numpy numbers, the result is also in float16 type number. My question is how exactly the result is computed? Say Im multiplying/adding two float16 numbers, does python generate the result in float32 and then truncate/round the result to float16? Or does the calculation performed in '16bit multiplexer/adder hardware' all the way?</p> <p>another question - is there a float8 type? I couldnt find this one... if not, then why? Thank-you all!</p>
0
Install libc++ on ubuntu
<p>I am wondering what is the right/easy way to install a binary libc++ on Ubuntu, in my case Trusty aka 14.04?</p> <p>On the LLVM web site there are apt packages <a href="http://apt.llvm.org/" rel="noreferrer">http://apt.llvm.org/</a> and I have used these to install 3.9. However these packages don't seem to include libc++. I install the libc++-dev package but that seems to be a really old version. There are also binaries that can be downloaded <a href="http://llvm.org/releases/download.html#3.9.0" rel="noreferrer">http://llvm.org/releases/download.html#3.9.0</a>. These do seem to contain libc++ but I'm not sure if I can just copy bits of this into places like /usr/include/c++/v1, in fact I'm not really sure what bits I would need to copy. I am aware I can use libc++ from an alternate location as documented here <a href="http://libcxx.llvm.org/docs/UsingLibcxx.html" rel="noreferrer">http://libcxx.llvm.org/docs/UsingLibcxx.html</a> which I have tried. However I can't modify the build system of the large code base I work on to do this.</p> <p>So is three any reason the apt packages don't include libc++ and any pointers to installing a binary would be gratefully recieved.</p>
0
Error on gradle-2.10-all.zip.lck (The system cannot find the path specified)
<p>I recently updated my Android Studio to the recent version of 2.1.3 and also did some other update that popped up, only to obtain this error below for all my already existing projects on my android studio.</p> <blockquote> <p>Error:C:\Program Files\Android\Android Studio1\gradle\gradle-2.2.1\wrapper\dists\gradle-2.10-all\a4w5fzrkeut1ox71xslb49gst\gradle-2.10-all.zip.lck (The system cannot find the path specified)</p> </blockquote> <p>Please Guys I need your assistance. Thanks.</p>
0
How can I use Angular 2 with NetBeans?
<p>I have tried every tutorial I could find to try to make a HTML/JS project with Angular 2 working on NetBeans, but none have worked. Maybe is my npm that is bugged (search, for example, doesn't work).</p> <p>The <code>node_modules</code> folder that is created with <code>npm install</code> is grey on NetBeans and have some errors in some files (I don't know if this is normal). Any <code>.js</code> I try to import from <code>node_modules</code> folder gives the error <code>Failed to load resource: net::ERR_EMPTY_RESPONSE</code> / <code>Uncaught ReferenceError: System is not defined</code>.</p> <p>Does anyone have any idea what could I be doing wrong? Or does anyone knows any tutorial that have the code to download so I can compare with what I'm doing and see what is the correct? Every tutorial I have found doesn't have any code to download, just some pieces of codes in the page for explanation. Sory if this isn't a good question, but I have been trying to make this work since yesterday without success and I'm completely out of idea.</p>
0
SSL Certificate not working - "no start line" Error - Apache2 Ubuntu 16.04.1
<p>We're setting up a new subdomain at the office and using our wildcard SSL Cert we have. I've created my key, and my csr files. I've then sent to csr file off to get our cer file, which i now have. (I will posted commands I've run further down). I've then copied the files into the /etc/ssl/private and /etc/ssl/certs folders, and updated the apache conf file, after using a2ensite for our new domain. When trying to restart apache, the following error message is displayed:</p> <p><em>SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: TRUSTED CERTIFICATE) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?</em></p> <p>Bash commands i've run so far (I have omitted out domain name):</p> <pre><code>openssl genrsa -des3 -out [domain].key 2048 openssl rsa -in star.[domain].key -out star.[domain].key.insecure mv star.[domain].key star.[domain].key.secure mv star.[domain].key.insecure star.[domain].key openssl req -new -key star.[domain].key -out star.[domain].csr </code></pre> <p>When our domain was requested in the creation *.[domain] was entered, rather than star.[domain], as this is what is required by our provider. We then sent our csr file to our provider, and received our .cer back.</p> <p>I copied the .cer to /etc/ssl/certs/star.[domain].cer and /etc/ssl/private/star.[domain].key and then updated the apache conf file [subdomain].[domain].conf with the following:</p> <pre><code>ServerAdmin IT@[domain] ServerName [subdomain].[domain] ServerAlias [subdomain].[domain] SSLCertificateFile /etc/ssl/certs/star.[domain].cer SSLCertificateKeyFile /etc/ssl/private/star.[domain].key </code></pre> <p>After saving and restarting apache (<em>service apache2 restart</em>), I am presented with the above error.</p>
0
require_tree argument must be a directory in a Rails 5 upgraded app
<p>I just upgraded my app from <code>Rails 4.2.7</code> to <code>Rails 5.0.0.1</code>. I used <a href="http://railsdiff.org/4.2.7/5.0.0.1" rel="noreferrer">RailsDiff</a> to make sure I had everything covered and I believe I did. So far everything has worked well up until the loading of my app. </p> <p>Now I am seeing this error:</p> <pre><code>Sprockets::ArgumentError at / require_tree argument must be a directory </code></pre> <p>This is my <code>application.css</code>:</p> <pre><code>/* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require_tree . *= require_self */ </code></pre> <p>This is my <code>application.js</code></p> <pre><code>// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . </code></pre> <p>This is what the server log looks like:</p> <pre><code>Started GET "/" for ::1 at 2016-09-02 09:08:19 -0500 ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations" User Load (1.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]] Processing by ProfilesController#index as HTML Rendering profiles/index.html.erb within layouts/application Profile Load (1.6ms) SELECT "profiles".* FROM "profiles" Rendered profiles/index.html.erb within layouts/application (45.8ms) Completed 500 Internal Server Error in 367ms (ActiveRecord: 6.3ms) DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1@myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:7) DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /.rvm/gems/ruby-2.3.1myapp/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:8) Sprockets::ArgumentError - require_tree argument must be a directory: sprockets (3.7.0) lib/sprockets/directive_processor.rb:182:in `rescue in block in process_directives' sprockets (3.7.0) lib/sprockets/directive_processor.rb:179:in `block in process_directives' sprockets (3.7.0) lib/sprockets/directive_processor.rb:178:in `process_directives' </code></pre> <p>I am using no plugins of any kind. It is a fairly simple/vanilla app. The only styling is from the default <code>scaffold.scss</code>.</p> <p>What could be causing this?</p>
0
Json String to Java Object with dynamic key name
<p>I'm trying to parse this structured of json string to Java Object but I failed every attempt. </p> <pre><code>{ "message": "Test Message", "status": true, "users": { "user_xy": [ { "time": "2016-08-25 19:01:20.944614158 +0300 EEST", "age": 24, "props": { "pr1": 197, "pr2": 0.75, "pr3": 0.14, "pr4": -0.97 } } ], "user_zt": [ { "time": "2016-08-25 17:08:36.920891187 +0300 EEST", "age": 29, "props": { "pr1": 1.2332131860505051, "pr2": -0.6628148829634317, "pr3": -0.11622442112006928 } } ] } } </code></pre> <p>props field can contain 1 properties or 6 properties, it depends on db record. Also Username part dynamically changing. </p> <p>Can I parse successfully this structured string with Jackson Lib?</p>
0
asp.net core remove X-Powered-By cannot be done in middleware
<p>Why can I not remove X-Powered-By as part of my middleware that I am executing? I can remove it if I put in the web.config but not if I put it in the middleware. I am removing another header in the middleware "Server" : "Kestrel" which works and tells me my middleware is being executed. </p> <p>I am using Visual Studio 2015, ASP.Net Core Web Application (.NET Framework), 1.0.0-rc2-final</p> <p>My middleware</p> <pre><code>public class ManageHttpHeadersMiddleware { private RequestDelegate _next; public ManageHttpHeadersMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { context.Response.OnStarting(() =&gt; { context.Response.Headers.Remove("Server"); context.Response.Headers.Remove("X-Powered-By"); return Task.CompletedTask; }); await _next(context); } } </code></pre> <p>My Startup.Configure method looks like this</p> <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddSerilog(new LoggerConfiguration() .ReadFrom.ConfigurationSection(Configuration.GetSection("Serilog")) .CreateLogger()) .AddDebug(); app.UseMiddleware&lt;ManageHttpHeadersMiddleware&gt;(); app.UseJwtBearerAuthentication(); app.UseMvc(); app.UseSwaggerGen(); app.UseSwaggerUi(); } </code></pre> <p>So my questions are :</p> <ol> <li>Is it because of the order in which I am executing the middleware in the Startup.Configure ? </li> <li>Is it because of the event I am executing in the middleware ? I have tried using OnCompleted but its obviously to late and does not then remove "Server" : "Kestrel" </li> <li>Is it because its added by Kestrel or IIS in Azure and the only way to remove is via the web.config ?</li> </ol> <p>I know that you could argue I have a work around and what's my problem, but it would be nice to achieve the same requirement in the same code location, to help maintainability, etc, etc.</p>
0
Laravel 5.1 one form two submit buttons
<p>I am using Laravel 5.1, and I would like to make a form with two submit buttons - Save and Save draft.</p> <p>But when I post my form I have all the fields except the submit value.</p> <p>I have read that Laravel won't put the submit button value in the POST when the form was sent via ajax, so could you please help me how to do this?</p> <p>I have tried some code as below:</p> <pre><code>{!! Form::open(['url' =&gt; 'offer/create', 'method' =&gt; 'post', 'id' =&gt; 'offer-create']) !!} .... here are my fields .... {!! Form::submit( 'Save', ['class' =&gt; 'btn btn-default', 'name' =&gt; 'save']) !!} {!! Form::submit( 'Save draft', ['class' =&gt; 'btn btn-default', 'name' =&gt; 'save-draft']) !!} </code></pre> <p>In my routes.php I have:</p> <pre><code>Route::controller('offer', 'OfferController'); </code></pre> <p>Thanks in advance</p>
0
802.1X Mac El Capitan profile delete
<p>How to delete 802.1x profile on Mac? </p> <p><a href="https://i.stack.imgur.com/JbYbr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JbYbr.png" alt="enter image description here"></a>Because I have no ability to connect to the "eduroam" wifi.</p>
0
Pass method from parent component to child component in vuejs
<p>Can someone help me with passing a method from a parent to a child component in vue.js? I've been trying to do it by passing the method in as a prop...</p> <p>My parent component snippet:</p> <pre><code>methods: { test: function () { console.log('from test method') } } &lt;template&gt; &lt;child-component test="test"&gt;&lt;child-component&gt; &lt;/template&gt; </code></pre> <p>Child component snippet</p> <pre><code>created: { this.test() //returns test is not a function }, props: ['test'] </code></pre> <p>Can someone help?</p> <p>Thanks in advance!</p>
0
Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?) in Angular RC 5 when unit testing
<p>I just upgraded to Angular RC 5 and now all component that uses 'ROUTER_DIRECTIVES' fails with 'Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?)' when I try to unit test the component. </p> <pre><code>import { inject, addProviders } from '@angular/core/testing'; import { ComponentFixture, TestComponentBuilder } from '@angular/core/testing'; import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES, Router } from '@angular/router'; import { HomeComponent } from './home.component'; import { UserService } from '../_services/user.service'; describe('Component: Home', () =&gt; { beforeEach(() =&gt; { addProviders([HomeComponent, UserService, ROUTER_DIRECTIVES, Router]); }); it('should inject the component', inject([HomeComponent, UserService, ROUTER_DIRECTIVES, Router], (component: HomeComponent) =&gt; { expect(component).toBeTruthy(); // expect(component.currentUser.firstname).toEqual('Jan'); })); </code></pre> <p>The full error log: </p> <pre><code> Chrome 52.0.2743 (Windows 10 0.0.0) Error: Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?). at new BaseException (webpack:///C:/ng/anbud/~/@angular/compiler/src/facade/exceptions.js:27:0 &lt;- src/test.ts:2943:23) at CompileMetadataResolver.getDependenciesMetadata (webpack:///C:/ng/anbud/~/@angular/compiler/src/metadata_resolver.js:551:0 &lt;- src/test.ts:24542:19) at CompileMetadataResolver.getTypeMetadata (webpack:///C:/ng/anbud/~/@angular/compiler/src/metadata_resolver.js:448:0 &lt;- src/test.ts:24439:26) at webpack:///C:/ng/anbud/~/@angular/compiler/src/metadata_resolver.js:594:0 &lt;- src/test.ts:24585:41 at Array.forEach (native) at CompileMetadataResolver.getProvidersMetadata (webpack:///C:/ng/anbud/~/@angular/compiler/src/metadata_resolver.js:575:0 &lt;- src/test.ts:24566:19) at CompileMetadataResolver.getNgModuleMetadata (webpack:///C:/ng/anbud/~/@angular/compiler/src/metadata_resolver.js:305:0 &lt;- src/test.ts:24296:58) at RuntimeCompiler._compileComponents (webpack:///C:/ng/anbud/~/@angular/compiler/src/runtime_compiler.js:150:0 &lt;- src/test.ts:37986:47) at RuntimeCompiler._compileModuleAndAllComponents (webpack:///C:/ng/anbud/~/@angular/compiler/src/runtime_compiler.js:78:0 &lt;- src/test.ts:37914:37) at RuntimeCompiler.compileModuleAndAllComponentsSync (webpack:///C:/ng/anbud/~/@angular/compiler/src/runtime_compiler.js:52:0 &lt;- src/test.ts:37888:21) </code></pre> <p>Any ideas how to unit test components with routing? </p>
0
creating self-signed certificates with open ssl on windows
<p>I am following <a href="https://jamielinux.com/docs/openssl-certificate-authority/create-the-intermediate-pair.html" rel="noreferrer">these guidelines</a> to generate self-signed certificates with OpenSSL.</p> <p>I am under Windows 10. My working directory is as follows:</p> <pre><code>PS E:\Certificats\predix\root\ca&gt; ls Directory: E:\Certificats\predix\root\ca Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/1/2016 11:57 AM certs d----- 9/1/2016 11:55 AM crl d----- 9/1/2016 12:00 PM intermediate d----- 9/1/2016 11:55 AM newcerts d----- 9/1/2016 11:56 AM private -a---- 9/1/2016 11:55 AM 2 index.txt -a---- 9/1/2016 11:56 AM 4306 openssl.cnf -a---- 9/1/2016 11:55 AM 14 serial </code></pre> <p>After several steps in the guideline, when I type</p> <pre><code>openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md s </code></pre> <p>I get the following error</p> <pre><code>Using configuration from openssl.cnf Enter pass phrase for ./private/ca.key.pem: unable to load number from ./serial error while loading serial number 12944:error:0D066096:asn1 encoding routines:a2i_ASN1_INTEGER:short line:.\crypto\asn1\f_int.c:212: PS E:\Certificats\predix\root\ca&gt; openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md sha256 -in intermediate/csr/intermediate.csr.pem -out intermediate/certs/intermediate.cert.pem Using configuration from openssl.cnf </code></pre> <p>telling me that it has some issue reading the serial file.</p> <p>The content of serial is</p> <pre><code>1000 </code></pre> <p>Does anyone have a fix for this ? The file exists and its pathname in the conf file is the correct...</p>
0
Why Spring Boot Application class needs to have @Configuration annotation?
<p>I am learning about the Spring Framework but I can't understand what exactly the <code>@Configuration</code> annotation means and which classes should be annotated so. In the Spring Boot docs it is said that the Application class should be <code>@Configuration</code> class.</p> <blockquote> <p>Spring Boot favors Java-based configuration. Although it is possible to call SpringApplication.run() with an XML source, we generally recommend that your primary source is a @Configuration class.</p> </blockquote> <p>Trying to learn about <code>@Configuration</code> I find that annotating a class with the <code>@Configuration</code> indicates that the class can be used by the Spring IoC container as a source of bean definitions. </p> <p>If that is so then how is this application class a source of bean definitions?</p> <pre><code>@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan public class App { public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } } </code></pre> <p>I have pretty much understood most other basic concepts regarding Spring but I can't understand the purpose of <code>@Configuration</code> or which classes should be <code>@Configuration</code> classes? Can someone please help. Thanks !!</p>
0
Enzyme call method
<p>Let's say I have a method in my React component:</p> <pre><code>doSomething() { // method uses this.props and this.state } </code></pre> <p>I want to test this method for different props and states that are set. So how can I call it? <code>MyClass.prototype.doSomething</code> will call the function, but then <code>this.props</code> and <code>this.state</code> are not set. </p>
0
What are the rules of semicolon inference?
<blockquote> <p>Kotlin provides “semicolon inference”: syntactically, subsentences (e.g., statements, declarations etc) are separated by the pseudo-token SEMI, which stands for “semicolon or newline”. In most cases, there’s no need for semicolons in Kotlin code.</p> </blockquote> <p>This is what the <a href="https://kotlinlang.org/docs/reference/grammar.html" rel="noreferrer">grammar</a> page says. This seems to imply that there is a need to specify semicolons in some cases, but it doesn't specify them, and the grammar tree below doesn't exactly make this obvious. Also I have suspicions that there are some cases where this feature may not work correctly and cause problems.</p> <p>So the question is when should one insert a semicolon and what are the corner cases one needs to be aware of to avoid writing erroneous code?</p>
0
Google Chrome Extension manifest.json file
<p>I'm developing a Google Chrome Extension and facing a challenge with the background; the browser doesn't load the background picture added in CSS.</p> <p>I can't seem to find an effective way to declare assets under the <code>web_accessible_resources</code> key in the <code>manifest.json</code> file.</p> <p>What is the <code>manifest.json</code> file and how does one declare assets in it?</p>
0
To get more than 5 reviews from google places API
<p>I am doing an application where I extract the google reviews using google places API.When I read the document related to it in "<a href="https://developers.google.com/maps/documentation/javascript/places" rel="noreferrer">https://developers.google.com/maps/documentation/javascript/places</a>",I found out that I could get only 5 top reviews.Is there any option to get more reviews.</p>
0
Tensorflow Deep MNIST: Resource exhausted: OOM when allocating tensor with shape[10000,32,28,28]
<p>This is the sample MNIST code I am running:</p> <pre><code>from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) import tensorflow as tf sess = tf.InteractiveSession() x = tf.placeholder(tf.float32, shape=[None, 784]) y_ = tf.placeholder(tf.float32, shape=[None, 10]) W = tf.Variable(tf.zeros([784,10])) b = tf.Variable(tf.zeros([10])) y = tf.nn.softmax(tf.matmul(x,W) + b) def weight_variable(shape): initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial) def bias_variable(shape): initial = tf.constant(0.1, shape=shape) return tf.Variable(initial) def conv2d(x, W): return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') def max_pool_2x2(x): return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') W_conv1 = weight_variable([5, 5, 1, 32]) b_conv1 = bias_variable([32]) x_image = tf.reshape(x, [-1,28,28,1]) h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1) h_pool1 = max_pool_2x2(h_conv1) W_conv2 = weight_variable([5, 5, 32, 64]) b_conv2 = bias_variable([64]) h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) h_pool2 = max_pool_2x2(h_conv2) W_fc1 = weight_variable([7 * 7 * 64, 1024]) b_fc1 = bias_variable([1024]) h_pool2_flat = tf.reshape(h_pool2, [-1, 7*7*64]) h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1) keep_prob = tf.placeholder(tf.float32) h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob) W_fc2 = weight_variable([1024, 10]) b_fc2 = bias_variable([10]) y_conv=tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2) cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv), reduction_indices=[1])) train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) init = tf.initialize_all_variables() config = tf.ConfigProto() config.gpu_options.allocator_type = 'BFC' with tf.Session(config = config) as s: sess.run(init) for i in range(20000): batch = mnist.train.next_batch(50) if i%100 == 0: train_accuracy = accuracy.eval(feed_dict={ x:batch[0], y_: batch[1], keep_prob: 1.0}) print("step %d, training accuracy %g"%(i, train_accuracy)) train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5}) print("test accuracy %g"%accuracy.eval(feed_dict={ x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0})) </code></pre> <p>The GPU I am using is: <code>GeForce GTX 750 Ti</code></p> <p>Error:</p> <pre><code>... ... ... step 19900, training accuracy 1 I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (256): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (512): Total Chunks: 1, Chunks in use: 0 768B allocated for chunks. 1.20MiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (1024): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (2048): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (4096): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (8192): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (16384): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (32768): Total Chunks: 1, Chunks in use: 0 36.8KiB allocated for chunks. 4.79MiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (65536): Total Chunks: 1, Chunks in use: 0 78.5KiB allocated for chunks. 4.79MiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (131072): Total Chunks: 1, Chunks in use: 0 200.0KiB allocated for chunks. 153.1KiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (262144): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (524288): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (1048576): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (2097152): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (4194304): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (8388608): Total Chunks: 1, Chunks in use: 0 11.86MiB allocated for chunks. 390.6KiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (16777216): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (33554432): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (67108864): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (134217728): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (268435456): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin. I tensorflow/core/common_runtime/bfc_allocator.cc:656] Bin for 957.03MiB was 256.00MiB, Chunk State: I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a40000 of size 1280 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a40500 of size 1280 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a40a00 of size 31488 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48500 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48600 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48700 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48800 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48900 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a48a00 of size 4096 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a49a00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a49b00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a49c00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a49d00 of size 3328 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a4aa00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a4ab00 of size 204800 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a7cb00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x601a7cc00 of size 12845056 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026bcc00 of size 4096 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026bdc00 of size 40960 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026c7c00 of size 31488 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cf700 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cf800 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cf900 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cfa00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cfb00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cfc00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cfd00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cfe00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026cff00 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026d0000 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026d0100 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026d0500 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026d0600 of size 3328 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026d1300 of size 40960 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6026db300 of size 80128 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x602702600 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x602734700 of size 204800 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x603342700 of size 4096 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x603343700 of size 3328 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334d700 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334d800 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334d900 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334da00 of size 3328 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334e700 of size 3328 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334f400 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334f500 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x60334f600 of size 204800 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x603381600 of size 204800 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6033b3600 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6033b3700 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6033b3800 of size 12845056 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x603ff3800 of size 12845056 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c33800 of size 4096 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c34800 of size 4096 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c35800 of size 40960 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c3f800 of size 40960 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c49800 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c49900 of size 256 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x604c49a00 of size 13053184 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6058bc700 of size 31360000 I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0x6076a4b00 of size 1801385216 I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0x6026d0200 of size 768 I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0x6026eec00 of size 80384 I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0x602702700 of size 204800 I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0x602766700 of size 12435456 I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0x603344400 of size 37632 I tensorflow/core/common_runtime/bfc_allocator.cc:689] Summary of in-use Chunks by size: I tensorflow/core/common_runtime/bfc_allocator.cc:692] 32 Chunks of size 256 totalling 8.0KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 2 Chunks of size 1280 totalling 2.5KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 5 Chunks of size 3328 totalling 16.2KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 5 Chunks of size 4096 totalling 20.0KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 2 Chunks of size 31488 totalling 61.5KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 4 Chunks of size 40960 totalling 160.0KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 80128 totalling 78.2KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 4 Chunks of size 204800 totalling 800.0KiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 3 Chunks of size 12845056 totalling 36.75MiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 13053184 totalling 12.45MiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 31360000 totalling 29.91MiB I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 1801385216 totalling 1.68GiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] Sum Total of in-use chunks: 1.76GiB I tensorflow/core/common_runtime/bfc_allocator.cc:698] Stats: Limit: 1898266624 InUse: 1885507584 MaxInUse: 1885907712 NumAllocs: 2387902 MaxAllocSize: 1801385216 W tensorflow/core/common_runtime/bfc_allocator.cc:270] **********************************************************xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx W tensorflow/core/common_runtime/bfc_allocator.cc:271] Ran out of memory trying to allocate 957.03MiB. See logs for memory state. W tensorflow/core/framework/op_kernel.cc:968] Resource exhausted: OOM when allocating tensor with shape[10000,32,28,28] Traceback (most recent call last): File "trainer_deepMnist.py", line 109, in &lt;module&gt; x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0})) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 559, in eval return _eval_using_default_session(self, feed_dict, self.graph, session) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3648, in _eval_using_default_session return session.run(tensors, feed_dict) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 710, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 908, in _run feed_dict_string, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 958, in _do_run target_list, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 978, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors.ResourceExhaustedError: OOM when allocating tensor with shape[10000,32,28,28] [[Node: Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](Reshape, Variable_2/read)]] Caused by op u'Conv2D', defined at: File "trainer_deepMnist.py", line 61, in &lt;module&gt; h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1) File "trainer_deepMnist.py", line 46, in conv2d return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 394, in conv2d data_format=data_format, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2320, in create_op original_op=self._default_original_op, op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1239, in __init__ self._traceback = _extract_stack() </code></pre> <p>I read some github issues (<a href="https://github.com/tensorflow/tensorflow/issues/136" rel="noreferrer">here</a>, <a href="https://github.com/tensorflow/tensorflow/issues/609" rel="noreferrer">here</a>) related to the same problem but could not understand how I should change my code to solve this problem.</p>
0
Is React Native's Async Storage secure?
<p>I want to store sensitive data locally in a React Native app.</p> <p>Is the data only available to the app that wrote it?</p>
0
"z-index" on Bootstrap navbar and dropdown
<p>I have a problem in my navbar dropdown and cart dropdown.</p> <p>I'm not sure how to fix this (I don't have solid knowledge about css <code>z-index</code>).</p> <p>What I want is the shopping cart menu dropdown to stay on top of <code>navbar</code> menu dropdown.</p> <p>I have changed the <code>z-index</code> on both dropdown menus and doesn`t work.<br> Thanks.</p> <p>Here is the image: <a href="https://i.stack.imgur.com/sOphf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sOphf.png" alt="Shopping Cart Screenshot"></a></p> <p>Here is the working jsfiddle:<br> <a href="https://jsfiddle.net/nmdh5vmv/2/" rel="nofollow noreferrer">https://jsfiddle.net/nmdh5vmv/2/</a></p>
0
Can we use sketch UI elements directly into Xcode?
<p>I am new to sketch 3. I have a hand on experience with Xcode and iOS development. </p> <p>My question is wether we can directly use sketch elements in xcode or sketch is only used for prototyping the UI?</p> <p>For example, If I design Label with a text field in sketch then can I used it as UI Label and UITextField in Xcode?</p>
0
How to capitalize the first letter in custom textview?
<p>In Custom TextView suppose if first character as a number then next character would be a character. How to find the first character amoung numbers.</p>
0
move files to .zip archive in windows command line
<p>I wanted to know how to move files to a .zip archive. I'm using this code: <code>xcopy C:\Folder C:\AnotherFolder\zippedFolder.zip</code>. This copies the files from C:\Folder <strong>DIRECTLY</strong> into the archive, but I want to have that file in the archive (so i can doubleclick the archive and see the file unopened). </p> <p>Want to do this to create an excel file with a .cmd</p>
0
Android: Collapsing Linearlayout instead of Collapsing Toolbar
<p>I'm trying to create a Master/Detail transaction in a single fragment. I thought of using LinearLayout as the container of my edittext for my header. Then a RecyclerView for details.</p> <p>How would one implement the collapsing/expanding of LinearLayout similar to that of the CollapsingToolbar effect?</p> <p>Here's a screenshot of what I'm trying to do.</p> <p><a href="https://i.stack.imgur.com/l09kz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l09kz.png" alt="enter image description here"></a></p> <p>My xml code so far.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@color/colorAccent" android:padding="@dimen/activity_horizontal_margin"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/ic_date_range_black_24dp" android:tint="@android:color/darker_gray" /&gt; &lt;android.support.v4.widget.Space android:layout_width="@dimen/activity_horizontal_margin" android:layout_height="wrap_content" /&gt; &lt;android.support.design.widget.TextInputLayout android:id="@+id/date_til" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Date"&gt; &lt;android.support.design.widget.TextInputEditText android:id="@+id/date" android:layout_width="match_parent" android:layout_height="wrap_content" android:cursorVisible="false" android:focusable="false" android:longClickable="false" /&gt; &lt;/android.support.design.widget.TextInputLayout&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/ic_store_black_24dp" android:tint="@android:color/darker_gray" /&gt; &lt;android.support.v4.widget.Space android:layout_width="@dimen/activity_horizontal_margin" android:layout_height="wrap_content" /&gt; &lt;android.support.design.widget.TextInputLayout android:id="@+id/store_til" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Store"&gt; &lt;android.support.design.widget.TextInputEditText android:id="@+id/store" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; &lt;/android.support.design.widget.TextInputLayout&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/ic_place_black_24dp" android:tint="@android:color/darker_gray" /&gt; &lt;android.support.v4.widget.Space android:layout_width="@dimen/activity_horizontal_margin" android:layout_height="wrap_content" /&gt; &lt;android.support.design.widget.TextInputLayout android:id="@+id/location_til" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;android.support.design.widget.TextInputEditText android:id="@+id/location" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Location" /&gt; &lt;/android.support.design.widget.TextInputLayout&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/recycler" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" app:layoutManager="LinearLayoutManager" tools:listitem="@layout/list_car" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Also, not sure if this can be done with the CollapsingToolbar since I've mostly seen only ImageView collapsing in the Toolbar.</p> <p>Appreaciate any help.</p> <p>UPDATE: Basically what I want to do here is to be able to collapse the header view when scrolling up. Then expand when scrolling down.</p>
0
Error:Execution failed for task ':app:processDebugGoogleServices'. Android
<p>Error:Execution failed for task ':app:processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at <a href="https://bintray.com/android/android-tools/com.google.gms.google-services/" rel="noreferrer">https://bintray.com/android/android-tools/com.google.gms.google-services/</a>) or updating the version of com.google.android.gms to 9.0.2</p> <p><strong>This is the error I am getting. Below is my gradle file. I have tried many solutions of stackoverflow but none worked in my case.</strong></p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.radioaudio.motivationalaudios" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile files('libs/YouTubeAndroidPlayerApi.jar') compile 'com.google.android.gms:play-services:9.0.2' compile 'com.google.firebase:firebase-ads:9.0.2' compile 'com.google.firebase:firebase-core:9.0.2' compile 'com.android.support:design:23.4.0' compile 'com.android.support:multidex:1.0.1' compile 'com.onesignal:OneSignal:2.+@aar' compile 'com.google.android.gms:play-services-gcm:+' compile 'com.google.android.gms:play-services-analytics:+' compile 'com.google.android.gms:play-services-location:+' } apply plugin: 'com.google.gms.google-services' </code></pre>
0
How to use identifier of cell in table view?
<p>here's the code:</p> <pre><code>import UIKit class SliderMenuTableViewController: UITableViewController { var tableArray = [String]() override func viewDidLoad() { super.viewDidLoad() // Uncomment the following line to preserve selection between presentations // self.clearsSelectionOnViewWillAppear = false // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem() let age: String age = String(LoginViewController.AGE) let Profile = LoginViewController.NAME! + ", " + age tableArray = [Profile,"Second","Third","Fourth","Logout"] } // table view delegate method override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell { var cell = tableView.dequeueReusableCellWithIdentifier(tableArray[indexPath.row], forIndexPath: indexPath) as UITableViewCell cell.textLabel?.text = tableArray[indexPath.row] if cell.textLabel?.text == tableArray[0] { cell.imageView?.frame = CGRectMake(10, 10, 50, 50) cell.imageView!.layer.borderWidth = 1 cell.imageView!.layer.masksToBounds = false cell.imageView!.layer.borderColor = UIColor.blackColor().CGColor cell.imageView!.layer.cornerRadius = cell.imageView!.frame.width/2 cell.imageView!.clipsToBounds = true cell.imageView?.image = LoginViewController.AVATAR } return cell } </code></pre> <p>Error occured:</p> <p><strong>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Viktor, Optional(29) - must register a nib or a class for the identifier or connect a prototype cell in a storyboard</strong></p> <p>I understand that I have to identifier the cell, how to do this from code cause the variable 'Profile' that in my <code>tableArray</code> isn't static and I can't identifier it from storyboard? </p>
0
VBA running Access Query from Excel
<p>I am trying to run a VBA script that will Run and Export an Access query. I'm able to get to the step in code where I run the query, however, I need to connect to DB2 to run this query in Access and I don't know how to implement into my code to enter the username and password.</p> <pre><code>Sub RunQuery() Dim A As Object Application.DisplayAlerts = False Set A = CreateObject("Access.Application") A.Visible = False A.OpenCurrentDatabase ("J:\user\filename.mdb") A.DoCmd.OpenQuery "QueryName" A.DoCmd.ConnectString Application.DisplayAlerts = True End Sub </code></pre> <p>The code just stalls at the line:</p> <pre><code>A.DoCmd.OpenQuery "QueryName" </code></pre> <p>And If I open my Database from here with my query it is just waiting for my username and password. I'll try and attach a picture of the prompt.</p> <p>Any help would be greatly appreciated!!</p> <p>Thank you very much<a href="https://i.stack.imgur.com/EAmIZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAmIZ.png" alt="enter image description here"></a></p>
0
how to get angular2 formcontrol parent
<p>How to get parent form group in a nested form group for a control. At the time of validation of a control, i need a sibling control value. Both these controls are part of formgroup, which is part of formArray. I know we have root, which gives the root element. How can I get immediate parent of a given form control.</p>
0
Django: Not Found static/admin/css
<p>I just deployed my first Django app on Heroku but I notice that it doesn't have any CSS like when I runserver on the local machine. I know there's something wrong with static files but I don't understand much about it even when I already read <a href="https://docs.djangoproject.com/en/1.10/howto/static-files/#serving-static-files-in-development" rel="noreferrer">the docs</a>. I can do</p> <p><code>python3 manage.py collectstatic</code></p> <p>to create a static folder but I don't know where to put it and how to change the DIRS in settings.py. I really need some help to get rid of it.</p> <p><a href="https://i.stack.imgur.com/1NtBa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1NtBa.png" alt="root directory"></a></p> <p>settings.py:</p> <pre><code>DEBUG = True INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'household_management', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] STATIC_ROOT = 'static' STATIC_URL = '/static/' </code></pre> <p>heroku logs:</p> <pre><code>2016-09-02T10:42:09.461124+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-earth-63194.herokuapp.com request_id=33fc071d-344c-47e7-8721-919ba6d5df65 fwd="14.191.217.103" dyno=web.1 connect=2ms service=53ms status=302 bytes=400 2016-09-02T10:42:09.760323+00:00 heroku[router]: at=info method=GET path="/admin/login/?next=/" host=peaceful-earth-63194.herokuapp.com request_id=c050edcd-02d9-4c39-88ba-8a16be692843 fwd="14.191.217.103" dyno=web.1 connect=1ms service=45ms status=200 bytes=2184 2016-09-02T10:42:10.037370+00:00 heroku[router]: at=info method=GET path="/static/admin/css/login.css" host=peaceful-earth-63194.herokuapp.com request_id=ec43016a-09b7-499f-a84b-b8024577b717 fwd="14.191.217.103" dyno=web.1 connect=2ms service=9ms status=404 bytes=4569 2016-09-02T10:42:10.047224+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=peaceful-earth-63194.herokuapp.com request_id=6570ee02-3b78-44f4-9ab9-0e80b706ea40 fwd="14.191.217.103" dyno=web.1 connect=1ms service=16ms status=404 bytes=4566 2016-09-02T10:42:10.030726+00:00 app[web.1]: Not Found: /static/admin/css/login.css 2016-09-02T10:42:10.043743+00:00 app[web.1]: Not Found: /static/admin/css/base.css 2016-09-02T10:48:56.593180+00:00 heroku[api]: Deploy d1d39dc by [email protected] 2016-09-02T10:48:56.593290+00:00 heroku[api]: Release v21 created by [email protected] 2016-09-02T10:48:56.803122+00:00 heroku[slug-compiler]: Slug compilation started 2016-09-02T10:48:56.803127+00:00 heroku[slug-compiler]: Slug compilation finished 2016-09-02T10:48:56.893962+00:00 heroku[web.1]: Restarting 2016-09-02T10:48:56.894722+00:00 heroku[web.1]: State changed from up to starting 2016-09-02T10:48:59.681267+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2016-09-02T10:49:00.418357+00:00 app[web.1]: [2016-09-02 17:49:00 +0000] [9] [INFO] Worker exiting (pid: 9) 2016-09-02T10:49:00.418377+00:00 app[web.1]: [2016-09-02 17:49:00 +0000] [10] [INFO] Worker exiting (pid: 10) 2016-09-02T10:49:00.418393+00:00 app[web.1]: [2016-09-02 10:49:00 +0000] [3] [INFO] Handling signal: term 2016-09-02T10:49:00.477684+00:00 app[web.1]: [2016-09-02 10:49:00 +0000] [3] [INFO] Shutting down: Master 2016-09-02T10:49:00.594623+00:00 heroku[web.1]: Process exited with status 0 2016-09-02T10:49:00.607775+00:00 heroku[web.1]: Starting process with command `gunicorn assignment.wsgi --log-file -` 2016-09-02T10:49:02.911936+00:00 app[web.1]: [2016-09-02 10:49:02 +0000] [3] [INFO] Starting gunicorn 19.6.0 2016-09-02T10:49:02.912529+00:00 app[web.1]: [2016-09-02 10:49:02 +0000] [3] [INFO] Listening at: http://0.0.0.0:18162 (3) 2016-09-02T10:49:02.917427+00:00 app[web.1]: [2016-09-02 10:49:02 +0000] [9] [INFO] Booting worker with pid: 9 2016-09-02T10:49:02.912655+00:00 app[web.1]: [2016-09-02 10:49:02 +0000] [3] [INFO] Using worker: sync 2016-09-02T10:49:02.980208+00:00 app[web.1]: [2016-09-02 10:49:02 +0000] [10] [INFO] Booting worker with pid: 10 2016-09-02T10:49:04.228057+00:00 heroku[web.1]: State changed from starting to up 2016-09-02T10:53:41.572630+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-earth-63194.herokuapp.com request_id=68c0b216-2084-46c8-9be5-b7e5aacaa590 fwd="14.191.217.103" dyno=web.1 connect=0ms service=42ms status=302 bytes=400 2016-09-02T10:53:41.880217+00:00 heroku[router]: at=info method=GET path="/admin/login/?next=/" host=peaceful-earth-63194.herokuapp.com request_id=17b91dc2-ba06-482c-8af0-e7b015fe2077 fwd="14.191.217.103" dyno=web.1 connect=0ms service=41ms status=200 bytes=2184 2016-09-02T10:53:42.156295+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=peaceful-earth-63194.herokuapp.com request_id=40dec62d-8c4a-4af6-8e0f-8053fe8379b9 fwd="14.191.217.103" dyno=web.1 connect=0ms service=9ms status=404 bytes=4566 2016-09-02T10:53:42.157491+00:00 heroku[router]: at=info method=GET path="/static/admin/css/login.css" host=peaceful-earth-63194.herokuapp.com request_id=3a29f200-c185-4344-a6e1-5af35e5d120e fwd="14.191.217.103" dyno=web.1 connect=0ms service=17ms status=404 bytes=4569 2016-09-02T10:53:42.164162+00:00 app[web.1]: Not Found: /static/admin/css/base.css 2016-09-02T10:53:42.177480+00:00 app[web.1]: Not Found: /static/admin/css/login.css 2016-09-02T11:01:19.031353+00:00 heroku[api]: Deploy 2beb15a by [email protected] 2016-09-02T11:01:19.031444+00:00 heroku[api]: Release v22 created by [email protected] 2016-09-02T11:01:19.262522+00:00 heroku[slug-compiler]: Slug compilation started 2016-09-02T11:01:19.262528+00:00 heroku[slug-compiler]: Slug compilation finished 2016-09-02T11:01:19.426837+00:00 heroku[web.1]: Restarting 2016-09-02T11:01:19.427455+00:00 heroku[web.1]: State changed from up to starting 2016-09-02T11:01:22.141325+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2016-09-02T11:01:22.545379+00:00 heroku[web.1]: Starting process with command `gunicorn assignment.wsgi --log-file -` 2016-09-02T11:01:22.754067+00:00 app[web.1]: [2016-09-02 18:01:22 +0000] [9] [INFO] Worker exiting (pid: 9) 2016-09-02T11:01:22.754077+00:00 app[web.1]: [2016-09-02 18:01:22 +0000] [10] [INFO] Worker exiting (pid: 10) 2016-09-02T11:01:22.757599+00:00 app[web.1]: [2016-09-02 11:01:22 +0000] [3] [INFO] Handling signal: term 2016-09-02T11:01:22.763197+00:00 app[web.1]: [2016-09-02 11:01:22 +0000] [3] [INFO] Shutting down: Master 2016-09-02T11:01:22.880977+00:00 heroku[web.1]: Process exited with status 0 2016-09-02T11:01:24.628348+00:00 app[web.1]: [2016-09-02 11:01:24 +0000] [3] [INFO] Starting gunicorn 19.6.0 2016-09-02T11:01:24.628921+00:00 app[web.1]: [2016-09-02 11:01:24 +0000] [3] [INFO] Listening at: http://0.0.0.0:34235 (3) 2016-09-02T11:01:24.629075+00:00 app[web.1]: [2016-09-02 11:01:24 +0000] [3] [INFO] Using worker: sync 2016-09-02T11:01:24.636198+00:00 app[web.1]: [2016-09-02 11:01:24 +0000] [9] [INFO] Booting worker with pid: 9 2016-09-02T11:01:24.722355+00:00 app[web.1]: [2016-09-02 11:01:24 +0000] [10] [INFO] Booting worker with pid: 10 2016-09-02T11:01:26.271435+00:00 heroku[web.1]: State changed from starting to up 2016-09-02T11:01:27.930795+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-earth-63194.herokuapp.com request_id=a844ef4b-a2d1-44fe-af0e-09c76cb0e034 fwd="14.191.217.103" dyno=web.1 connect=0ms service=46ms status=302 bytes=400 2016-09-02T11:01:28.363163+00:00 heroku[router]: at=info method=GET path="/admin/login/?next=/" host=peaceful-earth-63194.herokuapp.com request_id=31c0823a-466f-4363-b550-3c81681305f5 fwd="14.191.217.103" dyno=web.1 connect=0ms service=171ms status=200 bytes=2184 2016-09-02T11:01:28.716801+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=peaceful-earth-63194.herokuapp.com request_id=2d1b8bb2-9ab3-49f7-b557-a54eed996547 fwd="14.191.217.103" dyno=web.1 connect=0ms service=8ms status=404 bytes=4566 2016-09-02T11:01:28.693936+00:00 heroku[router]: at=info method=GET path="/static/admin/css/login.css" host=peaceful-earth-63194.herokuapp.com request_id=24aa1eed-aa87-4854-ab35-1604e8393b9d fwd="14.191.217.103" dyno=web.1 connect=0ms service=18ms status=404 bytes=4569 2016-09-02T11:01:28.681948+00:00 app[web.1]: Not Found: /static/admin/css/base.css 2016-09-02T11:01:28.692958+00:00 app[web.1]: Not Found: /static/admin/css/login.css 2016-09-02T11:12:43.686922+00:00 heroku[api]: Deploy 63085e6 by [email protected] 2016-09-02T11:12:43.687037+00:00 heroku[api]: Release v23 created by [email protected] 2016-09-02T11:12:43.951987+00:00 heroku[slug-compiler]: Slug compilation started 2016-09-02T11:12:43.951998+00:00 heroku[slug-compiler]: Slug compilation finished 2016-09-02T11:12:43.926959+00:00 heroku[web.1]: Restarting 2016-09-02T11:12:43.929107+00:00 heroku[web.1]: State changed from up to starting 2016-09-02T11:12:46.931285+00:00 heroku[web.1]: Starting process with command `gunicorn assignment.wsgi --log-file -` 2016-09-02T11:12:47.860591+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2016-09-02T11:12:48.729601+00:00 app[web.1]: [2016-09-02 18:12:48 +0000] [10] [INFO] Worker exiting (pid: 10) 2016-09-02T11:12:48.729617+00:00 app[web.1]: [2016-09-02 18:12:48 +0000] [9] [INFO] Worker exiting (pid: 9) 2016-09-02T11:12:48.729623+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [3] [INFO] Handling signal: term 2016-09-02T11:12:48.775112+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [3] [INFO] Shutting down: Master 2016-09-02T11:12:48.890301+00:00 heroku[web.1]: Process exited with status 0 2016-09-02T11:12:48.839674+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [3] [INFO] Starting gunicorn 19.6.0 2016-09-02T11:12:48.840093+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [3] [INFO] Listening at: http://0.0.0.0:20001 (3) 2016-09-02T11:12:48.840166+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [3] [INFO] Using worker: sync 2016-09-02T11:12:48.843687+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [9] [INFO] Booting worker with pid: 9 2016-09-02T11:12:48.939210+00:00 app[web.1]: [2016-09-02 11:12:48 +0000] [10] [INFO] Booting worker with pid: 10 2016-09-02T11:12:50.565750+00:00 heroku[web.1]: State changed from starting to up 2016-09-02T11:13:00.439745+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-earth-63194.herokuapp.com request_id=c30b47e6-fbb8-4412-9242-5fe37217026a fwd="14.191.217.103" dyno=web.1 connect=0ms service=49ms status=400 bytes=199 2016-09-02T11:14:01.686661+00:00 heroku[api]: Deploy c149525 by [email protected] 2016-09-02T11:14:01.686965+00:00 heroku[api]: Release v24 created by [email protected] 2016-09-02T11:14:02.189063+00:00 heroku[slug-compiler]: Slug compilation started 2016-09-02T11:14:02.189073+00:00 heroku[slug-compiler]: Slug compilation finished 2016-09-02T11:14:02.466456+00:00 heroku[web.1]: Restarting 2016-09-02T11:14:02.467005+00:00 heroku[web.1]: State changed from up to starting 2016-09-02T11:14:04.713176+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2016-09-02T11:14:05.259388+00:00 app[web.1]: [2016-09-02 18:14:05 +0000] [10] [INFO] Worker exiting (pid: 10) 2016-09-02T11:14:05.260345+00:00 app[web.1]: [2016-09-02 11:14:05 +0000] [3] [INFO] Handling signal: term 2016-09-02T11:14:05.265937+00:00 app[web.1]: [2016-09-02 18:14:05 +0000] [9] [INFO] Worker exiting (pid: 9) 2016-09-02T11:14:05.317647+00:00 app[web.1]: [2016-09-02 11:14:05 +0000] [3] [INFO] Shutting down: Master 2016-09-02T11:14:05.411311+00:00 heroku[web.1]: Process exited with status 0 2016-09-02T11:14:06.581314+00:00 heroku[web.1]: Starting process with command `gunicorn assignment.wsgi --log-file -` 2016-09-02T11:14:10.282506+00:00 heroku[web.1]: State changed from starting to up 2016-09-02T11:14:10.187781+00:00 app[web.1]: [2016-09-02 11:14:10 +0000] [3] [INFO] Starting gunicorn 19.6.0 2016-09-02T11:14:10.188490+00:00 app[web.1]: [2016-09-02 11:14:10 +0000] [3] [INFO] Listening at: http://0.0.0.0:27446 (3) 2016-09-02T11:14:10.188627+00:00 app[web.1]: [2016-09-02 11:14:10 +0000] [3] [INFO] Using worker: sync 2016-09-02T11:14:10.211822+00:00 app[web.1]: [2016-09-02 11:14:10 +0000] [9] [INFO] Booting worker with pid: 9 2016-09-02T11:14:10.231978+00:00 app[web.1]: [2016-09-02 11:14:10 +0000] [10] [INFO] Booting worker with pid: 10 2016-09-02T11:14:29.714607+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-earth-63194.herokuapp.com request_id=947ed6b9-b48a-48b1-8860-36846248acea fwd="14.191.217.103" dyno=web.1 connect=0ms service=153ms status=302 bytes=400 2016-09-02T11:14:30.522664+00:00 heroku[router]: at=info method=GET path="/admin/login/?next=/" host=peaceful-earth-63194.herokuapp.com request_id=b74c55bf-913c-4e0d-8d16-2b1f4f0cea13 fwd="14.191.217.103" dyno=web.1 connect=0ms service=561ms status=200 bytes=2184 2016-09-02T11:14:30.879732+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=peaceful-earth-63194.herokuapp.com request_id=769f989a-f051-4a89-a079-1d6acea3c185 fwd="14.191.217.103" dyno=web.1 connect=0ms service=86ms status=404 bytes=4566 2016-09-02T11:14:30.865971+00:00 heroku[router]: at=info method=GET path="/static/admin/css/login.css" host=peaceful-earth-63194.herokuapp.com request_id=b271b831-a4fb-4bdb-9f6a-e4d66297db88 fwd="14.191.217.103" dyno=web.1 connect=0ms service=75ms status=404 bytes=4569 2016-09-02T11:14:30.865501+00:00 app[web.1]: Not Found: /static/admin/css/login.css 2016-09-02T11:14:30.871110+00:00 app[web.1]: Not Found: /static/admin/css/base.css </code></pre>
0
event.path is undefined running in Firefox
<p>When I run <code>event.path[n].id</code> in Firefox, I get this error. It works in other browsers.</p> <blockquote> <p>event.path undefined</p> </blockquote>
0
SOAP-ERROR: Failed to load external entity error on SOAP using PHP
<p>I am using PHP Version 5.6.0 and openssl also enabled but still got this error. Can you please suggest a solution?</p> <blockquote> <p>SOAP-ERROR: Parsing WSDL: Couldn't load from '<a href="https://IP">https://IP</a> Address:9007/common?wsdl' : failed to load external entity "<a href="https://IP">https://IP</a> Address:9007/common?wsdl"</p> </blockquote>
0
how to embed external html file into current html file but without iframe tag
<p>I need to open External website inside my current html file without iFrame</p> <p>Help me..</p>
0
JSON Parsing Exception: Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '"' (code 0x22) in base64 content
<p>Using Jackson and I'm trying to encode data in JSON &amp; it's giving Exception.</p> <p>I tried String data &amp; byte[] data:</p> <pre><code>String representation of same data is here: Bytes converted to String--------&gt;&gt; { "appname": "aaa", "deviceType": "diehdcj", "reportedDate": "2015-05-03T15:38:45+00:00", "sessionId": "5366372183482-6736-23562378", "deviceId": "2151272389", "commandName" : "wqgduwusdue", "protocolVersion" : "0.1", "protocolName" : "whjs_ashk_ask", "data" : "false" } </code></pre> <p><strong>Java</strong></p> <blockquote> <p>16:50:46.065 [] [] ERROR AAATSHConnector [http-apr-10.40.120.85-80-exec-3] - JSON Parsing Exception: Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '"' (code 0x22) in base64 content</p> </blockquote> <p>Here's the code that does the parsing:</p> <p><strong>Java</strong></p> <pre><code>@Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response retrieveDevicePassword(InputStream request, @Context HttpServletRequest servletRequest) throws BadRequestException, ValidationException, UnknownServerException { ObjectMapper objectMapper = new ObjectMapper(); DemoRequest req = null; DemoRequest res = null; byte[] data = null; data= IOUtils.toByteArray(request); DemoRequest = objectMapper.readValue(data, DemoRequest.class); //It's where the Exception occurs </code></pre> <p><strong>Java</strong></p> <pre><code>//Snippet of POJO @XmlRootElement(name = "demoRequest") @JsonInclude(Include.NON_EMPTY) public class DemoRequest { private String commandName; private String sessionId; private byte[] data; //getters &amp; setters } </code></pre> <p>Amazingly when I try to convert same String or byte[] with a little change in the actual content "data" : "true" , it works.</p> <p>Can anyone please help</p> <p>Found the solution, but don't know what's it exactly doing: If I place an escape character in front of false, like "data" : "\false" , it works fine.</p> <p>What could be the explanation for that?</p>
0
onRequestPermissionsResult is not called in fragment android
<p>i am taking runtime permission from user by using below code in fragment .</p> <pre><code>if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(mActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, STORAGE_PERMISSION_CODE); } </code></pre> <p>and overriding</p> <pre><code>@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case 21: { // If request is cancelled, the result arrays are empty. if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! Do the // contacts-related task you need to do. } else { // permission denied, boo! Disable the // functionality that depends on this permission. Toast.makeText(getActivity(), "Permission denied", Toast.LENGTH_SHORT).show(); } return; } // other 'case' lines to check for other // permissions this app might request } } </code></pre> <p>but override method not called </p> <p>please give me hint for that i have to override in fragment</p>
0
How to check if an array index exists using Ruby and/or Rails
<p>Is there a Ruby (preferably) or Rails way to check if the second index of an array exists?</p> <p>In my Rails (4.2.6) app I have the following code in my view that shows the first two thumbnails for an array of photos:</p> <pre><code>&lt;% if array.photos.any? %&gt; &lt;%= image_tag array.photos.first.image.url(:thumb) %&gt; &lt;%= image_tag array.photos[1].image.url(:thumb) %&gt; &lt;% end %&gt; </code></pre> <p>However if there is no second item in the array, then there is an error</p> <p>I've tried the following <code>if</code> statements to make the rendering of the second thumbnail conditional, but they don't work:</p> <pre><code>&lt;% if array.photos.include?(1) %&gt; &lt;% if array.photos.second? %&gt; &lt;% if array.photos[1]? %&gt; &lt;% if array.photos[1].any? %&gt; </code></pre> <p>I figured that another way to get what I want would be to simply check the length of the array</p> <p>Still I was wondering if Ruby (or Rails) had a method or way to check if a specific index in an array exists or not. Thanks in advance</p> <p>EDIT: To clarify I just want to show the first two thumbnails in the array, if any</p>
0
Set background image in storyboard
<p>Can i set the background image from storyboard? I've set background in code:</p> <pre><code>override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png")) } </code></pre>
0
MongoDb: add element to array if not exists
<p>I'm using node.js and Mongo.db (I'm newly on Mongo). I have a document like this:</p> <pre><code>Tag : { name: string, videoIDs: array } </code></pre> <p>The idea is, the server receives a JSON like </p> <pre><code>JSON: { name: "sport", videoId: "34f54e34c" } </code></pre> <p>with this JSON, it has to find the tag with the same name and check if in the array it has the <code>videoId</code>, if not, insert it to the array.</p> <p>How can I check the array and append data?</p>
0
How to ignore NULL byte when reading a csv file
<p>I'm reading a csv file generated from an equipment and I got this error message:</p> <pre><code>Error: line contains NULL byte </code></pre> <p>I opened the csv file in text editor and I do see there're some NUL bytes in the header section, which I don't really care about. How can I make the csv reader function to ignore the NUL byte and just goes through the rest of the file? </p> <p>There're two blank lines between the header section and the data, maybe there's way to skip the whole header?</p> <p>My code for reading the csv file is </p> <pre><code>with open(FileName, 'r', encoding='utf-8') as csvfile: csvreader = csv.reader(csvfile) </code></pre>
0
java.lang.ClassNotFoundException: org.springframework.expression.ParserContext Spring HelloWorld?
<p>I have simple Spring HelloWorld program. Its contents are as follows:</p> <p><a href="https://i.stack.imgur.com/yLKC7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yLKC7.png" alt="enter image description here"></a></p> <p><strong>pom.xml</strong></p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.mahesha999.examples.spring&lt;/groupId&gt; &lt;artifactId&gt;SpringExamples&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-context&lt;/artifactId&gt; &lt;version&gt;4.3.2.RELEASE&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p><strong>eg1.xml</strong></p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"&gt; &lt;bean id="helloBean" class="com.mahesha999.examples.spring.eg1.HelloWorld"&gt; &lt;property name="name" value="Mahesha999" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p><strong>HelloWorld.java</strong></p> <pre><code>public class HelloWorld { private String name; public void setName(String name) { this.name = name; } public void printHello() { System.out.println("Spring : Hello ! " + name); } } </code></pre> <p><strong>App.java</strong></p> <pre><code>import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("eg1.xml"); HelloWorld obj = (HelloWorld) context.getBean("helloBean"); obj.printHello(); } } </code></pre> <p>This gave me following error:</p> <pre><code>INFO: Loading XML bean definitions from class path resource [eg1.xml] Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/expression/ParserContext at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:628) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:516) at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83) at com.mahesha999.examples.spring.eg1.App.main(App.java:8) Caused by: java.lang.ClassNotFoundException: org.springframework.expression.ParserContext at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 5 more </code></pre> <p>When I changed spring version from 4.3.2 to 4.2.2 in pom.xml, it worked fine. Why is it so?</p>
0
npm - The system cannot find the path specified
<p>I have installed <code>nodejs</code>. When I try and use <code>npm</code> via power shell or cmd it returns</p> <blockquote> <p>The system cannot find the path specified.</p> </blockquote> <p>If I run <code>node -v</code> everything works fine. I can use <code>npm</code> via the <code>nodejs</code> console just fine as well. I've tried uninstalling and reinstalling <code>nodejs</code> multiple times and it didn't help.</p> <p>Any ideas on what is causing this?</p>
0
Python - Select "Save link as" and save a file using Selenium
<p>Newbie: There are different files on a webpage, which can be downloaded as follows: 1. Right click on a file link 2. Select "Save link as" 3. Click "Save" button on the new window.</p> <p>I tried the following code(for first 2 steps), but it is not working:</p> <pre><code> from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.common.keys import Keys import time driver = webdriver.Chrome() driver.maximize_window() driver.get('www.example.com') time.sleep(1) driver.find_element_by_link_text("MarketFiles/").click() actionChains = ActionChains(driver) download_file = "Market_File1.csv" link = driver.find_element_by_link_text(download_file) actionChains.context_click(link).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.RETURN).perform(); </code></pre> <p>Kindly suggest how to download the file using these 3 steps. Thanks</p>
0
How to send parameters by POST
<p>resource receives the parameters</p> <p>example: <code>http://example.com/show-data?json={"fob":"bar"}</code></p> <p>in case of GET request, all clear and work well.</p> <pre><code>urlStr := "http://87.236.22.7:1488/test/show-data" json := `"foo":"bar"` r, _ := http.Get(urlStr+`?json=`+json) println(r.Status) 200 OK </code></pre> <p>But how it shoud be done when use POST request? </p> <p>i try </p> <pre><code> urlStr := "http://87.236.22.7:1488/test/show-data" json := `{"foo":"bar"}` form := url.Values{} form.Set("json", json) println(form.Encode()) post, _ := http.PostForm(urlStr, form) println(post.Status) 400 Bad Request json parameter is missing </code></pre> <p>but it`s not work.</p>
0
Explicitly disable caching for REST services
<p>I am to apply <code>Cache-Control: must-revalidate,no-cache,no-store</code> to all responses from out backend REST services. I have two questions about it:</p> <ul> <li>Is it common to do so? For some reason I was under the impression that it's not necessary, but I have no source to back this claim (yet).</li> <li>Is the value I mentioned above really sufficient, or should I set more?</li> </ul> <p>Edit: found this: <a href="https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers#cache-prevention" rel="noreferrer">https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers#cache-prevention</a>. Is says browsers may choose to cache when nothing is explicitly configured, so it means yes, it should be configured if I want to make sure cache is disabled.</p>
0
Using AJAX call in MVC5
<p>I have tried to use AJAX call in an MVC5 project as many similar examples on the web, but every time there is an error i.e. antiforgerytoken, 500, etc. I am looking at a proper AJAX call method with Controller Action method that has all the necessary properties and sending model data from View to Controller Action. Here are the methods I used:</p> <p><strong>View:</strong></p> <pre><code>@using (Html.BeginForm("Insert", "Account", FormMethod.Post, new { id = "frmRegister" })) { @Html.AntiForgeryToken() //code omitted for brevity } &lt;script&gt; AddAntiForgeryToken = function (data) { data.__RequestVerificationToken = $('#__AjaxAntiForgeryForm input[name=__RequestVerificationToken]').val(); return data; }; $('form').submit(function (event) { event.preventDefault(); //var formdata = JSON.stringify(@Model); //NOT WORKING??? var formdata = new FormData($('#frmRegister').get(0)); //var token = $('[name=__RequestVerificationToken]').val(); //I also tried to use this instead of "AddAntiForgeryToken" method but I encounter another error $.ajax({ type: "POST", url: "/Account/Insert", data: AddAntiForgeryToken({ model: formdata }), //data: { data: formdata, __RequestVerificationToken: token }, //contentType: "application/json", processData: false, contentType: false, datatype: "json", success: function (data) { $('#result').html(data); } }); }); &lt;/script&gt; </code></pre> <p>Controller: Code cannot hit to this Action method due to antiforgerytoken or similar problem. </p> <pre><code>[HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public JsonResult Insert(RegisterViewModel model) { try { //... //code omitted for brevity } } </code></pre> <p>I just need a proper AJAX and Action methods that can be used for CRUD operations in MVC5. Any help would be appreciated.</p> <p><strong>UPDATE:</strong> Here is some points about which I need to be clarified:</p> <p>1) We did not use "__RequestVerificationToken" and I am not sure if we send it to the Controller properly (it seems to be as cookie in the Request Headers of Firebug, but I am not sure if it is OK or not). Any idea? </p> <p>2) Should I use var formdata = new FormData($('#frmRegister').get(0)); when I upload files? </p> <p>3) Why do I have to avoid using processData and contentType in this scenario? </p> <p>4) Is the Controller method and error part of the AJAX method are OK? Or is there any missing or extra part there? </p>
0
How to read a json file into build.gradle and use the values the strings in build.gradle file
<p>for example, read the json file in <code>build.gradle</code> and use the json values as strings in the file</p> <pre><code>{ "type":"xyz", "properties": { "foo": { "type": "pqr" }, "bar": { "type": "abc" }, "baz": { "type": "lmo" } } } </code></pre> <p>I need to call <code>properties.bar.type</code> and <code>abc</code> should be replaced there.</p> <p>I need to convert these values to <code>string</code> and use in <code>build.gradle</code> file</p>
0
Get AM/PM from HTML time input
<p>First, I know that <code>&lt;input type="time"&gt;</code> is not supported by IE10 or earlier, and Firefox, but this is only for testing purposes and I will make appropriate, cross-browser changes at another time.</p> <p>For the time being, I have a HTML time input field. I am trying to extract the values from it including the hour, minutes and AM/PM. I can display the hour and minutes, but an AM/PM indication is not including.</p> <p>I have an input as follows:</p> <p><code>&lt;input type="time" name="end-time" id="end-time"&gt;</code></p> <p>I print out via <code>alert()</code> the input value as follows:</p> <p><code>alert(document.getElementById('end-time').value);</code></p> <p>Upon input I receive an alert such as:</p> <p><code>01:34</code>.</p> <p>Notice that an AM/PM is not included in the <code>alert()</code>.</p> <p>How can I get the AM/PM value from a HTML time input via Javascript?</p>
0
Move a Microsoft Azure VM to a Different Subnet Within a vNet
<p>Can't we Move a Microsoft Azure VM to a Different Subnet Within a vNet using the azure new portal or the azure classic portal ? if not possible through portal then how to do so ?then how to edit the properties of a VM after creation, like moving to a different subnet,, etc.,? </p>
0
How to get the request url in retrofit 2.0 with rxjava?
<p>I'm trying to upgrade to Retrofit 2.0 and add RxJava in my android project. I'm making an api call and want to retrieve the url and it with the response data in sqlite as a cache</p> <pre><code>Observable&lt;MyResponseObject&gt; apiCall(@Body body); </code></pre> <p>And in the RxJava call:</p> <pre><code>myRetrofitObject.apiCall(body).subscribe(new Subscriber&lt;MyResponseObject&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(MyResponseObject myResponseObject) { } }); </code></pre> <p>In Retrofit 1.9, we could get the url in the success callback:</p> <pre><code> @Override public void success(MyResponseObject object, Response response) { String url=response.getUrl(); //save object data and url to sqlite } </code></pre> <p>How do you do this with Retrofit 2.0 using RxJava?</p>
0
Autocomplete with ajax call(Json) in laravel, no response
<p><strong>I have the view:</strong></p> <pre><code>&lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" /&gt; &lt;script&gt; $(function() { $( "#q" ).autocomplete({ source : "{{ url('search/autocomplete') }}", minLength: 3, select: function(event, ui) { $('#q').val(ui.item.value); } }); }); &lt;/script&gt; &lt;input id="q" placeholder="Search users" name="q" type="text" value=""&gt; </code></pre> <p><strong>Controller:</strong></p> <pre><code>&lt;?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\NewTheme; use App\Http\Requests; use DB; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Input; use Auth; use Response; class SearchController extends Controller { public function autocomplete(){ $term = Input::get('term'); $results = array(); // this will query the users table matching the TagName $queries = DB::table('New_Themes') -&gt;where('TagName', 'like', '%'.$term.'%') -&gt;take(5)-&gt;get(); foreach ($queries as $query) { $results[] = ['value' =&gt; $query-&gt;TagName]; } return Response::json($results); } } </code></pre> <p><strong>And my route:</strong></p> <pre><code>Route::get('search/autocomplete', 'SearchController@autocomplete'); </code></pre> <p>My problem is that when I type more then 3 letters in input tag I don't get anything, which seems that input with q id isn't filled with the values. If I do add the form/action/method thing with submit button the controller works fine, so the problem is in this ajax call which doesn't work properly.</p> <p>Any thoughts why this isn't working properly(maybe it the ajax call doesn't get properly to route or something like this)?</p> <p><strong>FINAL SOLUTION thanks to stack and Borna:</strong></p> <p><strong>View:</strong></p> <pre><code> &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"&gt; &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt; &lt;input type="text" class="form-control" placeholder="TagName" id="searchname" name="TagName"&gt; &lt;script type="text/javascript"&gt; $('#searchname').autocomplete({ source:'{!!URL::route('autocomplete')!!}', minlength:1, autoFocus:true, select:function(e,ui) { $('#searchname').val(ui.item.value); } }); &lt;/script&gt; </code></pre> <p><strong>Controller:</strong></p> <pre><code>&lt;?php namespace App\Http\Controllers; use \Illuminate\Http\Request; use App\NewTheme; //Instead of NewTheme, your model name use Input; use App\Http\Requests; use App\Http\Controllers\Controller; use DB; class Theme extends Controller { //Instead of Theme your own controller name public function autocomplete(Request $request) { $term = $request-&gt;term; $queries = DB::table('New_Themes') //Your table name -&gt;where('TagName', 'like', '%'.$term.'%') //Your selected row -&gt;take(6)-&gt;get(); foreach ($queries as $query) { $results[] = ['id' =&gt; $query-&gt;id, 'value' =&gt; $query-&gt;TagName]; //you can take custom values as you want } return response()-&gt;json($results); } } </code></pre> <p><strong>Route:</strong></p> <pre><code>Route::get('/autocomplete', array('as' =&gt; 'autocomplete', 'uses'=&gt;'Theme@autocomplete')); //Instead of Theme your Controller name </code></pre>
0
In tableau, how do you modify the number of decimals of a percentage label?
<p>In tableau, how do you modify the number of decimals of a percentage label? On bar charts, histograms, maps, etc. </p>
0
Finding an object in array and taking values from that to present in a select list
<p>I have a string value (e.g. "Table 1") that I need to use to find a specific object in an array that looks like so:</p> <pre><code>[ { lookups: [], rows: [{data: {a: 1, b: 2}}, {data: {a: 3, b: 4}}], title: "Table 1", columns: [{name: "a"}, {name: "b"}] }, { lookups: [], rows: [{data: {c: 5, d: 6}}, {data: {c: 7, d: 8}}], title: "Table 2", columns: [{name: "c"}, {name: "d"}] } ] </code></pre> <p>Once I have found that object I then need to take the values from the columns key and display them in a select list.</p> <p>I know how to do the second part, but it is getting access to the object in the first place that I am having trouble with. I am trying to do this within a React component render.</p> <p>Any help with this would be greatly appreciated.</p> <p>Thanks for your time.</p>
0
Replace \n(new line) with space in bash
<p>I am reading some sql queries into a variable from db and it contains new line character (\n). I want to replace \n (new line) with space. I tried solutions provided on internet but was unsuccessful to achieve what I want. Here is what tried :</p> <pre><code>strr="my\nname\nis\nxxxx"; nw_strr=`echo $strr | tr '\n' ' '`; echo $nw_strr; </code></pre> <p>my desired output is "my name is xxxx" but what I am getting is "my\nname\nis\nxxxx". I also tried other solution provided at internet, but no luck: </p> <pre><code>nw_strr=`echo $strr | sed ':a;N;$!ba;s/\n/ /g'`; </code></pre> <p>Am I doing something wong? </p>
0
How to read connection string in .NET Core?
<p>I want to read just a connection string from a configuration file and for this add a file with the name "appsettings.json" to my project and add this content on it:</p> <pre><code>{ "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet- WebApplica71d622;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } </code></pre> <p>On ASP.NET I used this:</p> <pre><code> var temp=ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; </code></pre> <p>Now how can I read "DefaultConnection" in C# and store it on a string variable in .NET Core?</p>
0
Regular expression with if condition
<p>I am new to regular expression. I am trying to construct a regular expression that first three characters must be alphabets and then the rest of the string could be any character. If the part of the string after first three characters contains &amp; then this part should start and end with <code>&quot;</code>.</p> <p>I was able to construct <code>^[a-z]{3}</code>, but stuck at conditional statement.</p> <p>For example <code>abcENT</code> and <code>abc&quot;E&amp;T&quot;</code> are valid strings but not <code>abcE&amp;T</code>.</p> <p>Can this be done in a single expression?</p>
0
How to get response from Promise function .then?
<p>I have 2 input element as follows in my HTML:</p> <pre><code>&lt;input type="date" ng-model="calendarStart" class="form-control" style="display: inline-block; width: 180px !important;" /&gt; &lt;input type="date" ng-model="calendarEnd" class="form-control" style="display: inline-block; width: 180px !important;" /&gt; </code></pre> <p>and have .js : </p> <pre><code>$scope.calendarStart = new Date(); $scope.calendarEnd = new Date(); $scope.calendarEnd.setDate($scope.calendarEnd.getDate() + 7); var firstEndDate = new Date(); var firstStartDate = new Date(); var startData = "calendarStart"; var endData = "calendarEnd"; $scope.changeCalendarStart = function () { dataService.settings_get(startData).then(function(response) { firstStartDate = response; if (firstStartDate != null) $scope.calendarStart = firstStartDate; return firstStartDate; }); return firstStartDate; }; </code></pre> <p>How I can get response value from .then function , caz need to change value in inputs ?</p>
0