pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
26,570,325 | 0 | What are RecyclerView advantages compared to ListView? <p>I just started using RecyclerView and I've seen it lack in a lot of features like header, footer, divider, list selector, now I have second thoughts about using it instead of ListView.</p> <p>What are the advantages and disadvantages of RecyclerView compared to ListView? Can it handle more complex views than ListView ?</p> <p>I've been using ListView till now and for a few, is it time to switch to RecyclerView or is it too soon now?</p> |
19,317,676 | 0 | How to fetch all the variants, of each products, with out fetching product name multiple time <p>I have 3 tables.</p> <p>"table_products" </p> <pre><code> product_id product_name 1 A 2 B 3 C 4 D 5 E </code></pre> <p>"table_varients"</p> <pre><code>variant_id variant_name 1 v1 2 v2 3 v3 4 v4 5 v5 </code></pre> <p>"table_product_varients"</p> <pre><code>product_id variant_id 1 1 1 2 1 3 2 3 2 4 3 1 3 4 4 1 5 1 5 2 </code></pre> <p>And i want result from select Query like this:</p> <pre><code>A - V1, V2, V3 B - V3, V4 C - V1, V4 D - V1 E - V1, V2 </code></pre> <p>Devesh</p> |
35,155,904 | 0 | <p>The simplest and pretty much idiomatic way to do it would be:</p> <pre><code>QMap<QString, QVector<QString>> devices; // Get the vector constructed in the map itself. auto & commands = devices[RadioID]; // Fill commands with lots of data here - a bit faster commands.resize(2); commands[0] = "Foo"; commands[1] = "Bar"; // Fill commands with lots of data here - a bit slower commands.append("Baz"); commands.append("Fan"); </code></pre> <p>You'll see this pattern often in Qt and other code, and it's the simplest way to do it that works equally well on C++98 and C++11 :)</p> <p>This way you're working on the vector that's already in the map. The vector itself is never copied. The members of the vector are copied, but they are implicitly shared, so copying is literally a pointer copy and an atomic reference count increment.</p> |
18,713,652 | 0 | <p>The first thing to understand is why it keeps playing forever rather than just 0.2. You can see what's going on if you run the <code>Pbind</code> equivalent:</p> <pre><code> p = Pbind(\instrument, \default, \dur, 0.2, \freq, 400).play; </code></pre> <p>If you run this you don't just hear a single note, you hear the note being hit again and again forever, until you run</p> <pre><code> p.stop; </code></pre> <p>So why is that? It's because all of the "values" specified are simple numbers or symbols (<code>\default ... 0.2 ... 400</code>), and these are always interpreted as meaning "continue forever or until something else stops us".</p> <p>If you wanted Pbind to play just one note you would need to use at least one pattern in there which limits itself to just one item:</p> <pre><code> p = Pbind(\instrument, \default, \dur, 0.2, \freq, Pseq([400], 1)).play; </code></pre> <p>So you can do the same thing with Pmono:</p> <pre><code> p = Pmono(\default, \dur, 0.2, \freq, Pseq([400], 1)).play; </code></pre> <p>This has <em>exactly the same result</em> as the Pbind example, actually, but that's because it's playing only one note. We can make the difference a little bit clearer with these two-note examples:</p> <pre><code> p = Pbind(\instrument, \default, \dur, 0.4, \freq, Pseq([400, 500], 1)).play; p = Pmono(\default, \dur, 0.4, \freq, Pseq([400, 500], 1)).play; </code></pre> <p>The first plays two separate notes, the second plays one with a pitch change halfway through.</p> <p>So, note that your inference was correct - the node does get deleted after the Pmono terminates - but your Pmono was not terminating.</p> |
738,931 | 0 | <p>In case anyone ends up running into a similar situation, here was my solution: </p> <p>First to explain my datasets:</p> <pre><code>public Foo { string a; List<Bar> subInfo; } public Bar { string b; string c; } List<Foo> allFoos; </code></pre> <p>Basically instead of having the allFoos object that I passed to a master report, and then trying to pass the corresponding Bar object to the subReport, I created a new object:</p> <pre><code>Public FooBar { string a; string b; string c; } List<FooBar> allFooBars; </code></pre> <p>So basically I flattened the data. From there I created a single report. I added one table that had "FooBar" as it's DataSet, and passed in the collection of "allFooBars." I also created a footer on the report, so that I would have consistent paging across all pages. I then used grouping to keep "Foo" objects together. On the groups I set the "Page Break at start" and "Include Group Header" and "Repeat Group Header" options to true. Then I just set up the Group Headers to fake being my Page Headers along with group headers (basically just 5 lines of Group Headers, one of which was blank to provide some space).</p> <p>And that was basically it.</p> |
4,276,285 | 0 | Fusion Chart in ASP.Net <p>I am using fusion chart in my asp.net application. I want to use multiple fusion charts in a single page. But only one fusion chart is displayed.. Pls help me if any body knws about this problemm...</p> <p>Iam using an ashx file(handler) for creating xml.</p> <p>Advance thanks</p> |
9,281,971 | 0 | <p>The issue is in the fact that by default images are vertically aligned with the baseline. You can see this if you put an image next to some text. The image aligns to the baseline of the text, while letters like g and y go below the baseline. The space you are getting is the space below the baseline which is for the letters to go below. If you change the <code>vertical-align</code> to <code>top</code> the space will disappear.</p> <p><a href="http://jsfiddle.net/YJZRE/" rel="nofollow">http://jsfiddle.net/YJZRE/</a></p> <pre><code>.artwork img { height: 100%; vertical-align: top; } </code></pre> |
19,472,117 | 0 | <p>Basically, the idea is as follows:</p> <ol> <li><p>One of your pages checks whether the user knows the "secret". This is kind of authorization.</p></li> <li><p>Some other page(s) works only if the user has been authorized.</p></li> </ol> <p>It's obvious that information about successful authorization should be stored in some place, which is shared between various pages. There are a lot of ways to share information between pages.</p> <p>A) Session. Once the user has submitted the correct promo code, your authorizing page stores something in the Session collection. That could be just a flag indicating the fact of successful authorization, or that could be the promo code - if you would need its value later.</p> <p>Any other page can check what's stored (or not stored) in Session in the Page_Load handler and decide what to do then: continue or render an error, or redirect to another page. Note: sessions expire. What's you store there is forgotten when the session ends.</p> <p>B) Cookies. This way your information lasts as much time as you want - you set the expiry date. But since it's stored in the user's browser, there are disadvantages: the browser may refuse to store your cookies; the user may clear them.</p> <p>C) Database. If you want to make sure the user is authorized once and for ever, store this info in the database.</p> |
1,685,340 | 0 | <p>Even if you won't be uploading it, build your application like a CPAN module.</p> <p>That basically means you have a Makefile.PL that describes the dependencies formally, and your application is in the script/ directory as myapplication (assuming it's a command line/desktop app).</p> <p>Then, someone can use the CPAN client to install your module and it's dependencies directly, but untarring the tarball and then running</p> <blockquote> <p>cpan .</p> </blockquote> <p>Alternatively, the pip tool will let people install your application from a remote URL directly.</p> <blockquote> <p>pip <a href="http://someserver.com/Your-Application-0.01.tar.gz" rel="nofollow noreferrer">http://someserver.com/Your-Application-0.01.tar.gz</a></p> </blockquote> |
22,361,418 | 0 | <p>You can try <code>[self.myTextView sizeToFit];</code> and then see if it updates it for you.</p> |
19,978,197 | 0 | Gcdasynsocket did read data delegate dosent give correct tag value <p>I am using gcdasynsocket to establish socket communication. Below shown is the method that i am using to write the data</p> <pre><code>-(void)writeData:(NSData*)data withTag:(int)tag { [asyncSocket writeData:data withTimeout:-1.0 tag:tag]; [asyncSocket readDataWithTimeout:-1.0 tag:tag]; } - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag { if (tag == 18) { NSLog(@"First request sent"); [asyncSocket readDataWithTimeout:-1.0 tag:18]; } else if (tag == 125) { NSLog(@"Second request sent"); [asyncSocket readDataWithTimeout:-1.0 tag:125]; } } </code></pre> <p>//reading the data</p> <pre><code>- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { NSLog(@"tag---%ld",tag); } </code></pre> <p>In my did read data delegate i am not getting the tag value what i have passed. Since i am not getting the correct tag value. i couldnt read my another data. I am not sure what is going wrong here. Please help me to fix this issue</p> |
15,169,786 | 0 | <p>Add in MSBuild .proj file:</p> <pre><code><Exec Command="icacls "\\xxx\MyApp.zip" /grant User:F" ContinueOnError="true" /> </code></pre> <p>a sequence of simple rights: F - full access M - modify access RX - read and execute access R - read-only access W - write-only access</p> |
10,647,829 | 0 | <p>In the string you prepare use:</p> <pre><code>"var fileUploadDic = { 'firstname': 'Jo\\'hn', 'lastname' : 'Macy' , 'country' : 'USA };" </code></pre> <p>Now client side that will look like:</p> <pre><code>var fileUploadDic = { 'firstname': 'Jo\'hn', 'lastname' : 'Macy' , 'country' : 'USA }; </code></pre> <p>If you want to replace <code>''</code> client side you can use <code>[varstr].replace(/''/g,"\\'")</code>, but I think client side will be too late (the Error is already thrown on arrival and interpretation of the sent string)</p> |
31,980,211 | 0 | Building & using ZeroMQ with Visual Studio <p>Anyone out there successfully building/using ZeroMQ under Windows (MSVC)? </p> <p>I'm trying to build/use the current master in GitHub (<a href="https://github.com/zeromq/libzmq" rel="nofollow">https://github.com/zeromq/libzmq</a>) which has Visual Studio projects as well as CMake files. I've built the CMake project (after fixing some issues in the MSVC specific stuff) which also builds all the tests but the tests fail the same way my simple test program does.</p> <p>The first call to WinSock select() always results in WSAENOTSOCK and the app bails. I've now tried this on a 64bit Win7 and Win8 machines with both VS2010 and VS2013 for debug and release builds with no luck :(</p> <p>I get similar aborts when trying to build against the pre-built binaries on the ZeroMQ site or building my own with the included Visual Studio project directories they include in the repository.</p> |
33,381,765 | 0 | <p>Have you seen this post recommending the use of section?</p> <p><a href="http://stackoverflow.com/questions/7175398/maven-dependency-resolution-conflicted">Maven dependency resolution (conflicted)</a></p> <p>In short you specify the version you want once in a parent/top-level project and then declare the dependency <strong>without version</strong> in the other projects.</p> <p>EDIT: Does this blog post help? <a href="http://blog.mafr.de/2014/08/30/maven-discovering-dependency-conflicts/" rel="nofollow">http://blog.mafr.de/2014/08/30/maven-discovering-dependency-conflicts/</a></p> <p>It includes a clever command line invocation that lists dependencies in a project via "mvn dependency" and extracts the lines with conflicts.</p> <pre><code>mvn dependency:tree -Dverbose | grep --color=always '(.* conflict\|^' | less -r </code></pre> |
12,746,471 | 0 | <p>I believe this does what you want:</p> <pre><code>SlopeInterceptDemonstration[{mmin_, mmax_}, {bmin_, bmax_}] := Manipulate[ Plot[m*x + b, {x, xmin, xmax}, AspectRatio -> 1, PlotRange -> {xmin, xmax}], {{m, mmin, "m"}, mmin, mmax, 0.1}, {{b, bmin, "b"}, bmin, bmax, 0.1}, {xmax, None}, {xmin, None}, Initialization :> {xmax = Max[Abs[bmin + mmin], Abs[bmax + mmax]]*1.2, xmin = -xmax} ] </code></pre> <p><code>{xmax, None}</code> is used to localize <code>xmax</code> in the Module. The method with <code>DynamicModule</code> shown in the other answer is standard and more flexible.</p> |
32,419,613 | 0 | Modifying Cypher Query Engine <p>I would like to modify the way Cypher processes queries sent to it for pattern matching. I have read about Execution plans and how Cypher chooses the best plan with the least number of operations and all. This is pretty good. However I am looking into implementing a Similarity Search feature that allows you to specify a Query graph that would be matched if not exact, close (similar). I have seen a few examples of this in theory. I would like to implement something of this sort for Neo4j. Which I am guessing would require a change in how the Query Engine deals with queries sent to it. Or Worse :)</p> <p>Here are some links that demonstrate the idea</p> <p><a href="http://www.cs.cmu.edu/~dchau/graphite/graphite.pdf" rel="nofollow">http://www.cs.cmu.edu/~dchau/graphite/graphite.pdf</a> <a href="http://www.cidrdb.org/cidr2013/Papers/CIDR13_Paper72.pdf" rel="nofollow">http://www.cidrdb.org/cidr2013/Papers/CIDR13_Paper72.pdf</a></p> <p>I am looking for ideas. Anything at all in relation to the topic would be helpful. Thanks in advance</p> <p>(:I)<-[:NEEDING_HELP_FROM]-(:YOU)</p> |
39,253,154 | 0 | <p>You need to calculate the classification accuracy on the validation-set and keep track of the best one seen so far, and only write the checkpoint once an improvement has been found to the validation accuracy.</p> <p>If the data-set and/or model is large, then you may have to split the validation-set into batches to fit the computation in memory.</p> <p>This tutorial shows exactly how to do what you want:</p> <p><a href="https://github.com/Hvass-Labs/TensorFlow-Tutorials/blob/master/04_Save_Restore.ipynb" rel="nofollow">https://github.com/Hvass-Labs/TensorFlow-Tutorials/blob/master/04_Save_Restore.ipynb</a></p> <p>It is also available as a short video:</p> <p><a href="https://www.youtube.com/watch?v=Lx8JUJROkh0" rel="nofollow">https://www.youtube.com/watch?v=Lx8JUJROkh0</a></p> |
20,547,472 | 0 | <p>Note that: basicAuth is deprecated</p> <p>Here the code:</p> <pre><code>app.use(express.basicAuth(function(user, pass, callback){ if(config.credentials.clients[user] === undefined) { callback('user not found!!!'); } else { if(config.credentials.clients[user].password === pass) { callback(null, config.credentials.clients[user]); } else { callback('wrong pass!!!'); } } }); app.post('/put', function putEvents(req, res) { console.log(req.user.name) res.end(); }); </code></pre> |
14,636,733 | 1 | web2py insert on duplicate key update <p>How to use DAL in web2py to perform INSERT ... ON DUPLICATE KEY UPDATE. I have not found it in the <a href="http://web2py.com/books/default/chapter/29/06#insert" rel="nofollow">manual</a>.</p> |
22,603,692 | 0 | <p>gpg -c ... -u [signing user id or key hex id] ...</p> |
10,620,023 | 0 | WPF VisualBrush stretches instead of tileing <p>I've got a VisualBrush on which I've set the TileMode property to Tile.</p> <p>However, it doesn't tile - it stretches. Can anyone assist please?</p> <p>Thanks</p> <pre><code><UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="test" x:Name="UserControl" d:DesignWidth="500" d:DesignHeight="500"> <UserControl.Resources> <VisualBrush x:Key="MyBrush" TileMode="Tile"> <VisualBrush.Visual> <Grid Width="20"> <Ellipse Fill="#FF00EBFF" Stroke="Black" StrokeThickness="2" Width="20" Height="20" RenderTransformOrigin="0.5,0.5" > </Ellipse> </Grid> </VisualBrush.Visual> </VisualBrush> </UserControl.Resources> <Grid x:Name="LayoutRoot" > <Grid Background="{StaticResource MyBrush}" /> </Grid> </UserControl> </code></pre> |
25,604,012 | 0 | jaxrs - error throws in interceptor return status 500 <p>I'm bulid rest api using jax-rs. To handle authentication I'm using Interceptor. When auth failed I return WebApplicationException like:</p> <pre><code>try { Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(policy.getUserName(), policy.getPassword())); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(authentication); } catch (AuthenticationServiceException | BadCredentialsException e) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); //TODO set response status } </code></pre> <p>but it returns startus 500 instead 401.</p> <p>When i throw WebApplicationExceptions in services it return statuses that I set but in interceptor it didn't worked. How to return 401 from interceptor?</p> <p>jaxrs:server config:</p> <pre><code><jaxrs:server id="restService" address="/rest"> <jaxrs:serviceBeans> <ref bean="serviceBean"/> </jaxrs:serviceBeans> <jaxrs:inInterceptors> <ref bean="securityInterceptor"/> </jaxrs:inInterceptors> </jaxrs:server> <bean id="serviceBean" class="some_package.CustomerService"/> <bean id="securityInterceptor" class="some_package.AuthenticatorInterceptor"/> </code></pre> |
11,821,386 | 0 | <p>From the <a href="http://docs.jquery.com/Is" rel="nofollow">jQuery documentation for <code>is</code></a>.</p> <blockquote> <p>Checks the current selection against an expression and returns true, if at least one element of the selection fits the given expression.</p> <p>If no element fits, or the expression is not valid, then the response will be 'false'.</p> </blockquote> <p>So you can be sure the answer will either be <code>true</code> or <code>false</code>.</p> |
7,819,883 | 0 | <p>Add a dot <code>.</code> after the <code>localhost</code>.</p> <p>For example if you had <strong>http://localhost:24448/HomePage.aspx</strong></p> <p>Change it to <strong>http://localhost.:24448/HomePage.aspx</strong></p> <p>Internet Explorer is bypassing the proxy server for "localhost". With the dot, the "localhost" check in the domain name fails.</p> |
36,081,919 | 0 | <p><strong>1.</strong> <strong>Should I be considering flushing the cache from time to time?</strong></p> <p>No. Because $cacheFactory will destroy all the data once the session has been closed. Or if you want to flush manually then you can use destroy method.<br/><br/> <strong>destroy()</strong> - Removes references to this cache from $cacheFactory.</p> <p><strong>removeAll()</strong> - Removes all cached values.</p> <p><strong>2. I can cache all my API responses?</strong></p> <p>This is possible in two ways as follows.</p> <ol> <li>$localStorage - If your goal is to store client-side and persistent data.</li> <li>$cacheFactory - Data exist only for current session.</li> </ol> |
17,967,296 | 0 | <p>You haven't specified the IE version you're testing with, but your code appears to work fine in IE9 and higher, so I'm going to assume you're testing in IE8.</p> <p>Given that, there are is one main problem I can see that will be breaking your site:</p> <p><code><nav></code> and other new HTML5 elements are not supported as standard by IE8 or earlier. Using them will break your layout and cause other glitches.</p> <p>You have two options: Either replace the <code><nav></code> and any other HTML5 elements with old-style <code><div></code> elements, or use a polyfill like <a href="http://code.google.com/p/html5shiv/" rel="nofollow">html5shiv</a> or <a href="http://modernizr.com/" rel="nofollow">Modernizr</a>, both of which will fix the problem in IE8 and make these elements work as normal.</p> <p>Hope that helps.</p> <p><strong>[EDIT after OP clarified his IE version as IE10]</strong></p> <p>The other possibility is that it's displaying the page in compatibility mode or quirks mode.</p> <p>You can check the browser mode by pressing F12 to bring up the Dev Tools window; the mode information will be shown at the top of the window. If it's in either Quirks mode or compatibility mode (ie if it's in anything other than IE10 Standards mode) then there's a strong probability that this is the cause.</p> <p>If it's in quirks mode, it's because your HTML isn't standards compliant. Most of the time, adding a valid doctype to the top of the page will fix this (you can use <code><!DOCTYPE html></code> as the easiest valid doctype). You should also check for other errors in your HTML by running it through the <a href="http://validator.w3.org" rel="nofollow">W3C Validator</a> and fixing the errors it reports. (if the code you've posted is your whole code, then you're missing the <code><html></code> and <code><body></code> tags for starters, which is definitely not good).</p> <p>If it's in compatibility mode (eg "IE7 Standards"), then you can fix this by adding an <code>X-UA-Compatible</code> meta tag to your <code><head></code> section. (see <a href="http://stackoverflow.com/questions/12149353/why-does-webpage-display-in-ie8-browser-mode-and-ie7-document-mode/12149504#12149504">my answer here</a> for more info on why this might be happening and what to do to fix it).</p> |
258,758 | 0 | <p>There's no timeout that I'm aware of on .bat or .cmd files. However, there may be on the process that's launching it? How are you launching it?</p> |
1,625,563 | 0 | <p>This is the first thing I'd try:</p> <p><img src="http://img.skitch.com/20091026-ek3id5s121wqrsiu8apwm4qgir.png" alt="alt text"></p> <p>Wait until it doesn't say "Getting" anywhere anymore before doing anything documentation related. </p> |
21,130,927 | 0 | check number of child of current category magento <p>in magento ,check number of sub category of current category in category page</p> <pre><code>$cat = Mage::getModel('catalog/category')->getCollection()->load($id); </code></pre> <p>$subcats = $cat->getChildren();</p> <p>by using this code we have get chil category but we want to check number of sub category of current category in magento</p> |
30,746,468 | 0 | <p>You can create a form around the delete button. This will not add anything to the page visually.</p> <p>For example:</p> <pre><code>{{ Form::open(['url' => 'foo/bar', 'method' => 'delete', 'class' => 'deleteForm']) }} <input type="submit" class="deleteBtn" /> {{ Form::close() }} </code></pre> <p>The Laravel Form helper automatically spoofs the form and adds the hidden field for the <code>DELETE</code> method.</p> <p>Then you can style the button using the <code>.deleteBtn</code> class. If the button needs to be positioned inline, you can even assign a <code>display: inline;</code> property to the <code>.deleteForm</code> class.</p> |
10,826,982 | 0 | <p>Aside from the other good examples of how to use Core Location, also keep in mind the general technique for getting good kinematics results from a not-so-great sensor (e.g. smartphone location services) of <a href="http://en.wikipedia.org/wiki/Kalman_filter" rel="nofollow">Kalman Filtering</a>.</p> <p>It's a lot of math and testing and tweaking, but it does allow you to get what users would consider better results than simple data from the sensor provides.</p> <p>This is what's used in avionics and things like radar processing systems.</p> |
22,544,374 | 0 | <p>If your lines are strings you can do something like this</p> <pre><code>List<String> a = new ArrayList<>(Arrays.asList(new String[] { "1 2 3", "3 4 5 6", "1 2 4 5 7", "8", "7", "1 2 4" })); List<String> b = new ArrayList<>(Arrays.asList(new String[] { "7", "3 4 5 6", "1 2 4 5 7", "1 2 3", "8", "1 2 4" })); if (a.size() == b.size()) { a.removeAll(b); if (a.isEmpty()) System.out.println("A and B are the same sets"); } </code></pre> |
3,664,454 | 0 | <p>Under System>Transactional Emails, you can modify the Newsletter Subscription Success message including subject, and then assign your modified email in System>Configuration>Customers>Newsletter>Success Email Template from the drop-down</p> |
30,330,734 | 0 | <p>When you load in a <code>File</code> in the <code>open</code> JButton <code>ActionListener</code>, the code creates a new <code>TableModel</code> and sets the <code>JTable</code> model:</p> <pre><code>MyModel NewModel = new MyModel(); table.setModel(NewModel); </code></pre> <p>The <code>NewModel</code> instance is local to this method, thus any changes to the instance variable <code>model</code> will not be reflected in the <code>JTable</code> (in other words, <code>model != table.getModel()</code>). Instead of creating a local variable, set the instance variable to the new model. For example: </p> <pre><code>model = new MyModel();//sets the instance variable to the new model table.setModel(NewModel); </code></pre> <p>In this way, whenever code refers to <code>model</code>, it is acting on the current <code>TableModel</code> of the <code>JTable</code>. Alternatively, when making changes to the <code>TableModel</code>, you can get the model directly from the <code>JTable</code>, casting if necessary:</p> <pre><code>remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = table.getSelectedRow(); MyModel myModel = (MyModel)table.getModel();//get the model directly if (row!=-1) myModel .deleteRow(row); } }); </code></pre> |
7,119,223 | 0 | File name without extension in bash for loop <p>In a for loop like this one:</p> <pre><code>for f in `ls *.avi`; do echo $f; ffmpeg -i $f $f.mp3; done </code></pre> <p>$f will be the complete filename, including the extension. For example, for song1.avi the output of the command will be song1.avi.mp3. Is there a way to get only song1, without the .avi from the for loop?</p> <p>I imagine there are ways to do that using awk or other such tools, but I'm hoping there's something more straight forward.</p> <p>Thanks</p> |
9,958,894 | 0 | <p>Use an array:</p> <pre><code>String files[] = new String[]{"Hello", "Hola", "Bonjour"}; for (String file : files) { System.out.println(file); } </code></pre> |
39,573,916 | 0 | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() { var xingHref = $(".contact-sm > a").attr("href"); $(".contact-img > a").attr("href", xingHref); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="contact-img"> <a href="https://test.de" class="evcms-open-contacts"> <img src="https://cdn-cache.envivo-connect.com/license/Tw3sZjz8v/p/xckYV8bESwsZ/80x80c/xckYV8bESwsZ.png?v=2.4.84-z3p37YEER-1467970717-yZUA33Hxn" alt="F. Alexander Kep" /> </a> </div> <div class="contact-sm"> <a href="https://www.xing.com/profile/FfAlexander" /> </div></code></pre> </div> </div> </p> |
5,991,814 | 0 | <p>You can try this...</p> <p>1.Override <code>textFieldDidEndEditing</code> in your <code>viewController.m</code> file. See the example code below:</p> <pre><code>-(BOOL)textFieldDidEndEditing:(UITextField*) tf{ //your piece of code (goNext?) } </code></pre> <p>2.Remove</p> <pre><code>[eTextField addTarget:self action:@selector(goNext) forControlEvents:UIControlEventEventEditingDidEnd]; </code></pre> <p>from your code.</p> |
39,626,886 | 0 | <p>If you can guarantee that the data of each table is unique, then don't use <code>UNION</code>, because it has to an extra work to make distinct rows out of it.</p> <p>Use <code>UNION ALL</code> instead, which is basically an append of rows. <code>UNION</code> or <code>UNION DISTINCT</code> (the same) like you showed is somewhat equivalent to:</p> <pre><code>SELECT DISTINCT * FROM ( SELECT user_id, grapes, day FROM steps.steps_2016_04_02 UNION ALL SELECT user_id, grapes, day FROM steps.steps_2016_04_03 UNION ALL SELECT user_id, grapes, day FROM steps.steps_2016_04_04 ) t; </code></pre> <p>And the <code>DISTINCT</code> can be a very slow operation.</p> <p>Another simpler option is to use <a href="https://www.postgresql.org/docs/current/static/ddl-partitioning.html" rel="nofollow">PostgreSQL's partitioning with table inheritance</a> and work on Tableau as a single table.</p> |
31,219,669 | 0 | Join two tables and add the data with the same column id <p>I am using Laravel 4.2<br> I have two tables "questions" and "votes"<br> In my questions table I have columns like</p> <ul> <li><code>id</code>,</li> <li><code>id_user</code>,</li> <li><code>subject</code>,</li> <li><code>body</code>.</li> </ul> <p>In my votes table I have columns like </p> <ul> <li><code>id</code>,</li> <li><code>id_question</code>,</li> <li><code>id_user</code>, </li> <li><code>likes</code>,</li> <li><code>dislikes</code>.</li> </ul> <p>The user is allowed to vote only once therefore the values for likes and dislikes for each user is 0-1, the <code>id_question</code> has the <code>id</code> of the question from the questions table. Now U want to sort the questions in the descending order according to the number of votes cast for each question.</p> <p>How do I sum the votes and sort them. This is what I have tried but it just displays me the count of the first question</p> <pre><code>$questions=Question::leftJoin('votes', 'questions.id', '=', 'votes.id_question') ->groupBy('questions.id')->sum('likes'); return json_encode($questions); </code></pre> <p>after I get the counts i can sort them in the descending order by using <code>orderBy('likes','DESC')->get();</code> but how to get the sum of likes?</p> |
32,750,657 | 0 | <p>I'm confused in that two arguments to your function, my_dt1 and my_dt2, do not seem to be used. All you seem to be doing is adding a column to DF2? If so, just do this:</p> <pre><code>b_func = function(my_dt, my_col) { my_dt[[my_col]] = as.Date("2015-09-21") + 0:4 my_dt } </code></pre> |
30,503,870 | 0 | <p>What if you click on the <code>arrow</code> icon (near minimize/maximize), on the bar view and deselect <code>Show Tests in Hierarchy</code> ? Or play with different layout under <code>Layout</code> (same icon)</p> |
2,190,089 | 0 | Database Design <p>This is a general database question, not related to any particular database or programming language.</p> <p>I've done some database work before, but it's generally just been whatever works. This time I want to plan for the future.</p> <p>I have one table that stores a list of spare parts. Name, Part Number, Location etc. I also need to store which device(s) they are applicable too.</p> <p>One way to do is to create a column for each device in my spare parts table. This is how it's being done in the current database. One concern is if in the future I want to add a new device I have to create a new column, but it makes the programming easier.</p> <p>My idea is to create a separate Applicability table. It would store the Part ID and Device ID, if a part is applicable to more than one device it would have more than one row.</p> <pre><code>Parts ------- ID Name Description Etc... PartsApplicability ------- ID PartID DeviceID Devices ------ ID Name </code></pre> <p>My questions are whether this is a valid way to do it, would it provide an advantage over the original way, and is there any better ways to do it?</p> <p>Thanks for any answers.</p> |
24,425,177 | 0 | <p>Maybe I'm missing something in your question, but it seems that this should do it:</p> <pre><code>SELECT CONCAT('STK', LPAD(MAX(SUBSTRING(ticket_id, 4)) + 1, 10, '0') ) FROM sma_support_tickets; </code></pre> |
31,127,024 | 0 | <p>I use X-editable - In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery</p> <p>This library allows you to create editable elements on your page. It can be used with any engine (bootstrap, jquery-ui, jquery only) and includes both popup and inline modes. Documentation - </p> <p><a href="http://vitalets.github.io/x-editable/docs.html#gettingstarted" rel="nofollow">http://vitalets.github.io/x-editable/docs.html#gettingstarted</a></p> <p>[I am not affiliated with x-editable project. I found that its pretty easy to implement and works great. Hope this helps! thanks]</p> |
20,866,662 | 0 | <p>try this its working I've tested this code</p> <pre><code>$(document).ready(function() { alert($("input[value='Cancel']").attr("id")); }); </code></pre> <p>HTML code</p> <pre><code><input type="button" value="Cancel" class="supportButton" id="whitelist.onCancelUploadButton" /> </code></pre> |
7,288,317 | 0 | <p>That's an odd structure. Translating it to <code>dput</code> syntax</p> <pre><code>SOLK <- structure(list(structure(c(1L, 2L, 3L, 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("10:27:03,6", "10:32:58,4", "10:34:16,9", "10:35:46,0", "10:35:50,6", "10:36:10,3", "10:36:10,4"), class = "factor"), Close = c(0.99, 0.98, 0.98, 0.97, 0.96, 0.96, 0.95, 0.95, 0.95, 0.95), Volume = c(1000L, 100L, 600L, 500L, 50L, 1000L, 40L, 100L, 500L, 100L)), .Names = c("", "Close", "Volume" ), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")) </code></pre> <p>I'm assuming the comma in the timestamp is decimal separator.</p> <pre><code>library("chron") time.idx <- times(gsub(",",".",as.character(SOLK[[1]]))) </code></pre> <p>Unfortunately, it seems <code>xts</code> won't take this as a valid <code>order.by</code>; so a date (today, for lack of a better choice) must be included to make <code>xts</code> happy.</p> <pre><code>xts(SOLK[[2]], order.by=chron(Sys.Date(), time.idx)) </code></pre> |
11,282,499 | 0 | <p>Try this <code>findViewById(R.id.google_account).setVisibility(View.GONE);</code> And here is the full <a href="http://developer.android.com/reference/android/view/View.html#GONE" rel="nofollow">documentation</a>.</p> |
19,254,220 | 0 | RestEasy GET method accepts HEAD requests <p>I have the merhod annotated with @GET. But when here comes HEAD request, it is handled with this method. And in the body of the method I get request type HEAD from HttpRequest object. Why does GET method responces for HEAD requesrs?</p> |
40,597,128 | 0 | <p>You should really be storing those names on an object stored in a global and not as global variables. But you asked how to do it and so here is how:</p> <p>Using <a href="http://stackoverflow.com/questions/7027848/getting-corresponding-module-from-function">Getting corresponding module from function</a> with a <code>for</code> loop and <code>setattr</code> as modules do not support dictionary operations and it is possible to write the function as:</p> <pre><code>import sys def load_inmemory(): module = sys.modules[load_inmemory.__module__] for k, v in load237(fpath)[0].items(): setattr(module, k, v) load_inmemory() print x </code></pre> <p>I tested the following:</p> <pre><code>import sys def func(): module = sys.modules[func.__module__] for k,v in {'x':4}.items(): setattr(module, k, v) func() print x </code></pre> <p>Prints <code>4</code>. Tested in Python 2.7.3.</p> |
39,641,865 | 0 | Change height tableview when items not visible javafx <p>I would like show navigation arrow when items not visible in the component <code>TableView</code> at the screen. I don't know if there is an event when, visually, the <code>TableView</code> is full, and show arrow to scroll in the <code>TableView</code>.</p> <p>Thanks.</p> |
37,868,817 | 1 | Retrieve Django ManyToMany results outside of the current model <p>Hi I'm brand new to Django.</p> <ul> <li>I have a list of <strong>stores</strong>. Each of those stores carry <strong>brands</strong> of products.</li> <li>For a store, I can list the brands that they carry. </li> <li><strong>For a brand, I want to list the stores that carry that brand.</strong></li> </ul> <p>Here are my models (simplified):</p> <pre><code>class Store(models.Model): company = models.CharField(max_length=256) brands = models.ManyToManyField('Brand',related_name='brand') class Brand(models.Model): company = models.CharField(max_length=256) </code></pre> <p>Here is my view for the template:</p> <pre><code>def brand_detail_slug(request, slug): brand = Brand.objects.get(slug=slug) return render(request, 'storefinder/brand_detail.html', {'brand': brand}) </code></pre> <hr> <p>I can retrieve info for the brands successfully in my view:</p> <pre><code>{% for p in brand.product_types.all %} <li>{{ p }}</li> {% endfor %} </code></pre> <p>But I don't know how to do this for stores, since it's not really defined in the Brands. It's a separate model.... this is where I get confused.</p> <p>Thanks!</p> |
29,493,074 | 0 | <p>Here's the simplest solution:</p> <p>Assuming that you installed some up-to-date version of Perl and it is already in PATH, simply go to where GIT executables are is, which is normally </p> <pre><code>C:\Program Files (x86)\Git\bin </code></pre> <p>and <strong>rename <code>perl.exe</code> to <code>perl1.exe</code></strong>. If you really are so unhappy about this, rename it back after you're done with whatever is getting the problem.</p> <p>Why does this solve the problem? Because your program will not find perl in GIT's directory, and will try to find it somewhere else, and since your have the latest version of Perl in PATH, it will find it and everything will workout.</p> <p>PS: It worked with me :-)</p> |
22,417,299 | 0 | <p>This was a bug with that particular version of Chrome. It was fixed in a later release.</p> |
35,842,886 | 0 | Nested mongoose Schema giving trouble when trying to query in controller <p>I'm working on a small project and I have a solution to this problem, but it involves creating a new Schema with a reference to the new Schema in the old Schema. I would like to avoid this if at all possible because it will mean spending a couple hours rewriting some code and messing with tests. </p> <p>The project is a forum site, and there are three main Schemas that comprise it (in addition to cursory Schemas for the forums, notifications, settings and the schemas for the user and the users activities). The Board Schema (contains a list of all forum sections if that wasn't apparent) Is a Schema that makes a reference to the Threads Schema so it can get the threads for each Board. My problem is in the Thread Schema.</p> <pre><code>var ThreadSchema = new mongoose.Schema({ ... other unrelated Schema stuff... comments: [{ created: { type: Date, default: Date.now }, creator: { type: mongoose.Schema.ObjectId, required: true, ref: 'User' }, content: { type: String, required: true, get: escapeProperty }, likes: [{ type: mongoose.Schema.ObjectId, required: false, ref: 'User' }], liked: { type: Boolean, default: false }, saved: [{ type: mongoose.Schema.ObjectId, required: false, ref: 'User' }] }] }); </code></pre> <p>blah blah blah.</p> <p>I'm trying to pull for the users profile only the comments that that user has posted. The threads were easy, but comment data is not coming through. The request to the server goes through as successful, but I don't get any data back. This is what I am trying.</p> <pre><code>obj.profileComments = function (req, res) { var userId = req.params.userId; var criteria = {'comments.creator': userId}; Thread.find(criteria) .populate('comments') .populate('comments.creator') .skip(parseInt(req.query.page) * System.config.settings.perPage) .limit(System.config.settings.perPage + 1) .exec(function (err, threads) { if (err) { return json.bad(err, res); } json.good({ records: threads }, res); }); }; </code></pre> <p>This is a controller, and the json.bad and json.good are helpers that I have created and exported they basically are res.send.</p> <pre><code>var good = function (obj, res) { res.send({ success: 1, res: obj }); }; </code></pre> <p>and the bad is very similar, it just handles errors in an obj.res.errors and puts them into messages.</p> <p>So now that that is all out of the way, I'm a little lost on what to do? Is this something I should try to handle with a method in my Schema? It seems like I might have a little bit more luck that way. Thank you for any help.</p> |
38,168,546 | 0 | <p>Can you share the actual message that you're sending? This error is typical when you send a message that is missing the session token tag. This token is sent back by Siebel after the initial login, which prevents having to log in for each message - reducing the authentication overhead. </p> |
11,426,393 | 0 | <p>You dont need to import the whole project with examples and target of it.Just import whatever in the "<code>classes</code>" folder in that framework..</p> <p><a href="https://github.com/stig/json-framework/tree/master/src/main/objc" rel="nofollow">https://github.com/stig/json-framework/tree/master/src/main/objc</a></p> <p>Files listed in above link is enough to import framework.</p> <p>As @sanchitsingh said, you need to import only "<code>SBJSON.h</code>".</p> |
35,281,780 | 0 | change the default message on upload file cakephp <p>In cakephp I want to upload a file on a form entry, e.g. a resume to upload and also form entry of people's names, addresses etc. The problem is when I upload a file I get the message after the file is uploaded 'no file selected'. The function works but this message is confusing for the user as I want the name of the file displayed instead of 'no file selected'.</p> <p>EDIT Next to the button Browse, the label appears 'No file Selected'. How do I suppress/alter this message?</p> <p>UPDATE: Found a workaround answer which might not be the best solution. </p> <h2>View</h2> <pre><code>echo $this->Form->input('reason', array('label' => 'Reason for Cancellation', 'style'=> "width:30%",'value'=>$reason)); echo __('Upload Attachment'); echo $this->Form->input('resume_file', array('type' => 'file')); echo $this->Form->submit('Upload', array('name'=>'upload')); echo $this->Form->end(); </code></pre> <h2>Controller</h2> <pre><code>public function uploadfile() { $reason=null; if ($this->request->is('post')) { if (isset($this->request->data['upload'])) { $reason=$this->request->data['Resume']['reason']; if ($this->attachmentupload() && $this->Resume->save($this->request->data)) { $this->Session->setFlash(__('The attachment has been saved'), 'flash_success'); } else { $this->Session->setFlash(__('The attachment could not be saved. Please, try again.'),'flash_alert'); } } } } public function attachmentupload() { $file = $this->request->data['Resume']['resume_file']; $resume_org_filename = $file['name']; $resume_filename = $file['name']; if ($file['error'] === UPLOAD_ERR_OK) { // Code to check if file with the same name exists. If it exists - add n towards the end $t = 0; $url = APP.'Resumes'.DS.$resume_filename; while(file_exists($url)) { $resume_filename = substr($resume_filename,0, strpos($resume_filename, '.'))."_$t".strstr($resume_filename, '.'); $url = APP.'Resumes'.DS.$resume_filename; $t++; } // Set the parameters if (move_uploaded_file($file['tmp_name'], $url)) { $this->request->data['Resume']['tutor_id'] = -1; $this->request->data['Resume']['student_id'] = -1; $this->request->data['Resume']['url'] = $url ; $this->request->data['Resume']['resume_filename'] = $resume_filename; $this->request->data['Resume']['resume_org_filename'] = $resume_org_filename; return true; } } return false; } </code></pre> |
31,017,560 | 0 | <p>You can use a <a href="https://msdn.microsoft.com/en-us/library/ms175972.aspx" rel="nofollow">cte</a> for that:</p> <pre><code>;With cte as ( SELECT [id], Row_number() OVER(Order by [id] As rn FROM MyTable ) UPDATE MyTable SET recNum = rn FROM MyTable t INNER JOIN cte ON(t.[id] = cte.[id]) </code></pre> <p>However, you since already have an id column that seems to have the values you are asking for, you can simply do this:</p> <pre><code>UPDATE MyTable SET recNum = [id] </code></pre> |
22,488,176 | 0 | <p>I think, in this situation it is better to abstract of the commands, therefore I advise the third paragraph:</p> <blockquote> <p>I could call <code>Save()</code> inside the <code>Open()</code> function of my VM too.</p> </blockquote> <hr> <blockquote> <p><code>Open()</code> function should really only open a document and not do other validation/checks.</p> </blockquote> <p>I agree, but for example, before opening the door you should first make sure that it is closed. Does become to do a separate function? I think it will be easier and more correct:</p> <pre><code>private void Open() { if (IsSomeChanges == true) { Save(); } ... } </code></pre> <p><code>Command</code> is a <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="nofollow"><code>pattern</code></a> that allows you to call on the side <code>View</code> your method with minimal dependence and from different controls. If for example, you had to call the Command on the side of View, for example in the <em>attached</em> behavior, then you would need to use <code>SomeCommand.Execute()</code>. But inside in the <code>ViewModel</code> you can simply directly call this methods.</p> |
27,464,134 | 0 | <p>Sounds like the UIView itself is not being released. (Might as well fill out the answer now that we figured it out in the comments.)</p> |
33,696,553 | 0 | <p>I had a similar problem. The reason was that on one account the environment variable 'http_proxy' was set. Since wget had no info about how to get through the proxy the access failed. </p> |
721,517 | 0 | <p>You could set up a local server and save such files in a domain you can now add to the trusted sites, but opening the file in any other browser than IE is easier.</p> |
1,319,998 | 0 | <p>I would think that the proper answer to this, given that you don't want the hardware load measure (CPU, memory, IO utilization), is that heavy load is the amount of requests per time unit at or over the required maximum amount of requests per time unit. </p> <p>The required maximum amount of requests is what has been defined with the customer or with whomever is in charge of the overall architecture.</p> <p>Say X is that required maximum load for the application. I think something like this would approximate the answer:</p> <pre> 0 < Light Load < X/2 < Regular Load < 2X/3 < High Load < X <= Heavy Load </pre> <p>The thing with a single number out of thin air is that it has no relation whatsoever with your application. And what heavy load is is totally, absolutely, ineludibly tied to what the application is supposed to do.</p> <p>Although 200 requests per second is a load that would keep small webservers busy (~12000 a minute).</p> |
26,097,348 | 0 | Sorting a Table with jQuery <p>I have found and followed an example on here for sorting a table but it does not work. Here is my code:</p> <pre><code> function comparer(index) { return function (a, b) { var valA = getCellValue(a, index), valB = getCellValue(b, index); return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.localeCompare(valB); } } function getCellValue(row, index) { return $(row).children('td').eq(index).html(); } function sortTable(header) { var table = $(this).parents('table').eq(0); var rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index())); this.asc = !this.asc; if (!this.asc) { rows = rows.reverse(); } for (var i = 0; i < rows.length; i++) { table.append(rows[i]); } } function createTableHeader(table, headers, alignment) { if (headers.length > 0) { var thead = document.createElement('thead'); table.appendChild(thead); var tr = document.createElement('tr'); for (var i = 0; i <= headers.length - 1; i++) { var th = document.createElement('th'); var text = document.createTextNode(headers[i]); th.appendChild(text); th.style.textAlign = alignment; th.setAttribute('onclick', sortTable) tr.appendChild(th); } thead.appendChild(tr); } } </code></pre> <p>Nothing happens at all, and yet, when I look at the details I can see the function attached to the TH element. ANy ideas?</p> <p>Does the fact that I am creating this table on the fly with data received from an AJAX call have anything to do with the problem?</p> |
17,173,066 | 0 | <p>The reason for this </p> <p><code>this.without.apply(this, this.done())</code></p> <p>is that "_.without" does not accept as argument the array of items to be excluded as a single array ([]) argument</p> <p>See here <a href="https://github.com/documentcloud/underscore/issues/104" rel="nofollow">_.without to accept array as second argument</a></p> <p><em>apply</em>, which is part of the JS Function.prototype, here is a workaround to inject the excluding items in a single array argument</p> |
30,705,394 | 0 | <p>You can do this way:</p> <pre><code>var filters = {}; //when a link in the filters div is clicked... $('#content ul li').not(':first').hide(); $('#filters a').click(function(e){ e.preventDefault(); filters[$(this).parent().attr('class')] = $(this).attr('id'); var show = $('#content ul li').filter(function(){ for(k in filters) if( filters.hasOwnProperty(k) && !$(this).hasClass(filters[k]) ) return false; return true; }); $('#content ul li').not(show).hide(); show.fadeIn(); $('pre:first').html(JSON.stringify(filters)); }); }); </code></pre> |
38,750,836 | 0 | Glusterfs failover, high availability and scalability <p>How glusterfs can gracefully handle the failover scenario? In terms of storage how scalable is glusterfs filesystem ? and Is the performance affected when more bricks/instances are added?</p> <p>Can anyone please provide me answers on the above mentioned questions.</p> |
421,113 | 0 | <p>I suppose it would let them support multiple ranges. For example, they can return all dates between 1/1/2008 and 1/1/2009 AND 1/1/2006 and 1/1/2007 to compare 2006 data to 2008 data. You couldn't do that with a single pair of bound parameters. Also, I don't know how Oracle does it's query plan caching for views, but perhaps it has something to do with that? With the date columns being checked as part of the view the server could cache a plan that always assumes the dates will be checked.</p> <p>Just throwing out some guesses here :)</p> <p>Also, you wrote:</p> <blockquote> <p>I should mention that they use transactions and per-client locks, so it is guarded against most concurrency problems.</p> </blockquote> <p>While that may guard against data consistency problems due to concurrency, it hurts when it comes to performance problems due to concurrency.</p> |
5,481,452 | 0 | <p>You are already inside a code block; Razor does not parse within code blocks for other code blocks. The style part of the line should look something like this:</p> <pre><code>style = "width: 20px; background-color: " + Model.BackgroundColor + ";" </code></pre> |
5,831,887 | 0 | <p>There are no APIs for "decoding" video in the Android SDK, other than to play it back (e.g., <code>MediaPlayer</code>). You are welcome to try to find some third-party library that offers you whatever functionality it is that you seek.</p> |
37,810,714 | 0 | Create checkbox list from related divs <p>I need to create number of checkbox based on the number of array values returned from jQuery. Here is my code:</p> <pre><code><div class="bob" data-xyz="fish"></div> <div class="bob" data-xyz="dog"></div> <div class="bob" data-xyz="fish"></div> <div class="bob" data-xyz="cat"></div> <div class="bob" data-xyz="fish"></div> </code></pre> <p>Ineed to display the result value in HTML like this:</p> <pre><code><label> <input class="fish" type="checkbox" /> fish </label> <label> <input class="cat" type="checkbox" /> cat </label> <label> <input class="dog" type="checkbox" /> dog </label> </code></pre> <p>This is what I tried:</p> <pre><code>var items = {}; $('div.bob').each(function() { items[$(this).attr('data-xyz')] = true; }); var result = new Array(); for(var i in items) { result.push(i); } alert(result); </code></pre> |
239,101 | 0 | <blockquote> <p>but learning a language that helps my resume is still a benefit.</p> </blockquote> <p>You should try using VB6 or COBOL, then, as there is a <strong>lot</strong> of billing work out there for it.</p> |
10,260,931 | 0 | Why Ajax renders 2 views in rails 3.1 app <p>When entering log in our rails 3.1 app, ajax is used to render the input screen below. Here is the link for log:</p> <pre><code><%= link_to 'Log', new_part_out_log_path(@part, :format => :js), :remote => true, :id => 'new_log_link' %> </code></pre> <p>And the new.js.erb as this:</p> <pre><code>$("<%= escape_javascript render(:file => 'out_logs/new.html.erb') %>").insertAfter('#new_log_link'); $('#new_log_link').hide(); $('#close').hide(); </code></pre> <p>the problem is that after clicking 'Log', instead of one view, 2 identical views of out_logs/new.html.erb were rendered. What may be wrong with our code? thank so much. </p> |
21,185,558 | 0 | <p>In continuation to Raghunandan's answer, you could check similar implementation in the link.</p> <p><a href="http://stackoverflow.com/questions/19149872/update-textview-in-fragment-a-when-clicking-button-in-fragment-b/19149882#19149882">update TextView in fragment A when clicking button in fragment B</a></p> <p>Do not forget to get a reference of the textview of the TextSectionFragment into the MainActivity.</p> |
22,373,315 | 0 | <p>You need local coordinates. Change</p> <pre><code>CGContextAddRect(context, self.frame); </code></pre> <p>to</p> <pre><code>CGContextAddRect(context, self.bounds); </code></pre> |
21,026,518 | 0 | android custom view attributes not working after switch to gradle <p>so I recently migrated to gradle now my custom view attributes return null</p> <p>my project looks like this</p> <p>--custom_icon_view // library that holds the custom view with custom attributes --my application // this is the main app that actually uses the custom view</p> <p>in my layout I have the namespace defined like this :</p> <pre><code> xmlns:iconview="http://schemas.android.com/lib/be.webelite.iconview" </code></pre> <p>because using apk/res-auto retuns an error saying attibutes could not be identified</p> <p>this is how I try to get the icon name defined in xml, this used to work perfectlly but now it doesnt. and all I changed was migrating to gradle.</p> <pre><code> final TypedArray a = context.obtainStyledAttributes(attrs,be.webelite.iconview.R.styleable.icon); icon_name = a.getString(be.webelite.iconview.R.styleable.icon_name); </code></pre> <p>so I'm guessing my gradle.build files are causing a problem?</p> <p>I have the library set to </p> <pre><code> apply plugin: 'android-library' </code></pre> <p>end the main app gradle.build as </p> <pre><code> apply plugin: 'android' </code></pre> <p>this has been giving me headache for 2 days now :( any help/hints are very apperciated.</p> <p>here are my gradle files</p> <p><a href="http://pastie.org/private/h57o8nanydosq0dtm6eiq">http://pastie.org/private/h57o8nanydosq0dtm6eiq</a></p> <p>and here is the folder structure</p> <p><a href="http://pastie.org/private/nvbzomx2zeagdpzt8qqjsq">http://pastie.org/private/nvbzomx2zeagdpzt8qqjsq</a></p> <p>this is how I declare my view in the xml</p> <pre><code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <!-- tried res-auto didn't work --> xmlns:iconview="http://schemas.android.com/apk/lib/be.webelite.iconview" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background_gray"> <be.webelite.iconview.IconView android:layout_width="wrap_content" android:layout_height="wrap_content" iconview:icon_name="entypo_search" android:textSize="25dp"/> </code></pre> <p>attrs.xml in IconView>res>values directory</p> <pre><code> <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="icon"> <attr name="name" format="string" /> </declare-styleable> </resources> </code></pre> |
22,124,711 | 0 | Android Personal Dictionary App Issues <p>I am trying to write a personal dictionary application on android platform.<br> There are standard features like add,edit,delete.<br> I will be creating a personal application database to keep track of words.<br> Once the word is added in the personal dictionary; it should appear in the auto suggest when user is typing it in messaging/mail apps.<br>I looked at the following code snippet and tried to incorporate in my app:<br></p> <pre><code>UserDictionary.Words.addWord(this, "Joglekar", 1, "Jogl", getResources().getConfiguration().locale); </code></pre> <p>The code executes fine but the word does not appear in the auto suggest while typing.<br>I am testing on HTC One X as of now.<br> Any leads on how to accomplish this ?? <br> Have a few follow up questions but will wait for this one to resolve. :) </p> |
12,045,003 | 0 | <p>You could always add in your -(void)viewDidAppear method to reload content. If that's not the route you want to take then use an NSNotificationCenter and addObserver in view controller A and postNotification in view controller E.</p> |
35,569,859 | 0 | Maintaining FAQ data <p>Need to list down FAQ in a web page, most frequently asked question on top. Once user select or search a question, its frequency count should be increased. </p> <p>Questions,answers along with frequency count can be stored in data table or can be stored in xml/json format at server. </p> <p>What is the best way of maintaining such data? is there any standard way of doing FAQ?</p> |
38,138,883 | 0 | <p>Try this:</p> <pre><code> Picasso .with(context) .load(message.getMediaUrl()) .fit() // call .centerInside() or .centerCrop() to avoid a stretched image .into(messageImage); </code></pre> |
30,333,390 | 0 | <p>IMO it seems like the ::create array is confusing the basics. Also, I'm not clear what you are doing with $result and $marks - I am assuming they are columns on your Qualification table.</p> <p>I recommend doing something like this: </p> <pre><code>$r = $input::get('result'); if($r){ $q = new Qualification; $q->level_of_education = Input::get('level_education'); // do the same thing with the rest of your fields if($r == 1) { $q->result = 'First'; $q->marks = Input::get('marks'); } // rest of your elseif statements would follow $q->save(); } </code></pre> <p>This site has a great CRUD tutorial (this is addressed about 1/2 way through): <a href="https://scotch.io/tutorials/simple-laravel-crud-with-resource-controllers" rel="nofollow">https://scotch.io/tutorials/simple-laravel-crud-with-resource-controllers</a></p> <p>Good luck</p> |
34,338,640 | 0 | <p>One of the things you might do is to chain promises in your original array of promises, and use map to get promises for each element in array, ie consider this snipet</p> <pre><code>function getHotels(city) { return ajaxPromise ... } function getRooms(hotel) { ... } function getFurniture(room) { ... } function showUI(furniture) { ... } getHotels(city).then(function(hotels) { return $q.all(hotels.map( h => getRooms(h))) }).then(function(hotelRooms) { return $q.all(hotelRooms.map (hr => getFurniture(hr))) }).then(showUI) </code></pre> |
25,518,848 | 0 | Object html tag data attribute not working with angularjs binding in IE11 <p>I got any application where I need to display file from urls I got in database. Now this file can be an image and it can be a pdf. So I need to set some binding dynamically. I looked on internet and object tag looked promising but it is not working in IE11. It is working fine in Chrome and Firefox. SO that is why I am asking here for help. </p> <p>I have created a directive just to make sure If we have to do any dom manipulation. Here goes my directive code.</p> <pre><code>mainApp.directive("displayFile", function () { return { restrict: 'AE', // only activate on element attribute scope: { displayFile: "=", fileType:"=" }, link: function (scope, elem, attrs) { scope.filePath = ""; var element = angular.element(elem); // observe the other value and re-validate on change scope.$watch('displayFile', function (val) { if (val !== "") { scope.filePath = val; scope.type="application/"+ fileType; //element.attr("data", scope.filePath) } }); }, template: '<object data="{{filePath}}" type="{{type}}">' } }); </code></pre> <p>My html for directive</p> <pre><code><div data-display-pdf="fileUrl" file-type="type"></div> </code></pre> <p>Attaching an image also for IE and Chrome/FF output<img src="https://i.stack.imgur.com/dDYMC.png" alt="enter image description here"></p> <p>Above image is a comparison between IE and FF</p> |
39,164,633 | 0 | .sqlite file can i generate from java code <p>From SQLitestudio.exe i can easily generate .sqlite file .</p> <p>But from java code is it possible ,only.db file is generated </p> <p>What is difference between these files</p> |
31,282,552 | 0 | <p>you dont need to use a list</p> <p>and also it is considered an antipattern to do something like</p> <pre><code>def check(): if condition: return True else: return False </code></pre> <p>since you can just do</p> <pre><code>def check(): return condition </code></pre> <p>all that said ... I think you might be looking for</p> <pre><code>is_sep = lambda char:char in r"(\){}[]" </code></pre> <p>might be what you are looking for ... I guess</p> <pre><code>def is_sep(char): return char in r"(\){}[]" </code></pre> <p>if your set of characters is large you may be better off using a <code>set</code> ... if you are searching a lot of text you may be better served with something like</p> <pre><code>parts = re.split(r"[(\){}[]]",my_complete_text) </code></pre> |
13,344,237 | 0 | Searching for an image that already exist in plist file (xcode) <p>I am a new iphone developer, I am currently working on a project. *<em>Firstly I have a plist file that contain images.These images have their own id. For ex. image1's id is '100', image2's id is '101'. I also have a search bar in my app. When I entered a number(id) to the search bar, I want to get image from plist file,and show it in UIImageView.For ex. I entered '100' to my search bar. The image that its id is '100' will shown in UIImageView. *</em> Actually I have no idea about how to do this with xcode.</p> |
3,506,762 | 0 | <p>Look at how Spring does it, they have already figured out all this stuff and there is no need to re-invent it. Check out the petclinic sample code that is bundled with the full distribution of Spring, or (for a non-Spring approach) read the DAO chapter of the Bauer/King Hibernate book. </p> <p>Definitely the DAO shouldn't be in charge of getting the database connection, because you will want to group multiple DAO calls in the same transaction. The way Spring does it is there's a service layer that gets its transactional methods wrapped in an interceptor that pulls the connection from the datasource and puts it in a threadlocal variable where the DAOs can find it.</p> <p>Eating your SQLException and returning null is bad. As duffymo points out, letting the PreparedStatement get passed around with no assurance that it will ever get closed is very bad. Also, nobody should use raw JDBC anymore, Ibatis or spring-jdbc are better alternatives.</p> |
37,592,177 | 0 | C# combobox in datagridview can not set Text <p>I am writing code that display datagridviewCombobox in datagridview , i made it display and bind data to this datagridviewCombobox success. But i have the problem, I can not setText to this datagridviewCombobox.</p> <p>With normal combobox, I just set cb.Text = "", or it automatically display text in index = 0, but with datagridviewCombobox , I can not find method that accept setText to this.</p> <p>Here is some information:</p> <p><a href="https://i.stack.imgur.com/8vjQq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8vjQq.png" alt="Here is list of datagridview Column"></a></p> <p>Now is code that i add row to datagridView</p> <pre><code>private void addNewBillRow() { DataGridViewTextBoxCell stt = new DataGridViewTextBoxCell(); stt.Value = dataGridView1.RowCount + 1; DataGridViewComboBoxCell cbProduct = new DataGridViewComboBoxCell(); initCellCombobox("Select * from Product", "ID", "ProductName", cbProduct, false); DataGridViewComboBoxCell cbUnit = new DataGridViewComboBoxCell(); DataGridViewTextBoxCell amount = new DataGridViewTextBoxCell(); amount.Value = numericUpDown1.Value.ToString(); DataGridViewTextBoxCell bill = new DataGridViewTextBoxCell(); bill.Value = textBox1.Text; DataGridViewTextBoxCell ck = new DataGridViewTextBoxCell(); ck.Value = textBox5.Text; DataGridViewTextBoxCell money = new DataGridViewTextBoxCell(); money.Value = textBox6.Text; DataGridViewComboBoxCell dbDoctor = new DataGridViewComboBoxCell(); initCellCombobox("Select * from Doctor", "ID", "DoctorName", dbDoctor, false); DataGridViewTextBoxCell description = new DataGridViewTextBoxCell(); description.Value = ""; DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(stt); row.Cells.Add(cbProduct); row.Cells.Add(cbUnit); row.Cells.Add(amount); row.Cells.Add(bill); row.Cells.Add(ck); row.Cells.Add(money); row.Cells.Add(dbDoctor); row.Cells.Add(description); // Add the DataGridViewRow to the DataGridView: dataGridView1.Rows.Add(row); } </code></pre> <p>Then problem is when row added into datagridview, then I see that datagridviewCell didn't show default value ( index 0) , when I click into this datagridviewCell, now it dropdown data and fill the first value to datagridviewCell. I dont know data only show when click to this datagridviewCell .</p> <p>Here is the method I fill data to datagridviewComboBox:</p> <pre><code>private void initCellCombobox(String queryString, String key, String value, DataGridViewComboBoxCell combobox, bool isPutAll) { try { //Console.WriteLine(GlobalVar.Instance.ConnectionString); using (SqlConnection connection = new SqlConnection(GlobalVar.Instance.ConnectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); Dictionary<string, string> mapKeyValue = new Dictionary<string, string>(); if (!reader.HasRows) { combobox.Value = "Chưa có dữ liệu!"; return; } else { } if (isPutAll) { mapKeyValue.Add("-1", "Tất cả"); } while (reader.Read()) { mapKeyValue.Add(reader[key].ToString(), reader[value].ToString()); } combobox.DisplayMember = "value"; combobox.ValueMember = "key"; combobox.DataSource = new BindingSource(mapKeyValue, null); connection.Close(); } } catch (Exception ex) { //Console.WriteLine(ex.Message); MessageBox.Show("Không thể kết nối cơ sở dữ liệu: " + ex.Message); } } </code></pre> <p>Here is the picture when row just added to datagridview</p> <p><a href="https://i.stack.imgur.com/U8G8u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U8G8u.png" alt="enter image description here"></a></p> <p>When I click in to this datagridviewcombobox, It show the index 0 and show dropdown</p> <p><a href="https://i.stack.imgur.com/avvC7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/avvC7.png" alt="enter image description here"></a></p> |
38,203,517 | 0 | <p>Regarding your second question: Go to the menu item on the top called "IntelliJ Idea" and under that you'll find a "Preferences item"</p> |
21,216,344 | 0 | <p>following code snippets may help you:</p> <pre><code>(from c in db.tbl1 join d in db.tbl3 on c.tbl1ID equals d.tbl1ID join e in db.tbl2 on d.tbl2ID equals e.tbl2ID select new { c.tbl1ID, d.tbl2ID, e.tbl3ID, c.tbl1Name, d.tbl2Name, e.tbl3Name}).ToList(); </code></pre> |
20,691,705 | 0 | <p>If you use the <a href="http://view.jquerymobile.com/master/demos/filterable/" rel="nofollow">filterable widget</a> on a table, the widget will filter <strong>table rows</strong>, so to make it work with any kind of table cell content (text, input) you should use the <code>**data-filtertext**</code>-attribute and set the text to be queried on the table row like so:</p> <pre><code><tr data-filtertext="foo_from_cell_1, bar_from_cell_2, baz_from_cell_3..."> <td>foo</td> <td><div><p><span>bar</span></p></div></td> <td><input type="text" value="baz"/></td> </tr> </code></pre> <p>This way it will work. </p> <p>Also check the example provided in the JQM <a href="http://view.jquerymobile.com/master/demos/filterable/" rel="nofollow">demos</a></p> |
14,167,630 | 0 | <p>I ended up establishing a totally opaque div with top:0 left:0 and visible bottom and right borders. I then assign width and height to it as my main object moves.</p> |
9,279,278 | 0 | <p>It looks like you need to add script by calling <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx" rel="nofollow">ScriptManager.RegisterStartupScript</a> method to show elements on page:</p> <pre><code>ScriptManager.RegisterStartupScript(this, this.GetType(), this.ID, "$('#back_drop, #login_container').css('display', 'block');", true); </code></pre> |
7,715,530 | 0 | <p>the quickest way (if the strings do not change much!):</p> <p><a href="http://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/" rel="nofollow">http://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/</a></p> <pre><code>echo Classroom::levels($classroom['Classroom']['level']); </code></pre> <p>in the view - whereever you need it</p> <p>it also uses less resources than any other approach (therefor is the fastest).</p> |
5,791,568 | 0 | <p>A recursive solution:</p> <pre><code>public void addToEnd(Object data){ if (next==null) next = new Node(data, null); else next.addToEnd(data); } </code></pre> |
36,719,299 | 0 | CSS icon using :before keep text from wrapping under <p>I have an icon placed using <code>:before</code> and the text following it sometimes wraps to two or three lines. When it wraps the text goes under the icon. </p> <p>I am looking for CSS help to keep the text from wrapping under the icon.</p> <p>Here is an image showing what I am referring to:<br> <a href="https://i.stack.imgur.com/6fYff.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6fYff.png" alt="wrap"></a></p> <p>Current CSS:</p> <pre><code>a[href $='.pdf']:before, a[href $='.PDF']:before, a[href $='.pdf#']:before, a[href $='.PDF#']:before, a[href $='.pdf?']:before, a[href $='.PDF?']:before { content: "\f1c1"; font-family: 'FontAwesome'; color: #999; display: inline-block; margin: 0px 10px 0 0; font-size: 24px; vertical-align: middle; } .form-title:before { float: left; } </code></pre> <p>Here is a fiddle with my code: <a href="https://jsfiddle.net/west4me/x0yyfxmm/" rel="nofollow noreferrer">fiddle</a></p> |
8,795,975 | 0 | <p>Ensure you implement this in the header file: <code>GKPeerPickerControllerDelegate</code> </p> |
24,650,039 | 0 | MPI sending an array of 128bits integer <p>I have a struct like: </p> <pre><code>union W128_T { uint32_t u[4]; uint64_t u64[2]; }; struct SFMT_T { /** the 128-bit internal state array */ w128_t state[SFMT_N]; /** index counter to the 32-bit internal state array */ int idx; }; </code></pre> <p>It is an implementation for pseudo-random generator, mersenne twister. I want to send an SFM_T element to all workers. I have two options. </p> <ol> <li>Using MPI_Derived type: I create an MPI_Derived type for state array, using an MPI_Type for 128 bits. I searched and i found this page for MPI_Type: <a href="http://www-01.ibm.com/support/knowledgecenter/SSFK3V_1.3.0/com.ibm.cluster.pe.v1r3.pe400.doc/am106_pmd.htm?lang=en" rel="nofollow">IBM Knowledge Center-MPI Data Types</a>. There are types for 128 floating points. Can i use it for my data type.</li> <li><p>Using a char array to store state array: I plan to create a char array of size <code>[SFMT_N * 16 + 2]</code> because 128bit variable is equal to 16 chars and <code>+2</code> indicates the <code>idx</code> variable. I am not sure how to change state array into a character array. I wrote some code for this serialization: </p> <pre><code>typedef struct SFMT_T sfmt_t; char * serialize(sfmt_t* sfmt) { char buffer[SFMT_N*16+sizeof(int16_t)]; int16_t tmp_size = 0 ; int8_t offset = 0; int i=0,j; tmp_size =(4*sizeof(uint32_t)); for(i=0;i<SFMT_N;i++) { memcpy(buffer+offset,&sfmt->state[i].u, tmp_size); for(j=offset;j<offset+tmp_size;j++) { printf("buffer %c \n",buffer[j]); } offset += tmp_size; } memcpy(buffer+offset,&sfmt->idx,sizeof(uint16_t)); return buffer;} void deserialize(char* buffer, sfmt_t* sfmt) { int16_t tmp_size,start,i ; for(i=0;i<SFMT_N;i++) { start = sizeof(uint32_t)*4*i; tmp_size =(4*sizeof(uint32_t)); memcpy(sfmt->state[i].u,&buffer[start], tmp_size);} for(i=0;i<SFMT_N;i++) { printf("%d %d %d %d \n",sfmt->state[i].u[0],sfmt->state[i].u[1],sfmt->state[i].u[2],sfmt->state[i].u[3]); } } </code></pre> <p>It doesn't give exactly what i want. What am i missing? </p></li> </ol> <p>Also, i want to know which way can be more efficient for a distributed system. </p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.