pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
20,941,128
0
How to feed a custom ImageSource to Image in XAML <p>One way to set an ImageSource for Image in XAML is like this:</p> <pre><code>&lt;Image Width="75" Height="75"&gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource={Binding Uri} DecodePixelWidth="75" DecodePixelHeight="75" /&gt; &lt;Image.Source&gt; &lt;/Image&gt; </code></pre> <p>This code contains a nice optimization, since a potentially large bitmap will be decoded to 75x75 pixels.</p> <p>I'd like to be able to replace BitmapImage with my custom class like this:</p> <pre><code>&lt;Image Width="75" Height="75"&gt; &lt;Image.Source&gt; &lt;custom:PictureBitmap Picture={Binding Picture} Width="75" Height="75" /&gt; &lt;Image.Source&gt; &lt;/Image&gt; </code></pre> <p>My application implements the Picture class, which maps to a database table. Picture class has everything I need to create an instance of BitmapImage. So PictureBitmap is essentially an adapter for the BitmapImage.</p> <p>Here is how I started:</p> <pre><code>public class PictureBitmap : BitmapSource { // TODO: create Picture Dependency Property // TODO: create a BitmapImage from Picture // TODO: implement abstract methods by delegating calls to BitmapImage } </code></pre> <p>Although BitmapSource is abstract, the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.media.imaging.bitmapsource%28v=vs.105%29.aspx" rel="nofollow">API reference</a> doesn't explain how to implement it.</p> <p>Does anyone know how to feed a custom object to Image.Source?</p> <p>My app supports Windows Phone Mango (7.5) and up.</p> <p>Thanks!</p>
21,388,832
0
Oracle TIMESTAMP and Mybatis issue <p>I'm using mybatis in my web application.</p> <p>I'm executing the below select query:</p> <pre><code>&lt;select id="retrieveSearchResultReferrals" resultType="hashmap" parameterType="map"&gt; select * from table(xxxx.test_abc_pk.retrieveDA(#{searchString})) &lt;/select&gt; </code></pre> <p>Of the columns in result some are DATE data type and one column is TIMESTAMP data type.</p> <p>Mybatis is converting DATE column correctly to java.sql.Date BUT for the TIMESTAMP column it is converting it to oracle.sql.TIMESTAMP instead of java.sql.Timestamp.</p> <p>Any ideas on how can I make mybatis to convert TIMESTAMP to java.sql.Timestamp?</p>
32,363,968
0
Updates/Deletes in levelDB <p>The sorted SSTable data structure that levelDB uses is immutable. If so, how are records updated/deleted in levelDB ? Is this process done periodically ? </p>
15,377,246
0
<p>Renderer is an OpenGL method. OpenGL ES doesn't inherently support text. This leaves the following options:</p> <ol> <li>Use a texture, draw to it using Android's Canvas class.</li> <li>Use a library. This will most likely also draw to a texture as well.</li> <li>Create the text with polygons.</li> </ol> <p>Since your question is asking for a solution that doesn't draw to a texture, then 1 and 2 are both out. And since you want something simple, 3 is also out. Leaving no good solutions.</p> <p>An alternative to consider is to layer another view on top of the GLSurfaceView you are using. You can use a RelativeLayout to easily stack two views, one being a textview that you can anchor to the top right corner of the screen. Pseudocode below:</p> <pre><code>&lt;RelativeLayout ... /&gt; &lt;GLSurfaceView ... /&gt; &lt;TextView ... /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>This approach has the benefit of pulling you out of the OpenGL requirements to do your text. I've done this successfully on a couple of my apps.</p>
2,349,647
0
<p>Try this:</p> <pre><code> for (int x=0;x&lt;4;x++) flag[x]=guess[x]==answer[x]?1:0; for (int slot = 0;slot &lt; 4;slot++) { if (guess[slot] == answer[slot]) black++; else for (int s=0;s &lt; 4;s++) if (!flag[s] &amp;&amp; guess[slot] == answer[s]) { white++; flag[s]=1; break; } } </code></pre>
39,399,353
0
<p>Call the function and save the result in a variable:</p> <pre><code>$result = GetProductsByCategory($categoryID); </code></pre> <p>then inside the function:</p> <pre><code>$productsResult = $conn-&gt;query($sql); return $productsResult; </code></pre> <p>then your while loop should use this returned result (i.e., <code>$result</code>):</p> <pre><code>while ($row = $result-&gt;fetch_assoc()) { ... } </code></pre>
6,078,693
0
<p>After much work, thanks to cainmi's suggestion I have come up with a solution. My .htaccess for the protected directory looks like this</p> <pre><code>RewriteEngine On RewriteBase /php-wrapper/auth RewriteRule ^(.*) /php-wrapper/wrapper.php?topage=https://%{SERVER_NAME}/php-wrapper/auth/$1 </code></pre> <p>This passes the requests back to my php script which checks for Auth and if it passes does the following</p> <pre><code>$type = (get_object_vars(apache_lookup_uri("$abs_path"))); header('Content-type: '.$type['content_type']); readfile($abs_path); </code></pre> <p>Responding with the file and the proper MIME type</p> <p>Because some of the content I was serving had XML I had to disable short open tags. I achieved this by adding this line to the .htaccess of the directory that held the wrapper.</p> <pre><code>php_value short_open_tag 0 </code></pre> <p>Stackoverflow was integral to finding this solution and for that I thank you all.</p>
9,041,553
0
<p>Similar to Charlie Martin, you can do something like this:</p> <pre><code>static unigned __int64 _foo_id = 0; foo::foo() { ++_foo_id; if (_foo_id == MAGIC_BAD_ALLOC_ID) DebugBreak(); std::werr &lt;&lt; L"foo::foo @ " &lt;&lt; _foo_id &lt;&lt; std::endl; } foo::~foo() { --_foo_id; std::werr &lt;&lt; L"foo::~foo @ " &lt;&lt; _foo_id &lt;&lt; std::endl; } </code></pre> <p>If you can recreate it, even once or twice with the same allocation id, this will let you look at what is happening right then and there (obviously TLS/threading has to be handled as well, if needed, but I left it out for clarity).</p>
6,792,025
0
How to get and store Username and password when app is launched for the first time? <p>I have a tabbar app and I want to add login window that will show just for the first time the app is launched. and want username and password to be hard coded in the app. can anyone help me with this please.</p>
35,717,158
0
<p>I would recommend this </p> <pre><code>#element { display: table; /* IE8+ and all other modern browsers */ } </code></pre>
19,394,325
0
<p>Observations,</p> <p>Count_List() should count each element on list, your version only counts starting at the second item on the list. And it should always return an int,</p> <pre><code>int Count_List(Library *Head) { int count = 0; Library *Tmp = Head; if(!Tmp) return(count); while(Tmp != NULL) { count++; Tmp = Tmp-&gt;next; } return(count); } </code></pre> <p>Inside Read_File() you call Create_List(Entry,Head), but your function signature for Create_List(Head,Entry); which do you intend? Probably (Head,Entry). Use fgets and sscanf to Read_File,</p> <pre><code>Library * Read_File(FILE *fp) { Library *Head, *Entry; Head = Entry = NULL; char genre[100], band[100], album[100]; float rating; char line[100]; while(fgets(line,sizeof(line),fp) { sscanf(line,"%s %s %s %f", genre, band, album, &amp;rating); Entry = Create_Album(genre, band, album, rating); Head = Create_List(Head,Entry); } return Head; } </code></pre> <p>Looking at Create_List(), you seem to be implementing the List as a stack (push Entry onto head of list),</p> <pre><code>Library * Create_List(Library *Head, Library *Entry) { if(!Head) return Entry; Entry-&gt;next = Head; return Entry; } </code></pre> <p>Create_Album() needs to check for successful malloc before assigning values to member variables,</p> <pre><code> Library *Entry=NULL; if( !(Entry=(Library*)malloc(sizeof(Library))) ) { printf("error creating album\n");fflush(stdout); return Entry; } </code></pre> <p>Speaking of Library struct, you declare the members genre, band, album as pointers, but you need space to copy memory, example,</p> <pre><code>typedef struct library { char genre[50]; char band[50]; char album[50]; float rating; struct library *next; }Library; </code></pre> <p>My suggestion would be to build constructor and destructor functions LibraryNew, LibraryDel.</p> <p>Check for (argc&lt;2) arguments (your message says not enough, instead of need 2,</p> <pre><code> if(argc &lt; 2) { printf("Not enough arguments.\n"); return 0; } </code></pre> <p>And that fixes the biggest problems,</p> <pre><code>./library music.x 2 line:Rock Antrax Party 1.2 Rock,Antrax,Party,1.200000 Rock,Antrax,Party,1.200000 added: Rock,Antrax,Party,1.200000 Rock Antrax Party 1.20 Rock Antrax Party 1.20 Which genre would you like to delete? </code></pre>
7,926,799
0
Calculating difference between 2 Zend_Date objects <p>I have 2 Zend_Date objects:</p> <pre><code>$d1 = new Zend_Date('2011-11-14 12:20:30'); $d2 = new Zend_Date('2012-11-16 13:40:10'); </code></pre> <p>And I need to calculate difference. My output should be like this:</p> <pre><code>Years: 1, Months: 0, Days: 2, Hours: 1, Minutes: 19, Seconds: 40 </code></pre> <p>I can do it with <code>DateTime</code> class and <code>diff</code> method. But my hoster has PHP version &lt; 5.3. Can you help me how can I do it in Zend? Thanks.</p>
27,559,124
0
Double command execution with instanceof and HashMap <p>I'm really flummoxed by this one. After having some problems managing separate HashMaps for each child class, I decided to try using instanceof to make things simpler with a HashMap of the Parent class that will include any number of each of the child classes. I came up with this test code:</p> <pre><code>static HashMap &lt;Integer, ant&gt; antMap = new HashMap(); public static void main(String[] args) { // ant is parent to antF, antSo, and antB ant testSc = new ant(); antF testF = new antF(); antSo testS = new antSo(); antB testB = new antB(); antMap.put(testSc.ID, testSc); antMap.put(testF.ID, testF); antMap.put(testS.ID, testS); antMap.put(testB.ID, testB); ant grand = new ant(); int loop = 0; for (int s = 1; s &lt; 5; s++){ grand = antMap.get(s); loop++; if(grand instanceof ant){ System.out.println("type " + grand.type + grand.ID + "Loop " + loop); } if(grand instanceof antF){ antF work = (antF) grand; System.out.println("type " + work.type + work.ID + "Loop " + loop); } if(grand instanceof antSo){ System.out.println("type " + grand.type + grand.ID + "Loop " + loop); } if(grand instanceof antB){ System.out.println("type " + grand.type + grand.ID + "Loop " + loop); } } </code></pre> <p>I put the loop counter in there to see if the for loop was doubling up somehow but the output is: </p> <pre><code>type Scout1Loop 1 type Forager2Loop 2 type Forager2Loop 2 type Soldier3Loop 3 type Soldier3Loop 3 type Bala4Loop 4 type Bala4Loop 4 </code></pre> <p>I see the parent class (labeled scout here) executes once correctly. The constructor class in ant assigns an ID based on the number of ants, so the Forager should be Forager2, Soldier should be Soldier3, etc.</p> <p>I cannot for the life of me figure out why the child classes are executing twice. The loop counter shows this. </p> <p>Does anyone have any suggestions?</p> <p>Edit: you can see I tried a couple different things within the for loop to get the expected results.)</p> <p>(I did try to tag this as homework, although this is not a specific solution.)</p>
34,477,879
0
<p>The following worked to fix the issue:</p> <pre><code>url = urllib.unquote(str(res.url)).decode('utf-8', 'ignore') </code></pre> <p><code>res.url</code> was a unicode string, but didn't seem to work well with <code>urllib.unquote</code>. So the solution was to first convert it to a string (like how it was in the python interpreter) and then <code>decode</code> it into Unicode.</p>
17,398,407
0
<p>Thanks to art-divin, and to Jean-Baptiste for providing the answer via email. Below is the code that repositions a button matrix on rotation. The code for creating the button matrix remains the same.</p> <pre><code>- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration { if (orientation == UIInterfaceOrientationPortrait) { COLUMNS = 7; ROWSS = 8; int i=0; // button count iterator for (int rows = 0; rows &lt; ROWSS; rows++) { for (int columns = 0; columns &lt; COLUMNS; columns++) { NSUInteger chapter = columns + rows * COLUMNS + 1; if (chapter &gt; 50) break; UIButton *b = (UIButton *)[call.createButtonArray objectAtIndex:i++]; b.frame = CGRectMake(columns * WIDTH, rows * 38, HEIGHT, 37); // columns * X, rows * Y, width, height } } [rotateController rotateChapterButtons_Portrait]; } else if (orientation == UIInterfaceOrientationLandscapeRight ||orientation == UIInterfaceOrientationLandscapeLeft) { COLUMNS = 10; ROWSS = 9; int i=0; // button count iterator for (int rows = 0; rows &lt; ROWSS; rows++) { for (int columns = 0; columns &lt; COLUMNS; columns++) { NSUInteger chapter = columns + rows * COLUMNS + 1; if (chapter &gt; 50) // &gt; greater than break; NSLog(@"%i:",chapter); UIButton *b = (UIButton *)[call.createButtonArray objectAtIndex:i++]; b.frame = CGRectMake(columns * 48, rows * 38, 47, 37); // columns * X, rows * Y, width, height } } [rotateController rotateChapterButtons_Landscape]; } </code></pre> <p>}</p>
24,412,694
0
JWplayer raising Could not load plugins: File not found Error <p>I saw many answers for <strong>Could not load plugins:File not found</strong>. but it's bit different.</p> <p>I am using jwplayer for my rails app and i am playing videos in bootstrap modal.</p> <p>After page load if i click video to play in bootstrap it is raising above error after closing that modal and again i clicked the same video it is playing video now(My page not refreshed). </p> <p>I tried again after refreshing my page but for first time again same problem. </p> <p>Tried with two browsers same issue.</p> <pre><code>$('.playuservideo').click(function() { var videopath=$(this).data('videopath'); jwplayer('myElement').setup({'flashplayer': "/assets/flash.swf", 'id': 'playerID', 'width': '540','height': '360', 'file': videopath }); $('#playallmodal').modal('show'); }); </code></pre>
6,569,236
0
On line Table editor for MS SQL Server / Access? <p>I'm searching for a on line database table editor for SQL or Access that allows editing of records. Does it exist a .net application? Can someone help me?</p>
23,339,553
0
<pre><code>//try this way, hope this will help you... String value = "5571.329849243164"; Toast.makeText(MyActivity.this,""+Math.round(Double.parseDouble(value)),Toast.LENGTH_SHORT).show(); </code></pre>
5,686,666
0
<p>Yes you can, see here:</p> <p><a href="https://github.com/blog/128-let-there-be-renaming">Rename github repo</a></p> <p>If I understand you correctly you want to rename your git repository eg xyz.git to xyz1.git and then have all the git repositories that link to that repo link to the new name automatically?</p> <p>As far as I know this isn't possible. Each repository is self contained and keeps a list of locations it links to. If one of those locations changes its name the link would be broken. Each repository that references the changed name would need to update its link.</p> <p>But then, the same would happen if you deleted a repository and recreated it under a new name....</p> <p>Just realised you were specifically talking about GitHub and not git in general, sorry - should learn to read the entire question like my school teachers said. The answer still stands, with the addition that you can change the name in GitHub from the Admin page.</p>
18,876,602
0
<p>I am still at education so do know how good is my solution , but i did not crash so hope it is correct</p> <p>and it is quite similar to @muthu 's code</p> <p>I had used JPA-eclipselink and Struts2</p> <p>Action Class</p> <pre><code>String checkLogin = "SELECT user FROM UserEntity user WHERE user.username = :username AND user.password = :password"; Query checkLoginQuery = em.createQuery(checkLogin); checkLoginQuery.setParameter("username", loginUsername); checkLoginQuery.setParameter("password", loginPassword); userEntity = (UserEntity) checkLoginQuery.getSingleResult(); Map sessionMap = ActionContext.getContext().getSession(); sessionMap.put("userEntity", userEntity); </code></pre> <hr> <p>JSP -> all jsp pages have this(bug:affected if session is not killed when browser is not closed )</p> <pre><code>&lt;%@ taglib prefix="s" uri="/struts-tags" %&gt; &lt;s:if test="%{#session.userEntity == null}"&gt; &lt;jsp:forward page="login.jsp"/&gt; &lt;/s:if&gt; </code></pre> <hr> <hr> <p>Correct me if I am wrong</p> <p><a href="http://www.theserverside.com/discussions/thread.tss?thread_id=22795" rel="nofollow">Quoting this page</a></p> <blockquote> <p>Both and RequestDispatcher.forward() are what I refer to as "server-side" redirects</p> <p>The response.sendRedirect() is what I call a "client-side" redirect.</p> </blockquote> <p>so a server side forward looks more safe to me , maybe I am wrong (I am sorry if I am miss interpreting it ,not worked in real life projects yet)</p>
30,828,666
0
getting back additional info when webscraping with cheerio js <p>I am working with cheerio.js to make a simple web scraper. For some reason it does not respond to certain html tags. One div I cannot target is <b>the div with the class of 'dataTables_scrollBody'</b> on the website that I am scraping: <a href="http://www.caffeineinformer.com/the-caffeine-database" rel="nofollow">http://www.caffeineinformer.com/the-caffeine-database</a>.</p> <p>However, I think I found a work-around to my problem.</p> <p>I read through the documentation <a href="https://github.com/cheeriojs/cheerio" rel="nofollow">https://github.com/cheeriojs/cheerio</a> and am following this format <b>$( selector, [context], [root] </b>. </p> <pre><code>$(".main, div:nth-child(3) ").filter(function(){ var data = $(this).prev().text(); console.log(data); }) </code></pre> <p>In my console I am getting the data that I desire but with two problems</p> <pre><code>1. Caffeine Content of Drinks All Coffee Soda Energy Drinks Tea Shots Loading data.../*&lt;![CDATA[*/var totalrows=1127; var latestdate='06/12/2015';var tbldata= </code></pre> <p>I do not see this info on the page.</p> <pre><code>2. I am getting my data back two times. </code></pre> <p>I put in a console.log for the data length. I got back 8 different lengths. I believe there is a workaround. However, I cannot figure this out. </p> <p>Does anyone have any knowledge on the matter?</p>
39,391,922
0
Generate a .sparql file in order to backup rdf graphs <p>Is there a way to use SPARQL to dump all RDF graphs from a triplestore (Virtuoso) to a <code>.sparql</code> file containing all <code>INSERT</code> queries to rebuild the graphs?</p> <p>Like the <code>mysqldump</code> command?</p>
11,732,940
0
<p>Create a button in your XML layout and the add the attribute <code>android:onClick="takeAPicture"</code> then in your main activity create a method with the same name from the <code>onClick</code> attribute. </p> <pre><code>public void takeAPicture(View view){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, IMAGE_CAPTURE); } </code></pre> <p>And just do another method for when you want to get the image from the gallery:</p> <pre><code>public void getImageFromGallery(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); } </code></pre>
35,086,266
0
<p>You will need a new method which all it does it simply check if the radio button is there or not.</p> <pre><code>public static boolean isPrivateRadioButtonExist() { return driver.findElements(By.id("type-radio-private")).size() != 0; } </code></pre> <p>Then, in your base test class, call this method to determine if you need to skip the step or not.</p> <p><strong>However</strong>, the way you are approaching your problem is incorrect. If you have multiple versions of web app, then you should also have multiple versions of your automated tests. One way is to follow your web app's branching strategy. This will avoid yourself having to use all sorts of 'if' statements in your code.</p>
17,549,505
0
Struggling with regular expression <p>I'm struggling to find the regular expression I can use to classify data that matches a certain pattern:</p> <p>Here's a few examples:</p> <pre><code>pli:06e9b616-5712-d0e9-1bc2-000012e61393 pli:6fdd187d-cbdc-3028-4a8d-000020f3449a pli:0472def9-ccf3-e4e9-ca05-00005fecf9f8 </code></pre> <p>As you can see each string begins with pli: and they all have the same pattern even though the characters are different. Each set of characters is separated by a '-' at the same position.</p>
31,235,362
0
<p>You could create a class to map your patients to;</p> <pre><code>private static class Patient { @JsonProperty("name") private String name; @JsonProperty("age") private int age; public Patient() { } public String getName() { return name; } public int getAge() { return age; } } </code></pre> <p>Then read your json into it via jackson</p> <pre><code>HashMap&lt;String, Patient&gt; patients = objectMapper.readValue(new File("patients.json"), new TypeReference&lt;HashMap&lt;String,Patient&gt;&gt;() {}); Patient patientA = patients.get("A"); String patientAName = patientA.getName(); int pateintAAge = patientA.getAge(); </code></pre>
12,559,954
0
<p>With Java 7, it's as simple as:</p> <pre><code>final String EoL = System.getProperty("line.separator"); List&lt;String&gt; lines = Files.readAllLines(Paths.get(fileName), Charset.defaultCharset()); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(line).append(EoL); } final String content = sb.toString(); </code></pre> <p>However, it does havea few minor caveats (like handling files that does not fit into the memory).</p> <p>I would suggest taking a look on <a href="http://docs.oracle.com/javase/tutorial/essential/io/charstreams.html">corresponding section</a> in the official Java tutorial (that's also the case if you have a prior Java).</p> <p>As others pointed out, you might find sime 3rd party libraries useful (like Apache commons I/O or Guava).</p>
14,555,399
0
How do I handle the timezones for every Chat message <p>I am creating a web chat application using ASP.NET. I have got the chat system to work as messages are sent and relayed back to the clients. But there was something I noticed but never thought it would be a problem. I am from England and the chat application is sitting on servers in America and noticed when the message displayed the time, the times were situated in American time zones. How would I go about setting the timezones that will correspond to the user's timezone.</p>
35,956,306
0
<p>Add a parentheses after the stored procedure name, with an equal amount of question marks to match the amount of parameters you wish you fill in.</p> <p>Eg.</p> <pre><code>{call MyProc(?,?,?)} </code></pre>
32,251,714
0
Cannot derive user name for bundle org.demo.anthony.mybundle.core [446] and sub service null <p>I have a bundle that was working completely fine in AEM 6. I just upgraded to AEM 6.1 and when I deploy the bundle, I'm getting the error below:</p> <blockquote> <p>javax.jcr.LoginException: Cannot derive user name for bundle org.demo.anthony.mybundle.core [446] and sub service null at org.apache.sling.jcr.base.AbstractSlingRepository2.loginService(AbstractSlingRepository2.java:336) at org.demo.anthony.mybundle.core.impl.EvernoteSyncServiceImpl.getSession(EvernoteSyncServiceImpl.java:108) at org.demo.anthony.mybundle.core.impl.EvernoteSyncServiceImpl.syncNotes(EvernoteSyncServiceImpl.java:201) at org.demo.anthony.mybundle.core.impl.EvernoteSyncServiceImpl.syncWebClipperNotes(EvernoteSyncServiceImpl.java:174) at org.demo.nennig.evernote.core.impl.schedulers.EvernoteSyncTask.run(EvernoteSyncTask.java:96) at org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:105) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)</p> </blockquote> <p>This is how I'm getting hold of the session (this is line 108 in the code as referenced in the stacktrace):</p> <pre><code>session = repository.loginService(null, null); </code></pre>
3,649,673
0
What indices should be created to optimize sql query with multiple OR conditions <p>I have a query like this:</p> <pre><code>SELECT * FROM T WHERE A = @A AND (B=@B OR C=@C OR D=@D OR @E=E) ORDER BY F </code></pre> <p>What indices should I add to improve query performance? Also I'll need to implement paging so this query will be more complex.</p> <p>My guess is that four indices should be created: (A, B, F), (A, C, F), (A, D, F) (A, E, F), but I'm not sure and can't really test it as I don't have enough data yet. </p> <p>Does anyone have some experience to share? Thanks.</p>
35,901,074
0
<p>Here is a working version with some changes from your original code. As pointed out in the other answer, there are a few errors in your code. In addition, I changed textOutput to htmlOutput. In server.R, I put all code inside the <code>observeEvent</code> environment.</p> <p>In general, your method in your R script needs to <strong>return</strong> something suitable for process in <code>server.R</code>. For example, in this case, it returns a string, which <code>server.R</code> renders as text, and <code>ui.R</code> in turn renders as HTML. </p> <p>Any variable/data that is accessible in <code>server.R</code> (including any files that it <code>source</code>) can be displayed in the ui. What you need is (1) a suitable render method to render this data in <code>server.R</code> (2) a suitable output container to hold the output display in <code>ui.R</code></p> <p>ui.R</p> <pre><code>library(shiny) shinyUI(fluidPage( headerPanel("Inputting from Interface to Script"), sidebarPanel( #'a' input numericInput(inputId = "a", label = h4("Enter a:"), value = 3), numericInput(inputId = "b", label = h4("Enter b:"), value = 4), actionButton(inputId = "input_action", label = "Show Inputs")), mainPanel( h2("Input Elements"), htmlOutput("td")), # use dataTableOuput to display the result of renderDataTable. Just like the render methods, there are many output methods available for different kind of outputs. See Shiny documentation. dataTableOutput("table") )) </code></pre> <p>server.R</p> <pre><code>library(shiny) source("mathops.R") shinyServer(function(input, output) { observeEvent(input$input_action, { a = input$a b = input$b output$td &lt;- renderText({ mathops(a,b) }) }) # Use renderDataTable to convert mat2 to a displayable object. There are many other render methods for different kind of data and output, you can find them in Shiny documentation output$table &lt;- renderDataTable(data.frame(mat2)) }) </code></pre> <p>mathops.R</p> <pre><code>mathops &lt;- function(a,b) { return(paste0("Addition of two number is: ", a+b, br(), "Multiplication of two number is: ", a*b)) } mat1 &lt;- matrix(sample(1:16), ncol=4) mat2 &lt;- matrix(sample(1:25), ncol=5) </code></pre>
10,162,774
0
<p>Yeah, that's right. If you define a function inside a function, it will be private to that function. You need to create a global var</p> <pre><code>var recordjourney; $(document).ready(function(){ ... recordjourney = { var journey = ... etc </code></pre> <p>Although, of course, given that you are using JQuery I'd do</p> <pre><code>$(document).ready(function(){ ... $( 'button[name=record]' ).bind( function(){ //put your function here }) </code></pre> <p>and remove the ugly onclick="recordjourney from the button tags.</p>
40,688,288
0
<p>So after two days of research I cant find a proper solution to this issue i managed to bypass it by setting the cell frame in <em>layoutAttributesForElementsInRect</em> like this:</p> <pre><code> UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:[attributesForElementsInRect indexOfObject:attributes] inSection:0]]; if (!CGRectEqualToRect(cell.frame, refAttributes.frame)) cell.frame = refAttributes.frame; </code></pre> <p>this is the complete function</p> <pre><code>- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSArray* attributesForElementsInRect = [super layoutAttributesForElementsInRect:rect]; NSMutableArray* newAttributesForElementsInRect = [[NSMutableArray alloc] init]; // use a value to keep track of left margin CGFloat leftMargin = 0.0; for (id attributes in attributesForElementsInRect) { UICollectionViewLayoutAttributes* refAttributes = attributes; // assign value if next row if (refAttributes.frame.origin.x == self.sectionInset.left) { leftMargin = self.sectionInset.left; } else { // set x position of attributes to current margin CGRect newLeftAlignedFrame = refAttributes.frame; newLeftAlignedFrame.origin.x = leftMargin; refAttributes.frame = newLeftAlignedFrame; } // calculate new value for current margin leftMargin += refAttributes.frame.size.width + 8; [newAttributesForElementsInRect addObject:refAttributes]; UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:[attributesForElementsInRect indexOfObject:attributes] inSection:0]]; if (!CGRectEqualToRect(cell.frame, refAttributes.frame)) cell.frame = refAttributes.frame; } } </code></pre> <p>Hope this will help somebody or someone have a better solution </p>
24,465,190
0
NSDictionary loading a NSURL with URLByResolvingBookmarkData <p>I'm trying right now the Bookmark Data solution and I retraive a NSURL but it doen't work.The NSURL is correctly formatted but when i use it to create a dictionary or a string these are nil. The code I'm using is this:</p> <pre><code>- (NSData *)bookmarkFromURL:(NSURL *)url { NSError *error = nil; NSData *bookmark = [url bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:NULL relativeToURL:NULL error:&amp;error]; if (error) { NSLog(@"Error creating bookmark for URL (%@): %@", url, error); [NSApp presentError:error]; } return bookmark; } - (NSURL *)urlFromBookmark:(NSData *)bookmark { NSURL *url = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:NULL bookmarkDataIsStale:NO error:NULL]; return url; } </code></pre>
17,464,184
0
adding the text box values using javascript <p>I have a Grid view which contains various text boxes. I need to add all the text box values and display the result in a separate Text Box. I need to use java script for this. Please help me out.</p>
29,104,583
0
<p>I prefer to avoid select, activate and selection in deference to direct addressing. The paste special, values can also be handled more efficiently by direct cell value transfer.</p> <pre><code>'make sure that the worksheet vars are set correctly set wsOrigen2 = &lt;other workbook&gt;.Sheets("Sheet1") set wsDestino = ThisWorkbook.Sheets("Sheet1") With wsOrigen2.Cells(1, 1).CurrentRegion wsDestino.Cells(Rows.Count, 1).End(xlUp) _ .Offset(1, 0).Resize(.Rows.Count, .Columns.Count) = .Cells.Value End With set wsDestino = nothing set wsOrigen2 = nothing </code></pre> <p>If the workbooks are open and the worksheets are set correctly, that should be all that you really require.</p> <p>See <a href="http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros">How to avoid using Select in Excel VBA macros</a> for more methods on getting away from replying on select and activate.</p>
38,353,975
0
<p>Would you be okay using something like this? It also helps to have more views on Youtube.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code> #laptop-panel { position: relative; padding-top: 25px; padding-bottom: 67.5%; height: 0; } #laptop-panel iframe { box-sizing: border-box; background: url(http://176.32.230.43/testdigitalmarketingmentor.co.uk/wp-content/uploads/2016/07/laptop-1000x728-trans.png) center center no-repeat; background-size: contain; padding: 11.7% 17.9% 15.4%; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div id="laptop-panel"&gt; &lt;iframe src="https://www.youtube.com/embed/BhEWkcyXYwg?rel=0&amp;amp;controls=0&amp;amp;showinfo=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Happy coding!</p>
36,351,677
0
<p>Ok I don't know for your error but you're handling exception the wrong way. Here is how you should do it (not to mention the SQL injection here) :</p> <pre><code>Try ' Your code here Catch e as Exception MsgBox.show(e.Message, "An Error occured") End Try </code></pre> <p>NB : I post this here because it's too lon g for a comment...</p>
38,059,533
0
Why doesn't DbgPrintEx support floating-point numbers? <p>According to <a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff543634(v=vs.85).aspx" rel="nofollow">the documentation</a></p> <blockquote> <p>The <code>DbgPrintEx</code> routine does not support any of the floating point types <em>(%f, %e, %E, %g, %G, %a, or %A)</em></p> </blockquote> <p>That seems very strange, since they support most of the other C-style formatting parameters, and since <code>vsprintf</code> <em>(which is also available to kernel-mode drivers)</em> does support floating-point.</p> <p>Is there a technical reason for not supporting floating-point numbers?</p>
5,754,195
0
How to integrate twitter app in my iphone? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4012349/how-to-connect-to-twitter-from-iphone">How to connect to Twitter from iPhone?</a> </p> </blockquote> <p>hi, can anybody please explain how to integrate the twitter app in my iphone app with simple example?</p>
39,353,984
0
<p>I'll focus my answer on this part of your question:</p> <blockquote> <p>How can I make sure that my DateTime -> NodaTime outputs are consistent, regardless of current location?</p> </blockquote> <p>Several places in your code, you call <code>.ToUniversalTime()</code> on a <code>DateTime</code> object. When you do that, the operation depends on the <code>DateTimeKind</code> value assigned to the <code>Kind</code> property of the object. Per <a href="https://msdn.microsoft.com/library/system.datetime.touniversaltime.aspx" rel="nofollow noreferrer">the MSDN docs</a>:</p> <p><a href="https://i.stack.imgur.com/rjgM9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjgM9.png" alt="MSDN Table"></a></p> <p>Therefore, as long as the <code>Kind</code> is not <code>DateTimeKind.Utc</code>, then the input value is interpreted as being in the local time zone, and thus the conversion to UTC is affected by whatever that local time zone is on the computer where it is running, leading to inconsistent output.</p> <p>If you don't want your code to give different results when the local time zone differs between two computers, then you should not use this method. This is why option #2 and option #3 in your code give different results.</p> <p>As for option #1, it's not clear what you actually are trying to do. You are asserting that the input <code>dt</code> is in the <code>Africa/Johannesburg</code> time zone, but you never ask for any type of conversion. You are just emitting the same local value you passed in. If you meant to convert from UTC to South Africa, or vice-versa, then you need to explain that more clearly in the question. As it is, I cannot tell what you were actually wanting it to do.</p>
23,310,002
0
Match everything before last section of url <p>I want to match everything in a URL up to the last section.</p> <p>So I want to match: <code>http://www.test.com/one/two/</code> in all of the following cases:</p> <pre><code>http://www.test.com/one/two/three http://www.test.com/one/two/three/ http://www.test.com/one/two/three/?foo=bar </code></pre> <p>I'm working in PHP and currently I have <code>/.+\/(?=[^\/]+\/?$)/</code> this matches everything except the last case but I can't seem to 'not match a forward slash unless it's followed by a question mark' which would seeming sort the problem?</p>
15,616,949
0
<blockquote> <p>I am unable to find a convincing answer as to why the information from the -g option is insufficient for de-compilation, but sufficient for debugging?</p> </blockquote> <p>The debugging information basically contains only mapping between the addresses in the generated code and the source files line numbers. The debugger does not need to decompile code - it just shows you the original sources. If the source files are missing, debugger won't magically show them.</p> <p>That said, presence of debugging info does make decompilation easier. If the debug info includes the layout of the used types and function prototypes, the decompiler can use it and provide a much more precise decompilation. In many cases, however, it will still likely be different from the original source.</p> <p>For example, here's a function decompiled with the Hex-Rays decompiler without using the debug info:</p> <pre><code>int __stdcall sub_4050A0(int a1) { int result; // eax@1 result = a1; if ( *(_BYTE *)(a1 + 12) ) { result = sub_404600(*(_DWORD *)a1); *(_BYTE *)(a1 + 12) = 0; } return result; } </code></pre> <p>Since it does not know the type of <code>a1</code>, the accesses to its fields are represented as additions and casts.</p> <p>And here's the same function after the symbol file has been loaded:</p> <pre><code>void __thiscall mytree::write_page(mytree *this, PAGE *src) { if ( src-&gt;isChanged ) { cache::set_changed(this-&gt;cache, src-&gt;baseAddr); src-&gt;isChanged = 0; } } </code></pre> <p>You can see that it's been improved quite a lot.</p> <p>As for why decompiling bytecode is usually easier, in addition to NPE's answer check also <a href="http://stackoverflow.com/a/5160714/422797">this</a>.</p>
25,186,754
0
Magento Fatal error: Class 'Mage_Order_Helper_Data' not found <p>I must be over-thinking this issue, but I can't seem to resolve it. I need to overwrite the <strong>sendNewOrderEmail</strong> function of <strong>Mage_Sales_Model_Order</strong>. When I do this I lose my transactional email templates in the drop-down in the admin interface.</p> <p>Error:</p> <pre><code>Fatal error: Class 'Mage_Order_Helper_Data' not found </code></pre> <p>/app/code/local/Mine/Sales/etc/config.xml</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;config&gt; &lt;global&gt; &lt;models&gt; &lt;sales&gt; &lt;rewrite&gt; &lt;order&gt;Mine_Sales_Model_Order&lt;/order&gt; &lt;/rewrite&gt; &lt;/sales&gt; &lt;/models&gt; &lt;helpers&gt; &lt;sales&gt; &lt;class&gt;Mine_Sales_Helper&lt;/class&gt; &lt;/sales&gt; &lt;/helpers&gt; &lt;template&gt; &lt;email&gt; &lt;umicrosite_order_alert module="order"&gt; &lt;label&gt;Vendor Order Alert&lt;/label&gt; &lt;file&gt;umicrosite_order_alert.html&lt;/file&gt; &lt;type&gt;html&lt;/type&gt; &lt;/umicrosite_order_alert&gt; &lt;/email&gt; &lt;/template&gt; &lt;/global&gt; &lt;/config&gt; </code></pre> <p>/app/code/local/Mine/Model/Sales/Order.php</p> <pre><code>&lt;?php class Mine_Sales_Model_Order extends Mage_Sales_Model_Order { /** * Send email with order data * * @return Mage_Sales_Model_Order */ public function sendNewOrderEmail() { $storeId = $this-&gt;getStore()-&gt;getId(); $emailTemplate = Mage::getModel('core/email_template')-&gt;loadDefault('umicrosite_order_alert'); $emailTemplate-&gt;setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId)); $emailTemplate-&gt;setSenderEmail(Mage::getStoreConfig('trans_email/ident_sales/email')); $emailTemplate-&gt;setSenderName(Mage::getStoreConfig('trans_email/ident_sales/name')); $emailTemplate-&gt;setType('html'); $emailTemplate-&gt;setTemplateSubject('New Order from my store'); $emails = array(); foreach ($this-&gt;getItemsCollection() as $item) { $vendor = Mage::helper('udropship')-&gt;getVendor($item-&gt;getProduct()); $email = $vendor-&gt;getEmail(); if (!in_array($email,$emails)) { $emails[] = $email; $emailTemplateVariables = array(); $emailTemplateVariables = array('vendor_name'=&gt;$vendor-&gt;getVendorName()); $emailTemplate-&gt;send($email, $vendor-&gt;getVendorName(), $emailTemplateVariables); } } parent::sendNewOrderEmail(); } } </code></pre> <p>/app/code/local/Mine/Sales/Helper/Data.php</p> <pre><code>&lt;?php class Mine_Sales_Helper_Data extends Mage_Sales_Helper_Data { } </code></pre> <p>If I change my Data.php to:</p> <pre><code>class Mage_Order_Helper_Data extends Mage_Core_Helper_Abstract </code></pre> <p>It causes Class 'Mine_Sales_Helper_Data' not found.</p> <p>What am I doing wrong???</p>
4,496,251
0
What's a good way to integrate FB and Twitter into my commenting system (PHP) <p>There are so many options out there for integration. </p> <p>At the moment I have comments that are posted on my articles, where a user types in their name and the comment. This is then sent to a moderation queue and displayed when approved. </p> <p>I want to acheive this:</p> <ul> <li>Comment with facebook login (ie facebook account listed as the name w/ avatar)</li> <li>Comment with twitter login (ie twitter account name listed as the name w/ avatar) </li> <li>Push comment from my website to twitter and to facebook</li> </ul> <p>I could go down a few paths as far as I know:</p> <ul> <li>Integrate with XFBML, which I don't like because I find it annoying to setup and messy.</li> <li>Integrate facebook comments system, although this can't push to twitter, or allow me to moderate comments from my backend (as far as I can tell i'd have to login under the facebook login for the dev account to moderate the comment)</li> <li>Find a php class that does open auth and integrate with both face book and twitter at once</li> <li>find a pre-created php class </li> </ul> <p>Anyone have a solution that will bias:</p> <p>a. easy to integrate b. lightweight c. is free</p> <p>Thanks for your suggestions in advance.</p>
362,296
0
<p>Edited after reading Frans Bouma's answer, since my answer has been accepted and therefore moved to the top. Thanks, Frans.</p> <p>GUIDs do make a good unique value, however due to their complex nature they're not really human-readable, which can make support difficult. If you're going to use GUIDs you might want to consider doing some performance analysis on bulk data operations before you make your choice. Take into account that if your primary key is "clustered" then GUIDs are not appropriate.</p> <p>This is because a clustered index causes the rows to be physically re-ordered in the table on inserts/updates. Since GUIDs are random, every insert would require actual rows in the table to be moved to make way for the new row.</p> <p>Personally I like to have two "keys" on my data:</p> <p><strong>1) Primary key<br></strong> Unique, numeric values with a clustered primary key. This is my system's <em>internal</em> ID for each row, and is used to uniquely identify a row and in foreign keys.</p> <p>Identity can cause trouble if you're using database replication (SQL Server will add a "rowguid" column automatically for merge-replicated tables) because the identity seed is maintained per server instance, and you'd get duplicates.</p> <p><strong>2) External Key/External ID/Business ID<br></strong> Often it is also preferable to have the additional concept of an "external ID". This is often a character field with a unique constraint (possibly including another column e.g. customer identifier).</p> <p>This would be the value used by external interfaces and would be exposed to customers (who do not recognise your internal values). This "business ID" allows customers to refer to your data using values that mean something to them.</p>
20,751,202
0
Nested foreach statements... how to break out of child and continue parent if a match is found <p>I have an application that is passing a list of system printers to a PHP application. I am trying to set it up to ignore the printers that are basically just "software" printers. As you can see from the code below(which is by no means pretty). That I have an outer(parent) foreach that is looping through the printer list that is provided in a string that is delimited by a "pipe" symbol. Inside of that I have a second(child) foreach, that loops through a list of words that are common in the software printers names (i.e.. Adobe PDF would match the word "PDF")</p> <p>So my question is this, the parent loop works fine, the printers are inserted in the database from the string, however none of my attempts at filtering out the ones that match the keywords have been excluded. So How would you suggest going about breaking out of the "child" foreach to tell the parent to skip that loop?</p> <pre><code>&lt;?php // Set all QUEUE Printers to Unavailable, so we can reset as active only those that are present $SQL = "UPDATE `queues_printers` SET `status`='0' WHERE (`queue_id`='".$_GET['queue']."')"; $result = $mysqli-&gt;query($SQL); // Process Printers $ignore_names = array("PDF","OneNote","Fax","Microsoft XPS Document Writer","RemotePrinter"); $ignoreit=false; $today = date("Y-m-d"); // Get list from $_GET[printers] $printers = explode("|",base64_decode($_GET['printers'])); // Add/Update them foreach ($printers as $printer){ // Check if this printer is to be ignored(i.e.. pdf printers, fax software, and other software printers are not useful) foreach ($ignore_names as $ignored) { if($ignoreit === false){ if (strpos($printer,$ignored) === true) { $ignoreit = true; break; } } } if($ignoreit === true){ $ignoreit = false; continue; } // See if this is an existing printer and update it to available $SQL = "SELECT DISTINCT id FROM queues_printers WHERE queue_id = '".$_GET['queue']."' AND name = '".$printer."'"; $result = $mysqli-&gt;query($SQL); $row_cnt = $result-&gt;num_rows; if ($row_cnt &gt; '0'){ $printer_detail = $result-&gt;fetch_array(MYSQLI_ASSOC); $UpdateSQL = "UPDATE `queues_printers` SET `status`='1', `last_seen`='".$today."' WHERE (`id`='".$printer_detail["id"]."')"; $result2 = $mysqli-&gt;query($UpdateSQL); $result-&gt;close(); } else{ // Otherwise add it $InsertSQL = "INSERT INTO `queues_printers` (`queue_id`, `name`, `status`, `last_seen`) VALUES ('".$_GET['queue']."', '".$printer."', '1', '".$today."')"; $result2 = $mysqli-&gt;query($InsertSQL); } } $mysqli-&gt;close(); ?&gt; </code></pre>
21,159,987
0
<p>Your are starting activity <code>B</code> for result from activity <code>A</code></p> <pre><code>public void onClick(View v) { Intent intent = new Intent(A.this, B.class); startActivityForResult(intent,1); setResult(RESULT_OK); finish(); } </code></pre> <p>So activity <code>A</code> is expecting result to delivered by activity <code>B</code> when activity <code>B</code> finishes.</p> <p>Now, to get around this problem, start activity <code>B</code> in <code>onActivityResult()</code> method of the activity from which you started activity <code>A</code>.</p> <pre><code>// modified onClick method public void onClick(View v) { // simply set result to OK and finish activity A setResult(RESULT_OK); finish(); } </code></pre> <p>In the activity that starts activity <code>A</code>, define two constants or you can have a separate Java class to define constants and refer them in this class.</p> <pre><code>public static final int REQUEST_CODE_FOR_A = 100; public static final int REQUEST_CODE_FOR_B = 101; </code></pre> <p>Override the <code>onActivityResult()</code> method in the activity that starts activity <code>A</code> and start activity <code>B</code> as follows</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if(requestCode == REQUEST_CODE_FOR_A) { // start activity B when activity returns RESULT_OK Intent intent = new Intent(this, B.class); startActivityForResult(intent, REQUEST_CODE_FOR_B); } else if (requestCode == REQUEST_CODE_FOR_B) { // handle the result from Activity B } } } </code></pre> <p>Hope this helps.</p>
32,354,663
0
<p>You can get the notes from Feed end point.</p> <p>Get the feed.</p> <p><a href="https://graph.facebook.com/v2.0/YOURPAGEID/feed?access_token=TOKEN&amp;limit=250" rel="nofollow">https://graph.facebook.com/v2.0/YOURPAGEID/feed?access_token=TOKEN&amp;limit=250</a></p> <p>Find your note on your feed and use its ID.</p> <p><a href="https://graph.facebook.com/v2.0/FEED_ID_(NOTE_ID)/?access_token=TOKEN&amp;limit=250&amp;fields=attachments" rel="nofollow">https://graph.facebook.com/v2.0/FEED_ID_(NOTE_ID)/?access_token=TOKEN&amp;limit=250&amp;fields=attachments</a></p>
39,191,502
0
php links added to code <p>This code is from view-source in Chrome:</p> <pre><code>&lt;div class='pedSpouse'&gt;Relation med &lt;a class='familylink' file='157' pers='24351162'&gt;&lt;strong&gt;KARL EMRIK Jakobsson&lt;/strong&gt; f. 1897&lt;/div&gt;&lt;/div&gt;&lt;div&gt; &lt;img id='pedMore' src='cmn/prg/pics/hpil.png'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>In inspect the img is embedded within a copy of the previous a tag:</p> <pre><code>&lt;div&gt;&lt;a class='familylink' file='157' pers='24351162'&gt;&lt;img id='pedMore' src='cmn/prg/pics/hpil.png'&gt;&lt;/div&gt; </code></pre> <p>The same thing occurs in two other places. With other data the code is as expected.</p> <p>Same thing happens in Edge. I have no idea where the extra code comes from.</p>
20,955,706
0
JCL ICEMAN how many sort files are needed? <p>I am working with JCL and there is what is called an <strong><em>ICEMAN</em></strong> which is which is invoked when the IBM SORT utility DFSORT is used. DFSORT can be used to SORT, COPY or MERGE files, amongst other things. In the example below there the output is from a SORT. My question is how many sortwork (//<strong>SORTWK01</strong> DD UNIT=SYSDA,SPACE=(CYL,30)) files are needed. They seem to me to always vary in number when I see them in JCL. Is there a formula for this to figure the size of how many SORTWKnns are needed? </p> <p>JCL Code:</p> <pre><code>//STEP5 EXEC PGM=ICEMAN,COND=(4,LT) //SYSOUT DD SYSOUT=1 //SYSIN DD DSN=CDP.PARMLIB(cardnumberhere),DISP=SHR //SORTIN DD DSN=filename,DISP=SHR //SORTOUT DD DSN=filename,DISP=(OLD,KEEP), // DCB=(LRECL=5000,RECFM=FB), // SPACE=(CYL,30) //SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,30) //SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,30) //SORTWK03 DD UNIT=SYSDA,SPACE=(CYL,30) //SORTWK04 DD UNIT=SYSDA,SPACE=(CYL,30) </code></pre>
35,941,072
0
<p>If you want to save for example usersettings you could create <a href="https://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx" rel="nofollow">Settings </a>in your Properties.</p> <p>You can get them like this:</p> <pre><code>string anyProperty = WindowsFormsApplication1.Properties.Settings.Default.TestSetting; </code></pre> <p>You save them using the <code>Save</code>-method:</p> <pre><code>WindowsFormsApplication1.Properties.Settings.Default.TestSetting = "Hello World"; WindowsFormsApplication1.Properties.Settings.Default.Save(); </code></pre> <p>You can call the <code>Save</code>-method after you have clicked the close-button.</p> <p>For saving several string properties you could create a property of the type <code>System.Collections.Specialized.StringCollection</code>, so that you just create one property and not 21.</p>
36,693,052
0
Migrate large WordPress site <p>I need to export the current WordPress website data to my local machine. I know how to do this but i have a small problem and that's about the large amount of images in the <code>wp-content</code> folder. I only want to have the original images so i can generate the new sizes myself. Is there a good way to export and import the <code>wp-conten</code> files without all the extra image sizes? </p> <p>At this point when i do a export from the current website is doesn't include all the images when i import these and i get a lot of broken images.</p>
40,565,441
0
<p>You do not use arctan or <code>atan</code> to find an angle (except where explicitly demanded), but the argument function <code>arg(x+i*y)</code> usually found under <code>atan2(y,x)</code>.</p> <p>The angle around the origin between two points <code>a</code> and <code>b</code> can be found as </p> <pre><code>arg( (b.x+i*b.y)/(a.x+i*a.y) ) </code></pre> <p>or in real components</p> <pre><code>atan2(a.x*b.y-a.y*b.x, a.x*b.x + a.y*b.y) </code></pre>
38,000,800
0
NodeJS, Passport & Passport-Local <p>So I'm running into an issue authenticating using a local strategy. If I pass invalid credentials or anything unsuccessful, I get the appropriate error. However, if they authentication is successful, then I'm presented with a 404 error.</p> <p>I've dug around, and the best idea I ran across was dropping the session storage (which is where it seems to be happening, while serializing the user). Anyone encounter an issue like this?</p> <p>Here's some of the code, if you need any other sections of code, let me know I'll gladly provide it.</p> <p>My Passport configuration:</p> <pre><code>var passport = require('passport'), User = require('mongoose').model('User'); module.exports = function () { passport.serializeUser(function (user, done) { done(null, user.id); }); passport.deserializeUser(function (id, done) { User.findOne({ _id: id }, '-password -salt -__v', function (err, user) { done(err, user); }); }); require('./strategies/local')(); }; </code></pre> <p>My Local Strategy configuration:</p> <pre><code>var passport = require('passport'), LocalStrategy = require('passport-local').Strategy, User = require('mongoose').model('User'); module.exports = function () { passport.use(new LocalStrategy({ usernameField: 'email' }, function (email, password, done) { User.findOne({email: email}, function (err, user) { if (err) { return done(err); } if(!user || !user.active || !user.authenticate(password)) { return done(null, false, { message: 'Authentication Failed'}); } return done(null, user); }); })); }; </code></pre> <p>All other methods work, I can query the DB to find the user, I have stepped through matching the hashed password with the provided password, it all seems to happen fine and I get a user at the end of the LocalStrategy (I make it to the final <code>done(null, user)</code>. In the <code>serializeUser()</code> <code>done(null, user.id)</code> something happens. I've tried stepping through it, but what I end up getting into seems fairly obfuscated (or I'm too dumb to understand it) so I can't tell what's actually happening. </p>
8,821,665
0
<p>Try this for your jsfiddle:</p> <pre><code>function toggleMe(me) { var alreadyOpen = me.is(':visible'); jQuery('div[class^="content-"]').hide('fast'); if (!alreadyOpen) { me.show('slow'); } } jQuery('.expand-one').click(function() { toggleMe(jQuery('.content-one')); var img = $(this).find('img'), src = img.attr("src"), alt = img.data("altsrc"); img.attr("src", alt).data("altsrc", src); }); /// SECOND SESSION: ///////////////////////////////////////////////////////////////////////////////////// jQuery('.expand-two').click(function() { toggleMe(jQuery('.content-two')); var img = $(this).find('img'), src = img.attr("src"), alt = img.data("altsrc"); img.attr("src", alt).data("altsrc", src); }); </code></pre> <p>Hope this helps,</p> <p>Pete</p>
41,058,819
0
Photography or Continue Engineering <p>I'am a student of mechanical engineering,2 year in diploma.After 2 year I realize I'am not interested in engineering I love to capture nature photo I want to became photographer should I leave diploma and start photography course</p>
13,726,426
0
Web API Self hosting from a test assembly <p>I'm currently evaluating WebAPI and NancyFx for a new project about to start. I've managed to get Nancy to self host from a test assembly (by itself it uses asp.net hosting). </p> <p>Is there any way to do the same with Web API? I would like to keep the web api project hosted on IIS, but i would like to spin it up from my test assembly, so i can run tests against it. </p> <p>I have found some blogposts on how to use Autofac to scan controllers from another assembly (seems a little backwards only to get hosting from another assembly to work, but if it can be done, i guess that would be an option), but i would like to keep using Structuremap ioc for this project.</p>
5,475,103
0
<p>You're passing a list of entities to your <code>render_template</code> function instead of passing a dict. Try something like <code>utils.render_template(self, 'persons.html', {'persons': persons})</code></p>
35,847,078
0
<p>Reflection is rarely the correct answer to anything. Consider having your enum classes implement a common interface, like <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html" rel="nofollow">StandardCopyOption</a> and <a href="http://docs.oracle.com/javase/8/docs/api/java/time/Month.html" rel="nofollow">Month</a> do.</p> <p>If you can't modify the enum classes, and if you're using Java 8, you can pass the getter method as an argument:</p> <pre><code>public &lt;E extends Enum&lt;E&gt;&gt; E findMatch(Class&lt;E&gt; enumClass, Function&lt;E, String&gt; nameGetter, Predicate&lt;String&gt; matcher) { for (E value : EnumSet.allOf(enumClass)) { String name = nameGetter.apply(value); if (matcher.test(name)) { return value; } } return null; } </code></pre> <p>Example usage:</p> <pre><code>public static enum Season { SPRING("Spr"), SUMMER("Sum"), FALL("Fal"), WINTER("Win"); private final String abbreviation; private Season(String abbrev) { this.abbreviation = abbrev; } public getAbbreviation() { return abbreviation; } } public void doStuff() { // ... String abbrToFind = "Sum"; Season match = findMatch(Season.class, Season::getAbbreviation, Predicate.isEqual(abbrToFind)); } </code></pre> <p>If you're using a version older than Java 8, you can still do the same thing, but you'll need to define and implement the interfaces yourself:</p> <pre><code>public interface Function&lt;A, B&gt; { B apply(A input); } public interface Predicate&lt;T&gt; { boolean test(T value); } public void doStuff() { // ... final String abbrToFind = "Sum"; Season match = findMatch(Season.class, new Function&lt;Season, String&gt;() { @Override public String apply(Season season) { return season.getAbbreviation(), } }, new Predicate&lt;String&gt;() { @Override public boolean test(String name) { return Objects.equals(name, abbrToFind); } }); } </code></pre>
35,731,732
0
<p>Webjobs look for a Main function signature as an entry point by default. It's like your regular Console Aplication. If you put any <code>Console.Write</code> lines, it will output too.</p> <pre><code>public class Program { public static void Main(string[] args) { //your code... } } </code></pre> <p>Go to your <strong>WebApp blade</strong> > <strong>All Settings</strong> and scroll down, you should have a <strong>Webjobs</strong> item with your Webjob loaded, now double click on the link on the LOGS column:</p> <p><a href="https://i.stack.imgur.com/4WHaX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4WHaX.png" alt="enter image description here"></a></p> <p>Now, you should be able to Toggle Output and see the Console output of your webjob.</p> <p><a href="https://i.stack.imgur.com/XJSfn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XJSfn.png" alt="enter image description here"></a></p> <p>If there are any errors during execution, they should be there.</p> <p>If you <strong>can't get see the LOGS link</strong>, try opening the Tools section in the WebApp (top toolbar), scrolling to <strong>Kudu</strong> and Opening it.</p> <p><a href="https://i.stack.imgur.com/lgEDv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lgEDv.png" alt="enter image description here"></a></p> <p>Then go to the Tools > <strong>Webjobs Dashboard</strong>. Your job should be listed there.</p> <p><a href="https://i.stack.imgur.com/Apgm2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Apgm2.png" alt="enter image description here"></a></p> <p><strong>EDIT</strong></p> <p>After seeing the error reported, the problem is that the Azure environment is different than your computer. Google might be blocking the usage based on the access from an unknown origin. Check your <a href="https://www.google.com/settings/security/lesssecureapps" rel="nofollow noreferrer">Less secure settings</a> and try it with Off. If that fails, enable login in <a href="https://g.co/allowaccess" rel="nofollow noreferrer">from a different timezone</a>. Though I'd advice to use another services to send mail, like <a href="https://www.mailgun.com/" rel="nofollow noreferrer">MailGun</a> or <a href="https://sendgrid.com/windowsazure.html" rel="nofollow noreferrer">SendGrid</a>, even <a href="https://aws.amazon.com/ses/" rel="nofollow noreferrer">Amazon SES</a>.</p>
16,407,957
0
<p>In addition to what cygin points out (parameters seem reversed), <code>revStr</code> calls itself with a <em>smaller</em> value for <code>e</code>. But your description sounds like <code>e</code> is supposed to be less than or equal <code>k</code>. So then wouldn't you want to pass a <em>larger</em> value for <code>e</code>? Otherwise I don't see why you would ever reach <code>k</code>.</p> <p>As a side comment, I wonder why a substring function is named <code>revStr</code>.</p>
6,413,593
0
<p>None of those are even remotely good ideas, although the first one is passable with some modifications. <code>reinterpret_cast</code> doesn't work the way you think it does, and I'm not sure what exactly you're trying to achieve with placement new. Store a smart pointer of some sort in the first one to avoid the obvious issues with lifetime, and the first option isn't bad. </p> <p>There is a fourth option: just store the data in a struct, and provide whatever encapsulated access you desire.</p> <pre><code>struct data { data(int i_) : i(i_) { } int i; }; struct s { s(int i_) : i(i_) { } data i; }; </code></pre> <hr> <p>Rereading your question, it appears as though maybe your intent is for this struct to be an internal detail of some larger object. In that case, the lifetime issues with the first solution are likely taken care of, so storing a raw pointer is less of a bad idea. Absent additional details, though, I still recommend the fourth option.</p>
14,474,378
0
<p>It is bad practice to use null as id for your question I would use something like this</p> <pre><code>select * from post p1 where not exists (select 1 from comment c1 where c1.post_id = p1.id) union select * from post p2 where exists (select 1 from comment c1 where c1.post_id = p1.id and c2.user_id &lt;&gt; 124) </code></pre>
5,837,033
0
<p>Your logic seams correct to me. But I wonder about a possible problem with registering for a <code>UIKeyboardWillHideNotification</code> every time your <code>viewWillAppear</code>. Try to register only once in <code>viewDidLoad</code> and unsubscribe in <code>dealloc</code>. I am thinking that maybe when you register again after you dismiss the modal view the Notification Center sends you an old notification. If you register once for a notification you will not get it more then it is posted.</p>
26,239,435
0
<p>You need to use System.out.format. </p> <p>You can control the lengths of fields like this:</p> <pre><code>System.out.format("%32s%10d%16s", string1, int1, string2); </code></pre> <p>This pads string1, int1, and string2 to 32, 10, and 16 characters, respectively.</p> <p>See the Javadocs for java.util.Formatter for more information on the syntax (System.out.format uses a Formatter internally).</p> <p>Also, FYI, try overriding the ToString() method for the Player class and defining how you want this class to represent itself. This saves from having to have duplicate code and you can just say: </p> <p><code>p.ToString()</code></p> <p>and it will print out what it is (ID, name, club, goals).</p>
12,532,514
0
<p>I'm thinking that since <code>window.location</code> is a host object, it does not obey "native" JS object semantics, and that's why you're having problems doing the same thing for <code>location</code> as you did with <code>foo</code>.</p> <p><a href="http://jibbering.com/faq/#nativeObject" rel="nofollow">http://jibbering.com/faq/#nativeObject</a></p>
34,280,807
0
My executable ruby gems don't work as expected <p>I followed this tutorial <a href="http://guides.rubygems.org/make-your-own-gem" rel="nofollow">http://guides.rubygems.org/make-your-own-gem</a> to figure out how to create ruby gems but I'm having trouble figuring out how to create an executable. </p> <p>I originally thought I was making a mistake in my own code but the actual gem created with the tutorial itself doesn't seem to work as I expected. So I'll base my question around the actual gem from the tutorial itself.</p> <p>If you bundle the exact gem from the tutorial (the gem is named <code>hola</code>) into a rails application and try to use the executable command <code>hola</code>, all you get are error messages:</p> <pre><code>$ rails hola spanish # =&gt; Error: Command 'hola' not recognized $ ruby hola spanish # =&gt; ruby: No such file or directory -- hola (LoadError) $ hola spanish # =&gt; -bash: hola: command not found </code></pre> <p>Even if I attempt to execute the command this way it doesn't seem to work:</p> <pre><code>$ ruby -Ilib ./bin/hola spanish # =&gt; ruby: No such file or directory -- ./bin/hola (LoadError) </code></pre> <p>The only time this seems to execute anything is when I'm inside the actual gem directory recreated by hand in the tutorial and type this:</p> <pre><code>$ ruby -Ilib ./bin/hola spanish # =&gt; hola mundo </code></pre> <p>But this is useless because the whole point of creating an executable is to be able to execute it within an actual project not the gem directory (ie: someone downloading your gem and being able to use it with a single executable keyword, like <code>rake routes</code> which then does something).</p> <p>Can I bundle the <code>hola</code> gem from this official rubygems.org tutorial and use it as an executable in the way I was expecting to execute it, like this:</p> <pre><code>$ hola spanish # =&gt; hola mundo </code></pre> <p>If this is possible, how is it done?</p>
35,533,513
0
Highlight Google map marker when Image comes in Viewport of DIV scroll <p>Below is Image listing done using ng-repeat.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="data" ng-repeat = "image in images"&gt; &lt;div class="category"&gt; &lt;a href="#" class="thumbnail"&gt; &lt;img ng-src="images/{{happyning.image}}" /&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>and I have Google map loaded with all the Marks based on these entries. Now what I want is to highlight the specific Google Map marker when an Image is fully visible in screen/viewport (I have laded these image listing in DIV).</p> <p>Thanks- Abhishek</p>
37,174,975
0
<p>I had a similar problem and I solved it so:</p> <p>When adding Refresh Controller on View Controller it is necessary to write the following code:</p> <pre><code>dispatch_async(dispatch_get_main_queue()) { self.refreshControl.beginRefreshing() self.refreshControl.endRefreshing() } </code></pre>
23,170,845
0
Copy to ouput directory doesn't work like I thought <p>This question is probably asked thousand times, but no answer helped me. I added a XML file to my project and wanted it to be copied into the output directory when I debug/build the project. So I set "Copy to ouput directory" to "Copy always", but Visual Studio/Compiler doesn't copy the file into the output directory. <strong>How can I make Visual Studio copy the file into the output directory when I debug/build?</strong></p> <p><img src="https://i.stack.imgur.com/oDYS0.png" alt="Screenshot of my project"></p>
16,978,547
0
<p>There are a few of things I can see to improve this</p> <ul> <li>Before looping, check if the substring is 0 length, if so return false (dont check every iteration)</li> <li>Remove <strong>ALL</strong> <code>== true</code>'s its basically comparing a boolean against a boolean</li> <li>Use <a href="http://msdn.microsoft.com/en-us/library/k8b1470s.aspx" rel="nofollow">IndexOf</a> to find the first character of your substring (return false if result of indexOf is -1) and then use this index as the starting value for i</li> <li><p>I believe instead of the <code>j</code> variable you can just increment <code>i</code> but I've not tested this</p> <pre><code>if (FoundMatch) return true; </code></pre></li> </ul>
34,894,570
0
Pure virtual function which must set variable <p>recently i have read some about pure virtual function concept in c++ and i wonder, given following code:</p> <pre><code>class First { public: virtual void init() = 0; protected: bool initialized; }; class Second : public First { public: void init() { ((*someting*) ? (initialized=true) : (initialized=false)); }; </code></pre> <p>if creator of <code>First</code> class wanted to ensure the implementation of <code>init()</code> MUST set <code>initialized</code> variable either true or false how can they do that? Is there an option to enforce implementation of pure virtual function to set any variable inherited from base class?</p>
30,109,348
0
<p>If you are using Chrome, you should use the "Timeline" to record the memory usage. Launch the timeline, then wait for the page to refresh a few times, and then stop the timeline and have a look at the results. If you see the line keeping increasing, that means your objects in memory (or the DOM nodes) are never released and garbage collected.</p> <p>I have never used <code>document.open/write</code> myself so I do not know if that can cause issues with garbage collection, but I suspect it does.</p> <p>If your detect clearly a memory lak using the Timeline, then open the "Profiles" tab and take a Heat snapshot before and after a page reload, then use "comparison" to see what have changed and how much bigger your memory impact is. If for instance your old compiled code (or obejct references) is still there, plus the new one, then it explains your leak.</p>
13,300,071
0
<p>You should not place the outlet in the Application Delegate. Your app should contain a root view controller (created automatically if you're using a single view application template), which should handle anything related to the application's initial view. Once you have one, open the storyboard in the editor. Open an assistant editor using the buttons along the top, and use the drop-down menu at the top of the assistant editor to open up the header file of the controller. Select the scroll view, and control-drag from it into the controller's interface. Xcode will prompt you to make an outlet, allowing you to change the name. Let's use <code>scrollView</code> for the name. Select <code>weak</code> for the memory management, since it's already being retained by its superview. Xcode should automatically synthesize accessors, and now you can access the property using <code>self.scrollView</code> from within the controller's instance methods. Alternatively, you can select the scroll view and set its tag in the attributes inspector to any unique number, like 4. Then, you can use <code>[self.view viewWithTag:4]</code> to get a reference to it.</p>
3,390,711
0
Start new activity from onClickListener <p>I have an EditText area that is not showing due to the keyboard covering it when the focus is on the EditText area. What I want to do is use a button to call an activity that will display a editable text area that overlays the main display and returns the value to the main activity which stores it in a separate class variable. </p> <p>I added the activity to the main manifest xml. </p> <p>I added an onClickListener to a button. </p> <p>Here is some code:</p> <p>TextEntryActivity class:</p> <pre><code>public class TextEntryActivity extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.text_entry); EditText edit = (EditText)findViewById(R.id.editable); getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); } </code></pre> <p>}</p> <p>I have a separate XML file for the layout of the blurr.</p> <p>Originally I had an onClickListerner for an onSave button that stored all the info:</p> <pre><code> private View.OnClickListener onSave = new View.OnClickListener() { @Override public void onClick(View v) { Log.d(DEB_TAG, "INSIDE ONCLICK"); mCurrent = new Restaurant(); mCurrent.setName(mName.getText().toString()); mCurrent.setAddr(mAddr.getText().toString()); mCurrent.setDate(mDateDisplay.getText().toString()); mCurrent.setNotes(mNotes.getText().toString()); switch (mTypes.getCheckedRadioButtonId()){ case R.id.fast_food: mCurrent.setType("fast_food"); break;......... </code></pre> <p>The new activity is to provide a different view to add a "note"</p> <p>Does this make sense? I am fairly new to this and know what I want to do in my head, but describing it can be a challenge.</p>
17,871,222
0
<p>I assume you are running Ubuntu as production server. On your server you need to edit your <code>sudoers</code> file:</p> <p>First type <code>select-editor</code> and select nano (or another editor you feel confortable with)</p> <p>Then at the bottom of the file, before the <code>include</code> line, add this line: </p> <pre><code>%deployer ALL=(ALL)NOPASSWD:/path/to/your/unicorn_rails </code></pre> <p>You need to replace <code>deployer</code> by the user name you are using with capistrano, and to replace <code>/path/to/your/unicorn_rails</code> with its correct path. This will allow your deployer user to "sudo unicorn_rails" without being prompt for a password.</p> <p>Finally edit your <code>unicorn:start</code> capistrano task, and add <code>rvmsudo</code> ahead of your command line that start unicorn:</p> <pre><code>rvmsudo unicorn_rails -c config/unicorn/production.rb -D --env production </code></pre> <p>If it does not work you can try this instead</p> <pre><code>bundle exec sudo unicorn_rails -c config/unicorn/production.rb -D --env production </code></pre>
6,325,379
0
<p>Use a server-side language like PHP w/MySQL to write a text file or XML file that Flash can understand. in turn, when sending variables use ActionScript to send the variables to a PHP form parser that loads it to the server.</p> <p>I don't have any examples to show you right now, but that would certainly be a workaround to getting FlashCon or some other product, and you can get started right away. Check out some XML and PHP code sites -- you'll probably run into someone who has already solved your problem.</p>
26,790,364
0
<p>In C++, there is no type "string". Try to use container class std::string with <code>&lt;string&gt;</code> header.</p>
16,870,247
1
Is there an open source spider/crawler that supports build-in javascript execution <p>Nowadays most of web pages contain javascript, but I don't find any open source spider that supports build-in javascript execution.</p> <p>Is there such one crawler?</p>
24,671,557
0
<p>Try using <code>GNU Parallel</code> like this... it will split <code>file.xml</code> into chunks of 1MB (or thereabouts on nearest new line) and pass each chunk to one CPU core to run <code>grep</code>, so not only should it work, but it should work faster too:</p> <pre><code>parallel --pipe grep -o xmltag &lt; file.xml | wc -l </code></pre>
3,823,662
0
Changing Inherited Types in Entity Framework <p>I see there is a similar question asked here but I don't think it was very clear so I'm creating another : <a href="http://stackoverflow.com/questions/1239504/entity-framework-inheritance-change-object-type">http://stackoverflow.com/questions/1239504/entity-framework-inheritance-change-object-type</a></p> <p>I have an Entity Student that inherits from an Entity Person.</p> <p>At some point a Person could become a Student.</p> <p>Is there any way in Entity Framework 4 to handle this without a stored procedure or creating a new entity.</p>
25,695,061
0
<p>change <code>.profileList</code> to this:</p> <pre><code>.profileList { display: inline-block; width: 50%; vertical-align:top; } </code></pre> <p>when you use <code>inline-block</code>, you need to give it the desired vertical align, since the default is <code>baseline</code></p>
16,893,364
0
<p>Using matplotlib to export to TIFF will use PIL anyway. As far as I know, matplotlib has native support only for PNG, and uses PIL to convert to other file formats. So when you are using matplotlib to export to TIFF, you can use PIL immediately.</p>
8,196,392
0
<p>the checkbox isen't centerd it has just a width of 200px because you set the width of all input elements to 200px.</p> <p>so thats why you should specify your input which you wana be 200px width: <code>input[type="text"]</code></p> <p>Example: <a href="http://jsfiddle.net/sY9Fa/1/" rel="nofollow">http://jsfiddle.net/sY9Fa/1/</a></p>
26,508,675
0
<p>One problem that I saw : It won't work if you choose : <code>GridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;</code></p>
27,040,980
0
<p>The one underlined in red is App Display Name which may be in localized.strings as set in the info.plist. The blue underlined name is the product name, as set in the build settings.</p>
10,473,155
0
<p>Rather than using a timer to remove a user, I would use a more conventional approach of having an expiration time for the user (or perhaps their password). That is, when they first register, assign an expiration for 15 minutes after the present time (e.g. in a column <code>ExpirationDate</code> in the user table). In your authentication process, the logic should validate that the user's ID has not expired. </p> <p>The problem with using a timer is that many things can go wrong. For example, if your application restarts, any active timers will be lost. It's very brittle. It's also kind of using a hammer to kill a fly. It's not necessary to ensure that someone's user record is removed immediately from the database after 15 minutes. It's only necessary to make sure they can't authenticate after that time. So make the design match the business purpose in the easiest possible way. If you really want to delete records (rather than, say, give them a chance to try again after resetting a password or something) then you can do this with some external maintenance process.</p>
4,854,835
0
<p>My suspicion is that your Linux VM may be thrashing to swap space.</p> <p>Virtual machines are often limited in their allotted RAM. Have you checked whether it's run out? The 'top' command is useful for this. </p> <p>If you're not familiar with 'top', the upper part of its screen shows general memory and CPU use statistics, which may immediately answer your problem. The worst CPU hogs will be at the head of the processes list that takes up the rest of the screen.</p> <p>If you hit '?' whilst it's running, it'll show you the options to sort the process list: you may want to sort it by memory use (either virtual or hard).</p>
19,123,554
0
<p>Go to <code>config.php</code> and replace <code>localhost</code> in :</p> <pre><code>$CFG-&gt;wwwroot = 'http://localhost'; </code></pre> <p>With your server's external IP. </p>
26,493,128
0
clearInterval isn't functioning properly <p>This is my code that auto adds a certain amount "points" or gold every second depending a varable but when that variable variable changes which is done by a button that runs this command to stop the set Interval isn't functioning. Please help me figure this out.</p> <pre><code>function addMiner() { clearInterval(autoClick) if (localStorage.getItem('minercount') &gt; 0) { var autoClick = setInterval(function() { miner() }, 1000); document.getElementById("goldNumber").innerHTML = localStorage.getItem('clickcount'); } } </code></pre>
32,197,731
0
Is it possible define one-to-many relation in Sql Server and just define and use one side of this relation in entity code first <p>If I defined one-to-many relation foreign-key constraints in Sql Server, Is it possible just define and use it in code-first class definitions in one side? For example suppose I have Library and Book classes. Each Library can has many books but each book belong to one library.</p> <pre><code>public class Book { public Book() { } public int BookId { get; set; } public string BookName { get; set; } public virtual Library Library { get; set; } } public class Library { public Library() { } public int LibraryId { get; set; } public virtual ICollection&lt;Book&gt; Books { get; set; } } </code></pre> <p>If I want always just use this relation from Book side,Can I don't define below line in Library class definition?</p> <pre><code>public virtual ICollection&lt;Book&gt; Books { get; set; } </code></pre>
31,419,952
1
Adding 2 data frame in python pandas <p>I want to combine 2 seperate data frame of the following shape in Python Pandas:</p> <pre><code>Df1= A B 1 1 2 2 3 4 3 5 6 Df2 = C D 1 a b 2 c d 3 e f </code></pre> <p>I want to have as follows:</p> <pre><code>df = A B C D 1 1 2 a b 2 3 4 c d 3 5 6 e f </code></pre> <p>I am using the following code:</p> <pre><code>dat = df1.join(df2) </code></pre> <p>But problem is that, In my actual data frame there are more than 2 Million rows and for that it takes too long time and consumes huge memory.</p> <p>Is there any way to do it faster and memory efficient?</p> <p>Thank you in advance for helping.</p>
31,588,927
0
<blockquote> <p>I got to thinking about when I should await things</p> </blockquote> <p>It's better to always await the result from asynch calls.</p> <p>If you don't await, you <strong>fire &amp; forget</strong>, you don't receive response on your end in both success and error cases.</p>
31,832,599
0
Future failure in Clojure <p>In Scala a future can fail and this can be found out asynchronously:</p> <pre><code>f onComplete { case Success(_) =&gt; println("Great!") case Failure(t) =&gt; println("An error has occurred: " + t.getMessage) } </code></pre> <p>How would you 'translate' this into Clojure? My reading leads me to believe that the Clojure future/promise model is not as powerful as Scala's, and you can't just catch the failure like this. So what to do instead? </p> <p>A Scala future never needs to be asked for it's value - when it is good and ready it will tell you what happened (including whether it failed - that's the crux of this question). This is what I meant by 'asynchronously'. A Scala future can be in one of three possible states - uncompleted, completed with failure, completed with success.</p> <p>A typical example of a use case in Scala is a remote call that returns a Future[T], where T is the type of what you really want to get back. If the remote JVM is down then after a timeout the <code>case Failure(t)</code> will happen.</p> <p>This is quite a straightforward model to work with. In the question I was asking for a simple alternative. As a side-comment it would be good to hear that Clojure intends to adopt the Scala Futures model at some point.</p>
4,668,515
0
Problem in eclipse configuring tomcat <p>I have trouble when I want to configure eclipse. This error appears, but I dont know where is my problem. I copied <code>apache-tomcat-7.0.5</code> folder in <code>E:\Java</code> folder, where is java installed.</p> <blockquote> <p>Tomcat requires a Java SDK in order to compile JSP files. Ensure that the JRE preference settings point to an SDK install location.</p> </blockquote>
13,324,734
0
<p>Try this:</p> <pre><code>button(:id =&gt; 'submitEnrollmentCmdButtonId').click </code></pre>
33,675,403
1
pandas python inserting part of a column to a column based on conditions pandas python <p>i have a large dataset that i want to work with , but here i am using a mock dataset:</p> <pre><code>data = {'Block': [1, 1, 1, 1, 1, 1,1,1,1], 'Concentration': [100, 100, 100, 33, 33, 33, 0,0,0], 'Name' : ['A', 'A', 'A', 'A', 'A', 'A', 'PB', 'PB', 'PB'], 'value': [86, 194, 452, 140, 285, 2011, 100, 111, 222 ]} data = DataFrame(data) </code></pre> <p>looks like this:</p> <pre><code>In [12]: data Out[12]: Block Concentration Name value 0 1 100 A 86 1 1 100 A 194 2 1 100 A 452 3 1 33 A 140 4 1 33 A 285 5 1 33 A 2011 6 1 0 PB 100 7 1 0 PB 111 8 1 0 PB 222 </code></pre> <p><strong>there are a total of 24 Blocks, 3 types of concentrations and 5 Names for each Block.</strong> </p> <p>i want for each block to add 3 new '0' concentrations for each Name other than the name 'PB', and then append the values from 'PB' to the newly added '0' concentrations. </p> <p>for the mock dataset here the desired output would be:</p> <pre><code>In [13]: data2 Out[13]: Block Concentration Name value 0 1 100 A 86 1 1 100 A 194 2 1 100 A 452 3 1 33 A 140 4 1 33 A 285 5 1 33 A 2011 6 1 0 A 100 7 1 0 A 111 8 1 0 A 222 9 1 0 PB 100 10 1 0 PB 111 11 1 0 PB 222 </code></pre> <p>my code so far , im able to grab out only the 'PB' rows for each block:</p> <pre><code>def PBvalue(sgrp): PBvalue = sgrp.loc[data['Name']=='PB'].copy() return PBvalue PBvalues = data.groupby(['Block', 'Concentration']).apply(PBvalue) </code></pre> <p>output:</p> <pre><code>In [30]: PBvalues Out[30]: Block Concentration Name value Block Concentration 1 0 6 1 0 PB 100 7 1 0 PB 111 8 1 0 PB 222 </code></pre>
34,223,229
0
<p>Your current approach is very inefficient - it's O(N * M) <em>and</em> it creates a list on each iteration.</p> <p>Using a join would be more efficient - I would still use a <code>foreach</code> loop, but separate the querying part from the update part:</p> <pre><code>var pairsToUpdate = from original in vmlist join item in vlist on new { original.SId, original.ParameterId, original.WId } equals new { item.SId, item.ParameterId, item.WId } select new { original, item }; foreach (var pair in pairsToUpdate) { pair.original.Value = pair.item.Value; } </code></pre> <ul> <li>No abuse of <code>Select</code> with side-effects</li> <li>No extra lists created for no good reason</li> <li>More efficient selection of items to update</li> </ul>