title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
Can I make a file optional based on a variable's value in cookiecutter.json
<p>I would like to have a file that is optionally added in my python cookiecutter project.</p> <p>An example would be in cookiecutter.json have the variable</p> <pre><code>{"settings_file": true} </code></pre> <p>which would create a file <code>settings.py</code> at the root of my directory (with maybe some contents).</p> <p>Does cookiecutter offer an option to do this? Or should I be using the post processing hook to write a script which creates the files (which I feel like is not the most elegant solution).</p>
1
POST request with string parameters and array
<p>I want to make a POST request and pass some parameters. The parameters I want to pass is:</p> <pre><code>- Item : String - Length : String - Names : String Array - Age : String </code></pre> <p>Today I´m doing this </p> <pre><code>var URL: NSURL = NSURL(string: "URL")! var request:NSMutableURLRequest = NSMutableURLRequest(URL:URL) request.HTTPMethod = "POST" request.HTTPBody = // parameters here? NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) { (response, data, error) in println(NSString(data: data, encoding: NSUTF8StringEncoding)) } </code></pre> <p>Can anyone provide help of how to pass the above parameters in my request? I´m not quite sure how to do that.</p>
1
Changing the Git username
<p>I use Git GNU bash, version 4.3.42(5)-release (x86_64-pc-msys) windows 8.1 pro. I gave it a username at the very beginning by typing the command: git config --global user.name"xyz" but then when i've got to Github, this username was already taken, so i tried to change my Git username to be the same as the one Github. Typing the same command then typing : git config --list but it keeps showing the old username, i've tried even to uninstall it, and then retype the same command, but it's the same issue. Someone maybe can tell me how to fix it ?</p>
1
change selected item in md-select programmatically
<p>I want to initially (on page load) set the current schoolclass item in the md-select.</p> <p>This code sets the selected schoolclass but it is not reflected in the <code>md-select</code> visually.</p> <pre><code>$scope.selectedSchoolclass = schoolclasses.length &gt; 0 ? schoolclasses[0] : null; &lt;md-input-container&gt; &lt;label&gt;Schoolclasses&lt;/label&gt; &lt;md-select ng-model="selectedSchoolclass" md-on-close="getPupils()"&gt; &lt;md-option ng-repeat="s in schoolclasses" ng-value="{{s}}"&gt; {{s.schoolclassNumber}} &lt;/md-option&gt; &lt;/md-select&gt; &lt;/md-input-container&gt; </code></pre> <p>When I use <code>md-selected="$first"</code> then it is selected visually in the <code>md-select</code> but I get an error from a computed property which seem to evaluate first just before the $first. Thus I cannot set the first schoolclass as the selected schoolclass from html. I have to do it via JS in the controller.</p> <p>How can I do that?</p>
1
Kafka -> Flink DataStream -> MongoDB
<p>I want to setup Flink so it would transform and redirect the data streams from Apache Kafka to MongoDB. For testing purposes I'm building on top of flink-streaming-connectors.kafka example (<a href="https://github.com/apache/flink" rel="noreferrer">https://github.com/apache/flink</a>).</p> <p>Kafka streams are being properly red by Flink, I can map them etc., but the problem occurs when I want to save each recieved and transformed message to MongoDB. The only example I've found about MongoDB integration is flink-mongodb-test from github. Unfortunately it uses static data source (database), not the Data Stream.</p> <p>I believe there should be some DataStream.addSink implementation for MongoDB, but apparently there's not.</p> <p>What would be the best way to achieve it? Do I need to write the custom sink function or maybe I'm missing something? Maybe it should be done in different way? </p> <p>I'm not tied to any solution, so any suggestion would be appreciated.</p> <p>Below there's an example what exactly i'm getting as an input and what I need to store as an output.</p> <pre><code>Apache Kafka Broker &lt;-------------- "AAABBBCCCDDD" (String) Apache Kafka Broker --------------&gt; Flink: DataStream&lt;String&gt; Flink: DataStream.map({ return ("AAABBBCCCDDD").convertTo("A: AAA; B: BBB; C: CCC; D: DDD") }) .rebalance() .addSink(MongoDBSinkFunction); // store the row in MongoDB collection </code></pre> <p>As you can see in this example I'm using Flink mostly for Kafka's message stream buffering and some basic parsing.</p>
1
Spring AMQP Responding to ReplyTo Queue from MessageListener
<p>If I am asynchronously listening to Spring AMQP messages how do I respond using the ReplyTo Queue and Correlation ID provided by the sender?</p> <pre><code> @Override public void onMessage(Message message) { byte[] bytes = message.getBody(); String body = new String (bytes); logger.info(application + " processing message: \n" + body); //some business logic //now I want to respond to the replyto queue with the correlation ID //rabbitTemplate.???? } </code></pre>
1
Error when submitting formspree.io from GitHub pages
<p>I am hosting a website on GitHub pages, and when I try to submit a formspree.io form I get the following error: </p> <p><img src="https://i.stack.imgur.com/kup5V.png" alt="error"></p> <p>Here is my code:</p> <pre><code>&lt;form action="http://formspree.io/[email protected]" method="post"&gt; &lt;div class="row uniform collapse-at-2"&gt; &lt;div class="6u"&gt; &lt;input type="text" name="_replyto" placeholder="Email"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="12u"&gt; &lt;textarea name="Message" placeholder="Message..." rows="4" cols="50" maxlength="500"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;br&gt; &lt;div style="display:none"&gt; &lt;input type="hidden" name="_subject" value="New submission!"&gt; &lt;input type="hidden" name="_next" value="thanks.html"&gt; &lt;input type="text" name="_gotcha"&gt; &lt;/div&gt; &lt;div class="row uniform"&gt; &lt;div class="12u"&gt; &lt;ul class="actions"&gt; &lt;li&gt; &lt;input type="submit" class="special" value="Send"&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Would this be due to a code error, GitHub pages error, or a formspree error?</p>
1
how do I add “contact page or custom link” at top menu bar in OpenCart?
<p>how do I add “contact page or custom link” at top menu bar in OpenCart?</p> <p>i am using Version 2.1.0.2</p> <p>how can i add "homepage and other page" at responsive menu in opencart?</p> <p>Thanks</p>
1
Selecting all the check-boxes at once in Shiny
<p>I would like to know how to select all the check-boxes at once. In my code I have Five check-boxes. </p> <pre><code>server &lt;- function(input, output) { output$distPlot &lt;- renderPlot({ hist(rnorm(input$obs), col = 'darkgray', border = 'white') }) } ui &lt;- fluidPage( sidebarLayout( sidebarPanel( sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100), checkboxInput("checkbox1", label = "meanSNR", value= FALSE), checkboxInput("checkbox2", label = "t-statistics", value = FALSE), checkboxInput("checkbox3", label = "adjusted p-value", value = FALSE), checkboxInput("checkbox4", label = "log-odds", value = FALSE), checkboxInput("checkbox5", label = "All", value = FALSE)), mainPanel(plotOutput("distPlot")) ) ) shinyApp(ui = ui, server = server) </code></pre> <p>I would like to know how to make it work</p> <p>1) If the user selects the fifth check-box <code>All</code>, It should automatically select all the check-boxes. On uncheck, it should deselect all the Checkboxes.</p> <p>2 ) If the user selects the first four check-boxes, it should select the fifth one <code>All</code> check-box too. </p> <p>For condition 1) , the screen should like this <a href="https://i.stack.imgur.com/D6v6p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D6v6p.png" alt="enter image description here"></a></p>
1
Owl Carousel 2 - Drag active when clicking a slide
<p>I am using Owl Carousel 2 and I have (and want) the mouseDrag and touchDrag active.</p> <p>When I click anything in the slide, however, owl thinks I dragged and changed the slide, so it fires onDragged callback. I DID NOT change the slide though, I just clicked on a slide ("mousedown", "mouseup" fires onDragStart).</p> <p>I want to be able to do something IF and only IF I change the specific slide with a drag move (for example: I go from slide 1 to slide 2). More specificaly, I want to prevent onDragStart unless I really change from one slide to another.</p> <p>What am I doing wrong?</p>
1
WordPress: Advanced search for custom post types and custom fields
<p>I have the following problem. I am trying to create a real estate website with wordpress. I have created a custom post type and I included the following fields with Advanced custom fields: Listing type (select: For sale, For rent), Property type (select: Apartment, House), Price (Number), City (field type: select)</p> <p>I have the following query to get the values:</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'properties', 'posts_per_page' =&gt; 10, 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( array( 'key' =&gt; 'property_type', 'value' =&gt; 'Apartment', ), ), ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt; &lt;?php $property_type = get_field('property_type'); $property_price = get_field('price'); $property_location = get_field('location'); $property_description = get_field('description'); ?&gt; &lt;div class="propert_list"&gt; &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt; &lt;div class="property_type"&gt; Location - &lt;strong&gt;&lt;?php echo $property_type; ?&gt;&lt;/strong&gt; &lt;/div&gt; &lt;div class="property_price"&gt; Price - &lt;strong&gt;&lt;?php echo $property_price; ?&gt;&lt;/strong&gt; &lt;/div&gt; &lt;div class="property_location"&gt; Location - &lt;strong&gt;&lt;?php echo $property_location['address']; ?&gt;&lt;/strong&gt; &lt;/div&gt; &lt;div class="property_description"&gt; Property Description - &lt;strong&gt;&lt;?php echo $property_description; ?&gt;&lt;/strong&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt;&lt;hr /&gt; &lt;?php endwhile; ?&gt; </code></pre> <p>Where and how can I create my search form to filter properties by 'property_type' and 'location'.</p>
1
oEmbed loading only caption of Instagram post
<p>I'm trying to use the Instagram API to load the latest post by a particular user to a page. According to the API docs, using only the shortlink for the desired picture, the oEmbed response should contain everything that you'd get if you clicked the "embed" link on the picture itself. </p> <p>Here's my code:</p> <pre><code>window.onload = function () { var insta = new XMLHttpRequest(); var embed = document.getElementById('embed'); insta.open("GET", "https://api.instagram.com/v1/users/user/media/recent/?access_token=my-token"); insta.send(); insta.addEventListener("load", function(){ var jsonResponse = JSON.parse(insta.responseText); var lastImageLink = jsonResponse.data[0].link; var shortCode = lastImageLink.split("/p/")[1]; var url = "https://api.instagram.com/oembed?url=http://instagr.am/p/" + shortCode; var getLatest = new XMLHttpRequest; getLatest.open("GET", url); getLatest.send() getLatest.addEventListener("load", function(){ getLatest = JSON.parse(getLatest.responseText); embed.innerHTML = getLatest.html; }); }); }; </code></pre> <p>So I do a GET request to get the link of the last post, take the shortlink suffix from that, then use that shortlink to perform another GET request to get get the embed code via the oEmbed method. However, when I load the page, what I see is just this:</p> <p><img src="https://i.imgur.com/fFO4nwZ.png" alt="image"></p> <p>What I've tried:</p> <p>*I know the API depends on the embeds.js library, so I moved that to the head of the html doc and made it load synchronously. No change in result.</p> <p>*Loading different pictures apart from the latest post. No change there either.</p> <p>And that's about all I can think of. Is there any reason I'm not able to get the full embedded post with what I'm doing?</p> <p>Thanks!</p>
1
Retrofit ProgressBar
<p>I have recently studied about Retrofit. I am just implementing in my project. I have almost 20 plus api. I have declared all the methods like.</p> <pre><code>public interface RF_Calls { @POST(AppConstants.API_EVENTS_BYSTUDENTS) void getEvents(@Body JsonObject events); @POST(AppConstants.API_EXAMS_BYSTUDENTS) void getExamsbyStudents(@Body JsonObject exams); } </code></pre> <p>I just want a common progressbar for both the methods which has to dismissed once it get success and failure</p>
1
How to check if an xlsx file is valid?
<p>I'm using <code>openpyxl</code> to deal with Excel sheets. It works fine, but then I encountered a file that gives me the following error:</p> <pre><code>Traceback (most recent call last): File "/home/ute/OM/Python_Scripts/preparePlanFileFromExcelReport.py", line 13, in &lt;module&gt; wb = load_workbook(differenceReportFile) File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/excel.py", line 151, in load_workbook archive = _validate_archive(filename) File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/excel.py", line 118, in _validate_archive archive = ZipFile(f, 'r', ZIP_DEFLATED) File "/usr/lib/python2.7/zipfile.py", line 714, in __init__ self._GetContents() File "/usr/lib/python2.7/zipfile.py", line 748, in _GetContents self._RealGetContents() File "/usr/lib/python2.7/zipfile.py", line 763, in _RealGetContents raise BadZipfile, "File is not a zip file" zipfile.BadZipfile: File is not a zip file </code></pre> <p>After some search, I found this error pops if your file is not a valid <em>xlsx</em> file. </p> <p>I can open the file normally with MS Excel 2013, but how can I tell if this file is a valid xlsx file?</p>
1
Why or when does the InputMethodManager.showSoftInput return false?
<p>I'm trying to popup an soft keyboard on the screen first load programmatically (not change windowSoftInputMode in Manifest).</p> <p>The funny thing is on the screen first load, it didn't work at all. Here is the code block.</p> <pre><code>mEDT.requestFocus(); mEDT.requestFocusFromTouch(); mImm.showSoftInput(mEDT, InputMethodManager.SHOW_IMPLICIT); </code></pre> <p>The showSoftInput is return false, this cause the soft keyboard didn't show.</p> <p>But when i click on the EditText. The showSoftInput return true and the soft keyboard was shown.</p> <p>Can anyone explain to me what was happened ?</p>
1
Changing the text of an existing snackBar
<p>I want to display a snackBar when my token becomes invalid. The snackbar will have an action attached to "Refresh" the token.</p> <pre><code>SnackBar outerSnackBar; outerSnackBar = Snackbar.make(coordinatorLayout, "Your request is unauthorized. Please refresh your token", Snackbar.LENGTH_INDEFINITE).setAction("Refresh"), new View.OnClickListener() { @Override public void onClick(View v) { outerSnackBar.setAction("", null); outerSnackBar.setText("Refreshing"); outerSnackBar.show(); } }).show(); </code></pre> <p>When I click on the snackBar's "Refresh" action button, I want the existing snackBar's text to change to "Refreshing" and the action to display hence this is the code that I have written in the onClickListener.</p> <p>However, when I click on the "Refresh" action button, the snackbar just dismisses itself.</p> <p>Is there anyway to modify the text and action of an existing snackbar?</p>
1
can I aggregate embedded documents in mongoDB by using dot notation?
<p>I have a document in MongoDb like this:</p> <pre><code>{ "_id" : ObjectId("56b88d5f2628a6bca1b17f99"), "first_name" : "JAMES", "last_name" : "SMITH", "accounts" : [ { "account_type" : "Savings", "account_balance" : 8995952.153640702, "currency" : "PESO" }, { "account_type" : "Checking", "account_balance" : 3901436.5580737568, "currency" : "USD" } ] } </code></pre> <p>I want to group by "last_name" and "accounts.account_type" and summing every related balance.</p> <p>I try dot notation like this but I have error and I couldn't find an explanation for this type of aggregation:</p> <pre><code>db.bank_data.aggregate([ {$group:{_id: "$last_name",accounts.account_type:"$accounts.acount_type", total:{$sum:"$accounts.account_balance"}}}]) </code></pre>
1
Django : loaddata to update data
<p>I have a fixture <code>seed_data.json</code> on which I have my initial data.</p> <p>Sometimes I add new data into this fixtures and reload it, which updates my data correctly.</p> <p>However, I now want to remove some data from it. So I modified my <code>seed_data.json</code>, for instance, I had something like that :</p> <pre><code>{"fields": {"name": "Field 0"},"model": "catalog.product","pk": 1}, {"fields": {"name": "Field 1"},"model": "catalog.product","pk": 2}, {"fields": {"name": "Field 2"},"model": "catalog.product","pk": 3}, # ... </code></pre> <p>That became :</p> <pre><code>{"fields": {"name": "Field 1"},"model": "catalog.product","pk": 1}, {"fields": {"name": "Field 2"},"model": "catalog.product","pk": 2}, # ... </code></pre> <p>But I'm getting :</p> <p><code>django.db.utils.IntegrityError: Problem installing fixture .....\seed_data.json</code></p> <p><code>Could not load catalog.Product(pk=2): column name is not unique</code></p> <p>So there's no problem when adding some data, but when trying to remove some, there are conflicts with the primary keys.</p> <p>How can I achieve what I'm trying to do ?</p>
1
RegionCode in YouTube API v3
<p>I can't seem to find any information on the implications of using/not using regionCode in the YouTube v3 API, for example the <a href="https://developers.google.com/youtube/v3/docs/search/list" rel="nofollow">search/list</a> resource.</p> <p>In the specific, if the regionCode is not specified in the call to the API, will all the videos matching the criteria be returned? If a video is allowed only in certain regions, not specifying the regionCode in the search request, will the API return it? Or only the unrestricted videos will be returned?</p> <p>Where can I find some clarification on the topic?</p>
1
How to handle OAuth2 authorization code with Spring OAuth2ClientAuthenticationProcessingFilter + AuthorizationCodeResourceDetails
<p>I'm trying to do an oauth2 authentication using Spring Security OAuth.</p> <p>I've plugged an <code>OAuth2ClientAuthenticationProcessingFilter</code> to my security config, and with an <code>AuthorizationCodeResourceDetails</code>. I'm retrieving the authorization code, but the Oauth flow is broken, I'm not able to get the access_token.</p> <p>Here is my configuration:</p> <pre class="lang-java prettyprint-override"><code>@Override protected void configure(HttpSecurity http) throws Exception { /** * Moved from com.myscript.backend.configuration.WebApp.java * https://stackoverflow.com/questions/20863489/characterencodingfilter-dont-work-together-with-spring-security-3-2-0 * */ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); http.addFilterBefore(characterEncodingFilter, CsrfFilter.class); String key = "**************************"; ApiPersistentTokenBasedRememberMeServices rememberMeServices = new ApiPersistentTokenBasedRememberMeServices(key, userDetailsService, adminTokenRepository); // @formatter:off http .exceptionHandling() .authenticationEntryPoint(new Http403ForbiddenEntryPoint()) .and() .csrf().disable() .rememberMe() .rememberMeServices(rememberMeServices) .tokenRepository(adminTokenRepository) .key(key) .userDetailsService(userDetailsService) .and() .addFilterAfter(oauth2ClientContextFilter, SecurityContextPersistenceFilter.class) .addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class) .formLogin() .loginProcessingUrl("/**/authentication/login*") .usernameParameter("email") .passwordParameter("password") .successHandler(new RestAuthenticationSuccessHandler()) .failureHandler(new RestAuthenticationFailureHandler()) .permitAll() .and() .logout() .invalidateHttpSession(true) .logoutSuccessHandler(new LogoutSuccessHandler() { @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { response.setStatus(HttpServletResponse.SC_OK); } }) .logoutRequestMatcher(new AntPathRequestMatcher("/**/authentication/logout*")) .permitAll() .and() .authorizeRequests() .antMatchers("/authentication/**", ...) .permitAll() .anyRequest() .authenticated() .and() .anonymous(); // @formatter:on } private Filter ssoFilter() { OAuth2ClientAuthenticationProcessingFilter ssoFilter = new OAuth2ClientAuthenticationProcessingFilter("/**/authentication/login/sso"); final OAuth2RestTemplate template = new OAuth2RestTemplate(sso()); ssoFilter.setRestTemplate(template); return ssoFilter; } @Bean protected OAuth2ProtectedResourceDetails sso() { AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); details.setId("sso"); details.setClientId("*******"); details.setClientSecret("*******"); details.setAccessTokenUri("http://sso.test.com/oauth/token"); details.setUserAuthorizationUri("http://sso.test.com/oauth/authorize"); details.setPreEstablishedRedirectUri("http://localhost:8894/api/v3.0/admin/authentication/login/sso"); details.setScope(Arrays.asList("read", "write")); details.setUseCurrentUri(false); return details; } </code></pre> <p>And at least I'm redirected to: <a href="http://localhost:8894/api/v3.0/admin/authentication?code=YjMXjl&amp;state=ktv3am#" rel="nofollow noreferrer">http://localhost:8894/api/v3.0/admin/authentication?code=YjMXjl&amp;state=ktv3am#</a></p>
1
how can I modify the brightness&contrast automatically on my images with fiji macro?
<p>I try to write a very simple macro with Fiji in order to merge channels and enhance contrast automatically. </p> <pre><code>dir = getDirectory("Select input directory"); out = getDirectory("Select destination directory"); files = getFileList(dir); //foreach tiff couple files for (j=0; j&lt;lengthOf(dir);j+2) { channel1 = dir+files[j]; channel2 = dir+files[j+1]; open(channel1); open(channel2); run("Enhance Contrast", "saturated=0.35"); // the same for the channel1 run("Apply LUT", "stack"); // the same for the channel1 run("Merge Channels...", "c1="+channel1+" c2="+channel2); run("Z Project...", "projection=[Sum Slices]"); saveAs("Tiff", out+"merge"+files[j]); run("Close"); } </code></pre> <p>With "enhance contrast", I don't know how I can use the button "auto" of the brightness&amp;contrast window in the macro. The channel 2 is stronger than the first.</p> <p>And with "apply LUT", an error occur when I have this line : "The display range must first be updated using Image>Adjust>Brightness/Contrast or threshold levels defined using Image>Adjust>Threshold." I changed the threshold level and it still doesn't work...</p> <p>What could you suggest to me ?</p>
1
HTML Form File Uploads doesn't upload file
<p>Files doesn't get uploaded though all back-end code is correct. I tested the back end code with another front-end styled code and it worked fine.</p> <p>but in my front end code it doesn't upload any files. I removed all css and scripts as well to figure out the issue.</p> <p>here is my simple front end HTML form :</p> <pre><code>&lt;form action="upload_handler.php" method="post"&gt; Select image to upload: &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt; &lt;input type="submit" value="Upload" name="submit"&gt; &lt;/form&gt; </code></pre>
1
Axis Y and X labels in Kendo UI chart
<p>How could I set a horizontal title for X axis and a vertical title for axis Y in Kendo chart ? </p> <p>For example , for <a href="http://dojo.telerik.com/@urielz/ofIzo" rel="nofollow noreferrer">this chart</a> I want to set titles (<em>Month</em> and <em>VISITORS</em>) as in this image - </p> <p><a href="https://i.stack.imgur.com/ovlXg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ovlXg.png" alt="enter image description here"></a></p>
1
notify_one performance impact
<p>I was reading a bit about <a href="http://en.cppreference.com/w/cpp/thread/condition_variable" rel="noreferrer"><code>std::condition_variable</code></a> and more particularly on how to notify a waiting thread using <code>std::condition_variable::notify_one</code>.</p> <p>I came across a few questions I will be happy to get answers on:</p> <ul> <li>What exactly happens when a thread calls <code>notify_one</code> (OS-wise)? I guess this is OS-specific, so for the sake of argument - I'm working in Windows.</li> <li>What happens if a thread calls <code>notify_one</code> when there is no waiting thread? Does this call have any performance impact (CPU-cycles, power etc)?</li> </ul> <p>Thanks</p>
1
IntelliJ runs unit tests with Maven instead of JUnit
<p>I have some Unit tests, that when I try to run, it automatically creates <code>Maven</code> run/debug configuration, instead of <code>JUnit</code> (the integrated IDEA tab).</p> <p>For some tests it does use JUnit <code>run\debug configuration</code> and manually - I can create both <code>Maven</code> and <code>JUnit</code>.</p> <p>How do I make JUnit to be the default test runner ?</p>
1
How to get a range of serial numbers based on the movement type?
<p>I'm trying to figure out how to perform the task in object. I want to get serial numbers from range A (internal) when i perform GR (101, 501) in storage location X. After quality checks, materials are transfered to storage location B via 311. After the 311 movement i want to change serials and get the new ones from another range (external)</p> <p>I already defined ranges and i'm already posting GR with serials from range A. I have to figure out how to tell to SAP to get serials from the second range after posting the 311.</p> <p>Thank you very much for your advice</p>
1
Selenium python unable to scroll down
<p>Trying to scroll down to the bottom of the page with selenium-webdriver python so that more products load. </p> <pre><code>driver = webdriver.Firefox() driver.get('https://www.woolworths.com.au/Shop/Browse/back-to-school/free-school-labels') driver.implicitly_wait(100) driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(100) driver.quit() </code></pre> <p>The webpage loads but doesn't change.</p> <p>Am I missing something?</p>
1
Shifting tiles in a puzzle game
<p>I am trying to make a puzzle game but the problem is that I can't do the EventHandler setOnMouseClicked.Also I want to know how to make possible that to re-arrange the puzzle so it shows random images in every-coordinate. This is how far I got.</p> <pre><code>import javafx.application.Application; import javafx.geometry.Pos; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class eliss extends Application{ @Override public void start(Stage primaryStage) { ImageView view[][] = new ImageView[5][5]; Image imag = new Image("http://images.cdn.autocar.co.uk/sites/autocar.co.uk/files/styles/gallery_slide/public/ferrari-laferrari-zfye-059_1.jpg?itok=hfLNxUD9",600,600,false,true); GridPane pane = new GridPane(); pane.setAlignment(Pos.CENTER); pane.setVgap(2); pane.setHgap(2); PuzzleImage(view, imag, pane); Scene scene = new Scene(pane,1100,1100); primaryStage.setTitle("Elis"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] x) { launch(x); } public void PuzzleImage( ImageView view[][],Image imag,GridPane pane) { for(int i=0;i&lt;5;i++) { for(int j=0;j&lt;5;j++) { if(j==4 &amp;&amp; i==4) view[i][j]=null; else{ view[i][j]=new ImageView(imag); Rectangle2D rect = new Rectangle2D(120*i,120*j,120,120); view[i][j].setViewport(rect); pane.add(view[i][j], i, j); } } } } } </code></pre>
1
No resource found that matches the given name (at 'theme' with value '@android:style/Theme.my_theme').(APT0000)
<p>I recently installed Xamarin Android brand new (version 5.10.1 build 6). When I tried to add a theme, I got the dreaded "No resource found..." error.<br> It is the first theme I have tried to add, so I am not sure if the problem could be due to something I've written in my code. Searching on StackOverflow and the Xamarin fora however, I discovered that the issue probably means that some Android library is not installed. </p> <p>So I have installed a lot more stuff from the latest and previous APIs, as well as from Extras, but am still getting the same error.<br> The app is just a simple app aimed at phones, so I didn~t install wear or tv libraries. How far back do I have to go with Android APIs?<br> And is there anything that I should install that isn't obvious? </p> <p>There are a lot of answers out there already for this particular error, but many of them are vague, and don't give exact instructions, or refer to components that I don't recognise, I think because I am using Xamarin.</p> <p>Here is my theme code.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;resources&gt; &lt;style name="Theme.my_theme" parent="@android:style/Theme.DeviceDefault.Light.DialogWhenLarge"&gt; &lt;item name="android:textColor"&gt;#00FF00&lt;/item&gt; &lt;item name="android:typeface"&gt;monospace&lt;/item&gt; &lt;item name="android:textSize"&gt;20sp&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>Here is the manifest.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="My_app.My_app"&gt; &lt;uses-sdk android:minSdkVersion="17" /&gt; &lt;application android:label="My_app" android:theme="@android:style/Theme.my_theme" android:icon="@drawable/icon"&gt;&lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Here is the Android manager showing what is installed. Is there something obvious that is not installed?</p> <p><a href="https://i.stack.imgur.com/9bCI7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9bCI7.png" alt="androidmanager1"></a> <a href="https://i.stack.imgur.com/NCXdD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NCXdD.png" alt="androidmanager2"></a> <a href="https://i.stack.imgur.com/i6N56.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i6N56.png" alt="androidmanager3"></a> <a href="https://i.stack.imgur.com/t3Str.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t3Str.png" alt="androidmanager4"></a></p>
1
JsonGenerationException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?)
<p>I'm trying to add an instance of this class to <code>neo4j spring 4.0.0.RELEASE</code>:</p> <pre><code>@NodeEntity public class User { @GraphId private Long id; @Property private UUID uniqueId = UUID.randomUUID(); @Property private String username; @Property private String password; // getters, setters, blah blah... } </code></pre> <p>When I do I get this exception:</p> <pre><code>ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/pegboard] threw exception [Request processing failed; nested exception is org.neo4j.ogm.metadata.MappingException: Could not create JSON due to Null key for a Map not allowed in JSON (use a converting NullKeySerializer?)] with root cause com.fasterxml.jackson.core.JsonGenerationException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?) at com.fasterxml.jackson.databind.ser.impl.FailingSerializer.serialize(FailingSerializer.java:35) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:538) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:469) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:29) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:561) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:469) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:29) ~[jackson-databind-2.6.5.jar:2.6.5] at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693) ~[jackson-databind-2.6.5.jar:2.6.5] ...more stack trace... </code></pre> <p>What is going on?</p>
1
Power Query - Select Columns from table instead of removing afterwards
<p>The default behaviour when importing data from a database table (such as SQL Server) is to bring in all columns and then select which columns you would like to remove.</p> <p>Is there a way to do the reverse? ie Select which columns you want from a table? Preferably without using a Native SQL solution.</p> <p><strong>M:</strong></p> <pre><code>let db = Sql.Databases("sqlserver.database.url"){[Name="DatabaseName"]}[Data], Sales_vDimCustomer = db{[Schema="Sales",Item="vDimCustomer"]}[Data], remove_columns = Table.RemoveColumns(Sales_vDimCustomer,{"Key", "Code","Column1","Column2","Column3","Column4","Column5","Column6","Column7","Column8","Column9","Column10"}) in remove_columns </code></pre> <p>The snippet above shows the connection and subsequent removal.</p> <p>Compared to the native SQL way way:</p> <pre><code>= Sql.Database("sqlserver.database.url", "DatabaseName", [Query=" SELECT Name, Representative, Status, DateLastModified, UserLastModified, ExtractionDate FROM Sales.vDimCustomer "]) </code></pre> <p>I can't see much documentation on the <code>}[Data],</code> value in the step so was hoping maybe that I could hijack that field to specify which fields from that data.</p> <p>Any ideas would be great! :)</p> <p>My first concern is that when this gets compiled down to SQL, it gets sent as two queries (as watched in ExpressProfiler).</p> <p>The first query removes the selected columns and the second selects all columns.</p> <p>My second concern is that if a column is added to or removed from the database then it could crash my report (additional columns in Excel Tables jump your structured table language formulas to the wrong column). This is not a problem using Native SQL as it just won't select the new column and would actually crash if the column was removed which is something I would want to know about.</p>
1
Pants includes OS X specific Python wheels
<p><strong>TLDR</strong>: Pants fetches OS X specific wheels bc I'm developing on Mac. How can I avoid this, or specify that I will deploy to Ubuntu?</p> <p><strong>Full story</strong>:</p> <p>Trying to package a Python application with Pants. Going great so far, but ran into a problem which I've been stuck at for a while. I'm developing on a macbook but deploying to EC2 Ubuntu.</p> <p>Here's what I've done so far:</p> <ol> <li>Created virtualenv.</li> <li>Added BUILD files to applications, with the <a href="https://pantsbuild.github.io/3rdparty_py.html" rel="noreferrer">suggested 3rd party pattern</a> for third party packages.</li> <li>Ran <code>./pants run.py backend:admin_server</code> which runs fine and generated <code>dist/admin_server.pex</code></li> <li>Scp that .pex onto a fresh EC2 Ubuntu box.</li> </ol> <p>However when I run the application there, I get:</p> <pre><code>Failed to execute PEX file, missing compatible dependencies for: mysql-python pycrypto </code></pre> <p>The problem seems to be that Pants takes OS X specific wheels for these 2:</p> <p>pex: - MySQL_python-1.2.5-cp27-none-macosx_10_11_intel.whl pex: - pycrypto-2.6.1-cp27-none-macosx_10_11_intel.whl</p> <p>How can I avoid that, or specify which OS they should run on?</p> <p>Here's the full output:</p> <pre><code>ubuntu@ip-***:~$ export PEX_VERBOSE=1 ubuntu@ip-***:~$ python admin_server.pex pex: Found site-library: /usr/local/lib/python2.7/dist-packages pex: Found site-library: /usr/lib/python2.7/dist-packages pex: Tainted path element: /usr/local/lib/python2.7/dist-packages pex: Tainted path element: /usr/lib/python2.7/dist-packages pex: Scrubbing from site-packages: /usr/local/lib/python2.7/dist-packages pex: Scrubbing from site-packages: /usr/lib/python2.7/dist-packages pex: Scrubbing from user site: /home/ubuntu/.local/lib/python2.7/site-packages pex: Failed to resolve a requirement: MySQL-python==1.2.5 pex: Failed to resolve a requirement: pycrypto==2.6.1 pex: Unresolved requirements: pex: - mysql-python pex: - pycrypto pex: Distributions contained within this pex: pex: - six-1.10.0-py2.py3-none-any.whl pex: - protobuf-2.6.1-py2.7.egg pex: - setuptools-19.5-py2.py3-none-any.whl pex: - MySQL_python-1.2.5-cp27-none-macosx_10_11_intel.whl pex: - pycrypto-2.6.1-cp27-none-macosx_10_11_intel.whl pex: - futures-3.0.4-py2-none-any.whl pex: - webapp2-2.5.2-py2-none-any.whl pex: - requests-2.9.0-py2.py3-none-any.whl pex: - jmespath-0.9.0-py2.py3-none-any.whl pex: - beautifulsoup4-4.4.1-py2-none-any.whl pex: - python_dateutil-2.4.2-py2.py3-none-any.whl pex: - boto3-1.2.3-py2.py3-none-any.whl pex: - WebOb-1.5.1-py2.py3-none-any.whl pex: - cssutils-1.0.1-py2-none-any.whl pex: - webapp2_static-0.1-py2-none-any.whl pex: - Paste-2.0.2-py2-none-any.whl pex: - docutils-0.12-py2-none-any.whl pex: - botocore-1.3.22-py2.py3-none-any.whl pex: - protobuf_to_dict-0.1.0-py2-none-any.whl Failed to execute PEX file, missing compatible dependencies for: mysql-python pycrypto </code></pre> <p>PS: to make sure I didn't include my versions of the python libraries, I pip uninstalled both PyCrypto and MySQL-Python.</p>
1
sequelize query that implements calculation using provided value and table row value
<p>equivalent sequelize query for the following raw query:</p> <pre><code>SELECT *, (distance1 - table.distance) as distance FROM table HAVING distance &gt;= 100; </code></pre>
1
Python- Writing text to a file?
<p>I am trying to learn python and wanted to write some text to a file. I came across two kind of file objects.</p> <p>fout=open("abc.txt",a)</p> <p>with open("abc.txt",a) as fout:</p> <p>The following code:</p> <pre><code>f= open("abc.txt", 'a') f.write("Step 1\n") print "Step 1" with open("abc.txt", 'a') as fout: fout.write("Step 2\n") </code></pre> <p>Gave the output:</p> <pre><code>Step 2 Step 1 </code></pre> <p>And the following code:</p> <pre><code>f= open("abc1.txt", 'a') f.write("Step 1\n") f= open("abc1.txt", 'a') f.write("Step 2\n") </code></pre> <p>Gave the output:</p> <pre><code>Step 1 Step 2 </code></pre> <p>Why is there difference in the outputs? </p>
1
Query all dates less than the given date (Month and Year)
<p>I have a table: tblperson</p> <p>There are three columns in tblperson</p> <pre><code>id amort_date total_amort C000000004 12/30/2015 4584.00 C000000004 01/31/2016 4584.00 C000000004 02/28/2016 4584.00 </code></pre> <p>The user will have to provide a billing date <code>@bill_date</code></p> <p>I want to sum all the total amort of all less than the date given by the user on month and year basis regardless of the date</p> <p>For example</p> <pre><code> @bill_date = '1/16/2016' Result should: ID sum_total_amort C000000004 9168.00 </code></pre> <p>Regardless of the date i want to sum all amort less than January 2016</p> <p>This is my query but it only computes the date January 2016, it does not include the dates less than it:</p> <pre><code> DECLARE @bill_date DATE SET @bill_date='1/20/2016' DECLARE @month AS INT=MONTH(@bill_date) DECLARE @year AS INT=YEAR(@bill_date) SELECT id,sum(total_amort)as'sum_total_amort' FROM webloan.dbo.amort_guide WHERE loan_no='C000000004' AND MONTH(amort_date) = @month AND YEAR(amort_date) = @year GROUP BY id </code></pre>
1
Using Gulp to run Webpack + Babel, but no presets are being applied
<p>I'm using Gulp to run Webpack because some things that are trivial with Gulp are messy with Webpack, such as multiple outputs. However, <code>babel-loader</code> doesn't seem to be doing anything. When I have JSX in my scripts, I get a parse error. When I use ES6/7, nothing is transformed.</p> <p>Here's the Gulp task:</p> <pre><code>gulp.task('js', function() { return gulp.src('js/*.js') .pipe(webpack({ loaders: [{ test: /.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'stage-0', 'react'] } }], output: { filename: '[name].js' } })) .pipe(gulp.dest('public/js')); }); </code></pre> <p>Is there something I'm doing wrong?</p>
1
How to get response from facebook share button?
<blockquote> <p>This is facebook share button code from facebook</p> </blockquote> <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt; &lt;script&gt;(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));&lt;/script&gt; &lt;!-- Your share button code --&gt; &lt;div class="fb-share-button" data-href="http://www.your-domain.com/your-page.html" data-layout="button_count"&gt; &lt;/div&gt; </code></pre> <p>How can I get response of success or error from this?</p> <p>I tried some examples but didn't got response after sharing via code.</p> <p>Share button works and it also sharing the post.</p> <pre><code> window.fbAsyncInit = function() { // init the FB JS SDK FB.init({ appId : '1743496239724', // App ID from the App Dashboard //channelUrl : 'http://exampb.com/plugins/', // Channel File for x-domain communication status : true, // check the login status upon init? cookie : true, // set sessions cookies to allow your server to access the session? xfbml : true // parse XFBML tags on this page? }); // Additional initialization code such as adding Event Listeners goes here FB.ui( { method: 'feed', }, function(response) { if (response &amp;&amp; response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } ); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); </code></pre> <p>I tried this but its conflicting. With that share button obtained from FB.</p>
1
Bootstrap-treeview with jquery Ajax Get not showing response
<p>Working with the <a href="https://github.com/jonmiles/bootstrap-treeview" rel="nofollow">bootstrap-treeview</a> package in Laravel 5.1:</p> <pre><code>function getTree() { ... $.ajax({ type: 'GET', url: loadUrl, dataType: "json", }) .done(function (response) { return response; }) .fail(function (response) { console.log(response); }); } $('#tree').treeview({data: getTree()}); </code></pre> <p>This code is working, it gives me a proper JSON response, so routes etc are correct and working. </p> <p>When I take the raw response out of firebug and add it as a manual response to getTree (return [the raw json returned by getTree];) bootstrap-treeview shows exactly what's expected.</p> <p>When I compare both JSON strings (the above method and raw pasted in getTree) in the html source of the page they are EXACTLY the same.</p> <p>I am pulling my hair out for a day now. What can be the issue here?</p>
1
Gatling repeat with connection re-use
<p>With Gatling 2, is it possible to repeat with connection re-use? How?</p> <p>I have the below code, but it appears to open new connection every time. I want to maintain x connections for some time.</p> <pre><code>val httpProtocol = http .baseURL("http://mysrv.pvt") .inferHtmlResources() val uri1 = "http://mysrv.pvt" val scn = scenario("Simulation").repeat(50){ pause(2 seconds,20 seconds). exec(http("request_0") .get("/s1/serve.html") ) } setUp(scn.inject( atOnceUsers(20000) ).protocols(httpProtocol)) </code></pre>
1
Calling Cpanel UAPI method
<p>i have the following simple script to list the ftp accounts but i am unable to get it to work as i have the following error as soon as it tries to call the constructor</p> <pre><code> include '/usr/local/cpanel/php/cpanel.php'; $cpanel = new CPANEL(); // Connect to cPanel - only do this once. // List FTP account information. $list_ftp_accts = $cpanel-&gt;uapi('Ftp', 'list_ftp'); echo "&lt;pre&gt;"; print_r($list_ftp_accts); </code></pre> <blockquote> <p>Fatal error: Uncaught exception 'RuntimeException' with message 'There was a problem fetching the env variable containing the path to the socket' in /usr/local/cpanel/php/cpanel.php:146 Stack trace: #0 /public_html/uapi.php(4): CPANEL->__construct() #1 {main} thrown in /usr/local/cpanel/php/cpanel.php on line 146</p> </blockquote> <p>Line 146 in cpanel.php </p> <pre><code>$socketfile = getenv('CPANEL_PHPCONNECT_SOCKET'); </code></pre>
1
How to insert array of document in mongodb using node.js?
<p>I want to insert array of document to mongodb using node.js but while inserting it's only inserting first data only.</p> <pre><code>[{ "userid": "5664", "name": "Zero 2679", "number": "1234562679", "status": "contact", "currentUserid": "Abcd" }, { "userid": "5665", "name": "Zero 3649", "number": "1234563649", "status": "contact", "currentUserid": "Xyz" }] </code></pre> <p>Sample code</p> <pre><code>collection.insert([{"userid": userid,"name": name,"number": number,"status": status,"currentUserid": currentUserid}], function(err, docs) { if (err) { res.json({error : "database error"}); }else { collection.find({currentUserid:currentUserid}).toArray(function(err, users) { res.send(users); }); }}); </code></pre> <p>But it still inserting first value only can you please tell me how to insert all these documents.</p> <p>Please kindly go through my post and suggest me some solution.</p>
1
react redux login with facebook
<p>I am learning react and found redux. I am using redux to login with facebook.</p> <p>I have action in my actions folder like <code>actions/facebook.js</code></p> <pre><code> import * as types from '../constants/ActionTypes' export function loginSuccess(response){ return dispatch =&gt; { dispatch({ response, type: types.FB_LOGIN }); }; } export function login(){ window.fbAsyncInit = function() { FB.init({ appId : '172141521144545437894', cookie : true, xfbml : true, version : 'v2.1' }); FB.getLoginStatus(function(response) { this.statusChangeCallback(response); }.bind(this)); }.bind(this); (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function fetchUser() { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Successful login for: ' + response.name); }); }; function statusChangeCallback(response) { console.log('statusChangeCallback'); console.log(response); if (response.status === 'connected') { console.log(response.authResponse.accessToken); this.fetchUser(); } else if (response.status === 'not_authorized') { console.log("Not authorised"); } else { console.log("Please log in to facebook"); } }; function checkLoginState() { FB.getLoginStatus(function(response) { this.statusChangeCallback(response); }.bind(this)); dispatch(loginSuccess(response)) }; function handleLogin() { FB.login(this.checkLoginState()); }; function handleLogout(){ FB.logout(function(response) {}); }; } </code></pre> <p>and I have reducers like <code>reducers/Login.js</code></p> <pre><code> import { FB_LOGIN } from '../constants/ActionTypes' const initialState = [ { accessToken = null, isLoggedIn: false, isLoggedOut: true, userData: [] } ] export default function pvlogin(state = initialState, action) { if action.type === FB_LOGIN switch (action.type) { case FB_LOGIN: return { accessToken: action.authResponse.accessToken, isLoggedIn: true, isLoggedOut: false, }, default: return state } } </code></pre> <p>and my <code>reducers/index.js</code></p> <pre><code> import * as ActionTypes from '../actions' import { routerStateReducer as router } from 'redux-router' import { combineReducers } from 'redux' const rootReducer = combineReducers({ pvlogin, }) export default rootReducer and my container to handle this.. `containers/Login.js` import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import Login from '../components/Login' import * as FbActions from '../actions/facebook' function mapStateToProps(state) { return { login: state.pvlogin } } function mapDispatchToProps(dispatch) { return bindActionCreators(FbActions, dispatch) } export default connect(mapStateToProps, mapDispatchToProps)(Login) </code></pre> <p>and my store looks like </p> <pre><code> import { createStore, applyMiddleware } from 'redux' import thunk from 'redux-thunk' import rootReducer from '../reducers' const createStoreWithMiddleware = applyMiddleware( thunk )(createStore) export default function configureStore(initialState) { const store = createStoreWithMiddleware(reducer, initialState) if (module.hot) { // Enable Webpack hot module replacement for reducers module.hot.accept('../reducers', () =&gt; { const nextReducer = require('../reducers') store.replaceReducer(nextReducer) }) } return store } </code></pre> <p>and my component for login </p> <pre><code> import React, { Component, PropTypes } from 'react' class Login extends Component{ console.log("inside login") render() { const { login } = this.props return ( &lt;div&gt; &lt;a href="#" onClick={login.handleLogin}&gt;Login with Facebook&lt;/a&gt; &lt;/div&gt; ) } } Login.propTypes = { login: PropTypes.func.isRequired } export default Login </code></pre> <p>and finally my <code>index.js</code></p> <pre><code>import React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' import Login from './containers/Login' import configureStore from './store/configureStore' const store = configureStore() render( &lt;Provider store={store}&gt; &lt;Login /&gt; &lt;/Provider&gt;, document.getElementById('root') ) </code></pre> <p>I am very new to react and redux.. I am messing with this from few hours and not got any head out.. </p> <p>Can anyone suggest me how to handle facebook login ..</p>
1
angucomplete-alt: getting value of text when it doesn't match
<p>Angucomplete-alt works great for me when trying to force the user into a pre-defined selection among objects. </p> <p>But if I don't want to force the user to one of those objects, if instead I want the user to be able to enter free text and only have the completions as <em>suggestions</em>, how then do I access the text of the input field?</p> <p>For example I have a hidden field that marshals the string value of the Angucomplete-alt field for submission to the backend DB. Like this:</p> <pre><code>&lt;input type="hidden" name="dance[start_type]" ng-value="IS_THERE_A_SELECTION ? selectedStartType.originalObject.name : JUST_TELL_ME_THE_STRING_THEY_TYPED"/&gt; </code></pre> <p>What expressions should I put for IS_THERE_A_SELECTION and JUST_TELL_ME_THE_STRING_THEY_TYPED? </p>
1
In which thread FutureCallback will be called for a ListenableFuture in Guava?
<p>I must have missed something. I had a hard time to understand in which thread FutureCallback will be called for a ListenableFuture in Guava.</p> <p>The first version of my code is:</p> <pre><code> Log.d("mydebug", "Before submit, " + Thread.currentThread() + ", " + android.os.Process.myTid()); ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); ListenableFuture future = service.submit(new Runnable() { @Override public void run() { Log.d("mydebug", "In run, " + Thread.currentThread() + ", " + android.os.Process.myTid()); } }); Futures.addCallback(future, new FutureCallback() { @Override public void onSuccess(Object result) { Log.d("mydebug", "In onSuccess, " + Thread.currentThread() + ", " + android.os.Process.myTid()); } @Override public void onFailure(Throwable thrown) { Log.d("mydebug", "In onFailure, " + Thread.currentThread() + ", " + android.os.Process.myTid()); } }, MoreExecutors.sameThreadExecutor()); </code></pre> <p>The output for the first version of my code is:</p> <pre><code>02-04 12:37:00.815 11327 11327 D mydebug : Before submit, Thread[main,5,main], 11327 02-04 12:37:00.825 11327 11382 D mydebug : In run, Thread[pool-1-thread-1,5,main], 11382 02-04 12:37:00.825 11327 11327 D mydebug : In onSuccess, Thread[main,5,main], 11327 </code></pre> <p>I added Thread.sleep into the Runnable to make the second version of my code:</p> <pre><code> Log.d("mydebug", "Before submit, " + Thread.currentThread() + ", " + android.os.Process.myTid()); ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); ListenableFuture future = service.submit(new Runnable() { @Override public void run() { Log.d("mydebug", "In run, " + Thread.currentThread() + ", " + android.os.Process.myTid()); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } }); Futures.addCallback(future, new FutureCallback() { @Override public void onSuccess(Object result) { Log.d("mydebug", "In onSuccess, " + Thread.currentThread() + ", " + android.os.Process.myTid()); } @Override public void onFailure(Throwable thrown) { Log.d("mydebug", "In onFailure, " + Thread.currentThread() + ", " + android.os.Process.myTid()); } }, MoreExecutors.sameThreadExecutor()); </code></pre> <p>The output for the second version of code is:</p> <pre><code>02-04 12:43:02.165 17180 17180 D mydebug : Before submit, Thread[main,5,main], 17180 02-04 12:43:02.205 17180 17229 D mydebug : In run, Thread[pool-1-thread-1,5,main], 17229 02-04 12:43:04.215 17180 17229 D mydebug : In onSuccess, Thread[pool-1-thread-1,5,main], 17229 </code></pre> <p>So in the first version of my code, FutureCallback was executed in the thread that called service.submit, while the second version of my code executed FutureCallback in a thread in the thread pool. I am confused. What exactly does MoreExecutors.sameThreadExecutor() mean? It didn't work as I expected.</p>
1
How do I get the pay u key and salt
<p>I am getting a message </p> <blockquote> <p>SORRY! We were unable to process your payment Checksum Failed</p> </blockquote> <p>I have followed their document for the key and salt. The value is as follows.</p> <pre><code>$merchant_key='JBZaLc'; $merchant_salt='GQs7yium'; </code></pre> <p>I went through the following links:</p> <ul> <li><p><a href="https://stackoverflow.com/questions/33645696/transaction-error-pay-u-money">Transaction error pay u money</a></p></li> <li><p><a href="https://stackoverflow.com/questions/23773892/sorry-some-error-occurred-while-integrating-payumoney-payment-gateway-in-test">&#39;sorry some error occurred&#39; while integrating PayUMoney payment gateway in Test mode</a></p></li> </ul> <p>According to the above links the key and the salt has been changed. How do I get the key and salt value for testing payu account.</p> <p>Please help!</p>
1
Deep copy of CMSampleBufferRef
<p>I'm trying to perform a deep copy of a CMSampleBufferRef for audio and video connection ? I need to use this buffer for delayed processing. Can somebody helper here by point to a sample code.</p> <p>Thanks</p>
1
Handle MySQL exceptions in Visual Studio
<p>The following code checks if I can connect to the MySQL database or not. It is working fine when it connects but when it can't connect it throws out an error instead of executing the 'Else' statement</p> <pre><code> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace MySQLConnection { public partial class FrmConnection : Form { public FrmConnection() { InitializeComponent(); } string connectionString = "host=192.168.0.91; database=c#1; user=test1; password=test1"; private void button1_Click(object sender, EventArgs e) { using (MySqlConnection con= new MySqlConnection(connectionString)) { con.Open(); if(con.State==ConnectionState.Open) { label1.Text = "Connection Established!"; } else { label1.Text = "Connection Error!"; } } } } } </code></pre> <p>I get this error</p> <blockquote> <p>An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll</p> </blockquote> <p>Additional information: Unable to connect to any of the specified MySQL hosts.</p>
1
How to configure amazon cloudfront to block some S3 bucket files access?
<p>On S3 we have all files as private. Users can't load any file through S3 link. But they are all public through cloudfront link. </p> <p>How can i restrict access to ./restricted.txt? (only users who use signed URL link can see that file through cloudfront link), ./not_restricted.txt must be public the same time.</p> <p>How i did that.</p> <p>I have created /public &amp; /private folders on s3, separated my private/public files, created cloudfront origin that point to /public. So all my S3 files which are in /public folder are public and i can load them using link without public prefix /img1.jpg istead /public/img1.jpg, because cloudfront thinks about /public as a root folder. </p> <p>Now all my files that are in /private or any other place above /public folder are private through either S3 and cloudfront links. </p> <p>But i don't know how to create signed URL for /private/restricted.txt file that will have cloudfront path. I can create signed url which use S3 path, but i need to have cloudfront link.</p> <p>Thanks in advance.</p>
1
how to read file from resource folder in eclipse
<p>I'm trying to read an xml file from resource folder which is <strong>inside</strong> <strong>WebContent</strong> in the eclipse project. The problem is that i'm unable to read the file from resources folder but its working fine by giving a path outside(ie,E:/new/test.xml).</p> <pre><code>File file = new File(request.getSession().getServletContext().getContextPath()+"/resources/new/test.xml"); </code></pre> <p>Can anyone please help me to solve the issue..Thanks in advance.</p>
1
Can not Connect to Node Client. Error: connect ECONNREFUSED 127.0.0.1:27017
<p>I am writing this line of code to connect to mongodb via mongoose. </p> <pre><code>var db=mongoose.connect('mongodb://localhost/bookapi'); </code></pre> <p>But this is showing this error in command prompt.</p> <pre><code>Error: connect ECONNREFUSED 127.0.0.1:27017 at Object.exports._errnoException (util.js:870:11) at exports._exceptionWithHostPort (util.js:893:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14) </code></pre> <p>Help Please.</p>
1
How to generate a list of beans dynamically
<p>Hy</p> <p>I'm looking for a way to 'simplify'/shorten my spring configuration. I' ve got this Generic service that looks something like:</p> <pre><code>public class GenericService&lt;T&gt; { private Class&lt;T&gt; targetClass; public void setTargetClass(Class&lt;T&gt; targetClass) {this.targetClass = targetClass;} public void doSomething() {...} } </code></pre> <p>and in my spring-config.xml file I have</p> <pre><code>&lt;bean id="entity1Service" class="GenericService"&gt; &lt;property name="targetClass" value="model.Entity1" /&gt; &lt;/bean&gt; &lt;bean id="entity2Service" class="GenericService"&gt; &lt;property name="targetClass" value="model.Entity2" /&gt; &lt;/bean&gt; ... </code></pre> <p>I'm trying to build a factory that will build all these services for me so that I could write something like this in my spring-config.xml</p> <pre><code>&lt;bean class="ServiceFactory"&gt; &lt;property name="targets"&gt; &lt;list&gt; &lt;value&gt;model.Entity1&lt;/value&gt; &lt;value&gt;model.Entity2&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>which would generate 2 beans (one named entity1Service, the other entity2Service). Get-it?</p> <p>How would I start? I've looked at BeanFactory (not to be confused with FactoryBean!) but fail to see how to hookup everything up.</p> <p>It would be even better if my factory could scan my packages and generate a service when it finds an entity (either through annotation or interface implementation), a little like @EnableJpaRepositories annotation in spring-data does for all JpaRepository interfaces.</p> <p>Thanks for any insights, examples, pointers...</p> <p>w.</p>
1
Hibernate FetchMode SELECT vs JOIN
<p>I have the following class:</p> <pre><code> @Entity public class TestContentElementResponse { @Id @GeneratedValue(strategy = GenerationType.AUTO) protected Long id; @OneToMany(mappedBy = "testContentElementResponse", cascade = CascadeType.ALL, orphanRemoval = false) private Set&lt;ResponseAttribute&gt; associatedResponseAttributes = new HashSet&lt;ResponseAttribute&gt;(); @ManyToOne @JoinColumn(name = "userfulltestId", referencedColumnName = "id", nullable = false) private UserFullTest userFullTest; @ManyToOne @JoinColumn(name = "testContentElementId", referencedColumnName = "id", nullable = false) private TestContentElement testContentElement; @OneToOne(cascade = CascadeType.ALL) private TestContentElementScore testContentElementScore; @ManyToOne @JoinColumn(name = "userId", referencedColumnName = "id", nullable = false) private User user; </code></pre> <p>TestContentElementResponse.class represents one user response in a test. One test can be 30 questions, so 30 responses per user.</p> <p>Now I want to call ALL TestContentElementResponse for ONE user (common id is UserFullTestId) and ALL ResponseAttributes for each TestContentElementResponse. </p> <p>I can do this with a criteria query, but I am not sure whether to use a SELECT or JOIN FetchMode. I do understand that JOIN will make one big call to the database and SELECT will make many rapid calls. However, I do not know what factors help me decide which method is optimum.</p> <p>(Of course, I will run tests, but that will only answer which method is optimum, it won't explain why)</p> <p>Help would be greatly appreciated</p>
1
Angular Js infinite scroll with fixed header
<p>I want to implement the Infinite scroll for tables with fixed header and also first column need to be fixed .</p> <p>I tried to implement the same using Angular JS Infinite scroll directive . I am able to achieve the Infinite scroll but am not able to fix header and column inside the div.</p> <p>I've attached a link to my fiddle below.</p> <p><code>http://jsfiddle.net/jayasant1907/5yxa3xyg/</code></p> <p><strong>Javascript :</strong></p> <pre><code>var myApp = angular.module('myApp', [ 'infinite-scroll']) .controller('MyCtrl', function ($scope) { $scope.items = []; for (i = 0; i &lt; 5000; ++i) { $scope.items.push({ number: i }); } $scope.barLimit = 100; $scope.increaseLimit = function () { $scope.barLimit += 50; console.log('Increase Bar Limit', $scope.barLimit) } }); /* ng-infinite-scroll - v1.2.0 - 2015-02-14 */ var mod; mod = angular.module('infinite-scroll', []); mod.value('THROTTLE_MILLISECONDS', null); mod.directive('infiniteScroll', [ '$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', function ($rootScope, $window, $interval, THROTTLE_MILLISECONDS) { return { scope: { infiniteScroll: '&amp;', infiniteScrollContainer: '=', infiniteScrollDistance: '=', infiniteScrollDisabled: '=', infiniteScrollUseDocumentBottom: '=', infiniteScrollListenForEvent: '@' }, link: function (scope, elem, attrs) { var changeContainer, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement; windowElement = angular.element($window); scrollDistance = null; scrollEnabled = null; checkWhenEnabled = null; container = null; immediateCheck = true; useDocumentBottom = false; unregisterEventListener = null; height = function (elem) { elem = elem[0] || elem; if (isNaN(elem.offsetHeight)) { return elem.document.documentElement.clientHeight; } else { return elem.offsetHeight; } }; offsetTop = function (elem) { if (!elem[0].getBoundingClientRect || elem.css('none')) { return; } return elem[0].getBoundingClientRect().top + pageYOffset(elem); }; pageYOffset = function (elem) { elem = elem[0] || elem; if (isNaN(window.pageYOffset)) { return elem.document.documentElement.scrollTop; } else { return elem.ownerDocument.defaultView.pageYOffset; } }; handler = function () { var containerBottom, containerTopOffset, elementBottom, remaining, shouldScroll; if (container === windowElement) { containerBottom = height(container) + pageYOffset(container[0].document.documentElement); elementBottom = offsetTop(elem) + height(elem); } else { containerBottom = height(container); containerTopOffset = 0; if (offsetTop(container) !== void 0) { containerTopOffset = offsetTop(container); } elementBottom = offsetTop(elem) - containerTopOffset + height(elem); } if (useDocumentBottom) { elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement); } remaining = elementBottom - containerBottom; shouldScroll = remaining &lt;= height(container) * scrollDistance + 1; if (shouldScroll) { checkWhenEnabled = true; if (scrollEnabled) { if (scope.$$phase || $rootScope.$$phase) { return scope.infiniteScroll(); } else { return scope.$apply(scope.infiniteScroll); } } } else { return checkWhenEnabled = false; } }; throttle = function (func, wait) { var later, previous, timeout; timeout = null; previous = 0; later = function () { var context; previous = new Date().getTime(); $interval.cancel(timeout); timeout = null; func.call(); return context = null; }; return function () { var now, remaining; now = new Date().getTime(); remaining = wait - (now - previous); if (remaining &lt;= 0) { clearTimeout(timeout); $interval.cancel(timeout); timeout = null; previous = now; return func.call(); } else { if (!timeout) { return timeout = $interval(later, remaining, 1); } } }; }; if (THROTTLE_MILLISECONDS != null) { handler = throttle(handler, THROTTLE_MILLISECONDS); } scope.$on('$destroy', function () { container.unbind('scroll', handler); if (unregisterEventListener != null) { unregisterEventListener(); return unregisterEventListener = null; } }); handleInfiniteScrollDistance = function (v) { return scrollDistance = parseFloat(v) || 0; }; scope.$watch('infiniteScrollDistance', handleInfiniteScrollDistance); handleInfiniteScrollDistance(scope.infiniteScrollDistance); handleInfiniteScrollDisabled = function (v) { scrollEnabled = !v; if (scrollEnabled &amp;&amp; checkWhenEnabled) { checkWhenEnabled = false; return handler(); } }; scope.$watch('infiniteScrollDisabled', handleInfiniteScrollDisabled); handleInfiniteScrollDisabled(scope.infiniteScrollDisabled); handleInfiniteScrollUseDocumentBottom = function (v) { return useDocumentBottom = v; }; scope.$watch('infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom); handleInfiniteScrollUseDocumentBottom(scope.infiniteScrollUseDocumentBottom); changeContainer = function (newContainer) { if (container != null) { container.unbind('scroll', handler); } container = newContainer; if (newContainer != null) { return container.bind('scroll', handler); } }; changeContainer(windowElement); if (scope.infiniteScrollListenForEvent) { unregisterEventListener = $rootScope.$on(scope.infiniteScrollListenForEvent, handler); } handleInfiniteScrollContainer = function (newContainer) { if ((newContainer == null) || newContainer.length === 0) { return; } if (newContainer instanceof HTMLElement) { newContainer = angular.element(newContainer); } else if (typeof newContainer.append === 'function') { newContainer = angular.element(newContainer[newContainer.length - 1]); } else if (typeof newContainer === 'string') { newContainer = angular.element(document.querySelector(newContainer)); } if (newContainer != null) { return changeContainer(newContainer); } else { throw new Exception("invalid infinite-scroll-container attribute."); } }; scope.$watch('infiniteScrollContainer', handleInfiniteScrollContainer); handleInfiniteScrollContainer(scope.infiniteScrollContainer || []); if (attrs.infiniteScrollParent != null) { changeContainer(angular.element(elem.parent())); } if (attrs.infiniteScrollImmediateCheck != null) { immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck); } return $interval((function () { if (immediateCheck) { return handler(); } }), 0, 1); } }; }]); </code></pre>
1
Store location of command button cell address to variable in VBA
<p>Okay so I'm using Excel and trying to get a cell address based off the location of the command button I'm clicking. I want to store that cell address in a variable as I click the button to be used in the next code for the user form that pops up as a result of clicking that button. Ive looked at this link: <a href="https://stackoverflow.com/questions/24735803/store-location-of-cell-address-to-variable-in-vba">Store location of cell address to variable in VBA</a> , which is similar to what I'm trying to do but I cant seem to get it to work with the <code>ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address</code> that gives an address based off the top left corner of the command button. I'm trying to do it this way so I can use the same code from the next part for every similar button I add without having to manually change the code based off where the button is.</p> <p>I'm pretty new when it comes to Excel and VBA so any help would be appreciated.</p> <h2>Edit:</h2> <p>I tried adding the code but I'm getting a Runtime error '1004' Unable to get Buttons property of the Worksheet class. I have this</p> <pre><code>Sub Button2_Click() Dim BtRng As Range Set Btnrng = ActiveSheet.Buttons(Application.Caller).TopLeftCell MsgBox Btnrng.Address Btnrng.Offset(3, 3) = "Hello" formAddBill.Show End Sub </code></pre> <p>This button is also popping up a userform for information input. the error is happening on <code>Set Btnrng = ActiveSheet.Buttons(Application.Caller).TopLeftCell</code></p>
1
Where to put API key file in Laravel
<p>I am using Google API in Laravel. I am following the Google Developer <a href="https://developers.google.com/google-apps/calendar/quickstart/php" rel="nofollow">guide</a>. They suggest storing a <code>.json</code> key and then calling it like this:</p> <pre><code>define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json'); ... function getClient() { ... $client-&gt;setAuthConfigFile(CLIENT_SECRET_PATH); ... } </code></pre> <p><strong>My question is:</strong> where is the correct place to store the file in Laravel? And What is the correct way to call it?</p> <p>Obviously, I don't want it to be publicly visible... Thanks ahead for any suggestions.</p>
1
How to set Mouse Cursor in XAML / WPF?
<p><strong>How can I set the Mouse cursor in xaml?</strong></p> <p>What's the use of Cursor property in every control? Please don't answer as <code>Cursor="Arrow"</code> cause this is not working.</p> <p>Only way I can do it right now is from code behind by <code>Mouse.OverrideCursor</code>. Can I do it simply using XMAL?</p> <p>I have a Hierarchy of controls where there is a <code>GridSplitter</code> in between somewhere. I'm trying to set the Cursor to <code>SizeNS</code> but it's set to default as default <code>Arrow</code>. What Should I do?</p>
1
How to stop tween of element in CreateJS/TweenJS
<p>I have multiple Tweens in CreateJS/TweenJS:</p> <pre><code>createjs.Tween.get(elem1).to({..}); createjs.Tween.get(elem2).to({..}); </code></pre> <p>In timeline, I need to stop one of Tweens. I tried:</p> <pre><code>var tween1 = createjs.Tween.get(elem1).to({..}); var tween2 = createjs.Tween.get(elem2).to({..}); </code></pre> <p>and then:</p> <pre><code>tween1.setPaused(true); </code></pre> <p>But it's returns error that: <code>.setPaused()</code> is not a function.</p> <p>How to stop one of Tweens that I need?</p>
1
JavaFX: How to highlight certain Items in a TreeView
<p>I am trying to implement a search function for a <code>TreeView</code> in JavaFX. I want to highlight all the matches when the user hits the enter key. So I added a <code>boolean isHighlighted</code> to my <code>TreeItem</code> and in my <code>TreeCell</code>s <code>updateItem</code>, I check whether the item <code>isHighlighted</code> and if so I apply a certain CSS. Everything works fine with the items/cells not visible at the moment of the search -- when I scroll to them, they are properly highlighted. The problem is: How can I "repaint" the TreeCells visible at search so that they reflect whether their item <code>isHighlighted</code>? My Controller does currently not have any reference to the <code>TreeCells</code> the <code>TreeView</code> creates.</p>
1
YouCompleteMe: Autocompletion triggered while typing (suggestion inserted without using TAB)
<p>When I'm typing, YouCompleteMe automatically inserts the suggestions without me pressing TAB. This results in stuff like <code>selflf</code> when I'm typing <code>self</code>, or me not being able to write <code>file</code> anymore, because YouCompleteMe will automatically insert a function from my file, <code>fill_jacobian</code>. From the YouCompleteMe readme I figured that the plugin should not behave like that. Am I doing something wrong? My <code>~/.vimrc</code> looks as follows:</p> <pre class="lang-vimrc prettyprint-override"><code>set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html Plugin 'L9' " Git plugin not hosted on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Avoid a name conflict with L9 Plugin 'Valloric/YouCompleteMe' " Plugin 'scrooloose/syntastic' Plugin 'pangloss/vim-javascript' Plugin 'user/L9', {'name': 'newL9'} " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line set nocompatible " use vim defaults set ls=2 " allways show status line set tabstop=4 " numbers of spaces of tab character set shiftwidth=4 " numbers of spaces to (auto)indent set scrolloff=3 " keep 3 lines when scrolling "set showcmd " display incomplete commands set hlsearch " highlight searches set incsearch " do incremental searching set ruler " show the cursor position all the time set visualbell t_vb= " turn off error beep/flash set novisualbell " turn off visual bell "set nobackup " do not keep a backup file set number " show line numbers set ignorecase " ignore case when searching "set noignorecase " don't ignore case set title " show title in console title bar set ttyfast " smoother changes "set ttyscroll=0 " turn off scrolling, didn't work well with PuTTY set modeline " last lines in document sets vim mode set modelines=3 " number lines checked for modelines "set shortmess=atI " Abbreviate messages set nostartofline " don't jump to first character when paging set whichwrap=b,s,h,l,&lt;,&gt;,[,] " move freely between files "set viminfo='20,&lt;50,s10,h set autoindent " always set autoindenting on set smartindent " smart indent "set cindent " cindent "set noautoindent "set nosmartindent "set nocindent set cinkeys=0{,0},!^F,o,O,e " default is: 0{,0},0),:,0#,!^F,o,O,e "set autowrite " auto saves changes when quitting and swiching buffer set expandtab " tabs are converted to spaces, use only when required "set sm " show matching braces, somewhat annoying... "set nowrap " don't wrap lines syntax on " syntax highlighing if has("gui_running") " See ~/.gvimrc set guifont=Monospace\ 10 " use this font set lines=50 " height = 50 lines set columns=100 " width = 100 columns set background=light " adapt colors for background set selectmode=mouse,key,cmd set keymodel= else "colorscheme elflord " use this color scheme set background=light " adapt colors for background endif if has("autocmd") " Restore cursor position au BufReadPost * if line("'\"") &gt; 0|if line("'\"") &lt;= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif " Filetypes (au = autocmd) au FileType helpfile set nonumber " no line numbers when viewing help au FileType helpfile nnoremap &lt;buffer&gt;&lt;cr&gt; &lt;c-]&gt; " Enter selects subject au FileType helpfile nnoremap &lt;buffer&gt;&lt;bs&gt; &lt;c-T&gt; " Backspace to go back " When using mutt, text width=72 au FileType mail,tex set textwidth=72 "au FileType cpp,c,java,sh,pl,php,phtml,asp set autoindent au FileType cpp,c,java,sh,pl,php,phtml,asp,xml,javascript set smartindent nnoremap &lt;C-p&gt; :set invpaste paste?&lt;CR&gt; set pastetoggle=&lt;C-p&gt; set showmode "au FileType cpp,c,java,sh,pl,php,phtml,asp set cindent "au BufRead mutt*[0-9] set tw=72 " Automatically chmod +x Shell and Perl scripts "au BufWritePost *.sh !chmod +x % "au BufWritePost *.pl !chmod +x % " File formats au BufNewFile,BufRead *.phtml set syntax=php au BufNewFile,BufRead *.pls set syntax=dosini au BufNewFile,BufRead modprobe.conf set syntax=modconf " Ctrl+X O autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType c set omnifunc=ccomplete#Complete autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0 autocmd FileType php noremap &lt;C-L&gt; :!php -l %&lt;CR&gt; autocmd Filetype html,xml,xsl source ~/.vim/closetag.vim endif </code></pre>
1
Can't find my commit after doing a git pull
<p>I have a local branch that I was working on last week. I knew I was going to be away for it for a while, so I committed my changes, but did not push them. Today I went back to work on it, and when I checked it out, it told me I was 40 commits behind origin, and I should do a <code>git pull</code>.</p> <p>So I did. And now I can't find the changes that I had committed last week. I don't have the hash of it, and I can't find it in <code>gitk</code>.</p> <p>I've looked at <a href="https://stackoverflow.com/questions/1223354/undo-git-pull-how-to-bring-repos-to-old-state">this</a>, <a href="https://stackoverflow.com/questions/5815448/how-to-undo-a-git-pull">this</a>, and <a href="https://stackoverflow.com/questions/6201802/git-pull-deleted-my-commit">this</a>, but when I did a <code>git checkout HEAD@{1}</code> just to see where things were, it wasn't where it should have been.</p> <p>How can I find my local commit and get back to it safely?</p>
1
Compile TypeScript while ignoring type errors, but not syntax errors
<p>The TypeScript compiler (<code>tsc</code>) emits valid JS even when it has type errors. I am in a situation where I need to compile a TypeScript project to JS but cannot install the required <code>.d.ts</code> files for it to correctly type check.</p> <p>Is there a way I can get <code>tsc</code> to ignore any type errors, but still show other kinds of errors such as syntax errors?</p> <p>Thanks</p>
1
Highcharts - Is it possible to display the my own text on the data-labels of line chart?
<p>Is it possible to <strong>display my own text on the data-labels</strong> of the Line Chart, Only for Non-Zero Entries. Provided, the text to be displayed in the data-label is passed from an xml along with the data. </p> <p>I need the chart like the one in the image below. Please suggest an idea. Thanks for your time.</p> <p>Highcharts:</p> <pre><code> xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, plotOptions: { series: { dataLabels: { enabled: true, formatter: function () { if (this.point.y != 0) { return this.point.y; } }, borderRadius: 5, backgroundColor: 'pink', borderWidth: 1, borderColor: 'green', y: -6 } } }, series: [{ data: [0, 0,77,120,0,0,150,0,0,0,0] }] } </code></pre> <p>XML:</p> <pre><code>&lt;categories&gt; &lt;month&gt;Jan&lt;/month&gt; &lt;month&gt;Feb&lt;/month&gt; &lt;month&gt;Mar&lt;/month&gt; &lt;month&gt;Apr&lt;/month&gt; &lt;month&gt;May&lt;/month&gt; &lt;month&gt;Jun&lt;/month&gt; &lt;month&gt;Jul&lt;/month&gt; &lt;month&gt;Aug&lt;/month&gt; &lt;month&gt;Sep&lt;/month&gt; &lt;month&gt;Oct&lt;/month&gt; &lt;month&gt;Nov&lt;/month&gt; &lt;month&gt;Dec&lt;/month&gt; &lt;/categories&gt; &lt;Series&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;120|First&lt;/point&gt; &lt;point&gt;130|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;150|Second&lt;/point&gt; &lt;point&gt;230|Third&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;point&gt;0|0&lt;/point&gt; &lt;/Series&gt; </code></pre> <p>JQuery:</p> <pre><code>$xml.find('series').each( function(i,series){ var ser = { data : [], }; $(series).find('point').each( function(i,point){ ser.data.push(parseInt($(point).text().split("|")[0]); }); options.series.push(ser); }); </code></pre> <p><a href="https://i.stack.imgur.com/GeNC2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GeNC2.png" alt="enter image description here"></a></p>
1
Summernote table with more styling
<p>Is there any workaround to get more styling - bordered,header,stripped for the bootstrap table that summernote use ?</p> <p>I have seen a form from summernote named <a href="http://www.web-forge.info/projects/materialNote" rel="nofollow noreferrer">MaterialNote</a> have the table that I am after. <a href="https://i.stack.imgur.com/VQruR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQruR.jpg" alt="enter image description here"></a></p> <p>I have figured how table classes can be passed as summernote option :</p> <pre><code>$('textarea').summernote({ tableClassName: 'table table-striped ' }); </code></pre>
1
Integrate .aar file in multi-module android studio project
<p>I have a multi-module project in android studio and I want to integrate an <code>.aar</code> file in a module which is beeing referenced as library in the App module. The project structure is namely:</p> <pre><code>- module1 - module2 - module3 - module4 - moduleApp </code></pre> <p>The module1 is used as library reference in the module2.</p> <p><code>build.gradle module2</code>:</p> <pre><code> dependencies { ... compile project(':module1') } </code></pre> <p>The module2 and the other modules are referenced in th App module.</p> <p><code>build.gradle moduleApp</code>:</p> <pre><code>dependencies { ... compile project(':module2') compile project(':module3') compile project(':module4') } </code></pre> <p>I need to integrate an .aar file as library in the module1, since it is required from the module1 impementation. I do the integration in the normal manner:</p> <p><code>build.gradle module1</code>:</p> <pre><code>repositories { flatDir { dirs 'libs' } } dependencies { compile 'package.name.of.aar:myLibrary@aar' } </code></pre> <p>However when I run the <code>gradle sync</code> I receive the error:</p> <pre><code>failed to resolve package.name.of.aar:myLibrary@aar in module2 failed to resolve package.name.of.aar:myLibrary@aar in moduleApp </code></pre> <p>What should I do to let module2 and moduleApp find the .aar library? Should I include something more in their the build.gradle files? </p>
1
Validate against enum members in Python
<p>In Python, I have an input (called input_var below) that I would like to validate against a enum (called Color below). Is the following way the recommended Pythonic approach?</p> <pre><code>from enum import Enum class Color(Enum): red = 1 blue = 2 input_var = 'red' if input_var in Color.__members__: print('Everything is fine and dandy.') </code></pre>
1
Cache-Control Headers not respected on CloudFlare
<p>I am trying to get some html pages to be cached, the same way images are automatically cached via CloudFlare but I can't get CloudFlare to actually hits its cache for html.</p> <p>According to the documentation (Ref: <a href="https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-CloudFlare-What-to-Cache-" rel="noreferrer">https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-CloudFlare-What-to-Cache-</a>), it's possible to cache anything with a Cache-Control set to <code>public</code> with a <code>max-age</code> greater than 0.</p> <p>I've tried various combinations of headers on my origin Nginx server without success. From a simple <code>Cache-Control: public, max-age=31536000</code> to more complex headers including <code>s-maxage=31536000</code>, <code>Pragma: public</code>, <code>ETag: "569ff137-6"</code>, <code>Expires: Thu, 31 Dec 2037 23:55:55 GMT</code> without any results.</p> <p>Any ideas to force CloudFlare to serve the html pages from their cache?</p> <p>PS: I am getting the <code>CF-Cache-Status: HIT</code> on the images and it works fine but on the html pages nothing, not even <code>CF-Cache-Status: something</code>. With a CloudFlare page rule for html pages, it seems to work fine but I want to avoid using one, mainly because it's too CloudFlare specific. I am not serving cookies or anything dynamic from these pages.</p>
1
How to use tr command in linux to encrypt?
<p>I'm trying to figure out how to make the tr command encrypt characters from the space to the tilde (ASCII code 32-126). For example, if I enter a space in the command line, I want to see an exclamation point as my output since it adds one to the ASCII code. Any help would be much appreciated. I tried using</p> <pre><code>tr ' '-~ 32-126 </code></pre> <p>but it was giving me an error.</p>
1
Swift: second occurrence with indexOf
<pre><code>let numbers = [1,3,4,5,5,9,0,1] </code></pre> <p>To find the first <code>5</code>, use:</p> <pre><code>numbers.indexOf(5) </code></pre> <p>How do I find the second occurence?</p>
1
How to use Proxy with TcpClient.ConnectAsync()?
<p>HTTP proxy support in .NET does not actually support the lower level classes like TcpClient or Socket. But I want to connect a TCPServer (ip, port) through HTTP proxy that support 'CONNECT' command.</p> <p>So I need to do the following steps:</p> <ol> <li>Connect to proxy.</li> <li>Send <code>CONNECT Host:Port HTTP/1.1&lt;CR&gt;&lt;LF&gt;</code></li> <li>Send <code>&lt;CR&gt;&lt;LF&gt;</code></li> <li>Wait for a line of response. If it contains <code>HTTP/1.X 200</code>, the connection is successful.</li> <li>Read further lines of response until receive an empty line.</li> <li>It's connected to the outside world through a proxy. Any data exchange as posssible with proxy.</li> </ol> <p>Actually I do this without proxy</p> <pre><code> TcpClient _client; NetworkStream _stream; public static async Task&lt;bool&gt; ConnectAsync(string hostname, int port) { _client = new TcpClient(); await _client.ConnectAsync(hostname, port).ConfigureAwait(false); _stream = conn._client.GetStream(); ..... Do some stuff // Connexion OK return true; } </code></pre> <p>How can use proxy and credentials before connecting TcpClient?</p>
1
error: 'str' object has no attribute 'read'
<p>Hey there!</p> <pre><code> # import the module from __future__ import print_function import aerospike import urllib2 import json config = { 'hosts': [ ('127.0.0.1', 3000) ] } try: client = aerospike.client(config).connect() except: import sys print("failed to connect to the cluster with", config['hosts']) sys.exit(1) key = ('ip', 'hit', 'trial') try: for i in range(0,255): for j in range(0,255): for k in range(0,255): for l in range(0,255): if not((i == 198 and j == 168) or (i == 172 and j &gt; 15 and j &lt; 32) or (i == 10)): response = urllib2.urlopen('http://ip-api.com/json/'+str(i)+'.'+str(j)+'.'+str(k)+'.'+str(l)).read() html = response.read() client.put(key, json.load(response)) except Exception as e: import sys print("error: {0}".format(e), file=sys.stderr) client.close() </code></pre> <p><strong>Error</strong> error: 'str' object has no attribute 'read'</p> <p>Can anyone please help in resolving this error? Any help would be highly appreciated.</p>
1
How to get extension from base64 using c#
<p>I get base64 string as an input to save it as image. but my problem is i dont know what image format user have uploaded. so please help me if anybody know how to get image format or extension from base64 string.</p>
1
Laravel 5 - Save or update
<p>I want to store a list of departments in my database. I do not create the departments in my system, I obtain them from Active Directory. In the view for departments, I display all the departments. I also have a button to update departments in the database.</p> <p>This function at the moment looks like the following</p> <pre><code>public function updateDepartments() { $departments = Helper::returnDepartmentsFromLdap(); dd($departments); } </code></pre> <p>The dd produces something like the following</p> <pre><code>array:16 [▼ 0 =&gt; "Department 1" 8 =&gt; "Department 2" 21 =&gt; "Department 3" 22 =&gt; "Department 4" 29 =&gt; "Department 5" 43 =&gt; "Department 6" 47 =&gt; "Department 7" 48 =&gt; "Department 8" ] </code></pre> <p>You have to remember though that this list is not being obtained from my database, it is being obtained from Active Directory. However, I now want to add them to my database. So in the same function I do the following</p> <pre><code>public function updateDepartments() { $departments = Helper::returnDepartmentsFromLdap(); foreach($departments as $departmentID =&gt; $departmentName) { $department = new Department(); $department-&gt;departmentID = $departmentID; $department-&gt;departmentName = $departmentName; $department-&gt;save(); } return Redirect::route('departments.index')-&gt;with('message', 'Departments updated.'); } </code></pre> <p>Now the problem with the above is that every time the button is pushed, the database will insert new rows. Say I push the button for the first time, my database will be populated with the list. Say I then push it a second time, I do not want the same list added again. If it already exist in the database, it should overwrite it or something. It should only perform a save if a new item is in the list.</p> <p>Is something like this possible?</p> <p>Thanks</p>
1
Any easy way to monitor HTTP gzipped traffic on a live running Linux system?
<p>I'm running "sudo tcpdump -s 0 -A port 80" on my Linux system to monitor HTTP traffic. This works, but all of the traffic is gzipped. Is there any easy way to un-compress this on the fly so I can watch the traffic in real-time?</p>
1
How to get the first column from a json array using jquery
<p>I have a json array in the below format:</p> <pre><code>[ { "id":"01", "language": "Java", "edition": "third", "author": "Herbert Schildt" }, { "id":"07", "language": "C++", "edition": "second" "author": "E.Balagurusamy" } ] </code></pre> <p>I want a result consisting only the first column from this array in the form:</p> <pre><code>[ "01", "07" ] </code></pre> <p>I tried many codes but wouldn't succeed, is there a way to achieve this using jquery.</p>
1
How to run ansible script inside a docker container
<p>I am using docker for testing my playbooks.</p> <p>I created a container now when i am running below command inside container its giving me below error</p> <p><strong>ansible-playbook jenkins.yml</strong></p> <p><strong>Error:-</strong></p> <pre><code>[root@db1e9105692d jenkins-playbook]# ansible-playbook jenkins.yml -k -vvv SSH password: PLAY [localhost] ************************************************************** GATHERING FACTS *************************************************************** &lt;localhost&gt; ESTABLISH CONNECTION FOR USER: root &lt;localhost&gt; REMOTE_MODULE setup &lt;localhost&gt; EXEC sshpass -d4 ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o ConnectTimeout=10 localhost /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1454580537.38-114451000565344 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1454580537.38-114451000565344' EXEC previous known host file not found for localhost fatal: [localhost] =&gt; SSH Error: ssh: connect to host localhost port 22: Connection refused while connecting to 127.0.0.1:22 It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue. TASK: [jenkins | Include OS-Specific variables] ******************************* &lt;localhost&gt; ESTABLISH CONNECTION FOR USER: root fatal: [localhost] =&gt; One or more undefined variables: 'ansible_os_family' is undefined FATAL: all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @/root/jenkins.retry localhost : ok=0 changed=0 unreachable=2 failed=0 </code></pre> <p>But if i run this command on host machine its running fine.Do i need to do anything so that connection do not gets refused on port 22.inside docker container</p> <p>Please do not consider below line as reason for error.Its just that ansible has executed few more lines before throwing error. Actually its not able to run so thats why value of this variable is empty.</p> <pre><code>fatal: [localhost] =&gt; One or more undefined variables: 'ansible_os_family' is undefined </code></pre>
1
SonarQube warning on MSBuild version
<p>I am using <code>Sonar 5.3</code> server, and in <code>Jenkins</code> I am at <code>SonarQube Runner 2.2.1</code>. I recently upgraded sonar server from <strong>4.5.2</strong> to <strong>5.3</strong> but did not touch anything in <code>Jenkins</code>. </p> <p>Now when I am Invoking SonarQube standalone analysis, then I am getting the things done, but I am getting warning </p> <blockquote> <p>WARN - * Use MSBuild 14 to get the best analysis results * WARN - * The use of MSBuild 12 or the sonar-runner to analyze C# projects is DEPRECATED *</p> </blockquote> <p>I just wanted to know what I should upgrade here? I installed <code>MSBuild 14.0</code> on the machine where <code>Sonar Analysis</code> is running. Do I need to upgrade <code>SonarRunner</code> plugin in <code>Jenkins</code> to <strong><em>latest 2.3</em></strong>???</p>
1
Spring, JXLS : XLS transformer not loaded, even though dependency exists.
<p>I am trying my hands on <a href="http://jxls.sourceforge.net/getting_started.html" rel="nofollow">JXLS</a> which is a Java library for creating excel files, and other operations with it in a Spring-MVC project. When I try to create a excel-file out of some data, I get the following error :</p> <p>Error log :</p> <pre><code>java.lang.IllegalStateException: Cannot load XLS transformer. Please make sure a Transformer implementation is in classpath at org.jxls.util.JxlsHelper.createTransformer(JxlsHelper.java:200) at org.jxls.util.JxlsHelper.processTemplateAtCell(JxlsHelper.java:118) at com.journaldev.spring.service.GroupNotesServiceImpl.saveGroupNotesToExcel(GroupNotesServiceImpl.java:917) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) </code></pre> <p>Code :</p> <pre><code> @Override public void saveGroupNotesToExcel(int msectionid){ List&lt;GroupNotes&gt; groupNotesList = this.groupNotesDAO.listGroupNotesBySectionId(msectionid); try(InputStream is = GroupNotesServiceImpl.class.getResourceAsStream("/home/path/to/jls/test.xls")) { try (OutputStream os = new FileOutputStream("/home/path/to/jls/output.xls")) { Context context = new Context(); context.putVar("groupNotesList", groupNotesList); JxlsHelper.getInstance().processTemplateAtCell(is, os, context, "Result!A1"); }catch (Exception e){ e.printStackTrace(); } }catch (Exception e){ e.printStackTrace(); } } </code></pre> <p>Here is my POM.xml with the dependencies :</p> <pre><code> &lt;!-- Excel dependencies--&gt; &lt;dependency&gt; &lt;groupId&gt;org.jxls&lt;/groupId&gt; &lt;artifactId&gt;jxls&lt;/artifactId&gt; &lt;version&gt;2.2.8&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jxls&lt;/groupId&gt; &lt;artifactId&gt;jxls-poi&lt;/artifactId&gt; &lt;version&gt;1.0.7&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jxls&lt;/groupId&gt; &lt;artifactId&gt;jxls-jexcel&lt;/artifactId&gt; &lt;version&gt;1.0.4&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jxls&lt;/groupId&gt; &lt;artifactId&gt;jxls-reader&lt;/artifactId&gt; &lt;version&gt;2.0.1&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>I checked other answers on net, but there was only 1 of missing dependency, which I already have. What is going wrong here?</p>
1
Set Icon in Tkinter
<p>I want to replace the Tkinter icon with my own, but answers from other questions are not helping. In the same folder, I have my script and an image created using Paint saved as <code>icon.png</code>. Here is the script:</p> <pre><code>from Tkinter import * root = Tk() icon = PhotoImage(file='icon.png') root.tk.call('wm', 'iconphoto', root._w, icon) root.mainloop() </code></pre> <p>This error is made from the root.tk.call method:</p> <blockquote> <p>TclError: couldn't recognize data in image file "icon.png"</p> </blockquote>
1
Using Java 8 streams groupingBy on a list of list of maps?
<p>From the following input</p> <pre><code>[ [{group=a, value=cat}, {group=b, value=dog}], [{group=a, value=cow}, {group=b, value=bat}] ] </code></pre> <p>how do I get the following output </p> <pre><code>{ a=[{value=cat}, {value=cow}], b=[{value=dog}, {value=bat}] } </code></pre> <p>using Java 8 streams?</p> <p>I have the following <em>standard</em> solution</p> <pre><code>Map&lt;String, String &gt; map1 = new LinkedHashMap&lt;&gt;(); map1.put("group", "a"); map1.put("value", "cat"); Map&lt;String, String &gt; map2 = new LinkedHashMap&lt;&gt;(); map2.put("group", "b"); map2.put("value", "dog"); Map&lt;String, String &gt; map3 = new LinkedHashMap&lt;&gt;(); map3.put("group", "a"); map3.put("value", "cow"); Map&lt;String, String &gt; map4 = new LinkedHashMap&lt;&gt;(); map4.put("group", "b"); map4.put("value", "bat"); List&lt;Map&lt;String, String&gt;&gt; list1 = Arrays.asList(map1, map2); List&lt;Map&lt;String, String&gt;&gt; list2 = Arrays.asList(map3, map4); List&lt;List&lt;Map&lt;String, String&gt;&gt;&gt; input = Arrays.asList(list1, list2); Map&lt;String, List&lt;Map&lt;String, String&gt;&gt;&gt; output = new LinkedHashMap&lt;&gt;(); for (List&lt;Map&lt;String, String&gt;&gt; list : input) { for (Map&lt;String, String&gt; map : list) { String group = map.get("group"); if (!output.containsKey(group)) { output.put(group, new ArrayList&lt;&gt;()); } List&lt;Map&lt;String, String&gt;&gt; values = output.get(group); values.add(map); } } </code></pre> <p>I saw that there is a <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#groupingBy-java.util.function.Function-" rel="nofollow"><code>Collectors.groupingBy</code></a> method, but I couldn't figure out how to use it.</p> <pre><code>Map&lt;String, List&lt;Map&lt;String, String&gt;&gt;&gt; output = input.stream() .&lt;am I missing out some steps here?&gt; .collect(Collectors.groupingBy(&lt;what goes here?&gt;)) </code></pre>
1
Git mergetool using Android Studio (IntelliJ)
<p>I am trying to use Android Studio as my git mergetool in Windows. I followed the instructions on official <a href="https://www.jetbrains.com/idea/help/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html#d622577e199" rel="nofollow">IntelliJ documentation</a>. Yet, when I try to do the merge, Android Studio launches with the following error: </p> <blockquote> <p>Error showing merge: The system cannot find the path specified</p> </blockquote> <p>Here is my .gitconfig setup:</p> <pre><code>[merge] tool = androidstudio [mergetool] prompt = false [mergetool "androidstudio"] cmd = cmd.exe //c "\"C:/Program Files/Android/Android Studio/bin/studio64.exe\" merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"" keepbackup = false trustexitcode = true </code></pre>
1
How to convert minutes to days, hours, and minutes?
<p>I am a beginner to Python so I do not know a lot of terms or anything really. Can I ask on how to convert minutes to hours and minutes EX: 75 minutes -&gt;0 days, 1 hour, 15 minutes</p> <pre class="lang-py prettyprint-override"><code>print(&quot;Welcome to the Scheduler!&quot;) print(&quot;What is your name?&quot;) name = input() print(&quot;How many chocolates are there in the order?&quot;) chocolates = input() print(&quot;How many chocolate cakes are there in the order?&quot;) chocolate_cakes = input() print(&quot;How many chocolate ice creams are in the order?&quot;) chocolate_ice_creams = input() total_time = float(chocolates) + float(chocolate_cakes) + float(chocolate_ice_creams) print(&quot;Total Time:&quot;) print(&quot;How many minutes do you have before the order is due?&quot;) minutes = input() extra_time = float(minutes) - float(total_time) print(&quot;Your extra time for this order is&quot;, extra_time) time = extra_time // 60 print(&quot;Thank you,&quot;, name) </code></pre>
1
yii2: how to add a column in index ( GridView ) with innerjoin
<p>i want add a column in GridView::widget</p> <pre><code> &lt;?= GridView::widget([ 'dataProvider' =&gt; $dataProvider, 'filterModel' =&gt; $searchModel, 'columns' =&gt; [ ['class' =&gt; 'yii\grid\SerialColumn'], 'id', 'owner_id', 'situation', 'address', [ // 'attribute' =&gt; 'address', 'format' =&gt; 'html', 'label' =&gt; 'Image', 'value' =&gt; function ($data) { return Html::img('http://iicity.ir/' . $data['address'], ['width' =&gt; '60px']); }, ], 'slideshow_text', ['class' =&gt; 'yii\grid\ActionColumn'], ], ]); ?&gt; </code></pre> <p>i want add name of <strong><em>'owner_id',</em></strong> from another table name is in ( account )table table :</p> <p>id=1 name=jack</p> <p>id=2 name=sara</p>
1
AngularJS : Keep view state between differents views with differents controllers
<p>My angular application starts on a /home state ( i use ui-router ), which have its own controller, in which i call a factory method to get some json objects from my API that i share thanks to this factory between the whole app. I put the list that i get from this in a $scope object of the /home state.</p> <p>What i want to do is to call this init method of the factory only once, even better would be that the /home controller is only called once.</p> <p>Actually when i go to another state like /about, and when i go back to /home, the /home controller is called again and so is the init method of the factory. So how do i keep the initial view state ?</p> <p><strong>StuffFactory.js :</strong></p> <pre><code>app.factory('StuffFactory', function ($window, $http, $q) { var stuffs; return { initStuffsList: function () { return $http.get('http://myapi/stuff/init') .then(function (response) { stuffs = (angular.fromJson(response.data.result)); }); }, getStuffs: function () { return stuffs; } }; </code></pre> <p>});</p> <p><strong>homeController.js :</strong> </p> <pre><code>app.controller('homeCtrl', function ($scope,StuffFactory) { StuffFactory.initStuffsList().then(function(){ $scope.stuffs = StuffFactory.getStuffs(); }); }); </code></pre> <p><strong>app.js :</strong></p> <pre><code> .config(['$stateProvider', '$urlRouterProvider'] $urlRouterProvider.otherwise('/home'); $stateProvider .state('home', { url: '/home', templateUrl: './partials/home.html', controller:homeCtrl }) .state('about', { url: '/about', templateUrl: './partials/about.html', controller:aboutCtrl }) </code></pre>
1
User account is disabled - Spring Security
<p>I'm working on a web application that uses Spring Security 4.0.2 to authenticate users' username/password.</p> <p>When I try to login using an existing username, spring security tells me that "User account is disabled", but I don't know how to change this.</p> <p>My context:</p> <pre><code>&lt;!-- enable use-expressions --&gt; &lt;http auto-config="true" use-expressions="true"&gt; &lt;intercept-url pattern="/private/**" access="hasRole('ROLE_USER')" /&gt; &lt;!-- Erro aqui --&gt; &lt;form-login login-page="/public/login.xhtml" username-parameter="j_username" password-parameter="j_password" login-processing-url="/j_spring_security_check" authentication-failure-url="/public/login.xhtml?login_error=1" authentication-success-handler-ref="authenticationSuccessHandler" /&gt; &lt;logout logout-success-url="/public/login.xhtml" /&gt; &lt;csrf disabled="true" /&gt; &lt;/http&gt; &lt;b:bean id="authenticationSuccessHandler" class="br.com.jway.security.UrlAuthenticationSuccessHandler" /&gt; &lt;!-- Select users and user_roles from database --&gt; &lt;authentication-manager&gt; &lt;authentication-provider&gt; &lt;password-encoder hash="md5" /&gt; &lt;jdbc-user-service data-source-ref="dataSource" users-by-username-query="SELECT login,senha,role FROM usuario WHERE login = ?" authorities-by-username-query="SELECT login, role FROM usuario WHERE login = ? " /&gt; &lt;/authentication-provider&gt; &lt;/authentication-manager&gt; </code></pre> <p>Anybody knows how to fix that?</p>
1
How to define a variable in RPM specs?
<p>How to define a variable in RPM specs? I have 14 folders to create in the RPM and I am creating by following command:</p> <pre><code>mkdir -p /opt/{Folder,Names,Are,Pretty,Cumbersome} </code></pre> <p>My plan is to declare a array variable for all the folders.</p>
1
Vnet between Virtual Machine and App Service in Azure
<p>I cannot figure out how to connect a Web App (<em>App Service</em>) to a <em>Virtual Machine</em> in Azure. I've create a VNet from the Web App configuration panel. </p> <p>All items are created using the <em>Resource Management</em> model, are in the same <em>subscription</em> and are at least of the <strong>Standard</strong> pricing tier.</p> <p>Apparently a Web App cannot be connected to a V2 VNet. (Looks like these terms are used interchangeably, or is it something different).</p> <p>I've create a classic Vnet (V1?). But I cannot seem to find out how to connect my Virtual machine to it. </p> <p>How can I connect both a Web App and VM to the same network? Are there any other requirements I'm missing?</p>
1
TypeError: undefined is not an object (evaluating 'type.toString')
<p>I have been struggling with this for the past three hours. I have no idea what else I can try. I want the <code>var undecidedType, undecidedFilter</code> to be set when a certain button "id" is clicked. I have no idea what I am doing wrong. Maybe someone can help. </p> <p>Here is my .js:</p> <pre><code>function getLocation() { Modernizr.geolocation ? navigator.geolocation.getCurrentPosition(currentLocation, handle_error, { timeout: 1e4 }) : ($wait.fadeOut(), $locationBar.fadeIn()) } function handle_error(e) { $locationBar.css("opacity", 1), showError("Location not found"), 0 == e.code, 1 == e.code, 2 == e.code, 3 == e.code } function currentLocation(e) { $wait.fadeIn(), $locationBar.fadeOut(); var o = e.coords.latitude, t = e.coords.longitude; var undecidedType, undecidedFilter; var b1 = document.getElementById('rest'), b2 = document.getElementById('bar'); b1.onclick = function() { undecidedType = "restaurant"; undecidedFilter = "restaurant"; }; b2.onclick = function() { undecidedType = "bars"; undecidedFilter = "pubs"; }; currentlatlng = new google.maps.LatLng(o, t), getPlaces(currentlatlng, undecidedType) } function getPlaces(e, type) { userLoc = e, homeMarker = new google.maps.Marker({ map: map, animation: google.maps.Animation.DROP, position: e, icon: homeIcon }); var o = { location: e, radius: 1e3, rankby: "prominance", keyword: type.toString() }; service.search(o, storeRequestBar) } function storeRequestBar(e, undecidedFilter) { barResultsStore = e; var o = { location: currentlatlng, radius: 1e3, rankby: "prominance", keyword: undecidedFilter.toString() }; service.search(o, storeRequestPub) } function storeRequestPub(e) { for (pubResultsStore = e, totalResults = barResultsStore.concat(pubResultsStore), resultsStore = removeDupes(totalResults, "id"), resultsStore = resultsStore.sort(function() { return Math.random() - .5 }), i = 0; i &lt; resultsStore.length; i++); 0 == resultsStore &amp;&amp; showError("Cannot find anything in that location. Try somewhere else"), chooseBar(resultsStore) } function chooseBar(e) { barRef = { reference: e[shitCounter].reference }, service.getDetails(barRef, showBar) } function showBar(e, o, hello) { if (o == google.maps.places.PlacesServiceStatus.OK) { for (i in markersArray) markersArray[i].setMap(null); drinkMarker = new google.maps.Marker({ map: map, animation: google.maps.Animation.DROP, position: e.geometry.location, icon: drinkIcon }), markersArray.push(drinkMarker), placeName = e.name, calcRoute(userLoc, e.geometry.location), directionsDisplay.setMap(null), directionsDisplay.suppressMarkers=!0, directionsDisplay.polylineOptions = { strokeColor: "#ff8400", strokeOpacity: .8, strokeWeight: 5 }, directionsDisplay.setMap(map), placeSite = e.website ? e.website : e.url, placeAddress = e.formatted_address, $(".recommendation__destination").html("Why don't you go to &lt;br/&gt;&lt;a href='" + placeSite + "' target='_blank'&gt;" + placeName + "&lt;/a&gt;" + currentLocation.hello + ""), $(".map__address").html(placeAddress), $(".grid__row--links,.grid__row--actions,.fyyfs,.recommendation,.map__address,.recommendation__destination,.adsense").fadeIn(function() { $wait.fadeOut() }) } } function calcRoute(e, o) { var t = { origin: e, destination: o, travelMode: google.maps.TravelMode.WALKING }; directionsService.route(t, function(e, o) { o == google.maps.DirectionsStatus.OK &amp;&amp; directionsDisplay.setDirections(e) }) } function codeAddress() { $wait.fadeIn(function() { $locationBar.fadeOut(); var e = document.getElementById("locationsearch").value; geocoder.geocode({ address: e }, function(e, o) { o == google.maps.GeocoderStatus.OK ? (currentlatlng = e[0].geometry.location, getPlaces(currentlatlng)) : showError("Location not found. Try again") }) }) } function showError(e) { $wait.fadeOut(), $locationBar.fadeIn(), $(".locator__message").text(e).fadeIn() } function removeDupes(e, o) { var t = [], r = {}; for (var a in e) r[e[a][o]] = e[a]; for (a in r) t.push(r[a]); return t } var resultref, marker, markersArray = [], shitCounter = 0, iteration = 0, drinkIcon = "img/restaurant_map_pointer_small-2.png", homeIcon = "img/current_location_map_pointer_small-2.png", resultsStore, totalResults = [], pubResultsStore, barResultsStore, userLoc, currentlatlng, undecidedType, undecidedFilter; $wait = $(".loader"), $locationBar = $(".locator"), $mapCanvas = $(".map__canvas"), $type = $(".type"); var lowSat = [{ featureType: "all", stylers: [{ saturation: 1, strokeColor: "red", strokeOpacity: .8, strokeWeight: 5 } ] } ], myOptions = { zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP, styles: lowSat, mapTypeControl: !1, panControl: !1, zoomControl: !0, mapTypeControl: !1, scaleControl: !1, streetViewControl: !1, overviewMapControl: !1 }; map = new google.maps.Map(document.getElementById("googlemap"), myOptions), geocoder = new google.maps.Geocoder; var service = new google.maps.places.PlacesService(map); $(document).ready(function() { var e = window.location.href, o = e.split("?"); "undcd" == o[1] ? $locationBar.css("opacity", 1) : getLocation() }); var directionsDisplay = new google.maps.DirectionsRenderer({ suppressMarkers: !0 }), directionsService = new google.maps.DirectionsService; $(".locator").on("submit", function(e) { codeAddress(), e.preventDefault() }), $(".actions__shit").click(function() { return shitCounter &lt; resultsStore.length - 1 ? shitCounter++ : shitCounter = 0, chooseBar(resultsStore), !1 }); var autoOptions = { types: ["geocode"] }, autoInput = document.getElementById("locationsearch"); autocomplete = new google.maps.places.Autocomplete(autoInput, autoOptions); </code></pre> <p>Here is the html form:</p> <pre><code>&lt;form class="form" class="locator" action="#"&gt; &lt;button id="rest" class="btn" type="submit" value="restaurant"&gt;two&lt;/button&gt;&lt;br&gt; &lt;button id="bar" class="btn" type="submit" value="bar"&gt;one&lt;/button&gt;&lt;br&gt; &lt;/form&gt; </code></pre> <p>Here is the error:</p> <pre><code>TypeError: undefined is not an object (evaluating 'type.toString') getPlacesapp-min.js:37 currentLocationapp-min.js:24 </code></pre>
1
Fill PDF Input fields with Javascript
<p>How is it possible to fill PDF input fields with javascript ( if it is even possible ). In my case I want to create a javascript in which I can fill a HTML form, the data which the user put in the HTML form should be saved into the PDF Input Field.</p> <p>Thanks in advance.</p>
1
Linux signal handling. How to get address of interrupted instruction?
<p>Is there any way to figure out address of machine instruction, that was interrupted by some signal? Assuming that we are at handler established by <code>sigaction()</code> and have all access to passed <code>siginfo_t</code> and <code>ucontext_t</code>. As far as I see man pages says nothing about it.</p>
1
Google Calendar API PHP Installation
<p>I have been trying to get the Google Calendar API working with PHP, I even contacted my host (1and1) to figure things out, nothing is working</p> <p>I've followed the examples on the <a href="https://developers.google.com/google-apps/calendar/quickstart/php" rel="nofollow">PHP Quickstart</a>, tried to run it just by going to the page and it gave me an error to run it in command line. So I logged into my SSH, navigated to the file and ran the command <code>php5.4 CRON-temp.php</code>. Now, I get the same error:</p> <pre><code>&lt;b&gt;Fatal error&lt;/b&gt;: Uncaught exception 'Exception' with message 'This application must be run on the command line.' in /homepages/41/d159654153/htdocs/mysite /admin/php/CRON-temp.php:16 Stack trace: #0 {main} thrown in &lt;b&gt;/homepages/41/d159654153/htdocs/mysite/ admin/php/CRON-temp.php&lt;/b&gt; on line &lt;b&gt;16&lt;/b&gt;&lt;br /&gt; </code></pre> <p>So, I've run it in the command line, but it still tells me to run it there. The code throwing the error comes from this:</p> <pre><code>if (php_sapi_name() != 'cli') { throw new Exception('This application must be run on the command line.'); } </code></pre> <p>I've been held up here... I've sent the code to a friend to try out and he gets a link to return where I'm supposed to go authorize this, but I'm not able to see any of that.</p> <p>The tech person at 1and1 said </p> <blockquote> <p>Now, if you will look at the error, the error changes from "parse error" to "Uncaught exception 'Exception". It appears that this application will run in server environment and not on a shared hosting. This is a limitation on the package that you have. You might need to go to a server package for this API to run.</p> </blockquote> <p>Is this really the case? Do I really need to switch over to server hosting? Is there a way around this? </p> <p>All I want to do is have a 2 way sync between Google Calendar and a mySQL server.</p>
1
Create image file (Base64 to blob) using Google Appscript
<p>I have created a function using Google appscript that convert base64 to blob and then use the blob to create a file into my Google drive folder. However, the file is created but no image is displaying. </p> <p>Here's my code:</p> <pre><code>function base64toBlob() { var currentFolder = DriveApp.getFolderById("--My Google Drive ID--"); var base64 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGO0lEQVR42rWW+U9VRxTHD9uzQACfIqBFm6JNlYhLW6MGnuBW3MBYF9JitWlqo9YqLsi+wwNxKQqPRQHlB2WtIoILCs/iwqrIJkJUWk2tpPo3fHvm3qu3LMZXiySfzJ2ZM3O+c86ceRAAeoc/c+9Q+m5BGLXrwgheCuJbjIk5YWPKRv9ZwPS1pPUOp2ebDFpk1etQ93Ijrv8dKBDf0piYEzbCdkQFTF1J2gXhBP3lWah5vhFFj+Ygp8sJmZ2jBeJbjIk5yUbYuvvTmJESYMUhfpp0aTYq/liJo63WONBCEqkKSl/MSTZ6tvWOoL+ISPMuAix8wilFnGJpLGFxNCEgzR7lfSuQ0kjQNxCSmZSB8Jg8d6CJUPH7KnxrGAPPXbRVvhOmC7Bi5f0/5jmj/PFqGDm/tf3f4Oqzr3G8/VPE3SAk3iIkqXB/KEeabZFR5wO+lPeJ6ANTBVjogunQllwXdrgBp7qnIf2eA461OiC/ayoqH69HWqMLYq8T4n5juI01EmJqWUidBbdS//V84QNPkQbhRGuqAFufSEJRlx8ON9kg8Sa9JoFJbbBByX0/RF0jRNcQ4o3mONExGcWPP0cRwy333cS4NJ/R7AofWcA4UwU4+saZI6/NQ5xGIlZgVE+a3TIT4Zf5+5o5CrpnIa/rEylCv9y1Fi33p6Dg/kyeJyTXWb+KgJNJAjQ25LIkmsNptEbEFUIEOwqpIoRdJHYqk1jjgP2VhPQmNxhaJyHpNkno60Ur5z/9zgQcbZiEEF43P5iwIJSeeAfTKiIye5MAs3nbaLJ4zSLL3XHlz3WofhYocfHpemQ1umPPWcLecwy3Qb8SjjV+jKhaToWac25Fuqxw5oEn78EX93kgjC82IrtBB78UjbiQqeKeDRHgsZYcRckVdq1E1ZPV/Ki4Ir1ttER254dcDf4o6l6GuCtjUfZwuRAmHDCBOPtwBQ7VO0vRiauxwoW+ABT2eMHQNk66wFkdTih95IVLTwLgn6yBVxCtkSOhCrD0DqGKyHPTeeFcuc7rVZIUSnu+RGXfWhQ8mIGMNgdmtGilflXfBhgap+JkqycMdyciUU6LCq/PaZ8Eww0f8PvSL5elKsBO3NSyHn8kc/4SRJ3/i/g6wtEmZ5T2rsDhO9bQs8DkJkIKkyzgvhgv612OgnZPToO8JkGF+wzvVdyzUPxOKGWpCnAUAk7cmybVdZxxIDE1hDOdvjjYYMulONwjpJbomY6liKwWFTI86U2uWJ1io1SFKsBpYaQoGVtEXSVEVQ9EVELu3S9eX7T4oSgXULYLq+I1l4YSeZlt+DDsa6iARVGqIW8wgJBKwsEbzogWp3gzPC/b7S/nNecHEsqEXyBsP80CwunFYAGOut1UuymHDdloPxsHl6vsO0fKm/AW2EZEcFcJrxEly6W6h+GW+/I+yxMJ09dQ0OA7YOfgSl4iCjsL2alYXKZQypswIgphDAt8I+Ecrd28Zkks4fs8/i5hink9tz/ky87nbqHTRDRlcBVYMhPGz6B14mc30MCnKOSFxfIGO/h783GOTIUakcGI8RAW4XeYMGsrVc/ZRz1eMQRfdrooWgr7y2krKYyI3Bn7we+A+BvFfGTnQr5eO+nmkhh5oY/YJM4Ca+KtsCFTvIIirEyZCvel8fU8vy7eHA16C9QlmaH4J+myLWMWMfOZKYpzi2GfYkXEBGY2480sFhsUbye0HJuIAP0oLEvlcBZwhIoVOLxbuC/Gv4o3Q2u2DYwplsj9WXLuxbgpF06rhN3sbb+Glowd46gsdGN0eTsIbekTkZY+DosiOJdRMvNiOOeRhFi9Br259qg9oEGO7FzHuDKa//s/oUbZSHecRTQfG4/mNEeURHyEO/kuOLmVULTXHL35Y1Gbao1sk5wPFWCyiGwWcTNNi87zm9FzyhlZnOf2PEfUHrIFzw11broA00Vk8Kn76/ehgx3fytCi5choZA7jfGQFqCLcDELA7b1oy3VEW54TbifYIUsOvZvq/P0IkJ7tzG1yBNqFgHwWkGjPuVff9/cuQOT9ZXMouguc0VXggka9A3J2vl8BmtwgwiuOszMhIpPJ2kGS8xO7xJzKSF9CWyW/HsxnymVbPAidMueh2NqOaAQYLeNkIlpTI/APro4kS6kAbKwAAAAASUVORK5CYII="; var decoded = Utilities.base64Decode(base64); var blob = Utilities.newBlob(decoded); Logger.log(blob); // Returns blob currentFolder.createFile("A Blob Title", blob, "image/png"); } </code></pre> <p>Thanks in advance.</p>
1
Knime - How to use path input and output as variable
<p>This seems a quite simple question but I could not find a straight question.</p> <p><strong>Scenario</strong> I have a workflow in Knime that reads a file (excel), processes and outputs to several files. The input files and output file are in the same folder and its a different folder than the one where the knime workflow is.</p> <p>I want to run this workflow in several different folders. Each folder has the same input file and the output files will always have the same name. Now, I need to change manuallly the path to the folder in every input/output nodes, for each different folder.</p> <p><strong>Possible solution</strong> A variable with the path of the folder. To run the workflow on another folder, I would change that variable only. Is that possible in knime? How?</p>
1
Why does this two's complement shortcut work?
<p>A shortcut method of forming the two's complement of a binary number is to copy bits from the right until a one-bit has been copied, then complement (invert) the remaining bits. </p> <p>That's explained on SO <a href="https://stackoverflow.com/questions/33592801/converting-binary-to-negative-binary/33593355#33593355">here</a> and also on <a href="https://en.wikipedia.org/wiki/Two&#39;s_complement#Converting_to_two.27s_complement_representation" rel="nofollow noreferrer">Wikipedia</a>.</p> <p>What is <em>not</em> explained is why this shortcut works, that is, why does it produce the same result as inverting all the bits and adding one. So, my question is, why does this work?</p>
1
CordovaCamera always a Square photo?
<p>What do I have to change so CordovaCamera doesn't make Square photos anymore?</p> <p>Now when I call this code:</p> <pre><code> var options = { quality: 100, destinationType: Camera.DestinationType.DATA_URL, sourceType: Camera.PictureSourceType.CAMERA, allowEdit: true, encodingType: Camera.EncodingType.JPEG, // targetWidth: 1600, // targetHeight: 1280, popoverOptions: CameraPopoverOptions, saveToPhotoAlbum: false, correctOrientation:true }; $cordovaCamera.getPicture(options).then(function (imageData) { $scope.imgURI = "data:image/jpeg;base64," + imageData; </code></pre> <p>It opens the Camera, you take the photo, then you get a screen where you see a Square. When you say "use photo" it saves the picture part that was inside the square.. </p>
1
Error Casting Spring's JndiObjectFactoryBean to ConnectionFactory for Solace-MQ JMS
<p>I have a good working XML configuration for Camel Context that uses JNDI with Spring</p> <p> </p> <p>Later Solace.JndiObjectFactoryBean gets used as connectionFactory</p> <pre><code>&lt;bean id="Solace.JmsComponent" class=" on"&gt; &lt;property name="connectionFactory" ref="Solace.JndiObjectFactoryBean" /&gt; &lt;property name="destinationResolver" ref="Solace.JndiDestinationResolver" /&gt; &lt;/bean&gt; </code></pre> <p>I am trying to convert this into a Java class that extends from <code>org.apache.camel.spring.javaconfig.CamelConfiguration</code>. But there is one problem. When I try to set a connection factory on JMS component component.setConnectionFactory(getJndiObjectFactoryBean()); getJndiObjectFactoryBean(), I get a compile time exception :</p> <pre><code>The method setConnectionFactory(ConnectionFactory) in the type JmsComponent is not applicable for the arguments (JndiObjectFactoryBean) </code></pre> <p>But when I try to cast JndiObjectFactoryBean returned from getJndiObjectFactoryBean explicitly to SolConnectionFactory, I get a runtime error</p> <pre><code>016-02-05 17:39:09,234|[localhost-startStop-1]|[]|[]|[ERROR] web.context.ContextLoader [line:307] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getJMSConfiguration' defined in class path resource [com//camel /CamelRoutesConfig.class]: Instantiation of bean failed; nested exception is org .springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.camel.component.jms.JmsConfiguration com.camel.CamelRoutesConfig.getJMSConfiguration()] threw exception; nested exception is java.lang.ClassCastException: org.springframework.jndi.JndiObjectFactoryBean$$EnhancerByCG LIB$$18b94f95 cannot be cast to com.solacesystems.jms.SolConnectionFactory at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsi ngFactoryMethod(ConstructorResolver.java:581) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1029) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .createBeanInstance(AbstractAutowireCapableBeanFactory.java:925) </code></pre> <p>I believe do have have requisite jars in the class path. sol-common-x.y.z.jar, sol-jcsmp-x.y.z.jar, sol-jms-x.y.z.jar</p>
1
Unable to change array size in Inspector variable in Unity?
<p>From what I have read this is how a vector "Size" is set</p> <pre><code>public Color[] teamAColors = new Color[4]; </code></pre> <p>But when the code is run it looks like this <a href="https://i.stack.imgur.com/fhwb7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fhwb7.png" alt="enter image description here"></a></p> <p>It doesn't seem to matter what number I put for the [4], the Size always stays 6. I am not sure where the 6 number is even coming from as I have not set anything to that number.</p> <p>I have even tried to </p> <pre><code> public Color[] teamAColors; </code></pre> <p>And then let my array auto populate the Length, but that doesn't change the 6 either.</p>
1
python + selenium webdriver : using authenticate method
<p>I am using python + selenium webdriver to automatize checks. I am stuck on websites that request http authentication through popup window.</p> <p>I am trying to use the "authenticate" method through the following code :</p> <pre><code>#init. driver = webdriver.Firefox() driver.get(url) #get to the auth popup window by clicking relevant link elem = driver.find_element_by_id("login_link") elem.click() #use authenticate alert method driver._switch_to.alert.authenticate("login", "password") </code></pre> <p>the (scarce) infos/doc related to this method indicates that it should submit the credentials provided &amp; validate http auth. It doesn't and I am getting the following error :</p> <blockquote> <p>File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/alert.py", line 105, in authenticate self.driver.execute(Command.SET_ALERT_CREDENTIALS, {'username':username, 'password':password}) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 159, in check_response raise exception_class(value) selenium.common.exceptions.WebDriverException: Message: Unrecognized command: POST /session/c30d03e1-3835-42f5-ace0-968aef486b36/alert/credentials</p> </blockquote> <p>is there something I am missing here / has anybody come accross the same issue and resolved it ?</p> <p>PS : the <a href="http://username:password@url" rel="nofollow">http://username:password@url</a> trick doesn't work for me in my tests conditions.</p>
1
Getting geojson linestring from MySQL geometry WKT data
<p>I'm trying to get GeoJSON linestring format using awesome PHP-Database-GeoJSON library from here <a href="https://github.com/bmcbride/PHP-Database-GeoJSON" rel="nofollow noreferrer">https://github.com/bmcbride/PHP-Database-GeoJSON</a> but for now without any luck </p> <p>I was successful with calling simple points from MySQL table using that library but with lines and polygons the story is a bit different.</p> <p>First, I created table with geometry field, something like this:</p> <pre><code>-- phpMyAdmin SQL Dump -- version 4.4.6 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 20, 2016 at 10:12 PM -- Server version: 5.6.24 -- PHP Version: 5.6.8 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `web_gis` -- -- -------------------------------------------------------- -- -- Table structure for table `wkt_linija` -- DROP TABLE IF EXISTS `wkt_linija`; CREATE TABLE IF NOT EXISTS `wkt_linija` ( `id` int(11) NOT NULL, `oznaka` varchar(50) NOT NULL, `opis` varchar(200) NOT NULL, `sirina` varchar(200) NOT NULL, `podloga` varchar(200) NOT NULL, `mo` varchar(200) NOT NULL, `geometry` geometry NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -- -- Dumping data for table `wkt_linija` -- INSERT INTO `wkt_linija` (`id`, `oznaka`, `opis`, `Å¡irina`, `podloga`, `mo`, `geometry`) VALUES (1, 'K-8', 'D206 - Vulica - Kraljevec - Horvati - Kordej - S1', '5 m', 'Asfalt-makadam', 'Kostel', '\0\0\0\0\0\0\0¿\0\0\0§5l¹r/@##LêG@eëŸëÑr/@,†‰©G@E¤úâèr/@*éöŠG@Ç4sùr/@õYd\rG@}VHÉs/@·-G@-©`›\Zs/@ÜdÏG@Bß%s/@}*†G@®ñ„/s/@óÅ,ÞG@Ùª³ã7s/@w!™cÿG@PÝAs/@zOöüG@‘t·ÀMs/@Ê.›ÖúG@W…_e]s/@w;yùG@e­‰tts/@š¢ýöG@Ñ„»”s/@S`ùåôG@±å¡´s/@»÷‡óG@ÉSÔÏs/@Ê5@DòG@Ê„Sñs/@&lt;zòG@¥HÖHt/@Ï\n±ÏñG@8Wt/@«ôÚðG@Þôz(t/@äò=îG@׎¬/9t/@‚áoéG@•‡\0Kt/@ûq\0äG@kª†Xt/@n”TTßG@%-šmjt/@ÒÃ|‡ÛG@a =‰t/@\Zñ‡ÕG@‚~bÉt/@bnåÈG@’Oƒøt/@Ñ»oÙ¿G@r¶¡ãu/@F+BºG@ðèð9u/@õO‘¶G@õmeVu/@íójB´G@¬íæ_gu/@’''™²G@žº’îou/@›CذG@è1Bou/@Ž­G@8è’ju/@ýEŒªG@|¯Yu/@#H|L¦G@V8ÏHu/@ò†M¢G@¹¡_„0u/@ÑÞ„žG@ø*È&gt;/u/@ä]*RžG@s«®\0\ru/@› ššG@Ãbát/@m«NÈ—G@[÷¾t/@)hNè“G@…!E‹t/@‘FÕŽG@[$ïtbt/@ŠuŠG@8#dJt/@c€ÌD‡G@윔Î.t/@žZ.†G@4/bt/@qx›\Z†G@¶´·¯òs/@iŒ¶&amp;†G@×Í&gt;¼Õs/@Ãís³†G@ÃW‡@µs/@RqÈG@B-Ä…¡s/@B^µŠG@Ò3©‘s/@9Tþ5‰G@廨áˆs/@†ÍÀ†G@£ã…s/@S»ÌƒG@j)jm†s/@(E瘀G@üÊqцs/@\0{\0zG@ÂÄas/@Ë/c¸wG@¬¹…÷‘s/@d1oLsG@’€Ms/@c¹pG@©Æ+̤s/@àv¬lG@} ±s/@°{§,hG@»Bi,¿s/@ÆÇúœcG@sbæ1Ïs/@JJ‹#`G@ø;·rÑs/@''&gt;v¦_G@§`]Ös/@òc±]G@\Z¯žØs/@ZÂ`Ë\\G@/à/?Ýs/@µeòWG@ïú®ùës/@³¾â¿RG@®žéñs/@M.ö±NG@pÿ^òs/@ ÍaNG@&lt;Éhýs/@rÙ–LG@¸*Bt t/@&lt;ŸˆIG@Þù)t/@ËGò&gt;DG@ûÄj(t/@A©ÂK@G@¡›ãÕ-t/@:íB=G@o,5t/@Ÿ²@;G@a¬t*Bt/@ ¤‘8G@!zKt/@L¬ž6G@lj}Ut/@Ы¼¹4G@}Ö¼\\wt/@›É¤û.G@JI&amp;4œt/@ÖD¨(G@2Jæš±t/@‘&amp;¡#G@âq^³±t/@8Ûe›#G@“º»MÇt/@ï  G@‘£ßt/@™(FÏG@ª8W÷t/@¿¼¹UG@íQñGu/@º3æGG@²Þ2Ýu/@_¶L¶G@âR€u/@j|æ’G@''‚Öau/@½-ÞùG@ö¹­)u/@óèP‡G@-x1Ju/@È3¤G@˜Ôî%u/@Û$ÍG@H‘ðu/@&lt;˜G@UþBu/@=JPýG@¾ß"u/@K›tãúG@Oºw¤#u/@†‘ËÁúG@HO]N,u/@“;­GùG@eæß?u/@B_LöG@ÌvmÝVu/@áó×óG@˜§Ev[u/@¥2ÄðG@@TÏl_u/@â+qgíG@ɽ\Zeu/@[]a…çG@:ø )gu/@g-áG@é’du[u/@&gt;6wMÞG@úmNƒUu/@­V¦óÙG@ˆøÆQu/@ÔKÿÕG@¥K?MQu/@–ÑKÒG@œu~Vu/@¹Ã[õÎG@­È­ø]u/@ ÛñoÌG@D¦Åhu/@ÙŠ˜,ÊG@¤DÕ£wu/@Yá¿ÈG@+\Z‰u/@a¦­ÇG@lV3\r¤u/@׬œ?ÆG@ €ì¸u/@R½JJÅG@3}qaÂu/@èjûÄG@¢U§½Èu/@Í-)ÂG@j(Íu/@è.P¿G@`ûfåÑu/@ÂÁ¸F»G@þ¨²Öu/@œ™? ¸G@–Çû’Þu/@‰Œû]¶G@ÏÀéu/@3%´G@LhÝ]üu/@ß6$±G@]‘ó v/@ ©Zð®G@0s+v/@¥Éæ¬G@¤]¶v/@ŽòרG@˜.ôæ\Zv/@®÷—ФG@h v/@"á\0M—G@Ðitv/@ׄ½’G@ðüv/@Ý5­BŽG@µ3 \nv/@é¨þ‹G@ZTLv/@øP{‰ˆG@r;$P÷u/@ÏV’&gt;„G@ëàrYëu/@˜wÒ9G@à°y!Ýu/@ðÿMy~G@ÐfÃu/@g"òázG@3H¹Œ­u/@kU¸HwG@䉽;šu/@‰ôó™rG@ÿQJu/@ÜâroG@¶‰Š)‰u/@F&gt;#klG@PC´ú€u/@û]ŸªhG@ˆÚzu/@0EóLfG@Á¼©pu/@òÔ¦UdG@€]"X[u/@\0³''0bG@gÖæˆMu/@Ç&gt;\\`G@Ð\n|–Fu/@!¤……^G@''Ú9ôDu/@×Oi\\G@íµ PFu/@DmÅ^YG@¨®ÍHu/@¡žîUG@_¶WéJu/@Ål RG@£y¯OMu/@e¡ÆMG@™3¯äKu/@FpmHG@,šlAHu/@bä;‰DG@^J+îCu/@¾äPBG@æˆO\\=u/@y^ßþ?G@Î2¿.u/@‘šþ=G@œ—7Ru/@Óœ79G@˜¡q‹u/@+ê©ñ4G@ÖŒ„u/@³ì%–1G@÷fáÔ u/@%ó\Z|.G@|´zºu/@&amp;í“´+G@"¬+u/@OÉó\\)G@Þ_µ™u/@lW™%G@#§G[)u/@õŽ(''G@$t/“4u/@EIroG@q/;^&gt;u/@l”ÂG@¤¿²¯Lu/@³ê‰G@ß|Smau/@^GnG@Ê »Çuu/@ÃÖ¤ÃG@”1î‡u/@èÐ…\ZG@7úHd•u/@/U€G@&gt;bo¿¡u/@¢ôeöG@uß®u/@&amp;\nP-\0G@ï‹}r·u/@Tñ-ºüG@sU~ø¹u/@œ^Ì6úG@²eóºu/@걓\n÷G@~‹W)¸u/@bÍôG@Y0ø±u/@Üa*ÔòG@ug#k¨u/@müñG@INñ®šu/@i(q‹ñG@7ŸVˆu/@Š"ÈðG@Vÿ•ru/@MðFwïG@Éúeäbu/@i¶ÖíG@Fà;Uu/@ZÛ:ÐëG@ˆ+ìOu/@‘D4é[email protected]/@z 6æG@ä€3sHu/@èY;ãG@ÒŸng&gt;u/@x9„9àG@"‚ƒX1u/@3òïÝG@JT2u/@ïv\n–ÛG@7¯u/@%F\0ØG@—ÍH0ôt/@‰œìÄÔG@'); -- -- Indexes for dumped tables -- -- -- Indexes for table `wkt_linija` -- ALTER TABLE `wkt_linija` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `wkt_linija` -- ALTER TABLE `wkt_linija` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; </code></pre> <p>Here is picture. I don't know why but when I exported table I got strange symbols in geometry row, something like this "/@‰œìÄÔG@". Is it coz I selected GeomFromText function when creating geometry field ? </p> <p><a href="https://i.stack.imgur.com/7B3tP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7B3tP.png" alt="Picture example"></a></p> <p>The real question is this. When I'm using this block of code to extract data from MySQL and convert to GeoJSON:</p> <pre><code>&lt;?php include_once('geoPHP/geoPHP.inc'); $conn = new PDO('mysql:host=localhost;dbname=web_gis;charset=utf8','neven','gis',array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8')); $sql = 'SELECT *, geometry AS wkt FROM wkt_linija'; $rs = $conn-&gt;query($sql); if (!$rs) { echo 'An SQL error occured.\n'; exit; } $geojson = array( 'type' =&gt; 'FeatureCollection', 'features' =&gt; array() ); while ($row = $rs-&gt;fetch(PDO::FETCH_ASSOC)) { $properties = $row; unset($properties['wkt']); unset($properties['geometry']); $feature = array( 'type' =&gt; 'LineString', 'geometry' =&gt; json_decode(($row['wkt'])), 'properties' =&gt; $properties ); array_push($geojson['features'], $feature); } header('Content-type: application/json'); echo json_encode($geojson, JSON_NUMERIC_CHECK); $conn = NULL; ?&gt; </code></pre> <p>Geometry field gets ignored and I get results without any geometry, like this:</p> <pre><code>{"type":"FeatureCollection","features":[{"type":"LineString","geometry":null,"properties":{"id":1,"oznaka":"K-8","opis":"D206 - Vulica - Kraljevec - Horvati - Kordej - S1","sirina":"5 m","podloga":"Asfalt-makadam","mo":"Kostel"}}]} </code></pre> <p>and should be getting something like this if I'm not mistaken:</p> <pre><code>{"type": "FeatureCollection","features": [ { "type": "Feature", "properties": { "OBJECTID": 857, "OZNAKA": "K-8", "OPIS": "D206 - Vulica - Kraljevec - Horvati - Kordej - S1", "�IRINA": "5", "PODLOGE": "Asfalt-makadam", "DULJINA": 2.714530, "SHAPE_Leng": 2714.529879, "JLS": "Pregrada", "MO": "Kostel" }, "geometry": { "type": "LineString", "coordinates": [ [ 15.724070907944066, 46.188443457771676 ], [ 15.724257815619874, 46.188344185018963 ], [ 15.724433034034641, 46.188218470155633 ], [ 15.72455940264949, 46.188111948013024 ], [ 15.724699297027877, 46.187990209886379 ], [ 15.724812369870586, 46.187860416649634 ], [ 15.72489216542548, 46.187729597634622 ], [ 15.72497191850638, 46.187587520467694 ], [ 15.725035777742436, 46.18748135544859 ], [ 15.725105549827283, 46.187407292181923 ], [ 15.725202581781817, 46.187342477581822 ], [ 15.725321929846059, 46.187288459964229 ], [ 15.725497857862772, 46.187225059863707 ], [ 15.725739143267136, 46.18716120411468 ], [ 15.725983191502424, 46.187106791868665 ], [ 15.726194987431329, 46.187080890038104 ], [ 15.726450533317252, 46.187073593715894 ], [ 15.726602817685782, 46.187066995092771 ], [ 15.726732946011916, 46.187037820050442 ], [ 15.726868107327785, 46.186958068465223 ], [ 15.726998796285825, 46.18681143294458 ], [ 15.72713472037392, 46.186645560888834 ], [ 15.727237900023473, 46.186502972887737 ], [ 15.727374482221942, 46.186387000961659 ], [ 15.727609563629075, 46.186189834001382 ], [ 15.72809649660417, 46.185818387861914 ], [ 15.728458503155057, 46.185542277867746 ], [ 15.728743661394422, 46.185371657495338 ], [ 15.728957680163198, 46.185259021798828 ], [ 15.729172360784085, 46.185188581679405 ], [ 15.72930431074095, 46.185137873121803 ], [ 15.729369597827198, 46.185060721013734 ], [ 15.729363091545522, 46.184984028820601 ], [ 15.729328718981932, 46.184892184228353 ], [ 15.729199870961573, 46.184762535747971 ], [ 15.729071126927163, 46.184640592675251 ], [ 15.728885780977054, 46.184525116727102 ], [ 15.728876077589561, 46.184519072234053 ], [ 15.728614827463138, 46.184405640049697 ], [ 15.728282035417173, 46.184319532788187 ], [ 15.728019456787038, 46.184201277050597 ], [ 15.727625044660053, 46.184046453459025 ], [ 15.727313665573254, 46.183902676002639 ], [ 15.72713005952758, 46.183815574507001 ], [ 15.726919608727677, 46.183782381293177 ], [ 15.726687496419437, 46.183780027306859 ], [ 15.726460925269162, 46.183781470427512 ], [ 15.72624004618312, 46.183798247915114 ], [ 15.725992218514767, 46.183861189085874 ], [ 15.725841694066393, 46.183920515406967 ], [ 15.725715865521043, 46.183874844726638 ], [ 15.725653703409941, 46.18379975520206 ], [ 15.725630852584601, 46.18370970853416 ], [ 15.725634974679185, 46.183611977505564 ], [ 15.725637955799805, 46.183427810892681 ], [ 15.725685548243181, 46.183341072493555 ], [ 15.725723013948333, 46.183206133168625 ], [ 15.725809501193257, 46.183107700844715 ], [ 15.725866680473091, 46.183003917087035 ], [ 15.725960645833988, 46.182866651324161 ], [ 15.726067912911608, 46.182727453662253 ], [ 15.726190146802059, 46.182621424687184 ], [ 15.726207337253058, 46.182606513725027 ], [ 15.726244838952267, 46.182546780957537 ], [ 15.726262053423898, 46.182519361730286 ], [ 15.726297354311184, 46.182371391634128 ], [ 15.726409723863496, 46.182212815966885 ], [ 15.726455021424353, 46.182089085774898 ], [ 15.726458519588704, 46.1820795299138 ], [ 15.726542714259828, 46.182008813530857 ], [ 15.726634629323016, 46.181917731008497 ], [ 15.726792632784449, 46.181770199109074 ], [ 15.726870857759003, 46.181649656342877 ], [ 15.726912197145625, 46.181557050493623 ], [ 15.72696727853892, 46.181495749681858 ], [ 15.727067305319169, 46.181413846381595 ], [ 15.727138343041192, 46.181354299035405 ], [ 15.727214739777891, 46.181296555637914 ], [ 15.727473161746497, 46.181121306860597 ], [ 15.727754239724749, 46.180928261966685 ], [ 15.727917519198943, 46.180774825857164 ], [ 15.727918248442567, 46.180774140104802 ], [ 15.728083066145052, 46.180681243365932 ], [ 15.728268727778216, 46.180597218758699 ], [ 15.728449559847867, 46.180521693889652 ], [ 15.728548286636363, 46.180459010508869 ], [ 15.728575622997003, 46.180441653687687 ], [ 15.728626260838556, 46.180345881025303 ], [ 15.728632981715306, 46.180266602979351 ], [ 15.728631308037603, 46.180130877024475 ], [ 15.728609388865232, 46.180042767469388 ], [ 15.72863119640742, 46.179925578113505 ], [ 15.728675382393831, 46.179736203157688 ], [ 15.728754103415818, 46.179605518578782 ], [ 15.728781671000469, 46.179531509339164 ], [ 15.728787555327612, 46.17952749671808 ], [ 15.728853653803199, 46.179482421480451 ], [ 15.729002926254177, 46.179391428482766 ], [ 15.729178351986228, 46.179316475034064 ], [ 15.729213424685256, 46.17922260735417 ], [ 15.729243660267571, 46.179119997271997 ], [ 15.729286990802217, 46.178940460721343 ], [ 15.729302693271269, 46.178746820197198 ], [ 15.729213398482402, 46.178659136971405 ], [ 15.729168036769796, 46.178526359767922 ], [ 15.729134552992278, 46.178405644044375 ], [ 15.72913590810442, 46.178292729463621 ], [ 15.729175521649999, 46.178190870100885 ], [ 15.729232569898466, 46.178113930791596 ], [ 15.729312949540265, 46.178044867023068 ], [ 15.729428405555446, 46.177993744555984 ], [ 15.729561627668394, 46.177968698730346 ], [ 15.729767239109798, 46.177925063611546 ], [ 15.729926481857566, 46.177895819181359 ], [ 15.729998631576199, 46.177859065783025 ], [ 15.730047156025481, 46.177800306667997 ], [ 15.730080843602126, 46.177713416007506 ], [ 15.730117005177533, 46.177590217793764 ], [ 15.730153622997474, 46.177509337477403 ], [ 15.730213731036013, 46.177440402819293 ], [ 15.730294124893048, 46.177372576295973 ], [ 15.730441029813072, 46.177280928037128 ], [ 15.730544656814056, 46.177213711041304 ], [ 15.730607373995639, 46.177126634301466 ], [ 15.730649660998102, 46.177027590548377 ], [ 15.730673997218489, 46.176896404459839 ], [ 15.730686159036875, 46.176492333821685 ], [ 15.730678213040187, 46.176331131495026 ], [ 15.730644702457511, 46.17621644456424 ], [ 15.730591136985689, 46.176118015618904 ], [ 15.730532059952845, 46.176041779721288 ], [ 15.730402473852994, 46.175910779432904 ], [ 15.730311198495164, 46.175818660514039 ], [ 15.730202718834732, 46.175734675489252 ], [ 15.730003845739928, 46.175625079374008 ], [ 15.729839704148707, 46.175515260702774 ], [ 15.729692332160035, 46.175372356528051 ], [ 15.729618528196623, 46.175276053085071 ], [ 15.729562090073937, 46.175183670242902 ], [ 15.729499659065965, 46.175069167915318 ], [ 15.72944644429414, 46.1749969661563 ], [ 15.729370166749847, 46.174936968289231 ], [ 15.729212526507354, 46.174871463188538 ], [ 15.729107168367774, 46.174815683654337 ], [ 15.729054167405963, 46.17475956941076 ], [ 15.729041702329665, 46.17469517134213 ], [ 15.72905208551216, 46.174602362060369 ], [ 15.729071071151182, 46.174497439541717 ], [ 15.729087154347495, 46.174396528594606 ], [ 15.72910546319037, 46.174248531959883 ], [ 15.729094644915493, 46.17408531172007 ], [ 15.729066891200169, 46.17396655487461 ], [ 15.729033892425999, 46.173890151499549 ], [ 15.728983769139131, 46.173827990595733 ], [ 15.728872275277265, 46.173739313429117 ], [ 15.728754586492691, 46.173621131114167 ], [ 15.72865710985279, 46.173490722623988 ], [ 15.72860349855311, 46.173388260381579 ], [ 15.728590633883398, 46.173293603095125 ], [ 15.728612735251083, 46.173208782415074 ], [ 15.728646626318611, 46.173137301479635 ], [ 15.728726199522438, 46.173007798074508 ], [ 15.728831150528611, 46.172825712970656 ], [ 15.728916739981351, 46.172712260059178 ], [ 15.72899145576932, 46.172630617446742 ], [ 15.729100695199868, 46.172549311964211 ], [ 15.729258934441928, 46.172437431420562 ], [ 15.729414216596428, 46.172325568664313 ], [ 15.729546276642203, 46.172213855113853 ], [ 15.729655393513083, 46.172107398664927 ], [ 15.729749662729883, 46.171995925696379 ], [ 15.729846939429743, 46.171880401689393 ], [ 15.729915216279521, 46.171775124009088 ], [ 15.729934468671422, 46.171698426999882 ], [ 15.729941946170445, 46.171601602665604 ], [ 15.729920665680535, 46.17153322935043 ], [ 15.729873420226953, 46.171473046011414 ], [ 15.729800556251329, 46.171447282199416 ], [ 15.7296957654536, 46.171433859112604 ], [ 15.729553262542693, 46.171410576691585 ], [ 15.729389846247617, 46.171370420110726 ], [ 15.729270112465558, 46.171320761745136 ], [ 15.729164786156741, 46.171258953798954 ], [ 15.729123053626395, 46.17117657711163 ], [ 15.729104461899636, 46.171087984683425 ], [ 15.729068374669119, 46.170993474941326 ], [ 15.728991729978507, 46.170905294001329 ], [ 15.728892103245986, 46.170835384142627 ], [ 15.728746006764606, 46.170763735875759 ], [ 15.728573253271504, 46.170655965932646 ], [ 15.728425511252494, 46.170555701764052 ] ] } } ] } </code></pre> <p>I don't know what I'm I missing. Is it something in .php block of code, or did I failed with creating table and selecting wrong function when creating geometry field, really don't know.</p> <p>Thank you for any help or constructive criticism regarding question.</p> <h1>UPDATE</h1> <p>Even when including this block of code in .php file mentioned above ( copied from here <a href="https://github.com/phayes/geoPHP" rel="nofollow noreferrer">https://github.com/phayes/geoPHP</a></p> <pre><code>&lt;?php include_once('geoPHP/geoPHP.inc'); function wkt_to_json($wkt) { $geom = geoPHP::load($wkt,'wkt'); return $geom-&gt;out('json'); } ... </code></pre> <p>I get notice </p> <blockquote> <p><strong>Notice:</strong> Undefined offset: 1 in C:\xampp\htdocs\PHP-GEOJSON\MySQL_LINIJA\geoPHP\lib\adapters\WKT.class.php on line 23</p> </blockquote> <p>and</p> <p>fatal error</p> <blockquote> <p><strong>Fatal error:</strong> Call to a member function out() on null in C:\xampp\htdocs\PHP-GEOJSON\MySQL_LINIJA\line.php on line 16</p> </blockquote>
1
While loop multiple conditions don't check both conditions
<pre><code>var x = 0; var y = 0; while (x &lt; 10 &amp;&amp; y &lt; 20){ x += 1; y += 1; console.log('This is x: ', x) console.log('This is y: ', y) } </code></pre> <p>I don't think I understand how multiple conditions in loops work. What I expect that code to do is to continue to loop until x greater than 10 and y is greater than 20 however the loop stops once x is greater than 10. I thought the &amp;&amp; means both conditions have to be met.</p>
1
Increase price depending in product variation (woocommerce)
<p>Is it possible to make a product variation change the price?</p> <p>For example I have a basic product and variants of it:</p> <pre>Quantity -- 10 -- 20 -- 50 Color -- Blue -- Red Project -- Yes -- No</pre> <p>I have prices for quantities, no matter for what color. But I would like to increase the price if you check "Project - Yes" and don´t change anything, when you select "Project - No".</p>
1