Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
34,918,115
Getting "No qmlscene installed." warning in "QT CREATOR" on "Ubuntu"
<p>i added QTStatic to QT Versions, but i cant use this version to build and set in kits tab.</p> <p>i uploaded screenshot below : (plz help)</p> <p><a href="http://i.stack.imgur.com/rpaGB.jpg" rel="noreferrer">Versions Tab Screenshot</a></p> <p><a href="http://i.stack.imgur.com/3TRye.jpg" rel="noreferrer">Kits Tab Screenshot</a></p>
<qt><qt-creator>
2016-01-21 07:51:40
HQ
34,918,405
To know the sass structure
<p>This is my sass structure please explain what does its mean?</p> <p>actually am analysing a code structure. am unable to understad the structure.</p> <pre><code>.class-name{ some styles.. &amp;.class-name2{ some styles.. } } </code></pre>
<sass>
2016-01-21 08:09:35
LQ_CLOSE
34,919,798
Select two columns with different where clause
I want to select two columns, for the example one name x and the other one is y for to get x data I need to write in the where clause IsTure='no' and count the the id by grouping by date. and for y in need to count the id by different where clause and group by date also. and the date field is different for x and y It should like this : Id Date x y How can I implement this kind of query ? Thanks
<sql><select><sql-server-2012>
2016-01-21 09:28:15
LQ_EDIT
34,919,920
If Else Not Work in Php Script
I have php code to display information messages returned. But this is not working. As this is an example of the codes: <?php if(intval(mysql_num_rows($req2))==0) { ?> (No reply) <?php } else { ?> (<?php echo $dn2['reps']-1; ?> time reply) <?php } ?> How to fix?
<php>
2016-01-21 09:34:22
LQ_EDIT
34,920,463
Connect smartphone to website
<p>I've come across this link a while ago: <a href="https://lightsaber.withgoogle.com" rel="nofollow">https://lightsaber.withgoogle.com</a></p> <p>I thought it was really cool, the ability to connect your phone to a website and let it control certain things. And just now I found this link: <a href="http://www.pauljobard.com/#!/" rel="nofollow">http://www.pauljobard.com/#!/</a> it implements the phone connect option too (if you go to 'experience my work'). </p> <p>I'm considering of experimenting a little something with this for my portfolio website, but I have no idea where to start; can someone give me a push in the right direction? What is this 'function' called? Is it very hard? </p> <p>to be more specific what I want to use this for: I want the user to be able to drag along a screen and pan and rotate a 3D object that way (I'm a 3d artist).</p>
<javascript><jquery><css><smartphone>
2016-01-21 09:57:24
LQ_CLOSE
34,920,988
How to load a data using ajax-php with parameters
<p>i got a link that performs a javascript function onclick</p> <pre><code>&lt;input type='hidden' id='name'&gt; &lt;a href='#' onclick='getUsers(1)'&gt;Click here&lt;/a&gt; function getUsers(id){ $('#name').val(id); } </code></pre> <p>whenever i click the link i want to pass the '1' to be the value of the hidden input type.</p> <p>after that i want to perform an ajax to use the value of the hidden input type for my mysql query.</p> <p>would that be possible?</p> <p>Thank you</p>
<javascript><php><jquery><ajax>
2016-01-21 10:20:35
LQ_CLOSE
34,921,346
C# Split String - Split String into Array
<p>I am trying to split a string that the user tiped in. For example: He types in "Hello". So I want to split this up into an array: ["H","E","L",...]. So how do I use this .split() function? </p> <p>And how do I save it into an Array?</p> <p>Thank you guys.</p>
<c#><arrays><split>
2016-01-21 10:36:40
LQ_CLOSE
34,922,668
Get all data from JSON array
<p>I've a little problem with a simple thing.I believe. this is my code...</p> <p><a href="http://i.stack.imgur.com/p8A8D.png" rel="nofollow">javascript code</a></p> <p>I'm able to grab the first object element but I need all the data object, I guess I've to change something in this code line...</p> <pre><code>value[0]['firstName']; </code></pre>
<javascript><arrays><json><object>
2016-01-21 11:32:09
LQ_CLOSE
34,923,447
C++ MFC, Custom Grid with CheckBox, RadioButton
<p>I want to create Custom Grid which shall have inline edit feature, Checkbox, Radio button and Images.</p> <p>I came across very good article &lt;&lt; <a href="http://www.codeproject.com/Articles/8/MFC-Grid-control" rel="nofollow">http://www.codeproject.com/Articles/8/MFC-Grid-control</a>; Here DrawFrameControl is used to draw Check box and Radio Button</p> <p>I have a requirement to customize the look and feel of check box. Is it possible to customize DrawFrameControl's or is a good idea to create custom control (check box and radio button)? Will there be any performance issue in case of custom controls?</p> <p>Regards, Sanjay</p>
<c++><mfc><win32gui>
2016-01-21 12:09:30
LQ_CLOSE
34,923,788
Prometheus - Convert cpu_user_seconds to CPU Usage %?
<p>Currently i'm monitoring docker containers via Prometheus.io. My problem is that i'm just getting "cpu_user_seconds_total" or "cpu_system_seconds_total". My question is how to convert this ever-increasing value to a CPU percentage?</p> <p>Currently i'm querying: </p> <pre><code>rate(container_cpu_user_seconds_total[30s]) </code></pre> <p>But I don't think that it is quite correct (comparing to top).</p> <p>How to convert cpu_user_seconds_total to CPU percentage? (Like in top)</p>
<performance><performance-testing><cpu-usage><prometheus>
2016-01-21 12:25:40
HQ
34,923,868
Spring beans are not injected in flyway java based migration
<p>I'm trying to inject component of configuration properties in the flyway migration java code but it always null.</p> <p>I'm using spring boot with Flyway.</p> <pre><code>@Component @ConfigurationProperties(prefix = "code") public class CodesProp { private String codePath; } </code></pre> <p>Then inside Flyway migration code, trying to autowrire this component as following:</p> <pre><code>public class V1_4__Migrate_codes_metadata implements SpringJdbcMigration { @Autowired private CodesProp codesProp ; public void migrate(JdbcTemplate jdbcTemplate) throws Exception { codesProp.getCodePath(); } </code></pre> <p>Here, codesProp is always null.</p> <p>Is there any way to inject spring beans inside flyway or make it initialized before flyway bean?</p> <p>Thank You.</p>
<spring><spring-boot><flyway>
2016-01-21 12:28:53
HQ
34,923,961
Trouble in R with abline
it's my first time using R - I've only used SPSS before and this is all very confusing for me. I'm having trouble plotting 2 ablines on a graph of the log10 Brain mass and log10 body mass. I'm following someone else's script but it just doesn't work for me. This is what I have: [Click me][1] (I've taken a screenshot of it because when I write it out here it comes out all weird ;_;) This is the graph produced: [Click me!][2] Why are the lines off there like that? Are the values I'm getting for the intercept and slope incorrect, or am I using the wrong ones? I've done other examples of this and its worked ok, but I've always ended up using the first model, never the second one so I'm not sure if I'm using the right values. Thank you :) [1]: http://i.stack.imgur.com/pjWTl.png [2]: http://i.stack.imgur.com/I0Cla.png
<r><plot><glm>
2016-01-21 12:33:30
LQ_EDIT
34,924,513
regarding the validation of the input file separator in perl
I have csv input file in perl which is tab separated. I would like to add a check if it find anything other than tab as field separator then it should through error message.I am new to perl I don't know how to check. example of my input file:My file having only two field. 10001027^I1000102713921-1274^M$ 10010121^I1001012113921-1234^M$ 10000104^I10010126139211-9999^M$ 10010119^I10010126139211-9999^M$ Thanks
<perl><field><separator>
2016-01-21 12:58:15
LQ_EDIT
34,924,521
PHP - access values inside an object
I have a requirement to access value inside an object return from an API response in PHP. API response $res = { "data": { "first_name": "Dany", "last_name": "mate", "id": "1379933133290837510", "image": { "60x60": { "url": "https://s-media-cache-ak0.pinimg.com/avatars/dtest_1438666564_60.jpg", "width": 60, "height": 60 } } } } How to access the parameters "first_name" & "url"? Your help is much appreciated. I have tried to convert the response in to an array but not worked $array = get_object_vars($res); I don't know is it the correct way to do this?
<php><json>
2016-01-21 12:58:25
LQ_EDIT
34,924,676
How to read doc file in editorpane
I am trying to view word file in my editor pane I tried these lines import java.awt.Dimension; import java.awt.GridLayout; import java.io.File; import java.io.FileInputStream; import javax.swing.JEditorPane; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.extractor.WordExtractor; public class editorpane extends JEditorPane { public editorpane(File file) { try { FileInputStream fis = new FileInputStream(file.getAbsolutePath()); HWPFDocument hwpfd = new HWPFDocument(fis); WordExtractor we = new WordExtractor(hwpfd); String[] array = we.getParagraphText(); for (int i = 0; i < array.length; i++) { this.setPage(array[i]); } } catch (Exception e) { e.printStackTrace(); } but gives me org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF) at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:131) at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:104) at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:138) at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:106) at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:174) at frame1.editorpane.<init>(editorpane.java:24) in this line HWPFDocument hwpfd = new HWPFDocument(fis); how can I solve that ?? beside I am not sure about these lines for (int i = 0; i < array.length; i++) { this.setPage(array[i]); } can I get them confirmed ??
<java><ms-word><apache-poi><docx>
2016-01-21 13:05:51
LQ_EDIT
34,925,947
Javascript Compressing if statement
is there a way of compressing this if statement. var alive1 = true if (x2 >= (x10 - 10) && x2 <= (x10 + 10) && y2 >= (y10 - 10) && y2 <= (y10 + 10) || x3 >= (x10 - 10) && x3 <= (x10 + 10) && y3 >= (y10 - 10) && y3 <= (y10 + 10) || x4 >= (x10 - 10) && x4 <= (x10 + 10) && y4 >= (y10 - 10) && y4 <= (y10 + 10) || x5 >= (x10 - 10) && x5 <= (x10 + 10) && y5 >= (y10 - 10) && y5 <= (y10 + 10)|| x6 >= (x10 - 10) && x6 <= (x10 + 10) && y6 >= (y10 - 10) && y6 <= (y10 + 10)) { alive1 = false; }
<javascript>
2016-01-21 14:06:00
LQ_EDIT
34,926,013
Is it possible to create an Android Wear app with react native
<p>I have had a play with react native creating ios apps but have not tried android yet. With android you also get 'android wear' for watches etc, will react native work creating apps for those devices?</p>
<react-native><wear-os>
2016-01-21 14:09:06
HQ
34,926,544
Best way to handle data for several options C#
<p>My program workflow:</p> <p>1) Show menu</p> <p>2) Catch option by switch</p> <p>2.1)Add float to a list </p> <p>2.2)Increment int1</p> <p>2.3)Increment int2</p> <p>2.4)Show inputs</p> <p>Now I wanna to add a generator which will print in console how my fiber track looks like. For ex:</p> <p>1) Added a section of 20km lenght</p> <p>2) Added a weld in latest secion</p> <p>3) Added a regenerator</p> <p>4) Added connector</p> <p>5) Added section of 10km lenght</p> <p>And I want to get in my console:</p> <blockquote> <p>This is how your track looks like: [Transmitter]-> [--20km track--] -> [Weld] -> [Regenerator] -> [Connector] > -> [--10km track--]</p> </blockquote> <p>First question is what kind of List should I create to handle my track design? I tought only to make a integer list, and make a encoding method to convert for example 1 to section 2 for weld 3 for connector etc.</p> <p>Any suggestions would be nice! Thank you for your time and patience.</p> <pre><code>public class Program { public int WeldCount; public int ConnectroCount; public List&lt;float&gt; section = new List&lt;float&gt;(); //public List&lt;&gt; TrackElements = new List&lt;&gt;(); public Program() { section.Add(0); } public void showResults() { float allSections = 0; foreach (float item in section) { allSections += item; } Console.Clear(); Console.WriteLine("Weld count: {0}, connector count: {1}, sum of sections: {2}", WeldCount,ConnectroCount,allSections); Console.ReadKey(); } public void finalConstruction() { } public static void mainMenu() { Console.Clear(); Console.WriteLine("\n"); Console.WriteLine("Add: \n1. Section \n2. Weld \n3. Regenerator\n4. Show results"); } public void menuChoose() { var key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: Console.Clear(); Console.WriteLine("Give lenght:"); float result; float.TryParse(Console.ReadLine(), out result); section.Add(result); mainMenu(); menuChoose(); break; case ConsoleKey.D2: WeldCount++; mainMenu(); menuChoose(); break; case ConsoleKey.D3: ConnectroCount++; mainMenu(); menuChoose(); break; case ConsoleKey.D4: showResults(); mainMenu(); menuChoose(); break; default: Console.WriteLine("Coś ty odjebał"); break; } } static void Main(string[] args) { Program program = new Program(); mainMenu(); program.menuChoose(); } } </code></pre>
<c#>
2016-01-21 14:34:18
LQ_CLOSE
34,926,910
onFocus bubble in React
<p>jsfiddle : <a href="https://jsfiddle.net/leiming/5e6rtgwd/" rel="noreferrer">https://jsfiddle.net/leiming/5e6rtgwd/</a></p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>class Sample extends React.Component { onInputFocus(event) { console.log('react input focus') } onSpanFocus(event) { console.log('react span focus') // event.stopPropagation() } render() { return ( &lt;span onFocus = {this.onSpanFocus}&gt; react input: &lt;input type="text" onFocus = {this.onInputFocus} /&gt; &lt;/span&gt; ) } } ReactDOM.render( &lt; Sample / &gt; , document.getElementById('container') );</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt; &lt;!-- This element's contents will be replaced with your component. --&gt; &lt;/div&gt; &lt;div&gt; &lt;span onfocus="(function(){console.log('normal span')})()"&gt; normal input:&lt;input type="text" onfocus="(function(){console.log('normal input focus')})()"&gt; &lt;/span&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>jsfiddle : <a href="https://jsfiddle.net/leiming/5e6rtgwd/" rel="noreferrer">https://jsfiddle.net/leiming/5e6rtgwd/</a></p> <p>Using React, <code>onFocus</code> in <code>&lt;input/&gt;</code> will bubble which is not same as usual HTML5.</p> <p>Could anyone give me the refer doc why focus bubbles with React?</p>
<html><reactjs><reactive-programming>
2016-01-21 14:50:14
HQ
34,927,159
Installing modules
<p>I'm new to programming in Python. I can't figure out how to install a library called Requests. I followed a youtube instructional video, and it seems to be able to import the module in command prompt, but not from the IDLE, which I would prefer to use.</p>
<python>
2016-01-21 15:02:14
LQ_CLOSE
34,927,390
How do i call the self.timer's changing value and indicate it at the label.text the ViewDidLoad's
i'm making a UILabel that indicates the value of the self.timer. This is the code. The problem is that i can't indicate the timeFormatter.stringFromDate(date_SSS) in the label.text. Actually i also have a scrollView and a pageControl to scroll the label horizontally. But the main problem is at the UILabel and the self.timer. How can i import UIKit class ViewController: UIViewController { private var label: UILabel! private var timer: NSTimer! let intArray: String = ["12:00:00", "12:50:00", "15:30:00", "16:40:00"] let index = 0 override func viewDidLoad() { let timeFormatter = NSDateFormatter() timeFormatter.dateFormat = "HH:mm:ss" self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update:", userInfo: nil, repeats: true) self.timer.fire() for (var i = 0; i < intArray.count; i++) { let label: UILabel = UILabel(frame: CGRectMake(CGFloat(index) * 50,100,150,200) label.cornerRadius = 20 label.text = timeFormatter.stringFromDate(date_SSS) view.addSubView(label) } } func dateFromString(date:String) -> NSDate? { let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! calendar.locale = NSLocale(localeIdentifier: "en_US_POSIX") calendar.timeZone = NSTimeZone(abbreviation: "JST")! let begin = date.startIndex guard let hour = Int(date.substringWithRange(begin..<begin.advancedBy(2))), let minute = Int(date.substringWithRange(begin.advancedBy(3)..<begin.advancedBy(5))), let second = Int(date.substringWithRange(begin.advancedBy(6)..<begin.advancedBy(8))) else{ return nil } return calendar.dateBySettingHour(hour, minute: minute, second: second, ofDate: NSDate(), options: []) } func update(timer: NSTimer) { let timeFormatter: NSDateFormatter = NSDateFormatter() timeFormatter.timeZone = NSTimeZone(name: "GMT") timeFormatter.dateFormat = "HH:mm:ss" let time = dateFromString(intArray[i]) let remain = time!.timeIntervalSinceDate(NSDate()) let date_SSS = NSDate(timeIntervalSince1970: remain) } }
<ios><swift><swift2>
2016-01-21 15:13:18
LQ_EDIT
34,927,558
How does this string formatting trick work?
I've recently seen this string formatting example: >>> from datetime import date >>> 'Today is {0:%A}'.format(date.today()) 'Today is Thursday' I'm wondering how it works.
<python><date><string-formatting>
2016-01-21 15:21:16
LQ_EDIT
34,927,647
What regex pattern can I use to match this string?
<p>What regex pattern can I use to match the following:</p> <p>Dxx-xxxx/xxx</p> <p>So: - Any string that starts with character 'D' - Has any number of any character between the 'D' and the '-' - Has any number of any character between the '-' and the '/' - Has any number of any character after the '/'</p> <p>Apologies if I haven't explained this very well!</p>
<c#><regex>
2016-01-21 15:25:20
LQ_CLOSE
34,927,805
What to do next?
<p>This application will read roster data in JSON format, parse the file, and then produce an SQLite database that contains a User, Course, and Member table and populate the tables from the data file.</p> <p>This code is incomplete as I need to modify the program to store the role column in the Member table to complete the problem. And I cannot understand how to do it.</p> <pre><code>import json import sqlite3 conn = sqlite3.connect('rosterdb.sqlite') cur = conn.cursor() cur.executescript(''' DROP TABLE IF EXISTS User; DROP TABLE IF EXISTS Member; DROP TABLE IF EXISTS Course; CREATE TABLE User ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE ); CREATE TABLE Course ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, title TEXT UNIQUE ); CREATE TABLE Member ( user_id INTEGER, course_id INTEGER, role INTEGER, PRIMARY KEY (user_id, course_id) ) ''') fname = raw_input('Enter file name: ') if ( len(fname) &lt; 1 ) : fname = 'roster_data.json' # [ # [ "Charley", "si110", 1 ], # [ "Mea", "si110", 0 ], str_data = open(fname).read() json_data = json.loads(str_data) for entry in json_data: name = entry[0]; title = entry[1]; print name, title cur.execute('''INSERT OR IGNORE INTO User (name) VALUES ( ? )''', ( name, ) ) cur.execute('SELECT id FROM User WHERE name = ? ', (name, )) user_id = cur.fetchone()[0] cur.execute('''INSERT OR IGNORE INTO Course (title) VALUES ( ? )''', ( title, ) ) cur.execute('SELECT id FROM Course WHERE title = ? ', (title, )) course_id = cur.fetchone()[0] cur.execute('''INSERT OR REPLACE INTO Member (user_id, course_id) VALUES ( ?, ? )''', ( user_id, course_id ) ) conn.commit() </code></pre> <p>Once the necessary changes are made to the program and it has been run successfully reading the given JSON data, run the following SQL command:</p> <pre><code>SELECT hex(User.name || Course.title || Member.role ) AS X FROM User JOIN Member JOIN Course ON User.id = Member.user_id AND Member.course_id = Course.id ORDER BY X </code></pre> <p>Find the first row in the resulting record set and enter the long string that looks like 53656C696E613333.</p>
<python><json><sqlite>
2016-01-21 15:31:58
LQ_CLOSE
34,928,231
Why do we need exclude in pom
<p>Pom.xml have this elements and I am curious why do we need exclude <code>commons-logging</code> from <code>spring-core</code>? And how do it works?</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-core&lt;/artifactId&gt; &lt;version&gt;3.0.5.RELEASE&lt;/version&gt; &lt;type&gt;jar&lt;/type&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;artifactId&gt;commons-logging&lt;/artifactId&gt; &lt;groupId&gt;commons-logging&lt;/groupId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;!-- next is log4j dependencie --&gt; </code></pre>
<java><spring><maven><pom.xml>
2016-01-21 15:50:49
LQ_CLOSE
34,929,095
Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
<p>I've started using the latest beta of v2 of chart.js since I need to draw a chart that contains both a stacked bar chart and an unstacked line chart on the same chart. Here's an example of what I need:</p> <p><a href="https://i.stack.imgur.com/Blcid.jpg"><img src="https://i.stack.imgur.com/Blcid.jpg" alt="enter image description here"></a></p> <p>In this chart the lines are not stacked and are all showing their natural values but the bar chart is stacked and shows the combined total of the values (including some negative values).</p> <p>I've managed to get the two charts drawn together but so far I've only succeeded in either having both charts stacked or I've had to use two separate y-axis which ends up with 2 scales. There's an example of the separate y-axis in this <a href="https://jsfiddle.net/jptabubm/">fiddle</a>:</p> <pre><code>yAxes: [{ stacked: false, ticks: { beginAtZero: true } }, { id: "bar-y-axis", stacked: true, ticks: { beginAtZero: true }, type: 'linear' }] </code></pre> <p>If I remove the first y-axis then I ended up with a single scale with the only problem being that the line chart is now stacked as well.</p> <p>Is there any way to draw a chart like I need using chart.js?</p>
<javascript><chart.js>
2016-01-21 16:27:59
HQ
34,929,206
R Shiny selectInput that is dependent on another selectInput
<p>I have some data below that I'm using to create a donut chart in R shiny, where <code>date</code> is a character. I want to be able to select the email whose score I want to view, but then in the second dropdown selection only see the dates for which that email has activity.</p> <p>For example, if I select email = xxxx in the first dropdown, I want to see only 'no activity' in the date selection field. And for email = yyyy, I want to see only 6/17/14, 6/18/14, 6/19/14 as selections. </p> <p>I've tried a sort of nested subsetting in the ui. Example:</p> <pre><code>&gt; ui &lt;- shinyUI(fluidPage( + sidebarLayout( + sidebarPanel( + selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))), + selectInput("User", "Date:", choices = dat5[dat5$email==input$Select,date]) + ), + mainPanel(plotOutput("distPlot")) + ) + )) </code></pre> <p>But this still shows all possible date selections</p> <p><strong>DATA</strong></p> <pre><code>email date variable value ymin ymax xxxx no activity e_score 0 0 0 xxxx no activity diff 1 0 1 yyyy 6/17/14 e_score 0.7472 0 0.7472 yyyy 6/17/14 diff 0.2528 0.7472 1 yyyy 6/18/14 e_score 0.373 0 0.373 yyyy 6/18/14 diff 0.627 0.373 1 yyyy 6/19/14 e_score 0.533 0 0.533 yyyy 6/19/14 diff 0.467 0.533 1 </code></pre> <p>My code so far:</p> <p><strong>app.R</strong></p> <pre><code>library(shiny) library(shinydashboard) ui &lt;- shinyUI(fluidPage( sidebarLayout( sidebarPanel( selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))), selectInput("User", "Date:", choices = unique(dat5$date) ) ), mainPanel(plotOutput("distPlot")) ) )) server &lt;- function(input, output) { output$distPlot &lt;- renderPlot({ ggplot(data = subset(dat5, (email %in% input$Select &amp; date %in% input$User)), aes(fill=variable, ymax = ymax, ymin = ymin, xmax = 4, xmin = 3)) + geom_rect(colour = "grey30", show_guide = F) + coord_polar(theta = "y") + geom_text(aes(x = 0, y = 0,label = round(value[1]*100))) + xlim(c(0, 4)) + theme_bw() + theme(panel.grid=element_blank()) + theme(axis.text=element_blank()) + theme(axis.ticks=element_blank()) + xlab("") + ylab("") + scale_fill_manual(values=c('#33FF00','#CCCCCC')) }) } shinyApp(ui = ui, server = server) </code></pre>
<r><shiny><shinydashboard>
2016-01-21 16:32:37
HQ
34,929,954
Refresh Today Widget every time opened
<p>I thought that Today View every time when i open it it calls "viewWillAppear" but its not. When i change something in my app, and then I slide down for Today View it sometimes refresh the view and sometimes not.</p> <p>I do all logic in viewWillAppear (fetch data from coreData and put that data to labels), but its not called everytime.</p> <pre><code>override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) fetchContent() setLabels() setContentHeight() tableView.reloadData() print("view will appear") } </code></pre> <p>how to call fetchContent and setLabels every time when user opens Today Extensions?</p>
<swift>
2016-01-21 17:07:23
HQ
34,930,771
Why is 'this' undefined inside class method when using promises?
<p>I have a javascript class, and each method returns a <code>Q</code> promise. I want to know why <code>this</code> is undefined in <code>method2</code> and <code>method3</code>. Is there a more correct way to write this code?</p> <pre><code>function MyClass(opts){ this.options = opts; return this.method1() .then(this.method2) .then(this.method3); } MyClass.prototype.method1 = function(){ // ...q stuff... console.log(this.options); // logs "opts" object return deferred.promise; }; MyClass.prototype.method2 = function(method1resolve){ // ...q stuff... console.log(this); // logs undefined return deferred.promise; }; MyClass.prototype.method3 = function(method2resolve){ // ...q stuff... console.log(this); // logs undefined return deferred.promise; }; </code></pre> <p>I can fix this by using <code>bind</code>:</p> <pre><code>function MyClass(opts){ this.options = opts; return this.method1() .then(this.method2.bind(this)) .then(this.method3.bind(this)); } </code></pre> <p>But not entirely sure why <code>bind</code> is necessary; is <code>.then()</code> killing <code>this</code> off?</p>
<javascript><node.js><promise><this><q>
2016-01-21 17:46:47
HQ
34,931,121
Can cond support TF ops with side effects?
<p>The (source code) documentation for <code>tf.cond</code> is unclear on whether the functions to be performed when the predicate is evaluated can have side effects or not. I've done some tests but I'm getting conflicting results. For example the code below does not work:</p> <pre><code>import tensorflow as tf from tensorflow.python.ops import control_flow_ops pred = tf.placeholder(tf.bool, []) count = tf.Variable(0) adder = count.assign_add(1) subtractor = count.assign_sub(2) my_op = control_flow_ops.cond(pred, lambda: adder, lambda: subtractor) sess = tf.InteractiveSession() tf.initialize_all_variables().run() my_op.eval(feed_dict={pred: True}) count.eval() # returns -1 my_op.eval(feed_dict={pred: False}) count.eval() # returns -2 </code></pre> <p>I.e. no matter what value the predicate evaluates to, both functions are getting run, and so the net result is a subtraction of 1. On the other hand, this code snippet does work, where the only difference is that I add new ops to the graph every time <code>my_op</code> is called:</p> <pre><code>pred = tf.placeholder(tf.bool, []) count = tf.Variable(0) my_op = control_flow_ops.cond(pred, lambda:count.assign_add(1), lambda:count.assign_sub(2)) sess = tf.InteractiveSession() tf.initialize_all_variables().run() my_op.eval(feed_dict={pred: False}) count.eval() # returns -2 my_op.eval(feed_dict={pred: True}) count.eval() # returns -1 </code></pre> <p>Not sure why creating new ops every time works while the other case doesn't, but I'd obviously rather not be adding nodes as the graph will eventually become too big.</p>
<tensorflow>
2016-01-21 18:07:23
HQ
34,931,950
C++ Builder: Convert binary code to AnsiString
<p>when I have binary code like '01010100011001010111001101110100", how can I convert this back to "test"?</p> <p>Thanks.</p>
<c++><binary><ansistring>
2016-01-21 18:49:36
LQ_CLOSE
34,932,472
How To use Model OOP in Java, Sorry i am newbie
I have a Model Active Admin, i have created String ID setter and getter. when i use setID in Login Form, i use this : `ActiveAdmin AA = new ActiveAdmin();` AA.setId(txtIdAdmin.getText()); and i test getter from login form, it work. but when i test in another form, in another java class, in diffrent file, i can't get my string ID in Active Admin. i used `AA.getId();` and the result is blank. please help me. any suggestion or answer. sorry if my english is bad.
<java><oop>
2016-01-21 19:18:24
LQ_EDIT
34,932,611
the adapter does work?
**i get the input from the user and set them in a list view but when i click in the button does work NO Errors just open the layout and close direct but when a try with "arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,m_list);" is work perfect can you please tell me where im wrong thank you im New in Android** public class HomeChat extends AppCompatActivity { ListView listView; EditText writeSms; ArrayAdapter<String> arrayAdapter; ArrayList<String> m_list = new ArrayList<String>(); String emriUser; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home_chat); writeSms = (EditText) findViewById(R.id.shkrunSms); listView = (ListView) findViewById(R.id.listView); emriUser = getIntent().getExtras().getString("emri"); arrayAdapter = new ArrayAdapter<String>(this,R.layout.list_chat,m_list); listView.setAdapter(arrayAdapter); } public void sentSmsButton(View view) { String mesazhet = emriUser + ": " + writeSms.getText().toString(); if (writeSms != null && writeSms.length() > 0) { m_list.add(mesazhet); arrayAdapter.notifyDataSetChanged(); writeSms.setText(""); }else { Toast.makeText(getApplicationContext(),"Something Wrong",Toast.LENGTH_LONG).show(); } } } **and this is the list chat layout** <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/test123" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000" android:background="#cccccc" android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft="5dp" android:paddingRight="5dp" /> </LinearLayout>
<java><android>
2016-01-21 19:27:07
LQ_EDIT
34,932,734
ESO Authentication on IIS for PHP and .NET applications (Shibboleth / SAML / WiF ...)
<p>I just wondered if you could answer a question regarding authentication in an enterprise's intranet. We are currently setting up a server for intranet publishing which of course needs protection via an enterprise single sign on.</p> <p>Unfortunately we are stuck with an IIS server as we need to run both PHP and .NET applications. The main app is programmed in PHP, but we have to feature some jQuery included widgets that rely on ASPX handlers.</p> <p>The company offers all types of authentication. We've already successfully protected the server with Shibboleth (using SAML 2.0). It shows the ESO screen to login and then redirects to our server with a logged-in session. Unfortunately the widgets that are referring to the ASPX handlers don't authenticate correctly.</p> <p>I've never done authentication / SAML / WiF / anything, so please excuse my question:</p> <p>What would be the most promising way for authentication with our setup (IIS featuren PHP and ASPX apps)? Should we stick to SAML and Shibboleth or should we use WiF / WS Federation / Windows Authentication?</p> <p>Is it possible to support both PHP and ASPX with one authentication method?</p> <p>Thanks for a response! Nik</p>
<php><asp.net><authentication><iis><single-sign-on>
2016-01-21 19:34:14
HQ
34,933,380
SHA1 Key for DEBUG & RELEASE ANDROID STUDIO MAC
<p>How do I get my SHA1 Keys for debug and release using android studio on a mac? (These are required for Google API Keys)</p>
<android><google-api><sha1>
2016-01-21 20:11:15
HQ
34,933,433
(Delphi) I set a button to add a bold line to a rich edit, but the first time I click the button it doesn't come out bold?
I have set a button to add a line(bold) to a rich edit, but the first time I click the button it doesn't come out bold? eg: line1, **line2**, **line3** Code: red1.SelAttributes.Style := [fsBold]; red1.Lines.Add(' Name: ' + Edit1.Text); Does anyone know what I have done wrong? -Thanks
<delphi>
2016-01-21 20:14:19
LQ_EDIT
34,933,594
Angular2 parse string to html
<p>I'm importing rss items where in description there is a lot of html code (links, paragraphs, etc...). When I'm viewing it in component's view like:</p> <pre><code>{{rss.description}} </code></pre> <p>the output in site is like:</p> <pre><code>&lt;a href="http://link.com"&gt;Something&lt;/a&gt; &lt;p&gt;Long text&lt;/p&gt; </code></pre> <p>How can I quickly and easy parse it to html? I don't want to cross it with jQuery. Thank you</p>
<html><parsing><angular>
2016-01-21 20:22:42
HQ
34,933,990
Multi thread approach vs Akka actor model
<p>I'm new to akka actor. I have read the akka offical documents and still don't understand how actor works compare to threading model.</p> <p>Let's take a simple example like this. I have a traditional HttpServer , which have 10 threads in the thread pools . When 20 requests are coming at the same time , the HttpServer will delegate all 10 threads in the thread pool to handle the first 10 requests and the others will be queued in the network interface to wait for the thread to pick up.</p> <p>How will an actor-based HttpServer react to the same problem?. Will all of the requests are queued in front of a delegated actors to process them in a sequential order and send the messages to other actor?. If so, this is the point that I don't understand how can actor provide better performance than threading model, because only 1 actor process 20 requests in a sequential order can not faster than 10 thread process 20 requests concurrently.</p> <p>What I am trying to understand is that how actor react when multiple requests are coming together at the same time? , not how actor process and queue the message in the mail box , it's already showed up a lot in the documents. Can someone simulate the steps how actor work in this example?</p>
<multithreading><akka><actor>
2016-01-21 20:47:47
HQ
34,936,599
How to set up VS-Code to open new files in current instance?
<p>So I've been using Visual Studio Code recently and I really like it. However, every time I open a file, a new window will open rather than a new "tab." I've already tried setting <code>window.openInNewWindow</code> to <code>false</code> and that doesn't work.</p>
<visual-studio-code>
2016-01-21 23:48:56
HQ
34,936,726
Visual Studio 2015 (ASP.NET 5): show 'Manage Bower Packages...' context menu
<p>In Visual Studio 2015, when I create a brand new solution with a brand new ASP.NET 5 project, I see the <code>Manage Bower Packages...</code> context menu when I right-click on the project:</p> <p><a href="https://i.stack.imgur.com/EzHdw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/EzHdw.jpg" alt="enter image description here"></a></p> <p>However, when I add an ASP.NET 5 project to an existing solution, the <code>Manage Bower Packages...</code> context menu is nowhere to be seen:</p> <p><a href="https://i.stack.imgur.com/r0prL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/r0prL.jpg" alt="enter image description here"></a></p> <p>Any idea how to get the <code>Manage Bower Packages...</code> context menu option to appear?</p>
<visual-studio><visual-studio-2015><asp.net-core><asp.net-core-mvc>
2016-01-22 00:02:40
HQ
34,936,852
Using if else statement to assign a variable in python
<p>I'm trying to make a program telling you how to order a specific number of nuggets, using if and else statements to assign variables. My problem is if one of the first if statements is true, then the program throws an error, because I called a variable that doesn't exist. How can I make My program skip over the rest of the if/else statements if the first one is found to be true?</p> <pre><code>nuggets = input("How many nuggets do you need? ") nuggets = int(nuggets) nuggets20 = nuggets % 20 if nuggets20 == 0: n20 = True else: nuggets10 = nuggets20 % 10 if nuggets10 == 0: print(nuggets10) else: nuggets6 = nuggets10 % 6 if nuggets6 == 0: print(nuggets6) else: nuggets4 = nuggets6 % 4 if n20 == True: print("nuggets") </code></pre>
<python><python-3.x><if-statement>
2016-01-22 00:17:22
LQ_CLOSE
34,937,039
Number formatting - Java
<p>I need to convert an integer so that a dash is inserted after two characters, for example 12-34-56. </p> <p>The integer will be a randomly generated six digit number.</p>
<java><string><integer><format>
2016-01-22 00:37:28
LQ_CLOSE
34,937,379
C's coverage of assembly
<p>In an argument with a friend, I made the remark that it is impossible to write, in any language besides C, a program that is faster than <em>all</em> variants in C, that do the same thing. My argument was based on an affirmative answer to the question below. Is it true?</p> <ul> <li>If we think of "compiling" as a map from [C programs] to [assembly programs], then is this map surjective?</li> </ul> <p><strong>Caveat</strong>: Of course, you can include assembly in C programs, but pretend that isn't possible (makes for a more interesting question!).</p>
<c><assembly><compilation>
2016-01-22 01:15:39
LQ_CLOSE
34,937,438
SSIS licensing when deployed on different machine than the sql server
I have data warehouse database on SQL Server Enterprise. Currently the SSIS that feeds the data warehouse is running on the same server. I would like to move the SSIS execution on another server. What are the licensing options for SQL Server for running the SSIS? Can I use SQL Server Standard with server + 1 CAL license? SSIS runs under one service account. Thank you.
<sql-server><ssis>
2016-01-22 01:21:06
LQ_EDIT
34,937,724
Running bash scripts with npm
<p>I want to try using npm to run my various build tasks for a web application. I know I can do this by adding a <code>scripts</code> field to my <code>package.json</code> like so:</p> <pre><code>"scripts": { "build": "some build command" }, </code></pre> <p>This gets unwieldy when you have more complex commands with a bunch of options. Is it possible to move these commands to a bash script or something along those lines? Something like:</p> <pre><code>"scripts": { "build": "build.sh" }, </code></pre> <p>where <code>npm run build</code> would execute the commands in the <code>build.sh</code> file?</p> <p>Reading through <a href="http://substack.net/task_automation_with_npm_run" rel="noreferrer">this</a> post it seems like it is, but I'm not clear on exactly where I'm supposed to drop my <code>build.sh</code> file or if I'm missing something.</p>
<node.js><bash><shell><npm>
2016-01-22 01:54:33
HQ
34,938,016
Testing if an event has been triggered in Jasmine
<p>How do you test if an event has been fired in Jasmine without <code>jquery-jasmine</code>? </p> <p>I'm working on a project where we don't use jQuery (wohoo), and I'm trying to write a unit test for my menu triggering function. It works like this:</p> <ul> <li>You click a button</li> <li>My testable component then runs <code>document.dispatchEvent(new CustomEvent('menu.toggle'))</code></li> <li>I want to test that the component indeed dispatched the custom event. </li> </ul> <p>How do I test this?</p>
<javascript><unit-testing><testing><javascript-events><jasmine>
2016-01-22 02:31:50
HQ
34,938,202
Dynamic Div objects in web app?
<p>I am trying to figure out how to have a div display a certain amount of orange circles per a changing variable. How would this be done? </p> <p>If the number is 4, there should be 4 orange circles. If the number is 3, there should be 3 orange circles..</p> <p>Additional, Animating exit and entrance?</p> <p>Whats the best way to do this in a web app? THANKS!</p> <p>Example code/jsfiddle would be amazing. :)</p>
<javascript><jquery><html><css>
2016-01-22 02:54:29
LQ_CLOSE
34,938,663
1067: Implicit coercion of a value of type congrate to an unrelated type flash.display:DisplayObject
in one input text field has two possible answer which is luah or hal. why it is not working at all.someone please help me the right way to write a code?? stop(); //var jawapan1=Array; txt_zuhal.addEventListener(KeyboardEvent.KEY_DOWN,handler); function handler(event:KeyboardEvent) { //jawapan1=("luah", "hal"); // if the key is ENTER if(event.charCode == 13) { if(txt_zuhal.text=='luah'||'hal') { trace("1.correct"); } else { trace("1.Sorry, Wrong answer"); } } }
<actionscript-3><flash>
2016-01-22 03:48:11
LQ_EDIT
34,939,390
Generic programming via effects
<p>In the Idris <a href="https://github.com/idris-lang/Idris-dev/blob/master/libs/effects/Effects.idr" rel="noreferrer">Effects</a> library effects are represented as</p> <pre><code>||| This type is parameterised by: ||| + The return type of the computation. ||| + The input resource. ||| + The computation to run on the resource given the return value. Effect : Type Effect = (x : Type) -&gt; Type -&gt; (x -&gt; Type) -&gt; Type </code></pre> <p>If we allow resources to be values and swap the first two arguments, we get (the rest of the code is in Agda)</p> <pre><code>Effect : Set -&gt; Set Effect R = R -&gt; (A : Set) -&gt; (A -&gt; R) -&gt; Set </code></pre> <p>Having some basic type-context-membership machinery</p> <pre><code>data Type : Set where nat : Type _⇒_ : Type -&gt; Type -&gt; Type data Con : Set where ε : Con _▻_ : Con -&gt; Type -&gt; Con data _∈_ σ : Con -&gt; Set where vz : ∀ {Γ} -&gt; σ ∈ Γ ▻ σ vs_ : ∀ {Γ τ} -&gt; σ ∈ Γ -&gt; σ ∈ Γ ▻ τ </code></pre> <p>we can encode lambda terms constructors as follows:</p> <pre><code>app-arg : Bool -&gt; Type -&gt; Type -&gt; Type app-arg b σ τ = if b then σ ⇒ τ else σ data TermE : Effect (Con × Type) where Var : ∀ {Γ σ } -&gt; σ ∈ Γ -&gt; TermE (Γ , σ ) ⊥ λ() Lam : ∀ {Γ σ τ} -&gt; TermE (Γ , σ ⇒ τ ) ⊤ (λ _ -&gt; Γ ▻ σ , τ ) App : ∀ {Γ σ τ} -&gt; TermE (Γ , τ ) Bool (λ b -&gt; Γ , app-arg b σ τ) </code></pre> <p>In <code>TermE i r i′</code> <code>i</code> is an output index (e.g. lambda abstractions (<code>Lam</code>) construct function types (<code>σ ⇒ τ</code>) (for ease of description I'll ignore that indices also contain contexts besides types)), <code>r</code> represents a number of inductive positions (<code>Var</code> doesn't (<code>⊥</code>) receive any <code>TermE</code>, <code>Lam</code> receives one (<code>⊤</code>), <code>App</code> receives two (<code>Bool</code>) — a function and its argument) and <code>i′</code> computes an index at each inductive position (e.g. the index at the first inductive position of <code>App</code> is <code>σ ⇒ τ</code> and the index at the second is <code>σ</code>, i.e. we can apply a function to a value only if the type of the first argument of the function equals the type of the value).</p> <p>To construct a real lambda term we must tie the knot using something like a <a href="https://github.com/agda/agda-stdlib/blob/master/src/Data/W.agda" rel="noreferrer"><code>W</code></a> data type. Here is the definition:</p> <pre><code>data Wer {R} (Ψ : Effect R) : Effect R where call : ∀ {r A r′ B r′′} -&gt; Ψ r A r′ -&gt; (∀ x -&gt; Wer Ψ (r′ x) B r′′) -&gt; Wer Ψ r B r′′ </code></pre> <p>It's the indexed variant of the Oleg Kiselyov's <a href="http://okmij.org/ftp/Haskell/extensible/more.pdf" rel="noreferrer"><code>Freer</code></a> monad (effects stuff again), but without <code>return</code>. Using this we can recover the usual constructors:</p> <pre><code>_&lt;∨&gt;_ : ∀ {B : Bool -&gt; Set} -&gt; B true -&gt; B false -&gt; ∀ b -&gt; B b (x &lt;∨&gt; y) true = x (x &lt;∨&gt; y) false = y _⊢_ : Con -&gt; Type -&gt; Set Γ ⊢ σ = Wer TermE (Γ , σ) ⊥ λ() var : ∀ {Γ σ} -&gt; σ ∈ Γ -&gt; Γ ⊢ σ var v = call (Var v) λ() ƛ_ : ∀ {Γ σ τ} -&gt; Γ ▻ σ ⊢ τ -&gt; Γ ⊢ σ ⇒ τ ƛ b = call Lam (const b) _·_ : ∀ {Γ σ τ} -&gt; Γ ⊢ σ ⇒ τ -&gt; Γ ⊢ σ -&gt; Γ ⊢ τ f · x = call App (f &lt;∨&gt; x) </code></pre> <p>The whole encoding is very similar to the <a href="https://github.com/effectfully/DataData/blob/master/Container/Indexed.agda#L75" rel="noreferrer">corresponding encoding</a> in terms of <a href="http://strictlypositive.org/indexed-containers.pdf" rel="noreferrer">indexed containers</a>: <code>Effect</code> corresponds to <code>IContainer</code> and <code>Wer</code> corresponds to <code>ITree</code> (the type of Petersson-Synek Trees). However the above encoding looks simpler to me, because you don't need to think about things you have to put into shapes to be able to recover indices at inductive positions. Instead, you have everything in one place and the encoding process is really straightforward.</p> <p>So what am I doing here? Is there some real relation to the indexed containers approach (besides the fact that this encoding has the same <a href="http://mazzo.li/epilogue/index.html%3Fp=324.html" rel="noreferrer">extensionality problems</a>)? Can we do something useful this way? One natural thought is to built an effectful lambda calculus as we can freely mix lambda terms with effects, since a lambda term is itself just an effect, but it's an external effect and we either need other effects to be external as well (which means that we can't say something like <code>tell (var vz)</code>, because <code>var vz</code> is not a value — it's a computation) or we need to somehow internalize this effect and the whole effects machinery (which means I don't know what).</p> <p><a href="https://github.com/effectfully/random-stuff/blob/master/Wer.agda" rel="noreferrer">The code used</a>.</p>
<haskell><generic-programming><agda><dependent-type><idris>
2016-01-22 05:06:45
HQ
34,939,520
While submit job with pyspark, how to access static files upload with --files argument?
<p>for example, i have a folder:</p> <pre><code>/ - test.py - test.yml </code></pre> <p>and the job is submited to spark cluster with:</p> <p><code>gcloud beta dataproc jobs submit pyspark --files=test.yml "test.py"</code></p> <p>in the <code>test.py</code>, I want to access the static file I uploaded.</p> <pre><code>with open('test.yml') as test_file: logging.info(test_file.read()) </code></pre> <p>but got the following exception:</p> <pre><code>IOError: [Errno 2] No such file or directory: 'test.yml' </code></pre> <p>How to access the file I uploaded?</p>
<python><apache-spark><pyspark><google-cloud-dataproc>
2016-01-22 05:19:56
HQ
34,940,425
notifyDataSetChanged() NullPointerException
<p>i try to add onClick this button then create contact in database</p> <p>Here is code i try to add it to main_fragment</p> <pre><code> final Button addBtn = (Button) view.findViewById(R.id.btnadd); addBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri imageUri = Uri.parse("android.resource://org.intracode.contactmanager/drawable/no_user_logo.png"); import_fragment.Contact contact = new import_fragment.Contact(dbHandler.getContactsCount(), String.valueOf(nametxt.getText()), String.valueOf(phoneTxt.getText()), String.valueOf(emailTxt.getText()), String.valueOf(addressTxt.getText()), imageUri); if (!contactExists(contact)) { dbHandler.createContact(contact); Contacts.add(contact); contactAdapter.notifyDataSetChanged(); // Error in this line Toast.makeText(getActivity().getApplicationContext(), String.valueOf(nametxt.getText()) + " has been added to your Contacts!", Toast.LENGTH_SHORT).show(); return; } Toast.makeText(getActivity().getApplicationContext(), String.valueOf(nametxt.getText()) + " already exists. Please use a different name.", Toast.LENGTH_SHORT).show(); } }); </code></pre> <p>When i press this button in my app, 'app has stopped working'</p> <p>Here is my logcat</p> <pre><code>01-22 08:31:04.014 29398-29398/com.al3almya.users.al3almya E/AndroidRuntime: FATAL EXCEPTION: main Process: com.al3almya.users.al3almya, PID: 29398 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ArrayAdapter.notifyDataSetChanged()' on a null object reference at com.al3almya.users.al3almya.main_fragment$1.onClick(main_fragment.java:77) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20262) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5637) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) </code></pre>
<java><android><nullpointerexception>
2016-01-22 06:34:14
LQ_CLOSE
34,940,696
Array to string conversion
<p>I have view like this</p> <pre><code> &lt;?php foreach((array)$query as $row): ?&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;id_jeans ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;nama ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;ket ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;tglmulai ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row-&gt;tglselesai ?&gt;&lt;/td&gt; &lt;?php $cari = $this-&gt;db-&gt;query("select sum(bahanbenang.biaya) FROM bahanbenang WHERE id_benang IN('$row-&gt;benang')"); ?&gt; &lt;td&gt;&lt;?php echo $cari-&gt;result_array();?&gt;&lt;/td&gt; </code></pre> <p>and error</p> <p>A PHP Error was encountered</p> <p>Severity: Notice</p> <p>Message: Array to string conversion</p> <p>I anyone help me?</p>
<php><codeigniter>
2016-01-22 06:52:06
LQ_CLOSE
34,941,357
How to get the ip address of a windows 7/8/8.1/10 phone programmatically
<p>i am new to this community &amp; windows phone app development. I need to get the ip address of the network (wifi and mobile) to which the device is connected pro-grammatically on a windows phone app (C#). windows version 7/8/8.1/10 is required.</p>
<c#><windows-phone-7><windows-phone-8><windows-phone-8.1><ip>
2016-01-22 07:35:56
LQ_CLOSE
34,941,410
FetchFailedException or MetadataFetchFailedException when processing big data set
<p>When I run the parsing code with 1 GB dataset it completes without any error. But, when I attempt 25 gb of data at a time I get below errors. I'm trying to understand how can I avoid below failures. Happy to hear any suggestions or ideas.</p> <p>Differnt errors,</p> <pre><code>org.apache.spark.shuffle.MetadataFetchFailedException: Missing an output location for shuffle 0 org.apache.spark.shuffle.FetchFailedException: Failed to connect to ip-xxxxxxxx org.apache.spark.shuffle.FetchFailedException: Error in opening FileSegmentManagedBuffer{file=/mnt/yarn/nm/usercache/xxxx/appcache/application_1450751731124_8446/blockmgr-8a7b17b8-f4c3-45e7-aea8-8b0a7481be55/08/shuffle_0_224_0.data, offset=12329181, length=2104094} </code></pre> <p>Cluster Details:</p> <blockquote> <p>Yarn: 8 Nodes<br> Total cores: 64<br> Memory: 500 GB<br> Spark Version: 1.5 </p> </blockquote> <p>Spark submit statement:</p> <pre><code>spark-submit --master yarn-cluster \ --conf spark.dynamicAllocation.enabled=true \ --conf spark.shuffle.service.enabled=true \ --executor-memory 4g \ --driver-memory 16g \ --num-executors 50 \ --deploy-mode cluster \ --executor-cores 1 \ --class my.parser \ myparser.jar \ -input xxx \ -output xxxx \ </code></pre> <p>One of stack trace:</p> <pre><code>at org.apache.spark.MapOutputTracker$$anonfun$org$apache$spark$MapOutputTracker$$convertMapStatuses$2.apply(MapOutputTracker.scala:460) at org.apache.spark.MapOutputTracker$$anonfun$org$apache$spark$MapOutputTracker$$convertMapStatuses$2.apply(MapOutputTracker.scala:456) at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772) at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108) at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:771) at org.apache.spark.MapOutputTracker$.org$apache$spark$MapOutputTracker$$convertMapStatuses(MapOutputTracker.scala:456) at org.apache.spark.MapOutputTracker.getMapSizesByExecutorId(MapOutputTracker.scala:183) at org.apache.spark.shuffle.hash.HashShuffleReader.read(HashShuffleReader.scala:47) at org.apache.spark.rdd.ShuffledRDD.compute(ShuffledRDD.scala:90) at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:297) at org.apache.spark.rdd.RDD.iterator(RDD.scala:264) at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38) at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:297) at org.apache.spark.rdd.RDD.iterator(RDD.scala:264) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66) at org.apache.spark.scheduler.Task.run(Task.scala:88) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) </code></pre>
<apache-spark><yarn>
2016-01-22 07:39:22
HQ
34,941,546
Is there a way to integrate git with Jupyter and have a version control over the notebooks created?
<p>I have hosted jupyterhub on a server and added many users into it. I want the users to have an option of version control for their work. So is there any way to add a git kernel or extension do have this done?</p>
<git><github><jupyter><jupyter-notebook><jupyterhub>
2016-01-22 07:48:53
HQ
34,942,075
Building one web project breaks the compiled version of the second in solution
<p>I have a big solution with 30 projects of which 2 are web projects (MVC and WebAPI) with a bunch of background class library projects.</p> <p>I have visual studio set up to host the web projects in IIS.</p> <p>If I do a clean build, followed by a full build of the entire solution, then accessing both projects via a browser works fine. (they are in diff folders and hosted on diff 'domains' in iis) </p> <p>If I make NO code changes, simply rebuild one of the 2 web projects, the OTHER one stops working. </p> <p>To be clear, rebuilding the WebAPI project causes the MVC project to have errors. And vice versa.</p> <p>The error I get is saying that System.Web.Http.Formatter is not found. The detail says that the located assembly version is different from the reference version. Checking the bin folder shows that that is not the case. </p>
<c#><iis><visual-studio-2015><roslyn>
2016-01-22 08:24:28
HQ
34,942,796
Shell cmd "date" without new line in the end
<p>I want to output a line of date using date command, but it's end with a "\n" which I don't need it, currently, I use:</p> <pre><code>echo -n `date +"[%m-%d %H:%M:%S]"` </code></pre> <p>or </p> <pre><code>date +"[%m-%d %H:%M:%S]"|tr -d "\n" </code></pre> <p>Are there any built-in parameter for "date" to do that?</p>
<shell><newline>
2016-01-22 09:07:44
HQ
34,942,840
Lint error "Do not treat position as fixed; only use immediately..."
<p>I'm contributing to open source library and got lint error <strong>"Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later"</strong> for this code:</p> <pre><code> @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { mAdapter.onBindViewHolder(holder, position); if (!isFirstOnly || position &gt; mLastPosition) { for (Animator anim : getAnimators(holder.itemView)) { anim.setDuration(mDuration).start(); anim.setInterpolator(mInterpolator); } mLastPosition = position; } else { ViewHelper.clear(holder.itemView); } } </code></pre> <p>I've checked that it is because the position is saved for the future use. It is a question to library creator why they need this logic. But issue disappeared when I change the usage of the position to the usage <code>holder.getAdapterPosition()</code>:</p> <pre><code> @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { mAdapter.onBindViewHolder(holder, position); if (!isFirstOnly || holder.getAdapterPosition() &gt; mLastPosition) { for (Animator anim : getAnimators(holder.itemView)) { anim.setDuration(mDuration).start(); anim.setInterpolator(mInterpolator); } mLastPosition = holder.getAdapterPosition(); } else { ViewHelper.clear(holder.itemView); } } </code></pre> <p>I assume that conceptually it didn't change much but lint is satisfied now. Why? </p>
<android><lint><android-recyclerview>
2016-01-22 09:09:57
HQ
34,943,241
Finding columns in dataframe with specific number of values in R
<p>I have a dataframe(data.table) with over 3000 columns. I need to find out the columns in my dataframe that have only 2 and less than 2 values in them. I then after extracting those columns with 2 and less then 2 values I want to drop them out of the original data frame. I illustrate as follows: Original data frame</p> <pre><code>Month A B C Jan-00 0.007 NA 1758.27 Feb-00 0.004 NA 1310.43 Mar-00 0.004 NA 1260.89 Apr-00 0.004 0.0002 1137.34 May-00 0.005 6.05E-05 1595.78 Jun-00 0.003 NA 4968.89 Jul-00 0.007 NA NA Aug-00 0.005 NA NA Sep-00 0.004 NA NA </code></pre> <p>Desired output</p> <pre><code> Month A C Jan-00 0.007 1758.27 Feb-00 0.004 1310.435 Mar-00 0.004 1260.89 Apr-00 0.004 1137.342105 May-00 0.005 1595.78125 Jun-00 0.003 4968.895238 Jul-00 0.007 NA Aug-00 0.005 NA Sep-00 0.004 NA </code></pre> <p>I would appreciate your help in this regard.</p>
<r><data.table><multiple-columns>
2016-01-22 09:31:18
LQ_CLOSE
34,943,550
Realm Swift Models separate or not?
<p>I'm new to the world of iOS and Swift and am working on a new app which I want to use Realm for persistence. I have Entities in my code already which my Services access and populate for an HTTP API endpoint. </p> <p>Now I want to persist certain Entities and wanted advice as to whether I should create new Realm specific Models for each of my entities to read and write from Realm. Or should I convert all my existing plain Swift Entities to Realm Entities. At first this felt wrong as I would be passing Realm Entities al around my app instead of just in the persistence layer. </p> <p>However, the alternative is that every time I read/write entities to Realm I need to convert them back and forth from Entities to Realm Entities. </p> <p>Any advice on the best approach to this? </p> <p>Thanks </p>
<ios><swift><realm>
2016-01-22 09:46:37
HQ
34,944,698
Div odd and even
<p>I have a problem that i believe to have a simple fix I just don't know the fix myself.</p> <p>Say i have some divs i.e.</p> <pre><code>&lt;div class="box-1"&gt;&lt;/div&gt; &lt;div class="box-2"&gt;&lt;/div&gt; &lt;div class="box-3"&gt;&lt;/div&gt; &lt;div class="box-4"&gt;&lt;/div&gt; </code></pre> <p>etc.</p> <p>If these boxes need to be alternate colours. I need to create some css which basically does the following:</p> <pre><code>.box-(odd-number) { color:#000; } .box-(even-number) { color:#fff; } </code></pre> <p>Obviously I know the above is not the correct syntax. Could some one point me in the right direction.</p> <p>Thanks</p>
<html><css>
2016-01-22 10:41:42
HQ
34,945,554
How to set layer-wise learning rate in Tensorflow?
<p>I am wondering if there is a way that I can use different learning rate for different layers like what is in Caffe. I am trying to modify a pre-trained model and use it for other tasks. What I want is to speed up the training for new added layers and keep the trained layers at low learning rate in order to prevent them from being distorted. for example, I have a 5-conv-layer pre-trained model. Now I add a new conv layer and fine tune it. The first 5 layers would have learning rate of 0.00001 and the last one would have 0.001. Any idea how to achieve this?</p>
<python><deep-learning><tensorflow>
2016-01-22 11:22:10
HQ
34,945,621
WPF DataGrid......I want Display images in datagrid using WPF
I want to display images in DataGrid from Database and I am using WPF[enter image description here][1] [1]: http://i.stack.imgur.com/bM0lP.png I can retrive image name as u can see in Image Column ,but not able to display it
<c#><wpf><wpfdatagrid>
2016-01-22 11:25:12
LQ_EDIT
34,947,072
Macro for searching every cell in a particular column whether it ends with particular words defined in array
For instance, I want to see whether each cell from B10 till the end of the B colomn is ending with "@yahoo.com", "gmail.com", "rediff.com". If not then, it should color that particular cell
<vba><excel>
2016-01-22 12:45:29
LQ_EDIT
34,947,425
Regexp for mentions in html content
I'm trying to do a regexp for catch the mention in a html content. I have a content like this: <div data-user-id="@john">@john</div> I want catch only the mention inside the divs...not inside the "". I've done this regexp: http://regexr.com/3ckv8 ( /[^"]@[a-zA-Z0-9_]*[^"]/g ) That works almost fine...the problem is that it catch also the >< of the div tags. Any suggestion ? Thanks.
<html><regex>
2016-01-22 13:05:05
LQ_EDIT
34,947,642
Angular2 Observables -- Replay
<p>I am trying to set up an Angular2 Observable that will replay the latest value.</p> <pre><code>import {Injectable} from 'angular2/core'; import {Observable} from 'rxjs/Observable'; @Injectable() export class RefinementService { refining: any; private r: any; constructor() { this.refining = new Observable(observer =&gt; this.r = observer).replay(1); } } </code></pre> <p><br/> I continually get errors stating:</p> <blockquote> <p>Property 'replay' does not exist on type Observable&lt;{}>.</p> </blockquote> <p>and</p> <blockquote> <p>this.refining.replay is not a function</p> </blockquote> <p><br/> Has anyone successfully implemented an observable that will re-emit it's latest value to new subscribers?</p>
<typescript><angular><rxjs>
2016-01-22 13:16:30
HQ
34,948,650
How should I interpret "size" parameter in Doc2Vec function of gensim?
<p>I am using <code>Doc2Vec</code> function of <a href="https://radimrehurek.com/gensim/models/doc2vec.html" rel="noreferrer">gensim</a> in Python to convert a document to a vector.</p> <p>An example of usage</p> <p><code>model = Doc2Vec(documents, size=100, window=8, min_count=5, workers=4)</code></p> <p>How should I interpret the <code>size</code> parameter. I know that if I set <code>size = 100</code>, the length of output vector will be 100, but what does it mean? For instance, if I increase <code>size</code> to 200, what is the difference?</p>
<python><gensim><word2vec>
2016-01-22 14:07:52
HQ
34,949,625
parsing a nested dictionary
I would like to parse the following nested dictionary for all URL entries. They should be written into a list. How can I do this? {u'_id': ObjectId('56a22819ffd6f'), u'books': [{u'id': {u'id': u'4311'}, u'link': {u'name': u'Operating Business', u'url': u'http://ffff'}}, {u'id': {u'id': u'4310'}, u'link': {u'name': u'Operating Business', u'url': u'http://zzzzz'}}, {u'id': {u'id': u'7462'}, u'link': {u'name': u'European Credit Trading', u'url': u'http://xxxx'}}, {u'id': {u'id': u'3258'}, u'link': {u'name': u'Operating Business', u'url': u'http://dddddd'}}, {u'id': {u'id': u'7463'}, u'link': {u'name': u'US Credit Trading', u'url': u'http://aaaaa'}}], u'created': datetime.datetime(2016, 1, 2, 13, 1, 12, 744000), u'id': u'lingering-smoke', u'valuationDate': datetime.datetime(170, 1, 1, 0, 0, 16, 821000)}
<python><dictionary>
2016-01-22 14:58:58
LQ_EDIT
34,950,009
Chrome Extension "Refused to load the script because it violates the following Content Security Policy directive"
<p>I'm trying to create a Chrome extension, but none of my JS works. The console shows this error:</p> <blockquote> <p>Refused to load the script '<a href="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js</a>' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".</p> </blockquote> <p>Why is it blocking my jQuery from running?</p>
<javascript><jquery><html><google-chrome><google-chrome-extension>
2016-01-22 15:17:52
HQ
34,950,118
Debug console not showing values for Swift + Objective-C
<p>My app uses Swift and a 3rd-party library in Objective-C. When my debugger steps into the Objective-C code, the debug console does not show the values of my Swift string correctly. Instead, it shows unable to read data. How can we resolve this issue?</p> <p><a href="https://i.stack.imgur.com/I4C5V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/I4C5V.png" alt="enter image description here"></a></p>
<objective-c><swift><swift2><xcode7>
2016-01-22 15:24:29
HQ
34,950,322
Use of semicolons in ES6
<p>I was under the impression semicolons became obsolete with ES6. However, I came across this today:</p> <p>Doesn't work:</p> <pre><code>let i = 0 [0, 1, 2, 3, 4, 5, 6].forEach(item =&gt; console.log(item)) </code></pre> <p>Works:</p> <pre><code>let i = 0; [0, 1, 2, 3, 4, 5, 6].forEach(item =&gt; console.log(item)) </code></pre> <p>Why is the semicolon necessary here, and when should I use them?</p>
<javascript><node.js><ecmascript-6>
2016-01-22 15:33:15
HQ
34,950,767
How to import .XML code style into IntelliJ Idea 15
<p>I want to use a specific code style in my editor defined in an XML file, which looks something like this:</p> <pre><code>&lt;code_scheme name="CustomStyleName"&gt; &lt;option name="JAVA_INDENT_OPTIONS"&gt; &lt;value&gt; ... </code></pre> <p>How is it possible to import this style into IntelliJ Idea. When I go to Preferences->Editor->Code Style->Manage it is only possible to import an Eclipse XML Profile.</p> <p><a href="https://i.stack.imgur.com/eo3ke.png"><img src="https://i.stack.imgur.com/eo3ke.png" alt="screenshot of the import dialog"></a></p>
<intellij-idea><configuration><intellij-15>
2016-01-22 15:55:34
HQ
34,950,794
Google Maps in React-Native (iOS)
<p>My goal is to display a Google Map in React Native. I have seen examples that use the Google Maps SDK with an UIMapView or a MapBox map, but that is not what I am looking for.</p> <p>I currently have no errors. Here is my code:</p> <p>index.ios.js</p> <pre><code>'use strict'; import React, { AppRegistry, Component, StyleSheet, Text, View } from 'react-native'; import GoogleMaps from './ios/GoogleMaps.js'; class RCTGoogleMaps extends Component { constructor(props) { super(props); } render() { return ( &lt;View style={styles.container}&gt; &lt;GoogleMaps style={styles.map}/&gt; &lt;/View&gt; ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF' }, map: { height: 500, width: 300, marginLeft: 50 } }); AppRegistry.registerComponent('RCTGoogleMaps', () =&gt; RCTGoogleMaps); </code></pre> <p>ios/GoogleMaps.js</p> <pre><code>var {requireNativeComponent} = require('react-native'); module.exports = requireNativeComponent('RCTGoogleMapViewManager', null); </code></pre> <p>ios/RCTGoogleMapViewManager.h</p> <pre><code>#ifndef RCTGoogleMapViewManager_h #define RCTGoogleMapViewManager_h #import &lt;Foundation/Foundation.h&gt; #import "RCTViewManager.h" #import &lt;UIKit/UIKit.h&gt; @interface RCTGoogleMapViewManager : RCTViewManager&lt;UITextViewDelegate&gt; @end #endif /* RCTGoogleMapViewManager_h */ </code></pre> <p>ios/GoogleMapViewManager.m</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "RCTGoogleMapViewManager.h" #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "UIView+React.h" @import GoogleMaps; @implementation RCTGoogleMapViewManager RCT_EXPORT_MODULE() - (UIView *)view { GMSMapView *mapView_; // Create a GMSCameraPosition that tells the map to display the // coordinate -33.86,151.20 at zoom level 6. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; UIView *newView_ = mapView_; //self.view = mapView_; // Creates a marker in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); marker.title = @"Sydney"; marker.snippet = @"Australia"; marker.map = mapView_; return newView_; } RCT_EXPORT_VIEW_PROPERTY(text, NSString) @end </code></pre> <p>There is a red border around the component, but nothing displays inside. I am new to React Native and new to StackOverflow. Unfortunately, they will not let me upload a screenshot until I have more reputation.</p> <p>There is one line I suspect to be off, but have no idea what to change it to. Line #8 in RCTGoogleMapViewManager.h says, "@interface RCTGoogleMapViewManager : RCTViewManager". I have used UITextViewDelegates for other custom components, but this map is not a TextView. That might be it, but I have no clue.</p> <p>Any help at all would be appreciated.</p>
<ios><google-maps><google-maps-api-3><react-native>
2016-01-22 15:57:07
HQ
34,950,867
Vue.js : How to set a unique ID for each component instance?
<p>I want to create a component with Vue.js containing a label and an input. for example :</p> <pre><code>&lt;label for="inputId"&gt;Label text&lt;/label&gt; &lt;input id="inputId" type="text" /&gt; </code></pre> <p>How can I set a unique ID for each component instance?</p> <p>Thank you.</p>
<vue.js>
2016-01-22 16:00:16
HQ
34,951,043
Is it possible to combine if_not_exists and list_append in update_item
<p>I'm trying to use the <code>update_item</code> functionality for DynamoDB in boto3. </p> <p>I'm struggling right now to update lists for items. I would like to create a new list if the list does not exist yet and otherwise append to the existing list. </p> <p>Using an <code>UpdateExpression</code> of the form <code>SET my_list = list_append(my_list, :my_value)</code> returns an error <em>"The provided expression refers to an attribute that does not exist in the item"</em> if the list does not exist yet.</p> <p>Any idea how I would have to modify my <code>UpdateExpression</code>?</p> <p>Thanks &amp; best regards, Fabian</p>
<amazon-dynamodb><boto3>
2016-01-22 16:09:47
HQ
34,951,110
Robust endless loop for server written in Python
<p>I write a server which handles events and uncaught exceptions during handling the event must not terminate the server.</p> <p>The server is a single non-threaded python process.</p> <p>I want to terminate on these errors types:</p> <ul> <li>KeyboardInterrupt</li> <li>MemoryError</li> <li>...</li> </ul> <p>The list of built in exceptions is long: <a href="https://docs.python.org/2/library/exceptions.html" rel="noreferrer">https://docs.python.org/2/library/exceptions.html</a></p> <p>I don't want to re-invent this exception handling, since I guess it was done several times before.</p> <p>How to proceed? </p> <ol> <li>Have a white-list: A list of exceptions which are ok and processing the next event is the right choice</li> <li>Have a black-list: A list of exceptions which indicate that terminating the server is the right choice.</li> </ol> <p>Hint: This question is not about running a unix daemon in background. It is not about double fork and not about redirecting stdin/stdout :-)</p>
<python><exception-handling><server><infinite-loop><robustness>
2016-01-22 16:12:43
HQ
34,951,448
Issues iterating through JSON list in Python?
<p>I have a file with JSON data in it, like so:</p> <pre><code>{ "Results": [ {"Id": "001", "Name": "Bob", "Items": { "Cars": "1", "Books": "3", "Phones": "1"} }, {"Id": "002", "Name": "Tom", "Items": { "Cars": "1", "Books": "3", "Phones": "1"} }, {"Id": "003", "Name": "Sally", "Items": { "Cars": "1", "Books": "3", "Phones": "1"} }] } </code></pre> <p>I can not figure out how to properly loop through the JSON. I would like to loop through the data and get a Name with the Cars for each member in the dataset. How can I accomplish this?</p> <pre><code>import json with open('data.json') as data_file: data = json.load(data_file) print data["Results"][0]["Name"] # Gives me a name for the first entry print data["Results"][0]["Items"]["Cars"] # Gives me the number of cars for the first entry </code></pre> <p>I have tried looping through them with:</p> <pre><code>for i in data["Results"]: print data["Results"][i]["Name"] </code></pre> <p>But recieve an error: <strong>TypeError: list indices must be integers, not dict</strong></p>
<python><arrays><json><for-loop>
2016-01-22 16:28:40
HQ
34,951,683
MongoDB constantly high cpu usage
<p>According to docker container statistics, my mongo database consumes constantly between 250 and 350% cpu. That's pretty impressive since it's a single core system :P</p> <p>The sad part is that this is my production instance and much more sad is that it has to live until the next prod-backup and thats 3.5 more hours to go.</p> <p>I tried to do a mongotop but it tells me 0ms stats for all shown collections. Can I do anything else to figure out what's going on?</p> <p>PS: The db is up for 9 weeks and didn't cause problems.</p>
<mongodb>
2016-01-22 16:39:27
HQ
34,951,689
Set build number for Jenkins workflow (pipeline) builds
<p>I am migrating jenkins-workflow job to new template based workflow job. Because the build number is used as part of the version of build artifacts the workflow produces I have to start build number of the new workflow with a number greater than the old workflow. Unfortunately 'Next Build Number' plugin does not work with workflow pipeline. </p> <p>Anybody knows a good way do this?</p>
<jenkins><jenkins-workflow>
2016-01-22 16:39:44
HQ
34,951,691
Bash fail if any single command fails but still run all commands
<p>Probably a simple question but an elegant solution is not coming to mind. I would like to run a series of commands (each one is a test) and return 1 if any of them returned non-zero. Typically I would do something like:</p> <pre><code>thingA &amp;&amp; thingB &amp;&amp; thingC exit $? </code></pre> <p>However, that won't run thingC if thingB fails and I want to ensure that all 3 run. I can easily think of an inelegant approach:</p> <pre><code>final_result=0 retval=thingA if [[ $retval != 0 ]] then final_result=1 fi retval=thingB ... exit $final_result </code></pre> <p>Is there some simple, elegant way to get what I want?</p>
<bash>
2016-01-22 16:39:53
HQ
34,951,713
AspNet5 - Windows Authentication Get Group Name From Claims
<p>I have a asp.net5 project setup to use windows authentication. When I set a break point and look at the User, I see that there is a Claims array that contains Group SID's. How do I get the actual group name from the claims?</p> <p>I am trying to limit the windows logged in user using the active directory groups that they belong to, and am struggling setting it up.</p> <p>Questions: How can I see the active directory groups that the logged in user belongs to? How do I convert the GroupSID's to a group name? Do I need to include anything in the startup.cs to limit certain groups to REST service calls?</p> <p>I see examples of setting up claims manually based upon the logged in user. I am interested in using the Windows authenticated user and their groups to limit access.</p> <p>Thanks</p>
<asp.net-core><asp.net-core-mvc>
2016-01-22 16:41:10
HQ
34,951,812
Why does -Xrs reduce performance
<p>From IBM:</p> <blockquote> <p><strong>-Xrs</strong></p> <p>Disables signal handling in the JVM.</p> <p><strong>-Xrs</strong></p> <p>Setting -Xrs prevents the Java™ run time environment from handling any internally or externally generated signals such as SIGSEGV and SIGABRT. Any signals that are raised are handled by the default operating system handlers. <strong>Disabling signal handling in the JVM reduces performance by approximately 2-4%, depending on the application.</strong></p> <p><strong>-Xrs:sync</strong></p> <p>On UNIX systems, this option disables signal handling in the JVM for SIGSEGV, SIGFPE, SIGBUS, SIGILL, SIGTRAP, andSIGABRT signals. However, the JVM still handles the SIGQUIT and SIGTERM signals, among others. As with -Xrs, the use of <strong>-Xrs:sync reduces performance by approximately 2-4%, depending on the application.</strong></p> <p><strong>Note:</strong> Setting this option prevents dumps being generated by the JVM for signals such as SIGSEGV and SIGABRT, because the JVM is no longer intercepting these signals.</p> </blockquote> <p><a href="https://www-01.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.aix.70.doc/diag/appendixes/cmdline/Xrs.html">https://www-01.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.aix.70.doc/diag/appendixes/cmdline/Xrs.html</a></p> <p>From my understanding, <code>-Xrs</code> is really used to prevent dumps from being generated when certain OS Signals are intercepted.</p> <p>Since the JVM is no longer intercepting and handling these signals, it would stand to reason this would <em>increase</em> performance, not <em>decrease</em> it as claimed by IBM.</p> <p>Why does <code>-Xrs</code> reduce performance?</p>
<java><jvm>
2016-01-22 16:45:14
HQ
34,951,835
how can i style my php code result?
i wrote this code and i want to style it with css. I added style to it but same result appears can any body help please . <p> <phpcode> <?php $term = mysql_real_escape_string($_REQUEST['term']); $servername = "localhost"; $username = "cp22084"; $password = "1O7FRlB4D567"; $dbname = "cp22084_voltmotor"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT Install , power , RPM FROM SN WHERE serial = '$term'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "serial number: " . $term.'<br>'; echo "installation: " . $row["Install"].'<br>'; echo "power: " . $row["power"].'<br>'; echo "RPM: " . $row["RPM"].'<br>'; } } else { echo "no result"; } $conn->close(); ?> </phpcode> </p>
<php><css>
2016-01-22 16:46:40
LQ_EDIT
34,952,039
Is c# compatible with autocad lt?
<p>I've looked for this question several times but there's no answer. Lisp is a language that is exclusive to the full version of autocad, I wonder if c# is as well or if I can run c# on a lt version of autocad.</p>
<c#><autocad>
2016-01-22 16:56:55
LQ_CLOSE
34,952,530
I am using Redux. Should I manage controlled input state in the Redux store or use setState at the component level?
<p>I have been trying to figure out the best way to manage my react forms. I have tried to use the onChange to fire an action and update my redux store with my form data. I have also tried creating local state and when my form gets submitted I trigger and action and update the redux store. </p> <p>How should i manage my controlled input state?</p>
<reactjs><redux><redux-form>
2016-01-22 17:22:25
HQ
34,952,661
copying data with SSIS without recreating the tables
I want to copy data from db A to db B. I created a saved SSIS package successfully and data was indeed copied from A to B. Now I want to automate the process but when I'm launching the saved .dtsx file I get this error: "Error: Executing the query "CREATE TABLE ... failed with the following error: "There is already an object named ... in the database"..." Seems like SSIS is trying to create the table again. How do I set SSIS to copy the data only, without recreating the table? Ta.
<sql-server-2008><ssis>
2016-01-22 17:29:47
LQ_EDIT
34,952,792
How do I structure authenticated queries with GraphQL?
<p>I was thinking of writing an API that does the following things:</p> <ul> <li>Sign-up and sign-in users which provide the user with an authentication token</li> <li>Create maps (data example: <code>{ name: “Quotes”, attributes: [“quote”, “author"] }</code>)</li> <li>Create map items (data example: <code>{ quote: "...", author: "..." }</code>)</li> </ul> <p>I would build the queries somewhat like this:</p> <pre><code>// return the name and id of all the user's maps maps(authToken="…") {   name,   id } // return all the items of a single map maps(authToken="…") {   map(name=“Quotes") {     items   } } // OR by using the map_id maps(authToken="…") {   map(id=“…") {     items   } } </code></pre> <p><strong>So, my question is, is this correct or would I need to structure it differently?</strong></p>
<api><authentication><graphql>
2016-01-22 17:37:34
HQ
34,952,811
Is there a definitive *nix command line tool for inspecting protocol buffers?
<p>I'm looking for a command-line utility that will, at a minimum, render binary protobuf data in human-readable form. Filtering and selection options (along the lines of <code>cut</code> for text) would be nice, but the primary object is to make the data visible for debugging purposes.</p> <p>If there is no definitive tool for the job, links to relevant packages are fine.</p>
<unix><command-line-interface><protocol-buffers>
2016-01-22 17:38:46
HQ
34,952,984
React native flexbox - how to do percentages || columns || responsive || grid etc
<p>After working with react native on iOS for the last couple of weeks, I seem to have come across some shortcomings of flex styling... Particularly when it comes to "responsive" behavior. </p> <p>For instance, lets say you want to create a view that contains cards (the metadata for these cards comes from an API). You want the cards to be 50% of the view width minus the margin &amp; padding, and to wrap after each 2.</p> <p><a href="https://i.stack.imgur.com/IKGF1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IKGF1.jpg" alt="enter image description here"></a></p> <p>The current implementation I have for this view splits the returned array into rows with 2 items. The list container has <code>flex: 1, flexDirection: 'column</code>, the rows have <code>flex: 1</code> and then each card has <code>flex: 1</code>. The end result is each row has 2 columns which evenly take up half the view width. </p> <p>It seems like there is no trivial way to do this in React Native styles, without using javascript to do some sort of pre-processing on the data so that it comes out styled correctly. Does anyone have any suggestions? </p>
<javascript><css><reactjs><flexbox><react-native>
2016-01-22 17:51:47
HQ
34,953,398
Where is this image being generated on my webpage?
<p>I can't figure out where the chain link image is coming from on my blogger page (<a href="http://jareds94-wine.blogspot.com" rel="nofollow">http://jareds94-wine.blogspot.com</a>). Using Google Chrome's inspect feature I can see that it has something to do with hentry::before but it's not coming from the CSS so it must be coming form a javascript file right? Any help would be much appreciate as I'm trying to change it to another image.</p>
<javascript><html><css>
2016-01-22 18:17:26
LQ_CLOSE
34,953,711
Unwrap inner type when enum variant is known
<p>I have this enum type:</p> <pre><code>enum Animal { Dog(i32), Cat(u8), } </code></pre> <p>Now I have a function that takes this type as parameter. I <em>know</em> (for some reason) that the input is always a <code>Cat</code>. I want to achieve this:</p> <pre><code>fn count_legs_of_cat(animal: Animal) -&gt; u8 { if let Animal::Cat(c) = animal { c } else { unreachable!() } } </code></pre> <p>Can I write this shorter and/or more idiomatic?</p>
<enums><rust>
2016-01-22 18:38:35
HQ
34,954,032
How do i fix success is not a function error
<p>I'm getting the following error in my console Uncaught TypeError: success is not a function</p> <p>The error gets caught in Chrome browser console here: <strong>success();</strong></p> <p>I figured success is not properly defined or is in the wrong area. The following JavaScript that I'm using is:</p> <pre><code> if (jQuery === undefined) { // This ensures that jQuery is loaded before running document ready code: getScript('/imagesrv/apps/common/js/jq/jquery-1.8.3.min.js', function() { if (jQuery === undefined) { // Super failsafe - still somehow failed... bindAllHandlers(); } else { jQuery(document).ready(function(){ gpUtilsDocReady(); }); } }); } else { // jQuery was already loaded $(document).ready(function(){ gpUtilsDocReady(); }); } function gpUtilsDocReady() { $('div.headingarea').off('click').on('click', function() { $(this).closest('div.analystgroup').find('div.expandblock').toggle('normal'); $(this).closest('div.headingarea').toggleClass('boldText'); $(this).closest('div.headingarea').find('div.arrowdown').toggleClass('arrowright','arrowdown'); }); $("div.expandblock:first").show(); $("div.arrowdown:first").toggleClass('arrowright','arrowdown'); $("div.headingarea:first").toggleClass('boldText'); } function getScript(url, success) { var script = document.createElement('script'); script.src = url; var head = document.getElementsByTagName('head')[0], done = false; script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers if (!done &amp;&amp; (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { done = true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); }; }; head.appendChild(script); } function PTHTTPGETRequest_Replacement(url, functionOrDiv) { if (arguments.length == 1) { $.ajax(url); } else if (eval("typeof " + functionOrDiv + " == 'function'")) { $.ajax(url).complete(window[functionOrDiv] ); } else { $("#" + functionOrDiv).load(url, helpCallback(functionOrDiv)); } } //popup window functions function rawPopUp(url, width, height, features, target) { // attempt to clean up all random js popups var u = url; var t = target; var w = width; var h = height; var f = features; // return if there is no URL if (u == null) { return false; } // set up default values if none passed t = t ? t : "_blank"; w = w ? w : 990; h = h ? h : 650; f = f ? f : "resizable=yes,scrollbars=yes,toolbar=yes"; // find middle x and y position of the screen var left = (window.screen.width - w)/2; var top = (window.screen.height - h)/2; var newWin=null; var settings = 'width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ', ' + f; newWin = window.open(u, t, settings); newWin.focus(); return(newWin); } function openBio(href) { // opens Analysts Bio rawPopUp(href, '579', '450', 'scrollbars=yes,resizable=yes','_0'); return false; } var contentPopupInProgressMap = {}; /* * containerId - The unique id of the popup container div. It must also * contain a div with the id of &lt;containerId&gt;_content where * the html content will be loaded. The entire container will * be shown/hidden. * uniqueId - An id that is unique to the page for identifying the popup. * html - The html to display. * url - The query url for the html to display. * minDelayMs - The minimum delay until the popup is shown (hovering) * * Positioning is handled by the following pairs (if not supplied, * the popup will not be positioned): * absLeft/absCenter: Either the absolute left or center for the popup. * absTop/absMiddle: Either the absolute top or middle for the popup. */ function showContentPopup(args) { args = args || {}; var uniqueId = args.uniqueId; // Clear the popup delay for this source from the map. delete contentPopupInProgressMap[uniqueId]; var container = $('#' + args.containerId); if (container) { var popupInfo = jQuery.extend(true, {}, args); delete popupInfo["html"]; delete popupInfo["url" ]; popupInfo.startTime = new Date().getTime(); // Add it to the inProgress map. contentPopupInProgressMap[uniqueId]=popupInfo; if ('html' in args &amp;&amp; args.html) { $('#' + popupInfo.containerId + '_content').html(args.html); var minDelayMs = ('minDelayMs' in args &amp;&amp; args.minDelayMs) ? args.minDelayMs : 0; setTimeout("eval(" + "showContentPopup_callback('" + uniqueId + "')" + ")", minDelayMs); } else if ('url' in args &amp;&amp; args.url) { $.ajax({ url: args.url, success: function(html) { if(html) { $('#' + popupInfo.containerId + '_content').html(html); var minDelayMs = ('minDelayMs' in args &amp;&amp; args.minDelayMs) ? args.minDelayMs : 0; minDelayMs = Math.max((minDelayMs - (new Date().getTime() - popupInfo.startTime)), 0); setTimeout("eval(" + "showContentPopup_callback('" + uniqueId + "')" + ")", minDelayMs); } } }); } } } function hideContentPopup(uniqueId) { // Clear the delay. var popupInfo = contentPopupInProgressMap[uniqueId]; if (popupInfo) { $('#' + popupInfo.containerId).css('visibility', 'hidden'); } delete contentPopupInProgressMap[uniqueId]; } function showContentPopup_callback(uniqueId) { // Show the popup if in progress. var popupInfo = contentPopupInProgressMap[uniqueId]; if (popupInfo &amp;&amp; !popupInfo.visibile) { var container = $('#' + popupInfo.containerId); if ('absCenter' in popupInfo &amp;&amp; popupInfo.absCenter&gt; 0) { // Always keep the top edge of the container in view. container.offset({ left: Math.max(popupInfo.absCenter - (container.width()/2), 2) }); } else if ('absLeft' in popupInfo &amp;&amp; popupInfo.absLeft &gt;= 0) { container.offset({ left: popupInfo.absLeft }); } if ('absMiddle' in popupInfo &amp;&amp; popupInfo.absMiddle &gt; 0) { // Always keep the left edge of the container in view. container.offset({ top: Math.max(popupInfo.absMiddle - (container.height()/2), $(window).scrollTop() + 2) }); } else if ('absTop' in popupInfo &amp;&amp; popupInfo.absTop &gt;= 0) { container.offset({ top: popupInfo.absTop }); } container.css('visibility', 'visible'); popupInfo.visibile = true; } } function submitSearch(formName, location) { rForm = eval('document.' + formName); typeaheadTermType = document.getElementById("typeaheadTermType").value; typeaheadTermId = document.getElementById("typeaheadTermId").value; rForm.keywords.value = document.getElementById("keywords").value; if (typeaheadTermType) { if (typeaheadTermType.toLowerCase() == 'title') { document.getElementById("typeaheadTermType").value = ''; document.getElementById("typeaheadTermId").value = ''; rForm.keywords.value = escape(document.getElementById("keywords").value); window.location = documentdisplayurl + typeaheadTermId; return false; } } if (isValidKeyword(rForm.keywords.value)) { rForm.submit(); return false; }else if (isEmptyKeyword(rForm.keywords.value)) { alert("Please provide keywords for your search"); return false; } else { alert("Your search is too general. Please provide keywords for your search."); return false; } } function isValidKeyword(keywords) { if (keywords.match(/[A-Z]+/g) || keywords.match(/[a-z]+/g) || keywords.match(/[0-9]+/g)) { return true; } if(keywords == "" || keywords == null) { return true; } return false; } function isEmpty(control) { var s = control.value; // Trim leading whitespace. s = s.replace(/^\s+/g, ''); return (s.length == 0); } function isEmptyKeyword(keywords) { if (keywords.match(/^ *$/)) { return true; } if(keywords == "" || keywords == null) { return true; } return false; } &lt;!-- Searchbox autocomplete-related functionality --&gt; function getkey(e) { if (window.event) return window.event.keyCode; else if (e) return e.which; else return null; } &lt;!-- The submitSearch function must be implemented in the containing page. --&gt; function searchboxKeyPress(e, formName, location){ if (getkey(e)==13){ submitSearch(formName, location); return false; } else { return true; } } if (window.hdrSearchBox_InitTypeAheadSearch2) { function autocompleteCallbackSearchResults(searchboxName) { var location = searchboxName.replace('/keywords/',''); submitSearch('gSearchForm', location) } //typeaheadsugurl is defined in header.ftl for search dojo.addOnLoad(function() { hdrSearchBox_InitTypeAheadSearch(typeaheadsugurl,'gSearchForm', 'keywords', 'divSearchSuggestionsSearchResults', 'autocompleteCallbackSearchResults', 10); }); } function hdrSearchBox_InitTypeAheadSearch(typeaheadLink, formName, searchboxName, suggestionsDivName, callbackFunctionName, numResults) { //alert("personalized search:"+personalizedSearch); var minChars = 3; // Define an event handler to populate a hidden form field // when an item gets selected var typeaheadTermType = YAHOO.util.Dom.get("typeaheadTermType"); var typeaheadTermId = YAHOO.util.Dom.get("typeaheadTermId"); initTypeAheadSearch( { formName: formName, searchboxName: searchboxName, suggestionsDivName: suggestionsDivName, minQueryLength : minChars, url: typeaheadLink + '?num=' + numResults + '&amp;minChars=' + minChars + '&amp;keywords=', requestSchema: { resultsList : "suggestions", fields : [ { key: "term" }, { key: "count" }, { key: "separator" }, { key: "id" }, { key: "type" } ] }, formatResultFunction : function(oResultData, sQuery, sResultMatch) { document.getElementById("divSearchHistoryResults").innerHTML = ''; // Cast to Strings. sQuery = String(sQuery); // Preserve only alphanumerics, spaces, and the - symbol. sQuery = sQuery.replace(/[^a-zA-Z0-9 -]|^\s+|\s+$/g, ''); // Collapse all duplicate spaces. sQuery = sQuery.replace(/\s+/g, ' '); var displayItem = String(oResultData.term); var type = String(oResultData.type); var idx = displayItem.toLowerCase().indexOf(sQuery.toLowerCase()); var pre = (idx&gt; -1) ? displayItem.substr(0, idx) : ''; var sel = (idx&gt; -1) ? displayItem.substr(idx, sQuery.length) : ''; var post = (idx&gt; -1) ? displayItem.substr(idx + sQuery.length): displayItem; var aMarkup = ['']; if( oResultData.separator &amp;&amp; type != 'term') { var header = ""; if (type == 'title') { header = "Titles"; } else if (type == 'analyst') { header = "Analysts"; } else if (type == 'vendor') { header = "Vendors"; } else if (type == 'term') { header = "Keywords"; } aMarkup = ['&lt;div class=\"clusterTitle\"&gt; &lt;span class="TypeAheadBold"&gt;' + header + '&lt;/span&gt;&lt;/div&gt;&lt;ul class=\"smartClusters\"&gt;&lt;div class=\"TypeAheadWitdh\"&gt;', pre, '&lt;span class="TypeAheadBold"&gt;', sel, '&lt;/span&gt;', post, '&lt;/div&gt;&lt;/ul&gt;']; } else { aMarkup = ['&lt;div class="TypeAheadWitdh"&gt;', pre, '&lt;span class="TypeAheadBold"&gt;', sel, '&lt;/span&gt;', post, '&lt;/div&gt;']; } return (aMarkup.join('')); }, itemSelectEventFunction:function(sType, aArgs ) { var myAC = aArgs[0]; // reference back to the AC instance var elLI = aArgs[1]; // reference to the selected LI element var oData = aArgs[2]; // object literal of selected item's result data // update hidden form fields with the selected item's id and type typeaheadTermId.value = oData.id; typeaheadTermType.value = oData.type; // Disable autocomplete. eval(searchboxName + 'Enabled' + '=false;'); // Set a timeout to re-enable the typeahead. setTimeout(searchboxName + "Enabled=true", 3000); // Execute the callback. eval(callbackFunctionName + "('" + searchboxName + "')"); }, callbackFunction : callbackFunctionName, // Turn off local cache. queryMatchSubset : false, maxResults: numResults }); } // Basic type ahead configuration. function initTypeAheadSearch(oArgs) { // Create a var to track autocomplete enabled/disabled. eval(oArgs.searchboxName + 'Enabled' + '=true'); function autocompleteIsDisbabled() { return eval(oArgs.searchboxName + 'Enabled' + '==false'); } // Trap form submit for the form containing the autocomplete. YAHOO.util.Event.addListener( YAHOO.util.Dom.get(oArgs.formName), "submit", function(e, myForm) { YAHOO.util.Event.stopEvent(e); // Disable autocomplete. eval(oArgs.searchboxName + 'Enabled' + '=false;'); // Set a timeout to re-enable the typeahead. setTimeout(oArgs.searchboxName + "Enabled=true", 3000); } ); // Datasource. var ds = new YAHOO.util.XHRDataSource(oArgs.url); ds.connTimeout=5000; ds.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; ds.responseSchema = oArgs.requestSchema; ds.connXhrMode = 'cancelStaleRequests'; ds.maxCacheEntries = oArgs.maxCacheEntries ? oArgs.maxCacheEntries : 10; ds.queryMatchSubset = oArgs.queryMatchSubset ? oArgs.queryMatchSubset : false; // Create and configure the control. var autocomplete = new YAHOO.widget.AutoComplete(oArgs.searchboxName, oArgs.suggestionsDivName, ds); // Only the item of interest should be returned // (and thus appended to the url). autocomplete.generateRequest = function(sQuery) { return sQuery; }; autocomplete.forceSelection = oArgs.forceSelection ? true : false; autocomplete.maxResultsDisplayed = oArgs.maxResults ? oArgs.maxResults : 5; autocomplete.minQueryLength = oArgs.minQueryLength ? oArgs.minQueryLength : 2; autocomplete.queryDelay = oArgs.queryDelay ? oArgs.queryDelay :0.2; autocomplete.typeAheadDelay = autocomplete.queryDelay + 0.1; autocomplete.typeAhead=true; if (oArgs.header) { autocomplete.setHeader(oArgs.header); } if (oArgs.body) { autocomplete.setBody(oArgs.body); } if (oArgs.footer) { autocomplete.setFooter(oArgs.footer); } autocomplete.animVert = oArgs.animVert ? oArgs.animVert : true; autocomplete.animHoriz = oArgs.animHoriz ? oArgs.animHoriz :false; autocomplete.animSpeed = oArgs.animSpeed ? oArgs.animSpeed : 0.05; autocomplete.autoHighlight = oArgs.autoHighlight ? oArgs.autoHighlight : false; // Disable the browser's built-in autocomplete caching mechanism autocomplete.allowBrowserAutocomplete = false; autocomplete.prehighlightClassName = "yui-ac-prehighlight"; autocomplete.resultTypeList = false; autocomplete.formatResult = oArgs.formatResultFunction; // Block suggestion expansion of any in-progress requests. autocomplete.doBeforeLoadData = function(oResultData, sQuery, sResultMatch) { return !autocompleteIsDisbabled(); }; if (!autocomplete.forceSelection) { // Hook the ENTER key to disable the autocomplete and execute the callback. function checkReturn(e) { var keyno = YAHOO.util.Event.getCharCode(e); if (!autocompleteIsDisbabled() &amp;&amp; keyno == 13) { // Disable autocomplete. eval(oArgs.searchboxName + 'Enabled' + '=false;'); // Set a timeout to reenable the typeahead. setTimeout(oArgs.searchboxName + "Enabled=true", 3000); return eval(oArgs.callbackFunction + "('" + oArgs.searchboxName + "')"); } } YAHOO.util.Event.addListener(autocomplete.getInputEl(), "keypress", checkReturn); } // Hook item selection to populate hidden fields and disable the autocomplete and execute the callback. if (oArgs.itemSelectEventFunction) { try { autocomplete.itemSelectEvent.subscribe(oArgs.itemSelectEventFunction); } catch (excep) { } }else{ // Hook item selection to disable the autocomplete and execute the callback. try { autocomplete.itemSelectEvent.subscribe(function( oSelf , elItem , oData ) { // Disable autocomplete. eval(oArgs.searchboxName + 'Enabled' + '=false;'); // Set a timeout to re-enable the typeahead. setTimeout(oArgs.searchboxName + "Enabled=true", 3000); // Execute the callback. eval(oArgs.callbackFunction + "('" + oArgs.searchboxName + "')"); }); } catch (excep) { } } } function changeSearchView(viewId,isTabChange) { //var arr = viewIdbaseUrl.split("|"); //var viewId = arr[0]; //var baseUrl = arr[1]; //TODO: Handle Browse URL redirection here based on the viewId //Based on the viewId - determine the baseUrl - This is defined in main-nav.ftl if(viewId == 2){ baseUrl = researchUrl; }else if(viewId == 12){ baseUrl = analystUrl; } var keywords = document.getElementById("keywords").value //Allow null keywords var url = baseUrl + '?keywords=' + encodeURIComponent(keywords); if(isTabChange) { url += '&amp;tabChg=true'; } window.location = url; } function showSearchHistory() { var keywords = document.getElementById("keywords").value if(isEmptyKeyword(keywords)){ $.ajax({ type: 'GET', url: searchhistoryurl, success: function(htmlVal) { document.getElementById("divSearchHistoryResults").innerHTML = htmlVal; } }); } } function submitSearchHistory(searchterm) { document.getElementById("keywords").value = searchterm; submitSearch('gSearchForm',''); return false; } </code></pre>
<javascript>
2016-01-22 19:01:54
LQ_CLOSE
34,954,630
Java - Read line using InputStream
<p>I use InputStream to read some data, so I want to read characters until new line or '\n'. </p>
<java><inputstream>
2016-01-22 19:40:40
HQ
34,954,726
How do you add/remove to a redux store generated with normalizr?
<p>Looking the examples from the <a href="https://github.com/gaearon/normalizr">README</a>:</p> <p>Given the "bad" structure:</p> <pre><code>[{ id: 1, title: 'Some Article', author: { id: 1, name: 'Dan' } }, { id: 2, title: 'Other Article', author: { id: 1, name: 'Dan' } }] </code></pre> <p>It's extremely easy to add a new object. All I have to do is something like </p> <pre><code>return { ...state, myNewObject } </code></pre> <p>In the reducer.</p> <p>Now given the structure of the "good" tree, I have no idea how I should approach it.</p> <pre><code>{ result: [1, 2], entities: { articles: { 1: { id: 1, title: 'Some Article', author: 1 }, 2: { id: 2, title: 'Other Article', author: 1 } }, users: { 1: { id: 1, name: 'Dan' } } } } </code></pre> <p>Every approach I've thought of requires some complex object manipulation, which makes me feel like I'm not on the right track because normalizr is supposed to be making my life easier.</p> <p>I can't find any examples online of someone working with the normalizr tree in this way. <a href="https://github.com/rackt/redux/tree/master/examples/real-world">The official example</a> does no adding and removing so it was no help either.</p> <p>Could someone let me know how to add/remove from a normalizr tree the right way?</p>
<javascript><reactjs><redux><normalizr>
2016-01-22 19:47:26
HQ
34,955,820
Exclude Java package from dependency jar
<p>I want to use jar from third party vendor. But in this jar I have old version of Java package <code>org.osgi.framework</code> I need to find some way to exclude the package from the main project. Something like this:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;com.ibm&lt;/groupId&gt; &lt;artifactId&gt;com.ibm.ws.admin.client&lt;/artifactId&gt; &lt;version&gt;8.5.0&lt;/version&gt; &lt;exclusions&gt; &lt;exclusion&gt;org.osgi.framework&lt;/exclusion&gt; &lt;/exclusions&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/dependency&gt; </code></pre> <p>Can you recommend some solution?</p>
<maven><jar><dependencies><maven-3>
2016-01-22 20:57:05
HQ
34,955,987
Pass data through navigation back button
<p>I am in this situation:</p> <p><a href="https://i.stack.imgur.com/si4UZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/si4UZ.png" alt="img1"></a></p> <p>I am passing 4 array from Progress Table to Detail Exercise using prepare for segue and it works fine! The problem begin when I try to pass the data back from the Detail Exercise Controller to the Progress Table Controller. I would like to use the default navigation back button to go back to the parent view. Actually I'm using this code but it doesn't work, well the data pass from the child to the parent view but i can't see the result in the Progress Table, seems like i need to refresh but i also tryed the reloadData after the viewDidLoad and it doesn't work. Any suggestion? Thank you.</p> <pre><code>override func viewWillDisappear(animated : Bool) { super.viewWillDisappear(animated) if (self.isMovingFromParentViewController()){ print("n'drio") let historyView = self.storyboard!.instantiateViewControllerWithIdentifier("historyView") as! HistoryTableViewController historyView.isFirstTime = false historyView.arrayData = arrayDataDetails historyView.arrayRipetizioni = arrayRipetizioniDetails historyView.arrayPeso = arrayPesoDetails historyView.arrayRecupero = arrayRecuperoDetails historyView.tableView.reloadData() } } </code></pre>
<ios><swift><uinavigationcontroller><pass-data>
2016-01-22 21:08:40
HQ
34,956,826
Excel help - how many times number occurs in other numbers
So i have to make something to my job, I have like different values of meal vouchers and I want to type price of persons payout, and i want to know how many of each meal vouchers i have to give them. here is picture for better understanding. **So in the picture there is example, person gets payout 64€ and how many of 4.2 , 4 , 3.8..... vounchers he has to get. I want it to work like im gonna say the payout value and it is going to tell me exatcly how many vouchers of each times person is going to get, i will be very happy for any help !**[Image of excelss table][1] [1]: http://i.stack.imgur.com/jjexf.png
<excel><excel-formula>
2016-01-22 22:14:14
LQ_EDIT
34,957,345
Passing value from ViewController to NSObject in Xcode
I need to pass value from a ViewController to NSObject as soon as the view loaded using Xcode with Objective c. I am using the code below but the value is null. -(void)viewDidAppear:(BOOL)animated { MyHomeModelNSObject *nsOb; nsOb.myString = self.userName.text; } The above code is working between Views when using segue, but it does not work with when passing the value to NSObject. Thanks
<objective-c><nsobject>
2016-01-22 22:58:26
LQ_EDIT
34,957,575
var result = string.split('').forEach(...); Doesn't work in JavaScript
<p>In Javascript, why is result below <code>undefined</code>? </p> <pre><code>var x = "happy"; var result = x.split('').forEach(function(val,index,array){ array[index] = "0"; }); console.log(result); </code></pre> <p>The output is:</p> <pre><code>undefined </code></pre>
<javascript>
2016-01-22 23:19:47
LQ_CLOSE
34,957,790
Use plotly offline to generate graphs as images
<p>I am working with plotly offline and am able to generate an html file using</p> <pre><code>plotly.offline.plot({"data": data, "layout": layout}) </code></pre> <p>It works great. The graph is generated correctly and the html file gets saved to my current directory. </p> <p>What I want, though is, using plotly offline, is to have an image (.png, .jpg, etc.) file saved instead. Am I on the right track? What do I need to do from here?</p>
<python><html><image><python-2.7><plotly>
2016-01-22 23:41:51
HQ