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
39,248,014
Undefined_index ajax call
<h2>Hi Hello Every One i Start A New Code But i can not figure out the error on my code</h2> <p>The Code wen i send a call to my script like this <a href="http://www.mywebsite.com/savedata.php?user_id=abc" rel="nofollow">http://www.mywebsite.com/savedata.php?user_id=abc</a></p> <p>and this is my code</p> <pre><code>&lt;?php header('Access-Control-Allow-Origin: *'); error_reporting(E_ALL); ini_set('display_errors',1); $servername = "localhost"; $username = "user_name"; $password = "pass"; try { $conn = new PDO("mysql:host=$servername;dbname=mydb_name", $username, $password); // set the PDO error mode to exception $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e){ echo "Connection failed: " . $e-&gt;getMessage(); } if(isset($_GET['user_id'])){ //$user_id = intval($_GET['user_id']); //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks try { $dbh = new PDO("mysql:host=$servername;dbname=db_name", $username, $password); $user_id = @$_GET['user_id']; $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // &lt;== add this line $sql = "INSERT INTO users (user_id) VALUES ('".$_POST["user_id"]."')"; if ($dbh-&gt;query($sql)) { echo "&lt;script type= 'text/javascript'&gt;alert('New Record Inserted Successfully');&lt;/script&gt;"; } else{ echo "&lt;script type= 'text/javascript'&gt;alert('Data not successfully Inserted.');&lt;/script&gt;"; } $dbh = null; } catch(PDOException $e){ echo $e-&gt;getMessage(); } } ?&gt; $sql-&gt;execute(array($user_Id)); if($sql){ //The query returned true - now do whatever you like here. echo 'Your ID was saved. Congrats!'; }else{ //The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine. echo 'There was a problem saving your points. Please try again later.'; } }else{ echo 'Your id wasnt passed in the request.'; } // close MySQL connection $conn = null; ?&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;body bgcolor="#ffffff"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<php><ajax>
2016-08-31 11:10:03
LQ_CLOSE
39,248,985
Ruby Error on method: Array can't be coerced into Fixnum
I'm a beginner Ruby coder and working on a simple multiplying method. CODE: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: Ruby --> def multiply(*numbers) product = 1 numbers.each{|number| product *= number } return product end puts multiply([2, 3, 4, 5]) <!-- end snippet --> OUTPUT: `*': Array can't be coerced into Fixnum (TypeError) from calculator.rb:26:in `block in multiply' from calculator.rb:24:in `each' from calculator.rb:24:in `multiply' from calculator.rb:31:in `<main>' I get this error. It seems the method isn't allowing me to use ".each" on the array. Also, I want to keep the parameter as *numbers in case it's not an array but two numbers to multiply. I should bring it to your attention that the method works fine when the parameter being passed are two numbers and not an array (i.e. multiply(2, 4) Thanks in advance :D
<ruby>
2016-08-31 11:55:08
LQ_EDIT
39,249,048
How to scrape all metrics from a federate endpoint?
<p>We have a hierachical prometheus setup with some server scraping others. We'd like to have some servers scrape all metrics from others.</p> <p>Currently we try to use <code>match[]="{__name__=~".*"}"</code> as a metric selector, but this gives the error <code>parse error at char 16: vector selector must contain at least one non-empty matcher</code>.</p> <p>Is there a way to scrape all metrics from a remote prometheus without listing each (prefix) as a match selector?</p>
<prometheus>
2016-08-31 11:58:37
HQ
39,250,011
Is there any easy way to merge two arrays in swift along with removing duplicates?
<p>Basically I need a version of <code>appendContentsOf:</code> which does not append <strong>duplicate</strong> elements.</p> <p><strong>Example</strong></p> <pre><code>var a = [1, 2, 3] let b = [3, 4, 5] a.mergeElements(b) //gives a = [1, 2, 3, 4, 5] //order does not matter </code></pre>
<arrays><swift><swift2>
2016-08-31 12:42:57
HQ
39,250,449
React Native - TouchableOpacity not working inside an absolute positioned View
<p>I've got an absolute positioned View that holds 3 TouchableOpacity components and the 3 fail to respond they are just not working at all, what is going wrong here please help me :)</p> <p><strong>Code</strong></p> <pre><code>&lt;View style={[styles.highNormalLowDocListHeaderStateContainer, {width: this.windowWidth, height: this.headerSmallHeight, position: 'absolute', left: 0, top: floatedHeaderTitleTop, elevation: 2}]}&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('high')} style={[styles.highNormalLowDocListHeaderStateTextContainer, highSelected.borderStyle]}&gt; &lt;Text style={[styles.highNormalLowDocListHeaderStateText, highSelected.textStyle]}&gt;HIGH&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('normal')} style={[styles.highNormalLowDocListHeaderStateTextContainer, normalSelected.borderStyle]}&gt; &lt;Text style={[styles.highNormalLowDocListHeaderStateText, normalSelected.textStyle]}&gt;NORMAL&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('low')} style={[styles.highNormalLowDocListHeaderStateTextContainer, lowSelected.borderStyle]}&gt; &lt;Text style {[styles.highNormalLowDocListHeaderStateText, lowSelected.textStyle]}&gt;LOW&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;/View&gt; </code></pre> <p><strong>Screenshot</strong></p> <p><a href="https://i.stack.imgur.com/kLCUU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kLCUU.png" alt="enter image description here"></a></p>
<android><react-native>
2016-08-31 13:03:15
HQ
39,250,610
setting up OpenVPN to limit access to certain http dirs
<p>Im trying to configure everything in order to allow only VPN users to accesss to certain folders (wp-admin etc) and the thing is that by following some tutorials like <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04</a> i can connect to my openvpn (it gives me a 10.8.0.X ip through tun0 and the external IP is my server's one when checking at <a href="http://www.whatsmyip.org/" rel="nofollow">http://www.whatsmyip.org/</a> but when i enter my own server domain in my browser it sees my real IP (getenv('REMOTE_ADDR') shows my real IP) and not the one from the VPN so i cant set up a .htaccess file to restrict to my own server IP.</p> <p>As a summary of above tutorial config, i have:</p> <h2>/etc/openvpn/server.conf</h2> <pre><code>dh2048.pem push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 208.67.222.222" push "dhcp-option DNS 208.67.220.220" user nobody group nogroup </code></pre> <h2>/proc/sys/net/ipv4/ip_forward</h2> <pre><code>1 </code></pre> <h2>/etc/sysctl.conf</h2> <pre><code>net.ipv4.ip_forward=1 </code></pre> <h2>/etc/default/ufw</h2> <pre><code>DEFAULT_FORWARD_POLICY="ACCEPT" </code></pre> <h2>/etc/ufw/before.rules</h2> <pre><code># START OPENVPN RULES # NAT table rules *nat :POSTROUTING ACCEPT [0:0] # Allow traffic from OpenVPN client to eth0 -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE COMMIT # END OPENVPN RULES </code></pre> <h2>ufw status verbose:</h2> <pre><code>root@XXX:/# ufw status verbose Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), allow (routed) New profiles: skip To Action From -- ------ ---- 1194/udp ALLOW IN Anywhere 22/tcp ALLOW IN Anywhere 53 (Bind9) ALLOW IN Anywhere 80/tcp (Apache) ALLOW IN Anywhere 443/tcp (Apache Secure) ALLOW IN Anywhere 1194/udp (v6) ALLOW IN Anywhere (v6) 22/tcp (v6) ALLOW IN Anywhere (v6) 53 (Bind9 (v6)) ALLOW IN Anywhere (v6) 80/tcp (Apache (v6)) ALLOW IN Anywhere (v6) 443/tcp (Apache Secure (v6)) ALLOW IN Anywhere (v6) </code></pre> <p>Is there something im missing or a different workaround?</p> <p>Thank you in advance,</p>
<wordpress><apache><.htaccess><openvpn>
2016-08-31 13:11:41
LQ_CLOSE
39,251,005
Strange generic function appear in view controller after converting to swift 3
<p>In my project, after converting to swift 3, a new function appeared before my <code>ViewController</code> class: </p> <pre><code>fileprivate func &lt; &lt;T : Comparable&gt;(lhs: T?, rhs: T?) -&gt; Bool { switch (lhs, rhs) { case let (l?, r?): return l &lt; r case (nil, _?): return true default: return false } } </code></pre> <p>What does this function do? Why do I need it? </p>
<ios><swift><swift3>
2016-08-31 13:29:09
HQ
39,251,219
Find the approximate value in the vector
<p>I have a number of the vector with the numbers.</p> <pre><code>test &lt;- 0.495 vector &lt;- c(0.5715122, 2.2860487, 5.1436096, 9.1441949) </code></pre> <p>This vector is the need to take an approximate number to the number 0.495. Help me. </p>
<r>
2016-08-31 13:37:43
LQ_CLOSE
39,251,291
Is it possible to filter options requests in chrome inspector?
<p>I'm building a web application which uses CORS to communicate with it's server.</p> <p>This means that every request is preceded by one with OPTIONS method.</p> <p>Is it possible to filter those out in inspector? It makes a lot of unnecessary clutter on network tab.</p>
<google-chrome-devtools>
2016-08-31 13:40:59
HQ
39,252,731
Counting duplicate characters in Python string
I can't figure out why always the last character in a string gets omitted when I try the below. def duplicate_count(text): num = 0 count = {} for char in text: print(count.items()) if char in count.keys(): count[char] += 1 else: count [char] = 1 for key in count: if count[key] == 1: num = 0 else: num = count[key] - 1 return (num) char_s = 'abcde' print (duplicate_count(char_s))
<python><string><python-3.x>
2016-08-31 14:45:12
LQ_EDIT
39,253,152
How to exclude/disable a specific auto-configuration in Spring boot 1.4.0 for @DataJpaTest?
<p>I am using the @DataJpaTest from Spring for my test which will then use H2 as in memory database as <a href="https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4#testing-the-jpa-slice" rel="noreferrer">described here</a> . I'm also using Flyway for production. However once the test starts FLyway kicks in and reads the SQL file. How can I exclude the FlywayAutoConfiguration and keep the rest as described <a href="http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#test-auto-configuration" rel="noreferrer">here in spring documentation</a> in order to let Hibernate create the tables in H2 for me? </p> <pre><code>@RunWith(SpringRunner.class) @DataJpaTest public class MyRepositoryTest { @Autowired private TestEntityManager entityManager; @Autowired private MyRepository triggerRepository; } </code></pre>
<spring><unit-testing><spring-data-jpa>
2016-08-31 15:05:55
HQ
39,253,307
Export GIT LOG into an Excel file
<p>I have looked into the forum, but with no luck.</p> <p>Requirement :</p> <p>Run GIT LOG (format) command and write the results into an Excel File . </p> <p>I have seen examples wherein with GIT Log command, data can be written into a CSV, but formatting is double the effort.</p> <p>Any utility or approach would be helpful.</p> <p>Thanks Milind</p>
<git><logging>
2016-08-31 15:13:57
HQ
39,253,923
How companies develop (android) apps?
<p>i was curious about app dev procces. How companies develop their apps? If you have idea for app than what is the best way to make it real. </p> <p>1.Idea 2.Design 2.Wireframe 3.Coding 4.Publish 5.Fixing bugs</p> <p>This what i think how it works. I would happy if can someone expend this list and make it more complex. Thank for you answers!</p>
<android>
2016-08-31 15:45:43
LQ_CLOSE
39,254,040
Is it possible to prioritise a lock?
<p>I have a <code>multiprocessing</code> program where</p> <ul> <li>one process adds elements to a shared list (<code>multiprocessing.Manager().list()</code>)</li> <li>several other processes consume these elements from that list (and remove them); they run until there is something to process in the list and the process above is still adding to the list.</li> </ul> <p>I implemented locking (via <code>multiprocessing.Lock()</code>) when adding to the list, or removing from it. Since there is one "feeder" process and several (10-40) "consumer" ones all competing for the lock, and that the consumer processes are fast, I end up with the "feeder" process having a hard time acquiring the lock.</p> <p><strong>Is there a concept of "priority" when acquiring a lock?</strong> I would like the "feeder" process to acquire it with more priority than the others.</p> <p>Right now I mitigated the issue by having the "consumer" processes wait a random time before trying to acquire the lock while the "feeder" process is there (when it ends it sets a flag). This is a workaround which works but it is ugly and hardly effective (I have the processes wait <code>random.random()*n</code> seconds, where <code>n</code> is the number of processes. This is a completely made up number, probably wrong). </p>
<python><python-3.x><multiprocessing><python-multiprocessing>
2016-08-31 15:52:02
HQ
39,254,110
What is the correct name for IEEE Std 1003.1, 2004 Edition: POSIX.1-2001 or POSIX.1-2004?
<p>I came across two POSIX documents online.</p> <ul> <li><a href="http://pubs.opengroup.org/onlinepubs/009695399/">http://pubs.opengroup.org/onlinepubs/009695399/</a> (IEEE Std 1003.1, 2004 Edition) <blockquote> <p><strong>Abstract:</strong> The 2004 edition incorporates Technical Corrigendum Number 1 and Technical Corrigendum 2 addressing problems discovered since the approval of the 2001 edition. These are mainly due to resolving integration issues raised by the merger of the Base documents.</p> </blockquote></li> <li><a href="http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/9699919799/</a> (IEEE Std 1003.1β„’, 2013 Edition) <blockquote> <p><strong>Abstract:</strong> POSIX.1-2008 is simultaneously IEEE Std 1003.1β„’-2008 and The Open Group Technical Standard Base Specifications, Issue 7. This 2013 Edition includes IEEE Std 1003.1-2008/Cor 1-2013 incorporated into IEEE Std 1003.1-2008 (the base document). The 2013 edition incorporates Technical Corrigendum 1 addressing problems discovered since the approval of the 2008 edition.</p> </blockquote></li> </ul> <p>I want to know whether the first document is known as POSIX.1-2001 or POSIX.1-2004.</p> <p>The <a href="https://en.wikipedia.org/wiki/POSIX">Wikipedia article on POSIX</a> mentions the first one as POSIX.1-2004. But why? The base document of the first one is 2001 edition. So shouldn't it still be called POSIX.1-2001? The 2004 edition only adds TC1 and TC2 to the base document.</p> <p>For example, see the second one. Although it is 2013 edition but since the base document is 2008 edition, it is called POSIX.1-2008. Then why is the first one not called POSIX.1-2001?</p>
<posix><standards>
2016-08-31 15:56:20
HQ
39,254,597
Heroku - No web process running
<p>I made a twitter bot using tweepy in Python and tried deploying it using Heroku. The Bot just tweets after certain intervals. After deploying it, the Python program just doesn't run and Heroku log shows the following error : </p> <pre><code>at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=fathomless-island-25537.herokuapp.com request_id=0aa76d12-31e6-4940-85ec-a8476af4f82f fwd="182.64.210.145" dyno= connect= service= status=503 bytes= </code></pre> <p>After looking through some similar problems where a django app has to be deployed, I tried:</p> <pre><code>heroku ps:scale web=1 </code></pre> <p>and got:</p> <pre><code>Scaling dynos... ! ! Couldn't find that formation. </code></pre> <p>Does it mean that the program failed to establish a web process or is there something else related to dynos ? Or if I have to include some code related to dynos in my program ? I don't know which part of this whole process has a problem. Apologies if it's too basic.</p>
<python><python-3.x><heroku><tweepy>
2016-08-31 16:23:52
HQ
39,254,676
Roslyn compiler optimizing away function call multiplication with zero
<p>Yesterday I found this strange behavior in my C# code:</p> <pre><code>Stack&lt;long&gt; s = new Stack&lt;long&gt;(); s.Push(1); // stack contains [1] s.Push(2); // stack contains [1|2] s.Push(3); // stack contains [1|2|3] s.Push(s.Pop() * 0); // stack should contain [1|2|0] Console.WriteLine(string.Join("|", s.Reverse())); </code></pre> <p>I assumed the program would print <code>1|2|0</code> but in fact it printed <code>1|2|3|0</code>.</p> <p>Looking at the generated IL code (via ILSpy) you can see that <code>s.Pop() * 0</code> is optimized to simply <code>0</code>:</p> <pre><code>// ... IL_0022: ldloc.0 IL_0023: ldc.i4.0 IL_0024: conv.i8 IL_0025: callvirt instance void class [System]System.Collections.Generic.Stack`1&lt;int64&gt;::Push(!0) // ... </code></pre> <p><em>ILSpy decompilation</em>:</p> <pre><code>Stack&lt;long&gt; s = new Stack&lt;long&gt;(); s.Push(1L); s.Push(2L); s.Push(3L); s.Push(0L); // &lt;- the offending line Console.WriteLine(string.Join&lt;long&gt;("|", s.Reverse&lt;long&gt;())); </code></pre> <p>First I tested this initially under Windows 7 with Visual Studio 2015 Update 3 with both Release mode (<code>/optimize</code>) and Debug mode and with various target frameworks (4.0, 4.5, 4.6 and 4.6.1). In all 8 cases the result was the same (<code>1|2|3|0</code>).</p> <p>Then I tested it under Windows 7 with Visual Studio 2013 Update 5 (again with all the combinations of Release/Debug mode and target framework). To my surprise the statement is here <em>not</em> optimized away and yields the expected result <code>1|2|0</code>.</p> <p>So I can conclude that this behavior is neither dependent on <code>/optimize</code> nor the target framework flag but rather on the used compiler version.</p> <p>Out of interest I wrote a similar code in C++ and compiled it with the current gcc version. Here a function call multiplied with zero is not optimized away and the function is properly executed.</p> <p>I think such an optimization would only be valid if <code>stack.Pop()</code> were a pure function (which it definitely isn't). But I'm hesitant to call this a bug, I assume it's just a feature unknown to me?</p> <p>Is this "feature" anywhere documented and is there an (easy) way to disable this optimization?</p>
<c#><optimization><visual-studio-2015><roslyn>
2016-08-31 16:28:00
HQ
39,255,182
Why does Apple's documentation only show the properties and method signatures but not the actual code?
<p>I'm exploring Apple's documentation and would like to understand how classes such as UIApplication do what they do under the hood however if you command click "UIApplication", Xcode only shows UIApplication's properties and method signatures but not the actual code inside the methods. I figured this would be valuable information to know if we could see what's going on inside of Apple's provided classes but why isn't it available for us to know or see? </p> <p>For example, here is what's shown if you command click UIApplication: </p> <pre><code>public class UIApplication : UIResponder { public class func sharedApplication() -&gt; UIApplication unowned(unsafe) public var delegate: UIApplicationDelegate? public func beginIgnoringInteractionEvents() // nested. set should be set during animations &amp; transitions to ignore touch and other events public func endIgnoringInteractionEvents() public func isIgnoringInteractionEvents() -&gt; Bool // returns YES if we are at least one deep in ignoring events public var idleTimerDisabled: Bool // default is NO public func openURL(url: NSURL) -&gt; Bool @available(iOS 3.0, *) public func canOpenURL(url: NSURL) -&gt; Bool public func sendEvent(event: UIEvent) public var keyWindow: UIWindow? { get } public var windows: [UIWindow] { get } public func sendAction(action: Selector, to target: AnyObject?, from sender: AnyObject?, forEvent event: UIEvent?) -&gt; Bool public var networkActivityIndicatorVisible: Bool // showing network spinning gear in status bar. default is NO // default is UIStatusBarStyleDefault // The system only calls this method if the application delegate has not // implemented the delegate equivalent. It returns the orientations specified by // the application's info.plist. If no supported interface orientations were // specified it will return UIInterfaceOrientationMaskAll on an iPad and // UIInterfaceOrientationMaskAllButUpsideDown on a phone. The return value // should be one of the UIInterfaceOrientationMask values which indicates the // orientations supported by this application. @available(iOS 6.0, *) public func supportedInterfaceOrientationsForWindow(window: UIWindow?) -&gt; UIInterfaceOrientationMask public var statusBarOrientationAnimationDuration: NSTimeInterval { get } // Returns the animation duration for the status bar during a 90 degree orientation change. It should be doubled for a 180 degree orientation change. public var statusBarFrame: CGRect { get } // returns CGRectZero if the status bar is hidden public var applicationIconBadgeNumber: Int // set to 0 to hide. default is 0. In iOS 8.0 and later, your application must register for user notifications using -[UIApplication registerUserNotificationSettings:] before being able to set the icon badge. @available(iOS 3.0, *) public var applicationSupportsShakeToEdit: Bool @available(iOS 4.0, *) public var applicationState: UIApplicationState { get } @available(iOS 4.0, *) public var backgroundTimeRemaining: NSTimeInterval { get } @available(iOS 4.0, *) public func beginBackgroundTaskWithExpirationHandler(handler: (() -&gt; Void)?) -&gt; UIBackgroundTaskIdentifier @available(iOS 7.0, *) public func beginBackgroundTaskWithName(taskName: String?, expirationHandler handler: (() -&gt; Void)?) -&gt; UIBackgroundTaskIdentifier @available(iOS 4.0, *) public func endBackgroundTask(identifier: UIBackgroundTaskIdentifier) /*! The system guarantees that it will not wake up your application for a background fetch more frequently than the interval provided. Set to UIApplicationBackgroundFetchIntervalMinimum to be woken as frequently as the system desires, or to UIApplicationBackgroundFetchIntervalNever (the default) to never be woken for a background fetch. This setter will have no effect unless your application has the "fetch" UIBackgroundMode. See the UIApplicationDelegate method `application:performFetchWithCompletionHandler:` for more. */ @available(iOS 7.0, *) public func setMinimumBackgroundFetchInterval(minimumBackgroundFetchInterval: NSTimeInterval) /*! When background refresh is available for an application, it may launched or resumed in the background to handle significant location changes, remote notifications, background fetches, etc. Observe UIApplicationBackgroundRefreshStatusDidChangeNotification to be notified of changes. */ @available(iOS 7.0, *) public var backgroundRefreshStatus: UIBackgroundRefreshStatus { get } @available(iOS 4.0, *) public var protectedDataAvailable: Bool { get } @available(iOS 5.0, *) public var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection { get } // Return the size category @available(iOS 7.0, *) public var preferredContentSizeCategory: String { get } } </code></pre>
<ios><swift><xcode><apple-documentation>
2016-08-31 16:59:52
LQ_CLOSE
39,255,311
Can you use @ViewChild() or similar with a router-outlet? How if so?
<p>I repeatedly run into a situation where I'd like to access a child component existing on the other side of a router outlet rather than a selector:</p> <pre><code>Like: &lt;router-outlet&gt;&lt;/router-outlet&gt; NOT: &lt;selector-name&gt;&lt;/selector-name&gt; </code></pre> <p>This conflicts with the ViewChild functionality as I know it, yet it seems like my component should be able to see and interact with what's inside that router-outlet just as easily as with what's inside a selector-tag.</p> <p>For instance I tried this:</p> <pre><code>export class RequestItemCatsComp { @ViewChild('child') child: RequestItemsComp; ***etc...*** ngAfterViewInit() { if (this.child) // Always child is undefined this.groupId = this.child.groupId; } } </code></pre> <p>But naturally, <strong>child is undefined</strong> because this is the wrong way. Is there a right way?</p> <p>I'm trying to use a service to share the data but then run into another problem "expression has changed after it was checked" which I'm hoping to remedy without a hack or enabling prod mode.</p>
<angular><angular2-routing><angular2-services>
2016-08-31 17:08:28
HQ
39,255,973
Split 1 column into 3 columns in spark scala
<p>I have a dataframe in Spark using scala that has a column that I need split.</p> <pre><code>scala&gt; test.show +-------------+ |columnToSplit| +-------------+ | a.b.c| | d.e.f| +-------------+ </code></pre> <p>I need this column split out to look like this:</p> <pre><code>+--------------+ |col1|col2|col3| | a| b| c| | d| e| f| +--------------+ </code></pre> <p>I'm using Spark 2.0.0</p> <p>Thanks</p>
<scala><apache-spark>
2016-08-31 17:47:31
HQ
39,256,341
How to use Action Filters with Dependency Injection in ASP.NET CORE?
<p>I use constructor-based dependency injection everywhere in my <code>ASP.NET CORE</code> application and I also need to resolve dependencies in my action filters:</p> <pre><code>public class MyAttribute : ActionFilterAttribute { public int Limit { get; set; } // some custom parameters passed from Action private ICustomService CustomService { get; } // this must be resolved public MyAttribute() { } public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { // my code ... await next(); } } </code></pre> <p>Then in Controller:</p> <pre><code>[MyAttribute(Limit = 10)] public IActionResult() { ... </code></pre> <p>If I put ICustomService to the constructor, then I'm unable to compile my project. So, how do I supossed to get interface instances in action filter?</p>
<c#><asp.net><asp.net-mvc><asp.net-core><action-filter>
2016-08-31 18:11:10
HQ
39,256,682
Interface for dynamic key in typescript
<p>I have an Object like this that is created by underscore's <code>_.groupBy()</code> method.</p> <pre><code>myObject = { "key" : [{Object},{Object2},{Object3}], "key2" : [{Object4},{Object5},{Object6}], ... } </code></pre> <p>How would I define that as an Interface with TypeScript? i don't want to simply define it as <code>myObject:Object = { ...</code> but rather have an own type for it.</p>
<typescript>
2016-08-31 18:33:52
HQ
39,257,547
AttributeError: 'dict' object has no attribute 'cpe_mac'
I'm trying to print out all the cpe_mac fields of my API via python. I have # Last updated : BH | 8/31/2016 import requests import json ssc_ip = raw_input("What is your SSC Host (Ex. http://172.19.242.32:1234/ ) ? : ") if not ssc_ip: ssc_ip = 'http://172.19.242.32:1234/' cpe_num = raw_input("How many CPE(s) you want to delete ? : ") print '\n' url = ssc_ip+'vse/vcpes' json_data = requests.get(url).json() # print json_data for x in json_data: print json_data.cpe_mac ___ I kept getting >AttributeError: 'dict' object has no attribute 'cpe_mac'
<python>
2016-08-31 19:26:39
LQ_EDIT
39,257,740
How to access state inside Redux reducer?
<p>I have a reducer, and in order to calculate the new state I need data from the action and also data from a part of the state not managed by this reducer. Specifically, in the reducer I will show below, I need access to the <code>accountDetails.stateOfResidenceId</code> field.</p> <p><strong>initialState.js:</strong></p> <pre><code>export default { accountDetails: { stateOfResidenceId: '', accountType: '', accountNumber: '', product: '' }, forms: { blueprints: [ ] } }; </code></pre> <p><strong>formsReducer.js:</strong></p> <pre><code>import * as types from '../constants/actionTypes'; import objectAssign from 'object-assign'; import initialState from './initialState'; import formsHelper from '../utils/FormsHelper'; export default function formsReducer(state = initialState.forms, action) { switch (action.type) { case types.UPDATE_PRODUCT: { //I NEED accountDetails.stateOfResidenceId HERE console.log(state); const formBlueprints = formsHelper.getFormsByProductId(action.product.id); return objectAssign({}, state, {blueprints: formBlueprints}); } default: return state; } } </code></pre> <p><strong>index.js (root reducer):</strong></p> <pre><code>import { combineReducers } from 'redux'; import accountDetails from './accountDetailsReducer'; import forms from './formsReducer'; const rootReducer = combineReducers({ accountDetails, forms }); export default rootReducer; </code></pre> <p>How can I access this field?</p>
<javascript><reactjs><redux>
2016-08-31 19:40:49
HQ
39,257,937
3 variables (collumns) to be combined in 1 variable (collumn)
[1] click on the photo to see the demo data Either in Excel or in SPSS To combine the 3 colluns into 1 and to be able then to calculate the statistics of the collumn. Mean Median Moden Frequencies and all these. Anny help would be appreciated. Thank you in advance. [1]: http://i.stack.imgur.com/B5BPz.jpg
<database><excel><statistics>
2016-08-31 19:53:28
LQ_EDIT
39,258,250
How to detect if 64 bit MSVC with cmake?
<p>I have a project which uses cmake, one target is set to only build with MSVC:</p> <pre><code> if (MSVC) add_library(test SHARED source.cpp) endif() </code></pre> <p>Now the other issue is that this target is only designed for MSVC 32bit. So how can I detect that the generator is MSVC64 and skip this target?</p>
<visual-studio><cmake>
2016-08-31 20:13:02
HQ
39,258,979
Notepad++ view hidden characters
<p>I have a string that has been giving some of my code fits of rage and its got "extra" characters in it that I only stumbled upon by using the arrow keys to go through it. I noticed that the cursor stayed in place in certain areas for an extra keystroke of the arrow key. Using View >Show Symbols > Show All Characters still didnt seem to indicate anything there. What kind of character could be there and is there a plugin for it?</p>
<notepad++>
2016-08-31 21:04:08
HQ
39,259,098
What is the optimal way to return a private value from inside a class?
<p>I'm attempting to optimize my code for maximum readability and for that I need my code to be in-line through and through. I will present two snippets of code as an example. In my eyes the below one is more easier for the eyes. These snippets (one of them) would be stored in a class and setting <em>width</em> should only be possible inside the class while getting <em>Width</em> should always be possible.</p> <p><strong>A:</strong></p> <pre><code>private int width; public int Width { get { return width; } private set { } } </code></pre> <p><strong>B:</strong></p> <pre><code>private int width; public int Width() { return width; } </code></pre> <p>As far as I am concerned these two ways of achieving the same end result are identical. Because I would like to be thoroughly in-line in all my classes I wouldn't want to use both ways mixed together. The B-approach seems cleaner in my eyes.</p> <p><strong>Are there any downsides/upsides to either approach. Should one approach be favored over the other? Are A and B approaches really completely identical?</strong></p>
<c#><class><optimization><private><public>
2016-08-31 21:13:22
LQ_CLOSE
39,259,623
How to get the Main Activity to run after using a Splash Screen in Android Studio 2.1.3
I am just starting to learn about Android Development and in an exercise, I have to use a splash screen prior to starting my main activity in Android Studio. I currently have my splash screen coded by using the activity theme method as opposed to using the layout method. Everything in my code looks good in both the .java and .xml files (according to the software) because I have no errors yet every time I click the app icon in the emulator, it brings up the splash screen then the app exits without showing my main activity. Here's my code so far: SplashActivity.java package com.example.healthylife; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.content.Intent; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } } MainActivity.java: package com.example.healthylife; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } Here's my manifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.healthylife" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" > <activity android:name=".SplashActivity" android:label="@string/app_name" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> Any advice would be greatly appreciated.
<android><android-layout><splash-screen>
2016-08-31 21:56:16
LQ_EDIT
39,260,120
rebase vs reset vs revert? I just want to roll back
<p>Let's say I make a number of commits, let's call them 1, 2, 3, 4, 5, and 6 (hashes).</p> <p>Let's say I'm on a commit with hash 6. All I want to do is go back to hash 3, make it so the state of my codebase was as it was when I commited to hash 3 as if the other commit's never happened.</p> <p>When I look at answers like <a href="https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-a-sha-hash-in-git">this</a>, it seems like everybody has a different answer. <code>reset</code>, <code>revert</code>, <code>rebase</code>? I'm not even sure I know the difference between those three words in english.</p> <p>I just want to be at a previous commit. Can someone tell me how to do this?</p>
<git>
2016-08-31 22:41:48
HQ
39,260,407
Python Newbie: Accessing Objects within Lists
Newbie here. I am looking at a code given to me by a co-worker who no longer works with us. I have a list variable called rx. >> type(rx) type 'list' When I go to look inside rx[0] I get this: >> rx[0] <Thing.thing.stuff.Rx object at 0x10e1e1c10> Can anyone translate what this means? And, more importantly, how can I see what is inside this object within the rx list? Any help is appreciated.
<python><object><indexing>
2016-08-31 23:12:41
LQ_EDIT
39,260,521
how to replace all the zeros in javascript
How can I replace all the zeros in a javascript variable, I have some variables like this one: var a = 00000004567, and I need to replace the zeros with *, I'm using : a.replace(/0*\d/g,'*') the problem is that it returns -> ****567 Thanks
<javascript><regex>
2016-08-31 23:26:48
LQ_EDIT
39,260,595
Event Handlers in React Stateless Components
<p>Trying to figure out an optimal way to create event handlers in React stateless components. I could do something like this:</p> <pre><code>const myComponent = (props) =&gt; { const myHandler = (e) =&gt; props.dispatch(something()); return ( &lt;button onClick={myHandler}&gt;Click Me&lt;/button&gt; ); } </code></pre> <p>The drawback here being that every time this component is rendered, a new "myHandler" function is created. Is there a better way to create event handlers in stateless components that can still access the component properties?</p>
<javascript><reactjs>
2016-08-31 23:37:17
HQ
39,260,816
Override readonly variable lldb swift
<p>Is there a way in lldb to overwrite a readonly variable.</p> <p>For example if you had a struct</p> <pre><code>struct Object { let name: String } </code></pre> <p>Doing the following in at a breakpoint in Xcode with lldb</p> <pre><code>(lldb) expression object.name = "Tom" </code></pre> <p>Will result in</p> <pre><code>error: &lt;EXPR&gt;:2:19: error: cannot assign to property: 'name' is a get-only property </code></pre> <p>I fully understand why this happens, just want to know if there is an easy way to get around this during debugging?</p> <p>Please note this is in Swift &amp; <strong>NOT</strong> Objective-C</p>
<swift><lldb>
2016-09-01 00:05:37
HQ
39,261,204
typings vs @types NPM scope
<p>In some cases <code>typings</code> is used for handling TypeScript definitions (e.g. <a href="https://github.com/angular/angular2-seed">angular/angular2-seed</a>).</p> <p>In other cases scoped NPM <code>@types</code> packages are used with no <code>typings</code> involved (e.g. <a href="https://github.com/AngularClass/angular2-webpack-starter">AngularClass/angular2-webpack-starter</a>).</p> <p>What are the practical differences between them? Does one of them offer benefits for TypeScript development that the other doesn't?</p>
<typescript><npm><typescript-typings>
2016-09-01 01:01:05
HQ
39,261,460
Sql programming logic- beginner level
I am a beginner in Sql programming. any pointers would help me. Say we have table 1, table 2 say for one Server ID column in table 1 you have many application ID columns corresponding in table 2 Filter out many application ID columns for one particular server ID, then match it up with another markuptable (joining based on applicationtable. applnid= markup table.logical_name) you need to output the markup id listed for all the application ids for that particular server
<sql>
2016-09-01 01:36:43
LQ_EDIT
39,261,511
convert custom text to html
<p>Where can I find A code do this <a href="https://i.stack.imgur.com/FMjok.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FMjok.png" alt="enter image description here"></a></p> <p>to convert colored an aligned text to html . </p> <p>or what should search for to find something like that .</p>
<php><html>
2016-09-01 01:45:43
LQ_CLOSE
39,262,461
How to split domain-part from emailId in android?
I am making validation in email id in which I want to make condition for domain-part after "." not more than 255 character. for this I want to split domain-part after "." like "user@gmail.commmm" in this I want to split after ".".How can I do that code:- /*validation for email*/ private boolean isValidEmail(String email) {// validation for email Id boolean isValid = false; String expression = "^([_A-Za-z0-9-\\+])+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,255})$"; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(email); if (matcher.matches()) { isValid = true; } return isValid; }
<android>
2016-09-01 03:54:42
LQ_EDIT
39,263,221
i am trying to insert some data in database using this code
i'm using this code to insert image into databse but some error keep popping plz help me out <?php if(isset($_POST ['insert_post'])) { $product_title=$_POST['product_title']; $product_cat=$_POST['product_cat']; $product_brand=$_POST['product_brand']; $product_price=$_POST['product_price']; $product_desc=$_POST['product_desc']; $product_keyword=$_POST['product_keyword']; $product_img=$_FILES['product_image']['name']; $product_img_tmp=$_FILES['product_image']['tmp_name']; } echo $insert_product="insert into products (product_cat,product_brand,product_title,product_price,product_desc,product_imag e,product_keyword) values ('$product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_img','$product_keyword')"; ?>
<php><sql>
2016-09-01 05:21:35
LQ_EDIT
39,263,232
JIRA setup project constraints
How do I add the biz logic in the JIRA project where you can proceed to the next stage on only completing the earlier stages. I am aware that JIRA is a Agile scrum team tool, so it inherently is breaking fundamental agile principles. However, I am trying to define a kanban workflow where a set of tasks need to be completed before the next set of tasks can begin. I want to implement this biz rule in my board.
<jira-agile><agile-project-management>
2016-09-01 05:22:12
LQ_EDIT
39,263,358
super keyword unexpected here
<p>According to ES6 shorthand initialiser, following 2 methods are same:</p> <h2>In ES5</h2> <pre><code>var person = { name: "Person", greet: function() { return "Hello " + this.name; } }; </code></pre> <h2>In ES6</h2> <pre><code>var person = { name: "Person", greet() { return "Hello " + this.name; } }; </code></pre> <p>Do the ES6 way is in anyway different from the previous way? If not then using "super" inside them should be also treated as equal, which doesn't hold true, please see below two variaiton:</p> <h2>Below works</h2> <pre><code>let person = { greet(){ super.greet(); } }; Object.setPrototypeOf(person, { greet: function(){ console.log("Prototype method"); } }); person.greet(); </code></pre> <h2>Below fails</h2> <pre><code>let person = { greet: function(){ super.greet(); // Throw error: Uncaught SyntaxError: 'super' keyword unexpected here } }; Object.setPrototypeOf(person, { greet: function(){ console.log("Prototype method"); } }); person.greet(); </code></pre> <hr> <p>The only difference in above 2 examples is the way we declare method greet in person object, which should be same. So, why do we get error?</p>
<ecmascript-6><super>
2016-09-01 05:31:31
HQ
39,263,929
How can I read tar.gz file using pandas read_csv with gzip compression option?
<p>I have a very simple csv, with the following data, compressed inside the tar.gz file. I need to read that in dataframe using pandas.read_csv. </p> <pre><code> A B 0 1 4 1 2 5 2 3 6 import pandas as pd pd.read_csv("sample.tar.gz",compression='gzip') </code></pre> <p>However, I am getting error:</p> <pre><code>CParserError: Error tokenizing data. C error: Expected 1 fields in line 440, saw 2 </code></pre> <p>Following are the set of read_csv commands and the different errors I get with them:</p> <pre><code>pd.read_csv("sample.tar.gz",compression='gzip', engine='python') Error: line contains NULL byte pd.read_csv("sample.tar.gz",compression='gzip', header=0) CParserError: Error tokenizing data. C error: Expected 1 fields in line 440, saw 2 pd.read_csv("sample.tar.gz",compression='gzip', header=0, sep=" ") CParserError: Error tokenizing data. C error: Expected 2 fields in line 94, saw 14 pd.read_csv("sample.tar.gz",compression='gzip', header=0, sep=" ", engine='python') Error: line contains NULL byte </code></pre> <p>What's going wrong here? How can I fix this?</p>
<python><csv><pandas><gzip><tar>
2016-09-01 06:15:12
HQ
39,264,364
vim: difference between :n and :bn
<p>If I started vim with multiple files like so <code>vim *.java</code>, I can cycle through opened files using either <code>:n</code> or <code>:bn</code> (and other related commands). </p> <p>But if I start with only one file and load other files using <code>:split</code> (and later close the split window), I can cycle the buffers using <code>:bn</code> but not <code>:n</code>. </p> <p>What is the difference between these two situations? If I do :buffers in both cases, there is no difference whatsoever in the buffer list. It might seem like I am asking unnecessary question but I would like to understand if there is any gotchas lurking under the hood. Thanks. </p>
<vim>
2016-09-01 06:43:31
HQ
39,264,480
what practice is better using pure javascript & css is or using frameworks?
<p>being a student which practice is better using pure javascript &amp; css or frameworks? And which is better for professional field?</p>
<javascript><css><frameworks>
2016-09-01 06:49:38
LQ_CLOSE
39,265,333
Guava's Immutable filtering via Java 8 parallel stream
Need help in filtering Guava's ImmutableTable via parallel stream and collector Immutable<fieldA1,fieldB1,Boolean> validEntry; Immutable<ObjectA, String, ObjectB> tofilter; ObjectA{ String fieldA1 String fieldA2 } ObjectB{ String fieldB1 String fieldB2 } Usecase : iterate over toFilter and remove elements which are not present or entry value is false in validEntry table. Map<ObjectA, Map<String, ObjectB>> rowMap = toFIlter.rowMap(); //This will result into stream of stream for(loop over rowMap){ for(Loop over rowMap entry){ if(present in validEntry){ //add entry to new table } } } build new table How can i utilize flat map to convert this stream of streams.
<java><java-8><guava><java-stream><collect>
2016-09-01 07:30:39
LQ_EDIT
39,265,450
Firebase Authen with Facebook error Need to upgrate
Error is showing in image below [enter image description here][1] [1]: http://i.stack.imgur.com/HV0qV.png
<facebook><firebase><upgrade><firebase-authentication>
2016-09-01 07:36:44
LQ_EDIT
39,265,604
Is it safe to use a method's nested procedure as a winapi callback?
<p>This is the simplified scenario, in Delphi 7:</p> <pre><code>procedure TMyClass.InternalGetData; var pRequest: HINTERNET; /// nested Callback procedure HTTPOpenRequestCallback(hInet: HINTERNET; Context: PDWORD; Status: DWORD; pInformation: Pointer; InfoLength: DWORD); stdcall; begin // [...] make something with pRequest end; begin pRequest := HTTPOpenRequest(...); // [...] if (InternetSetStatusCallback(pRequest, @HTTPOpenRequestCallback) = PFNInternetStatusCallback(INTERNET_INVALID_STATUS_CALLBACK)) then raise Exception.Create('InternetSetStatusCallback failed'); // [...] end; </code></pre> <p>The whole thing <strong>seems to work fine</strong>, but is it really correct and safe? I'd like to have it encapsulated this way because it's more readable and clean. My doubt is whether the nested procedure is a simple, normal procedure or not, so that it can have its own calling convention (<code>stdcall</code>) and safely reference outer method's local variables (<code>pRequest</code>).</p> <p>Thank you.</p>
<delphi><callback><delphi-7>
2016-09-01 07:45:14
HQ
39,265,771
Why we use Redis and what is the right way to implement Redis with MySql in PHP?
<p>I have large amount data in database, sometimes server not responding when execution of result is more than the server response time. So, is there any way to reduce the load of mysql server with redis and how to implement it with right way.</p>
<mysql><redis>
2016-09-01 07:53:55
HQ
39,266,016
Building a html, css & javascript pages for wordpress without php?
<p>So as the titles already states, is it possible to build a fully functioning wordpress page layout/theme using only frontend languages? And how will I incorporate it into wordpress without php?</p> <p>Thanks!!!</p>
<php><html><css><wordpress><layout>
2016-09-01 08:06:07
LQ_CLOSE
39,266,099
Using lists in foreach R
<p>I am trying to parallelize the extraction of data saved in some html documents and to store it into data.frames (some millions of documents, hence the usefulness of the parallelization).</p> <p>In a first step, on the machine where I do register the queue, I select a subset of the html files and lapply to them the read_html function (from the rvest package, I have also tried the similar function from the XML package but I was getting memory leak problems) to obtain a unique list storing the content of many html pages.</p> <p>Then I use an iterator on this list to obtain smaller chunks of it to be feeded to the foreach.</p> <p>Inside the foreach I build up the data.frame(s) (using html_table function and some basic data manipulation) and I return a list whose elements are the cleaned data.frames.</p> <p>I have tried to use both the doSNOW backend on win 8 and the doRedis one on ubuntu 16.04.</p> <p>In the first case a list of empty lists is returned while in the second one an error of memory mapping is thrown; you can find the traceback at the very bottom of the question.</p> <p>To my understanding the (chunks of) lists that I am sending to the cores are not behaving as I expect. I have gathered around that the list object may be just a set of pointers but I have not been able to confirm it; maybe this could be the issue? Is there an alternative to the "list way" to "encapsulate" the data of multiple html pages? </p> <p>Below you can find some code reproducing the issue. I am a completely new to stack overflow, new to parallel programming and fairly new to R programming: any advice for improvement is welcome. Thank you all in advance.</p> <pre><code>library(rvest) library(foreach) #wikipedia pages of olympic medalist between 1992 and 2016 are # downloaded for reproducibility for(i in seq(1992, 2016, by=4)){ html = paste("https://en.wikipedia.org/wiki/List_of_", i, "_Summer_Olympics_medal_winners", sep="") con = url(html) htmlCode = readLines(con) writeLines(htmlCode, con=paste(i, "medalists", sep="_")) close(con) } #declaring the redis backend (doSNOW code is also included below) #note that I am using the package from #devtools::install_github("bwlewis/doRedis") due to a "nodelay error" #(more info on that here: https://github.com/bwlewis/doRedis/issues/24) # if it is not your case please drop the nodelay and timeout options #Registering cores ---Ubuntu--- cores=2 library('doRedis') options('redis:num'=TRUE) registerDoRedis("jobs", nodelay=FALSE) startLocalWorkers(n=cores, "jobs", timeout=2, nodelay=FALSE) foreachOpt &lt;- list(preschedule=FALSE) #Registering cores ---Win--- #cores=2 #library("doSNOW") #registerDoSNOW(makeCluster(cores, type = "SOCK")) #defining the iterator iterator &lt;- function(x, ...) { i &lt;- 1 it &lt;- idiv(length(x), ...) if(exists("chunks")){ nextEl &lt;- function() { n &lt;- nextElem(it) ix &lt;- seq(i, length=n) i &lt;&lt;- i + n x[ix] } }else{ nextEl &lt;- function() { n &lt;- nextElem(it) ix &lt;- seq(i, i+n-1) i &lt;&lt;- i + n x[ix] } } obj &lt;- list(nextElem=nextEl) class(obj) &lt;- c( 'ivector', 'abstractiter','iter') obj } #reading files names_files&lt;-list.files() html_list&lt;-lapply(names_files, read_html) #creating iterator ChunkSize_html_list&lt;-2 iter&lt;-iterator(html_list, chunkSize=ChunkSize_html_list) #defining expanding list (thanks StackOverflow and many thanks to #JanKanis's answer : http://stackoverflow.com/questions/2436688/append-an-object-to-a-list-in-r-in-amortized-constant-time-o1 ) expanding_list &lt;- function(capacity = 10) { buffer &lt;- vector('list', capacity) length &lt;- 0 methods &lt;- list() methods$double.size &lt;- function() { buffer &lt;&lt;- c(buffer, vector('list', capacity)) capacity &lt;&lt;- capacity * 2 } methods$add &lt;- function(val) { if(length == capacity) { methods$double.size() } length &lt;&lt;- length + 1 buffer[[length]] &lt;&lt;- val } methods$as.list &lt;- function() { b &lt;- buffer[0:length] return(b) } methods } #parallelized part clean_data&lt;-foreach(ite=iter, .packages=c("itertools", "rvest"), .combine=c, .options.multicore=foreachOpt, .options.redis=list(chunkSize=1)) %dopar% { temp_tot &lt;- expanding_list() for(g in 1:length(ite)){ #extraction of data from tables tables &lt;- html_table(ite[[g]], fill=T, header = T) for(i in 1:length(tables)){ #just some basic data manipulation temp&lt;-lapply(tables, function(d){d[nrow(d),]}) temp_tot$add(temp) rm(temp) gc(verbose = F) } } #returning the list of cleaned data.frames to the foreach temp_tot$as.list() } </code></pre> <p>Error thrown when using the redis backend:</p> <pre><code>*** caught segfault *** address 0x60, cause 'memory not mapped' Traceback: 1: .Call("xml2_doc_namespaces", PACKAGE = "xml2", doc) 2: doc_namespaces(doc) 3: xml_ns.xml_document(x) 4: xml_ns(x) 5: xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = Inf) 6: xml_find_all.xml_node(x, ".//table") 7: xml2::xml_find_all(x, ".//table") 8: html_table.xml_document(ite[[g]], fill = T, header = T) 9: html_table(ite[[g]], fill = T, header = T) 10: eval(expr, envir, enclos) 11: eval(.doRedisGlobals$expr, envir = .doRedisGlobals$exportenv) 12: doTryCatch(return(expr), name, parentenv, handler) 13: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 14: tryCatchList(expr, classes, parentenv, handlers) 15: tryCatch({ lapply(names(args), function(n) assign(n, args[[n]], pos = .doRedisGlobals$exportenv)) if (exists(".Random.seed", envir = .doRedisGlobals$exportenv)) { assign(".Random.seed", .doRedisGlobals$exportenv$.Random.seed, envir = globalenv()) } tryCatch({ if (exists("set.seed.worker", envir = .doRedisGlobals$exportenv)) do.call("set.seed.worker", list(0), envir = .doRedisGlobals$exportenv) }, error = function(e) cat(as.character(e), "\n")) eval(.doRedisGlobals$expr, envir = .doRedisGlobals$exportenv)}, error = function(e) e) 16: FUN(X[[i]], ...) 17: lapply(work[[1]]$argsList, .evalWrapper) 18: redisWorker(queue = "jobs", host = "localhost", port = 6379, iter = Inf, linger = 30, log = stdout(), timeout = 2, nodelay = FALSE) aborting ... </code></pre>
<r><list><foreach><parallel-processing>
2016-09-01 08:10:51
HQ
39,266,701
Wordpress search strange behaviour
<p>Has anyone come across or have a fix for the following Wordpress search issue:</p> <p>When you search '<strong><em>degrees</em></strong>', you get results.</p> <p>If you search '<strong><em>degree</em></strong>', you get no results.</p> <p>Very strange!</p> <p>Live site demo here: <a href="http://advice.milkround.com" rel="nofollow">http://advice.milkround.com</a></p>
<php><mysql><wordpress><forms><search>
2016-09-01 08:42:33
LQ_CLOSE
39,267,773
Understanding fetch_assoc()
<p>I am trying to understand how/why fetch_assoc works the way it does. I have the following piece of code: </p> <pre><code>$results = $connectToDb-&gt;fetch("SELECT * FROM customer"); $resultsArray = $results-&gt;fetch_assoc(); print_r($resultsArray); //print_r 1 while($row = $results-&gt;fetch_assoc()){ print_r($row); //print_r 2 } </code></pre> <p>The query returns 3 rows from a table. Why does the 1st print_r return only the 1st row of the queried data but the 2nd print_r returns all 3? How does putting fetch_assoc into a while loop tell it to do the action more than once? I read that fetch_assoc returns either an associative array or NULL but I'm struggling to understand how the while loop "tells" fetch_assoc to fetch the next row, if that makes sense?</p> <p>Thank you.</p>
<php><methods>
2016-09-01 09:29:46
HQ
39,268,002
expression must have a class file directory c++
<p>I don't understand this error . i'am trying to create a folder with a variable inside </p> <pre><code>std::ostringstream gr; gr &lt;&lt; "C:/Users/titib/Contacts/Desktop/Projet informatique/groupe/" &lt;&lt; groupe; CreateDirectory(gr.str().c_str()); </code></pre> <p>error : create directory dont take 1 argument</p>
<c++>
2016-09-01 09:40:17
LQ_CLOSE
39,268,168
Change the color of cancel button in UIAlertController with preferredStyle: .ActionSheet
<p>Is it possible to change the color of cancel button to red , i know we can by using Destructive style</p> <pre><code> let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Destructive) { action -&gt; Void in print("Cancel") } </code></pre> <p>but i want the cancel button separately , like this <a href="https://i.stack.imgur.com/ll5uy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ll5uy.png" alt="enter image description here"></a></p>
<swift><uiactionsheet><uialertcontroller>
2016-09-01 09:47:31
HQ
39,268,788
Using Hash Table to count the frequencies
Can we use hash table for the following problems, if i am allowing extra storage O(N)? 1. Count the frequencies of all elements in an array ? 2. Count the number of occurences in an array ? 3. Finding which number is repeating maximum times in an array ?
<arrays><algorithm><hashtable>
2016-09-01 10:14:40
LQ_EDIT
39,268,906
Render a View inside a View in Asp.Net mvc
<p>How do I render a full fledged view (not partial view) inside another view?</p> <p>Scenario, I have different controller and want the exactly same view to render which is already there under other controller with different layout.</p> <p>I have Wishlist page in Home Controller which shows list of added products, and when user logged in , when I click on wish list it also show me navigation when user is signed in. </p> <p>How would I do that??</p>
<c#><asp.net><asp.net-mvc><asp.net-mvc-4>
2016-09-01 10:19:39
HQ
39,269,786
New Category not showing in News options tab in typo3
I have created new category but when I want to create news and assign to a particular category that new category does not come in the options categories list.[list of categories][1] [created new category name][2] [1]: http://i.stack.imgur.com/6Htis.png [2]: http://i.stack.imgur.com/zKwub.png
<php><typo3><typo3-flow><tx-news>
2016-09-01 11:01:48
LQ_EDIT
39,269,855
SQL Database - Finding the previous value in a table
I have table `queue` with values. `id name 1 apple 2 mango 3 banana`(I assumed this name,dont remember it exactly) But I accidentally changed it to be `id name 1 apple 2 mango 3 John` So I reverted it back to <br> `id name 1 apple 2 mango 3 banana` But now came to know that name is not banana for id =3. How can I know what used to be there before I changed it?
<sql><sql-server>
2016-09-01 11:04:43
LQ_EDIT
39,270,107
Finding an object in array and taking values from that to present in a select list
<p>I have a string value (e.g. "Table 1") that I need to use to find a specific object in an array that looks like so:</p> <pre><code>[ { lookups: [], rows: [{data: {a: 1, b: 2}}, {data: {a: 3, b: 4}}], title: "Table 1", columns: [{name: "a"}, {name: "b"}] }, { lookups: [], rows: [{data: {c: 5, d: 6}}, {data: {c: 7, d: 8}}], title: "Table 2", columns: [{name: "c"}, {name: "d"}] } ] </code></pre> <p>Once I have found that object I then need to take the values from the columns key and display them in a select list.</p> <p>I know how to do the second part, but it is getting access to the object in the first place that I am having trouble with. I am trying to do this within a React component render.</p> <p>Any help with this would be greatly appreciated.</p> <p>Thanks for your time.</p>
<arrays><reactjs><javascript-objects>
2016-09-01 11:17:42
HQ
39,270,123
Multi-line user input in iOS: UITextField vs UITextView
<p>I need to show users a multi-line text input "box" with a height greater than the standard height of a <code>UITextField</code>. What the best or most correct approach should be?:</p> <ol> <li>Using a <code>UITextField</code> and change its height in code or by applying a certain height constraint.</li> <li>Using an editable <code>UITextView</code>. This is multi-line but it has no placeholder by default, I guess I should implement that feature in code.</li> </ol>
<ios><swift><uitextfield><uitextview><multiline>
2016-09-01 11:18:41
HQ
39,270,992
creating self-signed certificates with open ssl on windows
<p>I am following <a href="https://jamielinux.com/docs/openssl-certificate-authority/create-the-intermediate-pair.html" rel="noreferrer">these guidelines</a> to generate self-signed certificates with OpenSSL.</p> <p>I am under Windows 10. My working directory is as follows:</p> <pre><code>PS E:\Certificats\predix\root\ca&gt; ls Directory: E:\Certificats\predix\root\ca Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/1/2016 11:57 AM certs d----- 9/1/2016 11:55 AM crl d----- 9/1/2016 12:00 PM intermediate d----- 9/1/2016 11:55 AM newcerts d----- 9/1/2016 11:56 AM private -a---- 9/1/2016 11:55 AM 2 index.txt -a---- 9/1/2016 11:56 AM 4306 openssl.cnf -a---- 9/1/2016 11:55 AM 14 serial </code></pre> <p>After several steps in the guideline, when I type</p> <pre><code>openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md s </code></pre> <p>I get the following error</p> <pre><code>Using configuration from openssl.cnf Enter pass phrase for ./private/ca.key.pem: unable to load number from ./serial error while loading serial number 12944:error:0D066096:asn1 encoding routines:a2i_ASN1_INTEGER:short line:.\crypto\asn1\f_int.c:212: PS E:\Certificats\predix\root\ca&gt; openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md sha256 -in intermediate/csr/intermediate.csr.pem -out intermediate/certs/intermediate.cert.pem Using configuration from openssl.cnf </code></pre> <p>telling me that it has some issue reading the serial file.</p> <p>The content of serial is</p> <pre><code>1000 </code></pre> <p>Does anyone have a fix for this ? The file exists and its pathname in the conf file is the correct...</p>
<openssl>
2016-09-01 11:58:05
HQ
39,271,230
Azure AD vs Azure AD B2C vs Azure AD B2B
<p>Before Azure AD B2C and Azure AD B2B come into the picture, usualy I added my applications to Azure AD of our tenancy and office 365 users could access the applications using their account (SSO).</p> <p>I am not a guru so I need to see code and read about exact examples to understand the concepts. </p> <p>Can I use B2C for SSO as I usually used Azure AD? otherwise how/when can I use B2C and B2B?</p> <p>Thanks and appreciate all kind of advice.</p>
<azure><azure-ad-b2c><azure-active-directory>
2016-09-01 12:10:02
HQ
39,272,179
How to run sql multi line queries in php?
<p>I want to run the following sql code in php and store the result in a variable:</p> <pre><code>declare @d1 datetime, @d2 datetime select @d1 = '9/9/2011', @d2 = '9/18/2011' select datediff(dd, @d1, @d2) - (datediff(wk, @d1, @d2) * 2) - case when datepart(dw, @d1) = 1 then 1 else 0 end + case when datepart(dw, @d2) = 1 then 1 else 0 end </code></pre> <p>Any help would be appreciated. Thanks!</p>
<php><mysql><sql>
2016-09-01 12:57:24
LQ_CLOSE
39,273,192
What is the most efficient way to convert this jekyll code to PHP?
<p>What is the most efficient way to convert this jekyll code to PHP?</p> <pre><code>{% for post in site.posts limit: 12 %} &lt;a href="{{post.url}}" style="background-image: url(assets/img/posts/thumbnails/{{post.thumbnail}})" class="academic-thumb"&gt; &lt;div class="academic-meta"&gt; &lt;div class="name"&gt; {{post.title}} &lt;/div&gt; &lt;/div&gt; &lt;/a&gt; {% endfor %} </code></pre>
<php><html><css><jekyll>
2016-09-01 13:42:36
LQ_CLOSE
39,273,283
Reassigning Variables via Destructuring
<p>I love Kotlin's destructuring features, they help me to declutter code and focus on the essential.</p> <p>I encountered a case for which I could not figure out the correct syntax, how can I reassign variables via destructing?</p> <pre><code>var (start, end) = startEndDate(198502) // intellij neither accept this ... start, end = startEndDate(200137) // ... nor this (start, end) = startEndDate(200137) </code></pre>
<kotlin>
2016-09-01 13:46:53
HQ
39,273,482
Turn Array objects into JSON using javascript or jquery
<p>I have dynamic data coming into my website like this:</p> <pre><code>[{ "itemOne": { "url": "www", "name": "Bob" }, "itemTwo": { "url": "www", "name": "fred" } }] </code></pre> <p>Using jQuery or Javascript, I would like to turn this data into JSON, so it would be structured like this:</p> <pre><code>"products": { "itemOne": { "url": pageUrl, "name": productName }, "itemTwo": { "url": pageUrl, "name": productName, } } </code></pre> <p>Is this possible? If so, how would I go about it?</p>
<javascript><jquery><arrays><json><object>
2016-09-01 13:56:03
LQ_CLOSE
39,273,877
Intellij Java 2016 & Maven : how to embed dependencies in JAR?
<p>I'm using Intellij Java 2016.2.2 and Maven to create a very simple Java console application.</p> <p>I want to add an external library, so I add my dependency in Maven like this:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;jline&lt;/groupId&gt; &lt;artifactId&gt;jline&lt;/artifactId&gt; &lt;version&gt;2.12&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>It works fine when I run it in the IDE, but not in an external console (I have the following error: <em>java.lang.NoClassDefFoundError</em>).</p> <p>I checked and for some reason, the external JAR is not added in the JAR I just generated. I also tried many things in "File -> Project Structure", but still not working...</p> <p>I just want to build my JAR with my dependencies in it, so I can simply run my application in a console using:</p> <pre><code>java -jar myproject.jar </code></pre> <p>How can I do that? Thanks for your help!</p>
<java><maven><intellij-idea><jar><dependencies>
2016-09-01 14:12:30
HQ
39,274,438
explaining constuctor and coppy costructor example
i have this code and i can understand what happening with the contractor of class Fat. #include <iostream> using namespace std; class Block{ int data; public: Block(int i = 10) : data(i) { cout << "I just created a Block " << endl; } ~Block() { cout << "I will destroy a Block with " << data << endl; } void inc() { data++; } }; class A{ Block& block1; Block block2; public : A(Block& blk) : block1(blk),block2(blk) { cout << "I just created an A " << endl; } A(const A& a): block1(a.block1), block2(a.block2) { cout << "I just created an A by copying but I will also do bad things" << endl; block1.inc(); block2.inc(); } ~A() { cout << "I will destroy an A " << endl; } void inc() { block1.inc(); block2.inc(); } }; class Fat{ A a; A& ra; A* pa; public: Fat(A& da) : a(da),ra(da) { pa = new A(da); cout << "Fat just created !" << endl;} ~Fat() { delete pa; cout << "Fat to be destroyed !" << endl; } void inc() { a.inc(); ra.inc(); pa->inc(); } }; int main(){ Block block; A a(block); Fat fat(a); fat.inc(); return 0; } and the result of this : I just created a Block I just created an A I just created an A by copying but I will also do bad things I just created an A by copying but I will also do bad things Fat just created ! I will destroy an A I will destroy a Block with 12 Fat to be destroyed ! I will destroy an A I will destroy a Block with 12 I will destroy an A I will destroy a Block with 11 I will destroy a Block with 15 why copy contractor run twice?
<c++>
2016-09-01 14:35:56
LQ_EDIT
39,274,630
Alphabetically sort array by sub-array's first element
<p>I'm looking for a way to sort an array that looks like this:</p> <pre><code>$array = array( [0] =&gt; array('a', '1', '2', '3', '4,' test'), [1] =&gt; array('c', '1', '2', '3', '5', 'test'), [2] =&gt; array('b', '1', '3', '4,' 5,', 'test), ); </code></pre> <p>so that it sorts the sub-array's according to the sub-array's first element, such that it returns:</p> <pre><code>$array = array( [0] =&gt; array('a', '1', '2', '3', '4,' test'), [1] =&gt; array('b', '1', '3', '4,' 5,', 'test), [2] =&gt; array('c', '1', '2', '3', '5', 'test'), ); </code></pre> <p>Does anyone have a good way about doing this?</p> <p>Thank you!</p>
<php><arrays><sorting>
2016-09-01 14:44:51
LQ_CLOSE
39,275,156
will the app store reject my app if I use a javascript sdk for the backend?
<p>I'm using Trigger.io to make an app I can deploy to both the app store and google play. I'm researching baas backends that offer native sdk's for android and apple, but also offer javascript sdk's which I assume are meant for things like Trigger or Phonegap. My question is do the app store guidelines favor one kind of back end service over another? Is javascript risky for backend? I just want to be sure before I pay for a service. The services I'm considering are cloudmine and shephertz. </p>
<javascript><appstore-approval><mbaas>
2016-09-01 15:08:02
LQ_CLOSE
39,275,533
Select row from a DataFrame based on the type of the object(i.e. str)
<p>So there's a DataFrame say:</p> <pre><code>&gt;&gt;&gt; df = pd.DataFrame({ ... 'A':[1,2,'Three',4], ... 'B':[1,'Two',3,4]}) &gt;&gt;&gt; df A B 0 1 1 1 2 Two 2 Three 3 3 4 4 </code></pre> <p>I want to select the rows whose datatype of particular row of a particular column is of type <code>str</code>.</p> <p>For example I want to select the row where <code>type</code> of data in the column <code>A</code> is a <code>str</code>. so it should print something like:</p> <pre><code> A B 2 Three 3 </code></pre> <p>Whose intuitive code would be like:</p> <pre><code>df[type(df.A) == str] </code></pre> <p>Which obviously doesn't works!</p> <p>Thanks please help!</p>
<python><pandas>
2016-09-01 15:26:20
HQ
39,275,889
How to embed new Youtube's live video permanent URL?
<p>I stream live on youtube a lot and since yesterday I experience a weird thing:</p> <p>I embedded the livestream URL in my site. it was <code>youtube.com/embed/ABCDE</code> (normal embed link). That link used to show the <strong>current</strong> livestream and not a specific video. for example:</p> <p>I'm streaming and you can watch it on <code>youtube.com/embed/ABCDE</code>. When i'm finished, the video gets its own url, something like <code>youtube.com/watch?v=FGHIJ</code>. In the next time I will stream, users can watch the stream on <code>youtube.com/embed/ABCDE</code> (that was a permanent url that didn't change).</p> <p>Now, every time I stream, the livestream get its own link at first place, which means I have to update my embed code manually every time I stream.</p> <p>I researched a bit around Google, SO and YouTube and I found out that a livestream's permanent url is <code>youtube.com/channel/CHANNEL_ID/live</code>. It's awesome and all, but I can't find a way to embed it.</p> <p>(I use wordpress and I didn't find any plugin to do it automatically for me).</p> <p><strong>TL:DR;</strong> how to embed the livestream in the page <code>youtube.com/channel/CHANNEL_ID/live</code>?</p>
<video><youtube><embed><live><live-streaming>
2016-09-01 15:45:32
HQ
39,276,024
Import Dependency Management with Exclusion
<p>I have a beautiful BOM with a lot of dependencies in its dependencyManagement section and I would like to <strong>create another BOM</strong> that imports all that dependencies <strong>except one</strong>. I tried doing this:</p> <pre><code>... in my dependencyManagement section &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-dependencies&lt;/artifactId&gt; &lt;version&gt;${spring-boot-version}&lt;/version&gt; &lt;type&gt;pom&lt;/type&gt; &lt;scope&gt;import&lt;/scope&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt; &lt;artifactId&gt;gson&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; ... </code></pre> <p>The POM is formally correct and everything compiles. <strong>But the exclusion is simply ignored. What am I missing? Is this approach correct?</strong></p> <p>I'm using Maven 3+.</p>
<maven>
2016-09-01 15:53:21
HQ
39,276,437
Powershell Array to comma separated string with Quotes
<p>I have an array that I need to output to a comma separated string but I also need quotes "". Here is what I have.</p> <pre><code>$myArray = "file1.csv","file2.csv" $a = ($myArray -join ",") $a </code></pre> <p>The output for <code>$a</code> ends up </p> <pre><code>file1.csv,file2.csv </code></pre> <p>My desired output is </p> <pre><code>"file1.csv","file2.csv" </code></pre> <p>How can I accomplish this?</p>
<arrays><string><powershell><join>
2016-09-01 16:18:07
HQ
39,276,514
Negation in condition while sending FCM message
<p>I am subscribing to a topic which is my application version in Android.</p> <pre><code>FirebaseMessaging.getInstance().subscribeToTopic(APP_VERSION); </code></pre> <p>Now every time I launch an update, I have to unsubscribe to an old version and subscribe to a new version so if I send an update notification only old users will get it. Instead, it would be great if I just negate a version. </p> <pre><code>"condition": "!'2.1.1' in topics", </code></pre> <p>Is something like this exists in FCM?</p>
<android><firebase><firebase-cloud-messaging>
2016-09-01 16:23:19
HQ
39,276,573
MS SQL query if table exist
Hey all I have the following query: SELECT COUNT(*) over () as countNum ,[F1] AS STANDARDandOBJ ,[F2] AS CLUSTER ,[F3] AS OBJECTIVE ,[F4] AS EXTRA0 IF COL_LENGTH([tmpExcelDB].[dbo].['Blahsing$'], [F5]) IS NOT NULL BEGIN print 'exists' END ELSE BEGIN print 'Nope' END ,CONCAT([F1], [F2]) AS combined FROM [tmpExcelDB].[dbo].['0812 Orientation to Nursing$'] WHERE LOWER(F3) NOT LIKE 'course tools-%' But it seems that I have an error of: Incorrect syntax near ','. Which is pointing to row: > ,CONCAT([F1], [F2]) AS combined How does this need to be formatted in order to work?
<sql><sql-server><sql-server-2012>
2016-09-01 16:27:13
LQ_EDIT
39,276,794
setTimeout in javascript executing timeout code right away and not waiting
<p>I have the following line in my javascript code</p> <pre><code>setTimeout(reload(), 30000); </code></pre> <p>Which I expect to wait 30 seconds then call the reload function. </p> <p>The issue is that the reload function is being called right away and not waiting for the timeout, why is the <code>setTimeout</code> calling the reload function right away and not waiting the specified amount of time? The <code>setTimeout</code> call is also being done in an <code>onloadend</code> <code>FileReader</code> function if that would make any difference.</p>
<javascript><settimeout>
2016-09-01 16:41:05
LQ_CLOSE
39,277,231
Swift - Put Red Dot on iPhone App Icon
<p>Any ideas how to apply a red dot to the iPhone App icon - like the Mail or Messages' Icon with the number of unread messages in it?</p> <p><a href="https://i.stack.imgur.com/0uVii.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0uVii.png" alt="enter image description here"></a></p>
<iphone><swift><icons>
2016-09-01 17:04:38
LQ_CLOSE
39,277,315
HMAC encryption in Swift 2
<p>Java provides <a href="https://docs.oracle.com/javase/7/docs/api/javax/crypto/Mac.html" rel="nofollow">MAC(Message Authentication Code) algorithm API</a> with which I can encrypt <code>data</code> by: </p> <pre><code>byte[] data = getDataBytes(); Mac mac = Mac.getInstance("HMAC-SHA256"); mac.init(new SecretKeySpec(key, "HMAC-SHA256")); byte[] encryptedBytes = mac.doFinal(data); </code></pre> <p>I am new in Swift, how can I implement the same thing as above with Swift 2 ?</p>
<swift><swift2><hmac>
2016-09-01 17:10:07
LQ_CLOSE
39,277,654
Babel not transpiling ES6 computed property names
<p>Babel is not transpiling ES6 computed property names. It compiles everything else though. Not sure what's going on. Using the latest version of cli. </p> <pre><code>var name = "John"; var age = 12; var count = 5; var postfix = 'age'; var person = { name, age, count, postfix, printName(){ console.log(this.name); this.count--; while(this.count){ this.printName(); } }, ['print' + this.postfix]: function(){ console.log(this.age); } }; person.printName(); person.printAge(); </code></pre> <p><strong>Babel output</strong> </p> <pre><code>var name = "John"; var age = 12; var count = 5; var postfix = 'age'; var person = _defineProperty({ name: name, age: age, count: count, postfix: postfix, printName: function printName() { console.log(this.name); this.count--; while (this.count) { this.printName(); } } }, 'print' + postfix, function () { // Look here console.log(this.age); }); </code></pre>
<javascript><ecmascript-6><babeljs><babel-cli>
2016-09-01 17:32:09
LQ_CLOSE
39,278,110
What's the command to "reset" a bokeh plot?
<p>I have a bokeh figure that has a reset button in the toolbar. Basically, I want to "reset" the figure when I update the data that I'm plotting in the figure. How can I do that?</p>
<python><plot><jupyter><bokeh>
2016-09-01 17:59:52
HQ
39,278,482
Multiple row updates at a time using single query statement from code behind file
<p>I am new to ASP.NET and I am trying to <strong>update multiple rows</strong> at a time using <strong>single query</strong> statement. I am getting <strong>row IDs</strong> on button click through hidden field which are separated by <strong>commas</strong> like "140","141","142"</p> <p>My .cs file code is </p> <pre><code>protected void ibtnNoBid_Click(Object sender, EventArgs e) { var req_id_values = hfrequestid.Value;//retrieveing values from hidden field on button click //single update query for multiple req_id_values separated by comma } </code></pre>
<c#><sql><asp.net><sql-server><sql-update>
2016-09-01 18:22:59
LQ_CLOSE
39,278,930
Can factory provider have optional dependencies?
<p>For example:</p> <pre><code>@NgModule ({ providers: [ { provide: MyService, useFactory: (optionalDep) =&gt; new MyService(optionalDep) deps: [SOME_DEP] } }) class MyModule {} </code></pre> <p>Can <strong>useFactory</strong> have optional dependencies? </p>
<angular><typescript><dependency-injection>
2016-09-01 18:54:09
HQ
39,279,552
OData Support in ASP.net core
<p>Is oData supported now in ASP.netcore now that version 1 has been released?</p> <p>I have searched, but I could not find anything that says one way or the other.</p>
<asp.net-core><odata>
2016-09-01 19:33:09
HQ
39,279,824
Use None instead of np.nan for null values in pandas DataFrame
<p>I have a pandas DataFrame with mixed data types. I would like to replace all null values with None (instead of default np.nan). For some reason, this appears to be nearly impossible. </p> <p>In reality my DataFrame is read in from a csv, but here is a simple DataFrame with mixed data types to illustrate my problem. </p> <pre><code>df = pd.DataFrame(index=[0], columns=range(5)) df.iloc[0] = [1, 'two', np.nan, 3, 4] </code></pre> <p>I can't do:</p> <pre><code>&gt;&gt;&gt; df.fillna(None) ValueError: must specify a fill method or value </code></pre> <p>nor:</p> <pre><code>&gt;&gt;&gt; df[df.isnull()] = None TypeError: Cannot do inplace boolean setting on mixed-types with a non np.nan value </code></pre> <p>nor:</p> <pre><code>&gt;&gt;&gt; df.replace(np.nan, None) TypeError: cannot replace [nan] with method pad on a DataFrame </code></pre> <p>I used to have a DataFrame with only string values, so I could do:</p> <pre><code>&gt;&gt;&gt; df[df == ""] = None </code></pre> <p>which worked. But now that I have mixed datatypes, it's a no go.</p> <p>For various reasons about my code, it would be helpful to be able to use None as my null value. Is there a way I can set the null values to None? Or do I just have to go back through my other code and make sure I'm using np.isnan or pd.isnull everywhere? </p>
<python><pandas><dataframe>
2016-09-01 19:51:12
HQ
39,280,057
How do you use @Input with components created with a ComponentFactoryResolver?
<p>Is there a method that can be used to define an @Input property on an Angular 2 component that's created dynamically?</p> <p>I'm using the <a href="https://angular.io/docs/ts/latest/api/core/index/ComponentFactoryResolver-class.html" rel="noreferrer">ComponentFactoryResolver</a> to create components in a container component. For example:</p> <pre><code>let componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentName); let componentRef = entryPoint.createComponent(componentFactory); </code></pre> <p>Where "entryPoint" is something like this in the component HTML:</p> <pre><code>&lt;div #entryPoint&gt;&lt;/div&gt; </code></pre> <p>And defined in my container component with:</p> <pre><code>@ViewChild('entryPoint', { read: ViewContainerRef } entryPoint: ViewContainerRef; </code></pre> <p>This works well, but I can't find a way to make an @Input property work on the newly created component. I know that you can explicitly set public properties on the component class, but this doesn't seem to work with ng-reflect. Prior to making this change I had a "selected" property decorated with "@Input()" that caused Angular to add the following to the DOM:</p> <pre><code>&lt;my-component ng-reflected-selected="true"&gt;&lt;/my-component&gt; </code></pre> <p>With this in place I was able to dynamically update the markup to switch a CSS class:</p> <pre><code>&lt;div class="header" [class.active-header]="selected === true"&gt;&lt;/div&gt; </code></pre> <p>Based on some searching I was able to find a method to make "@Output" work as expected, but I've yet to find anything for @Input.</p> <p>Let me know if additional context would be helpful and I'd be happy to add it.</p>
<angular>
2016-09-01 20:06:16
HQ
39,280,407
web 2.0 sucks huge floppy disks?
<p>I was able to create a web site 10 years ago with Microsoft Frontpage without learning anything, today with a copy of Adobe Dreamweaver CS6, I can't even figure out a way to change the font size of a simple text. CSS is the thing, so I went through the CSS tutorials in w3 and I get it now. It's a good idea, but It is also a good idea to kill creativity, ie all sites like similar, see screenshot below. It sucks floppy disks.</p> <p><a href="https://i.stack.imgur.com/AZO2h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AZO2h.jpg" alt="enter image description here"></a></p> <p>My questions will be:</p> <ol> <li><p>Does web 2.0 really kill creativity?</p></li> <li><p>Is there a "modern" web design application that I don't need to go into these CSS thing?</p></li> <li><p>Is there a way to create a circular navigation menu like this using css? I want to have this menu in the middle of the page, and with a button on the corner to activate it.</p></li> </ol> <p><img src="https://www.designinformer.com/wp-content/uploads/circular-menu-black.png" alt="a busy cat"></p>
<html><css><web>
2016-09-01 20:31:10
LQ_CLOSE
39,280,638
How to share conda environments across platforms
<p>The conda docs at <a href="http://conda.pydata.org/docs/using/envs.html" rel="noreferrer">http://conda.pydata.org/docs/using/envs.html</a> explain how to share environments with other people.</p> <p>However, the docs tell us this is not cross platform:</p> <pre><code>NOTE: These explicit spec files are not usually cross platform, and therefore have a comment at the top such as # platform: osx-64 showing the platform where they were created. This platform is the one where this spec file is known to work. On other platforms, the packages specified might not be available or dependencies might be missing for some of the key packages already in the spec. NOTE: Conda does not check architecture or dependencies when installing from an explicit specification file. To ensure the packages work correctly, be sure that the file was created from a working environment and that it is used on the same architecture, operating system and platform, such as linux- 64 or osx-64. </code></pre> <p>Is there a good method to share and recreate a conda environment in one platform (e.g. CentOS) in another platform (e.g. Windows)?</p>
<python><cross-platform><conda>
2016-09-01 20:49:23
HQ
39,281,032
How to conditionally apply CSS classes in React JS
<p>I've been musing on how best to conditionally apply a CSS class in React JS. I've seen some answers banding around but there aren't many out there or they're just not as elaborative as I'd like.</p>
<javascript><css><reactjs>
2016-09-01 21:19:59
HQ
39,281,217
How can I insert actual values in dataframe as columns in R?
<p>I know some basic R but I'm stuck with this dataframe handling. I need to be able to use a package or base function in R to transoform a dataframe like this.</p> <pre><code>id value variable 1 25.5 max_temp 1 16.4 min_temp 2 23.1 max_temp 3 12.1 min_temp </code></pre> <p>into this:</p> <pre><code>id max_temp min_temp 1 25.5 16.4 2 23.1 NA 3 NA 12.1 </code></pre> <p>Check the NA example as some observations have missing measurements. Actually I can fix it directly in excel file but I'm trying to do preprocessing less manually.</p> <p>Thanks.</p>
<r><dataframe>
2016-09-01 21:34:35
LQ_CLOSE
39,281,482
Routing between modules in Angular 2
<p>I'm writing an application where all features got it's own module (A feature could be a page, or a part of a page). This because we want all features to have it's own domain logic, services, directives and components, i.e. in the dashboard module we got an ChartComponent widget that I don't want to expose to other views like login or profile.</p> <p>The problem is when working with routing in Angular 2 you always routes to a particular component, not a module.</p> <p>In our case, to set up a route for path: '/dashboard' component: DashboardComponent we need to declare DashboardComponent in app.module.ts, and that's fine, but since we're still in the module app.module our CharComponent is not exposed and will not render in our DashboardComponent since it's declared in dashboard.module.ts and not app.module.ts.</p> <p>If we declare ChartComponent in app.module.ts it's working as it should but we lost the architecture for our application.</p> <p>The file structure for the application is something like this:</p> <pre><code>└─ src/ └─ app/ β”œβ”€ app.module.ts β”œβ”€ app.component.ts β”œβ”€ app.routing.ts β”œβ”€ profile/ | β”œβ”€ profile.module.ts | └─ profile.component.ts β”œβ”€ login/ | β”œβ”€ login.module.ts | └─ login.component.ts └─ dashboard/ β”œβ”€ dashboard.module.ts └─ dashboard.component.ts └─ chart/ └─ chart.component.ts </code></pre>
<angular><angular2-routing>
2016-09-01 21:57:00
HQ
39,281,930
Extracting parts of a string with regular expression
<p>I've a bunch of strings that contains a pattern, which I want to extract. It looks like the following:</p> <pre><code> str &lt;- "Regular Expression Language (AbcDfE-BB)" </code></pre> <p>So I would like two new columns, one with the "AbcDfE" part, and the other with the after - part, in this case "BB".</p>
<regex><r>
2016-09-01 22:43:20
LQ_CLOSE
39,282,184
For every CreateProcess, call my function first
<p>My idea is, to make a pop up window for every new process that will be created so I can be sure, that there are only processes with my permission.</p> <p>The question is, how I link my function in before Windows is creating the new process. </p> <p>I tried some dll injections but it does not work.</p> <p>Has anyone a solution for this problem or is it even not possible?</p> <p>Thanks!</p>
<c++><windows><createprocess>
2016-09-01 23:16:20
LQ_CLOSE
39,282,253
How can I alias a default import in Javascript?
<p>Using ES6 modules, I know I can alias a named import</p> <pre><code>import { foo as bar } from 'my-module'; </code></pre> <p>And I know I can import a default import</p> <pre><code>import defaultMember from 'my-module'; </code></pre> <p>I'd like to alias a default import and I had thought the following would work</p> <pre><code>import defaultMember as alias from 'my-module'; </code></pre> <p>but that results in a parsing (syntax) error.</p> <p>How can I (or can I?) alias a default import?</p>
<javascript><ecmascript-6><es6-modules>
2016-09-01 23:24:09
HQ
39,282,377
React native packager fails on node 6.5
<p>This was working previously. But since I upgraded from node 4.6 to 6.5, When I do an <code>npm start</code>, I end up with below error</p> <pre><code>Failed to build DependencyGraph: @providesModule naming collision: Duplicate module name: String.prototype.es6 Paths: ...../node_modules/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ...../app/MallJell/nd/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js This error is caused by a @providesModule declaration with the same name across two different files. Error: @providesModule naming collision: Duplicate module name: String.prototype.es6 Paths: ....../react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ..../react-packager/src/Resolver/polyfills/String.prototype.es6.js This error is caused by a @providesModule declaration with the same name across two different files. at HasteMap._updateHasteMap (..../node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:155:13) at module.getName.then.name (.....node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:115:31) </code></pre>
<react-native>
2016-09-01 23:43:40
HQ
39,282,417
Name and function for the following matrix operation in R
<p>I am trying to reproduce this [50 x 50] matrix generated with Python as:</p> <pre><code>n = 50 a = np.linspace(-5, 5, n).reshape(-1,1) b = a np.sum(a**2, 1).reshape(-1, 1) + np.sum(b**2, 1) </code></pre> <p>using R. The problem is that the result is some sort of matrix, which cannot be reproduced through:</p> <pre><code>n = 50 a = seq(-5, 5, length.out = n) b = a a^2 + b^2 </code></pre> <p>which generates a vector.</p> <p>I am not familiar with the object names in Python, but I see that <code>np.sum(a**2, 1).reshape(-1, 1)</code> produces what looks like a [50 x 1] column vector:</p> <pre><code>array([[ 2.50000000e+01], [ 2.30008330e+01], ... [ 2.10849646e+01], [ 2.30008330e+01], [ 2.50000000e+01]]) </code></pre> <p>while <code>np.sum(b**2, 1)</code>:</p> <pre><code>array([ 2.50000000e+01, 2.30008330e+01, 2.10849646e+01, 1.92523948e+01, 1.75031237e+01, 1.58371512e+01, ... 1.27551020e+01, 1.42544773e+01, 1.58371512e+01, 1.75031237e+01, 1.92523948e+01, 2.10849646e+01, 2.30008330e+01, 2.50000000e+01]) </code></pre> <p>looks like the transposed of that same vector. So we have an operation of the form [50 x 1] * [1 x 50] = [50 x 50].</p> <p>What is the generic name of this operation? And how can I reproduce it in R?</p>
<python><r><matrix>
2016-09-01 23:48:23
LQ_CLOSE
39,282,671
(need a code of vba) I Need to copy the rest of the data of row after empty cell into next empy row from start e.(A1,2.3)
I need to get rest of the data after empty cell into next available empty row of the same sheet. you can review the attached image of input, and output which is required result. Images can clear more that I want [Input][1] [Output(required result)][2] [1]: http://i.stack.imgur.com/OZCuV.png [2]: http://i.stack.imgur.com/NRJdG.png
<vba><excel>
2016-09-02 00:25:59
LQ_EDIT
39,282,911
Heroku/python failed to detect set buildpack
<p>I'm a Django newbie, I created an app and want to deploy it using Heroku. However, when I do <code>git push heroku master</code> (I follow Heroku's getting started), this is what I got:</p> <pre><code>Counting objects: 36, done. Delta compression using up to 4 threads. Compressing objects: 100% (33/33), done. Writing objects: 100% (36/36), 19.22 KiB | 0 bytes/s, done. Total 36 (delta 3), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----&gt; Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure remote: remote: ! Push failed remote: Verifying deploy.... remote: remote: ! Push rejected to dry-waters-63931. remote: To https://git.heroku.com/dry-waters-63931.git ! [remote rejected] master -&gt; master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/dry-waters-63931.git' </code></pre> <p>My root directory:</p> <pre><code>β”œβ”€β”€ assignment β”œβ”€β”€ household_management (django app) β”œβ”€β”€ templates | β”œβ”€β”€ db.sqlite3 | β”œβ”€β”€ manage.py </code></pre> <p>I will be very appreciated if you guys can help. I'm really depressed right now...</p>
<python><django><git><heroku><deployment>
2016-09-02 01:02:11
HQ
39,283,230
Evaluate Irrational with Julia
<p>Julia has the built-in constant <code>pi</code>, with type <code>Irrational</code>.</p> <pre><code>julia&gt; pi Ο€ = 3.1415926535897... julia&gt; Ο€ Ο€ = 3.1415926535897... julia&gt; typeof(pi) Irrational{:Ο€} </code></pre> <p>Coming from SymPy, which has the <code>N()</code> function, I would like to evaluate <code>pi</code> (or other <code>Irrational</code>s, such as <code>e</code>, <code>golden</code>, etc.) to n digits.</p> <pre><code>In [5]: N(pi, n=50) Out[5]: 3.1415926535897932384626433832795028841971693993751 </code></pre> <p>Is this possible? I am assuming that <code>pi</code> is based on its mathematical definition, rather than just to thirteen decimal places.</p>
<constants><julia><sympy><evaluation>
2016-09-02 01:54:34
HQ
39,284,233
docker service replicas remain 0/1
<p>I am trying out docker swarm with 1.12 on my Mac. I started 3 VirtualBox VMs, created a swarm cluster of 3 all fine.</p> <pre><code>docker@redis1:~$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 2h1m8equ5w5beetbq3go56ebl redis3 Ready Active 8xubu8g7pzjvo34qdtqxeqjlj redis2 Ready Active Reachable cbi0lyekxmp0o09j5hx48u7vm * redis1 Ready Active Leader </code></pre> <p>However, when I create a service, I see no errors yet replicas always displays 0/1:</p> <pre><code>docker@redis1:~$ docker service create --replicas 1 --name hello ubuntu:latest /bin/bash 76kvrcvnz6kdhsmzmug6jgnjv docker@redis1:~$ docker service ls ID NAME REPLICAS IMAGE COMMAND 76kvrcvnz6kd hello 0/1 ubuntu:latest /bin/bash docker@redis1:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES </code></pre> <p>What could be the problem? Where do I look for logs? Thanks!</p>
<docker><docker-swarm>
2016-09-02 04:17:18
HQ