Id
int64
2.49k
75.6M
PostTypeId
int64
1
1
AcceptedAnswerId
int64
2.5k
75.6M
Question
stringlengths
7
28.7k
Answer
stringlengths
0
24.3k
Image
imagewidth (px)
1
10k
26,084,838
1
26,452,012
I am trying to make a website XML editor and I am using spry datasets and nested datasets to do this. However I have an XML file like this: ''' <Seating_Plan> <Department id="A"> <DeptCode>001</DeptCode> <DeptName>Test1</DeptName> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5<li> </Department> <Department id="B"> <DeptCode>002</DeptCode> <DeptName>Test2</DeptName> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> </Department> </Seating_Plan> ''' And I have my HTML like this: ''' <script type="text/javascript"> var XML = new Spry.Data.XMLDataSet("../XML/XML.xml", "Seating_Plan/Person"); var XML_Dept = new Spry.Data.XMLDataSet("../XML/XML.xml", "Seating_Plan/Department"); var dslists = new Spry.Data.NestedXMLDataSet("../XML/XML.xml", "li"); </script> <div spry:region="XML_Dept"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr class="XML_Container_Header"> <th height="40">ID</th> <th>DeptCode</th> <th>DeptName</th> <th>Description</th> <th>lists</th> </tr> <tr spry:repeat="XML_Dept"> <td><input id="ID_Dept" name="ID_Dept" type="text" class="textfields" value="{@id}" size="3" maxlength="3"></td> <td><input id="ID_Dept" name="ID_Dept" type="text" class="textfields" value="{DeptCode}" size="30" maxlength="30"></td> <td><input id="ID_Dept" name="ID_Dept" type="text" class="textfields" value="{DeptName}" size="50" maxlength="50"></td> <td><input id="ID_Dept" name="ID_Dept" type="text" class="textfields" value="{li}" size="50" maxlength="50"></td> <td spry:region="XML_Dept"><ul spry:repeatchildren="dslists"><li><input id="ID_Dept" name="ID_Dept" type="text" class="textfields" value="{li}" size="50" maxlength="50"></li></ul></td> </tr> </table> ''' The first row is displayed correctly with the XML LI elements of Department "A", however the second row or Department B in the table has duplicated the Department "A" XML Li Elements, How do I get it to display the department B li elements removing the duplication...? In other words: <IMAGE> Any ideas would be gratefully appreciated!! Many thanks!
SPRYS are no longer supported, it is better to use JQUERY or Javascript from additional research. Also using PHP Forms to post the values works well for my needs.
9,020,274
1
9,022,694
Im trying to test class from within of SAP class builder. I pressed F8 (Test) but 'Create instance' menu item is not active on test screen: <IMAGE> My class has both static and instance constructors. Where is my mistake? How to force this menu item to be active?
Is this parameter set to 'public'? <IMAGE> Moreover, if it is, then it is probably because your class implements an interface. Just click the magnifying glass icon next to the interface name and you will both be able to execute static and instance methods.
16,690,835
1
16,690,930
I am using <URL>. I would like to make the textview that starts current Activity be non-clickable, but for this, I have to create a condition where I can compare current Activity's context to the context of the Activity that created this SlidingMenu. I know it sounds quite complicated what I'm trying to explain, but I also feel like the solution could be quite simple. I'll show a picture so you can understand better: <IMAGE> So I would like, ie Cart textView to be disabled for tapping, if current Activity (the one on the right) is Cart Activity. I have to do something like this: ''' tv_menu_cart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // check if Cart Activity's context is the current one and -> do nothing, otherwise continue with starting the activity. startActivity(new Intent(getBaseContext(), Cart.class)); sm.toggle(false); } }); '''
It is not quite clear to me what content you wrote. But seeing at your title, I guess you are trying to get the context. If that is what you are looking for, there are few methods you can use: ''' - getContext() - getBaseContext() - getApplicationContext() ''' I hope it helps.
29,545,569
1
29,545,996
Why I am getting space between listview menu <IMAGE> Here is my code ''' <script id="panel-init"> $( document ).on( "pagecreate", function() { $( "body > [data-role='panel']" ).panel(); $( "body > [data-role='panel'] [data-role='listview']" ).listview(); }); $( document ).one( "pageshow", function() { $( "body > [data-role='header']" ).toolbar(); $( "body > [data-role='header'] [data-role='navbar']" ).navbar(); }); </script> ''' HTML: ''' <div data-role="header" data-position="fixed"> <h3>Order</h3> <a class="ui-btn ui-btn-left ui-btn-icon-notext ui-icon-back" data-rel="back"></a> <a class="ui-btn ui-btn-right ui-btn-icon-notext ui-icon-bars" href="#rightPanel"></a> </div> ''' Here is the external panel defined out of 'page' ''' <!-- Right panel--> <div data-role="panel" data-position-fixed="true" data-display="push" data-theme="b" id="rightPanel"> <ul data-role="listview"> <li data-icon="delete"><a href="#" data-rel="close">Close menu</a></li> <li><a href="#">Acura</a></li> <li><a href="#">Audi</a></li> <li><a href="#">BMW</a></li> <li><a href="#">Cadillac</a></li> <li><a href="#">Ferrari</a></li> </ul> </div><!-- /rightPanel --> '''
You only need to initialize the header and panel once on document ready, not on pagecreate or pageshow: ''' $(function() { $( "body > [data-role='panel']" ).panel(); $( "body > [data-role='panel'] [data-role='listview']" ).listview(); $( "[data-role='navbar']" ).navbar(); $( "[data-role='header']" ).toolbar(); }); ''' Other than that your code works: > Working <URL> Note: if you copied the listview markup from the jQM dem site, you might have ended up with extra '&nbsp;' characters instead of regular spaces in the markip. Try erasing all spaces between the '<LI>' elements in the source page, and see if the problem goes away.
14,845,864
1
14,847,754
I'm trying to display a datetime column from MSSQL. However when I was displaying the date from the database, it appears as this. <IMAGE> There is a .0 at the back of the time. Is there anyway to remove the .0? By the way, I'm using grails. This is my codes, hope you guys can help out over here. :) ''' def result = sql.rows("select * from user") def example = sql.rows(query) [result:result] '''
In your gsp while displaying your date you can format it like: ''' <g:formatDate format="yyyy-MM-dd HH:mm:ss" date="${result?.date}"/> ''' You can find the formatDate documentation <URL>
12,178,681
1
12,178,853
I have grid in extjs, where in column the value come as 200.00 GB, 12.00 GB, 23.34 GB. When i click on sorting it not shown in proper order like Ascending or decending. Please help me how to show the combination of number and string sorting. Check Image <IMAGE>
This is covered in the documentation: <URL> You can provide your own custom sorting method.
63,903,647
1
63,905,434
I'm reworking and extending an existing data model where a section covers person data. The current person table is just 1 big table containing all fields, both for natural and legal persons and the non-relevant fields just remain empty. As we're adding more and more fields, the idea would be to have a single PERSON table and 2 subclasses NATURALPERSON and LEGALPERSON, where a person could never be both at the same time. Sounds easy enough but started reading and doubting my initial approach. What would you do? 1. First option I had in mind was to have a single column in the PERSON table for the Foreign key, LEGAL_NATURAL, which would be a pointer to either LEGALPERSON or NATURALPERSON. To ensure mutually exclusiveness the record ID's for the subclasses could be constructed using a single sequence. <IMAGE> ''' SELECT * FROM PRSN pr left join LEGALPERSON_DETAIL lp on pr.legal_natural = lp.id left join NATURALPERSON_DETAIL np on pr.legal_natural = np.id; ''' 1. Instead of the 1 column for 2 FK's, an alternative would be to have 2 columns in the PERSON table (e.g. NATURALPERSON, LEGALPERSON), each with a possible pointer to a subclass. A constraint could then make sure both aren't filled at the same time. Could make the FK relationship more obvious. 2. Different approach would be to have the subclasses point to the PERSON table. Has the disadvantage that in the PERSON table it's not visible whether it's a natural or legal person record but might be a nicer design overall. Found some info on exclusive arcs on <URL>. Is there a clear winner here?
The design of your three tables looks good. AS far as PKs and FKs are concerned I recommend a technique called Shared Primary Key. The person table has an ID field which functions as a PK. The natural person and legal person tables do not have an independent ID field. Instead, both subclasses use PersonID as the PK in their own table. PersonID is also an FK that references ID in the person table. This makes joins simple, easy, and fast.
19,092,242
1
19,093,612
I am using Jquery full calender Resource view for scheduling purpose and Is working fine (as expected) but it create some problem in chrome. <IMAGE> you can clearly see that on 18th and 19th the event time are same but it display event in wrong sequence. Plz... help me to solve out this. Here is some gson data from my database. ''' {"allDay":"false","color":"","end":"2013-12-18T00:00","resource":10,"start":"2013-12-18T00:00","title":"01:00 to 08:00","__hashCodeCalc":false}, {"allDay":"false","color":"","end":"2013-12-18T00:00","resource":10,"start":"2013-12-18T00:00","title":"09:00 to 21:00","__hashCodeCalc":false}, {"allDay":"false","color":"","end":"2013-12-19T00:00","resource":10,"start":"2013-12-19T00:00","title":"01:00 to 08:00","__hashCodeCalc":false}, {"allDay":"false","color":"","end":"2013-12-19T00:00","resource":10,"start":"2013-12-19T00:00","title":"09:00 to 21:00","__hashCodeCalc":false} ''' I tried to change the sequence of my gson data but it doesn't make any difference. This code is properly working in Firefox.
I found that chrome need the start time. When Making the Event, I simply add a second to each Event in the Data and it working fine example. ''' {"allDay":"false","color":"","end":"2013-12-18T00:00:01-05:00","resource":10,"start":"2013-12-18T00:00:01-05:00","title":"01:00 to 08:00","__hashCodeCalc":false}, {"allDay":"false","color":"","end":"2013-12-18T00:00:01-05:00","resource":10,"start":"2013-12-18T00:00:01-05:00","title":"09:00 to 21:00","__hashCodeCalc":false} ''' Just change the Gson data like this it may help u because it work for me .
26,429,446
1
26,823,137
My company want integrate DocuSign to our project. We have a implemented form workflow for EchoSign API and we want to know that DocuSign have embedded Visual Editor <IMAGE> for create on our side. We want to create template in our service without redirect users to DocuSign.
Thanks for response. We found that possible pre-fill tags offline using native tags like DocuSignSignHere, DocuSignInitialHere: <URL> And using <URL> fully resolve our problem.
67,888,000
1
67,888,637
How to update the status as true: <IMAGE> ''' FirebaseFirestore rootRef = FirebaseFirestore.getInstance(); CollectionReference applicationsRef = rootRef.collection("Root"); DocumentReference applicationIdRef = applicationsRef.document("Registration"); applicationIdRef.update("Status",true).addOnCompleteListener(task -> { }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d("TAG", "onFailure: "+e); } }); ''' I was doing by this approach, but I was not getting how to go till status field .
The 'Map' field is (quite deeply) nested. To update nested fields, you use dot notation like this: ''' applicationIdRef.update("Map1.Map2.Map3.Status",true) ''' Also see the Firebase documentation on <URL> But even then, since the value is in an array, there's no way update a single item in an array by its index. So 'Map1.Map2.Map3.0.Status' won't work. You will need to: 1. Read the document from the database in your application code. 2. Update the item in the array in the nested field. 3. Write the entire array back to the database. This <URL> has been covered extensively before, so I recommend checking out some of those answers too.
17,753,910
1
17,754,141
I am trying to use the PHP inbuilt server feature 'php -S localhost:8888' to run a testing server for a project of mine. When I use it, an error appears: <IMAGE> In the event log, the following error appears: ''' Faulting application name: php.exe, version: 5.4.3.0, time stamp: 0x4fb15e42 Faulting module name: php5ts.dll, version: 5.4.3.0, time stamp: 0x4fb15f2c Exception code: 0xc0000005 Fault offset: 0x0000000000119940 Faulting process id: 0x1a40 Faulting application start time: 0x01ce84b22074fc3f Faulting application path: C:\wampin\php\php5.4.3\php.exe Faulting module path: C:\wampin\php\php5.4.3\php5ts.dll Report Id: 5e31c3a5-f0a5-11e2-b720-90e6bab78fd4 ''' I have commented out (';') every PHP extension in php.ini one by one, and none of them made a difference. I even tried commenting every PHP extension out, but still no result. I have re-installed WAMP and updated it to the latest version, but this yields no results. I do not have IIS installed or running, or any other services (aside from WAMP) running on port 80, and no services running on port 80. My PHP version is 5.4.3, Apache is 2.4.2 running on WAMP 2.2e, Windows 7 64-bit.
Solution (credit goes to DaveRandom) was to update PHP to version 5.5.1 following these steps: 1. Download 5.5.1 Windows Binaries. 2. Make new folder in {wamproot}/bin/php/ called "php5.5.1". 3. Replace all occurrences of "5.4.3" in {wamproot}/wampmanager.ini with "5.5.1". 4. Repeat step 3 for wampmanager.conf 5. Update PATH environment variable
7,551,034
1
7,551,143
How to set ASP.NET version to 3.5 in the IIS 6 Default Web site properties (ASP.NET tab)? From what I can see was version 2 (even though I have install version .NET 3.5) <IMAGE>
You cannot specify this in IIS. For websites earlier than Framework 4.0 and greater than 2.0 you need to specify version 2.0 in IIS. However there are configurations in web.config to restrict a website to run or compile under framework version 3.5. Visual Studio by default make these setting in web.config To be sure here are some parts of the web.config <IMAGE> --- <IMAGE>
27,409,167
1
27,409,195
While examining the 'String ==' operator, I noticed that it calls 'String.Equals(string a, string b)', meaning it's just a pass-through. Examining the 'String.Equals(string a, string b)' method, I see that it does an equality check using the '==' operator. How is this actually working and not causing a 'StackOverflowException' when doing something like '"x" == "x"' or '"x" == "y"'? : I let JetBrains know and they made it a critical priority for dotPeek. <URL> I also added an issue on ILSpy's GitHub repo. <IMAGE>
Your decompiler has a bug. <URL>b', bypassing the overloaded operator.
6,893,567
1
6,934,144
My java web start application always displays a warning icon in the top-right corner of the window. This is what I'm talking about: <IMAGE> I'd like to get rid of it. I have tried to sign my application without purchasing any certificate, just using 'jarsigner', but the icon is still there. In the other hand, if I don't sign the application at all, the icon is there as well. To be precise, i must say that my application runs in the basic sandbox. Can I get rid of this ugly icon ? I don't like it because I will target a public & general audience, and some people might misinterpret its meaning. Would purchasing a certificate from an authority help in removing this icon ? And in case it is related to my question, this is my 'jnlp' file: ''' <?xml version="1.0" encoding="UTF-8"?> <jnlp spec="1.0+" codebase="http://localhost:8080/bin/" href="xxx-webstart.jnlp"> <information> <title>xxx.com</title> <vendor>xxx.com</vendor> </information> <resources> <!-- Application Resources --> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> <jar href="xxx.jar" main="true" /> </resources> <application-desc name="xxx.com" main-class="com.xxx.client.swing.main.MainClientSwing" width="400" height="400"> </application-desc> <update check="always" policy="always"/> </jnlp> '''
If the code is signed (with any certificate, self-signed or verified), declares 'j2ee-application-client-permissions' or 'all-permissions' & is accepted by the user, the warning will disappear.
28,900,325
1
33,046,473
The error is: > There was an error running the selected code generator: 'Unable to retrieve metadata for 'WebApplication1.MySQLModels.***********. Sequence contains no matching element' <IMAGE> Where 'WebApplication1' is the name of my test project. 'MySQLModels' is where the 'DbContext' file with all the models generated by EF Code First are and '***********' replace the name of the table. ''' <add name="stringname" connectionString="server=server;user id=userid;password=password;persistsecurityinfo=True;database=database" providerName="MySql.Data.MySqlClient" /> ''' ''' namespace WebApplication1.MySQLModels { using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; [Table("database.SomeTable")] public partial class SomeTable { public int id { get; set; } [StringLength(255)] public string CM { get; set; } [StringLength(255)] public string Job { get; set; } [StringLength(255)] public string ClientJobNo { get; set; } [StringLength(255)] public string JobNo { get; set; } [StringLength(255)] public string Client { get; set; } [Column(TypeName = "date")] public DateTime? Start { get; set; } [Column(TypeName = "date")] public DateTime? Finish { get; set; } [StringLength(255)] public string Frequency { get; set; } [StringLength(255)] public string PONumber { get; set; } [Column(TypeName = "date")] public DateTime? AuditCompleted { get; set; } [Column(TypeName = "date")] public DateTime? Invoiced { get; set; } public decimal? InvoiceAmount { get; set; } [StringLength(255)] public string Query { get; set; } [StringLength(255)] public string Status { get; set; } [StringLength(255)] public string Type { get; set; } [StringLength(255)] public string Area { get; set; } [Column(TypeName = "date")] public DateTime? PlannedAudit { get; set; } [StringLength(255)] public string YellowJacketRequired { get; set; } [StringLength(255)] public string YellowJacketCompleted { get; set; } [StringLength(255)] public string SuperName { get; set; } [StringLength(255)] public string SuperPhone { get; set; } [StringLength(255)] public string ReasonsDateChange { get; set; } [Column(TypeName = "text")] [StringLength(65535)] public string Comments { get; set; } } } ''' ''' CREATE TABLE IF NOT EXISTS 'SomeTable' ( 'id' int(11) NOT NULL, 'CM' varchar(255) DEFAULT NULL, 'Job' varchar(255) DEFAULT NULL, 'ClientJobNo' varchar(255) DEFAULT NULL, 'JobNo' varchar(255) DEFAULT NULL, 'Client' varchar(255) DEFAULT NULL, 'Start' date DEFAULT NULL, 'Finish' date DEFAULT NULL, 'Frequency' varchar(255) DEFAULT NULL, 'PONumber' varchar(255) DEFAULT NULL, 'AuditCompleted' date DEFAULT NULL, 'Invoiced' date DEFAULT NULL, 'InvoiceAmount' decimal(7,2) DEFAULT NULL, 'Query' varchar(255) DEFAULT NULL, 'Status' varchar(255) DEFAULT NULL, 'Type' varchar(255) DEFAULT NULL, 'Area' varchar(255) DEFAULT NULL, 'PlannedAudit' date DEFAULT NULL, 'YellowJacketRequired' varchar(255) DEFAULT NULL, 'YellowJacketCompleted' varchar(255) DEFAULT NULL, 'SuperName' varchar(255) DEFAULT NULL, 'SuperPhone' varchar(255) DEFAULT NULL, 'ReasonsDateChange' varchar(255) DEFAULT NULL, 'Comments' text ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; ALTER TABLE 'SomeTable' ADD PRIMARY KEY ('id'); ''' I don't have much control over table definitions since this is an already existing database that I'm working with. 1. Create a new ASP.NET MVC 5 project (called WebApplication1 in my case) 2. Add MySQL DLLs: MySql.Data, MySql.Data.Entity.EF6, MySQL.Web. 3. Replace the existing EntityFramework tag (in Web.Config) with the following: <entityFramework> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" /> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> </providers> </entityFramework> 4. Rebuild the project. 5. Create a folder to import all the models and create the DbContext, in my case the folder is MySQLModels 6. Add an ADO.NET Entity Data Model to the project. Select the correct database connection. Select the tables and click finish. 7. Rebuild the project. 8. Right-click on Controllers folder, then Add->Controller. In the popup window select MVC 5 Controller with views, using Entity Framework and click Add. 9. Select one of the models, select your Data context class, enter the appropriate controller name and click Add. 10. Following this process you will see the error. There isn't much that I could find out there in relation with this error in general but specifically to do with MySQL. There is an unanswered question, which does not have a lot of details, that can be found here: <URL> 1. I tried the suggestion here: Unable to Retrieve Metadata which suggested that I change providerName in my connection string to System.Data.SqlClient but this results in the same error. 2. I uninstalled and reinstalled everything from MySQL but to no avail. 3. UPDATE: Adding separate ADO.NET Entity Data Models for each table fixes this error. This isn't exactly the solution but absent any other solution that allows me to create scaffolding with one Db Context, this may work. 4. UPDATE 2: Tried the migration tool from Microsoft: http://www.microsoft.com/en-us/download/details.aspx?id=42657. This works, however, a lot of the data is not ported over. Again, this is a last ditch effort. Still not the solution. I'll keep updating this question to add more details as I try various thingamajigs.
This is old, but still if someone is trying to find a fix, here it is. The Annotations which specify the datatype, are the culprits. Try removing the annotations from model. In this case below two [Column(TypeName = "text")], [Column(TypeName = "date")] And build, clean, build the project Now the Add Controller (Scaffolding) works like charm. Later you can re-add the same.
29,257,809
1
29,261,142
How can I build a bar chart with target lines in D3? I tried adding a line with the Target field on top of the bars but what I am trying to achieve is something similar to this: <IMAGE> This is my table: ''' Country,Nitrogen2012,Target Poland,0.22,0.213 Sweden,0.13,0.156 Russia,0.11,0.097 Finland,0.11,0.110 Latvia,0.08,0.076 Atmospheric,0.08,0.075 Germany,0.07,0.075 Denmark,0.07,0.088 Lithuania,0.06,0.050 Estonia,0.03,0.033 Shipping,0.02,0.003 ''' The code for the bar chart is this: ''' var margin = { top: 20, right: 20, bottom: 30, left: 80 }, width = 900 - margin.left - margin.right, height = 200 - margin.top - margin.bottom; var formatPercent = d3.format(".0%"); var x = d3.scale.ordinal() .rangeRoundBands([0, width], .1); var y = d3.scale.linear() .range([height, 0]); var xAxis = d3.svg.axis() .scale(x) .orient("bottom") .tickSize(-1); var yAxis = d3.svg.axis() .scale(y) .orient("left") .ticks(2, "d") .tickSize(-1) .tickFormat(formatPercent); var tip = d3.tip() .attr('class', 'd3-tip') .offset([-10, 0]) .html(function(d) { return "<strong>Average normalized input:</strong> <span style='color:red'>" + d.Nitrogen2012 * 100 + "</span>"; }) var chart1 = d3.select("#graph1").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); chart1.call(tip); d3.csv("Nitrogen_Inputs2012ComparedToTarget.csv", type, function(error, data) { x.domain(data.map(function(d) { return d.Country; })); //x2.domain(data.map(function(d){return d.Target})); y.domain([0, d3.max(data, function(d) { return d.Nitrogen2012 })]); chart1.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); chart1.append("g") .attr("class", "y axis") .call(yAxis); chart1.selectAll(".bar") .data(data) .enter().append("rect") .attr("class", "bar") .attr("x", function(d) { return x(d.Country); }) .attr("width", x.rangeBand()) .attr("y", function(d) { return y(d.Nitrogen2012); }) .attr("height", function(d) { return height - y(d.Nitrogen2012); }) .on('mouseover', tip.show) .on('mouseout', tip.hide); }); function type(d) { d.Nitrogen2012 = +d.Nitrogen2012; return d; } ''' Any ideas? Thanks!
On your enter selection, add the line. You could do this with 'svg:line', but I prefer building a 'path': ''' var eSel = chart1.selectAll(".bar") .data(data) .enter(); eSel.append("rect") .attr("class", "bar") ... eSel.append("path") .style("stroke", "blue") .style("stroke-width", 2) .attr("d", function(d){ var rv = "M" + x(d.Country) + "," + y(d.Target); // move to rv += "L" + (x(d.Country) + x.rangeBand()) + "," + y(d.Target); // line return rv; }); ''' Working example <URL>.
25,396,425
1
25,398,271
I have 2 tables with no relation between them. I want to display the data in tabular format by month. Here is a sample output: <IMAGE> There are 2 different tables - - Problem is that we have no direct relation between these. The only commonality between them is month (date). Does anyone have a suggestion on how to generate such a report? here is my union queries: ''' SELECT TO_DATE(TO_CHAR(PAY_DATE,'MON-YYYY'), 'MON-YYYY') , 'FEE RECEIPT', NVL(SUM(SFP.AMOUNT_PAID),0) AMT_RECIEVED FROM STU_FEE_PAYMENT SFP, STU_CLASS SC, CLASS C WHERE SC.CLASS_ID = C.CLASS_ID AND SFP.STUDENT_NO = SC.STUDENT_NO AND PAY_DATE BETWEEN '01-JAN-2014' AND '31-DEC-2014' AND SFP.AMOUNT_PAID >0 GROUP BY TO_CHAR(PAY_DATE,'MON-YYYY') UNION SELECT TO_DATE(TO_CHAR(EXP_DATE,'MON-YYYY'), 'MON-YYYY') , ET.DESCRIPTION, SUM(EXP_AMOUNT) FROM EXP_DETAIL ED, EXP_TYPE ET, EXP_TYPE_DETAIL ETD WHERE ET.EXP_ID = ETD.EXP_ID AND ED.EXP_ID = ET.EXP_ID AND ED.EXP_DETAIL_ID = ETD.EXP_DETAIL_ID AND EXP_DATE BETWEEN '01-JAN-2014' AND '31-DEC-2014' GROUP BY TO_CHAR(EXP_DATE,'MON-YYYY'), ET.DESCRIPTION ORDER BY 1 ''' Regards:
In order to do this you probably want to make the Income and Expenses into separate sub-queries. I have taken the two parts of your union query and separated them into sub-queries, one called income and one called expense. Both sub-queries summarise the data over the month period as before, but now you can use a JOIN on the Months to allow the data from each sub-query to be connected. Note: I have used an OUTER JOIN, because this will still join month where there is no income, but there is expense and vice versa. This will require some manipulation, because you probably are better off returning a set of zeros for the month if no transaction occur. In the top level SELECT, replace the use of *, with the correct listing of fields required. I simply used this to show that each field can be reused from the sub-query in the outer query, by referring to the alias as the table name. ''' SELECT Income.*, Expenses.* FROM (SELECT TO_DATE(TO_CHAR(PAY_DATE,'MON-YYYY'), 'MON-YYYY') as Month, 'FEE RECEIPT', NVL(SUM(SFP.AMOUNT_PAID),0) AMT_RECIEVED FROM STU_FEE_PAYMENT SFP, STU_CLASS SC, CLASS C WHERE SC.CLASS_ID = C.CLASS_ID AND SFP.STUDENT_NO = SC.STUDENT_NO AND PAY_DATE BETWEEN '01-JAN-2014' AND '31-DEC-2014' AND SFP.AMOUNT_PAID >0 GROUP BY TO_CHAR(PAY_DATE,'MON-YYYY') Income OUTER JOIN (SELECT TO_DATE(TO_CHAR(EXP_DATE,'MON-YYYY'), 'MON-YYYY') as Month, ET.DESCRIPTION, SUM(EXP_AMOUNT) FROM EXP_DETAIL ED, EXP_TYPE ET, EXP_TYPE_DETAIL ETD WHERE ET.EXP_ID = ETD.EXP_ID AND ED.EXP_ID = ET.EXP_ID AND ED.EXP_DETAIL_ID = ETD.EXP_DETAIL_ID AND EXP_DATE BETWEEN '01-JAN-2014' AND '31-DEC-2014' GROUP BY TO_CHAR(EXP_DATE,'MON-YYYY'), ET.DESCRIPTION) Expenses ON Income.Month = Expenses.Month ''' There are still many calculations that you will have to insert, to get your final result, which you will have to work on separately. The resulting query to perform what you expect above will likely be a lot longer than this, I am just trying to show you the structure. However the final tricky part for you is going to be the BBF. Balance Bought Forward. SQL is great a joining tables and columns, but each row is treated and handled separately, it does not read and value from the previous row within a query and allow you to manipulate that value in the next row. To do this you need another sub-query to SUM() all the changes from a point in time up until the start of the month. Financial products normally store Balance at points in time, because it is possible that not all transaction are accurately recorded and there needs to be a mechanism to adjust the Balance. Using this theory, you you need to write your sub-query to summarise all changes since the previous Balance. IMO Financial applications are inherently complex, so the solution is going to take some time to mould into the right one. Final Word: I am not familiar with OracleReports, but there may be something in there which will assist with maintaining the BBF.
13,252,577
1
13,252,690
I'm trying out Tuckey's URLRewriter. I declared one simple rule, as follows: ''' <rule> <from>/user/([0-9]+)$</from> <to>/user.do?id=$1</to> </rule> ''' I would expect requests like 'myapp.com/user/29' to be mapped to 'myapp.com/user.do?id=29'. This works fine and the request arrives on the backed. When viewing the response on GUI however, this is how Firebug complains: <IMAGE> As you can see, between '/roqket' and '/resources' there is now a . I have no idea how that ended up there. If I remove the '<rule>' it goes back to the normal, working resource requests. Can you help me? What am I missing? Thanks!
You need to define other filters for js, style and img. Something like this: ''' <rule> <from>/img/**</from> <to>/img/$1</to> </rule> <rule> <from>/js/**</from> <to>/js/$1</to> </rule> <rule> <from>/style/**</from> <to>/style/$1</to> </rule> ''' These filters should be declare before the one you define for the user. These rules will match before the one that apply to the filter and your problem should be solved. . Regarding your comment: . I think that is not correct, I mean, the filter is not the one that is adding "user" to the filter. I think the problem is how you are importing your resources. Probably, you are doing something like this: ''' <script type="text/javascript" language="javascript" src="resources/js/lang.js"></script> ''' In this example, see how the relative URI doesn't not content your application context and starts with no slash. When you use a URL like that the browser is going to look for the resource in a path relative to actual path. If you have in your browser 'http://localhost:8080/roqlet/user' the result will be 'http://localhost:8080/roqket/user/theResource' (assuming 'roqket' is your app context). So, you should do this: ''' <c:set var="ctx" value="${pageContext.request.contextPath}"/> <script type="text/javascript" language="javascript" src="${ctx}/resources/js/lang.js"></script> ''' Now, that you indicate the context, the URI will be built relative to it and not to the actual: 'http://localhost:8080/roqket/theResource' Take a look to this <URL>.
20,387,803
1
20,387,923
Right now I've got a GA Gradient layer where I've set the colors but I'd like to set the color point to (instead of top center, to top left) and the bottom to (instead of bottom center to bottom right) just to change things up a bit. Thoughts? Below is the code that I've got so far...I included core animation because I'm animation between colors. ''' - (id)init { self = [super init]; UIView *gradientView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.w, self.h)]; [self addSubview:gradientView]; [self sendSubviewToBack:gradientView]; topColor = [UIColor colorWithRed:0.012 green:0.012 blue:0.012 alpha:1]; bottomColor = [UIColor colorWithRed:1.000 green:0.765 blue:0.235 alpha:1]; gradient = [CAGradientLayer layer]; gradient.frame = gradientView.frame; gradient.colors = [NSArray arrayWithObjects:(id)topColor.CGColor, (id)bottomColor.CGColor, nil]; gradient.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f], [NSNumber numberWithFloat:0.7], nil]; [gradientView.layer addSublayer:gradient]; [self performSelector:@selector(animateColors) withObject:self afterDelay:2.0]; currentColorCount = 1; return self; } ''' On the right (What I've got) on the left (what I'd like) <IMAGE>
The 'startPoint' and 'endPoint' properties of a 'CAGradientLayer' are defined in the "unit coordinate system". In the unit coordinate system: - '(0,0)'- '(1,1)' Thus arranging your gradient the way you want should be this simple: ''' gradient.startPoint = CGPoint.zero gradient.endPoint = CGPoint(x: 1, y: 1) '''
67,386,596
1
67,412,909
I am currently trying to store (2) values into 2 1D tuples for OpenCV usage thereafter. However, as I am extremely new to Python, I am currently facing a rather "simple" problem regarding the tuple identifier. When I ran the following codes: ''' import cv2 import numpy as np import imutils cap= cv2.VideoCapture(0) cap.set(3,640) cap.set(4,480) point1 = [] point2 = [] while True: _,frame= cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) lower_red = np.array([0,50,120]) upper_red = np.array([10,255,255]) lower_yellow = np.array([25,70,120]) upper_yellow = np.array([30,255,255]) lower_blue = np.array([90,60,0]) upper_blue = np.array([121,255,255]) maskred = cv2.inRange(hsv,lower_red,upper_red) maskyellow = cv2.inRange(hsv,lower_yellow,upper_yellow) maskblue = cv2.inRange(hsv,lower_blue,upper_blue) cntsred = cv2.findContours(maskred, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) cntsred = imutils.grab_contours(cntsred) cntsyellow = cv2.findContours(maskyellow, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) cntsyellow = imutils.grab_contours(cntsyellow) cntsblue = cv2.findContours(maskblue, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) cntsblue = imutils.grab_contours(cntsblue) for c in cntsred: areared = cv2.contourArea(c) if areared > 5000: cv2.drawContours(frame,[c],-1,(0,255,0), 3) M = cv2.moments(c) cxred = int(M["m10"]/ M["m00"]) cyred = int(M["m01"]/ M["m00"]) cv2.circle(frame,(cxred,cyred),7,(255,255,255),-1) cv2.putText(frame, "Red", (cxred-20, cyred-20), cv2.FONT_HERSHEY_SIMPLEX, 2.5, (255, 255, 255), 3) redcoord = (cxred, cyred) for c in cntsyellow: areayellow = cv2.contourArea(c) if areayellow > 5000: cv2.drawContours(frame,[c],-1,(0,255,0), 3) M = cv2.moments(c) cxyellow = int(M["m10"]/ M["m00"]) cyyellow = int(M["m01"]/ M["m00"]) cv2.circle(frame,(cxyellow,cyyellow),7,(255,255,255),-1) cv2.putText(frame, "Yellow", (cxyellow-20, cyyellow-20), cv2.FONT_HERSHEY_SIMPLEX, 2.5, (255, 255, 255), 3) yellowcoord = (cxyellow, cyyellow) cv2.line(frame, redcoord, yellowcoord, (0, 255, 0), 3) ''' There was the following syntax error as shown in the image. <IMAGE> May I check whether it is due to some indent or declaration issue that caused the "yellowcoord" tuple to be unidentified?
'yellowcoord' is defined inside an if-block in a for loop. If the contents of the if-block are never run (i.e. if 'areayellow' is never greater than 5000), then 'yellowcoord' will not be defined. You can check for this contingency by initialising 'yellowcoord' to None before the loop, and then testing after the loop if it has been given another value: ''' yellowcoord = None for c in cntsyellow: areayellow = cv2.contourArea(c) if areayellow > 5000: ... yellowcoord = (cxyellow, cyyellow) if yellowcoord is not None: # Now I know I can use yellowcoord safely '''
23,073,539
1
23,096,343
I'm developing an app using a 'UITextView' to accept user input. For some reason, the auto-correct pop-up is not positioned properly over the word that is being corrected; it's off-screen. This is a screen shot from Spark Inspector, showing the pop-up just off screen: <IMAGE> The pop-up appears within a few pixels of the right edge of the screen (x-coordinate of 320ish), no matter where in the UITextView the word appears. The y-coordinate is usually correct (i.e., the pop-up is aligned vertically, but not horizontally). I've verified that none of my views have any transforms applied, and the app only supports portrait mode. Help!
The problem was caused by a category method elsewhere in the project: ''' @implementation UIView (VFrameManipulation) - (void)setSize:(CGSize)newSize { self.frame = CGRectMake(self.frame.origin.y, self.frame.origin.y, newSize.width, newSize.height); } @end ''' (notice the bug?) Apparently UIView has a private method called '-setSize', and this category was replacing it with a buggy version.
62,799,187
1
62,806,171
I am trying to edit a single row but edit all rows, also still trying to add a drop down that will populate some rows, any advice or info will be appreciated. Here is the code I am using, ''' <TableBody> {item.userBankAccount.map((item, index) => { return ( <TableRow hover key={index}> {!currentlyEditing ? ( <TextField label="bankName" name="bankName" onChange={(e) => this.onChangeUserBankAccount(e, index)} type="text" value={item.bankName || ''} /> ) : ( <TableCell>{item.bankName}</TableCell> )} {!currentlyEditing ? ( <TextField label="BankAddress" name="bankAddress" onChange={(e) => this.onChangeUserBankAccount(e, index)} type="text" value={item.bankAddress || ''} /> ) : ( <TableCell>{item.bankAddress}</TableCell> )} {!currentlyEditing ? ( <TextField label="bankSwift" name="bankSwift" onChange={(e) => this.onChangeUserBankAccount(e, index)} type="text" value={item.bankSwift || ''} /> ) : ( <TableCell>{item.bankSwift}</TableCell> )} </TableRow> ); })} </TableBody> ''' <IMAGE>
the problem is here, In each line of 'TableRow' you have ''' {!currentlyEditing ? ( ''' this is same for all 'TableRow'. so, if one gets 'currentlyEditing = true' then all of them becomes editable. ### Solution: Just take the 'state' of 'currentlyEditing' in the 'TableRow' So, Each an every of 'TableRow' gets their own 'currentlyEditing' state, AND, thus others in the mean time will not be editable
17,412,044
1
17,412,345
I want to do something very similar to email address textfield in iOS. Just like email address gets highlighted in a different colour and has a clear button next to it. On clicking the clear button that entire email address should get deleted.Attaching a picture of that. Can you please give me some pointers? I know how to use NSAttributedString to highlight the text but no idea how to add the clear button next to it. Thank you! <IMAGE>
To do this I would subclass a UIView object say for example call it emailAddressView with an associated nib file where you add a UILabel for the name and a UIButton for the 'x' button. You could then add this view as a subview to your UITextfield as the user enters in valid entries.
5,738,621
1
5,738,948
I'm experiencing a weird glitch in the <URL>. I'm trying to get the featured image to be pulled into a fancybox. The featured image exists as a hidden div that get's display:visible and fancyboxed. It works except the wrapping div doesn't match the image's dimensions. I've even followed the instructions to override by calling out an inline width and height for the container div that's hidden. Here's the screenshot of what's happening: <IMAGE> Here's the code from my page-casa.phtml template: ''' <aside class="galeria-preview" role="complementary"> <h2><a class="fancybox" href="#galeria-img">Pr&oacute;ximo Exposici&oacute;n: <br/> <span class="verde"><?php echo get_post_meta($post->ID, 'galeria-proximo',true); ?></span></a></h2> <div style="width:940px;height:400px;" id="galeria-img" class="hidden"> <?php the_post_thumbnail( 'full' ); ?> </div> </aside> ''' Thanks for any help peeps!
I suggest you to go directly without using a plugin for this. I had a resizing problem like yours. I coded and searched a lot for it and finally moved to this <URL> that has autoresing and my problem solved...
26,962,407
1
26,964,255
Below I have the controller action that will get both the proper campaign, as well as that campaigns associated relationships with its locations in the campaign_locations table as: ''' def edit @campaign = Campaign.find(params[:id]) @campaign_locations = CampaignLocation.where(campaign_id: :id).pluck(:location_id) end ''' and campaign_location table has the layout as: <IMAGE> What I need to do is pass the resulting data from the object '@campaign_location' into the jQuery/coffeecscript file 'campaigns.js.coffee' to prerocessp prior to the campaigns/edit/:id page load, but have seen nowhere on how to enable such actions with a jQuery object.
You can use the <URL> on how to use this gem. Hope this helps.
28,002,690
1
28,002,747
<IMAGE> Is there a shortcut or option in eclipse that will perform the opposite of tab. I can select a bunch of lines and if i do control tab, all of those lines will be tabbed over. Is there a control option that I can do to do the opposite of that? Is there a shortcut to get all of your code to line up? I looked on <URL> but didn't find anything. It's a hassle to go to each line and hit back a bunch of times....
Use + to move selected lines to the left. You could also use ++ to format the whole file.
53,398,334
1
53,402,122
I need to create a list of expression differentials (1st, 2nd order, and so on) and print results to the Grid. I'm trying to use next code (and a lot of other variants, but all were wrong). I think the problem is only in the line: 'ToString[D[z[x, y], {x, i - j}, {y, j}]]' ''' MyFunction2[z_] := Block[ {x, y}, arr = {{1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}}; result = {}; For[i = 1, i <= 4, i++, res = ""; For[j = 0, j <= i , j++, res = StringJoin[ res, If[res == "", "", " + "], If[arr[[i]][[j + 1]] > 1, StringJoin[ToString[arr[[i]][[j + 1]]], "*"], ""], ToString[D[z[x, y], {x, i - j}, {y, j}]], If[i - j > 0, "dx", ""], If[i - j > 1, StringJoin["^", ToString[ i - j]], ""], If[j > 0, "dy", ""], If[j > 1, StringJoin["^", ToString[j]], ""] ]; ]; AppendTo[result, { StringJoin["d", If[i > 1, StringJoin["^", ToString[i]], ""], "z" ], res }]; ]; Grid[result, Frame -> All] ]; MyFunction2[Sin[x*y]] ''' I am expecting to have something like this as the result: '| dz | *yCos(xy)dx + xCos(xy)dy* |' But the result I have is: <IMAGE> Can you advise me please how to print results in a human-readable format?
May not be exactly what you are looking for, but should be easy to modify. ''' derivativeGrid[f_Function, xmax_Integer, ymax_Integer] := Module[{derivatives, rowHeader, columnHeader, grid}, derivatives = Table[D[f[x, y], {x, i}, {y, j}], {i, 0, xmax}, {j, 0, ymax}]; columnHeader = Table["dx"^x, {x, 0, xmax}]; rowHeader = Join[{""}, Table["dy"^y, {y, 0, ymax}]]; grid = MapThread[Prepend, {Prepend[derivatives, columnHeader], rowHeader}]; Grid[grid, ItemStyle -> {{1 -> Bold}, {1 -> Bold}}, Background -> {{LightYellow, None}, {LightYellow, None}}, Frame -> All]] ''' Since it computes derivatives of a function of two arguments 'f[x, y]', it needs to be passed a function of two arguments. ''' derivativeGrid[Sin[#1*#2] &, 3, 3] ''' <URL>
53,741,519
1
53,985,437
I created a report with dynamic columns using dynamic reports. If any column in the last row is overflows then the only the overflowing column is stretched and printed on next page. Rest of the columns is not stretched. The printed report is look like this: <IMAGE> Following section of code is used for creating report with dynamic columns. ''' JasperReportBuilder jasperReportBuilder=DynamicReports.report(); for(Field field:fields){ for (Entry<String, String> entry : dynamicTableColumns.entrySet()) { if ( entry.getKey().equals(field.getName())){ jasperReportBuilder.columns(DynamicReports.col.column(entry.getValue(), field.getName().toString(), DynamicReports.type.stringType()).setStretchWithOverflow(true)); } } } ''' I haven't seen any option to set the column's stretch type as RELATIVE_TO_TALLEST_OBJECT. Is there any other way to fix this ?
Setting detail's split type as 'PREVENT' will prevent the row from stretching to next page and move the entire row to next page. ''' jasperReportBuilder.setDetailSplitType(SplitType.PREVENT); '''
4,134,091
1
4,134,119
the below shows the css i am using, yes it not profesional i am a beginner regarding css. i want to write some property in the css such that, the div's only take up the width needed and not more. that is the width property set as width: 60%; etc takes 20% even if the control within it, or text within it is not that long. like say "hi" within the div takes 60% still!!! ## css ''' #form1 { padding: 0px 0px 0px 0px; margin: 0px; display:inline-block; width:100%; font-family: Times New Roman; font-size: 2em; } #container { margin: 0 auto; width: 100%; /*background-color: Yellow;*/ /* for testing*/ } #header { background: #ccc; padding: 20px; /*remove as needed*/ color: Blue; text-align:center; } #navigation { float: left; width: 100%; background: White;/* black*/ color:White; font-size: smaller; } #ul { margin: 0; padding: 0; } #link { list-style-type: none; display: inline; } /* for url one */ #url1 { float: left; padding: 0px 5px 0px 5px; border-right: 1px solid #fff; background-color: White; } #url1 a { float: left; color: Black; text-decoration: none; } #url1 a:hover { background-color:ButtonShadow; color:Highlight; text-transform:uppercase; font-size:xx-large; } /*for url one ends*/ #content-container1 { padding-top:5px; float: left; width: 100%; /*background: #fff url(/wp-content/uploads/layout-three-liquid-background1.gif) repeat-y 20% 0;*/ } #content-container2 { float: left; width: 100%; /*background: url(/wp-content/uploads/layout-three-liquid-background2.gif) repeat-y 80% 0;*/ } #section-navigation { float: left; width: 16%; border-right-color:White; border-right-style:solid; border-right-width:thin; /*background: gray;*/ /* for testing */ display: inline; } #leftul { margin: 0; padding: 0; } #leftlink { padding-left:0.2em; list-style-type: none; /*background-color: Yellow;*/ /*for testing */ } #leftlink a { color: Aqua; text-decoration: underline; } #content { border-left-color: White; border-left-style:solid; border-left-width:thin; float: left; width: 56%; } #aside { float: right; width: 16%; padding: 20px 0; margin: 0 2% 0 0; display: inline; } #aside h3 { margin: 0; } #footer { clear: both; background: #ccc; text-align: right; padding: 20px; height: 1%; } .symbols { font-family: Webdings; } ''' ## and the pic <IMAGE> ## html as appears by ie6 ''' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> </title><link rel="stylesheet" type="text/css" href="LAYOUT1.css" /></head> <body> <form name="form1" method="post" action="DynamicLayout.aspx" id="form1"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZOy4VHs0ZOF6zRS6A7E09eCqf5GY" /> </div> <div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKFjacpAqDAiY0LQudCxpijJWZK6qWohE+SufqyOGA=" /> </div> <div> </div> <div id="container" runat="server"> <div id="header" runat="server"> <span>The header from code label</span><input name="ctl03" type="text" value="This is the text box" /> </div><div id="navigation" runat="server"> <div id="ul" runat="server"> <div id="link" runat="server"> <div id="url1" runat="server"> <a class="symbols" href="#">H</a> </div><div id="url2" runat="server"> <a href="#">About</a> </div> </div> </div> </div><div id="content-container1" runat="server"> <div id="content-container2" runat="server"> <div id="section-navigation" runat="server"> <div id="leftul" runat="server"> <div id="leftlink" runat="server"> LEFT SIDE </div> </div> </div><div id="content" runat="server"> This is the center of the page </div> </div> </div> </div></form> </body> </html> '''
try this style ''' .asNarrowAsPossible { width:1%; /* encourages the container to be very narrow */ white-space: nowrap; /* forces the content to one line*/ } '''
2,130,058
1
2,130,296
I'm trying to learn how to line up fields of a form using CSS instead of tables. I'm having a hard time with a CheckBox control. Here's the code: ''' <html xmlns="http://www.w3.org/1999/xhtml" > ''' ''' <label for="CheckBox1">CheckBox</label> <asp:CheckBox ID="CheckBox1" runat="server" /> <br /> <label for="TextBox1">TextBox</label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <div> </div> </form> ''' Here's the CSS: ''' body { } label { width:300px; float:left; } ''' I'm getting something that looks like this: CheckBox [] [CheckBox1] TextBox [ ] Why is [CheckBox1] on the next line? Here's a pic: <IMAGE> Also, is there a better way to do this?
It's been a while since I worked on ASP.Net but if I remember correctly, the checkbox control has a property that lets you specify where the text appears (below it or to the side). That may solve your problem.
26,506,539
1
26,506,895
I have a bash variable: 'agent1.ip' with '192.168.100.137' as its value. When I refer to it in 'echo' like this: ''' echo $agent1.ip ''' the result is: ''' .ip ''' How can I access the value? my variables are: <IMAGE>
Bash itself doesn't understand variable names with dots in them, but that doesn't mean you can't have such a variable in your environment. Here's an example of how to set it and get it all in one: ''' env 'agent1.ip=192.168.100.137' bash -c 'env | grep ^agent1\.ip= | cut -d= -f2-' '''
30,381,986
1
30,382,116
Safari Browser leaves query string (?) in the link when using this approach. Is there anyway to force the browser to also remove the query string? It's not an issue with Firefox or Chrome. I just checked IE and it's the same as issue as with Safari. ''' $("a")[0].search = ""; ''' ''' <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <a href="http://example.com/?title=dog">The Link</a> ''' Demo: <URL><IMAGE>
You could split on the question mark and take the first half: ''' $("a")[0].href = $("a")[0].href.split('?').shift() ''' <URL>
35,429,619
1
35,434,464
How to install Elixir SDK on IDEA 15.0.3 in Windows 10 ? [<IMAGE> "That selected directory is not valid home for Elixir SDK"
I got a "Corrupted SDK" error when selecting the 'Elixir' directory instead of the 'Elixir/bin'. Since it worked for my Elixir 1.1.1 install before I updated, there is likely a different different format to the 'elixir --version' for 1.2 than 1.1.1. This was the case for Elixir on OSX (using homebrew) and Linux. I'm guessing the output is another format for Windows 1.2. Please open a bug <URL> and I'll figure out why Windows' format isn't matching.
30,243,671
1
30,243,783
I'm creating a horizontal navigation bar and would like to stylize it so that a thin line will appear right above the bar (please see example). <URL> As you can see there is a thin, gold line just above the red navigation bar. I would like to get a thin, black line just above my orange navigation bar. <IMAGE> My code looks like this: (CSS) ''' nav {width:100%;display:block;} nav ul {list-style-type:none;margin:0;padding:0;text-align:center;background-color:#c0872e} nav li {display:inline-block;background-color:#c0872e;} nav a {line-height:35px; color:white; padding:0 30px; font-size:22px; font-family:WindsorDemi.fog Cn; background-color:#c0872e;} nav a:hover {text-decoration:none} ''' (HTML) ''' <div> <ul> <li><a href="index.html">Home</a></li> <li><a href="products.html">Products</a></li> </ul> </div> ''' Please let me know how I can achieve this desired effect. Thank you!
You could accomplish this using a border: ''' nav ul { border-top: 2px solid #000; /* Added */ list-style-type:none; margin:0; padding:0; text-align:center; background-color:#c0872e } ''' Here's a <URL> to show you how it looks. Hope this helps! Let me know if you have any questions.
12,819,188
1
19,242,236
The OpenGL ES Programming guide discusses that you should avoid misaligned vertex data and gives an example of aligning the data to 4 byte blocks. <URL> <IMAGE> However in most demo material and tutorials I've found online I don't see anyone doing this. Example below is from a demo project on 71 Squared: ''' static const SSTexturedVertexData3D EnemyFighterVertexData[] = { {/*v:*/{1.987003, -0.692074, -1.720503}, /*n:*/{0.946379, -0.165685, -0.277261}, /*t:*/{0.972816, 0.024320}}, ''' And how would you do it anyway? Add a dummy 0.0 to the v and n and 2 of them to the t? My guess is that if you're only loading the vertex data once per app it wouldn't matter much but if your binding and rebinding to different arrays on each rendered frame it would matter. My plan is to combine all my arrays into one anyway, but I'm curious.
General a vertex is made up of 'floats' which are going to be aligned, so you don't need to get too concerned with that. In fact a lot of books use ordinary 'struct's to hold vertex data, which are not guaranteed to be contiguous due to the padding issue, but if all you have are floats, that's fine since you aren't likely to have padding. Of course, some people (myself included) prefer to use the STL 'vector' from C++ but if you are on iOS, while you can use C++ you are probably using Objective-C thus contiguity in a non-struct way would involve normal C arrays which are not so fun to work with. If you create custom structures to hold vertex data as well as other data for your drawable object, and you use 'short's or other types, you might find padding to become an issue. But if you stick with only 'float's you will be fine, and you will be in good company since most educational sources on OpenGL do this.
28,719,898
1
28,720,204
I want to draw graphics (shapes) onto the panel to the top left. The shape will be drawn depending on the shape chosen and the value given by the track bar. The track bar values aren't specific i.e aren't pixels or millimeters, so basically when the track bar increases in number the shape should get larger. <IMAGE> This is the my main code. Other classes such as Circle, Square and Triangle also exist. ''' public partial class drawShape : Form { Graphics drawArea; public decimal area; double myBoundary = 0; double myArea = 0; public double length = 100; public drawShape() { InitializeComponent(); drawArea = pnlDrawArea.CreateGraphics(); } public void updateShape() { if(rbCircle.Checked) { drawCircle(); } if(rbSquare.Checked) { drawSquare(); } if(rbTriangle.Checked) { drawTriangle(); } if(rb2DecimalPlaces.Checked) { lblBoundaryLength.Text = myBoundary.ToString("#,0.00"); lblAreaResult.Text = myArea.ToString("#,0.00"); } if(rb3DecimalPlaces.Checked) { lblBoundaryLength.Text = myBoundary.ToString("#,0.000"); lblAreaResult.Text = myArea.ToString("#,0.000"); } if(rb4DecimalPlaces.Checked) { lblBoundaryLength.Text = myBoundary.ToString("#,0.0000"); lblAreaResult.Text = myArea.ToString("#,0.0000"); } } public void drawCircle() { Circle myCircle = new Circle(length); myArea = myCircle.GetArea(length); myBoundary = myCircle.GetCircumference(); lblAreaResult.Text = myArea.ToString(); lblBoundaryLength.Text = myBoundary.ToString(); } public void drawSquare() { Square mySquare = new Square(length); myArea = mySquare.GetArea(); myBoundary = mySquare.GetBoundLength(length); lblAreaResult.Text = myArea.ToString(); lblBoundaryLength.Text = myBoundary.ToString(); } public void drawTriangle() { Triangle myTriangle = new Triangle(length); myArea = myTriangle.GetArea(); myBoundary = myTriangle.GetBoundLength(); lblAreaResult.Text = myArea.ToString(); lblBoundaryLength.Text = myBoundary.ToString(); } '''
You should use the 'Panel''s 'Paint' event like this: ''' private void pnlDrawArea_Paint(object sender, PaintEventArgs e) { int offset = 20; Rectangle bounding = new Rectangle(offset, offset, (int)myBoundary.Value, (int)myBoundary.Value); if (rbSquare.Checked) { e.Graphics.DrawRectangle(Pens.Red, bounding); } else if (rbCircle.Checked) { e.Graphics.DrawEllipse(Pens.Red, bounding); } // else if... } ''' and in your 'updateShape' simply call the 'Paint' event by coding: 'pnlDrawArea.Invalidate();' For the triangle you will - 'DrawLines'- 'Points'- Don't forget to hook up the 'Paint' event!!
29,110,288
1
29,110,756
How can <URL>? I mean the chart similar to what Audacity generates: <IMAGE> I know that I can get the FFT data for given time 't' (when I play the audio) with: ''' float fft[1024]; BASS_ChannelGetData(chan, fft, BASS_DATA_FFT2048); // get the FFT data ''' That way I get 1024 values in array for each time 't'. Am I right that the values in that array are signal amplitudes ('dB')? If so, how the frequency ('Hz') is associated with those values? By the index? I am an programmer, but I am not experienced with audio processing at all. So I don't know what to do, with the data I have, to plot the needed spectrum. I am working with C++ version, but examples in other languages are just fine (I can convert them).
From the documentation, that flag will cause the FFT magnitude to be computed, and from the sounds of it, it is the linear magnitude. ''' dB = 10 * log10(intensity); dB = 20 * log10(pressure); ''' (I'm not sure whether audio file samples are a measurement of intensity or pressure. What's a microphone output linearly related to?) Also, it indicates the length of the input and the length of the FFT match, but half the FFT (corresponding to negative frequencies) is discarded. Therefore the highest FFT frequency will be one-half the sampling frequency. This occurs at N/2. The docs actually say > For example, with a 2048 sample FFT, there will be 1024 floating-point values returned. If the BASS_DATA_FIXED flag is used, then the FFT values will be in 8.24 fixed-point form rather than floating-point. Each value, or "bin", ranges from 0 to 1 (can actually go higher if the sample data is floating-point and not clipped). That seems pretty clear.
13,522,327
1
13,527,092
It appears this happens with any blendmode - not just erase I've been working on a crude lighting engine for a game of mine in Adobe AIR, written in pure AS3. How it works is there is a bitmap data the size of the screen, and at the beginning of each frame it is set to a black transparent rectangle. During that step, things can subtract from the bitmap data and then when it is drawn on the screen those areas will appear lighter. Setting that up and everything has gone smoothly. Currently I'm messing around with a basic radial gradient from the light source, and setting that up was pretty easy ''' _circ.graphics.lineStyle(); _circ.graphics.beginGradientFill(GradientType.RADIAL, [0x000000, 0x000000], [.9, 0], [0, 255]); _circ.graphics.drawCircle(0, 0, 100); _circ.graphics.endFill() ''' Then to draw (well, anti-draw) it onto the bitmap data, I just do this ''' FP.matrix.identity(); FP.matrix.tx = x + 30; FP.matrix.ty = y + 5; WorldGame.darkBit.draw(_circ, FP.matrix, null, BlendMode.ERASE, null, true); FP.matrix.identity(); ''' 'FP.matrix' is just a generic global matrix (I'm using Flashpunk). Now this ALMOST works, except for one tiny problem. <IMAGE> If you look very closely you'll be able to see a very thin black line going around the gradient, which is so very frustrating. I have no idea what's causing it - I've tried making the gradient smaller than the circle, I've tried making it linear, tried making it a different colour. It doesn't happen on blend modes other than 'ERASE' as well, and as far as I can tell, it doesn't happen to non-gradients either (still erasing). Any suggestions?
<URL> Somehow I missed this in my earlier searching, guess I didn't use the right keywords. The solution is just to set bitmap caching to true on the sprite that is being used as the "eraser". For example: ''' _circ.cacheAsBitmap = true; ''' And that's all there is to it!
20,906,641
1
21,142,457
I am trying to query a graph to return all of the paths with a specified relationship. I am building a family tree and I have the following nodes: 1. Person 2. Edge The relationships which connect two people are: 1. PARENT 2. CHILD 3. COUPLE So an example of some data are: 1. a:Person<-[:CHILD]-(Edge)-[:PARENT]->b:Person 2. a:Person<-[:COUPLE]-(r2:Edge)-[:COUPLE]->c:Person<-[:PARENT]-(r3:Edge)-[:CHILD]->d:Person In my query I would like to be able to draw the graph in my front end so I need to get every Person and Edge Node, and every relationship between them, that is connected to my starting person. I tried originally to use allShortestPaths to reduce the duplication of nodes but this misses a lot of relationships (e.g. if parents have multiple children then only either the mother or father relationship to a child will be returned and not both). My current cypher is as follows (I distinguish between Edge and Person nodes by filtering on the type property which only exists on Relationships): ''' START person = node({personId}) MATCH person-[:PARENT | CHILD | COUPLE*]-(relatedPeople:Person) WITH relatedPeople, person MATCH p = allShortestPaths(person-[:PARENT|CHILD|COUPLE]-(relatedPeople)) WITH [n in nodes(p) WHERE not(has(n.type))] AS people, last([n in nodes(p) WHERE has(n.type) | id(n)]) AS relationship, [r in rels(p) | TYPE(r)] AS rels WITH relationship, rels, last(people) AS destination, [p in people | id(p)] AS source MATCH destination-[:NAME]->(name), destination-[:GENDER]->gender RETURN source, id(destination), relationship, rels, collect(name), gender ''' I thought this was working but realised that the shortest path drops some relationships. I was thinking of just finding all related nodes and all of the relationships and then processing the results to construct the correct format but I feel there is probably an easier /more efficient way. I have tried returning all paths but the model can have loops and therefore the number of paths returned increases exponentially with size. The cypher below creates a sample data set. ''' CREATE (p1:Person)<-[:CHILD]-(r1:Edge { type:'parentChild' })-[:PARENT]->(p2:Person) <-[:COUPLE]-(r2:Edge { type:'couple' })-[:COUPLE]->(p3:Person)<-[:PARENT]- (r3:Edge { type:'parentChild' })-[:CHILD]->p1<-[:COUPLE]-(r4:Edge { type:'couple' })-[:COUPLE]-> (p4:Person)<-[:CHILD]-(r5:Edge { type:'parentChild' })-[:PARENT]->(p5:Person)<-[:COUPLE]- (r6:Edge { type:'couple' })-[:COUPLE]->(p6:Person)<-[:PARENT]-(r7:Edge { type:'parentChild' })- [:CHILD]->p4, p5<-[:PARENT]-(r8:Edge { type:'parentChild' })-[:CHILD]->(p7:Person), p5<-[:PARENT]-(r9:Edge { type:'parentChild' })-[:CHILD]->(p8:Person), p5<-[:PARENT]-(r10:Edge { type:'parentChild' })-[:CHILD]->(p9:Person) ''' The image shows the view of the data. <IMAGE> The desired result is a row for every Node-Edge-Node connection. There are 10 in total in this data but I get 128 rows when I return all paths due to the loops. Is there a more efficient method of filtering the paths?
In order to resolve this I used the following cypher. ''' START person = node({personId})' + MATCH person-[:PARENT | CHILD | COUPLE*0..]-(p:Person) WITH distinct p MATCH p-[r]-(edge:Edge), p-[:NAME]->(name), p-[:GENDER]->gender, edge-[:FACT]->(fact) RETURN p, id(p), collect(name), gender, type(r), id(edge), collect(fact.type) ORDER BY id(edge) ''' I used to in the relationship to match all of the "Person" nodes who are connected, including the original node. After removing the duplicates it was simply a case of finding all of the relationships between the nodes and the extra information on each point. This cypher returned a row for every "person" to "edge" relationships. There is some duplication in "person" information but this was easily parsed out once the data was returned. Thanks for the comments and help.
15,475,566
1
15,511,373
I'm having trouble persisting primitive type collection using (Fluent)NHibernate. Here's the entity and mapping: ''' public class SomeOne { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual Iesi.Collections.Generic.ISet<string> Foo { get; protected set; } public SomeOne() { Foo = new HashedSet<string>(); } } public SomeOneMap() { Id(x => x.ID).GeneratedBy.Identity(); Map(x => x.Name); Map(x => x.Description); HasMany(x => x.Foo).Element("Code").AsSet().Not.Inverse(); Table("SomeTypeOne"); } ''' However, when I try to save SomeOne instance, associated Foo strings get's ignored. ''' var session = factory.OpenSession(); var one = new SomeOne(); one.Foo.Add("Dato"); one.Foo.Add("Mari"); session.Save(one); ''' Any idea what could be wrong? Thanks UPDATE --- Here's db schema. it's generated by NH.<IMAGE>
There are two ways of ensuring your collected is persisted. 1. Call session.Flush(); after session.Save(one);. This will cause NHibernate to persist your collection. More information on flush can be found here. 2. Wrap the whole thing in a transaction, i.e. using (var session = factory.OpenSession()) using (var transaction = session.BeginTransaction()) { var one = new SomeOne(); one.Foo.Add("Dato"); one.Foo.Add("Mari"); session.Save(one); transaction.Commit(); } There are several reasons why option two is better than option one. The main advantage is that all objects are saved back to the DB within the same transaction, so if one insert fails then the transaction is rolled back and your DB is not left in an inconsistent state. The acceped answer to this <URL> has an extensive explanation of why you should use transactions with NHibernate.
30,159,398
1
30,159,693
How to design form which should be aligned in the center for (desktop,mobile,tablet) and Add border like in the image attached Jsfiddle : <URL> Code: ''' <div class="container"> <div class="row"> <div class="col-md-6 col-md-offset-3"> <p class="main_heading">Start building your project!</p> <p class="sub_heading"> Add a story, picture and other important details </p> <form class="form-horizontal" role="form"> <fieldset> <div class="form-group"> <label class="col-sm-3 control-label">Project title</label> <div class="col-sm-9"> <input type="text" class="form-control" name="project_title" id="project_title" placeholder="Enter Project Title"> <p>Your project title and blurb should be simple, specific, and memorable. Our search tools run through these sections of your project, so be sure to incorporate any key words here! These words will help people find your project, so choose them wisely! Your name will be searchable too.</p> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Story</label> <div class="col-sm-9"> <p>Use your story to share on your as well as your FRIEND AND FANS' Facebook wall!</p> <textarea class="form-control" name="story" id="story" placeholder="Enter Story"></textarea> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Picture</label> <div class="col-sm-9"> <input type="file" class="form-control" name="picture" id="picture"> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Video</label> <div class="col-sm-9"> <input type="file" class="form-control" name="video" id="video"> <p>Have fun - add a video. A video have a much higher chance of success. The video will be shared on your as well as your FRIEND AND FANS' Facebook Wall!</p> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Short blurb</label> <div class="col-sm-9"> <textarea class="form-control" name="short_blurb" id="short_blurb"></textarea> <p>If you had to describe what you're doing in one tweet, how would you do it?</p> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <button type="button" class="btn btn-success">Submit</button> </div> </div> </fieldset> </form> <!------------> </div> </div> </div> ''' This is the sample design , attached below <IMAGE>
You can style the '.container' and '.form-group' ''' .container { border: 1px solid #D8D8D8; border-radius: 3px; } .form-group { background-color: #F2F2F2; padding: 10px 0; } ''' <URL>
13,804,069
1
13,804,163
I'm developing an iPhone application with latest 'SDK' and 'XCode'. I'm using storyboarding and I don't know how to open a view when user runs the app at first time. I will check if there is user 'preferences' saved, and, if there isn't, I will open settings view: ''' prefs = [NSUserDefaults standardUserDefaults]; if ([prefs stringForKey:APP_LANGUAGE_KEY] == nil) { // Open SettingsViewController; } else { // Continue usually. } ''' This is my storyboard: <IMAGE>
You almost got it right. Just make sure you set a key at the first launch. ''' NSString *key = @"AppWasLaunchedInThePast"; BOOL firstLaunch = ![[NSUserDefaults standardUserDefaults] objectForKey:key]; if (firstLaunch) { // First launch. Open settings. UIStoryboard *sb = [UIStoryboard storyboardWithName:@"FileName" bundle:nil]; NSString *anID = @"SettingsViewController"; // or whatever you set in IB. SettingsViewController *vc = [sb instantiateViewControllerWithIdentifier:anID]; // push vc to your navigation controller, or present it modally here. } else { // Not first launch. } // Make sure we remember that the app was launched: [[NSUserDefaults standardUserDefaults] setBool:YES forKey:key]; [[NSUserDefaults standardUserDefaults] synchronize]; '''
27,756,183
1
27,756,231
I have two functions I need it to call one function ever 30 seconds. But when using setIntreval it calls every second. how can I fix this? ''' this.seconds = 30; // part of a class called "player" it holds a value in seconds var _seconds = this.seconds * 1000; // converts seconds to miliseconds this.init = function() { ws.send('init'); // sends "init" to the server } ws.onopen = function() { // ws is a local variable that holds the connection. //ws.onopen is a method of ws it is called once per page load, //and only if the client connects successfully to the server var call = this.init; setInterval(call, _seconds); } ''' <IMAGE>
Try to this, use your function name instead call_function ''' setInterval(function(){ call_function(); }, 30000); '''
11,834,004
1
11,851,636
I'm coding an application that has to get the network adapters configuration on a Windows 7 machine just like it's done in the Windows network adapters configuration panel: <IMAGE> So far I can get pretty much all the information I need from 'NetworkInterface.GetAllNetworkInterfaces()' . I'm aware that it can be retrieved from the C++ struc 'PMIB_UNICASTIPADDRESS_TABLE' via 'OnLinkPrefixLength' but I'm trying to stay in .net. I also took a look at the 'Win32_NetworkAdapterConfiguration' WMI class but it only seems to return the IP v4 subnet mask. I also know that some information (not the prefix length, as far as I know) are in the registry: ''' HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\Interfaces\{CLSID} ''' I also used SysInternals ProcessMon to try to get anything usefull when saving the network adapter settings but found nothing... So, is there any clean .NET way to get this value? (getting it from the registry wouldn't be a problem) ## EDIT: Gateways This doesn't concern the actual question, but for those who need to retrieve the entire network adapter IPv6 configuration, the 'IPInterfaceProperties.GatewayAdresses' property only supports the IPv4 gateways. As mentionned in the answer comments below, the only way to get the entire info until .NET framework 4.5 is to call WMI.
You can do so using Win32_NetworkAdapterConfiguration. You might have overlooked it. IPSubnet will return an array of strings. Use the second value. I didn't have time to whip up some C# code, but I'm sure you can handle it. Using WBEMTEST, I pulled this: ''' instance of Win32_NetworkAdapterConfiguration { Caption = "[<PHONE>] Intel(R) 82579V Gigabit Network Connection"; DatabasePath = "%SystemRoot%\System32\drivers\etc"; DefaultIPGateway = {"192.168.1.1"}; Description = "Intel(R) 82579V Gigabit Network Connection"; DHCPEnabled = TRUE; DHCPLeaseExpires = "201208080<PHONE>-240"; DHCPLeaseObtained = "201208070<PHONE>-240"; DHCPServer = "192.168.1.1"; DNSDomainSuffixSearchOrder = {"*REDACTED*"}; DNSEnabledForWINSResolution = FALSE; DNSHostName = "*REDACTED*"; DNSServerSearchOrder = {"192.168.1.1"}; DomainDNSRegistrationEnabled = FALSE; FullDNSRegistrationEnabled = TRUE; GatewayCostMetric = {0}; Index = 10; InterfaceIndex = 12; IPAddress = {"192.168.1.100", "fe80::d53e:b369:629a:7f95"}; IPConnectionMetric = 10; IPEnabled = TRUE; IPFilterSecurityEnabled = FALSE; IPSecPermitIPProtocols = {}; IPSecPermitTCPPorts = {}; IPSecPermitUDPPorts = {}; IPSubnet = {"255.255.255.0", "64"}; MACAddress = "*REDACTED*"; ServiceName = "e1iexpress"; SettingID = "{B102679F-36AD-4D80-9D3B-D18C7B8FBF24}"; TcpipNetbiosOptions = 0; WINSEnableLMHostsLookup = TRUE; WINSScopeID = ""; }; ''' IPSubnet[1] = IPv6 subnet; Edit: Here's some code. ''' StringBuilder sBuilder = new StringBuilder(); ManagementObjectCollection objects = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration").Get(); foreach (ManagementObject mObject in objects) { string description = (string)mObject["Description"]; string[] addresses = (string[])mObject["IPAddress"]; string[] subnets = (string[])mObject["IPSubnet"]; if (addresses == null && subnets == null) continue; sBuilder.AppendLine(description); sBuilder.AppendLine(string.Empty.PadRight(description.Length,'-')); if (addresses != null) { sBuilder.Append("IPv4 Address: "); sBuilder.AppendLine(addresses[0]); if (addresses.Length > 1) { sBuilder.Append("IPv6 Address: "); sBuilder.AppendLine(addresses[1]); } } if (subnets != null) { sBuilder.Append("IPv4 Subnet: "); sBuilder.AppendLine(subnets[0]); if (subnets.Length > 1) { sBuilder.Append("IPv6 Subnet: "); sBuilder.AppendLine(subnets[1]); } } sBuilder.AppendLine(); sBuilder.AppendLine(); } string output = sBuilder.ToString().Trim(); MessageBox.Show(output); ''' and some output: ''' Intel(R) 82579V Gigabit Network Connection ------------------------------------------ IPv4 Address: 192.168.1.100 IPv6 Address: fe80::d53e:b369:629a:7f95 IPv4 Subnet: 255.255.255.0 IPv6 Subnet: 64 ''' Edit: I'm just going to clarify in case somebody searches for this later. The second item isn't always the IPv6 value. IPv4 can have multiple addresses and subnets. Use Integer.TryParse on the IPSubnet array value to make sure it's an IPv6 subnet and/or use the last item.
15,323,515
1
15,324,306
<IMAGE> I hope to add a admob view at the top or bottom of an 'UITableView'. In Interface Builder it is easy -- just drag the view to the top or bottom of the 'UITableView'. But I would like to add view to the top or bottom of the table dynamically using code.
You can add header or footer views to a 'UITableView' by implementing the following 'UITableViewDelegate' methods in your 'UITableViewController': ''' - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { CGFloat height = 100.0; // this should be the height of your admob view return height; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = myAdMobView; // init your view or reference your admob view return headerView; } ''' For more informtation, see the <URL>.
72,398,975
1
72,406,229
I'm taking a cell that people can enter data into, and trying to interpret it in several ways. They can enter a code with between 7 and 20 characters. Depending upon the length, and the leading character, I want it to strip out the excess data and leave just a serial #. The different possibilities of data that people can enter are as follows: ''' 7 character serial # 8 character serial # 8 character serial # with leading L 9 character serial # with leading D or L 10 character serial # 11 character serial # with leading M 12 character serial # 13 character serial # with leading M 20 character serial # with 12 leading useless characters ''' I've managed to create multiple IF statements that individually can identify each of these, but I'm trying to combine them into a single formula so that one cell shows JUST a valid serial #, after editing the entered data from a separate cell. I've managed to mix a couple of them, but the more AND and/or OR statements I add, the more confusing, and more likely to break the formula gets. Is there an easier/better way to do this? As an addendum, thanks to Special Instance: <IMAGE> I have removed the attempted formulae above, and recreated 4 formulae, posted below, which does each of the above necessary steps, but they're separate, and I need them together: ''' =IF(AND(LEN(A2)=8,(LEFT(A2,1)="L")), RIGHT(A2,7),A2) =IF(AND(OR(LEFT(A2,1)="D",LEFT(A2,1)="L"),LEN(A2)=9),RIGHT(A2,8),A2) =IF(OR(LEN(A2)=11,LEN(A2)=13),RIGHT(A2,LEN(A2)-1),A2) =IF(NOT(LEN(A2)=20),A2,RIGHT(A2,8)) '''
The formula below consolidates your logic into 3 possibilities ''' =IF(SUM(N(LEN(A1)={7,10,12})),A1, IF(SUM(COUNTIF(A1,"L???????"),COUNTIF(A1,{"L","D"}&"????????"),COUNTIF(A1,"M??????????"&{"","??"})),REPLACE(A1,1,1,""), IF(SUM(N(LEN(A1)={8,20})),RIGHT(A1,8),"ERROR"))) ''' 1. where the input entered is valid 2. where the input requires the 1st character to be eliminated 3. where only the last 8 characters of the input are valid which, for the sample provided, yields the correct results: <URL> (due to the employment of array constants, this will have to be entered as an <URL> but this answer is purely a function of your sample which, because serial numbers are usually alphanumeric in type, I don't think is realistic, e.g. the logic involves removing leading 'L', 'D' or 'M' characters, but your data indicate that these 3 same characters occur in the reformatted data - if the reality is that such characters are never valid then the logic could be simplified by the use of a series of 'SUBSTITUTE()' functions.
18,528,228
1
18,528,675
<IMAGE>x = {"utf8"=>"", "authenticity_token"=>"xxxxxxxxxxxxx=", "file"=>#>, "unit_id"=>"00001"} I have ruby data structure like this and um trying to get the value of @original_filename field I tried something like this ''' x["@original_filename"] ''' and ''' x[:original_filename] ''' But both has thrown me an error . How to access that specified element value?
The parameter ["file"] is a ActionDispatch::Http::UploadedFile, which has the original_filename member variable, as you can see in the params displayed in your image or here: <URL> So, the way to get this value would be 'x["file"].original_filename'
28,986,819
1
28,987,755
Here is job I'm running from Spark shell : ''' val l = sc.parallelize((1 to <PHONE>).toList) val m = l.map(m => m*23) m.take(<PHONE>) ''' Workers appear to be "LOADING" state : <IMAGE> What is "LOADING" state ? Update : As I understand 'take' will perform job on cluster and then return results to Driver. So "LOADING" state equates to the data being loaded onto driver ?
I believe that if you do something like this, ''' (1 to <PHONE> ).toList ''' You are bound to encounter 'java.lang.OutOfMemoryError: GC overhead limit exceeded'. This happens when JVM realizes that it is spending too much time in 'Grabage Collection'. By default the JVM is configured to throw this error if you are spending 'more than 98% of the total time' in 'GC' and after the 'GC' 'less than 2%' of the 'heap' is recovered. In this particular case you are creating 'new instance' of 'List' for every iteration, ( 'immutability', so each time a 'new instance' of 'List' is returned ). Which means each iteration leaves an useless instance of 'List', and for 'List' with size in millions, it will take lot of memory and trigger 'GC' very frequently. Also, each time 'GC' has to free lot of memory hence take lot of time. This ultimately leads to error - 'java.lang.OutOfMemoryError: GC overhead limit exceeded'. -> This means that the little amount GC was able to clean will be quickly filled again thus forcing GC to restart the cleaning process again.This forms a vicious cycle where the CPU is 100% busy with GC and no actual work can be done. The application will face extreme slowdowns - operations which used to be completed in milliseconds will now likely to take minutes to finish. This is a pre-emptive fail-fast safeguard implemented in JVM's. You can disable this safeguard by using following Java Option. ''' -XX:-UseGCOverheadLimit ''' But I will strongly recommend doing this. And even if you disable this feature ( or if your Spark-Cluster avoids this 'to some extent' by allocating large heap space ), some thing like ''' (1 to <PHONE> ).toList ''' will take a long long time. Also, I have a strong feeling that systems like 'Spark' which are supposed to be running multiple jobs are configured ( by default, may be you can override ) to 'pause' or 'reject' such jobs as soon as they realize extreme GC which can lead to starvation of other jobs. And this may be the main reason your job is always loading. You can get a lot of relief by using a 'mutable List' and appending values to it with a for loop. Now you can parallelise your mutable list. ''' val mutableList = scala.collection.mutable.MutableList.empty[ Int ] for ( i <- 1 to <PHONE> ) { mutableList.append( i ) } val l = sc.parallelize( mutableList ) ''' But even this will lead to multiple ( but many times less severe ) memeory allocations( hence GC exectuions ) whenever the 'List' is 'half-full', which result in 'memory relocation' of whole 'List' with double of previously allocated memory.
15,217,989
1
15,429,890
Hi i am developing in Custom tabbar and my deployment Target is iOS4 <IMAGE> In iOS5 wise Everything fine. In iOS4 wise not working Code snippet ''' UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBack.png"]]; if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { //iOS 5 [self.tabBarController.tabBar insertSubview:imageView atIndex:1]; self.tabBarController.tabBar.selectionIndicatorImage =[UIImage imageNamed:@"red_Back.png"]; [[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]]; } else { //iOS 4 [self.tabBarController.tabBar insertSubview:imageView atIndex:0]; } ''' Iam tried some codes 1) <URL> 2) <URL> no effect to those code samples I tried a lot,any way to do this task in iOS4 ? Any shortcut? Any tutorial or example pls Thanks in Advance
''' - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSInteger tabbarHeight; CGRect Bounds = [[UIScreen mainScreen] bounds]; if (Bounds.size.height == 568) { // code for 4-inch screen tabbarHeight = 519; } else { // code for 3.5-inch screen tabbarHeight = 431; } UITabBarController *tabBarController = [[UITabBarController alloc]init]; tabBarController.selectedIndex=0; tabBarController.delegate=self; img = [[UIImageView alloc]init]; img.image=[UIImage imageNamed:@"Tabimage.png"]; img.frame=CGRectMake(0,tabbarHeight, 320, 49); [self.tabBarController.view addSubview:img]; tabBarController.viewControllers = @[homeNavigationController,profileNavigationControler,notificationNavigationController,newsNavigationController,aboutUsNavigationController]; self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; return YES; } - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ NSUInteger index=[[tabBarController viewControllers] indexOfObject:viewController]; switch (index) { case 0: self.img.image=[UIImage imageNamed:@"Tabone.png"]; break; case 1: self.img.image=[UIImage imageNamed:@"Tabtwo.png"]; break; case 2: self.img.image=[UIImage imageNamed:@"Tabthree.png"]; break; case 3: self.img.image=[UIImage imageNamed:@"Tabfour.png"]; break; case 4: self.img.image=[UIImage imageNamed:@"Tabfive.png"]; break; default: break; } return YES; } '''
21,007,937
1
21,008,279
I created database on localhost, wrote some pup code. When I run localhost I get the error ''' Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in: ''' This is php code: ''' <?php require('connect_review.php'); $query=mysql_query("SELECT * FROM reviews ORDER BY id DESC"); while($rows=mysql_fetch_assoc($query)) { $id=$rows['idname']; $dname=$rows['iname']; $dcomment=$rows['icomment']; echo '<font color="#02AAFC">Added:</font> ' . $dname . '<br />' . $dcomment . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '<br />' . '<br />' ; } ?> ''' This is result: <IMAGE>
As others have mentioned, you likely want to migrate away from mysql_* functions. However, if you insist on continuing this way, you should check that rows were returned before issuing your mysql_fetch_assoc Sample code: ''' .... $num_rows = 0 if ($query) { $num_rows = mysql_num_rows($query) if ($num_rows) { while($rows=mysql_fetch_assoc($query)) ... } } '''
17,775,829
1
17,776,182
I am trying to allow the user to take a photo using UIImagePickerController and after finishing take him to a UITableView, passing the chosen image, where he can add info about the photo in text fields such as description. Right now this is my code in didFinishPickingMediaWithInfo: ''' if (image) { PhotoInfoViewController* photo_info_controller = [[PhotoInfoViewController alloc] init]; photo_info_controller.image = image; [self dismissViewControllerAnimated:YES completion:^{ [self.parentViewController presentViewController:photo_info_controller animated:YES completion:nil]; }]; } ''' This takes the code to the next view which is a static tableviewcontroller<IMAGE> and in the PhotoInfoView controller I see that viewDidLoad gets called by NSLog but all I see is an empty tableViewController and no text fields... Any one have any advice??
Try to change PhotoInfoViewController initialization. 1. Set storyboard id in your storyboard file to PhotoInfoViewController 2. Change code. > ''' UIStoryboard *storyboard = [UIStoryboard storyboardWithName:<#name of storyboard#> bundle:[NSBundle mainBundle]]; PhotoInfoViewController *photo_info_controller = [storyboard instantiateViewControllerWithIdentifier:@"PhotoInfoViewController"]; '''
19,124,715
1
19,125,577
I've installed the cookie extension for jquery, and am attempting to access the session id cookie. I currently have two cookies for my session - see screenshot below: <IMAGE> however, $.cookie() only lists one: ''' > $.cookie() Object {csrftoken: "fFrlipYaeUmWkkzLrQLwepyACzTfDXHE"} > $.cookie('sessionid') undefined ''' can i/how do i access the sessionid cookie from javascript?
The session id cookie should be marked as HTTP Only, preventing access from javascript. This is a security issue, preventing session hijacking via an xss vulnerability. You can see in your screenshot that the cookie is indeed marked as HTTP. --- If you want to learn more about the flag see <URL>.
74,275,591
1
74,276,116
I am working on .net core web api and i have come across an issue where data is being sent as a model class but still in swagger no data is found in reponse i just see ''' {} ''' here is the screen shot of data returned by api <IMAGE> here is the response in <URL> I gone through so much possibilities on stack and havent found any issue related to this
The issue i had been through was that i had not made setter and getters for the object returned as it was returning multiple ienumerable objects. so setter and getters solved my problem
6,378,682
1
6,380,432
In the Flash IDE, I have made a dynamic text field bold. When the Flash is compiled and run, the bold styling disappears. How do I retain the bold styling? : IDE : SWF <IMAGE>
You're seeing only the characters that were in the TextField initally, because they are automatically embedded, and you have the font lookup set to something other than "Use Device Fonts". To fix the missing chars, change the font lookup to "Use Device Fonts", or embed both normal and bold "Arial". The top TextField is not bold because Flash Pro sets the font style only on the text you entered at design time. You can fix it by using 'textField.htmlText = '<b>Bold Text</b>'' instead of 'textField.text = 'Bold Text''.
18,134,675
1
18,134,749
I can't seem to figure out where the whitespace is coming from, above and below these '<code>' tags in HTML. It doesn't appear to be margin or padding. In the example below both are set to 0, and inspection w/ chrome dev tools doesn't seem to give any answers. The extra space (green boxes above and below) show up in Chrome, FF, and IE9. <URL> ''' <style type="text/css"> section{ border: thin solid black; } pre{ border: thin solid red; } code{ border: thin solid green; margin: 0px 0px; padding: 0px 0px; } </style> <section> <pre> <code> // some code goes here </code> </pre> </section> ''' <IMAGE>
The newlines inside '<pre>' cause the extra space. You can either remove the new lines or add 'white-space: nowrap;' to your css. See the edited fiddle here: <URL> EDIT: Also you can remove this: ''' margin: 0px 0px; padding: 0px 0px; ''' from your CSS as that is the default for a code block.
74,597,932
1
74,602,861
I'm trying to edit an user account based on the user id. I'm able to retrieve the user data from the database but there is a problem occurred when trying to update the data into the database after clicking the save button. I have no idea why the problem will occurred. May I know where did I make mistake? ''' @app.route('/edit',methods = ['GET','POST']) def edit(): id = session['id'] conn = get_db_connection() users = conn.execute('SELECT * FROM User WHERE id = ?',(id)).fetchall() form = EditForm(request.form) if request.method == 'POST' and form.validate(): hashed_pw = generate_password_hash(form.password.data,"sha256") print(form.first_name.data, form.last_name.data, form.email.data, hashed_pw, id) conn.execute('UPDATE User SET first_name = ?,last_name = ?,email = ?, password = ? WHERE id = ?',(form.first_name.data, form.last_name.data, form.email.data, hashed_pw, id)) conn.commit() conn.close() message = "Data has been modify successfully" flash(message,'edited') return redirect(url_for('edit')) return render_template('edit.html',users = users, form = form) ''' ''' <form action="/edit" method="POST"> <div> <h2 class="text-center fw-bold fs-2 mb-4 p-0 m-0">Edit Account</h2> {% for user in users %} <div class="input-group justify-content-between"> <div class="form-floating mb-4" style="min-width: 230px;"> <label for="firstName">First name</label> <input id="first_name" name="first_name" class="form-control" placeholder="John" value= "{{ user[1] }}" /> {% if form.first_name.errors %} <ul class="errors text-danger"> {% for error in form.first_name.errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} </div> <div class="form-floating mb-4" style="min-width: 230px;"> <label for="lastName">Last name</label> <input id="last_name" name="last_name" class="form-control" placeholder="Doe" value= "{{ user[2] }}"/> {% if form.last_name.errors %} <ul class="errors text-danger"> {% for error in form.last_name.errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} </div> </div> <div class="form-floating mb-4"> <label for="email">Email address</label> <input id="email" name="email" class="form-control" type="email" placeholder="name@example.com" value= "{{ user[3] }}" /> {% if form.email.errors %} <ul class="errors text-danger"> {% for error in form.email.errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} </div> <div class="form-floating mb-4"> <label for="password">Password</label> <input id="password" name="password" class="form-control" type="Password" placeholder="Enter your password" /> {% if form.password.errors %} <ul class="errors text-danger"> {% for error in form.password.errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} </div> <div class="form-floating mb-4"> <label for="passwordConfirmation">Confirm password</label> <input id="password_confirmation" name="password_confirmation" class="form-control" type="password" placeholder="Enter your password again" /> {% if form.password_confirmation.errors %} <ul class="errors text-danger"> {% for error in form.password_confirmation.errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} </div> {% endfor %} ''' [<IMAGE> ''' Traceback (most recent call last): File "C:\Users\user\desktop\phonebuddy\.venv\lib\site-packages\flask\app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "C:\Users\user\desktop\phonebuddy\.venv\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\user\desktop\phonebuddy\.venv\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\user\desktop\phonebuddy\.venv\lib\site-packages\flask\app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "C:\Users\user\Desktop\PhoneBuddy\app.py", line 127, in edit conn.execute('UPDATE User SET first_name = ?,last_name = ?,email = ?, password = ? WHERE id = ?',(form.first_name.data, form.last_name.data, form.email.data, hashed_pw, id)) sqlite3.InterfaceError: Error binding parameter 4 - probably unsupported type. 127.0.0.1 - - [28/Nov/2022 16:29:50] "POST /edit HTTP/1.1" 500 - ''' <URL>
The error message says that the type of parameter 4 is unsupported. The counting starts with 0, so we are talking about the 'id'. Your debug output shows that 'id' contains the <URL>'. This is no problem for the select-statement where you only pass one parameter, because it can coup with both, single values and tuples. But if you pass more than just 'id' like in your update statement, you get a tuple that contains a tuple. Please check how you set 'session['id']'. If you want to pass just one id then don't pass a tuple. If you want to pass a tuple then get the first value 'id[0]' when you pass it to the update statement!
4,708,893
1
4,709,070
I am trying to figure out the best design for a custom floating "pallet" for initiating actions (e.g., change sorting criteria of a list) as well as switching views (e.g., Help, Options). I want the pallet to start out collapsed so the initial view is full-screen. When the user touches the corner of the screen the view slides into place with animation. Another touch slides the view out of the way. The best example of the UI I am going for is one of my favorite apps, the iThoughts mind mapper (see below). How is this done? I really want to learn how the pros create such beautiful apps. Most of the help I find points me in the direction of the standard UITabbar, UIToolbar, etc. Yawn. Thanks! <IMAGE>
Assumptions: - 'toolbar'- 'CGRect toolbarFrameWhenHidden''CGRect toolbarFrameWhenShown'- 'BOOL toolbarHidden'- 'toggleToolbar:' The code: ''' - (IBAction) toggleToolbar:(id)sender { CGRect targetFrame = self.toolbarHidden ? self.toolbarFrameWhenShown : self.toolbarFrameWhenHidden; [UIView animateWithDuration:0.25 animations:^{ self.toolbar.frame = targetFrame; }]; self.toolbarHidden = !self.toolbarHidden; } '''
22,371,325
1
22,371,400
I'm aware of the <URL>. However in my opinion these are both inferior to the below type of dialog: <IMAGE> This is more in line with the open file dialog, and gives access to the navigation pane (or whatever it is on the left). I've seen it in a few programs (shown below is TortoiseHG), which makes me suspect that it a semi off-the-shelf component, and I'm just curious whether one is freely available. Unfortunately google-fu fails me and all I can find is the FolderBrowseDialog/Ex - so my question is, is there a pre-rolled version of this dialog box (if not in the .NET framework then elsewhere) that I can use?
This is free and seems to provide customization options. Try this out. <URL> and <URL>
61,708,916
1
61,772,356
I'm using STM32CubeIDE to write an application for a STM32F411RE Nucleo board. The code involves the use of a timer. When I attempt to build my project, I get a number of "undefined reference" errors for the timer functions called. After looking around, I noticed that the timer functions (ex: HAL_TIM_Base_Init()) related to the errors are located in stm32f4xx_hal_tim.c and are grayed out with a strike-through. I assume this is the cause of the undefined reference errors I'm seeing. Based on my googling, my understanding is that the strike-through means the function is deprecated. However, I'm unable to figure out how to resolve this. I did come across another question that's somewhat related to my issue: <URL>. However, the solution to it was related to the source file, rather than the functions within the source file. Screenshot of what I'm seeing: <IMAGE> I'm new to the world of STM32 and STM32CubeIDE so any help/explanation is greatly appreciated. Thank you
The functions are grayed out because a preprocessor directive is not met and therefore these functions are discarded during compile time. If you look in the file you will find something like these at the very beginning: '#ifdef HAL_TIM_MODULE_ENABLED' The STM32 HAL is designed to be able to enable or disable several modules explicitly. And these definitions are located in the 'stm32l4xx_hal_conf.h' file. Just open this file and find the 'HAL_TIM_MODULE_ENABLED' definition and remove the surrounding comment block. Moreover the config file is autogenerated in the CubeIDE depend on the selected "Pin & Configuration" settings (ioc file). Also check these to enabled the timer module.
69,154,584
1
69,154,716
I am trying to develop a system such that users are assigned tickets, and I get all tickets that are assigned for such user. <IMAGE> So, a user may be assigned 5 different tickets on 3 different projects. I am trying to fetch all tickets where the field of "assignee" equals [Name of user]. The screenshots I showed are the projectTickets for just one project. I need a way to fetch what I requested, and above it, put a for loop to go through every project. In every project name (d0c), there is a collection titled "projectTickets".
To get all projectTickets across all projects where 'assignee' = 'aa', use this: ''' db.collectionGroup("projectTickets").where("assignee", "==", "aa") .get() .then(function(querySnapshot) { // below is your loop querySnapshot.forEach(function(doc) { console.log(doc.id, " => ", doc.data()); }); }) .catch(function(error) { console.log("Error getting documents: ", error); }); ''' This will require indexes. For user named 'aa', the above function should get all tickets on all projects.
25,242,601
1
25,242,842
Good day. How to change the count and label of the cells by clicking using reloadData? <IMAGE> ''' - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:NO]; NSLog(@"test"); [tableView numberOfRowsInSection:3]; [tableView reloadData]; } '''
If you want to change the number of rows in section you should modify your dataSource from your delegate method. You shouldn't call any of dataSource methods. Below you can find one of the simplest way to modify data of yoru table view: ''' // In your category or header file: @property (nonatomic) NSInteger numberOfRows; - (void)viewDidLoad { self.numberOfRows = 1; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *) { self.numberOfRows = 3; [self.tableView reloadData]; } //Method in your table view datasrouce - (void)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.numberOfRows; } '''
29,505,274
1
29,505,975
First of all, I am new to 'Swift/iOS' development and just started learning. I am trying to create a simple app that . The interface has a play and pause buttons, and slider to control the music volume. I have searched SO and found some similar posts, but haven't found them helpful in my situation. When I build and start the app in Xcode, I got the errors: ''' 2015-04-07 23:04:25.403 Music Player[8772:102170] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Music_Player.ViewController 0x7f991ad3a160> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key play.' *** First throw call stack: ( 0 CoreFoundation 0x000000010a45bf35 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010bf9fbb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010a45bb79 -[NSException raise] + 9 3 Foundation 0x000000010a8737b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259 4 CoreFoundation 0x000000010a3a5e80 -[NSArray makeObjectsPerformSelector:] + 224 5 UIKit 0x000000010afacc7d -[UINib instantiateWithOwner:options:] + 1506 ..... 22 UIKit 0x000000010ace7420 UIApplicationMain + 1282 23 Music Player 0x0000000109f24afe top_level_code + 78 24 Music Player 0x0000000109f24b3a main + 42 25 libdyld.dylib 0x000000010c779145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) ''' I use the class to instantiate a player for playing and pausing music. ''' var player: AVAudioPlayer = AVAudioPlayer() @IBAction func play(sender: AnyObject) { var audioPath = NSString(string: NSBundle.mainBundle().pathForResource("music", ofType: "mp3")!) //file: music.mp3 var error: NSError? = nil //instantiate the player player = AVAudioPlayer(contentsOfURL: NSURL(string: audioPath), error: &error) //error pointer player.prepareToPlay() player.play() } @IBAction func pause(sender: AnyObject) { player.pause() } ''' I haven't done anything yet with the slider other than the below code: ''' @IBOutlet var slider: UISlider! @IBAction func sliderChanged(sender: AnyObject) { } ''' the GUI is attached below: <IMAGE>
''' if let resourceUrl = NSBundle.mainBundle().URLForResource("1", withExtension: "mp3") { if NSFileManager.defaultManager().fileExistsAtPath(resourceUrl.path!) { var error: NSError? = nil //instantiate the player player = AVAudioPlayer(contentsOfURL: resourceUrl, error: &error) player.prepareToPlay() player.play() } } ''' Update your code like this for avoid crashing if file is not there. ''' this class is not key value coding-compliant for the key play. ''' Means If you have a control in your nib (xib file) that is linked to a property (IBOutlet) or method (IBAction) in your view controller, and you have either deleted or renamed the property or method, the runtime can't find it because it has been renamed and therefore crashes. <URL> I created complete working project for you.
15,207,254
1
15,207,366
I want to learn Java EE Spring framwork. So, I downloaded Spring Tool Suite from their site, and I followed this "Hello World" example: <URL> As you can see, he is importing some .jar files, and I also import them but I dont have antlr-runtime-3.0.1 and commons-logging-1.1.1, or at least I cant find them. So when I run try to run application, I dont know how to run application, because I have just 2 options: AspectJ/Java and Java application. Of course, when I try to run app, I get error. You can take look at screenshoot. <IMAGE>
Here is a good place to go look for jars: <URL> Notice this page has several versions of antlr. If you click the link to 3.0.1, you can download the jar. There is probably a website for antlr that has the jars but it might not have old ones where they are easy to find. Similarly for commons-logging, there is an Apache site for it. But you can find it by searching at <URL> though you may have to poke around to find it. For your second question, run as a Java application. The tutorial has a class MainApp that contains a 'main()' method. You use 'MainApp' as the starting class and it will begin running the 'main()' method's code. This is standard Java behavior. You might want to run through some simple Java tutorials to learn how plain old Java works and then add Spring Framework when you are a bit more proficient.
5,247,081
1
5,247,255
I've got a div with a class of 'screenshot' (in pink), and inside it is an image element and a heading element (in blue). As you can see in the image below; the h3 tag is not being contained by its fixed width parent. How can I contain the heading element inside the parent div so it's width is the same? Specifying width, margin, padding etc. doesn't work. HTML: ''' <div class="screenshot"><a href="#"> <img src="img/vert_img1.png" alt="Image description"> <h3>Heading #1</h3> </a> </div> ''' CSS: ''' #screenshots .screenshot { background: pink; width: 209px; margin: 2px; padding-bottom: 1px; } .screenshot a img { width: 200px; height: 150px; margin-right: 0px; } .screenshot a h3 { background-color: blue; margin-bottom: 10px; text-align: center; width: 209px; } ''' <IMAGE>
Does <URL> fix the problem you have? I have fixed the markup, as I notice that other comments have already highlighted, since it is not valid to have an 'h3' (or any block level element) inside an 'a'.
31,380,808
1
31,381,950
I am using GoogleMaps SDK in my iOS application. I have implemented custom info window for GoogleMaps and calling it my ViewController as, ''' func mapView(mapView: GMSMapView!, markerInfoContents marker: GMSMarker!) -> UIView! { var calloutView:CalloutView = NSBundle.mainBundle().loadNibNamed("CalloutView", owner: self, options: nil)[0] as! CalloutView views!.detailDisclosure.addTarget(self, action: "detailDisclosureButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside) views.labelText.text = "ABC Text" return views } ''' And getting output as below <IMAGE> Info window overlapping and showing bottom edges as below. Also button on info window not getting clicked. Please help for the same.
With my experience, '- mapView:markerInfoContents:' have some problems. In my case, I ended up using <URL> instead. In this case, you have to draw balloon image by yourself, like this: <IMAGE> > Also button on info window not getting clicked. As <URL>, markerInfoWindow is rendered as an image, but not true 'UIView'. > The info window is rendered as an image each time it is displayed on the map. This means that any changes to its properties while it is active will not be immediately visible. The contents of the info window will be refreshed the next time that it is displayed. It does not receive any UI events. So, sad to say, any 'UIControl's on markerInfoWindow is useless. The only supported way is to use <URL> delegate method, that means, you define multiple clickable areas on the info window.
18,280,517
1
18,297,121
I have been trying to draw a transparent texture in LWJGL. However, the code I have doesn't seem to work. Whenever I run the code, the transparent image appears but the background is completely black. Here's what I mean by completely black, but the image is fine: <IMAGE> I have been able to draw non-transparent textures, but so far I've had no luck with drawing this one correctly. I would like to know what is missing/incorrect in this code. Code for drawing texture: ''' //draw transparent texture GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); GL11.glColor4d(1,1,1,1); texture.bind(); GL11.glTranslated(0.5,0.5,0.0); GL11.glRotated(270-this.getAngle(),0.0,0.0,1.0); GL11.glTranslated(-0.5,-0.5,0.0); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(0,0); GL11.glVertex2d(this.getX(), this.getY()); GL11.glTexCoord2f(1,0); GL11.glVertex2d(this.getX(),(this.getY()+this.getHeight())); GL11.glTexCoord2f(1,1); GL11.glVertex2d((this.getX()+this.getWidth()),(this.getY()+this.getHeight())); GL11.glTexCoord2f(0,1); GL11.glVertex2d((this.getX()+this.getWidth()), this.getY()); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); GL11.glMatrixMode(GL11.GL_MODELVIEW); ''' Here's the code that loads the texture from the file: ''' private Texture loadTexture(String key){ try { //in this case, key refers to a valid power of 2, transparent png return TextureLoader.getTexture("PNG", new FileInputStream(new File("res/"+key+".png"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } '''
The above code does not seem to have a problem. By using the simple code from the <URL>' method with your code I was able to correctly see transparency using this RGBA image of an up arrow: <IMAGE> Please make sure that you are clearing your colorbuffer in a color other than black i.e. use ''' GL11.glClearColor(0.7f, 0.7f, 0.7f, 1.0f); // try with red (1, 0, 0, 1) green (0, 1, 0, 1) to check the image's transparent area. ''' If this doesn't work for your case, please post a full runnable example because the problem must lie in the rest of your code.
20,499,391
1
20,505,714
I am using Chart Director ( <URL> to display 1 minute HLOC financial data. The dataset is missing some of the bars, so I add them back with H=L=O=C=arbitrary value. The result is ( red arrow points to period with missing bars ) <IMAGE> Is there some way to make the missing bars invisible? ( If I just leave them out, then the later bars move towards the left, which ruins the alignment with charts wich do not have missing bars )
The solution is to set the missing values to 1.7E+308 <URL>
14,650,927
1
14,651,174
Requesting a page from IIS (hosts ASP.NET MVC 3 site) with url containing web.config gives 404 error. Urls with app.config have no problem. Local Visual Studio development server has no issues with this type of urls. 1 - What are any other special words other than web.config, being handled this way by IIS? In request filtering page/hidden segments tab this is the current state: <IMAGE> I guess these are the words being handled by IIS this way. So these are the default words I think and this list is configurable (new items can be added to this list). 2 - Are there any quick fixes (like by web.config modification) to handle urls with these special words? Btw, I am not trying to serve the web.config file. Url format is :
This is part of the IIS configuration under the 'Request Filtering' section: <IMAGE> You can add/remove filters. , I do believe this is a really to remove 'web.config' from it. <URL>
25,168,712
1
25,168,929
I would like PHP to check the directory of selection i input in variable and out put the Folder, Files, Permission (writable or not writable) at same time. ''' <?php $directorySelection = '../app/'; if (file_exists($directorySelection)) { if ($existence = opendir('../app')) { while (false !== ($files = readdir($existence))) { if ($files != "." && $files != ".." && $files != ".DS_Store") { echo '<table>'; echo '<tr>'; echo '<td style="width: 90%; padding: 10px;">'. $files .'</td>'; if (is_writable($files)) { echo '<td><span class="label label-success">Writable</span></td>'; } else { echo '<td><span class="label label-danger">Not writable</span></td>'; } echo '<td>'. substr(sprintf('%o', fileperms($files)), -4) . '</td>'; echo '</tr>'; echo '</table>'; } } closedir($existence); } } else { echo '<div class="alert alert-warning" role="alert">Application Directory doesn't exist <a role ="button" data-toggle="alertInfo" placement="left" title="Application Directory" data-content="Please set your Application Directory, so that the installer can check for folder, files and there Permissions "> <span class="glyphicon glyphicon-info-sign floatRight"></span></a></div>'; } ?> ''' <IMAGE>
the problem is with your '$files' variable, as it doesn't contain the full path, only the name, and it is checking from CWD. Your code is testing for the file perms based on the CWD, but your files are not located in the CWD. so prefix the '$files' with the name of the directory such as ''' if ($files != "." && $files != ".." && $files != ".DS_Store") { $filepath = $directorySelection . $files; .... if (is_writable($filepath)) { ..... substr(sprintf('%o', fileperms($filepath)), -4) ''' And it should read the file correctly. Then use '$files' if you want the name, and '$filepath' for function that take a filename. (interior code not shown as to not clutter it up)
24,738,759
1
28,816,858
I am trying to see the items in the collection, but it seems like Eclipse just loops things over and over: <IMAGE> How can I see the individual items in the TreeMap collection?
There is a small button above the variables "Show Logical Structure". Try it and it makes things easier. :-)
25,691,735
1
25,691,983
Earlier today I was working on this script based on <URL> and Matlab answers: ''' clc; clear; close all; input_im=imread('C:\Users\Udell\Desktop\T2.jpg'); sz_im=size(input_im); cform = makecform('srgb2lab'); lab_he = applycform(input_im,cform); ab = double(lab_he(:,:,2:3)); nrows = size(ab,1); ncols = size(ab,2); ab = reshape(ab,nrows*ncols,2); nColors = 3; % repeat the clustering 3 times to avoid local minima [cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', 'Replicates',3); pixel_labels = reshape(cluster_idx,nrows,ncols); %imshow(pixel_labels,[]), title('image labeled by cluster index'); segmented_images = cell(1,3); rgb_label = repmat(pixel_labels,[1 1 3]); for k = 1:nColors color = input_im; color(rgb_label ~= k) = 0; segmented_images{k} = color; end for k=1:nColors %figure title_string=sprintf('objects in cluster %d',k); %imshow(segmented_images{k}), title(title_string); end finalSegmentedImage=segmented_images{1}; %imshow(finalSegmentedImage); close all; Icombine = [input_im finalSegmentedImage]; imshow(Icombine); ''' While running the script multiply times I noticed that I get different images when finalSegmentedImage=segmented_images{1} for the combined image (Icombine). Why? And how can I fix it that the results will be repetitive (e.g., segmented_images{1} image will be always the same)? Thanks a lot. The image: <IMAGE>
The reason why you are getting different results is the fact that your colour segmentation algorithm uses <URL>. I'm going to assume you don't know what this is as someone familiar in how it works would instantly tell you that this is why you're getting different results every time. In fact, the different results you are getting after you run this code each time are a natural consequence to -means clustering, and I'll explain why. How it works is that for some data that you have, you want to group them into groups. You initially choose random points in your data, and these will have labels from '1,2,...,k'. These are what we call the . Then, you determine how close the rest of the data are to each of these points. You then group those points so that whichever points are closest to any of these points, you assign those points to belong to that particular group ('1,2,...,k'). After, for all of the points for each group, you update the , which actually is defined as the representative point for each group. For each group, you compute the average of all of the points in each of the groups. These become the centroids for the next iteration. In the next iteration, you determine how close each point in your data is to . You keep iterating and repeating this behaviour until the centroids don't move anymore, or they move very little. How this applies to the above code is that you are taking the image and you want to represent the image using only possible colours. Each of these possible colours would thus be a centroid. Once you find which cluster each pixel belongs to, you would replace the pixel's colour with the centroid of the cluster that pixel belongs to. Therefore, for each colour pixel in your image, you want to decide which out of the possible colours this pixel would be best represented with. The reason why this is a colour segmentation is because you are the image to belong to only possible colours. This, in a more general sense, is what is called . Now, back to -means. How you choose the initial centroids is the reason why you are getting different results. You are calling -means in the default way, which automatically determines which initial points the algorithm will choose from. Because of this, you are to generate the same initial points each time you call the algorithm. If you want to the same segmentation no matter how many times you call 'kmeans', you will need to . As such, you would need to modify the -means call so that it looks like this: ''' [cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ... 'Replicates', 3, 'start', seeds); ''' Note that the call is the same, but we have added two additional parameters to the -means call. The flag 'start' means that you are specifying the initial points, and 'seeds' is a 'k x p' array where is how many groups you want. In this case, this is the same as 'nColors', which is 3. 'p' is the dimension of your data. Because of the way you are transforming and reshaping your data, this is going to be 2. As such, you are ultimately specifying a '3 x 2' matrix. However, you have a 'Replicate' flag there. This means that the -means algorithm will run a certain number of times specified by you, and it will output the segmentation that has the least amount of error. As such, we will repeat the 'kmeans' calls for as many times as specified with this flag. The above structure of 'seeds' will no longer be 'k x p' but 'k x p x n', where 'n' is the number of times you want to run the segmentation. This is now a 3D matrix, where each 2D slice determines the initial points for each run of the algorithm. Keep this in mind for later. How you choose these points is up to you. However, if you want to randomly choose these and not leave it up to you, but want to reproduce the same results every time you call this function, you should set the <URL> to be a known number, like '123'. That way, when you generate random points, it will always generate the same sequence of points, and is thus reproducible. Therefore, I would add this to your code before calling 'kmeans'. ''' rng(123); %// Set seed for reproducibility numReplicates = 3; ind = randperm(size(ab,1), numReplicates*nColors); %// Randomly choose nColors colours from data %// We are also repeating the experiment numReplicates times %// Make a 3D matrix where each slice denotes the initial centres for each iteration seeds = permute(reshape(ab(ind,:).', [2 nColors numReplicates]), [2 1 3]); %// Now call kmeans [cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ... 'Replicates', numReplicates, 'start', seeds); ''' Bear in mind that you specified the 'Replicates' flag, and we want to repeat this algorithm a certain number of times. This is '3'. Therefore, what we need to do is specify initial points for . Because we are going to have 3 clusters of points, and we are going to run this algorithm 3 times, we need 9 initial points (or 'nColors * numReplicates') in total. Each set of initial points has to be a in a 3D array, which is why you see that complicated statement just before the 'kmeans' call. I made the number of replicates as a variable so that you can change this and to your heart's content and it'll still work. The complicated statement with <URL> allows us to create this 3D matrix of points very easily. Bear in mind that the call to <URL> in MATLAB only accepted the second parameter as of recently. If the above call to 'randperm' doesn't work, do this instead: ''' rng(123); %// Set seed for reproducibility numReplicates = 3; ind = randperm(size(ab,1)); %// Randomly choose nColors colours from data ind = ind(1:numReplicates*nColors); %// We are also repeating the experiment numReplicates times %// Make a 3D matrix where each slice denotes the initial centres for each iteration seeds = permute(reshape(ab(ind,:).', [2 nColors numReplicates]), [2 1 3]); %// Now call kmeans [cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ... 'Replicates', numReplicates, 'start', seeds); ''' --- Now with the above code, you should be able to generate the same colour segmentation results every time. Good luck!
59,074,636
1
59,074,999
<IMAGE> I want to make a button with a define width, but I have a template with the button component defined including styles, so when I try to modify the style of the button, it happened nothing, here is my code Here is when I call the component in the react class ''' <Button className={classes.buttonW} component={Link} color="success" size="lg" to="/album-carousel-page" > Galeria </Button> ''' The classname when I modify the css button ''' buttonW: { width: "100px", height: "30px" } ''' And here is the code above the template original button (Very complex for my opinion) ''' button: { minHeight: "auto", minWidth: "auto", backgroundColor: grayColor, color: "#FFFFFF", boxShadow: "0 2px 2px 0 rgba(153, 153, 153, 0.14), 0 3px 1px -2px rgba(153, 153, 153, 0.2), 0 1px 5px 0 rgba(153, 153, 153, 0.12)", border: "none", borderRadius: "3px", position: "relative", padding: "12px 30px", margin: ".3125rem 1px", fontSize: "12px", fontWeight: "400", textTransform: "uppercase", letterSpacing: "0", willChange: "box-shadow, transform", transition: "box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1)", lineHeight: "1.42857143", textAlign: "center", whiteSpace: "nowrap", verticalAlign: "middle", touchAction: "manipulation", cursor: "pointer", "&:hover,&:focus": { color: "#FFFFFF", backgroundColor: grayColor, boxShadow: "0 14px 26px -12px rgba(153, 153, 153, 0.42), 0 4px 23px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(153, 153, 153, 0.2)" }, "& .fab,& .fas,& .far,& .fal,& .material-icons": { position: "relative", display: "inline-block", top: "0", fontSize: "1.1rem", marginRight: "4px", verticalAlign: "middle" }, "& svg": { position: "relative", display: "inline-block", top: "0", width: "18px", height: "18px", marginRight: "4px", verticalAlign: "middle" }, "&$justIcon": { "& .fab,& .fas,& .far,& .fal,& .material-icons": { marginRight: "0px", position: "absolute", width: "100%", transform: "none", left: "0px", top: "0px", height: "100%", lineHeight: "41px", fontSize: "20px" } } }, fullWidth: { width: "100%" }, ''' Thank you for helping me :) I hate to lose too much time with styles :'(
Make sure you are importing your CSS file correctly... If so, change your button to something like this. ''' <Button className="buttonW" component={Link} color="success" size="lg" to="/album-carousel-page" > Galeria </Button> ''' Then in your CSS, prefix a period "." before the class name ''' .buttonW { width: "100px", height: "30px"} ''' .. this should work for you.. If all fails, you can then use inline styling as shown below. ''' <Button className="buttonW" style={{height: '30px', width : '100px'}} component={Link} color="success" size="lg" to="/album-carousel-page" > ''' Good luck!
66,990,694
1
66,992,019
I am trying to control a stepper motor, using a A4988 driver along with a Nucleo 144 board with an STM32F767ZI on it. The A4988 driver expects a single rise in voltage to HIGH in order to step the motor. Having made some voltage readings using a multimeter, I have found that during and even while the program is paused, there is a steady voltage of around 1.2V being output by the pin. I also added some lines to toggle an LED (built onto the board) whenever the output to the A4988 driver is toggled between HIGH and LOW, which works fine. Here is the code: main.c ''' #include "./headers/stm32f767xx.h" #include <stdint.h> int main(void) { initMotor(0); initLed(0); uint32_t a = 0; while (1) { if (a >= 300000) { toggleLed(0); stepMotor(0); a = 0; } a++; } } ''' ./drivers/motor.c ''' #include "../headers/stm32f767xx.h" void initMotor(int step_pin) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; // enable GPIOG clock GPIOG->MODER &= ~(0b11 << (step_pin * 2)); // clear bits GPIOG->MODER |= (0b01 << (step_pin * 2)); // set mode to OUTPUT GPIOG->OTYPER &= ~(0b1 << step_pin); // set output type to PUSH-PULL GPIOG->PUPDR |= (0b10 << (step_pin * 2)); // pull the pin down GPIOG->ODR &= ~(0b1 << step_pin); // set output to LOW } void stepMotor(int step_pin) { GPIOG->ODR ^= (0b1 << step_pin); // toggle between LOW and HIGH } ''' ./drivers/led.c ''' #include "../headers/stm32f767xx.h" void initLed(int pin) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; // enable GPIOG clock GPIOB->MODER |= (0b01 << (pin * 2)); // set mode to OUTPUT GPIOB->OTYPER &= ~(0b1 << pin); // set output type to PUSH-PULL GPIOB->ODR &= ~(0b1 << pin); // set output to LOW } void toggleLed(int pin) { GPIOB->ODR ^= (0b1 << pin); // toggle between LOW and HIGH } ''' I've verified, using a multimeter, that the voltage being provided to the board via an STLINK USB is 5V (which I believe is sufficient), and the driver is also receiving the correct voltage of 5V. I do not believe this to be a problem to do with the A4988 driver. I have tried multiple of the same driver from various manufacturers, and still I get the same result. The motors are also being supplied a high enough voltage (12V) but are not drawing it all in. I have come to the conclusion that it is most likely an issue originating from the Nucleo 144 board, but a little stuck as to what the actual issue is. I am using GPIO G pin 0, which is labelled "IO" on the board. Any suggestions as to what I should try next, or ideas as to what it could be, are greatly appreciated. --- As requested, here is a diagram of my setup: <IMAGE>
If you configure the output to be PUSH/PULL, adding a PULLDOWN resistor will divide the output voltage over the resistor. Do not use PU/PD resistors with PP, because it is always driven and doesn't need a PU/PD.
53,814,478
1
53,814,972
I know that there is already sample programs floating around that cover this, but I need to do the towers of hanoi with 6 discs a specific way for an assignment and I'm having trouble. Code I currently have is below: ''' s([],[],[]). initial(s([1,2,3,4,5,6], [], [])). goal(s([],[],[1,2,3,4,5,6])). ''' I also have 26 lines of code to verify valid states, however I tested that code on it's own and it works, the issue I'm having is creating the code to move the discs from stack to stack. An example of what I'm trying to do along with an example query is below: ''' changeState((s([A | B],[],[])), s([C], [D], [])) :- C is B, D is A. ?- changeState((s([1,2,3,4,5,6],[],[])), s([2,3,4,5,6], [1], [])). ''' So this would be the very beginning, where all 6 plates are on the first stack, and I want to move the top plate to the second stack. Essentially, I want to be able to remove the first element from a list, and add it to another list, whether it is empty or not. Got what I needed above working, now I just need help fixing the traverse predicate. Entire code is below: ''' %Post A, Post B, Post C s([],[],[]). initial(s([1,2,3,4,5,6], [], [])). goal(s([],[],[1,2,3,4,5,6])). valid([], _). valid([H|_], X) :- X < H. changeState((s([A|T1], T2, T3)), s(T1, [A|T2], T3)) :- valid(T2, A). changeState((s([A|T1], T2, T3)), s(T1, T2, [A|T3])) :- valid(T3, A). changeState(s(T1, [A|T2], [B|T3]), s(T1, T2, [A,B|T3])) :- valid(A,B). changeState(s([A|T1], T2, [B|T3]), s([B,A|T1], T2, T3)) :- valid(B, A). changeState(s(T1, [A|T2], [B|T3]), s(T1, [B,A|T2], T3)) :- valid(B, A). changeState(s([A|T1], [B|T2], T3), s(T1, [A,B|T2], T3)) :- valid(A,B). changeState(s([A|T1], [B|T2], T3), s([B,A|T1], T2, T3)) :- valid(B,A). changeState(s([A|T1], T2, [B|T3]), s(T1, T2, [A,B|T3])) :- valid(A,B). changeState(s(T1, [A|T2], T3), s(T1, T2, [A|T3])) :- valid(T3, A). changeState(s(T1, [A|T2], T3), s([A|T1], T2, T3)) :- valid(T1, A). changeState(s(T1, T2, [A|T3]), s(T1, [A|T2], T3)) :- valid(T2, A). changeState(s(T1, T2, [A|T3]), s([A|T1], T2, T3)) :- valid(T1, A). traverse(StartNode,Sol,_) :- goal(StartNode), Sol = [StartNode]. traverse(StartNode,Sol,Visit) :- changeState(StartNode, NextNode), not(member(NextNode, Visit)), traverse(NextNode, PartialSol, [NextNode|Visit]), Sol = [StartNode | PartialSol]. ''' When I run this query: ''' ?- traverse((s([1,2,3,4,5,6], [], [])), Sol, s([1,2,3,4,5,6], [], [])). ''' I get this output: <IMAGE> I've left it running after I get those responses for about 10 minutes and it still doesn't produce new ones so it's just continuing to run over and over again. As mentioned above, the point of the program is to solve the Towers of Hanoi problem with 6 discs using Lists. For those not familiar with Towers of Hanoi, you essentially need to move all discs from the first stack, to the last 3rd stack. You can only move 1 disc at a time, and you cannot place a larger disc on-top of a smaller disc. So you start with (s([1,2,3,4,5,6], [], [])) with each list representing Stack A, Stack B, Stack C respectively, and the goal is to end with (s([], [], [1,2,3,4,5,6])). I manually ran through an entire solution (63 moves) through the changeState predicates and all transitions were accepted, so the issue is with the transverse predicate. The transverse predicate is meant to show all steps that lead up to the solution, and all possible solutions. It's also meant to stop cycles, so that it's not just swapping the same 2 discs over and over again. Can't quite figure out what's wrong with my predicates thats causing me to get this output, I'm still fairly new to prolog, so I would appreciate any help!
You can use here instead of 'is/2' (which is typically used to evaluate expressions). For example we can define a move from the first tower to the second tower, given the second tower is empty: ''' changeState((s([A|T1],[], T3)), s(T1, [A], T3)). ''' or we can move an element to the second tower that is non-empty, given the top of the stack is an element that is larger: ''' changeState(s([A|T1], [B|T2], T3), s(T1, [A,B|T2], T3)) :- A < B. ''' The above will result in a total of 12 rules: 3 sources, times 2 destinations times 2 possibilities (empty destination, versus non-empty destination). This is not very elegant. We can construct a helper predicate that checks if the destination stack is valid, with: ''' valid_stack([], _). valid_stack([H|_], X) :- X < H. ''' so then we can compress the two rules above into: ''' changeState((s([A|T1], T2, T3)), s(T1, [A|T2], T3)) :- valid_stack(T2, A). ''' This will thus result in six rules: three sources, and two destinations. We thus no longer need to validate the moves, since if the 'changeState' succeeds, then the proposed move is possible the original state was valid. This is not the full solution however (I leave the rest as an exercise). You will need a mechanism that enumerates over the possible moves, and makes sure that you do not end up in loops (like moving a disc constantly between two towers). After using the 'traverse/3' predicate, we obtain a list of moves to the goal: ''' ?- traverse(s([1,2,3,4,5,6], [], []), S, [s([1,2,3,4,5,6], [], [])]). S = [s([1, 2, 3, 4, 5, 6], [], []), s([2, 3, 4, 5, 6], [1], []), s([3, 4, 5, 6], [1], [2]), s([1, 3, 4, 5|...], [], [2]), s([3, 4, 5|...], [], [1, 2]), s([4, 5|...], [3], [1, 2]), s([1|...], [3], [2]), s([...|...], [...|...], [...]), s(..., ..., ...)|...] [write] S = [s([1, 2, 3, 4, 5, 6], [], []), s([2, 3, 4, 5, 6], [1], []), s([3, 4, 5, 6], [1], [2]), s([1, 3, 4, 5, 6], [], [2]), s([3, 4, 5, 6], [], [1, 2]), s([4, 5, 6], [3], [1, 2]), s([1, 4, 5, 6], [3], [2]), s([4, 5, 6], [1, 3], [2]), s([2, 4, 5, 6], [1, 3], []), s([1, 2, 4, 5, 6], [3], []), s([2, 4, 5, 6], [3], [1]), s([4, 5, 6], [2, 3], [1]), s([1, 4, 5, 6], [2, 3], []), s([4, 5, 6], [1, 2, 3], []), s([5, 6], [1, 2, 3], [4]), s([1, 5, 6], [2, 3], [4]), s([5, 6], [2, 3], [1, 4]), s([2, 5, 6], [3], [1, 4]), s([1, 2, 5, 6], [3], [4]), s([2, 5, 6], [1, 3], [4]), s([5, 6], [1, 3], [2, 4]), s([1, 5, 6], [3], [2, 4]), s([5, 6], [3], [1, 2, 4]), s([3, 5, 6], [], [1, 2, 4]), s([1, 3, 5, 6], [], [2, 4]), s([3, 5, 6], [1], [2, 4]), s([2, 3, 5, 6], [1], [4]), s([1, 2, 3, 5, 6], [], [4]), s([2, 3, 5, 6], [], [1, 4]), s([3, 5, 6], [2], [1, 4]), s([1, 3, 5, 6], [2], [4]), s([3, 5, 6], [1, 2], [4]), s([5, 6], [1, 2], [3, 4]), s([1, 5, 6], [2], [3, 4]), s([5, 6], [2], [1, 3, 4]), s([2, 5, 6], [], [1, 3, 4]), s([1, 2, 5, 6], [], [3, 4]), s([2, 5, 6], [1], [3, 4]), s([5, 6], [1], [2, 3, 4]), s([1, 5, 6], [], [2, 3, 4]), s([5, 6], [], [1, 2, 3, 4]), s([6], [5], [1, 2, 3, 4]), s([1, 6], [5], [2, 3, 4]), s([6], [1, 5], [2, 3, 4]), s([2, 6], [1, 5], [3, 4]), s([1, 2, 6], [5], [3, 4]), s([2, 6], [5], [1, 3, 4]), s([6], [2, 5], [1, 3, 4]), s([1, 6], [2, 5], [3, 4]), s([6], [1, 2, 5], [3, 4]), s([3, 6], [1, 2, 5], [4]), s([1, 3, 6], [2, 5], [4]), s([3, 6], [2, 5], [1, 4]), s([2, 3, 6], [5], [1, 4]), s([1, 2, 3, 6], [5], [4]), s([2, 3, 6], [1, 5], [4]), s([3, 6], [1, 5], [2, 4]), s([1, 3, 6], [5], [2, 4]), s([3, 6], [5], [1, 2, 4]), s([6], [3, 5], [1, 2, 4]), s([1, 6], [3, 5], [2, 4]), s([6], [1, 3, 5], [2, 4]), s([2, 6], [1, 3, 5], [4]), s([1, 2, 6], [3, 5], [4]), s([2, 6], [3, 5], [1, 4]), s([6], [2, 3, 5], [1, 4]), s([1, 6], [2, 3, 5], [4]), s([6], [1, 2, 3, 5], [4]), s([4, 6], [1, 2, 3, 5], []), s([1, 4, 6], [2, 3, 5], []), s([4, 6], [2, 3, 5], [1]), s([2, 4, 6], [3, 5], [1]), s([1, 2, 4, 6], [3, 5], []), s([2, 4, 6], [1, 3, 5], []), s([4, 6], [1, 3, 5], [2]), s([1, 4, 6], [3, 5], [2]), s([4, 6], [3, 5], [1, 2]), s([3, 4, 6], [5], [1, 2]), s([1, 3, 4, 6], [5], [2]), s([3, 4, 6], [1, 5], [2]), s([2, 3, 4, 6], [1, 5], []), s([1, 2, 3, 4, 6], [5], []), s([2, 3, 4, 6], [5], [1]), s([3, 4, 6], [2, 5], [1]), s([1, 3, 4, 6], [2, 5], []), s([3, 4, 6], [1, 2, 5], []), s([4, 6], [1, 2, 5], [3]), s([1, 4, 6], [2, 5], [3]), s([4, 6], [2, 5], [1, 3]), s([2, 4, 6], [5], [1, 3]), s([1, 2, 4, 6], [5], [3]), s([2, 4, 6], [1, 5], [3]), s([4, 6], [1, 5], [2, 3]), s([1, 4, 6], [5], [2, 3]), s([4, 6], [5], [1, 2, 3]), s([6], [4, 5], [1, 2, 3]), s([1, 6], [4, 5], [2, 3]), s([6], [1, 4, 5], [2, 3]), s([2, 6], [1, 4, 5], [3]), s([1, 2, 6], [4, 5], [3]), s([2, 6], [4, 5], [1, 3]), s([6], [2, 4, 5], [1, 3]), s([1, 6], [2, 4, 5], [3]), s([6], [1, 2, 4, 5], [3]), s([3, 6], [1, 2, 4, 5], []), s([1, 3, 6], [2, 4, 5], []), s([3, 6], [2, 4, 5], [1]), s([2, 3, 6], [4, 5], [1]), s([1, 2, 3, 6], [4, 5], []), s([2, 3, 6], [1, 4, 5], []), s([3, 6], [1, 4, 5], [2]), s([1, 3, 6], [4, 5], [2]), s([3, 6], [4, 5], [1, 2]), s([6], [3, 4, 5], [1, 2]), s([1, 6], [3, 4, 5], [2]), s([6], [1, 3, 4, 5], [2]), s([2, 6], [1, 3, 4, 5], []), s([1, 2, 6], [3, 4, 5], []), s([2, 6], [3, 4, 5], [1]), s([6], [2, 3, 4, 5], [1]), s([1, 6], [2, 3, 4, 5], []), s([6], [1, 2, 3, 4, 5], []), s([], [1, 2, 3, 4, 5], [6]), s([1], [2, 3, 4, 5], [6]), s([], [2, 3, 4, 5], [1, 6]), s([2], [3, 4, 5], [1, 6]), s([1, 2], [3, 4, 5], [6]), s([2], [1, 3, 4, 5], [6]), s([], [1, 3, 4, 5], [2, 6]), s([1], [3, 4, 5], [2, 6]), s([], [3, 4, 5], [1, 2, 6]), s([3], [4, 5], [1, 2, 6]), s([1, 3], [4, 5], [2, 6]), s([3], [1, 4, 5], [2, 6]), s([2, 3], [1, 4, 5], [6]), s([1, 2, 3], [4, 5], [6]), s([2, 3], [4, 5], [1, 6]), s([3], [2, 4, 5], [1, 6]), s([1, 3], [2, 4, 5], [6]), s([3], [1, 2, 4, 5], [6]), s([], [1, 2, 4, 5], [3, 6]), s([1], [2, 4, 5], [3, 6]), s([], [2, 4, 5], [1, 3, 6]), s([2], [4, 5], [1, 3, 6]), s([1, 2], [4, 5], [3, 6]), s([2], [1, 4, 5], [3, 6]), s([], [1, 4, 5], [2, 3, 6]), s([1], [4, 5], [2, 3, 6]), s([], [4, 5], [1, 2, 3, 6]), s([4], [5], [1, 2, 3, 6]), s([1, 4], [5], [2, 3, 6]), s([4], [1, 5], [2, 3, 6]), s([2, 4], [1, 5], [3, 6]), s([1, 2, 4], [5], [3, 6]), s([2, 4], [5], [1, 3, 6]), s([4], [2, 5], [1, 3, 6]), s([1, 4], [2, 5], [3, 6]), s([4], [1, 2, 5], [3, 6]), s([3, 4], [1, 2, 5], [6]), s([1, 3, 4], [2, 5], [6]), s([3, 4], [2, 5], [1, 6]), s([2, 3, 4], [5], [1, 6]), s([1, 2, 3, 4], [5], [6]), s([2, 3, 4], [1, 5], [6]), s([3, 4], [1, 5], [2, 6]), s([1, 3, 4], [5], [2, 6]), s([3, 4], [5], [1, 2, 6]), s([4], [3, 5], [1, 2, 6]), s([1, 4], [3, 5], [2, 6]), s([4], [1, 3, 5], [2, 6]), s([2, 4], [1, 3, 5], [6]), s([1, 2, 4], [3, 5], [6]), s([2, 4], [3, 5], [1, 6]), s([4], [2, 3, 5], [1, 6]), s([1, 4], [2, 3, 5], [6]), s([4], [1, 2, 3, 5], [6]), s([], [1, 2, 3, 5], [4, 6]), s([1], [2, 3, 5], [4, 6]), s([], [2, 3, 5], [1, 4, 6]), s([2], [3, 5], [1, 4, 6]), s([1, 2], [3, 5], [4, 6]), s([2], [1, 3, 5], [4, 6]), s([], [1, 3, 5], [2, 4, 6]), s([1], [3, 5], [2, 4, 6]), s([], [3, 5], [1, 2, 4, 6]), s([3], [5], [1, 2, 4, 6]), s([1, 3], [5], [2, 4, 6]), s([3], [1, 5], [2, 4, 6]), s([2, 3], [1, 5], [4, 6]), s([1, 2, 3], [5], [4, 6]), s([2, 3], [5], [1, 4, 6]), s([3], [2, 5], [1, 4, 6]), s([1, 3], [2, 5], [4, 6]), s([3], [1, 2, 5], [4, 6]), s([], [1, 2, 5], [3, 4, 6]), s([1], [2, 5], [3, 4, 6]), s([], [2, 5], [1, 3, 4, 6]), s([2], [5], [1, 3, 4, 6]), s([1, 2], [5], [3, 4, 6]), s([2], [1, 5], [3, 4, 6]), s([], [1, 5], [2, 3, 4, 6]), s([1], [5], [2, 3, 4, 6]), s([], [5], [1, 2, 3, 4, 6]), s([5], [], [1, 2, 3, 4, 6]), s([1, 5], [], [2, 3, 4, 6]), s([5], [1], [2, 3, 4, 6]), s([2, 5], [1], [3, 4, 6]), s([1, 2, 5], [], [3, 4, 6]), s([2, 5], [], [1, 3, 4, 6]), s([5], [2], [1, 3, 4, 6]), s([1, 5], [2], [3, 4, 6]), s([5], [1, 2], [3, 4, 6]), s([3, 5], [1, 2], [4, 6]), s([1, 3, 5], [2], [4, 6]), s([3, 5], [2], [1, 4, 6]), s([2, 3, 5], [], [1, 4, 6]), s([1, 2, 3, 5], [], [4, 6]), s([2, 3, 5], [1], [4, 6]), s([3, 5], [1], [2, 4, 6]), s([1, 3, 5], [], [2, 4, 6]), s([3, 5], [], [1, 2, 4, 6]), s([5], [3], [1, 2, 4, 6]), s([1, 5], [3], [2, 4, 6]), s([5], [1, 3], [2, 4, 6]), s([2, 5], [1, 3], [4, 6]), s([1, 2, 5], [3], [4, 6]), s([2, 5], [3], [1, 4, 6]), s([5], [2, 3], [1, 4, 6]), s([1, 5], [2, 3], [4, 6]), s([5], [1, 2, 3], [4, 6]), s([4, 5], [1, 2, 3], [6]), s([1, 4, 5], [2, 3], [6]), s([4, 5], [2, 3], [1, 6]), s([2, 4, 5], [3], [1, 6]), s([1, 2, 4, 5], [3], [6]), s([2, 4, 5], [1, 3], [6]), s([4, 5], [1, 3], [2, 6]), s([1, 4, 5], [3], [2, 6]), s([4, 5], [3], [1, 2, 6]), s([3, 4, 5], [], [1, 2, 6]), s([1, 3, 4, 5], [], [2, 6]), s([3, 4, 5], [1], [2, 6]), s([2, 3, 4, 5], [1], [6]), s([1, 2, 3, 4, 5], [], [6]), s([2, 3, 4, 5], [], [1, 6]), s([3, 4, 5], [2], [1, 6]), s([1, 3, 4, 5], [2], [6]), s([3, 4, 5], [1, 2], [6]), s([4, 5], [1, 2], [3, 6]), s([1, 4, 5], [2], [3, 6]), s([4, 5], [2], [1, 3, 6]), s([2, 4, 5], [], [1, 3, 6]), s([1, 2, 4, 5], [], [3, 6]), s([2, 4, 5], [1], [3, 6]), s([4, 5], [1], [2, 3, 6]), s([1, 4, 5], [], [2, 3, 6]), s([4, 5], [], [1, 2, 3, 6]), s([5], [4], [1, 2, 3, 6]), s([1, 5], [4], [2, 3, 6]), s([5], [1, 4], [2, 3, 6]), s([2, 5], [1, 4], [3, 6]), s([1, 2, 5], [4], [3, 6]), s([2, 5], [4], [1, 3, 6]), s([5], [2, 4], [1, 3, 6]), s([1, 5], [2, 4], [3, 6]), s([5], [1, 2, 4], [3, 6]), s([3, 5], [1, 2, 4], [6]), s([1, 3, 5], [2, 4], [6]), s([3, 5], [2, 4], [1, 6]), s([2, 3, 5], [4], [1, 6]), s([1, 2, 3, 5], [4], [6]), s([2, 3, 5], [1, 4], [6]), s([3, 5], [1, 4], [2, 6]), s([1, 3, 5], [4], [2, 6]), s([3, 5], [4], [1, 2, 6]), s([5], [3, 4], [1, 2, 6]), s([1, 5], [3, 4], [2, 6]), s([5], [1, 3, 4], [2, 6]), s([2, 5], [1, 3, 4], [6]), s([1, 2, 5], [3, 4], [6]), s([2, 5], [3, 4], [1, 6]), s([5], [2, 3, 4], [1, 6]), s([1, 5], [2, 3, 4], [6]), s([5], [1, 2, 3, 4], [6]), s([], [1, 2, 3, 4], [5, 6]), s([1], [2, 3, 4], [5, 6]), s([], [2, 3, 4], [1, 5, 6]), s([2], [3, 4], [1, 5, 6]), s([1, 2], [3, 4], [5, 6]), s([2], [1, 3, 4], [5, 6]), s([], [1, 3, 4], [2, 5, 6]), s([1], [3, 4], [2, 5, 6]), s([], [3, 4], [1, 2, 5, 6]), s([3], [4], [1, 2, 5, 6]), s([1, 3], [4], [2, 5, 6]), s([3], [1, 4], [2, 5, 6]), s([2, 3], [1, 4], [5, 6]), s([1, 2, 3], [4], [5, 6]), s([2, 3], [4], [1, 5, 6]), s([3], [2, 4], [1, 5, 6]), s([1, 3], [2, 4], [5, 6]), s([3], [1, 2, 4], [5, 6]), s([], [1, 2, 4], [3, 5, 6]), s([1], [2, 4], [3, 5, 6]), s([], [2, 4], [1, 3, 5, 6]), s([2], [4], [1, 3, 5, 6]), s([1, 2], [4], [3, 5, 6]), s([2], [1, 4], [3, 5, 6]), s([], [1, 4], [2, 3, 5, 6]), s([1], [4], [2, 3, 5, 6]), s([], [4], [1, 2, 3, 5, 6]), s([4], [], [1, 2, 3, 5, 6]), s([1, 4], [], [2, 3, 5, 6]), s([4], [1], [2, 3, 5, 6]), s([2, 4], [1], [3, 5, 6]), s([1, 2, 4], [], [3, 5, 6]), s([2, 4], [], [1, 3, 5, 6]), s([4], [2], [1, 3, 5, 6]), s([1, 4], [2], [3, 5, 6]), s([4], [1, 2], [3, 5, 6]), s([3, 4], [1, 2], [5, 6]), s([1, 3, 4], [2], [5, 6]), s([3, 4], [2], [1, 5, 6]), s([2, 3, 4], [], [1, 5, 6]), s([1, 2, 3, 4], [], [5, 6]), s([2, 3, 4], [1], [5, 6]), s([3, 4], [1], [2, 5, 6]), s([1, 3, 4], [], [2, 5, 6]), s([3, 4], [], [1, 2, 5, 6]), s([4], [3], [1, 2, 5, 6]), s([1, 4], [3], [2, 5, 6]), s([4], [1, 3], [2, 5, 6]), s([2, 4], [1, 3], [5, 6]), s([1, 2, 4], [3], [5, 6]), s([2, 4], [3], [1, 5, 6]), s([4], [2, 3], [1, 5, 6]), s([1, 4], [2, 3], [5, 6]), s([4], [1, 2, 3], [5, 6]), s([], [1, 2, 3], [4, 5, 6]), s([1], [2, 3], [4, 5, 6]), s([], [2, 3], [1, 4, 5, 6]), s([2], [3], [1, 4, 5, 6]), s([1, 2], [3], [4, 5, 6]), s([2], [1, 3], [4, 5, 6]), s([], [1, 3], [2, 4, 5, 6]), s([1], [3], [2, 4, 5, 6]), s([], [3], [1, 2, 4, 5, 6]), s([3], [], [1, 2, 4, 5, 6]), s([1, 3], [], [2, 4, 5, 6]), s([3], [1], [2, 4, 5, 6]), s([2, 3], [1], [4, 5, 6]), s([1, 2, 3], [], [4, 5, 6]), s([2, 3], [], [1, 4, 5, 6]), s([3], [2], [1, 4, 5, 6]), s([1, 3], [2], [4, 5, 6]), s([3], [1, 2], [4, 5, 6]), s([], [1, 2], [3, 4, 5, 6]), s([1], [2], [3, 4, 5, 6]), s([], [2], [1, 3, 4, 5, 6]), s([2], [], [1, 3, 4, 5, 6]), s([1, 2], [], [3, 4, 5, 6]), s([2], [1], [3, 4, 5, 6]), s([], [1], [2, 3, 4, 5, 6]), s([1], [], [2, 3, 4, 5, 6]), s([], [], [1, 2, 3, 4, 5, 6])] ''' In SWI-Prolog, one needs to hit you ask the interactive shell to <URL>.
17,742,725
1
17,742,861
In my app using coredata i have an entity with two attributes (numerical value), (NSdate)). The user in one tableview can enter these two values each day and they are recorded with a fetch controller. For more understanding here is a screenshot of the concerned with the issue: <IMAGE> Th is where the user adds a new value and when user clicks on any of the two fields in the static tableview, he is redirected to the view for editing. What I would like to do is to check the entered by the user and display a warning(could be an alert message or in this case the footer message that would show or pop up whenever the new entered value is less than a previous value entered in a different day(a previous stored value of RecordingDate(the NSdate input attribute from CoreData model). if the current user enters: Zahlerstand = and Datum: , and in a previous record the values were: Zahlerstand = and Datum: then we see than on successive dates. In this case a should be displayed(as in the tableview section footer. before he can click on "save" button in the . Please help with some sample code if possible. Thank you in advance,
Use NSComparisonResult for comparing older date to newer date as : ''' compare: method returns an NSComparisonResult value that indicates the temporal ordering of the receiver and another given date. - (NSComparisonResult)compare:(NSDate *)anotherDate switch ([olderDate compare:newDate]) { case NSOrderedAscending: // olderDate is earlier in time than newDate break; case NSOrderedSame: // Both dates are same break; case NSOrderedDescending: // olderDate is later in time than newDate break; } '''
17,264,395
1
17,265,120
I'm trying to make a CSS menu with submenus. When I move the mouse over a child element of list, I want the submenu to appear inside that child if there is any. <IMAGE> As it is avaliable to see above, sub menu appears but I don't want that to happen when I move the cursor over the areas that I've marked with circles. These are padding areas. Here's my markup: ''' <ul> <li><a href="/home">Home</a></li> <li><a href="#">About Us</a> <ul> <li><a href="/mission">Our Mission</a></li> <li><a href="/vision">Our Vision</a></li> </ul> </li> </ul> ''' And this is the CSS: ''' a { color: #000; text-decoration: none; } a:hover { color: #A0A0A0; } ul > li { float: left; padding: 0px 30px; list-style-type: none; margin: 0px 5px; background-color: #CACACA; } ul > li:hover > ul { display: inline; } ul > li > ul { position: fixed; display: none; } ''' Now there is no problem with this code. As you can see in <URL>, it works as I wanted, the submenu appears when I move the mouse over the "About Us" menu. However, my problem here is that there are blank spaces(padding) inside menu items and the submenu appears even if I hover over these spaces. But I want the submenu to appear only when I hover the '<a>' element inside the '<li>'. To accomplish this, I tried that code: ''' ul > li > a:hover > ul { display: inline; } ''' instead of the existing: ''' ul > li:hover > ul { display: inline; } ''' but it didn't work, I wasn't expecting since the '<a>' and '<ul>' are the children of the very same '<li>' element. I'm creating a template for a CMS, so I don't want to get involved with jQuery implementations too much, like setting 'id's or 'class'es for list elements. I want to make an implementation with pure CSS. And I will be using seperating images between list elements, so I must use 'padding' instead of 'margin'. If I was using 'margin', it would be easy since the 'width' of the list element would be same with the '<a>' element's 'width'. But here, after all these exceptions, I need some help. Any ideas are highly appreciated. Thanks in advance.
This is possible, but only-just, and with some fairly severe caveats; first the CSS to hide/show the sub-menu: ''' ul > li > ul { position: fixed; opacity: 0; -moz-transition: opacity 1s linear; -ms-transition: opacity 1s linear; -o-transition: opacity 1s linear; -webkit-transition: opacity 1s linear; transition: opacity 1s linear; } ul > li a:hover + ul, ul > li:hover a + ul:hover{ opacity: 1; -moz-transition: opacity 1s linear; -ms-transition: opacity 1s linear; -o-transition: opacity 1s linear; -webkit-transition: opacity 1s linear; transition: opacity 1s linear; } ''' <URL>. Now, the caveats: 1. The display property won't animate (it can't, there's no interim states between none and inline-block (or between any other valid values for the property), so the sub-menu always has to be 'visible'/'present' on the page (albeit with an opacity of 0 hiding it in most browsers). 2. The transitions are necessary, because that's the only way that the cursor would have time to move from the a link to the ul without it immediately hiding; the transition is, basically, a time-delay to allow the second of the selectors, ul > li:hover a + ul:hover to match. 3. cross-browser compatibility is likely to be a problem, since transitions aren't supported in Internet Explorer < 10, mind you nor is opacity until version 9. 4. The major problem, though, is selector specificity. It's going to be rather difficult to write the selectors for arbitrary-depth menus using this technique. So, while it's possible, I certainly wouldn't recommend using this approach, as it seems far too prone to failure.
21,704,159
1
21,707,901
i'm writing an app that changes an image through different conditions. When i debug everything is set but i do not see the image on my screen. Can anybody please help me? ''' -(void)setLuminanceImageSource { self.luminanceImageView.image = nil; UIImage *image; switch (self.luminanceImageSource) { case FULL_LIGHT: image = [UIImage imageNamed:@"belichting-goed"]; [self.luminanceImageView setImage:image]; NSLog(@"full"); break; case HALF_LIGHT: image = [UIImage imageNamed:@"belichting-matig"]; [self.luminanceImageView setImage:image]; NSLog(@"half"); break; case BAD_LIGHT: image= [UIImage imageNamed:@"belichting-slecht"]; [self.luminanceImageView setImage:image]; NSLog(@"bad"); break; default: image = [UIImage imageNamed:@"belichting-goed"]; break; } [self.luminanceImageView setImage:image]; [self.luminanceImageView setNeedsDisplay]; [self.view addSubview:self.luminanceImageView]; [self.view bringSubviewToFront:self.luminanceImageView]; } ''' This is my method that controls the image. I have an UIImageView in the .xib file and when i run the app i see the image i have selected in attribute inspector, but it disappears when this method is called. EDIT: I have changed the names to the conventional naming style. This is my debug-console, the image object is not nil but the 'luminanceImageView' stays 'nil'. <IMAGE> I have created a github repository where i cloned my project in so you can see my code. <URL> Only difference is the location of the luminaceImageView, now it is located in the middle of the screen so i can be sure that it is in view of the device.
You say that: > the image object is not nil but the luminanceImageView stays nil. Of course, you need to create the image view first, before you can set its image. The easiest in your case is probably to create it and set its image in one go, and then add it to your view: ''' self.luminanceImageView = [[UIImageView alloc] initWithImage:image]; [self.view addSubview:self.luminanceImageView]; ''' EDIT (after looking at the GitHub): You currently set the view like this: ''' self.luminanceImageView = [[UIImageView alloc] init]; [self.luminanceImageView setImage:image]; ''' That means that if you set it in the xib (I have not checked that), then you override it here. There are three problems with this: 1. the luminanceImageView still needs to be added to your view, as I already stated above 2. the plain init creates an imageView with size (0, 0). This is unlike the initWithImage:, which creates a imageView with the size of the image. 3. the setImage: does not resize the imageView. From the UIWebView documentation: > Setting the image property does not change the size of a UIImageView. Call sizeToFit to adjust the size of the view to match the image. If you have correctly set the imageView with its size in the XIB, then leave out everything else and just do: ''' [self.luminanceImageView setImage:image]; ''' If the size is not correct, then follow this with: ''' [self.luminanceImageView sizeToFit]; ''' EDIT (after debugging the code): Your problem is that you set the image from a background thread. Almost all view operation in iOS need to be done from the main thread. Doing like this solves your problem: ''' dispatch_async(dispatch_get_main_queue(), ^{ [self.luminanceImageView setImage:image]; [self.view bringSubviewToFront:self.luminanceImageView]; }); ''' BTW, you also change self.layer in your code. That is probably not a good idea and may lead to problems later. Use a separate view for the camera, and use [cameraView.layer addSublayer:newLayer] to get around that.
53,292,705
1
53,292,802
I am newbie in C. I do not know why I am getting this error and how to fix it? ''' void FPS_PRINT_ENROLLED(){ int checkNum = 0; int ID = 0; int num_Enroll = 0; num_Enroll = Available_ID(); char strNum[3] = 0; itoa(num_Enroll, strNum); uint32_t numLen = strlen((char *)strNum); UART_send_A3("Number of Stored Prints: ", 25); UART_send_A3(&strNum, numLen); } ''' The error message is: 'array initializer must be an initializer list or string literal' Please see the attached screenshot of the error message. Also, the c file is attached. <IMAGE> By the way, this is in PSoC Creator 4.1 which uses C language. <URL>
''' char strNum[3] = 0; ''' This line creates a three character string. You then use it as a string with the function strlen and the uart_send. As a C string it must be terminated with a null character, so you only have two usable characters. It must also be initialised as a string, the compiler is telling you that you haven't done this correctly. Try something like one of these lines ''' char strNum[3] = ""; // Empty string char strNum[3] = "AB"; // Full string char strNum[3] = "0"; // String holding the character zero '''
71,778,913
1
71,779,185
I have a problem, where I need a BasicTextField to customize the TextField as I want. Here I have tried to do a custom, but there is a problem with the cursor in the BasicTextField, it doesn't center align, what I need is center alignment Screen <URL>. <IMAGE> i code like this ''' BasicTextField( value = value, onValueChange = onValueChange, decorationBox = { innerTextField -> Column( modifier = Modifier .fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally ) { innerTextField() Space(height = 8.dp) Divider() } } ) '''
You can apply 'textAlign = TextAlign.Center' to the 'textStyle' attribute in the 'BasicTextField'. Something like: ''' BasicTextField( value = text, onValueChange = { text = it }, textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center), decorationBox = { innerTextField -> Column( modifier = Modifier .fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally ) { innerTextField() Spacer(modifier = Modifier.height(8.dp)) Divider() } } ) '''
10,569,499
1
10,569,660
<IMAGE> Is it OK to use multiple inheritance if one parent class is an interface (only contains pure virtual functions with virtual destructor)? I want to expose only interface part (yellow class in the picture) to increase compile speed. Green part is implementation part. But CPet should inherit from CAnimal(is-a relation) and IPet(implement), there are "Diamond of Death" :( Interface classes (in yellow) only have pure virtual functions and virtual destruction, so when I create CDog, CCat through factory class, there are no problem like ambiguity. CDog has two vtables (from IDog and CPet) but in the virtual function tables, the points indicate same function (CDog member functions). There's no compile error, no running error... but I'm worry about this hierarchy. Is it OK or are there any problems? PS : I don't want to use 'virtual inheritance' because if I use that, I can't look into class member variable through watch view.(I guess it is because virtual inheritance link to parent class like linked-list.) Environment : Visual Studio C++ 2008 or over.
Given the description above, you should not be able instantiate an instance of 'CPet' because the pure virtual function 'IAnimal::isAlive()' is undefined in the 'IPet' vtable. ''' struct IAnimal { virtual ~IAnimal() {} virtual void isAlive() = 0; }; struct IPet : public IAnimal { }; struct CAnimal : public IAnimal { virtual void isAlive() { } }; struct CPet : public CAnimal, public IPet { }; int main(void) { CPet cp; } ''' Produces the following when compiled with Visual C++ 2008 & 2010: ''' animal.cpp(18) : error C2259: 'CPet' : cannot instantiate abstract class due to following members: 'void IAnimal::isAlive(void)' : is abstract mytest.cpp(5) : see declaration of 'IAnimal::isAlive' ''' GCC produces a similiar warning: ''' animal.cpp: In function 'int main()': animal.cpp:18:7: error: cannot declare variable 'cp' to be of abstract type 'CPet' animal.cpp:14:8: note: because the following virtual functions are pure within 'CPet': animal.cpp:3:15: note: virtual void IAnimal::isAlive() '''
28,166,778
1
28,193,425
I am currently adding a SOAP-WSDL Service to my project using "Add Service Reference". it creates all necessary classes and functions for me to call. Some of these functions dont give me a response. After 1 minute delay i get a timeout exception. However when i forge the request using Postman (a chrome extension for making network requests) it gets full response. i got suspicious and started to inspect network using Wireshark. after inspection i saw that problem was at the service. but i can't make them fix that. so i need to imitate Postman request using C#. Main difference between mine and postman is, Postman posts all necessary data in single request for a response, but my client posts just http headers waits for a Http Continue and continues sending necessary data. i guess this breaks the service. Here are wireshark screenshots for Postman and my client (Postman is on the left of image and right one is my .net client - sorry for my perfect paint skills) <IMAGE> Is there any configuration on .net wsdl client with basicHttpBinding i can configure to make single request for a call? edit: when i further investigated my C# client i saw that .net http layer send an initial POST with saying (Expect: 100 Continue), after it receives continue it continues to send SOAP Envelope edit2: i changed my code to issue request using HttpWebRequest, but .net still sends header and post body with seperate requests (even when i disabled Expect: 100 Continue) and in my theory this breaks service. question2: is there anyway to say HttpWebRequest, don't split header and body? send all of them in single request? edit3: i solved the problem. but it wasn't about 100 Continue. service was being broken because of missing User-Agent Header
i finally solved the problem. after long inspections and tries i saw that remote service stops responding in the middle of the data communication if i dont add User-Agent HTTP Header. so i added http header using IClientMessageInspector before every request here is wcf code if anybody needs it ''' public object BeforeSendRequest(ref Message request, IClientChannel channel) { HttpRequestMessageProperty realProp; object property; //check if this property already exists if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out property)) { realProp = (HttpRequestMessageProperty) property; if (string.IsNullOrEmpty(realProp.Headers["User-Agent"])) //don't modify if it is already set { realProp.Headers["User-Agent"] = "doktorinSM/2.1"; } return null; } realProp = new HttpRequestMessageProperty(); realProp.Headers["User-Agent"] = "doktorinSM/2.1"; request.Properties.Add(HttpRequestMessageProperty.Name, realProp); return null; } '''
44,055,142
1
44,055,814
I want to change HSV value of my image. I wrote code below. Unfortunatelly I got that result when I do that: <IMAGE> Is it okay or what I am doing wrong? If you have any question, please write to me. I hope you know what I mean. Thanks! ''' #include "widget.h" #include "ui_widget.h" #include <iostream> #include <stdlib.h> #include <math.h> using namespace std; Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { image = QImage("D:/Pobrane/Grafika/Hsv (dla obrazka)/1.jpg"); imagee = QImage("D:/Pobrane/Grafika/Hsv (dla obrazka)/1.jpg"); bits = image.bits(); bitss = imagee.bits(); ui->setupUi(this); h=s=v=0; } Widget::~Widget() { delete ui; } void Widget::paintEvent(QPaintEvent*) { QPainter p(this); QImage pix(bitss, 600, 600, QImage::Format_RGB32); p.drawImage(0,0,pix); } void Widget::on_H_slider_valueChanged(int value) { update(); h=value; imagee=image; for(int i=0; i<imagee.width(); i++) { for(int j=0; j<imagee.height(); j++) { QColor color = imagee.pixelColor(i,j); if (s!=0 && v!=0) color.setHsv(h, s, v, color.alpha()); else if (s!=0) color.setHsv(h, s, color.value(), color.alpha()); else if (v!=0) color.setHsv(h, color.saturation(), v, color.alpha()); else color.setHsv(h, color.saturation(), color.value(), color.alpha()); imagee.setPixelColor(i, j, color); } } } void Widget::on_S_slider_valueChanged(int value) { update(); s=value; imagee=image; for(int i=0; i<imagee.width(); i++) { for(int j=0; j<imagee.height(); j++) { QColor color = imagee.pixelColor(i,j); if (h!=0 && v!=0) color.setHsv(h, s, v, color.alpha()); else if (h!=0) color.setHsv(h, s, color.value(), color.alpha()); else if (v!=0) color.setHsv(color.hue(), s, v, color.alpha()); else color.setHsv(color.hue(), s, color.value(), color.alpha()); imagee.setPixelColor(i, j, color); } } } void Widget::on_V_slider_valueChanged(int value) { update(); v=value; imagee=image; for(int i=0; i<imagee.width(); i++) { for(int j=0; j<imagee.height(); j++) { QColor color = imagee.pixelColor(i,j); if (h!=0 && s!=0) color.setHsv(h, s, v, color.alpha()); else if (h!=0) color.setHsv(h, color.saturation(), v, color.alpha()); else if (s!=0) color.setHsv(color.hue(), s, v, color.alpha()); else color.setHsv(color.hue(), color.saturation(), v, color.alpha()); imagee.setPixelColor(i, j, color); } } } '''
I have experienced this before. My mistake was I was always modifying the output image. Make sure that 'image' is always untouched. All the work should be done on 'image2'. The output should also be 'image2' You can basically connect all your 'valueChanged()' signal to one slot 'onSliderValueChanged(value)'. Pseudocode: ''' function onSliderValueChanged(value) h = get H slider value s = get S slider value v = get V slider value image2 = image for i = 0 to image2.width - 1 for j = 0 to image2.height - 1 if h != 0 and s != 0 and v != 0 // set image2 pixel color color = QColor::fromHSV(h, s, v) image2.setPixel(i, j, color) ''' Every slider movement, 'image2' should always be equal to 'image' at first. Then make the necessary pixel manipulations on image2.
23,553,331
1
23,553,391
I'm trying to make conway's game of life in python using pygame. I can't figure out why but the patterns its generating are way off. I've looked through the code a million times and I can't see whats wrong. Here is a screenshot of one of the generations <IMAGE> And here is the complete code of the game. ''' import pygame, sys from pygame.locals import * from random import randint import numpy #inititalize pygame.init() clock = pygame.time.Clock() #constants FPS = 10 BLACK = (0,0,0) RED = (255,0,0) GREY = (30,30,30) SCREENX = 640 SCREENY = 480 CELLSIZE = 10 HEIGHT = SCREENY/CELLSIZE WIDTH = SCREENX/CELLSIZE #set up window window = pygame.display.set_mode((SCREENX, SCREENY)) pygame.display.set_caption('Game of Life') window.fill(BLACK) #generate random seed cells = numpy.zeros((WIDTH,HEIGHT), dtype=numpy.int) for x in range(0,WIDTH): for y in range(0,HEIGHT): #0 is a dead cell, 1 is an alive cell cells[x][y] = randint(0,1) def findNeighbors(grid, x, y): if 0 < x < len(grid) - 1: xi = (0, -1, 1) elif x > 0: xi = (0, -1) else: xi = (0, 1) if 0 < y < len(grid[0]) - 1: yi = (0, -1, 1) elif y > 0: yi = (0, -1) else: yi = (0, 1) for a in xi: for b in yi: if a == b == 0: continue yield grid[x + a][y + b] def update(grid, x, y): #determine num of living neighbors neighbors = findNeighbors(cells,x,y) alive = 0 for i in neighbors: if i == 1: alive+=1 #if current cell is alive if grid[x][y] == 1: #kill if less than 2 or more than 3 alive neighbors if (alive < 2) or (alive > 3): return 0 else: return 1 #if current cell is dead elif grid[x][y] == 0: #make alive if 3 alive neighbors if alive == 3: return 1 else: return 0 #main loop while True: #check if user wants to exit for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() #update cells for x in range(0,WIDTH): for y in range(0,HEIGHT): cells[x][y] = update(cells,x,y) #draw grid for x in range(0,SCREENX,CELLSIZE): for y in range(0,SCREENY,CELLSIZE): #if cell is alive if cells[x/CELLSIZE][y/CELLSIZE] == 1: #draw red square pygame.draw.rect(window, RED, [x, y, CELLSIZE, CELLSIZE]) else: #draw black square pygame.draw.rect(window, BLACK, [x, y, CELLSIZE, CELLSIZE]) #draw square border pygame.draw.rect(window, GREY, [x, y, CELLSIZE, CELLSIZE], 1) #draw updates pygame.display.update() #generations per second clock.tick(FPS) ''' I don't think the problem is with the findNeighbors function since I got it from <URL> stackoverflow answer. So I assume the problem is in the update function but I can't see where the logic is wrong based on the game rules.
I suspect this is the problem: ''' cells[x][y] = update(cells,x,y) ''' You've only got grid, which you're updating . Generation n+1 should only take account of information from generation n - whereas currently you've got a mixture of information from n and n+1. You'll end up with the values of the neighbours above and to the left of you, and the values of the neighbours to the right and below you, because they haven't been recomputed yet. So for example, take this pattern (where # means "alive"): ''' ... ### ... ''' That go to: ''' .#. .#. .#. ''' ... but in fact, you'll end up with (I think): ''' .## #.# ... // Bottom-middle only has one live neighbour at computation time ''' By the time we compute top right, it has three neighbours. The left-middle has 2 live neighbours at computation time; the centre has 4, and the right-middle has 2. Nothing on the bottom row has three neighbours by the time it's computed, so it stays dead. Typically a Conway's Life implementation will either compute an entirely new grid for each generation, or it will flip between two grids, computing all of one from the other.
24,472,035
1
24,472,096
''' Object Value ''' <IMAGE> Above is the evaluate expression in Intellij of an Object field. I want to access both key and value but unable to do so.
You need to <URL> over your list, here is an example ''' public static void main(String[] args){ List<LinkedHashMap<String,String>> list = new ArrayList<LinkedHashMap<String, String>>(); LinkedHashMap<String, String> test = new LinkedHashMap<String, String>(); test.put("a","1"); test.put("b","2"); list.add(test); for(Map<String, String> map : list){ for(String key : map.keySet()){ System.out.println("key: " + key + " value " + map.get(key)); } } } '''
4,887,456
1
4,888,128
In the application that I'm working on right now, I need to periodically check eligibility of tens of thousands of objects for some kind of a service. The decision diagram itself is in the following form, just way larger: <IMAGE> In each of the end nodes (circles), I need to run an action (change an object's field, log information etc). I tried using Drool Expert framework, but in that case I'd need to write a long rule for every path in the diagram leading to an end node. Drools Flow doesn't seem to be built for such a use case either - I take an object and then, depending on the decisions along the way, I end up in one of the end nodes; and then again for another object. Or is it? Could you give me some examples/links to such solutions? Drools Flow calls might look like this: ''' // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); Map<String, Object> params = new HashMap<String, Object>(); for(int i = 0; i < 10000; i++) { Application app = somehowGetAppById(i); // insert app into working memory FactHandle appHandle = ksession.insert(app); // app variable for action nodes params.put("app", app); // start a new process instance ProcessInstance instance = ksession.startProcess("com.sample.ruleflow", params); while(true) { if(instance.getState() == instance.STATE_COMPLETED) { break; } } // remove object from working memory ksession.retract(appHandle); } ''' That is: I'd take an Application object, start a new process for it, when the process is finished (the final, action node would modify the application somehow), I'd remove the object from working memory and repeat the process for a new App object. What do you think about this solution? I've ended up using Drools Flow and it has been working quite fine. My decision process isn't as straightforward as Drools Expert asks for and depending on where in the decision tree the process is it needs to load lists of objects from the database, transform them, make decisions, log everything etc. I use a Process object that is passed to the process as a parameter and stores all my global variables (for the process) and some convenience methods that are repeated at different points in the tree (as writing Java code in the 'Script Task' nodes isn't very convenient itself). I also ended up using Java to make decisions (and not 'mvel' or rules) - it's faster and I'd say easier to control. All objects that I work with are passed as parameters and used as normal Java variables in the code.
is definitely the way to go. If you want to avoid repeating yourself for the higher nodes, then the trick is to use 'insertLogical' (or just 'insert' if you're in a stateless session) and to understand that rules can trigger rules (It's not your father's SQL query). For example: ''' // we just insert Customer objects in the WM rule "evaluateRetired" when $c : Customer(age > 65) then insertLogical(new Retiree($c)); end rule "evaluteRetireeIsFemale" when $r : Retiree(customer.gender == Gender.FEMALE, $c : customer) then ... end ''' If the decision diagram frequently changes (and you want non-programmers to edit it), take a look at the documentation on (and ). In that case you'll probably repeat the entire path for each rule, but that's actually ok in most cases.
23,725,892
1
23,726,424
I pretty much have the simplest thing set up and it refuses to work for whatever reason. The HTML document refuses to pick up on the CSS. If you View Source and click on the href attribute on line 6, it shows me the file so I know the browser can see it. I am about to lose my mind here. Here's what is rendered. <IMAGE> And here's the code. HTML: ''' <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <link rel="stylesheet" type="text/css" href="/css/master.css" /> </head> <body> <div id="wrapper"> test </div> </body> </html> ''' CSS ''' #wrapper { background: orange; } ''' I thought maybe its a server issue so here's the apache config ''' <VirtualHost *:80> ServerName adtest.dev DocumentRoot /var/www/adtest.dev/ <Directory /var/www/adtest.dev/> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/adtest.dev/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/adtest.dev/access.log combined </VirtualHost> ''' and here's the output of 'ls -Rn' ''' /var/www/adtest.dev$ ls -Rn .: total 8 drwxr-xr-x 2 <PHONE> 4096 May 18 19:06 css -rw-r--r-- 1 <PHONE> 204 May 18 19:06 index.html ./css: total 4 -rw-r--r-- 1 <PHONE> 33 May 18 19:06 master.css ''' I am obviously missing something super easy, right? When visiting the site while 'tail -f /var/log/apache2/adtest.dev/access.log' is running. I get only 1 line. ''' [18/May/2014:19:28:43 +0000] "GET / HTTP/1.1" 200 503 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" ''' If I go directly to the css file, i get ''' [18/May/2014:19:44:58 +0000] "GET /css/master.css HTTP/1.1" 200 314 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" ''' The error log remains empty.
This issue was caused by AdBlock. In the default rules, they have '/adtest.' which picked up on my test domain 'http://adtest.dev'. Either removing that rule from AdBlock or renaming my test domain to just 'test.dev' resolves the issue.
13,646,513
1
13,646,569
I even don't know, what to write in title bar. I want my app to implement this feature: <IMAGE> For those, who don't understand what I'm talking about: I have a 'LitsView'. I want to load some more data, if the user pulls the 'ListView' "out of it boundaries". Maybe there's some tutorial for this?
Have a look at <URL>. It's the best pull-to-refresh library on Android.
26,576,431
1
26,577,157
In some OS, like Ubuntu, Debian, etc. 'cal' return current calendar with highlighting of today. And 'cal -h' turns off highlighting of today: <IMAGE> But in some OS, like Arch Linux '-h' param displays the help of a calendar. I'm doing a small script with Lua: ''' function foo() local f, err = io.popen('cal -h', 'r') if f then local s = f:read("*all") f:close() return s else return err end end ''' And my main question - how do I determine exactly what specifically returned parameter '-h'?
Execute 'cal -h' and parse the output for the word "help". If the word is found, the "-h" is for help. If word not found it is likely used to mean highlight but there is no sure way of knowing (a way that will work on all flavors of Linux). Most likely you will need some code to read environment var that identifies platform so you can issue correct command and rely on users of different Linux flavors to report when default fails and report to you the correct command line parameters. OTOH you could limit supprt to only those platforms you have access to. Or combination of these approaches.
53,826,952
1
53,831,238
Am working on an app for iPad, to organise sports, using Firebase. The requirement is that: - Each Sport may contain many events. - Many teams would register for an event. The queries to be handled would be: - - Am new to designing the database model for firebase. I have designed the firebase structure, as shown in the image. Will this structure support my queries optimally? Kindly suggest changes that I would have to make. Thanks in advance:) <IMAGE>
, firebase push keys have the very handy feature of sorting chronological, meaning just apply alphanumeric sort and they will be in chronological order even for offline writes. Ideally, you design your document in such a way that you don't need to query them. Or in other words, store the documents as you expect the results of your queries. # Applying to an app Let's suppose: 1. You have a view in your app showing the start datetime, # of teams joined, and prize, for all events in a given sport. 2. Clicking any of the events, you have a view showing start datetime, end datetime, venue, sponsors, and the team name of all teams joined. This is essentially two nodes dedicated to such views: <URL>
19,205,341
1
19,234,953
I am creating a widget but when I run it I get this error in the console: ''' [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] ------------------------------ [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Android Launch! [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] adb is running normally. [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] No Launcher activity found! [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] The launch will only sync the application package on the device! [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Performing sync [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Automatic Target Mode: Unable to detect device compatibility. Please select a target device. [2013-10-05 22:03:00 - AwesomeFileBuilderWidget] Uploading AwesomeFileBuilderWidget.apk onto device 'HT18YMA05067' [2013-10-05 22:03:00 - AwesomeFileBuilderWidget] Installing AwesomeFileBuilderWidget.apk... [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] Success! [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] \AwesomeFileBuilderWidgetin\AwesomeFileBuilderWidget.apk installed on device [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] Done! ''' But the widget installs fine on my device and shows up in the Widget selection screen. The second error occurs when I try to put my widget on the homescreen. I get this error in LogCat: ''' 10-05 21:51:45.485: D/AndroidRuntime(3557): Shutting down VM 10-05 21:51:45.485: W/dalvikvm(3557): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 10-05 21:51:45.505: E/AndroidRuntime(3557): FATAL EXCEPTION: main 10-05 21:51:45.505: E/AndroidRuntime(3557): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.WidgetConfig}: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:1854) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread.access$1500(ActivityThread.java:135) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.os.Handler.dispatchMessage(Handler.java:99) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.os.Looper.loop(Looper.java:150) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread.main(ActivityThread.java:4333) 10-05 21:51:45.505: E/AndroidRuntime(3557): at java.lang.reflect.Method.invokeNative(Native Method) 10-05 21:51:45.505: E/AndroidRuntime(3557): at java.lang.reflect.Method.invoke(Method.java:507) 10-05 21:51:45.505: E/AndroidRuntime(3557): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 10-05 21:51:45.505: E/AndroidRuntime(3557): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 10-05 21:51:45.505: E/AndroidRuntime(3557): at dalvik.system.NativeStart.main(Native Method) 10-05 21:51:45.505: E/AndroidRuntime(3557): Caused by: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-05 21:51:45.505: E/AndroidRuntime(3557): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 10-05 21:51:45.505: E/AndroidRuntime(3557): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 10-05 21:51:45.505: E/AndroidRuntime(3557): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.Instrumentation.newActivity(Instrumentation.java:1040) 10-05 21:51:45.505: E/AndroidRuntime(3557): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738) 10-05 21:51:45.505: E/AndroidRuntime(3557): ... 11 more ''' Here is my Manifest: ''' <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.awesomefilebuilderwidget" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name=".AFBWidget" android:label="@string/app_name"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_stuff"/> </receiver> <activity android:name=".WidgetConfig" android:label="@string/app_name"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".AFBWidget" android:label="@string/app_name"/> </application> </manifest> ''' I have made sure I have checked all the boxes in the Order and Export section. I have also made sure that my AFBWidget and WidgetConfig classes are in src. (Please note that the actual widget configuration is in the correct xml location, the WidgetConfig.java is something else) What is the issue? Updated LogCat: ''' 10-05 22:47:40.628: D/AndroidRuntime(4113): Shutting down VM 10-05 22:47:40.628: W/dalvikvm(4113): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 10-05 22:47:40.638: E/AndroidRuntime(4113): FATAL EXCEPTION: main 10-05 22:47:40.638: E/AndroidRuntime(4113): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.WidgetConfig}: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread.access$1500(ActivityThread.java:135) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.os.Handler.dispatchMessage(Handler.java:99) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.os.Looper.loop(Looper.java:150) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread.main(ActivityThread.java:4333) 10-05 22:47:40.638: E/AndroidRuntime(4113): at java.lang.reflect.Method.invokeNative(Native Method) 10-05 22:47:40.638: E/AndroidRuntime(4113): at java.lang.reflect.Method.invoke(Method.java:507) 10-05 22:47:40.638: E/AndroidRuntime(4113): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 10-05 22:47:40.638: E/AndroidRuntime(4113): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 10-05 22:47:40.638: E/AndroidRuntime(4113): at dalvik.system.NativeStart.main(Native Method) 10-05 22:47:40.638: E/AndroidRuntime(4113): Caused by: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-05 22:47:40.638: E/AndroidRuntime(4113): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 10-05 22:47:40.638: E/AndroidRuntime(4113): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 10-05 22:47:40.638: E/AndroidRuntime(4113): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.Instrumentation.newActivity(Instrumentation.java:1040) 10-05 22:47:40.638: E/AndroidRuntime(4113): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738) 10-05 22:47:40.638: E/AndroidRuntime(4113): ... 11 more ''' ADDED CLASSES AND XML FILES: AFBWidget.java: ''' import java.util.Random; import com.example.awesomefilebuilderwidget.R; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; import android.widget.RemoteViews; import android.widget.Toast; public class AFBWidget extends AppWidgetProvider{ @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // TODO Auto-generated method stub super.onUpdate(context, appWidgetManager, appWidgetIds); Random r = new Random(); int randomInt = r.nextInt(<PHONE>); String rand = String.valueOf(randomInt); final int N = appWidgetIds.length; for (int i = 0; i < N; i++){ int awID = appWidgetIds[i]; RemoteViews v = new RemoteViews(context.getPackageName(), R.layout.widget); v.setTextViewText(R.id.tvwidgetUpdate, rand); appWidgetManager.updateAppWidget(awID, v); } } ''' WidgetConfig.java: ''' import android.app.Activity; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RemoteViews; import com.example.awesomefilebuilderwidget.R; public class WidgetConfig extends Activity implements OnClickListener{ EditText info; AppWidgetManager awm; Context c; int awID; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.widgetconfig); Button b = (Button)findViewById(R.id.bwidgetconfig); b.setOnClickListener(this); c = WidgetConfig.this; info = (EditText)findViewById(R.id.etwidgetconfig); //Getting info about the widget that launched this Activity Intent i = getIntent(); Bundle extras = i.getExtras(); if (extras != null){ awID = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID ); }else{ finish(); } awm = AppWidgetManager.getInstance(c); } @Override public void onClick(View v) { // TODO Auto-generated method stub String e = info.getText().toString(); RemoteViews views = new RemoteViews(c.getPackageName(), R.layout.widget); views.setTextViewText(R.id.tvConfigInput, e); Intent in = new Intent(c, WidgetConfig.class); PendingIntent pi = PendingIntent.getActivity(c, 0, in, 0); views.setOnClickPendingIntent(R.id.bwidgetOpen, pi); awm.updateAppWidget(awID, views); Intent result = new Intent(); result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID); setResult(RESULT_OK, result); finish(); } } ''' Widget.xml: ''' <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tvConfigInput" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/bwidgetOpen" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <TextView android:id="@+id/tvwidgetUpdate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> </LinearLayout> ''' WidgetConfig.xml: ''' <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/etwidgetconfig" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/user_input_application_name"> <requestFocus /> </EditText> <Button android:id="@+id/bwidgetconfig" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/ok" /> </LinearLayout> ''' App Widget Provider (app_stuff.xml): <IMAGE>
I FINALLY FIXED IT AFTER 3 DAYS! Ok, so it was indeed because my two java classes were in a default package. So to fix that, since my classes were being accessed via a different package, I created a new package that was my app (com.example.awesomefilebuilderwidget) and then moved the classes into there and now it works with no problemos! :DD Thanks for all you've done I really do apperciate it! - user1628978
29,843,856
1
29,847,707
I have a fairly simply computation I need to do, but I cannot figure out how to do it in a way that is even close to efficient. I have a large nxn matrix, and I need to compute the following: <IMAGE> I'm still fairly inexperienced at coding, and so the only way that comes to my mind is to do the straightforward thing and use 3 for loops to move across the indexes: ''' sum=0 for(i in 1:n) { for(j in 1:n) { for(k in 1:n) { sum = sum + A[i,j]*A[j,k] } } } ''' Needless to say, for any decent size matrix this takes forever to run. I know there must be a better, more efficient way to do this, but I cannot figure it out.
If you don't consider the 'k' and 'i' sums, you can realise that you are just doing the matrix product of 'A' with itself. Such product in R is obtained through the '%*%' operator. After calculating this matrix, you just need to sum all the elements together: ''' sum(A %*% A) ''' should give the result you are seeking.
30,935,383
1
30,936,187
I tried subclassing UILabel with the following code.. but unable to get a look similar to <IMAGE> ''' - (void) drawRect:(CGRect)rect { CGSize myShadowOffset = CGSizeMake(4, -4); CGFloat myColorValues[] = {0, 0, 0, .8}; CGContextRef myContext = UIGraphicsGetCurrentContext(); CGContextSaveGState(myContext); CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB(); CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues); CGContextSetShadowWithColor (myContext, myShadowOffset, 5, myColor); self.layer.shadowOffset = CGSizeMake(0, 1); self.layer.shadowOpacity = 0.5; self.shadowColor = [UIColor blackColor]; [super drawTextInRect:rect]; CGColorRelease(myColor); CGColorSpaceRelease(myColorSpace); CGContextRestoreGState(myContext); } '''
''' self.layer.shadowOffset = CGSizeMake(0, -2.5); self.layer.shadowRadius = 1; self.layer.shadowOpacity = 0.5; self.layer.shadowColor = [UIColor blackColor].CGColor; ''' <IMAGE>
59,987,142
1
59,993,045
I want to run a single webpage to display files, which are stored in an Azure File Storage. It must be Azure File storage because these files came from a Docker container, which is mounted, to that file storage. I have a Azure Container Instance witch stores PDF files in an Azure File Storage. Now I run a WebApp (PHP) that shall read all the PDFs. I've installed the Microsoft Azure Storage File PHP SDK but have no clue how to use it. Even the <URL> did not help me coming forward. It would be very helpful if someone could help me a bit a simple sniped. <IMAGE>
I see you want to directly display a PDF file from Azure File Storage in a web page. Generally, the best practice is to generate the url with sas token of a file in Azure File Storage. So I followed the GitHub repo <URL> to install Azure File Storage SDK for PHP in my sample project, here is my sample code and its dependencies. The file structure of my sample project is as the figure below. <URL> The content of my 'composer.json' file is as below. ''' { "require": { "microsoft/azure-storage-file": "*" } } ''' My sample PHP file 'demo.php' is as below, that's inspired by the function 'generateFileDownloadLinkWithSAS' of the offical sample <URL>. ''' <?php require_once "vendor/autoload.php"; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\File\FileSharedAccessSignatureHelper; $accountName = "<your account name>"; $accountKey = "<your account key>"; $shareName = "<your share name>"; $fileName = "<your pdf file name>"; $now = date(DATE_ISO8601); $date = date_create($now); date_add($date, date_interval_create_from_date_string("1 hour")); $expiry = str_replace("+0000", "Z", date_format($date, DATE_ISO8601)); $helper = new FileSharedAccessSignatureHelper($accountName, $accountKey); $sas = $helper->generateFileServiceSharedAccessSignatureToken( Resources::RESOURCE_TYPE_FILE, "$shareName/$fileName", 'r', // Read $expiry // A valid ISO 8601 format expiry time, such as '2020-01-01T08:30:00Z' ); $fileUrlWithSAS = "https://$accountName.file.core.windows.net/$shareName/$fileName?$sas"; echo "<h1>Demo to display PDF from Azure File Storage</h1>"; echo "<iframe src='$fileUrlWithSAS' width='800' height='500' allowfullscreen webkitallowfullscreen></iframe>"; ?> ''' The result of my web page is as the figures below in Chrome and Firefox. The result in Chrome: <URL> The result in Firefox: <URL> --- Update: The code to list files in a file share, as below. ''' <?php require_once "vendor/autoload.php"; use MicrosoftAzure\Storage\File\FileRestProxy; $accountName = "<your account name>"; $accountKey = "<your account key>"; $shareName = "<your share name>"; $connectionString = "DefaultEndpointsProtocol=https;AccountName=$accountName;AccountKey=$accountKey"; $fileClient = FileRestProxy::createFileService($connectionString); $list = $fileClient->listDirectoriesAndFiles($shareName); function endsWith( $str, $sub ) { return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub ); } foreach($list->getFiles() as &$file) { $fileName = $file->getName(); if(endsWith($fileName, ".pdf")) { echo $fileName." "; } }; ?> '''
30,030,481
1
30,031,519
I am displaying a loop of items from a list in controller using ng-repeat directive. They are just the regular todo items with a minimize button. So, what I am doing to minimize the items is by setting up ng-hide to true on click of minimize button for those particular elements. Code is as below. ''' <div ng-repeat="note in notesList"> <div class="col-md-3 single-note" style="margin:5px" ng-hide="note.minimize"> <div class="note-title" style="margin-left: 30px"> <i class="fa fa-2x fa-paperclip" style="position:absolute; left:5px; top:5px"></i> <b ng-bind="note.title"></b> </div> <div class="description" style="margin-left: 30px; text-align: justify" ng-bind="note.description"></div> <div class="note-footer" style="margin-left: 30px; margin-bottom: 2px"> <span> <img ng-src="{{ note.priority == 'imp' && 'img/imp.png' || ( note.priority == 'trivial' && 'img/trivial.png' || 'img/critical.png' )}}" /><!--<i class="fa fa-2x fa-dot-circle-o"></i>--></span> <div class="pull-right"> <button class="btn btn-sm btn-default minimize" style="border-radius: 100%" ng-click="note.minimize=true"><i class="fa fa-minus"></i></button> <button class="btn btn-sm btn-default" style="border-radius: 100%" data-toggle='modal' data-target='#editNoteModal' ng-click="editNote(note.id)"><i class="fa fa-pencil"></i></button> <button class="btn btn-sm btn-default" style="border-radius: 100%" ng-click="removeNote(note.id)"><i class="fa fa-trash-o"></i></button> </div> </span> </div> </div> </div> ''' Here is how it looks like <IMAGE> I have shown the list in right panel using another ng-repeat where I am just showing titles of notes and a button to maximize if they are hidden (constraint is I cannot have both left and right panels in single ng-repeat). Now the problem is whenever I click minimize button, that particular item hides, But I am now unable to display it again using maximize button in right panel. I tried creating a function in controller for ng-click of minimize button which will return true if current state of item is 'not hidden' and I have passed a variable to the same function via ng-click of maximize button setting it up as false for ng-hide. But it's not working. I am fed up now. If you guys got the purpose, please help me achieving the same. :( Edit: Here is right panel code ''' <!--Right Panel (TAKEN FIRST AND PULLED TO RIGHT IN ORDER TO MAINTAIN UPPER POSITOIN IN MOBILE RESPONSIVENESS)--> <div class="col-md-3 right-panel pull-right"> <div id="critical-notes-bunch"> <br/> <div class="alert alert-danger"><i class="fa fa-dot-circle-o"></i> Critical Notes</div> <ul style="margin-left: -35px; margin-top: -10px; margin-bottom: 20px;"> <li ng-repeat="miniNote in notesList"> <a ng-click="mininote.minimize=false" style="cursor: pointer"><i class="fa fa-folder-open-o"></i></a> <span ng-bind="miniNote.title"></span><a href="" class="pull-right">&times;</a> </li> <a style="color: gray"><i class="fa fa-2x fa-ellipsis-h"></i> <i class="fa fa-2x fa-ellipsis-h"></i></a> </ul> </div> <div id="critical-notes-bunch"> <div class="alert alert-warning"><i class="fa fa-dot-circle-o"></i> Important Notes</div> <ul style="margin-left: -35px; margin-top: -10px; margin-bottom: 20px;"> <li ng-repeat="miniNote in notesList"> <a ng-click="mininote.minimize=false" style="cursor: pointer"><i class="fa fa-folder-open-o"></i></a> <span ng-bind="miniNote.title"></span><a href="" class="pull-right">&times;</a> </li> <a style="color: gray"><i class="fa fa-2x fa-ellipsis-h"></i> <i class="fa fa-2x fa-ellipsis-h"></i></a> </ul> </div> <div id="critical-notes-bunch"> <div class="alert alert-success"><i class="fa fa-dot-circle-o"></i> Trivial Notes</div> <ul style="margin-left: -35px; margin-top: -10px; margin-bottom: 20px;"> <li ng-repeat="miniNote in notesList"> <a ng-click="mininote.minimize=false" style="cursor: pointer"><i class="fa fa-folder-open-o"></i></a> <span ng-bind="miniNote.title"></span><a href="" class="pull-right">&times;</a> </li> <a style="color: gray"><i class="fa fa-2x fa-ellipsis-h"></i> <i class="fa fa-2x fa-ellipsis-h"></i></a> </ul> </div> </div> <!--/Right Panel--> '''
In your right panel you interator is called 'miniNode', but in 'ng-click' you reference 'mininode.minimize'. Changing either 'miniNode' to 'mininode' or vice versa should fix your problem.
14,397,806
1
14,441,728
I'm currently working on a Titanium based iOS application. I want to display the application settings in settings app. <IMAGE> In iOS we can easily do it using info.plist. Is there anyway to do this in Titanium ? I searched a lot but couldn't find any solution. Please help me, Thanks in advance
take a look in the kitchen Sink example, it shows how to do this <URL>
13,524,343
1
13,524,441
Do you know why it's happening? <IMAGE>
easy, use [EnterPhoneNumber text] instead!
20,073,139
1
20,073,920
I have a program that uses 'findContours' function and this is the result that I get: <IMAGE> My question is: Is there any way to get the thickness of those bars without using the 'houghlines' method?
You also can use cv::reduce method for summing up all nonzero pixels along rows, and the same for cols. You'll get two histograms. The max values will have coords of your lines. <URL> you need use it with flag CV_REDUCE_SUM or CV_REDUCE_AVG.
26,458,572
1
26,476,818
I am trying, unsuccessfully, to get a background image to display. The java code is: ''' absolutePanel = new AbsolutePanel(); absolutePanel.setSize("600px", "600px"); absolutePanel.getElement().setId("cwAbsolutePanel"); absolutePanel.addStyleName("absolutePanel"); final Image img = new Image(Resources.INSTANCE.baseballBall()); absolutePanel.add(img, 10, 10); ''' CSS: ''' .absolutePanel { background-image: url(bbdiamond.png); background-size: 100% 100%; background-repeat: no-repeat; } ''' The path of the image and CSS file are: <IMAGE> I have tried '"url('bbdiamond.png');"' and '"url(..bdiamond.png);"' and '"url('..bdiamond.png');"'. I have also tried giving '.absolutePanel' a height and width of 100% each; 'background-color: white' and 'opacity: 1'. Your assistance would be greatly appreciated. Regards, Glyn
I do not know why, however when I started testing this morning the CSS background was displayed. I have not made any changes to the CSS or the AbsolutePanel. In future if I am having issues with CSS I will reboot first. Regards, Glyn
20,842,548
1
20,842,595
I am using the same style for my dropdown box, and a textbox, which is working fine, except that they are different lengths, only by ~10px <URL> <IMAGE> I can't seem to get them the same length without using seperate classes for each. It actually seems that the dropdown icon at the end is suppose to be to the right more? ''' #container { width:500px; } .form-textbox, .form-dropdown { border: 0; outline: 0; height: 20px; width:100%; padding-left: 10px; background-color: rgb(204, 204, 204); color: #666; } ''' ''' <div id="container"> <select class="form-dropdown " name="turnover" /> <option value="1">Less than PS49,999 per year</option> <option value="2">PS50,000 - PS99,999 per year</option> <option value="3">PS100,000 - PS249,999 per year</option> <option value="4">PS250,000 - PS499,999 per year</option> <option value="5">PS500,000 - PS999,999 per year</option> <option value="6">PS1,000,000 or more per year</option> </select> <br> <p> <input class="form-textbox ofTextbox" name="market" type="text" /> </p> </div> '''
Apply <URL> ''' .form-textbox, .form-dropdown{ border: 0; outline: 0; height: 20px; width:100%; padding-left: 10px; background-color: rgb(204, 204, 204); color: #666; -moz-box-sizing: border-box; // Added rule -webkit-box-sizing: border-box; // Added rule box-sizing:border-box; // Added rule } ''' <URL>
29,124,788
1
29,125,350
Given a complex array 'data', I need to construct a band-diagonal matrix in the form of <IMAGE> using matlab or python, where * means the complex conjugate. For now I'm using 'diag(data(k)*ones(1,n-k),k)' to get the k-th diagonal, then put it in a loop that iterates over k and at the same time do conjugate for negative k, and then taking the sum. However, this is inside another loop and profiling shows that this procedure takes a really long time. The matrix is not sparse and is quite big (~2000x2000). Is there another way to achieve this efficiently? It is somewhat related to <URL>, ...]' but a cleaner approach is much appreciated. Also, my case is more symmetric than the linked question, so maybe a better solution is possible. MWE for my code, which took ~170 sec. to run on my pc: ''' tn=2000; ats=randn(1,tn)+1j*randn(1,tn); cm=0; for jx=-tn+1:tn-1 if jx>=0 cm=cm+diag(ats(jx+1)*ones(1,tn-abs(jx)),jx); else cm=cm+diag(conj(ats(-jx+1))*ones(1,tn-abs(jx)),jx); end end '''
Using the approach given in the <URL>: ''' a = [conj(data(end👎2)), data]; n = (numel(a)+1)/2; A = a(bsxfun(@minus, n+1:n+n, (1:n).')); '''