pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
19,490,989 | 0 | ASP.NET WebForms with Angular Postback <p>im trying to use Angular framework in existing ASP.NET WebForms application and problem i ran into is this:</p> <p>Client side code:</p> <pre><code><select id="fooSelect" class="span8" runat="server" clientidmode="Static"> <option ng-repeat="foo in foos" value="{{foo.Id}}">{{foo.Title}}</option> </select> </code></pre> <p>When form gets submited (whole page postback), value of <code>fooSelect.Value</code> is <code>"{{foo.Id}}"</code></p> <p>How to get value of selected option on server side?</p> |
39,582,650 | 0 | How do I bind alpaca.js to an existing HTML form <p>I have an existing form in plain HTML with a lot of css and layout tweaks. I'm trying to figure out if I can use alpaca.js without the rendering step but still get the full power of the schema and validation capabilities. I looked at Views, Layouts, Templates, etc. within the docs, and was either blind (probably) or just making some bad assumptions, but there didn't seem to be a simple way to declare <code>schema-property-FOO</code> should be bound to <code>#html-element-BAR</code>. It seems like something that would be mapped out in the <code>options</code> section of my alpaca declarations, but no luck (that I saw).</p> <p>Essentially I want all the alpaca goodness without the rendering step. Is that possible, or square-peg/round-hole thinking?</p> <p>Thanks for any guidance.</p> |
29,048,621 | 0 | android app data not appearing on parse dashboard <p>I'm trying to make a new social app. I went parse.com and made a new app. downloaded the zip file and opened it in the android studio. after that i initialized my keys and compiled the code. It gave no errors and loaded the app on the emulator. Then i added the code to add new user to the database and ran the app. All went ok and log cat didn't give me any errors but when i pressed the test button to check if data got added in the cloud or not but it said "no data yet". yes i did initialize the keys right and my manifest file does include internet permission. Can anyone please tell me whats wrong? I copied all this code from parse</p> <pre><code>public class ParseStarterProjectActivity extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ParseUser user = new ParseUser(); user.setUsername("my name"); user.setPassword("my pass"); user.setEmail("[email protected]"); // other fields can be set just like with ParseObject user.put("phone", "650-555-0000"); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { // Hooray! Let them use the app now. } else { // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } }); ParseAnalytics.trackAppOpenedInBackground(getIntent()); } } </code></pre> |
39,681,101 | 1 | Text arbitrarily not reading into buffer <p>I'm trying to analyze philosophical and classic texts with the Watson Alchemy API, I'm having trouble with reading texts from a .txt file on my computer to a python variable.</p> <p>Here is the code:</p> <pre><code>from __future__ import print_function from alchemyapi import AlchemyAPI import argparse import json def conceptual(fileName): path = "/Users/myname/Desktop/texts/" name = path + fileName with open(name, 'r') as myfile: data=myfile.read().replace('\n', ' ') if data != None: print(data) def main(): parser = argparse.ArgumentParser() parser.add_argument('--concepts', dest = 'conceptFile', required = False) args = parser.parse_args() if args.conceptFile: conceptual(args.conceptFile) else: print('Use CL args.') main() </code></pre> <p>The issue is that for some texts it works fine: The entire .txt file prints out onto the terminal window. For others it prints something like this(for all the files that aren't working the output is very similar to this):</p> <pre><code>. THE ENDy mountains. glowing and strong, like a </code></pre> <p>The end of that particular file (Zarauthstra_Nietzsche.txt) is </p> <pre><code> Thus spake Zarathustra and left his cave, glowing and strong, like a morning sun coming out of gloomy mountains. THE END </code></pre> <p>But the rest of the file doesn't print.</p> <p>I've been tinkering around with various differences, tweaking it here and there, but the only common thread to those that don't work seem to be that I downloaded them from a different website (<a href="http://philosophy.eserver.org/texts.htm" rel="nofollow">http://philosophy.eserver.org/texts.htm</a> not Project Gutenberg). I've tried changing the file's path, the contents, the permissions, the filenames. Any ideas?</p> |
25,074,763 | 0 | Docker container get Host IP address <p>How do I get the Host IP address within an Java application running inside a Docker?</p> <p>Obviously, if I use the traditional InetAddress.getLocalHost(), it works if the Java program runs directly on the Host. However, if it is running inside a container, then it would not be the physical ip address outside world sees the host.</p> <p>My use case is that my Java application registers itself as a service provide by inserting into a shared registry (like a database table) with informations like service name, ip address and port number so that others can find and invoke the service.</p> <p>Someone mentioned the only way is through run --env when you start the container, but how do my Java program gets it? If I have a way to retrieve it from Java, that would work though it looks ugly .....</p> |
18,251,594 | 0 | <p>You need to add a column, e.g. "label" to the node import file, and give numbers according to how you want to "group the nodes into one color". And then you can select to color the nodes via your new column.</p> |
30,675,367 | 0 | <p>The best way to do this is my using the <code>set()</code> function like this:</p> <pre><code>x=['a','b','a','b','c','d'] print list(set(x)) </code></pre> <p>As the <code>set()</code> function returns an unordered result. Using the <code>sorted()</code> function, this problem can be solved like so:</p> <pre><code>x=['a','b','a','b','c','d'] print list(sorted(set(x))) </code></pre> |
36,524,642 | 0 | <pre><code>while( someOuterLoopCondition ) { var m = 0; var innerLoopOK = true; while( innerLoopOK ) { try { // your original inner-loop body goes here } catch e { innerLoopOK = false; } m++; } } </code></pre> <p>Or:</p> <pre><code>while( someOuterLoopCondition ) { for( var m = 0; m < upperBound; m++ ) { try { // your original inner-loop body goes here } catch e { break; // breaks inner-loop only } } } </code></pre> |
11,147,440 | 0 | <p>In the C++ code you are translating to C#, look for a macro definition or inline function definition for <code>SIGN</code>. The definition should spell out exactly how you should implement it in C#.</p> <p>If I had to guess from the name, <code>SIGN(x,y)</code> returns true if <code>x</code> and <code>y</code> have the same sign, and false otherwise.</p> |
1,062,289 | 0 | <p>Got it.<br> 1-Go to design view of your table.<br> 2-select the look-up tab bellow the field list.<br> 3-Change row source type to "values".</p> |
34,122,801 | 0 | <p>I think this is what you want:</p> <pre><code>dat[ , `:=`(var1 = var[1L], var2 = var2[1L]), by = .(id, year)] </code></pre> <p>As a function you'd have to do something like:</p> <pre><code>fn_const <- function(data, id, year, constant){ data[ , (constant) := .SD[1L], by = c(id, year), .SDcols = constant] data } </code></pre> <p>Note that this won't assign to <code>dat</code>, so you'll have to use something like <code>dat <- fn_const(...)</code>, which is probably not ideal (making copies). Instead, why not eliminate <code>data</code> as an argument:</p> <pre><code>fn_const<-function(id, year, constant){ dat[ , (constant) := .SD[1L], by = c(id, year), .SDcols = constant] } </code></pre> <p>Now simply running <code>fn_const(id, year, constant)</code> will assign <code>constant</code> by reference to <code>dat</code> with no copies necessary.</p> <p>TBH I don't really see any benefit of writing this as a function in the first place, except maybe to save space if you plan on doing this over and over.</p> |
12,529,450 | 0 | validation for models in ruby on rails <p>I have a model:</p> <pre><code>class HelloRails < ActiveRecord::Base attr_accessible :filename, :filevalidate include In4systemsModelCommon validates :filename, presence: true def update parameters = [self.filename, @current_user] parameters.map!{|p| ActiveRecord::Base.connection.quote p} sql = "call stored_procedure(#{parameters.join(',')})" ActiveRecord::Base.connection.execute(sql) end end </code></pre> <p>In the view I have a <code>text_field</code> called as <code>:filename</code>. When I click the submit button it calls this update method in model to call the stored proc to execute. Now validations are not working. </p> <p>I dont want to accept <code>nil</code> for filename. How can I do this?</p> |
36,635,821 | 0 | <p>Ok, on your second question, exporting and importing passwords, the encryption is done per user (and I'm pretty sure per machine), so you can't export it, and then have another account import it, but for just straight saving an encrypted password you can use these functions:</p> <pre><code>Function Out-EncryptedPasswordFile{ [cmdletbinding()] Param( [Parameter(Mandatory = $true)] [string]$Password, [Parameter(Mandatory = $true)] [ValidateScript({If(Test-Path (Split-Path $_)){$true}else{Throw "Unable to create file, directory '$(Split-Path $_)\' does not exist."} })][String]$Path ) ConvertTo-SecureString -AsPlainText $Password -Force | ConvertFrom-SecureString | Set-Content $Path -Encoding Unicode } #Usage Example #Out-EncryptedPasswordFile TestP@ssw0rd c:\temp\password.txt Function Import-EncryptedPasswordFile{ [cmdletbinding()] Param( [Parameter(Mandatory = $true)] [ValidateScript({Test-Path $_})][string]$Path ) $SSPassword = Get-Content $Path | ConvertTo-SecureString $Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($SSPassword) [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr) [System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr) } #Usage Example #Import-EncryptedPasswordFile C:\temp\password.txt </code></pre> |
5,149,574 | 0 | Deploy two connected webparts in a page layout during feature activation? <p>I've implemented 2 webparts (deriving from Microsoft.SharePoint.WebPartPages.WebPart, the WSS 3 WebPart), one of which is a provider and the other the consumer (implementing ASP.net connection model, with <em>ConnectionProviderAttribute</em> and <em>ConnectionConsumerAttribute</em> methods).</p> <p>I managed to deploy them in a feature which also deploys a Page Layout containing two webpart zones, which are themselves populated during the FeatureAvtivated method of the feature receiver, with the 2 newly created webparts. All of this works just fine.</p> <p>For information, I used <a href="http://vspug.com/michael/2009/05/25/manage-webparts-of-page-layouts-through-a-feature-resolving-the-quot-alluserswebpart-quot-pain/" rel="nofollow">this link</a> to make it work. Beware, the method using <em>AllUsersWebPart</em> tag in <em>elements.xml</em>, shown in links like this one (http://www.andrewconnell.com/blog/archive/2007/10/07/Having-Default-Web-Parts-in-new-Pages-Based-Off-Page.aspx) work, but if you deactivate, then reactivate your feature, you just have double webparts in your future pages based on the layout. The method described here (http://sharepoint.coultress.com/2008/06/adding-web-part-to-page-layout.html) just threw me an error when analysing metadata for the layout aspx file (the problem seemed to come from the line in the ZoneTemplate tag).</p> <p>My next goal is to connect these webparts together right after all this, thus enabling the end user to create pages, based on the layout, containing <strong>by default</strong> the two webparts <strong>connected</strong> together (right now everything works except for the <em>connected</em> part).</p> <p>I tried something like <a href="http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/" rel="nofollow">this</a>, using ASP.net connection model (the other one, WSS model, throws logically an error because I'm not implementing the good interfaces). But even though the connection resulting from the "mgr.SPConnectWebParts()" method doesn't throw any exception and actually adds the connection to the connection list of the webpart manager, I can see in debug mode that the connection property 'IsActive" is false (maybe normal), and that when I create a new page based on the layout, the webparts appear not connected.</p> <p>Any guess? I believe there's something with the fact that the webparts cannot be connected before the page containing them is actually created, but I'm far from sure of it.</p> |
23,132,430 | 0 | <p>Could it be something simple like this:</p> <pre><code> query = em.createNativeQuery("SELECT state_id, state_name, country_id FROM state_table,country WHERE state_table.country_id=country.country_id and country.country_name = ?1)").setParameter(1, country_name); list = (List<Object>) query.getResultList(); </code></pre> <p>where country_name is the parameter you are searching for and list is the list of objects returned by the native query?</p> |
25,405,010 | 0 | Getting the current call stack from a different thread <p>In a multiple thread situation, is it possible to get the call stack at the current moment inside some thread <code>t1</code> from another thread <code>t2</code> running outside of <code>t1</code>? If so, how?</p> <p><hr></p> <h3>Response to Stefan:</h3> <p>I tried:</p> <pre><code>def a; b end def b; c end def c; d end def d; sleep(1) end t1 = Thread.new do 100.times{a} end p t1.backtrace </code></pre> <p>but it always returns an empty array <code>[]</code>.</p> <p><hr></p> <h3>Edit:</h3> <p>Following suggestions by Stefan, the following parameters worked for my computer:</p> <pre><code>def a; b end def b; c end def c; d end def d; end t1 = Thread.new do 1000.times{a} end sleep(0.0001) p t1.backtrace </code></pre> <p>It returns a random call stack with the top-most method varying around <code>a</code> to <code>d</code>.</p> |
6,292,749 | 0 | Rails: Can't run DB Rake on OS X 10.6 because gem SQL lite cannot be found <p>Here's my error message when I do a DB rake:</p> <blockquote> <p>Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in your Gemfile.</p> </blockquote> <p>I've tried Installing xCode 4.0.2</p> <p>Commands: </p> <pre><code>sudo gem install sqlite3-ruby sudo gem update --system sudo gem update rails sudo gem update sqlite3-ruby </code></pre> <p>Gem list produces: </p> <pre><code>abstract (1.0.0) actionmailer (3.0.8, 2.2.2) actionpack (3.0.8, 2.2.2) activemodel (3.0.8) activerecord (3.0.8, 2.2.2) activeresource (3.0.8, 2.2.2) activesupport (3.0.8, 3.0.6, 2.2.2) arel (2.0.10) builder (2.1.2) bundler (1.0.14) erubis (2.6.6) i18n (0.5.0) mail (2.2.19) mime-types (1.16) polyglot (0.3.1) rack (1.2.3) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.8, 2.2.2) railties (3.0.8) rake (0.9.2, 0.8.3) rubygems-update (1.8.5, 1.8.4, 1.3.1) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.27) </code></pre> <p>Any suggestions? I'm on Max OS X 10.6 </p> |
40,403,922 | 0 | ionic2 - change font attribute of .loadcontent <p>I am using <code>LoadingController</code> to manage the loading page. Below is my code:</p> <pre><code>presentLoadingCustom() { let loading = this.loadingCtrl.create({ spinner: 'hide', content: ` <div padding> <div class="loadingheader">processing...</div > </div> <div> <p> Verifying your mobile phone number </p> <p>`+ " 011 232 43146" + ` </p> <p> Please wait </p> </div> `, duration: 100000 }); </code></pre> <ol> <li><p>How can I change the font size of <code>loadheader</code>? I tried add <code>css</code> code in <code>scss</code> file of the same page but fail.</p></li> <li><p>How to put spinner at the position I wanted? Say I want to put between <code>loadheader</code> and my other text. Currently it is at the right of all my text.</p></li> </ol> |
16,921,721 | 0 | <p>Your solution is not so bad. The queuing of the HTTP requests is really a standard thing to do, so that should not be a big problem. </p> <p>Just do <em>not</em> use the objectIDs on your server. They are really unique to the database on one particular device. Their main purpose is to identify managed objects across different managed object contexts. Instead us your own id, maybe a server generated one that is authoritative. </p> <p>The obvious "elegant" alternative is to use Apple's integration of iCloud with Core Data. Then you have to do absolutely nothing on the server side. The drawback is that you cannot access the user info (which might be desired). The much more significant drawback (showstopper) is that it does not work reliably (see my SOF question <a href="http://stackoverflow.com/questions/14478517/more-icloud-core-data-synching-woes">here</a>). </p> |
19,664,291 | 0 | <p>Something like:</p> <pre><code>SELECT col1, col2, col3 FROM ( SELECT *,1 AS SortCol FROM tbl_post WHERE paid_until >= :time_stamp UNION SELECT *,2 AS SortCol FROM tbl_post WHERE paid_until < :time_stamp )AS sub ORDER BY SortCol, modified DESC </code></pre> |
31,954,787 | 0 | ngAnimate doesn't work with ngShow/ngHide: ng-hide-add and ng-hide-remove classes are not generated <p>I am trying to animate the ng-hide/ng-show directive and for some reasons none of the ng-hide-add*/ng-hide-remove* classes are not generated. ng-animate class is not generated as well. I do have the 'ngAnimate' as a dependency for my module (if i type "angular.module('ngAnimate')" in Chrome console I get an Object). I removed the classNameFilter ($animateProvider.classNameFilter(/xyz/)). What else should I look for? I am working on a huge project and I don't know what other settings/configurations might be in place. Version of angular used is 1.4.3 Version of angular-animate used is 1.4.3</p> <p>I debugged ngAnimate and:</p> <ul> <li>function areAnimationsAllowed always returns false because</li> <li>rootElementDetected is always false because</li> <li>$rootElement is : <!-- uiView: --> instead of <div ng-app="myApp" ui-view class="ng-scope"></li> </ul> <p>Is that a known issue?</p> <p>Thank you in advance!</p> |
9,107,856 | 0 | Problems with svd in java <p>I have gone through jama and colt(I code in java) . Both of them expect me to use arrays such that the number of rows are more than the number of coloumns . </p> <p>But in case of the Latent semantic analysis (LSA) i have 5 books and there are a total of 1000 odd words . When i use a term document matrix i get a 5*1000 matrix.</p> <p>Since this does not work , i am forced to transpose the matrix . On transposing i use a 1000 * 5 . With a 1000*5 when i perform a svd i get a S matrix with 5*5 . To perform dimensionality reduction this the 5*5 matrix looks small . </p> <p>What can be done ? </p> |
20,620,272 | 0 | how to retrieve codeigniter's cookie using javascript? <p>In my codeigniter's controller I have the following code:</p> <pre><code>$cookie = array( 'name' => 'my_name', 'value' => 'my value goes here' ); $this->input->set_cookie($cookie); </code></pre> <p>However, when I tried to retrieve the cookie using javascript's document.cookie, it printed strings like cookie_name, csrf_cookie_name but not my_name and 'my value goes here'. Why?</p> <p>Note: if I use the php function setcookie('my_name', 'my value goes here') then it works fine, it just I can't make it work with codeigniter's cookie helper.</p> |
24,067,521 | 0 | <p>The origin should be half the width and height of the item that you're rotating if you wish to rotate it about its centre. Note that the dot is not the true origin; I've tweaked your code a bit:</p> <pre><code>import QtQuick 2.0 Rectangle { id: dial width: 360 height: 360 color: "gray" Rectangle { id: dot height: 5 width: 5 color: "red" anchors.centerIn: parent z: 1 } Rectangle { id: line height: 5 width: 50 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter transform: Rotation { origin.x: line.width / 2 origin.y: line.height / 2 angle: 40 } } } </code></pre> <p><img src="https://i.stack.imgur.com/Zy6VK.png" alt="rotated line"></p> <p>Or, if you want to get even simpler:</p> <pre><code>import QtQuick 2.0 Rectangle { id: dial width: 360 height: 360 color: "gray" Rectangle { id: line height: 5 width: 50 anchors.centerIn: parent rotation: 40 } Rectangle { id: dot height: 5 width: 5 color: "red" anchors.centerIn: parent } } </code></pre> |
31,135,595 | 0 | <p>Adding <code>Message.framework</code> to your project and Get <code>IMEI</code> Number,</p> <pre><code>NetworkController *ntc = [NetworkController sharedInstance]; NSString *imeistring = [ntc IMEI]; </code></pre> <p>Apple allow some of the details of device, Not give IMEI, serial Number. in <code>UIDevice</code> class provide details.</p> <pre><code>class UIDevice : NSObject { class func currentDevice() -> UIDevice var name: String { get } // e.g. "My iPhone" var model: String { get } // e.g. @"iPhone", @"iPod touch" var localizedModel: String { get } // localized version of model var systemName: String { get } // e.g. @"iOS" var systemVersion: String { get } // e.g. @"4.0" var orientation: UIDeviceOrientation { get } // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated. @availability(iOS, introduced=6.0) var identifierForVendor: NSUUID! { get } // a UUID that may be used to uniquely identify the device, same across apps from a single vendor. var generatesDeviceOrientationNotifications: Bool { get } func beginGeneratingDeviceOrientationNotifications() // nestable func endGeneratingDeviceOrientationNotifications() @availability(iOS, introduced=3.0) var batteryMonitoringEnabled: Bool // default is NO @availability(iOS, introduced=3.0) var batteryState: UIDeviceBatteryState { get } // UIDeviceBatteryStateUnknown if monitoring disabled @availability(iOS, introduced=3.0) var batteryLevel: Float { get } // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown @availability(iOS, introduced=3.0) var proximityMonitoringEnabled: Bool // default is NO @availability(iOS, introduced=3.0) var proximityState: Bool { get } // always returns NO if no proximity detector @availability(iOS, introduced=4.0) var multitaskingSupported: Bool { get } @availability(iOS, introduced=3.2) var userInterfaceIdiom: UIUserInterfaceIdiom { get } @availability(iOS, introduced=4.2) func playInputClick() // Plays a click only if an enabling input view is on-screen and user has enabled input clicks. } </code></pre> <p>example : <code>[[UIDevice currentDevice] name];</code></p> |
4,366,388 | 0 | Persisting the table name in codeigniter models <p>In my models I'm setting them up using constructors like the following</p> <pre><code>function Areas() { parent::Model(); $this->db->from("areas"); } </code></pre> <p>However, if a method of my model queries the database several times it looks like the FROM clause is only included in the first query. Is there an easy way to persist the FROM for all queries run within my model (unless I manually override it)?</p> |
8,894,192 | 0 | <p>Please <a href="http://www.jetbrains.com/ruby/webhelp/ruby-gems-support.html" rel="nofollow">refer to help</a>. You need Gemfile with the used gems listed in it for RubyMine to recognize the dependencies.</p> |
16,649,375 | 0 | <p>Figured it out, think I have been multiplying by 1000 when I shouldn't have, the following works</p> <pre><code>var offset = (int)Math.Floor(buffer.WaveFormat.SampleRate * barDuration / 128) * 128 * bar; </code></pre> |
12,937,848 | 0 | <p>Well you said without redirecting. Well its a javascript code:</p> <pre><code><a href="JavaScript:void(0);" onclick="function()">Whatever!</a> <script type="text/javascript"> function confirm_delete() { var delete_confirmed=confirm("Are you sure you want to delete this file?"); if (delete_confirmed==true) { // the php code :) can't expose mine ^_^ } else { // this one returns the user if he/she clicks no :) document.location.href = 'whatever.php'; } } </script> </code></pre> <p>give it a try :) hope you like it</p> |
13,877,208 | 0 | How to go about multithreading with "priority"? <p>I have multiple threads processing multiple files in the background, while the program is idle.<br> To improve disk throughput, I use critical sections to ensure that no two threads ever use the same <em>disk</em> simultaneously.</p> <p>The (pseudo-)code looks something like this:</p> <pre><code>void RunThread(HANDLE fileHandle) { // Acquire CRITICAL_SECTION for disk CritSecLock diskLock(GetDiskLock(fileHandle)); for (...) { // Do some processing on file } } </code></pre> <p>Once the user requests a file to be processed, I need to <em>stop all threads</em> -- <em>except</em> the one which is processing the requested file. Once the file is processed, then I'd like to resume all the threads again.</p> <p>Given the fact that <code>SuspendThread</code> is a bad idea, how do I go about stopping all threads except the one that is processing the relevant input?</p> <p>What kind of threading objects/features would I need -- mutexes, semaphores, events, or something else? And how would I use them? (I'm hoping for compatibility with Windows XP.)</p> |
9,002,367 | 0 | <p><code>AttachDbFilename</code> is used with local database. If you have remote database then the connection string will <a href="http://www.connectionstrings.com/sql-server-2008" rel="nofollow">be different</a>. Have a look at article - <a href="http://support.microsoft.com/kb/914277" rel="nofollow">How to configure SQL Server 2005 to allow remote connections.</a></p> |
11,283,881 | 0 | Backbone.js: Best way to handle multiple nullable filter parameters <p>have the following function on my <strong>collection</strong>:</p> <pre><code>getFiltered: function (status, city) { return this.filter(function (trainer) { return ((status === null) ? trainer : trainer.get("TrainerStatusName") === status) && ((city === null) ? trainer : trainer.get('City') === city); }); } </code></pre> <p>What is is best way to deal with nullable params passed in i.e. if city it null then ignore filter/fetch all and if status is null then ignore filter/fetch all</p> <p>The code above works, but curious about alternatives</p> |
11,146,431 | 0 | <p>The null in most programming languages is considered "known", while NULL in SQL is considered "unknown".</p> <ul> <li>So <code>X == null</code> compares X with a known value and the result is known (true or false).</li> <li>But <code>X = NULL</code> compares X with an unknown value and the result is unknown (i.e. NULL, again). As a consequence, we need a special operator <code>IS [NOT] NULL</code> to test for it.</li> </ul> <p>I'm guessing at least part of the motivation for such NULLs would be the behavior of foreign keys. When a child endpoint of a foreign key is NULL, it shouldn't match any parent, even if the parent is NULL (which is possible if parent is UNIQUE instead of primary key). Unfortunately, this brings many more <a href="http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/">gotchas</a> than it solves and I personally think SQL should have gone the route of the "known" null and avoided this monkey business altogether.</p> <p>Even E. F. Codd, inventor or relational model, later indicated that the traditional NULL is not optimal. But for historical reasons, we are pretty much stuck with it.</p> |
16,467,473 | 0 | <p>Yes, use the <a href="https://github.com/caolan/async#control-flow" rel="nofollow">async</a> library. It's awesome for doing this sort of thing.</p> <p>If you need to do one map and then pass the results to the next function then you need to look at <a href="https://github.com/caolan/async#waterfall" rel="nofollow">async.waterfall</a>.</p> |
12,872,568 | 0 | <p>For a perfect effect you will need to do 2 things. Assuming you used Image class to render it, first, is to put the same image bellowthe original one and use the scaleY to flip it vertically.</p> <p>this will create reflection effect, but you will need to apply same things that you applied to first image to the second one, like movement, rotation, whatever you did to it.</p> <p>Besides that you will probably need your reflection image to fade out like a gradient, if you are doing everything on a solid not moving background, you can create a third image which is a gradient png from transparent to the color of your background, and put it over the reflection image. If you have a dynamic background, then you will probably need to use shaders (sorry, openGL 2 only). You can read more on how to write custom shaders here: <a href="http://blog.josack.com/2011/08/my-first-2d-pixel-shaders-part-3.html" rel="nofollow">http://blog.josack.com/2011/08/my-first-2d-pixel-shaders-part-3.html</a> (A great tutorial)]</p> <p>Hope that helps. There might be other solution I don't know about, so keep researching, but this is what came to my mind.</p> |
20,277,336 | 0 | How to check a folder exists in DropBox using DropNet <p>I'm programming an app that interact with dropbox by use DropNet API. I want to check if the folder is exist or not on dropbox in order to I will create one and upload file on it after that. Everything seen fine but if my folder is exist it throw exception. Like this:</p> <pre><code>if (isAccessToken) { byte[] bytes = File.ReadAllBytes(fileName); try { string dropboxFolder = "/Public/DropboxManagement/Logs" + folder; // I want to check if the dropboxFolder is exist here _client.CreateFolder(dropboxFolder); var upload = _client.UploadFile(dropboxFolder, fileName, bytes); } catch (DropNet.Exceptions.DropboxException ex) { MessageBox.Show(ex.Response.Content); } } </code></pre> |
35,174,852 | 0 | How to get rows and count of rows simultaneously <p>I have a stored procedure that returns <code>rows</code> and <code>count</code> simultaneously.</p> <p>I tried following <code>ADO.net</code> code but I get <code>IndexOutOfRange</code> Exception on ItemCount(ItemCount contains <code>count</code> of rows)</p> <pre><code> public List<Product> GetProductDetails(Product p) { List<Product> products = new List<Product>(); using (SqlConnection con = new SqlConnection(_connectionString)) { SqlCommand cmd = new SqlCommand("[usp_Get_ServerPagedProducts]", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@rvcName", System.Data.SqlDbType.VarChar).Value = p.Name; cmd.Parameters.AddWithValue("@rvcCode", System.Data.SqlDbType.VarChar).Value = p.Code; cmd.Parameters.AddWithValue("@riProductTypeID", System.Data.SqlDbType.Int).Value = p.ProductTypeID; cmd.Parameters.AddWithValue("@ristartIndex", System.Data.SqlDbType.Int).Value = p.RowIndex; cmd.Parameters.AddWithValue("@rimaxRows", System.Data.SqlDbType.Int).Value = p.PageSize; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Product product = new Product(reader["Name"].ToString(), reader["Code"].ToString(), reader["Description"].ToString(), (DateTime)reader["DateCreated"], Convert.ToInt32(reader["ProductID"]), Convert.ToInt32(reader["ProductTypeID"]), reader["ProductTypeName"].ToString(), Convert.ToInt32(reader["ItemCount"])); products.Add(product); } } } return products; } </code></pre> <p>The Stored Procedure:</p> <pre><code>SELECT ProductID, Name, [Description], Code, DateCreated, ProductTypeID, ProductTypeName FROM ( SELECT P.pkProductID AS ProductID, P.Name AS Name, P.[Description] AS [Description], P.Code AS Code, P.DateCreated AS DateCreated, P.fkProductTypeID AS ProductTypeID, PT.Name AS ProductTypeName, ROW_NUMBER() OVER (ORDER BY P.pkProductID) AS RowNumber FROM Product P INNER JOIN ProductType PT ON PT.pkProductTypeID = P.fkProductTypeID WHERE P.Name LIKE '%' + @rvcName + '%' AND P.Code LIKE '%' + @rvcCode + '%' AND (@riProductTypeID = 0 OR P.fkProductTypeID = @riProductTypeID) ) AS tblProduct WHERE RowNumber >= @ristartIndex AND RowNumber < (@ristartIndex + @rimaxRows) SELECT COUNT(*) AS ItemCount FROM ( SELECT P.pkProductID, P.Name, P.[Description], P.Code, P.DateCreated, P.fkProductTypeID AS 'ProductTypeID', PT.Name AS 'ProductTypeName', ROW_NUMBER() OVER (ORDER BY P.Name DESC) AS RowNumber FROM Product P INNER JOIN ProductType PT ON PT.pkProductTypeID = P.fkProductTypeID WHERE P.Name LIKE '%' + @rvcName + '%' AND P.Code LIKE '%' + @rvcCode + '%' AND (@riProductTypeID = 0 OR P.fkProductTypeID = @riProductTypeID) ) AS TotalCount </code></pre> <p>Is it because its returning two tables? What's the solution?</p> |
6,492,838 | 0 | Generate two object files from the same source file in scons <p>Does scons allow to rename the result of Object('foo.cpp') along the lines of</p> <pre><code> o1 = env1.Object('src/foo.cpp', targetname='bar.o') o2 = env2.Object('src/foo.cpp', targetname='ney.o') </code></pre> <p>so that I can create two different object files from the same source file but different environments?</p> |
6,969,989 | 0 | What does {x:1} do in Javascript? <p>From Javascript: The Definitive Guide,</p> <pre><code>var o = { x:1 }; // Start with an object o.x = 2; // Mutate it by changing the value of a property o.y = 3; // Mutate it again by adding a new property </code></pre> <p>What does { x: 1} do here? With the braces, it reminds me of function (or for objects, constructor). Can someone please elaborate on it, thanks.</p> <p>An additional related question is:</p> <pre><code>({x:1, y:2}).toString() // => "[object Object]" </code></pre> <hr> <p>I find this question interesting as well. What is the difference between object and Object in the above code? In fact, when do we use Object? </p> |
264,881 | 0 | Can there ever be a "silver bullet" for software development? <p>I recently read the great article by Fred Brooks, "No Silver Bullet".</p> <p>He argues that there hasn't been a silver bullet that made software devlopment remarkably easier and that there never will be one.</p> <p>His argument is very convincing and I certainly agree with it.</p> <p>What is the stack overflow community's take on it? Is it possible for a silver bullet to one day come along and slay the software development werewolf?</p> <p>For more information on the article itself, see this article: <a href="http://en.wikipedia.org/wiki/No_Silver_Bullet" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/No_Silver_Bullet</a></p> |
6,838,793 | 0 | NSMutableArray initWithCapacity method description and memory management <p>It's about the instance method of NSMutableArray "initWithCapacity".</p> <p>From documentation, the Return Value is described as:</p> <blockquote> <pre><code>Return Value An array initialized with enough memory to hold numItems objects. The returned object might be different than the original receiver. </code></pre> </blockquote> <p>There seems to be a typo at "different than", my guess is it should be "different from". And also if the returned object is indeed different from the original, do we have to worry about releasing the memory associated with the original object ?</p> <p>Hope that somebody knowledgable on this can help ...</p> <p><a href="http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableArray" rel="nofollow">http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableArray</a></p> |
6,129,079 | 0 | <p>If you include a <code>\</code> at the start of your line, asp recognizes the whitespace.</p> <pre><code><%@ Language=JavaScript %> <% var s = "\ \ a"; Response.Write(s.length); %> </code></pre> <p>I wasn't familiar with using the <code>\</code> character to create multiline strings. Neat stuff, but I couldn't find documentation for that. I guess it's just escaping the line break? Do you have a link to a reference?</p> <p><strong>Edit</strong> Additionally, this code:</p> <pre><code><pre> <% var s = "\ unescaped"; Response.Write(s); Response.Write("\n"); s = "\ \ escaped"; Response.Write(s); %> </pre> </code></pre> <p>Gives this output:</p> <pre><code>unescaped escaped </code></pre> |
13,405,732 | 0 | <p>In addition to @MartinPieters answer the other way of doing this is to define the <code>find_global</code> method of the <code>cPickle.Unpickler</code> class, or extend the <code>pickle.Unpickler</code> class.</p> <pre><code>def map_path(mod_name, kls_name): if mod_name.startswith('packageA'): # catch all old module names mod = __import__('WrapperPackage.%s'%mod_name, fromlist=[mod_name]) return getattr(mod, kls_name) else: mod = __import__(mod_name) return getattr(mod, kls_name) import cPickle as pickle with open('dump.pickle','r') as fh: unpickler = pickle.Unpickler(fh) unpickler.find_global = map_path obj = unpickler.load() # object will now contain the new class path reference with open('dump-new.pickle','w') as fh: pickle.dump(obj, fh) # ClassA will now have a new path in 'dump-new' </code></pre> <p>A more detailed explanation of the process for both <code>pickle</code> and <code>cPickle</code> can be found <a href="http://nadiana.com/python-pickle-insecure" rel="nofollow">here</a>.</p> |
15,329,949 | 0 | <p>I had same problem and solve it by change in <code>AndroidManifest.xml</code>. You have to set theme of particular Activity or complete application to <code>Theme.Sherlock.Light</code> (I think you can specify only <code>Theme.Sherlock</code>).</p> <p>In code it will be:</p> <pre><code><application ... android:theme="@style/Theme.Sherlock.Light"> </code></pre> <p>or</p> <pre><code><activity ... android:theme="@style/Theme.Sherlock.Light"> </code></pre> |
21,991,603 | 0 | <p>Because they depend on how the route table is configured in each individual router or device it pass through from source to target locations.</p> <p>Given this network:</p> <pre><code>A - B - C | / D </code></pre> <p>A message can go from A to D by traveling through B (<code>A-B-D</code>) But maybe D is configured to every outgoing packets be routed through C so the return path can be (<code>D-C-B-A</code>).</p> <p>Probably not the best example but I think it makes a point. <em>Every</em> router is in charge of building and maintain their local <code>route tables</code> so this kind of situations can happen. You can find more information on <a href="http://en.wikipedia.org/wiki/Routing_table" rel="nofollow">Wikipedia page for Routing Tables</a>.</p> <p>Hope this helps!</p> |
26,134,796 | 1 | Python will not understand List <p>Sorry I have a very basic python question. In the following program I'm trying to duplicate a list and then sort it in ascending order. The code I've written is:</p> <pre><code>def lesser_than(thelist): duplicate = thelist[:] duplicate = duplicate.sort() return duplicate </code></pre> <p>The error it gives me is that it cannot sort something of the type None. Does anyone know why this is happening?</p> |
39,311,893 | 0 | Unable to attach matlab.exe process to visual studio 2013 for debugging mex files? <p>I am writing some mex files to run in my matlab program using visual studio 2013 compiler.<br> In order to be able to debug your mex files, you should follow <a href="http://www.mathworks.com/help/matlab/matlab_external/debugging-on-microsoft-windows-platforms.html" rel="nofollow noreferrer">these steps</a><br> Everything was right just some minutes ago and I was doing my project without any problem.<br> Today I have typed the code </p> <pre><code>mex -g mx_minimum_power.cpp cvm_em64t_debug.lib </code></pre> <p>on command prompt many times and after getting the success message, I've attached matlab.exe to visual studio and through setting a break point, I've debugged my code.<br> But this time I suddenly ran into the following error and I don't know how to solve it.<br> <a href="https://i.stack.imgur.com/djKSM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/djKSM.jpg" alt="enter image description here"></a> </p> <p><a href="https://i.stack.imgur.com/Ogjvx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ogjvx.jpg" alt="enter image description here"></a> </p> <p>When I right-clicked on the third option and clicked <code>run as administrator</code>, I encountered the following message:<br> <a href="https://i.stack.imgur.com/lKCCx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lKCCx.jpg" alt="enter image description here"></a> </p> <p>Then if I choose <code>configure remote debugging</code>, I'll encounter:<br> <a href="https://i.stack.imgur.com/aF7AH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aF7AH.jpg" alt="enter image description here"></a> </p> <p>Now I have the following processes that are shown to be running. </p> <p><a href="https://i.stack.imgur.com/rBfnQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rBfnQ.jpg" alt="enter image description here"></a> </p> <p>and again:<br> <a href="https://i.stack.imgur.com/4Npeh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Npeh.jpg" alt="enter image description here"></a> </p> <p>When I click on permissions or options for remote debugger: </p> <p><a href="https://i.stack.imgur.com/jsZm8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsZm8.jpg" alt="enter image description here"></a></p> |
11,084,022 | 0 | <p>Looking at your <a href="https://www.google.com/fusiontables/DataSource?dsrcid=4310315" rel="nofollow">table</a>, the column name is "ROLLING AREA".</p> <p>Try: <a href="http://www.geocodezip.com/v3_FusionTablesLayer_linktoA.html?lat=55.134627&lng=-7.702476&zoom=9&type=m&tableid=4310315&tablequery=select%20geometry%20from%204310315%20where%20%22%27ROLLING%20AREA%27%20%3C%20400%22" rel="nofollow">"'ROLLING AREA' < 400"</a></p> |
15,885,528 | 0 | <p>This is an old question, so I'm not going to go on and on, but, look into /proc/pid/oom_adj and /proc/pid/oom_score</p> |
28,480,261 | 0 | Extract IPs before string <p>I have this text:</p> <pre><code>111.11.1.111(*)222.22.2.221(mgn)333.33.3.333(srv) 111.11.1.111(*)333.33.3.333(srv)222.22.2.222(mgn) 222.22.2.223(mgn)111.11.1.111(*)333.33.3.333(srv) </code></pre> <p>I only want to know the IP's before (mgn), output:</p> <pre><code>222.22.2.221 222.22.2.222 222.22.2.223 </code></pre> <p>thanks</p> |
37,002,578 | 1 | Python read file into list - edit <ul> <li><p>edit - It seems that I have made an error with the calculation of number of parts tested:</p> <p><code>lines = len(file.readlines())</code> <code>N = lines - 2</code></p></li> </ul> <p>It did work when i tested it in a separate script though...</p> <p>Beginner here in need of help. I have a problem with my python script which I haven't been able to work out by myself. The script is supposed to read floating point from a text file and do some calculations. I can't get the numbers into the list <code>R[]</code>.</p> <p>Below is a sample of the text file where the first line (<code>s[0]</code>) is the nominal value, line two (<code>s[1]</code>) is the tolerance and the following lines are some resistors.</p> <hr> <p>3300.0</p> <p>10.0</p> <p>3132.0</p> <p>3348.5</p> <p>3557.3</p> <p>3467.4</p> <p>3212.0</p> <p>3084.6</p> <p>3324.0</p> <p>I have the following code:</p> <pre><code>R = [] Ntoolow = Nlow = Nhigh = Ntoohigh = 0.0 lines = 0 def find_mean(q): tot = 0.0 c = len(q) for x in range (c): tot += q[x] return tot/c def find_median(q): c = len(q) if c%2: return float(q[int(c/2)]) else: c /= 2 return (q[int(c)]+q[int(c-1)])/2.0 file_name = input("Please enter the file name: ") file = open(file_name, "r") s = file.readlines() Rnom = float(s[0]) Tol = float(s[1]) keepgoing = True while keepgoing: s = file.readline() if s == "": keepgoing = False else: R.append(float(s)) lines = len(file.readlines()) N = lines - 2 R.sort() Rmin = R[0] Rmax = R[N-1] Rlowerlimit = Rnom - Tol Rupperlimit = Rnom + Tol for rn in R: if rn < Rlowerlimit: Ntoolow += 1 elif rn < Rnom: Nlow += 1 elif rn <= Rupperlimit: Nhigh += 1 else: Ntoohigh += 1 Ptoolow = 100.0 * Ntoolow / N Plow = 100.0 * Nlow / N Phigh = 100.0 * Nhigh / N Ptoohigh = 100.0 * Ntoohigh / N Rmean = find_mean(R) Rmedian = find_median(R) print("Total number of parts tested: " + str(N)) print("The largest resistor is: " + str(Rmax) + " and the smallest is: " + str(Rmin)) print("The mean is: " + str(Rmean) + " and the median is: " + str(Rmedian)) print("The percentage of resistors that have too low tolerance is: " + str(Ptoolow) + "%") print("The percentage of resistors that have low tolerance is: " + str(Plow) + "%") print("The percentage of resistors that have high tolerance is: " + str(Phigh) + "%") print("The percentage of resistors that have too high tolerance is: " + str(Ptoohigh) + "%") file.close() </code></pre> |
3,388,666 | 0 | <p>They are probably using three20's <code>TTLauncherView</code> control or they might of made their own version of it</p> <p>More info: <a href="http://three20.info/overview" rel="nofollow noreferrer">http://three20.info/overview</a></p> |
1,379,981 | 0 | <p>I think because XOR is reversible. If you want to create hash, then you'll want to avoid XOR.</p> |
20,961,224 | 0 | <p>Check out Open Graph- Twitter & Facebook both use this architecture to retrieve "stories" posted by users. It's a version of the semantic web idea. <a href="https://developers.facebook.com/docs/opengraph/" rel="nofollow">https://developers.facebook.com/docs/opengraph/</a> The days of SQL calls are over (thank god). FQL- the Facebook Query Language still works, but is largely being deprecated. It's not SQL but a version of a query language against the graph (was databases).</p> |
39,079,482 | 0 | NestedScrollView inside CoordinatorLayout don't have smooth scroll <p>I have some trouble trying to do a Smooth scrolling using a NestedScrollView inside a CoordinatorLayout. Now when I scroll It stops and don't have a smooth scroll, like when I scroll on a RecyclerView.</p> <p>Code:</p> <pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingPrefix"> <include layout="@layout/tool_bar" /> <android.support.design.widget.CoordinatorLayout android:layout_below="@+id/toolbar" android:layout_above="@+id/eventDetailActivity_bottomRelativeLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.design.widget.AppBarLayout android:id="@+id/main.appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" > <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/eventDetailActivity_collapsingToolbarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimary"> <RelativeLayout app:layout_collapseMode="parallax" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/eventDetailActivity_speakerPictureImageView" android:layout_width="match_parent" android:layout_height="250dp" android:scaleType="centerCrop" android:src="@drawable/bg_profile" /> </RelativeLayout> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:fillViewport="true" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/eventDetailActivity_nestedScrollView" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:layout_gravity="fill_vertical"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:paddingBottom="7dp" android:paddingTop="7dp" android:id="@+id/eventDetailActivity_speakerInfoRl" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/orange"> <TextView android:height="21dp" android:id="@+id/eventDetailActivity_speakerLocationTextView" android:layout_marginLeft="20dp" android:textColor="@color/violet" tools:text="Londres, Reino Unido" android:textSize="12sp" fontPath="fonts/Roboto-Medium.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_alignParentStart="true" android:layout_alignParentLeft="true" /> <TextView android:height="21dp" android:id="@+id/eventDetailActivity_speakerEmailTextView" android:layout_marginRight="20dp" android:textColor="@color/violet" tools:text="Londres, Reino Unido" android:textSize="12sp" fontPath="fonts/Roboto-Medium.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" /> </RelativeLayout> <TextView android:id="@+id/eventDetailActivity_speakerDescriptionTextView" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginBottom="20dp" android:layout_marginTop="20dp" android:textColor="@color/grayA" tools:text="Cuantos estilos de ilustración existen en el mundo? Nosotros conocemos 30, y te los queremos enseñar a todos en un workshop tan exagerado y tenaz..." android:textSize="14sp" android:lineSpacingExtra="@dimen/lines_spacing" fontPath="fonts/Roboto-Light.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="start"/> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/plus_x3"/> <LinearLayout android:layout_marginTop="20dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginBottom="20dp" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/eventDetailActivity_eventTitleTextView" android:textColor="@color/grayA" tools:text="Event Title" android:textSize="16sp" fontPath="fonts/Roboto-Bold.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/eventDetailActivity_eventDateTextView" android:layout_marginTop="15dp" android:textColor="@color/grayA" tools:text="Event Date" android:textSize="14sp" fontPath="fonts/Roboto-Light.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/eventDetailActivity_eventLocationTextView" android:layout_marginTop="10dp" android:textColor="@color/grayA" tools:text="Event Location" android:textSize="14sp" android:lineSpacingExtra="@dimen/lines_spacing" fontPath="fonts/Roboto-Light.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout> <include android:layout_below="@+id/toolbar" layout="@layout/tool_bar_dropshadow" android:layout_height="wrap_content" android:layout_width="match_parent"/> <RelativeLayout android:id="@+id/eventDetailActivity_bottomRelativeLayout" android:background="@color/violet" android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content"> <RelativeLayout android:id="@+id/eventDetailActivity_favoriteRelativeLayout" android:clickable="true" android:background="?attr/selectableItemBackground" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/eventDetailActivity_favoriteTextView" android:padding="16dp" android:layout_centerInParent="true" android:textColor="@color/orange" android:text="@string/eventDetailActivity_addToFavs" android:textSize="14sp" fontPath="fonts/Roboto-Medium.ttf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawablePadding="11dp"/> </RelativeLayout> </RelativeLayout> </code></pre> <p></p> <p>I tried putting the NestedScrollView on a Fragment but that doesn't worked.</p> |
29,934,384 | 0 | <p>You have a spurious semicolon between the <code>for</code> loop and what you think is the body. Eliminate that and it should work as expected.</p> <pre><code>for(x = 0; x < 3 ; x++); { ^ | eliminate this </code></pre> <p>What's happening now is that the <code>for</code> loop is looping three times and each time it is executing the empty statement formed by the semicolon. Then the block statement that you want executed three times is being executed once.</p> |
26,185,915 | 0 | <p>Array hydration is not the best way for achieve this kind of situations. The same scenario here:</p> <pre><code>Person - id_person - name - child //self refering </code></pre> <p>Array hydration only select the first level. I resolving it taking one of these two options:</p> <ol> <li><p>Use <code>left join</code> association</p> <pre><code>$query = $entityManager->createQueryBuilder() ->select('p1, p2, p3, p4, p5, p6') ->from('Entity\Person', 'p1') ->leftJoin('p1.child', 'p2') ->leftJoin('p2.child', 'p3') ->leftJoin('p3.child', 'p4') ->leftJoin('p4.child', 'p5') ->leftJoin('p5.child', 'p6') ->createQuery(); </code></pre> <p>and then, use array hydration.</p></li> <li><p>Create your own recursive function in order to add manually each element in an array.</p></li> </ol> |
40,948,013 | 0 | meteor update method not working <p>this is my colletion:</p> <pre><code>{ "_id" : "Kan6btPXwNiF84j8e", "title" : "Chapter Title 1", "businessId" : "qmWJ3HtZrpka8dpbM", "createdBy" : "GfdPfoPTiSwLv8TBR", "sections" : [ { "id" : "T5KAfTcCb7pCudT3a", "type" : "TEXT", "data" : { "text" : "<h1>2</h1><h1>asd</h1>" }, "createdAt" : ISODate("2016-12-03T10:35:59.023Z"), "updatedAt" : ISODate("2016-12-03T10:35:59.023Z") } ], "createdAt" : ISODate("2016-12-02T12:15:16.577Z"), "updatedAt" : ISODate("2016-12-03T12:54:50.591Z") } </code></pre> <p>this is the meteor method I am calling from client side</p> <pre><code>deleteSection: function (section_id, chapter_id) { chaptersCollection.update( {$and: [{_id: chapter_id}, {'sections.id': section_id}]}, {$pull: {'sections': {'id': section_id}}}, function (err, numAffected) { if (err) { console.log(err); return err; }else{ console.log(numAffected); } }); return 'Section Successfully Deleted'; } </code></pre> <p>in callback function of meteor method, it returns 1 as affected rows. But on server document is not updating.</p> <p>Any suggestion where am I wrong?</p> |
19,374,950 | 0 | Best tool to generate normal distribution graph in java or jquery <p>I want to generate <strong>normal distribution</strong> graph for a set of values as in the <a href="http://en.wikipedia.org/wiki/File%3aStandard_deviation_diagram.svg" rel="nofollow">link</a>,I have tried using <code>JFreeChart</code> but could not get the desired output <a href="http://stackoverflow.com/questions/19357905/how-to-give-a-different-color-for-each-sigma-section">problem</a>.so asking a new question,hope our stack users will give suggestions.</p> <p>Is there any way to generate the graph as it is in the link with <strong>java</strong> or <strong>jquery</strong> from the calculated mean and standard deviation?</p> |
22,118,351 | 0 | <p>zmq_send and zmq_recv seems to handle zmq_msg_t structures rather than just the buffer.<p> Maybe you should try to create such structures rather than just sending your buffer ?<p> See the examples in <a href="http://api.zeromq.org/2-1:zmq-send" rel="nofollow">http://api.zeromq.org/2-1:zmq-send</a> and <a href="http://api.zeromq.org/2-1:zmq-recv" rel="nofollow">http://api.zeromq.org/2-1:zmq-recv</a></p> |
37,290,885 | 1 | Can't view Heroku logs - Cannot read property 'run' of undefined <p>I am attempting to deploy a python3 app to heroku. The app has some kind of error and isn't rendering (I see the generic error message in the browser) so I'm trying to troubleshoot via Heroku logs, but I get this error instead of the log output.</p> <pre><code>C:\Users\Kate\AppData\Local\heroku\tmp\heroku-script-182282411:14 cmd.run(ctx) ^ TypeError: Cannot read property 'run' of undefined at Object.<anonymous> (C:\Users\Kate\AppData\Local\heroku\tmp\heroku-script- 182282411:14:4) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:456:32) at tryModuleLoad (module.js:415:12) at Function.Module._load (module.js:407:3) at Function.Module.runMain (module.js:575:10) at startup (node.js:160:18) at node.js:445:3 </code></pre> <p>This is on Windows 7 x86, I tried in both windows command prompt and Git Bash and got the same result. I installed the latest Heroku toolbelt with no change. Any thoughts on what to try next?</p> |
13,753,208 | 0 | <p>The answer to your question is that Objective-C does not have a direct equivalent of annotations as found in Java/C#, and though as some have suggested you might be able to engineer something along the same lines it probably is either far too much work or won't pass muster.</p> <p>To address your particular need see <a href="http://stackoverflow.com/questions/5197446/nsmutablearray-force-the-array-to-hold-specific-object-type-only/5198040#5198040">this answer</a> which shows how to construct an array which holds objects of only one type; enforcement is dynamic and not static as with parametric types/generics, but that is what you'd be getting with your annotation so it probably matches your particular need in this case. HTH.</p> |
14,746,477 | 0 | <p>use <code>overflow:auto</code> property of css instead of <code>scroll</code>, and give some <code>height</code> for your list.</p> |
23,044,032 | 0 | <p>Write this lines of code in oncreate() </p> <pre><code> Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); </code></pre> |
3,837,890 | 0 | <p>Here's my go at it... basically an unrolled loop. The JIT would probably have recognized that a loop would have gone from 0 to 3 and unrolled it itself anyway, but who knows...</p> <pre><code>public static int max(int[] a) { int max = a[0] > a[1] ? a[0] : a[1]; max = a[2] > max ? a[2] : max; return a[3] > max ? a[3] : max; } </code></pre> <p>Sum would obviously just be <code>a[0] + a[1] + a[2] + a[3]</code>.</p> <hr> <p>You could also try packing the four 0-255 values in an int, and do some bit-operations instead.</p> |
37,621,380 | 0 | Set up angular 2 Visual Studio 2015 <p>I have been trying for days to get my project set up correctly. I am going from this post <a href="http://www.mithunvp.com/angular-2-in-asp-net-5-typescript-visual-studio-2015/" rel="nofollow">here</a></p> <p>I have everything working but when I want to put my view in an .html file instead of inline I am having trouble getting the folder structure and html files in the wwwroot folder so I can correctly map my templateUrl's. </p> <p>So my questions are: Is it possible to put the scripts folder and my angular app files inside the wwwroot folder instead of in the root of my project?</p> <p>If not, how do I get gulp to move my compiled .ts files and my folder structure and html to the wwwroot folder?</p> <p>My current folder structure is something like this <a href="http://screencast.com/t/DAk3yEBu0X3b" rel="nofollow">http://screencast.com/t/DAk3yEBu0X3b</a></p> <p>I do not know how to reference my app.html since it does not get moved into wwwroot file.</p> <p>Thanks</p> <p><strong>EDIT:</strong> I am trying to use Steve Sanderson's Template, the one @Mike Mazmanyan suggested. The template is making me even more confused. It looks like its using CommonJS to compile the templates and put them in the script file instead of just referencing them from the server. </p> <p>Is the the preferred way to write angular applications? It seams like if you put your whole application including html in one script file it will take a long time to download.</p> <p>Is it possible to do both? Put some templates in a script file and have some that are just a path to a endpoint? I want to use the server side partial templates like in the <a href="https://ievangelistblog.wordpress.com/2016/01/13/building-an-angular2-spa-with-asp-net-5-mvc-6-web-api-2-and-typescript-1-7-5/" rel="nofollow">post</a></p> |
15,279,765 | 0 | <p>We have implemented exactly that kind of feature on the homepage of ilsschools.co.uk using client side onchange event:</p> <pre><code>var com2 = XSP.getElementById("#{id:comboBox2}"); XSP.partialRefreshGet("#{id:comboBox2}", { onComplete : com2.selectedIndex = 0 }); </code></pre> <p>We get the element we want to refresh (i.e. comboBox2 and we do this for comboxBox3, 4 etc as well). Then we use partialRefreshGet to refresh the choices in comboBox2, this can be repeated for 3, 4 and other comboBoxes as well. You can compute the disabled property of a comboBox to disable it. You can compute the selections for a comboBox using SSJS.</p> <p>Hope this helps.</p> |
22,626,811 | 0 | <p>In the order by clause we can add two thing:</p> <ul> <li><p>Column names</p> <pre><code>Select * from TTT order by age; </code></pre></li> <li><p>Coulmn number to filter</p> <pre><code>Select * from TTT order by 2;//if age is the second column in the table or Select name,age from TTT order by 2; // this will order by age </code></pre></li> </ul> <p>In the following case the inner query</p> <pre><code> SELECT AGE FROM TTT WHERE NAME='TANDEL' </code></pre> <p>will return 5</p> <p>and the parent query</p> <pre><code> SELECT * FROM TT ORDER BY 5 </code></pre> |
4,024,815 | 0 | <p>Set an <code>onkeyup</code> or <code>onkeydown</code> event on your textarea, the latter is better because it fires before the new line is added to the textarea</p> <pre><code>var $form = $( '#yourForm' ); $( '#yourTextArea' ).keydown(function( e ){ if( e.keyCode == 13 ){ $form.submit(); } }); $form.submit(function(){ alert( 'submitted' ); return false; }); </code></pre> |
32,270,616 | 0 | asp.net not deploying non-referenced assemblies <p>I have a asp.net mvc project that is part of a azure cloud project. Lets call it <code>WebRole</code>.</p> <p>The <code>WebRole</code> project depends on a service interface witch is in it's own assembly. Let's call that <code>Services</code>. The implementation of those service interfaces sits in yet another assembly, which we can call <code>Services.Implementations</code>.</p> <p>The <code>WebRole</code> project have no direct dependency on <code>Service.Implementations</code>, but the IoC-container will map things together. The problem is that as long as the direct reference is not there, <code>Service.Implementations</code> won't get deployed. Neither to local IIS Express or to the cloud.</p> <p>How can I tell that the <code>Service.Implementations</code> project needs to be deployed, without exposing it to the <code>WebRole</code> project?</p> |
36,190,407 | 0 | ceil function doesn't return what it should <p>I have a problem with the ceil function in matlab. When I say "ceil(192.00)" it returns 192, as it should. However, when I declare a variable x and assign it 14*(256/20)+(256/20), that being exactly 192.00, ceil(x) returns 193. Why is that? Thanks in advance!</p> |
25,766,005 | 0 | <pre><code>} catch (InputMismatchException e) { correctInput = false; System.out.println("Please enter int value"); inputScanner.next(); } </code></pre> <p>consume one token and continue</p> |
5,675,448 | 0 | <pre><code>SELECT a.* FROM a LEFT JOIN b USING (signup) WHERE b.id IS NULL AND *signup thingie*; </code></pre> <p>though this is the way to select rows that have no match I do not see how you want to get the desired result from these tables, I believe you missed something in your illustration.</p> |
13,935,454 | 1 | split python string on multiple string delimiters efficiently <p>Suppose I have a string such as <code>"Let's split this string into many small ones"</code> and I want to split it on <code>this</code>, <code>into</code> and <code>ones</code></p> <p>such that the output looks something like this:</p> <pre><code>["Let's split", "this string", "into many small", "ones"] </code></pre> <p>What is the most efficient way to do it?</p> |
15,859,581 | 0 | <p>No, you don't. A quality implementation (<code>Hashtable</code>/<code>HashMap</code>) will resize itself automatically as the number of elements increases.</p> <p>If you are talking about your own implementation, the answer depends on whether the hash table is capable of increasing the number of buckets as its size grows.</p> <p>If you are worried about the performance implications of the resizing, the correct approach is to profile this in the context of your overall application.</p> |
3,595,562 | 0 | <p>I just went through the process of installing and trying several carts for a project that I was working on. As Pierre says above, "There is no best shopping cart, however there is one best for your specific need" That is a very truthful statement.</p> <p>My project was for an on line soap company that has 5 different categories with 5 or so variations each. Not a big store and not one that changes inventory often.</p> <p>I tried the following carts: PrestaShop, Zen Cart, Magento, getshopped and phpurchase.</p> <p>My findings were that for a small store, PrestaShop, Zen Cart and Magento are a bit overkill. For a small shop, getshopped and phpurchase are better fits.</p> <p>Out of the 3 big shop solutions, I felt that Zen Cart is really hard to make look nice. It has a 90's vibe about the template that it comes with and takes a lot of work to get around that. Magento and PrestaShop were really cool. PrestaShop seems very UK specific. It did not take Authorize.net and I think that there may be a plugin that you can get. Magento seems like a great solution for a larger store and I liked the backend admin interface.</p> <p>I purchased getshopped plugin and integrated it into my Wordpress site (I purchased the Authroize.net integration gold cart level) I had such trouble dealing with the multiple bugs that I found riddled through the code base. I looked at their forum and many people who had similar issues were not responded to. Alot of people were as frustrated as me. I tried customer support - no response. I asked for a refund, no response. Basically, Get Shopped was a complete waste of time and money.</p> <p>I then found Phpurchase. The customer support person, Lee Blue was really nice - Lee answered my emails morning, noon and night. Lee is literally the nicest customer support person I've ever worked with! - so helpful. The code worked just as specced - no troubles and no complaints. I'm a very happy customer with phpurchase. If I need a small ecommerce site in the future, I will use that solution again, for sure. </p> <p>Note, I'm not an affiliate of Phpurchase or have any type of financial gain by recommending them, I just had such a rough time with getShopped and such a wonderful experience with <a href="http://www.phpurchase.com/" rel="nofollow noreferrer">Phpurchase!</a></p> |
28,513,861 | 0 | <p>Code placed in App_Code folder is treated a bit different, it is compiled at runtime. cshtml file is 'Content' so that could be the reason why you get errors. Create normal folder within your project name it Code or something similar (but not App_Code) and place your file there.</p> |
23,626,280 | 0 | Yellow border on hover using ZeroClipboard <p>I have the following code generating a ZeroClipboard element for me:</p> <pre><code>RunClipboardClient: function (elementSelector) { var client = new ZeroClipboard($(elementSelector)); client.on("load", function (client) { client.on("datarequested", function (client) { client.setText("Text here"); }); client.on("complete", function (client, args) { $("#ActiveMenu").hide(); }); }); } </code></pre> <p>Im using this in combination with <a href="http://medialize.github.io/jQuery-contextMenu/" rel="nofollow noreferrer">jQuery Context Menus</a> open event. The problem is that there is a odd yellow border around the element when hovering the second time I open the context menu.</p> <p><img src="https://i.stack.imgur.com/X2LPe.jpg" alt="enter image description here"></p> <p>I tried applying <code>outline: none</code> to the styling but it did not remove the border. This is the code i'm running when generating the context menu:</p> <pre><code>$(".MenuSmall").destroyContextMenu(); $(".MenuSmall").contextMenu( { menu: 'ActiveMenu' }, // On item clicked function (action, element) { // Run Menu Item action }, // On close function () { // Run other code }, // On open function (event) { self.RunClipboardClient("#pdf_link"); } ); </code></pre> <p>This is the HTML using for the context menu</p> <pre><code><ul id="ActiveMenu"> <li class="MenuPDFLink CustomMenuOption" id="pdf_link"><div class="iconsBlack PDFLink"></div> <a href="#">Link til PDF</a></li> </ul> </code></pre> |
17,134,117 | 0 | <pre><code>// jquery plugin uploader.plupload('getUploader').splice(); $('.plupload_filelist_content', uploader).empty(); </code></pre> |
9,285,914 | 0 | <p>It doesn't matter. As long as Apache is installed before the PHP package then you are good to go. (Because when you install the PHP package some distributions do some auto-configuring with Apache).</p> |
3,443,598 | 0 | Get php results with jquery ajax <p>I don't know why I am having a hard time with this, but it's about time I came up for air and asked the question.</p> <p>What is the best way to call a php file with jquery ajax, have it process some inputs via $_GET, return those results and again use ajax to replace the content of a div?</p> <p>So far, I can call the php file, and in the success of the jquery ajax call I get an alert of the text.</p> <pre><code>$.ajax({ url: "xxx/xxx.php", type: "GET", data: data, cache: false, success: function (html) { alert("HTLM = " + html); $('#product-list').html(html); } }); </code></pre> <p>I set the php function to echo the result, the alert spits out the html from the php file. But I get a side effect. I get the code that the php generated echoed at the top of the page. So php is doing it's job (by echoing the content). Next jquery is doing it's job by replacing the div's content with the values from the php file.</p> <p>How do I stop the php file from echoing the stuff at the top of the page?</p> <p>Sample code being echoed from php and alerted in the success of jquery ajax</p> <p>HTML = </p> <pre><code><div class="quarter"> <div class="thumb"> <a href="productinfo.php?prod-code=Y-32Z&cat=bw&sub="> <img src="products/thumbs/no_thumb.gif" alt="No Image" border="0" /> </a> </div> <div class="labels"><span class="new-label">New</span></div> <p><span class="prod-name">32OZ YARD</span></p> <p><span class="prod-code">Y-32Z</span></p> </div> </code></pre> <p>Thanks!!!</p> <p>-Kris</p> |
35,134,647 | 0 | Invoke service when screen turns on (Android) <p>I am creating a lockscreen app with facial recognition. As a first step I am creating a simple lockscreen that unlocks on <code>Button</code> click. The lockscreen should start when <code>Switch</code> on <code>MainActivity</code> is turned on. I created a <code>Service</code> which starts my lockscreen activity, but the activity does not show again once I turn off and then turn on my screen. I am a beginner in android and don't understand what to do. I would be happy if i could get some help.</p> <p>The java files are:</p> <p>MainActivity.java</p> <pre><code>package com.sanket.droidlockersimple; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.Switch; public class MainActivity extends ActionBarActivity { private Switch enableLocker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); enableLocker = (Switch) findViewById(R.id.enableLocker); enableLocker.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(enableLocker.isChecked()) { Intent intent = new Intent(MainActivity.this, DroidLockerService.class); startService(intent); } } }); } } </code></pre> <p>DroidLockerService.java</p> <pre><code>package com.sanket.droidlockersimple; import android.app.Service; import android.content.Intent; import android.os.IBinder; public class DroidLockerService extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Intent intent1 = new Intent(this, LockScreen.class); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent1); } @Override public void onDestroy() { super.onDestroy(); } } </code></pre> <p>LockScreen.java</p> <pre><code>package com.sanket.droidlockersimple; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.widget.Button; public class LockScreen extends ActionBarActivity { private Button unlock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); setContentView(R.layout.activity_lock_screen); Button unlock = (Button) findViewById(R.id.button); unlock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } } </code></pre> |
41,070,767 | 0 | ensimeConfig creates directories java and scala-2.11, which I don't need <p>When I run <code>ensimeConfig</code>, it creates directories such as</p> <pre><code>src/main/java src/main/scala-2.11 </code></pre> <p>which I don't need, since I have my sources always inside </p> <pre><code>src/main/scala </code></pre> <p>How can I avoid such behaviour?</p> <p>NOTE: This is the version I'm using: <code>addSbtPlugin("org.ensime" % "sbt-ensime" % "1.12.4")</code></p> |
20,077,212 | 0 | New Relic iOS app doesn't notify of downtime anymore <p>Not sure when this started happening, but I used to get alerts on my iPhone from the New Relic app when our site went non-responsive. I don't think we changed anything. How can I re-enable these alerts?</p> |
759,223 | 0 | <p>Yes. A float (or double) is guaranteed to exactly represent any integer that does not need to be truncated. For a double, there is 53 bits of precision, so that is more than enough to exactly represent any 32 bit integer, and a tiny (statistically speaking) proportion of 64 bit ones too.</p> |
28,116,320 | 0 | <p>You need to use the place.Search function of The Wikimapia API and enter the latitude, longitude and the name of the place as parameters.</p> <p>The API returns a lot of data separated in blocks. The one you are interested in is the <strong>geometry</strong>.</p> <p>You can make tests with the <a href="http://wikimapia.org/api/?action=examples&function=place.search" rel="nofollow">Wikimapia API</a> to filter the results to your needs. With the lat lon parameters and the district name you provided I was able to get the area you needed as the first result.</p> <p>The places[0].polygon is what you need. A JSON array of coordinates.</p> <p>Here´s the url I used to get the results:</p> <p><a href="http://api.wikimapia.org/?key=example&function=place.search&q=Chervonozavodsky-district&lat=49.964473&lon=36.262436&format=json&pack=&language=en&data_blocks=geometry%2C&page=1&count=1" rel="nofollow">http://api.wikimapia.org/?key=example&function=place.search&q=Chervonozavodsky-district&lat=49.964473&lon=36.262436&format=json&pack=&language=en&data_blocks=geometry%2C&page=1&count=1</a></p> <p>Note that in this example i made the request for a JSON result. But you can also ask for a XML if you prefer.</p> <p>Hope it helps!</p> |
38,719,978 | 0 | <p>Bootstrap has no direct provision for partial columns.</p> <p>You can rewrite the stylesheet to operate on a different number of columns (i.e. 24).</p> <p>The <a href="http://getbootstrap.com/customize/" rel="nofollow">customize</a> page will let you specify a different number of columns and generate the stylesheet for you.</p> <p>Alternatively, you can check out Bootstrap from Git and modify <a href="https://github.com/twbs/bootstrap/blob/master/less/variables.less#L325" rel="nofollow">the variables file</a> to the same effect.</p> |
7,322,272 | 0 | <p>Update: the Firefox bug is now marked as “fixed” and will make it into a near-future update.</p> <hr> <p>I’ve run into this too and would <strong>love</strong> to see the root cause fixed.</p> <ul> <li><p>I talked to a couple of Firefox developers (mbrubeck and gavin), and they think that it’s a bug! <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=300849" rel="nofollow">The same issue was reported, and fixed,</a> in 2005 for Firefox 1.9. Then, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=489259" rel="nofollow">bug 489259</a> was opened in 2009. mbrubeck has graciously moved it out of the “unconfirmed” pile.</p></li> <li><p>Safari behaves better than Firefox, but an error message (“One error in opening the page…”) shows up in the status bar if you remove the iframe during the <code>load</code> event. I found two similar WebKit bugs which have been open since 2007: <a href="https://bugs.webkit.org/show_bug.cgi?id=15485" rel="nofollow">15485</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=13281" rel="nofollow">13281</a>. </p></li> </ul> <p>This appears to happen when you remove an <code>iframe</code> from the document during the <code>load</code> event. JavaScript events fire <em>synchronously</em> — that is, in series with the browser’s own handling of the web page. That’s why it's possible to prevent a form from being submitted or prevent a keypress or mouse click from being registered from within an event handler.</p> <p>The last time this bug was fixed in Firefox, the cause was that the removing an <code>iframe</code> from the page makes it forget which page owned it, but the <code>iframe</code> notifies the page that it was finished loading <em>after</em> the <code>load</code> event.</p> <p>Anything you schedule with <code>setTimeout</code> happens after the current cycle of the event loop — after the browser finishes what it’s doing <em>right now</em>. So, using setTimeout to remove the <code>iframe</code>, even with a timeout of zero, lets it finish:</p> <pre><code>iframe.onload = function(){ // Do work with the content of the iframe… setTimeout(function(){ iframe.parentNode.removeChild(iframe); }, 0); } </code></pre> <p>You can find this technique in use <a href="https://github.com/malsup/form/blob/e77e287c8024d200909a7b4f4a1224503814e660/jquery.form.js#L511" rel="nofollow">in the jQuery form plugin</a>.</p> |
25,594,636 | 0 | Getting content from opening associated file Android SDK <p>So, I am associating a particular file type with my app and I want to be able to make it so that when a file of that type is opened, the app opens and is able to retrieve the information from the file. How would I go about doing this? I know I can associate the file by using the following:</p> <pre><code><action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="file" android:host="*" android:pathPattern=".*\\.shrt" android:mimeType="*/*" /> </code></pre> <p>Of course the code is in the manifest file in an intent filter, but getting the text of the file is what is leaving me stuck. I couldn't find any article relating to the subject(only one, which had no solutions).</p> |
1,228,323 | 0 | <p>You don't want to use <code>@course.chapters.build</code> here because this does add an empty chapter to the course. Instead you'll want to use <code>Chapter.new</code> and set the <code>:course</code> option like this.</p> <pre><code>@newchapter = Chapter.new(:course => @course) </code></pre> <p>It may not even be necessary to specify <code>:course</code> here depending on how you are using <code>@newchapter</code>.</p> |
2,954,820 | 0 | Determine if point intersects 35km radius around another point? Possible in Linq? <p>Assume I have a point at the following location:</p> <p>Latitude: 47°36′N Longitude: 122°19′W</p> <p>Around the above point, I draw a 35Km radius. I have another point now or several and I want to see if they fall within the 35Km radius? How can I do this? Is it possible with Linq given the coordinates (lat, long) of both points?</p> |
36,617,616 | 0 | <p>Have you tried on <strong>your php file</strong> , that?:</p> <pre><code>header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST/GET'); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); </code></pre> <h2>UPDATE</h2> <p>As i read <strong>your error message above</strong> ,the error seems to be on the response, so i show you a screenshot of my request to the server(from my live web-app where i use CORS on the php), you need these headers on the response ,please see my response from the server:</p> <p><a href="https://i.stack.imgur.com/XYUdy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XYUdy.png" alt="enter image description here"></a></p> <p>Hope helps, good luck.</p> |
30,203,524 | 0 | navBar not fading out <p>I'm writing a script in order for the navBar to go in on certain place and disappear on that same place. I managed to make it go in, but it won't leave. I can't find my mistake. Please help me. Here is my code: </p> <pre><code>var dummie = document.getElementById("dummie"); var navBar = document.getElementById("navBar"); var test = function(){ dummie.textContent = window.pageYOffset; if(window.pageYOffset > 351){ navBar.style.visibility = "visible"; } else { if(window.pageYOffset < 351){ navBar.visibility = "hidden"; } } } window.setInterval(test, 1); </code></pre> |
40,921,341 | 1 | bytearray instead of regular string value <p>I am loading data from one table into pandas and then inserting that data into new table. However, instead of normal string value I am seeing bytearray.</p> <p><code>bytearray(b'TM16B0I8')</code> it should be <code>TM16B0I8</code></p> <p>What am I doing wrong here? </p> <h2>My code:</h2> <pre><code>engine_str = 'mysql+mysqlconnector://user:pass@localhost/db' engine = sqlalchemy.create_engine(engine_str, echo=False, encoding='utf-8') connection = engine.connect() th_df = pd.read_sql('select ticket_id, history_date', con=connection) for row in th_df.to_dict(orient="records"): var_ticket_id = row['ticket_id'] var_history_date = row['history_date'] query = 'INSERT INTO new_table(ticket_id, history_date)....' </code></pre> |
714,475 | 1 | What is a maximum number of arguments in a Python function? <p>It's somewhat common knowledge that Python functions can have a maximum of 256 arguments. What I'm curious to know is if this limit applies to <code>*args</code> and <code>**kwargs</code> when they're unrolled in the following manner:</p> <pre><code>items = [1,2,3,4,5,6] def do_something(*items): pass </code></pre> <p>I ask because, hypothetically, there might be cases where a list larger than 256 items gets unrolled as a set of <code>*args</code> or <code>**kwargs</code>.</p> |
4,657,548 | 0 | <p>That's an error Windows gives when you're trying to bind to an address on the local machine that's not assigned to any of the adapters on the machine. If <code>ipconfig</code> doesn't show it, you can't bind to it. </p> <p>If the external address is on a router that is NAT'ing requests from it to the server's internal address, you can't bind to it because it's on a different machine. This is probably the case. You might want to bind to <code>socket.INADDR_ANY</code> (or its Django equivalent). This will bind to all addresses that are on the machine right now.</p> <p>Also note that if the external address is NAT'ed to your internal one, binding to the internal one should be enough.</p> |
37,131,110 | 0 | How to select sql query for two table with multiple values in php <p>I have two tables in my SQL Server database. The first is <code>bidder_interest_name</code> and second is <code>tender_type_subcat</code> . There have multiple value column <code>bidder_interest_subcategory</code> in <code>bidder_interest_name</code> and <code>tender_type_subcategory</code> in <code>tender_type_subcat</code> tables.</p> <p>Now I want to select the multiple values from both the tables for a particular subcategory and need to both table minimum matching value.</p> <p>This is what I'm doing</p> <p>What I have tried:</p> <pre><code>SELECT bi.bidder_interest_subcategory,tt.tender_type_subcategory FROM bidder_interest_list as bi,new_tender_two as tt WHERE bi.bidder_id=$bidder_id </code></pre> |
35,260,364 | 0 | <p>While it is acceptable to return pointers to the string literals, buit not to a local pointer, it might be the wrong approach.</p> <p>If <code>str</code> does not change, make it <code>static const char * const str[] = ....</code> That qualifies both, the array and the <code>char []</code> (which is each string literal) it points to const. The <code>static</code> makes it permanent, but with still local scope. It is setup once before your program code starts. In contrast, a non-<code>static</code> version will setup the array for every call.</p> <p>Note that you have to return a <code>const char *</code> to maintain const-correctness. I strongly recommend that; if you cannot, omit the first <code>const</code> only.</p> <p><strong>Note:</strong> Do not cast the result of <code>malloc</code> & friends (or <code>void *</code> in general) in C.</p> |
19,143,323 | 0 | <p>How did you install R ? It looks like you are missing R headers. Perhaps you need to install the <a href="http://cran.r-project.org/bin/linux/debian/" rel="nofollow"><code>r-base-dev</code> package</a>. </p> <p>About the code, you don't need the wrapper. You can just put this in a <code>.cpp</code> file : </p> <pre><code>#include <Rcpp.h> using namespace Rcpp ; // [[Rcpp::export]] int fibonacci(const int x){ if(x == 0) return(0); if(x == 1) return(1); return(fibonacci(x - 1) + fibonacci(x - 2)); } </code></pre> <p>and just <code>sourceCpp</code> this file : </p> <pre><code>> sourceCpp( "fib.cpp" ) > fibonacci(6) [1] 8 </code></pre> |
8,103,887 | 0 | Static variable in objective c <p>I am somewhat confused about memory allocation of static variable in objective C. </p> <ol> <li><p>should we allocate memory for static variable using <code>alloc:</code>? and initialize it using<code>init:</code>?</p></li> <li><p>Is objective c static variable same as c static variable?</p></li> <li><p>is it worth to apply <code>retain</code> on static variable?</p></li> </ol> |
Subsets and Splits