title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
height of html with body and default margin on chrome
<p>As you might know, Chrome has a default body margin of <strong><code>8px</code></strong>.</p> <p>However, this poses an issue when I keep the margin on the body and set its height to <strong><code>100%</code></strong> (along with html at <strong><code>100%</code></strong>). It takes the height of html and places it after the top margin of <strong><code>8px</code></strong>, and ends with a bottom margin of <strong><code>8px</code></strong>. However the html size doesn't adapt to the 16 pixel difference (top 8 + bottom 8). </p> <p>I'm thinking this has to do with how the document flow works, html having its size assigned before body does, but I do not have any clue how to fix issue.</p> <p>The only way I thought I could fix this was to do <code>calc()</code> notation on the html height attribute: <code>height: calc(100% + 16px)</code> but doesn't work. If you know why it doesn't I would like to be told.</p> <p>code to replicate the issue:</p> <p>CSS</p> <pre><code>html { height: 100%; background: rgb(42,69,66); background: -webkit-linear-gradient(top, rgba(73,94,8,1) 0%, rgba(145,232,66,1) 100%) no-repeat; } body { height:100%; } .divz { background-color: olive; height: 100%; } </code></pre> <p>HTML</p> <pre><code>&lt;body&gt; &lt;div class="divz"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p><a href="https://jsfiddle.net/nd1hhz6q/" rel="nofollow">Here is a jsfiddle</a> that replicates the issue. Notice at the bottom how theres a <strong><code>16px</code></strong> spacing between the end of the page and the end of html. </p> <p><strong>EDIT:</strong> I want the margin to stay on body.</p> <p><strong>EDIT 2:</strong> another thing I attempted is to set the <code>min-height: 100%</code> to the <code>html</code>, which does do what I want but setting <code>min-height: 100%</code> to <code>body</code> doesn't work if it is set to html.</p>
1
Host Multiple Sites on Apache with same IP and Port
<p>Trying to host multiple sites from the same Ubuntu Apache box. Same IP and Same Port. The differentiation being the host header or domain address. I could do this easy with IIS but I'd like to move to Apache.</p> <p>Right now with this code, every time I do a test with these URL's. I get pointed to the 1st URL even if I try a different URL. (I assume because it's the 1st Port 80 website). Everything works fine locally if your on the desktop of the Ubuntu server but not if your on a local desktop or internet. (These are my lab domain names.)</p> <p>My www.conf file that sits in /etc/apache2/sites-available. The same conf file shows in /etc/apache2/sites-enabled</p> <pre><code>&lt;VirtualHost *:80&gt; DocumentRoot /var/www/dizydiz ServerName dizydiz.com ServerAlias www.dizydiz.com &lt;/VirtualHost&gt; ### &lt;VirtualHost *:80&gt; DocumentRoot /var/www/dizydiz2 ServerName dizzydiz.com ServerAlias www.dizzydiz.com &lt;/VirtualHost&gt; ### &lt;VirtualHost *:80&gt; DocumentRoot /var/www/squeakerkiller ServerName squeakerkiller.com ServerAlias www.squeakerkiller.com &lt;/VirtualHost&gt; ### &lt;VirtualHost *:80&gt; DocumentRoot /var/www/dizydiz_legacy1 ServerName old.dizydiz.com &lt;/VirtualHost&gt; </code></pre> <p>I am using another Ubuntu box in front of this Web box as a ProxyPass box.</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName dizydiz.com ServerAlias www.dizydiz.com ServerAlias kb.dizydiz.com ServerAlias old.dizydiz.com ServerAlias squeakerkiller.com ServerAlias www.squeakerkiller.com ServerAlias dizzdiz.com ServerAlias www.dizzydiz.com ProxyPass / http://10.10.10.18/ # ProxyPassReverse / http://10.10.10.18/ # Uncomment the line below if your site uses SSL. #SSLProxyEngine On &lt;/VirtualHost&gt; </code></pre> <p>Thoughts?</p>
1
PHP: Copy entire contents of a directory
<p><strong>Sorry for new post!</strong> I'm not yet trusted to comment on others posts.</p> <p>I'm having trouble copying folders and this is where I started: <a href="https://stackoverflow.com/a/2050909/5649888">Copy entire contents of a directory</a></p> <p><strong>Function</strong></p> <pre><code>function recurse_copy($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) &amp;&amp; ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { recurse_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); } </code></pre> <p><strong>My input</strong></p> <pre><code>$src = "http://$_SERVER[HTTP_HOST]/_template/function/"; $dst = "http://$_SERVER[HTTP_HOST]/city/department/function/"; recurse_copy($src, $dst); </code></pre> <p>I've also tried this</p> <pre><code>$src = "$_SERVER[DOCUMENT_ROOT]/_template/function/"; // And so on... </code></pre> <p>The function is executed but nothing is being copied.</p> <p>Any ideas on what might be wrong?</p> <p><strong>SOLVED</strong></p> <p><a href="https://stackoverflow.com/a/35310905/5649888">Working solution</a></p> <p>Along with</p> <pre><code>$src = "$_SERVER[DOCUMENT_ROOT]/_template/function/"; $dst = "$_SERVER[DOCUMENT_ROOT]/city/department/function/"; recurse_copy($src, $dst); </code></pre>
1
Why am I getting "error: type name is not allowed" with these spaghetti templates?
<p>I have the following code with a bit of a "spaghetti" of templates:</p> <pre><code>template &lt;typename A, typename B, typename... Args&gt; class C { /*... */ Bar&amp; getBar() { /* ... */ } public: template &lt;typename U&gt; static void Foo() { A a = getA&lt;U&gt;(); Baz&amp; bar = getBar(); bar.frob&lt;U&gt;(a); /* @@@ */ } /*... */ } /* no template */ class D : public C&lt;SomeA, D, const SomeE&amp;&gt; { /* ... */ } /* no template */ class F : public D { /* ... */} </code></pre> <p>and when I try to compile a function with the following statement:</p> <pre><code>D::Foo&lt;F&gt;(); </code></pre> <p>I get the error <code>type name is not allowed</code>, on the line marked <code>@@@</code>. Why would I be getting that? I know you get it when you try to call a function with a type name, but it doesn't look like I'm doing it here.</p>
1
Fast way to determine filtered values in a Pivot Table
<p>I need to check if a host of pivot tables are correctly filtering out the right items. Right now I am scrolling down and eye-balling to see if certain entries are excluded and nothing else. But each of my fields have 10,000+ items and it's taking forever and I am worried that I might miss something. Is there some way that I can get excel to simply list the values excluded in a Pivot table?</p> <p><a href="https://i.stack.imgur.com/7fxPs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7fxPs.jpg" alt="enter image description here"></a></p>
1
Is it possible to have two vue.js instances in different windows use the same data?
<p>I would like to be able to use two windows in my vue.js app, one for managing data, and one for presentation of the same data. (Imagine a live presentation where I can change things on the fly in one window on my laptop but my audience sees a simplified presentation of the data—ie, they don't see all the editing tools—in a separate window on a projected screen.)</p> <p>As a prototype, I've tried implementing a basic todo app, like so:</p> <pre><code>&lt;html&gt; &lt;body id="app"&gt; &lt;div id="entry-form"&gt; &lt;input type="text" placeholder="enter a todo item" v-model="todo"&gt; &lt;button v-on:click="addTodo"&gt;+&lt;/button&gt; &lt;/div&gt; &lt;div id="todo-list"&gt; &lt;ol&gt; &lt;li v-for="t in todos"&gt; &lt;span&gt;{{ t }}&lt;/span&gt;&lt;button v-on:click="delTodo"&gt;-&lt;/button&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;button v-on:click="openViewer"&gt;Viewer&lt;/button&gt; &lt;script src="vue.min.js"&gt;&lt;/script&gt; &lt;script&gt; var stateData = { todo : '', todos : [], } new Vue({ el: '#app', data: stateData, methods : { addTodo : function() { if ( this.todo ) { this.todos.push(this.todo); this.todo = ''; } }, delTodo : function(index) { this.todos.splice(index,1); }, openViewer : function() { var w = window.open("viewer.html", "viewer"); w.getStateData = function() { return stateData; } } }, }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And then a viewer.html (that is opened by the openViewer function in the above file) like so:</p> <pre><code>&lt;html&gt; &lt;body id="viewer"&gt; &lt;div id="todo-list"&gt; &lt;ol&gt; &lt;li v-for="t in todos"&gt; &lt;span&gt;{{ t }}&lt;/span&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;script src="vue.min.js"&gt;&lt;/script&gt; &lt;script&gt; window.onload = function() { new Vue({ el: "#viewer", data: getStateData() }); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This seems to get me half-way there. I can enter a few todos and click on the Viewer button, and a second window opens up showing the todos as expected. However, when I start entering new todos after opening the viewer window things start behaving strangely. The input fields get cleared upon blur, and the todo list no longer appears in the main window but it still works in the viewer window.</p> <p>Obviously I'm abusing something about the way vue.js is intended to work. Is what I'm trying to achieve possible with vue.js? If so, please inform me how this would be done in the vue.js way?</p> <p>Thanks</p>
1
Base of semilog in matplotlib
<p>What is the default logarithmic base of the <code>semilogx()</code> and <code>semilogy()</code> functions in matplotlib, when not passing any other parameters? Is it base-10, or any other base?</p>
1
Block IP from accessing Google Compute Engine instance
<p>I'm trying to block a certain IP address or range to reach my WordPress server that's configured on my Google Compute Engine server.</p> <p>I know I can block it via Apache, but even if I do my access_logs will still be filled with 403 error from requests from this IP.</p> <p>Is there any way to block the IP entirely and don't even let it reach Apache?</p> <p>Thanks in advance for any help.</p>
1
AttributeError: 'module' object has no attribute 'cm'
<p>I'm using Python2.7. This is a function from Udacity's Intro to Machine Learning course. When the function is called, a plot is shown. However, there are suppose to be colored regions shown too, and they are not shown.</p> <p>When I run the script which calls this function, the figure opens. When I close the figure, I see this message:</p> <pre><code>Traceback (most recent call last): File "your_algorithm.py", line 45, in &lt;module&gt; prettyPicture(clf, features_test, labels_test) File "e:\Projects\Udacity\Intro to Machine Learning\ud120-projects\choose_your_own\class_vis.py", line 22, in prettyPicture plt.pcolormesh(xx, yy, Z, cmap=pl.cm.seismic) AttributeError: 'module' object has no attribute 'cm' </code></pre> <p>It seemed to me like <code>cm</code> is an attribute of <code>matplotlib</code> from <a href="http://matplotlib.org/api/cm_api.html" rel="noreferrer">matplotlib cm</a>. Thus, I changed <code>pl</code> to 'plt`. This gets rid of the error message, but the colored regions still do not show up in plot. Thus, I'm less convinced this is correct.</p> <p>Why are the colored regions not showing up?</p> <p>Here is the code for the function prettyPicture:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt import pylab as pl def prettyPicture(clf, X_test, y_test): x_min = 0.0; x_max = 1.0 y_min = 0.0; y_max = 1.0 # Plot the decision boundary. For that, we will assign a color to each # point in the mesh [x_min, m_max]x[y_min, y_max]. h = .01 # step size in the mesh xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h)) Z = clf.predict(np.c_[xx.ravel(), yy.ravel()]) # Put the result into a color plot Z = Z.reshape(xx.shape) plt.xlim(xx.min(), xx.max()) plt.ylim(yy.min(), yy.max()) plt.pcolormesh(xx, yy, Z, cmap=pl.cm.seismic) # Plot also the test points grade_sig = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==0] bumpy_sig = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==0] grade_bkg = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==1] bumpy_bkg = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==1] plt.scatter(grade_sig, bumpy_sig, color = "b", label="fast") plt.scatter(grade_bkg, bumpy_bkg, color = "r", label="slow") plt.legend() plt.xlabel("bumpiness") plt.ylabel("grade") plt.savefig("test.png") </code></pre>
1
How can I implement comparable interface in go?
<p>I've recently started studying Go and faced next issue. I want to implement Comparable interface. I have next code:</p> <pre><code>type Comparable interface { compare(Comparable) int } type T struct { value int } func (item T) compare(other T) int { if item.value &lt; other.value { return -1 } else if item.value == other.value { return 0 } return 1 } func doComparison(c1, c2 Comparable) { fmt.Println(c1.compare(c2)) } func main() { doComparison(T{1}, T{2}) } </code></pre> <p>So I'm getting error</p> <pre><code>cannot use T literal (type T) as type Comparable in argument to doComparison: T does not implement Comparable (wrong type for compare method) have compare(T) int want compare(Comparable) int </code></pre> <p>And I guess I understand the problem that <code>T</code> doesn't implement <code>Comparable</code> because compare method take as a parameter <code>T</code> but not <code>Comparable</code>.</p> <p>Maybe I missed something or didn't understand but is it possible to do such thing?</p>
1
Check if SQL server service is running
<p>Currently we are facing a problem that effects system stability, our server has SQL server 2012 and for unknown reason its services stop running and that needs someone to restart it manually every single day. I have created a command in batch file to restart SQL server automatically and it works fine, however, I am looking for better command that can check if SQL server stop, just restart it, if running, just ignore. How can I do that command that ?</p> <pre><code>@ECHO OFF NET START MSSQL$SQLEXPRESS </code></pre>
1
connect external db with codeIgniter
<p>i am new in code igniter, i tried to connect with local db then successfully connected,but while connecting with external db it resulting an error</p> <pre><code>A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/2003): Can't connect to MySQL server on 'xxxxx.gridserver.com' (110) Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: /var/www/html/restapi/application/libraries/REST_Controller.php Line: 375 Function: __construct File: /var/www/html/restapi/application/controllers/Project.php Line: 26 Function: __construct File: /var/www/html/restapi/index.php Line: 292 Function: require_once </code></pre> <p>i am not familiar with mysql,</p> <p>i searched more for it, but i have no idea what they speaking about it, is there anything to do for external db connecton</p> <p>Thank you in advance!</p>
1
How do I switch between active docker-machines on OSX?
<p>Within MacOS, I have created 2 docker machines, say, dev1 and dev2. In one terminal running <code>$docker-machine active</code> shows dev1 as an active docker-machine and in the other, dev2. Now I want to switch to dev2 in the 1st terminal (without stopping/removing etc. dev1) so that I'll have dev2 in both. </p> <p>How do I do this? Thanks! </p>
1
How to get current time in milliseconds in Haxe?
<p>I need a function that returns the local time in milliseconds on the CPP target.</p> <p>I tried Haxe's <code>Date</code> class, but <code>Date.now()</code> gives me the time in seconds.</p>
1
What is the Rails way to work with polymorphic associations?
<p>I have few models in my Rails application, which are:</p> <ol> <li>User</li> <li>Photo</li> <li>Album</li> <li>Comment</li> </ol> <p>I need to make comments belog to either to <code>Photo</code> or <code>Album</code>, and obviously always belong to <code>User</code>. I'm going to use <a href="http://guides.rubyonrails.org/association_basics.html#polymorphic-associations" rel="noreferrer">polymorphic associations</a> for that.</p> <pre><code># models/comment.rb class Comment &lt; ActiveRecord::Base belongs_to :user belongs_to :commentable, :polymorphic =&gt; true end </code></pre> <p>The question is, what is the Rails way to describe <code>#create</code> action for the new comment. I see two options for that.</p> <p><strong>1. Describe the comment creation in each controller</strong></p> <p>But ths is not a DRY solution. I can make one common partial view for displaying and creating comments but I will have to repeat myself writing comments logic for each controller. So It doesn't work</p> <p><strong>2. Create new CommentsController</strong></p> <p>This is the right way I guess, but as I aware:</p> <blockquote> <p>To make this work, you need to declare both a foreign key column and a type column in the model that declares the polymorphic interface</p> </blockquote> <p>Like this:</p> <pre><code># schema.rb create_table "comments", force: :cascade do |t| t.text "body" t.integer "user_id" t.integer "commentable_id" t.string "commentable_type" t.datetime "created_at", null: false t.datetime "updated_at", null: false end </code></pre> <p>So, when I will be writing pretty simple controller, which will be accepting requests from the remote form:</p> <pre><code># controllers/comments_controller.rb class CommentsController &lt; ApplicationController def new @comment = Comment.new end def create @commentable = ??? # How do I get commentable id and type? if @comment.save(comment_params) respond_to do |format| format.js {render js: nil, status: :ok} end end end private def comment_params defaults = {:user_id =&gt; current_user.id, :commentable_id =&gt; @commentable.id, :commentable_type =&gt; @commentable.type} params.require(:comment).permit(:body, :user_id, :commentable_id, :commentable_type).merge(defaults) end end </code></pre> <p>How will I get <code>commentable_id</code> and <code>commetable_type</code>? I guess, <code>commentable_type</code> might be a model name.</p> <p>Also, what is the best way to make a <code>form_for @comment</code> from other views? </p>
1
Catching EJBTransactionRolledbackException
<p>I have problem with understanding the EJBTransactionRolledbackException.</p> <p>I have entity:</p> <pre><code>@Entity public class MyEntity { @Id @GeneratedValue private Long id; @Size(max=5) private String name; //... } </code></pre> <p>and repository which is SLSB because of ease of CMT:</p> <pre><code>@Stateless public class ExampleRepository { @PersistenceContext private EntityManager em; public void add(MyEntity me) { em.persist(me); } } </code></pre> <p>now I have test Servlet, when I simulate ConstraintViolation (too long name).</p> <pre><code>@WebServlet("/example") public class ExampleServlet extends HttpServlet { @Inject private ExampleRepository repo; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MyEntity me = new MyEntity(); me.setName("TooLongName"); try { repo.add(me); } catch(EJBTransactionRolledbackException e) { System.out.println("Exception caught"); } } } </code></pre> <p>I know that in such scenario EJB container will wrap the ConstraintViolationException so I catch the EJBTransactionRolledbackException instead. The problem is that in the console I can see my message from catch block ("Exception caught") but before that there are tons of exception logs produced (<a href="http://pastebin.com/BBT66RyB" rel="nofollow">link</a>). I don't quite understand what happened - is this exception caught or not? How to prevent all these error messages in the console in such simple scenario?</p>
1
Add content in bounce margin of ScrollView in React Native?
<p>In my app I'm using <code>&lt;ScrollView /&gt;</code> to view pages of a book scrolling horizontally. When a user gets to the end of the <code>&lt;ScrollView /&gt;</code> there is a bounce that shows a white area to the right that is only visible if the user drags the last page to the left. I want to add some text there that says "The End" vertically. How can I add content to the right of the <code>&lt;ScrollView /&gt;</code> in the bounce area?</p>
1
Codeigniter retrieve top 5 most occurring rows in column
<p>I currently am using codeigniter 3 to build a website. I have been able to build a full gallery and cart system using the database and active record. As well as a backend. I am currently now working the charts.js to build a pie graph in the backend of the 5 top sellers on the site. As well I will be making a graph for items sold by hour using the line graph. I can make the charts appear with dummy data no problem, however I am running into an issue of trying to retrieve the right data from the DB. It appears the query is going to be quite complex. </p> <p>My mysql table is named <code>order_items</code>. And in order items there is a column <code>qty</code> and a column <code>product_type</code>. Both return integers. What I need is to find which five items have sold the most quantity. Eventually I will need to add the data to my charts.js setup as follows. Anyone with advanced experience with codeigniter active record?</p> <pre><code>var pieData = [{ value : 300, color : "#F7464A", highlight : "#FF5A5E", label : "Product 1" }, { value : 125, color : "#46BFBD", highlight : "#5AD3D1", label : "Product 2" }, { value : 100, color : "#FDB45C", highlight : "#FFC870", label : "Product 3" }, { value : 40, color : "#949FB1", highlight : "#A8B3C5", label : "Product 4" }, { value : 20, color : "#4D5360", highlight : "#616774", label : "Product 5" }]; </code></pre>
1
jq: exclude object with specified key
<p>Input:</p> <pre><code>{ "name":"JSON", "good":true, "target":"yes" } { "name":"XML", "good":false } </code></pre> <p>I would like to exclude object WITHOUT key "target", as follow but NOT has:</p> <pre><code>jq -r ".| select(has(\"target\"))" </code></pre> <p>expected output:</p> <pre><code>{ "name":"XML", "good":false } </code></pre> <p>tried this:</p> <pre><code>jq -r " . | del(select(has(\"target\")))" </code></pre> <p>but there are two returned objects, one of them NULL</p> <pre><code>null { "good": false, "name": "XML" } </code></pre>
1
MPI - mpirun noticed that process... exited on signal 6
<pre><code>int proc_cnt, rank; MPI_Init(&amp;argc, &amp;argv); MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank); MPI_Comm_size(MPI_COMM_WORLD, &amp;proc_cnt); if (rank == 0) { std::vector&lt;int&gt; segment_ids = read_segment_ids(argv[kParDataIx]); std::map&lt;int, ParameterSet&gt; computed_par_sets; int buf_send[kBufMsToSlSize]; double buf_recv[kBufSlToMsSize]; MPI_Status status; int curr_segment_ix = 0; int recv_par_sets = 0; //inits workers for (int i = 1; i &lt; proc_cnt; i++) { buf_send[0] = segment_ids[curr_segment_ix++]; MPI_Send( buf_send, kBufMsToSlSize * sizeof (int), MPI_INT, i, 0, MPI_COMM_WORLD); } //sends slaves what to do and receives answers while(recv_par_sets &lt; segment_ids.size()) { //receives answer MPI_Recv(buf_recv, kBufSlToMsSize * sizeof (double), MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &amp;status); recv_par_sets++; if (curr_segment_ix &lt; segment_ids.size()) { //there are still segments to process buf_send[0] = segment_ids[curr_segment_ix++]; } else { //there is no segment to process, sends to slave termination char buf_send[0] = -1; } //sends back to source which segment to process as next MPI_Send( buf_send, kBufMsToSlSize * sizeof (int), MPI_INT, status.MPI_SOURCE, 0, MPI_COMM_WORLD); std::pair&lt;int,ParameterSet&gt; computed_seg_par_set = convert_array_to_seg_par_set(buf_recv); computed_par_sets.insert(computed_seg_par_set); } print_parameter_sets(computed_par_sets); std::cout &lt;&lt; "[Master] was termianted" &lt;&lt; std::endl; } else { int bufToSl[kBufMsToSlSize]; double bufToMs[kBufSlToMsSize]; Bounds bounds = read_bounds_file(argv[kParBoundsIx]); Config config = read_config_file(kConfigFileName); while (true) { MPI_Recv(bufToSl, kBufMsToSlSize * sizeof (int), MPI_INT, 0, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUSES_IGNORE); int segment_id = bufToSl[0]; if (segment_id == -1) { //termination character was found break; } Segment segment = read_segment(argv[kParDataIx], segment_id); std::map&lt;int, Segment&gt; segment_map; segment_map.insert(std::pair&lt;int, Segment&gt;(segment.GetId(), segment)); SimplexComputer simplex_computer(segment_map, bounds, config); ParameterSet par_set = simplex_computer.ComputeSegment(&amp;segment); convert_seg_par_set_to_array(segment_id, par_set, bufToMs); MPI_Send( bufToMs, kBufSlToMsSize * sizeof (double), MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); } std::cout &lt;&lt; "[SLAVE] " &lt;&lt; rank &lt;&lt; " was terminated" &lt;&lt; std::endl; } MPI_Finalize(); </code></pre> <p>I just don't get it. When I try to run this with mpirun and process count set to 5, all processes finish, control outputs saying that master or slave was terminated are printed, but in the end there is this statement:</p> <p>mpirun noticed that process rank 0 with PID 1534 on node Jan-MacBook exited on signal 6 (Abort trap: 6).</p> <p>What am I doing wrong? Thank you guys in advance.</p>
1
How to Use OpenCV for Java in Netbeans-Ubuntu
<p>I am trying to develop a small project in java for image keypoint recognition and matching to compare images using OpenCv library in Netbeans. i installed openCV-3.1.0 and add a New Library in netbeans named as OpenCV giving classpath<code>as "/home/shoaib/opencv-3.1.0/build/bin/opencv-310.jar"</code>. Then i right click on my netbeans project and add opencv library in "Libraries". In Run opton i gave <code>VM Options as "java -Djava.library.path="/home/shoaib/opencv-3.1.0/build/bin/opencv-310.jar"</code> also tried <code>java -Djava.library.path="/home/shoaib/opencv-3.1.0/build/bin/"</code></p> <p>when i compile my programme it compiled successfullly and shows</p> <pre><code>Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar </code></pre> <p>but when i run my java programme it gives error:</p> <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path </code></pre> <p>error is at line <code>System.loadLibrary(Core.NATIVE_LIBRARY_NAME);</code></p> <p>i googled it a lot but couldn't resolve my problem.Can anyone help me?? i am beginner to java and openCV.</p>
1
Laravel ResetsPasswords Trait
<p>Locally, I have updated this trait to do some different redirecting after the user submits the getEmail() method to request the reset password link. When pushed to production, my editions aren't there. I'm guessing this is because the ResetsPasswords trait is in the laravel framework which is installed separately from my repository on the server.</p> <p>If this is the case, what's the best way to change how this ResetsPasswords trait functions. Do I make my own and include that in the repository and just change my controller? Below is the PasswordController.</p> <p>Thanks!</p> <pre><code>&lt;?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ResetsPasswords; class PasswordController extends Controller { /* |-------------------------------------------------------------------------- | Password Reset Controller |-------------------------------------------------------------------------- | | This controller is responsible for handling password reset requests | and uses a simple trait to include this behavior. You're free to | explore this trait and override any methods you wish to tweak. | */ use ResetsPasswords; protected $redirectPath = '/main'; /** * Create a new password controller instance. * * @return void */ public function __construct() { $this-&gt;middleware('guest'); } } </code></pre> <p>Update: So, in the ResetsPasswords trait, I modify the redirect getSendResetLinkEmailSuccessResponse() method. So, do I instead just put that method in my controller (with the same name) and my edited code?</p> <pre><code>protected function getSendResetLinkEmailSuccessResponse($response) { ...modified code... } </code></pre>
1
AngularJS adding a new item and removing an existing item from a list
<p>(1) I am trying to add a new user to a list of items (userList). The functionality works, but there is an issue. I made the list 'selectable' aka.. when a user clicks on an item on the list the textboxes in my html5 code gets populated w/ values from the selected item in the list. This allows the user to edit the individual properties from the item. Right underneath the group of textboxes is my 'add new user' button..... When the app first runs, the textboxes are empty and I fill them w/ appropriate text and click the add button and the new user is appended to the list. However the issues is, when I have already selected an item, edited it... then the textboxes are still populated w/ the item values... now if I click add new user... a new user is added... but now I have duplicate users in my list.. which is fine because I can always edit one of them... However.... it looks like both the new and the old user are now somehow linked... if I edit one of them, the values in the other also change... (I hope this makes sense). I feel that because the new user was created via the selected record of the old user, somehow their indexes are related....can't seem to figure out how to create a new user without having the old user connected to it.</p> <p>(2) Deleting a user works fine, but except, the user deleted is always from the bottom of the list. I want to be able to select any item in the list and delete that specific item. I tried using something like:-</p> <pre><code>$scope.userList.splice($scope.userList.indexOf(currentUser), 1); </code></pre> <p>but to no avail.</p> <p>My Javascript:- </p> <pre><code>&lt;script type="text/javascript"&gt; function UserController($scope) { $scope.userList = [ { Name: "John Doe1", Title: "xxxx", Company: "yyyy", Place: "zzzz" }, { Name: "John Doe2", Title: "xxxx", Company: "yyyy", Place: "zzzz" }, { Name: "John Doe3", Title: "xxxx", Company: "yyyy", Place: "zzzz" }, { Name: "John Doe4", Title: "xxxx", Company: "yyyy", Place: "zzzz" } ]; $scope.selectUser = function (user) { $scope.currentUser = user; } $scope.addNew = function (currentUser) { $scope.userList.push(currentUser); $scope.currentUser = {}; //clear out Employee object } $scope.removeItem = function (currentUser) { // $scope.userList.pop(currentUser); $scope.userList.splice($scope.userList.indexOf(currentUser), 1); $scope.currentUser = {}; //clear out Employee object } } &lt;/script&gt; </code></pre> <p>My HTML:-</p> <pre><code>&lt;div class="row"&gt; &lt;div style="margin-top: 40px"&gt;&lt;/div&gt; &lt;div data-ng-app="" data-ng-controller="UserController"&gt; &lt;b&gt;Employee List&lt;/b&gt;&lt;br /&gt; &lt;br /&gt; &lt;ul&gt; &lt;li data-ng-repeat="user in userList"&gt; &lt;a data-ng-click="selectUser(user)"&gt;{{user.Name}} | {{user.Title}} | {{user.Company}} | {{user.Place}}. &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;hr&gt; &lt;div style="margin-top: 40px"&gt;&lt;/div&gt; &lt;b&gt;Selected Employee&lt;/b&gt;&lt;br /&gt; &lt;br /&gt; &lt;div style="border:dotted 1px grey; padding:20px 0 20px 0; width:40%;"&gt; &lt;div class="row" style="margin-left: 30px"&gt; &lt;div style="display: inline-block;"&gt; Name: &lt;/div&gt; &lt;div style="display: inline-block; margin-left: 35px;"&gt; &lt;input type="text" data-ng-model="currentUser.Name"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="margin-top: 20px"&gt;&lt;/div&gt; &lt;div class="row" style="margin-left: 30px"&gt; &lt;div style="display: inline-block;"&gt; Title: &lt;/div&gt; &lt;div style="display: inline-block; margin-left: 45px;"&gt; &lt;input type="text" data-ng-model="currentUser.Title"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="margin-top: 20px"&gt;&lt;/div&gt; &lt;div class="row" style="margin-left: 30px"&gt; &lt;div style="display: inline-block;"&gt; Company: &lt;/div&gt; &lt;div style="display: inline-block; margin-left: 10px;"&gt; &lt;input type="text" data-ng-model="currentUser.Company"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="margin-top: 20px"&gt;&lt;/div&gt; &lt;div class="row" style="margin-left: 30px"&gt; &lt;div style="display: inline-block;"&gt; Place: &lt;/div&gt; &lt;div style="display: inline-block; margin-left: 35px;"&gt; &lt;input type="text" data-ng-model="currentUser.Place"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;div style="margin: 2% 0 0 8%; display:inline-block"&gt; &lt;button data-ng-click="addNew(currentUser)" class="btn btn-primary" type="button"&gt;Add New Employee&lt;/button&gt; &lt;/div&gt; &lt;div style="margin: 2% 0 0 1%; display:inline-block"&gt; &lt;button data-ng-click="removeItem(currentUser)" class="btn btn-primary" type="button"&gt;Delete Employee&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;hr&gt; &lt;div style="margin-top: 40px"&gt;&lt;/div&gt; &lt;b&gt;Employee Details:&lt;/b&gt;&lt;br /&gt; &lt;br /&gt; {{currentUser.Name}} is a {{currentUser.Title}} at {{currentUser.Company}}. He currently lives in {{currentUser.Place}}. &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>* EDIT *</strong> I solved the delete user issue as:-</p> <pre><code> $scope.removeItem = function (currentUser) { if ($scope.userList.indexOf(currentUser) &gt;= 0) { $scope.userList.splice($scope.userList.indexOf(currentUser), 1); $scope.currentUser = {}; //clear out Employee object } } </code></pre> <p>and thanks to the suggestion, the add new user issue has also been resolved.</p>
1
how to make a sub navigation in html
<p>here is index.html code: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;link rel="icon" type="image/png" href="SENCOR_Logo.ico"&gt; &lt;title&gt;SENCOR&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="bg-div"&gt; &lt;img class="logo-img" src="SENCOR_Logo.jpg" width="130" height="45"&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Monitoring&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Process&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Post and Create Email/Excel&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Reports&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Re-Create Email&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Merge and Post&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Create Excel Report&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;li&gt;&lt;a href="#"&gt;Tools&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Users&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Folder Path&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Change Folder Path&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Sales&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>here are the style.css code:</p> <pre><code>body{ margin: 0; padding: 0; font-size: 15px; font-family: "Lucida Grande", "Helvetica Nueue", Arial, sans-serif; } nav { background-color: #333; border: 1px solid #333; color: #fff; display: block; margin: 0; overflow: hidden; } nav ul{ margin: 0; padding: 0; list-style: none; } nav ul li { margin: 0; display: inline-block; list-style-type: none; transition: all 0.2s; } nav &gt; ul &gt; li &gt; a { color: #aaa; display: block; line-height: 2em; padding: 0.5em 2em; text-decoration: none; } nav li &gt; ul{ display : none; margin-top:1px; background-color: #bbb; } nav li &gt; ul li{ display: block; } nav li &gt; ul li a { color: #111; display: block; line-height: 2em; padding: 0.5em 2em; text-decoration: none; } nav li:hover { background-color: #666; } nav li:hover &gt; ul{ position:absolute; display : block; } ----------- .logo-img{ position: fixed; margin: 10px 15px 15px 10px; left: 0; display:inline; } .bg-div{ background:#333; height: 50px; } .bg-div nav { position: fixed; display:inline; right: 0; } </code></pre> <p>so i wanted to have a sub menu for may navigation bar that if the mouse pointed in the nav menu the sub menu will drop down. but my code didnt work. what seem to be the problem?</p>
1
Best practice for merging solution files with project id conflicts
<p>Let's say a TFS branch was created out of some main branch which had 2 projects (FirstNewProject) but while the work was still ongoing in that branch, another branch was created (SecondNewProject) the task was finished and that other branch was merged back down.</p> <p>If we now try to merge that first branch back into the main branch from which both of these branches were branched we now have a conflict in the solution file which can apparently only be manually resolved...</p> <p>The first conflict is with <code>SccNumberOfProjects = 3</code> TFS variable which is the same in both FirstNewProject and SecondNewProject solution files but needs to be changed to <code>SccNumberOfProjects = 4</code> because when SecondNewProject was merged back down the number of projects was 3 but now that we're merging the FirstNewProject the number of projects is now 4.</p> <p>Would changing this variable manually to 4 create an invalid solution file?</p> <p>The second conflict is within Global section and it has to do with project numbering.</p> <p>SecondNewProject added these lines to solution file:</p> <pre><code>SccProjectUniqueName3 = SecondNewProject\\SecondNewProject.csproj SccProjectName3 = SecondNewProject SccLocalPath3 = SecondNewProject </code></pre> <p>FirstNewProject added these lines to solution file:</p> <pre><code>SccProjectUniqueName3 = FirstNewProject\\FirstNewProject.csproj SccProjectName3 = FirstNewProject SccLocalPath3 = FirstNewProject </code></pre> <p>But FirstNewProject is now 4th project so should we change these entries to </p> <pre><code>SccProjectUniqueName4 = FirstNewProject\\FirstNewProject.csproj SccProjectName4 = FirstNewProject SccLocalPath4 = FirstNewProject </code></pre> <p>manually and will that make the solution file invalid and is there anything else to be done when merging back down in a situation like this one?</p>
1
Catching Exceptions from library using Laravel 5.2
<p>Pretty new to laravel, so I'm not exactly sure how it handles errors and how best to catch them.</p> <p>I'm using a 3rd party game server connection library that can query game servers in order to pull data such as players, current map etc..</p> <p>This library is called Steam Condenser : <a href="https://github.com/koraktor/steam-condenser" rel="nofollow">https://github.com/koraktor/steam-condenser</a></p> <p>I have imported this using composer in my project and all seems to be working fine, however I'm having trouble with catching exceptions that are thrown by the library.</p> <p>One example is where the game server you are querying is offline.</p> <p>Here is my code:</p> <pre><code>public function show($server_name) { try{ SteamSocket::setTimeout(3000); $server = server::associatedServer($server_name); $server_info = new SourceServer($server-&gt;server_ip); $server_info-&gt;rconAuth($server-&gt;server_rcon); $players = $server_info-&gt;getPlayers(); $total_players = count($players); $more_info = $server_info-&gt;getServerInfo(); $maps = $server_info-&gt;rconExec('maps *'); preg_match_all("/(?&lt;=fs\)).*?(?=\.bsp)/", $maps, $map_list); }catch(SocketException $e){ dd("error"); } return view('server', compact('server', 'server_info', 'total_players', 'players', 'more_info', 'map_list')); } </code></pre> <p>If the server is offline, it will throw a SocketException, which I try to catch, however this never seems to happen. I then get the error page with the trace.</p> <p>This causes a bit of a problem as I wish to simply tell the end user that the server is offline, however I cannot do this if I can't catch this error.</p> <p>Is there something wrong with my try/catch? Does laravel handle catching errors in this way? Is this an issue with the 3rd party library?</p>
1
reCaptcha ERROR: Invalid domain for site key in Google Server
<p>i get recaptcha, put my domain.com.ar and get a key</p> <p>i use this code</p> <p>Code.gs</p> <pre><code>function doGet() { var t = HtmlService.createTemplateFromFile('Index') return t.evaluate().setTitle("Contacto de Usuarios").setSandboxMode(HtmlService.SandboxMode.IFRAME); } function include(filename) { return HtmlService.createHtmlOutputFromFile(filename) .getContent(); } function processForm(formObject) { var userCompleto = formObject.userCompleto; var Email = formObject.Email; var Movil = formObject.Movil; var Mensaje = formObject.Mensaje var captcha = formObject.g-recaptcha-response var captcha1 = formObject.g-recaptcha Logger.log(userCompleto+Email+Movil+captcha) //etc code ........ } </code></pre> <p>Index.htm</p> <pre><code> &lt;form id="myForm2" action="?" method="post" &gt; &lt;input type="text" name="userCompleto" value="" class="ss-q-short" id="userCompleto" size="30"&gt; &lt;input type="text" name="Email" value="" class="ss-q-short" id="Email" size="30"&gt; &lt;input type="text" name="Movil" value="" class="ss-q-short" id="Movil" size="30"&gt; &lt;textarea rows="4" cols="50" name="Mensaje" value="" class="ss-q-short" id="Mensaje" size="30" &gt; &lt;div id= "example2"&gt;&lt;/div&gt; &lt;input type="button" value="Comunicate" id="comunica" name="comunica" style="height: 30px" onclick="validateForm2()" /&gt; &lt;/form&gt; &lt;?!= include('JavaScript'); ?&gt; </code></pre> <p>JavaScript.htm</p> <pre><code> &lt;script type="text/javascript"&gt; var onloadCallback = function() { var widgetId2 = grecaptcha.render(document.getElementById('example2'), { 'sitekey' : '6LeDlhUTAAAAAMbdjlTLHDzA8MMb_pQS6epqgLHs' }); }; &lt;/script&gt; &lt;script src="https://www.google.com/recaptcha/api.js onload=onloadCallback&amp;render=explicit" async defer&gt; &lt;/script&gt; &lt;script type='text/javascript' &gt; function validateForm2(){ //..validation var objDatosGuardar = document.getElementById("myForm2") google.script.run.processForm2(objDatosGuardar); }; &lt;/script&gt; </code></pre> <p>trow a ERROR ERROR: Invalid domain for site key</p> <p>I try change de key for the captcha and nothing I try to put in the key new domains like 127.0.0.0 I dont get Looger.log nothing</p> <p>Please Help</p>
1
How to put google map API in codeigniter?
<p>I got my library from </p> <blockquote> <p><a href="http://biostall.com/codeigniter-google-maps-v3-api-library" rel="nofollow">http://biostall.com/codeigniter-google-maps-v3-api-library</a></p> </blockquote> <p>and followed the instructions in </p> <blockquote> <p><a href="http://biostall.com/demos/google-maps-v3-api-codeigniter-library/" rel="nofollow">http://biostall.com/demos/google-maps-v3-api-codeigniter-library/</a></p> </blockquote> <p>but i am receiving an error message </p> <p>A PHP Error was encountered</p> <pre><code>Severity: 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP; Googlemaps has a deprecated constructor Filename: libraries/Googlemaps.php Line Number: 16 Backtrace: File: C:\xampp\htdocs\test_map\application\controllers\Welcome.php Line: 25 Function: library File: C:\xampp\htdocs\test_map\index.php Line: 292 Function: require_once </code></pre> <p>Anyone knows how to solve this problem?</p>
1
Is the order of results of re.findall guaranteed?
<p>Will the list of matches returned by <code>re.findall</code> always be in the same order as they are in the source text?</p>
1
How to inject upgraded Angular 1 service/factory to Angular 2 component in ES5?
<p>I have an Angular1 service with name, say, 'myService'</p> <p>I then upgraded it using the Angular2 UpgradeAdapter like this:</p> <pre><code>var upgradeAdapter = new ng.upgrade.UpgradeAdapter(); upgradeAdapter.upgradeNg1Provider('myService'); </code></pre> <p>Now I need to inject it to the angular2 component. Official upgrade guide only has typescript version for now. In typescript you use @Inject anotation with the service name for it like so:</p> <pre><code>export class MyComponent { constructor(@Inject('myService') service:MyService) { ... } } </code></pre> <p>What is the syntax for injecting a service by name using ES5?</p>
1
Set ValidateAntiForgeryToken attribute to GET/POST for same action MVC5
<p>My question is very straight forward...</p> <p>I have an <code>Action</code> which accepts both <code>HttpGet</code> and <code>HttpPost</code>, but I want to set <code>ValidateAntiForgeryToken</code> attribute to the action when the http request is <code>POST</code>, not for <code>HttpGet</code>. </p> <p>I can find whether the request is <code>GET</code> or <code>POST</code> inside the action, but I need to know before the action called.</p> <pre><code> [ValidateAntiForgeryToken] // Only for HttpPost public ActionResult Index() // Allows HttpPost / HttpGet { } </code></pre> <p>Is there any possibilities to achieve this without duplicating the action?</p> <p>Thank you</p>
1
Fill specific Y Range with different color in Line Chart using MP Android Chart Library?
<p>I am new to MP Android Chart, and I am not able to figure out, how to fill specific Y Range with different color. Highlighted in screenshot as point 2.</p> <p>Also after reading function documentation I am trying to change line color highlighted in point 1, and fill area under graph with some color point 3. But point 1 and point 3 are not working, and I couldnt figure out how point 2 can be done.Screenshot and code attached.<a href="https://i.stack.imgur.com/u2O7g.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u2O7g.jpg" alt="Screenshot"></a></p> <pre><code>public class LineChartActivity extends AppCompatActivity { private static final String TAG = "Test"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_line_chart); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Log.i(TAG, "Line Chart Activity Created"); LineChart chart = (LineChart) findViewById(R.id.chart); LineData data = new LineData(getXAxisValues(), getDataSet()); chart.setData(data); setXAxis(chart); chart.getAxisRight().setDrawLabels(false); //chart.setAutoScaleMinMaxEnabled(true); chart.setGridBackgroundColor(128); chart.setBorderColor(255); chart.setDrawGridBackground(false); //chart.setBackgroundColor(0); chart.getLegend().setEnabled(false); chart.setPinchZoom(true); chart.setDescription(""); chart.setTouchEnabled(true); chart.setDoubleTapToZoomEnabled(true); chart.animateXY(2000, 2000); chart.invalidate(); } private ArrayList&lt;ILineDataSet&gt; getDataSet() { ArrayList&lt;ILineDataSet&gt; dataSets = null; ArrayList&lt;Entry&gt; valueSet1 = new ArrayList&lt;&gt;(); Entry v1e1 = new Entry(110.000f, 0); valueSet1.add(v1e1); Entry v1e2 = new Entry(40.000f, 4); valueSet1.add(v1e2); Entry v1e3 = new Entry(60.000f, 5); valueSet1.add(v1e3); Entry v1e4 = new Entry(30.000f, 6); valueSet1.add(v1e4); Entry v1e5 = new Entry(90.000f, 7); valueSet1.add(v1e5); Entry v1e6 = new Entry(100.000f, 8); valueSet1.add(v1e6); LineDataSet lineDataSet1 = new LineDataSet(valueSet1, "Brand 1"); int[] colors = new int[] {R.color.red ,R.color.red, R.color.orange ,R.color.green, R.color.orange, R.color.red }; lineDataSet1.setCircleColors(colors, this); lineDataSet1.setCircleRadius(8f); lineDataSet1.setLineWidth(3f); lineDataSet1.setValueTextSize(20f); lineDataSet1.enableDashedLine(6f, 18f, 0); dataSets = new ArrayList&lt;&gt;(); dataSets.add(lineDataSet1); return dataSets; } private ArrayList&lt;String&gt; getXAxisValues() { ArrayList&lt;String&gt; xAxis = new ArrayList&lt;&gt;(); xAxis.add("JAN"); xAxis.add("FEB"); xAxis.add("MAR"); xAxis.add("APR"); xAxis.add("MAY"); xAxis.add("JUN"); xAxis.add("JUL"); xAxis.add("AUG"); xAxis.add("SEPT"); xAxis.add("OCT"); xAxis.add("NOV"); xAxis.add("DEC"); return xAxis; } private void setXAxis(LineChart chart){ XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextSize(10f); xAxis.setTextColor(Color.BLUE); //xAxis.setDrawGridLines(true); xAxis.setDrawAxisLine(true); } } </code></pre> <p>Many Thanks ! Ankit </p>
1
Navigation with only Back Button and transparent background
<p>I had tried to implement Navigation Controller which embeds in my View Controller. It works as expected. </p> <p>But my requirement is slightly different which needs only a back button and already have a top banner with logo image background in all the screens . So if I try to implement back button it takes the space for the navigation bar which covers the Logo/top banner. </p> <p>Is there any way to overcome this scenario . </p>
1
Rqc package error: "GhostScript was not found"
<p>I'm following the <a href="http://bioconductor.org/packages/release/bioc/vignettes/Rqc/inst/doc/Rqc.html" rel="nofollow noreferrer">Rqc package documentation</a> so i typed the following :</p> <pre><code>library(Rqc) folder &lt;- system.file(package = &quot;ShortRead&quot;, &quot;extdata/E-MTAB-1147&quot;) rqc(path = folder, pattern = &quot;.fastq.gz&quot;) </code></pre> <p>but i'm getting the following error :</p> <blockquote> <p>Error in bitmap(file = filename, width = width, height = height, res = 300) : GhostScript was not found</p> </blockquote>
1
Error using babel-relay-plugin
<p>I stumbled upon an error while using babel-relay-plugin.</p> <p>When I require babel-relay-plugin module and export the output with my graphql schema and call it in my webpack list of babel plugins as a path works.</p> <pre><code>// webpack/plugins/babel-relay-plugin.js var babelRelayPlugin = require('babel-relay-plugin'); var schema = require('./../../cloud/data/schema.json'); module.exports = babelRelayPlugin(schema.data); // webpack/pro.config.js module.exports = [ { module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: { plugins: [ './webpack/plugins/babel-relay-plugin' ] } } ] } } ] </code></pre> <p>But when I create the plugin in the same file as this:</p> <pre><code>// webpack/pro.config.js var BabelRelayPlugin = require('babel-relay-plugin'); var schema = require('./../cloud/data/schema.json').data; module.exports = [ { name: 'server', target: 'node', devtool: 'cheap-module-source-map', entry: cloudPath, output: { path: buildPath, filename: 'index.js' }, module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: { plugins: [ new BabelRelayPlugin(schema) ] } } ] } } ] </code></pre> <p>It throws this error stack:</p> <pre><code>ERROR in ./cloud/index.js Module build failed: TypeError: Cannot read property '__esModule' of null at Function.normalisePlugin (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:156:20) at /Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:197:30 at Array.map (native) at Function.normalisePlugins (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20) at OptionManager.mergeOptions (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36) at OptionManager.init (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:416:10) at File.initOptions (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/index.js:191:75) at new File (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/file/index.js:122:22) at Pipeline.transform (/Users/AJ/Desktop/winebox/app/node_modules/babel-core/lib/transformation/pipeline.js:42:16) at transpile (/Users/AJ/Desktop/winebox/app/node_modules/babel-loader/index.js:14:22) at Object.module.exports (/Users/AJ/Desktop/winebox/app/node_modules/babel-loader/index.js:88:12) </code></pre> <p>Any pointers as to how fix this inside the same file would be awesome. Thanks in advance.</p> <p>All my packages are up-to-date an I already asked and it's not a Relay-side problem.</p>
1
Generic insertionSort using a Comparator object as a parameter?
<p>If I'm given this method header: </p> <pre><code>/** * This generic method sorts the input array using an insertion sort and the input Comparator object. */ public static &lt;T&gt; void insertionSort(T[] array , Comparator&lt;? super T&gt; comparatorObj){ // Implement method } </code></pre> <p>For the <code>Comparator&lt;? super T&gt; comparatorObj</code> part in the parameter, am I suppose to be making a comparator object method that tells how it should be comparing when it's used in the insertionSort parameter?</p>
1
CISC and RISC architectures
<p>I read a lot about the difference between CISC and RISC architectures from different sources. One of the things that seemed to be agreed upon is that CISC is always used with Von Neumann whereas RISC is used with Harvard architecture. But I couldn't quite grasp the reason behind this classification.</p>
1
Display results of join query in blade
<p>I'm having a bit of a struggle displaying results from a query in a blade template. The basics: I have two tables; countries and issuers. The Country model has a hasMany relation to Issuer, and vice versa. Both relations are properly defined in the models. I am trying to display a list of issuers that contains the name (nation) of the country as well. My query, in the IssuersController, is as follows: </p> <pre><code> $issuers = ISSUER::join('countries', 'issuers.country_id', '=', 'countries.id') -&gt;select('issuers.*', 'countries.nation') -&gt;orderBy('nation', 'asc') -&gt;orderBy('author', 'asc') -&gt;get(); </code></pre> <p>This query works and dd(); shows it returning an array for each issuer that includes all of the issuer data as well as the corresponding country name as nation. Perfect. However, when I attempt to display this in my view I run into a wall. My first attempt was to just use </p> <pre><code> @foreach($issuers as $issuer) &lt;tr&gt; &lt;td&gt;{{ $issuer-&gt;id }}&lt;/td&gt; &lt;td&gt;{{ $issuer-&gt;nation }}&lt;/td&gt; &lt;td&gt;{{ $issuers-&gt;author }}&lt;/td&gt; </code></pre> <p>This returns an undefined variable on $nation. I'm not sure why this happens as I'm not attempting to access the relationship. I'm simply trying to access the results of an array that was returned from the query. The relationship should not be relevant at that point. Anyway, attempting to use the relationship I try </p> <pre><code> @foreach($issuers as $issuer) &lt;tr&gt; &lt;td&gt;{{ $issuer-&gt;id }}&lt;/td&gt; @foreach($issuer-&gt;nation as $nation) &lt;td&gt;{{ $issuer-&gt;nation }}&lt;/td&gt; @endforeach &lt;td&gt;{{ $issuers-&gt;author }}&lt;/td&gt; </code></pre> <p>Which returns and invalid argument supplied in foreach() error. Next I attempt to use the method...</p> <pre><code> @foreach($issuers as $issuer) &lt;tr&gt; &lt;td&gt;{{ $issuer-&gt;id }}&lt;/td&gt; @foreach($issuer-&gt;Country() as $nation) &lt;td&gt;{{ $issuer-&gt;nation }}&lt;/td&gt; @endforeach &lt;td&gt;{{ $issuers-&gt;author }}&lt;/td&gt; </code></pre> <p>This throws no error but also returns nothing. The colum is simply skipped and everything else that is echoed gets shifted one column to the left. </p> <p>I'm sort of lost here and I think it's because my brain is stubbornly holding on to the idea that I'm accessing elements of a query result rather than elements of a relationship, so I can't quite figure out why I need a separate loop for that one column, or how that loop should work. Any help would be appreciated.</p> <p>EDIT: Changed the last part because I typed it wrong.</p>
1
how do I use Artemis with Camel Java DSL using the camel-jms component?
<p>Right now I'm using JMS 2.0 with Artemis 1.2.0 on a Java EE 7 application and I would like to do some integration tasks with Camel.</p> <p>Right now checking the camel-jms documentation, there is no mention whatsoever on how to use the generic camel JMS component to produce and consume messages to any JMS 2.0 compliant broker.</p> <p>The only example on <a href="http://camel.apache.org/jms.html" rel="noreferrer">the component documentation</a> is configuring an ActiveMQ connection factory with its specialized ActiveMQ component using the Spring DSL. How can I configure a connection for Camel JMS to connect to my Artemis instance?</p> <p>Take into account that even though Artemis is compatible with ActiveMQ 5.x, I'm going to use a Camel route to publish and subscribe to shared durable topics, so I need to be able to configure an Artemis connection and do a publisher and a shared durable subscriber with it (only supported in JMS 2.0, ActiveMQ only supports JMS 1.1).</p> <p>Thanks!</p>
1
Vertica: Subquery OR and co related tables error
<p><strong>Model Data</strong></p> <p><img src="https://i.stack.imgur.com/vuqlO.jpg" /></p> <p><strong>Revenue Table</strong></p> <p><img src="https://i.stack.imgur.com/2YSJQ.jpg" /></p> <p>I'm trying to find out my model performance that is I had given a score of 0.001 for a Product Category A in the model_month of May (5) for the Model_year(2015) now to track the performance i'm tracking the revenue. </p> <p>I claim to say that the model numbers are valid for 3 months so to check the performance i want to see a new coloumn next to model table with 3 months revenue after the model_month. </p> <pre><code>SELECT a.*, case when (a.MODEL_MONTH&lt;10 ) then (select sum(b.net_revenue) from Revenue as b where ((b.cal_month &gt; a.MODEL_MONTH OR b.cal_month&lt;a.MODEL_MONTH+4) AND b.cal_year=a.MODEL_YEAR) and a.model_BU=b.prodcat a.model_region=b.hp_region) when (a.MODEL_MONTH&gt;=10) then (select sum(b.net_revenue) from Revenue b where (((b.cal_month &gt; a.MODEL_MONTH and b.cal_year=a.MODEL_YEAR) || (b.cal_month &lt; a.MODEL_MONTH-9 and b.cal_year=a.MODEL_YEAR+1)) AND a.model_BU=b.prodcat)) ELSE '0' END as Net_Revenue FROM ModelData as a limit 10 ; </code></pre> <p>i'm getting errors as Error: [Vertica]VJDBC ERROR: Non-equality correlated subquery expression is not supported SQLState: HY000 ErrorCode: 4160</p>
1
Add error message to field with codeigniter form_validation
<p>With Codeigniter you can validate forms with the form_validation library. However I don't use this all the time but I like to use the <code>form_error('fieldname')</code> function.</p> <p>Is it possible to push a error message to a field manually without doing <code>form_validation-&gt;run()</code>.</p>
1
Android EditText bottom line color and theme changes
<p>hello all i need to remove the edittext default style <a href="https://i.stack.imgur.com/XyFmP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XyFmP.png" alt="from this image"></a> i want to remove the selected portion from both the side on focus of edittext or on normal edittext i just want the simple black line on normal edittext and blue line on focus </p> <p>I have created 1 xml:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true"&gt;&lt;shape android:shape="line"&gt; &lt;!-- Draw a 2dp width border around shape --&gt; &lt;stroke android:width="1dp" android:color="@color/blue" /&gt; &lt;/shape&gt; &lt;!-- Overlap the left, top and right border using background color --&gt; &lt;item android:bottom="1dp" &gt; &lt;shape android:shape="rectangle"&gt; &lt;solid android:color="@color/white"/&gt; &lt;/shape&gt; &lt;/item&gt; &lt;!-- pressed --&gt; &lt;/item&gt; &lt;item android:state_focused="true"&gt;&lt;shape android:shape="rectangle"&gt; &lt;!-- Draw a 2dp width border around shape --&gt; &lt;stroke android:width="1dp" android:color="@color/blue" /&gt; &lt;/shape&gt;&lt;/item&gt; &lt;!-- focused --&gt; &lt;item&gt;&lt;shape android:shape="rectangle"&gt; &lt;!-- Draw a 2dp width border around shape --&gt; &lt;stroke android:width="1dp" android:color="@color/orange" /&gt; &lt;/shape&gt;&lt;/item&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p>but it giving me RECTANGLE i just want LINE @bottom </p>
1
How to map predicted values to unique id in dataset?
<p>I have written this R code to reproduce. Here, I have a created a unique column "ID", and I am not sure how to add the predicted column back to test dataset mapping to their respective IDs. Please guide me on the right way to do this.</p> <pre><code>#Code library(C50) data(churn) data=rbind(churnTest,churnTrain) data$ID&lt;-seq.int(nrow(data)) #adding unique id column rm(churnTrain) rm(churnTest) set.seed(1223) ind &lt;- sample(2,nrow(data),replace = TRUE, prob = c(0.7,0.3)) train &lt;- data[ind==1,1:21] test &lt;- data[ind==2, 1:21] xtrain &lt;- train[,-20] ytrain &lt;- train$churn xtest &lt;- test[,-20] ytest&lt;- test$churn x &lt;- cbind(xtrain,ytrain) ## C50 Model c50Model &lt;- C5.0(churn ~ state + account_length + area_code + international_plan + voice_mail_plan + number_vmail_messages + total_day_minutes + total_day_calls + total_day_charge + total_eve_minutes + total_eve_calls + total_eve_charge + total_night_minutes + total_night_calls + total_night_charge + total_intl_minutes + total_intl_calls + total_intl_charge + number_customer_service_calls,data=train, trials=10) # Evaluate Model c50Result &lt;- predict(c50Model, xtest) table(c50Result, ytest) #adding prediction to test data testnew = cbind(xtest,c50Result) #OR predict directly xtest$churn = predict(c50Model, xtest) </code></pre>
1
XSLT to remove non-ASCII
<p>I need to modify XML document with XSLT. I would like to replace all non-ASCII characters by space.</p> <p><strong>Example input:</strong> </p> <pre><code>&lt;input&gt;azerty12€_étè&lt;/input&gt; </code></pre> <p>Only these characters are allowed :</p> <pre><code>!"#$%&amp;'()*+,-./0123456789:;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ </code></pre> <p><strong>Expected output:</strong></p> <pre><code> &lt;input&gt;azerty12 _ t &lt;/input&gt; </code></pre>
1
ReportViewer column group page break
<p>I need to generate a daily employee attendance report using ASP.NET ReportViewer. It must be grouped by month, meaning I have to set page break based on the <code>monthName</code> field. </p> <p>I come up with the following design in my RDLC report:</p> <p><a href="https://i.stack.imgur.com/JaNqM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JaNqM.png" alt="enter image description here"></a></p> <p>The result is: <a href="https://i.stack.imgur.com/0KgKZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KgKZ.png" alt="enter image description here"></a></p> <p>At first, everything is fine. The first page shows the attendance for the month of January, from Jan. 1 to 31. Clicking on the "Next Page" button on the report shows the employee attendance record for the next month (i.e. February.) </p> <p>But employees can be quite numerous thus it is better to be rendered as a row instead of as a column. No problem. I can just redesign the report and again, set the page break to <code>[monthName]</code> such as:</p> <p><a href="https://i.stack.imgur.com/bosdw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bosdw.png" alt="enter image description here"></a></p> <p>To my surprise, it doesn't work. I found out in MSDN that <strong>page break is not allowed in column group</strong>!</p> <p>My question is:</p> <ol> <li><p>What's the problem with setting column group page breaks? Why did <em>they</em> set this limitation?</p></li> <li><p>What's the workaround to accomplish this? I'm sure you people have also tried to accomplish the same task and succeed.</p></li> </ol>
1
Number of mappers while doing distcp
<p>How can I set the number of mappers to do distcp job? I know that we can set the max number of mappers by doing Hadoop <code>distcp -m</code>. But is it possible to set the number instead of the maximum number of mappers?</p> <p>Thanks</p>
1
Convert a JavaRDD String to JavaRDD Vector
<p>I'm trying to load a csv file as a JavaRDD String and then want to get the data in JavaRDD Vector</p> <pre><code>import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.Function; import org.apache.spark.mllib.feature.HashingTF; import org.apache.spark.mllib.linalg.Vector; import org.apache.spark.mllib.linalg.Vectors; import org.apache.spark.mllib.regression.LabeledPoint; import org.apache.spark.mllib.stat.MultivariateStatisticalSummary; import org.apache.spark.mllib.stat.Statistics; import breeze.collection.mutable.SparseArray; import scala.collection.immutable.Seq; public class Trial { public void start() throws InstantiationException, IllegalAccessException, ClassNotFoundException { run(); } private void run(){ SparkConf conf = new SparkConf().setAppName("csvparser"); JavaSparkContext jsc = new JavaSparkContext(conf); JavaRDD&lt;String&gt; data = jsc.textFile("C:/Users/kalraa2/Documents/trial.csv"); JavaRDD&lt;Vector&gt; datamain = data.flatMap(null); MultivariateStatisticalSummary mat = Statistics.colStats(datamain.rdd()); System.out.println(mat.mean()); } private List&lt;Vector&gt; Seq(Vector dv) { // TODO Auto-generated method stub return null; } public static void main(String[] args) throws Exception { Trial trial = new Trial(); trial.start(); } } </code></pre> <p>The program is running without any error but i'm not able to get anything when trying to run it on spark-machine. Can anyone tell me whether the conversion of string RDD to Vector RDD is correct.</p> <p>My csv file consist of only one column which are floating numbers</p>
1
Websocket protocol request header and response header no content type
<p>I am using Websocket protocol, but when I check the request and response content, I find there is no "Content-Type" in the header, which exists in the HTTP protocol.</p> <p>Here is what I get from Google Developer Tools:</p> <pre><code>General Request URL:ws://127.0.0.1:8080/websocket/websocket2 Request Method:GET Status Code:101 Switching Protocols Request Headers Cache-Control:no-cache Connection:Upgrade Host:127.0.0.1:8080 Origin:http://127.0.0.1 Pragma:no-cache Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits Sec-WebSocket-Key:6iABBFrV7sdwS4Dz9rqkXw== Sec-WebSocket-Version:13 Upgrade:websocket User-Agent: ... Chrome/32.0.1700.102 Safari/537.36 Response Headers Connection:Upgrade Sec-WebSocket-Accept:L6wqtsHk6dzD+kd9NCYT6Wt7OCU= Sec-WebSocket-Extensions:permessage-deflate;client_max_window_bits=15 Server:Apache-Coyote/1.1 Upgrade:WebSocket </code></pre> <p>In the Request headers and Response Headers sections, there is no "Content-Type".</p> <p>Is this normal in Websocket protocol?</p> <p>Thanks.</p>
1
Google Maps in React-Native (iOS)
<p>My goal is to display a Google Map in React Native. I have seen examples that use the Google Maps SDK with an UIMapView or a MapBox map, but that is not what I am looking for.</p> <p>I currently have no errors. Here is my code:</p> <p>index.ios.js</p> <pre><code>'use strict'; import React, { AppRegistry, Component, StyleSheet, Text, View } from 'react-native'; import GoogleMaps from './ios/GoogleMaps.js'; class RCTGoogleMaps extends Component { constructor(props) { super(props); } render() { return ( &lt;View style={styles.container}&gt; &lt;GoogleMaps style={styles.map}/&gt; &lt;/View&gt; ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF' }, map: { height: 500, width: 300, marginLeft: 50 } }); AppRegistry.registerComponent('RCTGoogleMaps', () =&gt; RCTGoogleMaps); </code></pre> <p>ios/GoogleMaps.js</p> <pre><code>var {requireNativeComponent} = require('react-native'); module.exports = requireNativeComponent('RCTGoogleMapViewManager', null); </code></pre> <p>ios/RCTGoogleMapViewManager.h</p> <pre><code>#ifndef RCTGoogleMapViewManager_h #define RCTGoogleMapViewManager_h #import &lt;Foundation/Foundation.h&gt; #import "RCTViewManager.h" #import &lt;UIKit/UIKit.h&gt; @interface RCTGoogleMapViewManager : RCTViewManager&lt;UITextViewDelegate&gt; @end #endif /* RCTGoogleMapViewManager_h */ </code></pre> <p>ios/GoogleMapViewManager.m</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "RCTGoogleMapViewManager.h" #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "UIView+React.h" @import GoogleMaps; @implementation RCTGoogleMapViewManager RCT_EXPORT_MODULE() - (UIView *)view { GMSMapView *mapView_; // Create a GMSCameraPosition that tells the map to display the // coordinate -33.86,151.20 at zoom level 6. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; UIView *newView_ = mapView_; //self.view = mapView_; // Creates a marker in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); marker.title = @"Sydney"; marker.snippet = @"Australia"; marker.map = mapView_; return newView_; } RCT_EXPORT_VIEW_PROPERTY(text, NSString) @end </code></pre> <p>There is a red border around the component, but nothing displays inside. I am new to React Native and new to StackOverflow. Unfortunately, they will not let me upload a screenshot until I have more reputation.</p> <p>There is one line I suspect to be off, but have no idea what to change it to. Line #8 in RCTGoogleMapViewManager.h says, "@interface RCTGoogleMapViewManager : RCTViewManager". I have used UITextViewDelegates for other custom components, but this map is not a TextView. That might be it, but I have no clue.</p> <p>Any help at all would be appreciated.</p>
1
Click button from another page - HTML
<p>What i need to do:</p> <p>page.com/index have a button, this button need to click Example from page.com/PageWhereThereIsExample</p> <pre><code>&lt;li class="filter" data-filter=".color-1"&gt;&lt;a href="#0" data-type="color-1"&gt;Example&lt;/a&gt;&lt;/li&gt; </code></pre> <p>Is possible to "click" Example or something similar using URL?</p> <p>Filter template: <a href="https://codyhouse.co/demo/content-filter/index.html" rel="nofollow">https://codyhouse.co/demo/content-filter/index.html</a></p>
1
How to keep absolutely positioned element in place when browser window resized
<p>I have absolutely positioned text so that it sits inside of my header image, but I cannot figure out how to keep it from moving outside of the header when the browser gets re-sized. If the browser window gets re-sized to a smaller size, the text moves outside of the header, but if the browser window gets re-sized to a bigger size, the text keeps moving to the right of the header!</p> <p>The header is 800px wide and 150px tall, and it's positioned in the middle of the browser window.</p> <p>Here's my HTML code:</p> <pre><code>&lt;div id="container"&gt; &lt;div id="header"&gt; &lt;img src="images/header.jpg" alt="Site Header Image"&gt; &lt;h1&gt;Our Site&lt;/h1&gt; &lt;h2&gt;Catchy slogan...&lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here's my CSS code:</p> <pre class="lang-css prettyprint-override"><code>body { margin: 0px; padding: 0px; } #header h1 { color: #FFFFFF; position: absolute; top: 0px; left: 305px; } #header h2 { color: #FFFFFF; position: absolute; top: 30px; left: 330px; } #header img { width: 800px; height: 150px; display: block; margin-left: auto; margin-right: auto; } </code></pre>
1
How to load data from edge node to Hadoop cluster?
<p>I have two servers A (edge node) and B (Hadoop cluster). I need to move directories from A to B (Hadoop location). I am able to copy to B cluster local but don't know exact command to copy to hdfs location in B Server</p>
1
Disabling of TCP SYN retransmission
<p>I am developing a client which connects to server through TCP. Servers are configured such that if one server is down, connection is set up with another server. </p> <p>My requirement is that if TCP connection is not established with the 1st server within 2s, client needs to establish connection with the 2nd server.</p> <p>Below is my observation based on testing- TCP SYN message is sent by client to the 1st server to establish connection. Since 1st server is down, after 1s, TCP SYN retransmission is sent to the 1st server. After 2s(owing to processing and network delays), TCP SYN message is sent to the 2nd server by the client. So its taking 3s (1s + 2s) for the SYN message to be sent to the 2nd server, which is not what I wanted. I want the TCP SYN message to be sent to 2nd server within 2s.</p> <p>In order to send TCP SYN message to the 2nd server within 2s, I want to avoid TCP SYN retransmission. </p> <p>I tried setting net.ipv4.tcp_syn_retries=0 in /etc/sysctl.conf. But I get 1 TCP SYN retransmission.</p> <p>So is there any way to disable TCP SYN retransmission from userspace without changing the kernel source?</p>
1
how to disable js2-mode syntax checking globally in spacemacs
<p>Since im using eslint, syntax checking from js-mode is redundant to me. so how to turn it off globally instead of toggling on and off?</p> <p>I configured eslint not to check for semicolons, but js2-mode still checks it. if js2-mode syntax checking cant be disabled globally, is there a way to only turn off semicolon check?</p>
1
How to check TR is hidden or has class 'display:none' from TD's a's i's id
<p>I have a very weird situation where I have assigned attribute <code>id</code> to the TD . From this <code>id</code> I want to check whether TR id <code>hidden</code> or <code>visible</code>.</p> <pre><code>&lt;table id="tableID" class="tableClass"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th width="3px"&gt;Header1&lt;/th&gt; &lt;th align="left"&gt;Header2&lt;/th&gt; &lt;/tr&gt; &lt;tr align="left"&gt; &lt;td&gt;Data1&lt;/td&gt; &lt;td&gt;&lt;a &lt;i id="1"&gt;&gt;&lt;/i&gt;&lt;/a&gt;Data2&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; </code></pre> <p></p> <p>I have tried this</p> <p><code>document.getElementById(id).parentNode.parentNode.parentNode.hidden</code> but its giving <code>false</code> all time even if it hidden by using <code>hide()</code>.</p> <p><strong>Console:</strong></p> <p><a href="https://i.stack.imgur.com/BVDBV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BVDBV.png" alt="enter image description here"></a></p>
1
Overflow-y not working on iPad
<p>I have a panel with a scrollable content. It works fine in every browser &amp; device except for iPad (no matter what browser I use on the iPad).</p> <p>I have a panel-container and a panel-slide</p> <pre><code>.panel-container { position: relative; width:100%; height:100%; z-index:1; } .panel-slide { width:90%; height: 90%; display:block; position: absolute; z-index: 2; background-color: white; overflow-y: scroll; overflow-x: hidden; } </code></pre> <p>The panel-slide contains a lot of content, so I get the scroll bar. However I can't scroll on iPad.</p> <p>I have googled the problem and have tried the -webkit-overflow-scrolling: touch, but I can't seem to get to the bottom of it.</p> <p>What is there to do?</p>
1
Hooking to Zapier using .Net WebHooks as RESThooks
<p>I am looking into creating a "Zap App" and am wondering if anyone has done so using the new .Net Webhooks. They seem to have the "pattern" requested by RESTHooks, the Subcription/Publish mechanism. Not a lot of examples of it working and I wanted to check before I spent days implementing it and find it is incompatible.</p> <p>Actual code examples of hooking to Zapier would be great!</p>
1
try-with-resources: "use" extension function in Kotlin does not always work
<p>I had some trouble expressing the Java's <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/language/try-with-resources.html" rel="noreferrer">try-with-resources</a> construct in Kotlin. In my understanding, every expression that is an instance of <code>AutoClosable</code> should provide the <code>use</code> extension function.</p> <p>Here is a complete example:</p> <pre><code>import java.io.BufferedReader; import java.io.FileReader; import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; public class Test { static String foo(String path) throws Throwable { try (BufferedReader r = new BufferedReader(new FileReader(path))) { return ""; } } static String bar(TupleQuery query) throws Throwable { try (TupleQueryResult r = query.evaluate()) { return ""; } } } </code></pre> <p>The Java-to-Kotlin converter creates this output:</p> <pre><code>import java.io.BufferedReader import java.io.FileReader import org.openrdf.query.TupleQuery import org.openrdf.query.TupleQueryResult object Test { @Throws(Throwable::class) internal fun foo(path: String): String { BufferedReader(FileReader(path)).use { r -&gt; return "" } } @Throws(Throwable::class) internal fun bar(query: TupleQuery): String { query.evaluate().use { r -&gt; return "" } // ERROR } } </code></pre> <p><code>foo</code> works fine, but the code in <code>bar</code> does not compile: </p> <pre><code>Error:(16, 26) Kotlin: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public inline fun &lt;T : java.io.Closeable, R&gt; ???.use(block: (???) -&gt; ???): ??? defined in kotlin.io </code></pre> <p><code>query.evaluate()</code> is from <a href="http://rdf4j.org/" rel="noreferrer">Sesame</a> and implements <code>AutoClosable</code>. Is it a Kotlin bug, or is there a reason why it does not work?</p> <hr> <p>I am using IDEA 15.0.3 with Kotlin 1.0.0-beta-4584-IJ143-12 and the following <code>sasame-runtime</code> version:</p> <pre><code>&lt;groupId&gt;org.openrdf.sesame&lt;/groupId&gt; &lt;artifactId&gt;sesame-runtime&lt;/artifactId&gt; &lt;version&gt;4.0.2&lt;/version&gt; </code></pre>
1
Grails RestBuilder query parmeters
<p>I'm writing some functional tests for a Grails controller, and I feel it's getting messy when testing the query parameters.</p> <p>I know that I can do this, but it just seems clunky. </p> <pre><code>Map getParms = [id:1, x:foo, y:bar, z:baz] RestResponse response = builder.get("http://example.com/api/{id}?x={x}&amp;y={y}&amp;z={z}") { urlVariables getParams } </code></pre> <p>Ideally I'd like to:</p> <ol> <li>Fill the base URL (i.e. the Id) using the <code>urlVariables</code> argument above</li> <li>Pass another map of query params that appends each as a key value pair</li> </ol> <p>Something like:</p> <pre><code>Map queryParms = [x:foo, y:bar, z:baz] RestResponse response = builder.get("http://example.com/api/{id}") { urlVariables id:1 queryVariables queryParams } </code></pre> <p>I feel this would be much more 'DRY', and easier to read/write.</p> <p>Does anyone know if such a mechanism exists? I know I could put together a class to do it, but I was hoping to avoid this if there is an existing implementation.</p>
1
proxmox KVM routed network with multiple public IPs
<p>I have a dedicated hosting with hetzner. Additionally i have bought a 6IP subnet.</p> <p>My main IP is: 88.198.60.125 My main subnet is: 255.255.255.224</p> <p>My additional IPs are 46.4.214.81 to 46.4.214.86</p> <p>the internet access work on windows servers . but centos give me invalid host I cannot use bridged mode, since hetzner does not allow multiple MACs on same external ip, so I have to use routing mode. Here is my /etc/network/interfaces file for the host:</p> <pre><code>auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 88.198.60.125 netmask 255.255.255.255 pointopoint 88.198.60.97 gateway 88.198.60.97 post-up echo 1 &gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp auto vmbr0 iface vmbr0 inet static address 88.198.60.125 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0 bridge_maxwait 0 #subnet up ip route add 46.4.214.80/29 dev vmbr0 up ip route add 46.4.214.81/29 dev vmbr0 up ip route add 46.4.214.82/29 dev vmbr0 up ip route add 46.4.214.83/29 dev vmbr0 up ip route add 46.4.214.84/29 dev vmbr0 up ip route add 46.4.214.85/29 dev vmbr0 up ip route add 46.4.214.86/29 dev vmbr0 up ip route add 46.4.214.87/29 dev vmbr0 </code></pre> <p>and this my interfaces for vm</p> <pre><code>auto eth0 iface eth0 inet static address 46.4.214.81 netmask 255.255.255.255 pointopoint 88.198.60.125 gateway 88.198.60.125 </code></pre>
1
apache phoenix Join query performance
<p>I started using phoenix couple of months back. Below are the environment and version details.</p> <p>Hadoop – Cloudera CDH 5.4.7-1. Phoenix – 4.3 – Phoenix which comes as parcels on CDH5.4.7-1. HBase version – HBase 1.0.0 JDK – 1.7.0_67 1 Master and 3 region servers.</p> <p>We started to do a POC to evaluate Apache Phoenix. We have data in 12 different tables on Oracle DB. We get the data into Hadoop system using Oracle golden gate.</p> <p>There are 12 different Phoenix tables each having 40-100 columns with a few hundred rows. We do a transformation process and then load into a final table. This is basic ETL which we are doing. The transformation process goes through a couple of intermediate stages where we populate intermediate tables. Hence there are “joins” between tables. </p> <p>Everything worked great and we were able to implement the entire ETL process. I was very happy with the ease of use and implementation. </p> <p>The issues started when we started with the Performance testing with millions of rows. Below are the issues.</p> <ol> <li><p>The intermediate transformation process crashes the region servers: Joining two tables, each with 20 Million rows. Secondary Index created on the column I am joining on. The two tables are salted with 9 buckets. This performed well if the number of rows resulted from the join is less than ~200k. The 200k rows take more than 10 minutes to execute. If the number of rows resulting is more, then the region servers start crashing. Test code explain select count(available_bal) from salted.b_acct2 ba inner join (select c_item_id from salted.m_item2 mi where s_info_id = 12345) as mi on ba.c_item_id = mi.c_item_id;</p> <p>+------------------------------------------+ | PLAN | +------------------------------------------+ | CLIENT 9-CHUNK PARALLEL 9-WAY FULL SCAN OVER SALTED.S2_BA_CI_IDX | | SERVER AGGREGATE INTO SINGLE ROW | | PARALLEL INNER-JOIN TABLE 0 (SKIP MERGE) | | CLIENT 9-CHUNK PARALLEL 9-WAY RANGE SCAN OVER SALTED.S_MI_SI_IDX [0,19,266] | | CLIENT MERGE SORT | | DYNAMIC SERVER FILTER BY TO_BIGINT("C_ITEM_ID") IN (MI.C_ITEM_ID) | +------------------------------------------+</p></li> <li><p>Joining 6 tables for the final transformation hangs: Joining 6 tables on indexed columns returns data for less than 1M rows. This takes 10-12 minutes. But if the join results are approximately more than 1M, it hangs and the result doesn’t come back. Initially I got InsufficientMemoryException, which I resolved by changing the configuration and increasing the memory available. I don’t get the InsufficientMemoryException again, but the query doesn’t execute for more than 20 min. We are expecting to execute within a few seconds.</p></li> </ol> <p>Below are the parameters:</p> <pre><code>jvm.bootoptions= -Xms512m –Xmx9999M. hbase.regionserver.wal.codec : org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec hbase.rpc.timeout 600000 phoenix.query.timeoutMs 360000000 phoenix.query.maxServerCacheBytes 10737418240 phoenix.coprocessor.maxServerCacheTimeToLiveMs 900000 hbase.client.scanner.timeout.period 600000 phoenix.query.maxGlobalMemoryWaitMs 100000 phoenix.query.maxGlobalMemoryPercentage 50 hbase.regionserver.handler.count 50 </code></pre> <p>Summary: The core issues being Slow execution of join queries and eventually crashing of region servers when the data goes beyond 1 million of rows. Is there a limitation on the execution? Please help me resolve these issues as we are going through an evaluation process and I don’t want to let go of Phoenix! If I am able to execute the above queries within quick time, then I would not hesitate to use Phoenix.</p> <p>Regards, Shivamohan</p>
1
Laravel cache remaining TTL
<p>I am looking for a way to access the remaining TTL of a redis key value pair via laravel. I don't mind using either the <code>Cache</code> or <code>Redis</code> facades (or anything else for that matter). </p> <p><a href="https://laravel.com/api/5.2/Illuminate/Cache/Repository.html" rel="nofollow">In the api</a> I can only see how to return the default TTL - <code>getDefaultCacheTime()</code>. </p> <p>I want to find the remaining TTL.</p> <p>For reference, the redis terminal command is <code>TTL mykey</code></p>
1
Webpack exclude entries for CommonsChunkPlugin
<p>I am trying to set up webpack production configuration. All looks well. However, I realized that while using the commons chunk plugin, it covers all the files in common as expected. What I want to do is, separation of common library modules and common application modules. My config file is :</p> <pre><code>module.exports = { entry: { lib: ["react", "react-dom"], app: "./ui-v2/app/app.js", app2: "./ui-v2/app/app2.js" }, output: { path: path.join(__dirname, "target/ui/v2"), filename: "/app/[name].[chunkhash].min.js" }, module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }, { test: /\.(png|jpg|svg)/, loader: "file-loader?name=img/[name].[hash].[ext]" // loaders: ["url", "image-webpack"] }, { test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader!autoprefixer-loader!sass-loader", { publicPath: __dirname }) }, { test: /\.(woff|woff2|ttf|eot)$/, loader: "file-loader?name=fonts/[name].[hash].[ext]" } ] }, plugins: [ clean, new webpack.optimize.CommonsChunkPlugin("common", "app/common.[chunkhash].js"), new webpack.ProvidePlugin({ React: "react", ReactDOM: "react-dom", $: "jquery", _: "lodash" }), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false sourceMap: true }, mangle: { except: ["exports", "import", "$", "_", "require", "React", "ReactDOM"] } }), new ExtractTextPlugin("styles/[name].[contenthash].css"), new Manifest() ] } </code></pre> <p>Basically I have 3 modules in the app; app.js, app2.js and a common component user.js.</p> <p>What I want to achieve is to bundle all library related files like react, react-dom, lodash, etc in a lib bundle, and common application components like user.js in a common bundle. In order to do this, I thought there might be an option to exclude the files that I don't want them to go to "common" file. If I use this output, what is the point for long term caching files for library bundles because whenever I get a common component in my project, they will go into the common bundle and the content hash will be different, but nothing changes in this library files like react, jquery, lodash, etc.</p> <p>Anyway, what I have at the end of build process is everything still goes into the common bundle and lib has nothing and the file sizes are :</p> <pre><code>app.&lt;hash&gt;.min.js -&gt; 3.05KB app2.&lt;hash&gt;.min.js -&gt; 3.05KB lib.&lt;hash&gt;.min.js -&gt; 165 Bytes (has almost nothing!) common.&lt;hash&gt;.js -&gt; 678 KB </code></pre> <p>Is there any way to achieve what I want or what would be the best approach to a production build in similar cases? Thank you!</p>
1
How to create condition "if element not exist - do smth" by using Nightwatch?
<p>I have a list of users, presented by table, and I need to search for td element with appropriate value - and if element not exist on current page - click on link to go on another page. I have no ideas how to do this but I used xpath selector to find element with some value.</p> <p>Each user presented by "tr" element and contains "td" elements inside:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;tr&gt; &lt;td class="break-all"&gt;acceptance&lt;/td&gt; &lt;td&gt;client&lt;/td&gt; &lt;td class="break-all"&gt;&lt;/td&gt; &lt;/tr&gt;</code></pre> </div> </div> </p> <p>So, I need to find td element with value = "acceptance", if it's not exist on current page - click on link to go on another page and continue the search.</p> <p><strong>I found solution, and it works for me!</strong></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 isActive(client) { client.getAttribute("div.right", "class", function (result) { if (result.value == "right active") { client .click("div.icon-caret-right") .perform(function () { findByText(client) }) } else { //Throw error in this case!!! } }) } function findByText(username, client) { client.elements("xpath", "//td[text()='" + username + "']", function (result) { if (!result.value.length) { isActive(client) } }) } module.exports = findByText;</code></pre> </div> </div> </p> <p>And I just call <code>findByText(username, client)</code>.</p> <p>But now I have another question - how to throw error from <code>else</code> statement???</p>
1
Laravel Validation Error customise format of the Response
<p>I am working with L5 Form Requests and don't I just love Taylor! Well, I am doing some AJAX requests and I still want to retain my form requests. The problem is that in the case of a validation error the Validator just returns a 422 error response and flashes the errors, but my AJAX frontend expects a very specific format of response from server whether validation is successful or not. </p> <p>I want to format the response on Validation errors to something like this </p> <pre><code>return json_encode(['Result'=&gt;'ERROR','Message'=&gt;'//i get the errors..no problem//']); </code></pre> <p>My problem is how to format the response for the form requests, especially when this is not global but done on specific form requests. <p> I have googled and yet not seen very helpful info. Tried this method too after digging into the <code>Validator</code> class.</p> <pre><code>// added this function to my Form Request (after rules()) public function failedValidation(Validator $validator) { return ['Result'=&gt;'Error']; } </code></pre> <p>Still no success.</p>
1
IntelliJ shows shorthand package names. How to see the actual package names?
<p>Using IntelliJ IDEA 14.1.5 and working on a Maven project, the package names in the project tab are showing up as <code>a.b.g.d</code> for a package named <code>alpha.beta.gamma.delta</code>. How can I see the actual package names? I tried using the filters and preferences but couldn't find any solution.</p>
1
scale the loss value according to "badness" in caffe
<p>I want to scale the loss value of each image based on how close/far is the "current prediction" to the "correct label" during the training. For example if the correct label is "cat" and the network think it is "dog" the penalty (loss) should be less than the case if the network thinks it is a "car".</p> <p>The way that I am doing is as following:</p> <p>1- I defined a matrix of the distance between the labels,<br> 2- pass that matrix as a bottom to the <code>"softmaxWithLoss"</code> layer,<br> 3- multiply each log(prob) to this value to scale the loss according to badness in <code>forward_cpu</code></p> <p>However I do not know what should I do in the <code>backward_cpu</code> part. I understand the gradient (bottom_diff) has to be changed but not quite sure, how to incorporate the scale value here. According to the math I have to scale the gradient by the scale (because it is just an scale) but don't know how.</p> <p>Also, seems like there is loosLayer in caffe called <code>"InfoGainLoss"</code> that does very similar job if I am not mistaken, however the backward part of this layer is a little confusing:</p> <pre><code>bottom_diff[i * dim + j] = scale * infogain_mat[label * dim + j] / prob; </code></pre> <p>I am not sure why <code>infogain_mat[]</code> is divide by <code>prob</code> rather than being multiply by! If I use identity matrix for <code>infogain_mat</code> isn't it supposed to act like softmax loss in both forward and backward?</p> <p>It will be highly appreciated if someone can give me some pointers.</p>
1
How to check for ending period in Excel?
<p>What formula can I use to check if there is a period on the end of my cell. If there isn't add one. Thanks!</p> <p><a href="https://i.stack.imgur.com/mMRfp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mMRfp.png" alt="enter image description here"></a></p>
1
Text color of default console window
<p>What is the default color of text appearing on the console window ? It is not pure white, but it is some shade of white. Can I use this color for Rich Textbox text ?</p>
1
IntelliJ IDEA 15 Scene Builder not showing all controls
<p>I have troubles with the built in Scene Builder. When used standalone Scene Builder displays everything fine. Did I mess up some settings in IntelliJ Idea or it's a bug. </p> <p>I use IntelliJ Idea 15.0.3 (64 bit) and Scene Builder 2.0.</p> <p>One thing I changed in IntelliJ was the heap size. Here is my idea64.exe.vmoptions file: -Xms512m -Xmx2048m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=256m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow</p> <p>I increased -Xmx to 2GB because it was complaining that it needs more ram ... hungry java... That's also the reason I switched to 64 bit version. The 32 bit didn't want to boot with more than 1.1GB heap. I noticed that SceneBuilder about dialog sais "Operating System: Windows 7, x86, 6.1". Does it have troubles working with 64 JRE? It's java, it shouldn't matter what's below...</p> <p>I'll post an update when I try Scene Builder with idea running with 32-bit JRE.</p> <p><strong>Update:</strong> IntelliJ with 32 bit JRE acts the same way.</p> <p><a href="https://i.stack.imgur.com/28bvH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/28bvH.png" alt="Scene builder built in IntelliJ Idea 15"></a></p>
1
Failed to execute 'registerProtocolHandler' on 'Navigator': The scheme 'message' doesn't belong to the scheme whitelist
<p>I am trying to use,</p> <pre><code>navigator.registerProtocolHandler("message", "http://localhost/?uri=%s", "message handler") </code></pre> <p>But getting this error,</p> <pre><code>Failed to execute 'registerProtocolHandler' on 'Navigator': The scheme 'message' doesn't belong to the scheme whitelist. </code></pre> <p>Actually I have mobile app. The server returning custom protocol to mobile. I am testing this on mobile.</p>
1
Accessing every second row in matrix and save it to a new matrix, Python
<p>I am new to python and struggling with the following problem.</p> <p>I have a Matrix (6x2) and I want to save every second row into a new Matrix (3x2).</p> <pre><code>M = numpy.array([[1,2],[3,4],[5,6],[7,8],[9,10],[11,12]]) SM = [] for i in M(0,len(M),2): append.SM(i) </code></pre> <p>Is that even possible? Or do I have to split every single column first? SM should then look like that:</p> <pre><code>SM = [[3,4],[7,8],[11,12]] </code></pre> <p>So far, I only found how to do that with a single column vector, that doesn't help, as I am not used to Python at all. Thanks in advance for you help.</p>
1
CardView and RecyclerViews on kitkat
<p>I am planning to use <code>CardView</code> and <code>RecyclerView</code> in my current application replacing the <code>GridView</code>. However, these views (<code>CardView</code> and <code>RecyclerView</code>) are supported on <code>Lollipop (5.0)</code> and onwards. </p> <p>I wonder, what would happened if a user has operating system lower than <code>Lollipop</code>, like <code>Kitkat</code>? </p> <p>How could I support that devices?</p>
1
npm Cannot find module 'minimatch'
<p>I update my <code>Node.js</code> to 5.5.0. But it does not work when i use npm.</p> <p>It reports error: <code>Cannot find module 'minimatch'</code>.</p> <p>But <code>Node.js</code> version 4.2 is ok on my mac.</p>
1
Angular2 Http Response missing header key/values
<p>I'm making an http.patch call to a REST API that is successful (Status 200) but not all the response headers key/values are being returned. I'm interested in the ETag key/value.</p> <p>Here is a code snippet:</p> <pre><code>let etag:number = 0; let headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('If-Match', String(etag)); this.http.patch( 'http://example.com:9002/api/myresource/', JSON.stringify(dto), {headers: headers} ) .subscribe( (response:Response) =&gt; { let headers:Headers = response.headers; let etag:String = headers.get('ETag'); console.log(etag); } ); </code></pre> <p>When making the same call with a REST Client (Postman), the response header contains:</p> <pre><code>Content-Type: application/hal+json;charset=UTF-8 Date: Mon, 01 Feb 2016 05:21:09 GMT ETag: "1" Last-Modified: Mon, 01 Feb 2016 05:15:32 GMT Server: Apache-Coyote/1.1 Transfer-Encoding: chunked X-Application-Context: application:dev:9002 </code></pre> <p>Is the missing response header key/values a bug? Can the issue be resolved with configuration?</p>
1
How to set node color different in one cluster using R {igraph}?
<p>I have a set of data of city, each city have a majority etnic. Let's say</p> <pre><code>City Etnic A x B y C z </code></pre> <p>etc. I make a graph of social network where the node represent the name of the city, and the link is the neighborhood of the city with another city. I'm using package igraph in R. After that I do graph partitioning to find it's community. Let's say it came with 4 communities. And in one community, there was multiple etnic. The node color represent the majority etnic. The problem is, the node color of graph is following the community. This is my code:</p> <pre><code>#make a graph from data frame g=graph.data.frame(link, directed=T, vertices=node) #clustering/graph partitioning clust=cluster_optimal(g) #node color V(g)$color &lt;- ifelse(V(g)$etnic == "x", "red",ifelse(V(g)$etnic =="y", "blue", "green") plot(clust, g, edge.arrow.size=.15, edge.curved=0, vertex.frame.color="black", vertex.label=V(g)$city, vertex.label.color="black", vertex.label.cex=.8,layout=l) </code></pre> <p>The question is how I make the node color represent the color of etnic I declare?</p>
1
Pass list of Strings to gradle task property without using parentheses
<p>I have a <code>build.gradle</code> like so, with a tiny little custom task:</p> <pre><code>task ListOfStrings(type: ExampleTask, description: 'Prove we can pass string list without parentheses') { TheList ('one', 'two', 'three') // this works but it's not beautiful } public class ExampleTask extends DefaultTask { public void TheList(String... theStrings) { theStrings.each { println it } } } </code></pre> <p>In the <code>test.testLogging</code> block is <code>events</code>: and we can pass a comma-separated list of strings <strong>without parentheses</strong>.</p> <pre><code>test { outputs.upToDateWhen { false } testLogging { showStandardStreams true exceptionFormat 'short' events 'passed', 'failed', 'skipped' // this is beautiful } } </code></pre> <p>My question is: how do I write my <code>ExampleTask</code> so I can write <code>TheList</code> as a simple list of comma-separated strings <strong>omitting the parentheses</strong>?</p> <p>My perfect-world scenario is to be able to express the task like so:</p> <pre><code>task ListOfStrings(type: ExampleTask, description: 'Prove we can pass string list without parentheses') { TheList 'one', 'two', 'three' } </code></pre>
1
Spring-Boot-Jersey Setup CORS
<p>I serve my front- and backend from two different servers. Now I am trying to get CORS working on the Spring-Boot-Jersey backend. I tried everything I could find on the internet but nothing seem to work or I am missing something.</p> <p>My current setup uses a <code>ContainerResponseFilter</code>. I tried registering it automatically with <code>@Provider</code> and manually in the Jersey configuration.</p> <p>ContainerResponseFilter</p> <pre><code>@Provider public class CORSFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException { response.getHeaders().add("Access-Control-Allow-Origin", "*"); response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization"); response.getHeaders().add("Access-Control-Allow-Credentials", "true"); response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); } } </code></pre> <p>Maybe it is important but I also used <code>Spring-Security-oauth2</code> by adding the <code>@EnableOAuth2Sso</code> annotation. Please tell me if you need more of my setup.</p>
1
Dynamic column name in panda dataframe evaluation
<p>I'm referencing a dataframe as follows (<code>Sales</code> is the column name):</p> <pre><code>total = pd.to_numeric(sales_df.Sales.str.replace("$", "")).sum() </code></pre> <p>But I don't want <code>Sales</code> to be hard coded, I want a variable to make it dynamic. How is this done?</p> <p>TIA</p>
1
Using webpack and react-router for lazyloading and code-splitting not loading
<p>I'm working on moving my <code>react v0.14</code>+ <code>redux v3.0</code> + <code>react-router v1.0</code> codebase from client-side rendering to server-side rendering using <code>webpack v1.12</code> to bundle and code-split into chunks to load routes and components on-demand.</p> <p>Im following and basing my setup on <a href="https://github.com/rackt/example-react-router-server-rendering-lazy-routes">https://github.com/rackt/example-react-router-server-rendering-lazy-routes</a> as I think it provides simplicity and great utilities. All day yesterday I have been working on moving to server-side rendering but I run into a few issues I haven't been able to solve and I'm not completely sure if they are because of <code>webpack</code> not being setup correctly, if am doing something wrong with <code>react-router</code> on the server/client or the routes config, or if its something I'm doing wrong with setting up <code>redux</code> that is causing these issues.</p> <p>I run into the following issues:</p> <ol> <li>I'm able to load the initial page and everything works well but no other routes load and gives me <a href="http://i.stack.imgur.com/YFga4.png">GET http://localhost:3000/profile 404 (Not Found)</a></li> <li>The index/home page javascript works but all assets(css) are rendered as <code>text/javascript</code> so the styles don't show up unless they are inline.</li> </ol> <h2>webpack.config.js</h2> <pre class="lang-js prettyprint-override"><code>var fs = require('fs') var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'source-map', entry: './client/client.jsx', output: { path: __dirname + '/__build__', filename: '[name].js', chunkFilename: '[id].chunk.js', publicPath: '/__build__/' }, module: { loaders: [ { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader' } ] }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.DedupePlugin(), new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false }, }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') }) ] } </code></pre> <h2>server.js</h2> <pre class="lang-js prettyprint-override"><code>import http from 'http'; import React from 'react'; import {renderToString} from 'react-dom/server'; import { match, RoutingContext } from 'react-router'; import {Provider} from 'react-redux'; import configureStore from './../common/store/store.js'; import fs from 'fs'; import { createPage, write, writeError, writeNotFound, redirect } from './server-utils.js'; import routes from './../common/routes/rootRoutes.js'; const PORT = process.env.PORT || 3000; var store = configureStore(); const initialState = store.getState(); function renderApp(props, res) { var markup = renderToString( &lt;Provider store={store}&gt; &lt;RoutingContext {...props}/&gt; &lt;/Provider&gt; ); var html = createPage(markup, initialState); write(html, 'text/html', res); } http.createServer((req, res) =&gt; { if (req.url === '/favicon.ico') { write('haha', 'text/plain', res); } // serve JavaScript assets else if (/__build__/.test(req.url)) { fs.readFile(`.${req.url}`, (err, data) =&gt; { write(data, 'text/javascript', res); }) } // handle all other urls with React Router else { match({ routes, location: req.url }, (error, redirectLocation, renderProps) =&gt; { if (error) writeError('ERROR!', res); else if (redirectLocation) redirect(redirectLocation, res); else if (renderProps) renderApp(renderProps, res); else writeNotFound(res); }); } }).listen(PORT) console.log(`listening on port ${PORT}`) </code></pre> <h2>server-utils</h2> <p>Is the same as from the repo that I posted above <code>example-react-router-server-rendering-lazy-routes</code> just navigate to <code>/modules/utils/server-utils.js</code> in the repo.The only difference is the <code>createPage</code> function:</p> <pre class="lang-js prettyprint-override"><code>export function createPage(html, initialState) { return( ` &lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"/&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="./../bower_components/Ionicons/css/ionicons.min.css"&gt; &lt;link rel="stylesheet" href="./../dist/main.css"&gt; &lt;title&gt;Sell Your Soles&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="app"&gt;${html}&lt;/div&gt; &lt;script&gt;window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};&lt;/script&gt; &lt;script src="/__build__/main.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; `); } </code></pre> <h2>rootRoute.js</h2> <pre class="lang-js prettyprint-override"><code>// polyfill webpack require.ensure if (typeof require.ensure !== 'function') require.ensure = (d, c) =&gt; c(require) import App from '../components/App.jsx' import Landing from '../components/Landing/Landing.jsx' export default { path: '/', component: App, getChildRoutes(location, cb) { require.ensure([], (require) =&gt; { cb(null, [ require('./UserProfile/UserProfileRoute.js'), require('./UserHome/UserHomeRoute.js'), require('./SneakerPage/SneakerPageRoute.js'), require('./Reviews/ReviewsRoute.js'), require('./Listings/ListingsRoute.js'), require('./Events/EventsRoute.js') ]) }) }, indexRoute: { component: Landing } } </code></pre> <h2>userProfileRoute.js</h2> <pre class="lang-js prettyprint-override"><code>import UserProfile from '../../components/UserProfile/UserProfile.jsx'; export default { path: 'profile', component: UserProfile } </code></pre> <h2>client.js</h2> <pre class="lang-js prettyprint-override"><code>import React from 'react'; import { match, Router } from 'react-router'; import { render } from 'react-dom'; import { createHistory } from 'history'; import routes from './../common/routes/rootRoutes.js'; import {Provider} from 'react-redux'; import configureStore from './../common/store/store.js'; const { pathname, search, hash } = window.location; const location = `${pathname}${search}${hash}`; const initialState = window.__INITIAL_STATE__; const store = configureStore(initialState); // calling `match` is simply for side effects of // loading route/component code for the initial location match({ routes, location }, () =&gt; { render( &lt;Provider store={store}&gt; &lt;Router routes={routes} history={createHistory()} /&gt; &lt;/Provider&gt;, document.getElementById('app') ); }); </code></pre>
1
Force UIViewController to layout correctly without bringing it onto the screen
<p>I am having some difficulty with the following problem. I have laid out a UIViewController in Storyboard with the correct constraints. It has all the same views as the UIViewController on the screen at the present. I am using this new UIViewController for some resizing. Therefore, I would like to initialize this UIViewController, layout all the subviews, according to the constraints I have given it, and then use the UIView's frames for the primary UIViewController. Since I never need this secondary UIViewController, it is never displayed. </p> <p>I instantiate the secondary UIViewController as follows:</p> <pre><code>secondaryVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("secondaryVCId") as? secondaryVC </code></pre> <p>This works fine, but getting the positions of the subviews, the most important thing, does not. Even though the view is sized correctly, (i.e. when <code>secondaryVC.view.size</code> is printed, it is the same as <code>primaryVC.view.size</code>) but the subviews still think that the view is 600 x 600. I have tried many things to force the subviews to layout again, but none seem to work, other than adding the view as a subview, (i.e. <code>primaryVC.view.addSubview(secondaryVC.view)</code>) which I would prefer not to do, (because I would then have to remove it again.)</p>
1
How to add Data to Specific index of json array using angularjs
<p>I was created table data and edit button and i am getting problem when i was trying to add edit data to specific row.</p> <p>Here my plunkr :- <a href="http://plnkr.co/edit/QKz7nu458i8Il4OLmAyw?p=preview" rel="nofollow">http://plnkr.co/edit/QKz7nu458i8Il4OLmAyw?p=preview</a></p> <p>Here HTML page</p> <pre><code> &lt;table class="table table-bordered"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;input type='checkbox' ng-modal='isall' ng-click='selectallrows()'&gt;&lt;/th&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;EDIT&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr ng-repeat='p in person' ng-class="{'success':tableselection[$index]}"&gt; &lt;td&gt;&lt;input type='checkbox' ng-model='tableselection[$index]'&gt;&lt;/td&gt; &lt;td&gt;{{p.id}}&lt;/td&gt; &lt;td&gt;{{p.name}}&lt;/td&gt; &lt;td&gt;&lt;button class='btn btn-primary' ng-click='edit(p.id)'&gt;&lt;span class="glyphicon glyphicon-pencil"&gt;&lt;/span&gt;Edit&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;div ng-show='editabledata'&gt; &lt;form role='form' class='form-horizontal'&gt; &lt;div class='form-group'&gt; &lt;label&gt;Id :-&lt;/label&gt; &lt;input type='text' ng-model='pid' class='from-group col-sm-2'&gt;&lt;/div&gt; &lt;div class='form-group'&gt; &lt;label&gt;Name:-&lt;/label&gt; &lt;input type='text' ng-model='pname' class='from-group col-sm-2'&gt; &lt;/div&gt; &lt;button class='btn btn-primary' ng-click='saveeditdata(pid)'&gt;Save&lt;/button&gt; &lt;button clas='btn btn-primary' ng-click='canceleditdata()'&gt;Cancel&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Here my .js </p> <pre><code>$scope.person=[ {id:1,name:'devendher'}, {id:2,name:'Macha'}, {id:3,name:'Macha devendher'} ]; $scope.editabledata=false; $scope.edit=function(id){ $scope.editabledata=true; for(i=0;i&lt;$scope.person.length;i++){ if($scope.person[i].id==id) { $scope.pid=$scope.person[i].id; $scope.pname=$scope.person[i].name; } } } $scope.saveeditdata=function(id){ for(i=0;i&lt;$scope.person.length;i++){ if($scope.person[i].id==id){ $scope.person[i].push({'id':$scope.pid,'name':$scope.pname}) } } } </code></pre> <p>i got error " $scope.person[i].push " is not a function Is there any alternate way to add data to specific index of array?</p>
1
Double tap Gesture on UICollectionViewCell?
<p>I want to double tap on the UICollectionViewCell to like the profile just like <strong>OkCupid App</strong>. I have applied Tap Gesture on Collection View but it does not work. </p> <p>When I try to double tap the cell every time <code>didSelectCollectionViewCell</code> Method call.</p>
1
how to add scope for google login api
<p>I am creating a google login for my website to sign up users directly from their google account. I followed this tutorial <code>http://www.sanwebe.com/2012/11/login-with-google-api-php</code> and i'm able to access to information required. But on the request for permission page it says the website would like to have <code>offline access</code>. </p> <p>How do I show it to state that I would like to access email and basic profile information. </p> <p>The client creation code is as below : </p> <pre><code>$client = new Google_Client(); $client-&gt;setClientId($client_id); $client-&gt;setClientSecret($client_secret); $client-&gt;setRedirectUri($redirect_uri); $client-&gt;addScope("email"); $client-&gt;addScope("profile"); </code></pre>
1
Mongoose Pre-Save Hook is Firing, but Not Saving Additional Field (NOT using model.update)
<p>I am attempting to implement a counter in my schema to grab the next issue number. I have implemented it as a hook pre-save hook in Mongoose, and everything looks fine... with the exception the actual 'number' field does not update. I can easily tell the hook is firing off by what gets logged to the console, even the field seems to get assigned. But alas, no matter what I try, the 'number' field does not end up in the results.</p> <p>I have seen a couple issues related to Mongoose hooks, but they all seem to be related to findOneAndUpdate or the like, which I am not using.</p> <p><strong>Here is my full model with the hooks at the bottom:</strong></p> <pre><code>var mongoose = require('mongoose'); var Schema = mongoose.Schema; var Project = require('./projects.js'); var IssueSchema = new Schema({ title: {type: String, required: true, trim: true, index: true}, number: {type: Number}, description: {type: String, required: true}, vote_up: {type: Number, default: 0}, vote_down: {type: Number, default: 0}, comments: [new Schema({ _id: {type: Schema.ObjectId, ref: 'users'}, description : {type: String}, likes: {type: Number}, date: {type: Date} })], attachments: [], fields: [new Schema({ _id: {type: Schema.ObjectId, ref: 'fields'}, value : {type: String} })], project: {type: Schema.ObjectId, required: true, index: true, ref: 'projects'}, tags: {type: [Schema.ObjectId], required: false, default: ['56a2a0b1ea805d403f6d014b']}, isResolved: {type: Boolean, default: false}, created_by: {type: Schema.ObjectId, required: true, ref: 'users'}, updated_by: {type: Schema.ObjectId, required: false, ref: 'users'}, created_at: {type: Date, default: Date.now}, updated_at: {type: Date, default: Date.now} }); IssueSchema.pre('save', function(next){ var now = new Date(); this.updated_at = now; if(!this.created_at) { this.created_at = now; } next(); }) .pre('save', function(next) { Project.findOne({_id: this.project}).select('numberSeq').exec(function(err, doc) { if (err) { console.log(err); } console.log('pre-save hook firing'); this.number = doc.numberSeq; console.log(this.number); next(); }); }) .post('save', function(doc) { Project.update({_id: doc.project}, {$inc: {numberSeq: 1}}, function(err, result) { if (err) { console.log(err); } console.log('Updated next number in seq for ' + doc.project); }); }); module.exports = mongoose.model('issues', IssueSchema); </code></pre> <p>And the route to insert the issue (I am guessing this isn't where the issue is)</p> <pre><code>app.post('/api/issue/create', function(req, res) { var issue = new Issues({ title: req.body.title, description: req.body.description, fields: req.body.fields, attachments: req.body.attachments, project: req.body.project, created_by: req.user || req.body.created_by, }); issue.save(function(err, result) { if (err) { return res.status(409).send({message: 'There was an error creating the issue: ' + err}); } if (!result.number) { console.log('number = :('); } console.log(result); res.send({message: 'New issue created', result: result}); }); }); </code></pre> <p><a href="https://i.stack.imgur.com/m9RRx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m9RRx.png" alt="Screenshot of result from console with logging"></a></p>
1
Update a subset of weights in TensorFlow
<p>Does anyone know how to update a subset (i.e. only some indices) of the weights that are used in the forward propagation?</p> <p>My guess is that I might be able to do that after applying compute_gradients as follows:</p> <pre><code>optimizer = tf.train.GradientDescentOptimizer(learning_rate=learning_rate) grads_vars = optimizer.compute_gradients(loss, var_list=[weights, bias_h, bias_v]) </code></pre> <p>...and then do something with the list of tuples in <code>grads_vars</code>.</p>
1
Rails: Set config.time_zone to the server's time zone?
<p>For compatibility reasons I need to store and display all dates in the server's local time zone. To do this I configured the rails application like this in <code>application.rb</code>:</p> <pre><code># Do not convert database DATETIME / DATE columns to UTC: config.active_record.default_timezone = :local </code></pre> <p>It works okay when I store dates they are stored in the server's local timezone. However when retrieving the data Rails converts it to UTC, so for example <code>Post.find(1).posted</code> returns <code>2016-02-02 18:06:48 UTC</code> but it is actually stored as <code>2016-02-02 13:06:48</code> in the database.</p> <p>How can I keep Rails from converting it to UTC?</p> <p>I thought that setting the application time zone to the server's local time zone will help so I wanted to set <code>config.time_zone</code> to the server's local time zone and tried with:</p> <pre><code>config.time_zone = Time.now.zone </code></pre> <p>But the problem with it is that it returns a three character timezone code like <code>COT</code> and config.time_zone is expecting a Time Zone name like <code>Bogota</code></p> <p>How can I translate the three character code to the full time zone name? or, how can I get the local time zone name? or, how can I configure Rails to not convert the database dates to UTC?</p>
1
Aptana studio 3.6 installation error
<p>When trying to install Aptana Studio 3.6.1 (on WinXP) I get an error: "Failed to correctly acquire installer_nodejs_windows.msi file: CRC error".</p> <p>I downloaded node.js windows installer from nodejs.org and installed it, but next trial to install Aptana failed. I copied the file to "/AppData/Roaming/Appcelerator/Aptana Studio/installer_nodejs_windows.msi", but next Aptana installation trial failed with the same error message.</p>
1
Why does Spark throw "SparkException: DStream has not been initialized" when restoring from checkpoint?
<p>I am restoring a stream from a HDFS checkpoint (ConstantInputDSTream for example) but I keep getting <code>SparkException: &lt;X&gt; has not been initialized</code>.</p> <p>Is there something specific I need to do when restoring from checkpointing?</p> <p>I can see that it wants <code>DStream.zeroTime</code> set but when the stream is restored <code>zeroTime</code> is <code>null</code>. It doesn't get restored possibly due to it being a private member IDK. I can see that the <code>StreamingContext</code> referenced by the restored stream does have a value for <code>zeroTime</code>.</p> <p><code>initialize</code> is a private method and gets called at <code>StreamingContext.graph.start</code> but not by <code>StreamingContext.graph.restart</code>, presumably because it expects <code>zeroTime</code> to have been persisted.</p> <p>Does someone have an example of a Stream that recovers from a checkpoint and has a non null value for <code>zeroTime</code>?</p> <pre><code>def createStreamingContext(): StreamingContext = { val ssc = new StreamingContext(sparkConf, Duration(1000)) ssc.checkpoint(checkpointDir) ssc } val ssc = StreamingContext.getOrCreate(checkpointDir), createStreamingContext) val socketStream = ssc.socketTextStream(...) socketStream.checkpoint(Seconds(1)) socketStream.foreachRDD(...) </code></pre>
1
The constraint cannot be put on properties or getters
<p>I try create <a href="http://symfony.com/doc/current/cookbook/validation/custom_constraint.html#class-constraint-validator" rel="noreferrer">custom constraint</a> in symfony 3</p> <p>I have error </p> <p><strong><em>The constraint App\Bundle\MyBundle\Validator\Constraints\Code cannot be put on properties or getters</em></strong></p> <pre><code>&lt;?php // vendor/app/mybundle/Validator/Constraints/Code.php namespace App\Bundle\MyBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; class Code extends Constraint { public $message = 'Error validate message!!!'; public function validatedBy() { return 'alias_name'; } public function getTargets() { //return self::CLASS_CONSTRAINT; // error "The constraint cannot be put on properties or getters" return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); // working, but $value is a STRING!!! } } </code></pre> <p>My <em>vendor/app/mybundle/Validator/Constraints/CodeValidator.php</em></p> <pre><code>&lt;?php // vendor/app/mybundle/Validator/Constraints/CodeValidator.php namespace App\Bundle\MyBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; class CodeValidator extends ConstraintValidator { public function validate($value, Constraint $constraint) { $value-&gt;getId(); // this code not working, because $value is STRING!! $this-&gt;context-&gt;buildViolation($constraint-&gt;message) -&gt;atPath('code') -&gt;addViolation(); } </code></pre> <p>}</p> <p><strong>where I made a mistake?</strong></p>
1
Youtube get video file link
<p>Im trying to extract the location for a saved youtube video file (like youtube downloader do).</p> <p>When I use chromes developer tools I can easily see in the network section a GET request to the file. For example:</p> <pre><code>Request URL:ttps://r7---sn-35cxacf-43ce.googlevideo.com/videoplayback?sver=3&amp;expire=1454883491&amp;upn=tsTA82e-o9E&amp;itag=251&amp;id=o-APaDOeTiHGebIWBx11PdJn2W306GFYIoYkYRzOOCnq8o&amp;mn=sn-35cxacf-43ce&amp;mm=31&amp;keepalive=yes&amp;pl=32&amp;ip=2a02%3A8071%3A2782%3A8c00%3Ad8e%3Aeb17%3Ab477%3Ad45b&amp;ms=au&amp;mv=m&amp;mt=1454861758&amp;ipbits=0&amp;initcwndbps=1905000&amp;clen=5116592&amp;sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&amp;key=yt6&amp;gir=yes&amp;fexp=3300130%2C3300161%2C3310848%2C3312381%2C3312708%2C9406984%2C9416126%2C9420452%2C9422596%2C9423661%2C9423662&amp;mime=audio%2Fwebm&amp;requiressl=yes&amp;lmt=1449558944068050&amp;dur=308.401&amp;source=youtube&amp;cpn=TrlaqPAJmEUJLKte&amp;alr=yes&amp;ratebypass=yes&amp;signature=704658DBE8F05AC56D741F2061B2F16B0B5F37DD.6929579BD72F61B1401C96078192EC20BA8CE6EC&amp;c=WEB&amp;cver=html5&amp;range=781669-1125882&amp;rn=9&amp;rbuf=43086 Request Method:GET Status Code:200 OK Remote Address:[*****address*****]:443 </code></pre> <p>If I delete a few of the last params (starting at c=WEB) I got the location <a href="https://r7---sn-35cxacf-43ce.googlevideo.com/videoplayback?sver=3&amp;expire=1454883491&amp;upn=tsTA82e-o9E&amp;itag=251&amp;id=o-APaDOeTiHGebIWBx11PdJn2W306GFYIoYkYRzOOCnq8o&amp;mn=sn-35cxacf-43ce&amp;mm=31&amp;keepalive=yes&amp;pl=32&amp;ip=2a02%3A8071%3A2782%3A8c00%3Ad8e%3Aeb17%3Ab477%3Ad45b&amp;ms=au&amp;mv=m&amp;mt=1454861758&amp;ipbits=0&amp;initcwndbps=1905000&amp;clen=5116592&amp;sparams=clen%2Cdur%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&amp;key=yt6&amp;gir=yes&amp;fexp=3300130%2C3300161%2C3310848%2C3312381%2C3312708%2C9406984%2C9416126%2C9420452%2C9422596%2C9423661%2C9423662&amp;mime=audio%2Fwebm&amp;requiressl=yes&amp;lmt=1449558944068050&amp;dur=308.401&amp;source=youtube&amp;cpn=TrlaqPAJmEUJLKte&amp;alr=yes&amp;ratebypass=yes&amp;signature=704658DBE8F05AC56D741F2061B2F16B0B5F37DD.6929579BD72F61B1401C96078192EC20BA8CE6EC" rel="nofollow">(see here)</a>*. But how can I get this "request URL" by code? Do I need to analyze the network traffic? Or is there an other way?</p> <p>*Its getting only the sound of the video file - but thats ok. The sound starts after 4 seconds.</p> <p>A second way I tried: Getting the html-cocde of the normal youtubevideo (on youtube.com) and extracting and decoding the .googlevideo urls. But this way is not very safe, because I have to set up the url with some parameters and values which can be required or not for every video. So this way works only for every second video...</p> <p>Does somebody know an other way to get the filelocation?</p>
1
How can I implement restore purchase in android
<p>Thanks for visiting my page.</p> <p>Few days ago, I've developed simple android game with in app-billing.</p> <p>Now I am going to implement restore purchase function but I don't know how can I dot it.</p> <p>I've made few days of googling and found many links to help it but they didn't work me now.</p> <p>Please let me know how to do it programmatically.</p> <p>Where can i find sample of restore purchase ?</p> <p>I've implemented in app purchase already but not restore purchase.</p> <p>I used Android Studio 1.5.1.</p> <p>I've refered <a href="http://www.techotopia.com/index.php/An_Android_Studio_Google_Play_In-app_Billing_Tutorial" rel="nofollow noreferrer">http://www.techotopia.com/index.php/An_Android_Studio_Google_Play_In-app_Billing_Tutorial</a> to implement in app purchase.</p> <p>Please help me :(</p> <p>Thanks in advance.</p>
1
SQLAlchemy ORM DateTime with specific format
<p>I have a table which stores a datetime value in the following format: (e.g.) 20160213145512. Unfortunately, SQLAlchemy gives me no chance to specify the format used to store a datetime value into the database with sqlalchemy´s DateTime type.</p> <p>Therefore, i have created the following dataype:</p> <pre><code>class Timestamp(TypeDecorator): impl = String(14) def process_bind_param(self, value, dialect): if isinstance(value, datetime): value = '%04d%02d%02d%02d%02d%02d' % (value.year, value.month, value.day, value.hour, value.minute, value.second) return value def process_result_value(self, value, dialect): if value: return datetime(year=int(value[0:4]), month=int(value[4:6]), day=int(value[6:8]), hour=int(value[8:10]), minute=int(value[10:12]), second=int(value[12:14]) ) </code></pre> <p>I do not use strftime and strptime for performance reasons. What I am now able to do is the following:</p> <pre><code>class TestTable(Base): __tablename__ = "TESTTABLE" id = Column(Integer, primary_key=True) timestamp = Column(Timestamp) </code></pre> <p>Insert row by defining the datetime via a datetime object:</p> <pre><code>session.add(TestTable(timestamp=datetime(year=2016, month=2, day=3, hour=2))) </code></pre> <p>Or inserting a row by defining datetime as a string:</p> <pre><code>session.add(TestTable(timestamp="20160203031422")) </code></pre> <p>So far, so good. But the following is not working as expected:</p> <pre><code>session.query(TestTable).filter(TestTable.timestamp.year == 2016).all() </code></pre> <p>If I am runnning this code snippet I get this error:</p> <pre><code>AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with ORDERS.dz_statakt has an attribute 'year' </code></pre> <p>However this works:</p> <pre><code>session.query(TestTable).filter(TestTable.timestamp.startswith("2016")).all() </code></pre> <p>Until now I was not able to solve this problem. I guess I am missing something in my own Timestamp class.</p> <p>Is this possible at all?</p>
1
Get frame from SurfaceTexture (Android)
<p>I'm using a <code>SurfaceTexture</code> to run the camera of a device in the background and get frames from it. I see that that <code>onFrameAvailable</code> callback don't bring a frame, but a <code>SurfaceTexture</code> instead. I want to get the frame or an image representation of it, but I'm not sure how to do that. When I searched I found that I need to use GraphicBuffer, but it seems too complicated and it's not clear to me how to use it. </p> <p>I've also looked at solutions here: </p> <p><a href="https://stackoverflow.com/questions/423663/texture-image-processing-on-the-gpu">Texture Image processing on the GPU?</a></p> <p><a href="https://stackoverflow.com/questions/10775942/android-sdk-get-raw-preview-camera-image-without-displaying-it">Android SDK: Get raw preview camera image without displaying it</a></p> <p>But it's not clear how to do it in the code. Here is my code: </p> <pre><code>public class BackgroundService extends Service { private Camera camera = null; private int NOTIFICATION_ID= 1; private static final String TAG = "OCVSample::Activity"; // Binder given to clients private final IBinder mBinder = new LocalBinder(); private WindowManager windowManager; private SurfaceTexture mSurfaceTexture= new SurfaceTexture (10); Intent intializerIntent; public class LocalBinder extends Binder { BackgroundService getService() { // Return this instance of this service so clients can call public methods return BackgroundService.this; } }//end inner class that returns an instance of the service. @Override public IBinder onBind(Intent intent) { intializerIntent = intent; return mBinder; }//end onBind. @Override public void onCreate() { Log.i(TAG, "onCreate is called"); // Start foreground service to avoid unexpected kill startForeground(NOTIFICATION_ID, buildNotification()); Thread thread = new Thread() { public void run() { camera = Camera.open(1); mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { Log.i(TAG, "frame captured from texture"); if (camera!=null) { //camera.setPreviewCallbackWithBuffer(null); //camera.setPreviewCallback(null); //camera.setOneShotPreviewCallback(null); //if the following two lines are not called, many frames will be droped. camera.stopPreview(); camera.startPreview(); } } }); //now try to set the preview texture of the camera which is actually the surfaceTexture that has just been created. try { camera.setPreviewTexture(mSurfaceTexture); } catch (IOException e) { Log.e(TAG, "Error in setting the camera surface texture"); } camera.startPreview(); } }; thread.start(); } private Notification buildNotification () { NotificationCompat.Builder notificationBuilder=new NotificationCompat.Builder(this); notificationBuilder.setOngoing(true); //this notification should be ongoing notificationBuilder.setContentTitle(getString(R.string.notification_title)) .setContentText(getString (R.string.notification_text_and_ticker)) .setSmallIcon(R.drawable.vecsat_logo) .setTicker(getString(R.string.notification_text_and_ticker)); return(notificationBuilder.build()); } @Override public void onDestroy() { Log.i(TAG, "surfaceDestroyed method"); camera.stopPreview(); //camera.lock(); camera.release(); mSurfaceTexture.detachFromGLContext(); mSurfaceTexture.release(); stopService(intializerIntent) ; //windowManager.removeView(surfaceView); } } </code></pre> <p>How can I get the frames and process them whether that's on GPU or CPU? If there is a way to do that on GPU, then get the results from there, that would be great as it seems more efficient. </p> <p>Thank you. </p>
1
Java equivalent to python's "with"
<p>Python has a nice feature: the "with" statement. It's useful for making global changes that affect all code called within the statement.</p> <p>e.g. you could define a class CapturePrintStatements to capture all print statements called within the "with"</p> <pre><code>with CapturePrintStatements() as c: print 'Stuff Done' print 'More Stuff Done' assert c.get_text() == 'Stuff Done' </code></pre> <p>Is there an equivalent in Java?</p>
1
How to select/lock cell network frequency band?
<p>I am developing a very specialized piece of software for Android and I need the capability to select and lock on to a specific frequency band within the cell network. Does anyone know a way of doing this. I realize there is no API, but maybe by issuing AT commands directly to the modem chip or something?</p>
1
EF Core column name from mapping api
<p>In EF 6.1 the mapping API was introduced where we could finally get access to table names and column names. Getting the table name is a very nice change in EF Core, but I have not yet uncovered how to get the column names.</p> <p>For anyone interested here is how I got the table name in the latest version (RC1)</p> <pre><code>context.Model.FindEntityType(typeof(T)).SqlServer().TableName </code></pre> <p>What is the current method to get column names or is this not available yet?</p>
1
What is correct Native Library Path to use OpenCV in eclipse-ubuntu
<p>I have an issue in setting native library path for opencv in eclipse-ubuntu.i am using ubuntu 15.04.installed opencv 3.1.0 following this link <a href="http://milq.github.io/install-opencv-ubuntu-debian/" rel="noreferrer">http://milq.github.io/install-opencv-ubuntu-debian/</a> and add new library(OpenCV) in eclipse and set it's jar path as</p> <pre><code>/home/user/opencv-3.1.0/build/bin/opencv-310.jar </code></pre> <p>and native library path as</p> <pre><code>/home/user/opencv-3.1.0/build/lib </code></pre> <p><code>lib</code> folder contains <code>.so</code> and <code>.a</code> files. But when i try to use Mat object it gives me error:here is <strong>Main Method</strong></p> <pre><code>System.out.println("Welcome to OpenCV hhhh " + Core.VERSION); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Mat img=new Mat(); </code></pre> <p>and here is screenshot of my code and console <a href="https://i.stack.imgur.com/1jlRz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1jlRz.png" alt="enter image description here"></a> it gives me error:</p> <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat()J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.&lt;init&gt;(Mat.java:24) </code></pre> <p>if i use mat like this</p> <pre><code>Mat m1 =Imgcodecs.imread("/home/zed/Desktop/img.png"); </code></pre> <p>then it gives me diff error:</p> <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(Ljava/lang/String;)J at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method) at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:102) </code></pre> <p>am i giving right path for native library? If not then what is the right path for Native Library to use Opencv3.1.0 in eclipse-ubuntu</p>
1
PostgreSQL query for a list of allowed values in a constraint?
<p>Given a PostgreSQL table named <code>requests</code> with a column named <code>status</code> and a constraint like this:</p> <pre><code>ALTER TABLE requests ADD CONSTRAINT allowed_status_types CHECK (status IN ( 'pending', -- request has not been attempted 'success', -- request succeeded 'failure' -- request failed )); </code></pre> <p>In <code>psql</code> I can pull up information about this constraint like this:</p> <pre><code>example-database=# \d requests Table "public.example-database" Column | Type | Modifiers ----------------------+-----------------------------+------------------------------------------------------------------- id | integer | not null default nextval('requests_id_seq'::regclass) status | character varying | not null default 'pending'::character varying created_at | timestamp without time zone | not null updated_at | timestamp without time zone | not null Indexes: "requests_pkey" PRIMARY KEY, btree (id) Check constraints: "allowed_status_types" CHECK (status::text = ANY (ARRAY['pending'::character varying, 'success'::character varying, 'failure'::character varying]::text[])) </code></pre> <p>But is it possible to write a query that specifically returns the <code>allowed_status_types</code> of pending, success, failure?</p> <p>It would be great to be able to memoize the results of this query within my application, vs. having to maintain a duplicate copy.</p>
1
Onsen 2.0 - Adding event listener to Ons-Switch with Javascript
<p>I fear I am missing something really simple, but I have tried multiple attempts with various errors. On to the code:</p> <pre><code>&lt;script&gt; document.getElementById("optStats").on("change", function(e) { alert("Switch changed!"); }); &lt;/script&gt; &lt;ons-switch modifier="list-item" id="optStats"&gt;&lt;/ons-switch&gt; </code></pre> <p>So the above does not work. It generates an error of <code>Uncaught TypeError: Cannot read property of on of null</code>. So I assumed that I needed to add the function to the onload init function but it still failed with the same error.</p> <p>I have tried all the options listed here: <a href="https://onsen.io/guide/overview.html#EventHandling" rel="nofollow">https://onsen.io/guide/overview.html#EventHandling</a> without success. This would include using var instead of id and just about anything else listed that I thought would work.</p> <p>Edit: Full code that is not working, but works in codepen without template tag.</p> <pre><code>&lt;ons-template id="options.html" &gt; &lt;ons-page&gt; &lt;ons-toolbar&gt; &lt;div class="center"&gt;Options&lt;/div&gt; &lt;/ons-toolbar&gt; &lt;ons-list modifier="inset" style="margin-top:10px;"&gt; &lt;ons-list-item&gt; Detailed Stats &lt;ons-switch modifier="list-item" id="optStats"&gt;&lt;/ons-switch&gt; &lt;/ons-list-item&gt; &lt;/ons-list&gt; &lt;/ons-page&gt; &lt;/ons-template&gt; </code></pre> <p>I am using this in ons.ready() and have tried it outside which results in the same error, <code>cannot read property of addEventListener</code>, as listed above for both.</p> <pre><code>document.getElementById('optStats').addEventListener('change', function(e) { console.log('click', e.target.checked); }); </code></pre> <p><strong>Last Update I swear: FINALLY!!!! Thank you @Fran-dios!</strong></p> <p>After working with this, init is not the event you want to use, you definitely want to use show for what I was trying to do.</p> <pre><code>document.addEventListener("show", function(event){ if (event.target.id == "pgOptions") { document.getElementById('optStats').addEventListener('change', function(e) { localStorage.setItem('useDetailedStats', e.target.checked); useDetailedStats = e.target.checked; }); document.getElementById('optStats').setChecked(useDetailedStats); } },false); </code></pre> <p>For whatever reason, when using init on a <code>&lt;ons-tabbar&gt;</code>, whenever you would press the tab, it would cause the switch to change states. By using show, it does not. Additionally, when I logged the init action, the page, even though it was not being shown on app startup, was still being logged as being init twice. Show does not cause this. Either way, the code that @fran-dios provided is the correct basis to get what I needed and his answer is still correct, I just needed to use a different event.</p>
1