pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
25,609,357 | 0 | windows ce application can't connect to sql azure <p>when a try to connect to sql azure database from windows ce application show "sql server requires encryption on" </p> <p>i try adding device ip to sql azure firewall and i had used "encrypt=true" in connection string but not works, shows "unknown connection option in connection string encrypt"</p> <p>i suspect that is necessary an ssl connection but i don't know how make it</p> <p>when i try to make a desktop test it work perfectly</p> <p>im using -visual studio 2008 - windows ce 05 - sql azure</p> <p>many thanks</p> <p>Alejandro</p> |
3,901,838 | 0 | <p>Usually, attaching a debugger would not slow down an application too much (compared to starting the application from the debugger, which will set the heap in debug mode).</p> <p>But by default, the debugger will trace events (exceptions and OutputDebugString), and in your case, there may be too much of them. After attaching with the debugger, you can disable all exception handling. (Menu Debug/Event Filters, or command sxi). You have to change the handling for all events (<code>sxi *</code> means unknown events, and does not apply to all events). You can also disable all tracing with <code>.outmask-0xFFFFFFFF</code>. Then enable only the stack overflow event with <code>sxe -c ".outmask /d" sov</code></p> |
13,494,953 | 0 | <p>The reason for the result you see is the comparison operator you use. == is too imprecise sometimes and can result in wierd things like this. Using the === will compare the values for exactness and will prevent the issue you have.</p> <p>so: </p> <pre><code>foreach ($arr as $k=>$v) { // this is the important thing if ($k === "thispage") { echo $k." "; } else { echo '<a href="'.$v.'">'.$k.'</a> '; } } </code></pre> |
22,377,361 | 0 | <p>If you are binding your DataGridView through code that is, using <code>DataSource</code> property you can clear DataGridView using the following code.</p> <p><code>dataGridView1.DataSource=null;</code></p> <p>It will not delete data from your database,just clear your DataGridView.</p> |
21,995,652 | 0 | <p>This happens to me sometimes. In the Debug Perspective there is a breakpoints tab. Even if breakpoints have become invisible in the editor, they are probable visible in that list. So you can safely remove the breakpoints that you want to get rid off.</p> |
10,518,402 | 0 | Validation with exceptions vs IDataErrorInfo and the new INotifyDataErrorInfo <p>I'm trying out different ways of validating and I'm having a problem with the new INotifyDataErrorInfo-interface.</p> <p>When writing in for instance a bound textbox that only accepts 10 chars. I write 11 chars and tab out. The validation kicks in and marks the textbox red etc. Now, I don't want to write this invalid value down to the source of this binding, but if I'm not doing this I immediately get the value in the textbox reset to the last valid value. It's as if the binding does an UpdateTarget on it's binding even though there was an error.</p> <p>By using ValidatesOnExceptions and throwing exception in the setter I get the behaviour I'm after. The binding is not updating it's value from the source if an exceptions has been thrown in the setter. This leaves the invalid value in the textbox so that I can work with it to make it valid. I think this is far better than having to store the invalid value in the underlying object.</p> <p>The question is why IDataErrorInfo and the new INotifyDataErrorInfo behaves in this way that it updates target from source even though there were errors? Can I make it to behave more like ValidatesOnExceptions?</p> <p>I need INotifyDataErrorInfo because of other features such as async validation...</p> |
37,251,354 | 0 | <p>You can do it easily with custom directory of your Models Folder (I assume Models Folder is sub folder of App). Just use this command <code>php artisan make:model Models/core</code> then you will get your desire result.<br> Thanks.</p> |
4,945,275 | 0 | <p>Something like this?</p> <pre><code>select a.col1, a.col2, a.col3, b.colC from ( select row_number() over (partition by col1, col2 order by 1) r, col1, col2 from table1 ) a, ( select row_number() over (partition by col1, col2 order by 1) r, col1, col2 from table2 ) b where a.r = b.r and a.col1 = b.col1 and a.col2 = b.col2; </code></pre> |
32,522,176 | 0 | No Scroll bar appears when I run my site through a browser with my slide out menu position set to fixed <p>I have just started coding websites. I just recently started a website for a friend and though it would be cool to have a slide out menu that slide out from the top rather than the left or right of the page. However having done so and got it to work and all then having added some other content to the page have found that I am unable to get a scroll bar when processed through a browser. I have tried in the body tag, "overflow;scroll" which did not work and I have tried adding a div with the height of 3000px</p> <p>Pls if anyone can help that will be great I will attach all my css and html (take note there is some jQuery and java)</p> <p>Thanks</p> <p>HTML & Java</p> <pre><code><!doctype html> <html> <head> <meta charset="utf-8"> <title>Josh Site</title> <link rel="stylesheet" type="text/css" href="../CSS/index.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="../jQuery/jquery.cycle2.min.js"></script> <script src="../jQuery/jquery.cycle2.video.js"></script> <script src="../jQuery/jquery.cycle2.carousel.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <!--Skeleton for Slide out Menu--> <body class="menu menu-open"> <header> <nav class="menu-side"> <!--Content for Menu Side--> <ul> <li><a href="#"></a>Item 1</li> <li><a href="#"></a>Item 2</li> <li id="logo"><img src="../../Assets/Josh-Logo.png" alt="Josh Meyers"></li> <li><a href="#"></a>Item 3</li> <li><a href="#"></a>Item 4</li> </ul> <!--End of Content for Menu Side--> </nav> </header> <!--End of Skeleton for Slide out Menu--> <!--Button to Toggle "Menu Side"--> <a href="#" class="menu-toggle"><img src="../../Assets/top-menu-icon.png" width="50px" height="50px" alt=""/></a> <!--End of Button to Toggle "Menu Side"--> <!--Josh Meyers about and Title--> <div id="Josh-Meyers"> <h1>Josh Meyers</h1> <p>Photography is the science, art and practice of creating durable images by recording light or other electromagnetic radiation, either electronically by means of an image sensor, or chemically by means of a light-sensitive material such as photographic film.[1] Typically, a lens is used to focus the light reflected or emitted from objects into a real image on the light-sensitive surface inside a camera during a timed exposure. With an electronic image sensor, this produces an electrical charge at each pixel, which is electronically processed and stored in a digital image file for subsequent display or processing. The result with photographic emulsion is an invisible latent image, which is later chemically "developed" into a visible image, either negative or positive depending on the purpose of the photographic material and the method of processing. A negative image on film is traditionally used to photographically create a positive image on a paper base, known as a print, either by using an enlarger or by contact printing. </p> </div> <!--Responsive Video Slider and Title--> <div id="Recent-Projects"> <h1>Recent Projects</h1> </div> <div id="video-wrapper"> <span class="cycle-prev">&#9001</span> <span class="cycle-next">&#9002</span> <div class="cycle-slideshow" data-cycle-carousel-visible="3" data-cycle-fx="carousel" data-cycle-timeout="0" data-cycle-auto-height="640:360" data-cycle-prev=".cycle-prev" data-cycle-next=".cycle-next" data-cycle-slides=">iframe" data-cycle-youtube="true" data-cycle-youtube-autostart="true" data-cycle-pager=".cycle-pager" data-cycle-carousel-fluid="true" > <iframe width="560" height="315" src="https://www.youtube.com/embed/7TccWhZ6T8c?rel=0" frameborder="0" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/VPuKbzP2KNM?rel=0" frameborder="0" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/DHW0hQHLpTc?rel=0" frameborder="0" allowfullscreen></iframe> </div> <div class="cycle-pager"></div> </div> <!--End Responsive Video Slider and Title--> <script> (function() { var body = $('body'); $('.menu-toggle').bind('click', function() { body.toggleClass('menu-open', 'toggle-open'); return false; }); })(); </script> </code></pre> <p></p> <p> </p> <p>CSS</p> <pre><code>body { background-color:black; overflow:scroll; } /*Design for Slide Down menu*/ .menu { overflow:hidden; position:relative; top:0px; -webkit-transition: top 0.8s ease; -moz-transition: top 0.8s ease; transition: top 0.8s ease; } .menu-open { top:231px; } .menu-open .menu-side { top:0px; } .menu-side { background-color:#333; border-bottom:1px solid #000; color:#fff; position:fixed; top:-231px; left:0px; width: 100%; max-width:100%; height: 210px; padding: 10px; -webkit-transition: top 0.8s ease; -moz-transition: top 0.8s ease; transition: top 0.8s ease; } .menu-toggle { position:relative; display:block; width:50px; height:50px; margin-left:auto; margin-right:auto; top:-23.5px; } /*Content style for Menu Side*/ .menu-side ul { width:800px; max-width:100%; height:100px; display:block; text-align:center; margin-left:auto; margin-right:auto; border-style:solid; border-color:white; border-width:thick; -moz-box-shadow:20px 20px 20px 10px black; -webkit-box-shadow:10px 10px 10px 10px 10px black; box-shadow:1px 1px 20px 0.5px black; } .menu-side li { margin-top:auto; margin-bottom:auto; padding:10px; display:inline-block; text-align:center; font-family:Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif; font-size:18px; font-style:italic; } /*Style for Josh Meyers About*/ #Josh-Meyers h1 { text-align:center; color:#FFF; } #Josh-Meyers p { color:#FFF; } /*Style for Video Slide Show and Title*/ #Recent-Projects { text-align:center; height:40px; width:100%; max-width:100%; } #Recent-Projects h1 { text-align:center; color:#FFF; } iframe {max-width:100%} #video-wrapper { width:100%; max-width:100%; height:400px; margin-top:5px; } .cycle-slideshow { width:100%; top:2%; margin-left:auto; max-width:90%; margin-right:auto; } .cycle-prev, .cycle-next { font-size:40px; font-weight:bold; color:#FFF; display:block; position:absolute; top:60%; z-index:999; cursor:pointer; } .cycle-prev {left:2%;} .cycle-next {right:2%;} .cycle-pager { text-align: center; width: 100%; z-index: 999; position: absolute; overflow: hidden; top:85% } .cycle-pager span { font-family: arial; font-size: 50px; width: 16px; height: 16px; display: inline-block; color: #ddd; cursor: pointer; } .cycle-pager span.cycle-pager-active { color: #D69746;} .cycle-pager > * { cursor: pointer;} iframe { padding-left:5px; padding-right:5px; } </code></pre> |
6,756,061 | 0 | Yet another EXC_BAD_ACCESS - However with zombie (instruments), never exe_bad_access <p>I have spent hours on this and read everybit on the web about memory management, zombies. leaks (tried instruments). But I cannot figure this one out. Does someone has a clue? I am getting a EXC_BAD_ACCESS at the following like of code on popping the ChildViewController.</p> <pre><code>[profileVO release]; profileVO = nil; </code></pre> <p>I strongly feel I have followed all memory management best practices!</p> <p><strong>Details:</strong></p> <p>I have a model file. (CachedProfileVO)</p> <p><strong>CachedProfileVO.h</strong></p> <pre><code>@interface CachedProfileVO : NSObject { NSString *name; NSString *email; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *email; @end </code></pre> <p><strong>CachedProfileVO.m</strong></p> <pre><code>@synthesize name, email; - (void) dealloc { [super dealloc]; [name release]; name= nil; [email release]; email = nil; } </code></pre> <p>Now I have a UINavigationController. The ParentViewController and the ChildViewController. I invoke the ChildViewController as follows:</p> <pre><code>[self.navigationCntroller pushViewcontroller:childViewcontroller animated:YES]; </code></pre> <p>In the ChildViewController, I basically use the model CachedProfileVO. However when this view controller is popped (back button on UI), it gives a EXC_BAD_ACCESS</p> <p><strong>ChildViewController.h</strong></p> <pre><code>@interface ChildViewcontroller : UITableViewController { CachedProfileVO *profileVO; } @property (nonatomic, retain) CachedProfileVO *profileVO; @end </code></pre> <p><strong>ChildViewController.m</strong></p> <pre><code>@synthesize profileVO; - (void) dealloc { [super dealloc]; [profileVO release]; profileVO = nil; ****** GETTING EXE_BAD_ACCESS here } - (void) viewDidLoad { CachedProfileVO *vo = [CachedProfileVO alloc] init]; self.profileVO = vo; [vo release]; } //responseString looks like this: [Murdoch, [email protected]][other data][more data] - (void) populateProfile:(NSString *) responseString { NSMutableString *str = [[NSMutableString alloc] initWithCapacity:20]; [str setString:responseString]; [str deleteCharactersInRange: NSMakeRange(0,1)]; [str deleteCharactersInRange: NSMakeRange([str length]-1,1)]; NSArray *tempArray = [str componentsSeparatedByString: @"]["]; NSString *tempStr = (NSString*)[tempArray objectAtIndex:0]; NSArray *bioArray = [tempStr componentsSeparatedByString:@","]; self.profileVO.name = (NSString*)[bioArray objectAtIndex:0]; self.profileVO.email= (NSString*)[bioArray objectAtIndex:1]; [str release]; str = nil; } </code></pre> <p>Note that the function populateProfile is called after some event. I know it is called. And dealloc then causes the problem. Also this does not happen in every pop. I have to try several times to reproduce. It is never reproduced using zombies in instruments!!!</p> |
6,533,588 | 0 | <p>Try to change your classes like this:</p> <pre><code>class root { public root() { } public studentinfo studentinfo { get; set; } } class studentinfo { public studentinfo() { subject = new List<subject>(); } public string name { get; set; } public int age { get; set; } public string gender { get; set; } public address address; public List<subject> subject; } class address { public string street { get; set; } public string city { get; set; } public string state { get; set; } } class subject { public string name { get; set; } public int marks { get; set; } public string grade { get; set; } } </code></pre> <p>and there's an error with your JSON</p> <pre><code>'gender':male, </code></pre> <p>should be</p> <pre><code> 'gender': 'male', </code></pre> |
8,144,338 | 0 | <p>Windows batch files don't execute themselves IIRC. You should run them through one of the two interpreters:</p> <pre><code>print shell_exec("cmd m.bat"); </code></pre> <p>(Otherwise that's the same as using the backtick operator.)</p> |
666,821 | 0 | <p>No major issues. Spring was particularly of benefit for:</p> <ul> <li>Making all the configuration plumbing consistent and straightforward</li> <li>Dependency Injection to support better factoring of code</li> <li>Declarative "Open Session In View" functionality for Hibernate</li> <li>Declarative Transaction Demarcation</li> <li>The Acegi (now Spring Security) project made it easy to integrate a custom security model</li> <li>The Spring data access support removes the need for a lot of boilerplate from any JDBC access - maybe not such a boost for Hibernate usage, but we had a mix of both. It also allows you to use JDBC & Hibernate together fairly seamlessly</li> </ul> |
34,309,908 | 0 | What is the reqular expression for RFC4716 SSH2 public key <p>I need to restore the RFC4716 SSH2 public key structure after having replaced all new line characters with spaces (the key contents is passed as a parameter to the program and retrieved as $@ in bash). I would like to use regular expression and sed program to do it. Has anyone come across a solution?</p> <p>Example:</p> <ul> <li><p>input string passed to the program (one string all new lines replaced by spaces):</p> <p><code>---- BEGIN SSH2 PUBLIC KEY ---- Comment: "1024-bit RSA, converted from OpenSSH by [email protected]" x-command: /home/me/bin/lock-in-guest.sh AAAAB3NzaC1y(... some spaces are inserted instead of LF)9zcE= ---- END SSH2 PUBLIC KEY ----</code></p></li> <li><p>output string:</p> <p><code>---- BEGIN SSH2 PUBLIC KEY ---- Comment: "1024-bit RSA, converted from OpenSSH by [email protected]" x-command: /home/me/bin/lock-in-guest.sh AAAAB3NzaC1yc2EAAAABIwAAAIEA1on8gxCGJJWSRT4uOrR13mUaUk0hRf4RzxSZ1zRb YYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ 5TT4SfsUu/iKy9lUcCfXzwre4WWZSXXcPff+EHtWshahu3WzBdnGxm5Xoi89zcE= ---- END SSH2 PUBLIC KEY ----</code></p></li> </ul> |
33,484,049 | 0 | <p>If you want view1 and view2 to remain fixed at the top, that’s easy enough to do by constraining view1.bottom == tableView.top.</p> <p>If you want view1 and view2 to scroll with the table view, then put them inside the table view’s header. (To make a header, drag a generic UIView to the space just above the prototype cells in the storyboard editor.) I don’t recommend using constraints to try to make something outside the table view scroll with it, even though that’s (sometimes) possible.</p> <p>Control-drag from view1 to view2 and create an “equal widths” constraint to divide the space equally.</p> |
24,990,876 | 0 | <p>Can't you send the commands to the background with & in order to process the others simultaneously? Something like below;</p> <pre><code>#!/bin/bash ports="20 21 22 25 80 443" for p in $ports do nmap -Pn -p$p 10.0.1.0/24 & done </code></pre> |
23,491,777 | 0 | Android-Boot Completed is not working in Broadcastreceiver <p>I'm using android(version 4.1.1) MeLE box(SmartTv) for developing one application, i need to start up my application when device Boot Time is completed but my device not catch up the BOOT_COMPLETED Action. If i'm use that same application in mobiles or emulator the Boot_Completion action were caught by Broadcast_receiver.</p> <p>if anyone known about this issue help me thanks in advance....</p> <p>here is my code...</p> <p>manifest:</p> <pre><code><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> </code></pre> <p> <blockquote> <p></p> </blockquote> <pre><code><receiver android:name=".BootCompletedReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> <service android:name="NotifyingDailyService" > </service> </code></pre> <p>BootCompletedReceiver class:</p> <pre><code>public class BootCompletedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent arg1) { // TODO Auto-generated method stub Log.w("boot_broadcast_poc", "starting service..."); context.startService(new Intent(context, NotifyingDailyService.class)); } } </code></pre> <p>Service class:</p> <pre><code>public class NotifyingDailyService extends Service { @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public int onStartCommand(Intent pIntent, int flags, int startId) { // TODO Auto-generated method stub Toast.makeText(this, "NotifyingDailyService", Toast.LENGTH_LONG).show(); Log.i("com.example.bootbroadcastpoc","NotifyingDailyService"); return super.onStartCommand(intent, flags, startId); } } </code></pre> |
28,774,045 | 0 | Different background color in Emacs after 80 columns? <p>In Emacs, how to set a different background color after 80 columns?</p> <p>So that if the window is wider than 80 columns, all the columns after 80 would have a different background color.</p> |
7,477,232 | 0 | <p><a href="http://bplusdotnet.sourceforge.net/" rel="nofollow">http://bplusdotnet.sourceforge.net/</a> but this one is known to be somewhat buggy on deletes.</p> <p>Another one that appears to work well:</p> <p><a href="http://www.codeproject.com/KB/database/RaptorDB.aspx" rel="nofollow">http://www.codeproject.com/KB/database/RaptorDB.aspx</a></p> <p>RaptorDB allows you to store key/values either indexed using a b+ tree or a hash index. You can pick when you create the files.</p> |
1,892,638 | 0 | <p>What is the context?</p> <p>Your situation might be calling for generics, with which you could pass in <code>Collection<Integer></code> or <code>Collection<SomeOtherType></code> as you please.</p> |
4,646,047 | 0 | Why AppleScript display dialog behaves so differently between Editor and Automator? <p>For instance, why this script works on <strong>AppleScript Editor</strong> but not <strong>Automator</strong>?</p> <p><code>display dialog "a lot of text just to break to line 4 whatever continuing... few more... argh... there!" with title "just a test" buttons {"Cancel", "Uninstall", "Continue"} default button 3 with icon caution</code></p> <p>Commenting out everything after the <em>title</em> just on Automator, this is the difference I get:</p> <p><img src="https://i.stack.imgur.com/trFrT.png" alt="alt text"></p> <p>I <em>want</em> the <strong>title</strong> and more than <strong>3 lines</strong> if possible, but those are not the only weird inconsistent behaviors I've seem in the past hour about applescript between <strong>editor</strong> and <strong>automator</strong>. The icon is another one.</p> <p>In the instance, the error I get for trying it in Automator is this:</p> <p><img src="https://i.stack.imgur.com/KWV7d.png" alt="Syntax Error"></p> <p>Recording, questions here are:</p> <ol> <li>Why? Why oh Apple, why?</li> <li>Any way to at least make the <strong><em>title</em></strong> work?</li> </ol> |
30,161,904 | 0 | <p>I am dealing with exactly the same problem, but my setting is allready on 'Windows' but I can not get it to work properly.</p> <p>Changing the settings here (ASP.Net Configuration for Website), result in invalid connectionstrings, because it is not writing the web.config well. Can you tell me if your web.config changed after changing this setting ("None" to "Windows")? Do you know if your provider has had these problems before?</p> |
12,293,523 | 1 | Python idle syntax highlighting <p>I'm using idle on windows 7 as I've just come from a mac and the text editor I was using highlighted different keywords then what idle does. I know that I can change the colour of the current syntax like print and def but can I add other keywords to highlight as well? Thanks</p> |
39,801,471 | 0 | <p>I'm not sure how accurate will be.</p> <pre><code> @Override public boolean onTouchEvent(MotionEvent event) { Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics mertrics = new DisplayMetrics (); display.getMetrics(metrics); float density = getResources().getDisplayMetrics().density; float dpHeight = metrics.heightPixels / density; float y = (float)event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_MOVE: if(y < dpHeight / 2 + 50 && y > dpHeight / 2 - 50){ //no hello() here } else { // call hello() here and remove it from layout } } return false; } </code></pre> |
3,908,844 | 0 | <p>You're reassigning val <code>b</code> in the expression <code>b+=p.name->p.emailAddresses</code>.</p> |
29,822,930 | 0 | <p>Maven couldn't find goal <strong>create-DgroupId=com.tutorialspoint.test</strong></p> <p>Try to put space after <strong>create</strong></p> <pre><code>mvn archetype:create -DgroupId=com.tutorialspoint.test -DartifactId=helloworld -DarchetypeArtifactId=maven-archetype-webapp </code></pre> |
39,056,981 | 0 | <p>You <em>can</em> do what you want with the help of namespaces. However look into hash tables first.</p> <pre><code>#lang racket (define-namespace-anchor here) (define ns (namespace-anchor->namespace here)) (define foo 42) (parameterize ([current-namespace ns]) (namespace-variable-value (string->symbol "foo"))) </code></pre> <p>The output of this program is 42.</p> |
21,708,379 | 0 | <p>I found few issues on a first look, you should change the :</p> <pre><code>$dom.bind('mousedown.auto_dropdown_box_ul' </code></pre> <p>to:</p> <pre><code>$dom.unbind('mousedown.auto_dropdown_box_ul').bind('mousedown.auto_dropdown_box_ul' </code></pre> <p>To prevent multiple events binding to the dom node, you can also use .one event handling of jQuery. In the same event handling you should also put:</p> <pre><code>console.log('bind mousedown'); e.preventDefault(); return false; </code></pre> <p>To be sure event is not firing.</p> <p>Hope this helps (I'm not having IE8 for a long time now)</p> |
31,643,262 | 0 | How can I build and test libffi under cygwin with mingw32? <p>After checking (most recent) tag v3.2.1:</p> <pre><code>% sh autogen.sh % ./configure CC=i686-pc-mingw32-gcc % make check </code></pre> <p>All tests appear to fail.</p> <p>Using CC=gcc, tests seem to work properly. Unfortunately I need the resulting build to have no cygwin dependencies, since I'm building a JNI DLL.</p> |
9,580,713 | 0 | Implementing a simple thread pool <p>I'm currently in the need of a simple and efficient thread pool implementation. I have searched here and also on Google and found numerous interesting links, but nothing i've found so far seems to be suitable. Most of the implementations i have found on the web are either too complicated or lack some of the key features i need.</p> <p>Also i don't want to use code that i do not understand, so i decided to code it myself (sometimes reinventing the wheel helps me push myself forward in terms of knowledge and experience). I of course understand the basic idea behind thread pool, but some implementation details are still somewhat unclear to me. This is probably because the kind of thread pool i need is a bit special. Let me describe it. I have a task that is done hundreds of thousands of times on a particular (large) buffer. I have measured that the performance is much better if I use threads for this task - the buffer is split into sub-buffers and each thread performs its task on the sub-buffer and returns the result. All the results from all threads are then added together, giving me the final solution.</p> <p>However since this is done very often i'm losing precious time because of so many threads being created (because of the overhead that comes with thread creation). So i would like to have a pool of threads that would perform this task, instead of creating a new set of threads every time.</p> <p>To be more clear, this is what i have so far:</p> <ul> <li>Split the buffer into N sub-buffers of the same size</li> <li>For each sub-buffer, create a thread and run it on the sub-buffer</li> <li>Wait for all threads to complete (WaitForMultipleObjects), add together the results and destory the threads</li> <li>Repeat</li> </ul> <p>What i would like to achieve is this:</p> <ul> <li>Split the buffer into N sub-buffers of the same size</li> <li>Assign each sub-buffer to a thread from the threadpool (which has exactly N threads)</li> <li>Once a thread finishes, let it sleep until another task is ready</li> <li>When all threads are done (and sleeping) add together the results they produced</li> <li>Repeat by waking up the threads and assign them new tasks</li> </ul> <p>As you can see, this is a bit of a special thread pool, since i need to wait for the threads to finish. Basically i want to get rid of the overhead of creating threads all the time, since the program goes through hundreds of thousands of iterations so it can create&destroy milions of threads over its lifetime. Good news is that i do not need any synchronization at all between threads, they all get their own data and storage place fot the results. However i must wait until all threads are finished and i have the final solution, because the next task depends on the results of the previous task.</p> <p>My main problem is with the management of threads:</p> <ul> <li>how do i make my threads "sleep" and wake them up once new task is ready?</li> <li>how do i wait for all the threads to finish?</li> </ul> <p>I will be grateful for any help. Also feel free to ask questions if i was not clear enough. Thanks!</p> |
14,721,966 | 0 | <p>Easy.</p> <pre><code>SELECT name, COUNT(name) KeyCount FROM table GROUP BY name; </code></pre> |
13,368,832 | 0 | <p>I think you are looking for something like this:</p> <pre><code>select TableA.idTableA, TableB.idTableB, case when EXISTS(select null from TableA TableA_1 where TableA_1.idTableA = TableA.idTableA and TableA_1.idTableB_FK = TableB.idTableB) then 'yes' else 'no' end as is_set from TableB left join TableA on TableB.idTableA_FK = TableA.idTableA </code></pre> |
24,190,761 | 0 | <p>It's pretty obvious here:</p> <pre><code>FileInfo[] fileinfo=null; // <-- fileinfo is null for (int i = 0; i < num; i++) { fileinfo[i] = new FileInfo(files[i]);//Exception at this line of code // ^--- fileinfo is still null! } </code></pre> <p>you are trying to use the indexer on a null reference to set a value. I think you want:</p> <pre><code>FileInfo[] fileinfo= new FileInfo[num]; for (int i = 0; i < num; i++) { fileinfo[i] = new FileInfo(files[i]);//Exception at this line of code } </code></pre> <p>or just</p> <pre><code>FileInfo[] fileinfo = files.Select(f => new FileInfo(f)).ToArray(); </code></pre> <p><strong>EDIT</strong></p> <p>After reading your comments, it seems that you think that <code>FileInfo[] fileinfo=null;</code> will initialize an array of null values (which is true in some languages, but not C#). In fact, it creates an array variable that is <em>itself</em> a null value. To initialize an array, you use the syntax <code>FileInfo[] fileinfo=new FileInfo[size];</code> which <em>will</em> create an array of null values (more precisely, of the default value for <code>FileInfo</code>, which is <code>null</code> since it's a reference type). </p> |
36,454,767 | 0 | <p>Found the issue and it was very minor, I was removing everything with a class of default which was being removed every time a state changed, so now it will remove everything with class tile and prevent any duplicate containers.</p> <pre><code>socket.on("presenceusers", function (userPresence) { $('.tile').remove();\\ <------ for (var i = 0; i < userPresence.length; i++) { if (userPresence[i][1] === "enable") { $presence.append('<div class="col-md-2 md tile default"><h6><img src="../images/offline.png"><b>' + userPresence[i][0] + '</b></h6></div>'); } } }); </code></pre> |
6,725,326 | 0 | Rails can not find rake gem? <p>Started learning ruby on rails today, after spending the half day fixing the other errors, I am stuck at the following: When I enter the following command in the terminal: " bundle exec rake db:migrate" or "rails server" it gives me the following error: </p> <blockquote> <p>Could not find rake-0.9.2 in any of the sources Run <code>bundle install</code> to install missing gems.</p> </blockquote> <p>I ran bundle install rake (Both with version number and without) and it says it has been installed to ./rake. When I run the command it gives me the same error again. No Idea how to fix this, so any help is wholeheartedly appreciated. I am using ruby 1.9.2 and rails 3.0.9 in the directory the App is located in with RVM. Thanks in advance for any help.</p> <p>EDIT:</p> <p><strong>* LOCAL GEMS *</strong></p> <p>Using rake (0.9.2) Using abstract (1.0.0) Using activesupport (3.0.9) Using builder (2.1.2) Using i18n (0.5.0) Using activemodel (3.0.9) Using erubis (2.6.6) Using rack (1.2.3) Using rack-mount (0.6.14) Using rack-test (0.5.7) Using tzinfo (0.3.29) Using actionpack (3.0.9) Using mime-types (1.16) Using polyglot (0.3.1) Using treetop (1.4.9) Using mail (2.2.19) Using actionmailer (3.0.9) Using arel (2.0.10) Using activerecord (3.0.9) Using activeresource (3.0.9) Using bundler (1.0.15) Using rdoc (3.8) Using thor (0.14.6) Using railties (3.0.9) Using rails (3.0.9) Using sqlite3-ruby (1.2.5) </p> <p><strong>EDIT2: This has been fixed: Try using rvm and go back to ruby 1.8.7 instead of 1.9.2. This fixed it for me. Don't forget to install rails again (sudo gem install rails while already on 1.8.7) if you have only installed rails for 1.9.2.]</strong></p> |
33,214,845 | 0 | <p>If query_image and list_image are came from the same form, you can do this:</p> <p>Try to </p> <pre><code>def query_image(request): #it woul be better to rename it to all_image if form.is_valid(): query_image = form.cleaned_data['query_image'] list_image = form.cleaned_data['list_image'] my_context = {'query_image': form.cleaned_data['query_image'], 'list_image': form.cleaned_data[] #... any other data} return render(request, "all_image.html", my_context) </code></pre> <p>And you have to make sure that all_image.html renders list_image somehow (using django templates <code>for</code>, for example)</p> |
41,071,836 | 0 | How to create a box with line and add icon on side <p>I want to have a box with line on side as input and output. A line has add icon which should be clickable. How can i design such one so that add icon will be clickable? Should i use svg image for line and icon? what is the best way? I tried using css as i want it to be <code>responsive</code> but i had to use :before and :after and i can't make it clickable. </p> <p><a href="https://i.stack.imgur.com/8JCpR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8JCpR.png" alt="enter image description here"></a></p> |
13,375,624 | 0 | <p>I know it is too late, but I found this topic because I had the same problem.</p> <p>And my solution may help other people.</p> <p>The solution above didnt work well because it killed every running instance of Word, though it wasn't opened by the c# program but the user.</p> <p>So this was not that userfriendly.</p> <p>My code checks the processes before/after the creation of the <code>Word.Application</code> Object in c# and writes the IDs of the <code>WINWORD</code> Processes in <code>List<int></code> then it compares the values in both <code>List<int></code>. When a <code>processID</code> is not found in both <code>List<int></code> it kills the process with this ID.</p> <pre><code>public List<int> getRunningProcesses() { List<int> ProcessIDs = new List<int>(); //here we're going to get a list of all running processes on //the computer foreach (Process clsProcess in Process.GetProcesses()) { if (Process.GetCurrentProcess().Id == clsProcess.Id) continue; if (clsProcess.ProcessName.Contains("WINWORD")) { ProcessIDs.Add(clsProcess.Id); } } return ProcessIDs; } </code></pre> <p>Run this twice (one time before the creation of the Word.Application and once after).</p> <pre><code> List<int> processesbeforegen = getRunningProcesses(); // APP CREATION/ DOCUMENT CREATION HERE... List<int> processesaftergen = getRunningProcesses(); </code></pre> <p>Then run <code>killProcesses(processesbeforegen, processesaftergen);</code></p> <pre><code> private void killProcesses(List<int> processesbeforegen, List<int> processesaftergen) { foreach (int pidafter in processesaftergen) { bool processfound = false; foreach (int pidbefore in processesbeforegen) { if (pidafter == pidbefore) { processfound = true; } } if (processfound == false) { Process clsProcess = Process.GetProcessById(pidafter); clsProcess.Kill(); } } } </code></pre> |
32,696,337 | 0 | <p>Your call for:</p> <p><a href="http://localhost:4200/api/users" rel="nofollow">http://localhost:4200/api/users</a></p> <p>can't return <code>exactly the same JSON response</code>.</p> <p>Your call for: <code>http://localhost:4200/api/users/1</code> should return:</p> <pre><code>{ "data": { "id":"1", "type": "user", "attributes" : { "firstname":"John", "lastname":"Doe", "email":"[email protected]", "mobile":"12345678", "nextAppointment":1 } } } </code></pre> <p>Read more about JSONAPIAdapter:</p> <ul> <li><a href="http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_json-api-adapter-and-serializer" rel="nofollow">JSON API ADAPTER AND SERIALIZER in Ember Data v1.13 blog post</a></li> <li><a href="http://jsonapi.org/" rel="nofollow">jsonapi.org</a></li> </ul> |
776,837 | 0 | <p>Have you found a resolution to this yet? I having the same issue, my code is pretty much a mirror of yours. Main difference is my pdf is hosted in an IFrame. </p> <p>So interesting clues I have found: If I stream back a Word.doc it only gets loaded once, if pdf it gets loaded twice. Also, I have seen different behavior from different client desktops. I am thinking that Adobe version may have something to do with it. </p> <p><strong>Update:</strong></p> <p>In my case I was setting the HttpCacheability to NoCache. In verifying this, any of the non client cache options would cause the double download of the pdf. Only not setting it at all (defaults to Private) or explicitly setting it to Private or Public would fix the issue, all other settings duplicated the double load of the document.</p> |
37,458,400 | 0 | How to merge two separate column data into one column in sqlite android <p>I store hour and minute in two separate column. i want to combine it like as hour:minute(9:15) and store timeunit(AM-PM) in separate column.how to do this can any one knows.hour and minute of String type. </p> |
25,867,195 | 0 | Pass the arguments received in C down to bash script <p>I have the following piece of C code that is being called with arguments:</p> <pre><code>int main(int argc, char *argv[]) { system( "/home/user/script.sh" ); return 0; } </code></pre> <p>how do i pass all arguments received down to script.sh?</p> |
37,506,789 | 0 | Normalization to 3NF from un-normalized relation <p>Given</p> <pre><code>INSURANCE PORTFOLIO (portfolio id, insurance company name, insurance company phone, ((agent name, agent license number, state of residence, ((policy number, policy description, annual premium, benefit, beneficiary details)), number of policies)), number of policies in a portfolio) </code></pre> <p>I'm trying to get this into 3NF. Am I on the right track?</p> <p>1NF:</p> <pre><code>1NF: INSURANCE PORTFOLIO:(portfolio id, insurance company name, insurance company phone, ,agentname, number of policies in a portfolio) agentdetails: (agent name, agent license number, state of residence, policy number,number of policies in a portfolio#) policydetails:(agent name#,policy number#, policy description, annual premium, benefit, beneficiary details) </code></pre> <p>2NF</p> <pre><code>2NF: INSURANCE PORTFOLIO:( agent name ,portfolio id, insurance company name, number of policies in a portfolio) Agentdetails: (agent name, agent license number, state of residence, policynumber,number of policies in a portfolio#) policydetails:(agentname,policy number, policy description, annual premium, benefit, beneficiary details) </code></pre> <p>3NF:</p> <pre><code> INSURANCE PORTFOLIO:( agent name ,portfolio id, phonenumber , number of policies in a portfolio) agentdetails:(agent name#, agent license number, state of residence,policynumber,number of policies in a portfolio#) policydetails:(agent name#,policy number#, policy description, annual premium, benefit, beneficiary details) </code></pre> <p>Any guidance is appreciated</p> |
3,331,069 | 0 | List Item Background Image - Neighbor Floated Content Overlaps <p>I've used list item background images for customized bullets hundreds of times in the past, and somehow never came across this issue.</p> <p>Essentially, I have an IMG floated left of the Unordered List. The bullet background images are set to top-left of each LI. However, the floated image is covering the bullets, as the browser is treating the list as if it's still full width (as if the floated image almost isn't there).</p> <p>It's a bit hard to explain. So here is a screenshot with notes. <a href="http://img695.imageshack.us/img695/1328/cssquestion.jpg" rel="nofollow noreferrer"><a href="http://img695.imageshack.us/img695/1328/cssquestion.jpg" rel="nofollow noreferrer">http://img695.imageshack.us/img695/1328/cssquestion.jpg</a></a></p> <p>Here are some code snippets (sorry, can't upload to a server at the moment):</p> <pre><code><h2>About Us</h2> <img src="image.jpg" class="img-left" /> <h3>Heading</h3> <p>Text</p> <ul> <li>List Item One</li> <li>List Item Two</li> <li>List Item Three</li> </ul> ul { padding: 0; margin: 0; } ul li { background: url(../images/bg-main-bullet.gif) top left no-repeat; list-style: none; padding: 0; margin: 0; } .img-left {float: left; margin: 0 19px 0 0;} </code></pre> <p>Does anyone have any ideas how to achieve my desired result?</p> <p>Any tips or input is greatly appreciated! Thanks</p> |
21,936,989 | 0 | Moved multisite from domain.com to localhost - Can't get it to work <p>I've copied the entire wordpress folder from a server to my local machine. I have also exported and imported our MySQL database which I can access just fine. </p> <p><strong>What settings do I need to modify in order to make the wordpress sites run on my computer?</strong> </p> <p>So far I have done this:</p> <ol> <li>Changed <code>define('DOMAIN_CURRENT_SITE', 'domain.com')</code> to <code>define('DOMAIN_CURRENT_SITE', 'localhost.com')</code> in <strong>wp-config.php</strong></li> <li>I've added <code>127.0.0.1 localhost.com</code> to my <strong>hosts file</strong></li> <li>I've changed the row <code>siteurl</code> to <code>localhost.com</code> in the database table <strong>wp_options</strong></li> </ol> <p>But I'm not sure what else to change to make it work. Whenever I try to access localhost.com I get redirected to the url listed in wp_config.php <code>define('NOBLOGREDIRECT', 'http://www.domain.com')</code>.</p> <p>I'm using MAMP and accessing MAMP works fine. It's accessing the WP sites that trouble me. I don't know how/where to set the urls to make it work. </p> |
24,311,281 | 0 | <p>I'm coming late in the game but I tried all of the solutions above! couldn't get it to drop the zero's in the parameter and give me a default (it ignored the formatting or appeared blank). I was using SSRS 2005 so was struggling with its clunky / buggy issues.</p> <p>My workaround was to add a column to the custom [DimDate] table in my database that I was pulling dates from. I added a column that was a string representation in the desired format of the [date] column. I then created 2 new Datasets in SSRS that pulled in the following queries for 2 defaults for my 'To' & 'From' date defaults -</p> <p>'from'</p> <pre><code> SELECT Datestring FROM dbo.dimDate WHERE [date] = ( SELECT MAX(date) FROM dbo.dimdate WHERE date < DATEADD(month, -3, GETDATE() ) </code></pre> <p>'to'</p> <pre><code> SELECT Datestring FROM dbo.dimDate WHERE [date] = ( SELECT MAX(date) FROM dbo.dimdate WHERE date <= GETDATE() ) </code></pre> |
13,972,021 | 0 | <p>In JSON (by standard) you have <a href="http://www.json.org/" rel="nofollow">Arrays, Objects, values and strings</a>, arrays are not Objects like in JavaScript. JSON is only a data-interchange format, you don't have a base prototype like in JavaScript where almost everything is an object and have properties.</p> <p>So, if you want to have a property <code>z3</code> of <code>z2</code> you have to make <code>z2</code> an object.</p> |
31,793,268 | 0 | Hibernate Child table saves null foreign key instead of auto increment parent's primary key <p>I'm trying to save to two parent and child table at the same time. It does save the both parent and child rows but the issue is child table doesn't contain the primary key(Auto Increment) of parent table in foreign key column in child table. Instead of that foreign key column in child table shows null</p> <p>here are the Models 01.Feed Order class (Parent Class)</p> <pre><code>@Entity public class FeedOrder { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String date; private double total; private double discount; @OneToMany(mappedBy="feedOrder",cascade = CascadeType.PERSIST) private List<FeedOrderDetail> feedOrderDetail; @ManyToOne private Supplier supplier; //With Getters and Setters } </code></pre> <p>02.Feed Order Details class (Child Class)</p> <pre><code>@Entity public class FeedOrderDetail { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private double unitPrice; private long quantity; @ManyToOne @JoinColumn(name="feed_id") private Feed feed; @ManyToOne @JoinColumn(name="order_id") private FeedOrder feedOrder; //With Getters and Setters } </code></pre> <p>I use Spring MVC as well.</p> <p>Here is the Repository class Code.</p> <pre><code>@Repository("feedOrderRepository") public class FeedOrderRepositoryImp implements FeedOrderRepository { @PersistenceContext private EntityManager em; public FeedOrder save(FeedOrder feedOrder) { em.persist(feedOrder); em.flush(); return null; } } </code></pre> <h2>Update</h2> <p>AddFeedOrder.jsp</p> <pre><code><html> <body> <form:form commandName="feedOrder"> <table> <tr> <td>Date</td> <td><form:input path="date" /></td> </tr> <tr> <td>Discount</td> <td><form:input path="discount" /></td> </tr> <tr> <td>Total</td> <td><form:input path="total" /></td> </tr> <tr> <td>Supplier</td> <td><form:input path="supplier.id" /></td> </tr> </table> <table id="mytable"> <tr> <td>Feed ID</td> <td>Unit Price</td> <td>Quantity</td> </tr> <tr> <td><form:input path="feedOrderDetail[0].feed.id" /></td> <td><form:input path="feedOrderDetail[0].unitPrice" /></td> <td><form:input path="feedOrderDetail[0].quantity" /></td> </tr> </table> <INPUT type="button" value="Add More" onclick="addRow('mytable')" /> <tr> <td><input type="submit" value="Save Feed Order"></td> </tr> </form:form> </body> </html> </code></pre> |
25,613,512 | 0 | <p>This is not a good idea, to serve static files with Django HttpResponse.<br> Why don't you set up Nginx proxy? Check this: <a href="https://coderwall.com/p/rlguog" rel="nofollow">https://coderwall.com/p/rlguog</a></p> |
2,419,077 | 0 | <p>Using OSGi bundles you can do that. Take a look at <a href="http://blog.springsource.com/2008/02/18/creating-osgi-bundles/" rel="nofollow noreferrer">http://blog.springsource.com/2008/02/18/creating-osgi-bundles/</a>. Search for "multiple versions".</p> |
5,934,152 | 0 | <p>The most comprehensive library i know of (and the only one i've actually used) is <a href="http://pear.php.net/package/Console_CommandLine" rel="nofollow">Console_CommandLine</a>. I have not used argparse so I can't tell you if it is as featured or compare them.</p> |
12,424,468 | 0 | triggering the printscreen keyboard function and sending the converted image to server in jQuery <p>How can i trigger the PrtScn i.e, PrintScreen keyboard event through some jQuery function and then save that captured image to server ?</p> <pre><code>function ErrorLog(errorCode, errorMessage) { // Here i want the screenshot of the user's screen where the error have occurred ... var _screenShot = ""; SendErrorToServer(errorCode, errorMessage, _screenShot); } </code></pre> <p>Can you pleases help me by providing the code.</p> |
12,770,987 | 0 | High traffic - Multiple requests to set same memcached key? <p>I'm setting up memcached. I have a couple questions regarding high traffic and best practice for updating/setting keys. I'm creating a online game where users are assigned points in a increment of 10,50,100. </p> <p>Use : Store user "game stats" in keys and running a cron job every 5 minutes or so to update the stats permanently in the datastore. This way the "game" can function without ever going to the db to crud values, points. </p> <p>Will use warm up scripts to pull and populate keys for user stats</p> <p>Questions :<br> 1)Would there be a issue down the road with high traffic and trying to write to that users points key? </p> <p>2)Best practice for incrementing values in memcache?</p> <p>This is a rough idea of what I'm using now </p> <pre><code>$newval = $memcache->get( $key ); $memcache->set($key, $newval+10, false, 1000) or die ("Failed to save data at the server"); </code></pre> <p>3)Recommendations for storing users game stats in memcache? Any input would be greatly appreciated. </p> <p>Thank you all!</p> |
8,520,835 | 0 | <p>In general an object can be removed in two ways from an <a href="http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html" rel="nofollow"><code>ArrayList</code></a> (or generally any <a href="http://docs.oracle.com/javase/6/docs/api/java/util/List.html" rel="nofollow"><code>List</code></a>), by index (<a href="http://docs.oracle.com/javase/6/docs/api/java/util/List.html#remove%28int%29" rel="nofollow"><code>remove(int)</code></a>) and by object (<a href="http://docs.oracle.com/javase/6/docs/api/java/util/List.html#remove%28java.lang.Object%29" rel="nofollow"><code>remove(Object)</code></a>).</p> <p>In this particular scenario: Add an <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#equals%28java.lang.Object%29" rel="nofollow"><code>equals(Object)</code></a> method to your <code>ArrayTest</code> class. That will allow <a href="http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html#remove%28java.lang.Object%29" rel="nofollow"><code>ArrayList.remove(Object)</code></a> to identify the correct object.</p> |
15,232,729 | 0 | <p>Change</p> <pre><code>query_posts("cat=$cat_id&post_per_page=9999"); </code></pre> <p>To</p> <pre><code>query_posts("cat=" . $categories_item->term_id . "&post_per_page=9999"); </code></pre> |
123,773 | 0 | Is OOP & completely avoiding implementation inheritance possible? <p>I will choose Java as an example, most people know it, though every other OO language was working as well.</p> <p>Java, like many other languages, has interface inheritance and implementation inheritance. E.g. a Java class can inherit from another one and every method that has an implementation there (assuming the parent is not abstract) is inherited, too. That means the interface is inherited and the implementation for this method as well. I can overwrite it, but I don't have to. If I don't overwrite it, I have inherited the implementation.</p> <p>However, my class can also "inherit" (not in Java terms) just an interface, without implementation. Actually interfaces are really named that way in Java, they provide interface inheritance, but without inheriting any implementation, since all methods of an interface have no implementation.</p> <p>Now there was this <a href="http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html" rel="nofollow noreferrer">article, saying it's better to inherit interfaces than implementations</a>, you may like to read it (at least the first half of the first page), it's pretty interesting. It avoids issues like the <a href="http://en.wikipedia.org/wiki/Fragile_base_class" rel="nofollow noreferrer">fragile base class problem</a>. So far this makes all a lot of sense and many other things said in the article make a lot of sense to me.</p> <p>What bugs me about this, is that implementation inheritance means <strong>code reuse</strong>, one of the most important properties of OO languages. Now if Java had no classes (like James Gosling, the godfather of Java has wished according to this article), it solves all problems of implementation inheritance, but how would you make code reuse possible then?</p> <p>E.g. if I have a class Car and Car has a method move(), which makes the Car move. Now I can sub-class Car for different type of cars, that are all cars, but are all specialized versions of Car. Some may move in a different way, these need to overwrite move() anyway, but most would simply keep the inherited move, as they move alike just like the abstract parent Car. Now assume for a second that there are only interfaces in Java, only interfaces may inherit from each other, a class may implement interfaces, but all classes are always final, so no class can inherit from any other class.</p> <p>How would you avoid that when you have an Interface Car and hundred Car classes, that you need to implement an identical move() method for each of them? What concepts for code reuse other than implementation inheritance exist in the the OO world?</p> <p>Some languages have Mixins. Are Mixins the answer to my question? I read about them, but I cannot really imagine how Mixins would work in a Java world and if they can really solve the problem here.</p> <p>Another idea was that there is a class that only implements the Car interface, let's call it AbstractCar, and implements the move() method. Now other cars implement the Car interface as well, internally they create an instance of AbstractCar and they implement their own move() method by calling move() on their internal abstract Car. But wouldn't this be wasting resources for nothing (a method calling just another method - okay, JIT could inline the code, but still) and using extra memory for keeping internal objects, you wouldn't even need with implementation inheritance? (after all every object needs more memory than just the sum of the encapsulated data) Also isn't it awkward for a programmer to write dummy methods like</p> <pre><code>public void move() { abstractCarObject.move(); } </code></pre> <p>?</p> <p>Anyone can imagine a better idea how to avoid implementation inheritance and still be able to re-use code in an easy fashion?</p> |
23,861,017 | 0 | UIScrollView not moving <p>I am trying to scroll the view up when the keyboard covers a "textfield". I have a setter to determine which "textfield" is active (as Apple's documentation instructed). When I try to use method "scrollRectToVisible" nothing happens. I used <code>NSLog</code> to test when the view should and shouldn't move. The rest of the program seems to work fine. I don't understand what I did wrong. Could this be caused by using storyboard with auto layout enabled?</p> <pre><code>if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) { [self.scrollView scrollRectToVisible:activeField.frame animated:YES]; //not working NSLog(@"View Should Move"); } </code></pre> <p>Thanks</p> |
17,604,123 | 0 | how to get blackberry db file? <p>I used <strong>Phonegap</strong> to create a mobile app with HTML and Javascript files. I could upload my files to <strong>phonegap/apps</strong> to create my app online. I did all things well, but BlackBerry requires a signing key and .db file. I have signing keys, as I have the <strong>.csi</strong> and <strong>.csj</strong> files.</p> <p>I tried to get BlackBerry .db file, but <strong>how can I get it?</strong>. </p> |
7,136,170 | 0 | <p>I know this is old but it kept coming up when I searched on this subject. I was able to get this working by adding a "DataMemberAttribute" attribute to the property. Below is a code example. </p> <pre><code>public partial class SecurityItemCollection { [global::System.Runtime.Serialization.DataMemberAttribute()] public int TotalRecords { get; set; } } </code></pre> |
6,362,223 | 0 | <p><code>if(!($('textarea').val().length == 0))</code> will work if you have only one <code>textarea</code> element in your page. I think what you were trying to do with that <code>:name</code> selector was select a specific <code>textarea</code> based on its name, in which case you need:</p> <p><code>$('textarea[name=yourName]')</code></p> |
4,481,114 | 0 | which blog software manages multiple language posts, modular privacy, and custom RSS syndication? <p>I'm considering which software to use for a blog that I would like to install in a personal home server (synology). Here are my requirements:</p> <ul> <li><p><strong>Language management</strong>: I'll be writing in different languages, and some entries would be translated in different languages, not always the same. Blog readers should be able to select which languages they can/wish to read. For instance, if they chose English, then all entries which have English translation would appear in English, the remaining appearing in whatever language they were written, or not at all.</p></li> <li><p><strong>RSS customization</strong>: the blog will broach different subjects. I would like the users to be able to customize a RSS syndication which corresponds to their interests, so that the sigal to noise ration in their RSS readers remains bearable. This should probably work with a "Categoriy" or "Tag" system.</p></li> <li><p><strong>sub-blogs</strong>: I would like to have sub-blogs with their own url, which would present a subset of the blog entries. For instance my blog could deal with politics, sports, and myLife, and I could produce the following blog urls: blog.mydomain.tld (shows everything), opinions.mydomain.tld (shows only the politics related posts), sports.mydomain.tld (all entries dedicated to sports). I would also like to theme differently those sub-blogs (i.e. a ball picture for sports.mydomain.tld, etc).</p></li> <li><p><strong>modular privacy</strong>: my intended audience is heterogeneous (family, sets of friends, the internet), and I would like to be able to limit access to certain entries to different subsets of users. To me, the most obvious way to do this would be to define users with a login and password. I would then pool them into groups, and define for each entry if it is private, and if so which groups can read it. I do not necessarily want to share the same things between my neighbors and my school friends.</p></li> </ul> <p>That also brings the issue of RSS syndication: either each user would have its how RSS thread, or then RSS could be category specific and the private entries would appear without content. Perhaps other possibilities exist.</p> <p>These set of features are quite specific. I was thinking of using a blog software to implement them, but perhaps I'm thinking this wrong and I should use a CMS or even a framework?</p> <p>Another point is that this is done for "fun", and although I can program (python, etc), this is not my day job, so it should not require expert level skills or full time investment to implement. A solution which involves me developing a whole new blog application is not adapted to my constraints.</p> <p><strong>EDIT</strong></p> <ul> <li><strong>OpenID</strong>: I like the Stack Overflow login system (check this <a href="http://nsa20.casimages.com/img/2010/12/19/101219101041560868.png" rel="nofollow">screen capture of it</a>), because most readers already have an OpenID, and in any case do not need to create a specific one for my blog. The system I would use should be capable of using the OpenID method of authentication</li> </ul> |
27,840,147 | 0 | Parse Unstructured Data in Shell script/Linux <pre><code>Example log : "some data7.575=tf.some data2.0=tf.some data1.23=tf.some data.." I want to get each TF value as output. i.e. output should be TF=7.575 TF=2.0 TF=1.23 </code></pre> <p>How can I parse this? Using Shell script (preferrable). Unix command or using Java.</p> |
34,224,357 | 0 | <p>This is <a href="http://jsfiddle.net/catch_shailendra/4mtyu/1033/" rel="nofollow">working fiddle</a> of your code what is wrong with your code is you open a map on window load by <code>initMap( $( '.map' ) );</code> which run <code>google.maps.event.addDomListener( window, 'load', function()</code> and later you call same function on click that not make any sense , because this line register window load event to run function inside it's block </p> <p>and appending new map in existing map also not working, that's all hope This may help </p> <p>it's not complete code just a idea how this will work </p> |
39,440,214 | 0 | <p>This might not give the same performance as an UNION but I think this is what you are looking for</p> <p>You need to create a view:</p> <pre><code>create view mutex as select i from (select 0 union select 1)sq (i) </code></pre> <p>Now you can use this view to get your desired results as:</p> <pre><code>select coalesce(a.A,b.B),coalesce(a.coll1,b.coll1),coalesce(a.coll2,b.coll2),coalesce(a.coll3,b.coll3) from mutex left join TABLE_A as a on i =0 left join TABLE_B as b on i =1 </code></pre> <p>Note: Instead of a mutex view, you can also use a table that will have these 2 rows</p> |
24,064,661 | 0 | <p><code>requirejs</code> has some magic arguments that you can request - among them is <a href="https://github.com/jrburke/requirejs/blob/19a98167858db65342a269ba76f06e3be152210e/require.js#L584-597" rel="nofollow"><code>module</code></a>:</p> <pre><code>define(["module", "other", "dependencies"], function(module, other, deps) { var whereAmI = module.uri; }); </code></pre> |
22,986,538 | 0 | <p>With David Fritsch answer I get to do a encrypted password as Joomla does:</p> <pre><code><?php define( '_JEXEC', 1 ); define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root define( 'DS', DIRECTORY_SEPARATOR ); require_once( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once( JPATH_BASE .DS.'includes'.DS.'framework.php' ); $mainframe =& JFactory::getApplication('site'); $mainframe->initialise(); jimport('joomla.user.helper'); $password = "test"; echo "<strong>Password: </strong>" . JUserHelper::hashPassword($password); ?> </code></pre> <p>Note that you have to store the file in joomla root directory, or change JPATH_BASE.</p> |
19,589,215 | 0 | am using ScratchPadView for iphone app when am taking screenshot on scratchpad i have written some thing but its not showing the content <pre><code> UIGraphicsBeginImageContext(self.bounds.size ); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *currentScreen = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>here am unable get the screenshot of updated scratchpad something done on scratchpad but it not showing in my screenshot ![Scratchpad screenshot][1]</p> |
30,193,088 | 0 | Rxjava, how to design an Observable that has to wait for another Observable <p>I'm building an Android app, and new to Rxjava, having a beginner's question: I have an Observable that should emit something straightaway if a condition is met. Otherwise, it has to pause, then trigger another Observable, and wait for that second Observable to emit the second thing. Once the second thing is emitted, it (the first Obserable) should continue and emit its object.</p> <p>Should the 2nd Observable be placed inside 'call' function of the 1st Observable?</p> <p>If this question sounds vague, pardon me since I'm not even sure how to design the code. </p> |
4,363,941 | 0 | Asp.net - <customErrors mode="Off"/> error when trying to access working webpage <p>I have created an asp.net webpage and have uploaded it onto a webserver. However when I try to view the page remotely, I get errors about the customerror tag in the web.config file. The page works locally with no errors or warnings. Also if I upload the page as a .html file, I can view it fine remotely. I have seen a lot of other people with this error, but the 'solutions' just say to change the customErrors tag to 'Off', which I have done and does not work, do you know is there an issue with the webserver or what could be the problem here? </p> <p><strong>Here is the error page:</strong></p> <blockquote> <p>Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error >settings for this application prevent the details of the application error from being >viewed remotely (for security reasons). It could, however, be viewed by browsers running >on the local server machine.</p> <p>Details: To enable the details of this specific error message to be viewable on remote >machines, please create a tag within a "web.config" configuration file >located in the root directory of the current web application. This tag >should then have its "mode" attribute set to "Off".</p> </blockquote> <pre><code><configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration> </code></pre> <blockquote> <p>Notes: The current error page you are seeing can be replaced by a custom error page by >modifying the "defaultRedirect" attribute of the application's >configuration tag to point to a custom error page URL.</p> </blockquote> <pre><code><configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration> </code></pre> <p><strong>And here is my web.config file:</strong></p> <pre><code><?xml version="1.0"?> <configuration> <system.web> <customErrors mode="Off"/> </system.web> <system.web> <compilation debug="true"/> <authentication mode="None"/> </system.web> </configuration> </code></pre> |
35,531,526 | 0 | <p>Wikipedia has a nice <a href="https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bgeosearch" rel="nofollow">Geo Search API</a> that will let you search for nearby pages: </p> <p><a href="https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gspage=Berlin&gslimit=500&gsprop=type|name|dim|country|region|globe&format=json" rel="nofollow">https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gspage=Berlin&gslimit=500&gsprop=type|name|dim|country|region|globe&format=json</a></p> <pre><code>{ "batchcomplete": "", "query": { "geosearch": [ ... { "pageid": 391156, "ns": 0, "title": "Berlin State Opera", "lat": 52.516666666667, "lon": 13.395, "dist": 789.4, "primary": "", "type": "landmark", "name": "", "dim": 1000, "country": "DE", "region": "BE" }, ... { "pageid": 1005900, "ns": 0, "title": "Berlin Zoological Garden", "lat": 52.508333333333, "lon": 13.3375, "dist": 3237.1, "primary": "", "type": "landmark", "name": "", "dim": 500, "country": "DE", "region": "BE" }, ... </code></pre> <p>You can use <code>gspage</code> to search using the title of any Wikipedia article <a href="https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Dates_and_numbers#Geographical_coordinates" rel="nofollow">with geographic coordinates</a>. You'll see some geotagged historical events, landmarks, and other features, so you can add <code>gsprop=type</code> to add properties to help you filter articles you aren't interested in.</p> <p>A few notes:</p> <ul> <li><p>The API can (currently) only return a maximum of 500 items that are within a 10,000 meter radius of the point you are searching. You may want to try a series of more narrow searches or using a small bounding box (with the <code>gsbbox</code> parameter) if you don't get everything you want.</p></li> <li><p>Each language of Wikipedia has its own API endpoint. You can try the <a href="https://de.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gspage=Berlin&gslimit=500&gsprop=type|name|dim|country|region|globe" rel="nofollow">same query on the German language Wikipedia</a> and you may see slightly different results.</p></li> <li><p>Wikidata has extensive data across languages with a <a href="https://query.wikidata.org/" rel="nofollow">SPARQL interface</a>, but it doesn't support geo coordinate searches (<a href="https://phabricator.wikimedia.org/T123565" rel="nofollow">yet</a>). Someday, you may be able to use Wikidata to find items based on their location (<a href="https://www.wikidata.org/wiki/Property:P625" rel="nofollow">P625</a>).</p></li> </ul> |
22,672,108 | 1 | merging in pandas vs merging in R <p>I'm afraid I do not quite understand the merging capabilities of pandas, although I much prefer python over R for now.</p> <p>In R, I have always been able to merge dataframes very easily as follows:</p> <pre><code>> merge(test,e2s, all.x=T) Gene Mutation Chromosome Entrez 1 AGRN p.R451H chr1 375790 2 C1orf170 p.V663A/V683A chr1 84808 3 HES4 p.R44S chr1 57801 4 ISG15 p.S83N chr1 9636 5 PLEKHN1 p.S476P/S511P/S563P/S76P chr1 84069 </code></pre> <p>However, I have been unable to reconstruct this in pandas with merge(how="left,right,inner,outer").. For example:</p> <pre><code>Outer yields a union, which makes sense: x = test.merge(e2s, how="outer") In [133]: x.shape Out[133]: (46271, 4) </code></pre> <p>But inner yields an empty dataframe, even though <code>Entrez_Gene_Id</code> has been merged successfully:</p> <pre><code>In [143]: x = test.merge(e2s, how="inner") In [144]: x Out[144]: Empty DataFrame Columns: [Gene, Mutation, Chromosome, Entrez_Gene_Id] Index: [] [0 rows x 4 columns] </code></pre> <p>The intersection should contain one row with the <code>gene : HES4</code>. Is there some sort of string matching I need to turn on for this?:</p> <p>e2s:</p> <pre><code>57794 SUGP1 57795 BRINP2 57796 DKFZP761C1711 57798 GATAD1 57799 RAB40C 57801 HES4 57804 POLD4 57805 CCAR2 57817 HAMP </code></pre> <p>test:</p> <pre><code> Gene Mutation Chromosome 0 PLEKHN1 p.S476P/S511P/S563P/S76P chr1 1 C1orf170 p.V663A/V683A chr1 2 HES4 p.R44S chr1 3 ISG15 p.S83N chr1 4 AGRN p.R451H chr1 5 RNF223 p.P242H chr1 </code></pre> <p><strong>Update:</strong></p> <p>As far as I know the columns are labelled so that they should merge fine, I only want to merge by the <code>Gene</code> column and keep all test rows:</p> <pre><code>In [148]: e2s.columns Out[148]: Index([u'Gene', u'Entrez_Gene_Id'], dtype='object') In [149]: test.columns Out[149]: Index([u'Gene', u'Mutation', u'Chromosome'], dtype='object') </code></pre> <p>This was done by explicitly renaming the dataframes:</p> <pre><code>e2s.rename(columns={"Gene":u'Gene',"Entrez_Gene_Id":u'Entrez_Gene_Id'}, inplace=True) </code></pre> <p>to dict:</p> <pre><code>{u'Chromosome': {0: u'chr1', 1: u'chr1', 2: u'chr1', 3: u'chr1', 4: u'chr1', 5: u'chr1'}, u'Gene': {0: u'PLEKHN1', 1: u'C1orf170', 2: u'HES4', 3: u'ISG15', 4: u'AGRN', 5: u'RNF223'}, u'Mutation': {0: u'p.S476P/S511P/S563P/S76P', 1: u'p.V663A/V683A', 2: u'p.R44S', 3: u'p.S83N', 4: u'p.R451H', 5: u'p.P242H'}} {u'Entrez_Gene_Id': {14118: u'SUGP1', 14119: u'BRINP2', 14120: u'DKFZP761C1711', 14121: u'GATAD1', 14122: u'RAB40C', 14123: u'HES4', 14124: u'POLD4', 14125: u'CCAR2', 14126: u'HAMP'}, u'Gene': {14118: 57794, 14119: 57795, 14120: 57796, 14121: 57798, 14122: 57799, 14123: 57801, 14124: 57804, 14125: 57805, 14126: 57817}} </code></pre> |
21,907,107 | 0 | <p>I think it's wrong argument type, it should be: <code>include Geolocalizable</code> </p> |
2,718,796 | 0 | <p>This sounds a lot like an <code>SFAuthorizationPluginView</code>.</p> <p>Apple has an API for you to add your own authentication methods. Here is some sample code to get started.</p> <p><a href="http://developer.apple.com/mac/library/samplecode/NameAndPassword/Introduction/Intro.html" rel="nofollow noreferrer">http://developer.apple.com/mac/library/samplecode/NameAndPassword/Introduction/Intro.html</a></p> |
15,659,079 | 0 | <p>Your <code>booking</code> url takes one parameter as <code>course_code</code>, hence you are getting error.</p> <p>You should update the line <code>{% url 'booking' %}</code> appropriately to pass some <code>course_code</code> to the url.</p> <p>So you need to update it with something like <code>{% url 'booking' course_code %}</code>, here I assume to have <code>course_code</code> parameter available in template, you can change it according to your code.</p> |
1,444,659 | 0 | <p>It all depends on what _repository.ToList() is doing under the covers. You can force "eager" fetching of your collections via HQL syntax similar to the following:</p> <pre><code>"from Parent inner join fetch Children" </code></pre> <p>HQL statements are meant to be flexible, and so they tend to ignore your collection mapping and join strategies defined either fluently or in the hbm xml files.</p> <p>You should now see only a single query executed against the database.</p> |
36,288,004 | 0 | <p>If you want to write something generic, you would still need to locate the next sibling tag/text node with <code>next_sibling</code> or <code>find_next_sibling</code>.</p> <p>Here is the code that would handle both cases - when there is an element after the label and the text node:</p> <pre><code>soup = BeautifulSoup(html, "html.parser") for label in soup.find_all("span", class_="pl"): value = label.find_next_sibling("span", class_="attrs") value = label.next_sibling.strip() if not value else value.get_text(strip=True) label = label.get_text(strip=True).strip(":") print(label, value) </code></pre> <p>Prints:</p> <pre><code>Director James Actor Tom Countries USA Language English </code></pre> |
2,019,701 | 0 | What is a quick way to run a single script to automatically install missing modules using only Perl core? <p>I inherited a project which is supposed to be able to be deployed to other servers. This project has a number of simple module dependencies which however might not be present on all target machines.</p> <p>As such I'd like to be able to run a single command line script that checks which Perl modules are installed and tries to automatically install missing ones via CPAN.</p> <p>Since this should be very basic (i.e. needing to install stuff to run the module installer would defeat the point) said script should only use Perl 5.8.8 core modules.</p> <p>Does something like that exist already or would i need to write it myself?</p> |
39,936,407 | 0 | <p>You've put your XML traversal inside a string. That traversal won't happen if it's not actual javascript. Additionally, moment.js will try to parse that literal string as a date, NOT the value from that traversal.</p> <pre><code>'x[i].getElementsByTagName("Date")[0].childNodes[0].nodeValue' </code></pre> <p>You need to unquote your traversal to get its value, then feed that to moment.js.</p> <pre><code>var utcDate = moment.utc(x[i].getElementsByTagName("Date")[0].childNodes[0].nodeValue, 'DD/MM/YYYY HH:mm'); </code></pre> |
4,133,771 | 0 | <p>You don't have to capture the <code>Horsie</code> or the <code>Birdie</code>.</p> <pre><code>s/Horsie(Doggie)Birdie/$1/g; </code></pre> <p>A similar thing should work for Javascript as well. This is probably as efficient as it gets, and at least as fast as using look-around assertions; although you should benchmark it if you want to know for sure. (The results, of course, will depend on the horsies, doggies and birdies in question.)</p> <p>Mandatory disclaimer: you should know <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">what happens</a> when you use regular expressions with HTML...</p> |
1,815,391 | 0 | <p>The idea is to use following fact which is true for integral operation:</p> <p><code>a*b > c</code> if and only if <code>a > c/b</code></p> <p><code>/</code> is integral division here.</p> <p>The pseudocode to check against overflow for positive numbers follows:</p> <p><strong>if (a > max_int64 / b) then "overflow" else "ok"</strong>.</p> <p>To handle zeroes and negative numbers you should add more checks.</p> <p>C code for non-negative <code>a</code> and <code>b</code> follows:</p> <pre><code>if (b > 0 && a > 18446744073709551615 / b) { // overflow handling }; else { c = a * b; } </code></pre> <p>Note: </p> <pre><code>18446744073709551615 == (1<<64)-1 </code></pre> <p>To calculate carry we can use approach to split number into two 32-digits and multiply them as we do this on the paper. We need to split numbers to avoid overflow.</p> <p>Code follows:</p> <pre><code>// split input numbers into 32-bit digits uint64_t a0 = a & ((1LL<<32)-1); uint64_t a1 = a >> 32; uint64_t b0 = b & ((1LL<<32)-1); uint64_t b1 = b >> 32; // The following 3 lines of code is to calculate the carry of d1 // (d1 - 32-bit second digit of result, and it can be calculated as d1=d11+d12), // but to avoid overflow. // Actually rewriting the following 2 lines: // uint64_t d1 = (a0 * b0 >> 32) + a1 * b0 + a0 * b1; // uint64_t c1 = d1 >> 32; uint64_t d11 = a1 * b0 + (a0 * b0 >> 32); uint64_t d12 = a0 * b1; uint64_t c1 = (d11 > 18446744073709551615 - d12) ? 1 : 0; uint64_t d2 = a1 * b1 + c1; uint64_t carry = d2; // needed carry stored here </code></pre> |
39,428,224 | 0 | <p>Assuming you are using <code>WPF</code> try to reading this: <a href="http://stackoverflow.com/questions/847752/net-wpf-remember-window-size-between-sessions">.NET WPF Remember window size between sessions</a></p> <p>Assuming you are using <code>winForms</code>: <a href="http://www.codeproject.com/Articles/15013/Windows-Forms-User-Settings-in-C" rel="nofollow">http://www.codeproject.com/Articles/15013/Windows-Forms-User-Settings-in-C</a></p> <p>I think these articles will be a good starting point. Good Luck:)</p> |
21,107,852 | 0 | Change the column label? e.g.: change column "A" to column "Name" <p>Can anyone tell me how to change the column label? </p> <p>For example, I want to change Column "A" to Column "Name" in <code>Excel</code>.</p> |
35,612,931 | 1 | Python CSV joining columns <p>I am trying to make a new columnn with conditional statements utilizing Pandas Version 0.17.1. I have two csv's both about 100mb's in size.<br> What I have:</p> <p>CSV1:</p> <pre><code> Index TC_NUM 1241 1105.0017 1242 1105.0018 1243 1105.0019 1244 1105.002 1245 1105.0021 1246 1105.0022 </code></pre> <p>CSV2:</p> <pre><code>KEYS TC_NUM UXS-689 3001.0045 FIT-3015 1135.0027 FIT-2994 1140.0156 FIT-2991 1910, 1942.0001, 3004.0004, 3004.0020, 3004.0026, 3004.0063, 3004.0065, 3004.0079, 3004.0084, 3004.0091, 2101.0015, 2101.0016, 2101.0017, 2101.0018, 2101.0050, 2101.0052, 2101.0054, 2101.0055, 2101.0071, 2101.0074, 2101.0075, 2206.0001, 2103.0001, 2103.0002, 2103.0009, 2103.0011, 3000.0004, 3000.0030, 1927.0020 FIT-2990 2034.0002, 3004.0035, 3004.0084, 2034.0001 FIT-2918 3001.0039, 3004.0042 </code></pre> <p>What I want:</p> <pre><code> Index TC_NUM Matched_Keys 1241 1105.0017 FIT-3015 1242 1105.0018 UXS-668 1243 1105.0019 FIT-087 1244 1105.002 FIT-715 1245 1105.0021 FIT-910 1246 1105.0022 FIT-219 </code></pre> <p>If the TC_NUM in CSV2 matches the TC_NUM from CSV1, it prints the key in a column on CSV1</p> <p>Code:</p> <pre><code>dftakecolumns = pd.read_csv('JiraKeysEnv.csv') dfmergehere = pd.read_csv('output2.csv') s = dftakecolumns['KEYS'] a = dftakecolumns['TC_NUM'] d = dfmergehere['TC_NUM'] for crows in a: for toes in d: if toes == crows: print toes dfmergehere['Matched_Keys'] = dftakecolumns.apply(toes, axis=None, join_axis=None, join='outer') </code></pre> |
28,113,938 | 0 | <p>Your code should look something like this,</p> <pre><code><?php $items_extended = array("1. \\Device\\NPF_{1AAAAA99-7933-4CBC-AF26-2A1C1394BD94} (VirtualBox Host-Only Network)", "2. \\Device\\NPF_{2BBBBB88-75BB-4CD0-970A-36430287C245} (Wireless Network Connection 6)", "3. \\Device\\NPF_{3CCCCC77-8469-4445-A2ED-9C0FDDBA1C3D} (Wireless Network Connection 7)", "4. \\Device\\NPF_{4EEEEE66-2C9D-4D47-B7EA-8A20A40A149B} (Local Area Connection)"); $items = array(); foreach($items_extended as $key => $value){ preg_match('#\((.*?)\)#', $value, $match); $items[($key + 1)] = $match[0]; } ?> </code></pre> |
7,831,503 | 0 | Managing two tableviews in a single class <p><strong>How to access two or more tableViews in a single class with tabledatasource and tabledelegates?</strong></p> |
40,598,603 | 0 | <p>Well, you defintitely need a ETL tool then and preferably SSIS. First it will drastically improve your transfer rates while also providing robust error handling. Additionally you will have to use lookup transforms to ensure duplicates do not enter the sytsem. I would suggest go for Cache Connection Manager in order to perform the look-ups. </p> <p>In terms of design, if your source system (OurDB) is having a primary key say recId, then have a column say source_rec_id in your InterfaceDB table. Say your first run has transferred 100 rows. Now in your second run, you would then need to pick 100+1th record and move on to the next rows. This way you will have a tracking mechanism and one-to-one correlation between source system and destination system to understand how many records have got transferred, how many are left etc.</p> <p>For best understanding of SSIS go to <a href="https://channel9.msdn.com/Search?term=ssis#ch9Search&lang-en=en" rel="nofollow noreferrer">Channel 9 - msdn - SSIS</a>. Very helpful resource.</p> |
767,774 | 0 | <p>If you sometimes need an expression and sometimes need a delegate, you have 2 options:</p> <ul> <li>have different methods (1 for each)</li> <li>always accept the <code>Expression<...></code> version, and just <code>.Compile().Invoke(...)</code> it if you want a delegate. Obviously this has cost.</li> </ul> |
25,934,148 | 0 | SAS: Table name with too many characters <p>SAS has a 32 character limit for table- and column-names. I have a scenario where I want to select from Table A and join with Table B (where Table B has a name above 32 characters). If I try to write this in PROC SQL, I get an error saying that Table B has a name exceeding 32 characters. </p> <p>Anyone know how I can get arround this?</p> |
5,715,452 | 0 | Can I publish another site's image as it is mine with htaccess mod_rewrite? <p>I know question seems little scamy but I couldn't find a better way to ask.</p> <p>I have few websites and there are lot of images that are common. So I decided to publish common files from one source not to use more disc space. But I also don't want visitors to know it and want to show all contents publishing from own domain.</p> <p>Can I get an image from <a href="http://domain2.com/image.jpg" rel="nofollow">http://domain2.com/image.jpg</a> by requesting <a href="http://domain1.com/image.jpg" rel="nofollow">http://domain1.com/image.jpg</a> ? I tried some combinations but couldn't succeed!</p> <p>Thank you!</p> |
4,262,193 | 0 | <p>You need to convert the values to Number, there are plenty of ways to do it:</p> <pre><code>var test1 = +window.prompt("Number1"); // unary plus operator var test2 = Number(window.prompt("Number2")); // Number constructor var test3 = parseInt(window.prompt("Number3"), 10); // an integer? parseInt var test4 = parseFloat(window.prompt("Number4")); // parseFloat </code></pre> |
23,358,967 | 0 | Sorting hash of hashes in perl using a Dumper <p>I have a hash of hashes like this:</p> <pre><code>%hash = { car => { '10' => 'y', '11' => 'y', '12' => 'y', '13' => 'y' }, bus => { '10' => 'y', '11' => 'y', '12' => 'y', '13' => 'y' }, tr => { '10' => 'y', '11' => 'y', '12' => 'y', '13' => 'y' } } </code></pre> <p>How can I can in PERL to print this hash of hashes (using Dumper) where the keys of each section are sorted (10,11,12,13,14...) in the above order?</p> <p>Thanks in advance,</p> <p>Miki</p> |
417,078 | 0 | ASP.NET - how to stop unrequired server validation <p>I have used ValidatorEnable to disable a RequiredFieldValidator in javascript. However on postback the control being validated by the validator is still validated ... even though I disabled the validator on the client.</p> <p>I understand why this is happening since I've only disabled the client validation ... however is there a nice way to determine that I've disabled the client validation and to then disable the server validation on postback?</p> |
40,145,387 | 0 | this.style.background is returning wrong value <p>I am trying to create an RGB color guessing game. The premise is that each time someone clicks on a div, the function should retrieve it's color value and match it with the random color value(pre-selected) out of a given number of color values.</p> <p>Now, the game has two difficulty levels. Easy and hard. The code for the two levels is almost same, the number of color divs in easy are 3, while in the case of hard, the number of color divs is 6.</p> <p>However, while in easy mode, the function is retrieving a color value which belongs to none of the three divs. In fact, it is returning the background color value.</p> <p>Here is the code</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-js lang-js prettyprint-override"><code> var colors = randomColors(6); var easyColor = []; var squares = document.querySelectorAll(".square"); function color() { var a = Math.floor(Math.random()*250); var b = Math.floor(Math.random()*250); var c = Math.floor(Math.random()*250); return "rgb("+ [(a),(b),(c)].join(', ') + ")"; } function randomColors(num) { var arr = []; for(var i =0; i < num; i++) { arr.push(color()); } return arr; } // Tried to generate different set of colors for easy mode. Still working on it. for(var x = 0; x < 3; x++) { easyColor[x] = color(); } var easyRandomColor = easyColor[Math.floor(Math.random()*easyColor.length)]; // selecting hard difficulty works same as playing again, hence the reload() document.getElementById("hard").addEventListener("click", function() { window.location.reload(); }); document.getElementById("reset").addEventListener("click", function() { window.location.reload(); }); var squareColor; // setting up the easy level of the game document.getElementById("easy").addEventListener("click", function() { document.getElementById("header").style.background = "#232323"; for(var y = 0; y < 3; y++) { squares[y].style.background = easyColor[y]; } for(var z = 3; z < 6; z++) { squares[z].style.background = "#232323"; } easyRandomColor = easyColor[Math.floor(Math.random()*easyColor.length)]; document.getElementById("guess").textContent = easyRandomColor; // setting up the background colors of easy level squares for(var j = 0; j < easyColor.length; j++) squares[j].addEventListener("click", function() { squareColor = this.style.background; console.log(squareColor, easyRandomColor); if(squareColor === easyRandomColor) { document.getElementById("header").style.background = name; document.getElementById("display").textContent = "Correct!"; document.getElementById("reset").textContent = "Play again?"; for(var k = 0; k < easyColor.length; k++) { squares[k].style.background = name; } } else{ this.style.background = "#232323"; document.getElementById("display").textContent = "Try again."; } }); document.getElementById("easy").classList.add("selected"); document.getElementById("hard").classList.remove("selected"); }); var randomColor = colors[Math.floor(Math.random()*colors.length)]; //changing the RGB in h1 to rgb of one the squares document.getElementById("guess").textContent = randomColor; //assigning colors to the squares and adding the click event for(var j = 0; j < squares.length; j++) { squares[j].style.background = colors[j]; squares[j].addEventListener("click", function() { var name = this.style.background; // console.log(name, randomColor); if(name === randomColor) { document.getElementById("header").style.background = name; document.getElementById("display").textContent = "Correct!"; document.getElementById("reset").textContent = "Play again?"; for(var k = 0; k < squares.length; k++) { squares[k].style.background = name; } } else{ this.style.background = "#232323"; document.getElementById("display").textContent = "Try again."; } }); }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { background-color: #232323; margin: 0; } html { margin: 0; padding: 0; } .square { width: 30%; /*background: purple;*/ padding-bottom: 30%; float: left; margin: 1.66%; transition: 0.2s ease-in; border-radius: 6%; } #container { margin: 0 auto; max-width: 600px; } h1, h3 { color: white; padding-top: 1%; padding-bottom: 0.5%; margin-top: 0; margin-bottom: 0; text-align: center; } #header { transition: 0.2s ease-in; } #nav { margin-top: 0; padding-top: 0; background: white; max-width: 100%; clear: left; } #nav p { margin: 0 auto; position: relative; max-width: 580px; } #reset { position: relative; } #hard { position: absolute; right: 0; } #easy { position: absolute; right: 50px; } #display { position: relative; left: 27%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html> <html> <head> <title>RGBA Guess</title> <link rel="stylesheet" type="text/css" href="colorgame.css"> </head> <body> <div id="header"> <h3> The Great </h3> <h1> <span id="guess">number</span> </h1> <h3> Guessing Game </h3> </div> <div id="nav"> <p> <button id="reset">New Colors</button> <span id="display"></span> <button id="easy">Easy</button> <button id="hard" class="selected">Hard</button> </p> </div> <div id="container"> <div class="square" id="sqaure1"></div> <div class="square" id="sqaure2"></div> <div class="square" id="sqaure3"></div> <div class="square" id="sqaure4"></div> <div class="square" id="sqaure5"></div> <div class="square" id="sqaure6"></div> </div> <script type="text/javascript" src="colorgame.js"></script> </body> </html></code></pre> </div> </div> </p> <p>I know, there is a better way to do this. I can instead call the randomColors(3) in easy mode, but I want to know what is it that I am doing wrong so that I can avoid it in the future.</p> <p>Than You</p> |
19,210,874 | 0 | PHP/MySQL - Best way to work with dates in DD MMM YYYY format? <p>I need to display dates in the <strong>DD MMM YYYY</strong> format on the website I'm working on. My first thought was to store the dates in a DATE type in MySQL, then convert to the proper format using PHP. However, this is just returning <strong>01 Jan 1970</strong> - not the actual date of <strong>04 May 1891</strong>. </p> <p>I found a few other places where people have asked similar questions and the answer was always something like <code>SELECT date_format(dt, '%d/%m/%Y')</code> which was giving me <strong>04/05/1891</strong>. I want the month to be 3 characters (May, Jun, Jul, Aug, etc).</p> <p>I thought about storing the dates as a VARCHAR but that seems like it would be bad practice. It looks like I will have to store the date as a string and will not be able to use the PHP date() function because it cannot handle dates prior to 1970.</p> <p>I may want to do things like calculate ages which sounds painful when dealing with strings... I am wondering if anyone has a more elegant solution?</p> |
9,157,550 | 0 | <p><a href="http://xamarin.com/monotouch">Monotouch</a> is not a cross-compiler, and even if it were that alone would not cause a performance penalty.</p> <p>Monotouch is a .Net compatible runtime that <a href="http://www.mono-project.com/Mono%3aRuntime#Embedded_systems">runs on iOS embedded</a> within a normal c/obj-c program. It includes bindings for more or less the same things you can do from normal iOS apps. Monotouch apps are AOT compiled rather than JIT compiled so in most cases they run just as fast as "normal apps"</p> <p>The fact that <a href="http://www.sencha.com/products/touch">SenchaTouch</a> is a javascript framework suggests to me that you will be running mainly interpretted code. I'm sure the Sencha people have done a good job but I would be suprised if it were faster than mono. Looking at Sencha, one advantage is that you can write for android, blackberry and iOS. You can share much of your code between MonoTouch and <a href="http://xamarin.com/monoforandroid">Mono for Android</a>, you need two licenses and can't share everything.</p> |
26,800,079 | 0 | <p>If you already have <code>NSData* dataRead</code> from "Safari Extensions List", just save it to a file:</p> <pre><code>[dataRead writeToFile:@"/tmp/extensions_list.plist" atomically:YES]; </code></pre> |
35,273,100 | 0 | How to catch up full gcc compile command <p>For example during use <code>make</code> or <code>b2</code> you can't see command, because build system invokes gcc implicitly. I want to know full command, which build system send to compiler. conceptually. I want to catch up it independently on build system. Maybe on system level, maybe do you know another way. OS: linux.</p> |
13,044,573 | 0 | <p>you may use Session variable to store updated status and then check if it is available in otherpage.aspx,update textbox and reset it.</p> <p>Insert Page</p> <pre><code>if (CodeClass.InsertData(txtFirstName.Text, txtLastName.Text, Gender) == true) { Session["status"]="InsertSuccess"; Response.Redirect("OtherPage.aspx"); } } </code></pre> <p>Other Page</p> <pre><code>if (Session["status"]!=null) { txtLabel.Text = "Record inserted succesfully!"; Session["status"]=null; } </code></pre> |
24,981,436 | 0 | Show parks in terrain view <p>I use a map with the "terrain"-view on. But in this view the POI -> Parks are somehow overlayed. Any idea how to solve this? Maybe overlaying an terrain-map with an standard roadmap?</p> <p>Funny thing is: when zoom level >13, the Parks are shown, maybe this zoom level can be adjusted?</p> <p>I don't know how but somehow <a href="http://instaearth.me/" rel="nofollow">http://instaearth.me/</a> solved this problem.</p> |
36,039,768 | 0 | <p>You can use</p> <pre><code>(?im)^.*\bthe car\b(?!.*\bnot\b).* </code></pre> <p>The <a href="https://regex101.com/r/pT0mP7/2" rel="nofollow">regex demo is available here</a></p> <p>Pattern breakdown:</p> <ul> <li><code>(?im)</code>- enable case-insensitive and multiline matching modes</li> <li><code>^</code> - start of a line (since <code>(?m)</code> is used)</li> <li><code>.*</code> - match 0+ any characters but a newline</li> <li><code>\bthe car\b</code> - 2 whole words "the car" (a sequence of 2 words)</li> <li><code>(?!.*\bnot\b)</code> - a negative lookahead that fails the match if there is a whole word "not" somewhere to the right of <code>the car</code></li> <li><code>.*</code> - the rest of the line up to the newline or end of string</li> </ul> |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.