Invalid JSON:Unexpected non-whitespace character after JSONat line 2, column 1
| {"QuestionId": 26611062, "AnswerCount": 1, "Tags": "<mysql><linux><postgresql><ubuntu><database-migration>", "CreationDate": "2014-10-28T14:36:06.510", "AcceptedAnswerId": "26611590", "Title": "PostgreSQL to MySQL conversion of large tables", "Body": "<p>I need to convert a table from PostgreSQL to MySQL. The size of the table is <strong>5.2GB</strong>. I am doing it on workbench, but after some <strong>3minutes</strong> I am getting errors like below.</p>\n\n<p><strong>HY001:14:Out of memory in allocating item buffer.</strong></p>\n\n<p>I have tried changing <strong>innodb_log_file_size, innodb_log_buffer_size, query_cache_size, key_buffer_size</strong> and some other variables, but no go.</p>\n\n<p>Can someone help me in doing this. Is there is any other conversion tools to do this. It will be great if I solve the above error too.</p>\n", "Lable": "No"} | |
| {"QuestionId": 26681557, "AnswerCount": 1, "Tags": "<ruby-on-rails><validation>", "CreationDate": "2014-10-31T18:52:36.330", "AcceptedAnswerId": "26681739", "Title": "Rails validation - inclusion", "Body": "<p>I am trying to add a validation to prevent the user from entering a url that does not include the word 'mywebsite' in it.</p>\n\n<pre><code>validates :url, inclusion: { in: %w(mywebsite), message: \"Must be a mywebsite.com subdomain\" }\n</code></pre>\n\n<p>The problem with the above code is that it will only accept 'mywebsite' as a valid argument, while I'd like it to accept any argument which includes the word mywebsite in it. Example: mywebsite.com/something</p>\n\n<p>How should I approach this?</p>\n", "Lable": "No"} | |
| {"QuestionId": 26819262, "AnswerCount": 1, "Tags": "<java><android><webview><android-webview>", "CreationDate": "2014-11-08T16:19:51.487", "AcceptedAnswerId": null, "Title": "WebView falsely shows my \"no connection\"-page", "Body": "<p>I've made a WebView where it checks internet connection and if there is none it will display an error-page.</p>\n\n<p>It worked just fine until it recently when it would just display the error-page even though me having cellular data on, this persists even on WiFi's.</p>\n\n<pre><code>package se.welovecode.tismatapp;\n\nimport android.support.v7.app.ActionBarActivity;\nimport android.annotation.SuppressLint;\nimport android.os.Bundle;\nimport android.view.KeyEvent;\nimport android.view.Window;\nimport android.webkit.WebSettings;\nimport android.webkit.WebView;\nimport android.webkit.WebViewClient;\n\n@SuppressLint(\"SetJavaScriptEnabled\") public class MainActivity extends ActionBarActivity {\n\nWebView myWebView;\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n requestWindowFeature(Window.FEATURE_NO_TITLE);\n setContentView(R.layout.activity_main);\n final WebView myWebView = (WebView) findViewById(R.id.webview);\n myWebView.loadUrl(\"http://www.welovecode.se/t-matapp\");\n WebSettings webSettings = myWebView.getSettings();\n webSettings.setJavaScriptEnabled(true);\n myWebView.setWebViewClient(new WebViewClient() {\n public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {\n myWebView.loadUrl(\"file:///android_asset/index.html\");\n\n }\n });\n }\n\n@Override\npublic boolean onKeyDown(int keyCode, KeyEvent event) {\n\n if (keyCode == KeyEvent.KEYCODE_BACK) {\n return false;\n }\n\n return super.onKeyDown(keyCode, event);\n}\n};\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 26895470, "AnswerCount": 1, "Tags": "<crystal-reports>", "CreationDate": "2014-11-12T19:57:57.130", "AcceptedAnswerId": null, "Title": "Crystal Reports: Converting Selected Row Data to Column Data", "Body": "<p>Is it possible to transpose data for a select column in Crystal? Here is my issue... I am using ttx file to get data fields for the Crystal Report...</p>\n\n<p>I want only the tax_type and the tax_rate and tax amount to show up in the same row as the product sold. The tax_rate is stored in a separate table that needs to be pulled in as a column as well. I need to group and sum on product, buy, sell, tax_type, and then net the whole amount to come up with net total which I kinda know how... but I am stuck at transposing a row. Basically I only want to show row as column where tax type, amount, and rate matches transaction number and YN_tax == 1. The tax rate is stored in a totally separate table... Mind you that tax will not be applicable to each transaction... Here are the table Details</p>\n\n<p><strong>Details Table</strong>\n <pre>\n <b>Transaction Sales_Date buy_sell Product location ProductType price amount YN_tax tax_type</b>\n 123456 11/9/2014 Sell DEF Brazil trinkets 5 703.08<br>\n 123457 11/9/2014 Sell ABC Canada widget 10 213.5<br>\n 123458 11/9/2014 Buy DEF Brazil trinkets 2 630<br>\n 123459 11/9/2014 Buy DEF Brazil trinkets 3 34.41<br>\n 123457 11/9/2014 Sell ABC Canada SalesTax 3 688.2 1 SalesTax\n 123458 11/9/2014 Buy DEF Brazil FederalTax 2 132 1 FedTax\n </pre></p>\n\n<p><strong>Tax Rates Table</strong>\n <pre>\n <b>title rate</b>\n SalesTax 8.25\n FedTax 9.75\n </pre></p>\n", "Lable": "No"} | |
| {"QuestionId": 26951445, "AnswerCount": 3, "Tags": "<python><python-3.x>", "CreationDate": "2014-11-15T22:25:29.787", "AcceptedAnswerId": "26951498", "Title": "Having issues exiting my while loop", "Body": "<p>I have been testing my code for the past few hours and I am stumped. This program takes a text file of names, turns the names into a list, prints the names, sorts the names, prints the sorted names, then allows you to search through the list. Everything seems to be working fine, but the one issue I have is exiting the while loop. If y or Y is selected you can search again, but that also happens if anything else is selected. I added a print statement outside the loop so if anything other than y is selected then the program should end with that last printed string, but it doesn't seem to be working. Does anyone have any ideas about why it isn't working and what I could change to get it to work?</p>\n\n<p>Thank you for your time.</p>\n\n<pre><code>#define the main function\ndef main():\n\n #create a variable to control the loop\n keep_going = 'y'\n\n #setup loop to search for name\n while keep_going == 'y' or keep_going == 'Y': \n\n #call input name function\n names = input_name()\n\n #call print name function\n print_name(names)\n\n #sort the printed list\n names.sort()\n\n #call the print name function\n print_name(names)\n\n #call the output name function\n output_name(names)\n\n #call the search name function\n search_name(names)\n\n #add user input for another search\n search_again = input('Would you like to make another search?(y for yes): ') \n\n #print if anything other than y or Y is selected\n print()\n print('Goodbye!')\n\n#define the input function \ndef input_name():\n\n #open the names.txt file\n infile = open('names.txt', 'r')\n\n #read contents into a list\n names = infile.readlines()\n\n #close the file\n infile.close()\n\n #strip the \\n from each element\n index = 0\n while index < len(names):\n names[index] = names[index].rstrip('\\n')\n index += 1\n\n #return the list back to main function \n return names\n\n#define the print name function\ndef print_name(names):\n\n #print the contents of the list\n for name in names:\n print(name)\n\n#define the output name function\ndef output_name(names):\n\n #open file for writing\n outfile = open('sorted_names.txt', 'w')\n\n #write the list to the file\n for item in names:\n outfile.write(item + '\\n')\n\n #close the file\n outfile.close()\n\n #return to main function\n return\n\n#define the search name function\ndef search_name(names):\n\n #add a user input to search the file\n search = input('Enter a name: ')\n\n #determine whether the name is in the list\n if search in names:\n\n #get the names index\n name_index = names.index(search)\n\n #print the name was found and give the items index\n print(search, \"was found in list. This item's index is\", name_index) \n\n else:\n\n #print the item was not found\n print(search, 'was not found in the list.') \n\nmain() \n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 27096346, "AnswerCount": 1, "Tags": "<php><json>", "CreationDate": "2014-11-24T00:49:23.990", "AcceptedAnswerId": "27097033", "Title": "Getting value with array", "Body": "<p>I am struggling to get the value of an element in a particular array. I would like to get the value of the \"logo\" in this case to return \"Logo Google 2013 Official.svg\" from the code below. \nAny help is greatly appreciated.</p>\n\n<pre><code><html>\n<head>\n</head>\n<body>\n\n<html>\n\n<body>\n<h2>Search</h2>\n<form method=\"post\">\nSearch: <input type=\"text\" name=\"q\" value=\"google\" />\n<input type=\"submit\" value=\"Submit\">\n</form>\n\n<?php\n\nif (isset($_POST['q'])) {\n$search = $_POST['q'];\n\n\n$url_2 = \n\"http://en.wikipedia.org/w/api.php? \naction=query&prop=revisions&rvprop=content&format=json&titles=$search&rvsection=0&continue=\";\n$res_2 = file_get_contents($url_2);\n$data_2 = json_decode($res_2);\n\n\n?>\n\n<h2>Search results for '<?php echo $search; ?>'</h2>\n<ol>\n<?php foreach ($data_2->query->pages as $r): \n\n?>\n\n<li>\n\n<?php foreach($r->revisions[0] as $a); \necho $a; ?>\n\n</li>\n<?php endforeach; ?>\n</ol>\n\n<?php \n}\n?>\n\n</body>\n</html>\n</code></pre>\n\n<p>The resulting <code>$url_2</code> is <a href=\"http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=google&rvsection=0&continue=\" rel=\"nofollow\">http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=google&rvsection=0&continue=</a></p>\n", "Lable": "No"} | |
| {"QuestionId": 27156138, "AnswerCount": 1, "Tags": "<java><swing><user-interface><label><logic>", "CreationDate": "2014-11-26T18:12:13.903", "AcceptedAnswerId": null, "Title": "Label will not update with the flow", "Body": "<p>I am working on this RPSGUI; everything works swell as far as logic is conserned, but I moved onto the final stage about a week or so ago and I have been stuck here every since. I cannot get my labels to update. So say the user won, the counter would go from 0 to 1, 2 etc. I have a lot of stuff commented out so you can see I have tried. I actually deleted several portions of what I was commenting out because I was getting confused, but yeah. I would also like for the gui to say what was played and am unsure about where to even begin with that :-/. I'm hoping someone could help me with this. It would mean a lot to me. </p>\n\n<p>Here is the program without the driver class. Nothing is in the driver class aside making it display. </p>\n\n<pre><code>import java.awt.Color;\nimport java.awt.GridLayout;\nimport java.awt.event.ActionEvent;\nimport java.awt.event.ActionListener;\n\nimport javax.swing.JButton;\nimport javax.swing.JLabel;\nimport javax.swing.JOptionPane;\nimport javax.swing.JPanel;\n\n\npublic class GamePanel extends JPanel{\n private JButton rockButton, paperButton, scissorsButton;\n private JLabel userLabel, computerLabel, resultLabel, winLabel, tieLabel, loseLabel;\n private int winInt, tieInt, loseInt = 0;\n private String rockButtonText = \"Rock\";\n private String paperButtonText = \"Paper\";\n private String scissorsButtonText = \"Scissors\";\n private JPanel buttonPanel, labelPanel, resultPanel;\n public int computerInt;\n\n String[] attackArray = {\"Rock\", \"Paper\", \"Scissors\"};\n\n public GamePanel(){\n String[] attackArray = {\"Rock\", \"Paper\", \"Scissors\"};\n\n setLayout(new GridLayout(5,3));\n\n setBackground(Color.white.brighter());\n setForeground(Color.ORANGE.darker());\n\n //make the buttons\n JButton rockButton = new JButton(rockButtonText);\n JButton paperButton = new JButton(paperButtonText);\n JButton scissorsButton = new JButton(scissorsButtonText);\n\n //style the buttons\n rockButton.setBackground(Color.orange);\n rockButton.setForeground(Color.black.darker());\n paperButton.setBackground(Color.orange);\n paperButton.setForeground(Color.black.darker());\n scissorsButton.setBackground(Color.orange);\n scissorsButton.setForeground(Color.black.darker());\n\n //add labels\n JLabel userLabel = new JLabel(\"User:\");\n JLabel computerLabel = new JLabel(\"Computer:\");\n JLabel winLabel = new JLabel(\"Win: \" + winInt);\n JLabel tieLabel = new JLabel(\"Tie: \" + tieInt);\n JLabel loseLabel = new JLabel(\"Lose:\" + loseInt);\n\n //style Labels\n userLabel.setBackground(Color.orange);\n userLabel.setForeground(Color.black.darker());\n computerLabel.setBackground(Color.orange);\n computerLabel.setForeground(Color.black.darker()); \n winLabel.setBackground(Color.orange);\n winLabel.setForeground(Color.black.darker()); \n tieLabel.setBackground(Color.orange);\n tieLabel.setForeground(Color.black.darker()); \n loseLabel.setBackground(Color.orange);\n loseLabel.setForeground(Color.black.darker());\n\n\n //add buttons to panel\n add(rockButton);\n //add(Box.createRigidArea(new Dimension (0,10)));\n add(paperButton);\n //add(Box.createRigidArea(new Dimension (0,10)));\n add(scissorsButton);\n //add(Box.createRigidArea(new Dimension (0,10)));\n\n\n add(userLabel);\n //add(Box.createRigidArea(new Dimension (0,10)));\n add(computerLabel);\n //add(Box.createRigidArea(new Dimension (0,10)));\n\n\n add(winLabel);\n //add(Box.createRigidArea(new Dimension (0,10)));\n add(tieLabel);\n //add(Box.createRigidArea(new Dimension (0,10)));\n add(loseLabel);\n //add(Box.createRigidArea(new Dimension (0,10)));\n\n\n // add action listeners\n rockButton.addActionListener(new ButtonListener());\n paperButton.addActionListener(new ButtonListener());\n scissorsButton.addActionListener(new ButtonListener());\n\n\n }\n private class ButtonListener implements ActionListener {\n public void actionPerformed(ActionEvent ae){\n int computerSourceAI = (int) (Math.random() * 2); //random generator\n\n String oppChoice = attackArray[computerSourceAI]; // the choice of your opponent \n\n String yourChoice = ((JButton) ae.getSource()).getText(); // casts source from object to button and gets the text\n\n\n\n int outcome = determineWinner(yourChoice, oppChoice);\n\n // 0 = tie\n //1 == win\n //2 = lose\n\n if (outcome == 1) \n {\n\n // win message \n //System.out.println(\"You win!\");\n winLabel.setText(\"You Won\" + winInt++);\n }\n\n else if (outcome == 0)\n {\n\n // tie message\n //System.out.println(\"Tie\");\n tieLabel.setText(\"You tied\" + tieInt++);\n\n\n }\n\n else\n {\n loseLabel.setText(\"You lose\" + loseInt++);\n }\n\n\n }\n }\n\n\n\n public int determineWinner(String you, String opponent)\n{\n\n if(you.equals(\"Rock\") && (opponent.equals(\"Rock\"))){\n //tieInt++;\n tieLabel.setText(\"You tied\" + tieInt++);\n return tieInt++;\n }else if(you.equals(\"Rock\") && (opponent.equals(\"Rock\"))){\n //tieInt++;\n tieLabel.setText(\"You tied\" + tieInt++);\n return tieInt++;\n }else if(you.equals(\"Scissors\") && (opponent.equals(\"Scissors\"))){\n //tieInt++;\n tieLabel.setText(\"You tied\" + tieInt++);\n return tieInt++;\n }else if(you.equals(\"Rock\") && (opponent.equals(\"Scissors\"))){\n //winInt++;\n winLabel.setText(\"You Won\" + winInt++);\n return winInt++; \n }else if(you.equals(\"Paper\") && (opponent.equals(\"Rock\"))){\n //winInt++;\n //return 1;\n winLabel.setText(\"You Won\" + winInt++);\n return winInt++;\n }else if(you.equals(\"Scissors\") && (opponent.equals(\"Paper\"))){\n //winInt++;\n //return 1;\n winLabel.setText(\"You Won\" + winInt++);\n return winInt++;\n }else if(you.equals(\"Scissors\") && (opponent.equals(\"Rock\"))){\n //loseInt++;\n //return -1;\n loseLabel.setText(\"You lose\" + loseInt++);\n return loseInt++;\n }else if(you.equals(\"Rock\") && (opponent.equals(\"Paper\"))){\n //loseInt++;\n //return -1;\n loseLabel.setText(\"You lose\" + loseInt++);\n return loseInt++;\n }else \n if(you.equals(\"Paper\") && (opponent.equals(\"Scissors\"))){\n //loseInt++;\n //return -1;\n loseLabel.setText(\"You lose\" + loseInt++);\n return loseInt++;\n }\n return 0;\n\n\n}\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 27245101, "AnswerCount": 2, "Tags": "<sql><postgresql>", "CreationDate": "2014-12-02T08:38:46.060", "AcceptedAnswerId": "27245234", "Title": "Why should we use rollback in sql explicitly?", "Body": "<p>I'm using PostgreSQL 9.3</p>\n\n<p>I have one misunderstanding about transactions and how they work. Suppose we wrapped some SQL operator within a transaction like the following:</p>\n\n<pre><code>BEGIN;\n insert into tbl (name, val) VALUES('John', 'Doe');\n insert into tbl (name, val) VALUES('John', 'Doee');\nCOMMIT;\n</code></pre>\n\n<p>If something goes wrong the transaction will automatically be rolled back. Taking that into account I can't get when should we use ROLLBACK explicitly? Could you get an example when it's necessary?</p>\n", "Lable": "No"} | |
| {"QuestionId": 27328787, "AnswerCount": 0, "Tags": "<python><cryptography><memoization><exponentiation><charm-crypto>", "CreationDate": "2014-12-06T05:53:53.360", "AcceptedAnswerId": null, "Title": "Big List Python for Charm-Crypto group element", "Body": "<p>While working with Charm-Crypto package, I need to do lots and lots of group element exponentiation. The group elements come from bi-linear pairing group. The Order of the group element is a 1024 bit integer. So to reduce the average cost of exponentiation, I wanted to use memoization.</p>\n\n<p>But I came to know that List does not support long indices (which I need very much). So I went for dictionary which is taking a lot of time & space.</p>\n\n<p>Could you suggest some other methods/data structure in python to reduce the exponentiation cost. I am using iterative square-multiply technique to do the exponentiation.</p>\n", "Lable": "No"} | |
| {"QuestionId": 27348862, "AnswerCount": 1, "Tags": "<php><wordpress><loops><woocommerce>", "CreationDate": "2014-12-07T22:55:37.930", "AcceptedAnswerId": "29567016", "Title": "Loop Through product subcategories (WOOCOMMERCE) and return the price of the cheapest product", "Body": "<p>In Woo-commerce the default shop page can be set to show the products by their categories. When doing so it lists their thumbnail/title/link/how many products are available. </p>\n\n<p>It does not however show price.</p>\n\n<p>The goal is to list out the product categories and list the starting price of their products. For example: Category-1 starts at $9.99 (category-1 cheapest products is 9.99) </p>\n\n<p>Tips/tricks/ideas would all be appreciated </p>\n\n<p>Below is the default template that is used for that page:</p>\n\n<pre><code><?php\n/**\n * The template for displaying product category thumbnails within loops.\n * Override this template by copying it to yourtheme/woocommerce/content-product_cat.php\n */\n\nif ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly\n\nglobal $woocommerce_loop;\n\n// Store loop count we're currently on\nif ( empty( $woocommerce_loop['loop'] ) )\n $woocommerce_loop['loop'] = 0;\n\n// Store column count for displaying the grid\nif ( empty( $woocommerce_loop['columns'] ) )\n $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );\n\n// Increase loop count\n$woocommerce_loop['loop']++;\n?>\n<li class=\"product-category product<?php\n if ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 || $woocommerce_loop['columns'] == 1 )\n echo ' first';\n if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 )\n echo ' last';\n ?>\">\n\n <?php do_action( 'woocommerce_before_subcategory', $category ); ?>\n\n <a href=\"<?php echo get_term_link( $category->slug, 'product_cat' ); ?>\">\n\n <?php\n /**\n * woocommerce_before_subcategory_title hook\n *\n * @hooked woocommerce_subcategory_thumbnail - 10\n */\n do_action( 'woocommerce_before_subcategory_title', $category );\n ?>\n\n <h3>\n <?php\n echo $category->name;\n\n if ( $category->count > 0 )\n echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class=\"count\">(' . $category->count . ')</mark>', $category );\n ?>\n </h3>\n\n <?php\n /**\n * woocommerce_after_subcategory_title hook\n */\n do_action( 'woocommerce_after_subcategory_title', $category );\n ?>\n\n </a>\n\n <?php do_action( 'woocommerce_after_subcategory', $category ); ?>\n\n</li>\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 27364186, "AnswerCount": 1, "Tags": "<javascript><jquery>", "CreationDate": "2014-12-08T18:11:00.623", "AcceptedAnswerId": "29889941", "Title": "Getting decent sized pictures using the rottentomatoes API", "Body": "<p>I am using the rotten tomatoes API, which is fairly straight forward. The following is my basic code:</p>\n\n<pre><code>var apikey = \"xxxxx\";\n\nfunction queryForMovie(query) {\n queryUrl = \"http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=\" + apikey + \"&q=\" + encodeURI(query);\n $.ajax({\n url: queryUrl,\n dataType: \"jsonp\",\n success: queryCallback\n });\n}\n\nfunction queryCallback(data) {\n var el = $('#movie-listings');\n $.each(data.movies, function(index, movie) {\n el.append('img src=\"' + movie.posters.original + '\" alt=\"' + movie.title + '\"');\n })\n};\n\n$(document).on(\"load\", queryForMovie(\"Star Wars\"));\n</code></pre>\n\n<p>However, this gives back a very small image.</p>\n\n<p>What would be a good way to get a larger sized image, while limiting requests where possible? </p>\n", "Lable": "No"} | |