pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
12,924,387 | 0 | <h2><a href="http://developer.apple.com/library/ios/#technotes/tn2265/_index.html" rel="nofollow">Apple's recommended way to reset the notification</a></h2> <p>During development only, of course.</p> <blockquote> <p>If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:</p> <p>Delete your app from the device. Turn the device off completely and turn it back on. Go to Settings > General > Date & Time and set the date ahead a day or more. Turn the device off completely again and turn it back on.</p> </blockquote> <p>Don't forget to turn it off completely and back on.</p> |
40,251,223 | 0 | Downloading Firebase Storage Files Device Issue <p>I am trying to download a word document from Firebase storage. On the simulator everything is working as expected. Yet on my device, I get the following error:</p> <blockquote> <p>Optional(Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=Bulletin/26 October 2016.docx, bucket=southam-college-app.appspot.com, NSLocalizedDescription=An unknown error occurred, please check the server response., ResponseErrorDomain=NSCocoaErrorDomain, NSFilePath=/tmp/bulletin, NSUnderlyingError=0x1702590b0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}, ResponseErrorCode=513})</p> </blockquote> <p>Other posts I have been looking at do not seem to give me a working answer, and all I know is that there is an issue with file permissions, even though I am using the recommended directory (tmp).</p> <p>This is the code for downloading the file</p> <pre><code> let Ref_Bulletin = Bulletin.referenceForURL("gs://southam-college-app.appspot.com/Bulletin/\(Today.stringFromDate(NSDate())).docx") // Create local filesystem URL let localURL: NSURL! = NSURL(string: "file:///tmp/bulletin/today.docx") // Download to the local filesystem let downloadTask = Ref_Bulletin.writeToFile(localURL) { (URL, error) -> Void in if (error != nil) { print(error.debugDescription) // Uh-oh, an error occurred! } else { print("Working As Expected") self.Web_View.loadRequest(NSURLRequest(URL: localURL)) } </code></pre> <p>So what is causing this problem and how do I fix it?</p> <p><strong>Update:</strong></p> <p>So I tried to create the directory but I am being told that I don't have permission even though the documentation says I can write to the tmp.</p> <blockquote> <p>Unable to create directory Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “today.docx” in the folder “bulltin”." UserInfo={NSFilePath=/tmp/bulltin/today.docx, NSUnderlyingError=0x1702498a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}</p> </blockquote> <p>This is the code for creating the directory:</p> <pre><code> do { try NSFileManager.defaultManager().createDirectoryAtPath(localURL.path!, withIntermediateDirectories: true, attributes: nil) } catch let error as NSError { NSLog("Unable to create directory \(error.debugDescription)") } </code></pre> |
39,103,868 | 0 | Xamarin iOS project need suggestion <p>I am developing a survey app using Xamarin and Mvvmcross. Can some one help with suggesting a way to build a View to display questionnaire. These questionnaire will be supplying from my View Model as a List of question with Question Text, Answer options. Based on a flag I need to prompt the questionnaire with input type as drop down or Text boxes. Number of questions can be vary.</p> <p>In Android I achieved it using MvxGridView and Layout templates. But not sure how to do it in iOS.</p> |
18,716,263 | 0 | Blogger API v.3 - can't transfer the data to the post (javascript) <p>New post created with out data - <a href="http://yatsynych.blogspot.com/" rel="nofollow">http://yatsynych.blogspot.com/</a>. Problem on object body_data?</p> <p>My source:</p> <pre><code>function makeApiCallBlogger() { gapi.client.setApiKey('AIzaSyDFnBwpKVqjMm9NJ4L0Up5Y_bYpsaJdC6I'); gapi.client.load('blogger', 'v3', function() { var body_data = { "kind": "blogger#post", "blog": { "id": "********" }, "title": "A new post", "content": "With <b>exciting</b> content..." } var request = gapi.client.blogger.posts.insert({ "blogId": '********', "body": body_data}); request.execute(function(response) { alert(response.toSource()); }); }); } </code></pre> |
37,327,688 | 0 | <p>You're using Spark 1.3.0 and Python version of <code>createDirectStream</code> has been introduced in Spark 1.4.0. Spark 1.3 provides only Scala and Java implementations.</p> <p>If you want to use direct stream you'll have to update your Spark installation. </p> |
10,951,894 | 0 | <p>You shouldn't be storing all that HTML in the database. Only store the <em>data</em> in the database. I'm not sure whats going on exactly since I don't understand that language but you should be storing each of those numbers in a column in your database and the querying for them in PHP. You will have a variable for each of those numbers and then you print those out in your table format. Something as simple as the line below will work:</p> <pre><code><tr><td> </td> <td align='right'><?php echo $variable_name; ?></td></tr> </code></pre> |
22,677,583 | 0 | <p>You probably want to pad it with 0 bytes. Fill your newtitle buffer with zeroes before copying the string into it, then write that buffer to the file:</p> <pre><code>char newtitle[80]; memset(newtitle, '\0', 80); strncpy(newtitle, title, 80); fwrite(newtitle, sizeof(char), 80, fp); </code></pre> <p>You can pass whatever ASCII character you want into memset(), to pad it with. But with binary files you'll generally use <code>'\0'</code>.</p> |
16,022,220 | 0 | Reverse words in C Language <p>I'm trying to reverse the letters for words in a sentence. I am also trying to store these words in a new char array. At the moment I getting a runtime error, which for all my tweaking I can not solve. My approach is to create a new char array the same length as the sentence. Then loop through the sentence until I reach a ' ' character. Then loop backwards and add these characters to a word. Then add the word to the new Sentence. Any help would be much appreciated.</p> <pre><code>int main(void) { char sentence [] = "this is a sentence"; char *newSentence = malloc(strlen(sentence)+1); int i,j,start; start = 0; for(i = 0; i <= strlen(sentence); i++) { if(sentence[i] == ' ') { char *word = malloc((i - start)+1); for(j = sentence[i]; j >= start; j--) { word[j] = sentence[j]; } strcat(newSentence,word); start =sentence[i +1]; } } printf("%s",newSentence); return 0; } </code></pre> |
31,841,491 | 0 | <p>Use a symlink.</p> <pre><code># Move current storage folder to where you want it to be mv storage ../storage # Create a symlink to this new location ln -s ../storage ./storage </code></pre> |
31,176,091 | 0 | <p>A solution with the <code>data.table</code> package:</p> <pre><code>require(data.table) df <- data.table(CLNCL_TRIAL_ID = c(89794, 89794,8613, 8613), SITE_ID = c(12456, 12456, 100341, 30807)) df[,length(unique(SITE_ID)),by=CLNCL_TRIAL_ID] </code></pre> <p>Produces</p> <pre><code> CLNCL_TRIAL_ID V1 1: 89794 1 2: 8613 2 </code></pre> |
3,333,923 | 0 | <p>You defined the variable <code>masterTable</code> but are accessing it with lowercase <code>mastertable</code>?</p> |
37,446,529 | 0 | <p>You can't force something to be synchronous if it goes outside of the event loop like an ajax call. You're going to need something that looks like this:</p> <pre><code>PlanLineActions.calculateFlightEndDate(periodTypeId, numberOfPeriods, momentTimeUnix) .then(endDate => { this.theNextSyncFunction(..., ..., ...); }) </code></pre> <p>In order to do this, <code>calculateFlightEndDate</code> will also need to return a promise, and thus it's a good thing that promises are chainable.</p> <pre><code>calculateFlightEndDate(periodTypeId, numberOfPeriods, startDate) { let plan = new Plan(); // return promise! return plan.getFlightEndDate(periodTypeId, numberOfPeriods, startDate).then(response => { return response.EndDate; // must return here }, error => { log.debug("There was an error calculating the End Date."); }); } </code></pre> <p>That should do it.. and one more thing: you're doubling up on promises in your server call. If something has <code>.then</code> it's already a promise, so you can just return that directly. no need to wrap in <code>new Promise</code> (a promise in a promise.. no need!)</p> <pre><code>callServer(path, method = "GET", query = {}, data, inject) { // just return! return super.callServer(uri.toString(),method,data,inject).then((data) => { return data; }).catch((data) => { if (data.status === 401) { AppActions.doRefresh(); } throw data; // throw instead of reject }); } </code></pre> |
38,503,076 | 0 | <p>Try this code</p> <pre><code>$('input').each(function(){ self = $(this) if(!self.val()){ require(self); } }); function require(that){ console.log('Please fill in ' +that.data('validate-msg') + '.'); } </code></pre> |
28,489,982 | 0 | Set range and define named range in VBA <p>I am trying to define a named range (with Workbook scope) in VBA based on certain inputs to help figure out the cells that should be included in the range. To make it really simple, I have tried the following two with the errors indicated below. A, B, X, Y are found from some calculations</p> <pre><code>rName = <some string that decides the name> Set TempRng = .Range(.Cells(A,B), .Cells(X,Y)) ActiveWorkbook.Names.Add Name:=rName, RefersTo:=Worksheets("Sheet1").TempRng </code></pre> <p>This gives me an "object or method not supported" error or something like that, on the Set TempRng line.</p> <pre><code>rName = <string ...> Set TempRng = Worksheets("Sheet1").Range(Cells(A,B), Cells(X,Y)) ActiveWorkbook.Names.Add Name:=rName, RefersTo:= <blah blah...> </code></pre> <p>This gives me an "application defined or object defined error" on the same line.</p> <p>Can you please help me find the correct way to define this range?</p> |
17,725,714 | 0 | Nested MySQL select error <p>I'm trying to make the following transaction work, but the I get a mysql error near SELECT. I've double-checked that all column names are correct.</p> <p><strong>Error message</strong></p> <blockquote> <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO articles (catid,content,title,keywords,isactive) (SELEC' at line 2</p> </blockquote> <p><strong>SQL</strong></p> <pre><code>START TRANSACTION; INSERT INTO articles (catid,content,title,keywords,isactive) (SELECT 1, pendingarticles.content, pendingarticles.title, pendingarticles.keywords, 1 FROM pendingarticles WHERE pendingarticles.id=1); DELETE FROM pendingarticles WHERE id=1; COMMIT; </code></pre> <p><strong>UPDATE</strong></p> <p>The code itself works. Both the INSERT INTO - SELECT part, and the DELETE part. Something's wrong with the transaction. Perhaps <code>;</code>? Or my db server can't do transactions? </p> |
19,429,888 | 0 | how to find identical columns in different tables <p>I have two tables each with multiple columns.</p> <pre><code>+------+-------+--+ | Col1 | Col2 | | +------+-------+--+ | 1 | 1231 | | | 2 | 123 | |table 1 | 3 | 14124 | | +------+-------+--+ +------+-------+--+ | Col3 | Col4 | |table 2 +------+-------+--+ | 1 | 1231 | | | 2 | 323 | | | 3 | 14324 | | +------+-------+--+ </code></pre> <p>I want to check is if <code>col1</code> and <code>col3</code> are identical. That is: all the values match, to be determined using sql?</p> <p>I dont want to use <code>except</code> and also I don't want to take difference of the two columns and check if its zero.</p> <p>Is there a more efficient way to do this?</p> |
21,546,802 | 0 | <p>You just need to change the value of size. You have assigned 1480. Please change it to 7 or less than 7 or you can just remove size from select statement That is the reason. It wont show the selected value till the time it completes its size , which according to your code is 1480. Just change its value and execute again. Good luck</p> |
31,552,598 | 0 | Remove Query String from Rootdomain <p>I know with a simple redirect one (Sub-)Domain or Folder to another i can get rid of a string like this</p> <pre><code>RewriteEngine On RewriteRule (.*) http://www.domain.tld/? [R=301,L] </code></pre> <p>I know how to get rid of it when it is a simple file too.</p> <p>But when it comes to the Rootdomain itself (<a href="http://domain.tld/?Stringwhatsoever" rel="nofollow">http://domain.tld/?Stringwhatsoever</a>), i am at a loss here. My last try used a modified version of a redirect I used to redirect files and folders around and that worked pretty nicely and also removed the query, but it ended up in a redirection error.</p> <pre><code>RewriteRule ^ http://domain.tld/? [L,NC,R=301] </code></pre> <p>So i have no clue how to get rid of Query Strings at urls without breaking it.</p> |
15,843,558 | 0 | <p>As per Sams comment... Readthedocs has the working example: <a href="http://zf2.readthedocs.org/en/latest/modules/zend.view.helpers.html#headtitle-helper" rel="nofollow">http://zf2.readthedocs.org/en/latest/modules/zend.view.helpers.html#headtitle-helper</a></p> <p>Thanks for your help Sam!</p> |
38,932,157 | 0 | <p>Your code is a beginning, but doesn't fill all values. You should <em>nest</em> your for-loops, and only fill the left part. The right entry can then be mirrored from the left entry. Try this:</p> <pre><code>public static void main(String[] args) { int[][] table = new int[5][8]; for (int row = 0; row < 5; row++) { for (int column = 0; column < 4; column++) { // left side entry [row][0..3] // each entry is 5 more than the entry left of it table[row][column] = column * 5 + row + 1; // right side entry [row][7..4] mirrored from corresponding entry [row][0..3] // i.e. column 7 <- column 0, column 6 <- column 1, etc. table[row][7 - column] = table[row][column]; } } for (int row = 0; row < 5; row++) { for (int column = 0; column < 8; column++) { System.out.format("%4d", table[row][column]); } System.out.println(); } } </code></pre> <p>Output:</p> <pre><code> 1 6 11 16 16 11 6 1 2 7 12 17 17 12 7 2 3 8 13 18 18 13 8 3 4 9 14 19 19 14 9 4 5 10 15 20 20 15 10 5 </code></pre> |
36,068,945 | 0 | <p>Not sure what your exact goal is, but I can think of two approaches to accomplish this without compiling:</p> <p>1) Split up the values like so:</p> <pre><code><div ng-repeat="string in myStrings"> <p>{{string}}{{mathValue}}</p> </div> </code></pre> <p>in controller:</p> <pre><code>$scope.mathValue = 2+2; </code></pre> <p>2) Use a function to return the string (I like using this anytime I'm doing anything binding that is non-trivial):</p> <pre><code><div ng-repeat="string in myStrings"> <p>{{stringFunction()}}</p> </div> </code></pre> <p>in controller:</p> <pre><code>$scope.mathValue = 2+2; $scope.stringFunction = function() { return 'I want to count to 4 via angular: '+$scope.mathValue; }; </code></pre> |
27,584,236 | 0 | Splitting equation made of NSString with NSRegularExpression and finding left side of Equation <p>I have a string such as below in my application:</p> <pre><code> b=c+32 </code></pre> <p>I parse the string using below code snippet to split it to b,=,c,+,32. That works fine. However I need to know which variable is left side of the "=" operator. This variable always comes first in the expression. Is there a way in NSRegularExpressions to give me index of the results so I can compare them to see what's left side of "=". If there's a better match that would give me the first element I would settle for that too.</p> <p>Here's the code to split them.</p> <pre><code> NSString * textpattern = @"[A-Za-z]+"; NSString * numberpattern = @"[0-9]+"; NSString * opPattern = @"[-+/*]"; NSString * copPattern = @"="; NSRegularExpression * reg = [NSRegularExpression regularExpressionWithPattern: @"(\\d+\\.\\d+)|(\\d+)|([a-z])|([+-/*=///^])|([/(/)])" options:0 error:nil]; NSArray *matches = [ reg matchesInString: exp options: 0 range:NSMakeRange(0, [exp length])]; for (NSTextCheckingResult *match in matches) { NSString* text = [exp substringWithRange:[match range]]; NSMutableDictionary *term = [NSMutableDictionary new]; if ([text doesMatchRegStringExp:textpattern]) { NSLog(@"variable"); [term setObject:@"variable" forKey:@"name"]; } else if ([text doesMatchRegStringExp:numberpattern]) { NSLog(@"number"); [term setObject:@"number" forKey:@"name"]; } else if ([text doesMatchRegStringExp:opPattern]) { NSLog(@"op"); [term setObject:@"op" forKey:@"name"]; } else if ([text doesMatchRegStringExp:copPattern]) { NSLog(@"cop"); [term setObject:@"cop" forKey:@"name"]; } else { [term setObject:@"other" forKey:@"name"]; } } // NSString+RegExpExtensions.h #import <Foundation/Foundation.h> @interface NSString (RegExpExtensions) - (BOOL)doesMatchRegStringExp:(NSString *)string; @end #import "NSString+RegExpExtensions.h" @implementation NSString (RegExpExtensions) - (BOOL)doesMatchRegStringExp:(NSString *)string { NSPredicate *regExpPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", string]; return [regExpPredicate evaluateWithObject:self]; } @end </code></pre> <p>Thank you. </p> |
40,314,623 | 0 | Method that returns DataReader -- will it cause resource leaks? <p>Say I have the following code:</p> <pre><code>private AdomdDataReader ExecuteReader(string query) { var conn = new AdomdConnection(ConnectionString); conn.Open(); var cmd = new AdomdCommand(query, conn); cmd.Parameters.Add("Foo", "Bar"); return cmd.ExecuteReader(CommandBehavior.CloseConnection); } </code></pre> <p>Then in usage, you'd wrap the reader in a <code>using</code> statement:</p> <pre><code>using (var reader = ExecuteReader("...")) ... </code></pre> <p>This would be in contrast to manually opening a connection and executing a reader each time:</p> <pre><code>using(var conn = new AdomdConnection(ConnectionString)) { conn.Open(); using(var cmd = new AdomdCommand(query, conn)) { cmd.Parameters.Add("Foo", "Bar"); var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); ... } } </code></pre> <p>So I'm basically just trying to reduce boilerplate for reading many similar queries from a database. Am I exposing myself to resource leaks by doing so?</p> |
12,746,372 | 0 | TDD for a new Java application - Where should I start? <p><strong>Goal</strong> : testing TDD in a typical enterprise Java environment.</p> <p><strong>Context :</strong></p> <p>Frameworks used (even if it's overkill, I practice <a href="http://www.scotthyoung.com/blog/2008/05/05/use-projects-to-educate-yourself-for-free/" rel="nofollow">project based learning</a>) :</p> <ul> <li>DAO : Hibernate</li> <li>Spring IoC</li> <li>Front : Spring MVC + Twitter Boostrap (if possible)</li> <li>TDD : JUnit</li> <li>DB : PostgreSQL</li> </ul> <p>My project is a simple billing system which would help freelancers create, edit and print/send bills to customers.</p> <p>Once my project is created and configured, I don't know where to start. Let's say my first my first feature is to create a bill with a unique number and a title.</p> <p><strong>Question</strong> : What should I test first ?</p> <ul> <li>the Domain layer with a createBill(String title) method which would generate a unique Serial Number ? I'd mock the DB layer.</li> <li>the UI first, mocking the service layer ? I don't know how to do it.</li> </ul> <p>Thanks in advance for your answers,</p> <p>Cheers</p> |
38,359,039 | 1 | python - minimax algorithm for tic tac toe updating the board by filling every empty space with the same symbol <p>I have been trying to improve my understanding of python by programming small games, such as tic tac toe. I created a copy of the game from scratch, but then went off to find a way of creating a reasonable ai for the game. I decided to use minimax to achieve this goal. I found a tutorial for the algorithm and attempted to mould it for the game. </p> <p>However when the code is run, on the ai's first turn. Every empty space left on the board is filled with the same symbol, forcing a win, making the game unplayable.</p> <p>As I was unfamiliar and inexperienced with the algorithm, I took the code from a youtube tutorial and edited it so that it was functional for the game. </p> <p>Here is the code</p> <pre><code>import random import time import sys from sys import maxsize #converts numbers from the board to X O and "" for printing out the board def numToSymbol(board): visual = board for i in range(0, 9): if visual[i] == -1: visual[i]= "X" elif visual[i] == 1: visual[i] = "O" elif visual[i] == 0: visual[i] = " " return visual def symbolToNum(visual): board = visual for i in range(0, 9): if board[i] == "X": board[i] = -1 elif board[i] == "O": board[i] = 1 elif board[i] == " ": board[i] = 0 return board # prints the board, first coverting numbers throught numtoSymbol def drawBoard(): visual = numToSymbol(board) print( "|"+ str(visual[0]) + "|" + str(visual[1]) + "|" + str(visual[2]) + "| \n" "-------\n" "|"+ str(visual[3]) + "|" + str(visual[4]) + "|" + str(visual[5]) + "| \n" "-------\n" "|"+ str(visual[6]) + "|" + str(visual[7]) + "|" + str(visual[8]) + "| \n" "-------") symbolToNum(visual) # checks the possible options for 3 in a row and if any are all held by one side returns true def checkWin(board, winConditions, ai): if ai == True: win = 3 if ai == False: win = -3 for row in winConditions: checkA = board[row[0]] checkB = board[row[1]] checkC = board[row[2]] if checkA + checkB + checkC == int(win): return True return False def checkDraw(board): emptyTile = 9 for tile in board: if tile != 0: emptyTile -= 1 if emptyTile == 0: completion(2) def availableMoves(board, bonus): availableSlots = [] for position in range(0,9): if board[position] == 0: availableSlots.append(position + bonus) return availableSlots def playerTurn(board, remainingTurns): board = board checkDraw(board) visual =drawBoard() print("pick one of the available slots \n") availableSlots = availableMoves(board, 1) print(availableSlots) choice = int(input('Select a tile from those shown above:\n')) -1 while True: if 0 <= choice <= 8: if board[choice] == 0: board[choice] = -1 break else: choice = int(input('Select a tile from those shown above which has not already been selected:\n')) -1 else: choice = int(input('Select a tile from those shown above:\n')) -1 visual = drawBoard() if checkWin(board, winConditions, False) == True: completion(0) else: aiTurn(board, remainingTurns - 1) class Node(object): def __init__(self, remainingTurns, playerNum, board, value = 0): self.depth = remainingTurns self.playerNum = playerNum self.board = board self.value = value self.moves = availableMoves(self.board, 0) self.children = [] self.createChildren() def availableMoves(self, board): self.availableSlots = [] for position in range(0,9): if board[position] == 0: availableSlots.append(position) return self.availableSlots def winCheck(self, state, playerNum): self.winConditions = [[0, 1, 2],[3, 4, 5],[6, 7, 8],[0, 3, 6],[1, 4, 7],[2, 5, 8],[0, 4, 8],[2, 4, 6]] self.win = 3 for row in self.winConditions: self.checkA = self.state[row[0]] self.checkB = self.state[row[1]] self.checkC = self.state[row[2]] if self.checkA + self.checkB + self.checkC == int(self.win * self.playerNum): return True return False def createChildren(self): if self.depth > 0: for i in self.moves: self.state = self.board self.state[i] = self.playerNum print(board) self.children.append(Node(self.depth - 1, self.playerNum * -1, self.state, self.realVal(self.state, self.playerNum) )) def realVal(self, value, playerNum): value = self.winCheck(self.state, self.playerNum) if value == True: return maxsize * self.playerNum else: return 0 def minimax(node, depth, playerNum): if depth == 0 or abs(node.value) == maxsize: return node.value bestValue = maxsize * -playerNum for i in range(len(node.children)): child = node.children[i] val = minimax(child, depth - 1, -playerNum) if (abs(maxsize * playerNum - val) < abs(maxsize * playerNum - bestValue)): bestValue = val return bestValue def aiTurn(board, remainingTurns): checkDraw(board) print('Waiting for ai') time.sleep(2) board = board state = board currentPlayer = 1 tree = Node(remainingTurns, currentPlayer, state) bestChoice = -100 bestValue = maxsize * -1 for i in range(len(tree.children)): n_child = tree.children[i] i_val = minimax(n_child, remainingTurns, -currentPlayer,) if (abs(currentPlayer * maxsize - i_val) <= abs(currentPlayer * maxsize - bestValue)): bestValue = i_val bestChoice = i print(bestChoice) print(board) #choice = minimax(tree, remainingTurns, 1) board[bestChoice] = 1 print(board) if checkWin(board, winConditions, True) == True: completion(1) else: playerTurn(board, remainingTurns - 1) def completion(state): if state == 1: print('The computer has won this game.') choice = str(input('press y if you would like to play another game; Press n if you would not \n')) if choice == 'y' or choice == 'Y': playGame() else: sys.exit() if state == 0: print('you win!') choice = str(input('press y if you would like to play another game; Press n if you would not \n')) if choice == 'y' or choice == 'Y': playGame() else: sys.exit() if state == 2: print('you drew') choice = str(input('press y if you would like to play another game; Press n if you would not \n')) if choice == 'y' or choice == 'Y': playGame() else: sys.exit() def playGame(): global board board = [0,0,0,0,0,0,0,0,0] global winConditions winConditions = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6] ] global remainingTurns remainingTurns = 9 playerFirst = random.choice([True, False]) if playerFirst == True: playerTurn(board, remainingTurns) else: aiTurn(board, remainingTurns) if __name__ == '__main__': playGame() </code></pre> <p>This is the output from the above code</p> <pre><code>[1, 0, 0, 0, 0, 0, 0, 0, 0] [1, -1, 0, 0, 0, 0, 0, 0, 0] [1, -1, 1, 0, 0, 0, 0, 0, 0] [1, -1, 1, -1, 0, 0, 0, 0, 0] [1, -1, 1, -1, 1, 0, 0, 0, 0] [1, -1, 1, -1, 1, -1, 0, 0, 0] [1, -1, 1, -1, 1, -1, 1, 0, 0] [1, -1, 1, -1, 1, -1, 1, -1, 0] [1, -1, 1, -1, 1, -1, 1, -1, 1] [1, -1, 1, -1, 1, -1, 1, -1, -1] [1, -1, 1, -1, 1, -1, 1, 1, -1] [1, -1, 1, -1, 1, -1, 1, 1, 1] [1, -1, 1, -1, 1, -1, -1, 1, 1] [1, -1, 1, -1, 1, -1, -1, -1, 1] [1, -1, 1, -1, 1, -1, -1, -1, -1 [1, -1, 1, -1, 1, 1, -1, -1, -1] [1, -1, 1, -1, 1, 1, 1, -1, -1] [1, -1, 1, -1, 1, 1, 1, 1, -1] [1, -1, 1, -1, 1, 1, 1, 1, 1] [1, -1, 1, -1, -1, 1, 1, 1, 1] [1, -1, 1, -1, -1, -1, 1, 1, 1] [1, -1, 1, -1, -1, -1, -1, 1, 1] [1, -1, 1, -1, -1, -1, -1, -1, 1 [1, -1, 1, -1, -1, -1, -1, -1, - [1, -1, 1, 1, -1, -1, -1, -1, -1 [1, -1, 1, 1, 1, -1, -1, -1, -1] [1, -1, 1, 1, 1, 1, -1, -1, -1] [1, -1, 1, 1, 1, 1, 1, -1, -1] [1, -1, 1, 1, 1, 1, 1, 1, -1] [1, -1, 1, 1, 1, 1, 1, 1, 1] [1, -1, -1, 1, 1, 1, 1, 1, 1] [1, -1, -1, -1, 1, 1, 1, 1, 1] [1, -1, -1, -1, -1, 1, 1, 1, 1] [1, -1, -1, -1, -1, -1, 1, 1, 1] [1, -1, -1, -1, -1, -1, -1, 1, 1 [1, -1, -1, -1, -1, -1, -1, -1, [1, -1, -1, -1, -1, -1, -1, -1, [1, 1, -1, -1, -1, -1, -1, -1, - [1, 1, 1, -1, -1, -1, -1, -1, -1 [1, 1, 1, 1, -1, -1, -1, -1, -1] [1, 1, 1, 1, 1, -1, -1, -1, -1] [1, 1, 1, 1, 1, 1, -1, -1, -1] [1, 1, 1, 1, 1, 1, 1, -1, -1] [1, 1, 1, 1, 1, 1, 1, 1, -1] [1, 1, 1, 1, 1, 1, 1, 1, 1] 8 [1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1] The computer has won this game. </code></pre> <p>Any suggestions?</p> |
26,614,215 | 0 | <p>Open JDK version 1.7.0_09 do not have this package. JDK by Oracle has this package.</p> |
2,996,559 | 0 | <p>You can use <code>unsafe</code> and pointers. But your particular case would say a bit more about what direction you should head.</p> |
39,872,775 | 0 | In Android Studio how to create jar Including other jar libraries <p>In android studio, i'm trying to create .jar file of my library and it contains another .jar dependancies. After adding created .jar file to another project and run it gives me </p> <pre><code>java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.co.xyz.MyLibrary/in.co.xyz.MyLibrary.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "in.co.xyz.MyLibrary.MainActivity" on path: DexPathList[[zip file "/data/app/in.co.xyz.MyLibrary-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] </code></pre> <p>how to fix this issue, please help me</p> |
22,912,056 | 0 | Can't save data to Access Database <p>I learnt this programming from other sources, and I also downloaded his file to test is it works. I did everything same with him, but mine is not works and not coming out any errors. Could any senior help me to do some correction or debug.</p> <p>This is my code:</p> <pre><code>Dim Command As New OleDb.OleDbCommand Dim Adapter As New OleDb.OleDbDataAdapter Dim Connection As OleDb.OleDbConnection = AConnection() Public Function AConnection() As OleDb.OleDbConnection Return New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Music_Sales_Database.mdb") End Function Private Sub SendCustomerInformationToDatabase() Connection.Open() With Command .Connection = Connection .CommandText = "INSERT into Customer(Customer_ID,First_Name,Last_Name,Contact_Number,Email_Address) " & _ "Values('" & txtCustomerID.Text & "','" & txtFirstName.Text & "','" & txtLastName.Text & "','" & txtContactNumber.Text & "','" & _ "','" & txtEMail.Text & "')" End With Connection.Close() End Sub Private Sub CheckOut_Reservation_Load(sender As Object, e As EventArgs) Handles MyBase.Load txtDateOfReservation.Text = Date.Today txtCustomerID.Focus() InputText = txtContactNumber.Text NumericCheck = IsNumeric(InputText) Connection.Open() With Command .Connection = Connection .CommandText = "SELECT * from Customer" End With Dim Table As New DataTable Adapter.SelectCommand = Command Adapter.Fill(Table) Connection.Close() Adapter.Dispose() End Sub Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click SendCustomerInformationToDatabase() Dim CheckOutSound As String Dim path = System.Windows.Forms.Application.StartupPath Dim MyPlayer As New SoundPlayer() CheckOutSound = "\Success.wav" MyPlayer.SoundLocation = path & CheckOutSound MyPlayer.Play() If AInputCorrect = True And BInputCorrect = True And CInputCorrect = True And DInputCorrect = True And EInputCorrect = True Then FInputCorrect = True Else FInputCorrect = False End If If FInputCorrect = True Then MessageBox.Show("Reservation Submitted.", "Reservation Successful", MessageBoxButtons.OK, MessageBoxIcon.None) End If If FInputCorrect = False Then MessageBox.Show("Please check your Customer Information and try again.", "Reservation Failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) End If 'Me.Close() End Sub </code></pre> <p>Thank You</p> |
19,559,568 | 0 | <p>To delete a row/cell from table view, you need to call the <code>deleteRowsAtIndexPaths:withRowAnimation:</code> method on your <code>UITableView</code> instance. </p> <pre><code>NSIndexPath *previousPath = [NSIndexPath indexPathForRow:selectedRowIndex1.integerValue-1 inSection:0]; [self.yourTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:previousPath] withRowAnimation:UITableViewRowAnimationFade]; </code></pre> <p>This will update the UI, but remember to remove that row from your data source as well. This will ensure it is deleted completely.</p> <p>Hope that helps!</p> |
24,007,232 | 0 | <p>Sure, the function like <code>sprintf</code> is <code>sprintf</code>. You can put functions in the stash and call them from TT, and if you want them to be available all the time you can add them to the <code>TEMPLATE_VARS</code> in your view.</p> |
19,390,606 | 0 | Authenticate with LinkedIn api using javascript issues <p>Using the Linkedin Tutorial, I'm trying to login to LinkedIn using Javascript.</p> <p>The issue I have: using firebug for verification I realize that the http request does not show errors, but the LinkedIn Button is not rendered and the http response is:</p> <pre><code>(function(){ var r=("true" === "false"), a=("false" === "false"), h=[], e=("false" === "true"); var p="${SCOPE_NAME}"; var s=("SCOPE_VALID" === "SCOPE_INVALID"), n=("SCOPE_VALID" === "SCOPE_NOT_AUTHORIZED"), d=("SCOPE_VALID" === "SCOPE_DISABLED"); if(e){ throw new Error("An error occurred."); } else if (!a) { throw new Error("API Key is invalid"); } else if (s) { throw new Error("Scope parameter is invalid: " + p); } else if (n) { throw new Error("Scope parameter is not authorized: " + p); } else if (d) { throw new Error("Scope parameter is disabled: " + p); } else if (h.length == 0) { throw new Error("You must specify a valid JavaScript API Domain as part of this key's configuration."); } else if (!r) { throw new Error("JavaScript API Domain is restricted to "+h.join(", ")); } else { throw new Error("Unknown Error"); } })(); </code></pre> <p>Can you assist me in solving this issue?</p> |
31,132,179 | 0 | Symfony join with many to many <p>I would like to know how can I Make a join into another join.</p> <p>My QueryBuilder</p> <pre><code>return $this->createQueryBuilder("t") ->leftjoin("t.playlist","p","WITH","p.genres=:genreP") ->setParameter(":genreP",$genre) ->addSelect("p") ->getQuery() ->getResult() ; </code></pre> <p>I had this error: [Semantical Error] line 0, col 170 near 'genres=:genreP': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.</p> <p>What I am trying to do:</p> <p>I have the <strong>Trending</strong> entity that has a relation OneToOne to the <strong>Playlist</strong> entity.The <strong>playlist</strong> entity has a relation ManyToMany to the <strong>Genre</strong> entity.</p> <p>The trending entity:</p> <pre><code>class Trending { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** *@ORM\OneToOne(targetEntity="Song", inversedBy="trending") */ private $song; /** *@ORM\OneToOne(targetEntity="Album", inversedBy="trending") */ private $album; /** *@ORM\OneToOne(targetEntity="Playlist", inversedBy="trending") */ private $playlist; } </code></pre> <p>The playlist entity</p> <pre><code>class Playlist { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="titre", type="string", length=255) */ private $titre; /** * @ORM\Column(name="public", type="boolean") */ private $public = true; /** *@ORM\ManyToOne(targetEntity="user", inversedBy="playlists") *@ORM\joinColumn(nullable=false) */ private $user; /** *@ORM\ManyToMany(targetEntity="Song", inversedBy="playlists") *@ORM\joinColumn(nullable=false) */ private $songs; /** *@ORM\ManyToMany(targetEntity="Genre", inversedBy="playlists") */ private $genres; /** *@ORM\OneToOne(targetEntity="Image", cascade={"persist","remove","refresh"}) */ private $image; /** *@ORM\ManyToMany(targetEntity="user", inversedBy="playlistLikes") *@ORM\JoinTable(name="playlist_likes") */ private $likes; /** *@ORM\Column(name="played", type="integer") */ private $played; /** *@ORM\ManyToMany(targetEntity="user", inversedBy="playlistDislikes") *@ORM\JoinTable(name="playlist_dislikes") */ private $dislikes; /** *@ORM\Column(name="description", type="text", nullable=true) */ private $description; /** *@ORM\ManyToMany(targetEntity="Langue", inversedBy="playlist") */ private $languages; /** *@ORM\Column(name="lien", type="string", length=255) */ private $lien; /** *@ORM\OneToOne(targetEntity="Trending", mappedBy="playlist", cascade= {"persist","remove"}) */ private $trending; } </code></pre> <p>The </p> <p>Trending table</p> <pre><code>id | playlist_id | song_id | album_id 54 | 9 | null | null </code></pre> <p>The playlist table</p> <pre><code>id | title 9 | My best </code></pre> <p>The playlist_genre table</p> <pre><code>playlist_id | genre_id 9 | 1 9 | 4 </code></pre> <p>The genre table</p> <pre><code>id | name 1 | Hip Hop 2 | Konpa 3 | Electronic 4 | Reggae </code></pre> <p>I would like to select any playlist where the genre_id is 4.</p> <p>Thanks.</p> |
7,465,792 | 0 | <p>Regular expressions are like the <code>sort</code> function in Perl. You think it's pretty simple because it's just a single command, but in the end, it uses a lot of processing power to do the job.</p> <p>There are certain things you can do to help out:</p> <ol> <li>Keep your syntax simple as possible.</li> <li>Precompile your regular expression pattern by using qr// if you're using that regular expression in a loop. That'll prevent Perl from having to <em>compile</em> your regular expression with each loop.</li> <li>Try to avoid regular expression syntax that has to do <a href="http://perldoc.perl.org/perlre.html#Special-Backtracking-Control-Verbs" rel="nofollow">backtracking</a>. This usually ends up being the most general matching patterns (such as <code>.*</code>). </li> </ol> <p>The wretched truth is that after decades of writing in Perl, I've never masted the deep dark secrets of regular expression parsing. I've tried many times to understand it, but that usually means doing research on the Web, and ...well... I get distracted by all of the other stuff on the Web.</p> <p>And, it's not that difficult, any half decent developer with an IQ of 240, and a penchant for sadism should easily be able to pick it up. </p> <hr> <blockquote> <p>@David W.: I guess I'm confused on backtracking. I had to read your link several times but still don't quite understand how to implement it (or, not implement it) in my case. – user522962</p> </blockquote> <p>Let's take a simple example:</p> <pre><code>my $string = 'foobarfubar'; $string =~ /foo.*bar.*(.+)/; my $result = $1; </code></pre> <p>What will <code>$result</code> be? It will be <code>r</code>. You see how that works? Let's see what happens.</p> <p>Originally, the regular expression is broken into tokens, and the first token <code>foo.*</code> is used. That actually matches the whole string:</p> <pre><code>"foobarfubar" =~ /foo.*/ </code></pre> <p>However, if the first regular expression token captures the whole string, the rest of the regular expression fails. Therefore, the regular expression matching algorithm has to back track:</p> <pre><code>"foobarfubar" =~ /foo.*/ #/bar.*/ doesn't match "foobarfuba" =~ /foo.*/ #/bar.*/ doesn't match. "foobarfub" =~ /foo.*/ #/bar.*/ doesn't match. "foobarfu" =~ /foo.*/ #/bar.*/ doesn't match. "foobarf" =~ /foo.*/ #/bar.*/ doesn't match. "foobar" =~ /foo.*/ #/bar.*/ doesn't match. ... "foo" =~ /foo.*/ #Now /bar.*/ can match! </code></pre> <p>Now, the same happens for the rest of the string:</p> <pre><code>"foobarfubar" =~ /foo.*bar.*/ #But the final /.+/ doesn't match "foobarfuba" =~ /foo.*bar.*/ #And the final /.+/ can match the "r"! </code></pre> <p>Backtracking tends to happen with the <code>.*</code> and <code>.+</code> expression since they're so loose. I see you're using non-greedy matches which can help, but it can still be an issue if you are not careful -- especially if you have very long and complex regular expressions.</p> <p>I hope this helps explain backtracking.</p> <p>The issue you're running into isn't that your program doesn't work, but that it takes a long, long time.</p> <p>I was hoping that the general gist of my answer is that regular expression parsing isn't as simple as Perl makes it out to be. I can see the command <code>sort @foo;</code> in a program, but forget that if <code>@foo</code> contains a million or so entries, it might take a while. In theory, Perl could be using a bubble sort and thus the algorithm is a O<sup>2</sup>. I hope that Perl is actually using a more efficient algorithm and my actual time will be closer to O * log (O). However, all this is hidden by my simple one line statement.</p> <p>I don't know if backtracking is an issue in your case, but you're treating an entire webpage output as a single string to match against a regular expression which could result in a very long string. You attempt to match it against another regular expression which you do over and over again. Apparently, that is quite a process intensive step which is hidden by the fact it's a single Perl statement (much like <code>sort @foo</code> hides its complexity).</p> <p>Thinking about this on and off over the weekend, you really should not attempt to parse HTML or XML with regular expressions because it is so sloppy. You end up with something rather inefficient and fragile.</p> <p>In cases like this may be better off using something like <a href="http://search.cpan.org/~gaas/HTML-Parser-3.68/Parser.pm" rel="nofollow">HTML::Parser</a> or <a href="http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm" rel="nofollow">XML::Simple</a> which I'm more familiar with, but doesn't necessarily work with poorly formatted HTML.</p> <p>Perl regular expressions are nice, but they can easily get out of our control.</p> |
12,006,838 | 0 | <p>I usually add the <code>RKObjectMapping</code> to the managedObject class</p> <p>Add this to your Document.h</p> <pre><code> + (RKObjectMapping *)objectMapping; </code></pre> <p>Add this method to your Document.m</p> <pre><code>+ (RKObjectMapping *)objectMapping { RKManagedObjectMapping *mapping = [RKManagedObjectMapping mappingForClass:[self class] inManagedObjectStore:[[RKObjectManager sharedManager] objectStore]]; mapping.primaryKeyAttribute = @"word"; [mapping mapKeyPath:@"word" toAttribute:@"word"]; [mapping mapKeyPath:@"min_lesson" toAttribute:@"minLesson"]; </code></pre> <p>} </p> <p>Off course you should change the key paths to your Document object properties. each pair is the name of the key on the server responds and it's corresponded keyPath on your managedObject.</p> <p>Then when you initialize the <code>objectManager</code> you can set the mapping for each managedObject you have.</p> <pre><code> RKManagedObjectStore *store = [RKManagedObjectStore objectStoreWithStoreFilename:databaseName usingSeedDatabaseName:seedDatabaseName managedObjectModel:nil delegate:self]; objectManager.objectStore = store; //set the mapping object from your Document class [objectManager.mappingProvider setMapping:[SRLetter objectMapping] forKeyPath:@"Document"]; </code></pre> <p>YOu can find a great tutorial here - <a href="http://mobile.tutsplus.com/tutorials/iphone/advanced-restkit-development_iphone-sdk/" rel="nofollow">RestKit tutorial</a>. In the middle of the article you will find data about mapping.</p> |
31,859,643 | 0 | MS Access Compare all fields in two tables <p>I am working on a project that has a definite start and end date, with data that will be produced daily. Every day I will be receiving a dataset with all the data from the start of the project until the previous day (e.g. on Day 10 I will receive the data from days 1 to 9, on day 11 I will receive the data for days 1 to 10 etc.). Each row of data will have approx 15 fields and I need to be able to highlight if any retrospective changes have been made to any of the fields in each row of data.</p> <p>Is there any way to do this?</p> <p>Many thanks in advance for any advice!</p> |
3,868,587 | 0 | <p><code>sqllite3</code> will probably be the easiest way forward. It's lightweight and doesn't need to be installed by users. To access it though, consider using an ORM (Object Relational Mapper) to simplify things. <a href="http://www.sqlalchemy.org/" rel="nofollow">SQL Alchemy</a> and <a href="https://storm.canonical.com/" rel="nofollow">Storm</a> are both good tools.</p> <p>An ORM deals with the nitty-gritty of writing SQL code and so forth. If you want to hop between databases, it's often just a matter of changing a single line of code.</p> |
37,601,019 | 0 | <p>I somewhat got it to work using some of the existing code above, but it is still not optimal. This might be useful for others.</p> <p>This is what I did:</p> <p>1) I socket dial only once (during initialization)</p> <p>2) The POST-section is running inside a loop infinitely. The 5 second delay is now reduced to 200 ms and I added some headers, like so:</p> <pre><code> //unsigned long data = random(1000000000000000, 9999999999999999); LTESerial.print("POST /index.php?data="); LTESerial.print(data); LTESerial.print(" HTTP/1.1\r\n"); LTESerial.print("Host: ADDRESS\r\n"); LTESerial.print("Connection: keep-alive\r\n\r\n"); delay(200); while (getResponse() > 0); </code></pre> <p>3) Turns out my WAMP server (PHP) had limitations as default in terms of maximum HTTP requests, timeouts and the like. I had to increase these numbers (I changed them to unlimited) inside <code>php.ini</code>.</p> <p>However, while I am able to "continuously" send data to my server, a delay of 200 ms is still a lot. I would like to see something close to serial communication, if possible.</p> <p>Also, when looking at the serial monitor, I get:</p> <pre><code>[...] 408295030 4238727231 3091191349 2815507344 ----------->(THEN SUDDENLY)<------------ HTTP/1.1 200 OK Date: Thu, 02 Jun 2 2900442411 016 19:29:41 GMT Server: Apache/2.4.17 (Win32) PHP/5.6.15 X-P16 3817418772 Keep-Alive: timeout=5 Connection: Keep-Alive Content-Type: te 86026031 HTTP/1.1 200 OK Date: Thu, 02 Jun 2016 19:29:4 3139838298 75272508 [...] ----------->(After 330 iterations/POSTs, I get)<------------ NO CARRIER NO CARRIER NO CARRIER NO CARRIER </code></pre> <p>So my question is: 1) How do I eliminate the 200 ms delay as well?</p> <p>2) If my data-points have different sizes, the delay will have to change as well. How to do this dynamically?</p> <p>3) Why does it stop at 330-ish iterations? This doesn't happen if data is only 4 digits.</p> <p>4) Why do I suddenly get responses from the server?</p> <p>I hope someone can use this for their own project, however this does not suffice for mine. Any ideas?</p> |
34,575,204 | 0 | Regex - has six digits, starts with 0, 1, or 2 <p>I need a regex that will match a number containing six digits. The first digit must be 0, 1, or 2.</p> <p>For example - 054654 or 198098 or 265876.</p> <p>So far I got this: <code>/^\d{6}$/</code> - matches a number containing six digits. How do I add the second requirement: first digit must be 0, 1, or 2?</p> |
36,581,850 | 0 | international chars in tcl/tk can't be handle <p>I use tcl shellicon command to extract icons, as it mentioned on wiki page below, there are some international character problems in it, then I write some code to test but it doesn't work, could anyone to help me correct it.</p> <pre><code>/* * testdll.c * gcc compile: gcc testdll.c -ltclstub86 -ltkstub86 -IC:\Users\L\tcc\include -IC:\Users\L\tcl\include -LC:\Users\L\tcl\lib -LC:\Users\L\tcc\lib -DUSE_TCL_STUBS -DUSE_TK_STUBS -shared -o testdll.dll */ #include <windows.h> #include <tcl.h> #include <stdlib.h> int TestdllCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { char * path; Tcl_DString ds; if (objc > 2) { Tcl_SetResult(interp, "Usage: testdll ?path?",NULL); return TCL_ERROR; } if (objc == 2) { path = Tcl_GetString(objv[objc-1]); path = Tcl_TranslateFileName(interp, path, &ds); if (path != TCL_OK) { return TCL_ERROR; } } Tcl_AppendResult(interp, ds, NULL); return TCL_OK; } int DLLEXPORT Testdll_Init(Tcl_Interp *interp) { if (Tcl_InitStubs(interp, "8.5", 0) == NULL) { return TCL_ERROR; } Tcl_CreateObjCommand(interp, "testdll", TestdllCmd, NULL, NULL); Tcl_PkgProvide(interp, "testdll", "1.0"); return TCL_OK; } </code></pre> <p>I compile it with:</p> <pre><code>gcc compile: gcc testdll.c -ltclstub86 -ltkstub86 -IC:\Users\USERNAME\tcc\include -IC:\Users\USERNAME\tcl\include -LC:\Users\USERNAME\tcl\lib -LC:\Users\USERNAME\tcc\lib -DUSE_TCL_STUBS -DUSE_TK_STUBS -shared -o testdll.dll </code></pre> <p>windows cmd shell run: tclsh testdll.tcl</p> <pre><code>load testdll puts [testdll C:/Users/L/桌面] </code></pre> <p>the output is:</p> <pre><code>// This line isn't in the output, just to show the first line of output is a *EMPTY LINE* while executing "testdll 'C:/Users/L/桌面'" invoked from within "puts [testdll 'C:/Users/L/桌面']" (file "testdll.tcl" line 2) </code></pre> <p>In fact, I want to print a line, whose content is "C:/Users/L/桌面"</p> <p>I write this dll to debug how to replace Tcl_GetString,Tcl_TranslateFileName with Tcl_FSGetNormalizedPath, Tcl_FSGetNativePath, I wonder if it's clear?</p> <p>Thank you!</p> |
31,607,434 | 0 | Remove join from Hibernate query with OneToOne <p>I have two simple entities with one-to-one mapping:</p> <pre><code>@Entity @Table(name="DRIVER") public class Driver implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="ID") private long id; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="CAR_ID",referencedColumnName="ID") private Car car; } </code></pre> <p>and:</p> <pre><code>@Entity @Table(name="CAR") public class Car { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="ID") private Long id; @OneToOne(mappedBy="car") private Driver driver; @Column(name="MILEAGE") private Long mileage; } </code></pre> <p>To update the mileage I call:</p> <pre><code> Car c = em.find(Car.class, id); c.setMileage(mileage); </code></pre> <p>And Hibernate query looks like this:</p> <pre><code>select car0_.ID as ID0_1_, car0_.DATE_OF_PURCHASE as DATE2_0_1_, car0_.MILEAGE as MILEAGE0_1_, car0_.MODEL as MODEL0_1_, car0_.PRODUCER as PRODUCER0_1_, driver1_.ID as ID1_0_, driver1_.CAR_ID as CAR3_1_0_, driver1_.NAME as NAME1_0_ from CAR car0_ left outer join DRIVER driver1_ on car0_.ID=driver1_.CAR_ID where car0_.ID=? </code></pre> <p>What I want is to query Car table only and remove the join operation. I tried to put FetchType.LAZY on both sides, it changes the query a bit but it doesn't remove the join.</p> <p>Is it possible to do it in such model? </p> <p>It looks like whenever you query for the owning entity, the owned entity is queried as well but I'm not sure if this is a rule.</p> |
20,385,910 | 0 | <p>Why don't you simply use static variables ?</p> <p><code>HttpContext</code> is dependent on ASP.NET pipeline. In a host-agnostic model (OWIN or self-hosted) you don't have access to it.</p> <p>Application storage in <code>HttpApplicationState</code> is only useful if you need to access the current HttpContext. If it's not necessary, you should simply use static properties. </p> <p>Moreover, <code>HttpApplicationState</code> was initially created for backward compatibility with classic ASP.</p> <pre><code>public static class StaticVariables { public static object SomeInfo { get; set; } } </code></pre> <p>See also <a href="http://stackoverflow.com/questions/2179923/singleton-and-httpapplicationstate">Singleton and HttpApplicationState</a> and <a href="http://forums.asp.net/t/1574797.aspx" rel="nofollow">http://forums.asp.net/t/1574797.aspx</a></p> |
35,788,107 | 0 | <p>I'm not sure whether you just implemented the <a href="http://stackoverflow.com/q/23803743/1048572"><code>Promise</code> constructor antipattern</a> by accident, and are now trying to generalise it, or genuinely recognised the <a href="http://stackoverflow.com/a/22562045/1048572">usefulness of functors/monads</a> (congrats!), but <strong>you've reinvented the <code>.then</code> method</strong>.</p> <p>Your code is <a href="http://stackoverflow.com/q/24662289/1048572">more or less exactly</a> equivalent to</p> <pre><code>function promiseWrap(promiseInstance, resolveFunc, rejectFunc) { // assuming promiseInstance instanceof Promise - if not, add a `Promise.resolve()` return promiseInstance.then(resolveFunc, rejectFunc); } </code></pre> <p>Indeed, this return value of <code>then()</code> calls - another promise for the result of the callback(s) - is what promises are all about.</p> |
37,804,533 | 0 | UIBezierPath set context <p>I'm trying to draw some lines using <code>UIBezierPath</code> in an overlay renderer. I get error <code>CGContextSetStrokeColorWithColor: invalid context 0x0</code> which I suspect is due to the <code>UIBezierPath</code> not knowing the context. How do I set the UIBezierPath's context?</p> <p>My <code>MKOverlayRenderer</code> is roughly:</p> <pre><code>override func drawMapRect(mapRect: MKMapRect, zoomScale: MKZoomScale, inContext context: CGContext) { let path = UIBezierPath() path.moveToPoint(...) path.addLineToPoint(...) path.lineWidth = 2 UIColor.blueColor().setStroke() path.stroke() } </code></pre> |
34,413,771 | 0 | <p>Actually the work of proximity is to detect other devices like windows phone , or windows computer through NFC.It detect those devices which has NFC tags</p> <p>Here is the link for your reference <a href="https://msdn.microsoft.com/library/windows/apps/jj207060(v=vs.105).aspx#BKMK_Requiredcapabilities" rel="nofollow">https://msdn.microsoft.com/library/windows/apps/jj207060(v=vs.105).aspx#BKMK_Requiredcapabilities</a></p> <p>and there is no clear explanation on any of the website about the detection of human body or any object that comes near the phone like when the screen turns off while getting it near to our ears may be we can use light sensors to detect object nearby.</p> <p>I think that this sensor does not have a API and is provided by default by windows phone API if we use the calling API classes</p> |
16,018,398 | 0 | <p>The compiler seems to place the casting from <code>const char&</code> to <code>char</code> on the same level as upcasting <code>std::ostringstream</code> to <code>std::ostream</code> when the overload resolution comes.</p> <p>The solution could be to template the type of <code>operator<<</code> to avoid the upcasting:</p> <pre><code>namespace _impl { template <typename T, typename Y> Y& operator<<(Y& osstr, const T& val) { return osstr; } } </code></pre> |
14,797,735 | 0 | Memcache - How to prevent frequent cache rebuilds? <p>I have been working for Memcache for the last week or so, I have managed to work out how to set keys/delete keys. This is fine but Im still attempting to work out how to do the same for a while loop of results. </p> <p>For example I will have a while loop of posts, from within the logic the function will check to see if Memcache is set, if not it will collect the results and create the key. My question is this, <strong>If I have set the looped data into a set key and display the set key (Newest First) Then what happens when a new post is inserted?</strong> I understand I can set a time limit on the set key, but as the content will/could be added whenever it seems that setting a limit could still display old posts. So my question is how would I be able to update the set key. </p> <p>The only way I can think of a possible solution is for when a user inserts a new post, this deletes the key, and when the all posts is viewed again this is when the key gets set again. But this seems rather counter productive, just as if there are 10's of users submitting posts then all the posts will be set over and over again (Doesn't really seem beneficial)</p> <p>I hope this makes sense, any help or guidance would be appreciated.</p> |
9,781,359 | 0 | Magento product zoom files <p>Can someone please tell me what are the Javascript files for default Magento Product Zoom extension. On my site its not working and seems I am missing some files.</p> <p>please reply.</p> |
40,228,331 | 0 | <p>If I understand correctly, you shouldn't need to use floats at all. Bootstrap will automatically take care of the alignment of your <code><div></code>s. Just reverse the order of your two input fields; the first one will be on the left.</p> |
32,248,418 | 0 | NodeJS with PHP <p>I am a PHP developer who just started learning Node.js and I saw this video: <a href="https://www.youtube.com/watch?v=_D2w0voFlEk" rel="nofollow">https://www.youtube.com/watch?v=_D2w0voFlEk</a> where it is explained that a html file can be given as response to the browser which is fine.</p> <p><strong>Now, my question:</strong></p> <p>If I am running Node.js and PHP in the same server and if the user visits my website, the request goes to nodejs script running in my server. Now, can I process the request in NodeJS and then give a PHP file as a response (after processing on server side) instead of .html file</p> <p>An outline of what I mean is:</p> <p>Client Request-> NodeJS server->NodeJS script->PHP server->PHP script->Client Response</p> <p>Its like stacking of 2 servers.</p> <p><strong>Why I was thinking of this..</strong></p> <p>I am making a social networking website where I already made most of my code in PHP and now I am working on real time communications where I do video/audio conferencing, text chat, etc. So, I am planning to use WebRTC and Websockets for this and found many websites telling that NodeJS is the best way to go about when taking Real Time communications to consideration. </p> <p>But, if I have to do it, I have to change all my code from PHP to NodeJS which is not a good option. So, I thought why not run PHP server inside NodeJS server.</p> <p>Thanks in advance</p> <p>I did refer this question by the way: <a href="http://stackoverflow.com/questions/2808125/recommendation-for-integrating-nodejs-with-php-application">Recommendation for integrating nodejs with php application</a> and felt my case is a bit different.</p> |
16,569,078 | 0 | <p>Move the contents of the <strong>/public</strong> folder down a level.</p> <p>You'll need to update the include lines in index.php to point to the correct location. (if it's down a level, remove the '../').</p> |
5,041,432 | 0 | Mvc 3 Razor : Using Sections for Partial View? <p>I defined a section in partial view and I want to specify the content of section from view. But I can't figure out a way. In asp.net user controls, we can define asp:placeholders, and specify the content from aspx where user control lies. I'll be glad for any suggestion.</p> <p>Thanks</p> <p>[edit] Here is the asp.net user control and I want to convert it to razor partial view</p> <p>User control:</p> <pre><code><%@ Control Language="C#" AutoEventWireup="true" CodeFile="SpryListView.ascx.cs" Inherits="SpryListView" %> <div spry:region="<%=this.SpryDataSetName%>" id="region<%=this.ID%>" style="overflow:auto;<%=this.DivStyle%>" > <table class="searchList" cellspacing="0" style="text-align:left" width="100%"> <thead> <tr> <asp:PlaceHolder ID="HeaderColumns" runat="server"></asp:PlaceHolder> </tr> </thead> </table> </code></pre> <p>User control code:</p> <pre><code>public partial class SpryListView : System.Web.UI.UserControl { private string spryDataSetName ; private string noDataMessage = "Aradığınız kriterlere uygun kayıt bulunamadı."; private bool callCreatePaging; private string divStyle; private ITemplate headers = null; private ITemplate body = null; [TemplateContainer(typeof(GenericContainer))] [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate HeaderTemplate { get { return headers; } set { headers = value; } } [TemplateContainer(typeof(GenericContainer))] [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate BodyTemplate { get { return body; } set { body = value; } } public string DivStyle { get { return divStyle; } set { divStyle= value; } } public string NoDataMessage { get { return noDataMessage; } set { noDataMessage = value; } } public string SpryDataSetName { get { return spryDataSetName; } set { spryDataSetName = value; } } public bool CallCreatePaging { get { return callCreatePaging; } set { callCreatePaging = value; } } void Page_Init() { if (headers != null) { GenericContainer container = new GenericContainer(); headers.InstantiateIn(container); HeaderColumns.Controls.Add(container); GenericContainer container2 = new GenericContainer(); body.InstantiateIn(container2); BodyColumns.Controls.Add(container2); } } public class GenericContainer : Control, INamingContainer { internal GenericContainer() { } } protected void Page_Load(object sender, EventArgs e) { } } </code></pre> <p>aspx</p> <pre><code><spry:listview SpryDataSetName="dsOrders" CallCreatePaging="true" runat="server" ID="orderListView"> <HeaderTemplate> <th>&nbsp;</th> <th>SİPARİŞ TARİHİ</th> <th style="text-align:right">GENEL TOPLAM</th> <th style="text-align:right">KDV</th> <th style="text-align:right">NET TOPLAM</th> </HeaderTemplate> </spry:listview> </code></pre> <p>[edit]</p> <p>I want to do exactly this in mvc 3 razor partial view.</p> |
16,029,384 | 0 | <p>Well,</p> <p>If you are in the PHP and Open Source world, you can consider Node.Js, Socket.IO or NowJs</p> <p>I am in the ASP.Net wonderworld and I love SignalR.</p> |
30,765,223 | 0 | <p>Your syntax is wrong, and doesn't produce anything except an error message as you've written it here.</p> <p>If I understand your question correctly, this should produce the output you want:</p> <pre><code>SELECT old_column, CASE old_column WHEN 'A' THEN 1 WHEN 'B' THEN 2 WHEN 'C' THEN 3 ELSE 0 END AS new_column FROM table_name </code></pre> <p>A <code>SELECT</code> does exactly what it says it does - it selects the data, but doesn't actually alter it's content.</p> <p>To <em>permanently</em> add a new column and populate it, you'll need to first <code>ALTER TABLE</code> to add the new column, and then <code>UPDATE</code> that new column's content.</p> <pre><code>ALTER TABLE table_name ADD COLUMN newcolumn integer; UPDATE table_name SET newcolumn = CASE oldcolumn WHEN 'A' THEN 1 WHEN 'B' THEN 2 WHEN 'C' THEN 3 ELSE 0 END; </code></pre> <p>For future reference: If you want help with your SQL syntax, include the actual code you've tried that isn't working, instead of inventing something as you go or re-typing. With SQL-related questions, it's almost always a good idea to post some sample data and the output you'd like to obtain from that data, along with your <em>actual</em> SQL code trying to produce that output. It makes it much easier to help you when we can understand what you're trying to do and have samples to use.</p> |
10,079,340 | 0 | jquery submit input and textareas at the same time <p>The code below saves all the Input Fields. If I change the word "INPUT" to "TEXTAREA" it will save the textarea text boxes, is there a way to change the code to save all the input fields and the textarea fields at the same time, as opposed to running through the code twice?</p> <pre><code>// JQUERY: Run .autoSubmit() on all INPUT fields within form $(function(){ $('#ajax-form INPUT').autoSubmit(); </code></pre> |
18,517,891 | 0 | retrieve real-time data from JBloomberg API <p>I want to retrieve the time and the real-time last Price as double instead of having an output like</p> <pre><code>DataChangeEvent{ESA Index,ASK_SIZE: 204==>192} </code></pre> <p>from the code below</p> <pre><code>DataChangeListener lst = new DataChangeListener() { @Override public void dataChanged(DataChangeEvent e) { System.out.println(e); } }; SubscriptionBuilder builder = new SubscriptionBuilder() .addSecurity("ESA Index") .addField(RealtimeField.LAST_PRICE) .addField(RealtimeField.ASK) .addField(RealtimeField.ASK_SIZE) .addListener(lst); session.subscribe(builder); Thread.sleep(3000); </code></pre> |
31,675,368 | 0 | How to make MathJax responsive and add line breaks automatically? <p>I've read the MathJax documentation for adding line breaks automatically but it seems to have no effect. </p> <p>I don't know how to make MathJax responsive. My website allows users to write in LaTeX especially for mathematical formulas. However, on mobile screen, sometimes the output is too wide and I need somehow to find a way to resize it.</p> <p>I can't ask my users to use this functionality only for short formulas.</p> <p><em>Exemple of incorrect output :</em> </p> <p><a href="https://i.stack.imgur.com/z2s4c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z2s4c.png" alt="enter image description here"></a></p> <p><em>What I did based on the documentation (but does not work) :</em></p> <pre><code>MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] }, "HTML-CSS": { linebreaks: { automatic: true } }, SVG: { linebreaks: { automatic: true } } }); </code></pre> <p>Full code on JS Fiddle : <a href="https://jsfiddle.net/ao8cnquw/" rel="nofollow noreferrer">https://jsfiddle.net/ao8cnquw/</a></p> |
36,550,777 | 0 | Average rating from SQL database survey data <p>I've been trying to return the average rating of an organizer based on ratings from a table with survey data (targetting one column).</p> <pre><code>Table: Workshops Cols: id[pk] | title | description | survey_id[fk] | organizer_id[fk] Table: Organizers Cols: organizer_id[pk] | organizer_name | organizer_email | organizer_rating Table: Surveys Cols: survey_id[pk] | survey_desc | survey </code></pre> <p>And the table with user responses is as follows:</p> <pre><code>Table: SurveyUserResponse Cols: s_u_r_id[pk] | username | survey_id[fk] | answer_1 | answer_2 | answer_3 </code></pre> <p>Answer 3 is essentially the speaker's rating. I attempted to select the average rating on answer 3 and joining it with workshops based on organizer ID but it does not return the right average for an organizer. </p> <p>This has got me quite stumped and I am unsure how to get the rating into the organizer rating column of the ratings table.</p> <p>Any help would be greatly appreciated.</p> <p><strong>EDIT:</strong></p> <p>Thank you for the advice Eduard. As per your suggestion, this is an example record:</p> <pre><code>Table: Workshops id | title | description | survey_id | organizer_id --------------------------------------------------- 1 | ws01 | on pottery | 1 | 1 Table: Organizers organizer_id | organizer_name | organizer_email | organizer_rating ----------------------------------------------------------------------- 1 | Ray Dion | [email protected] | <trying to get result here> Table : Surveys survey_id | survey_desc | survey --------------------------------- 1 | ws01 survey | test Table: SurveyUserResponse s_u_r_id | username | survey_id | answer_1 | answer_2 | answer_3 ----------------------------------------------------------------- 114 | joe21331 | 1 | 4 | 5 | 3 </code></pre> <p>This is what I came up with so far just to test if a proper data set is returned:</p> <pre><code> SELECT Organizers.organizer_id, Organizers.organizer_name, AVG(survey_user_response.answer_value_3) AS organizer_rating FROM Organizers, survey_user_response INNER JOIN Workshops organizer_id ON Workshops.organizer_id = Organizers.organizer_id ORDER BY organizer_rating DESC </code></pre> |
18,253,331 | 0 | <p>You are trying to upload an array of files, you will not be able to upload more than 20 files due to <a href="http://php.net/manual/en/ini.core.php#ini.sect.file-uploads" rel="nofollow">max_file_uploads</a> limit in <code>php.ini</code> which is by default set to <code>20</code>. </p> <p>So you have to increase this limit to upload more than 20 files.</p> <p><strong>Note</strong>: <code>max_file_uploads</code> can NOT be changed outside php.ini. See <a href="http://bugs.php.net/bug.php?id=50684&edit=1" rel="nofollow">PHP "Bug" #50684</a></p> |
32,167,137 | 0 | <p>From the documentation, it looks like you can set the location where you want to save by means of the properties <code>imageCapture</code>, which has the method <code>captureToLocation</code>.</p> <p>It has also a property called <code>capturedImagePath</code> that maybe contains what you are looking for.</p> <p>Look <a href="http://doc.qt.io/qt-5/qml-qtmultimedia-cameracapture.html#capturedImagePath-prop" rel="nofollow">here</a> and <a href="http://doc.qt.io/qt-5/qml-qtmultimedia-cameracapture.html" rel="nofollow">here</a> and <a href="http://doc.qt.io/qt-5/qml-qtmultimedia-cameracapture.html#capturedImagePath-prop" rel="nofollow">here</a> for further details.</p> <p>Sorry, just seen you were asking for the <code>videoRecording</code>. It has the <code>actualLocation</code> property as well and it works as above, doesn't it?</p> <p>The <a href="http://doc.qt.io/qt-5/qml-qtmultimedia-camerarecorder.html#actualLocation-prop" rel="nofollow">documentation</a> states that that property holds the actual location of the last saved media content. Be aware that it's available once the recording starts, so you should look at it after the <code>record</code> method has been invoked.</p> |
12,738,390 | 0 | <p>The Android SDK provides the <code>SharedPreferences</code> class to <code>set</code> and <code>get</code> App preferences.</p> <p>These preferences are for small amounts of data, and there are methods for the all the data types (including <code>String</code>).</p> <p>The preferences are removed when the App is uninstalled. Or if the user goes to their device settings, finds the App and selects the "Clear Cache" button.</p> <p>You can set preferences this way:</p> <pre><code>SharedPreferences get = getSharedPreferences("MyApp", Context.MODE_PRIVATE); SharedPreferences.Editor set = get.edit(); set.putInt("BUTTON_COLOR", 0xFF000000); set.commit(); // You must call the commit method to set any preferences that you've assigned. </code></pre> <p>And you can retrieve them this way:</p> <pre><code>get.getInt("BUTTON_COLOR", 0xFF000000); // A preference will never return null. You set a default value as the second parameter. </code></pre> |
9,985,103 | 0 | <p><a href="http://wiki.bash-hackers.org/scripting/posparams" rel="nofollow">http://wiki.bash-hackers.org/scripting/posparams</a></p> <p>It explains the use of <code>shift</code> (if you want to discard the first N parameters) and then implementing Mass Usage (look for the heading with that title).</p> |
33,792,933 | 0 | <p>Add below code in your activity.</p> <pre><code>public void Condition(View view) { boolean checked = ((RadioButton) view).isChecked(); switch(view.getId()) { case R.id.newoption: if (checked) break; case R.id.usedoption: if (checked) break; } } </code></pre> <p>and your code should work!</p> |
25,509,155 | 0 | java selenium - hidden input value <p>First Stack post, so don't be harsh if I get it wrong.</p> <p>Im using selenium and java for some automated testing. All was going well until I tried to set the value of a hidden input.</p> <p>When using 'type' in the Firefox IDE, it works a treat, but when I use the line below, it doesn't play at all. It just fails. </p> <pre><code>// This line doesnt like to run because its hidden selenium.type("name=startDate_submit", "2015-09-25"); </code></pre> <p>Can anyone point me in the right direction. </p> <p>Many Thanks.</p> <p><strong>Edit:</strong></p> <pre><code>WebDriver driver = new ChromeDriver(); JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("$([name=startDate_submit]).attr('type', 'text');"); Thread.sleep(3000); // This line doesnt like to run because its hidden selenium.type("name=startDate_submit", "2015-09-25"); </code></pre> <p>Should this be the way I do this? I just cannot get it working.</p> |
33,662,039 | 0 | <p>just add a class at your main ul (i added 'main-menu' for example) and then add this css:</p> <pre><code>.main-menu > li > ul, .main-menu > li > ul > li > ul, .main-menu > li > ul > li > ul > li > ul { display: none; } .main-menu > li:hover > ul, .main-menu > li > ul > li:hover > ul, .main-menu > li > ul > li > ul > li:hover > ul { display:block; } </code></pre> |
19,683,858 | 0 | <p>You can use <a href="http://api.jquery.com/clearQueue/" rel="nofollow"><strong><code>clearQueue()</code></strong></a> to stop the animation</p> <blockquote> <p>clearQueue() : Stop the remaining functions in the queue</p> </blockquote> <p><kbd><a href="http://jsfiddle.net/b4hwq/3/" rel="nofollow">jsFiddle here</a></kbd></p> <p><strong>HTML</strong></p> <pre><code><div class="box"></div> <button id="restartTransition">Click Me</button> </code></pre> <p><strong>CSS</strong></p> <pre><code>.box{ opacity: 0.8; position: absolute; left: 0; top: 5%; background: #505060; border-radius: 1px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); margin: -16px 0 0 -16px; width: 32px; height: 32px; z-index: 2; } </code></pre> <p><strong>jQuery</strong></p> <pre><code>$(document).ready(function(){ $("#restartTransition").on("click", function(){ $('.box').clearQueue().transition({ x: '0px' },10); $('.box').transition({ x: '350px' },5000); }); }); </code></pre> |
13,130,522 | 0 | JavaScript - Reposition a DIV incrementally onClick <p>Very simple code, very simple problem. When a link is pressed, it moves a div either up or down. However, I cannot get it to move incrementally. I know this is a simple syntax error, but google isn't revealing the error of my ways. Anyone willing to enlighten me?</p> <p><code><a class="galsel" onclick="document.getElementById('innerscroll').style.bottom -='167px';">&laquo;</a></code></p> <p><code><a class="galsel" onclick="document.getElementById('innerscroll').style.bottom +='167px';">&raquo;</a></code></p> <p>I already have it so that the div tiles itself vertically, so I'm not worried about it going "too high" or "too low"</p> <p>Here's what it looks like right now: drainteractive.com/FBD/projects.php</p> |
40,230,927 | 0 | Half-transparent elements in the Adobe Illustrator have a black outlines <p>I'm new in Adobe Illustrator and I just need to extract one element from EPS-file.</p> <p>So it's the light. And as you see in the attached file, I can't save it clean. I mean, when it has a some background, it looks good. But when I remove this background and trying to save the clean light as PNG image this is what happenes.</p> <p><a href="https://i.stack.imgur.com/fldQB.png" rel="nofollow">Here's the demonstration</a></p> <p>How can I fix it?</p> |
8,281,411 | 0 | <p>View source shows you the source of the original html file, it does not update when javascript updates the DOM. Most browsers have some form of tool that allows you to inspect the current state of the DOM, such as the inspector in webkit browsers or firebug in firefox.</p> |
24,748,398 | 0 | <pre><code> data["objects"][0].keys() ['cuisines', 'postal_code', 'lat', 'id', 'categories', 'name', 'locality', 'country', 'street_address', 'has_menu', 'website_url', 'resource_uri'] </code></pre> |
25,332,174 | 0 | Using conditions to specify groups for GROUP BY <p>I'm not even sure if this is possible using SQL, but I'm completely stuck on this problem. I have a table like this: </p> <pre><code>Total Code 212 XXX_09_JUN 315 XXX_7_JUN 68 XXX_09_APR 140 XXX_AT_APR 729 XXX_AT_MAY </code></pre> <p>I need to sum the "total" column grouped by the code. The issue is that "XXX_09_JUN" and "XXX_7_JUN" and "XXX_09_APR" need to be the same group. </p> <p>I was able to accomplish this by creating a new column where I assigned values based on the row's code, but since this needs to be done on multiple tables with millions of entries, I can't use that method.</p> <p>Is there some way that I could group the rows based on a condition such as:</p> <pre><code>WHERE Code LIKE '%_09_%' OR Code LIKE '%_7_%' </code></pre> <p>This is not the only condition - I need about 10 conditions like this. Sorry if that doesn't make sense, I'm not sure how to explain this...</p> <p>Also, if this can be accomplished using Visual Studio 2008 and SSRS more easily, that would work as well because that is the final goal of this query.</p> <p>Edit: To clarify, this would be the ideal result:</p> <pre><code>Total Code 595 had_a_number 869 had_at </code></pre> |
19,425,808 | 0 | What is the structure of the Thread Environment Block on Microsoft Windows? <p>What is the structure of the Thread Environment Block on Microsoft Windows?</p> |
22,355,882 | 0 | <ol> <li>Arguments with defaults and splat argument must be grouped together;</li> <li>Splat argument must appear after positional arguments with default values but before keyword arguments;</li> <li>Keyword arguments must appear after positional arguments and before double splat argument;</li> <li><p>Double splat argument must appear last but before block argument.</p> <p>def foo(a, b=1, c=2, *d, e, f: 1, g: 2, **kwargs, &block)</p></li> </ol> |
10,167,541 | 0 | <p>Personally, I do not rely on implicit conversion. Too often this results in unexpected grief down the road. If asked to provide a filter between a date range, I would be explicit. Pick whatever format you want, but if it might be confusing, then try to eliminate as much of the confusion as possible: </p> <pre><code>SELECT employee_id, first_name, last_name, hire_date FROM employees WHERE hire_date BETWEEN TO_DATE('JAN-01-1980', 'MON-DD-YYYY') AND TO_DATE('JAN-01-1999', 'MON-DD-YYYY') ORDER BY hire_date; </code></pre> |
10,222,599 | 0 | <p>Uninstall the application from android device or emulator, and try to re-run / install the application. Because <strong>debug.keystrore</strong> is different for every devices.</p> |
39,400,500 | 0 | Compiling example UBOOT standalone application <p>I am trying to build a UBOOT standalone application.</p> <p>Looking at the README and the minimal documentation on this, I am curious.</p> <p>Is the hello world example standalone, simply just compiled/cross-compiled the same way any other application is? Obviously for whatever the target architecture is.</p> <p>Do I need to use makeelf or something to get a .bin file?</p> |
30,696,197 | 0 | <p>Sometimes regexp only further complicates things. PHP has a great function called <code>ctype_alpha()</code> that will check if a variable is only A-Za-z.</p> <pre><code>(ctype_alpha($newcompanycity)) </code></pre> <p>Here's a <a href="https://eval.in/376859" rel="nofollow">working example for you</a></p> |
40,485,653 | 0 | Connecting C# Application to MS Access 2013 DB <p>I'm using VS 2012 & Office 2013 64 bits, and i changed the target platform to x86, but I still got this weard error </p> <blockquote> <p>The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine".</p> </blockquote> |
21,440,485 | 0 | <p>I haven't used sublime, but here is what i found.</p> <ol> <li><p>you could create snippets using Ruby on <a href="https://sublime.wbond.net/packages/Ruby%20on%20Rails%20snippets" rel="nofollow">Rails Snippet</a> package</p></li> <li><p>You could use the solution given in '<a href="http://www.sublimetext.com/forum/viewtopic.php?f=2&t=8302" rel="nofollow">How to automatically add "end" to code blocks?</a>'.</p></li> </ol> |
31,356,274 | 0 | delaying the hover of background- image <p>CSS</p> <pre><code>.navbar-brand { display: block; margin: 0; padding: 0; height: 80px; width: 70px; background: url('img/logo_orig.png') no-repeat center center; background-size: 100% auto; } .navbar-brand:hover { background: url('img/logo_hov.png') no-repeat center center; background-size: 100% auto; } </code></pre> <p>This creates a button with a background image, when hovered it hnages the background.</p> <p>I want to add a delay to the background image when hovered. similar to using </p> <pre><code>transition: background-color 0.35s ease; </code></pre> |
21,570,475 | 0 | <p>in order to declare publicly accessible function inside JavaScript object you have to use <code>this</code>. By applying <code>this</code> you actually expose this function as a property of an object</p> <pre><code>function Person(first,last) { this.firstname = first; this.lastname = last; //private variable available only for person internal use var age = 25; //private function available only for person internal use var returnAge = function() { return age; }; // public function available as person propert this.askAge = function() { return returnAge ; } } var john = new Person('John','Smith'); console.log(john.returnAge); // will return undefined var johnsAge = john.askAge(); // will return 25 </code></pre> |
29,048,677 | 0 | <p>First of all, I will assume that this is homework and you must not use <code>std::string</code>. If you can use <code>std::string</code>, forget about everything and refrain from using dynamically allocated C-style strings!</p> <hr> <p>Here we go. If you want to replace <em>one</em> character (a space) with <em>two</em> characters (two stars), then your output string becomes <strong>larger</strong>.</p> <pre><code>"hello there, world!" = 19 characters "hello**there,**world!" = 21 characters </code></pre> <p>I doubt that overwriting the character following each space with a star conforms to the requirements of this exercise:</p> <pre><code>"hello**here,**orld!" = 19 characters, but seems to be wrong </code></pre> <p>You have space for 49 characters, but what if you enter, say, a string with 45 non-spaces and 5 spaces? The result would consist of 55 characters. More generally speaking: <strong>Who says the resulting string will fit in the old array?</strong></p> <p>The easiest way to overcome this problem and arrive at a satisfactory solution is to first <em>count</em> the number of spaces, then <em>allocate a new string</em>, then <em>copy</em> the characters.</p> <p>Here is an example. I left your original way of receiving user input, and a few other problems with the code, intact, even though it could use a few further improvements. This is <em>not</em> C++ code you would use in production! I also used <code>malloc</code> and <code>free</code> to conform to the general C-style of your code (in fact, this may really be a C exercise!). Take it strictly as a learning exercise:</p> <pre><code>#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; int new_size(char str[]); char* convert(char str[], int new_size); int main() { char string[50]; cout<<"Enter a string "<<endl; gets(string); int new_size_with_stars = new_size(string); char* new_string = convert(string, new_size_with_stars); printf("result: %s\n", new_string); free(new_string); return 0; } int new_size(char str[]) { int result = 0; for (int i = 0; str[i] != '\0'; ++i) { if (str[i] == ' ') { ++result; } ++result; } return result; } char* convert(char str[], int new_size) { char* new_str = (char*) malloc(new_size + 1); for(int old_str_index = 0, new_str_index = 0; str[old_str_index] != '\0'; ++old_str_index, ++new_str_index) { if (str[old_str_index]==' ') { new_str[new_str_index] = '*'; new_str[new_str_index + 1] = '*'; ++new_str_index; } else { new_str[new_str_index] = str[old_str_index]; } } new_str[new_size] = '\0'; return new_str; } </code></pre> |
23,979,786 | 0 | <p>Supposing you have an <code><input></code> with <code>id="myInput"</code>, you can use following javascript:</p> <pre><code>document.getElementById("myInput").value="0"+parseFloat(document.getElementById("myInput").value)+1; </code></pre> |
8,099,695 | 0 | <p>Per the docs from <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.close.aspx" rel="nofollow">Form.Close</a>:</p> <blockquote> <p>The two conditions when a form is not disposed on Close is when (1) it is part of a multiple-document interface (MDI) application, and the form is not visible; and (2) you have displayed the form using ShowDialog. In these cases, you will need to call Dispose manually to mark all of the form's controls for garbage collection.</p> </blockquote> <p>I am presuming your form is a dialog since that is what is mentioned in the title. It looks like you will need to explicitly call Dispose to deallocate the win32 resources.</p> |
27,203,080 | 0 | java.lang.RuntimeException Simple Http Get Code <p>This simple and well organized code is not working. Code uses AsyncTask and its a sample code from internet.<a href="http://hayageek.com/android-http-post-get/" rel="nofollow">Sample Code</a> Im using android studio and tried starting it over and over.</p> <pre><code>package com.example.jakiro.jakki; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import java.io.IOException; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new Rush().execute(); } private class Rush extends AsyncTask { @Override protected Object doInBackground(Object[] objects) { makePostRequest(); return null; } } private void makePostRequest() { HttpClient httpClient = new DefaultHttpClient(); // replace with your url HttpGet httpPost = new HttpGet("https://www.google.com"); HttpResponse response; try { response = httpClient.execute(httpPost); Log.d("Response of GET request", response.toString()); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre> <p>error codes:</p> <pre><code>java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=www.example.com at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) at com.example.nova.myapplication.MainActivity.makePostRequest(MainActivity.java:66) at com.example.nova.myapplication.MainActivity.access$100(MainActivity.java:22) at com.example.nova.myapplication.MainActivity$Rush.doInBackground(MainActivity.java:36) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) </code></pre> <p>Manifest:</p> <pre><code><?xml version="1.0" encoding="utf-8"?> </code></pre> <p></p> <pre><code><uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.jakiro.jakki.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </code></pre> <p></p> |
18,983,503 | 0 | <p>For some reason theming using the "searchAutoCompleteTextView" wasn't working for me either. So I solved it using the following code when setting up my SearchView:</p> <p>Note: This is all done with the android v7 support/AppCompat library</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search_menu, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Theme the SearchView's AutoCompleteTextView drop down. For some reason this wasn't working in styles.xml SearchAutoComplete autoCompleteTextView = (SearchAutoComplete) searchView.findViewById(R.id.search_src_text); if (autoCompleteTextView != null) { autoCompleteTextView.setDropDownBackgroundResource(R.drawable.abc_search_dropdown_light); } } </code></pre> <p>There are two search drop down resources provided by the compatibility library, they are </p> <ul> <li>R.drawable.abc_search_dropdown_light (Light background)</li> <li>R.drawable.abc_search_dropdown_dark (Dark background)</li> </ul> |
5,377,486 | 0 | JavaScript unixtime problem <p>I get the time from the database in Unix format.</p> <p>It looks like this: console.log (time); Result: 1300709088000</p> <p>Now I want to reformat it and pick out only the time, I found this: <a href="http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript">Convert a Unix timestamp to time in Javascript</a></p> <p>That did not work as I want. The time I get is this:</p> <pre><code>1300709088000 9:0:0 1300709252000 6:33:20 1300709316000 0:20:0 1300709358000 12:0:0 1300709530000 11:46:40 </code></pre> <p>It is very wrong times when I know that times are quite different. How can I fix it?</p> <pre><code> console.log(time); var date = new Date(time*1000); // hours part from the timestamp var hours = date.getHours(); // minutes part from the timestamp var minutes = date.getMinutes(); // seconds part from the timestamp var seconds = date.getSeconds(); // will display time in 10:30:23 format var formattedTime = hours + ':' + minutes + ':' + seconds; console.log(formattedTime); </code></pre> |
40,968,814 | 0 | <p>As most of people mentioned here - one of the solutions will be to use aliases. Don't like them to be honest because they are preventing me learning some really nice Linux commands :) It's just a joke. But the best way for you, as I think, will be to locate a <code>~/.bashrc</code> file located in your home directory and put there:</p> <pre><code>alias mysql="mysql -h 127.0.0.1" </code></pre> <p>Don't forget that you have to restart your session in order for this solution to work or you may type <code>bash</code> command at the same terminal session - it will reload all your bash settings. Good luck!</p> <p>P.S. I suggest you to close all other terminal windows before editing <code>.bashrc</code> because you may just got a read-only file. I had such issue under Win7x64</p> |
522,156 | 0 | <p>Add your user.Firstname and User.lastname to your group by clause</p> |
5,239,028 | 0 | edit resolution in flash page <p>that's my flash site , I want to extend the gray box to reach the edge of the HTML page . I mean that I don't want the background color to appear <strong>all I want in the page the flash site in the resolution of the page whatever the PC resolution</strong> . sorry for my bad English . <img src="https://i.stack.imgur.com/sn9zW.jpg" alt="enter image description here"></p> |
34,551,615 | 0 | <p>Dplyr is much more intuitive and easy in my opinion. Using it here, you can do something like this:</p> <pre><code>library(dplyr) > zzz <- data.frame(name=rep(c('x','y','z'),100),balance=sample(100:300,100,replace = T)) > zzz <- arrange(zzz, name) > zzz[5:7,2] <-238 > zzz[20:22,2]<- 204 > zzz <- zzz %>% group_by(name) %>% mutate(code = as.numeric(balance != lag(balance))) > zzz[5:7, ] Source: local data frame [3 x 3] Groups: name [1] name balance code (fctr) (dbl) (dbl) 1 x 238 1 2 x 238 0 3 x 238 0 > zzz[20:22, ] Source: local data frame [3 x 3] Groups: name [1] name balance code (fctr) (dbl) (dbl) 1 x 204 1 2 x 204 0 3 x 204 0 > </code></pre> |
5,273,510 | 0 | <p>While this question is old I must say that I am having a pretty tough experience right now due to delimited strings that I have to use on the backend. I agree with most posts on this question in that it does depend on the needs of the application, but what also must be considered are the needs of the backend, meaning those who might actually have to use the data later on. As Vincent stated, if you plan on doing reporting, or somehow using the data that you're storing for some purpose later on, then generally you'll want to be sure you avoid making it harder on yourself or whomever may be using the data. If all you're worried about is storing it, then do whatever makes you happy.</p> |
39,656,693 | 0 | How to get the text in a dynamic text box of a form in Angular Js? <p>Thank you. In my form there are some dynamic input text boxes created by using ng-repeat. How to get the values of these text boxes when submit the form using Angular js?</p> <pre><code><form ng-submit="submit()"> <div ng-repeat="opt in option"> <input type="text" name=""> </div> </form> </code></pre> |
20,966,927 | 0 | Access 2010: Refresh Navigation Pane and Sum/Avg not visible on report <p>I have noticed a strange problem in Access 2010: when a user creates a new object (table, form, query, ...), this object does not show up in the navigation pane. It only does so after manually refreshing the navigation pane (F5) or after closing and reopening the access file. Furthermore, when previewing a report, the Sums and Averages do not show up until the user clicks on the field(s). Printing the report is ok.</p> <p>This behaviour is machine dependant, the same file behaves correctly on other PCs. I was looking at the video cards installed on different PCs, but they all have Intel(R) HD Graphics. </p> <p>Any ideas anyone?</p> <p>Cheers</p> |
4,834,368 | 0 | <blockquote> <p>Alternately, is there a way to add a simple queueing system short of completely rewriting the application?</p> </blockquote> <p>Yes, you can use an array. It looks like you may already have one, with the _processQ variable. I might try something like this:</p> <pre><code>// A process queue item method protected function processItemInQueue():Void{ if(_processQ.length > 0){ fObj = _processQ.pop(); f = fObj.Name; fObj.Progress = "Processing..."; ro.process(gameid,f); } } </code></pre> <p>Then in your remote Object result handler:</p> <pre><code>protected function roResultHandler(event:ResultEvent):void{ // process results // process next item in queue processItemInQueue(); } </code></pre> |
5,386,789 | 1 | Refactoring a python function so that it can take any sized list <p>How can I make this function take as input an arbitrary list size?</p> <pre><code>def ugly_function(lst): for a in lst[0]: for b in lst[1]: for c in lst[2]: for d in lst[3]: for e in lst[4]: for f in lst[5]: for g in lst[6]: for h in lst[7]: if some_test([a,b,c,d,e,f,g,h]): return [a,b,c,d,e,f,g,h] </code></pre> |
30,461,238 | 0 | <p>I'm not sure if you can do this in Ruby, but doing it like this in Jquery may work. However you should definitely fix the databases.</p> <pre><code>$(document).ready(function() { //On document ready $("form").find('input').each(function(){ //find all inputs in forms if ($(this).val() == "(NULL)") { //if the value of an input is "(NULL)" $(this).val(""); //Set it to "" } }) }) </code></pre> |
20,120,756 | 0 | <p>In your fragment, you can use</p> <p><code>((MainActivity)getActivity()).myMethod()</code></p> <p>to call myMethod of MainActivity. This solution assumes, that your fragment is located in MainActivity (getActivity must return MainActivity instance) :-)</p> |
36,903,928 | 0 | how to unsubscribe livequery in orientjs <p>When my NODEJS web service stops, I find the LiveQuerys remain connected. So, should I unsubscribe the LiveQuery manually? And how? My solution is like that, but it does not work</p> <pre><code>process.on('exit', function () { odb.exec("LIVE UNSUBSCRIBE "+iToken); }); </code></pre> <p>Sorry for my poor English. Any words will be really appreciated!</p> |
9,690,740 | 0 | decode form-urlencoded to hash <p>The response I get to an LWP request is <code>application/x-www-form-urlencoded</code> is it possible convert the text of this to a hash via some object method?</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.