pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
28,422,403 | 0 | <p>In apps with user sessions, it is usually best to keep login/signup on a separate view hierarchy from the rest of the app and present the internal structure if there is an active session. You can achieve this by checking for</p> <pre><code>[PFUser currentUser] </code></pre> <p>as it will return <code>nil</code> if the user is not logged in.</p> <p><strong>Provide a check in your AppDelegate like so:</strong></p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // .. Rest of your initialization code if ([PFUser currentUser]) { // Let's pop them right to the home screen [self showHomeScreen]; } else { // Present login vc LoginView *lv = [[LoginView alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:lv]; self.window.rootViewController = nav; } return YES; } - (void)showHomeScreen { SidebarViewController *sbvc = [[SidebarViewController alloc] init]; UINavigationController *menuVC = [[UINavigationController alloc] initWithRootViewController:sbvc]; UIViewController *home = [[UIViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:home]; SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:menuVC frontViewController:nav]; self.window.rootViewController = revealController; } </code></pre> <p>Then, by including</p> <pre><code>- (void)showHomeScreen; </code></pre> <p>in <code>AppDelegate.h</code>, you can call this method upon successful registration/login:</p> <pre><code>AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [delegate showHomeScreen]; </code></pre> |
1,233,445 | 0 | <p>In Erlang, the <code>and</code> and <code>or</code> operators do not do short-circuit evaluation; you have to use <code>orelse</code> and <code>andalso</code> operators if you want short-circuiting behavior.</p> |
18,693,543 | 0 | <p>If you're using smarty 3, just remove the {literal} tag and it should work fine. If not, and you don't want to be opening and closing literal tags, declare all the variables you need outside the literal section ie:</p> <pre><code><script> var video_link = "{$video_link}"; {literal} function postlike() {... video : video_link </code></pre> |
7,901,430 | 0 | How to execute multiple async calls in parallel? <p>I have a number of commands that make calls to a soap web service (Betfair API). All are of the classic asynchronous programming model type ...</p> <pre><code>public void DoXXX( <input parameters ...> ) { XXXRequest Request = new XXXRequest(); // populate Request from input parameters ... BetfairService.BeginXXX( Request, XXXCallback, State ); } private void XXXCallback(IAsyncResult Result) { XXXResponse Response = BetfairService.EndXXX(Result); if (Response.ErrorCode == XXXErrorCode.OK) // store data from Response else // deal with error } </code></pre> <p>I want to execute a specified set of commands, and then do some calculations using the combined returned data values, once all of commands are completed.</p> <p>I'm able to do this as a sequence, by making a queue of commands and having each callback method trigger the next command in the queue once it's complete, with the calculation as the last item in the queue. This is relatively slow however.</p> <p>My ideal solution would be to have all of these commands running in parallel and then to have the calculation triggered once all of the commands are completed. I've tried looking at Task.Factory.FromAsync(), but all of the examples I can find only include direct calls to BeginXXX / EndXXX, not doing anything with the response.</p> <p>Does anyone have any pointers for a suitable solution to this problem?</p> |
28,342,923 | 0 | How to access nodejs config parameter in angular side? <p>i have nodejs config file(backend) in which some configuration data is defined:</p> <pre><code>module.exports = { product: { name: 'Event' }, server: { host: '0.0.0.0', port: 8000 }, database: { host: '127.0.0.1', port: 27017, db: 'EventExchange', username: '', password: '' }, key:{ privateKey: 'dufediioeduedhn', tokenExpiry: 1*30*1000*60 //1 hour }, admin:{ "username" : "admssin", "password" : "adminss123", "scope" : "adamssin" } }; </code></pre> <p>i have to access <code>port</code> and <code>host</code> parameter in angular(client side). how is it posssible ? Thanks!</p> |
37,735,629 | 0 | recursive attempt to load library - What does that mean in android? <p>I am working with android SIP for VoIP. The application is receiving calls successfully. However, initiation a call is having some bugs.</p> <p>there is no error in the logs but info which says </p> <p>" I/art: Thread[1,tid=23775,WaitingForJniOnLoad,Thread*=0xb4f07800,peer=0x759512e0,"main"] recursive attempt to load library "/system/lib/librtp_jni.so" "</p> <p>Can anyone explain what is the problem and how could we possible solve it?</p> |
8,298,799 | 0 | SSRS Summing Group Variables outside of the group <p>I have succeeded in building a number of group variables within an SSRS report, however what I want to do now is to use that variable outside of the group. </p> <p>eg - I have a variable that calculates a payment within one dataset, and another one that calculates a payment within another dataset. </p> <p>The first would be <code>=Variables!QualityPayment.Value</code>, the second would be <code>=Variables!RevenuePayment.Value</code>. Revenue and Quality are displayed in different SSRS tables. </p> <p>I want to add the Quality Payment and Revenue Payment together, but when I try and put them outside of the table I get the error message </p> <p><em>'Expressions can only refer to a Variable declared within the same grouping scope, a containing grouping scope, or those declared on the report.'</em></p> <p>How do I go about adding the two together?</p> <p>Thanks in advance</p> <p>Jon</p> |
35,741,298 | 0 | <p>Yes, you may use inner_product (dot product) to take the result in very simple way.</p> <p>Make vectors </p> <pre><code>V2 = P - P2 V3 = P - P3 V = P3 - P2 </code></pre> <p>Find signs of dot products <code>D2 = Dot(V2,V)</code> and <code>D3 = Dot(V3,V)</code></p> <p>Projection of Point P lies at S(P2, P3), if </p> <pre><code>D2 >=0 and D3 <=0 </code></pre> <p>Note - there is no need in normalizations, square roots etc. Just some subtractions, multiplications and additions.</p> <p>(Explanation - angles <code>P-P2-P3</code> and <code>P-P3-P2</code> should be acute or right)</p> |
13,694,421 | 0 | Resize tumblr videos <p>I have created a tumblr theme. Everything was working till I decided to post a video on tumblr video upload. I have a box on main page 250x196 pixels where everything goes in. </p> <ul> <li>If it is a photo, I just make it 250x196 pixels (I don't care about aspect ratio. I've used jQuery to keep aspect ratio but I didn't like the result).</li> <li>If it's a photoset I use anythingslider and create a slide.</li> <li>If it's a text post I use jquery and take the first image as a tumbnail.</li> <li>If it's a video the same as photos. I just resize the iframe. At least that's what I thought I was doing.</li> </ul> <p><em>I also use prettyphoto as a lightbox clone for both images and videos.</em></p> <p>So when I used tumblr upload video, I had these problems: </p> <ol> <li>First the video didn't get the aspect ratio of the iframe i think the reason for that might be the data values for height and with the iframe is using.</li> <li>As you can see <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/" rel="nofollow"><strong>here</strong></a>; for the iframe to appear, I was using the inline method. I had a hidden div which had the 500pixels version of the video. The problem is that {Video-250} and {Video-500} tumblr variables both create a div for the tumblr videos with the same id. So it takes the hidden video and moves it next to the 250 pixels version.</li> <li>The build in lightbox of tumblr for videos had a conflict with prettyphoto. When I was clicking the full screen of the video something was wrong with the z-indexes. I didn't spend time on solving this issue because I already had so many problems.</li> </ol> <p>As a workaround, What I did was this: </p> <pre><code> <div class="media" data-embed="{JSVideoEmbed-250}" data-video="{JSVideo-250}"></div> </code></pre> <p>You can see exactly what I mean on a test blog i create with three random videos:</p> <p><a href="http://stroumfaki.tumblr.com/" rel="nofollow">http://stroumfaki.tumblr.com/</a></p> <p>But the problem with the resizing still remains. The iframe is 250x196 pixels but the contents aren't. I also don't understand why tumblr posts a javascript in the first only video. The same script it posts at the end of the page. </p> <p>What I ask might be a bit hard to articulate. I hope the test blog will help you understand what I mean.</p> |
32,471,459 | 0 | How to find visible element and perform click action in robot framework? <p>I have one window on which i have four links</p> <ol> <li><p>Exit Button Link - <code><a id="exitBtn" class="x-btn questionpreview_exitbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 0px; top: 0px; margin: 0px;"></code></p></li> <li><p>Submit button Link - <code><a id="submitBtn" class="x-btn questionpreview_submitbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 864px; top: 0px; margin: 0px;"></code></p></li> <li><p>Back Button Link - <code><a id="prevBtn" class="x-btn questionpreview_backbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 733px; top: 0px; margin: 0px; display: none;"></code></p></li> <li><p>Review Button Link - <code><a id="reviewBtn" class="x-btn questionpreview_reviewbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 798px; top: 0px; margin: 0px; display: none;"></code></p></li> </ol> <p>Out of these five button only two button (Exit and Submit) are visible on first window. When I click on submit button having using this locator:</p> <pre><code>xpath=//*[contains(text(),'Question Preview')]/ancestor::div[6]//div[@id="previewWindow-body"]//div[@id="preview-top-container"]//*[contains(text(),'Submit')]/ancestor::a` </code></pre> <p>it works and the next window opens. On next window submit button gets hidden and it shows exit, back and Review button</p> <p>They look like this</p> <ol> <li><p>Exit button - <code><a id="exitBtn" class="x-btn questionpreview_exitbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 0px; top: 0px; margin: 0px;"></code></p></li> <li><p>Back Button - <code><a id="prevBtn" class="x-btn questionpreview_backbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 798px; top: 0px; margin: 0px;"></code></p></li> <li><p>Review Button - <code><a id="reviewBtn" class="x-btn questionpreview_reviewbtn_sb x-unselectable x-btn-toolbar x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" tabindex="0" unselectable="on" hidefocus="on" style="right: auto; left: 863px; top: 0px; margin: 0px;"></code></p></li> </ol> <p>My question is when next window opens I could not click any or find any of these three buttons. I am using xpath for back button as <code>//*[contains(text(),'Back')]/ancestor::a[@id="prevBtn" and not(contains(@style,'display: none'))]</code> but it is not working.</p> |
10,378,109 | 0 | <p>If you look in the code, it looks like there was a pull request to get generators in, but for some reason that hasn't happened. You can use twitter-bootstrap-rails first to get those files, and then overwrite them with bootstrap-sass.</p> <p>You can also try this:</p> <pre><code>compass create compass-test -r bootstrap-sass --using bootstrap </code></pre> <p>This isn't really a substitute for scaffolding, though.</p> |
283,180 | 0 | Is there a way to put aspx files into a class library in Visual Studio 2008 .NET 3.5? <p>I've got a lot of pages in my site, I'm trying to think of a nice way to separate these into areas that are a little more isolated than just simple directories under my base web project. Is there a way to put my web forms into a separate class library? If so, how is it done?</p> <p>Thanks in advance.</p> |
2,957,250 | 0 | <p>In your edit you specify that your helper class is in a seperate assembly. If you want to avoid references and you have control over your app.config files you could put an </p> <pre><code><add key="typeOfSystem" value="Forms|Web"/> </code></pre> <p>in your projects and access it with</p> <pre><code>ConfigurationManager.AppSettings["typeOfSystem"] </code></pre> <p>using <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx" rel="nofollow noreferrer">ConfigurationManager</a> along with its property <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx" rel="nofollow noreferrer">AppSettings</a>. Don't forget to add a reference to <code>System.Configuration</code> in your project. Note that you get the AppSettings of the hosting application. By doing this you <em>need</em> to add a key in your parent application's app.config, or output some error or warning if it's not specified perhaps.</p> |
12,711,362 | 0 | <p>Go to <code>Plugins -> Source Code Formatter -> Format Current Source</code> or just press <code>Ctrl + I</code>.</p> <p>If you want to set up your formatting preferences, choose <code>Plugins -> Source Code Formatter -> Options...</code></p> |
19,805,745 | 0 | <p>The "offender" can be found in <code>TitleAreaDialog.getInitialSize()</code>. It uses some hard-coded constants for minimum size.</p> <p>Depending on how you want the dialog to look like, there are several solutions:</p> <ul> <li>override <code>getInitialSize()</code> and specify whatever size you want</li> <li>override <code>initializeBounds()</code> and set some size of your own, or call <code>this.getShell().pack()</code>. In this case don't forget to first call <code>super.initializeBounds()</code> because from what I see from the code, it seems it does more than just initializing the bounds.</li> </ul> |
3,146,328 | 0 | Making an HttpRequest with MultipartEntity in it <p>I've been frustrated at trying to figure out how to make an http request with a multipart entity in it. The multipart has a custom boundary but I can't seem to be able to set it. My code below results in a response message of saying that my message does not contain multiple parts. </p> <pre><code>HttpPut addDoc = new HttpPut(url); addDoc.addHeader("Content-Type", "multipart/related; boundary=\"END_OF_PART\""); String bodyString = "Test for multipart update"; String titleString = "Title Test for multipart update"; MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); StringBody title = new StringBody(titleString, "application/atom+xml",Charset.forName("UTF-8")); StringBody body = new StringBody(bodyString, "text/plain",Charset.forName("UTF-8")); entity.addPart("title", title); entity.addPart("body", body); addDoc.setEntity(entity); </code></pre> |
31,508,189 | 0 | Shopify - Untrusted Connection on App Instal <p>I am working on a new app and am installing it manually by typing the URL into my web browser. This is properly bringing me to my Shopify store and is displaying the permissions screen as desired; however, when I click the 'Install app' button, I receive a page that says there is an Untrusted Connection. The URL in the browser reads:</p> <p>https://.myshopify.com.myshopify.com/admin/oauth/authorize?client_id=&scope=read_customers,write_orders&redirect_uri=;</p> <p>Note that the myshopify.com portion of the URL is repeated twice and the user is not sent to the redirect URI I specified.</p> <p>What could be going wrong here? How can I fix this issue? Shopify doesn't really offer much in the form of support. Any help would be appreciated.</p> |
12,006,393 | 0 | <p>From the "Core Data Programming Guide":</p> <blockquote> <p>... To summarize, though, if you execute a fetch directly, you should typically not add Objective-C-based predicates or sort descriptors to the fetch request. Instead you should apply these to the results of the fetch.</p> </blockquote> <p>This means that you cannot use a custom sort descriptor in your fetch request. You must store an additional (non-transient) attribute in the entity, for example "0", "1", "2" for positive/negative/zero sums.</p> <p>You can then use this attribute for both the sort descriptor <em>and</em> for the <code>sectionNameKeyPath</code>, you don't need a transient attribute "sectionName".</p> <p>The mapping from "0", "1", "2" to the actual section header is then done in <code>tableView:titleForHeaderInSection:</code>.</p> <pre><code>- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[self.controller sections] objectAtIndex:section]; int order = [[sectionInfo name] intValue]; if (order == 0) return @"POSITIVE SECTION"; else if (order == 1) return @"NEGATIVE SECTION"; else return @"ARCHIVE SECTION"; } </code></pre> |
2,264,213 | 0 | 'MINMAXINFO' : undeclared identifier in MFC application <p>I tried to use MINMAXINFO to resize the window dynamically in MFC application (in VS 2008). i added OnGetMinMaxInfo function through properties window.</p> <p>When i compile the code, i get an error saying that </p> <p>'ON_WM_GETMINMAXINFO': identifier not found 'MINMAXINFO' : undeclared identifier</p> <p>Please help me to resolve this.</p> <p>Regards, AH</p> |
17,204,279 | 0 | Does Java 8 Support Closures? <p>I'm confused. I thought Java8 was going to emerge from the stone age and start supporting lambdas / closures. But when I try:</p> <pre><code>public static void main(String[] args) { int number = 5; ObjectCallback callback = () -> { return (number = number + 1); }; Object result = callback.Callback(); System.out.println(result); } </code></pre> <p>it says that <code>number should be effectively final</code>. That's uh, not a closure I think. That just sounds like it's copying the environment by value, rather than by reference.</p> <p><strong>Bonus question!</strong></p> <p>Will android support Java-8 features?</p> |
976,465 | 0 | parallel c++ join in .net 1.1 <p>I'm trying to spawn and then join two threads using MS VS 6.0 (2003), MS .NET Framework 1.1.</p> <p>The following seems to be a reasonable solution:</p> <pre><code>CWinThread* thread1 = AfxBeginThread(worker, &parallel_params); CWinThread* thread2 = AfxBeginThread(worker, &parallel_params); WaitForSingleObject(thread1->m_hThread, INFINITE); WaitForSingleObject(thread2->m_hThread, INFINITE); </code></pre> <p>but my main concern has to do with this statement in the documentation: "If this handle is closed while the wait is still pending, the function's behavior is undefined." When do handles get closed? Does ending the worker proc close the handle? If so, am I in trouble? Is this really a reasonable solution??</p> |
34,325,120 | 0 | Isabelle and class overloading <p>Two classes are defined containing the same function, but when the two classes is used in a locale there is an unification error:</p> <pre><code>theory Scratch imports Main begin class c1 = fixes getName :: "'a ⇒ string" class c2 = fixes getName :: "'a ⇒ string" locale c12 = fixes match :: "('a::c1) ⇒ ('b::c2) ⇒ bool" assumes as : "match a b ⟶ (getName a) = (getName b)" end </code></pre> <p>The unification error is resolved by renaming (getName b) to (getName_b b) and use the class definition</p> <pre><code> class c2 = fixes getName_b :: "'a ⇒ string" </code></pre> <p>Does a solution exist without renaming?</p> <p><a href="http://stackoverflow.com/questions/15870788/defining-overloaded-constants-in-isabelle">Here</a> a solution is given when the overloading is needed when datatypes are parameters. </p> |
26,773,244 | 0 | <p>In the code specified there is no implementation of com.konylabs.middleware.common.JavaService2 class. JavaService will work if you implement JavaService2 class in your class file and override its invoke meathod.</p> <p>below is the sample:</p> <pre><code>public class <YOUR CLASS NAME> implements JavaService2 { @Override public Object invoke(String serviceId, Object[] arg1, DataControllerRequest arg2, DataControllerResponse arg3) throws Exception { // YOUR LOGIC return result; } </code></pre> <p>}</p> |
27,044,983 | 0 | <p>The Swift solution (thanks @YvesJusot): </p> <pre><code>let calendar = NSCalendar.currentCalendar() let comps = calendar.components(NSCalendarUnit.WeekOfYearCalendarUnit|NSCalendarUnit.YearCalendarUnit|NSCalendarUnit.MonthCalendarUnit|NSCalendarUnit.WeekCalendarUnit|NSCalendarUnit.WeekdayCalendarUnit, fromDate: NSDate()) as NSDateComponents comps.setValue(2, forComponent: NSCalendarUnit.WeekdayCalendarUnit) let monday = calendar.dateFromComponents(comps)! println("\(monday)") </code></pre> |
29,915,283 | 0 | <p>Twilio developer evangelist here.</p> <p>I'm afraid <a href="https://www.twilio.com/docs/api/rest/call#list-get-filters" rel="nofollow">the Calls endpoint only takes one "From" number as a filter</a>, you can't pass a list of numbers to it. You might want to return all calls and then filter manually yourself or alternatively loop through the numbers you want to return calls from and make list calls for each of them.</p> |
31,529,310 | 0 | Where is the Java bug in my constructor code for this KnockKnockProtocol class? <p>I'm studying the following client/server code called <a href="https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html" rel="nofollow">KnockKnockServer and KnockKnockClient.</a> It also has a helper class called <a href="https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockProtocol.java" rel="nofollow">KnockKnockProtcol</a>, which is responsible for the order of KnockKnock jokes.</p> <p>I want to modify it so that you can start the program at a specific joke. As it is right now, you have to start with the first joke. </p> <p>This is what tried for KnockKnockProtocol:</p> <pre><code>public class KnockKnockProtocol { int ourstep; public KnockKnockProtocol (int step) { this.ourstep = step; } private static final int WAITING = 0; private static final int SENTKNOCKKNOCK = 1; private static final int SENTCLUE = 2; private static final int ANOTHER = 3; private static final int NUMJOKES = 5; private int state = WAITING; int currentJoke = ourstep; //we initialize the step here private String[] clues = { "Turnip", "Little Old Lady", "Atch", "Who", "Who" }; private String[] answers = { "Turnip the heat, it's cold in here!", "I didn't know you could yodel!", "Bless you!", "Is there an owl in here?", "Is there an echo in here?" }; public String processInput(String theInput) { String theOutput = null; if (state == WAITING) { theOutput = "Knock! Knock!"; state = SENTKNOCKKNOCK; } else if (state == SENTKNOCKKNOCK) { if (theInput.equalsIgnoreCase("Who's there?")) { theOutput = clues[currentJoke]; state = SENTCLUE; } else { theOutput = "You're supposed to say \"Who's there?\"! " + "Try again. Knock! Knock!"; } } else if (state == SENTCLUE) { if (theInput.equalsIgnoreCase(clues[currentJoke] + " who?")) { theOutput = answers[currentJoke] + " Want another? (y/n)"; state = ANOTHER; } else { theOutput = "You're supposed to say \"" + clues[currentJoke] + " who?\"" + "! Try again. Knock! Knock!"; state = SENTKNOCKKNOCK; } } else if (state == ANOTHER) { if (theInput.equalsIgnoreCase("y")) { theOutput = "Knock! Knock!"; if (currentJoke == (NUMJOKES - 1)) currentJoke = 0; else currentJoke++; state = SENTKNOCKKNOCK; } else { theOutput = "Bye."; state = WAITING; } } return theOutput; } } </code></pre> <p>And in the Server class, I call the KnockKnockProtocol like this :</p> <pre><code> /* omitting boilerplate code */ String inputLine, outputLine; // Initiate conversation with client KnockKnockProtocol kkp = new KnockKnockProtocol(2); outputLine = kkp.processInput(null); out.println(outputLine); while ((inputLine = in.readLine()) != null) { outputLine = kkp.processInput(inputLine); out.println(outputLine); if (outputLine.equals("Bye.")) break; </code></pre> <p>The problem is that , when I run my code I am always starting with the "Turnip" joke. How do I make it so that I can start at an arbitrary joke within the list of jokes? I can see that the joke is controlled by the <code>clues</code> array, but after that I'm not seeing it. thanks</p> |
9,972,988 | 0 | <p>You have to add your activity in <strong>AndroidManifest.xml</strong>. Refer this link : <a href="http://stackoverflow.com/questions/736571/using-intent-in-an-android-application-to-show-another-activity">Using Intent in an Android application to show another activity</a></p> |
11,364,484 | 0 | <p>I see the join is taking a while can you confirm you have the foreign key in place. Also if you show me the SQL I might be able to help.</p> |
26,804,433 | 0 | <p>Found my problem, had to specify the owner (self) when loading my nib:</p> <pre><code>self.view.addSubview(UINib(nibName: "KeyboardView", bundle: nil).instantiateWithOwner(self, options: nil)[0] as UIView) </code></pre> |
34,060,177 | 0 | <p>Jade indentation is "2 spaces"</p> <p>you should use</p> <pre><code>if !hide_it p hello </code></pre> <p>it would also work with the "-" prefix (javascript mode) but it is not advised in this case where the standard Jade <code>if</code> notation can work.</p> <p>you can test your template in the online demo - <a href="http://jade-lang.com/demo/" rel="nofollow">http://jade-lang.com/demo/</a></p> |
22,724,556 | 0 | <p>Sure it's possible. You'd need to explode the captured pages on the slash <code>/</code> and go from there though.</p> <pre><code>Route::any('{any}', function($pages) { $pages = explode('/', $pages); // Do whatever... })->where('any', '.*'); </code></pre> <p>A few things to be aware of:</p> <ol> <li>This route should be placed <strong>last</strong>, otherwise you won't be able to hit any other routes.</li> <li>This captures absolutely <strong>everything</strong>, you'll need to return an error should the page not exist.</li> <li>I'm using <code>Route::any</code> in the above to capture any request (<code>POST</code>, <code>GET</code>, etc), you might want to limit this to a subset of those or only <code>GET</code>, that's up to you.</li> <li>As pointed out in the comments below, you can no longer use the <code>URL::route</code> helper but you can still make use of the <code>URL::to</code> helper. This shouldn't be a problem as it's more than likely you're storing these dynamic pages in a database and as such the URI should be stored within the database as well.</li> </ol> |
24,454,657 | 0 | <p>Unfortunately for your case, I don't think this is possible to do <em>before</em> a bind like that. Here is another question on the subject: <a href="http://stackoverflow.com/questions/1379125/make-drop-down-list-item-unselectable">make drop down list item unselectable</a></p> <p><strong>Update:</strong></p> <p>I'm editing my answer based on Derrick's answer and your comment about it. Derrick is suggesting that <em>after</em> the dropdownlist is bound, then go through and disable the separators. So it would look something more like this:</p> <pre><code>protected void gvCategory_DataBound(object sender, EventArgs e) { foreach (ListItem li in gvCategory.Items) { if(li.Text.Contains("--")) li.Attributes.Add("disabled", "true"); } } </code></pre> <p><strong>Update 2:</strong></p> <p>Add the OnDataBound event to manipulate the DropDownList after it is bound.</p> <pre><code><asp:DropDownList ID="gvCategory" runat="server" OnDataBound="gvCategory_DataBound"></asp:DropDownList> </code></pre> |
33,045,588 | 0 | <p>Using data.table...</p> <pre><code>my_rows <- seq.int(max(tabulate(df$Initials))) library(data.table) setDT(df)[ , .SD[my_rows], by=Initials] # Initials data # 1: a 2 # 2: a 3 # 3: b 4 # 4: b NA </code></pre> <p><code>.SD</code> is the <strong>S</strong>ubset of <strong>D</strong>ata associated with each <code>by=</code> group. We can subset its rows like <code>.SD[row_numbers]</code>, unlike a data.frame which requires an additional comma <code>DF[row_numbers,]</code>.</p> <p>The analogue in dplyr is</p> <pre><code>my_rows <- seq.int(max(tabulate(df$Initials))) library(dplyr) setDT(df) %>% group_by(Initials) %>% slice(my_rows) # Initials data # (fctr) (dbl) # 1 a 2 # 2 a 3 # 3 b 4 # 4 b NA </code></pre> <p>Strangely, this only works if <code>df</code> is a data.table. I've filed <a href="https://github.com/hadley/dplyr/issues/1446" rel="nofollow">a report/query with dplyr</a>. There's a good chance that the dplyr devs will prevent this usage in a future version.</p> |
17,414,398 | 0 | Visual Studio 2012 Express Code Analysis <p>The Microsoft documentation talks about a limited set of code analysis tools being available for the express edition (e.g. <a href="http://blogs.msdn.com/b/visualstudio/archive/2012/09/12/visual-studio-express-2012-for-windows-desktop-is-here.aspx" rel="nofollow noreferrer">Microsoft Visual Studio Blog</a> ). </p> <p>I am using VS 2012 update 3, and can not see any code analysis options in context menus, or any buttons or menu options. I am pretty sure I ran some code analysis at some point, but that might have been before update 2 was installed.</p> <p>Does anyone know if this option has been removed from more recent express editions, and if not where I can find the appropriate menu item or settings to be able to run and view the results of code analysis.</p> <h3>Edit</h3> <p>there is a very clear description given below by Crippledsmurf, and it is obviously possible to access Code Analysis from vs express. I must have somehow changed some option, because none of the options described are accessible:</p> <p>Solution explorer - solution context menu: <img src="https://i.stack.imgur.com/6Dhd8.jpg" alt="solution context menu"></p> <p>project context menu:</p> <p><img src="https://i.stack.imgur.com/UtXlB.jpg" alt="project context menu"></p> <p>project properties:</p> <p><img src="https://i.stack.imgur.com/HXYZp.jpg" alt="project properties"></p> |
33,832,948 | 0 | <p><strong><a href="http://sqlfiddle.com/#!9/66a621/2" rel="nofollow">Sql Fiddle Demo</a></strong></p> <pre><code>SELECT g.country, g.gender, g.gender_count, (g.gender_count * 1.0 / c.country_count) * 100 FROM ( SELECT country, gender, count(*) as gender_count FROM YourTable GROUP BY country, gender ) g JOIN ( SELECT country, count(*) as country_count FROM YourTable GROUP BY country ) c ON g.country = c.country </code></pre> |
35,661,785 | 0 | <blockquote> <p>What I would like is for the Parent component to intercept the props.parentClassName set in GrandParent and change it, or create it if it doesn't exist.</p> </blockquote> <p>A component cannot intercept props from its parent because it has no access to its parent, only to its children!</p> <p>I'm still don't clearly understand what you want to achieve... Does the following code do what you want?</p> <pre><code>import _ from 'underscore'; import React from 'react'; class Grandparent extends React.Component { render() { return ( <div {... this.props}> <Parent> <span>hello</span> <span>welcome</span> <span className="red">red</span> </Parent> </div> ); } } // Parent component will add ``className="border"`` to each its // child without ``className`` property. class Parent extends React.Component { render() { return ( <div {... this.props}> {_.map(this.props.children, (v, k) => React.cloneElement(v, {className: v.props.className || 'border', key: k}))} </div> ); } } </code></pre> |
38,843,315 | 0 | <p>You can make JsonString to NSDicitonary.</p> <pre><code>NSError *jsonError; NSData *objectData = [@"{\"2\":\"3\"}" dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:&jsonError]; </code></pre> <p>and It is make NSDictionary with array.</p> <pre><code>- (NSDictionary *) indexKeyedDictionaryFromArray:(NSArray *)array { id objectInstance; NSUInteger indexKey = 0U; NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] init]; for (objectInstance in array) [mutableDictionary setObject:objectInstance forKey:[NSNumber numberWithUnsignedInt:indexKey++]]; return (NSDictionary *)[mutableDictionary autorelease]; } </code></pre> |
37,588,321 | 0 | <p>We can use <code>uniqueN</code> from <code>data.table</code></p> <pre><code>library(data.table) setDT(Database)[, NumDates := uniqueN(Date) , by = UserId] Database # UserId Hour Date NumDates #1: 1 18 01.01.2016 3 #2: 1 18 01.01.2016 3 #3: 1 14 02.01.2016 3 #4: 1 14 03.01.2016 3 #5: 2 21 03.01.2016 2 #6: 2 8 05.01.2016 2 #7: 2 8 05.01.2016 2 #8: 3 23 05.01.2016 1 </code></pre> |
39,119,798 | 0 | <p>There's an example in the documentation that uses a <code>ko.pureComputed</code> layer on top of the "real" number value:</p> <pre><code>this.price = ko.observable(25.99); this.formattedPrice = ko.pureComputed({ read: function () { return '$' + this.price().toFixed(2); }, write: function (value) { // Strip out unwanted characters, parse as float, then write the // raw data back to the underlying "price" observable value = parseFloat(value.replace(/[^\.\d]/g, "")); this.price(isNaN(value) ? 0 : value); // Write to underlying storage }, owner: this }); </code></pre> <p>Source: <a href="http://knockoutjs.com/documentation/computed-writable.html" rel="nofollow">http://knockoutjs.com/documentation/computed-writable.html</a></p> <p>This allows you to use the <code>formattedPrice</code> in your data-bind, and you can even write to it. <code>price</code> will remain a number. You'll need an extra property in your viewmodel for each number though...</p> <p>If it's only a one-way bind you're after, you could also create a <code>currencyFormatter</code> bind that extends the <code>text</code> binding:</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 formatCurrency = function(value) { value = parseFloat(("" + value).replace(/[^\.\d]/g, "")); return "$" + (isNaN(value) ? 0 : value); } ko.bindingHandlers.currencyText = { update: function(element, valueAccessor) { var originalValue = ko.unwrap(valueAccessor()); var formatValue = formatCurrency.bind(null, originalValue); ko.bindingHandlers.text.update.call(null, element, formatValue); } }; ko.applyBindings({ source: ko.observable(1) })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script> <input type="number" step="0.1" data-bind="value: source"> <h1 data-bind="currencyText: source"></h1></code></pre> </div> </div> </p> |
39,638,973 | 0 | <p>I think this should help you:-</p> <pre><code>var lols = [ { prop1: "h1", prop2: "h2", }, { prop1: "g1", prop2: "g2", } ] Object.keys(lols).map(function(key,index){ var lol = lols[key] lol["props3"]="g3" console.log(lol) }) </code></pre> <p>JS fiddle link <a href="https://jsfiddle.net/bps7zzf8/" rel="nofollow">https://jsfiddle.net/bps7zzf8/</a></p> |
14,320,527 | 0 | Android: should I use MimeTypeMap.getFileExtensionFromUrl()? [bugs] <p>For example, I wanted to get the file Extension from the file URL using the function below:</p> <p>File name:</p> <pre><code>Greatest Hits - Lenny Kravitz (Booklet 01) [2000].jpg </code></pre> <p>Url of the file:</p> <pre><code>String url = "/mnt/sdcard/mydev/Greatest Hits - Lenny Kravitz (Booklet 01) [2000].jpg"; </code></pre> <p>Function call:</p> <pre><code>String extension = MimeTypeMap.getFileExtensionFromUrl(url); </code></pre> <p>But I'm getting an exception on the function call. Is this a bug or a feature?</p> <p>It works fine for file names that don't contain that many foreign characters (such as paranthesis).</p> <p>Is the function buggy? Am I missing something? How am I supposed to differentiate a bug from a feature? I've read the function description and it should work properly.</p> <p>Do you personally use it in your projects? It doesn't seem <a href="http://code.google.com/p/android/issues/detail?id=5510" rel="nofollow">reliable</a>.</p> |
20,947,587 | 0 | <pre><code>array.forEach(function(object) { object.current = false; }); </code></pre> <p>or, if <code>forEach</code> is not present, such as on an ES3 implementation:</p> <pre><code>for (var i = 0, len = array.length; i < len; ++i) { array[i].current = false; } </code></pre> <p>or, with <a href="http://lodash.com/docs#forEach" rel="nofollow"><code>_.forEach</code></a> in Lo-Dash</p> <pre><code>_.forEach(array, function(object) { object.current = false; }); </code></pre> |
5,417,746 | 0 | <p>I tested the link on IE6,7,8. The slider works fine but they all throw an error on line 17:</p> <pre><code><script type="text/javascript"> <meta name="generator" content="Big Cartel" /> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-22000995-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </code></pre> <p>You have a meta tag inside the script tag</p> |
36,797,358 | 0 | <p>This is some code I knocked up in LinqPad, which does what you want:</p> <pre><code>void Main() { c(); } void a() { using(var id = new IndentedDebug()) { id.Trace("I'm in A"); } } void b() { using(var id = new IndentedDebug()) { id.Trace("I'm in B"); a(); } } void e() { a(); } void d() { e(); } void c() { using(var id = new IndentedDebug()) { id.Trace("I'm in C"); a(); b(); { using(var id2 = new IndentedDebug()) { id2.Trace("I'm still in C"); d(); } } } } class IndentedDebug : IDisposable { const int indentSize = 2; const char indentChar = ' '; static int indentLevel = 0; private string _indentSpaces; public IndentedDebug() { _indentSpaces = new string(indentChar, indentSize * indentLevel); ++indentLevel; } public void Trace(string message) { Console.WriteLine("{0}{1}", _indentSpaces, message); } public void Dispose() { --indentLevel; } } </code></pre> <p>So your code doesn't quite look the same, but on the other hand, it's not doing any "magic" either - the code itself shows you when the indented debug ends.</p> |
27,117,083 | 0 | asp.net c# create a new page and refresh routing map <p>I am using the <a href="https://github.com/Haacked/RouteMagic" rel="nofollow">routemagic</a> library and it works great. Except when I create a new page it doesn't refresh the route map.</p> <p>this is my save action:</p> <pre><code> protected void lbSave_Click(object sender, EventArgs e) { //save data to database; //recompile the route.cs var assembly = BuildManager.GetCompiledAssembly("~/Config/Routes.cs"); var registrar = assembly.CreateInstance("Routes") as IRouteRegistrar; } </code></pre> <p>in the Config/Route.cs class I have a foreach loop that ties the slug to the ID:</p> <pre><code>routes.MapPageRoute(events.Slug, events.Slug, "~/index.aspx?id=" + events.ID, true, new System.Web.Routing.RouteValueDictionary { { "id", events.ID } }); </code></pre> <p>but i still keep getting a 404 page for all new pages unless i refresh IIS..What I would need to do is add a new MapPageRoute everytime I create a new "event" to avoid the 404.</p> |
16,553,371 | 0 | <p>You're looking for <code>.distinct()</code></p> <p><a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.distinct" rel="nofollow">documentation</a></p> |
11,847,754 | 0 | <p>I haven't tried it myself, but possibly an <a href="http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html" rel="nofollow">AnimationDrawable</a> could work.</p> |
3,533,328 | 0 | <p>Put this in your app.config:</p> <pre><code><configuration> <appSettings> <add key="server" value="HASIBPC\SQLEXPRESS" /> <appSettings> </configuration> </code></pre> <p>And then in your code, access it using:</p> <pre><code>return ConfigurationSettings.AppSettings["server"].ToString(); </code></pre> |
27,656,881 | 0 | <p>You can not call private methods, there is no way for it directly. You could create wrappers that are those methods but as public. Best solution move them to public segemnt</p> |
40,920,960 | 0 | Cover flow works in Activity but it gives an error when I convert Activity to Fragment <pre><code> public class AnaSayfa extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { .... ... ... } public View getView(final int position, View convertView, ViewGroup parent) { MyFrame v; if (convertView == null) { v = new MyFrame(AnaSayfa.this); } else { v = (MyFrame)convertView; } v.setImageResource(mResourceIds[position % mResourceIds.length]); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); public static class MyFrame extends FrameLayout { private ImageView mImageView; public void setImageResource(int resId){ mImageView.setImageResource(resId); } public MyFrame(Context context) { super(context); mImageView = new ImageView(context); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); addView(mImageView); setBackgroundColor(Color.WHITE); setSelected(false); } @Override public void setSelected(boolean selected) { super.setSelected(selected); if(selected) { mImageView.setAlpha(1.0f); } else { mImageView.setAlpha(0.5f); } } } </code></pre> <p>I am getting "cannot be applied" error in this code </p> <pre><code>v = new MyFrame(AnaSayfa.this); </code></pre> <p>I used cover flow for the project, but the library is written as an activity, I need to use fragment for Navigation Drawer. I'm new to android.How do i solve this error?.Thanks.</p> |
1,733,066 | 0 | <p>PHP Framework: <a href="http://www.pradosoft.com/" rel="nofollow noreferrer">http://www.pradosoft.com/</a></p> |
40,645,269 | 0 | <p>Add the style import above your existing style, then apply the css rule to whichever element you wish. In this case I applied it to the body. I would also recommend using here strings instead of += as they are far more readable.</p> <pre><code>$a = @" <style> @import url('https://fonts.googleapis.com/css?family=Ubuntu') </style> <style> BODY{background-color:peachpuff; font-family: 'Ubuntu', sans-serif;} TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;} TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle} TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod} strong{color: green;} </style> "@ $b = @" <H2>Service Information</H2> <p> This is the list of services that are on this system. It dispays <strong>both</strong> running and stopped services </p> "@ Get-Service | Select-Object Status, Name, DisplayName | ConvertTo-HTML -Head $a -Body $b | Out-File C:\Scripts\Test.htm Invoke-Item C:\Scripts\Test.htm </code></pre> |
19,047,723 | 0 | <p>How is this using <a href="http://apidock.com/ruby/Object/initialize_copy" rel="nofollow"><strong><em><code>initialize_copy</code></em></strong></a>:</p> <pre><code>a=[] b=[] a.object_id # => 11512248 b.object_id # => 11512068 b.send(:initialize_copy,a << 10) a # => [10] b # => [10] a.object_id # => 11512248 b.object_id # => 11512068 </code></pre> |
5,528,198 | 0 | <p>If the link is supposed to be "enhanced" with some javascript code, the third party probably gave you a javascript file to include as well. Be sure you're including that javascript file, and that you're doing it in the right place according to the vendor's instructions.</p> |
33,800,089 | 0 | <p>I tested your code, for the first method you took, it works fine by me, I just added a <code>Dispose()</code> in it. And for the second method, I think it may be the problem that you didn't get the <code>ContentLength</code> of your var <code>response</code>.</p> <p>Here is my code, and the commented part of the code is the first method, I took a <code>Button Click</code> event to handle this:</p> <pre><code> public async void HTTP(object sender, RoutedEventArgs e) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("URL"); HttpWebResponse response = (HttpWebResponse)await httpWebRequest.GetResponseAsync(); Stream resStream = response.GetResponseStream(); StringBuilder sb = new StringBuilder(); StreamReader read = new StreamReader(resStream); string tmpString = null; int count = (int)response.ContentLength; int offset = 0; Byte[] buf = new byte[count]; do { int n = resStream.Read(buf, offset, count); if (n == 0) break; count -= n; offset += n; tmpString = Encoding.ASCII.GetString(buf, 0, buf.Length); sb.Append(tmpString); } while (count > 0); text.Text = tmpString; read.Dispose(); //using (StreamReader read = new StreamReader(resStream)) //{ // var result = await read.ReadToEndAsync(); // text.Text = result; // read.Dispose(); //} response.Dispose(); } </code></pre> <p>I've tested it, and it works fine.</p> |
32,674,704 | 1 | list's index() method for nested structures OR how to match against particular value of composed element stored in list and get it's index <p>It is possible to get index of particular element in list using <code>index()</code> method, following way (borrowed from <a href="http://stackoverflow.com/questions/176918/finding-the-index-of-an-item-given-a-list-containing-it-in-python">here</a>):</p> <pre><code>>>> ["foo", "bar", "baz"].index('bar') 1 </code></pre> <p>Is it possible to apply the same principle to nested structures (if not what is the closest most pythonic way)? The result should looks like this:</p> <pre><code>In [20]: list Out[20]: [(0, 1, 2), (3, 4, 5)] In [21]: list.someMagicFunctionHere(,4,) Out[20]: 1 </code></pre> |
26,481,816 | 0 | gitlab disable access over ip address <p>I installed gitlab_7.3.2-omnibus-1_amd64 on Ubuntu 14.04.1. </p> <p>I defined a domain name for gitlab and it works well. However, gitlab is still accessible over server's ip address. I want gitlab to be only accessible via domain name, not server's ip. Can you help me?</p> <p>Thank you.</p> |
7,397,790 | 0 | <p>This does not make much sense to begin with. A <code>Derived</code> should be able to be used anywhere a <code>Base</code> is expected, so you should be able to do</p> <pre><code>Base *foo = new Base(); Apple x = foo->func(); // this is fine Base *bar = new Derived(); Apple y = foo->func(); // oops... </code></pre> <p>I think you need to look into a different design. It's not clear just what your goal is here, but I'm guessing you might either want <code>Base</code> to be a class template with <code>Fruit</code> as a template parameter, or maybe you need to get rid of the inheritance altogether.</p> |
4,228,451 | 0 | <p>You could also check the most commonly used commercial profiler/coverage tool, AQTime from <a href="http://www.automatedqa.com" rel="nofollow">http://www.automatedqa.com</a></p> <p>Here's a video on features: <a href="http://www.automatedqa.com/products/aqtime/screencasts/coverage-profiling/" rel="nofollow">http://www.automatedqa.com/products/aqtime/screencasts/coverage-profiling/</a></p> |
30,118,171 | 0 | <p>No , your regular expression <code>^/flashmediaelement.swf$</code> specifies <strong>exact</strong> match for url , so it won't match <strong>'/mediaplayer/flashmediaelement.swf</strong></p> <p>See first section <a href="https://www.icewarp.com/support/online_help/203030104.htm" rel="nofollow">here for <strong>exact match</strong></a> regex</p> |
8,787,942 | 0 | <p>I've managed to pull a somewhat 'generic' solution. <em>removeAttribute</em> doesn't work if opacity is between 0 and 1, so my two cents solution follows:</p> <p><em>Put this code just after the first line of jQuery animate method definition (jquery.x.x.x.js)</em></p> <pre><code>animate: function( prop, speed, easing, callback ) { var optall = jQuery.speed(speed, easing, callback); /* * IE rendering anti-aliasing text fix. */ // fix START var old_complete_callback = optall.complete; optall = jQuery.extend( optall, {complete: function(){ if (jQuery.browser.msie) { var alpha = $(this).css('opacity'); if(alpha == 1 || alpha == 0) { this.style.removeAttribute('filter'); } } if (jQuery.isFunction(old_complete_callback)) { old_complete_callback.call(this); } } }); // fix END ... </code></pre> <p>Hope this will help...</p> |
16,697,004 | 0 | jQuery - toggle() a form when a button is clicked in a list <p>Problem: I don't want it to toggle when I am clicking on the table. Only when I click the button(div). Also, there has to be a selector so that other li's tables doesnt toggle.</p> <p>jQuery</p> <pre><code>$(document).ready(function() { $('table.edititem').hide(); $('.menu-category > li ul li .button').click(function(){ $('table.edititem', this).toggle(); }); }); </code></pre> <p>I know the problem is: $('table.edititem', >>>this<<<).toggle(); Because the table is not inside the ".button". We need to grab the parent, but how do we do it?</p> <p>HTML</p> <pre><code><ul> <li> Category1 <ul> <li> <div> <div class="button"></div> <table class="edititem"> </table> </div> </li> </ul> </li> </ul> </code></pre> <p>I hope you understand what I mean.</p> |
3,753,443 | 0 | <p>AIR addition to the actionscript 3 language that provide ways to control features from windows, mac, and linux. eg the titlebar and saving files.</p> <p>Flex is an addition to the actionscript 3 language that provides way to new interrogation features from server technologies like java, php, asp and connection between multiple flash applications and databases.</p> <p>Flash (CS4) can include AIR code but doesn't include Flex code. the server technology in Flash is limited but exists. Flash includes the GUI that stream lines developing. Like vector based graphics, filters, and components. Also more documentation and examples because it's easier to rewrite classes from Flex into Flash then rewriting Flash code for classes.</p> <p>Where in Flash you have a button, radio button, dropdown, or menu for every property of a movieclip, image, button. Where in Flex you can write all these properties/options by simply copying pasting, and tweaking the raw code.</p> |
27,542,746 | 0 | <p>You can also ask the window: </p> <p>var hidpi = ('devicePixelRatio' in window && devicePixelRatio > 1);</p> <p>and create the default Layers like this: </p> <p>var defaultLayers = platform.createDefaultLayers(hidpi ? 512 : 256, hidpi ? 320 : null);</p> |
32,547,416 | 0 | <p>Assuming cell A1 is the range in question, select it and for Data Validation enter this formula under Custom:</p> <pre><code>=AND(LEN(A1)=7,ISTEXT(A1),ISNUMBER(MID(A1,2,6)+0)) </code></pre> |
17,107,499 | 0 | Draw multiple views of scene on single screen <p>I have a class for projection in OpenGL, which a user can use as follows:</p> <pre><code>//inside the draw method customCam1.begin(); //draw various things here customCam1.end(); </code></pre> <p>The <code>begin</code> and <code>end</code> methods in my class are simple methods right now as follows:</p> <pre><code>void CustomCam::begin(){ saveGlobalMatrices(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-hParam,hParam,-tParam,tParam,near,far);//hParam and tParam are supplied by the user of the class glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void CustomCam::end(){ loadGlobalMatrices(); }; </code></pre> <p>I want the user to be able to create multiple instances of the above class (supply different params for <code>lParam</code> and <code>tParam</code> for each of these classes) and then draw all the three on the screen. In essence, this is like three different cameras for the scene which are two be drawn on the screen. (Consider for example top, right, bottom view to be draw on the screen with the screen divided in three columns).</p> <p>Now since there's only one projection matrix, how do I achieve three different custom cam views at the same time?</p> |
21,018,077 | 0 | <p>The reference you have given seems to be a little misleading. It explains <code>function pointers</code> as <code>callbacks</code> <strong>without actually serving the purpose of a callback</strong>. <br /><a href="http://www.prog2impress.com/downloads/The%20Function%20Pointer%20Tutorials.pdf" rel="nofollow">This</a> would be a better tutorial for <code>function pointers</code>. The <code>qsort()</code> library function is a good example of <code>callback</code>.</p> |
10,346,536 | 0 | <p>Easy enough. </p> <ol> <li><p>First create a database that uses the Contacts template (or you can use your contacts database. </p></li> <li><p>Create your document in Symphony. (I have only used the embedded productivity tools in Notes). </p></li> <li><p>Select Tools->Mail Merge. </p></li> <li><p>Click Browse that appears on the left, select your NSF file that contains the contacts. </p></li> </ol> <p>After this you should have an "Insert Fields" list appear. You can add these to your document. </p> <p>Then click "Finish Merge" and select the option you want. (Easier then LS IMHO).</p> <p>... As for LotusScript. The following should get you started. </p> <p><a href="http://www.ibm.com/developerworks/lotus/library/symphony-toolkit/" rel="nofollow">http://www.ibm.com/developerworks/lotus/library/symphony-toolkit/</a></p> |
39,204,525 | 0 | <p>Add this into model/User.php Hope it will work</p> <pre><code>public $hasMany = array( 'Phonenumber' => array( 'className' => 'Phonenumber', 'foreignKey' => 'user_id', 'conditions' => array('Phonenumber.user_id' => 'User.id'), 'dependent' => true ) </code></pre> |
18,683,079 | 0 | <p>The regular CursorLoader is based on Android's ContentProvider - so if you're not using it, you'll have to write your own Loader. Here's one way you can do it:</p> <p><a href="https://github.com/commonsguy/cwac-loaderex/blob/master/src/com/commonsware/cwac/loaderex/acl/AbstractCursorLoader.java" rel="nofollow">https://github.com/commonsguy/cwac-loaderex/blob/master/src/com/commonsware/cwac/loaderex/acl/AbstractCursorLoader.java</a></p> <p>From that point it's pretty straight forward. Your activity/fragment can be a callback for the LoaderManager - it will need to implement LoaderCallbacks interface. </p> <p>Instead of running your query, use getLoaderManager().initLoader(this, null, LOADER_ID) to initialize data loading. Here's an example: <a href="http://developer.android.com/reference/android/app/LoaderManager.html" rel="nofollow">http://developer.android.com/reference/android/app/LoaderManager.html</a></p> <p>Now, the data will be in the onLoadFinished() callback. If you did everything right, you'll get your cursor here. Now simply use the cursor to populate your list. </p> |
40,729,708 | 0 | Track Dependency Property Value Changes WPF <p>I am looking for a Way to be notified on property changed of a dependency property. Similar question was answered <a href="http://stackoverflow.com/questions/4764916/listen-to-changes-of-dependency-property">here</a></p> <p>What is meant by: </p> <p>"If it's a DependencyProperty of a separate class, the easiest way is to bind a value to it, and listen to changes on that value."</p> <p>can someone explain with an example. </p> <p>thanks!</p> |
27,047,011 | 0 | <p>This is not an inherent limitation in Windows, problems like these are environmental. A basic check-list:</p> <ul> <li>Try this with a <a href="http://download.linnrecords.com/test/mp3/tone.aspx">known-good MP3 file</a>. That test file is encoded at 320 kbps. This helps eliminate a specific problem with your files, like a wonky DRM scheme that only permits playback on an approved player.</li> <li>Make sure you run this code on an STA thread, the kind provided by a Winforms or WPF app. <em>Not</em> a console mode app, it requires the kind of code you find in <a href="http://stackoverflow.com/a/21684059/17034">this post</a>.</li> <li>Beware of having non-standard ACM drivers installed. There is a <em>lot</em> of junk out there, always treat "codec packs" with strong distrust. Review the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32 registry key, that's where ACM drivers are registered.</li> <li>And last but certainly not least, you are blind as a bat as long as you are ignoring the return value of mciSendString(). When it fails, it produces an error code that tells you the reason.</li> </ul> <p>A simple implementation of an error checker method:</p> <pre><code> private static void checkMCIResult(long code) { int err = (int)(code & 0xffffffff); if (err != 0) { throw new Exception(string.Format("MCI error {0}", err)); } } </code></pre> <p>Usage:</p> <pre><code> public static void open(string file) { string command = "open \"" + file + "\" type MPEGVideo alias MyMp3"; checkMCIResult(mciSendString(command, null, 0, 0)); } </code></pre> <p>There are a lot of possible MCI errors, you'll find them listed in MMSystem.h file in the Windows SDK "include" directory on your machine. Like C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\MMSystem.h. Start at MCIERR_INVALID_DEVICE_ID, subtract 256 from the error code. Always mention your Windows and VS version btw.</p> |
16,054,711 | 0 | How this linq execute? <pre><code>Data = _db.ALLOCATION_D.OrderBy(a => a.ALLO_ID) .Skip(10) .Take(10) .ToList(); </code></pre> <p>Let say I have 100000 rows in <code>ALLOCATION_D</code> table. I want to select first 10 row. Now I want to know how the above statement executes. I don't know but I think it executes in the following way...</p> <ol> <li>first it select the 100000 rows</li> <li>then ordered by ALLO_ID</li> <li>then Skip 10</li> <li>finally select the 10 rows.</li> </ol> <p>Is it right? I want to know more details. </p> |
21,434,037 | 0 | Bash Shell Script - If with Find not returning what I expected <p>My program:</p> <pre><code>find teste1 | while read -r firstResult do find teste2 | while read -r secondResult do if [[ $firstResult == $secondResult ]]; then echo "$firstResult" "$secondResult" > equal.lst else echo "$firstResult" "$secondResult" > notEqual.lst fi done done </code></pre> <p>Now, my problem is that when it searches the contents of the find on the "<code>IF</code>" command, it isn't saving the differences on "notEqual" nor the equals to "equal".</p> <p>Am I doing something wrong or missing anything?</p> <p>If you don't know the answer or can at least point me in a better direction, I would trully appreciate it! :)</p> <p>What I want from the program as a total:</p> <p>Search a directory and whilst doing this, search another directory, if any of the searches on those directories match each other, save it to "equal", if not, save it to "notequal".</p> <p>I need this program so I can find which files have been renamed or deleted and so on.</p> <p>----------EDIT----------------</p> <p>After seeing other comments, I tried messing around with Differ:</p> <pre><code>find teste1 -type f | while read -r firstResult do find teste2 -type f | while read -r secondResult do diff -rs $firstResult $secondResult done done </code></pre> <p>The problem with this one is that it does find some "identical" files, however, the "identical" for this means the files with the same .extension, could I remove this possibility somehow?</p> <p>----------EDIT 2----------------</p> <p>Ok, so, hopefully this will be my last EDIT and will finally post an ANSWER, I did some modifications to my original program and I know it's not as farfetched as most of those that are around here but it got me pretty damn close to where I wanted and since I am a noob, please bare with extensiveness of the program when it could be much smaller:</p> <pre><code>find teste1 -type f | while read -r firstResult do find teste2 -type f | while read -r secondResult do firstName=${firstResult##*[/|\\]} secondName=${secondResult##*[/|\\]} if [[ $firstName == $secondName ]]; then echo "$firstResult" "$secondResult" >> equal.lst else echo "$firstResult" "$secondResult" >> notEqual.lst fi done done </code></pre> <p>Now... My final dillema and I think it's quite easy: This only finds and saves files with the exact cases and I'd like, imagine as this -> You have a folder on 1 directory, now someone comes and saves another folder just like that (different content) on another directory but "renames" the folder to a different casing, as in 1st dir "tEsT" and 2nd dir "test". The program won't consider those two as the same, how do I change this? I have heard of case sensitive but I don't know exactly "where" to put it.</p> |
10,856,504 | 0 | <p>If you want to compute the <a href="http://en.wikipedia.org/wiki/Euclidean_distance" rel="nofollow">Euclidean distance</a> between vectors <code>a</code> and <code>b</code>, just use <a href="http://en.wikipedia.org/wiki/Pythagorean_theorem" rel="nofollow">Pythagoras</a>. In Matlab:</p> <pre><code>dist = sqrt(sum((a-b).^2)); </code></pre> <p>However, you might want to use <a href="http://www.mathworks.nl/help/toolbox/stats/pdist.html" rel="nofollow"><code>pdist</code></a> to compute it for all combinations of vectors in your matrix at once.</p> <pre><code>dist = squareform(pdist(myVectors, 'euclidean')); </code></pre> <p>I'm interpreting columns as instances to classify and rows as potential neighbors. This is arbitrary though and you could switch them around.</p> <p>If have a separate test set, you can compute the distance to the instances in the training set with <code>pdist2</code>:</p> <pre><code>dist = pdist2(trainingSet, testSet, 'euclidean') </code></pre> <p>You can use this distance matrix to knn-classify your vectors as follows. I'll generate some random data to serve as example, which will result in low (around chance level) accuracy. But of course you should plug in your actual data and results will probably be better.</p> <pre><code>m = rand(nrOfVectors,nrOfFeatures); % random example data classes = randi(nrOfClasses, 1, nrOfVectors); % random true classes k = 3; % number of neighbors to consider, 3 is a common value d = squareform(pdist(m, 'euclidean')); % distance matrix [neighborvals, neighborindex] = sort(d,1); % get sorted distances </code></pre> <p>Take a look at the <code>neighborvals</code> and <code>neighborindex</code> matrices and see if they make sense to you. The first is a sorted version of the earlier <code>d</code> matrix, and the latter gives the corresponding instance numbers. Note that the self-distances (on the diagonal in <code>d</code>) have floated to the top. We're not interested in this (always zero), so we'll skip the top row in the next step.</p> <pre><code>assignedClasses = mode(neighborclasses(2:1+k,:),1); </code></pre> <p>So we assign the most common class among the k nearest neighbors!</p> <p>You can compare the assigned classes with the actual classes to get an accuracy score:</p> <pre><code>accuracy = 100 * sum(classes == assignedClasses)/length(classes); fprintf('KNN Classifier Accuracy: %.2f%%\n', 100*accuracy) </code></pre> <p>Or make a confusion matrix to see the distribution of classifications:</p> <pre><code>confusionmat(classes, assignedClasses) </code></pre> |
37,507,547 | 0 | <p>Try</p> <pre><code>INSERT INTO [dbo].[WordRelationship] SElECT a.WordId, b.WordId from [dbo].[Temp] t JOIN [dbo].{Word] a on t.HeaderWord = a.Word LEFT JOIN [dbo].{Word] b on t.OtherWord = b.Word </code></pre> <p><strong>EDIT</strong></p> <p>removed LEFT in Join over Headerword since it is a not null field in WordRelationship.</p> |
8,227,531 | 0 | <p>You are overwritting the first value in your variable "myAjax" by assigning it a second value. It would be just like doing something like </p> <pre><code>var x=5; x=7; alert(x); </code></pre> <p>Here x would hold the value of 7, because that was the last value assigned to it.</p> <p>This function </p> <pre><code>myAjax.onreadystatechange=function() { if (myAjax.readyState==4 && myAjax.status==200) { document.getElementById(div).innerHTML=myAjax.responseText; } } </code></pre> <p>will be called when the server you are calling returns a response. When the first call returns myAjax will be holding the value of the second call already, making the first call not display anything. You need to either assign these two variables synchronously (one after the other one has completed), or assign them to different variable names. </p> |
12,512,677 | 0 | How to write equations in an Android textview? <p>I want to display some equations in my android app and was wondering how to display a simple equation. Any ideas? </p> <p>EDIT: Is it possible to do to this in the xml file or does it has to defined dynamically in the java code?</p> |
38,906,439 | 0 | <p>Use <a href="https://lodash.com/docs#orderBy" rel="nofollow"><code>orderBy</code></a> with with <code>order</code> ascending or descending to decide if lowest or highest. Group by <code>custormerId</code>, and take the 1st item from each customer orders:</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>function getMinMax(orders, min) { // orders - array of orders, min - true if minimum, undefined / false if maximum var order = !!min ? 'asc' : 'desc'; return _(orders) .orderBy('orderAmount', order) // orderBy the orderAmount property, with order determining highest or lowest .groupBy('customerId') // group all orders by customer id .map(function(orders) { // create a new array of just the 1st order of each customer, which will be the highest or the lowest return orders[0]; }).value(); } var orders = [{ customerId: 1, orderId: '1-1', orderAmount: 100 }, { customerId: 2, orderId: '1-2', orderAmount: 128 }, { customerId: 2, orderId: '1-3', orderAmount: 12 }, { customerId: 1, orderId: '1-3', orderAmount: 113 }, { customerId: 2, orderId: '1-1', orderAmount: 125 }, { customerId: 2, orderId: '4-1', orderAmount: 11 }, { customerId: 1, orderId: '1-2', orderAmount: 25 }]; var highestOrders = getMinMax(orders); console.log('highestOrders', highestOrders); var lowesetOrders = getMinMax(orders, true); console.log('lowesetOrders', lowesetOrders);</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.14.2/lodash.min.js"></script></code></pre> </div> </div> </p> |
36,383,877 | 0 | <p>i'm sure there are more elegant solutions but maybe it helps:</p> <pre><code>var myString = "___" myString = "1__" let input = "6" for index in 0 ..< myString.characters.count { let startIndex = myString.startIndex.advancedBy(index) let endIndex = startIndex.advancedBy(1) let range = startIndex..<endIndex let substring = myString[range] if substring == "_" { myString = myString.stringByReplacingCharactersInRange(range, withString: input) break } } </code></pre> |
40,620,698 | 0 | Text not displaying on screen <p>I cannot get the entire text to display on screen. </p> <p>My code is:</p> <pre><code>akiss =("Romeo.txt") numwords = 0 numchars = 0 with open(akiss, 'r') as file: for line in file: wordslist = line.split() numwords += len(wordslist) numchars += len(line) print (" number of words are:") print (numwords) print ("number of characters are:") print (numchars) </code></pre> |
40,042,882 | 0 | <p>There are two dependencies usually involved: <code>jmh-core</code> and <code>jmh-generator-annprocess</code>. Their versions should agree. If they don't, then generator may produce the benchmark list in a format that core cannot understand. This most probably is such case.</p> |
40,413,480 | 0 | <p><strong>This is my first answer in stackOverflow, so please, go easy.</strong></p> <p>If i'm understanding your question right, you're wondering how the math behind an artificial neuron works. The neuron is made up of 5 components shown in the following list. (The subscript i indicates the i-th input or weight.)</p> <ol> <li>A set of inputs, xi.</li> <li>A set of weights, wi.</li> <li>A threshold, u.</li> <li>An activation function, f.</li> <li>A single neuron output, y.</li> </ol> <p>The artificial neuron has a fairly simple structure.</p> <p>Using the unit step activation function, you can determine a set of weights (and threshold value) that will produce the following classification: <a href="https://i.stack.imgur.com/J2apd.png" rel="nofollow noreferrer">Click to view classification</a></p> <p>Looking at number 4. An activation function f. Many different functions can take place with the identity function being the simplest. </p> <p>The neuron output Y, is the result of applying the <strong>activation function</strong> to the <strong>weighted sum</strong> of the <strong>inputs</strong>, less the <strong>threshold</strong>. </p> <p>This value can be discrete or real depending on the activation function used.</p> <p><a href="https://i.stack.imgur.com/4hHb5.png" rel="nofollow noreferrer">Here's</a> an output of Y that holds a specific function F.</p> <p>Once the output has been calculated, it can be passed to another neuron (or group of neurons) or sampled by the external environment. The interpretation of the neuron output depends upon the problem under consideration</p> <p>@Seephore</p> <p>In principle, there is no limit on the number of hidden layers that can be used in an artificial neural network. Such networks can be trained using "stacking" or other techniques from the deep learning literature. Yes, you could have 1000 layers, though I don't know if you'd get much benefit: in deep learning I've more typically seen somewhere between 1-20 hidden layers, rather than 1000 hidden layers. In practice the number of layers is based upon pragmatic concerns, e.g., what will lead to good accuracy with reasonable training time and without overfitting.</p> <p><strong>What you're asking:</strong> Im going to assume you meant to say 100 input and 1000 output? When a input takes in the weighted value, its output gives it to all the other nodes (neurons) in the next layer, but the value is still from the given node. </p> <p>There are many "wish wash" books out their for java, but if you really want to get into it read <a href="https://i.stack.imgur.com/J2apd.png" rel="nofollow noreferrer">This</a></p> <p><a href="https://i.stack.imgur.com/OH3gI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OH3gI.png" alt=""></a></p> |
4,802,584 | 0 | How to get "Internet Call" Information in Android <p>Im working on android application in which i take backup of all contact information and then restore,i retreive all information of contact, For example:</p> <p>Display Name</p> <pre><code>Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null,null, null, null) String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); </code></pre> <p>Phone Number</p> <pre><code>Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, null); </code></pre> <p>Similary But i unable to get "Internet Call" value. Kindly anyone tell in which class i will get information about Internet Call information.</p> <p>Any help in this regards greatly appreciated.and it is urgent </p> |
37,589,894 | 0 | Error while build SyntaxNet with Bazel <p>I am trying to run Syntaxnet on Ubuntu in my VirtualBox following instructions on <a href="https://github.com/tensorflow/models/tree/32ab5a58dd3714d0747da6993a01315dadbf0e0f/syntaxnet#installation" rel="nofollow noreferrer" title="TensorFlow git">SyntaxNet Github page</a></p> <p>When i ran "bazel test syntaxnet/... util/utf8/...", all test targets were skipped. The error codes are as below.<a href="https://i.stack.imgur.com/Knvb9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Knvb9.png" alt="Error codes while building SyntaxNet"></a></p> |
10,457,033 | 0 | <p>I would recommend you to have a look at the <a href="https://github.com/FriendsOfSymfony/FOSRestBundle" rel="nofollow">FOSRestBundle</a>. Another attempt could be to handle the requests yourself, and return the date from the orm/odm via <a href="http://jmsyst.com/bundles/JMSSerializerBundle" rel="nofollow">Serializer</a></p> <p>the only thing bothered me so far, was the form handling (used <a href="https://github.com/powmedia/backbone-forms" rel="nofollow">backbone-forms</a>), where I simply not was able to keep my code DRY (had duplicate data for the form+validation in symfony and in the frontend-part).</p> |
20,542,552 | 1 | How to speed up matrix code <p>I have the following simple code which estimates the probability that an h by n binary matrix has a certain property. It runs in exponential time (which is bad to start with) but I am surprised it is so slow even for n = 12 and h = 9. </p> <pre><code>#!/usr/bin/python import numpy as np import itertools n = 12 h = 9 F = np.matrix(list(itertools.product([0,1],repeat = n))).transpose() count = 0 iters = 100 for i in xrange(iters): M = np.random.randint(2, size=(h,n)) product = np.dot(M,F) setofcols = set() for column in product.T: setofcols.add(repr(column)) if (len(setofcols)==2**n): count = count + 1 print count*1.0/iters </code></pre> <p>I have profiled it using n = 10 and h = 7. The output is rather long but here are the lines that took more time.</p> <pre><code> 23447867 function calls (23038179 primitive calls) in 35.785 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 2 0.002 0.001 0.019 0.010 __init__.py:1(<module>) 1 0.001 0.001 0.054 0.054 __init__.py:106(<module>) 1 0.001 0.001 0.022 0.022 __init__.py:15(<module>) 2 0.003 0.002 0.013 0.006 __init__.py:2(<module>) 1 0.001 0.001 0.003 0.003 __init__.py:38(<module>) 1 0.001 0.001 0.001 0.001 __init__.py:4(<module>) 1 0.001 0.001 0.004 0.004 __init__.py:45(<module>) 1 0.001 0.001 0.002 0.002 __init__.py:88(<module>) 307200 0.306 0.000 1.584 0.000 _methods.py:24(_any) 102400 0.026 0.000 0.026 0.000 arrayprint.py:22(product) 102400 1.345 0.000 32.795 0.000 arrayprint.py:225(_array2string) 307200/102400 1.166 0.000 33.350 0.000 arrayprint.py:335(array2string) 716800 0.820 0.000 1.162 0.000 arrayprint.py:448(_extendLine) 204800/102400 1.699 0.000 5.090 0.000 arrayprint.py:456(_formatArray) 307200 0.651 0.000 22.510 0.000 arrayprint.py:524(__init__) 307200 11.783 0.000 21.859 0.000 arrayprint.py:538(fillFormat) 1353748 1.920 0.000 2.537 0.000 arrayprint.py:627(_digits) 102400 0.576 0.000 2.523 0.000 arrayprint.py:636(__init__) 716800 2.159 0.000 2.159 0.000 arrayprint.py:649(__call__) 307200 0.099 0.000 0.099 0.000 arrayprint.py:658(__init__) 102400 0.163 0.000 0.225 0.000 arrayprint.py:686(__init__) 102400 0.307 0.000 13.784 0.000 arrayprint.py:697(__init__) 102400 0.110 0.000 0.110 0.000 arrayprint.py:713(__init__) 102400 0.043 0.000 0.043 0.000 arrayprint.py:741(__init__) 1 0.003 0.003 0.003 0.003 chebyshev.py:87(<module>) 2 0.001 0.000 0.001 0.000 collections.py:284(namedtuple) 1 0.277 0.277 35.786 35.786 counterfeit.py:3(<module>) 205002 0.222 0.000 0.247 0.000 defmatrix.py:279(__array_finalize__) 102500 0.747 0.000 1.077 0.000 defmatrix.py:301(__getitem__) 102400 0.322 0.000 34.236 0.000 defmatrix.py:352(__repr__) 102400 0.100 0.000 0.508 0.000 fromnumeric.py:1087(ravel) 307200 0.382 0.000 2.829 0.000 fromnumeric.py:1563(any) 271 0.004 0.000 0.005 0.000 function_base.py:3220(add_newdoc) 1 0.003 0.003 0.003 0.003 hermite.py:59(<module>) 1 0.003 0.003 0.003 0.003 hermite_e.py:59(<module>) 1 0.001 0.001 0.002 0.002 index_tricks.py:1(<module>) 1 0.003 0.003 0.003 0.003 laguerre.py:59(<module>) 1 0.003 0.003 0.003 0.003 legendre.py:83(<module>) 1 0.001 0.001 0.001 0.001 linalg.py:10(<module>) 1 0.001 0.001 0.001 0.001 numeric.py:1(<module>) 102400 0.247 0.000 33.598 0.000 numeric.py:1365(array_repr) 204800 0.321 0.000 1.143 0.000 numeric.py:1437(array_str) 614400 1.199 0.000 2.627 0.000 numeric.py:2178(seterr) 614400 0.837 0.000 0.918 0.000 numeric.py:2274(geterr) 102400 0.081 0.000 0.186 0.000 numeric.py:252(asarray) 307200 0.259 0.000 0.622 0.000 numeric.py:322(asanyarray) 1 0.003 0.003 0.004 0.004 polynomial.py:54(<module>) 513130 0.134 0.000 0.134 0.000 {isinstance} 307229 0.075 0.000 0.075 0.000 {issubclass} 5985327/5985305 0.595 0.000 0.595 0.000 {len} 306988 0.120 0.000 0.120 0.000 {max} 102400 0.061 0.000 0.061 0.000 {method '__array__' of 'numpy.ndarray' objects} 102406 0.027 0.000 0.027 0.000 {method 'add' of 'set' objects} 307200 0.241 0.000 1.824 0.000 {method 'any' of 'numpy.ndarray' objects} 307200 0.482 0.000 0.482 0.000 {method 'compress' of 'numpy.ndarray' objects} 204800 0.035 0.000 0.035 0.000 {method 'item' of 'numpy.ndarray' objects} 102451 0.014 0.000 0.014 0.000 {method 'join' of 'str' objects} 102400 0.222 0.000 0.222 0.000 {method 'ravel' of 'numpy.ndarray' objects} 921176 3.330 0.000 3.330 0.000 {method 'reduce' of 'numpy.ufunc' objects} 102405 0.057 0.000 0.057 0.000 {method 'replace' of 'str' objects} 2992167 0.660 0.000 0.660 0.000 {method 'rstrip' of 'str' objects} 102400 0.041 0.000 0.041 0.000 {method 'splitlines' of 'str' objects} 6 0.003 0.000 0.003 0.001 {method 'sub' of '_sre.SRE_Pattern' objects} 307276 0.090 0.000 0.090 0.000 {min} 100 0.013 0.000 0.013 0.000 {numpy.core._dotblas.dot} 409639 0.473 0.000 0.473 0.000 {numpy.core.multiarray.array} 1228800 0.239 0.000 0.239 0.000 {numpy.core.umath.geterrobj} 614401 0.352 0.000 0.352 0.000 {numpy.core.umath.seterrobj} 102475 0.031 0.000 0.031 0.000 {range} 102400 0.076 0.000 0.102 0.000 {reduce} 204845/102445 0.198 0.000 34.333 0.000 {repr} </code></pre> <p>The multiplication of the matrices seems to take a tiny fraction of the time. Is it possible to speed up the rest?</p> <p><strong>Results</strong> </p> <p>There are now three answers but one seems to have a bug currently. I have tested the remaining two with n=18, h=11 and iters=10 .</p> <ul> <li>bubble - 21 seconds, 185MB of RAM . 16 seconds on "sort".</li> <li>hpaulj - 7.5 seconds, 130MB of RAM . 3 seconds on "tolist". 1.5 seconds on "numpy.core.multiarray.array", 1.5 seconds on "genexpr" (the 'set' line).</li> </ul> <p>Interestingly, the time for multiplying the matrices is still a tiny fraction of the overall time taken.</p> |
22,790,087 | 0 | How to attack on RC4 <p>Friends, I am working on a project where I need to crack as much keys as possible for RC4 algorithm. I would request you to go through RC4 algorithm before reading his question.</p> <p>I have given 50 different files (A00.data,A01.data...A49.data) each containing millions of lines. Every record of file contains 5 tuples</p> <ol> <li>Initial Vector[0]</li> <li>Initial Vector[1]</li> <li>Initial Vector[2]</li> <li>1st byte of PRGA algorithm</li> </ol> <p>Every key contains 8 bytes (3 bytes of Initial Vector-given + 5 bytes of secret key)</p> <p>How can I apply any specific attack (i.e RC4 ) and find the keys (5 secret bytes) from millions of rows in each file?</p> |
12,493,694 | 0 | <p>Use grep:</p> <pre><code> grep ^hello file | awk '{print $2}' </code></pre> <p><code>^</code> is to match lines that starts with "hello". This is assuming you want to print the second word.</p> <p>If you want to print all words except the first then:</p> <pre><code> grep ^hello file | awk '{$1=""; print $0}' </code></pre> |
16,414,051 | 0 | Eclipse RCP - Multi User Installation using Windows Environment Variables <p>I have an Eclipse RCP application.</p> <p>At startup this RCP application creates a folder for the "configuration area" <a href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/multi_user_installs.html" rel="nofollow">(see eclipse help) </a>.</p> <p>Currently I pass a hardcoded path to the -configuration parameter in the launcher .ini file to define the location where this folder for the "configuration area" should be located.</p> <p>So far, this is working fine.</p> <p>Now the requirement of a customer is, that this "configuration area" should be saved in the roaming profile of the Windows user.</p> <p>The location of the roaming profile is defined by the Windows environment variable APPDATA. But this location does not corespond to the Java <em>user.home</em> directory, which points to a shared network drive in the case of my customer.</p> <p>How can I implement this requirement?</p> <p>As far as I found out, the only variables I can use in the launcher .ini are @user.home and @user.dir <a href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html" rel="nofollow">(see Eclipse runtime options)</a>. Both seem to be useless for my scenario.</p> <p>There is a <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=102239" rel="nofollow">bug on the Eclipse Bugzilla</a> since 2005 that seems to address exactly my issue. But it is not resolved, and there seems not much demand in resolving the issue. So I am wondering how other people are dealing with similar scenarios?</p> <p>Any help for setting up an Eclipse RCP multi-user scenario using Windows Roaming Profiles is greatly appreciated...</p> |
8,325,059 | 0 | Current Location Simulation on AppCode <p>Please correct me if this question is duplicated.</p> <p>I just started using AppCode for iOS programming.</p> <p>I found it very useful but issues started happening.</p> <p>My application is location based app and I need to simulate the current location but with AppCode I could not seem to find that option.</p> <p>I also tried to choose iOS 5 as the target platform but no joy.</p> <p>Does anyone know how to do it with this IDE?</p> |
8,282,619 | 0 | <p>passthru is a method in PHP see <a href="http://php.net/manual/en/function.passthru.php" rel="nofollow">http://php.net/manual/en/function.passthru.php</a></p> <p>Do you know what the script does? Maybe reverse engineer it into windows batch script?</p> <p>From the looks of it, the script came from a *nix system it:</p> <ul> <li>execute a command as another user</li> <li>change the current directory</li> <li>set environment variables </li> <li>calls a PHP script directly from the PHP interpreter and dumps the log into a file, and pipes the stderrs to /dev/null</li> </ul> <p>That script is imo, is impossible to "covert" to Windows batch script (since Windows != POSIX), you need to rewrite it. </p> |
21,318,943 | 0 | Back-office tab and helper form? <p>Following <a href="http://doc.prestashop.com/display/PS14/Creating+a+PrestaShop+module" rel="nofollow">this</a> prestashop instruction on how to make a tab in a back-office I did a class and controller like it's need. But what if I want to use a helper form for form creation in the <code>AdminTest</code> controller?</p> <pre><code>class AdminTest extends AdminTab { public function __construct() { $this->table = 'test'; $this->className = 'Test'; $this->lang = false; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'id_test' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'test' => array( 'title' => $this->l('Name'), 'width' => 200) ); $this->identifier = 'id_test'; parent::__construct(); } public function displayForm() { global $currentIndex; $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $obj = $this->loadObject(true); $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Edit carrier'), 'image' => '../img/admin/icon_to_display.gif' ), 'input' => array( array( 'type' => 'text', 'name' => 'shipping_method', ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); return $helper->generateForm($fields_form); } } </code></pre> <p>But it wont work. Why the helper form isn't working? </p> <p>p.s. btw, also I would like to use a <code>$this->setTemplate('mytemplate.tpl')</code> method but it's not possible aswell.</p> |
26,634,504 | 0 | EF6 DB First Pre-Generated Views difficulties <p>The 50 seconds it takes EF to complete it's first query (as compared to milliseconds for the same or similar queries when it's warm) is making my MVC website look bad. I really need to get pre-compiled views working.</p> <p>I have tried the power tools but when I run 'Generate Views' the VS12 output window shows</p> <pre><code>System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.DbContextPackage.Utilities.EdmxUtility.GetMappingCollectionEF6(Assembly ef6Assembly, String& containerName) at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.OptimizeEdmx(String inputPath) </code></pre> <p>The T4 templates that can generate views seem to be for code first only.</p> <p>How can I get power tools working or is there another way to pre-generate the Views?</p> |
15,469,534 | 0 | Remove signing from an assembly <p>I have a project open in Visual Studio (it happens to be Enyim.Caching). This assembly wants to be delay-signed. In fact, it desires so strongly to be delay-signed, that I am unable to force Visual studio to compile it <em>without</em> delay signing.</p> <ol> <li><p>I have unchecked "Delay sign only" and "Sign the assembly" on the Visual Studio project properties box, and rebuilt. The assembly is still marked for delay sign (as shown by <code>sn.exe -v</code>).</p></li> <li><p>I have unloaded the project and verified that the signing is set to false. When reloading the project, the check boxes for "Sign" and "Delay Sign" are checked.</p></li> <li><p>I have verified that no attributes are present in the AssemblyInfo (or elsewhere) that would cause this.</p></li> <li><p>I have searched the Internet for a solution, but have found none.</p></li> </ol> <p>How can I do this?</p> |
6,933,860 | 0 | <p>Have a look at the quota implementation; this is a mechanism (ok, presumably not available on vfat) which reads/writes files from the kernel.</p> <p>Additionally, the "loop" block device is another example of a kernel facility which does file IO.</p> |
12,704,142 | 0 | <p>You have not initialized <code>locationManager</code> To fix this, in your onCreate method you can do something like:</p> <pre><code>locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); </code></pre> |
14,310,172 | 1 | Python: Extract info from xml to dictionary <p>I need to extract information from an xml file, isolate it from the xml tags before and after, store the information in a dictionary, then loop through the dictionary to print a list. I am an absolute beginner so I'd like to keep it as simple as possible and I apologize if how I've described what I'd like to do doesn't make much sense.</p> <p>here is what i have so far.</p> <pre><code>for line in open("/people.xml"): if "name" in line: print (line) if "age" in line: print(line) </code></pre> <p>Current Output:</p> <pre><code> <name>John</name> <age>14</age> <name>Kevin</name> <age>10</age> <name>Billy</name> <age>12</age> </code></pre> <p>Desired Output</p> <pre><code>Name Age John 14 Kevin 10 Billy 12 </code></pre> <p>edit- So using the code below I can get the output:</p> <pre><code>{'Billy': '12', 'John': '14', 'Kevin': '10'} </code></pre> <p>Does anyone know how to get from this to a chart with headers like my desired output?</p> |
565,460 | 0 | <p>You sound as though you are "rolling your own" authentication system.</p> <p>I would look into using ASP.NET's built in <a href="http://msdn.microsoft.com/en-us/library/xdt4thhy.aspx" rel="nofollow noreferrer">Forms authentication</a> system that is commonly used with an ASP.NET <a href="http://msdn.microsoft.com/en-us/library/aa478949.aspx" rel="nofollow noreferrer">Membership Provider</a>. Built-in providers already exist for SQL Server, and you can create your own Membership Provider by inheriting from the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx" rel="nofollow noreferrer">System.Web.Security.MembershipProvider</a> base class.</p> <p>Essentially, the ASP.NET membership providers usually work by setting a client side cookie (also known as an Authentication Ticket) in the client's browser, once the client has successfully authenticated themselves. This cookie is returned to the web server with each subsequent page request, allowing ASP.NET, and thus your code, to determine who the user is, usually with a single line of code like so:</p> <pre><code>string username = HttpContext.Current.User.Identity.Name; // The above gets the current user's name. if(HttpContext.Current.User.Identity.IsAuthenticated) // Do something when we know the user is authenticated. </code></pre> <p>You then should not need to store anything in the Session state. Of course, if you <em>want</em> to store user-specific data in a session variable (i.e. user-data that may not be part of the authentication of a user, perhaps the user's favourite colour etc.) then by all means you can store that in a session variable (after retrieving it from the DB when the user is first authenticated). The session variable could be stored based on the user's name (assuming unique names) and retrieved using code similar to the above which gets the current user's name to access the correct session object.</p> <p>Using the built-in forms authentication will also allow you to "protect" areas of your website from un-authorized users with simple declarative code that goes in your web.config, for example:</p> <pre><code><authorization> <deny users="?"/> </authorization> </code></pre> <p>Adding the above to your "main" web.config would ensure that none of your pages are accessible to un-authorized users (though you'd probably never do this in reality - it's just meant as an example). Using the ASP.NET <a href="http://msdn.microsoft.com/en-us/library/aa479032.aspx" rel="nofollow noreferrer">Role Provider</a> in conjunction with the Membership Provider will give you even greater granularity over who can or can't access various sections of your website.</p> |
13,068,475 | 0 | <p>Looks like its a date. You can parse the string to DateTime, using <a href="http://msdn.microsoft.com/en-us/library/system.datetime.parseexact.aspx">DateTime.ParseExact</a> and then use .ToString to return formatted result. </p> <pre><code>DateTime dt = DateTime.ParseExact(temp1, "dd MM yyyy", CultureInfo.InvariantCulture); Console.Write(dt.ToString("yyyy MM dd")); </code></pre> <p><em>You may use that DateTime object later in your code, and also apply different formatting (if you need)</em></p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.