pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
33,739,087 | 0 | <p>Since you have 30 & 60 use those values:</p> <pre><code>update #Temp_Test set prod = 30 , total = 60 where id = 1 </code></pre> |
16,346,066 | 0 | <p>You should pass strings enclosed in quotes - otherwise JavaScript thinks they're variable names:</p> <pre><code><p><input type="radio" name="look" onClick="setActiveStyleSheet('main')" checked> Light & dark blue</p> <p><input type="radio" name="look" onClick="setActiveStyleSheet('alt1')"> Black & white</p> <p><input type="radio" name="look" onClick="setActiveStyleSheet('alt2')">Yellow & red</p> </code></pre> <p>But your real problem is this: </p> <pre><code>a = document.getElementsByTagName("link") </code></pre> <p>sets <code>a</code> as an HTMLCollection object, not as the link itself. Change it to:</p> <pre><code>a = document.getElementsByTagName("link")[i] </code></pre> <p>And you'll be fine. </p> <p>It seems alistapart isn't perfect after all.</p> |
40,460,816 | 0 | Can user makes sharing folder in Active Directory? <p>I'm using Active Directory and belong to specified group. (Not an Administrator.) I have made folder in my 'C:' and then trying to share to another group users. But I can't. Just i can get the warning message that '~Access denied~. You did not make shared resources.'. Is there way to take care of this problem? Thank you~!</p> |
35,045,984 | 0 | <p>Flexbox can do that:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.chatbox { margin: 1em auto; width: 150px; height: 500px; border: 1px solid grey; display: flex; flex-direction: column-reverse; justify-content: flex-start; text-align: center; } .message { background: lightgreen; margin-bottom: .25em; padding: .25em 0 0 0; border-bottom: 2px solid green; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><div class="chatbox"> <div class="message">MESSAGE 1</div> <div class="message">MESSAGE 2</div> <div class="message">MESSAGE 3</div> <div class="message">MESSAGE 4</div> <div class="message">MESSAGE 5</div> <div class="message">MESSAGE 6</div> <div class="message">MESSAGE 7</div> <div class="message">MESSAGE 8</div> <div class="message">MESSAGE 9</div> <div class="message">MESSAGE 10</div> <div class="message">MESSAGE 11</div> <div class="message">MESSAGE 12</div> </div></code></pre> </div> </div> </p> |
17,932,643 | 0 | <p>If you had two tables in the same database, you could use a statement like this:</p> <pre class="lang-sql prettyprint-override"><code>INSERT INTO messages1 SELECT * FROM messages2 </code></pre> <p>When you have two different database files, you can <a href="http://www.sqlite.org/lang_attach.html" rel="nofollow">ATTACH</a> one to the other:</p> <pre class="lang-sql prettyprint-override"><code>ATTACH DATABASE '...' AS toMerge </code></pre> <p>and then access it by prefixing the table name with the database name:</p> <pre class="lang-sql prettyprint-override"><code>INSERT INTO messages SELECT * FROM toMerge.messages </code></pre> |
23,445,854 | 0 | <p>I made a librairy to make Hexadecimal / Decimal conversion without the use of <code>stdio.h</code>. Very simple to use :</p> <pre class="lang-c prettyprint-override"><code>char* dechex (int dec); </code></pre> <p>This will use <code>calloc()</code> to to return a pointer to an hexadecimal string, this way the quantity of memory used is optimized, so don't forget to use <code>free()</code></p> <p>Here the link on github : <a href="https://github.com/kevmuret/libhex/" rel="nofollow">https://github.com/kevmuret/libhex/</a></p> |
8,930,678 | 0 | <pre><code>$strBody = "Today is" .date("l"); </code></pre> <p>Otherwise (when using +) it converted to <code>int</code>.</p> |
35,616,180 | 0 | <p>Array index start from 0.<br> I presume when you say it hides the right answer button is when the answer is "2", since by your <code>giveHint</code> function it will remove index 1 from <code>answers</code> array which is "2".</p> <p>Change your <code>giveHint</code> removeAtIndex will do the trick.</p> <pre><code>func giveHint(sender: UIButton){ if self.answer != "1" { answers.removeAtIndex(0) Button1.alpha = 0 } else if self.answer != "2" { answers.removeAtIndex(1) Button2.alpha = 0 } else if self.answer != "3" { answers.removeAtIndex(2) Button3.alpha = 0 } else if self.answer != "4" { answers.removeAtIndex(3) Button4.alpha = 0 } } </code></pre> |
33,593,540 | 0 | Volley NetworkImageView with spinner? <p>so I want to provide some feedback to the user while I am loading a gridview of images. Below is my adapters UI. I have a very nasty way of doing my task, adding a spinner to each element of the gridview. When the NetworkImageView loads it hides the spinner..</p> <p>However I ask myself, do I want to use or show this to anyone? No way, aside from being a hack, having 8+ spinners is terrible for performance. </p> <p>I've been researching it... I see there is some copyNpaste a custom version of the NetworkImageViewer code that lets me put an observer, but that seems to be way intense / overkill.</p> <p>I also tried putting a callback into the get / set image in the volley ImageLoader to turn off the spinners when the data is accessed. It half worked, but decided it was too ugly of a solution as well.</p> <p>Aside from just doing it manually with the normal volley request and having to process the image manually and putting it on the volley success listener.. I'm stumped. Anyone know of a clean solution here? I'm guessing I have to do it manually..</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="@dimen/image_size" android:paddingBottom="@dimen/element_spacing" android:paddingTop="@dimen/element_spacing"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="@dimen/element_spacing" android:background="@color/color_primary" android:gravity="center_vertical" /> <ProgressBar android:id="@+id/grid_adapter_spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> <com.android.volley.toolbox.NetworkImageView android:id="@+id/gridview_adapter_networkimageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/element_spacing" android:background="@color/color_primary" android:layout_centerInParent="true" /> </RelativeLayout> </code></pre> |
17,838,168 | 1 | Can I build an automatic class-factory that works on import? <p>I have a class-factory F that generates classes. It takes no arguments other than a name. I'd like to be able to wrap this method and use it like this:</p> <pre><code>from myproject.myfactory.virtualmodule import Foo </code></pre> <p>"myfactory" is a real module in the project, but I want virtualmodule to be something that pretends to be a module.</p> <p>Whenever I import something from virtualmodule I want it to build a new class using my factory method and make it look as if that was imported. </p> <p>Can this be done? Is there a pattern that will allow me to wrap a class-factory as a module?</p> <p>Thanks!</p> <p>--</p> <p>UPDATE0: Why do I need this? It's actually to test a process that will be run on a grid which requires that all classes should be importable.</p> <p>An instance of the auto-generated class will be serialized on my PC and then unserialized on each of the grid nodes. If the class cannot be imported on the grid node the unserialize will fail. </p> <p>If I hijack the import mechanism as an interface for making my test-classes, then I know for sure that anything I can import on my PC can be re-created exactly the same on the grid. That will satisfy my test's requirements.</p> |
5,539,077 | 0 | <p>You could use ManualResetEvents and WaitHandle.WaitAny. Basically when one thread is done you would notify the other thread by using a ManualResetEvent (ManualResetEvent.Set()). </p> <pre><code>ManualResetEvent threadFinished = new ManualResetEvent(false); //You would set this in the thread that has finished threadFinished.Set() //You would use this in the thread that you want to wait for this event to be signalled int nWait = WaitHandle.WaitAny(new ManualResetEvent[] { threadFinished }, 10, true); //if yes stop thread if (nWait == 0) { //Thread is finished } </code></pre> |
14,206,874 | 0 | <p>I have had an amazing experience with Behat / Mink <a href="http://behat.org">http://behat.org</a></p> <p>I agree with others php as a unit testing platform is not a fun or experience BDD is the best way to go if you are using any php framework</p> <p>Wrapping my head around composer as a repo build tool was the biggest stumbling block but we were able to use Behat Mink Selenium Webdriver standalone server jar as an amazing design and regression testing tool. We used to run our regression suite against our CakePHP application on a Jenkins server but it proved to be not so very "fail fast" enough</p> <p>Now our workflow goes like this: Create story in gherkin refine story write feature and stub out any new step defs begin coding php solution to test Then at the end we have a working feature or bug fix with a bdd test covering it</p> <p>We setup an Ubuntu VM with a working Behat setup and copied it to every workstation. We baked it into our process. We just pull down changes run tests then begin coding new stuff.</p> <p>We wrote a shell script to automatically run mysql dumps and load them before each feature which has made refactoring code a breeze.</p> <p>The Mink WebAssert class gives you all the assertions you need to validate behavior The regular session / CommonContext classes are great for using css or xpath. </p> <p>I have used Capybara / WebDriver with Java and Rails projects before and found the setup overhead / learning curve is too high compared to Behat. </p> |
13,146,879 | 0 | <p>Try like below,</p> <pre><code>//Note the quotes moved -----------------v $.getJSON('http://api.websiteexample.com/' + apikey); </code></pre> <p>When you have it inside quotes.. It would be considered as a <code>string</code>. You need to put it outside quotes for it to know it is an variable.</p> |
7,008,429 | 0 | Programmatically change view orientation without rotating ipad <p>I would like to rotate a ViewController based on some condition. The problem with shouldAutorotateToInterfaceOrientation is that the view always start with portrait/landscape orientation (as set in Interface Builder) and the user has to rotate the ipad to use the correct mode.... How can I change this behavior? Thank you.</p> |
28,424,284 | 0 | <p><code>out</code> has two forms, <code>out <imm8>, al/ax/eax</code> and <code>out dx, al/ax/eax</code>. Your instruction matches neither of these, so it is malformed.</p> <p>Change your code such that the value you want is in <code>eax</code> instead of <code>ecx</code> (which might be as easy as <code>mov eax, ecx</code>) and use the second form.</p> <p>Assembler messages are often inadequate, so get your hands on an instruction reference.</p> |
24,708,692 | 0 | <p>if you are using storyboard to get a viewcontroller ,you can try this.</p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIStoryboard *storyboard = [ UIStoryboard storyboardWithName:@"Main" bundle:nil ]; SecondViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"test" ]; vc.title = @"something"; [self.navigationController pushViewController:detailView animated:YES]; } </code></pre> |
39,857,565 | 0 | Typescript warnings when using interface and OpaqueToken in Angular 2 app <p>I have been following the documentation <a href="https://angular.io/docs/ts/latest/guide/dependency-injection.html#!#non-class-dependencies" rel="nofollow">here</a> and use <strong>ng-cli</strong>.</p> <p>I created the following configuration file (<strong>app-config.ts</strong>):</p> <pre><code>import { OpaqueToken } from '@angular/core'; export interface AppConfig { supportTelephoneNumber: string; } export let APP_CONFIG_t = new OpaqueToken('app.config'); export const APP_CONFIG: AppConfig = { supportTelephoneNumber: '1111 111 1111' }; </code></pre> <p>and in my <strong>app.module.ts</strong> file I have:</p> <pre><code>... @NgModule({ declarations: [ UkCurrencyPipe, AppComponent, HomeComponent ], imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(ROUTES, { useHash: true }), MaterialModule.forRoot() ], providers: [ { provide: APP_CONFIG_t, useValue: APP_CONFIG }, ... </code></pre> <p>I use this configuration in my <strong>app.component.ts</strong> file like this:</p> <pre><code>import { Component, Inject } from '@angular/core'; import { APP_CONFIG_t, AppConfig } from './app-config'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.less'] }) export class AppComponent { constructor(@Inject(APP_CONFIG_t) public config: AppConfig) { callSupport(): void { window.location.href = 'tel:+' + this.config.supportTelephoneNumber; } } </code></pre> <p>When I serve my app using <strong>ng serve</strong> everything seems to work fine but I do see these warnings in the console from where I run <strong>ng server</strong>:</p> <blockquote> <p>WARNING in ./src/app/app.component.ts<br/> 40:166 export 'AppConfig' was not found in './app-config'</p> <p>WARNING in ./src/app/app.component.ts<br/> 40:195 export 'AppConfig' was not found in './app-config'</p> </blockquote> <p>Does anyone know what these warnings mean and whether or not I should worry about them?</p> <p><strong>My Versions</strong></p> <ul> <li>OS: Mac OS X El Capitan v10.11.6</li> <li>ng-cli: v1.0.0-beta.16</li> <li>angular: v2.0.1</li> <li>typescript: v2.0.2</li> </ul> |
38,464,553 | 0 | <p>Client side rules obviously run only when the client (Outlook) is open. Server side rules (Exchange only) always run, but they do not run any scripts and are limited to things like forwarding.</p> |
21,008,833 | 0 | build query to select data based on another table <p>tables <img src="https://i.stack.imgur.com/PbdgS.jpg" alt="enter image description here"></p> <p>sample data</p> <p>walls</p> <pre><code>wall_id wall_name 1 wall_1 2 wall_2 6 wall_6 </code></pre> <p>wall_categories</p> <pre><code>wall_id category_id 1 2 2 1 6 1 6 2 </code></pre> <p>categories</p> <pre><code>category_id category_name 1 Wallpaper 2 Photography </code></pre> <p>html</p> <pre><code><a href="file.php?category=wallpaper">Wallpaper</a> <a href="file.php?category=photography">Photography</a> </code></pre> <p>What I need to do is when the user click the <code>Wallpaper</code> link, I want the images with <code>wallpaper</code> as category to be displayed same with <code>photography</code>. I have built an initial query but it generates duplicate records as I'm using join, there must be something else that need to be added to make it work.</p> <pre><code> SELECT DISTINCT walls.wall_id, walls.wall_name, walls.wall_views, walls.upload_date, categories.category_name FROM categories INNER JOIN wall_categories ON wall_categories.category_id=categories.category_id INNER JOIN walls ON walls.wall_id=wall_categories.wall_id; </code></pre> <p>or since the <code>category_id</code> is fixed, we can use <code>walls</code> and <code>wall_categories</code> table only. Then lets' say we can use the following html.</p> <pre><code><a href="file.php?category=1">Wallpaper</a> <a href="file.php?category=2">Photography</a> </code></pre> |
27,621,483 | 0 | netbeans oracle 12c occi windows <p>I'm using netbeans 8.0 on Windows 7 x64 and trying to connect to oracle 12.1 using occi. I've downloaded 12.1.0.2.0 Oracle Instant Client for Windows x64 Basic+SDK. Installed it just unzipping to D:\instantclient_12_1. And then added this path into Windows Path variable. Netbeans is using mingw64 compiler In project properties in Make>compiler C++ category for include catalog(-I) D:/instantclient_12_1/sdk/include In linker addiational libraries(-L) catalog is D:/instantclient_12_1</p> <pre><code>#include <iostream> #include <occi.h> using namespace std; using namespace oracle::occi; /* * */ int main(int argc, char** argv) { Environment *env = Environment::createEnvironment(); Environment::terminateEnvironment(env); return 0; } </code></pre> <p>But during making project I get:</p> <pre><code>g++ -o dist/Debug/MinGW_64-Windows/cppapplication_1 build/Debug/MinGW_64-Windows/main.o build/Debug/MinGW_64-Windows/main.o: In function `main': C:\NetBeansProjects\CppApplication_1/main.cpp:17: undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long long), void* (*)(void*, void*, unsigned long long), void (*)(void*, void*))' C:\NetBeansProjects\CppApplication_1/main.cpp:18: undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)' collect2.exe: error: ld returned 1 exit status make.exe[2]: *** [dist/Debug/MinGW_64-Windows/cppapplication_1.exe] Error 1 make.exe[2]: Leaving directory `/c/NetBeansProjects/CppApplication_1' make.exe[1]: *** [.build-conf] Error 2 make.exe[1]: Leaving directory `/c/NetBeansProjects/CppApplication_1' make.exe": *** [.build-impl] Error 2 </code></pre> <p>I tried to add libraries "oraociei12.dll", "oraocci12d.dll"(in Debug mode), "oraocci12.dll", "orannzsbb12.dll", "oci.dll" with -l option but without changes. What's wrong?</p> |
32,803,472 | 0 | Create a SIN number validator <p>I am creating a C program which tests if a user has entered a valid SIN number. Here is what I have done so far:</p> <pre><code>#include <stdio.h> int main(void) { int num1; printf("Enter your SIN number: \n"); scanf("%d", &num1); } </code></pre> <p>SIN number is a 9 digit long number. To see if it is valid, I want to multiply the SIN number like this: </p> <pre><code>add SIN number with 121 212 121. 123 456 789 121 212 121 </code></pre> <p>How would I do this part in C programming language?</p> |
24,607,298 | 0 | <p>You're not storing the actual image (binary data) into the database, but the <code>tmp_name</code> (string). Use <code>file_get_contents()</code>, like so:</p> <pre><code>$image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); </code></pre> |
5,944,027 | 0 | <p>You don't, the user decided that she was tired of waiting and wanted to work with a responsive program. Review the fine print in SetForegroundWindow() for all the reasons that trying to find a workaround for this won't actually work. Make sure she can get back to the program when it is initialized, a taskbar button is key.</p> |
115,155 | 0 | <p>Bjarne Stroustrup has a short paper called <a href="http://www.research.att.com/~bs/abstraction.pdf" rel="nofollow noreferrer">Abstraction, libraries, and efficiency in C++</a> where he mentions techniques used to achieve what you're looking for. Specifically, he mentions the library <a href="http://www.oonumerics.org/blitz/" rel="nofollow noreferrer">Blitz++</a>, a library for scientific calculations that also has efficient operations for matrices, along with some other interesting libraries. Also, I recommend reading <a href="http://www.artima.com/intv/abstreffi.html" rel="nofollow noreferrer">a conversation with Bjarne Stroustrup on artima.com</a> on that subject.</p> |
24,196,291 | 0 | <p>As Henrique said, you just need to call the function you made as below</p> <pre><code> function sendEmail() { var firstThread = GmailApp.getInboxThreads(0,1)[0]; var message = firstThread.getMessages()[0]; var sender = message.getFrom(); var body = "Detta mail är ursprungligen skickat från" + " " + sender + '\n' + message.getBody(); var subject = message.getSubject(); var attachment = message.getAttachments(); GmailApp.sendEmail("user.name@adje.com", subject, "", {htmlBody: body, attachments: attachment}); Logger.log(body); markArchivedAsRead(); } function markArchivedAsRead() { var threads = GmailApp.search('label:unread -label:inbox'); GmailApp.markThreadsRead(threads); }; </code></pre> |
517,126 | 0 | <p>Xcode can display man pages:</p> <p><a href="http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/XcodeWorkspace/200-Documentation_Access/chapter_6_section_8.html" rel="nofollow noreferrer">http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/XcodeWorkspace/200-Documentation_Access/chapter_6_section_8.html</a></p> <p>For this to work, the "Core Library" doc set or "All Doc Sets" must be selected.</p> |
21,264,714 | 0 | Procedure to return first name when inputting last name <pre><code>create or replace procedure p_inout (v_emp_lname in varchar2(25)) as v_first_name varchar2(20); begin select first_name into v_first_name from employees where last_name=v_emp_lname; dbms_output.put_line(v_first_name); end; </code></pre> <p>I am getting Error(2,25): PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "(" to continue. </p> |
38,354,426 | 0 | <p>Two mistakes: 1) remove letter "s". 2) Add first Upper case</p> <pre><code>... class Product extends Model { protected $table='product'; } </code></pre> |
253,185 | 0 | <p>I've usually experience this whenever the ClassLoader changes.</p> <p>Depending on the exact context that an app is running ClassLoaders have different rules about when a resource file exists. For example in netbeans getResource is case insensitive, but in Sun's JRE it is.</p> <p>Although not directly answering your question, I thought you should know this (if you didn't already).</p> |
26,185,432 | 0 | <p>The ProductAreaRegistration was configured to default to a controller that would redirect to the Home controller on the web site root (area="").</p> <p><strong>The ProductAreaRegistration</strong> </p> <pre><code> public class ProductAreaRegistration : AreaRegistration { public override string AreaName { get { return "Product"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Product_default", "Product/{controller}/{action}/{id}", defaults: new { controller="Redirect", action = "Index", id = UrlParameter.Optional }); } } </code></pre> <p><strong>The Controller</strong></p> <pre><code>public class RedirectController : Controller { // GET: Product/Redirect public ActionResult Index() { return RedirectToAction("Index","Home",new { area = "" }); } } </code></pre> |
35,191,083 | 0 | How to avoid 'Unable to load DLL' scenarios <p>I'm trying to build a game using Monogame. Monogame uses its own bunch of DLLs. However inside one of those DLLs is a dependency on another DLL (which could potentially not exist as it was not installed).</p> <p>More specifically when trying to utilize a method/class of Monogame's DLLs</p> <pre><code>GamePad.GetState(PlayerIndex.One).Buttons.Back </code></pre> <p>This error is produced:</p> <blockquote> <p>Unable to load DLL 'xinput1_3.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)</p> </blockquote> <p>The fix for this error isn't difficult. The user needs to install the correct system requirements.</p> <p>How do I tell this to the user from the front end? My aim is to inform the user that 'Gamepad controllers are disabled for this because xxx is not installed on your system', while carrying on running the game - as gamepads are optional.</p> <p>Is there a way I could have caught this issue (i.e. is there a way I could have checked to see if this DLL exists - without being very specific of its location/filepath) before attempting to utilize the method/class?</p> <p>Is having a <code>try-catch</code> block around the whole application the best approach?</p> <p>Are there better ways to handling the (common?) 'Unable to load DLL' cases?</p> <p>My main goal is to ignore any DLL dependency issues as I plan to distribute this game without installers. Plus any missing non-game-breaking DLLs should just be ignored.</p> |
17,533,496 | 0 | <p>To get the list of uploaded file names from the <strong>server</strong>, requires server-side code:</p> <p><em>UploadHandler.php</em> is used to upload files to a directory/s on your server.</p> <p>If you've downloaded the plug-in archive and extracted it to your server, the files will be stored in php/files by default. (Ensure that the php/files directory has server write permissions.) see: <a href="https://github.com/blueimp/jQuery-File-Upload/wiki/Setup" rel="nofollow">https://github.com/blueimp/jQuery-File-Upload/wiki/Setup</a></p> <p><em>UploadHandler.php</em> is just that, an upload handler. It does not provide access to server files without a connection to the server.</p> <p>JavaScript cannot access files on the <strong>server</strong>, so you'll need a php script to do so. (Although JavaScript could possibly keep track of everything uploaded, renamed, and deleted.)</p> <p>You can modify <em>UploadHandler.php</em> to connect to your database, and write the file paths (and any other data) to a files table during upload. Then you can access your files via standard SQL queries:</p> <h2>Modify <em>UploadHandler.php</em>:</h2> <ol> <li>Add your database connection parameters</li> <li>Write an SQL query function</li> <li>Write a second function to perform your query</li> <li>Call the second function</li> </ol> <p>see: <a href="https://github.com/blueimp/jQuery-File-Upload/wiki/Working-with-databases" rel="nofollow">https://github.com/blueimp/jQuery-File-Upload/wiki/Working-with-databases</a></p> |
32,025,692 | 0 | <p>Try this:</p> <pre><code><?php if ($_POST['sub']) { $server = "localhost"; $username = "yourusernamehere"; $pass = "yourpasswordhere"; $db = "users"; // Create connection $mysqli = new mysqli($server, $username, $pass, $db); // Check connection if ($mysqli->connect_error) { die("Connection failed: " . $mysqli->connect_error); } echo "Connected successfully"; $uname = mysql_escape_string($_POST['username']) $mail = mysql_escape_string($_POST['email']); $sql = "INSERT INTO users (username, email) VALUES ('$uname', '$mail')"; $insert = $mysqli->query($sql); if ($insert){ echo "Success! Row ID: {$mysqli->insert_id}"; header("Location:main.php"); } else { die("Error: {$mysqli->errno} : {$mysqli->error}"); } $mysqli->close(); } ?> <!DOCTYPE html> <html> <body> <form action = "" method = "POST"> <label>Enter your Username:</label> <input type="text" name="username" required> <label>Enter your Email:</label> <input type="email" name="email" required > <input type="hidden" name = "check"> <input type="submit" name = "sub" value = "INSERT"> </form> </body> </html> </code></pre> <blockquote> <p>Your database name as it lookes on the third line is <code>'users'</code> and so is the name of your table that you are trying to <code>INSERT INTO</code> into <code>"users'</code> line 10. Are you sure your are not messing up there?</p> </blockquote> |
16,701,139 | 0 | <p>I think I found another solution to this problem, which lets you leave the Colorized Parameter Help feature turned on.</p> <p>In Fonts and Colors, I specified a value for the "Signature Help - User Types(Value Types)" item, and I don't have the problem any more.</p> <p>Note: I also have the Color Theme Editor extension installed - I'm not sure if this plays any part in the effectiveness of the workaround (but I had it installed before as well, so the extension alone didn't fix the problem).</p> <p>Also, someone posted the bug on MS Connect: <a href="http://connect.microsoft.com/VisualStudio/feedback/details/770603/text-editor-the-type-color-for-structs-is-black" rel="nofollow">http://connect.microsoft.com/VisualStudio/feedback/details/770603/text-editor-the-type-color-for-structs-is-black</a></p> |
13,291,700 | 1 | executemany for MySQLdb error for large number of rows <p>I'm currently running a script to insert values (a list of tuples) into a MySQL database, using the execute many function. When I use a small number of rows (`1000), the script runs fine.</p> <p>When I use around 40,000 rows, I receive the following errors:</p> <pre><code>cursor.executemany( stmt, trans_frame) Traceback (most recent call last): File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2538, in run_code exec code_obj in self.user_global_ns, self.user_ns File "<ipython-input-1-66b44e71cf5a>", line 1, in <module> cursor.executemany( stmt, trans_frame) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 253, in executemany r = self._query('\n'.join([query[:p], ',\n'.join(q), query[e:]])) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 346, in _query rowcount = self._do_query(q) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 310, in _do_query db.query(q) OperationalError: (2006, 'MySQL server has gone away') </code></pre> <p>Any suggestions?</p> |
15,945,808 | 0 | <p>Although I am quite new in this let me share with you what I am doing. </p> <p>Firstly, I create the engine (where is the service that I call located).</p> <p>In my interface: </p> <pre><code>@interface INGMainViewController (){ MKNetworkEngine *engine_; } </code></pre> <p>In my Initialization:</p> <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { engine_= [[MKNetworkEngine alloc] initWithHostName:@"www.xxx.gr"]; // Custom initialization } return self; } </code></pre> <p>Then in the function that I'll call the service: </p> <pre><code>NSDictionary *formParams = [NSDictionary dictionaryWithObjectsAndKeys: theClientCode, @"ClientCode", theContractNumber, @"ContractCode", theAppleID, @"AppleID", @" ", @"AndroidID", @" ", @"WindowsID", uid, @"AppleDeviceID", @" ", @"AndroidDeviceID", @" ", @"WindowsDeviceID", theCellPhone, @"TelephoneNumber" , nil]; MKNetworkOperation *operation = [self.engine operationWithPath:@"/services/Authentication.ashx" params: formParams httpMethod:@"POST"]; [operation addCompletionHandler: ^(MKNetworkOperation *operation) { NSLog(@" Operation succeds: %@", [operation responseString]); } errorHandler:^(MKNetworkOperation *errorOperation, NSError *error) { NSLog(@" Errors occured: %@", error); }]; [self.engine enqueueOperation:operation]; } </code></pre> <p>...and that is all. </p> <p>Of course I still face some issues but i think there are not coming from the Kit.</p> <p>I hope I have helped you. </p> |
37,023,758 | 0 | How to move HBase tables to HDFS in Parquet format? <p>I have to build a tool which will process our data storage from HBase(HFiles) to HDFS in parquet format.</p> <p>Please suggest one of the best way to move data from HBase tables to Parquet tables.</p> <p>We have to move 400 million records from HBase to Parquet. How to achieve this and what is the fastest way to move data?</p> <p>Thanks in advance.</p> <p>Regards,</p> <p>Pardeep Sharma.</p> |
36,349,319 | 0 | <p>I assume you want to do this in an activity class.</p> <p>You first create a new instance of <code>EditText</code>:</p> <pre><code>EditText textfield = new EditText(this); </code></pre> <p>Then you want to set the properties of the <code>EditText</code>:</p> <pre><code>textfield.setText(...); textfield.setHint(...); textfield.setLayoutParams(...); textfield.setTextSize(...); ... </code></pre> <p>After that, just add the edit text to the activity:</p> <pre><code>this.addView(textfield); </code></pre> <p>Easy! Right?</p> <p>Of course not!</p> <p>The hardest part of this is deciding how you want to layout the views. If you don't like doing that, you can use this alternative way.</p> <p>First, create an XML layout file, then use XML to design how your view will look. Let's say you want to have a <code>TextView</code> on the left and an <code>EditText</code> on the right. You just need to put a text view and an edit text in a horizontal linear layout.</p> <p>After that, get the inflated view:</p> <pre><code>View v = getLayoutInflater().inflate(R.layout.your_layout_name, null); </code></pre> <p>And add it to parent:</p> <pre><code>addView(v); </code></pre> |
12,108,875 | 0 | <p>@JcFx - This has not been the case actually!</p> <pre><code><div style="width: 100%; margin-top: 10px"> <div style="float: left; display: inline-block; width: 50%" class="div1"> <div style="float: left; display: inline-block; width: 25%" class="div2"> <ul> <li class="list1"> <asp:Label ID="lblPrefix" runat="server" Text='Prefix'></asp:Label> </li> </code></pre> <p>and so on.</p> |
6,774,428 | 1 | Python get start and end date of the week <p>How to get the start date and end date of a week, and also if the following dates below comes under a particular range of start and end dates of the week how to show only those weeks start and end date.I am using python 2.4</p> <pre><code>2011-03-07 0:27:41 2011-03-06 0:13:41 2011-03-05 0:17:40 2011-03-04 0:55:40 2011-05-16 0:55:40 2011-07-16 0:55:40 </code></pre> |
40,883,500 | 0 | java-regex: How to write regular expression for two digit numbers <p>I have password field with ID locator "j_idt90". However the ID is dynamic and the two digits in the preceeding changes everytime login page loads.</p> <p>Iam using automation to capture this field and used below regular expression but it is failing. Do, let me know where I'm failing to identify the element.</p> <p>Reg Exp - <code>driver.findElement(By.id("j_idt[0-9]{2}"));</code></p> |
28,351,505 | 0 | <p>I think that your problem is that you want to use $requests as a global variable. In your code it's not. You should pass it as a reference:</p> <pre class="lang-php prettyprint-override"><code>$mh = curl_multi_init(); $requests = array(); addSentimentHandle ( 'Hello', $requests ); addSentimentHandle ( 'Hello :)', $requests ); function addSentimentHandle($tweet, &$requests) { $url = makeURLForAPICall($tweet); array_push($requests, curl_init ($url)); print_r($requests); } </code></pre> <p>note the '&' as a prefix for $requests in function declaration. Then php wont used it as a local variable in this function.</p> <p>I recommend to you to use php as an object oriented language.</p> <pre class="lang-php prettyprint-override"><code>class myAwesomeTweeterClass{ protected $_requests; public function __construct(){ $this->_requests = array(); } public function addSentimentHandle($tweet) { $url = makeURLForAPICall($tweet); array_push($this->_requests, curl_init ($url)); } public function getRequests(){ return $this->_requests; } } $mh = curl_multi_init(); $obj = new myAwesomeTweeterClass(); $obj->addSentimentHandle ( 'Hello'); $obj->addSentimentHandle ( 'Hello :)'); print_r($obj->getRequests()); </code></pre> |
37,187,338 | 0 | Input path limit for Android ndk source file <p>Is there a known limit on the path for the Android ndk input files? I've run into an issue where the input path is over 155 characters the android g++ command fails to find the file.</p> <p>The local path back down to my base directory is quite deep, in a few cases I have a full path back to a source file in the jni project making the path a bit long, though 155 doesn't seem like a very high limit.</p> <p><code>LOCAL_PATH := $(call my-dir)/../../../../../../../../../..</code></p> <p>Here is an example of a failure, at 155 characters:</p> <pre><code>/cygdrive/c/java/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/./././VECodecG723/VECodecG723.cpp arm-linux-androideabi-g++.exe: error: jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/./././VECodecG723/VECodecG723.cpp: No such file or directory arm-linux-androideabi-g++.exe: fatal error: no input files </code></pre> <p>And a success case, at 153 characters:</p> <pre><code>/cygdrive/c/java/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/././VECodecG723/VECodecG723.cpp jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/././VECodecG723/VECodecG723.cpp:26:17: fatal error: jni.h: No such file or directory #include <jni.h> </code></pre> <p>The repeating ../gen is just for this sample, the actual path contains 10 ../ and then the full path back to the file.</p> <p>I've tried the paths with the regular g++ compiler and it does not fail because of the path length. I have also tried this in a Windows command shell with the android g++ and it has the same issue.</p> <p>Is there anything I can do short of renaming my folders.</p> |
34,944,982 | 0 | <p>This is not a bug but an unsupported feature. It is currently not possible to set the parallelism for a single operator, but only the complete job.</p> <p>I have opened a JIRA for this: <a href="https://issues.apache.org/jira/browse/FLINK-3275" rel="nofollow">https://issues.apache.org/jira/browse/FLINK-3275</a></p> |
37,516,178 | 0 | Maven not able to download dependencies using eclipse, proxy not working <p>I am trying to build a maven project using eclipse. My overall problem is Maven will not connect to the online Maven repository to collect the necessary artifacts needed to build the project. I have tried using numerous proxies, but get the following errors:</p> <pre><code>Caused by: java.io.IOException: unexpected end of stream on Connection{repo.maven.apache.org:443, proxy=HTTP @ /101.96.11.44:95 hostAddress=101.96.11.44 cipherSuite=none protocol=http/1.1} (recycle count=0) at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:210) at com.squareup.okhttp.Connection.makeTunnel(Connection.java:400) at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:229) at com.squareup.okhttp.Connection.connect(Connection.java:159) at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175) at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120) at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330) at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319) at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241) at com.squareup.okhttp.Call.getResponse(Call.java:271) at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228) at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199) at com.squareup.okhttp.Call.execute(Call.java:79) at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:154) at io.takari.aether.okhttp.OkHttpAetherClient.get(OkHttpAetherClient.java:100) at io.takari.aether.connector.AetherRepositoryConnector$GetTask.resumableGet(AetherRepositoryConnector.java:600) at io.takari.aether.connector.AetherRepositoryConnector$GetTask.run(AetherRepositoryConnector.java:453) at io.takari.aether.connector.AetherRepositoryConnector.get(AetherRepositoryConnector.java:304) ... 48 more Caused by: java.io.EOFException: \n not found: size=0 content=... at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200) at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:190) ... 65 more </code></pre> <p>I have also tried connecting to another network that is not my own and have had no success. </p> <p>When I do not use a proxy, I get the following errors:</p> <pre><code>Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:980) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375) at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:242) at com.squareup.okhttp.Connection.connect(Connection.java:159) at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175) at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120) at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330) at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319) at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241) at com.squareup.okhttp.Call.getResponse(Call.java:271) at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228) at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199) at com.squareup.okhttp.Call.execute(Call.java:79) at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:154) at io.takari.aether.okhttp.OkHttpAetherClient.get(OkHttpAetherClient.java:100) at io.takari.aether.connector.AetherRepositoryConnector$GetTask.resumableGet(AetherRepositoryConnector.java:600) at io.takari.aether.connector.AetherRepositoryConnector$GetTask.run(AetherRepositoryConnector.java:453) at io.takari.aether.connector.AetherRepositoryConnector.get(AetherRepositoryConnector.java:304) ... 48 more Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:505) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961) ... 67 more </code></pre> <p>The only solution that I have found is downloading the dependencies one by one from the Maven repository manually. Given that there are more than 100 dependencies left to install, I'd really prefer not to spend that much time getting this to work. If any other details need to be provided, I will be happy to do so. </p> |
25,185,601 | 0 | shift/reduce Error with Cup <p>Hi i am writing a Parser for a Programming language my university uses, with jflex and Cup I started with just the first basic structures such as Processes an Variable Declarations.</p> <p>I get the following Errors</p> <pre><code> Warning : *** Shift/Reduce conflict found in state #4 between vardecls ::= (*) and vardecl ::= (*) IDENT COLON vartyp SEMI and vardecl ::= (*) IDENT COLON vartyp EQEQ INT SEMI under symbol IDENT Resolved in favor of shifting. Warning : *** Shift/Reduce conflict found in state #2 between vardecls ::= (*) and vardecl ::= (*) IDENT COLON vartyp SEMI and vardecl ::= (*) IDENT COLON vartyp EQEQ INT SEMI under symbol IDENT Resolved in favor of shifting. </code></pre> <p>My Code in Cup looks like this : </p> <pre><code>non terminal programm; non terminal programmtype; non terminal vardecl; non terminal vardecls; non terminal processdecl; non terminal processdecls; non terminal vartyp; programm ::= programmtype:pt vardecls:vd processdecls:pd {: RESULT = new SolutionNode(pt, vd, pd); :} ; programmtype ::= IDENT:v {: RESULT = ProblemType.KA; :} ; vardecls ::= vardecl:v1 vardecls:v2 {: v2.add(v1); RESULT = v2; :} | {: ArrayList<VarDecl> list = new ArrayList<VarDecl>() ; RESULT = list; :} ; vardecl ::= IDENT:id COLON vartyp:vt SEMI {: RESULT = new VarDecl(id, vt); :} | IDENT:id COLON vartyp:vt EQEQ INT:i1 SEMI {: RESULT = new VarDecl(id, vt, i1); :} ; vartyp ::= INTEGER {: RESULT = VarType.Integer ; :} ; processdecls ::= processdecl:v1 processdecls:v2 {: v2.add(v1); RESULT = v2; :} | {: ArrayList<ProcessDecl> list = new ArrayList<ProcessDecl>() ; RESULT = list; :} ; processdecl ::= IDENT:id COLON PROCESS vardecls:vd BEGIN END SEMI {: RESULT = new ProcessDecl(id, vd); :} ; </code></pre> <p>I Guess i get the Errors because the Process Declaration and the VariableDeclaration both start with Identifiers then a ":" and then either the Terminal PROCESS or a Terminal like INTEGER. If so i'd like to know how i can tell my Parser to look ahead a bit more. Or whatever Solution is possible.</p> <p>Thanks for your answers.</p> |
34,691,358 | 0 | <p>Put what you want to exclude inside a negative lookahead in front of the match. For example,</p> <ul> <li><p>To match all punctuations apart from the question mark,</p> <pre><code>/(?!\?)[[:punct:]]/ </code></pre></li> <li><p>To match all words apart from <code>"go"</code>,</p> <pre><code>/(?!\bgo\b)\b\w+\b/ </code></pre></li> </ul> |
25,217,150 | 0 | 200 error: missing username when logging in using Parse and LiveCode <p>I am trying to login to Parse through LiveCode but keep getting this error:</p> <blockquote> <p>{"code":200,"error":"missing username"}</p> </blockquote> <p>I have been able to create users, even validate user's email (through the REST API in Parse) but when I try to login I keep getting an error. I think there is something wrong with my JSON formatting or the GET call but I can't figure it out. </p> <pre><code>command mainLogin local tLoginA, tLoginJson, tReturn, tLogin setHeaders put fld "username" into tLoginA [ "username" ] put the cPassword of fld "password" into tLoginA [ "password" ] put urlEncode ( JSON_stringified ( tLoginA ) ) into tLogin put urldecode ( tLogin ) --testing get url ( "https://api.parse.com/1/login?" & tLogin ) put it --testing put JSON_parsed ( it ) into tReturn if ( tReturn [ "error" ] <> empty ) then answer "Please try again: " & tReturn [ "error" ] end if if ( tReturn [ "sessionToken" ] is NOT empty ) then //user logged in successfully put tReturn [ "sessionToken" ] into sSessionToken put tReturn [ "objectid" ] into sObjecteID answer "Welcome " && tLoginA [ "username" ] mainClearFields end if end mainLogin </code></pre> <p>The functions <code>JSON_parsed()</code> and <code>JSON_stringified()</code> are from a JSON library by Andreas Rozek.</p> <hr> <p><strong>Update</strong></p> <p>I pulled this from the Parse.com REST API documentation on logging in:</p> <blockquote> <p>After you allow users to sign up, you need to let them log in to their account with a username and password in the future. To do this, send a GET request to the /1/login endpoint with username and password as URL-encoded parameters...</p> </blockquote> <p>I get that conceptually but I can't get it to work.</p> <p>Thanks Mark for your comment. I see that I was using the Post header handler which has the <code>Content-Type: application/json</code> added but that doesn't change much. According to the Parse.com docs the GET verb is the proper one (I changed the code to show the new header handler).</p> |
35,178,104 | 0 | <p>Try this:-</p> <pre><code><RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/clock_number"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Hello World!" /> </RelativeLayout> </code></pre> |
4,528,828 | 0 | <p>Your plugin should add a class or maybe a .data cache item to elements that have already been activated by the plugin. Then inside your plugin you can ignore an element if it has already been activated.</p> <p>Also another way is just to select elements from the fragment returned by the ajax call.</p> <pre><code>$('.class').plugin(); $.post(url, function(response) { // add more .class elements. $(response).find('.class').plugin(); }); </code></pre> |
36,774,431 | 0 | How to load images from a directory on the computer in Python <p>Hello I am New to python and I wanted to know how i can load images from a directory on the computer into python variable. I have a set of images in a folder on disk and I want to display these images in a loop.</p> |
21,222,137 | 0 | <p>It simply replaces <code>x</code> with <code>1.0f</code>, so:</p> <pre><code>NSNumber *n = FBOX(1.0f); </code></pre> <p>becomes:</p> <pre><code>NSNumber *n = [NSNumber numberWithFloat:1.0f]; </code></pre> <p>this is then presented to the compiler.</p> |
34,524,294 | 0 | How to open only inbuilt calling application in android not skype or other applications <pre><code>private void makeCall() { Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + phoneNumber)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } </code></pre> <p>I want to open only phone built call app not Skype or other applications.</p> |
15,426,142 | 0 | Log Files in HBase <p>Where will be the HLog files are stored in HBase. Currently i am using HBase on top of my local file system instead of HDFS, I wanted to observe how HBase is logging the details for each operation like put. How can i observe that?<br> I wanted to check how it is handling the user given timestamp</p> |
23,243,249 | 0 | How to play .mkv video in ASP.NET MVC using Microsoft.Web.Helpers.Video? <p>THis is a Self explantory title! I have a asp.net mvc application where I display videos from youtube. Now we decided not to use youtube because of their ads and other... First I used </p> <pre><code> @Microsoft.Web.Helpers.Video.Flash(...) </code></pre> <p>to display <code>.swf</code> videos. Can anyone tell me How to play <code>.mkv</code> videos in ASP.NET MVC using(or not using) <code>Microsoft.Web.Helpers.Video</code> helper ?</p> |
6,378,822 | 0 | <p>The months are numbered from zero, not one. In other words, "6" is July, not June.</p> <p>(I mean, they're numbered that way as far as the JavaScript "Date" class is concerned.)</p> |
3,138,626 | 0 | <p>You're essentially asking what is referred to as 'matchmaking' in PC and console games.</p> <p>The notion of displaying all currently online players or active matches is an early one in online multiplayer gaming, and I think it's seen its time. Instead, try and offer your players two options: Play with your friends or play against people of your skill level.</p> <p>Showing someone a complete list of tens/hundreds or even thousands of games/players is just going to overwhelm them. People are much more comfortable knowing they're playing against people they know (and trust not to be unsportsmanlike) or at least that they're playing against someone of comparable skill level. These 2 concepts are often called 'buddy based matchmaking' (or friend lists) and 'automatch' or skill based matchmaking. </p> <p>Unfortunately, from what I've seen in the <a href="http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008304-CH1-SW1" rel="nofollow noreferrer">GameKit framework</a>, neither are fully supported, at least as far as playing on non LAN connections. You're going to have to either develop that yourself (and very few iPhone developers are going to have the resources to create and host it), or see if someone like <a href="http://openfeint.com/developers" rel="nofollow noreferrer">OpenFeint</a>, ngmoco (<a href="http://plusplus.com/about" rel="nofollow noreferrer">plusplus</a>), Chillingo (<a href="http://www.crystalsdk.com/" rel="nofollow noreferrer">Crystal</a>) etc match your needs. OpenFeint seem to be talking about matchmaking on their site and plusplus offer buddy based challenges. The OpenFeint signup process is the easiest and you get access to their SDK right away for development without prior approval.</p> <p>Now here's one final thing to consider: smaller games aren't going to have the player base to have enough concurrent players around so that everyone will always find a suitable match at any time of the day/week. Unless you have promotion and publisher backing, or a breakaway hit, picking an automatch based solution is not your best bet and shouldn't be your only mode of matchmaking. Ideally your game should allow for some turn based form of game play, so you can play asynchronously. That model has worked great for games like Words With Friends.</p> |
22,048,718 | 0 | <p>The only progress I have made on this question is the discovery that on the workstation I was using, the SUBST command was used to create drive D. That is to say, C and D are really the same physical drive.</p> <p>SUBST does not seem to completely break Git though. I have the project on drive D and the git repo on a completely different directory on drive D and everything works.</p> <pre><code>username@host /d/ProjectName (branch) $ cat .git gitdir: d:\gitrepo\ProjectName.git </code></pre> <p>So the best answer I have is a workaround, where I advise: In Windows there may be an issue:</p> <pre><code>1. If the repo and working dir are on different drives 2. If (1) is true and you use SUBST </code></pre> <p>But whichever of those is the case, the work around is one or both of the following:</p> <pre><code>1. put everything on the same drive letter. It works even if that drive is a 'subst' drive. 2. Use the windows "d:\" notation in the .git file </code></pre> |
3,713,871 | 0 | Globally Reuse ActiveRecord Queries across Models? <p>Not sure how to word the question concisely :).</p> <p>I have say 20 Posts per page, and each Post has 3-5 tags. If I show all the tags in the sidebar (<code>Tag.all.each...</code>), then is there any way to have a call to <code>post.tags</code> not query the database and just use the tags found from <code>Tag.all</code>?</p> <pre><code>class Post < ActiveRecord::Base end class Tag < ActiveRecord::Base end </code></pre> <p>This is how you might use it:</p> <pre><code># posts_controller.rb posts = Post.all # posts/index.html.haml - posts.each do |post| render :partial => "posts/item", :locals => {:post => post} # posts/_item.html.haml - post.tags.each do |tag| %li %a{:href => "/tags/#{tag.name}"}= tag.name.titleize </code></pre> <p>I know about the following optimizations already:</p> <ol> <li>Rendering partials using <code>:collection</code></li> <li>Eager loading with <code>Post.first(:include => [:tags])</code></li> </ol> <p>I'm wondering though, if I use <code>Tag.all</code> in my <code>shared/_sidebar.haml</code> template, is there anyway to reuse the result from that query in the <code>post.tags</code> calls?</p> |
27,323,524 | 0 | Execute ScriptCS from c# application <p><strong>Background</strong></p> <p>I'm creating a c# application that runs some status checks (think nagios style checks).</p> <p>What I ideally want is this c# application to look at a specific directory, and just compile/execute any scriptcs scripts within it, and act on the results (send email alerts for failing status checks for example).</p> <p>I would expect the script to return an integer or something (for example) and that integer would indicate weather the status check succeeded or failed.</p> <p>Values returned back to C# application.</p> <pre><code>0 - Success 1 - Warning 2 - Error </code></pre> <p>When first tasked with this I thought this is a job for MEF, but it would be vastly more convenient to create these 'status checks' without having to create a project or compile anything, just plopping a scriptcs script within a folder seems way more attractive.</p> <p><strong>So my questions are</strong></p> <ol> <li><p>Is there any documentation/samples on using a c# app and scriptcs together (google didn't net me much)?</p></li> <li><p>Is this a use case for scriptcs or was it never really intended to be used like this? </p></li> <li><p>Would I have an easier time just creating a custom solution using roslyn or some dynamic compilation/execution? (I have very little experience with scriptsc)</p></li> </ol> |
2,329,519 | 0 | <p>String literals are simply zero terminated array of chars in C++. There is no operator that allows you to add 2 arrays of chars in C++. </p> <p>There is however a char array and std::string + operator.</p> <p>Change to: </p> <pre><code>const std::string message = std::string("Hello") +", world" + exclam; </code></pre> <p>In some languages like Python string literals are equivalent to variables of type strings. C++ is not such a language.</p> |
32,053,810 | 0 | <p>Your code does not call the replyBlock in the first if block (before the else). Might that be the code path that you see the error log for? </p> |
14,763,233 | 0 | <p>If there is a <code>FOREIGN KEY</code> constraint from <code>activity</code> to <code>item</code> (and assuming that <code>user_id</code> is in table <code>activity</code>), then your query is equivalent to:</p> <pre><code>SELECT COUNT(*), COUNT(DISTINCT user_id) FROM activity WHERE item_id = 3839 AND created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY) ; </code></pre> <p>which should be more efficient as it has to get data from only one table or just one index. An index on <code>(item_id, created_at, user_id)</code> would be useful.</p> |
10,766,037 | 0 | Calling External function from within function - Javascript <p>I am using Phonegap and JQueryMobile to create a web application. I'm new to javascript and am having an issue.</p> <p>My issue is with calling a function I have in a file named "testscript.js", the function is called testFunc. The testscript.js containts only this:</p> <pre><code>function testFunc() { console.log("Yes I work"); } </code></pre> <p>Within my html page I have the following code:</p> <pre><code><script> $('#pageListener').live('pageinit', function(event) { testFunc(); }); </script> </code></pre> <p>The test function is found within my "testscript.js" which I am including with this line within the head tags:</p> <pre><code><script src="testscript.js"></script> </code></pre> <p>The error I get is a "testFunc is not defined".</p> <p>I am assuming its some type of scope issue as I'm able to call other jquery functions such as:</p> <pre><code>alert("I work"); </code></pre> <p>and I am able to call my functions by sticking them within script tags in the html elsewhere.</p> <p>I've tried all sorts of ways of calling my function with no success, any help is appreciated!</p> |
19,447,200 | 0 | <pre><code>public class Car { private String make; private String model; public Car(String make, String model) { this.make = make; this.model = model; } public void setMake (String str1) { make = str1; } public void setModel (String str2) { model = str2; } public String getMake() { return make; } public String getModel() { return model; } } public class PrintCars { public static void main(String []args) { Car cars[] = new Car[10]; // Assume you populate the array with Car objects here by code cars[0] = new Car("make1", "model1"); for (Car carObj : cars) { System.out.println(carObj.getmake()); System.out.println(carObj.getmodel()); } } } </code></pre> |
27,827,463 | 0 | <p>On Windows at the command prompt run: <code>gradlew referencePdf --stacktrace</code> and that should tell you what happened. In my case, it was a heap size issue. I set an environment variable <code>set GRADLE_OPTS="-Xmx1024m"</code> then was able to build the pdf successfully.</p> |
15,445,045 | 0 | <p>it's an array, not a string, so just give it the array of points:</p> <pre><code>... var points = []; $(this).children("input").each(function(index) { points[index] = $(this).val(); }); var plot1 = $.jqplot('chart1',[points]); </code></pre> <p>updated fiddle: <a href="http://jsfiddle.net/fdKRw/4/" rel="nofollow">http://jsfiddle.net/fdKRw/4/</a></p> |
8,850,112 | 0 | <p>This can be done simply with the following to get the actual text value...</p> <pre><code>var value = $("[name='MyName'] option:selected").text(); </code></pre> <p>or this to get the option 'value' attribute...</p> <pre><code>var value = $("[name='MyName']").val(); </code></pre> <p>With the following html, the first will give you 'MyText', the second will give you 'MyValue'</p> <pre><code><select name="MyName"> <option value="MyValue" selected="selected">MyText</option> </select> </code></pre> <p><a href="http://jsfiddle.net/mQSYh/">Here is a working example</a></p> |
17,752,366 | 0 | element select validation error <p>I am confused as how to validate this strip of code in HTML5:</p> <pre><code><select onChange="window.open(this.options[this.selectedIndex].value,'_top')"> <option value=""> Choose Your State or Jurisdiction </option> <option value="allaw.htm">Alabama </option> <option value="aklaw.htm">Alaska </option> (and so on for all states) </code></pre> <p>Which gives me a dropdown box of all the states. The error I get in validation is "text not allowed in element select in this context"</p> <p>Could someone please point out how to validate this? Do I change the element select to something else? </p> <p>Thanks a lot!</p> <p>Gordon</p> |
5,398,532 | 0 | <p>Strange. I use webview and an options menu, works fine. </p> <p>I don't extend WebView... I extend activity, then config the webview in the XML or add the webview to "content view". </p> <p>Do all the websettings and add my own chromeclient and viewclient to change the functionality of webview.</p> <p>I just switched from adding menus programmatically to using an XML descriptor. So I know it still works.</p> <p>I'm using SDK 7 (2.1.x)</p> <p>If you need to extend webview, post your reasons and some code and hopefully I can help.</p> |
34,502,580 | 0 | <p>It is really hard to work with transformations if node will be transformed before cache. As workaround you can add transformed node to a group, then cache the group.</p> <pre><code>var text1 = new Konva.Text({ text:'Test', scale: {x:10,y:10}, x:10, y:10 }); group1.add(text1); group1.cache(); </code></pre> <p><a href="http://jsbin.com/fotano/edit?html,js,output" rel="nofollow">http://jsbin.com/fotano/edit?html,js,output</a></p> |
27,885,585 | 0 | <p>This is a <em>one-to-one</em> translation to F#:</p> <pre class="lang-ml prettyprint-override"><code>type A() = let mutable _items = null member this.items with get() = if _items = null then _items <- DAL.FetchFromDB() _items let a = A() let x = a.items // db access here let y = a.items </code></pre> <p>There are better (and shorter) ways to write equivalent code in F# using objects (see the other answer), but you don't need to create an object at all, you can simply define a function and as others already pointed out you can use the <code>lazy</code> keyword:</p> <pre class="lang-ml prettyprint-override"><code>let items = let v = lazy DAL.FetchFromDB() fun () -> v.Value let x = items() // db access here let y = items() </code></pre> <p>or use the standard lazy value directly, I would prefer this because you are making explicit in the type of <code>items</code> that your value is lazy evaluated instead of hiding it behind a <em>magic</em> object property or function:</p> <pre class="lang-ml prettyprint-override"><code>let items = lazy DAL.FetchFromDB() let x = items.Value // db access here let y = items.Value </code></pre> <p>So now the type of <code>items</code> is <code>Lazy<'List<'T>></code> which is always telling you that the value will be lazy computed, apart from that in this case the code is actually shorter.</p> |
533,040 | 0 | <p>The two forms are equivalent.</p> <p>The recommended style is to use the braces for one line blocks and use the "do"-"end" for multiline blocks.</p> <p><strong>Edit:</strong> <a href="http://stackoverflow.com/users/36378/austin-ziegler/">Austin Ziegler</a> pointed out (in the comment below) that the two forms have difference precedence levels: Curly braces have higher precedence. Therefore, when calling a method without parenthesis a block enclosed in {} will bind to the last argument instead of the calling method. </p> <p>The following example was suggested by Austin:</p> <pre><code>def foo yield end puts foo { "hello" } puts foo do "hello" end </code></pre> <p>The first "puts" prints "hello": foo gets called returning "hello" which is the argument to puts.</p> <p>The second bails with an error:</p> <pre><code>in `foo': no block given </code></pre> <p>Since in this case the do-end block binds to the puts method.</p> <p>Thanks again to Austin for clearing this up.</p> |
4,543,593 | 0 | Is ther any tool to extract keywords from a English Text or Article In Java? <p><strong>I am trying to identify the type of the web site(In English) by machine.</strong> I try to download the homepage of the web iste, download html page, parsing and get the content of the web page. Such as here are some context from CNN.com. I try to get the keywords of the web page, mapping with my database. If the keywords include like news, breaking news. The web site will go to the news web sites. If there exist some words like healthy, medical, it will be the medical web site.</p> <p>There exist some tools can do the text segmentation, but it is not easy to find a tool do the semantic, such as <strong>online shopping</strong>, it is a keywords, should not spilt two words. The combination will be helpful information. But "oneline", "shopping" will be less useful as it may exist online travel...</p> <p>• Newark, JFK airports reopen • 1 runway reopens at LaGuardia Airport • Over 4,155 flights were cancelled Monday • FULL STORY</p> <pre><code>* LaGuardia Airport snowplows busy Video * Are you stranded? | Airport delays * Safety tips for winter weather * Frosty fun Video | Small dog, deep snow </code></pre> <p>Latest news</p> <pre><code>* Easter eggs used to smuggle cocaine * Salmonella forces cilantro, parsley recall * Obama's surprising verdict on Vick * Blue Note baritone Bernie Wilson dead * Busch aide to 911: She's not waking up * Girl, 15, last seen working at store in '90 * Teena Marie's death shocks fans * Terror network 'dismantled' in Morocco * Saudis: 'Militant' had al Qaeda ties * Ticker: Gov. blasts Obama 'birthers' * Game show goof is 800K mistakeVideo * Chopper saves calf on frozen pondVideo * Pickpocketing becomes hands-freeVideo * Chilean miners going to Disney World * Who's the most intriguing of 2010? * Natalie Portman is pregnant, engaged * 'Convert all gifts from aunt' CNNMoney * Who controls the thermostat at home? * This Just In: CNN's news blog </code></pre> |
13,159,540 | 0 | <p>There's no such thing as internal/private methods in perl objects. Common practise is to start any methods which should not be used publicly with an underscore, but this is not enforced in any way. Also have a look at moose - it takes a lot of the hassle out of OO perl.</p> <p>With regards to your question the below shows how one module method can call another module method, with both having access to the object data. Again I woulds really recommend you use Moose!</p> <pre><code>sub publicSub{ my ( $self ) = @_; return $self->_privateSub(); } sub _privateSub{ my ( $self ) = @_; return $self->{name}; } </code></pre> |
4,695,740 | 0 | translate dutch sql data to english <p>i currently have a dutch sql 2005 database and would like to hopefully convert a good portion of it to english if possible. I have scoured google for options however im at a loss. Some sites are suggesting a wordlist database (from TT Solutions) however the most complete one that i could find is $2000. Anybody have any suggestions?</p> |
38,837,424 | 0 | Rails 4.2: datetime attribute not being saved <p>I'm using an attribute named <code>:subscription_active_untill</code> in my user table, its type is <code>datetime</code>, I'm trying to save a datetime stamp in it but it is not being saved. For example, executing current command in rails console</p> <pre><code>User.find(3).update(:subscription_active_untill => 1473363930) </code></pre> <p>it returns <code>true</code> in console but when I see the record using <code>User.find(3)</code> the <code>:subscription_active_untill</code> attribute is still <code>nill</code>. What could be the issue?</p> <p><strong>Note:</strong> I can update any other attribute of the same record without any issue, the problem is with this specific attribute.</p> |
18,022,794 | 0 | How to call jQuery function inside jquery tmpl? <p>This is my code:</p> <pre><code><script id="quotes" type="text/x-jquery-tmpl"> {{each(i,market) Markets}} <span style="margin-left:3px;">${market.Symbol}</span>&nbsp; <span class="lastPrice">${market.CurrentQuote.LastPrice}</span>&nbsp; {{/each}} </script> </code></pre> <p>What I want is to make LastPrice look like "3.00". I tried to use jquery's number function, but can't make it work. For example, if I do this:</p> <pre><code>$.number(${market.CurrentQuote.LastPrice}, 2) </code></pre> <p>it shows $.number(3, 2) instead of 3.00. If I do this,</p> <pre><code>${number($market.CurrentQuote.LastPrice, 2)} </code></pre> <p>it returns nothing.</p> |
14,511,449 | 0 | Understanding Core Data Queries(searching data for a unique attribute) <p>Since I am coming from those programmers who have used sqlite extensively, perhaps I am just having a hard time grasping how Core Data manages to-many relationships. </p> <p>For my game I have a simple database schema on paper. </p> <pre><code>Entity: Level - this will be the table that has all information about each game level Attributes: levelNumber(String), simply the level number : levelTime(String), the amount of time you have to finish the level(this time will vary with the different levels) : levelContent(String), a list of items for that level(and that level only) separated by commas : levelMapping(String), how the content is layed out(specific for a unique level) </code></pre> <p>So basically in core data i want to set up the database so i can say in my fetchRequest:</p> <blockquote> <p>Give me the levelTime, levelContent and levelMapping for Level 1.(or whatever level i want)</p> </blockquote> <p>How would i set up my relationships so that i can make this type of fetchRequest? Also I already have all the data ready and know what it is in advance. Is there any way to populate the entity and its attributes within XCode? </p> |
38,808,629 | 0 | <p>First you must tried something :)</p> <p>Please check this links </p> <p><a href="http://stackoverflow.com/questions/19730598/right-to-left-support-for-twitter-bootstrap-3">Right to Left support for Twitter Bootstrap 3</a> </p> <p><a href="http://stackoverflow.com/questions/23336065/twitter-bootstrap-pull-right-and-pull-left-for-rtl-languages">Twitter Bootstrap pull-right and pull-left for RTL languages</a></p> |
33,894,259 | 0 | <p>You need <code>GROUP_CONCAT/LISTAGG</code> equivalent in <code>SQL Server</code>. You can use <code>XML, STUFF and correlated subquery</code> as replacement.</p> <p>If <code>PRODUCT_ID</code> is <code>UNIQUE</code> you can use:</p> <pre><code>WITH cte AS ( SELECT PD.PRODUCT_ID, PD.PRODUCT_NAME, PD.BARCODE, PD.SUPPLIER_BARCODE, ODI.ORDER_ITEM_ID FROM PRODUCTS PD JOIN ORDER_ITEMS ODI ON PD.PRODUCT_ID = ODI.PRODUCT_ID WHERE ODI.SUPPLIER_ID = 34359738399 AND ORDER_STATUS = 6 AND ODI.RECORD_DELETED = 0 ) SELECT PRODUCT_ID, PRODUCT_NAME, BARCODE, SUPPLIER_BARCODE, [COUNTED] = COUNT(PD.PRODUCT_ID), [ORDER_ITEM_ID] = STUFF((SELECT CONCAT(',' , ORDER_ITEM_ID) FROM cte c2 WHERE c2.PRODUCT_ID = c1.PRODUCT_ID ORDER BY c2.ORDER_ITEM_ID FOR XML PATH ('')), 1, 1, '') FROM cte c1 GROUP BY PRODUCT_ID,PRODUCT_NAME,BARCODE,SUPPLIER_BARCODE HAVING COUNT(PRODUCT_ID) = 1 ORDER BY PRODUCT_ID ASC; </code></pre> <p><kbd><strong><a href="https://data.stackexchange.com/stackoverflow/query/397868" rel="nofollow"><code>LiveDemo_SimplifiedVersion</code></a></strong></kbd></p> <p>Otherwise correlate using multiple columns:</p> <pre><code>SELECT CONCAT(',' , ORDER_ITEM_ID) FROM cte c2 WHERE c2.PRODUCT_ID = c1.PRODUCT_ID AND c2.PRODUCT_NAME = c1.PRODUCT_NAME AND ... ORDER BY c2.ORDER_ITEM_ID FOR XML PATH ('')), 1, 1, '') </code></pre> |
23,745,636 | 0 | <p>Function templates <a href="http://stackoverflow.com/a/22411782/2567683">mix weirdly with overloading</a>.</p> <p>A possible solution (not the unique) would be to use <code>enable_if</code> for the declaration of each function enalbing the second for pointer types and vise versa for the first</p> <pre><code>#include <type_traits> template <class TO, class FROM> FORCE_INLINE typename enable_if<!is_pointer<FROM>::value, TO>::type punning_cast(const FROM &input) { ... } template <class TO, class FROM> FORCE_INLINE typename enable_if<is_pointer<FROM>::value, TO>::type punning_cast(const FROM input) { ... } </code></pre> <p>So an example of achieving the dissambiguation (between reference and pointer) would be <a href="http://ideone.com/xsbd55" rel="nofollow"><strong>this one</strong></a></p> |
9,593,651 | 0 | <p>In most cases, you could have one RDS instance that all 3 ec2 instances connect to. If you have a very relational demanding database application, you can look into database replication.</p> |
1,295,337 | 0 | <p>Eh.. probably not. They are different enough that you cant even Interface them.</p> |
26,404,630 | 0 | MySQL query with "not exists" takes too long <p>I have a table like this:</p> <p>u</p> <p>My query is </p> <pre><code>SELECT *, week (pdate,3) FROM pubmed where not exists (select 1 from screened where suser=86 and ssearch=pubmed.aid) order by pdate desc </code></pre> <p>Screened has only 30000 records, but the query takes several minutes. </p> <p>Pubmed.aid is the primary index.</p> <p>I think I have created all the indexes I can use. Any ideas?</p> <p>Thank you.</p> |
23,573,074 | 0 | Can I load all shipping methods automatically on the shopping cart page without selecting a country first? <p>Can I load all my shipping methods automatically on the shopping cart page without prior to selecting a country?</p> <p>By Magento default, you have to select your country where you want to ship your order to. Then you have to hit the button <strong>'Get a quote'</strong> for the '<strong>Estimate Shipping and Tax</strong>'. But I want to skip this step by showing all my shipping methods automatically as soon as you are on this page. </p> <p>Is it possible?</p> |
10,294,907 | 0 | <p>There's no general "turn everything off" facility. You need to select what you want to turn off and do each individually, if that's actually possible...</p> <p>You can't disable animated zoom. This is the subject of a <a href="http://code.google.com/p/gmaps-api-issues/issues/detail?id=3033" rel="nofollow">long-standing enhancement request</a> which has been marked WontFix.</p> <p>There's no option to disable layer-switch fade. I don't think there's an enhancement request, either.</p> <p>Panning for InfoWindows is controlled by the <a href="https://developers.google.com/maps/documentation/javascript/reference#InfoWindowOptions" rel="nofollow"><code>disableAutoPan</code></a> option <em>for each InfoWindow</em>. You can set that option individually with <code>InfoWindow.setOptions()</code>.</p> <p>IE6 is <a href="https://developers.google.com/maps/faq#browsersupport" rel="nofollow">not a supported browser</a> for Version 3. If it works, it's a bonus.</p> |
3,806,858 | 0 | <p>If a DLL needs to invoke behavior in the host application, then the host should provide a <em>callback function</em> to the DLL that the DLL stores and calls when appropriate.</p> <p>Your DLL exports a function that tells it to display the form, right? Add a couple of parameters to that function for the EXE to provide a pointer to a callback function. The callback function should accept at least one parameter, which should be of type <code>Pointer</code>. The caller (the EXE) will use that parameter as a <em>context parameter</em>, some way for it to be reminded why the DLL is calling the EXE's function. Your DLL will store the function pointer and the context pointer, and when it's time for the DLL to tell the EXE something, it will call that function and pass the context value back. The DLL won't do anything with the context value; it's just something to store and pass back to the EXE verbatim.</p> <p>The DLL's interface will look like this:</p> <pre><code>type TDllCallback = function(Context: Pointer): DWord; stdcall; function DisplayForm(Parent: HWnd; Callback: TDllCallback; Context: Pointer): DWord; stdcall; external Dll; </code></pre> <p>The EXE will define a callback function like this:</p> <pre><code>function CallbackFunction(Context: Pointer): DWord; stdcall; begin TMainForm(Context).DoSomething; Result := 0; end; </code></pre> <p>It will call the DLL function like this:</p> <pre><code>procedure TMainForm.DoDllTaskClick(Sender: TObject); begin DisplayForm(Handle, CallbackFunction, Pointer(Self)); end; </code></pre> <p>Notice how the signature of <code>CallbackFunction</code> matches the <code>TDllcallback</code> type defined earlier. Tey both use the stdcall calling convention, and they're both <em>standalone functions</em>, not methods. Avoid methods since method pointers are particular to Delphi, and you shouldn't require your DLL to be used only by Delphi hosts, if possible.</p> |
37,610,094 | 0 | <p>You could use:</p> <pre><code>echo "<pre>"; var_dump($array); echo "</pre>"; </code></pre> <p>This way you will get a nice preformatted result of var_dump.</p> |
32,241,155 | 0 | <p>You don't import variables from a function to another. Functions are for returning values and variables, and you can always call a function to get its return value. For example:</p> <pre><code>def interest(amt): return amt * FIXED_INT def calc(debt, time): return debt * interest(debt) ** time </code></pre> |
16,596,107 | 0 | <p>Aptana Studio 3 was the reason for such behavior. Obviously it set some eclipse settings which are conflicted with Zend Studio. Uninstalling Aptana and re-installing Zend Studio solved this issue.</p> |
26,011,938 | 0 | <p>The important bit in the Oracle article you mention is the part titled - <strong>Supporting Multiple Clients</strong>.</p> <p>The basic Java socket API is a blocking API, which basically means you call a method and that method blocks until an IO event happens. If you need to wait for multiple IO events - in your case an incoming client connection and incoming data - you have to create multiple threads.</p> <p>The server shown in the article only accepts a single incomming (client) connection and will close once the client closes because the <code>InputStream</code> on the server will return <code>null</code> causing the loop to terminate.</p> <p>First your server needs to look something like this (which is simplified example):</p> <pre><code>try (ServerSocket serverSocket = new ServerSocket(portNumber)) { while (running) { Socket clientSocket = serverSocket.accept(); new Thread(new ClientHandler(clientSocket)).start(); } } </code></pre> <p><strong>Note:</strong> starting a thread for each client connection demonstrates the point but is a vast over simplification of managing the connection load on a server.</p> <p>The client code can remain as is.</p> <p>That's the basics that as I pointed out leaves the thread management in the developers hands - this often leads to trouble because people simply get it wrong. Because of this Java's socket APIs have been extended to create the <a href="http://en.wikipedia.org/wiki/Non-blocking_I/O_(Java)" rel="nofollow">NIO</a> API - Jakob Jenkov has written some good <a href="http://tutorials.jenkov.com/java-nio/index.html" rel="nofollow">tutorials</a>.</p> <p>It's also worth looking at <a href="http://netty.io/" rel="nofollow">Netty</a>, which personally I think is easier to use than <a href="http://en.wikipedia.org/wiki/Non-blocking_I/O_(Java)" rel="nofollow">NIO</a>.</p> |
16,506,692 | 0 | <p>thanks to to the answer here</p> <p><a href="http://www.rohitab.com/discuss/topic/39969-hook-function-without-knowing-signature/" rel="nofollow">http://www.rohitab.com/discuss/topic/39969-hook-function-without-knowing-signature/</a></p> <blockquote> <p>I guess, you almost there with your code... you just need to make your trampoline function not >damaging the stack... firstly the function should be declared naked (without default prologue, in >studio I believe it would be something like __declspec(naked) or something)... secondly you need to >think about do you need to do something after the call to original function... if not, I think it is >better just to simply make a jmp instead of call (using inline assembler or something)... </p> </blockquote> <p>Here is my code. used vs2012 on windows 7 64bit but 32bit compile. simple win32 console app . hope it helps anyone else</p> <pre><code>#include "stdafx.h" void originalFunction(int x,int y,int z) { printf("running originalFunction with x=%d\n",x); } __declspec(naked) void trampolineFunction() { __asm jmp [originalFunction] } int _tmain(int argc, _TCHAR* argv[]) { ((void (*)(...))trampolineFunction)(7,8,9); getchar(); return 0; } </code></pre> |
15,307,875 | 0 | MVC3 and EF5: Including Child and GrandChild entities in the View <p>To make things simple, I have 3 entities (one to many, left to right):</p> <p>COURSE -> MODULE -> CHAPTER</p> <p>A course can have multiple modules and a module can have multiple chapters.</p> <p>All I have in the controller is this:</p> <pre><code>Course course = db.Courses.Find(id); return View(course); </code></pre> <p>I was trying to use an include but it doesn't seem to evaluate (this doesn't seem to work: <code>Course course = db.Courses.Include("Modules").Find(id);</code>)</p> <p>So I let it be. In my view, I have this nested List:</p> <pre><code><ul> @foreach (var item in Model.Modules) { <li>@module.Title <ul> @foreach (var item in module.Chapters) { <li>@chapter.Title</li> } </ul> </li> } </ul> </code></pre> <p>Will this work automatically?</p> <p>Lastly, I applied a SortOrder column so I could arrange the child entities. I know that this should be done in the query, but how can I do this?</p> <p>Thanks! Any piece of information or advise would be highly appreciated.</p> <p><strong>UPDATE</strong></p> <p><strong>Course Class</strong></p> <pre><code>public partial class Course { public Course() { this.Modules = new HashSet<Module>(); this.Assets = new HashSet<Asset>(); } public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public string Author { get; set; } public System.DateTime CreateDate { get; set; } public bool IsDeleted { get; set; } public int IndustryId { get; set; } public virtual ICollection<Module> Modules { get; set; } public virtual ICollection<Asset> Assets { get; set; } public virtual Industry Industry { get; set; } } </code></pre> <p><strong>Module Class</strong></p> <pre><code>namespace RocketLabs.Models { using System; using System.Collections.Generic; public partial class Module { public Module() { this.Chapters = new HashSet<Chapter>(); this.Assets = new HashSet<Asset>(); } public int Id { get; set; } public string Title { get; set; } public System.DateTime CreateDate { get; set; } public int CourseId { get; set; } public bool IsDeleted { get; set; } public short SortOrder { get; set; } public virtual Course Course { get; set; } public virtual ICollection<Chapter> Chapters { get; set; } public virtual ICollection<Asset> Assets { get; set; } public virtual Exam Exam { get; set; } } } </code></pre> <p><strong>Chapter Class</strong></p> <pre><code>namespace RocketLabs.Models { using System; using System.Collections.Generic; public partial class Chapter { public Chapter() { this.Assets = new HashSet<Asset>(); } public int Id { get; set; } public string Title { get; set; } public int ModuleId { get; set; } public string Notes { get; set; } public short SortOrder { get; set; } public System.DateTime CreateDate { get; set; } public bool IsDeleted { get; set; } public virtual Module Module { get; set; } public virtual ICollection<Asset> Assets { get; set; } } } </code></pre> |
31,247,229 | 0 | Which version of swift compiler is the default Xcode 6.4? <p>I have some tests failing on a new machine with Xcode 6.4, with this error:</p> <pre><code>'NSDictionary' is not implicitly convertible to '[NSObject : AnyObject]'; did you mean to use 'as' to explicitly convert? </code></pre> <p>On my machine (still on a old Xcode 6.2) the test is ok. Unfortunately I can't upgrade my machine for the moment. </p> <p>Any suggestion on how can I achieve the same behaviour on both Xcode versions? I'm suspecting different Swift compilers are used, because that part of code isn't changed at all...</p> <p><strong>EDIT</strong>: Found the versions:</p> <ul> <li>Swift version 1.1 (swift-600.0.57.4) -> Xcode 6.2</li> <li>Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53) -> Xcode 6.4</li> </ul> |
20,985,860 | 0 | Extensions-like context menu in Chrome Apps (browser wide) <p>I have been practicing with Chrome extensions and apps and noticed <code>chrome.contextMenu</code> is not browser-wide for Chrome Apps. It only manages the context menu of the App background windows.</p> <p>Is there a way to create browser-wide context menus like extensions have? If there isn't any API in Apps, how can I also include an extension with my app so that users won't need to install two different things?</p> <p>Here is the project: <a href="https://github.com/metherealone/chorrent" rel="nofollow">https://github.com/metherealone/chorrent</a></p> <p>Obviously, I only need to catch magnet links and torrent files with the extension.</p> |
10,074,904 | 0 | Why I can't perform mouse move using Selenium WebDriver for C# and PageFactory in initialization <p>I have an link in HTML and I use Page Object pattern to write scripts with Selenium. But I can't perform MouseMove action when object is initialized with pageFactory. So, I have such class:</p> <pre><code>class BingPage { private readonly IWebDriver driver; public static readonly String BASE_URL = "http://bing.com/"; [FindsBy(How = How.XPath, Using = ".//*[@id='scpt2']/a[text()='Shopping']")] private IWebElement ShoopingLink; public BingPage(IWebDriver driver) { this.driver = driver; //Page Factory will use Driver to init searchButton and queryEdit objects PageFactory.InitElements(driver, this); } public void HoverShoppingLink() { Actions builder = new Actions(driver); IWebElement elem = driver.FindElement(By.XPath(".//*[@id='scpt2']/a[text()='Shopping']")); builder.MoveToElement(elem).Build().Perform();//This will work builder.MoveToElement(ShoopingLink).Build().Perform(); //This will fail } } </code></pre> <p>Line marked with comment "This will fail" will throw an exception "Must provide a location for a move action. Parameter name: actionTarget"</p> <p>But when I manually lookup element - it works. Could someone tell me why?</p> <p>It is selenium 2.0 for .Net, .Net 4.0 with IE driver.</p> |
142,503 | 0 | <p>Great Question! If I'm not mistaken I don't think debugging is possible inside of SQL Management Studio anymore (as it was back in the SQL Server 2000, Enterprise Studio days).</p> <h2>Instructions to Remote Debug MS SQL Stored Procedures within Visual Studio 2005</h2> <ol> <li>Launch Visual Studio (If you're running from Vista, <strong>Run As Administrator</strong>)</li> <li>Within Visual Studio 2005 click <strong>View->Server Explorer</strong>, which you'll notice brings up a panel with a <strong>Data Connections</strong> element.</li> <li>Right click on <strong>Data Connections</strong> and select <strong>Add Connection</strong></li> <li>Ensure the <strong>Data Source</strong> is set to <strong>SqlClient</strong>.</li> <li>Fill out the Server connection information, filling in the database name where the stored procedure that you wish to debug lives.</li> <li>Once a successful connection is made you'll notice the a tree for the database is populated that gives you the list of Tables, Views, Stored Procedures, Functions, etc.</li> <li>Expand <strong>Stored Procedures</strong>, finding the one you wish to debug and right click on it and select <strong>Step Into Stored Procedure</strong>. </li> <li>If the stored procedure has parameters a dialog will come up and you can specify what those parameters are.</li> <li>At this point, depending on your firewall settings and what not, you maybe be prompted to make modifications to your firewall to allow for the necessary ports to be opened up. However, Visual Studio seems to handle this for you.</li> <li>Once completed, Visual Studio should place you at the beginning of the stored procedure so you can starting the act of debugging!</li> </ol> <p>Happy Debugging!</p> |
5,176,398 | 0 | <p>I have a project called <a href="http://yaam.codeplex.com/" rel="nofollow">Yaam on CodePlex</a> that uses C# to send data through the serial port. Check that out for an example. On the C# side (see Yaam\Yaam.xaml.cs), simply use the <code>SerialPort</code> class in the <code>System.IO.Ports</code> namespace. Once you instantiate the object and set the properties (baud rate, com port, etc), simply call<code>.Open()</code> . There are also plenty of other examples on the web. Take a look at these:</p> <ul> <li><a href="http://jtoee.com/2009/02/talking-to-an-arduino-from-net-c/" rel="nofollow">http://jtoee.com/2009/02/talking-to-an-arduino-from-net-c/</a></li> <li><a href="http://www.instructables.com/id/Interfacing-your-arduino-with-a-C-program/" rel="nofollow">http://www.instructables.com/id/Interfacing-your-arduino-with-a-C-program/</a></li> </ul> |
3,983,544 | 0 | Programatically set OnSelectedIndexChanged for a ddl <p>a minor question but it's driving me nuts. I'm programatically generating about 50 DDLs based on a database schema (i.e. item 1 can do a,b,c item 2 can do d, e, a, etc etc).</p> <p>If I was just writing the markup, I could specify:</p> <p>asp:DropDownList OnSelectedIndexChanged="funTimes"</p> <p>and be done with it, unfortunately, I'm just not sure how to set that programatically. I found a "SelectedIndexChanged" event, but I'm not sure what I need to return in terms of an event handler when all I want to do is set the method called. I realize I could write 50 methods:</p> <p>ddl1_SelectedIndexChanged() ddl2_SelectedIndexChanged() etc etc</p> <p>but that solution isn't terribly flexible, especially when I really only want the same method called. Is there a good way to accomplish what I'm trying to do here? Any input is greatly appreciated. Thanks.</p> |