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
38,188,848
Why compilers value initialize arrays while they should not?
I'm trying to understand when compilers should value initialize arrays and when they should default initialize it. I'm trying two options: one raw array, another array aggregated in a struct: const int N = 1000; struct A { uint32_t arr[N]; A() = default; }; void print(uint32_t* arr, const std::string& message) { std::cout << message << ": " << (std::count(arr, arr + N, 0) == N ? "all zeros" : "garbage") << std::endl; } int main() { uint32_t arrDefault[N]; print(arrDefault, "Automatic array, default initialization"); uint32_t arrValue[N] = {}; print(arrValue, "Automatic array, value initialization"); uint32_t* parrDefault = new uint32_t[N]; print(parrDefault, " Dynamic array, default initialization"); uint32_t* parrValue = new uint32_t[N](); print(parrValue, " Dynamic array, value initialization"); A structDefault; print(structDefault.arr, "Automatic struct, default initialization"); A structValue{}; print(structValue.arr, "Automatic struct, value initialization"); A* pstructDefault = new A; print(pstructDefault->arr, " Dynamic struct, default initialization"); A* psstructValue = new A(); print(psstructValue->arr, " Dynamic struct, value initialization"); } Here is what I see for [clang][1] and [VC++][2]: Automatic array, default initialization: garbage Automatic array, value initialization: all zeros Dynamic array, default initialization: garbage Dynamic array, value initialization: all zeros Automatic struct, default initialization: all zeros Automatic struct, value initialization: all zeros Dynamic struct, default initialization: garbage Dynamic struct, value initialization: all zeros Output for [gcc][3] is different only in the first line, where it also puts "all zeros". From my point of view they are all wrong, and what I expect is: Automatic array, default initialization: garbage Automatic array, value initialization: all zeros Dynamic array, default initialization: garbage Dynamic array, value initialization: all zeros Automatic struct, default initialization: garbage Automatic struct, value initialization: garbage Dynamic struct, default initialization: garbage Dynamic struct, value initialization: garbage I.e. output is ok for raw arrays (except for gcc): we have garbage for default and zeros for value. Great. But for a struct I would expect to have garbage all the time. From [default initialization][4]: > Default initialization is performed in three situations: > > 1. ... > 2. ... > 3. when a base class or a non-static data member is not mentioned in a constructor initializer list and that constructor is called. > The effects of default initialization are: > > * if T is a non-POD (until C++11) class type, ... > * if T is an array type, every element of the array is > default-initialized; > * otherwise, nothing is done: the objects with automatic storage duration (and their subobjects) are initialized to indeterminate values. In my example I have non-static data member that is not mentioned in a constructor initializer list, which is an array of POD type. I expect it to be left with indeterminate values, no matter how my struct is constructed. My questions are: * Why does compilers violate that? Am I wrong in my readings? * How can I enforce such behavior to make sure I do not waste my runtime populating arrays with zeros? * Why gcc performs value initialization for an automatic array? [1]: http://rextester.com/MOWXS13214 [2]: http://rextester.com/GRR38772 [3]: http://rextester.com/SUM2221 [4]: http://en.cppreference.com/w/cpp/language/default_initialization
<c++><arrays><initialization>
2016-07-04 16:14:17
LQ_EDIT
38,189,119
Simple way to visualize a TensorFlow graph in Jupyter?
<p>The official way to visualize a TensorFlow graph is with TensorBoard, but sometimes I just want a quick look at the graph when I'm working in Jupyter.</p> <p>Is there a quick solution, ideally based on TensorFlow tools, or standard SciPy packages (like matplotlib), but if necessary based on 3rd party libraries?</p>
<tensorflow><jupyter><graph-visualization><tensorboard>
2016-07-04 16:33:32
HQ
38,189,160
Can a progressive web app be registered as a share option in Android?
<p>Total newbie question.</p> <p>Tl;dr - Can a progressive web app be registered as a share option in Android?</p> <p>In Android, we can “Share” things to other installed Android apps. For example, let’s say I have Chrome for Android and the Google+ app installed on my Android device. I can share a web site which I am viewing in Chrome to Google+ by going to Chrome’s hamburger menu → Share… → Google+ (with a list of other installed native apps). Can a progressive web app be registered in this list of installed native apps? If yes, can you show me some examples or code labs? If no, is this feature in progressive web app or Android’s roadmap?</p>
<android><progressive-web-apps>
2016-07-04 16:36:39
HQ
38,189,198
how to use setSupportActionBar in fragment
<p>I need to use the setSupportActionBar in fragment which I am unable to also I am unable to use setContentView please to help with it also Thankyou in advance the related code is given</p> <pre><code>public class StudentrFragment extends Fragment { Toolbar toolbar; TabLayout tabLayout; ViewPager viewPager; ViewPagerAdapter viewPagerAdapter; public StudentrFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.tabbar_layout); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); tabLayout = (TabLayout) findViewById(R.id.tabLayout); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); viewPagerAdapter.addFragments(new CivilFragment(),"Civil Dept"); viewPagerAdapter.addFragments(new ComputerFragment(),"CSE Dept"); viewPagerAdapter.addFragments(new EeeFragment(),"EEE Dept"); viewPagerAdapter.addFragments(new EceFragment(),"ECE Dept"); viewPager.setAdapter(viewPagerAdapter); tabLayout.setupWithViewPager(viewPager); } } </code></pre>
<android><android-fragments><android-actionbar>
2016-07-04 16:39:15
HQ
38,189,219
Please check what is wrong in this mysql query i am getting the following error
<p>I am getting the following error:<br> Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given I tried to change the code but no use can any body help me please make this code workable. My code is:</p> <pre><code>&lt;?php /*home page bannerrotator*/ $sql="SELECT homelb,bdetails1,bdetails2,abovefoo1,abovefoo2 FROM adsettings WHERE NOT(hview1=hometotal AND hview2=bdtotal1 AND hview3=bdtotal2 AND hview4=foototal1 AND hview5=foototal2) LIMIT 10"; $result=mysqli_query($connection,$sql); $rows=mysqli_num_rows($result); if($rows!=0) { $leaderboard = array(); $bd1=array(); $bd2=array(); $foo1=array(); $foo2=array(); $i=0; while ($row = mysqli_fetch_assoc($result)) { $leaderboard[i]=$row['homelb']; $bd1[i]=$row['bdetails1']; $bd2[i]=$row['bdetails2']; $foo1[i]=$row['abovefoo1']; $foo2[i]=$row['abovefoo2']; i++; } shuffle($leaderboard); shuffle($bd2); shuffle($bd1); shuffle($foo1); shuffle($foo2); } else { $leaderboard[0]="Advertise Here"; $bd1[0]="Advertise Here"; $bd2[0]="Advertise Here"; $foo1[0]="Advertise Here"; $foo2[0]="Advertise Here"; } /*login page adverts*/ ?&gt; </code></pre>
<php><mysql><mysqli><adrotator>
2016-07-04 16:40:42
LQ_CLOSE
38,189,485
Python regex remove all character except 4 digitals
<pre><code>+1511 0716 +4915 CZECHY +3815/0616 PORT MO, AO _3615 USA *, SUV run on flat +4515 PORT SUV *, SUV +3215 USA *, SUV +4414 +4815 NIEM _0616 NIEM * / MO +2115 NIEM J </code></pre> <p>I need get only first 4 digits </p> <blockquote> <p>+<strong>3715</strong> NIEM</p> </blockquote> <p>Please help.</p>
<python><regex>
2016-07-04 17:05:42
LQ_CLOSE
38,189,545
General understanding of OOP Languages
<p>Why a language has to be object oriented in order to define local variables?</p> <p>For example Cobol allowed the definition of local variable only since 2002 because only then the language became object oriented</p>
<oop>
2016-07-04 17:10:51
LQ_CLOSE
38,189,713
What is an Embedding in Keras?
<p>Keras documentation isn't clear what this actually is. I understand we can use this to compress the input feature space into a smaller one. But how is this done from a neural design perspective? Is it an autoenocder, RBM?</p>
<keras>
2016-07-04 17:26:24
HQ
38,190,253
Android Google Sign In: check if User is signed in
<p>I am looking for a way to check if my user already signed in with Google Sign In.</p> <p>I support several logging APIs (Facebook, Google, custom), so I would like to build a static helper method like: <code>User.isUserLoggedIn()</code></p> <p>With Facebook I use: </p> <pre><code>if AccessToken.getCurrentAccessToken() != null { return true } </code></pre> <p>to check if the user is logged via Facebook.</p> <p>On iOS I use the following to check if the user is logged via Google Sign In:</p> <pre><code>GIDSignIn.sharedInstance().hasAuthInKeychain() </code></pre> <p><strong>My question: Is there an equivalent on Android to the iOS method :</strong> </p> <p><code>GIDSignIn.sharedInstance().hasAuthInKeychain()</code> ?</p> <p>I am looking for a method that doesn’t involve a callback. </p> <p>Thanks! Max</p>
<android><google-signin>
2016-07-04 18:10:08
HQ
38,190,360
Duplicate files in DerivedData folder using CoreData generator
<p>I'm trying to generate NSManagedModels from my datamodel. Generation works but after I got many errors :</p> <blockquote> <p>error: filename "Station+CoreDataProperties.swift" used twice: '/Users/Me/MyApp/Models/CoreData/Station+CoreDataProperties.swift' and '/Users/Me/Library/Developer/Xcode/DerivedData/MyApp-gwacspwrsnabomertjnqfbuhjvwc/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/DerivedSources/CoreDataGenerated/Model/Station+CoreDataProperties.swift' :0: note: filenames are used to distinguish private declarations with the same name</p> </blockquote> <p>I try clean build folder and derivedData directory hard delete. I'm using Xcode 8 BETA maybe it's a bug ?</p>
<core-data><swift3><xcode8>
2016-07-04 18:18:45
HQ
38,190,365
How does one initialize a variable with tf.get_variable and a numpy value in TensorFlow?
<p>I wanted to initialize some of the variable on my network with numpy values. For the sake of the example consider:</p> <pre><code>init=np.random.rand(1,2) tf.get_variable('var_name',initializer=init) </code></pre> <p>when I do that I get an error:</p> <pre><code>ValueError: Shape of a new variable (var_name) must be fully defined, but instead was &lt;unknown&gt;. </code></pre> <p>why is it that I am getting that error? </p> <p>To try to fix it I tried doing:</p> <pre><code>tf.get_variable('var_name',initializer=init, shape=[1,2]) </code></pre> <p>which yielded a even weirder error:</p> <pre><code>TypeError: 'numpy.ndarray' object is not callable </code></pre> <p>I tried reading <a href="https://www.tensorflow.org/versions/r0.9/api_docs/python/state_ops.html#variable_scope" rel="noreferrer">the docs and examples</a> but it didn't really help.</p> <p>Is it not possible to initialize variables with numpy arrays with the get_variable method in TensorFlow?</p>
<python><numpy><tensorflow>
2016-07-04 18:19:09
HQ
38,191,090
nil is the only return value permitted in initializer?
<p>I'm attempting to subclass UICollectionViewFlowLayout but I get the error that 'nil is the only return value permitted in an initializer.' I attempted to check the super class for an initializer and if there wasn't, I would return nil, but alas, I get another error saying that self is immutable.</p> <pre><code>import UIKit class CollectionViewSpringLayout: UICollectionViewFlowLayout { var dynamicAnimator: UIDynamicAnimator? override init() { self.minimumInteritemSpacing = 10 self.minimumInteritemSpacing = 10 //self.itemSize = CGSizeMake(44, 44) self.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10) self.dynamicAnimator = UIDynamicAnimator(collectionViewLayout: self) return self } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } </code></pre>
<ios><swift><uicollectionview>
2016-07-04 19:21:55
HQ
38,191,161
How to make this regex have proper syntax for python 3
#!/usr/bin/env python # -*- encoding: utf8 -*- import re sample = u'I am from 美国。We should be friends. 朋友。' for n in re.findall(ur'[\u4e00-\u9fff]+',sample): print n
<python><regex><python-3.5>
2016-07-04 19:27:09
LQ_EDIT
38,191,170
Multiple dex files define Lcom/google/firebase/FirebaseException
<p>I encountered a problem with the Firebase integration. First of all, I have added rules to the root-level <code>build.gradle</code> file:</p> <pre><code>buildscript { repositories { maven { url "http://dl.bintray.com/populov/maven" } jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.google.gms:google-services:3.0.0' } } allprojects { repositories { maven { url "http://dl.bintray.com/populov/maven" } jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> <p>And the module Gradle file:</p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24" defaultConfig { applicationId "com.example.app" minSdkVersion 14 targetSdkVersion 24 versionCode 2 versionName "0.9" } buildTypes { /// } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.google.firebase:firebase-core:9.0.2' compile 'com.google.firebase:firebase-crash:9.0.2' } apply plugin: 'com.google.gms.google-services' </code></pre> <p>During the build of the project, I get the error:</p> <blockquote> <p>Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/FirebaseException;</p> </blockquote> <p>Error reason is clear, but I didn't compile any library twice. Should I exclude <code>FirebaseException</code> class from the build process manually? If so, how? Perhaps this is a bug within the Firebase dependencies?</p> <p>Thanks.</p>
<android><gradle><firebase><android-gradle-plugin><build.gradle>
2016-07-04 19:28:00
HQ
38,191,372
Reference cycles with value types?
<p>Reference cycles in Swift occur when properties of reference types have strong ownership of each other (or with closures). </p> <p>Is there, however, a possibility of having reference cycles with value types <em>only</em>? </p> <hr> <p>I tried this in playground without succes (<strong>Error: Recursive value type 'A' is not allowed</strong>).</p> <pre><code>struct A { var otherA: A? = nil init() { otherA = A() } } </code></pre>
<swift><automatic-ref-counting><value-type><reference-counting><reference-type>
2016-07-04 19:46:48
HQ
38,191,794
Hey guys, i wrote this program and for some reason it won't compile.
i keep getting " Grades.java:10: error: illegal start of type" i can't figure out why. please help! import java.util.Scanner; public class Grades { final int StudentGrades = 3; int total; double average; int[] GradesArray = new int[StudentGrades]; Scanner keyboard = new Scanner(System.in); for (int i = 0; i < GradesArray.length; i++) { System.out.print("Enter grades for Student" + (i+1)); GradesArray[i] = keyboard.nextInt(); total += GradesArray[i]; } average = total/StudentGrades; if(average >= 90 && average <= 100) System.out.print("you Got a A"); else if(average >= 80 && average <= 89) System.out.print("you Got a B"); else if (average >= 70 && average <= 79) System.out.print("you Got a C"); else if (average >= 60 && average <= 69) System.out.print("you Got a D"); else System.out.print("you Got a F"); for(int i = 0; i < GradesArray.length; i++) { System.out.println("Grades for exam #" + (it1)+"are as follows " + GradesArray[i]); } }
<java>
2016-07-04 20:25:41
LQ_EDIT
38,191,875
Avoid const locals that are returned?
<p>I always thought that it's good to have const locals be const</p> <pre><code>void f() { const resource_ptr p = get(); // ... } </code></pre> <p>However last week I watched students that worked on a C++ exercise and that wondered about a const pointer being returned</p> <pre><code>resource_ptr f() { const resource_ptr p = get(); // ... return p; } </code></pre> <p>Here, if the compiler can't apply NRVO (imagine some scenario under which that is true, perhaps returning one of two pointers, depending on a condition), suddenly the <code>const</code> becomes a pessimization because the compiler can't move from <code>p</code>, because it's const. </p> <p>Is it a good idea to try and avoid <code>const</code> on returned locals, or is there a better way to deal with this?</p>
<c++><c++14><move-semantics><nrvo>
2016-07-04 20:32:52
HQ
38,191,886
Select id and name of users having their birthday this week from database with mysql and php
<p>I have a script that stores user information in a database table. I want to output all users celeberating their birthday in each week of the year (monday - sunday), and I have this already.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Surname&lt;/th&gt; &lt;th&gt;Firstname&lt;/th&gt; &lt;/tr&gt; &lt;?php $req = mysql_query( "SELECT * FROM elementary WHERE birthday BETWEEN CURDATE() - INTERVAL 1 WEEK AND CURDATE() + INTERVAL 1 WEEK" ); while($dnn = mysql_fetch_array($req)){ ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $dnn["id"] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dnn["surname"] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $dnn["firstname"] ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; </code></pre> <p>Thanks in advance. </p>
<php><mysql>
2016-07-04 20:33:43
LQ_CLOSE
38,192,013
What is wrong with the program I am trying to write
<pre><code>#This is a program which illustrates a chaotic behavior. def main(): print("This is a program which illustrates a chaotic behavior") x = eval(input("Enter a value between 0 and 1: ")) for i in range(10): x = 3.9 * x * (1 - x) print(x) </code></pre> <p>main()</p> <p>I am reading through the book "Python programming, an introduction to computer science by John Zelle" and I am trying to copy-paste this simple program. I am using Geany IDE and after writing the above code I am trying to compile it but I am getting the following error : </p> <pre><code>Sorry: IndentationError: expected an indented block (chaos.py, line 5) </code></pre>
<python>
2016-07-04 20:45:42
LQ_CLOSE
38,192,498
Where do i download XNA? (in visual studio)
<p>I was looking to start learning XNA and make games with it.When i tried looking online for videos and websites it didn't work, I saw videos about XNA but i didn't download button.</p>
<c#><visual-studio-2010><xna>
2016-07-04 21:35:08
LQ_CLOSE
38,192,711
How to retrieve multiple keys in Firebase?
<p>Considering this data structure:</p> <pre><code>{ "users":{ "user-1":{ "groups":{ "group-key-1":true, "group-key-3":true } } }, "groups":{ "group-key-1":{ "name":"My group 1" }, "group-key-2":{ "name":"My group 2" }, "group-key-3":{ "name":"My group 3" }, "group-key-4":{ "name":"My group 4" }, } } </code></pre> <p>I could get the groups of a particular user with:</p> <pre><code>firebase.database().ref('users/user-1/groups').on(...) </code></pre> <p>Which would give me this object:</p> <pre><code>{ "group-key-1":true, "group-key-3":true } </code></pre> <p>So now I want to retrieve the info for those groups.</p> <p>My initial instinct would be to loop those keys and do this:</p> <pre><code>var data = snapshot.val() var keys = Object.keys(data) for (var i = 0; i &lt; keys.length; i++) { firebase.database().ref('groups/' + keys[i]).on(...) } </code></pre> <p>Is this the appropriate way to call multiple keys on the same endpoint in Firebase?</p> <p>Does Firebase provide a better way to solve this problem?</p>
<javascript><firebase><firebase-realtime-database>
2016-07-04 21:59:46
HQ
38,193,278
What is the pythonic way for 'do_this() if condition else do_that() '?
There is exists a pythonic way for doing somethings like that? >> list.append(elem) if condition else pass >> list.append(elem) if condition else other_list.append(elem) I have needed sometimes something like that and I don't know the best way for accomplish it. Thanks.
<python><if-statement>
2016-07-04 23:18:09
LQ_EDIT
38,193,878
How to create/modify a jupyter notebook from code (python)?
<p>I am trying to automate my project create process and would like as part of it to create a new jupyter notebook and populate it with some cells and content that I usually have in every notebook (i.e., imports, titles, etc.)</p> <p>Is it possible to do this via python?</p>
<jupyter-notebook>
2016-07-05 01:04:05
HQ
38,193,958
How to properly mask a numpy 2D array?
<p>Say I have a two dimensional array of coordinates that looks something like</p> <p><code>x = array([[1,2],[2,3],[3,4]])</code></p> <p>Previously in my work so far, I generated a mask that ends up looking something like</p> <p><code>mask = [False,False,True]</code></p> <p>When I try to use this mask on the 2D coordinate vector, I get an error</p> <pre><code>newX = np.ma.compressed(np.ma.masked_array(x,mask)) &gt;&gt;&gt;numpy.ma.core.MaskError: Mask and data not compatible: data size is 6, mask size is 3.` </code></pre> <p>which makes sense, I suppose. So I tried to simply use the following mask instead:</p> <pre><code>mask2 = np.column_stack((mask,mask)) newX = np.ma.compressed(np.ma.masked_array(x,mask2)) </code></pre> <p>And what I get is close:</p> <p><code>&gt;&gt;&gt;array([1,2,2,3])</code></p> <p>to what I would expect (and want):</p> <p><code>&gt;&gt;&gt;array([[1,2],[2,3]])</code></p> <p>There must be an easier way to do this?</p>
<python><numpy><matrix><mask><masked-array>
2016-07-05 01:18:46
HQ
38,194,012
AutoMapper.Mapper does not contain definition for CreateMap
<p>This might be a basic question but wondering I am not getting AutoMapper.Mapper.CreateMap method. </p> <p><a href="https://i.stack.imgur.com/Iprvy.jpg"><img src="https://i.stack.imgur.com/Iprvy.jpg" alt="enter image description here"></a></p> <p>Am I using wrong AutoMapper reference/package? Thanks</p>
<asp.net-mvc><asp.net-web-api><automapper>
2016-07-05 01:29:24
HQ
38,194,292
Equal height double column using css
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#DIV_1 { bottom: -10px; height: 176px; left: 0px; position: relative; right: 0px; text-align: left; top: 10px; width: 379px; perspective-origin: 189.5px 88px; transform-origin: 189.5px 88px; background: rgb(238, 238, 238) none repeat scroll 0% 0% / auto padding-box border-box; font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif; list-style: none outside none; margin: 0px 0px -5px; overflow: hidden; }/*#DIV_1*/ #DIV_2 { box-sizing: border-box; float: left; height: 77px; text-align: center; width: 189.5px; perspective-origin: 94.75px 38.5px; transform-origin: 94.75px 38.5px; border-right: 5px solid rgb(255, 255, 255); font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif; list-style: none outside none; padding: 30px; }/*#DIV_2*/ #DIV_3 { box-sizing: border-box; float: left; height: 77px; text-align: center; width: 189.5px; perspective-origin: 94.75px 38.5px; transform-origin: 94.75px 38.5px; font: normal normal normal normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif; list-style: none outside none; padding: 30px; }/*#DIV_3*/ #DIV_4 { box-sizing: border-box; color: rgb(255, 255, 255); float: left; height: 99px; text-align: center; width: 189.5px; column-rule-color: rgb(255, 255, 255); perspective-origin: 94.75px 49.5px; transform-origin: 94.75px 49.5px; background: rgb(192, 57, 43) none repeat scroll 0% 0% / auto padding-box border-box; border-top: 5px solid rgb(255, 255, 255); border-right: 5px solid rgb(255, 255, 255); border-bottom: 0px none rgb(255, 255, 255); border-left: 0px none rgb(255, 255, 255); font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif; list-style: none outside none; outline: rgb(255, 255, 255) none 0px; padding: 30px; }/*#DIV_4*/ #DIV_5 { box-sizing: border-box; color: rgb(255, 255, 255); float: left; height: 82px; text-align: center; width: 189.5px; column-rule-color: rgb(255, 255, 255); perspective-origin: 94.75px 41px; transform-origin: 94.75px 41px; background: rgb(142, 68, 173) none repeat scroll 0% 0% / auto padding-box border-box; border-top: 5px solid rgb(255, 255, 255); border-right: 0px none rgb(255, 255, 255); border-bottom: 0px none rgb(255, 255, 255); border-left: 0px none rgb(255, 255, 255); font: normal normal bold normal 14px / normal "Lucida Grande", Helvetica, Arial, sans-serif; list-style: none outside none; outline: rgb(255, 255, 255) none 0px; padding: 30px; }/*#DIV_5*/</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="DIV_1"&gt; &lt;div id="DIV_2"&gt; Ben Franklin &lt;/div&gt; &lt;div id="DIV_3"&gt; Thomas Jefferson &lt;/div&gt; &lt;div id="DIV_4"&gt; George Washington &lt;/div&gt; &lt;div id="DIV_5"&gt; Abraham Lincoln &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I have 2 column that its content might have different length, thus it will have multiple lines, so how do I ensure that the least line of content have the equal height? I can't use fixed height like <code>height:100px;</code> because the length of the content might be more than that.</p>
<html><css>
2016-07-05 02:16:40
LQ_CLOSE
38,194,756
Usage difference beteen Apache and Apache Tomcat
As Tomcat is a widely used java web server, and apache is also a web server, what's the different between them in real project usage?
<apache><tomcat>
2016-07-05 03:24:13
LQ_EDIT
38,195,073
Hi i have created a private class "PathakP" but i am getting PathakP cannot be resolved to a type
Ok i tried to create a dialog box with Jbutton but when i am adding actionListener to it and passing the class to button which i have created to implements ActionListener i am getting "PathakP(Class Name) cannot be resolved to a type" the code i have used is import java.awt.*; import javax.swing.*; import java.awt.event.*; public class GUI1 extends JFrame { private JTextField J; private Font pf,bf,itf,bif; private JRadioButton pb,bb,ib,bib; private ButtonGroup B; private JButton ab; public GUI1(){ super("To check the Font styles" ); setLayout(new FlowLayout()); J=new JTextField("This is the Text who's Font will be Changed pahtak is with me ",40); add(J); pb=new JRadioButton("Plain Button",true); bb=new JRadioButton("Bold Button",false); bib=new JRadioButton("Bold & Italic Button",false); ib=new JRadioButton("Italic Button",false); ab=new JButton("PathakButton"); add(ab); add(pb); add(bb); add(bib); add(ib); B=new ButtonGroup(); B.add(pb); B.add(bb); B.add(bib); B.add(ib); pf=new Font("Serif",Font.PLAIN,15); bf=new Font("Serif",Font.BOLD,15); itf=new Font("Serif",Font.ITALIC,15); bif=new Font("Serif",Font.BOLD+Font.ITALIC,16); J.setFont(pf); pb.addItemListener(new HandlerClass(pf)); bb.addItemListener(new HandlerClass(bf)); bib.addItemListener(new HandlerClass(bif)); ib.addItemListener(new HandlerClass(itf)); ab.addActionListener(new PathakP()); } private class HandlerClass implements ItemListener{ private Font font; public HandlerClass(Font f){ font=f; } public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub J.setFont(font); } private class PathakP implements ActionListener{ public void actionPerformed(ActionEvent ae) { JOptionPane.showMessageDialog(null, "This is just JOptionPane example"); } } } } ------------------------------------------------------------ Main Class import javax.swing.*; public class Apples { public static void main(String[] args) { GUI1 G=new GUI1(); G.setVisible(true); G.setSize(500,250); G.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } ----------------- i don't believe there is any error in the main class i can troubleshoot this error by just creating another class outside but i want to know why it is not taking the class i have created and show unused in it
<java><swing>
2016-07-05 04:13:07
LQ_EDIT
38,195,536
Jupyter Shortcut not working
<p>I am working my code on Jupyter(Python). Normally, the shortcut to insert cell below is 'b' and for above is 'a', but when I do that search bar opens instead of insertion of cell.<a href="https://i.stack.imgur.com/HlUJt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HlUJt.png" alt="Jupyter shortcut problem"></a></p>
<python><jupyter><jupyter-notebook>
2016-07-05 05:08:23
HQ
38,195,689
Prime Factorisation in C
Well I have been assigned to do the prime factorisation but the problem is i have hard-coded it till prime numbers:2,3,5,7,11,13,19 and i want to make it general... #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { void prime(int flag,int num); int num,flag,i,div; printf("Enter your number: "); scanf("%d",&num); flag=1; prime(flag,num); return 0; } void prime(int flag, int num) { void factor(int num,int i); int sq,i,square; sq=abs(sqrt(num)); if (num==2) flag=1; else for (i=2;i<=sq;i++) { if (num%i==0) { flag=0; break; } else flag=1; } if (flag==1) printf("\n%d is a prime number",num); else { printf("\n%d is not a prime number\n",num); factor(num,i); } } void factor(int num,int i) { for (i=2;i<=num;i++) { again: if(num%i==0) { num=num/i; printf("%d ",i); if (num!=2||3||5||7||11||17||19) goto again; } } } P.S.:Try to make it as simpler as possible.
<c>
2016-07-05 05:23:29
LQ_EDIT
38,196,001
error: lvalue required as left operand of assignment, I GOT THIS ERROR WHAT IS lvalue and rvalue and how to remove this error
I got this error in my code while compiling here is the code #include <iostream> using namespace std; int main() { int l,n,w,h; cin>>l>>n; while(n--){ cin>>w>>h; if(w>l||h>l) cout<<"CROP IT"<<endl; if(w==l&&h==l&&w=h) cout<<"ACCEPTED"<<endl; if(w<l||h<l) cout<<"UPLOAD ANOTHER"<<endl; } } and the error 11:22: error: lvalue required as left operand of assignment
<c++><c><linux>
2016-07-05 05:49:28
LQ_EDIT
38,196,629
how to disable scroll bar on fullscreen slider
Hello i am sonu anyone tell me about that how to disable scroll bar on full screen slider. There is scroll down button at each slider when click on this button go to just below slider and show scroll bar, otherwise don't show scrollbar. Please tell me anyone example code
<javascript><jquery><css><html><scrollbar>
2016-07-05 06:32:22
LQ_EDIT
38,196,923
How to check if a dict value contains a word/string?
<p>I have a simple condition where i need to check if a dict value contains say <code>[Complted]</code> in a particular key. </p> <p><strong>example</strong> :</p> <pre><code>'Events': [ { 'Code': 'instance-reboot'|'system-reboot'|'system-maintenance'|'instance-retirement'|'instance-stop', 'Description': 'string', 'NotBefore': datetime(2015, 1, 1), 'NotAfter': datetime(2015, 1, 1) }, ], </code></pre> <p>I need to check if the <code>Description</code> key contains <code>[Complted]</code> in it at starting. i.e </p> <blockquote> <p>'Descripton': '[Completed] The instance is running on degraded hardware'</p> </blockquote> <p>How can i do so ? I am looking for something like </p> <pre><code>if inst ['Events'][0]['Code'] == "instance-stop": if inst ['Events'][0]['Description'] consists '[Completed]": print "Nothing to do here" </code></pre>
<python><dictionary>
2016-07-05 06:50:18
HQ
38,197,158
Shared Transaction between different OracleDB Connections
<p>After several days passed to investigate about the issue, I decided to submit this question because there is no sense apparently in what is happening.</p> <p><strong>The Case</strong></p> <p>My computer is configured with a local Oracle Express database. I have a JAVA project with several JUnit Tests that extend a parent class (I know that it is not a "best practice") which opens an OJDBC Connection (using a static Hikari connection pool of 10 Connections) in the @Before method and rolled Back it in the @After.</p> <pre><code>public class BaseLocalRollbackableConnectorTest { private static Logger logger = LoggerFactory.getLogger(BaseLocalRollbackableConnectorTest.class); protected Connection connection; @Before public void setup() throws SQLException{ logger.debug("Getting connection and setting autocommit to FALSE"); connection = StaticConnectionPool.getPooledConnection(); } @After public void teardown() throws SQLException{ logger.debug("Rollback connection"); connection.rollback(); logger.debug("Close connection"); connection.close(); } </code></pre> <p>StacicConnectionPool</p> <pre><code>public class StaticConnectionPool { private static HikariDataSource ds; private static final Logger log = LoggerFactory.getLogger(StaticConnectionPool.class); public static Connection getPooledConnection() throws SQLException { if (ds == null) { log.debug("Initializing ConnectionPool"); HikariConfig config = new HikariConfig(); config.setMaximumPoolSize(10); config.setDataSourceClassName("oracle.jdbc.pool.OracleDataSource"); config.addDataSourceProperty("url", "jdbc:oracle:thin:@localhost:1521:XE"); config.addDataSourceProperty("user", "MyUser"); config.addDataSourceProperty("password", "MyPsw"); config.setAutoCommit(false); ds = new HikariDataSource(config); } return ds.getConnection(); } </code></pre> <p>}</p> <p>This project has hundreds tests (not in parallel) that use this connection (on localhost) to execute queries (insert/update and select) using Sql2o but transaction and clousure of connection is managed only externally (by the test above). The database is completely empty to have ACID tests.</p> <p>So the expected result is to insert something into DB, makes the assertions and then rollback. in this way the second test will not find any data added by previous test in order to maintain the isolation level.</p> <p><strong>The Problem</strong> Running all tests together (sequentially), 90% of times they work properly. the 10% one or two tests, randomly, fail, because there is dirty data in the database (duplicated unique for example) by previous tests. looking the logs, rollbacks of previous tests were done properly. In fact, if I check the database, it is empty) If I execute this tests in a server with higher performance but the same JDK, same Oracle DB XE, this failure ratio is increased to 50%. </p> <p>This is very strange and I have no idea because the connections are different between tests and the rollback is called each time. The JDBC Isolation level is READ COMMITTED so even if we used the same connection, this should not create any problem even using the same connection. So my question is: Why it happen? do you have any idea? Is the JDBC rollback synchronous as I know or there could be some cases where it can go forward even though it is not fully completed?</p> <p>These are my main DB params: processes 100 sessions 172 transactions 189</p>
<java><oracle><junit><transactions><sql2o>
2016-07-05 07:03:47
HQ
38,197,255
Forms in Angular 2 RC4
<p>I am experimenting with forms in Angular 2 RC4. It's all working fine but when I start the app the browser console gives me this message:</p> <pre><code>*It looks like you're using the old forms module. This will be opt-in in the next RC, and will eventually be removed in favor of the new forms module. </code></pre> <p>The relevant part of my component looks like this:</p> <pre><code>import { FORM_DIRECTIVES, REACTIVE_FORM_DIRECTIVES, FormBuilder, FormGroup } from '@angular/forms'; import {Observable} from "rxjs/Rx"; @Component ({ selector: "hh-topbar", moduleId: module.id, templateUrl: "topBar.component.html", directives: [HHPagerComponent, FORM_DIRECTIVES, REACTIVE_FORM_DIRECTIVES] }) export class HHTopBarComponent implements OnChanges, OnInit { ... private filterForm: FormGroup; private title$: Observable&lt;string&gt;; constructor(private formBuilder: FormBuilder) { } public ngOnInit(): any { this.filterForm = this.formBuilder.group ({ "title": [this.info.filters.searchFileName] }); this.title$ = this.filterForm.controls["title"].valueChanges; this.title$.subscribe(val =&gt; { this.info.filters.searchFileName = val; this.filterChanged.emit(this.info.filters); }); } } </code></pre> <p>And the relevant part of my template looks like this:</p> <pre><code>&lt;form [formGroup]="filterForm"&gt; &lt;div&gt; &lt;label for="title"&gt;Title&lt;/label&gt; &lt;input [formControl]="filterForm.controls['title']" id="title" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Does anybody here know what is the new forms module the warning is talking about and which directives will change and to what?</p>
<angular>
2016-07-05 07:08:36
HQ
38,197,406
Overriding configuration with environment variables in typesafe config
<p>Using <a href="https://github.com/typesafehub/config" rel="noreferrer">typesafe config</a>, how do I override the reference configuration with an environment variable? For example, lets say I have the following configuration:</p> <pre><code>foo: "bar" </code></pre> <p>I want it to be overriden with the environment variable <code>FOO</code> if one exists.</p>
<environment-variables><config><typesafe>
2016-07-05 07:17:05
HQ
38,197,449
matlab data file to pandas DataFrame
<p>Is there a standard way to convert <em>matlab</em> <code>.mat</code> (matlab formated data) files to Panda <code>DataFrame</code>? </p> <p>I am aware that a workaround is possible by using <code>scipy.io</code> but I am wondering whether there is a straightforward way to do it.</p>
<python><database><matlab><pandas>
2016-07-05 07:19:04
HQ
38,198,043
how to add tooltip(image )in javafx
How to add tooltip (i button in image) in javafx.[![enter image description here][1]][1] [1]: http://i.stack.imgur.com/gNKQq.png
<java><javafx>
2016-07-05 07:53:22
LQ_EDIT
38,198,668
Rails 5: Load lib files in production
<p>I've upgraded one of my apps from Rails 4.2.6 to Rails 5.0.0. The <a href="http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#autoloading-is-disabled-after-booting-in-the-production-environment" rel="noreferrer">Upgrade Guide</a> says, that the Autoload feature is now disabled in production by default.</p> <p>Now I always get an error on my production server since I load all lib files with autoload in the <code>application.rb</code> file.</p> <pre><code>module MyApp class Application &lt; Rails::Application config.autoload_paths += %W( lib/ ) end end </code></pre> <p>For now, I've set the <code>config.enable_dependency_loading</code> to <code>true</code> but I wonder if there is a better solution to this. There must be a reason that Autoloading is disabled in production by default.</p>
<ruby-on-rails><autoload><ruby-on-rails-5>
2016-07-05 08:30:25
HQ
38,198,751
DOMException: Error processing ICE candidate
<p>I get this error <code>DOMException: Error processing ICE candidate</code> when I try to add an ice candidate. Here's the candidate:</p> <blockquote> <p>candidate:1278028030 1 udp 2122260223 10.0.18.123 62694 typ host generation 0 ufrag eGOGlVCnFLZYKTsc network-id 1</p> </blockquote> <p>Moreover, it doesn't always happen - other time everything goes smoothly. I can't reproduce a consistent pattern where it would throw this error. Any ideas how to go about solving this / debugging it would be appreciated!</p>
<webrtc>
2016-07-05 08:34:59
HQ
38,198,957
Cannot implicitly convert System.Eventhandler to System.Window.Form.KeyPressEventHandler
private void grdPOItems_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { int colIndex = grdPOItems.CurrentCell.ColumnIndex; string colName = grdPOItems.Columns[colIndex].Name; if(colName == "Qty" || colName == "Rate") { e.Control.KeyPress += new EventHandler(CheckKey); } } private void CheckKey(object sender, EventArgs e) { if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar!='.')) { e.Handled = true; } }
<c#>
2016-07-05 08:45:49
LQ_EDIT
38,199,008
Python returns MagicMock object instead of return_value
<p>I have a python file <code>a.py</code> which contains two classes <code>A</code> and <code>B</code>.</p> <pre><code>class A(object): def method_a(self): return "Class A method a" class B(object): def method_b(self): a = A() print a.method_a() </code></pre> <p>I would like to unittest <code>method_b</code> in class <code>B</code> by mocking <code>A</code>. Here is the content of the file <code>testa.py</code> for this purpose:</p> <pre><code>import unittest import mock import a class TestB(unittest.TestCase): @mock.patch('a.A') def test_method_b(self, mock_a): mock_a.method_a.return_value = 'Mocked A' b = a.B() b.method_b() if __name__ == '__main__': unittest.main() </code></pre> <p>I expect to get <code>Mocked A</code> in the output. But what I get is:</p> <pre><code>&lt;MagicMock name='A().method_a()' id='4326621392'&gt; </code></pre> <p>Where am I doing wrong?</p>
<python><python-unittest><magicmock>
2016-07-05 08:48:12
HQ
38,199,434
angular2: How to use observables to debounce window:resize
<p>so i am trying to figure out a way to debouce window:resize events using observables, so some kind of function would be called only after user stoped resizing window or some time has passed without size change (say 1sec).</p> <p><a href="https://plnkr.co/edit/cGA97v08rpc7lAgitCOd" rel="noreferrer">https://plnkr.co/edit/cGA97v08rpc7lAgitCOd</a></p> <pre><code>import {Component} from '@angular/core' @Component({ selector: 'my-app', providers: [], template: ` &lt;div (window:resize)="doSmth($event)"&gt; &lt;h2&gt;Resize window to get number: {{size}}&lt;/h2&gt; &lt;/div&gt; `, directives: [] }) export class App { size: number; constructor() { } doSmth(e: Event) { this.size = e.target.innerWidth; } } </code></pre> <p>is just a simple sample that uses window:resize and shows that it reacts instantly (use "Launch preview in separate window").</p>
<angular><observable>
2016-07-05 09:10:26
HQ
38,199,818
Slack icon not visible any more in notification area
<p>Not sure why but since recently, the <code>Slack</code> icon in bottom right notification area (Windows 10) isn't visible anymore despite Slack app being checked in "Select which icons appear on the taskbar" section. Consequently I need to keep <code>Slack</code> open at all times in my app bar (which I don't want because it's crowded).</p> <p>Any idea what's causing the problem here?</p>
<slack>
2016-07-05 09:29:15
HQ
38,200,162
i want to send {"emailId":"IDtxt.text","password":"passtxt.text"} this string as whole string in alamofire request how could i do that?
code : let str :String = "{"emailId":"\(id)","password":"\(pass)"}" Alamofire.request(.GET, "http://constructionapp.dev04.vijaywebsolutions.com/proroffingservice.asmx?op=wsUserLogin", parameters: ["json":str]) .responseJSON{response in self.arrresult = JSON(response.result.value!)}
<ios><swift><alamofire>
2016-07-05 09:44:54
LQ_EDIT
38,200,460
npm install doesn't save dependency to package.json
<p>It does add only when I execute: <code>npm install &lt;package_name&gt; --save</code></p> <p>In the documentation though: <a href="https://docs.npmjs.com/cli/install" rel="noreferrer">https://docs.npmjs.com/cli/install</a> is written this: </p> <blockquote> <p>By default, npm install will install all modules listed as dependencies in package.json.</p> </blockquote> <p>Which is misleading. </p>
<node.js><npm>
2016-07-05 09:58:04
HQ
38,200,666
Airflow parallelism
<p>the Local Executor spawns new processes while scheduling tasks. Is there a limit to the number of processes it creates. I needed to change it. I need to know what is the difference between scheduler's "max_threads" and "parallelism" in airflow.cfg ?</p>
<airflow>
2016-07-05 10:08:56
HQ
38,200,982
How to compute all second derivatives (only the diagonal of the Hessian matrix) in Tensorflow?
<p>I have a <strong>loss</strong> value/function and I would like to compute all the second derivatives with respect to a tensor <strong>f</strong> (of size n). I managed to use tf.gradients twice, but when applying it for the second time, it sums the derivatives across the first input (see <em>second_derivatives</em> in my code). </p> <p>Also I managed to retrieve the Hessian matrix, but I would like to only compute its diagonal to avoid extra-computation.</p> <pre><code>import tensorflow as tf import numpy as np f = tf.Variable(np.array([[1., 2., 0]]).T) loss = tf.reduce_prod(f ** 2 - 3 * f + 1) first_derivatives = tf.gradients(loss, f)[0] second_derivatives = tf.gradients(first_derivatives, f)[0] hessian = [tf.gradients(first_derivatives[i,0], f)[0][:,0] for i in range(3)] model = tf.initialize_all_variables() with tf.Session() as sess: sess.run(model) print "\nloss\n", sess.run(loss) print "\nloss'\n", sess.run(first_derivatives) print "\nloss''\n", sess.run(second_derivatives) hessian_value = np.array(map(list, sess.run(hessian))) print "\nHessian\n", hessian_value </code></pre> <p>My thinking was that <strong>tf.gradients(first_derivatives, f[0, 0])[0]</strong> would work to retrieve for instance the second derivative with respect to f_0 but it seems that tensorflow doesn't allow to derive from a slice of a tensor.</p>
<python><tensorflow>
2016-07-05 10:23:35
HQ
38,201,441
how to extract a substring from a string in Python with regex?
<p>I have a string </p> <p><code>&lt;b&gt;Status : Active&lt;br&gt;Code : C1654&lt;br&gt;&lt;br&gt;Shop &lt;a class="top"&lt;b&gt;Shop A&lt;/b&gt;&lt;/a&gt;&lt;/b&gt;</code> </p> <p>And I want get <code>Active</code> , <code>C1654</code> and <code>Shop A</code>.</p> <p>How to do the same thing in Python?</p>
<python><regex>
2016-07-05 10:45:19
LQ_CLOSE
38,202,047
Total Number of pixels in an image
<p>How to get the total number of pixel in an image (785x728) image. I have applied loops here and it is taking lot of time. Any easy way</p> <pre><code>for i=1:height for j=1:width for d=1:colorChannel value = double(rgbImage(i,j,d)); display(i); totalSum = totalSum + value; display(totalSum); end end end </code></pre>
<matlab>
2016-07-05 11:15:35
LQ_CLOSE
38,202,408
C# - Display Files in a Folder on Button Click
<p>I am using Microsoft Visual Studio and i have a WPF project where i would like to be able to click a button and it displays all the .txt files in a specified folder.</p> <p>Is it possible to display the text files that are in the folder in a list?</p> <p>Any help appreciated.</p>
<c#>
2016-07-05 11:33:53
LQ_CLOSE
38,203,176
You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again
Gives this error on updating my 2nd version on google play store for beta testing. My first version was developed in eclipse whereas this version is in android studio. Please help.
<android><eclipse><google-play>
2016-07-05 12:14:15
LQ_EDIT
38,203,317
Ansible: no hosts matched
<p>I'm trying to execute my first remote shell script on Ansible. I've first generated and copied the SSH keys. Here is my yml file:</p> <pre><code>--- - name: Ansible remote shell hosts: 192.168.10.1 user: myuser1 become: true become_user: jboss tasks: - name: Hello server shell: /home/jboss/script.sh </code></pre> <p>When launching the playbook however, the outcome is "no hosts matched":</p> <pre><code>ansible-playbook setup.yml PLAY [Ansible remote shell ******************************************** skipping: no hosts matched PLAY RECAP ******************************************************************** </code></pre> <p>I've tried also using the host name (instead of the IP address), however nothing changed. Any help ?</p>
<ansible><ansible-playbook>
2016-07-05 12:20:32
HQ
38,203,352
Expand pandas DataFrame column into multiple rows
<p>If I have a <code>DataFrame</code> such that:</p> <pre><code>pd.DataFrame( {"name" : "John", "days" : [[1, 3, 5, 7]] }) </code></pre> <p>gives this structure:</p> <pre><code> days name 0 [1, 3, 5, 7] John </code></pre> <p>How do expand it to the following?</p> <pre><code> days name 0 1 John 1 3 John 2 5 John 3 7 John </code></pre>
<python><pandas>
2016-07-05 12:22:22
HQ
38,203,890
All rows getting update in sql server
I am trying to update a single row but found all rows are getting update. Stucted since morning. Idon't want to use datatable also create proc [dbo].[spUserProfile] @FirstName nvarchar(50), @MiddleName nvarchar(50), @LastName nvarchar(50), @Mobile nvarchar(50), @Aadhar nvarchar(50), @PAN nvarchar(50), @Address text, @CityID int, @PinCode int, @StateID int, @CountryID int AS Begin update tblUserProfiles Set FirstName = @FirstName, MiddleName = @MiddleName, LastName = @LastName, Mobile = @Mobile, Aadhar = @Aadhar, PAN = @PAN, Address = @Address, CityID = @CityID, PinCode = @PinCode, StateID = @StateID, CountryID = @CountryID, UserID = UserId End please give me a solution to me and error what i am missing
<sql><sql-server><tsql>
2016-07-05 12:47:47
LQ_EDIT
38,204,114
Javascript .animate() not working in HTML page
As simple as it is, I am wondering how is it possible that my little div is not getting any bigger. Anyone knows why? (p.s. I've tried to run it on every browser and i really can't find any syntax errors, I'm getting blind.. or just older) <!DOCTYPE html> <html> <head> <script> $(document).ready(function () { $(document.getElementById("abc").animate({ height:"500px", width:"500px", }, 5000, function() { // Animation complete. }); }); </script> <style> #abc { border:1px solid green; width: 100px; height:100px; } </style> </head> <body> <div id="abc"></div> </body> </html>
<javascript><jquery><html>
2016-07-05 12:58:34
LQ_EDIT
38,204,189
Regular Expression in Django URLs
<p>i am trying to add url to my view but it throws an exception </p> <p>"^(?p[0-9]+)/$" is not a valid regular expression: unknown extension ?p at position 2</p> <p>view url in URLs file</p> <pre><code>url(r'^(?p&lt;studentID&gt;[0-9]+)/$',views.Student,name ='Student' ) </code></pre>
<python><regex><django>
2016-07-05 13:02:18
LQ_CLOSE
38,204,370
Calculate time difference between two datetime in double digit hour,minutes and seconds format
<p>I am calculating time difference between two dates with format:</p> <blockquote> <p>Hour:Minutes:Seconds</p> </blockquote> <p>Right now i am getting output like this with the following input:</p> <pre><code>StartDate=2016-06-29 15:52:32.360 EndDate=2016-06-29 15:52:36.970 Output: 0 : 0 : 4 </code></pre> <p>But i want to get double digit output in time :</p> <pre><code>Expected Output: 00 : 00 : 04 </code></pre> <p><strong>Input:</strong> </p> <pre><code>StartDate=2016-06-29 15:52:32.360 EndDate=2016-06-29 15:53:36.970 Expected output: 00 : 01 : 04 </code></pre> <p>This is my code:</p> <pre><code>public class Attendance { public int Id { get; set; } public Nullable&lt;System.DateTime&gt; StartDateTime { get; set; } public Nullable&lt;System.DateTime&gt; EndDateTime { get; set; } } var query = (from t in context.Attendance select new { TotalTime =SqlFunctions.DateDiff("s",t.StartDateTime,t.EndDateTime) /3600 + " : " + SqlFunctions.DateDiff("s", t.StartDateTime, t.EndDateTime) % 3600 / 60 + ": " + SqlFunctions.DateDiff("s", t.StartDateTime, t.EndDateTime) % 60, }).tolist(); </code></pre> <p><strong>Note</strong>:I dont want to do like below:</p> <pre><code>var query = (from t in context.Attendance.toList(). select new { //code to calculate time difference and format time }).tolist(); </code></pre>
<c#><.net><entity-framework><linq>
2016-07-05 13:11:12
LQ_CLOSE
38,204,393
Order 'Contain' Model in CakePHP 3.x
<p>I have multiple <code>Things</code> in <code>AnotherThing</code> now I am trying to order them in my edit action in my <code>AnotherThing Controller</code> - I can access the <code>Things</code> just fine in my edit, but I want to sort them differently (not over their ID), for example <code>Things.pos</code></p> <p>Whats the best practice here? I tried it with </p> <pre><code>public $hasMany = array( 'Thing' =&gt; array( 'order' =&gt; 'Thing.pos DESC' ) ); </code></pre> <p>But nothing changed. Any idea?</p>
<model><cakephp-3.x><contain>
2016-07-05 13:12:47
HQ
38,205,290
Summing a number recursively and displaying it
<p>I searched for a solution to this problem quite a bit, but couldn't reach a solution. Would be great if someone can point me in the right direction.</p> <p>Ok, so suppose there's a number :-</p> <pre><code>0.001 </code></pre> <p>What I want to do is, <em>add</em> 0.001 (the same number) to it again and again ever second and also display the change dynamically. </p> <p>So :-</p> <pre><code>second 1 :- 0.001 second 2:- 0.002 second 3 :- 0.003 </code></pre> <p>This has to keep running for <em>1 hour</em> and I should be able to see it's value changing dynamically on my web page. How can I achieve this? I did quite a research on using <em>countup.js</em>, but no result. I thought of a solution to use ajax, but this would cause a lot of load. Whats the best that I can do here?</p>
<javascript><php><jquery><ajax>
2016-07-05 13:53:28
LQ_CLOSE
38,206,646
Do we need to import React or just {Component, PropTypes} will do?
<p>in all of my components I am currently including react like this:</p> <pre><code>import React, {Component, PropTypes} from 'react' </code></pre> <p>I don't see why everyone is including React when it is not used, hence wanted to check if it is safe to remove it?</p>
<javascript><reactjs><ecmascript-6>
2016-07-05 14:56:02
HQ
38,207,168
Is it possible to change the colour of the line below / Border of a TextBox (Entry)
<p>I am creating a <code>Xamarin.Forms</code> application on <code>Android</code> and I am trying to change the colour of the line below my <code>Xamarin.Forms</code> <code>Entry</code> control.</p> <p>I have an <code>Entry</code> control like so:</p> <pre><code>&lt;Entry Text="new cool street"/&gt; </code></pre> <p><a href="https://i.stack.imgur.com/xfn3V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xfn3V.png" alt="enter image description here"></a></p> <p>I would like to change the colour of the line below this <code>Entry</code> from the default white to more of a purple to match my theme.</p> <p>Idealy it would be better to do using Android Styles as it would apply to all controls inheriting from <code>Entry</code> if possible</p> <p>Is this possible to do?</p>
<c#><android><xamarin><xamarin.forms>
2016-07-05 15:20:46
HQ
38,207,785
How to recreate this mouseover effect from Blue Origin?
<p>On <a href="https://www.blueorigin.com/" rel="nofollow">https://www.blueorigin.com/</a> they have a mouseover effect on the front page with the "Astronaut Experience" and "tech..." boxes that are side by side each other underneath the video.</p> <p>I am learning how to code websites right now, and working on making one right now with that similar style of effect. How would I be able to implement this? I have some basic javascript knowledge, html, css and using nodejs+express</p>
<javascript><css>
2016-07-05 15:54:35
LQ_CLOSE
38,207,799
Python OOP sprite.Sprite.kill does really remove it
<p>I am using Python 2.7 and pygame to create Asteroid game using OOP and sprite class. I have a player and asteroids. When I detect a collision between a player and any asteroid using spritecollide, asteroid is removed from the group and I remove the player using kill. The player disappears from the screen but it is still there hidden. When another asteroid passes through where player used to be, it registers a collision and disappears as if player is still there. Is this the correct behavior? How do I remove the player from the game completely? Or do I just move it out of the game frame?</p>
<python><oop><pygame><sprite><kill>
2016-07-05 15:55:36
LQ_CLOSE
38,208,901
bootstrap-table hide column in mobile view
<p>I have a checkbox column which should only be visible on desktop and not on Mobile or Tabs.</p> <p>There are no options available in the documentation to hide/show any columns based on the devise.</p> <p>Can we do this?</p>
<bootstrap-table>
2016-07-05 17:03:09
HQ
38,209,656
Get Angular2 routing working on IIS 7.5
<p>I have been learning Angular2. The routing works just fine when running on the nodejs lite-server. I can go to the main (localhost:3000) page and move through the application. I can also type localhost:3000/employee and it will go to the requested page. </p> <p>The app will eventually live on an Windows IIS 7.5 server. The routing works fine if I start at the main page (localhost:2500), I am able to move through application with out any problems. Where I run into a problem is when trying to go directly to an page other then the main landing page (localhost:2500/employee). I get a HTTP Error 404.0.</p> <p>Here is my app.component file that handles the routing.</p> <pre class="lang-js prettyprint-override"><code>import { Component } from '@angular/core'; import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated'; import { HTTP_PROVIDERS } from '@angular/http'; import { UserService } from './services/users/user.service'; import { LogonComponent } from './components/logon/logon.component'; import { EmployeeComponent } from './components/employee/employee.component'; @Component({ selector : 'opi-app', templateUrl : 'app/app.component.html', directives: [ROUTER_DIRECTIVES], providers: [ROUTER_PROVIDERS, UserService, HTTP_PROVIDERS] }) @RouteConfig([ { path: '/', name: 'Logon', component: LogonComponent, useAsDefault: true }, { path: '/employee', name: 'Employee', component: EmployeeComponent } ]) export class AppComponent { } </code></pre> <p>I would like to say I understand the issue. IIS is looking for a direcotry of /employee but it does not exist. I just do not know how to make IIS aware of the routing. </p>
<html><angular><iis-7.5>
2016-07-05 17:51:31
HQ
38,209,815
How do I make a slack bot leave a channel?
<p>bots cannot use the regular channels.leave api call, so how do I make a bot leave a channel, short of kicking it? I need it to leave a channel where I do not have rights to kick users.</p>
<bots><slack>
2016-07-05 18:02:38
HQ
38,209,993
Index Bounds on Mongo Regex Search
<p>I'm using MongoDB, and I have a collection of documents with the following structure:</p> <pre><code>{ fName:"Foo", lName:"Barius", email:"fbarius@example.com", search:"foo barius" } </code></pre> <p>I am building a function that will perform a regular expression search on the <code>search</code> field. To optimize performance, I have indexed this collection on the search field. However, things are still a bit slow. So I ran an <code>explain()</code> on a sample query:</p> <pre><code>db.Collection.find({search:/bar/}).explain(); </code></pre> <p>Looking under the winning plan, I see the following index bounds used:</p> <pre><code>"search": [ "[\"\", {})", "[/.*bar.*/, /.*bar.*/]" ] </code></pre> <p>The second set makes sense - it's looking from anything that contains bar to anything that contains bar. However, the first set baffles me. It appears to be looking in the bounds of <code>""</code> inclusive to <code>{}</code> exclusive. I'm concerned that this extra set of bounds is slowing down my query. Is it necessary to keep? If it's not, how can I prevent it from being included?</p>
<regex><mongodb><indexing>
2016-07-05 18:14:15
HQ
38,210,604
Visual Studio Code Automatic Imports
<p>I'm in the process of making the move from Webstorm to Visual Studio Code. The Performance in Webstorm is abysmal.</p> <p>Visual studio code isn't being very helpful about finding the dependencies I need and importing them. I've been doing it manually so far, but to be honest I'd rather wait 15 seconds for webstorm to find and add my import that have to dig around manually for it.</p> <p><a href="https://i.stack.imgur.com/pjeiN.png"><img src="https://i.stack.imgur.com/pjeiN.png" alt="Screenshot: cannot find import"></a></p> <p>I'm using the angular2 seed from @minko-gechev <a href="https://github.com/mgechev/angular2-seed">https://github.com/mgechev/angular2-seed</a></p> <p>I have a tsconfig.json in my baseDir that looks like this:</p> <pre><code> { "compilerOptions": { "target": "es5", "module": "commonjs", "declaration": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true, "pretty": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitUseStrict": false, "noFallthroughCasesInSwitch": true }, "exclude": [ "node_modules", "dist", "typings/index.d.ts", "typings/modules", "src" ], "compileOnSave": false } </code></pre> <p>and I have another one in my src/client dir that looks like this:</p> <pre><code>{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "allowSyntheticDefaultImports": true } } </code></pre> <p>I don't know why there are two. The angualr seed project uses typescript gulp build tasks so I guess the compilation is different.</p> <p>What can I do get vscode to be more helpful??</p>
<typescript><angular><visual-studio-code>
2016-07-05 18:50:56
HQ
38,211,000
C# Get computer name from IP
<p>I'm using Xamarin Studio to develop to iOS and I need a couple of functions to get the Computer Name from the IP and vice-versa</p> <p>I've tried this code to get the machine name from IP</p> <pre><code>string machineName = string.Empty; try { IPHostEntry hostEntry = Dns.GetHostEntry(ipAdress); machineName = hostEntry.HostName; } catch (Exception ex) { // Machine not found... } return machineName; </code></pre> <p>But I keep getting the machine IP Address, so it's useless because I input the IP Address and get the IP Address.</p> <p>I've tried something alike to get the IP Address from the HostName I always get the exception "Unable to resolve hostname <em>HITMAN-DESKTOP</em>" being the <em>HITMAN-DESKTOP</em> my remote machine that is accessible from any point in the network and online during the tests.</p> <p>Any ideas?</p>
<c#><ios><xamarin><hostname><system.net>
2016-07-05 19:15:17
LQ_CLOSE
38,211,089
finding the index based on two data frames of strings
One of my data look like this O75663 O95456 O75663 O95456 O95400 O95670 O95400 O95670 O95433 O95433 O95801 O95456 P00352 O95670 My second data looks like this O75663 O95400 O95433 O95456 O95670 O95801 P00352 P00492 I want to know each string from second data is seen in which columns of the first data. it might never be seen or seen several time. I want the output to look like the following strings column ids O75663 1, 3 O95400 1, 3 O95433 1, 3 O95456 2, 3, 4 O95670 2, 3, 4 O95801 4 P00352 4 P00492 NA
<r>
2016-07-05 19:21:32
LQ_EDIT
38,211,393
I am getting a Fatal Exception: Main
<p>I am very new to android and just learning on the fly mostly from tutorial videos. I am having an issue where I am getting a fatal exception when I try to run the app. I believe the portion of the code generating the error is below, I have a char array of letters that I am trying to scramble and then set the text of certain buttons to those letters (i.e. letter1A.setText(scrambleLettersChar[0]). I did the same thing above this portion of the code and it worked just fine. TIA.</p> <pre><code>char[] solutionLetters = {letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12}; for (int i = 0; i &lt; solutionLetters.length; i++) { int randomIndex = (int) (Math.random() * solutionLetters.length); char temp = solutionLetters[i]; solutionLetters[i] = solutionLetters[randomIndex]; solutionLetters[randomIndex] = temp; } String scrambleLettersString = new String(solutionLetters); scrambleLettersChar = scrambleLettersString.toCharArray(); letter1A.setText(scrambleLettersChar[0]); } </code></pre>
<java><android><null>
2016-07-05 19:38:31
LQ_CLOSE
38,211,411
Java script to display partial value of the select tag
<p>I'm very new to javascript but I want to write a script for a select tag (for countries and their phone codes). I want it such that the dropdown list shows the country and code, but after the user selects only the code should be displayed. I'm using PHP to write the webpage. Thanks</p>
<javascript><php><html>
2016-07-05 19:39:48
LQ_CLOSE
38,212,471
Springboot @retryable not retrying
<p>The following code is not retrying. What am I missing?</p> <pre><code>@EnableRetry @SpringBootApplication public class App implements CommandLineRunner { ......... ......... @Retryable() ResponseEntity&lt;String&gt; authenticate(RestTemplate restTemplate, HttpEntity&lt;MultiValueMap&lt;String, String&gt;&gt; entity) throws Exception { System.out.println("try!"); throw new Exception(); //return restTemplate.exchange(auth_endpoint, HttpMethod.POST, entity, String.class); } </code></pre> <p>I have added the following to the pom.xml.</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.springframework.retry&lt;/groupId&gt; &lt;artifactId&gt;spring-retry&lt;/artifactId&gt; &lt;version&gt;1.1.2.RELEASE&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>I also tried providing different combinations of arguments to @Retryable.</p> <pre><code>@Retryable(maxAttempts=10,value=Exception.class,backoff=@Backoff(delay = 2000,multiplier=2)) </code></pre> <p>Thanks.</p>
<java><spring><maven><spring-boot><spring-retry>
2016-07-05 20:49:50
HQ
38,212,529
Relative links/partial routes with routerLink
<p>In my app some URLs take the form</p> <pre><code>/department/:dep/employee/:emp/contacts </code></pre> <p>In my sidebar I show a list of all employees, each of which has a <code>[routerLink]</code> which links to that employee's contacts</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;a [routerLink]="['/department', 1, 'employee', 1, 'contacts']"&gt;&lt;/a&gt; &lt;li&gt; &lt;li&gt; &lt;a [routerLink]="['/department', 1, 'employee', 2, 'contacts']"&gt;&lt;/a&gt; &lt;li&gt; ... &lt;/ul&gt; </code></pre> <p>However, with this approach I always need to provide the full path, including all the params (like <code>dep</code> in the above example) which is quite cumbersome. Is there a way to provide just part of the route, such as</p> <pre><code>&lt;a [routerLink]="['employee', 2, 'contacts']"&gt;&lt;/a&gt; </code></pre> <p>(without the <code>department</code> part, because I don't really care about <code>department</code> in that view and my feeling is that this goes against separation of concerns anyway)?</p>
<angular><angular2-routing>
2016-07-05 20:53:20
HQ
38,212,649
Feature Importance with XGBClassifier
<p>Hopefully I'm reading this wrong but in the XGBoost library <a href="http://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn" rel="noreferrer">documentation</a>, there is note of extracting the feature importance attributes using <code>feature_importances_</code> much like sklearn's random forest.</p> <p>However, for some reason, I keep getting this error: <code>AttributeError: 'XGBClassifier' object has no attribute 'feature_importances_'</code></p> <p>My code snippet is below:</p> <pre><code>from sklearn import datasets import xgboost as xg iris = datasets.load_iris() X = iris.data Y = iris.target Y = iris.target[ Y &lt; 2] # arbitrarily removing class 2 so it can be 0 and 1 X = X[range(1,len(Y)+1)] # cutting the dataframe to match the rows in Y xgb = xg.XGBClassifier() fit = xgb.fit(X, Y) fit.feature_importances_ </code></pre> <p>It seems that you can compute feature importance using the <code>Booster</code> object by calling the <code>get_fscore</code> attribute. The only reason I'm using <code>XGBClassifier</code> over <code>Booster</code> is because it is able to be wrapped in a sklearn pipeline. Any thoughts on feature extractions? Is anyone else experiencing this?</p>
<python><scikit-learn><xgboost>
2016-07-05 21:00:30
HQ
38,212,691
How to change base url only for rest controllers?
<p>Is there any configuration option that allows to change base url only for rest controllers, for example if my api's base url is www.example.com/user/{id} becomes www.example.com/rest/user/{id} ?</p> <p>I am using spring boot v1.3.2</p> <p>I tried to create custom annotation which extends RestController by adding RequestMapping. Here is the example, but it does not work.</p> <pre><code>@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @RestController @RequestMapping(value = "/rest", path = "/rest") public @interface MyRestController { } </code></pre>
<java><spring-boot>
2016-07-05 21:03:11
HQ
38,212,841
How to write a form that catches all errors,c#?
I want to write a form in my Windows Application Solution that catches all the error and instead of showing that ugly error page shows me sth beatifully designed (by myself)? Thanks for your answer in advance.
<c#>
2016-07-05 21:14:23
LQ_EDIT
38,212,926
open iOS iPad simulator with React Native
<p>When testing a React Native app with <code>react-native run-ios</code> it opens an iPhone simulator.</p> <p>You can change the virtual device to an iPad in the Simulator options, but the React Native app does not appear in the list of installed apps.</p> <p>Is there a way to open an iPad simulator from the CLI?</p>
<ios><ipad><react-native>
2016-07-05 21:19:57
HQ
38,213,286
Overriding methods in Swift extensions
<p>I tend to only put the necessities (stored properties, initializers) into my class definitions and move everything else into their own <code>extension</code>, kind of like an <code>extension</code> per logical block that I would group with <code>// MARK:</code> as well.</p> <p>For a UIView subclass for example, I would end up with an extension for layout-related stuff, one for subscribing and handling events and so forth. In these extensions, I inevitably have to override some UIKit methods, e.g. <code>layoutSubviews</code>. I never noticed any issues with this approach -- until today.</p> <p>Take this class hierarchy for example:</p> <pre><code>public class C: NSObject { public func method() { print("C") } } public class B: C { } extension B { override public func method() { print("B") } } public class A: B { } extension A { override public func method() { print("A") } } (A() as A).method() (A() as B).method() (A() as C).method() </code></pre> <p>The output is <code>A B C</code>. That makes little sense to me. I read about Protocol Extensions being statically dispatched, but this ain't a protocol. This is a regular class, and I expect method calls to be dynamically dispatched at runtime. Clearly the call on <code>C</code> should at least be dynamically dispatched and produce <code>C</code>?</p> <p>If I remove the inheritance from <code>NSObject</code> and make <code>C</code> a root class, the compiler complains saying <code>declarations in extensions cannot override yet</code>, which I read about already. But how does having <code>NSObject</code> as a root class change things?</p> <p>Moving both overrides into their class declaration produces <code>A A A</code> as expected, moving only <code>B</code>'s produces <code>A B B</code>, moving only <code>A</code>'s produces <code>C B C</code>, the last of which makes absolutely no sense to me: not even the one statically typed to <code>A</code> produces the <code>A</code>-output any more!</p> <p>Adding the <code>dynamic</code> keyword to the definition or an override does seem to give me the desired behavior 'from that point in the class hierarchy downwards'...</p> <p>Let's change our example to something a little less constructed, what actually made me post this question:</p> <pre><code>public class B: UIView { } extension B { override public func layoutSubviews() { print("B") } } public class A: B { } extension A { override public func layoutSubviews() { print("A") } } (A() as A).layoutSubviews() (A() as B).layoutSubviews() (A() as UIView).layoutSubviews() </code></pre> <p>We now get <code>A B A</code>. Here I cannot make UIView's layoutSubviews dynamic by any means.</p> <p>Moving both overrides into their class declaration gets us <code>A A A</code> again, only A's or only B's still gets us <code>A B A</code>. <code>dynamic</code> again solves my problems.</p> <p>In theory I could add <code>dynamic</code> to all <code>override</code>s I ever do but I feel like I'm doing something else wrong here.</p> <p>Is it really wrong to use <code>extension</code>s for grouping code like I do?</p>
<swift><swift2><swift-extensions>
2016-07-05 21:44:04
HQ
38,213,926
Interface for associative object array in TypeScript
<p>I have an object like so:</p> <pre><code>var obj = { key1: "apple", key2: true, key3: 123, . . . key{n}: ... } </code></pre> <p>So <code>obj</code> can contain any number of named keys, but the values must all be either string, bool, or number.</p> <p>How do I declare the type of <code>obj</code> as an interface in TypeScript? Can I declare an associative array (or variadic tuple) of a union type or something similar?</p>
<typescript><tuples><associative-array><unions>
2016-07-05 22:35:11
HQ
38,213,980
PHP function that accepts a JSON encoded array
<p>I was solving some math matrix problem, and I got idea to write PHP function that accepts a JSON encoded array and:</p> <p>1) Sort first row of the given matrix (2D array) in ascending order. During the sorting, other rows should be moved like they are sticked to the first row (you are moving all columns when sorting first row).</p> <p>2) Find the biggest number in the sorted 2D array except of first row. Then calculate the sum of the biggest number's coordinates (coordinates are starting at [1, 1]).</p> <p>-- First row is only for sorting, it is not used for calculations</p> <p>-- If the biggest number exist in more than one row then all coordinates of this biggest number have to be added to the sum) </p> <p>Example of matrix (2D array) is:</p> <p>6 3 9</p> <p>9 1 6</p> <p>4 7 9</p> <p>Solution to the example is following:</p> <p>6 3 9 => 3 6 9 => 3 6 9</p> <p>9 1 6 => 1 9 6 => 1 <strong>9</strong> 6 => 9 (2, 2) and 9 (3, 3) => (2 + 2) + (3 + 3) => 10</p> <p>4 7 9 => 7 4 9 => 7 4 <strong>9</strong></p> <p>But, at the moment,I`m beginner in PHP and such code is above my skill, so I need some help.</p> <p>First part is PHP array, but how to write such array with values found with coordinates as index. As you see, I`m stuck at the beginning of the problem!</p>
<php><arrays><json><sorting>
2016-07-05 22:40:39
LQ_CLOSE
38,214,078
React Native rnpm unlink library
<p>Recently added this library: <a href="https://github.com/ivpusic/react-native-image-crop-picker" rel="noreferrer">https://github.com/ivpusic/react-native-image-crop-picker</a> but after trying to debug the issues that I get on build, I saw that this library is unavailable for linking through rnpm and only through cocoapods. Is there any way to unlink the library using rnpm and then install cocoa pods and do it that way? I don't want to create some conflicts between the two. </p> <p>The issue I'm getting with the library is <code>'RCTHBridgeModule.h file not found.'</code> and the creator of the library said he currently does not support rnpm. </p>
<ios><node.js><reactjs><react-native><cocoapods>
2016-07-05 22:54:17
HQ
38,214,157
Changing DateTime format to dd/mmmm/yyyy
<p>I have a DateTime object in the format of <code>6/07/2016</code>, and I want to change it to be in the format of <code>6th July 2016</code>.</p> <p>How can I do this in C#? Been looking around but only seem to find ways to turn strings into DateTime in this format. What if I already have a DateTime object? Convert to string first?</p> <p>Thanks</p>
<c#><.net><datetime>
2016-07-05 23:02:39
LQ_CLOSE
38,215,243
Passing PowerShell $_ to DOS
Is there to feed from PowerShell to DOS through a pipeline? For example can I do something like get-admember abc123 | net user /domain $_.samaccountname (I know there are other ways to get it to work, I just want to focus on the communication between PowerShell and DOS)? Regards, George
<powershell><cmd>
2016-07-06 01:40:24
LQ_EDIT
38,215,274
Devise NoMethodError 'for' ParameterSanitizer
<p>I'm going nuts with an error I'm getting every time I try to sing in/sing up on my web.</p> <p>Heroku logs:</p> <pre><code>Started GET "/users/sign_in" for 201.235.89.150 at 2016-07-06 01:35:03 +0000 Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms) NoMethodError (undefined method `for' for #&lt;Devise::ParameterSanitizer:0x007f5968e0a920&gt;): app/controllers/application_controller.rb:11:in `configure_permitted_parameters' </code></pre> <p>application_controller.rb</p> <pre><code>class ApplicationController &lt; ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_filter :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :provider, :uid) } devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :current_password) } end end </code></pre> <p>The thing is it is working fine locally. It´s just on Heroku. And also it was working just fine a couple of days ago.</p>
<ruby-on-rails><ruby><heroku><devise>
2016-07-06 01:45:16
HQ
38,215,602
Using date pipe in a conditional expression - Angular 2
<p>With the follow expression I'm expecting for Angular to interpolate a date (if not null) through the date pipe, but I get the proceeding error.</p> <pre><code>{{charge.offenseDate ? charge.offenseDate | date : 'No date'}} EXCEPTION: Error: Uncaught (in promise): Template parse errors: Parser Error: Conditional expression {{charge.offenseDate ? charge.offenseDate | date : 'No Date' }} requires all 3 expressions at the end of the expression </code></pre> <p>Is what I'm expecting possible, or just a...<em>pipe dream</em> :)</p>
<angular>
2016-07-06 02:39:25
HQ
38,215,606
defining functions and index in PostgreSQL
I have 2 questions in Postgres: 1- How can I define(create) these functions? - AnyElement(s): which returns any element. - FirstElement(s): which returns the first element. - lastElement(s): which returns the last element. - ithElement(s): which returns the ith element. - currentElement(s): which returns current element. 2- How can I define(create) index?
<postgresql><function><indexing>
2016-07-06 02:40:00
LQ_EDIT
38,217,065
When is the parent class variables available to use in Python?
<pre><code>class frozen(object) : isFrozen = False print 'In base' class layer(frozen): print isFrozen </code></pre> <p>I am trying to understand the inheritance concept in Python, the above lines are a silly example. "print" statement in the parent class is working as I try to create an object of layer class. But it's throwing an error at the "print" statement of the child class. Saying "isFrozen" is not defined.</p> <p>But, if I comment out the "print" statement in child class, I can create an object of the child class and access "isFrozen" as "layerObject.isFrozen".</p> <p>So, could anyone please point out my misunderstanding here? </p>
<python><inheritance>
2016-07-06 05:49:23
LQ_CLOSE
38,217,359
How to target child element in JavaScript
<p>How to target the img element in JavaScript to change img src. </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt; &lt;div class="cover"&gt; &lt;img src="img.jpg" width="60" height="60"&gt; &lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p>
<javascript>
2016-07-06 06:16:08
LQ_CLOSE
38,217,414
Android Studio Tutorial
<p>I need an Android Studio programming tutorial.</p> <p>I'm new to programming in android, but not programming itself, so i would want to follow a tutorial of both Android Studio IDE and Android Programming.</p>
<android><android-studio>
2016-07-06 06:21:06
LQ_CLOSE
38,217,443
Creating an app like instagram
<p>I want to create an application like instagram and I have already created a simple social app on parse which shows user photos. However I want to implement complex functions such as adding friends, viewing friend's feed,etc. I want to know if such an app can be built entirely on Parse or a similar service? Do I need to develop a backend for such an app? If yes, what programming languages should I learn. I'm familiar with android studio, SQLite, JSON, Java. Pls suggest.</p>
<android><ios><android-studio><server><instagram>
2016-07-06 06:23:34
LQ_CLOSE
38,217,507
How to get mimimum and maximum values in text file in C#?
In the text file(test.txt) have value "Hi this my code project file" Minimum=5 and maximum=6 I need out put is minimum= 5 ("Hi t) maximum=6 ("Hi th) "Hi th
<c#>
2016-07-06 06:28:15
LQ_EDIT
38,217,683
What are the pros and cons of using AWS Code Deploy Vs Jenkins?
<p>We are using a bunch of EC2 instances which might scale in the future (around 100 instances), now we are looking towards auto deployments using either Jenkins or AWS Code deploy.</p> <p>I found that we can use AWS Code deploy plugin with Jenkins, but What are the pros and cons of following?</p> <p>1) Standalone AWS Code Deploy 2) Jenkins with AWS Code Deploy plugin.</p>
<amazon-web-services><jenkins><continuous-integration><continuous-deployment><aws-code-deploy>
2016-07-06 06:40:41
HQ
38,218,080
How do i get this in my website?
[I want something like this in my website. What is it called? How can i include something like this. I need all those Options too.][1] [1]: http://i.stack.imgur.com/I2rMN.jpg
<javascript><html><css>
2016-07-06 07:07:05
LQ_EDIT
38,219,032
Bootstrap button inside input-group
<p>How to make it so that it appears nicely after input page with same height?</p> <pre><code>&lt;div class="input-group"&gt; &lt;input type="text" class="form-control"/&gt; &lt;button class="input-group-addon" type="submit"&gt; &lt;i class="fa fa-search"&gt;&lt;/i&gt; &lt;/button&gt; &lt;/div&gt; </code></pre> <p>Here is code <a href="http://jsfiddle.net/6mcxdjdr/" rel="noreferrer">http://jsfiddle.net/6mcxdjdr/</a> The first one is original input-group, the second one is something what I am trying to have</p>
<html><css><twitter-bootstrap>
2016-07-06 08:03:10
HQ
38,219,918
How to find element with attribute?
<p>I have the following html:</p> <pre><code>&lt;div class="item" data-value="100"&gt;Something&lt;/div&gt; </code></pre> <p>Now, I am using the following to find this element:</p> <pre><code>$( "div[data-value=value]") </code></pre> <p>Where <code>value</code> is <code>"100"</code>. However, I don't think jquery sees the <code>value</code> as javascript object - I think it takes it as it is. How can I fix this?</p>
<jquery>
2016-07-06 08:54:18
LQ_CLOSE
38,220,329
Can't show a model info in template
<p>I would like to show my model in template, but I've a problem :</p> <pre><code>Uncaught ReferenceError: title is not defined </code></pre> <p>There's my code:</p> <pre><code> var NewsView2 = Backbone.View.extend({ NewsView: _.template(NewsView), initialize: function () { console.log(this); this.$el.html(this.NewsView()); this.render(); }, render: function () { this.$el.html(this.NewsView()); var html = this.NewsView(this.model.toJSON()); this.$el.append(html); return this; } }); </code></pre> <p>initialize:</p> <pre><code> var news2 = new News({ author: "costam", }); var widok2 = new NewsView2({model: news2}); </code></pre> <p>and code in my template:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;%= title %&gt; &lt;/body&gt; </code></pre> <p></p> <p>Someone could help me with that? I don't have any idea to do it.</p>
<backbone.js>
2016-07-06 09:15:09
LQ_CLOSE
38,220,543
Java 8 LocalDate - How do I get all dates between two dates?
<p>Is there a usablility to get <strong>all dates between two dates</strong> in the new <code>java.time</code> API?</p> <p>Let's say I have this part of code:</p> <pre><code>@Test public void testGenerateChartCalendarData() { LocalDate startDate = LocalDate.now(); LocalDate endDate = startDate.plusMonths(1); endDate = endDate.withDayOfMonth(endDate.lengthOfMonth()); } </code></pre> <p>Now I need all dates between <code>startDate</code> and <code>endDate</code>.</p> <p>I was thinking to get the <code>daysBetween</code> of the two dates and iterate over:</p> <pre><code>long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); for(int i = 0; i &lt;= daysBetween; i++){ startDate.plusDays(i); //...do the stuff with the new date... } </code></pre> <p>Is there a better way to get the dates?</p>
<java><date><java-8><java-time>
2016-07-06 09:25:57
HQ
38,221,126
How to do pattern matching on map keys in function heads in elixir
<p>I can't seem to find a way to pattern match on a map's key in a function head. Is there a way to do this? What I'm trying to do is run different code depending on whether a certain key already exists in a map or not (and also wanted to avoid if/else and the like)</p> <p>This is what my code looks like</p> <pre class="lang-ex prettyprint-override"><code>def my_func(key, %{key =&gt; _} = map), do: ... </code></pre> <p>which gives me this error</p> <blockquote> <p>** (CompileError) illegal use of variable key inside map key match, maps can only match on existing variable by using ^key</p> </blockquote> <p>Of course I also tried it using the <code>^</code></p> <pre><code>def my_func(key, %{^key =&gt; _} = map), do: ... </code></pre> <p>which then gives</p> <blockquote> <p>** (CompileError) unbound variable ^key</p> </blockquote> <p>I'm using elixir 1.3.1/erlang 19.0 x64 on a windows 8.1 machine. Thanks for reading!</p>
<pattern-matching><elixir>
2016-07-06 09:53:16
HQ