pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
1,967,112
0
<p>It's as insecure as the Django test server itself, for starters, like the above answer said -- that is, it's not tested for any sort of security the way a "production-ready" server like CherryPy would be. As a result, there could be all sorts of lurking security issues with users accessing files they shouldn't be able to; while these are generally fixed they're not considered "priority" as they would be with a production server, and no one's really banging on it looking for these things. </p> <p>Furthermore, see this summer's <a href="http://www.djangoproject.com/weblog/2009/jul/28/security/" rel="nofollow noreferrer">Django security update</a> that fixed a situation where a maliciously-crafted URL could give a visitor access to any file the Django user could see, even if it wasn't under the static root. It's fixed, but should give you an idea about why you should use a Real Server in production settings.</p>
30,323,558
0
<p>Place below lines of code into your view hierarchy:</p> <pre><code>- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event { UIView* hitView = [super hitTest:point withEvent:event]; if (hitView != nil) { [self.superview bringSubviewToFront:self]; } return hitView; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event { CGRect rect = self.bounds; BOOL isInside = CGRectContainsPoint(rect, point); if(!isInside) { for (UIView *view in self.subviews) { isInside = CGRectContainsPoint(view.frame, point); if(isInside) break; } } return isInside; } </code></pre> <p>For the more clarification, it was explained in my blog: "goaheadwithiphonetech" regarding "Custom callout : Button is not clickable issue". </p> <p>I hope that helps you...!!!</p>
24,746,210
0
<pre><code>X.each do |key, value| value.class == BigDecimal ? puts value.to_s : puts value end </code></pre> <p>or </p> <pre><code>X.each { |key, value | value.class == BigDecimal ? puts value.to_s : puts value } </code></pre> <p>Check out the ternary operator. </p> <p>Edit:</p> <p>Also in regards to your edited question requesting one string: </p> <p><code>new_array = X.map {|object| object.class == BigDecimal ? object.to_s : object }</code> then turn it into a string with <code>new_array.join("")</code></p>
6,979,943
0
<p>Have you tried</p> <pre><code>if foo.bar == "crazy value" require 'ruby-debug'; debugger end </code></pre> <p>This should place a breakpoint that triggers when you run <code>bundle exec rails server</code> normally, and only when <code>foo.bar</code> has the value you (don't) want.</p> <p>If you are using bundler, and Ruby 1.9 make sure you have </p> <pre><code>gem 'ruby-debug19', :require =&gt; 'ruby-debug' </code></pre> <p>in your Gemfile (in the development and test group).</p>
39,459,006
1
scikit ShuffleSplit raising pandas "IndexError: index N is out of bounds for axis 0 with size M" <p>I'm trying to use a scikit's GridSearch to find the best alpha for a Lasso, and one of parameters I want it iterate is the cross validation split. So, I'm doing:</p> <pre><code># X_train := Pandas Dataframe with no index (auto numbered index) and 62064 rows # y_train := Pandas 1-column Dataframe with no index (auto numbered index) and 62064 rows from sklearn import linear_model as lm from sklearn import cross_validation as cv from sklearn import grid_search model = lm.LassoCV(eps=0.001, n_alphas=1000) params = {"cv": [cv.ShuffleSplit(n=len(X_train), test_size=0.2), cv.ShuffleSplit(n=len(X_train), test_size=0.1)]} m_model = grid_search.GridSearchCV(model, params) m_model.fit(X_train, y_train) </code></pre> <p>But it raises the exception</p> <pre><code>--------------------------------------------------------------------------- IndexError Traceback (most recent call last) &lt;ipython-input-113-f791cb0644c1&gt; in &lt;module&gt;() 10 m_model = grid_search.GridSearchCV(model, params) 11 ---&gt; 12 m_model.fit(X_train.as_matrix(), y_train.as_matrix()) /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/grid_search.py in fit(self, X, y) 802 803 """ --&gt; 804 return self._fit(X, y, ParameterGrid(self.param_grid)) 805 806 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/grid_search.py in _fit(self, X, y, parameter_iterable) 551 self.fit_params, return_parameters=True, 552 error_score=self.error_score) --&gt; 553 for parameters in parameter_iterable 554 for train, test in cv) 555 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self, iterable) 798 # was dispatched. In particular this covers the edge 799 # case of Parallel used with an exhausted iterator. --&gt; 800 while self.dispatch_one_batch(iterator): 801 self._iterating = True 802 else: /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in dispatch_one_batch(self, iterator) 656 return False 657 else: --&gt; 658 self._dispatch(tasks) 659 return True 660 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in _dispatch(self, batch) 564 565 if self._pool is None: --&gt; 566 job = ImmediateComputeBatch(batch) 567 self._jobs.append(job) 568 self.n_dispatched_batches += 1 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __init__(self, batch) 178 # Don't delay the application, to avoid keeping the input 179 # arguments in memory --&gt; 180 self.results = batch() 181 182 def get(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self) 70 71 def __call__(self): ---&gt; 72 return [func(*args, **kwargs) for func, args, kwargs in self.items] 73 74 def __len__(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in &lt;listcomp&gt;(.0) 70 71 def __call__(self): ---&gt; 72 return [func(*args, **kwargs) for func, args, kwargs in self.items] 73 74 def __len__(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/cross_validation.py in _fit_and_score(estimator, X, y, scorer, train, test, verbose, parameters, fit_params, return_train_score, return_parameters, error_score) 1529 estimator.fit(X_train, **fit_params) 1530 else: -&gt; 1531 estimator.fit(X_train, y_train, **fit_params) 1532 1533 except Exception as e: /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/linear_model/coordinate_descent.py in fit(self, X, y) 1146 for train, test in folds) 1147 mse_paths = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, -&gt; 1148 backend="threading")(jobs) 1149 mse_paths = np.reshape(mse_paths, (n_l1_ratio, len(folds), -1)) 1150 mean_mse = np.mean(mse_paths, axis=1) /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self, iterable) 798 # was dispatched. In particular this covers the edge 799 # case of Parallel used with an exhausted iterator. --&gt; 800 while self.dispatch_one_batch(iterator): 801 self._iterating = True 802 else: /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in dispatch_one_batch(self, iterator) 656 return False 657 else: --&gt; 658 self._dispatch(tasks) 659 return True 660 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in _dispatch(self, batch) 564 565 if self._pool is None: --&gt; 566 job = ImmediateComputeBatch(batch) 567 self._jobs.append(job) 568 self.n_dispatched_batches += 1 /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __init__(self, batch) 178 # Don't delay the application, to avoid keeping the input 179 # arguments in memory --&gt; 180 self.results = batch() 181 182 def get(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in __call__(self) 70 71 def __call__(self): ---&gt; 72 return [func(*args, **kwargs) for func, args, kwargs in self.items] 73 74 def __len__(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/externals/joblib/parallel.py in &lt;listcomp&gt;(.0) 70 71 def __call__(self): ---&gt; 72 return [func(*args, **kwargs) for func, args, kwargs in self.items] 73 74 def __len__(self): /home/user/Programs/repos/pyenv/versions/3.5.2/envs/work/lib/python3.5/site-packages/sklearn/linear_model/coordinate_descent.py in _path_residuals(X, y, train, test, path, path_params, alphas, l1_ratio, X_order, dtype) 931 avoid memory copies 932 """ --&gt; 933 X_train = X[train] 934 y_train = y[train] 935 X_test = X[test] IndexError: index 60527 is out of bounds for axis 0 with size 41376 </code></pre> <p>I tried to use X_train.as_matrix() but didn't work either, giving the same error.</p> <p>Strange that I can use it manually:</p> <pre><code>cv_split = cv.ShuffleSplit(n=len(X_train), test_size=0.2) for tr, te in cv_split: print(X_train.as_matrix()[tr], y_train.as_matrix()[tr]) [[0 0 0 ..., 0 0 1] [0 0 0 ..., 0 0 1] [0 0 0 ..., 0 0 1] ..., [0 0 0 ..., 0 0 1] [0 0 0 ..., 0 0 1] [0 0 0 ..., 0 0 1]] [2 1 1 ..., 1 4 1] [[ 0 0 0 ..., 0 0 1] [1720 0 0 ..., 0 0 1] [ 0 0 0 ..., 0 0 1] ..., [ 773 0 0 ..., 0 0 1] [ 0 0 0 ..., 0 0 1] [ 501 1 0 ..., 0 0 1]] [1 1 1 ..., 1 2 1] </code></pre> <p>What am I not seeing here? Am I doing something wrong or is that a scikit bug?</p> <hr> <p><strong>Update 1</strong></p> <p>Just found out that cv parameter is not a cv.ShuffleSplit object. This is counterintuitive for me, since <a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LassoCV.html#sklearn-linear-model-lassocv" rel="nofollow noreferrer">the docs says</a></p> <p><a href="https://i.stack.imgur.com/nHLXC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nHLXC.png" alt="enter image description here"></a></p> <p>Aren't cross_validation classes "object to be used as a cross-validation generator"?</p> <p>Thanks!</p>
10,610,652
0
<p><a href="https://docs.google.com/viewer?url=http://www.google.com/events/io/2011/static/presofiles/dgalpin_android_pirates_and_vampires.pdf" rel="nofollow">The Presentation Notes</a> from <em>Evading Pirates and Stopping Vampires</em></p> <p><strong>Some basic keypoints</strong></p> <ul> <li><a href="https://docs.google.com/viewer?url=http://www.google.com/events/io/2011/static/presofiles/dgalpin_android_pirates_and_vampires.pdf#%3ar.page.15" rel="nofollow">Modify the LVL</a></li> <li>Implement <a href="https://docs.google.com/viewer?url=http://www.google.com/events/io/2011/static/presofiles/dgalpin_android_pirates_and_vampires.pdf#%3ar.page.21" rel="nofollow">LVL Tamper Resistance</a></li> <li>Use <a href="https://docs.google.com/viewer?url=http://www.google.com/events/io/2011/static/presofiles/dgalpin_android_pirates_and_vampires.pdf#%3ar.page.30" rel="nofollow">obfuscation</a></li> <li>Add <a href="https://docs.google.com/viewer?url=http://www.google.com/events/io/2011/static/presofiles/dgalpin_android_pirates_and_vampires.pdf#%3ar.page.25" rel="nofollow">reflection</a> </li> </ul> <p>Please note, the <code>#:r.page.X</code> at the end of the links I've provided will not always bring you to that specific slide page number for whatever reason. If it doesn't, take note and browse manually.</p>
18,946,812
0
<p>i would like to see the retrieveContent method's code if it's possible and if you are trying to read a url's html content directly then there is a nice example here <a href="http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html</a></p>
12,872,862
0
<p>what happens if you change it to: </p> <pre><code>select info1, info2, info3, id from profile_info where id = new.id into @i1, @i2, @i3, @id; If @id is null THEN insert into profile_info (id) values (new.id); ELSE set new.info1 = @i1; set new.info2 = @i2; set new.info3 = @i3; END IF; </code></pre>
15,351,745
0
<p>Use <code>mouseenter</code> and <code>mouseleave</code>. The problem is that <code>mouseoever</code>/<code>mouseout</code> get triggered when you move between child elements, which you don't want.</p> <p><a href="http://jsfiddle.net/ExplosionPIlls/qNBEJ/3/" rel="nofollow">http://jsfiddle.net/ExplosionPIlls/qNBEJ/3/</a></p>
8,482,144
0
<p>Like the other answers above, i agree that this is just asking for an injection attack (and probably other types). Some things that you can do to prevent that and enhance security in other ways could be the following:</p> <p>1 Look for something suspicious with your response handler. Lack of a query variable in the post, for instance, doesn't make sense, so it should just kill the process.</p> <pre><code>@$_POST["query"] or die('Restricted access'); </code></pre> <p>2 Use preg_match to sanatize specific fields.</p> <pre><code>if (!preg_match("/^[a-zA-Z0-9]+$/", $_POST[query])){ die('Restricted access'); } </code></pre> <p>3 Use more fields, even if they are semi-meaningless and hidden, to add more reasons to kill the process through their absence, or lack of a certain text pattern (optional).</p> <p>4 You shouldn't send a complete query through the POST at all. Just the elements that are necessary as input from the user. This will let you build the query in PHP and have more control of what actually makes it to the final query. Also the user doesn't need to know your table names</p> <p>5 Use mysql_real_escape_string on the posted data to turn command characters into literal characters before entering data into a db. This way someone would have a last name of DROP TABLE whatever, instead of actually dropping table whatever.</p> <pre><code>$firstname = mysql_real_escape_string($_POST[fname]); $lastname = mysql_real_escape_string($_POST[lname]); $email = mysql_real_escape_string($_POST[email]); $sql="INSERT INTO someTable (firstname, lastname, email) VALUES('$firstname','$lastname','$email')"; </code></pre> <p>6 Last, but not least, be creative, and find more reasons to kill your application, while at the same time giving the same die message on every die statement (once debugging is done). This way if someone is hacking you, you don't give them any feedback that they are getting through some of your obstacles.</p> <p>There's always room for more security, but this should help a little.</p>
5,637,266
0
<p>I've found a couple of Java crawlers that are supposed to be pretty close to Mercator:</p> <ul> <li><a href="http://nutch.apache.org/" rel="nofollow">Nutch</a> is multithreaded and distributed.</li> <li><a href="http://crawler.archive.org/index.html" rel="nofollow">Heritrix</a> is only multithreaded.</li> </ul> <p>Other references are welcome.</p>
19,266,185
0
<p>This involves some guesswork - does <code>admin</code> relate just to <code>quant1</code>? and <code>admin_custom</code> to just <code>quant1_cust</code>? Then this should reduce the effort required for a distinct list of those 2 fields:</p> <pre><code>SELECT `Fund_ID`, `Fund_Name` FROM `admin` INNER JOIN `quant1` ON `admin`.`Fund_ID` = `quant1`.`Fund_ID` AND `quant1`.`VaR 95`&gt;-0.028 UNION SELECT `Fund_ID`, `Fund_Name` FROM `admin_custom` INNER JOIN `quant1_cust` ON `admin_custom`.`Fund_ID` = `quant1_cust`.`Fund_ID` AND `admin_custom`.`user_id` = `quant1_cust`.`user_id` AND `quant1_cust`.`VaR 95`&gt;-0.028 WHERE `admin_custom`.`user_id`=361 ; </code></pre> <p>Looking at your existing query structure there are several things I would suggest you do not do. There is no point in using UNION and SELECT DISTINCT. Don't use select * with UNION or UNION ALL - be specific and only involve the fields you really need. And your existing where clause does suppress any nulls returned by a left join - so don't use left join.</p> <pre><code>SELECT DISTINCT --&lt;&lt; effort for distinctiveness here ... FROM ( SELECT * --&lt;&lt; too many fields ... UNION --&lt;&lt; effort for distinctiveness here SELECT * --&lt;&lt; too many fields ... ) LEFT JOIN ( SELECT * --&lt;&lt; too many fields ... UNION --&lt;&lt; effort for distinctiveness here SELECT * --&lt;&lt; too many fields ... ) quant1 WHERE quant1 ... </code></pre> <p>edit: an alternate - sorry, it might be easier to follow this way:</p> <pre><code>SELECT `Fund_ID`, `Fund_Name` FROM `admin` INNER JOIN `quant1` ON `admin`.`Fund_ID` = `quant1`.`Fund_ID` WHERE `quant1`.`VaR 95`&gt;-0.028 UNION SELECT `Fund_ID`, `Fund_Name` FROM `admin_custom` INNER JOIN `quant1_cust` ON `admin_custom`.`Fund_ID` = `quant1_cust`.`Fund_ID` AND `admin_custom`.`user_id` = `quant1_cust`.`user_id` WHERE `admin_custom`.`user_id`=361 AND `quant1_cust`.`VaR 95`&gt;-0.028 ; </code></pre>
2,628,350
0
<pre><code> deleted=`mysql mydb -e "delete from mytable where insertedtime &lt; '2010-04-01 00:00:00'"|tail -n 1` int icount = mysql_CountRow(deleted); </code></pre> <p>it works for me try this.</p>
33,168,568
0
Prevent element width from shrinking <p>I have a tooltip with some text, and in order to control the tooltip's position relative to the cursor with CSS, I placed it inside a zero-sized div. Javascript moves the outer div, and the tooltip can be aligned via any of the top/right/left/bottom attributes, depending on which side it should be placed on.</p> <p>However, this creates a new problem - the tooltip contents now tries to use as little width as possible. I can't disable wordwrap because it needs to fit on mobile screens. Without the outer container, it works perfectly, stretching up to the window edge. Is there a way to ignore the outer container while calculating the line breaks?</p> <p>From what I can tell, the tooltip no longer 'sees' the body element so it can't know how much it can stretch. However, controlling the tooltip position directly via Javascript is more complicated if I need to align the bottom or right sides - I have to either consider tooltip size (which can change depending on its position), or set bottom/right properties and consider window size.</p> <p>Here's an example: <a href="http://jsfiddle.net/03gdomLt/1/" rel="nofollow">http://jsfiddle.net/03gdomLt/1/</a><br> The first tooltip works correctly, while the second one tries to shrink to zero width.</p> <pre><code>.tip-outer { position: absolute; top: 200px; left: 100px; } .tooltip { position: absolute; left: 10px; top: 10px; border: 1px solid black; } &lt;div class="tip-outer"&gt; &lt;div class="tooltip"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra feugiat augue, non pretium massa ultricies vel. In hendrerit tellus. &lt;/div&gt; &lt;/div&gt; &lt;div class="tooltip"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra feugiat augue, non pretium massa ultricies vel. In hendrerit tellus. &lt;/div&gt; </code></pre>
13,152,679
0
<p>Scripting may be your best choice. </p>
14,499,413
0
<p>You can use like </p> <pre><code>CREATE OR replace PROCEDURE Test_procedure IS date CHAR(10); BEGIN SELECT To_char(SYSDATE, 'MM/DD/YYYY') INTO date FROM dual; dbms_output.Put_line(date); END; </code></pre> <p>it will return date into char format.</p> <p>If you want to get date into date format just declare the date type variable then assign the sysdate value INTO that variable.Then use DBMS_OUTPUT.PUT_LINE(variable) to print the DATE.</p>
6,038,296
0
<p>If there's an outside chance that the order of <code>[i]</code> is not in a predictable order, or possibly has gaps, but you need to use it as a key:</p> <pre><code>public class Thing { int SubjectID { get; set; } int VarNumber { get; set; } string VarName { get; set; } string Title { get; set; } } Dictionary&lt;int, Thing&gt; things = new Dictionary&lt;int, Thing&gt;(); dict.Add(i, thing); </code></pre> <p>Then to find a <code>Thing</code>:</p> <pre><code>var myThing = things[i]; </code></pre>
36,747,651
0
<p>actually JPA2 is specification and Hibernate is implementation of this specification. </p> <p>None of them provides cache implementation, except session cache (your entities within single transaction/session interaction) </p> <p>If you plan to add possibility to replace hibernate, then use pure JPA2 annotations and configurations. </p> <p>Hibernate's annotation @Cache provides a bit more fine grained control on how entities are stored in cache, JPA's @Cacheable provides only possibility either to include in cache or not (all the control of storage in cache is defined in the general JPA configuration and caching implementation). </p>
21,287,685
0
<blockquote> <p>Is node traversal far better (in a multilevel datetime index) in term of performance than dealing with indexed properties for dates in this case?</p> </blockquote> <p>No, indexed properties for dates is more performant than traversals for this type of data structure.</p> <p>Here is detailed example of using a hybrid approach. Consider the following subgraph, where the elipses indicate a continuing pattern in the graph.</p> <p><img src="https://i.stack.imgur.com/896SD.png" alt="Multilevel Calendar Index"></p> <p>Please take a look at <a href="https://gist.github.com/kbastani/8519557" rel="nofollow noreferrer">https://gist.github.com/kbastani/8519557</a> for the full calendar Cypher scripts that get or create (merge) a multilevel datetime index. This data structure allows you to traverse from one date to another date to get a range of events for a time series. A combination of both indexed property matching and traversals is the best approach, and is performant when modeled correctly.</p> <p><img src="https://i.stack.imgur.com/Pc1iB.png" alt="Example Data Model for Time"></p> <p>For example, consider the following Cypher query:</p> <pre><code>// What staff have been on the floor for 80 minutes or more on a specific day? WITH { day: 18, month: 1, year: 2014 } as dayMap // The dayMap field acts as a parameter for this script MATCH (day:Day { day: dayMap.day, month: dayMap.month, year: dayMap.year }), (day)-[:FIRST|NEXT*]-&gt;(hours:Hour), (hours)&lt;-[:BEGINS]-(shift:Event), (shift)&lt;-[:WORKED]-(employee:Employee) WITH shift, employee ORDER BY shift.timestamp DESC WITH employee, head(collect(shift)) as shift MATCH (shift)&lt;-[:CONTINUE*]-(shifts) WITH employee.firstname as first_name, employee.lastname as last_name, SUM(shift.interval) as time_on_floor // Only return results for staff on the floor more than 80 minutes WHERE time_on_floor &gt;= 80 RETURN first_name, last_name, time_on_floor </code></pre> <p>In this query we are asking the database "What staff have been on the floor for 80 continuous minutes or more on a specific day?" where shifts are broken up into 20 minute continuous intervals pointing to the next one in the series as CONTINUE or BREAK. </p> <p>First you start with matching the day using the indexed properties. Then you scan the day's hours for connected events by traversing the datetime multilevel index. Then reverse the order of the events to get the most recent event in the series. Then traverse until a "BREAK" relationship is encountered. Finally, apply the condition of time_on_floor being greater or equal to 80 minutes.</p>
9,846,677
0
print json data <p>This is jquery (ajax) -> php response</p> <pre><code> {"errorInfo":["23000",1062,"Duplicate entry 'blahblah' for key 'sn'"]} </code></pre> <p>how to print out, with jquery, only "Duplicate entry 'blahblah' for key 'sn'"</p> <pre><code> success: function (html) { $("#notification").fadeIn("slow") .text(html); //Duplicate entry 'blahblah' for key 'sn'? html-&gt;errorInfo[2]? } </code></pre> <p>thank you </p> <p>UPDATE:</p> <p>It's Standard PDO Error function</p> <pre><code> catch(PDOException $e) { print json_encode($e); } </code></pre> <p>that print out like this: </p> <pre><code> {"errorInfo":["23000",1062,"Duplicate entry 'SDAAASSASADASADASDAS' for key 'sn'"]} </code></pre> <p>UPDATE:</p> <p>I change it on other side, on source, I use </p> <pre><code> print json_encode($e-&gt;errorInfo[2]); instead of print json_encode($e) </code></pre>
11,675,622
0
Split String into Array with No Delimiter <p>I have a string like <code>s = "abcdefgh"</code>. I want to split it by number of characters like:</p> <pre><code>a(0)="ab" a(1)="cd" a(2)="ef" a(3)="gh" </code></pre> <p>Can someone tell me how to do this?</p>
39,419,865
0
<p>Build a string up, and then print it out:</p> <pre><code>std::stringstream value; for (int i=0;i&lt;N;i++) { value &lt;&lt; covariance[0][i]; if (i + 1 &lt; N) { value &lt;&lt; ","; } } YAML::Emitter out; out &lt;&lt; YAML::BeginMap; out &lt;&lt; YAML::Key &lt;&lt; "covariance" &lt;&lt; YAML::Value &lt;&lt; value.str(); out &lt;&lt; YAML::EndMap; </code></pre> <p>The point is that the value you're printing isn't a YAML list, it's just a plain string that happens to look a little bit like YAML. So you can't use yaml-cpp to format it for you; you need to do that yourself.</p>
31,707,505
0
<p>Check your <code>php.ini</code> file for <code>date.timezone</code> and make sure its set to </p> <p><code>date.timezone = "Europe/Moscow"</code></p>
17,410,137
0
<p>Well, as far as I can understand, you want to join the two tables. This is done like this:</p> <pre><code>SELECT distinct it.id, idesc.title FROM item it JOIN item_description idesc ON it.id=idesc.item_id; </code></pre> <p>Of course, you need a column in your <code>item_description</code> table that corresponds to your <code>id</code> column in the <code>item</code> table.</p>
23,418,867
0
SBT ScalaTest dependency resolving <p>In <strong>build.sbt</strong>. </p> <pre><code>resolvers += "Repo1" at "http://oss.sonatype.org/content/repositories/releases" resolvers += "Repo2" at "http://repo1.maven.org/maven2" libraryDependencies ++= Seq( "org.specs2" %% "specs2" % "2.3.11" % "test", "org.scalatest" %% "scalatest_2.11" % "2.1.5" % "test" ) scalacOptions in Test ++= Seq("-Yrangepos") // Read here for optional dependencies: // http://etorreborre.github.io/specs2/guide/org.specs2.guide.Runners.html#Dependencies resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo) </code></pre> <p>Symptoms:</p> <ul> <li><code>Specs2</code> is resolvable, <strong><a href="http://www.scalatest.org/download" rel="nofollow">scalatest</a> is not</strong></li> </ul> <blockquote> <p>org.scalatest#scalatest_2.11_2.10;2.1.5: not found</p> </blockquote> <ul> <li>With <code>Maven</code>, using the same repositories - everything works perfectly.</li> </ul> <p>Question:</p> <ul> <li>What's wrong with <code>sbt</code>, why does it complain all the time?</li> </ul>
25,595,348
0
SonarQube +Unit Test coverage +Java Project <p>I am invoking SonarQube analysis from Jenkins and able to get the Unit Test Success Percentage but not able to see the Unit Tests coverage??? Can anyone please help in getting this in Sonar dashboard?What parameter should I add while invoking from Jenkins?Please let know for both Windows and Linux machines?</p> <p>This is a huge blocker for my project.Please help.Sonar version is 4.4.</p>
14,788,166
0
<p>It depends on what kind of a website it is, but if the changes made to the DOM are meant to be permanent, and changes are only permitted to be made by registered users, I would maybe write the HTML snippet to a file, and keep track of the changes in the database. And then render the HTML snippet every time the page is requested.</p>
40,890,833
0
<p>In my case, after setting the limit @ <strong>node.js</strong> (webapp) <code> var express = require('express'); var app = express(); var bodyParser = require('body-parser'); app.use(bodyParser.json({limit:'50mb'})); app.use(bodyParser.urlencoded({extended:true, limit:'50mb'})); </code></p> <p>I also <strong>(most important)</strong> had to set up the limit @ <strong>nginx</strong> (webapp reverse proxy) <code> # Max upload size. client_max_body_size 50M; </code></p>
32,666,575
0
<p>You should convert your cert and you can use openssl to achieve the conversion that you are wanting. </p> <p>For instance:</p> <pre><code>openssl pkcs12 -export -out cert.pfx -inkey cert.key -in cert.crt </code></pre>
35,895,541
0
CRM Online 2015 Authentication Raw Soap <p>Hi and thanks for taking this time to look,</p> <p>I've recently been asked to investigate integration using CRM Online 2015, I've come across some issues trying to Authenticate using Raw SOAP requests.</p> <p>While I know there's other ways to authenticate, predominantly the using the CRM SDK, my iron will is pushing me to find a solution using Raw SOAP.</p> <p>I came across a very helpful blog by Jason Lattimer: <a href="http://jlattimer.blogspot.co.uk/2015/02/soap-only-authentication-using-c.html" rel="nofollow">http://jlattimer.blogspot.co.uk/2015/02/soap-only-authentication-using-c.html</a></p> <p>Following this sample, I successfully authenticated with a Trial CRM account using RAW SOAP... Great... Done... I was wrong.</p> <p>As soon as I pointed this sample at the CRM development environment I got a SOAP error:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault"&gt; &lt;S:Body&gt; &lt;S:Fault&gt; &lt;S:Code&gt; &lt;S:Value&gt;S:Sender&lt;/S:Value&gt; &lt;S:Subcode&gt; &lt;S:Value&gt;wst:FailedAuthentication&lt;/S:Value&gt; &lt;/S:Subcode&gt; &lt;/S:Code&gt; &lt;S:Reason&gt; &lt;S:Text xml:lang="en-US"&gt;Authentication Failure&lt;/S:Text&gt; &lt;/S:Reason&gt; &lt;S:Detail&gt; &lt;psf:error&gt; &lt;psf:value&gt;0x80048821&lt;/psf:value&gt; &lt;psf:internalerror&gt; &lt;psf:code&gt;0x80047860&lt;/psf:code&gt; &lt;psf:text&gt;Direct login to WLID is not allowed for this federated namespace&lt;/psf:text&gt; &lt;/psf:internalerror&gt; &lt;/psf:error&gt; &lt;/S:Detail&gt; &lt;/S:Fault&gt; &lt;/S:Body&gt; &lt;/S:Envelope&gt; </code></pre> <p>The only difference I can think between the Trial version which worked and the development environment is that the development environment setup uses ADFS / AD On-Premises.</p> <p>Fiddler logs show that Jason's Sample goes straight to login.microsoftonline.com whereas CRM SDK (which works) goes to dynamicscrmemea.accesscontrol.windows.net.</p> <p>So I believe this is the problem area!</p> <p>I've been around in circles on stack overflow/other sources, I have a feeling it will a relatively small change required to the SOAP request but I've reached the point where I need some fresh eyes/advice.</p> <p>Has anyone had experience with this setup? Can anyone gently push me in the right direction?</p> <p>Many Thanks</p> <p>Gareth</p>
5,500,341
0
<p>Generally, function like macro can be used to prevent unintentional macro expansion.<br> For example, assuming that we have the following macro call:</p> <pre><code>BOOST_PP_CAT( BOOST_PP_ITERATION, _DEPTH ) </code></pre> <p>and we expect this will be expanded into <code>BOOST_PP_ITERATION_DEPTH</code>.<br> However, if <code>BOOST_PP_ITERATION</code> is an object like(non-functional) macro, it will be expanded to its own definition before the token <code>BOOST_PP_ITERATION_DEPTH</code> is generated by concatenation.</p>
1,557,451
0
<p>If you're changing the data directed by the iterator, you're changing the list.</p> <blockquote> <p>The idea that I'm trying to express here, of course, is that the passed in list cannot/willnot be changed, but once I make the list reference const I then have to use 'cons_iterator's which then prevent me from doing anything with the result.</p> </blockquote> <p>What is "dong anything"? Modifying the data? That's changing the list, which is contradictory to your original intentions. If a list is const, it (and "it" includes its data) is constant.</p> <p>If your function were to return a non-const iterator, it would create a way of modifying the list, hence the list wouldn't be const.</p>
3,660,512
0
<p>Cross-platform generally refers to a technology which can be used for multiple operating systems. For example, Mono is an open-source implementation of the Common Language Runtime (CLR), which are the underlying libraries required by .NET.</p> <p>Mono runs on Linux, BSD, Unix, Mac OS X, Solaris and Windows. Mono itself is not an IDE, but several cross-platform IDEs exist as well. The most popular is <a href="http://monodevelop.com/" rel="nofollow noreferrer">MonoDevelop</a>.</p> <p>Several languages are built on top of the .NET framework such as C# and VB.NET. C# is the most popular for cross-platform development.</p>
16,286,526
0
Magento Checkout Conversion Back to Base Currency not Working <p>After installing a magento connect theme I am having an issue on checkout whereby; whichever total is being displayed in a converted currency (not base), is not being converted back into base on final checkout/place order. Any ideas where the code is that handles this final conversion? I have contacted the extension vendor though am awaiting a reply. Thank you</p> <pre><code>Subtotal Rs6,723.03 Processing Fee Rs672.30 Grand Total Rs7,395.34 Your credit card will be charged for £7,395.34 </code></pre> <p>Screenshot here (less than 10 rep so can't embed! only posted once before which resulted in a triumph!)</p> <p><img src="https://i.stack.imgur.com/9ccO7.png" alt=""></p> <p>EDIT -----</p> <p>Hi thanks for the suggestion, however the currency rates are set and the correct values for each are confirmed. When using a default magento install (sample data) the problem is not occurring, which means it’s isolated to the extension I’m using.</p> <p>I have had a dig about in the theme files and have isolated the currency functions to be occurring in the the files found in the following path (theme files)</p> <p>app\code\local\ <em>extension vendor</em> \ <em>extension name</em></p> <p>Within this folder there are various files which may be pertaining to currency inluding:</p> <p>CartController.php</p> <p>Order.php</p> <p>Price.php</p> <p>Total.php</p> <p>I am almost certain that it’s going to be a line of code within one of these files, or those within the specified folder that’s causing the issue. I am hoping someone is able to tell me where this final conversion is happening and in what file. There are equivalents of these files in the core magento folder and having this theme installed tells the website to use the third-party variants of the core/default magento file. If someone knows which file it is, I can post the code for that file to have a look at or perhaps if I knew which file I could debug myself.</p> <p>Thanks again!</p>
22,524,237
0
<p>You dont need to pass class selector <code>.</code> in <code>removeClass()</code>.so use:</p> <pre><code>$(this).removeClass('colspan') </code></pre> <p>to remove both classes <code>colspan</code> and <code>create</code>,use:</p> <pre><code>$(this).removeClass('colspan create') </code></pre>
17,316,311
0
Get Checked RadioButtons using JavaScript <p>so I’m trying to build a win 8 app, which includes a WebView. The WebView contains the HTML code (+JavaScript) below.</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8' &gt; &lt;script type='text/javascript'&gt; function get_radio_value() { for (var i=0; i &lt; document.myForm.frage1.length; i++) { if (document.orderform.frage1[i].checked) { var rad_val = document.myForm.frage1[i].value; return rad_val; } } } &lt;/script&gt; &lt;title&gt;Kundenfragebogen&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Kundenfragebogen&lt;/h1&gt; &lt;div id='myDiv'&gt;Hello&lt;/div&gt; &lt;form name='myForm' action=''&gt; &lt;table border='2'&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;sehr gut&lt;/td&gt; &lt;td&gt;gut&lt;/td&gt; &lt;td&gt;schlecht&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Wie geht es Ihnen?&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage1" value='1'/&gt;Mir ging es noch nie besser!&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage1" value='2'/&gt;Es geht mir so wie immer.&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage1" value='3'/&gt;Heute geht einfach gar nichts…&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Können Sie Auto fahren?&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage2" value='1'/&gt;Ja&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage2" value='3'/&gt;Nein&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Möchten Sie unseren Newsletter abonnieren?&lt;/td&gt; &lt;td&gt;&lt;input type='radio' name="frage3" value='1'/&gt;Ja&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type='button' value='Formular absenden' onclick="return get_radio_value()"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So the html contains some radio buttons and a button. I’ve used JavaScript ~2 years ago (just a little), so I don’t really know how to write the exact code. I’ve found something on the internet, but it doesn’t do what I want. I want to have the following:</p> <p>The user can check the RadioButtons. When the user clicks the Button, the JavaScript function should return all the checked radio buttons (I only need to know which RadioButton is checked). Since I know the name of the RadioButtons in my Windows 8 App, I can do the following:</p> <pre><code>var object = WebView.InvokeScript("JavaScriptFunctionNAME", NameOfRadiobutton); </code></pre> <p>So the WebView invokes the script and should get as a return the VALUE of the RadioButton, which is checked. </p> <p>“JavaScriptFunctionNAME” = name of the function in Javascript</p> <p>NameOfRadiobutton = the name of the RadioButton as a parameter (for example “frage1”).</p> <p>Currently I’m returning the value of the radiobutton, which is checked in the RadioGroup “frage1”. How can I check every RadioButton by it’s parameter? By this I mean I have a parameter “frage1” and return the value of the checked RadioButton. After this, I call the function again with the parameter “frage2” and return the checked RadioButtons value. Could anyone help me out with the JavaScript-function?</p>
3,141,079
0
<p>Short answer: NO</p> <p>Longer answer: This should show some means to get at the intervals but it does not</p> <pre><code>&lt;div id="msg"&gt;&lt;/div&gt; &lt;script&gt; function test() { document.getElementById('msg').innerHTML=x+':'+new Date(); cnt++; if (cnt==3) { alert('hey'); clearAll(); } } var x = setInterval(test,1000) var y = setInterval(test,2000) var cnt = 0; var win = window; for (var obj in window) { if (obj==x) alert('found!') document.write('&lt;hr&gt;'+obj+':'+typeof obj) } alert(window.x+'-'+window.y) function clearAll() { clearInterval(); // does not work } &lt;/script&gt; </code></pre>
13,199,923
0
A reflection after a Java interview: Inheritance and polymorphism <p>The following code:</p> <pre><code>class Base{} class Agg extends Base{ public String getFields(){ String name="Agg"; return name; } } public class Avf{ public static void main(String args[]){ Base a=new Agg(); //please take a look here System.out.println(((Agg)a).getFields()); // why a needs cast to Agg? } } </code></pre> <p>My question is: why we can't replace <code>((Agg)a).getFields()</code> to <code>a.getFields()</code>? Why we need to type cast on <code>a</code>? And I mention that <code>getFields()</code> is not defined in class <code>Base</code>, thus class <code>Agg</code> does not extend this method from its base class. But if I defined method <code>getFields()</code> in class <code>Base</code>, like:</p> <pre><code>class Base{ public String getFields(){ String name="This is from base getFields()"; return name; } } </code></pre> <p>everything would be all right. Then <strong>((Agg)a).getFields() is equivalent to a.getFields()</strong></p> <p>In the code </p> <pre><code>Base a=new Agg(); </code></pre> <p>Does this line means <code>a</code> has the reference of <code>Agg()</code> and a can invoke directly the method of class <code>Agg</code>. But why is there difference if I do not define the method <code>getFields()</code> in class <code>Base</code>? Can any one explain this to me? </p>
25,675,646
0
<p>The Linq way:</p> <pre><code>var lastname = "Abumademal"; var formatted = (new string(lastname.Take(8).ToArray())).PadRight(lastname.Length, '*'); // will yield "Abumadem**" </code></pre> <p>"Take 8 chars and create a new string from this array, then pad it with as many * as needed."</p> <p>full implementation:</p> <pre><code>private string lastname; public string LastName { get { if (null == this.lastname) { return null; } char[] firsteight = this.lastname.Take(8).ToArray(); string tmp = new string(firsteight); // padding this way wasn't the actual requirement ... string result = tmp.PadRight(this.lastname.Length, '*'); return result; } set { this.lastname = value; } } </code></pre>
3,014,238
0
How to prepend a JS event handler in Prototype? <p>I would like to add an event listener/handler to be prepended before an existing event handler in Prototype. Here is the example:</p> <pre><code>&lt;form ... onsubmit="alert('foo')" id="f1"&gt; $('f1').observe("submit", function() { alert('do this before foo'); }); &lt;/form&gt; </code></pre>
13,629,575
0
How to use SSH with PuTTY using a proxy server? <p>This is a journey that doesn't seem to have an end. Please bear with the story.</p> <p>I am wanting to write a variety of Perl programs that connect to an SSH server. The server is a Mac, the client is Windows behind an HTTP proxy. PuTTY works perfectly to connect, but executing the Perl scripts isn't ideal, for several reasons.</p> <p>I want to have an interactive (not with the user, but with the software running on the server) Perl program running on the client and the server, a la how rsync works with the -e option.</p> <p>First step, how do I connect? I use plink (from PuTTY), which has a variety of useful options... tunneling, running a series of commands, etc. From there, I can easily run commands and scripts on the server and get back the result, process the result, and then do the next command. But this is SLOW because it has to renegotiate the PuTTY/SSH connection each time. Hence the desire for an interactive approach.</p> <p>When running plink in this manner, I could interact with the plink command, but I'm having trouble with double-piping (input and output, never mind triple-piping to also get STDERR). I tried everything on <a href="http://docstore.mik.ua/orelly/perl2/prog/ch16_03.htm" rel="nofollow">http://docstore.mik.ua/orelly/perl2/prog/ch16_03.htm</a> and nothing worked. Got various errors, etc.</p> <p>Next I tried writing my own client/server programs using sockets. Worked pretty well, except for some reason each time I run the SocketServer on the server program and then connect to it (using plink to tunnel localhost to the server's port), the port closes itself off and refuses future connections. So I have to change the port every time, which seems counterproductive (probably an issue with my code, but I don't see it).</p> <p>The next step was trying Expect.pm. However, that seems to only work under Linux or CYGWIN, which I don't want to get too deep into. This needs to stay native Windows as much as possible.</p> <p>My latest is looking into Net::SSH::Perl and other SSH modules. I set up a port 22 tunnel with plink and then in CYGWIN I try:</p> <pre><code>ssh user@localhost </code></pre> <p>I enter my password and all is wonderful! Works like a champ!</p> <p>So then I try the following program (again, with the port 22 tunnel established)</p> <pre><code>use Net::SSH::Perl; my $ssh = Net::SSH::Perl-&gt;new('localhost'); $ssh-&gt;login('&lt;user&gt;','&lt;pass&gt;'); my($stdout, $stderr, $exit) = $ssh-&gt;cmd('ls -l'); while (&lt;$stdout&gt;) { print; } </code></pre> <p>(user and pass above are substituted for the real user and pass) I can see the plink tunnel opening the forwarded port, but the program returns</p> <pre><code>Permission denied at E:\Scripts\ExplorationScripts\NetSSHPerl.pl line 3 </code></pre> <p>So, this is where I am... I have many more SSH Perl modules to try, but I was wondering if anyone else had this situation. I see tons of people using PuTTY and SSH stuff, but none of them are going through a proxy (and thus NEED PuTTY). And I don't have the time or patience to mess with something like corkscrew, so please let's not go down that particular rabbit hole.</p> <p>I'm open for suggestions...</p> <p>Thanks.</p> <p>... continuing the journey... the new thing I've tried, and y'all will probably laugh at this bass-ackward solution... I tunneled port 23 through the Mac to a Windows machine on the same network running Telnet. Then, using Net::Telnet I am able to telnet to the Windows machine. Very awkward. I also wanted to be able to establish the tunnel and then kill it at the end of the program, so I added some oddball stuff. Check it out and PLEASE help me get a better solution to this.</p> <pre><code>use Net::Telnet; #establish tunnel open my $tunnel,"| plink -L 23:&lt;local IP of windows machine&gt;:23 &lt;server&gt; -pw &lt;pass&gt;"; sleep 7; #Now it's time to do the telnet boogie! my $t=new Net::Telnet ( Timeout=&gt;10, Errmode=&gt;'return',Prompt =&gt; '/&gt;$/'); #$t-&gt;output_log('telnet.log'); $t-&gt;input_log('telneti.log'); $t-&gt;open("localhost"); $t-&gt;login('&lt;user&gt;','&lt;pass&gt;'); @lines = $t-&gt;cmd("dir /b"); print @lines; $t-&gt;close(); print $tunnel "exit\n"; close $tunnel; </code></pre> <p>The $tunnel thing is the weirdness. plink will establish a terminal session, so I opened a handle to it's STDIN via the pipe. The -L establishes the tunnel. When I'm done with the telnetting, I print "exit" to plink which exits the bash session. I also use the "sleep 7" to give it enough time to establish the session. Ugh! But it seems to work moderately well.</p>
31,124,505
0
<p>Putting hpaulj's answer into actual code, something like this works:</p> <pre><code>class CustomHelpFormatter(argparse.HelpFormatter): def _format_action_invocation(self, action): if not action.option_strings or action.nargs == 0: return super()._format_action_invocation(action) default = self._get_default_metavar_for_optional(action) args_string = self._format_args(action, default) return ', '.join(action.option_strings) + ' ' + args_string fmt = lambda prog: CustomHelpFormatter(prog) parser = argparse.ArgumentParser(formatter_class=fmt) </code></pre> <p>To additionally extend the default column size for help variables, add constructor to <code>CustomHelpFormatter</code>:</p> <pre><code>def __init__(self, prog): super().__init__(prog, max_help_position=40, width=80) </code></pre> <p>Seeing it in action:</p> <pre><code>usage: bk set [-h] [-p] [-s r] [-f] [-c] [-b c] [-t x y] [-bs s] [-bc c] [--crop x1 y1 x2 y2] [-g u r d l] monitor [path] positional arguments: monitor monitor number path input image path optional arguments: -h, --help show this help message and exit -p, --preview previews the changes without applying them -s, --scale r scales image by given factor -f, --fit fits the image within monitor work area -c, --cover makes the image cover whole monitor work area -b, --background c selects background color -t, --translate x y places the image at given position -bs, --border-size s selects border width -bc, --border-color c selects border size --crop x1 y1 x2 y2 selects crop area -g, --gap, --gaps u r d l keeps "border" around work area </code></pre>
17,221,784
0
Using a Singleton pattern to Linq to Sql Data Context <p>I have some confusion in Linq to SQL.I am searching for an actual reason why Data context class gives follwing Exception some times .</p> <p>"There is already an open data reader associated with this command which must be closed first</p> <p>Specially in multitasking environment.Most people are saying that the reason is ,Data Context is not thread Safe.All are suggesting to use DataContex as one per unit of work.</p> <p>Please refer following thread for best answer </p> <p><a href="http://stackoverflow.com/questions/4918625/linq-to-sql-datacontext-across-multiple-threads">Linq-to-SQL Data Context across multiple threads</a></p> <p>But in my case,i am using another class call "A" which is implemented in Singleton pattern.Purpose of this class is ,provide Data context object in singleton manner.I am maintaining instance of this class "A" as global instance in derived class and calling to Datacontex by using particular instance.</p> <p><strong>My question is,</strong></p> <p>Will my method call cause uncontrolled memory growth ? based on my understanding,singleton maintaining one instance as static object .If my assumption is wrong ,please give me good explanation.</p> <p><strong>Note:</strong></p> <p>Any way my method call also throws same exception.So i am sure same problem is happen in this scenario also.</p>
19,353,946
0
absolute position div disappers inside parrent div <p>I am trying to put simple divs and arrange them, but my child div disappearing from parent div even though I am using parent div with relative and child div with absolute positioning. I want connect_us_01 and registeration divs insideheader_block1. I am working towards responsive webdesign. Many thanks.</p> <p><a href="http://jsfiddle.net/aNzEB/" rel="nofollow">JSFiddle</a></p> <pre><code>&lt;div id="header"&gt; &lt;div id="header_block1"&gt; &lt;div id ="registeration"&gt;reg&lt;/div&gt; &lt;div id ="connect_us_01"&gt;social media&lt;/div&gt; &lt;/div&gt; &lt;div id="header_block2"&gt; &lt;div id="crown_logo"&gt;logo&lt;/div&gt; &lt;div id="nav"&gt;navigation&lt;/div&gt; &lt;div class="contact_No_01"&gt;020324234233&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <h2> css</h2> <pre><code>#header { position: relative; width: 100%; background-color: #ff6a00; } #header_block1 { position: relative; margin: 0 auto; width: 90%; background-color: pink; } #header_block2 { margin: 0 auto; width: 90%; position: relative; background-color: aqua; } /*----social media &amp; connect us block*/ #connect_us_01 { position: absolute; width: 300px; height: 50px; right: 0; background-color: blue; } #registeration { position: absolute; left: 1px; width: 200px; height: 50px; background-color: brown; } </code></pre>
8,040,163
0
<p>First dataset add this SQL</p> <pre><code>Select ContryName, CountryID From Country </code></pre> <p>Assuming the name the above dataset's parameter is @country add the following SQL on the second dataset</p> <pre><code>Select RegionName, RegionID From Region Where CountryID IN( @country) </code></pre>
13,003,646
0
<p>You can just use boolean clauses:</p> <pre><code>(assert (myTemp (one asd) (second jhg)) (myTemp (one asd) (second kjh)) (myTemp (one bvc) (second jhg)) (myTemp (one bvc) (second jhg) (third qwe))) (find-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:third qwe)) (&lt;Fact-4&gt;) (find-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:second jhg)) (&lt;Fact-1&gt;) (find-all-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:second jhg)) (&lt;Fact-1&gt; &lt;Fact-3&gt; &lt;Fact-4&gt;) </code></pre>
15,067,139
0
<p>This error is returned when the cell exists and there are childobjects of type link, but not with this index (3). Try to see if you can confirm that the link with index 0 exists by:</p> <pre><code>Set EditLink = Browser("Browser").Page("Page").WebTable("Emp Index").ChildItem(2,3,"Link",0) MsgBox EditLink.Exist(0) </code></pre> <p>To see where that link is placed on your page, you can use <code>EditLink.Highlight</code><br> From this point you can start debugging to see if the link with index 1, 2 and finally 3 exists.</p>
13,304,253
0
Can the android Emulator in eclipse can be shutdown? how? need it for testing my Alarm Manager auto start at boot <p>I dont have an actual Android phone, and i want to test Alarm, but i dont know if its the code that has error, or the emulator doesnt do the way like an actual phone in terms of booting.</p> <p>the Autostart Code is from here: <a href="http://stackoverflow.com/questions/4459058/alarm-manager-example">Alarm Manager Example</a></p> <p>The code doesnt give me error, the simple alarm manager and service is OK, but the autostart of the alarm is not working, i hope its only on the emu, wish it will work in an actual phone. The code below is from the above-mentioned thread, and it also the one that i uses.. i'd put it because maybe the code are the problems</p> <p>Manifest</p> <pre><code>&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"&gt;&lt;/uses-permission&gt; ... &lt;receiver android:name=".AutoStart"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.BOOT_COMPLETED"&gt;&lt;/action&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; ... </code></pre> <p>And this is the on-boot trigger</p> <pre><code>package YourPackage; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class AutoStart extends BroadcastReceiver { Alarm alarm = new Alarm(); @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { alarm.SetAlarm(context); } } } </code></pre>
37,426,564
0
Laravel 5.2 Multi-Auth with API guard uses wrong table <p>I'm trying to get a multi-auth system working where Users can log in via the normal web portal, but a separate database of entities (named "robots" for example) can also log in via an API guard token driver. But no matter what I do, the setup I have is not directing my authentication guard to the correct Robot database and keeps trying to authenticate these requests as Users via tokens (which fails, because users don't have tokens). </p> <p>Can someone help me find where I've gone wrong?</p> <p>I've started by putting together a middleware group in Kernel.php:</p> <pre><code>'api' =&gt; [ 'throttle:60,1', 'auth:api', ], </code></pre> <p>This uses settings in config/auth.php</p> <pre><code>'guards' =&gt; [ 'web' =&gt; [ 'driver' =&gt; 'session', 'provider' =&gt; 'users', ], 'api' =&gt; [ 'driver' =&gt; 'token', 'provider' =&gt; 'robots', ], ], 'providers' =&gt; [ 'users' =&gt; [ 'driver' =&gt; 'eloquent', 'model' =&gt; App\User::class, ], 'robots' =&gt; [ 'driver' =&gt; 'eloquent', 'model' =&gt; App\Models\Robot::class, ], ], </code></pre> <p>The middleware gets called in routes.php</p> <pre><code>Route::group(['middleware' =&gt; 'api'], function () { Route::get('api/request', 'API\RequestController@index'); }); </code></pre> <p>It uses this model:</p> <pre><code>&lt;?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Auth\Authenticatable; class Robots extends Authenticatable { protected $fillable = [ 'serial_number','api_token', ]; protected $guard = 'Robots'; protected $hidden = [ 'api_token', ]; } </code></pre> <p>Any ideas?</p> <p><strong>Update:</strong> on further inspection, it appears that most of the settings in auth.php are not applying properly - is there some way I can force these settings to take effect? </p>
19,614,228
0
<p><code>StreamWriter</code> writes UTF8 text characters to a stream.<br> You're writing <code>plaintext.ToString()</code> as text for the ciphertext.</p> <p>This returns <code>"System.Byte[]"</code>, which does not translate into 16 bytes of UTF8.</p>
40,427,357
0
StreamWriter not writing all characters <p>I have this bit of code run when people close the game to save all their currently selected pets (this is for school don't worry about how I named it "Squirtle", no copyright problems here). The code in question is:</p> <pre><code>using (StreamWriter sw = File.CreateText(@"..\..\pets.txt")) { sw.AutoFlush = true; foreach (Pet p in petList) { sw.Write(p.PetID + ' '); sw.Write(p.Name + ' '); sw.Write(p.HP + ' '); sw.Write(p.Type + ' '); sw.Write(p.Level + ' ' ); sw.Write(p.Rarity + ' '); sw.WriteLine(p.Speed); } } </code></pre> <p>the commas were spaces and I just added the autoflush to try and fix the problem, but basically no matter how many times I run it, the first two, next two, and last 3 pieces of data have no spaces between them, example: 32SQUIRTLE 77AQUATIC 41930. this happens every time I run it and am wondering if anyone knows of why it's doing this? I can use any delimiter also if space and comma are notorious with StreamWriter or something.</p>
35,886,874
0
<p>So you just want to exclude files containing <code>backup</code> in their names? This should work:</p> <pre><code>@echo off setlocal enabledelayedexpansion for /r "C:\Users\b00m49\Desktop\LSPTEST" %%a in (K_E*.dwg) do ( set filename=%%a if "!filename:backup=!"=="!filename!" ( rem start /wait "C:\Program Files\Autodesk\Autocad 2013\acad.exe" "%%a" /b "C:\Users\b00m49\Desktop\LSPTEST\expSQM.scr" ) ) pause </code></pre>
10,115,144
0
<p>In the penultimate line when you create $query_AddTestimonial, the string you're creating isn't putting the php variables in because you're not telling it that they're variables. You can use the php variables like this:</p> <pre><code>$query_AddTestimonial = "INSERT into testimonials (company,job_function,location,overall,project_details,pros,cons,sr_mgmt,submitted_by,class,school,anonymous) VALUES ('{$company}','{$jobfunc}','{$location}','{$overall}','{$detail}','{$pros}','{$cons}','{$sr_mgmt}','{$submitted_by}','{$class}','{$school}','{$anonymous}')"; </code></pre>
30,901,183
1
Django @csrf_exempt decorator not working <p>I'm using DJango 1.8 on a linode server, and have the following view:</p> <pre><code>import json from django.http import HttpResponse from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt def home_view(request): r = { 'response': 'OK', 'data': None } return HttpResponse(json.dumps(r), content_type = "application/json") @csrf_exempt def ping(request): r = { 'response': 'OK', 'data': 'ping' } return HttpResponse(json.dumps(r), content_type = "application/json") </code></pre> <p>My urls look like this:</p> <pre><code>urlpatterns = [ url(r'^django/admin/', include(admin.site.urls)), url(r'^django/$', home_view), url(r'^django/ping/$', ping), url(r'^django/echo/$', echo), ] </code></pre> <p>If I go to my linode site at <code>http://mylinodesite/django/ping/</code> </p> <p>I get:</p> <p><code>{"data": "ping", "response": "OK"}</code></p> <p>Great. If I use jquery and do a </p> <p><code>$.get("http://mylinodesite/django/ping/")</code></p> <p>I get </p> <p><code>No 'Access-Control-Allow-Origin' header is present on the requested resource.</code></p> <p>From what I understand the @csrf_exempt is supposed to get rid of the CSRF header stuff. What gives?</p>
8,059,012
0
jquery $(this).prev(".class") not working <p>Given this simple setup</p> <pre><code>&lt;div class="parent"&gt; &lt;div class="child"&gt;I'm spoiled&lt;/div&gt; &lt;/div&gt; &lt;div class="aunt"&gt;&lt;/div&gt; &lt;div class="uncle"&gt;&lt;/div&gt; &lt;div class="parent"&gt; &lt;div class="child"&gt;I'm spoiled&lt;/div&gt; &lt;/div&gt; &lt;div class="aunt"&gt;&lt;/div&gt; &lt;div class="uncle"&gt;&lt;/div&gt; </code></pre> <p>When I detect a click on class "uncle", I want to get the sibling of the closest previous ".parent". I should be able to do</p> <pre><code>$( this ).prev( ".parent" ).children( ".child" ).text(); </code></pre> <p>...but this returns a blank. </p> <p>If I do</p> <pre><code>$( this ).prev().prev().children( ".child" ).text(); </code></pre> <p>...this returns the expected result: "I'm spoiled"</p> <p>Is there some limitations to the use of prev( [selector] ) I'm missing?</p> <p>[UPDATE]</p> <p>.prevAll() returns all previuos classes, so the result of </p> <pre><code>$( this ).prevAll( ".parent" ).children( ".child" ).text(); </code></pre> <p>Is "I'm spoiledI'm spoiled" if I click on the second ".uncle", which is not the result I want.</p> <p>I just need the immediate closest previous one.</p>
31,851,349
0
map(&:id) work but not pluck(:id) <p>In part of my code I need to grab users's id but <code>pluck</code> doesn't grab them. Only <code>map(&amp;:id)</code> can do it. I was wondering why.</p> <p>I've wrote a quick and dirty block of code to find what's happen</p> <pre><code> def remove_users user_ids p users_to_remove.class users_to_remove = self.users.where(id: user_ids) if users_to_remove.present? self.users -= users_to_remove self.save p users_to_remove.class p users_to_remove Rails::logger.info "\n#{users_to_remove}\n" users_to_remove_map = users_to_remove.map(&amp;:id) p users_to_remove_map Rails::logger.info "\nmap id: #{users_to_remove_map}\n" users_to_remove_pluck = users_to_remove.pluck(:id) p users_to_remove_pluck Rails::logger.info "\npluck id: #{users_to_remove_pluck}\n" #... end self.user_ids end </code></pre> <p>Who return in my test.log </p> <pre><code>#&lt;User::ActiveRecord_AssociationRelation:0x007fb0f9c64da8&gt; map id: [144004] (0.3ms) SELECT "users"."id" FROM "users" INNER JOIN "groups_users" ON "users"."id" = "groups_users"."user_id" WHERE "groups_users"."group_id" = $1 AND "users"."id" IN (144004, 144005) [["group_id", 235819]] pluck id: [] </code></pre> <p>And in my test</p> <pre><code>User::ActiveRecord_AssociationRelation User::ActiveRecord_AssociationRelation #&lt;ActiveRecord::AssociationRelation [#&lt;User id: 144004, created_at: "2015-08-06 08:55:11", updated_at: "2015-08-06 08:55:11", email: "[email protected]", token: "rpf5fqf5bs1ofme6aq66fwtcz", reset_password_token: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, disabled: false, first_name: "John_2", last_name: "Rivers_4", is_owner: false, organisation_id: 235826, encrypted_password: "$2a$04$8ev1j...f6ICL.ezS....", reset_password_sent_at: nil, default_language: nil, uid: nil, api_key: "rmhh...noyn"&gt;]&gt; [144004] [] </code></pre> <p>The strange thing is. I have user with id. <code>map</code> can get them. <code>pluck</code> not.</p> <p>I don't understand sql log also. How can I get <code>map id</code> result without any select in sql log? Caching ?</p>
40,934,859
0
<p>I was using IntelliJ with JBoss EAP and it failed like your error (Access Denied). So I turned off my virus protection (MSE), problem was solved.</p>
14,368,301
0
<p>You should have a look at this great module, <a href="https://github.com/caolan/async">async</a> which simplifies async tasks like this. You can use queue, simple example:</p> <pre><code>N = # of simultaneous tasks var q = async.queue(function (task, callback) { somehttprequestfunction(task.url, function(){ callback(); } }, N); q.drain = function() { console.log('all items have been processed'); } for(var i = 0; i &lt; 2000; i++){ q.push({url:"http://somewebsite.com/"+i+"/feed/"}); } </code></pre> <p>It will have a window of ongoing actions and the tasks room will be available for a future task if you only invoke the callback function. Difference is, your code now opens 2000 connections immidiately and obviously the failure rate is high. Limiting it to a reasonable value, 5,10,20 (depends on site and connection) will result in a better sucess rate. If a request fails, you can always try it again, or push the task to another async queue for another trial. The key point is to invoke callback() in queue function, so that a room will be available when it is done.</p>
33,010,859
0
Importing data into an existing database in neo4j <p>I am using <code>neo4j-import</code> to import millions of nodes and relationship. </p> <p>Is there any option to create relationships in to the existing database. I want to import the relationship using <code>neo4j-import</code> because I have millions of relationships. </p> <p>Your cooperation is truly appreciated! Thanks</p>
1,241,820
0
<p>I do exactly this using P/Invoke to talk to the <a href="http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx" rel="nofollow noreferrer"><code>GetLastInputInfo</code></a> API.</p> <p><strong>Edit</strong>: Here's a complete VB.Net program to display the number of milliseconds since the last input event, system-wide. It sleeps for a second before getting the information, so it reports a time of around a thousand milliseconds, assuming you use the mouse or keyboard to run it. :-)</p> <pre><code>Imports System.Runtime.InteropServices Module Module1 &lt;StructLayout(LayoutKind.Sequential)&gt; _ Public Structure LASTINPUTINFO Public Shared ReadOnly SizeOf As Integer = Marshal.SizeOf(GetType(LASTINPUTINFO)) &lt;MarshalAs(UnmanagedType.U4)&gt; _ Public cbSize As Integer &lt;MarshalAs(UnmanagedType.U4)&gt; _ Public dwTime As Integer End Structure &lt;DllImport("user32.dll")&gt; _ Public Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) As Boolean End Function Sub Main() Dim lii As New LASTINPUTINFO() lii.cbSize = LASTINPUTINFO.SizeOf lii.dwTime = 0 System.Threading.Thread.Sleep(1000) GetLastInputInfo(lii) MsgBox((Environment.TickCount - lii.dwTime).ToString) End Sub End Module </code></pre>
39,160,621
0
apply css to a html element after finding some specific class name avaialble <p>I am trying to apply css to a div(.references) after finding a specific class name(.overview) available in anywhere in that document. its not working .references div not inside .overview div</p> <pre><code>if ($('div').hasClass('overview')) { $('.references').css("display", "none !important"); } </code></pre> <p>Please help</p>
34,897,067
0
How to get input data from an external excel file into a feature file in cucumber (JAVA)...? <p>Is there a way to get input data from an excel file in gherkin into a feature file (Cucumber) specially in JAVA...? For .Net there is a way to specify the location of the excel file in the feature file using @source tag. Is there any similar way for JAVA as well...?</p> <p>For an example,</p> <p>Feature: User provides details to sign in</p> <p>Scenario Outline: Provide details</p> <pre><code>Given user navigates to 'https://world.com/signin' And user waits for short And user fills 'first_name' with '&lt;Firstname&gt;' And user waits for short And user fills 'email' with '&lt;Email&gt;' </code></pre> <p>How to provide the Firstname and Email from the excel file in feature file (JAVA)...? </p>
14,341,264
0
<p>I had the exact same issue - when I stopped and restarted the Glassfish server, the "View Endpoint" link appeared. Not sure if that will work for you, but it did the trick for me.</p>
20,849,440
0
<p>Removing following seems to work fine: </p> <pre><code>#rslider-animate .animating { -webkit-perspective: 1000px; -moz-perspective: 1000px; -ms-perspective: 1000px; -o-perspective: 1000px; perspective: 1000px; } </code></pre> <p>Check here <a href="http://jsfiddle.net/JUvnm/3/" rel="nofollow">http://jsfiddle.net/JUvnm/3/</a>.</p>
35,573,208
0
<p>Surprised!</p> <p>Its getting <code>text/plain</code> mime for the CSV, that was the cause of the issue.</p> <p>So to fix this I just found which extension is responsible for <code>text/plain</code> and I found <strong>txt</strong> so i just updated my rules:</p> <pre class="lang-php prettyprint-override"><code>return [ 'sheet' =&gt; 'required|mimes:csv,txt' ]; </code></pre>
25,318,056
0
How do I make SSHJ initiate outbound SFTP on a non-standard port? <p>I'm doing this and it works fine but I'd like to be able to hit an sshd on a port other than 22.</p> <pre><code> final SSHClient ssh = new SSHClient(); ssh.addHostKeyVerifier( SFTP_KEY_FINGERPRINT ); ssh.connect( SFTP_SERVER_HOSTNAME ); try { ssh.authPassword( SFTP_USER , SFTP_PASSWORD ); final String src = fileToFtp.getFileName().toString(); final SFTPClient sftp = ssh.newSFTPClient(); try { sftp.put(new FileSystemFile(src), "/"); success = true; } finally { sftp.close(); } } finally { ssh.disconnect(); } </code></pre>
30,195,625
0
<p>It removes all the whitespace (replaces all whitespace matches with empty strings). </p> <p>A wonderful regex tutorial is available at <a href="http://www.regular-expressions.info/">regular-expressions.info</a>. A citation <a href="http://www.regular-expressions.info/unicode.html">from this site</a>: </p> <blockquote> <p>\p{Z} or \p{Separator}: any kind of whitespace or invisible separator. </p> </blockquote>
10,137,380
0
<p>Simply use <code>echo form_dropdown('school', $school_list, set_value('school', @$school-&gt;id));</code></p> <p>Then you know by the <code>@</code> that value may be empty sometimes, and it supresses errors if that value is missing.</p> <p>Doing this will send a <code>NULL</code> value to the 3rd parameter if you have no id, and it will instead select the first <code>&lt;option&gt;</code> by default.</p>
14,100,282
0
<p>Two ways to do this:</p> <p>One way, would be to maintain a list of pointers to the textboxes &amp; labels as you create them:</p> <p>In your class definition, add a private list variable:</p> <pre><code>public partial class Form1 : Form { private List&lt;TextBox&gt; generatedTextboxes = new List&lt;TextBox&gt;(); private List&lt;Label&gt; generatedLabels = new List&lt;Label&gt;(); .... </code></pre> <p>Now, as you create them, add them to the list:</p> <pre><code>//Generate labels and text boxes for (int i = 1; i &lt;= inputNumber; i++) { //Create a new label and text box Label labelInput = new Label(); TextBox textBoxNewInput = new TextBox(); //Keep track of the references generatedTextboxes.Add(textBoxNewInput); generatedLabels.Add(labelInput ); .... </code></pre> <p>Now, when you wish to remove them:</p> <pre><code>for (int i = 1; i &lt;= generatedTextboxes.Count; i++) { this.Controls.Remove(generatedTextboxes[i]); this.Controls.Remove(generatedLabels[i]); } generatedTextboxes.Clear(); generatedLabels.Clear(); </code></pre> <p>Another way, would be to put a <code>Panel</code> control on your form, and add the new textboxes/labels onto that, instead of directly onto the main form. Then, do <code>panel1.Controls.Clear()</code> - to just clear the controls off the panel.</p>
33,573,249
0
<pre><code>import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { String string = "1-50 of 500+"; String[] stringArray = string.split("\\s+"); for (String str : stringArray) { System.out.println(str); } } } </code></pre>
18,110,124
0
Carousel slide effect with ng hide/show and ng-animate? <p>I have a slider type carousel with two section containers that can slide left and right. In my developed version I have images inside one section container. The problem I'm experiencing is that because my images from the server take a while to load I'm finding that when the user clicks the back button the page is being added to the DOM again (due to ng switch) and is having to reload the images.</p> <p>My question: Is there a way to use ngif or hide/show with this instead so that the page is simply setting display: none when hidden so that the page containers not currently shown are not removed from the DOM?</p> <pre><code> &lt;!--ANIMATE--&gt; &lt;div ng-animate="{enter: 'enter', leave: 'leave';}" ng-switch on="par.selection"&gt; &lt;!--PAGE1--&gt; &lt;div class="page page1" ng-switch-when="settings"&gt; &lt;b&gt;page 1&lt;/b&gt;&lt;br&gt;&lt;br&gt; &lt;button ng-click="par.selection = 'home'; go('front');" &gt;go page 2&lt;/button&gt; &lt;/div&gt; &lt;!--PAGE2--&gt; &lt;div class="page page2" ng-switch-when="home"&gt; &lt;b&gt;page 2&lt;/b&gt;&lt;br&gt;&lt;br&gt; &lt;button ng-click="par.selection = 'settings'; go('back');" &gt;go page 1&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Plunkr here: <strong><a href="http://plnkr.co/edit/Vvvsp1s45xvejRJt7cD0?p=preview" rel="nofollow">LINK</a></strong></p> <p>I made the above example from a blog I visited a phew days ago which I can no longer seem to find but the above example works using the ng-switch method.</p>
7,584,662
0
Gsoap undefined references <p>I'm trying to use and web service with gsoap. I've already generated all *.h and *.cpp using wsdl2h and soapcpp2, included all libraries, at least I think so, but when I build the project it gives me the message of undefined references to a lot of methods. The thing is all methods are declared in soapH.h (the prototype) and in soapC.cpp (the implementation).</p> <p>Any help will be appreciated.</p>
559,018
0
<p>I'm not sure how you'd get the "shared" LineStrings from your shapes. Secondly, once you reduce a "subset" of the shape since your endpoints may move from the original and you will not be able to make them match up after reduction.</p> <p>The nutshell of what I would do is basically use boolean operations to play with the reduced shapes.</p> <p>First, do what you do, namely create a temporary table of reduced shapes (called <code>#ReducedShapes</code>). </p> <p>Then, I would create a second temp table and find the areas of overlap (using <code>STIntersection</code>) between all shapes. In this table, I would basically have columns <code>naam1</code>, <code>naam2</code> and <code>intsec</code>, the last one being of type shape. Something like (untested):</p> <pre><code>INSERT INTO #IntSecs(naam1, naam2, intsec) SELECT s1.naam, s2.naam, s1.naam.STIntersection(s2.naam) FROM #ReducedShapes s1, #ReducedShapes s2 WHERE s1.naam.STIntersection(s2.naam) IS NOT NULL </code></pre> <p>This gets you a list of where pairs of shapes overlap. In fact, you have two rows for each overlap. For example, if A and B overlap you'd have and . I would make a pass and delete one of the two for each occurence.</p> <p>Lastly, for each overlap, I would subtract (<code>STDifference</code>) the intersection <strong>from only one of the two</strong> regions in the pair from the <code>#ReducedShapes</code> table. Imagine you have two squares A and B, half-overlapping. The operation would involve A.STDifference(B) meaning you keep all of B and half of A. I would insert the modified shapes into a third table (say <code>#ModifiedShapes</code>).</p> <p>Two problems: a) as you can see from your "orange" and "blue" shapes, they did not reduce similarly, so you'll get one of two possible reductions depending on how you deal with who "wins". b) a more complicated form of the problem is that, depending on the complexity of the initial shapes, you may get overlap between three or more regions. You'll have to determine your own way to establish which one shape "wins" in that intersection, based on your particular needs. It's not clear if there are constraints. Could be as simple as arbitrarily picking a winner by ordering, or more complicated since accuracy is important. </p> <p>The above concept unfortunately does not address the issue of gaps. This one's a little more complicated and I am not 100% sure how to resolve it. But, if you create a third table that subtracts (<code>STDifference</code> again) all the modified shapes <code>#ModifiedShapes</code> from all the original shapes in <code>#Shapes</code> (testing for overlap before actually subtracting, of course), you'd be left with the remainder shapes in the gaps. You'd want to aggregate the adjoining shapes and assign a "winning color", possibly merging it back in with the related shape.</p> <p>This answer is long and I will leave it like this. I may be barking up the wrong tree. Based on your feedback/questions, I would add to the post.</p>
1,185,946
0
<p>i do not know which mock implementation you use it. But <a href="http://www.easymock.org" rel="nofollow noreferrer">EasyMock</a> has an extension available at the EasyMock home page that generate mock Objects for classes. See your mock implementation whether it does not support mock Objects for classes.</p> <p>regards,</p>
38,884,806
0
<p>The problem is in <a href="http://pythonhosted.org/pyparsing/" rel="nofollow">pyparsing</a>:</p> <blockquote> <p>The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you don't need to learn a new syntax for defining grammars or matching expressions - the parsing module provides a library of classes that you use to construct the grammar directly in Python.</p> </blockquote> <p>In order to "construct the grammar directly in Python", pyparsing needs to read the source file (in this case a matplotlib source file) where the grammar is defined. In what would usually just be a bit of harmless extra work, pyparsing is reading not just the matplotlib source file but everything in the stack at the point the grammar is defined, all the way down to the source file where you have your <code>import matplotlib</code>. When it reaches your source file it chokes, because your file indeed is not in UTF-8; 0x96 is the Windows-1252 (and/or Latin-1) encoding for the en dash. This issue (reading too much of the stack) has <a href="https://sourceforge.net/p/pyparsing/code/415/" rel="nofollow">already been fixed</a> by <a href="http://stackoverflow.com/users/165216/paul-mcguire">the author of pyparsing</a> so the fix should be in the next <a href="https://pypi.python.org/pypi/pyparsing" rel="nofollow">release of pyparsing</a> (probably 2.1.8).</p> <p>By the way, matplotlib is defining a pyparsing grammar in order to be able to read fontconfig files, which are a way of configuring fonts used mainly on Linux. So on Windows pyparsing is probably not even required to use matplotlib!</p>
40,839,068
0
<blockquote> <p>This is really surprising to me, is there any internal memory copy that slow down the processing?</p> </blockquote> <p><code>ArrayOps.drop</code> internally calls <code>IterableLike.slice</code>, which allocates a builder that produces a new <code>Array</code> for each call:</p> <pre><code>override def slice(from: Int, until: Int): Repr = { val lo = math.max(from, 0) val hi = math.min(math.max(until, 0), length) val elems = math.max(hi - lo, 0) val b = newBuilder b.sizeHint(elems) var i = lo while (i &lt; hi) { b += self(i) i += 1 } b.result() } </code></pre> <p>You're seeing the cost of the iteration + allocation. You didn't specify how many times this happens and what's the size of the collection, but if it's large this could be time consuming.</p> <p>One way of optimizing this is to generate a <code>List[String]</code> instead which simply iterates the collection and drops it's <code>head</code> element. Note this will occur an additional traversal of the <code>Array[T]</code> to create the list, so make sure to benchmark this to see you actually gain anything:</p> <pre><code>val items = s.split(" +").toList val afterDrop = items.drop(2).mkString(" ") </code></pre> <p>Another possibility is to enrich <code>Array[T]</code> to include your own version of <code>mkString</code> which manually populates a <code>StringBuilder</code>:</p> <pre><code>object RichOps { implicit class RichArray[T](val arr: Array[T]) extends AnyVal { def mkStringWithIndex(start: Int, end: Int, separator: String): String = { var idx = start val stringBuilder = new StringBuilder(end - start) while (idx &lt; end) { stringBuilder.append(arr(idx)) if (idx != end - 1) { stringBuilder.append(separator) } idx += 1 } stringBuilder.toString() } } } </code></pre> <p>And now we have:</p> <pre><code>object Test { def main(args: Array[String]): Unit = { import RichOps._ val items = "hello everyone and welcome".split(" ") println(items.mkStringWithIndex(2, items.length, " ")) } </code></pre> <p>Yields:</p> <pre><code>and welcome </code></pre>
14,468,955
0
<p>Try appending the search keyword to Yahoo search api url and accessing it via uri onClick new button in your activity.</p>
8,584,890
0
Git default files (ignoring after first pull) <p>How would you go about setting up this scenario in git:</p> <p>My source has a settings file with configuration settings such as db connection credentials, etc... (this is a Drupal source and I'm referring to settings.php)</p> <p>When developers clone the source, they'll need to go in and change settings specific to their environment. These changes of course should not be pushed back to origin. And at the same time I want them to be able to work with this default template (since most of it will not be changed).</p> <p>So .gitignore doesn't work here because I want it in their first clone. Do I need to teach every new developer about <code>git update-index --assume-unchanged</code>?</p> <p>Isn't there a slicker way to do this?</p>
1,451,112
0
<p>This tutorial on kirupa website could help you. </p> <p><a href="http://www.kirupa.com/web/xml/index.htm" rel="nofollow noreferrer">http://www.kirupa.com/web/xml/index.htm</a></p> <p>It explains how to work with AS and XML. Hope this helps you get the answer. </p>
8,039,556
0
<p>How about we do this the jQuery way.</p> <h3>HTML</h3> <pre><code>&lt;ul id="items"&gt; &lt;li&gt;&lt;a href="#" class="item" title="Gallery" data-key="1" data-title="A+D Gallery" data-address="123 Main St" data-hours="10:00, 10:30, 11:00, 11:30, 1:00"&gt;Gallery&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="item" title="Radio" data-key="2" data-title="Radio" data-address="321 Center Dr" data-hours="11:00, 11:30, 12:00, 12:30, 1:00, 1:30, 2:00, 2:30"&gt;Radio&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <h3>JavaScript</h3> <pre><code>$(function() { $('#items').on('click', 'a.item', function () { console.log($(this).data('key')); return false; }); }); </code></pre> <h3>Demo <a href="http://jsfiddle.net/mattball/XBrfH/" rel="nofollow">http://jsfiddle.net/mattball/XBrfH/</a></h3>
4,681,447
0
<p>Have you considered using the DebuggerStepThrough attribute? <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx</a></p> <pre><code>[DebuggerStepThrough] internal void MyHelper(Action someCallback) { try { someCallback(); } catch(Exception ex) { // Debugger will not break here // because of the DebuggerStepThrough attribute DoSomething(ex); throw; } } </code></pre>
16,551,250
0
OpenSuse 12.3 + Java Dual Display <p>I have a Java application that displays two JFrames on two separate monitors. On Ubuntu and Windows the application displays just fine. I can configure the JFrames to display on the monitors with the specified screen ID. However on openSUSE it keeps displaying on the same monitor regardless of the setting. What is different to openSUSE?</p> <p>Here is some of the code that I use to determine on which monitor the JFrame must display:</p> <pre><code> GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); for (int s = 0; s &lt screens.length; s++) { GraphicsConfiguration configuration = null; for (int c = 0; c &lt screens[s].getConfigurations().length; c++) { if (AWTUtilities.isTranslucencyCapable(screens[s].getConfigurations()[c])) { configuration = screens[s].getConfigurations()[c]; break; } } if (configuration == null) { configuration = screens[s].getDefaultConfiguration(); } if (screens[s].getIDstring().equals[frame1_id]) { frame1 = new JFrame("Frame 1", configuration); frame1.setResizable(false); frame1.setUndecorated(true); frame1.setBounds(configuration.getBounds()); frame1.setVisible(true); } if (screens[s].getIDstring().equals[frame2_id]) { frame2 = new JFrame("Frame 2", configuration); frame2.setResizable(false); frame2.setUndecorated(true); frame2.setBounds(configuration.getBounds()); frame2.setVisible(true); } } </code></pre>
7,316,030
0
Saving wysiwyg Editor content with Ajax <p>I am writing a cms (on .net) and have structured the whole page to work client side. There is a treeview that lets you add/remove/move items and define their names in the languages defined. For each language I save the names of the category defined, but when there is HTML content associated with it, i fall into the JavaScript serializer problem that finds the content too long to be serialized.</p> <p>What would be the best approach to make sth like this work. Shall I change everything to work with postbacks, or try to manually call _doPostBack for the editor content (which I don't want). Thank you in advance.</p>
11,672,493
0
SQL-based, FIFO logic <p>I need to build a query that will aggregate the # of units of blood that has been transfused so it can be compared to the # of units of blood that has been cross-matched. Blood (a precious resource) that is cross-matched, but not transfused is wasted.</p> <p>Providers are supposed to check the system-of-record (Epic) for 'active' cross-match orders before creating new ones. Providers that don't do this are 'penalized' (provider 20). No penalty applies (it seems) for providers that don't transfuse all of the blood that they've cross-matched (provider 10).</p> <p>Cross-match orders:</p> <pre><code>|ENC_ID|PROV_ID|ORDER_ID|ORDER_TIME |UNITS| | 1| 10| 100|26-JUL-12 13:00| 4| | 1| 20| 231|26-JUL-12 15:00| 2| </code></pre> <p>Transfusion orders:</p> <pre><code>|ENC_ID|PROV_ID|ORDER_ID|ORDER_TIME |UNITS| | 1| 10| 500|26-JUL-12 13:05| 1| | 1| 10| 501|26-JUL-12 13:25| 1| | 1| 20| 501|26-JUL-12 15:00| 1| | 1| 20| 501|26-JUL-12 15:21| 2| </code></pre> <p>Rules:</p> <ul> <li>compare transfusions to cross-matches for same encounter (<code>transfusion.END_ID=cross-match.ENC_ID</code>)</li> <li>transfusion orders are applied to cross-match orders in a FIFO manner</li> <li><code>transfusion.ORDER_TIME &gt;= cross-match.ORDER_TIME</code></li> <li>a provider may transfuse more than their cross-match order, as long as all of the 'active' cross-match order still have available units (provider 20's second transfusion order)</li> </ul> <p>Desired result:</p> <pre><code>|ENC_ID|PROV_ID|ORDER_ID|ORDER_TIME |CROSS-MATCHED|TRANSFUSED| | 1| 10| 100|26-JUL-12 13:00| 4| 4| | 1| 20| 231|26-JUL-12 15:00| 2| 1| </code></pre> <p>Provider 10 'credited' with Provider 20's transfusions.</p> <p>Can this logic be implemented without resorting to a procedure?</p>
37,816,643
0
Why cursor type adOpenForwardOnly performance is better than adOpenStatic? <p>I am trying to understand the difference between <code>CursorTypeEnum</code> 0 and 3, as described <a href="https://msdn.microsoft.com/en-us/library/ms681771(v=vs.85).aspx" rel="nofollow">here</a>. Both are static, except type 0 only supports forward iteration.</p> <p>In my case <code>rs.Open strsql, cn, 0</code> returns consistently in under 30 seconds, whereas performance of the same query with type 3 cursor fluctuates widely between 3 and 8 minutes.</p> <p>They both need to lock the underlying tables in order to create static set, so why such dramatic difference?</p> <p><em>Disclaimer: I am no expert in VBA or transactional databases. I understand concurrency, algorithmic complexity and data structures.</em></p>
17,807,386
0
<p>you can use this,</p> <pre><code>Cursor cursor = db.query(true, YOUR_TABLE_NAME, new String[] { COLUMN1 ,COLUMN2, COLUMN_NAME_3 }, null, null, COLUMN2, null, null, null); </code></pre> <p>Here first parameter is used to set the DISTINCT value i.e if set to true it will return distinct column value.</p> <p>and sixth parameter denotes column name which you want to <code>GROUP BY</code>.</p>
2,969,853
0
<p>SharePoint document versioning is internal to the server architecture, and cannot be extended.</p> <p><a href="http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/67936a2b-e534-4c53-8802-a601eade73ff" rel="nofollow noreferrer">http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/67936a2b-e534-4c53-8802-a601eade73ff</a></p>
2,556,672
0
<p>What happens when you just do this?</p> <pre><code>public Bitmap GetBitmap() { Bitmap bmp = new Bitmap(codeEditor.Width, codeEditor.Height); Rectangle rect = new Rectangle(0, 0, codeEditor.Width, codeEditor.Height); codeEditor.DrawToBitmap(bmp, rect); return bmp; } </code></pre>
9,108,647
0
<p>I'm having exactly the same problem. At first I thought that it was not working, but I forgot my app opened and after a while the video showed up.</p> <p>The funny thing is that if I use this video[1] which I found in a tutorial on VideoView, the lag is much smaller. I am thinking on installing Darwin Streaming server to check if it is a matter of VLC or another issue.</p> <p>[1] rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp</p>
39,141,112
0
<p>I would like to share my test steps for your reference:</p> <ol> <li>I created a project <code>testgit</code> in a TFVC project, then add a folder <code>test</code> which is under git.</li> </ol> <p><a href="https://i.stack.imgur.com/qxBon.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qxBon.png" alt="enter image description here"></a></p> <ol start="2"> <li>perform <code>git-tf clone</code>, and clone the project successfully:</li> </ol> <p><a href="https://i.stack.imgur.com/624H3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/624H3.png" alt="enter image description here"></a></p>
14,174,692
0
setText of a TextView array <p>What I'm trying to do is have an EditText where people enter their names. As people press the "Add Player" button, the name which they just typed appears below in the list form. So I've created 8 textviews which are initially invisible but as people type the name press the "Add Player" button, the text changes to their names and becomes visible.</p> <p>So I set up a TextView array of the list of names, which are all text views</p> <pre><code>TextView[] nameList = new TextView[]{name1, name2, name3, name4, name5, name6, name7, name8}; </code></pre> <p>Later on in the code in the onClick section, I had</p> <pre><code>for (int i = 0; i &lt; 8; i++) { String name = etName.getText().toString(); nameList[i].setText(name); nameList[i].setVisibility(View.VISIBLE); } </code></pre> <p>However, with this, whenever I press the "add player" button, the app crashes and I get a NullPointerException. How would I solve this?</p> <p>The problem isn't with the for loop as the app crashed without it. The problem seems to be with the array as if I put</p> <pre><code>name1.setText(name); name1.setVisibility(View.VISIBLE); </code></pre> <p>the code worked fine.</p>
6,925,226
0
<p>May be best way for u will be use HashMap </p> <p><a href="http://msdn.microsoft.com/ru-ru/library/xfhwa508.aspx" rel="nofollow">Dictionary</a>?</p>
7,700,839
0
<p>I just wrote a library which provides this, called "knob" [<a href="http://hackage.haskell.org/package/knob">hackage</a>]. You can use it to create <code>Handle</code>s which reference/modify a <code>ByteString</code>:</p> <pre><code>import Data.ByteString (pack) import Data.Knob import System.IO main = do knob &lt;- newKnob (pack []) h &lt;- newFileHandle knob "test.txt" WriteMode hPutStrLn h "Hello world!" hClose h bytes &lt;- Data.Knob.getContents knob putStrLn ("Wrote bytes: " ++ show bytes) </code></pre>
21,230,175
0
Fastest between mat of Vec2 or 2 Mat <p>I have a question concerning access speed of OpenCV matrix.</p> <p>I currently need two channels of unsigned char to contain my data. But at one point i need to split my data to process them separately (which probably results in a matrix copy)</p> <pre><code>for( auto ptr = ROI.begin&lt;cv::Vec2b&gt;(); ptr!=ROI.end&lt;cv::Vec2b&gt;();ptr++){ //insert values } cv::split(ROI,channels_vector) process(channels_vector[0]); process(channels_vector[1]); more_stuff(ROI); </code></pre> <p>My question is the following : Should I use two different matrix at the beginning to avoid the split or let it like this ? Or as it may depend on my computation what is the difference of cost between two accesses of a matrix and a matrix copy ?</p>
22,852,946
0
Two calendar form in one page Joomla <p>I implemented two calendar form in one view page in joomla component. the code is like this:</p> <pre><code> &lt;tr&gt; &lt;td&gt;Start Date&lt;/td&gt; &lt;td&gt;&lt;?php echo JHTML::calendar(date("Y-m-d"),'from', 'date', '%Y-%m-%d',array('size'=&gt;'8','maxlength'=&gt;'10','class'=&gt;' validate[\'required\']',)); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;End Date&lt;/td&gt; &lt;td&gt;&lt;?php echo JHTML::calendar(date("Y-m-d"),'to', 'date', '%Y-%m-%d',array('size'=&gt;'8','maxlength'=&gt;'10','class'=&gt;' validate[\'required\']',)); ?&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>But now only the first calendar form would pop up a jQuery calendar that let me select a date, the second form, when clicking on it, there is no effect.</p> <p>Hope someone could help me solve this problem.</p>
37,570,362
0
<p>For example you can change </p> <p>font-size: 40px; to font-size: 2.500em;</p> <p>There is also a online convertor to check your pixels in em-s</p> <p><a href="http://pxtoem.com/" rel="nofollow">http://pxtoem.com/</a></p>
16,272,611
0
<p>I just added "-с" parameter. It makes Psexec copy executable to remote machine. So it works without access errors.</p>
25,806,052
0
<p>I used <a href="http://helpandmanual.com" rel="nofollow">Help and Manual</a> in my previous position. It supports conditional building. Perhaps it can work in your case. (Not affiliated, just a user.)</p>
32,561,088
0
<p>I may have assumed that when you say Tableau Online, you dont mean the Tableau Public.. I assume your tableau online is your local or let's say company hosted tableau server... for the answers to your questions in sequence 1 - 3 it can be done.</p> <p>tableau supports a lot of datasources even the classic text based data it can read..</p> <p>did you tried installing your database drivers?</p> <blockquote> <p>If the server is configured to use local authentication, when you add a user identity, you specify a username, a password and a site role. In that case, the Tableau Server repository is used exclusively to authenticate the user.</p> </blockquote> <p><a href="http://onlinehelp.tableau.com/current/server/en-us/security_auth.htm" rel="nofollow">http://onlinehelp.tableau.com/current/server/en-us/security_auth.htm</a></p>
15,986,463
0
<pre><code>self.lblQuestionTitle.text = [nextQuestion objectForKey:@"QuestionTitle"]; </code></pre>