title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
bootstrap datepicker: run function when date is changed
<p>I want to run a function when the user changes the date input value using the datepicker, here is my code:</p> <p><a href="http://bootstrap-datepicker.readthedocs.org" rel="nofollow">The datepicker used.</a></p> <p>html:</p> <pre><code>&lt;div class="input-group date form-group" data-provide="datepicker"&gt; &lt;input type="text" class="form-control" id="birthdate" name="birthdate" placeholder="Student Birth Date..."&gt; &lt;div class="input-group-addon"&gt; &lt;span class="glyphicon glyphicon-th"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>js:</p> <pre><code>$('#birthdate').datepicker({ format: 'yyyy/mm/dd', startDate: '-3d' }); $('#birthdate').datepicker() .on('changeDate', function(e) { alert(); }); </code></pre> <p>When the date is changed, nothing happened. I've searched for this question before asking it, but no answer solved my problem!</p>
1
how to pass params as json arrays in postman having key and value pair
<p>I am not able to pass json array in postman with key and value pair. when using like this working</p> <pre><code>[ { "serviceTypeId": 40, "serviceName": "standard Cut2", "active": true, }, { "serviceTypeId": 44, "serviceName": "Special Cut1", "active": true, }, { "serviceTypeId": 46, "serviceName": "Feather xxxy", "active": true, } ] </code></pre> <p>but when i add a key its not(i.e like below)</p> <pre><code>{"serviceType": [ { "serviceTypeId": 40, "serviceName": "standard Cut2", "active": true, }, { "serviceTypeId": 44, "serviceName": "Special Cut1", "active": true, }, { "serviceTypeId": 46, "serviceName": "Feather xxxy", "active": true, } ] } </code></pre>
1
Unable to deploy war file using Tomcat Manager
<p>I am unable to deploy war file using Tomcat Manager<br> My \Tomcat\conf\tomcat-users.xml looks like below: </p> <pre><code>&lt;!-- &lt;role rolename="manager-gui"/&gt; &lt;user name="tomcat" password="admin" roles="admin-gui,standard,manager-gui"/&gt; --&gt; </code></pre> <p>Also, edited \Servers\Tomcat v7.0 Server at localhost-config\tomcat-users.xml to</p> <pre><code>&lt;!-- &lt;role rolename="manager-gui"/&gt; &lt;user name="tomcat" password="admin" roles="admin-gui,standard,manager-gui"/&gt; --&gt; </code></pre> <p>Still it is showing below error on launching server as <a href="http://localhost:8080/manager/html" rel="nofollow">http://localhost:8080/manager/html</a> and providing appropriate credentials</p> <pre><code>401 Unauthorized You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp. For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above. </code></pre> <p>I have also tried adding manager.xml to \Tomcat\conf but nothing worked</p> <pre><code>&lt;Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager"&gt; &lt;Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.0\.0\.1" /&gt; &lt;/Context&gt; </code></pre> <p>Note: I am restarting the server and <a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a> is not working</p>
1
Gradle custom plugin's build throws "unable to resolve class"
<p>I'm trying to build a gradle custom plugin that in turn depends on other plugin. In particular, the plugin depends on <em>com.bmuschko.docker-remote-api</em> plugin (that again depends on java library <em>com.github.docker-java:docker-java:2.1.1</em>).</p> <p>So I tried with the following <em>gradle.build</em> file</p> <pre><code>apply plugin: 'groovy' apply plugin: 'maven' apply plugin: 'com.bmuschko.docker-remote-api' buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-docker-plugin:2.6.1' } } group = 'com.example' version = '1.0' dependencies { compile gradleApi() compile localGroovy() compile group: 'com.github.docker-java', name: 'docker-java', version: '2.1.1' } </code></pre> <p>and the following plugin file:</p> <pre><code>package com.example.build import org.gradle.api.Project import org.gradle.api.Plugin import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage class BndPlugin implements Plugin&lt;Project&gt; { @Override void apply(Project project) { task buildDockerImage(type: DockerBuildImage) { println file("${projectDir}/docker/") } } } </code></pre> <p>but what I get with <code>gradle build</code> is just the error</p> <pre><code>unable to resolve class com.bmuschko.gradle.docker.tasks.image.DockerBuildImage </code></pre> <p><h2>Question:</h2> how to properly manage custom plugin's dependencies?</p> <hr> <p>You can get the full <a href="https://github.com/mrulli/com.example.wabplugin" rel="noreferrer">plugin project</a> on github.</p>
1
how to get span id with jquery when i click the element mathematics/physics/checmistry
<pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;jQuery Accordion Menu Demo&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="main.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id='menu'&gt; &lt;ul&gt; &lt;li&gt; &lt;a href='#'&gt;&lt;span id="Science"&gt;Science&lt;/span&gt;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href='#'&gt;Mathematics&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='#'&gt;Physics&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='#'&gt;Chemistry&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;script&gt; $('#menu li&gt;ul&gt;li').click(function() { alert(span id is Science); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the code what I am trying to do. </p> <p>I want that when a user clicks on the Mathematics or Physics or Chemistry, it should show in ALERT using JQuery the parent's SPAN ID.</p>
1
Change maximum number of Virtual interfaces in Kernel
<p>I am running Ubuntu server 14.04.3.</p> <p>I have smcroute installed - Version 0.95, Build 130523. When I attempt to start the daemon I get the error message: <code>ERRO: addVIF, out of VIF space;</code>, this happens after it attempts to add the 33rd network interface of my machine.</p> <p>Looking in <code>mroute.h</code> in <code>/usr/include/linux/</code> folder, I saw a <code>MAXVIFS</code> defined as <code>32</code>, so I upped it to <code>100</code> and saved the file.</p> <p>After a reboot I can still see the 32 limit being imposed, but the file still states <code>100</code>. How can I force the OS to read from this file?</p>
1
Bootstrap Modal not working on User Control
<p>I've got an ASP.NET web page that creates a series of User Controls with varying data. Each User Control utilizes Bootstrap 3 Modal controls for a better user experience. I've double checked all of the tags are in the correct format. Some of the modals on the page work, but the modals in the User Controls do not.</p>
1
React JSX integration with erb and Ruby block syntax
<p>In my <code>app/assets/javascripts/components/navbar.js.jsx.erb</code> I can write something like this in the render function of my component (I'm using the gem <a href="https://github.com/reactjs/react-rails" rel="nofollow">react-rails</a>):</p> <pre class="lang-js prettyprint-override"><code>class Navbar extends React.Component { render() { return( &lt;div className="navbar-header"&gt; &lt;ul&gt; &lt;li&gt; &lt;%= link_to root_path, className: 'navbar-brand' do %&gt; &lt;span className='glyphicon glyphicon-home'&gt;&lt;/span&gt; &amp;nbsp; &lt;%= I18n.t('menu.now') %&gt; &lt;% end %&gt; &lt;/li&gt; &lt;li&gt;&lt;%= link_to I18n.t('menu.archive'), archive_path%&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; ); } } </code></pre> <p>All works fine except for the <code>link_to</code> with block, which gives me a syntax error:</p> <blockquote> <p>syntax error, unexpected keyword_end, expecting ')'</p> </blockquote> <p>If I remove the block all works fine. Any idea?</p> <p>PS: To use the Rails helpers, I have added these lines in <code>config/initializers/assets.rb</code>:</p> <pre><code># Include Rails helpers in the assets pipeline Rails.application.config.assets.configure do |env| env.context_class.class_eval do include ActionView::Helpers include Rails.application.routes.url_helpers end end </code></pre>
1
Changing a variable inside a if - jade/pugjs
<p>I'm trying to make a div have a location inside of it based on the state of two variables, for example if <code>$city = 'New York'</code> and <code>$state = 'NY'</code> the div would display <code>New York, NY</code>. However, it's not working and I think it has to do with scoping. Here's my jade:</p> <pre><code>$city = data.City $state = data.State $locString = "" if $city != "" $locString = $locString + $city if $city != "" &amp;&amp; $state != "" $locString = $locString + ", " if $state != "" $locString = $locString + $state .location #{$locString} </code></pre> <p>This is ending with $locString being empty, but if I print off $locString inside the if statements it has only the most recently added value, suggesting that it is redeclaring a local copy of the variable inside of each if statement. I can't find anything about this in the reference <a href="http://jade-lang.com/reference/" rel="nofollow">http://jade-lang.com/reference/</a></p>
1
How do I change query parameters in Ember?
<p>I'm writing an action handler in <code>route:application</code>:</p> <pre><code>actions: { changeFoo(foo) { // I want to change the fooId queryParam to foo.get('id') } } </code></pre> <p>The problem is that the only documented ways I can find to change the query params are <code>transitionTo('some.route', someModel, { queryParams: { ... } }</code> and the <code>replaceWith</code> version of the same. But I'm in <code>route:application</code>, so I don't know the current route's name. That means I don't know what the first argument to <code>transitionTo</code> would be.</p> <p>Is there another way to get the URL to become <code>?fooId=123</code>?</p>
1
Inno Setup Section [Run] with condition
<p>I need a help with condition in <code>[Run]</code>. If it's possible...<br> I need to run a command that depends on a condition.</p> <p>Like this:</p> <pre><code>if (UserPage.Values[0] = 'NC') then FileName: {sys}\inetsrv\appcmd.exe; Parameters: "set......" </code></pre> <p>Or other way to do it.</p> <p>Regards.</p>
1
Using R in Python with Rpy2: how to ggplot2?
<p>I am trying to use R in Python and I found Rpy2 very interesting. It is powerful and not that difficult to use, however even if I have read the documentation and looked for a similar question, I wasn't able to solve my problem with the ggplot2 library.</p> <p>Basically I have a dataset with 2 columns, 11 rows and no header and I would like to do a scatter plot using this R code from Python:</p> <pre><code>ggplot(dataset,aes(dataset$V1, dataset$V2))+geom_point()+scale_color_gradient(low=&quot;yellow&quot;,high=&quot;red&quot;)+geom_smooth(method='auto')+labs(title = &quot;Features distribution on Scaffolds&quot;, x='Scaffolds Length', y='Number of Features') </code></pre> <p>I have tested this code in R (after read.table my file) and it works. Now, this is my python script:</p> <pre><code>import math, datetime import rpy2 import rpy2.robjects as robjects import rpy2.robjects.lib.ggplot2 as ggplot2 r = robjects.r df = r(&quot;read.table('file_name.txt',sep='\t', header=F)&quot;) gp = ggplot2.ggplot(df, ggplot2.aes(df[0], df[1])) + ggplot2.geom_point() + ggplot2.scale_color_gradient(low=&quot;yellow&quot;,high=&quot;red&quot;) + ggplot2.geom_smooth(method='auto') + ggplot2.labs(title = &quot;Features distribution on Scaffolds&quot;, x='Scaffolds Length', y='Number of Features') gp.plot() </code></pre> <p>If i run this Python code, it gives me two errors. The first is:</p> <pre><code>gp = ggplot2.ggplot(df, ggplot2.aes(df[0], df[1])) TypeError: new() takes exactly 1 argument (3 given) </code></pre> <p>and the second is:</p> <pre><code>AttributeError: 'module' object has no attribute 'scale_color_gradient' </code></pre> <p>Can someone help me to understand where I'm wrong please?</p>
1
How do I get Spring generated cookies to expire when browser is closed?
<p>A Spring Boot app has REST services that set cookie values inside a Spring Controller and then send the cookies out to the client in the response using <code>HttpServletResponse</code> as follows: </p> <pre><code>response.addCookie(new Cookie("AUTH1", "no")); </code></pre> <p>But when I close firefox, then re-open firefox and call the app's url again, the cookie values are exactly the same. <strong>How can I make sure that cookie values are destroyed when the browser closes, so that the cookies do not exist when the browswer is re-opened?</strong> Can this be configured in the Spring Boot app? Or do I need to configure it in the front end app?</p> <hr> <p><strong>ONGOING EFFORTS:</strong> </p> <p>Changing all the <code>response.setCookie()</code> lines in the backend REST controller to <code>session.setAttribute()</code> lines for the same key value pairs did not produce anything that the AngularJS client app could read using <code>$cookies.get('keyname')</code> even though they were the same key names. <strong>Is there a way to set session cookies in Spring controllers that will automatically be destroyed when the user closes their browser?</strong> </p> <p>I also tried to implement <code>@shazin</code>'s suggestion by using a method (because cookies are recreated many times in the controller class), but the problem is only partially resolved. Specifically, I took the following steps: </p> <p>1.) I started with a couple of browser windows open, only one of which contained the app being tested.<br> 2.) I changed all the code as shown below,<br> 3.) then I killed the app with control-C and also killed the process running on the port.<br> 4.) Then I <code>mvn clean package</code><br> 5.) and then I start up the app again with <code>java -jar jarname</code>, and load it up in a new InPrivate browser window.<br> 6.) I use the logout method to remove any cookies that might have lingered from previous versions,<br> 7.) then I use the GUI to trigger new cookie definitions, which work as intended.<br> 8.) But then I test by closing the browser window that contains the app being tested and then re-opening a new browser window and navigating to the site again, <strong>but the cookie values are still there, so this approach has not solved the problem.</strong><br> 9.) Finally, I closed both open browser windows (each browser window has a few tabs of its own open. After closing all the browser windows, I opened a new browser window, and found that the cookies had been removed. <strong>So the approach below only works if you close ALL open browser windows and not just the browser window containing the app.</strong> </p> <p>Here is the method that I wrote to implement @shazin's suggestion: </p> <pre><code>public Cookie getTempCookie(String key, String val){ Cookie tempCookie = new Cookie(key, val); tempCookie.setMaxAge(-1); return tempCookie; } </code></pre> <p>And here is how I call the method from the various url pattern handlers inside the controller: </p> <pre><code>response.addCookie(getTempCookie("AUTH1", "yes")); </code></pre> <p><strong>What else can I do to get the cookies to be deleted when only the window containing the app gets closed?</strong> In its present form, there is still a security risk if a user closes their browser window without realizing that another browser window is still opened. </p>
1
Calculate and plot confidence intervals for the mean in MATLAB (bootci)
<p>I have a set of curves varying over time, that are stored in a MATLAB matrix. Each row of the matrix is one of those curves, unfolding over time. Those are repetitions of a random experiment.</p> <p>I need to plot the mean of these curves over time, along with the 95% confidence intervals.</p> <p>My understanding of statistics this is rather poor, but I was suggested to use bootstrap confidence intervals using MATLAB's bootci function.</p> <p>I implemented a minimal example in MATLAB, but I have some doubts. I hope you can help me gaining a better grasp on this and avoiding dumb mistakes. </p> <p>Here's the example:</p> <pre><code>NVARIABLES = 200; NOBSERVATIONS = 1000; RESAMPLING = 10000; DATA = rand(NOBSERVATIONS, NVARIABLES); [CI, STAT] = bootci(RESAMPLING, @mean, DATA); MEAN = mean(DATA); % &lt;------- [1] x = 1:NVARIABLES; figure; hold on; plot(x, MEAN, 'LineWidth', 2); plot(x, CI(1,:), '--', 'LineWidth', 2); % [2] plot(x, CI(2,:), '--', 'LineWidth', 2); % plot(x, MEAN-CI(1,:)); % ? % plot(x, MEAN+CI(2,:)); % ? hold off; </code></pre> <p>Here are my questions:</p> <ul> <li>Am I using the function properly?</li> <li>When reporting/plotting the mean, is it correct to plot mean(DATA) (see line <a href="https://i.stack.imgur.com/YDAmL.png" rel="nofollow noreferrer">1</a>) or I should plot a mean derived by the bootstrapping procedure? I saw that STAT contains the mean for each bootstrap example, but I don't know whether I should use this information, and how</li> <li>Is it correct to plot the confidence intervals the way I am doing (see line [2]), or I should plot MEAN-CI(1,:) and MEAN+CI(2,:)?</li> </ul> <p>Please find attached the plot generated by the code.</p> <p><a href="https://i.stack.imgur.com/YDAmL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YDAmL.png" alt="enter image description here"></a></p>
1
Google reCaptcha - empty error message, not receiving response to challenge (The reCAPTCHA wasn't entered correctly)
<p>EDIT: I'm using reCaptcha 2.0, should I not be using recaptchalib.php? </p> <p><strong>Live DEMO</strong> <a href="http://josiahbertoli.com/" rel="nofollow">http://josiahbertoli.com/</a></p> <p>I'm getting the following error when I submit a form (ignore the blank values for the input fields)(with debug code):</p> <p><strong>Error</strong></p> <pre><code>_POST: ========= Array ( [first_name] =&gt; [last_name] =&gt; [email] =&gt; [subject] =&gt; [comments] =&gt; [g-recaptcha-response] =&gt; big-long-value ) ========= </code></pre> <p>The reCAPTCHA wasn't entered correctly. Go back and try it again.(reCAPTCHA said: )`</p> <p>How my webpage is set up:</p> <p><strong>HTML</strong></p> <pre><code>&lt;form id="query-form" action="wp-content/themes/portfolio/submit-form.php" method="post" name="myForm"&gt; &lt;input id="first_name" name="first_name" size="35" type="text" placeholder="e.g. John" /&gt; &lt;input id="last_name" name="last_name" size="35" type="text" placeholder="e.g. Smith" /&gt; &lt;input id="email" name="email" size="35" type="text" placeholder="e.g. [email protected]" /&gt; &lt;input id="subject" name="subject" size="35" type="text" placeholder="e.g. Feedback" /&gt; &lt;textarea id="comments" name="comments"&gt;&lt;/textarea&gt; &lt;div class="g-recaptcha" data-sitekey="6Le8WxcTAAAAAGqymotU9wtOBFEmWgjM3j2kqTcB"&gt;&lt;/div&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>Submit uses method POST to call the action submit-form.php which is as follows</p> <p><strong>PHP</strong></p> <pre><code>&lt;?php require_once('recaptchalib.php'); $privatekey = "the-key-that-i-put-in"; echo "&lt;pre&gt; _POST: =========\n"; print_r($_POST); echo "\n=========\n&lt;/pre&gt;"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); $resp = null; if (!$resp-&gt;is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp-&gt;error . ")"); } else { // Your code here to handle a successful verification include '../../../../process.php'; } ?&gt; </code></pre> <p>Thank you for your responses, I appreciate it.</p>
1
Javascript simple add class remove class
<pre><code>&lt;div onclick="myFunction();"&gt; Click Me&lt;/div&gt; &lt;div id="nav" style="" class="hide"&gt; &lt;ul&gt; &lt;li&gt;sample&lt;/li&gt; &lt;li&gt;sample&lt;/li&gt; &lt;li&gt;sample&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <pre><code>function myFunction (){ if ("show"){ document.getElementById('nav').style.display='none'; } else if ("hide"){ document.getElementById('nav').style.display='none'; } } </code></pre> <p>Onclick the click me btn, i want to show &amp; hide this "nav". using addclass remove class.</p> <p>Please help me in this pure javascript.</p> <p>Thanks.</p>
1
Method.Invoke failing with Parameter Count Mismatch
<p>I am trying to invoke a generic method. The definition of the method is as follows:</p> <pre><code>public System.Collections.Generic.IList&lt;T&gt; Query&lt;T&gt;(string query, [string altUrl = ""]) where T : new() </code></pre> <p>This is from the SalesforceSharp library on github. I am trying to make an additional service layer over this call and am struggling to invoke it. See my code below.</p> <pre><code>public List&lt;T&gt; Query&lt;T&gt;() { //IList&lt;Salesforce.Account&gt; _returnList = null; IList&lt;T&gt; _returnList = null; Type _t = typeof(T); SqlBuilder _sb = new SqlBuilder(); _sb.Table = _t.Name.ToString(); foreach (PropertyInfo p in _t.GetProperties()) _sb.Fields.Add(p.Name.ToString()); MethodInfo method = _Client.GetType().GetMethod("Query"); method = method.MakeGenericMethod(_t); try { object[] _prms = new object[1]; _prms[0] = _sb.SQL; _returnList = (IList&lt;T&gt;)method.Invoke(_Client, new object[] { _prms }); //_returnList = _Client.Query&lt;Salesforce.Account&gt;(_sb.SQL); } catch { } return (List&lt;T&gt;)_returnList; } </code></pre> <p>If I run this i get a Parameter Count Mismatch exception on the method.invoke line, but i am confused because if i bring in the two uncommented lines and execute without the generic call it is working ok. I have tried many combinations of string arrays wrapped in object arrays, strings in strings, etc but can't get it to go. I thought maybe it was treating the second parameter as mandatory? but adding another object to my _prms array didnt work either.</p> <p>Please help!</p> <p>Thanks, Dom</p>
1
SwipeRefreshLayout and TabLayout issue
<p>I have a simple project with a TabLayout in the MainActivity with 3 tabs, each tab has a SwipeRefreshLayout.</p> <p>If I pull to refresh the first tab, then move to the third tab while the first tab is still refreshing, when I go back to the first tab it looks like there is a view over the first tab with a snapshot of the state of the tab before I moved to the third tab. I can scroll the items and use the tab normally. </p> <p>Please see the images below and my code below.</p> <p>I can dismiss the "refresh indicator" calling swipeLayout.setRefreshing(false); in onPause of ContentFragment, but the overlay view stays there.</p> <h2>Initial screen</h2> <p><a href="https://i.stack.imgur.com/raxof.png" rel="noreferrer"><img src="https://i.stack.imgur.com/raxof.png" alt="Initial screen"></a></p> <h2>Screen with the issue</h2> <p><a href="https://i.stack.imgur.com/tJBAw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tJBAw.png" alt="Screen with the issue"></a></p> <h3>MainActivity</h3> <pre><code>public class MainActivity extends AppCompatActivity { ViewPager viewPager; TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.viewpager); tabLayout = (TabLayout) findViewById(R.id.tablayout); PagerAdapter pageAdapter = new PagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); tabLayout.setupWithViewPager(viewPager); } static class PagerAdapter extends FragmentPagerAdapter { private final int TAB_COUNT = 3; public PagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { return new ContentFragment(); } @Override public int getCount() { return TAB_COUNT; } @Override public CharSequence getPageTitle(int position) { switch (position) { case 0: return "Tab 1"; case 1: return "Tab 2"; case 2: return "Tab 3"; default: throw new IndexOutOfBoundsException("Invalid tab position"); } } } } </code></pre> <h3>ContentFragment</h3> <pre><code>public class ContentFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { RecyclerView recyclerView; private RecyclerAdapter adapter; SwipeRefreshLayout swipeLayout; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_content, container, false); adapter = new RecyclerAdapter(); recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapter); swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); swipeLayout.setOnRefreshListener(this); swipeLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN); return view; } @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { swipeLayout.setRefreshing(false); } }, 5000); } private class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerAdapter.ViewHolder&gt; { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_item, parent, false); return new ViewHolder(v); } @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.tvTitle.setText("Item #" + position); } @Override public int getItemCount() { return 50; } class ViewHolder extends RecyclerView.ViewHolder { private final TextView tvTitle; public ViewHolder(View itemView) { super(itemView); tvTitle = (TextView) itemView.findViewById(R.id.tvTitle); } } } } </code></pre> <h3>activity_main.xml</h3> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;android.support.design.widget.TabLayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" app:tabGravity="fill" /&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_below="@id/tablayout" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/RelativeLayout&gt; </code></pre> <h3>fragment_content.xml</h3> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_container" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent"/&gt; &lt;/android.support.v4.widget.SwipeRefreshLayout&gt; </code></pre> <h3>recyclerview_item.xml</h3> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="100dp"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:id="@+id/tvTitle" /&gt; &lt;/RelativeLayout&gt; </code></pre>
1
Sparkpost Rails sending domain rejected
<p>I am using this <a href="http://thehungrycoder.com/ruby-on-rails/integrate-sparkpost-in-your-rails-app.html" rel="nofollow">guide</a> as a reference to set up ActionMailer for my Rails app but I am getting this error whenever I try to send a mail. I have also tried to copy using the same exact settings as the guide but I still get the same error.</p> <pre><code>550 5.7.1 Unconfigured Sending Domain &lt;gmail.com&gt; </code></pre> <p>I have properly configured my sending domain, for example myapp.com at Sparkpost which is <strong>marked as ready to send</strong> and this is my rails actionmailer settings under production and development settings for the rails app.</p> <pre><code>config.action_mailer.smtp_settings = { user_name: 'SMTP_Injection', password: 'my_api_key', address: 'smtp.sparkpostmail.com', port: 587, enable_starttls_auto: true, domain: 'myapp.com' } </code></pre>
1
How to select a value from a drop down in python
<p>I have tried many things it can't seem to get it to work so I am posting this question to hopefully learn the simple method of selecting from a drop down menu in python.</p> <p>I manage to open the drop down menu but how can I select a value (let's say 4 in this example) from the drop down?</p> <p>Below is the code that opens the drop down:</p> <pre><code>#select adults adults = driver.find_element_by_xpath("//*[@id='adults-number']").click() </code></pre> <p>Below is the html that consists of all the options in the drop down (the one highlighted is the value I want selected):</p> <p><a href="https://i.stack.imgur.com/nBIaA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nBIaA.png" alt="enter image description here"></a></p>
1
Disable CKEditor Link "browse server" button
<p>Looking for a very simple way to disable/remove the CKEditor "browse server" button when using the Link toolbar button.</p>
1
Rails 4 devise: How to log out all users
<p>Im just about to perform an update to my app, I want to log out all users that have remembered session. I mean, once I deploy the update I want to force all the users to log in again.</p> <p>What is the best way to do it?</p>
1
Using of "skipWhile" combined with "repeatWhen" in RxJava to implement server polling
<p>I really like the RxJava, it's a wonderful tool but somethimes it's very hard to understand how it works. We use Retrofit with a RxJava in our Android project and there is a following use-case:</p> <p>I need to poll the server, with some delay between retries, while server is doing some job. When server is done I have to deliver the result. So I've successfully done it with RxJava, here is the code snippet: I used "skipWhile" with "repeatWhen"</p> <pre><code>Subscription checkJobSubscription = mDataManager.checkJob(prepareTweakJob) .skipWhile(new Func1&lt;CheckJobResponse, Boolean&gt;() { @Override public Boolean call(CheckJobResponse checkJobResponse) { boolean shouldSkip = false; if (SHOW_LOGS) Logger.v(TAG, "checkJob, skipWhile, jobStatus " + checkJobResponse.getJobStatus()); switch (checkJobResponse.getJobStatus()){ case CheckJobResponse.PROCESSING: shouldSkip = true; break; case CheckJobResponse.DONE: case CheckJobResponse.ERROR: shouldSkip = false; break; } if (SHOW_LOGS) Logger.v(TAG, "checkJob, skipWhile, shouldSkip " + shouldSkip); return shouldSkip; } }) .repeatWhen(new Func1&lt;Observable&lt;? extends Void&gt;, Observable&lt;?&gt;&gt;() { @Override public Observable&lt;?&gt; call(Observable&lt;? extends Void&gt; observable) { if (SHOW_LOGS) Logger.v(TAG, "checkJob, repeatWhen " + observable); return observable.delay(1, TimeUnit.SECONDS); } }).subscribe(new Subscriber&lt;CheckJobResponse&gt;(){ @Override public void onNext(CheckJobResponse response) { if (SHOW_LOGS) Logger.v(TAG, "checkJob, onSuccess, response " + response); } @Override public void onError(BaseError error) { if (SHOW_LOGS) Logger.v(TAG, "checkJob, onError, canEditTimeline, error " + error); Toast.makeText(ChoseEditOptionActivity.this, R.string.NETWORK__no_internet_message, Toast.LENGTH_LONG).show(); } @Override public void onCompleted() { if (SHOW_LOGS) Logger.v(TAG, "onCompleted"); } }); </code></pre> <p>The code works fine:</p> <p>When server responded that job is processing I return "true" from "skipWhile" chain, the original Observable waits for 1 second and do the http request again. This process repeats until I return "false" from "skipWhile" chain.</p> <p>Here is a few things I don't understand:</p> <ol> <li><p>I saw in the documentation of "skipWhile" that it will not emit anything (onError, onNext, onComplete) from original Observable until I return "false" from its "call" method. So If it doesn't emit anything why does the "repeatWhen" Observable doing it's job? It waits for one second and run the request again. Who launches it?</p></li> <li><p>The second question is: Why Observable from "repeatWhen" is not running forever, I mean why it stops repeating when I return "false" from "skipWhile"? I get onNext successfully in my Subscriber if I return "false".</p></li> <li><p>In documentation of "repeatWhile" it says that eventually I get a call to "onComplete" in my Subscriber but "onComplete" is never called.</p></li> <li><p>It makes no difference if I change the order of chaining "skipWhile" and "repeatWhen". Why is that ?</p></li> </ol> <p>I understand that RxJava is opensource and I could just read the code, but as I said - it's really hard to understand.</p> <p>Thanks.</p>
1
Get wikipedia page url by pageId
<p>I use <a href="https://www.mediawiki.org/wiki/API:Main_page" rel="nofollow">wikipedia api</a> to get an extract from a random page.</p> <p>There is example response:</p> <pre><code>{ "batchcomplete": "", "continue": { "grncontinue": "0.701350797294|0.701351244349|4312122|0", "continue": "grncontinue||" }, "query": { "pages": { "1485573": { "pageid": 1485573, "ns": 0, "title": "some title", "extract": "some text" } } } } </code></pre> <p>And now I know <code>pageid</code> of this page. </p> <p><strong>How</strong> can I get <code>url</code> of this page by <code>pageid</code>?</p>
1
How does the GRUB2 UEFI loader know where to look for the configuration file (or where the 2nd stage's files are located)?
<p>If I use GRUB2 on a GPT-enabled partition how does loader "know" where to find its configuration file and other 2nd stage's files?</p> <p>Note: I found some mentions about a config file which is located in the same folder as GRUB's EFI loader and contains chained load of "primary" configuration file from the specified partition, but that definitely is not true - there is only one "something.efi" file.</p>
1
Windows - read last line of text file, find word/phrase perform action
<p>I am trying to do the following:</p> <p>I have a file of which i am trying to read and if a certain phrase is found in the very last line, i want to perform an action.</p> <p>This is the last few lines of the the text file</p> <p><em> </em></p> <p>A PC is either going to have the above in the log file repeated over and over or it will not have anything close.</p> <p>I essentially want to read the very last line and see if it finds "Failed to get registration state" and if it does run a script.</p> <p>Here is what i have so far but i think i am nowhere near what i should be doing. Any help would be greatly appreciated as i am not very good at scripting. I was basically trying to count the number of lines and store it in a variable:</p> <pre><code>@echo off for /f %%i in ('find /v /c "" ^&lt; C:\Client.log') do set /a lines=%%i set /a startLine=%lines% for /f "tokens=*" %%a in ('findstr /i "Failed to get registration state. Error" more /e +%startLine% C:\Client.log') do echo %%a </code></pre>
1
How to use appProperties in Google Drive api v3?
<p>How to set the app properties of a file using Google Drive v3 in java?</p> <p>The reference says: "files.update with {'appProperties':{'key':'value'}}", but I don't understand how to apply that to my java code.</p> <p>I've tried things like</p> <pre><code>file = service.files().create(body).setFields("id").execute(); Map&lt;String, String&gt; properties = new HashMap&lt;&gt;(); properties.put(DEVICE_ID_KEY, deviceId); file.setAppProperties(properties); service.files().update(file.getId(), file).setFields("appProperties").execute(); </code></pre> <p>but then I get an error that "The resource body includes fields which are not directly writable." </p> <p>And to get the data:</p> <pre><code>File fileProperty = service.files().get(sFileId).setFields("appProperties").execute(); </code></pre> <p>So how to set and get the properties for the file? Thanks! :)</p> <p><strong>Edit</strong> I tried</p> <pre><code>file = service.files().create(body).setFields("id").execute(); Map&lt;String, String&gt; properties = new HashMap&lt;&gt;(); properties.put(DEVICE_ID_KEY, deviceId); file.setAppProperties(properties); service.files().update(file.getId(), file).execute(); </code></pre> <p>but I still get the same error message.</p>
1
How to read specific lines from sparkContext
<p>Hi I am trying to read specific lines from a text file using spark.</p> <pre><code>SparkConf conf = new SparkConf().setAppName(appName).setMaster(master); sc = new JavaSparkContext(conf); JavaRDD&lt;String&gt; lines = sc.textFile("data.txt"); String firstLine = lines.first(); </code></pre> <p>It can used the .first() command to fetch the first line of the data.text document. How can I access Nth line of the document? I need java solution.</p>
1
Pygame, set transparency on an image imported using convert_alpha()
<p>in my pygame game, to import jpeg image, I use <code>convert()</code> <a href="http://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert" rel="nofollow">http://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert</a></p> <p>then, to play with the image transparency (how much we can see trough the image), I use <code>set_alpha()</code> <a href="http://www.pygame.org/docs/ref/surface.html#pygame.Surface.set_alpha" rel="nofollow">http://www.pygame.org/docs/ref/surface.html#pygame.Surface.set_alpha</a></p> <p>However, to import my png image, which have a tranparent background, I use <code>convert_alpha()</code> <a href="http://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert_alpha" rel="nofollow">http://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert_alpha</a></p> <p>but with this way of importing, I can't play with the general transparency using <code>set_alpha()</code>. Any other idea to adjust the transparency (how much we see trough the image) ?</p>
1
How can I turn off the debug mode in oTree?
<p>I'm trying to run a web application from Otree (a web platform based on django and Python) in production mode(debug = false). I can't find where the variable OTREE_PRODUCTION is located. </p>
1
Decode HTML Escape Characters
<p>I'm downloading a JSON from the Google Directions API. For the HTML_Instructions field, representing the actual instruction needed for navigation, here is the format:</p> <pre><code>"Head \u003cb\u003esoutheast\u003c/b\u003e on \u003cb\u003eMinor Ave\u003c/b\u003e toward \u003cb\u003eMadison St\u003c/b\u003e", </code></pre> <p>Is there a way to decode/remove the escape characters from the String that is downloaded in Java/an Android application.</p> <p>Thanks for the help.</p>
1
How to make multiple charts using highcharts in a loop?
<p>This is the relevant code I have:</p> <pre><code> &lt;script&gt; titles = &lt;?php echo json_encode($graphTitles)?&gt;; //Loop through the graphs for (var graphNO = 0; graphNO &lt; titles.length; graphNO++) { //CREATE NEW CONTAINER var container = document.createElement('div'); document.body.appendChild(container);er); dates = &lt;?php echo json_encode($recivedDates);?&gt;[titles[graphNO]]; //I EXTRACT A FEW MORE ARRAYS THE SAME METHOD $(function () { $(container).highcharts({ title: { text: titles[graphNO] }, xAxis: { categories: dates }, series: [{ type: 'column', color: 'gold', name: 'Created Issues', data: createdIssues.map(Number) }, //MORE COLUMN'S AND SOME SPLINES. IT ALL WORKS AS EXPECTED }); }); } &lt;/script&gt; </code></pre> <p>I didn't want to post all the code and just make it messy, what I expected this code to do is:</p> <p>graphNO has the value of 2, I thought it would loop through twice (which it does), make a container for each loop (which it does), then draw a different graph for each loop it does in the container it just made (but instead it just draws the second graph).</p> <p>I don't know whats wrong, but any ideas on how to fix this, or any ideas on how to make multiple graphs in a loop would be great help.</p> <p>Also, this is the first site I'm making so I haven't used javascript, php, or html for more then a day, so sorry if it's really obvious, I couldn't find anything on this though.</p>
1
Sqoop job fails with KiteSDK validation error for Oracle import
<p>I am attempting to run a Sqoop job to load from an Oracle db and into Parquet format to a Hadoop cluster. The job is incremental.</p> <p>Sqoop version is 1.4.6. Oracle version is 12c. Hadoop version is 2.6.0 (distro is Cloudera 5.5.1).</p> <p>The Sqoop command is (this creates the job, and executes it):</p> <pre><code>$ sqoop job -fs hdfs://&lt;HADOOPNAMENODE&gt;:8020 \ --create myJob \ -- import \ --connect jdbc:oracle:thin:@&lt;DBHOST&gt;:&lt;DBPORT&gt;/&lt;DBNAME&gt; \ --username &lt;USERNAME&gt; \ -P \ --as-parquetfile \ --table &lt;USERNAME&gt;.&lt;TABLENAME&gt; \ --target-dir &lt;HDFSPATH&gt; \ --incremental append \ --check-column &lt;TABLEPRIMARYKEY&gt; $ sqoop job --exec myJob </code></pre> <p>Error on execute:</p> <pre><code>16/02/05 11:25:30 ERROR sqoop.Sqoop: Got exception running Sqoop: org.kitesdk.data.ValidationException: Dataset name 05112528000000918_2088_&lt;USERNAME&gt;.&lt;TABLENAME&gt; is not alphanumeric (plus '_') at org.kitesdk.data.ValidationException.check(ValidationException.java:55) at org.kitesdk.data.spi.Compatibility.checkDatasetName(Compatibility.java:103) at org.kitesdk.data.spi.Compatibility.check(Compatibility.java:66) at org.kitesdk.data.spi.filesystem.FileSystemMetadataProvider.create(FileSystemMetadataProvider.java:209) at org.kitesdk.data.spi.filesystem.FileSystemDatasetRepository.create(FileSystemDatasetRepository.java:137) at org.kitesdk.data.Datasets.create(Datasets.java:239) at org.kitesdk.data.Datasets.create(Datasets.java:307) at org.apache.sqoop.mapreduce.ParquetJob.createDataset(ParquetJob.java:107) at org.apache.sqoop.mapreduce.ParquetJob.configureImportJob(ParquetJob.java:80) at org.apache.sqoop.mapreduce.DataDrivenImportJob.configureMapper(DataDrivenImportJob.java:106) at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:260) at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:668) at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:444) at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:497) at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605) at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:228) at org.apache.sqoop.tool.JobTool.run(JobTool.java:283) at org.apache.sqoop.Sqoop.run(Sqoop.java:143) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227) at org.apache.sqoop.Sqoop.main(Sqoop.java:236) </code></pre> <p>Troubleshooting Steps:</p> <p>0) HDFS is stable, other Sqoop jobs are functional, Oracle source DB is up and the connection has been tested.</p> <p>1) I tried creating a synonym in Oracle, that way I could simply have the --table option as:</p> <p>--table TABLENAME (without the username)</p> <p>This gave me an error that the table name was not correct. It needs the full USERNAME.TABLENAME for the --table option.</p> <p>Error:</p> <pre><code>16/02/05 12:04:46 ERROR tool.ImportTool: Imported Failed: There is no column found in the target table &lt;TABLENAME&gt;. Please ensure that your table name is correct. </code></pre> <p>2) I made sure that this is a Parquet issue. I removed the --as-parquetfile option and the job was <strong>successful</strong>.</p> <p>3) I wondered if this is somehow caused by the incremental options. I removed the --incremental append &amp; --check-column options and the job was <strong>successful</strong>. This confuses me.</p> <p>4) I tried the job with MySQL and it was <strong>successful</strong>.</p> <p>Has anyone run into something similar? Is there a way (or is it even advisable) to disable the Kite validation? It seems that the dataset is being created with dots ("."), which then Kite SDK complains about - but this is an assumption on my part as I am not too familiar with Kite SDK.</p> <p>Thanks in advance,</p> <p>Jose</p>
1
Capture video frames with opencv in android
<p>I am trying to process android video in real time with opencv-android. So far I am able to access the video with opencv, and display it on a <code>org.opencv.android.JavaCameraView</code>.(I referred to <a href="http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html" rel="nofollow">this link</a>) I haven't been able to access the video feed of the camera by frame-wise. I need to get each and every frame in order to apply some opencv algorithms on them for object tracking. Please suggest a method to access and process the frames with opencv. (Redirect this if it's already been asked)</p>
1
Python: How to get real depth from disparity map
<p>I am a complete beginner I am trying to obtain real depth map from left and right image. I've used OpenCV to get the disparity map via block matching as you can see in the code bellow.</p> <pre><code>import cv2 import cv2.cv as cv import sys import numpy as np def getDisparity(imgLeft, imgRight, method="BM"): gray_left = cv2.cvtColor(imgLeft, cv.CV_BGR2GRAY) gray_right = cv2.cvtColor(imgRight, cv.CV_BGR2GRAY) print gray_left.shape c, r = gray_left.shape if method == "BM": sbm = cv.CreateStereoBMState() disparity = cv.CreateMat(c, r, cv.CV_32F) sbm.SADWindowSize = 11 sbm.preFilterType = 1 sbm.preFilterSize = 5 sbm.preFilterCap = 61 sbm.minDisparity = -50 sbm.numberOfDisparities = 112 sbm.textureThreshold = 507 sbm.uniquenessRatio= 0 sbm.speckleRange = 8 sbm.speckleWindowSize = 0 gray_left = cv.fromarray(gray_left) gray_right = cv.fromarray(gray_right) cv.FindStereoCorrespondenceBM(gray_left, gray_right, disparity, sbm) disparity_visual = cv.CreateMat(c, r, cv.CV_8U) cv.Normalize(disparity, disparity_visual, 0, 255, cv.CV_MINMAX) disparity_visual = np.array(disparity_visual) elif method == "SGBM": sbm = cv2.StereoSGBM() sbm.SADWindowSize = 9; sbm.numberOfDisparities = 0; sbm.preFilterCap = 63; sbm.minDisparity = -21; sbm.uniquenessRatio = 7; sbm.speckleWindowSize = 0; sbm.speckleRange = 8; sbm.disp12MaxDiff = 1; sbm.fullDP = False; disparity = sbm.compute(gray_left, gray_right) disparity_visual = cv2.normalize(disparity, alpha=0, beta=255, norm_type=cv2.cv.CV_MINMAX, dtype=cv2.cv.CV_8U) return disparity_visual imgLeft = cv2.imread('1.png') imgRight = cv2.imread('2.png') try: method = "BM" except IndexError: method = "BM" disparity = getDisparity(imgLeft, imgRight, method) cv2.imshow("disparity", disparity) #cv2.imshow("left", imgLeft) #cv2.imshow("right", imgRight) cv2.waitKey(0) </code></pre> <p>My question is what is the easiest way to obtain real depth map (distance) from disparity using python?</p>
1
How to use Sweet Alert to replace standard confirm dialog?
<p>I want replace standart confirm dialog. My javascript function is in the MasterPage.</p> <pre><code>function checkDelete() { swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", closeOnConfirm: false },function () { swal("Deleted!", "Your imaginary file has been deleted.", "success"); }); } </code></pre> <p>I want call checkDelete function in the content page.How i use sweet alert in gridview templatefield button?</p> <pre><code>&lt;asp:TemplateField ItemStyle-Width="60" HeaderText="Delete"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="lbDelete" Runat="server" OnClientClick=" return confirm('Are you sure?');" CommandName="Delete"&gt;Delete&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; </code></pre> <p>Please help.</p>
1
Sentiment score of a complete message using Python NLTK
<p>I have tried a lot from other relevant stack overflow discussions, but could not find what I am looking for. </p> <p>What I want is this: for a given message (i.e., paragraph with one or more sentences), I want to have a sentiment score in the range -5 to +5. </p> <p>The Valder module with the nltk.sentiment package provides three different scores: pos, neu, and neg. But this is not what I want. </p> <p>Is there any way to do it using nltk sentiwordnet? </p>
1
Asp.Net MVC - Inserting multiple rows in Database
<p>I'm building an E-Commerce app and now working on ProductAttributes. I want to handle Size and Color and Quantity attribues.</p> <p><strong>Example</strong> T-shirt has multiple colors and sizes with different quantity.</p> <pre><code> Name - Color - Size - Qty T-shirtA - Black - Small - 5pc T-shirtA - Blue - Medium - 10pc T-shirtA - Blue - Large - 4pc </code></pre> <p>I want to handle he above scenario.</p> <p><strong>Tables</strong></p> <pre><code>1. Product: Product_Id(pk), Name, Price, Description 2. ProductSizes: ProductSize_Id(pk), SizeName 3. ProductSizeValues: ProductSizeValue_Id(pk), ProductSize_Id(fk), Name 4. ProductColors: ProductColor_Id(pk), Name 5. ProductAttribues: ProductAttribute_Id(pk), ProductSize_Id(fk), ProductColor_Id(fk) 6. ProductAttribueValues: ProductAttributeValue_Id(pk), ProductAttribute_Id(fk), Product_Id(fk), ProductSizeValue_Id(fk), ProductColor_Id(fk), Quantity. </code></pre> <p>First I was confused about how can I store Colors and Sizes with quantity, then I installed <strong>OpenCart</strong> and saw their DB Schema and no I've above tables.</p> <p>I've inserted some values directly into the DB and everything is working fine. Getting the desired results. But obviously I want my user to store these details using ViewPage.</p> <p>I've created a <strong>ViewModel</strong></p> <p><strong>ProductAttributeViewModel.cs</strong></p> <pre><code>public class ProductAttributesViewModel { public Product Product { get; set; } public ProductAttribute ProductAttribute { get; set; } public ProductAttributeValue ProductAttributeValue { get; set; } public int ProductId { get; set; } public string Name { get; set; } [AllowHtml] public string Description { get; set; } public decimal? Price { get; set; } public int? Quantity { get; set; } public string Sizes { get; set; } public int Stock { get; set; } public int ProductColorVariantId { get; set; } public int ProductSizeVariantId { get; set; } public int ProductSizeVariantValueId { get; set; } public int ProductAttributeId { get; set; } public int ProductAttributeValueId { get; set; } } </code></pre> <p><strong>Contoller</strong> I have to insert data into mutliple tables. so his is my controller</p> <pre><code>[HttpPost] [ValidateAntiForgeryToken] public ActionResult AddProduct(ProductAttributesViewModel newRecord) { IEnumerable&lt;SelectListItem&gt; productsizevariants = db.ProductSizeVariants.Select(c =&gt; new SelectListItem { Value = c.ProductSizeVariantId.ToString(), Text = c.Name }); ViewBag.ProductSizeVariantId = productsizevariants; IEnumerable&lt;SelectListItem&gt; productsizevariantsvalues = db.ProductSizeVariantValues.Select(c =&gt; new SelectListItem { Value = c.ProductSizeVariantValueId.ToString(), Text = c.Name }); ViewBag.ProductSizeVariantValueId = productsizevariantsvalues; IEnumerable&lt;SelectListItem&gt; productcolorvariantsid = db.ProductColorVariants.Select(c =&gt; new SelectListItem { Value = c.ProductColorVariantId.ToString(), Text = c.Name }); ViewBag.ProductColorVariantId = productcolorvariantsid; var product = new Product { Name = newRecord.Name, Description = newRecord.Description, Price = newRecord.Price, }; var productattributes = new ProductAttribute { ProductSizeVariantId = newRecord.ProductSizeVariantId, ProductColorVariantId = newRecord.ProductColorVariantId, ProductId = newRecord.ProductId }; var productattributevalues = new ProductAttributeValue { ProductAttributeId = newRecord.ProductAttributeId, ProductId = newRecord.ProductId, ProductSizeVariantId = newRecord.ProductSizeVariantId, ProductSizeVariantValueId = newRecord.ProductSizeVariantValueId, ProductColorVariantId = newRecord.ProductColorVariantId, Quantity = newRecord.Stock }; db.Products.Add(product); db.ProductAttributes.Add(productattributes); db.ProductAttributeValues.Add(productattributevalues); db.SaveChanges(); return RedirectToAction("Index", "Home"); } </code></pre> <p>Everything is working great. Data is stored in all tables with foreign keys and all values. Now I want to add dynamic text fields for adding Size and Colors.</p> <p>I've colors and sizes stored in DB and from controller I'm passing those values in dropdownlist and populating them.</p> <p><strong>View</strong></p> <pre><code>@model FypStore.ViewModels.ProductAttributesViewModel @using (Html.BeginForm("AddProduct", "Store", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form-horizontal col-md-12", role = "form" })) { &lt;div class="form-group"&gt; @Html.LabelFor(m =&gt; m.Name, new { @class = "col-md-2 control-label", data_val_required = "required" }) &lt;div class="col-md-10"&gt; @Html.TextBoxFor(m =&gt; m.Name, new { @class = "form-control" }) @Html.ValidationMessageFor(m =&gt; m.Name) &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; @Html.LabelFor(m =&gt; m.Description, new { @class = "col-md-2 control-label" }) &lt;div class="col-md-10"&gt; @Html.TextAreaFor(m =&gt; m.Description, new { @class = "form-control" }) &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;div class="row"&gt; @*@Html.LabelFor(m =&gt; m.ProductSizeVariantId, new { @class = "col-md-2 control-label" })*@ &lt;div class="col-md-2 control-label"&gt; &lt;/div&gt; &lt;div class="input_fields_wrap"&gt; &lt;button class="add_field_button"&gt;Add More Fields&lt;/button&gt; &lt;div class="col-md-2"&gt; @Html.DropDownList("ProductSizeVariantId", null, "Size", new { @class = "control-label" }) &lt;/div&gt; &lt;div class="col-md-2"&gt; @Html.DropDownList("ProductSizeVariantValueId", null, "Select Size", new { @class = "control-label" }) &lt;/div&gt; &lt;div class="col-md-2"&gt; @Html.DropDownList("ProductColorVariantId", null, "Select Color", new { @class = "control-label" }) &lt;/div&gt; &lt;div class="col-md-2"&gt; @Html.TextBoxFor(x =&gt; x.Stock, new { @placeholder = "Quantity", @class = "form-control" }) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;div class="col-md-offset-2 col-md-10"&gt; &lt;input type="submit" class="btn btn-default" value="Create Product" /&gt; &lt;/div&gt; &lt;/div&gt; } </code></pre> <p>Here is the <strong>demo</strong> what I'm trying to achieve. </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.multi-field-wrapper').each(function() { var $wrapper = $('.multi-fields', this); $(".add-field", $(this)).click(function(e) { $('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper).find('input').placeholder('quantity').focus(); }); $('.multi-field .remove-field', $wrapper).click(function() { if ($('.multi-field', $wrapper).length &gt; 1) $(this).parent('.multi-field').remove(); }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;form role="form" action="/wohoo" method="POST"&gt; &lt;input type="text" placeholder="Name" name="name"&gt;&lt;br /&gt; &lt;input type="text" placeholder="Price" name="price"&gt;&lt;br /&gt; &lt;input type="text" placeholder="Description" name="description"&gt;&lt;br /&gt; &lt;label&gt;Attributes&lt;/label&gt; &lt;div class="multi-field-wrapper"&gt; &lt;div class="multi-fields"&gt; &lt;div class="multi-field"&gt; &lt;select&gt; &lt;option&gt;Green&lt;/option&gt; &lt;option&gt;Blue&lt;/option&gt; &lt;option&gt;Black&lt;/option&gt; &lt;option&gt;Purple&lt;/option&gt; &lt;option&gt;White&lt;/option&gt; &lt;/select&gt; &lt;select&gt; &lt;option&gt;XS&lt;/option&gt; &lt;option&gt;Small&lt;/option&gt; &lt;option&gt;Medium&lt;/option&gt; &lt;option&gt;Large&lt;/option&gt; &lt;option&gt;XL&lt;/option&gt; &lt;/select&gt; &lt;input type="text" placeholder="quantity" name="quantity"&gt; &lt;button type="button" class="remove-field"&gt;Remove&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;button type="button" class="add-field"&gt;Add field&lt;/button&gt; &lt;/div&gt; &lt;button type="button"&gt;Create Product&lt;/button&gt; &lt;/form&gt;</code></pre> </div> </div> </p>
1
Adding a directory to the system path variable through registry
<p>I am trying to add a directory to the <code>PATH</code> variable in windows. This is what I am entering the command line. (Or a batch file)</p> <pre><code>@echo off set value=%path%;%ProgramFiles%\AtomScript\ reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment" /v Path /t REG_EXPAND_SZ /d %value% /f </code></pre> <p>And it comes up with this message</p> <pre><code>ERROR: Invalid syntax. Type "REG ADD /?" for usage. </code></pre> <p>What am I doing wrong?</p>
1
Change user agent in QWebEngineView
<p>How to change the user agent in <code>QWebEngineView</code>? I know that for <code>QWebView</code> there is a way to do this but I didn't find the solution for the <code>QWebEngineView</code>.</p>
1
How can I test ActionCable channels using RSpec?
<p>I am wondering how to test ActionCable channels.</p> <p>Let's say I have the following chat channel:</p> <pre><code>class ChatChannel &lt; ApplicationCable::Channel def subscribed current_user.increment!(:num_of_chats) stream_from &quot;chat_#{params[:chat_id]}&quot; stream_from &quot;chat_stats_#{params[:chat_id]}&quot; end end </code></pre> <p>The <code>subscribed</code> method updates the db and defines two streams to be broadcasted across the channel, but the details are not very important since my question is a more general one:</p> <ul> <li>How can I set up a test to test the logic involved by subscribing to this channel?</li> </ul> <p>RSpec provides a lot of helper methods and various utilities when testing similar interactions like controller actions, but I couldn't find anything regarding RSpec and ActionCable.</p>
1
Get Entire Hierarchy of Parents From a Given Child in Postgresql
<p>Here is a sample of the data I am looking at:</p> <p>Table:</p> <pre><code>id | name | parent_id _______|____________|______________ 1 |Root | null 2 |Parent #2 | 1 3 |Parent #3 | 1 4 |Parent #4 | 2 5 |Child #5 | 2 6 |Child #6 | 2 7 |Child #7 | 3 8 |Child #8 | 3 9 |Child #9 | 3 </code></pre> <p>Using a recursive query, I am able to start from a Parent, and get all associated children.</p> <p>My question is, how can I start at the child, and get all related parents, grandparents, etc, right up to the root.</p> <p>So, given Child #9, I would like a query that returns the following:</p> <pre><code>id | name | parent_id _______|____________|______________ 1 |Root | 0 3 |Parent #3 | 1 9 |Child #9 | 3 </code></pre> <p>Any help would be greatly appreciated.</p>
1
Where is the .idlerc folder for Python IDLE on Mac?
<p>I'm looking for the .idlerc folder for IDLE. My setup is Python 2.7.9 + Mac OSX El Capitan. This folder contains the "config-highlight.cfg" file to apply new custom themes.</p>
1
Travis CI creates two builds for each Github commit push
<p>Each time I push to Github, it appears to trigger <em>two</em> Travis CI builds - one for the PR and one for the Push itself. They also appear to be separate builds, judging by the links.</p> <p>What's the exact difference between the two, and how can I enable it so that only one runs?</p> <p><a href="https://i.stack.imgur.com/iGfy0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iGfy0.png" alt="travis ci build"></a></p>
1
Installing google play services in genymotion, stuck with checking info
<p>I was trying to install google play services in genymotion. Everything went ok but after launching google play, it's just showing <strong><em>Checking info..</em></strong> from 2 hours. <a href="https://i.stack.imgur.com/iiZLq.png" rel="nofollow noreferrer">EmuatorStuck</a></p> <p>I followed instructions from here</p> <p><a href="https://stackoverflow.com/questions/20121883/how-to-install-google-play-services-in-a-genymotion-vm-with-no-drag-and-drop-su">How to install Google Play Services in a Genymotion VM (with no drag and drop support)?</a></p> <p>My device configurations are as follows:</p> <p>Google Nexus 5-5.1.0- API22 -1080*1920</p> <p>HDPI_miniGAPPS-5...150120-signed.zip</p>
1
What is the hbase.zookeeper.quorum in hbase-site.xml
<p>I would like to know how can I properly configure the hbase.zookeeper.quorum to point the zookeeper instance in a cluster mode.</p>
1
Installation of redis-3.0.7 on windows 10
<p>How to install redis-3.0.7 on windows 10 ?. I have downloaded the package and followed the installation procedure on <a href="http://redis.io/download" rel="nofollow">http://redis.io/download</a>.</p> <pre><code>C:\Downloads\redis-3.0.7&gt;make 'make' is not recognized as an internal or external command, operable program or batch file. </code></pre>
1
Highlight Wordpress parent menu item when submenu link active
<p>I have a simple menu in Wordpress.</p> <p>I need to highlight the ACTIVE PARENT MENU ITEM when a submenu item is selected. </p> <p>The problem is, whenever I do that via current-page-parent/current-page-ancestor - ALL menu items in the dropdown are have the active style applied to them as well as the parent.</p> <p>Any ideas how I can do this without touching the submenu item styles?</p> <pre><code>&lt;ul id="menu-main" class="nav navbar-nav navbar-right"&gt; &lt;li id="menu-item-249" class="menu-item menu-item-type-post_type menu-item-object-page current-page-ancestor current-menu-ancestor current-menu-parent current-page-parent current_page_parent current_page_ancestor menu-item-has-children menu-item-249 dropdown"&gt;&lt;a href="#"&gt;Parent Menu Item&lt;/a&gt; &lt;ul role="menu" class=" dropdown-menu"&gt; &lt;li id="menu-item-251" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-251"&gt;&lt;a href="#"&gt;Sub-menu Item&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
1
Is it possible to use symfony debug bar standalone?
<p>I am trying to use the Symfony debug bar in a standalone application without symfony framework. I have install the package using composer but whe i run Debug::enable() no bar shows up in the screen. Am i missing anything?</p> <p>thank you.</p>
1
Having 2 CollapsingToolbarLayout that can be expanded / collapsed one after the other
<p>Is there a way to have 2 CollapsingToolbarLayouts (one below the other) that can be expanded / collapsed one after the other ?</p> <p>Let's take this image as an example :</p> <p><a href="https://i.stack.imgur.com/6o0WL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6o0WL.png" alt="enter image description here"></a></p> <p>The section 1 and 2 are two CollapsingToolbarLayouts (and each one contains a Toolbar I suppose), and the section 3 is a list (a RecyclerView) that can be scrolled.</p> <p>The user can scroll on the section 3, and it will collapse the section 1. Once the section 1 is fully collapsed, it will collapse the section 2. Once the 2 layouts are collapsed, the user can continue to scroll on the list.</p> <p>If the user scrolls in the other direction, he will first have to reach the top of the list, and then if he continues scrolling, it will expand the section 2, and then expand the section 1 once the section 2 is fully expanded.</p>
1
While working with Selenium webdriver, why do we use linked list for gathering links or dropdown contents with mutliple matches?
<p>Example code is something like this, (this was an interview question asked for me recently)</p> <p>List linkElements = driver.findElements(By.tagName("a"));</p>
1
Entity Framework 6 multiple savechanges transaction with foreign key constraint
<p>I have the following code in a controller. I'm trying to batch update the database but am getting the folliwing error message:</p> <p>The INSERT statement conflicted with the FOREIGN KEY constraint.</p> <pre><code>using (var context = new EFDbContext()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { // MessageThread context.MessageThreads.Add(messageThread); context.SaveChanges(); // Message context.Messages.Add(message); context.SaveChanges(); // Recipient context.Recipients.Add(recipient); context.SaveChanges(); dbContextTransaction.Commit(); } catch //(Exception ex) { ModelState.AddModelError("", "Something went wrong. Please try again."); return View("Message", model); // dbContextTransaction.Rollback(); no need to call this manually. } } } </code></pre> <p>The Message class has following property: </p> <pre><code>[ForeignKey("MessageThread")] public long MessageThreadID { get; set; } // ID public virtual MessageThread MessageThread { get; set; } </code></pre> <p>I can't add a Message because MessageThreadID there is a foreign key constraint on MessageThread. But I can't save them one at a time, this needs to be done in one transaction for data integrity.</p> <p>How do I do this in one go? Perhaps could I temporarily disable the foreign key constraint?</p>
1
Is there a major difference between the two scipy Hilbert transforms?
<p>I was looking for Hilbert transforms in the scipy package and I noticed there are two versions of the Hilbert transform--one in <a href="https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.fftpack.hilbert.html" rel="nofollow"><code>scipy.fftpack</code></a> and the other in <a href="https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.signal.hilbert.html" rel="nofollow"><code>scipy.signal</code></a>. I saw that they differ in the outputs being complex conjugates, but are there any other fundamental difference between the two Hilbert transforms I should be aware of before using one version or the other? Nothing particularly jumped out at me when I looked at the source-code.</p>
1
JPQL - Calculate difference between Timestamps
<p>I want to calculate the difference between the <code>TIMESTAMP</code> saved in the Database with the <code>CURRENT_TIMSTAMP</code> and verify if the number of <strong>days</strong> between them is less than a given number.</p> <pre><code>TypedQuery&lt;Person&gt; q = entityManager.createQuery("SELECT p FROM Person p WHERE (p.createdOn - CURRENT_TIMESTAMP &lt;= :constant))", Person.class); </code></pre> <p>The <code>p.createdOn</code> is automatically set by the Database.</p> <p>The <code>constant</code> would be the number of days the difference has to be less than.</p> <pre><code>q.setParameter("constant", 14); </code></pre> <p>The query is compiling but not retrieving what it needs to and I am unable to get the number of days between them working in my query. </p> <p>An alternative (inefficient) approach is getting all and looping through them and calculating.</p>
1
Implement bad word filter in to my input in html?
<p>I plan on putting this list of bad words (<a href="https://github.com/shutterstock/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/blob/master/en" rel="nofollow">https://github.com/shutterstock/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/blob/master/en</a>) into a .txt file on my web server. How can I this javascript check the variable "userNickName" against the .txt file named "blacklist.txt" on my web server.</p> <p>(This is the code I want the bad word check implemented on, how would I do that?)</p> <pre><code>if (wsIsOpen() &amp;&amp; null != userNickName) { var msg = prepareData(1 + 2 * userNickName.length); msg.setUint8(0, 0); for (var i = 0; i &lt; userNickName.length; ++i) msg.setUint16(1 + 2 * i, userNickName.charCodeAt(i), true); wsSend(msg) </code></pre>
1
How to reuse mongodb connection through Promise
<p>I want to reuse MongoDB connection. I 'am aware of <a href="https://stackoverflow.com/questions/17647779/how-to-reuse-mongodb-connection-in-node-js">How to reuse mongodb connection in node.js</a> I want to acheive the same using Promises and Mongo driver v2</p> <p>Currently I have to connect to db for every request which makes it slow. This is my code </p> <pre><code>"use strict" var app = require('./utils/express')(); var mongodb = require('mongodb'); var MongoClient = mongodb.MongoClient; //Actually I 'am connecting to MongoLab var url = 'mongodb://localhost/my-mongo'; app.set('port', (process.env.PORT || 5000)); app.listen(app.get('port'), function () { console.log('ParkMe app is running on port', app.get('port')); }); app.get('/location/create', function(req,res,next){ MongoClient.connect(url).then(function(db) { return db.collection('parkme_parkingLots').find({}).toArray().then(function (docs) { return docs; }); }); }); </code></pre> <p>I want to do something like:</p> <pre><code>"use strict" var app = require('./utils/express')(); var mongodb = require('mongodb'); var MongoClient = mongodb.MongoClient; var url = 'mongodb://nidhind:[email protected]:51635/my-mongo'; var db = MongoClient.connect(url).then(function(db) { return db; }); app.set('port', (process.env.PORT || 5000)); app.listen(app.get('port'), function () { console.log('ParkMe app is running on port', app.get('port')); }); app.get('/location/create', function(req,res,next){ db.collection('parkme_parkingLots').find({}).toArray().then(function (docs) { return docs; }); }); </code></pre>
1
System.InvalidCastException occurred in EntityFramework.Core.dll
<p>The below is the the <code>Application Entity</code>:</p> <pre class="lang-cs prettyprint-override"><code>public class Application { [Key] [Column(TypeName = "integer")] public int ApplicationID { get; set; } [Required] [Column(TypeName = "nvarchar(50)")] public string ApplicationName { get; set; } [Column(TypeName = "nvarchar(150)")] public string Description { get; set; } [Required] [ForeignKey("mTechnology")] [Column(TypeName = "integer")] public int TechnologyID { get; set; } [Required] [Column(TypeName = "int")] public string CreatedBy { get; set; } [Required] [Column(TypeName = "datetime")] public DateTime CreatedDate { get; set; } public virtual mTechnology Technology { get; set; } } </code></pre> <p>On executing the below LINQ query, I am getting an error at <code>run-time</code> in the <code>foreach loop</code></p> <pre class="lang-cs prettyprint-override"><code>List&lt;int&gt; technologyList = new List&lt;int&gt;(); var query = from a in _mApplicationDbContext.Applications group a.Technology by a.TechnologyID into g select new { TechnologyID = g.Key }; foreach (var item in query) { technologyList.Add(item.TechnologyID); } </code></pre> <p>The below is the error message:</p> <blockquote> <p>An exception of type 'System.InvalidCastException' occurred in EntityFramework.Core.dll but was not handled in user code</p> <p>Additional information: Unable to cast object of type 'System.Int32' to type 'System.String'.</p> </blockquote> <p>Is the LINQ query wrong or any other error?</p>
1
How to ignore invalid ssl cert using javascript request library?
<p>Is there a way to ignore invalid ssl certs using the popular request library: <a href="https://www.npmjs.com/package/request" rel="nofollow">https://www.npmjs.com/package/request</a></p> <p>I'm using this in a nodejs server to make an https request to a server with a self-signed cert and need to be able to ignore the invalid ssl cert.</p> <p>I couldn't find an option for this in the documentation, does anyone know if this is possible?</p>
1
In protractor , when to use protractor.promise.controlFlow() >
<p>I'm confused when to use </p> <pre><code>var flow = protractor.promise.controlFlow() </code></pre> <p>in <strong>protractor scripts</strong> and also I can see a method called execute method <code>flow.execute()</code>. </p> <p>Can Any one give me some example and elaborate above statement</p>
1
How to change the text color of disabled Asp.net DropDownList
<p>I searched for some time on this question and couldn't find a working answer anywhere. </p> <p>I have an asp DropDownList that gets disabled and enabled based on whether the form is in view mode or not. The problem I was having is when the DropDownList.Enabled = false the text is hard to read(grey on lightgrey).</p> <p>I solved the issue by passing the DropDownList to some methods.</p> <pre><code>public void DisableDDL(ref DropDownList DDL) { DDL.BackColor = System.Drawing.Color.LightGray; foreach (ListItem i in DDL.Items) { if (i != DDL.SelectedItem) { i.Enabled = false; } } } public void EnableDDL(ref DropDownList DDL) { DDL.BackColor = System.Drawing.Color.White; foreach (ListItem i in DDL.Items) { i.Enabled = true; } } </code></pre> <p>Is there another way to do this? I tried using css but that didn't work.</p> <pre><code>&lt;style&gt; .disabledStyle { color: black; } &lt;/style&gt; myDDl.CssClass = "disabledStyle"; </code></pre>
1
Add New External Git Repository Connection - Visual Studio Team Services
<p>I am trying to add an external git repository to a visual studio team services build process but always receive an error during build:</p> <blockquote> <p>Starting clone </p> <p>Request failed with status code: 404 </p> <p>Prepare repository failed with exception.</p> </blockquote> <p>On the page <a href="https://msdn.microsoft.com/en-us/library/vs/alm/build/define/repository" rel="nofollow">Specify the repository</a> I can only read </p> <blockquote> <p>Fill in the Add New External Git Repository Connection dialog box.</p> </blockquote> <p>But how? Searching the internet I could not find any help. Trying out different settings - nothing helped. </p> <p>What do I have to enter for a repository located at for example</p> <p><a href="https://[email protected]/repodir/repo.git" rel="nofollow">https://[email protected]/repodir/repo.git</a></p> <p>In the build definition within the repository tab I enter</p> <p>Repository type: External Git Connection: </p> <p>Add new external git repository connection (setting up a connection)</p> <blockquote> <p>Server URL: <a href="https://bitbucket.org" rel="nofollow">https://bitbucket.org</a></p> <p>User name: myUserName </p> <p>Password/Token Key: ********</p> <p>Repository name: repodir/repo.git ( I also tried Repository name: repodir/repo )</p> </blockquote> <p>What ever I try - I always get the error message. Using command line, I can easily clone the repository. How can I enable Team Services to clone an external repository? I think I am missing something big here... </p> <p>Thanks a lot for any help.</p>
1
base64Binary datatype is equivalent to base64?
<p>"The base64Binary datatype represents Base64-encoded arbitrary binary data. In other words, the data is encoded by using the Base64 Content-Tranfer-Encoding defined in Section..." from XML Schema Essentials</p> <p>So, what I understand is if we decode the value, we obtain binary data. Is it true? Can we also have something like base64String, base64float? It is totally different if we have base64 and baseBinary?</p> <p>Maybe, it is obvious but this confuses me when in the second line they say "the data is encoded by using the Base64 Content-Tranfer-Encoding " and they didn't specify "binary data".</p> <p>Regards</p>
1
Three.js invisible plane not working with raycaster.intersectObject
<p>I am trying to make draggable objects, as seen in this example: <a href="https://www.script-tutorials.com/demos/467/index.html" rel="nofollow">https://www.script-tutorials.com/demos/467/index.html</a></p> <p>The objects which should be draggable are in the array objectMoverLines.</p> <p>I have added a plane to my scene with the following code:</p> <pre><code>plane = new THREE.Mesh(new THREE.PlaneBufferGeometry(500, 500, 8, 8), new THREE.MeshBasicMaterial({color: 0x248f24, alphaTest: 0})); plane.visible = false; scene.add(plane); </code></pre> <p>The problem occurs under the <strong>onDocumentMouseDown</strong> function. For some reason, if the planes visibility is set to false (plane.visible = false), then at a certain point, intersectsobjmovers will not be populated. If the plane's visibility is set to true, however, it will work fine (but obviously, that causes a huge plane to be in the way of everything):</p> <pre><code>function onDocumentMouseDown(event) { // Object position movers var vector = new THREE.Vector3(mouse.x, mouse.y, 1); vector.unproject(camera); raycaster.set( camera.position, vector.sub( camera.position ).normalize() ); var intersectsobjmovers = raycaster.intersectObjects(objectMoverLines); if (intersectsobjmovers.length &gt; 0) { console.log('clicking an object mover'); // Disable the controls controls.enabled = false; // Set the selection - first intersected object objmoverselection = intersectsobjmovers[0].object; // Calculate the offset var intersectsobjmovers = raycaster.intersectObject(plane); // At this point, intersectsobjmovers does not include any items, even though // it should (but it does work when plane.visible is set to true...) offset.copy(intersectsobjmovers[0].point).sub(plane.position); } else { controls.enabled = true; } } </code></pre> <p>Also, this is what I currently have under the <strong>onDocumentMouseMove</strong> function:</p> <pre><code>function onDocumentMouseMove(event) { event.preventDefault(); mouse.x = ( event.clientX / renderer.domElement.clientWidth ) * 2 - 1; mouse.y = - ( event.clientY / renderer.domElement.clientHeight ) * 2 + 1; // Get 3D vector from 3D mouse position using 'unproject' function var vector = new THREE.Vector3(mouse.x, mouse.y, 1); vector.unproject(camera); // Set the raycaster position raycaster.set( camera.position, vector.sub( camera.position ).normalize() ); if (objmoverselection) { // Check the position where the plane is intersected var intersectsobjmovers = raycaster.intersectObject(plane); // Reposition the object based on the intersection point with the plane objmoverselection.position.copy(intersectsobjmovers[0].point.sub(offset)); } else { // Update position of the plane if need var intersectsobjmovers = raycaster.intersectObjects(objectMoverLines); if (intersectsobjmovers.length &gt; 0) { // var lookAtVector = new THREE.Vector3(0,0, -1); // lookAtVector.applyQuaternion(camera.quaternion); plane.position.copy(intersectsobjmovers[0].object.position); plane.lookAt(camera.position); } } requestAnimationFrame( render ); } </code></pre>
1
On check Child Checkbox checks Parent Checkbox
<p>I managed to do on checking Parent Checkbox to check all Child Checkboxes but i dont know how to do on checking any child checkbox to check the parent checkbox and if all the child checkboxes are unchecked then the Parent checkbox needs to be unchecked. 1. I did on checking Parent Checkbox to check all Child Checkboxes (completed) 2. on checking any child checkbox also checks parent checkbox (not complete) 3. if all the child checkboxes are unchecked then the Parent checkbox unchecks(not complete). This is how far i got:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function () { $("input[type='checkbox']").change(function () { $(this).siblings('ul') .find("input[type='checkbox']") .prop('checked', this.checked); }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt;Lead1 &lt;br&gt; &lt;ul&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; All Leads &lt;br&gt;&lt;/li&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; Recent Leads &lt;br&gt;&lt;/li&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; My Leads &lt;br&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt;Lead2 &lt;br&gt; &lt;ul&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; first &lt;br&gt;&lt;/li&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; second &lt;br&gt;&lt;/li&gt; &lt;li style="display: block;"&gt;&lt;input type="checkbox"&gt; third &lt;br&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt;</code></pre> </div> </div> </p> <p>Please Help me to solve this as i am new to jquery and js.</p>
1
How do I make a nuget package target multiple frameworks correctly?
<p>Currently, I get the following error:</p> <pre><code>Could not install package 'csharp-extensions 1.2.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. </code></pre> <p>Here is a link to my repo: <a href="https://github.com/NullVoxPopuli/csharp-extensions" rel="nofollow noreferrer">https://github.com/NullVoxPopuli/csharp-extensions</a><br> The Nuget Link: <a href="https://www.nuget.org/packages/csharp-extensions/1.2.0" rel="nofollow noreferrer">https://www.nuget.org/packages/csharp-extensions/1.2.0</a></p> <p>In my project.json, I specify dnx46 and dnxcore50</p> <pre><code>{ "version": "1.2.0", "configurations": { "Debug": { "compilationOptions": { "define": [ "DEBUG", "TRACE" ] } }, "Release": { "compilationOptions": { "define": [ "RELEASE", "TRACE" ], "optimize": true } } }, "dependencies": { "Microsoft.Extensions.PlatformAbstractions": "1.0.0-*", "System.Reflection": "4.1.0-*", "xunit": "2.1.0-*", "xunit.runner.dnx": "2.1.0-*" }, "commands": { "run": "csharp_extensions", "test": "xunit.runner.dnx" }, "frameworks": { "dnx46": { "dependencies": { "System.Console": "4.0.0-beta-*", "System.Reflection.TypeExtensions": "4.1.0-beta-*", "System.Runtime.Extensions": "4.0.11-beta-*", "System.Dynamic.Runtime": "4.0.11-beta-*", "Microsoft.CSharp": "4.0.1-beta-*", "System.IO": "4.0.11-beta-*" } }, "dnxcore50": { "_": "this is the recommended windows runtime", "dependencies": { "System.Console": "4.0.0-beta-*", "System.Reflection.TypeExtensions": "4.1.0-beta-*", "System.Runtime.Extensions": "(4.0,]", "System.Dynamic.Runtime": "(4.0.0,]", "Microsoft.CSharp": "(4.0.0,]", "System.IO": "(4.0,]" } } }, } </code></pre> <p>The project I'm trying to install the nuget into is a Class Library targeting .NET Framework 4.6 (and isn't a dnx project)</p> <p>UPDATE:</p> <p>This is what happens when I build the nuget package with <code>nuget pack</code> <a href="https://i.stack.imgur.com/09EQS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/09EQS.png" alt="enter image description here"></a></p>
1
Real time image processing Android camera2 api
<p>I'm very new to android. I'm trying to use the new Android Camera2 api to build a real time image processing application. My application requires to maintain a good FPS rate as well. Following some examples i managed to do the image processing inside the onImageAvailable(ImageReader reader) method available with ImageReader class. However by doing so, i can only manage to get a frame rate around 5-7 FPS.</p> <p>I've seen that it is advised to use RenderScript for YUV processing with Android camera2 api. Will using RenderScript gain me higher FPS rates? If so please can someone guide me on how to implement that, as i'm new to android i'm having a hard time grasping concepts of Allocation and RenderScript. Thanks in advance. </p>
1
How to make Extent report (in Jenkins) show screenshot when a test fails?
<p>I'm having an issue where extent report is not showing the screenshot when a test fails and when accessing the report remotely via Jenkins url. But if the report is viewed on the same machine where Jenkins is installed, the screenshot is displayed. When saving the image into the report, I pass the absolute path of the image file. Is this the right way to do it?</p>
1
elasticsearch Not_analyzed and analyzed
<p>Hello For certain requirement i have made all the index not_analyzed </p> <pre><code>{ "template": "*", "mappings": { "_default_": { "dynamic_templates": [ { "my_template": { "match_mapping_type": "string", "mapping": { "index": "not_analyzed" } } } ] } } } </code></pre> <p>But now as per our requirement i have to make certain field as analyzed . and keep rest of the field as not analyzed </p> <p>My Data is of type : </p> <pre><code>{ "field1":"Value1", "field2":"Value2", "field3":"Value3", "field4":"Value3", "field5":"Value4", "field6":"Value5", "field7":"Value6", "field8":"", "field9":"ce-3sdfa773-7sdaf2-989e-5dasdsdf", "field10":"12345678", "field11":"ertyu12345ffd", "field12":"A", "field13":"Value7", "field14":"Value8", "field15":"Value9", "field16":"Value10", "field17":"Value11", "field18":"Value12", "field19":{ "field20":"Value13", "field21":"Value14" }, "field22":"Value15", "field23":"ipaddr", "field24":"datwithtime", "field25":"Value6", "field26":"0", "field20":"0", "field28":"0" } </code></pre> <p>If i change my template as per recommendation to something like this </p> <pre><code>{ "template": "*", "mappings": { "_default_": { "properties": { "filed6": { "type": "string", "analyzer": "keyword", "fields": { "raw": { "type": "string", "index": "not_analyzed" } }}}, "dynamic_templates": [ { "my_template": { "match_mapping_type": "*", "mapping": { "type": "string", "index": "not_analyzed" } } } ] } } } </code></pre> <p>Then i get error while i insert data stating </p> <p>{"error":"MapperParsingException[failed to parse [field19]]; nested: ElasticsearchIllegalArgumentException[unknown property [field20 ]]; ","status":400}</p>
1
knex.js: incorporating validation rules in create, update, and delete queries
<p>Is it possible to incorporate data validation rules for Create, Update, and Delete operations when using the Knex.js query builder library, even though Knex does not do this <a href="https://github.com/tgriesser/knex/issues/772" rel="nofollow">out of the box</a>? </p> <p>If yes, then:</p> <ul> <li>is it a good idea or bad idea to stay inside Knex for this?</li> <li>if it is an OK approach, is there a decent example of this someone can point to?</li> <li>would you be better off and have less friction if you include Bookshelf.js?</li> </ul> <p>Even Bookshelf does not come with a validation engine.</p>
1
Changing Icon Size in splash screen
<p> </p> <pre><code>&lt;item android:drawable="@color/colorIcon"/&gt; &lt;item&gt; &lt;bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /&gt; &lt;/item&gt; </code></pre> <p></p> <p>This is my code for my splash screen but the icon that is used in the splash is too small, I would like help as to how to resize the icon. Thank you.</p>
1
Could not find 'bundler' (>= 0) among 0 total gem(s) (Gem::LoadError)
<p>I'm trying to install gitlab on my vhost. It's an Ubuntu 14.04. </p> <p>The introduction tells me to run the command:</p> <pre><code>sudo -u gitlab -H bundle install --deployment --without development test postgres aws kerberos </code></pre> <p>But than I always get the error: </p> <pre><code>/usr/local/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (&gt;= 0) among 0 total gem(s) (Gem::LoadError) Checked in 'GEM_PATH=/home/gitlab/.gem/ruby/2.2.0:/usr/local/lib/ruby/gems/2.2.0', execute `gem env` for more information from /usr/local/lib/ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec' from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem' from /usr/local/bin/bundle:22:in `&lt;main&gt;' from /usr/local/bin/ruby_executable_hooks:15:in `eval' from /usr/local/bin/ruby_executable_hooks:15:in `&lt;main&gt;' </code></pre> <p>If I start bundle as root it works normally. </p> <p>I tried a lot of solutions provided in other threads like:</p> <p><a href="https://stackoverflow.com/questions/6166081/could-not-find-bundler-error">“Could not find bundler” error</a> or <a href="https://stackoverflow.com/questions/29626468/could-not-find-bundler-0-amongst-gemloaderror-with-rails-2-3-18">Could not find bundler (>= 0) amongst [] (Gem::LoadError) with rails 2.3.18</a></p> <p>and so on but nothing resloves this error. Now I have no idea what I could do. </p> <p>My system: </p> <ul> <li>Ubuntu 14.04 (x_64)</li> <li>bundler 1.11.2</li> <li>ruby 2.2.4p230</li> </ul> <p>I hope you can help me out. </p> <p>If you need any other information please let me know. </p>
1
Twitter button to share content from page
<p>I'm doing a random quote machine and need to be able to share the quote to twitter, I have the twitter button set up but can't seem to change the data-text value to have the quote on the pop-up window. I've tried adding twttr.widgets.load() but it hasn't helped, any other suggestions?</p> <p>HTML-</p> <pre><code>&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="col-xs-4 centered"&gt; &lt;button id="newQuote" class="btn btn-default"&gt;Click here for new quote&lt;/button&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div id="quote" class="col-xs-12"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div id="author" class="col-xs-4"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div id= "twitter-button" class="col-xs-12"&gt; &lt;a class="twitter-share-button"&gt; Tweet &lt;/a&gt; &lt;!--javascript for twitter button--&gt; &lt;script&gt;window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))returnt;js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,"script","twitter-wjs"));&lt;/script&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p>Javascript-</p> <pre><code>var quotes = [ ['"She got a big booty so I call her big booty"', '2Chainz'], ['"fjdkaljfdksla"', 'bhd'], ['"fdhafjdahaa"', 'fndun'], ['"fjdkfjsdkfjdsiojdsvndio\"', 'fvdsw'] ]; var quoteText = ""; $("#newQuote").click(function() { var randomNum = Math.floor(Math.random() * quotes.length); quoteText = quotes[randomNum][0] + " -" + quotes[randomNum][1] $("#quote").empty(); $("#author").empty(); $("#quote").append(quotes[randomNum][0]); $("#author").append(" -"+quotes[randomNum][1]); createButton(); }); var createButton = function () { var twtr = $(".twitter-share-button"); twtr.attr("href", "https://twitter.com/share"); twtr.removeAttr("data-text"); twtr.attr("data-text", quoteText); twttr.widgets.load(); }; </code></pre> <p>and a link to the codepen-<a href="http://codepen.io/Davez01d/pen/Ywaydd?editors=1010" rel="nofollow">http://codepen.io/Davez01d/pen/Ywaydd?editors=1010</a></p>
1
Realm: the right way to make add,update,remove operations from background thread and get results on the main thread
<p>I am using Realm for my app, i want to be able to query results on a background thread and receive them on the main thread. What is the best way to achieve this? and what is the best practice to use realm (having different method for main thread and background? and in main using a static instance of realm across the app? maybe another good way?)</p> <p>I've read and saw this options are available: - parsing the realm object to my own object and return them (kind of a copy of the results). - returning a the key of the object and querying again from main thread.</p> <p>Thanks for any help anyone can give me, i really think realm has great potential but there is a lack of good tutorials and best practices.</p>
1
Guzzle 6 progress of download
<p>I want to download a large file with Guzzle and want to track the progress. I don't know if I have to pass a stream or use the RequestMediator somehow.</p> <ul> <li>I tried with subscribing to the event curl.callback.progress, but the PSR 7 Request doesn't have an event dispatcher.</li> <li>I tried the <a href="http://docs.guzzlephp.org/en/latest/request-options.html#on-stats" rel="noreferrer">on_stats</a>, but the callback is only fired at the end.</li> <li>The progress subscriber plugin is deprecated <a href="https://github.com/guzzle/progress-subscriber" rel="noreferrer">https://github.com/guzzle/progress-subscriber</a></li> </ul> <p>I'm testing the following code.</p> <pre><code> $dl = 'http://archive.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/current/images/netboot/mini.iso'; $client = new Client([]); $request = new GuzzleHttp\Psr7\Request('get', $dl); $promise = $this-&gt;client-&gt;sendAsync($request, [ 'sink' =&gt; '/tmp/test.bin' ]); $promise-&gt;then(function (Response $resp) use ( $fs) { echo 'Finished'; }, function (RequestException $e) { }); $promise-&gt;wait(); </code></pre> <p>An hint would be appreciated.</p>
1
What is the different between kafka artifactIds kafka_2.10 and kafka-clients?
<p>What is different about the following maven dependency for Kafka 0.9 client API? </p> <p>Part 1:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt; &lt;artifactId&gt;kafka_2.10&lt;/artifactId&gt; &lt;version&gt;0.9.0.0&lt;/version&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;log4j&lt;/groupId&gt; &lt;artifactId&gt;log4j&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.scala-lang&lt;/groupId&gt; &lt;artifactId&gt;scala-library&lt;/artifactId&gt; &lt;version&gt;2.10.0&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Part 2:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt; &lt;artifactId&gt;kafka-clients&lt;/artifactId&gt; &lt;version&gt;0.9.0.0&lt;/version&gt; &lt;/dependency&gt; </code></pre>
1
after() vs update() in python
<p>i am new to python and started working with tkinter as canvas.</p> <p>up to now i used .update() to update my canvas. but there is also a .after() method. could anyone explain me this function (with an example please :) ) and is there a difference between:</p> <pre><code> root.after(integer,call_me) </code></pre> <p>and</p> <pre><code>while(True): time.sleep(integer) root.update() call_me </code></pre> <p>i have searched already and couldn't find a good explanation (and my .after examples wont work neither :( ).</p>
1
Hadoop on windows: Not a valid DFS filename
<p><strong>I have configured Hadoop 2.7.2 on Windows, I can see name node, data node, resource manager and node manager are running properly, problem occures when I try to run one of the map reduce program provided as example.</strong></p> <p>Please find below the command I am running<br><code>c:\hdp\bin\yarn jar c:\hdp\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.7.2.jar wordcount c:\hdp\LICENSE.txt /out</code></p> <p>I can see all the files are present at the desired locations. Please find below the stack trace:</p> <pre><code>C:\WINDOWS\system32&gt;c:\hdp\bin\yarn jar c:\hdp\share\hadoop\mapreduce\hadoop-map reduce-examples-2.7.2.jar wordcount c:\hdp\LICENSE.txt /out 16/02/03 16:50:55 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0 :8032 16/02/03 16:50:56 INFO mapreduce.JobSubmitter: Cleaning up the staging area /tmp /hadoop-yarn/staging/tbhakre/.staging/job_1454492091405_0006 java.lang.IllegalArgumentException: Pathname /c:/hdp/LICENSE.txt from hdfs://0.0 .0.0:19000/c:/hdp/LICENSE.txt is not a valid DFS filename. at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedF ileSystem.java:197) at org.apache.hadoop.hdfs.DistributedFileSystem.access$000(DistributedFi leSystem.java:106) at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFil eSystem.java:1305) at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFil eSystem.java:1301) at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkRes olver.java:81) at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(Distribute dFileSystem.java:1301) at org.apache.hadoop.fs.Globber.getFileStatus(Globber.java:57) at org.apache.hadoop.fs.Globber.glob(Globber.java:252) at org.apache.hadoop.fs.FileSystem.globStatus(FileSystem.java:1674) at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.singleThreadedL istStatus(FileInputFormat.java:294) at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(File InputFormat.java:265) at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileI nputFormat.java:387) at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter. java:301) at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.jav a:318) at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitt er.java:196) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1290) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1287) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInforma tion.java:1657) at org.apache.hadoop.mapreduce.Job.submit(Job.java:1287) at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1308) at org.apache.hadoop.examples.WordCount.main(WordCount.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(Progra mDriver.java:71) at org.apache.hadoop.util.ProgramDriver.run(ProgramDriver.java:144) at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.run(RunJar.java:221) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) </code></pre>
1
How to wait until Kubernetes assigned an external IP to a LoadBalancer service?
<p>Creating a <a href="http://kubernetes.io/v1.1/docs/user-guide/services.html#type-loadbalancer" rel="noreferrer">Kubernetes LoadBalancer</a> returns immediatly (ex: <code>kubectl create -f ...</code> or <code>kubectl expose svc NAME --name=load-balancer --port=80 --type=LoadBalancer</code>).</p> <p>I know a manual way to wait in shell:</p> <pre><code>external_ip="" while [ -z $external_ip ]; do sleep 10 external_ip=$(kubectl get svc load-balancer --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") done </code></pre> <p>This is however not ideal:</p> <ul> <li>Requires at least 5 lines Bash script.</li> <li>Infinite wait even in case of error (else requires a timeout which increases a lot line count).</li> <li>Probably not efficient; could use <code>--wait</code> or <code>--wait-once</code> but using those the command never returns.</li> </ul> <p>Is there a better way to wait until a service <em>external IP</em> (aka <em>LoadBalancer Ingress IP</em>) is set or failed to set?</p>
1
How to set object to AsyncState and pass it into AsyncCallback method
<p>Two questions:</p> <ol> <li><p>How do I pass arguments to the <code>AsyncCallback</code> method?</p></li> <li><p>How do I invoke the <code>AsyncCallback</code> method?</p></li> </ol> <p>Here's the background:</p> <p>I am working on an old project in .NET Framework 3.5. I want to create an async method doing some works without blocking current thread. Since the project is an old version Async Await key words are not available, I plan to do all parallel works including some database queries and api calling in AsyncCallback method. I know AsyncState can be used to convey arguments. Because I need multiple arguments, I plan to include these arguments into an object and set the object to AsyncState, so I can cast AsyncState as the object to be used in AsyncCallback method. I didn't find a good way. I've found this <a href="https://stackoverflow.com/questions/5625501/c-sharp-how-do-i-pass-more-than-just-iasyncresult-into-asynccallback">link</a>, but I don't use HttpWebRequest. </p> <pre><code> public Class ArgumentObject { public string A{get;set;} public string B{get;set;} ... } public void CallBack(IAsyncResult result, ArgumentObject arObj) { Console.WriteLn(arObj.A); Console.WriteLn(arObj.B); } </code></pre> <p>The following are the code which call the AsyncCallBack method.</p> <pre><code> var argumentsObj=new ArgumentObject{ A="argument1", B="argument2"..}; AsyncCallback callback = (IAsyncResult result) =&gt; CallBack(result, argumentsObj); // How do I know it is triggered? I set the break point into CallBack method, but it never goes to there. </code></pre> <p>Any idea or correction is appreciated.</p>
1
Why do I get, "Cannot bind to the new display member." with this code?
<p>I have this code to assign the values of a Dictionary to a combo box:</p> <pre><code>private void PopulateComboBoxWithSchedulableWeeks() { int WEEKS_TO_OFFER_COUNT = 13; BindingSource bs = new BindingSource(); Dictionary&lt;String, DateTime&gt; schedulableWeeks = GetWeekBeginningsDict(WEEKS_TO_OFFER_COUNT); bs.DataSource = schedulableWeeks; comboBoxWeekToSchedule.DataSource = bs; comboBoxWeekToSchedule.DisplayMember = "Key"; comboBoxWeekToSchedule.ValueMember = "Value"; } public static Dictionary&lt;String, DateTime&gt; GetWeekBeginningsDict(int countOfWeeks) { DateTime today = DateTime.Today; int daysUntilMonday = ((int)DayOfWeek.Monday - (int)today.DayOfWeek + 7) % 7; DateTime nextMonday = today.AddDays(daysUntilMonday); Dictionary&lt;String, DateTime&gt; mondays = new Dictionary&lt;String, DateTime&gt; (); if (!IsAssemblyOrConventionWeek(nextMonday)) { mondays.Add(nextMonday.ToLongDateString(), nextMonday); } for (int i = 0; i &lt; countOfWeeks; i++) { nextMonday = nextMonday.AddDays(7); if (!IsAssemblyOrConventionWeek(nextMonday)) { mondays.Add(nextMonday.ToLongDateString(), nextMonday); } } return mondays; } </code></pre> <p>At runtime, I get, "<em>Cannot bind to the new display member.</em>" with this code, though, on this line:</p> <pre><code>comboBoxWeekToSchedule.ValueMember = "Value"; </code></pre> <p>Why?</p>
1
Offset Right and Bottom in jquery
<p>The following code is a sample from w3schools.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $("button").click(function(){ var x = $("p").offset(); alert("Top: " + x.top + " Left: " + x.left); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;This is a paragraph.&lt;/p&gt; &lt;button&gt;Return the offset coordinates of the p element&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>it is possible to get offset right and offset bottom using jquery?</p> <p>Link : </p> <p><a href="https://jsfiddle.net/0hhxdbk5/1/" rel="nofollow">https://jsfiddle.net/0hhxdbk5/1/</a></p>
1
Make selected button titlelabel to be uppercase
<p>I have button with title "Button". After some actions this button gets "selected" status. While it is selected it have different text color that is easy to specify in interface builder. </p> <p>The problem is that I also want set it's title to be uppercase. Which I don't know how.</p>
1
how to call oracle function in mybatis
<p>I want to call Oracle function using Mybatis i tried Different way but did not get result. please solve my issue.</p> <pre><code> &lt;select id="getNo" resultType="String" parameterType="map" statementType="CALLABLE"&gt; begin #{retval, mode=OUT, jdbcType=VARCHAR} = CALL pc_sys.f_get_no ( #{notyp, mode=IN, jdbcType=VARCHAR}, #{ymdDate, mode=IN, jdbcType=DATE} ); end; &lt;/select&gt; </code></pre> <p><strong>Error Contents :</strong><br></p> <pre><code>begin ? = CALL pc_sys.f_get_no ( ?, ? ); end; java.sql.SQLException: ORA-06550: line 2, column 10: PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ; indicator ; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550: line 2, column 10: PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ; indicator. </code></pre>
1
Soft Delete Cascading with Laravel 5.2
<p>I'm trying to implement soft deleting in Laravel.</p> <p>Here are my relationships</p> <pre><code>Tournament ( hasMany ) CategoryTournament (hasOne) CategorySettings Tournament ( hasMany ) CategoryTournament (belongsToMany) CategoryTournamentUser </code></pre> <p>So, I used <a href="https://stackoverflow.com/questions/31456804/laravel-5-cascade-soft-delete">this answer</a> that help me a lot</p> <p>Now, when I SoftDelete a Tournament, all CategoryTournaments related are also deleted.</p> <p>But then, I tried to apply it recursively, so I wrote the same code in CategoryTournament Model:</p> <pre><code>static::deleting(function($categoryTournament) { $categoryTournament-&gt;settings()-&gt;delete(); $categoryTournament-&gt;users()-&gt;delete(); }); </code></pre> <p>But this code is never ran. I checked that I have settings and user to delete, but none of them are soft deleted...</p> <p>Did I miss something??? It should work!</p> <p>EDIT: </p> <p>Now, I am trying to Soft Delete a User, it is just one more level:</p> <pre><code>User (HasMany) Tournament ( hasMany ) CategoryTournament (hasOne) CategorySettings </code></pre> <p>So now, when I soft Delete user, it delete his tournaments, but it doesn't delete anymore his CategoryTournaments, so this is not a config error.</p>
1
Datepicker on codeigniter
<p>I have Datepicker that is purely working in test_datepicker.html. Here is my code:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Date Picker&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" &gt; &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $( "#datepicker" ).datepicker(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; </code></pre> <p> </p> <p>this is working, but when i sync this on my ci with php the code is not working. </p>
1
Drawing a rounded hollow thumb over arc
<p>I want to create a rounded graph that will display a range of values from my app. The values can be classified to 3 categories: low, mid, high - that are represented by 3 colors: blue, green and red (respectively). </p> <p>Above this range, I want to show the actually measured values - in a form of a "thumb" over the relevant range part:</p> <p><a href="https://i.stack.imgur.com/0o4je.png"><img src="https://i.stack.imgur.com/0o4je.png" alt="See the attached photo"></a></p> <p>The location of the white thumb over the range arc may change, according to the measured values.</p> <p>Currently, I'm able to draw the 3-colored range by drawing 3 arcs over the same center, inside the view's onDraw method:</p> <pre><code>width = (float) getWidth(); height = (float) getHeight(); float radius; if (width &gt; height) { radius = height / 3; } else { radius = width / 3; } paint.setAntiAlias(true); paint.setStrokeWidth(arcLineWidth); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStyle(Paint.Style.STROKE); center_x = width / 2; center_y = height / 1.6f; left = center_x - radius; float top = center_y - radius; right = center_x + radius; float bottom = center_y + radius; oval.set(left, top, right, bottom); //blue arc paint.setColor(colorLow); canvas.drawArc(oval, 135, 55, false, paint); //red arc paint.setColor(colorHigh); canvas.drawArc(oval, 350, 55, false, paint); //green arc paint.setColor(colorNormal); canvas.drawArc(oval, 190, 160, false, paint); </code></pre> <p>And this is the result arc:</p> <p><a href="https://i.stack.imgur.com/VdlkW.png"><img src="https://i.stack.imgur.com/VdlkW.png" alt="current arc"></a></p> <p>My question is, how do I: </p> <ol> <li>Create a smooth <strong>gradient</strong> between those 3 colors (I tried using <code>SweepGradient</code> but it didn't give me the correct result). </li> <li><p>Create the <strong>overlay white thumb</strong> as shown in the picture, so that I'll be able to control where to display it. </p></li> <li><p><strong>Animate</strong> this white thumb over my range arc.</p></li> </ol> <p>Note: the 3-colored range is static - so another solution can be to just take the drawable and paint the white thumb over it (and animate it), so I'm open to hear such a solution as well :)</p>
1
Right To Left SnackBar
<p>I want to display a <strong>text</strong> with an <strong>action</strong> on <em>Design Support Library SnackBar</em>. <br> My language is writen in Right-to-Left. So how can i change SnackBar text and action direction? <br> Something like this:<br><br></p> <p><a href="https://i.stack.imgur.com/RE4y2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RE4y2.png" alt="enter image description here"></a></p>
1
Unexpected top-level error
<p>I have been trying many solutions even enabled multiDexEnabled true, but still getting this error UNEXPECTED TOP-LEVEL ERROR. This is my build</p> <pre><code>android { compileSdkVersion 22 buildToolsVersion '22.0.1' defaultConfig { applicationId "com.xxx" minSdkVersion 11 targetSdkVersion 22 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.loopj.android:android-async-http:1.4.9' compile 'com.google.android.gms:play-services:8.1.0' compile 'com.googlecode.libphonenumber:libphonenumber:6.2' compile 'com.paypal.sdk:paypal-android-sdk:2.12.4' compile 'com.android.support:design:22.2.1' compile 'com.google.zxing:core:3.2.0' compile 'com.android.support:multidex:1.0.1' } </code></pre> <p>I am getting this Error </p> <pre><code> UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: GC overhead limit exceeded at com.android.dx.rop.code.PlainInsn.withNewRegisters(PlainInsn.java:152) at com.android.dx.ssa.NormalSsaInsn.toRopInsn(NormalSsaInsn.java:126) at com.android.dx.ssa.back.SsaToRop.convertInsns(SsaToRop.java:341) at com.android.dx.ssa.back.SsaToRop.convertBasicBlock(SsaToRop.java:322) at com.android.dx.ssa.back.SsaToRop.convertBasicBlocks(SsaToRop.java:259) at com.android.dx.ssa.back.SsaToRop.convert(SsaToRop.java:123) at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:69) at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:101) at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72) at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297) at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137) at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93) at com.android.dx.command.dexer.Main.processClass(Main.java:729) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505) at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:244) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'. &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 3 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. </code></pre> <p>What am i doing wrong here, I is it a library conflict or am i missing something here</p>
1
How to implement percentile in Hive?
<p>Can anyone please tell me ,how to implement Percentile in Hive? I tried with percentile function,but not able to get the expected result. Example code will greatly help.</p>
1
sum total of column in rdlc report footer
<p>I have dataset1 contains : ( name - price ) in rdlc report and textbox1 placed in the footer of the report. I tried to sum the total of column (price) but I get error :</p> <blockquote> <p>Severity Code Description Project File Line Suppression State Error<br> The Value expression for the text box ‘Textbox1’ references report item 'price' in an aggregate expression with a scope. A scope is not allowed on aggregates in the page header or footer which reference report items</p> </blockquote> <p>here is the expression I used :</p> <pre><code>=SUM(reportitems!price.Value, "dataset1") </code></pre> <p>how to sum the column price and show the result in textbox1 in the footer ?</p>
1
How can I run a method asynchronously in Google Apps Script?
<p>I have a function that's called by the client when some data is submitted via a form. This triggers an action that sends an email out to individuals that wish to receive notifications. The problem is that this has to be done synchronously with the form submit, so the user submitting the form has to wait for the emails to be sent before they receive the return data from Apps Script saying that the submission was successful.</p> <p>This can sometimes take several seconds. Is there a way to asynchronously run a function in apps script (So the server can return a message to the client while the emails are being sent)? </p> <p>Or even better, create an event that I can listen to similar to events in .NET?</p>
1
Set selected value in a paper-menu in Polymer 1.0
<p>I've created a custom element which utilizes <code>paper-dropdown-menu</code> and <code>paper-menu</code> in order to manage a select box in a web form. However, when trying to set the selected value through JavaScript, even though the value updates, the element in the page does not actually show the selected item in the list afterwards.</p> <p>I've looked at countless examples and tried dozens of different methods. I wasn't sure what to use as my <code>attr-for-selected</code>, but tried <code>value</code>, <code>name</code>, and <code>label</code> so far.</p> <pre><code>&lt;dom-module is="custom-listbox"&gt; &lt;template&gt; &lt;template is="dom-repeat" items="{{dropMenus}}"&gt; &lt;paper-dropdown-menu id="dropdownmenu" label="Type"&gt; &lt;paper-menu id="menu" class="dropdown-content" selected="{{selectedValue}}" attr-for-selected="label"&gt; &lt;template is="dom-repeat" items="{item}}"&gt; &lt;paper-item{{item}}&lt;/paper-item&gt; &lt;/template&gt; &lt;/paper-menu&gt; &lt;/paper-dropdown-menu&gt; &lt;/template&gt; &lt;/template&gt; &lt;script&gt; Polymer({ is: 'custom-listbox', ready: function() { var arr = ["value1", "value2", "value3"]; this.set('dropMenus', [arr]); }, properties: { selectedValue: { type: String, value: 'value1' // initially selected? ...doesn't work either. }, setSelected:function(selectedVal) { console.log(selectedVal); this.selectedValue = selectedVal; console.log(this.selectedValue); } }); &lt;/script&gt; &lt;/dom-module&gt; </code></pre> <p>Later in my app.js I try to set the selected value like so:</p> <pre><code>document.querySelector('#CustomListboxID').setSelected('value2'); </code></pre> <p>Console logs this, showing that 'value2' was passed to the element, and that within the element, this.selectedValue was properly set to 'value2'. However, again, the element does not actually update in the page. Am I missing something?</p> <pre><code>value2 value2 </code></pre> <p><strong>Edit</strong></p> <p>Many of the discussions in Stack Overflow regarding this topic are tagged as <code>Polymer</code> although it isn't always indicated whether the discussion relates to version 0.5 or 1.0, which might as well be two completely different frameworks. I'm not sure if the methods I've used above are maybe outdated, for this reason...</p> <p>It seems like I should be able to use <code>paper-menu</code>'s <code>.select(value)</code> function to set the selected value like so:</p> <pre><code>this.querySelector('#menu').select(selectedVal); </code></pre> <p>This function is documented, and I confirmed that it exists and is being imported into paper-menu from iron-menu-behavior. However, though it throws no errors, it also does nothing.</p>
1
Azure Active Directory Connection String
<p>I've been trying to set up my IIS website's connection string to connect to an Azure SQL Database with the following connection string:</p> <pre><code>&lt;add name="ConnectionString" connectionString="Server=tcp:some.database.windows.net,1433;Database=myDB;Authentication=Active Directory Integrated;" /&gt; </code></pre> <p>The IIS application pool is using a service account which has Azure Active Directory privileges and is added as an user on the Azure SQL Database.</p> <p>This works fine on my local development machine (probably because it is using my credentials and not a service account) but when I place the site on IIS I get:</p> <pre><code>System.ArgumentException: Keyword not supported: 'authentication'. </code></pre> <p>Does anyone know the correct syntax for logging in via Azure AD?</p>
1
Google Sheets Formula for Condition based on Current Month
<p>I've been struggling with this formula for a few days now. I'd like to return a specified cell based on the current month. For example: If it's January return AC5, if its February return AC6, march returns AC7, etc.</p> <p>I'm using <em>=MONTH(NOW())</em> to return the number of the month in cell T2, but just can't figure out where to go from here. Can you have more than one condition in an IF statement? I can't get past the idea that if the month equals "1" its true (so use January) but if it's false what would it do?</p> <p>Is this even possible to do in Google Sheets?</p> <p><strong>EDIT: I found a formula that works! It is long and ugly but it works correctly:</strong></p> <p>=IF(T2=1,AC5,IF(T2=2,AC6,IF(T2=3,AC7,IF(T2=4,AC8,IF(T2=4,AC9,IF(T2=5,AC9,IF(T2=6,AC10,IF(T2=7,AC11,IF(T2=8,AC12,IF(T2=9,AC13,IF(T2=10,AC14,IF(T2=11,AC15,IF(T2=12,AC16,poop)))))))))))))</p> <p>I nested the IF statement to death, but it does what I want.</p>
1
Hide userform in VBA in order to work with data
<p>I have a following problem. I would like to hide a userform in order to work with data in worksheet.</p> <p>I would like to enable user to get back to application. So I thought if there is a possibility to move userform down on the screen and activate workbook. Afterwards the user could drag userform back in the middle of the screen and work with it again.</p> <p>Does anyone have an experience with something like that?</p>
1
Check if Local User account exists and create it if it doesn't exist
<p>I'm trying to write a command line script that will check if an local user account exists and create that account if it doesn't.</p> <p>I have the two commands, but I want to put it together into a conditional check.</p> <p>Command to check if the account exists.</p> <pre><code>Net user | find /i "Username" </code></pre> <p>Here's the command to create the account.</p> <pre><code>NET USER Username {Password} /EXPIRES: NEVER /ADD </code></pre> <p>Also, I'm having problems with the /Expires switch working. When I check the account's settings it doesn't have "Password never expires" as checked.</p>
1
Mule-How to convert payload into json
<p>I have this:</p> <pre><code>{a=1, b=2, c=3}, {a2=1, b2=2, c2=3}, {a3=1, b3=2, c3=3}, </code></pre> <p>I need an output of json like this:</p> <pre><code>[{"a":"1", "b":"2", "c":"3"}, {"a2":"1", "b2":"2", "c2":"3"}, {"a3":"1", "b3:2", "c3:3"}] </code></pre> <p>How to do so in Mule CE? Any Suggestions?</p> <p>EDIT:</p> <p>I have return data from magento <code>&lt;magento:list-products/&gt;</code>, and converted the payload like this:</p> <pre><code> &lt;json:object-to-json-transformer doc:name="Object to JSON"/&gt; &lt;json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/&gt; </code></pre> <p>I had to do some filtering on that payload: used <code>&lt;foreach/&gt;</code> and for every product that fit the condition I saved in a variable like this:</p> <pre><code> &lt;set-variable variableName="productsInfoArr" value="#[flowVars.productsInfoArr.concat(flowVars.productInfo)+',']"/&gt; </code></pre> <p>so the results are as above...</p> <p>So basically the question is: how to create an array using json items?</p>
1
Setting up Microsoft Edge with Protractor (JS), Cucumber JS and Gulp - (no Java, no C#)
<p>Does anyone know how to setup the Microsoft Edge browser with Protractor?</p> <p>I'm using Protractor (Javascript) and Gulp; NOT Java or C#.</p> <p>Here's my Protractor config file:</p> <pre><code>exports.config = { framework: 'cucumber', seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/selenium/MicrosoftWebDriver.exe'], multiCapabilities: { 'browserName': 'MicrosoftEdge', javascriptEnabled=true, //'platform': 'windows', // 'version': '11' } , { 'browserName': 'chrome', loggingPrefs: { driver: 'DEBUG', server: 'INFO', browser: 'ALL' } }], } </code></pre> <p><strong><em>1. I specify the browser name which is 'MicrosoftEdge' then</em></strong><br /><br /> <strong><em>2. I thought I would point to the EdgeDriver.exe just like I did and it worked for the IE browser.</em></strong></p> <p>What else am I missing, this successfully opens up the Edge browser but fails to navigate to a URL with error </p> <pre><code>var template = new Error(this.message); ^ UnknownError: null (WARNING: The server did not provide any stacktrace information) </code></pre> <p>Has anyone successfully set up Microsoft Edge with Protractor/CucumberJS?</p>
1
AEM How to package user group and permission in AEM 6
<p>I got a problem in AEM 6.1. I created some groups in an author instance (ex: group1, group2) and assign these groups to contributor group of AEM. After that, grant some permissions (read, modify, delete in /content node) for these groups.</p> <p>I would like to package these groups (include permissions) and install into other author instance. Package node under /home/groups, /content/rep:policy and even /jcr:system/rep:permissionStore/crx.default, then install into other author instance.</p> <p>Problem: In the second author instance, only have the groups. The permissions of the groups cannot installed into this instance. Need to grant permissions again.</p> <p>Does anyone have a solution for this.</p> <p>Thank you very much.</p>
1
UIImage size in pixels
<p>Can I get the pixel size for a UIImage if I just multiply the image.size with the image.scale ? Is it the same as doing this:</p> <pre><code> guard let cgImage = image.CGImage else{ return nil } let width = CGImageGetWidth(cgImage) let height = CGImageGetHeight(cgImage) </code></pre>
1