texts
sequence | tags
sequence |
---|---|
[
"How can I embed plotly graphs into powerpoints or apple's keynote?",
"I am learning how to generate graphs with plotly. I am biochemistry graduate student. I would like to use these graphs into presentations (e.g. powerpoint, keynote). I was wondering if someone could please give me a general strategy or link to a tutorial. \n\nThank you!"
] | [
"plotly"
] |
[
"How to fine tune ELK",
"We are running out of heap memory and also unstability issues in our ELK, below the configuration screenshot.\n-Version 6.2.4\n-No of nodes: 5\n-Data nodes: 3\n-Indices: 6138\n-Documents: 3,840,550,046\n-Primary shards: 14,934\n-Replica Shards: 14,934\n-Disk Available: 25.98(1TB/5TB)\n-JVM Heap: 62.045(46GB/74GB)\nI am know that I have to reduce on number of shards and also data we are holding is since Jan 2019-although 2019 data is in closed state.\nI need help on understanding as how can I do\n1- re-indexing to reduce the number of shards of the old indices\n2- download of old indices and keep in a archive and later re-use the same if and when required\n3- we are having daily indices rotation, how to change it to weekly/monthly indices and how it will help.\nLooking forward for some guidance as ELK is new to me and am held up with this.\nThanks,\nAbhishek"
] | [
"elastic-stack"
] |
[
"vector::clear :Memory Issue",
"Vector::Clear() will erase the elements in the vector array.\n\nThe issue is that if we pass objects in vector list then Clear() will delete the memory of objects or not.\n\nI post my sample:\n\n CData *m_data = new CData();\n vector<CData*> m_logdata;\n m_logdata.push_back(m_data);\n m_logdata.clear();\n\n\nwill this code delete the memory allocated by m_data or simply remove the element in the vector list?\n\nRegards,\nkarthik"
] | [
"c++",
"stl",
"mfc",
"vector"
] |
[
"Standard python error for input being too large?",
"I have an object that processes images to reduce their size (by center cropping). The object is constructed with a given size to crop down to, and then it provides a function called process() to actually crop the image. But if the image is smaller than the specified output size I need to throw an error.\nIs ValueError the appropriate error here or is there a better standard error for this or should I create a custom error type?\nCode:\nclass CenterCropCameraPreprocessor(object):\n """Class for adding preprocessing images by center cropping them.\n """\n\n def __init__(self, center_size):\n self.center_size = center_size\n\n def process(self, color_img):\n if color_img.shape[0] < self.center_size[0] or color_img.shape[1] < self.center_size[1]:\n # THROW ERROR\n \n # DO WORK"
] | [
"python",
"exception"
] |
[
"SSRS : Using URL Access Parameters to printer",
"Currently, I am using this method to generate PDF file via SSIS and SSRS.\n\nhttps://msdn.microsoft.com/en-us/library/ms152835(v=sql.105).aspx\n\n\n\nHowever, I manage to output it to local drive only.\n\nIs it possible to send the PDF file to network printer ?\n\nand do I need to install Adobe Acrobat reader on this machine ?"
] | [
"vb.net",
"reporting-services",
"ssis",
"ssrs-2008-r2"
] |
[
"I have configure Couchbase with AWS using kubectl but unable to create a new bucket on aws instance",
"I have configured Couchbase using kubectl below is the link I have followed to configure the Couchbase DB to AWS instance using kubectl..\n\nWhen I hit the basic query of Couchbase\ncurl -v http://Administrator:password@localhost:8091\n-> Response showing is correct means the installation is done right.. Below is the screen shot..\n\n\n\nBut when i tried to create an bucket using this command\n\ncurl -v -X POST http://Administrator:password@localhost:8091/pools/default/buckets -d name=Guardium -d ramQuotaMB=100\nFollowing is the output -- Showing some 202 accepted response but the bucket is not creating over there..\n\nLink for Configuring Couchbase with AWS\nhttps://github.com/couchbase-partners/amazon-eks-couchbase\nI am not sure what is wrong or some permission required for pods to create an new bucket ?? Please try to help me out on this.."
] | [
"amazon-web-services",
"kubernetes",
"couchbase",
"kubectl"
] |
[
"SSR for react-redux application with sails",
"I am creating a nodejs project with sails framework , and want to use react SSR (server side rendering) with sails (not express or another thing).\n\nI ask some questions of my self when want to use sails SSR : \n\n\nCould we use sails for SSR ? (as it has no documentation to do\nthat)\nCould we trust some libraries like : sails-hook-next for\nproduction usage of sails SSR ?\nWhat about using express and having two servers running . [express-react-redux-server-side-rendering]"
] | [
"node.js",
"reactjs",
"sails.js",
"server-side-rendering"
] |
[
"JIRA REST API -- Create Project HTTP 400 error",
"I have downloaded latest version of Jira (https://www.atlassian.com/software/jira/download) and have set it up on my laptop. I am trying to use the REST api for creating a project and running into issues , I am using java for making the call.\n\nthe JSON I am sending is -- {\\\"key\\\":\\\"VSPRJ\\\",\\\"name\\\":\\\"FROMVSPROJ\\\",\\\"projectTypeKey\\\":\\\"software\\\",\\\"description\\\":\\\"VSPROJDESC\\\",\\\"lead\\\":\\\"ADMIN\\\",\\\"assigneeType\\\":\\\"PROJECT_LEAD\\\"}\n\nJava code snippet I am using is below \n\nprivate static ResponseEntity WriteProjectIssueInformation2Jira()\n{\n httpHeaders = createHeadersWithAuthentication();\n\n String createProjJSON = createCreateProjectJSON(\"INEMP2\", \"EMPMGMT\", \"com.atlassian.jira-core-project-templates:jira-core-project-management\",\"business\",\"ADMIN\",\"PROJECT_LEAD\",\"10000\",\"0\",\"http://atlassian.com\",\"10324\",\"0\",\"0\",\"projfromcode\");\n\n String url = JIRA_URL + \"/rest/api/2/project\";\n\n System.out.println(url);\n httpHeaders.setContentType(MediaType.APPLICATION_JSON);\n\n HttpEntity<String> requestEntity = new HttpEntity<String>(createProjJSON, httpHeaders);\n\n return restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);\n}\n\n\nI am getting 400 not matter what I change w.r.t to the JSON I am sending , I have tried the project GET api's and it returns back data. Both the sample java program and JIRA is running in my local laptop. \n\nNot sure if there is any permissions required , please help"
] | [
"jira",
"jira-rest-api",
"jira-rest-java-api"
] |
[
"character is of string is always changing the position when ever I change the string value by using CCLabelBMFont",
"I update the score label when I'm playing my game and I display it by using CCLabelBMFont, when the score changes, each character of the score label always change the position of the label.\n\nI want to keep it the same position!\n\nExample: 00:01 take small space than 00:50; when the text change the CCLabelBMFont reposition the text again. help me , how to keep the same position?"
] | [
"objective-c",
"cocos2d-iphone"
] |
[
"Generic field validation with traits in Lift",
"I'm trying to define a trait Required to encapsulate the logic to validate the presence of required Record Fields, however, I haven't been able to figure out what the self type should be. My goal is to be able to write something as close as possible to e.g. object foo extends SomeField(...) with Required, however I do realize I might have to explicitly pass in some type parameters to Required.\n\nMy incompetent take so far has been:\n\nimport net.liftweb.record.Field\nimport net.liftweb.util.FieldError\n\ntrait Required[ThisType, OwnerType] {\n this: Field[ThisType, OwnerType] =>\n def errMsg = \"is required\"\n\n override def validations = {\n val required =\n (x: String) => if (x.isEmpty) List(FieldError(this, errMsg)) else Nil\n // this asInstanceOf call also seems fishy\n // --why's it even required if we already have the self type in place?\n required :: super.asInstanceOf[Field[ThisType, OwnerType]].validations\n }\n}\n\n\nhowever, this leads to compilation errors and warnings related to existential types from:\n\nmyfield = object SomeField(...) with Required[SomeField[SomeModel], SomeModel]\n\n\nnot to mention it's as far as it gets from the concise with Required.\n\nEDIT:\n\nI've come up with this instead:\n\ntrait Required[OwnerType] extends Field[String, OwnerType] {\n def errMsg = \"is required\"\n\n override def validations = {\n val required =\n (x: String) => if (x.isEmpty) List(FieldError(this, errMsg)) else Nil\n required :: super.validations\n }\n}\n\n\nhowever, it doesn't allow me to prepend required to super.validations because it expects this.type.ValueType => List[FieldError] not String => List[FieldError], which I find odd because in the case of Field[String, ...], ValueType is String.\n\nIf I change required to be ValueType => ..., it compiles, but with Required[SomeModel] errors out with:\n\n\n type arguments [String,OwnerType] do not conform to trait Field's type parameter bounds [ThisType,OwnerType <: net.liftweb.record.Record[OwnerType]]\n\n\n...even though StringField.ThisType is String and String.OwnerType is a subclass of Record[SomeModel], SomeModel being a subclass of MongoRecord[SomeModel]. —I'm lost.\n\nP.S. This is related to Lift Record: empty value for required field but no validation errors"
] | [
"validation",
"scala",
"lift",
"traits",
"lift-record"
] |
[
"How can I locally debug Facebook PHP applications?",
"I'm using Zend debugger and PDT for PHP development and have run into an issue debugging Facebook PHP. I'm using the example.php in the SDK to test. The application runs fine from Facebook, but I'm having trouble setting breakpoints. I have tried:\n\n\nRun from Eclipse - Application does not run as expected. I'm getting null values for $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] although I can set breakpoints and debug.\nRun from Facebook - the application runs as expected, but ignores breakpoints.\n\n\nI'm using DynDNS for my DNS lookup and have changed my host file to redirect the URL to my local host.\n\nI'm not even sure if #1 is possible, but it would be nice to use Eclipse and not have to refresh a web page as in #2. Any ideas?"
] | [
"php",
"facebook",
"zend-framework"
] |
[
"Image Resizing and Crop to fit in Frame",
"I am trying to build a PHP library that will resize an image down to a specific size, but am coming across a few issues which I can't quite work out.\n\nI am trying to make it so that it will resize and crop an image in the following way (all scaling is kept to the aspect ratio of the image):"
] | [
"php",
"image",
"resize",
"crop"
] |
[
"Android studion: Disable auto formatting of line comments",
"I've recently started working with Android studio, and while I like the auto-formatter and use it often for whole files (The Ctrl+Alt+L thing), there's one thing that I would like to disable:\n\nSometimes I comment a code line like this:\n\ndoSomething(); // This is some side-comment\n // that might span over 2 lines.\n\n\nI would like the comment to stay as is, but the auto-formatter will turn it into:\n\ndoSomething(); // This is some side-comment\n// that might span over 2 lines.\n\n\nIs there a way to prevent this while keeping all the other auto-formatter goodies intact? I couldn't find any code-style setting that controls the indentation of comments.\nIs there perhaps a way to add a custom rule to the auto formatter?"
] | [
"android",
"android-studio",
"autoformatting"
] |
[
"How to replace a className part with JavaScript Regex?",
"I've a simple divwith various class attributs:\n\n<div id=\"divId\" class=\"anInformationIWantToGet aClassUsedForCss\"></div>\n\n\nI want to programatically get the anInformationIWantToGet class which vary, the problem should be easy because others classes are known, so a Regex like following should do the job:\n\nvar anInformationIWantToGet = div.className.replace(/(\\s*(aClassUsedForCss)?\\s*)/, '');\n\n\nBut it doesn't work and I don't understant why... What did I miss?\n\nI create a Fiddle to test the problem.\n\nPS : my browser is Firefox17."
] | [
"javascript",
"regex"
] |
[
"How to upload multiple files in jsp?",
"I have been using \"input type='file' \" tag to upload single file but I want to extend the functionality to upload multiple files (selecting multiple file in the same dialog box to upload). I don't have any idea how to accomplish these, any ideas and suggestions?"
] | [
"html",
"jsp",
"file-upload"
] |
[
"How to query XML elements from a local XML file in Internet Explorer using jQuery?",
"I am building a single HTML page for use in a touch-screen kiosk. I have an external XML file named data.xml which resides in the same directory as my HTML page. I was able to use jQuery to load the external XML file, parse it and build some HTML dynamically on page load without any problems in Firefox and Chrome. But then I tried it in Internet Explorer...\n\nThe XML document loads just fine using the $.ajax() function. I did an alert(xmlDoc.text()) and it showed all the text contents of the XML document. So that is not the problem.\n\nI did some searching and found a StackOverflow answer which gives a solution to the problem IF you're serving the XML from a web server. It basically states that the following HTTP HEADER is needed in order for Internet Explorer to treat the xml string as xml.\n\ncontent-type:application/xml;charset=utf-8\n\nThis HTML page needs to just run as a standalone page inside Internet Explorer. We will not have a web server running on the kiosk machine.\n\nMy question is whether there is any way to specify the correct content-type when loading a local resource in jQuery?\n\nHere's the relevant ajax code I am working with...\n\n$.ajax({\n url: 'data.xml',\n async : false,\n success : function(response) {\n xml = $(response);\n }\n});\n\n// Following line works in Firefox/Chrome, but not in Internet Explorer\nvar firstItemText = $(\"item:first\", xml).text();\n\n\nEDIT: I have added an error handling function on the ajax request like so...\n\n$.ajax({\n url: 'data.xml',\n async : false,\n dataType : \"xml\",\n success : function(response) {\n xml = $(response);\n },\n error: function(XMLHttpRequest, textStatus, errorThrown) {\n alert('Data Could Not Be Loaded - '+ textStatus);\n }\n});\n\n\nThis function is firing in Internet Explorer and the resulting message is:\n\nData Could Not Be Loaded: - parsererror\n\nI checked my XML document with several online XML validator tools and it has no errors.\n\nAny help is appreciated."
] | [
"jquery",
"xml",
"internet-explorer"
] |
[
"Handle click event on a flash banner",
"I want to handle the click event on a flash banner. The flash banner is a link to another page. \n\nThis is my code :\n\n<!DOCTYPE html>\n<html>\n <head>\n <meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />\n <script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.9.1.min.js\"></script>\n <script type=\"text/javascript\">\n $(document).ready(function($) {\n $('.banner').click(function () {\n var id = $(this).attr('id');\n\n alert(id);\n }); \n });\n </script>\n </head>\n <body>\n <a id=\"banner_1\" class=\"banner\" href=\"http://google.com\">\n <h1>Banner 1</h1>\n </a>\n\n <embed id=\"test_1\" class=\"banner\" src=\"http://www.dg/wp-content/uploads/2013/03/sera-flash_web-banner_preset.swf\" \n width=\"400\" \n height=\"120\" \n type=\"application/x-shockwave-flash\"\n /> \n\n <a id=\"banner_2\" class=\"banner\" href=\"http://yahoo.com\">\n <h1>Banner 2</h1>\n </a>\n </body>\n</html>\n\n\nHow can I do this?\n\nEdit \n\nAlso i try to add onclick, onrelease event as follows. but it not working. \n\n <embed onrelease=\"alert('ddd');\" src=\"http://www.dlk/stg/wp-content/uploads/2013/03/sera-flash_web-banner_preset.swf\" \n width=\"400\" \n height=\"120\" \n type=\"application/x-shockwave-flash\"\n />"
] | [
"jquery",
"flash",
"click"
] |
[
"Toolbar Android L Custom TextView Font not applying",
"I have a problem with the new Toolbar in android. \n\nI have a similar layout: \n\n<android.support.v7.widget.Toolbar\n android:id=\"@+id/tlb_wineoox_login\"\n android:layout_height=\"wrap_content\"\n android:layout_width=\"match_parent\"\n android:elevation=\"1dp\"\n android:minHeight=\"?attr/actionBarSize\"\n android:background=\"?attr/colorPrimary\">\n\n <al.eng.utils.TextOratorStdMedium\n android:id=\"@+id/txt_home_acitivity_title\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:gravity=\"left\"\n android:text=\"@string/app_name\"\n android:layout_gravity=\"left\"\n android:textColor=\"#3f3434\"\n android:textSize=\"@dimen/tetembedhjet_sp\" />\n</android.support.v7.widget.Toolbar>\n\n\nAnd the class of the custom TextView is like this: \n\npublic class TextOratorStdMedium extends TextView {\n\n public TextOratorStdMedium(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n init(context);\n }\n\n public TextOratorStdMedium(Context context, AttributeSet attrs) {\n super(context, attrs);\n init(context);\n }\n\n public TextOratorStdMedium(Context context) {\n super(context);\n init(context);\n }\n\n private void init(final Context context) {\n Typeface tf = Typeface.createFromAsset(context.getAssets(),\"fonts/Orator-Std-Medium.ttf\");\n setTypeface(tf);\n\n }\n}\n\n\nIn this way my code doesn't seem to change the font type. But if i make the custom text view with an thread that wait's for one second before changing the typeface than it works:\n\npublic class TextOratorStdMedium extends TextView {\n\n public TextOratorStdMedium(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n init(context);\n }\n\n public TextOratorStdMedium(Context context, AttributeSet attrs) {\n super(context, attrs);\n init(context);\n }\n\n public TextOratorStdMedium(Context context) {\n super(context);\n init(context);\n }\n\n private void init(final Context context) {\n final Handler handler = new Handler();\n handler.postDelayed(new Runnable() {\n @Override\n public void run() {\n Typeface tf = Typeface.createFromAsset(context.getAssets(),\"fonts/Orator-Std-Medium.ttf\");\n setTypeface(tf);\n }\n }, 1000);\n }\n}\n\n\nSo it looks like the toolbar is somehow rewriting the type face of the custom textview after the creation. There is no style applied at all. How can this be possible? Do we have any other solution beside creating a new thread and waiting for some moments?\n\nThank you."
] | [
"android",
"android-layout",
"textview",
"toolbar"
] |
[
"Anyone know why issues in without type attribute \"text/css\" in XHTML are intermittent in the issues?",
"Before you vote or answer, I know that you should use the attributes for XHTML, (actually this should be placed in its own .css) I am simply trying to understand how it is handled because of the unique results I was getting.\n\nI found issues with a few sites I ended up taking on, that ran the CSS with what looked to be no issues at least with the CSS. It was after having a few jquery issues and slow processing that I looked to optimize. I ended up finding a common issue. It was a module holding inline CSS <style> tags without the type attributes. Btw, these are XHTML and not HTML5 sites. Changing the tags by adding attributes or removing the inline CSS looks to correct each site with the problems. \n\nMy question is, what is actually happening that would cause an issue to corrupt the process and still allow the CSS to function properly. This is out of pure curiosity and all style has been placed in it's own file. These are in a Joomla 1.5 module.\n\nTo really detail out one issue that happened more than once was a mask failed to complete it's process and happened to be code that followed the inline CSS. So far, this has yet to happen on 80 or so other sites with the same exact code, minus the style error."
] | [
"javascript",
"jquery",
"css",
"browser",
"mask"
] |
[
"Create an excel file using xlsxwriter and save the excel file into PDF",
"I manage to create many excel files by extracting the relevant data from MySQL tables and populating these data into Excel using Xlsxwriter. The number of created Excel files may exceed 100s at the point of data generation, and I need each excel file to be converted into PDF before I email out the files. \n\nManually converting each Excel file takes a few minutes, but just imagine doing for hundreds of files. I want to avoid using com32 or comtypes, and just through Xlsxwriter or VBA to get the conversion done. I have written some codes for Xlsxwriter, but somehow, this didn't work. Can someone advise, please. Thanks. \n\nVBA_worksheet=current_workbook.add_worksheet()\ncurrent_workbook.add_vba_project('printPDF')\nVBA_worksheet.write_formula('A1', 'ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF')\nVBA_worksheet.activate()\nVBA_worksheet.hide()"
] | [
"vba",
"excel",
"pdf",
"xlsxwriter"
] |
[
"from zonal_stats i get this error: ValueError: width and height must be > 0",
"I am using the function zonal_stats from the Rasterstats library. I have already used this function on data I have for precipitation which works impeccably. But when i try to run the function using the same vector, but with a different raster dataset (for Actual Evapotranspiration) I get the error message: \n\n Traceback (most recent call last):\n File \"<input>\", line 3, in <module>\n File \"/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/main.py\", line 31, in zonal_stats\n return list(gen_zonal_stats(*args, **kwargs))\n File \"/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/main.py\", line 159, in gen_zonal_stats\n rv_array = rasterize_geom(geom, like=fsrc, all_touched=all_touched)\n File \"/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterstats/utils.py\", line 47, in rasterize_geom\n all_touched=all_touched)\n File \"/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterio/env.py\", line 386, in wrapper\n return f(*args, **kwds)\n File \"/Users/ida/opt/anaconda3/envs/thesis_env/lib/python3.7/site-packages/rasterio/features.py\", line 347, in rasterize\n raise ValueError(\"width and height must be > 0\")\n\n\nThe code I try to run is this:\n\nvec = '/path/to/file/watersheds_template.shp'\nAET = '/path/to/file/AET_2003.tif'\navg_AET = zonal_stats(vec, AET, layer='watersheds_template', stats='mean', geojson_out=True)\n\n\nI have opened the AET raster file in Qgis, where there is no problem, projection looks fine as well as the range of the data and it does also overlap with the vector shapefile. I can do the calculations in Qgis using \"Zonal Statistics\", but I need to do the same calculations on a bunch of raster data, so it is too timeconsuming to run through all the data one at a time with Qgis. \n\nI can open the AET data with GDAL and it looks like this, without any problems:\n\nAET_raster = gdal.Open(filepath)\n\n\nI thought it was something with the dimensions of the file but this also looks fine.\nThe string of the raster is like so \n\n<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x119250810> >\n\n\nAnd the dimesions are: \n\nRasterCount = {int} 1, RasterXSize = {int} 1115, RasterYSize = {int} 834 \n\n\nThese are the same dimensions a the raster file I have for precipitation. \n\nDoes anyone know what can be wrong here?"
] | [
"python",
"raster",
"gdal"
] |
[
"How to run background service in flutter",
"I am trying to develop a flutter app which will fetch data from server every 10 seconds using timer. It all works well when in foreground. So I followed the documentation provided here Work Manager and I can get the data from server even when app is in background but cannot reduce the frequency below 15 minutes. I dont want to code in native android and ios. How can I approach this situation ? Is there a solution I am missing ?"
] | [
"flutter",
"background-task"
] |
[
"I did my research, but still cant put text above my image: NEW CODER",
"Here is my CSS:\n\n.info {\n color: black;\n padding: 100px 15%;\n}\n\n.info img {\n display: block;\n margin-left: auto;\n margin-right: auto;\n opacity: 0.4;\n filter:alpha (opacity=40); /* For IE8*/\n}\n\n.info p { \n background: none repeat scroll 0 0 white;\n line-height: 1.5;\n}\n\n.info h3 { \n font-size: 36px; \n margin: 0;\n}\n\n\nHere is my HTML:\n\n<div class=\"info\" id=\"aboutus\">\n <h3>About Us</h3>\n <img src=\"image/pink.jpg\">\n <p>text</p>\n</div>\n\n\nI'm trying to display the text above the image with a drop shadow on the text, and i'm stuck."
] | [
"html",
"image",
"css"
] |
[
"Why reading my tcp inputstream lead a byte array fill in with null character only?",
"I am not used to C# (I do C++ usually) and try to debug an application that is not mine, at all.\n\nMy application tries to read a big line from a TCP socket. Let say around 140 000 characters. And it fails. Let me explain how.\n\nMy code is here (inside a loop actually )\n\n System.IO.Stream inputStream;\n\n //...\n\n // Loop code:\n buffer = new byte[2];\n readByteForLength = inputStream.Read(buffer, 0, 2);\n\n\nIt turns out that Read() may fill in the buffer array correctly up to a point, where it fills it with NULL characters instead of valid values. And it returns 2 as it would in a correct case. \n\nDo you have an idea why such NULL characters?\n\nIs the tcp pacquet still on the network when I try to read more of my data?\nIs there a limit for inputStream before it behaves wrongly ?\n\nUpdate:\nBy the way doing so lead to the same kind of issue:\n\n System.IO.StreamReader sr = new StreamReader(inputStream);\n string s = sr.ReadToEnd();\n\n File.WriteAllText(@\"c:\\temp\\toto.txt\", s);\n\n\nActually the toto file stops exactly where I encounter an issue in the first version of my code while it is a little bit longer because the rest of the line is then filled up with NULL characters, nearly up to 400 000!"
] | [
"c#",
"tcp",
"inputstream"
] |
[
"How to initialize a koa node.js app application on IISNode (Azure WebSites)",
"We are currently moving a self-hosted koa app to IISNode on Azure WebSites..\n\nIn self-hosting, we initiallize the application by calling \n node --harmony ./bin/application\nRequests then go to ./index.js.\n\nHowever we could not find how to setup IISNode to call \"bin/application\" at initialization time.\n\nAny ideas?\nThanks"
] | [
"node.js",
"azure-web-app-service",
"ecmascript-harmony",
"koa",
"kudu"
] |
[
"Django multiple pictures one product",
"I have the following problem: I'm programming a webshop and every product has multiple pictures. So this is a one-to-many relation, where the foreign key is in the picture model. However, if i register the models "product" and "picture" to the admin site the user obviously needs to add a product then navigate to the pictures and add a picture and referencing a product within the picture creation process. Instead of this i want the user to be able to create a product and then add multiple pictures in the dropdown menu inside the same subpage inside admin-pannel. How can i accomplish this behaviour? It should look exact like it would with a many-to-many relation. But i don't want to use ManyToManyField sience i already tried it and then it lead to logical issues.\nmodels.py:\nclass Picture(models.Model):\n picture = models.ImageField(upload_to='shop/static/shop/images/')\n product = models.ForeignKey(Product, on_delete=models.CASCADE)\n\n def __str__(self):\n return self.picture.url\n\nclass Product(models.Model):\n\n name = models.CharField(max_length=200)\n\n def __str__(self):\n return self.name\n\nadmin.py\nadmin.site.register(Picture)\nadmin.site.register(Product)"
] | [
"django",
"database",
"model",
"admin"
] |
[
"progressmeter is updated too rarely",
"I have progressmeter in my XUL source code and button that I created for testing, that increments value of progressmeter by constant value.\nProblem exists because if value of increment is smaller than 4, progressmeter won't be updated.\nFor example if that const value is 1, value must be increment four times, to see change on the screen. Also internal value of progressmeter's object is not updated, ie logging variable progressmeter.value give non updated result.\nAnalogously if I increment value by 2, I must do it two times to see result. \nIt does not depend on max value, the same behaviours is if max is 100 or 2000.\n\nFor example:\n\n<progressmeter value=\"0\" max=\"100\" id=\"progressmeter1\" />\n\nvar pm_value = 0;\nfunction incrementProgressmeter(){\n var value_for_increment = 1;\n pm_value += value_for_increment;\n var progressmeter = document.getElementById(\"progressmeter1\"); \n progressmeter.value = pm_value;\n}\n\n\nIf value of value_for_increment is 1, I must invoke incrementProgressmeter function four times to see on the screen that progressmeter is progressing and also progressmeter.value is updated after that time.\nIf value of value_for_increment is 2, I must invoke incrementProgressmeter function two times. This behaviour doesn't depend on max attribute of progressmeter.\n\nI wonder if it is designed behaviour, but I don't understand reason why it may be designed in such way. If it is, I would like to know why. Also I would like to know how to omit that limitation, ie I want to value of progressmeter to be increment properly by 1,2,3 values, so the user can see progress on the screen."
] | [
"xul"
] |
[
"Generation of an HTML div based table with column header spanning several (but not all) cells",
"Given a XML like this fragment (which will be generated), I need to generate a web page using div entries, based on XSLT 1.0, which looks like the one below:\n\n <div class=\"rTable\">\n <div class=\"rTableRowS\">\n <div class=\"hCell\">SIT</div>\n </div>\n <div class=\"rTableRowS\">\n <div class=\"rTableCellS\">Header 1</div>\n <div class=\"rTableCellS\">Header 2</div>\n <div class=\"rTableCellS\">Header 3</div>\n <div class=\"rTableCellS\">Header 4</div>\n </div>\n <div class=\"rTableRowQ\">\n <div class=\"rTableCellQ\">a1</div>\n <div class=\"rTableCellQ\">single</div>\n <div class=\"rTableCellQ\">a2</div>\n <div class=\"rTableCellQ\">secondary</div>\n <div class=\"rTableCellQ\">a3</div>\n <div class=\"rTableCellQ\">single</div>\n <div class=\"rTableCellQ\">a4</div>\n <div class=\"rTableCellQ\">secondary</div>\n </div>\n <div class=\"rTableRowS\">\n <div class=\"rTableCellS\">header 5</div>\n <div class=\"rTableCellS\">header 6</div>\n <div class=\"rTableCellS\">header 7</div>\n <div class=\"rTableCellS\">header 8</div>\n </div>\n <div class=\"rTableRowQ\">\n <div class=\"rTableCellQ\">b5</div>\n <div class=\"rTableCellQ\">single</div>\n <div class=\"rTableCellQ\">b6</div>\n <div class=\"rTableCellQ\">secondary</div>\n <div class=\"rTableCellQ\">b7</div>\n <div class=\"rTableCellQ\">single</div>\n <div class=\"rTableCellQ\">b8</div>\n <div class=\"rTableCellQ\">secondary</div>\n </div>\n\n\nDesired output (look and feel):\n\nSIT\nHeader 1 ¦ Header 2 ¦ Header 3 ¦ Header 4\na1 ¦ single ¦ a2 ¦ secondary ¦ a3 ¦ single ¦ a4 ¦ secondary \nHeader 5 ¦ Header 6 ¦ Header 7 ¦ Header 8\nb5 ¦ single ¦ b6 ¦ secondary ¦ b7 ¦ single ¦ b8 ¦ secondary \n\n\nand so on.\n\nWhat is an easy XSLT1.0 transformation to achieve the column matching (based on div). I can adapt the input XML to some level, such as changing the class entries."
] | [
"html",
"xslt-1.0"
] |
[
"Using Dependency Injection for hardware abstraction",
"I've been playing around with Dependency Injection in connection with hardware abstraction. So, basically I have some hardware devices which i want to control from within a C# application. These devices have usually a root device which is used to access leaf devices. The structure is quite simple: LeafDevice1 & 2 are connected through Interface1 to RootDevice1, LeafDevice3 is connected to RootDevice2 and so forth.\n\nNow i thought i can solve this issue with dependency injection since \"leaf\" devices usually don't care how they're connected as long as they're connected to a specified interface. But I'm wondering if Dependency Injection using an IOC container is actually the best way to do it. The main reason for my doubts is:\nI use named dependencies ALL THE TIME. If I connect device B and C to root device A I want to make sure that they're referring to the exact same device. Also, I use a lot of singleton scopes since a named dependency xyz should only exist once.\n\nSo in my situation configuring the container means gluing together a lot of named dependencies.\n\nAs I understand it, using IOC containers makes most sense when you want to specify which implementation will be injected. But as far as I can see, I'm using the container to manage which specific object is used where. The actual implementation of said object can, of course, be different, but it's still more of a \"what is used where?\" not a \"which implementation is used\" question.\n\nWouldn't it be better to build something like a device tree which i can use to access my devices?\n\nBind<RootDevice>().ToConstructor<RootDevice>(e => new RootDevice(serialNumber))\n .InSingletonScope().Named(\"ConcreteRootDevice\");\n\nBind<IBusMaster>().ToMethod<IBusMaster>(e => e.Kernel.Get<RootDevice>(\"ConcreteRootDevice\")\n .GetBusMaster(0)).Named(\"ConcreteBus1\");\n\nBind<IBusMaster>().ToMethod<IBusMaster>(e => e.Kernel.Get<RootDevice>(\"ConcreteRootDevice\")\n .GetBusMaster(1)).Named(\"ConcreteBus2\");\n\nBind<IBusMaster>().ToMethod<IBusMaster>(e => e.Kernel.Get<RootDevice>(\"ConcreteRootDevice\")\n .GetBusMaster(2)).Named(\"ConcreteBus3\");\nBind<IBusMaster>().ToMethod<IBusMaster>(e => e.Kernel.Get<RootDevice>(\"ConcreteRootDevice\")\n .GetBusMaster(3)).Named(\"ConcreteBus4\");\n\nBind<LeafDevice>().ToConstructor<LeafDevice>(o =>\n new LeafDevice(o.Context.Kernel.Get<IBusInterface>(\"ConcreteBus1\")))\n .Named(\"ConcreteLeafDevice1\");\n\nBind<LeafDevice>().ToConstructor<LeafDevice>(o =>\n new LeafDevice(o.Context.Kernel.Get<IBusInterface>(\"ConcreteBus1\")))\n .Named(\"ConcreteLeafDevice2\");\n\nBind<LeafDevice>().ToConstructor<LeafDevice>(o =>\n new LeafDevice(o.Context.Kernel.Get<IBusInterface>(\"ConcreteBus2\")))\n .Named(\"ConcreteLeafDevice3\");\n\n\nIn this example LeafDevices would depend on an abstract IBusInterface to communicate with the actual hardware devices. Root Device offers several BusMasters which can be used to communicate with said leaf devices.\n\nThanks in advance"
] | [
"c#",
"dependency-injection",
"hardware-programming"
] |
[
"Thread data encapsulation best practices",
"I have a question how to encapsulate data gracefully in such case.\nLet's think we want to make some class that can asynchronous download images from internet. Let us have unblocking method:\n\nvoid download(string url)\n\n\nThis method will create thread and start downloading, and then invoke callback:\n\nvoid callback(char* data)\n\n\nWhat is best: allocate memory for data in Downloader or allocate it out of Downloader class? In first case we will need to copy data returned in callback and if data is big - it is not good, otherwise we will allocate memory in Downloader class and release it somewhere else. In second case we need to allocate memory for data and pass it as parameter in download method:\n\nchar *data = new char[DATA_SIZE];\ndownloader.download(url, data);\n\n\nBut how can we protect this allocated data from changing it from callable thread, while it used by downloader thread. I think there is some way to make it without synchronization in callable thread some way to make this logic invisible for client.\n\nHope you get my mind right"
] | [
"c++",
"multithreading"
] |
[
"How to keep flash when redirecting to the login page",
"I'm implementing an email mechanism in Play:\n\n\nUser gets an email with a validation link\nClicks on it, gets to a controller that saves the \"validated\" bit on the user model, then redirects him to another page.\nBefore redirecting, that last page puts a message into the flash object ... to be displayed later in whatever page the user ends up at, via javascript. The message says \"thanks for validating your email\".\nThe target page has @With(Secure.class), so if the user is not authenticated I reach the Secure.login() method.\n\n\nNow, at this point, I find that flash does not contain the message I just put in there before the redirection. What is the correct way to use flash in a way that survives this redirect?"
] | [
"java",
"playframework"
] |
[
"Testing before_save with RSpec and Factory Girl",
"I'm using a before_save call to update all the records that belong to a particular master. Both have a field called item_id:\n\nclass Master < ActiveRecord::Base\n has_many :records\n before_save :update_records\n def update_records\n self.records.find_each do |r|\n r.item_id = self.item_id\n r.save\n end\n end\nend\n\nclass Record < ActiveRecord::Base\nend\n\n\nThis works as intended (leaving aside for the minute whether it's a good idea to do something like this). However I can't get an RSpec test that passes. This is what I tried:\n\ndescribe Master do\n describe 'before_save' do\n it 'updates records belonging to it' do\n master = FactoryGirl.create(:master, item_id: 1)\n record = FactoryGirl.create(:record, master_id: master.id, item_id: 1)\n master.item_id = 2\n master.save\n record.item_id.should == 2\n end\n end\nend\n\n\nThe reason is interesting. The model does its work on a second instance of a Record model which gets saved successfully, but is not returned to the spec:\n\n\"MASTER - CREATED IN SPEC\"\n#<Master:0x007fd0ed55ec20> {\n :id => 26,\n :item_id => 1,\n}\n\"RECORD - CREATED IN SPEC\"\n#<Record:0x007fd0ea157e40> {\n :id => 16,\n :item_id => 1,\n :master_id => 26,\n}\n\"RECORD - AFTER SAVE IN MODEL\"\n#<Record:0x007fd0ed2f9a70> {\n :id => 16,\n :item_id => 2,\n :master_id => 26,\n}\n\"MASTER - UPDATED IN SPEC\"\n#<Master:0x007fd0ed55ec20> {\n :id => 26,\n :item_id => 2,\n}\n\"RECORD - FINAL IN SPEC\"\n#<Record:0x007fd0ea157e40> {\n :id => 16,\n :item_id => 1,\n :master_id => 26,\n}\n\n\nDo you know:\n\n\nwhy this is happening?\nHow I can get this spec to pass?"
] | [
"ruby-on-rails",
"rspec",
"factory-bot"
] |
[
"Sort array elements based on their frequency",
"I need to sort an array of elements based on their frequency, for example:\n\nInput array: [1, 6, 6, 6, 6, 4, 3, 5, 5, 5, 2, 2]\nExpected output: [1, 3, 4, 2, 2, 5, 5, 5, 6, 6, 6, 6]\n\n\nI tried with the code below:\n\nvar set: NSCountedSet = [1, 6, 6, 6, 6, 4, 3, 5, 5, 5, 2, 2]\n\nvar dictionary = [Int: Int]()\nset.forEach { (item) in\n dictionary[item as! Int] = set.count(for: item)\n}\ndictionary.keys.sorted()\nprint(dictionary)\n\n\nDescription: As 1, 3, 4 occur only once, they are shown at the beginning, 2 occurs two times, 5 three times, 6 four times. And [1, 3, 4] are sorted among them.\n\nExpected result: Time complexity should be O(n)"
] | [
"ios",
"arrays",
"swift",
"sorting",
"time-complexity"
] |
[
"concatenating string to solr field value while searching?",
"is it possible to concatenate string to solr field while we are searching \nExample:\nlocalhost:8983/solr/collection1/select?q=item_type%3Apostings&wt=json&indent=true\n\nnow i have one field id i need to append text \"locality_\" before every id value.so that i need not to to for loop on large data set."
] | [
"search",
"solr",
"solrj"
] |
[
"Spring: How can I log the PageNotFound exception in a database?",
"I would like to log when the spring fails to find a request handler because, for instance, a client tries to access our REST service with a misspelled required parameter.\n\nWhat's the recommended way to do that?"
] | [
"spring-mvc"
] |
[
"ptrace %edx for sys_open inconsistent",
"I am trying to get the filename from the sys_open system call using ptrace. I get the filepath pointer, and I am able to get the correct data from that address, however, I need a way to know how much data to get, ie the length of the filename. I thought this value was supposed to be in edx, but that doesn't seem to be the case here. Any thoughts?\n\n orig_eax = ptrace(PTRACE_PEEKUSER, child, 4 * ORIG_EAX, NULL);\n if(orig_eax == __NR_open){\n ptrace(PTRACE_GETREGS, child, NULL, &regs);\n if(regs.eax > 0){ \n filepath = (char *)calloc((regs.edx+1), sizeof(char));\n getdata(child, regs.ebx, filepath, regs.edx);\n\n printf(\"Open eax %ld ebx %ld ecx %ld filepath %s\\n\",regs.eax, regs.ebx, regs.ecx, filepath);\n\n free(filepath);\n }\n } \n\n\nSample output:\n\nOpen eax 3 ebx 2953895 edx 438 filepath /etc/localtime\nOpen eax 3 ebx 143028320 edx 384 filepath /var/log/vsftpd.log\nOpen eax 4 ebx 2957879 edx 438 filepath /etc/nsswitch.conf\nSegmentation Fault\n\n\nJust the edx:\n\nedx 438\nedx 384\nedx 438\n//seg fault here\nedx -1217013808\nedx 0\nedx 143035796\nedx 0\nedx 0"
] | [
"linux",
"x86",
"system-calls",
"ptrace"
] |
[
"How could I remove slash from a url in .htaccess file?",
"How could I remove trailing slash in front of a url? For example: stackoverflow.com/hello works on server, which definitely redirects to page named hello, but actually this is not the case on localhost.\n\nHowever, it ends up something like localhost/hello instead of folder name included in it,Expected result would be localhost/stackoverflow/hello.\n\n<a href=\"/hello\" />\n\n\nExpected output: localhost/stackoverflow/hello\n\nOutput got: localhost/hello\n\nActually this stuff is working on a live website but not on localhost. o I was looking for some tips to make it this way with .htaccess file.\n\nHTACCESS FILE\n\nRewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^([^\\.]+)$ $1.php [NC,L]\n\n\nPS: I have more than 40 files, So I don't think removing \"/\" from every url makes sense."
] | [
".htaccess"
] |
[
"More quickly ingest data from mongo into python",
"I have the following data read:\n\nprint datetime.datetime.now()\n\nopts = m.get_unique_dates_for_underlying(ticker, \"date\")\n\nprint datetime.datetime.now()\n\n\nWith the following output:\n\n2015-11-02 22:46:50.371000\n2015-11-02 22:46:50.371000\n\n\nNow when I go to read the data into my dataframe it takes 12 minutes when running:\n\ndf_opts = pd.DataFrame(list(opts)).convert_objects()\n\n\nIs there a faster way to accomplish this? \n\ndf_opts is of length 351,500."
] | [
"python",
"mongodb",
"pandas"
] |
[
"Need to Optimize delta lake table design for certain data access pattern(queries)",
"Suppose i have a delta table in s3, Resource table -> (clientid, instanceid, resourceid, version, modified_time_utc, payload ). Payload is a complex json with unknown schema.\nversion is associated with each resource. Don't confuse this with version of audit_history table.\nOne resource (same resourceid) can have multiple version(increasing number), also modifiedtime for each version is (a increasing number).\nThere are certain data access patterns that i need to have good performance,\n\nInput(clientid, instanceid, resourceid) -> return the payload associated with "Latest Version" of (clientid, instanceid, resourceid)\n\nInput(clientid, instanceid, Range of (modified time utc) -> return all the "latest" resource that given (clientid, instanceid) created within the time range.\n\n\nI was thinking of having a delta table partitioned by clientid, instanceid , resourceid, version.\nfor first access pattern, ->\nselect payload, version from (SELECT MAX(version) as Version from Resource where clientid=cid and instanceid=iid and resourceid=rid) as subquery\nwhere clientid=cid and instanceid=iid and resourceid=rid and version=subquery.Version\nSubquery will be used for finding max version. It uses partitioning for skipping data.\nIs there a way in delta-lake to optimize this process. Like create certain index on version so that i don't have to run a subquery.\nfor second access pattern ->\nselect resourceid, max(version) from Resource\nwhere clientid=cid and instanceid=iid and modifiedtimeutc between (t1,t2)\ngroupby resourceid, version\nIs there some feature in delta-lake which can help me in increasing performance of these queries.\nPlease feel free to suggest alternative design.\nAny help would be deeply appreciated.\nThanks\nEveryday, volume is around 2 - 3 tb of data to this table. Payload(huge json) contributes to the size. Mostly all of the records are <= 1mb compressed, few outliers of size 20 mb compressed."
] | [
"databricks",
"delta-lake"
] |
[
"Cordova has two timeouts if a Url does not load",
"I am building an application built on Cordova 5.2.0 codebase. I notice that when attempting to load an invalid URL two timeouts seem to occur. The first occurs in CordovaWebViewImpl after about 20 seconds:\n\n\n\nAbout a minute or two later an ERR_CONNECTION_TIMED_OUT error is captured in the onReceivedError method of my SystemWebViewClient instance.\n\n\n\nMy question basically is why there are two different timeouts and how are these timeout values set? Ideally I would actually want a single timeout being triggered in the SystemWebViewClient, but I guess I could just ignore the first one (CordovaWebViewImpl) if I could control the timeout for the second (SystemWebViewClient)."
] | [
"android",
"cordova",
"webview"
] |
[
"Load Operation failed",
"When we create a new project or open some project in visual studio mac 2019(Version 8.6.8) then it shows two errors:\n\nLoad Operation Failed.\nCould not load project "project directory"."
] | [
"xamarin",
"xamarin.forms",
"xamarin.ios"
] |
[
"Php script not finding include file",
"I am running a php command (edited) from the command line that runs a php file on the web server.\n\nIn that file I need to include a file that is one level up from its location.\n\nI have tried \n\ninclude(../the_file_in the parent.php) \n\n\nand every other suggestion I could find here for the last two days.\n\nI keep getting the same error in the CLI:\n\nPHP Warning: require_once($_SERVER[DOCUMENT_ROOT]/html/wp-load.php): failed to open stream: No su\nch file or directory in /var/www/html/wp-admin/email_processor.php on line 16\nPHP Fatal error: require_once(): Failed opening required '$_SERVER[DOCUMENT_ROOT]/html/wp-load.ph\np' (include_path='.:') in /var/www/html/wp-admin/email_processor.php on line 16\n\n\nAs with all thing computing, I have a sneaking suspicion this is ridiculously simple...that’s why it is taking so long to get it sorted.\n\nAny assistance would be greatly appreciated."
] | [
"php",
"wordpress",
"command-line"
] |
[
"Is there a way to label each wedge of pie chart in this grid?",
"I want to have multiple pie charts in a grid.\nEach pie chart will have a different number of wedges, values, and labels.\nThe code below shows multiple labels in one pie chart.\nIs there a way to label each wedge of pie-charts in this grid?\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ndef heatmap_with_circles(data_array,row_labels,column_labels,ax=None, cmap=None, norm=None, cbar_kw={}, cbarlabel="", **kwargs):\n\n for row_index, row in enumerate(row_labels,0):\n for column_index, column in enumerate(column_labels,0):\n print('row_index: %d column_index: %d' %(row_index,column_index))\n if row_index==0 and column_index==0:\n colors=['indianred','orange','gray']\n values=[10,20,30]\n else:\n values=[45,20,38]\n colors=['pink','violet','green']\n\n wedges, text = plt.pie(values,labels=['0', '2', '3'],labeldistance = 0.25,colors=colors)\n print('len(wedges):%d wedges: %s, text: %s' %(len(wedges), wedges, text))\n radius = 0.45\n [w.set_center((column_index,row_index)) for w in wedges]\n [w.set_radius(radius) for w in wedges]\n\n # We want to show all ticks...\n ax.set_xticks(np.arange(data_array.shape[1]))\n ax.set_yticks(np.arange(data_array.shape[0]))\n\n fontsize=10\n ax.set_xticklabels(column_labels, fontsize=fontsize)\n ax.set_yticklabels(row_labels, fontsize=fontsize)\n\n #X axis labels at top\n ax.tick_params(top=True, bottom=False,labeltop=True, labelbottom=False,pad=5)\n plt.setp(ax.get_xticklabels(), rotation=55, ha="left", rotation_mode="anchor")\n\n # We want to show all ticks...\n ax.set_xticks(np.arange(data_array.shape[1]+1)-.5, minor=True)\n ax.set_yticks(np.arange(data_array.shape[0]+1)-.5, minor=True)\n\n ax.grid(which="minor", color="black", linestyle='-', linewidth=2)\n ax.tick_params(which="minor", bottom=False, left=False)\n\ndata_array=np.random.rand(3,4)\nrow_labels=['Row1', 'Row2', 'Row3']\ncolumn_labels=['Column1', 'Column2', 'Column3','Column4']\n\nfig, ax = plt.subplots(figsize=(1.9*len(column_labels),1.2*len(row_labels)))\nax.set_aspect(1.0)\nax.set_facecolor('white')\nheatmap_with_circles(data_array,row_labels,column_labels, ax=ax)\nplt.tight_layout()\nplt.show()\n\n\nAfter updating heatmap_with_circles\ndef heatmap_with_circles(data_array,row_labels,column_labels,ax=None, cmap=None, norm=None, cbar_kw={}, cbarlabel="", **kwargs):\n labels = ['x', 'y', 'z']\n\n for row_index, row in enumerate(row_labels,0):\n for column_index, column in enumerate(column_labels,0):\n print('row_index: %d column_index: %d' %(row_index,column_index))\n if row_index==0 and column_index==0:\n colors=['indianred','orange','gray']\n values=[10,20,30]\n else:\n values=[45,20,38]\n colors=['pink','violet','green']\n\n # wedges, texts = plt.pie(values,labels=['0', '2', '3'],labeldistance = 0.45,colors=colors)\n wedges, texts = plt.pie(values,labeldistance = 0.25,colors=colors)\n print('text:%s len(wedges):%d wedges: %s' %(texts, len(wedges), wedges))\n radius = 0.45\n [w.set_center((column_index,row_index)) for w in wedges]\n [w.set_radius(radius) for w in wedges]\n [text.set_position((text.get_position()[0]+column_index,text.get_position()[1]+row_index)) for text in texts]\n [text.set_text(labels[text_index]) for text_index, text in enumerate(texts,0)]\n\n\nI got the following image :)"
] | [
"matplotlib",
"label",
"pie-chart"
] |
[
"Specify custom temporary directory for ghc compiler",
"I am using ghc on my web server running Ubuntu 14.04 LTS. Due to some restrictions, I cannot provide write permissions to /tmp folder.\n\nThe ghc compiler is throwing this error after removing permissions to the /tmp folder\n\n/tmp/ghc12032_0: createDirectory: permission denied (Permission denied)\n\n\nIs there a way to provide a custom temporary directory for ghc? I didn't find any compiler flag which can help with that. I need to provide a custom directory every time I invoke ghc. Any help would be appreciated."
] | [
"haskell",
"ghc"
] |
[
"Use gem 'postgres-copy' to import csv file",
"currently, I want to import above 55,000 records into my database from a CSV file. This is the code that I am using:\n\nCSV.foreach(Rails.root.join('db/seeds/locations.csv'), headers: true) do |row|\n val = Location.find_or_initialize_by(code: row[0])\n val.name = row[1]\n val.ecc = row[2] || 'MISSING'\n val.created_by = User.find_by(name: 'anh')\n val.updated_by = User.find_by(name: 'anh')\n val.save!\nend\n\n\nHowever, it is too slow and I have just installed the gem 'postgres-copy'. I read the official documentation, and I believe I can use the class method copy_from to do the job, but if you read my current code, you can see that I am referring the data to the another table(association), and the documentation doesn't mention anything about association or validation. Therefore, I am wondering if there are any ways to solve it. This is the first time I use this gem. Thanks for reading."
] | [
"ruby-on-rails",
"postgresql",
"csv"
] |
[
"Not getting correct answer in Dynamic Programming problem \"Regular Expression II\"",
"I solved the CodeX - Regular Expression Match problem before solving the Regular Expression II problem. In the solution to the first problem, I created a 2d dynamic programming solution and I'm doing:\n\ndp[i][j] = dp[i-1][j-1]; if (B[i-1] == A[j-1]) || (B[i-1] == '?'), it means if characters match or there is '?' in pattern then we can take the answer without curr i-1 in B and curr j-1 in A,\ndp[i][j] = ( dp[i-1][j] || dp[i-1][j-1] || dp[i][j-1] ); if B[i-1]=='**', it means if you encounter with '*' you can take answer without considering i-1, j-1 or without considering i-1, or without considering j-1.\n\nThe code of 1st problem is:\nint Solution::isMatch(const string A, const string B) \n{\n int n=A.size();\n int m=B.size();\n vector<vector<bool>> dp(m+1,vector<bool>(n+1,false));\n \n int k=1;\n dp[0][0]=true;\n \n while(k<=m && B[k-1]=='*')\n {\n dp[k][0] = true;\n k++;\n }\n \n for(int i=1; i<=m; i++)\n {\n for(int j=1; j<=n; j++)\n {\n if( (B[i-1] == A[j-1]) || (B[i-1] == '?'))\n {\n dp[i][j] = dp[i-1][j-1];\n }\n else if(B[i-1]=='*')\n {\n dp[i][j] = ( dp[i-1][j] || dp[i-1][j-1] || dp[i][j-1] );\n }\n else\n {\n dp[i][j] = false;\n }\n }\n }\n return dp[m][n];\n}\n\nNow, I am thinking if we reverse both the strings we can use same approch for 2nd, but I am not getting correct answer.\nMy code of 2nd problem is:\nint Solution::isMatch(const string A, const string B) \n{\n int n = B.size();\n int m = A.size();\n \n vector<vector<bool>> dp(n+1, vector<bool>(m+1, false));\n \n int k = n-1;\n int x = 1;\n \n dp[0][0] = true;\n \n while(k>=0 && B[k] == '*')\n {\n dp[x][0] = true;\n k--;\n x++;\n }\n \n for(int i=1; i<=n; i++)\n {\n for(int j=1; j<=m; j++)\n {\n if( B[n-i]=='.' || (B[n-i]==A[m-j]) )\n {\n dp[i][j] = dp[i-1][j-1];\n }\n \n if(B[n-i] == '*')\n {\n dp[i][j] = (dp[i-1][j-1] || dp[i-1][j] || dp[i][j-1]);\n }\n }\n }\n\n return dp[n][m];\n}"
] | [
"algorithm",
"data-structures",
"dynamic-programming"
] |
[
"How can I fix \"the Enumeration constraint failed\"?",
"I've been following a Microsoft tutorial. on setting up AJAX-enabled WCF services and accessing them with a client. However, despite following the tutorial exactly, the result will not display as it is supposed to due to errors. Specifically, the errors state that the Enumeration constraint failed, rendering the \"name\" and \"contract\" attributes invalid.\n\nThe error appears to be originating from my Web.config file, as the error list only shows issues in that file. Below I have included the code from the file, as well as from the service I am trying to access.\n\n//The service model segment of the configuration file. \n<system.serviceModel>\n <behaviors>\n <endpointBehaviors>\n <behavior name=\"SandwichServices.Service1AspNetAjaxBehavior\">\n <enableWebScript />\n </behavior>\n <behavior name=\"SandwichServices.CostServiceAspNetAjaxBehavior\">\n <enableWebScript />\n </behavior>\n </endpointBehaviors>\n </behaviors>\n <serviceHostingEnvironment aspNetCompatibilityEnabled=\"true\"\n multipleSiteBindingsEnabled=\"true\" />\n <services>\n <service name=\"SandwichServices.CostService\">\n <endpoint address=\"\" behaviorConfiguration=\"SandwichServices.CostServiceAspNetAjaxBehavior\"\n binding=\"webHttpBinding\" contract=\"SandwichServices.CostService\" />\n </service>\n </services>\n </system.serviceModel>\n\n\n//The .svc.cs file for my service\nusing System.ServiceModel;\nusing System.ServiceModel.Activation;\n\nnamespace SandwichServices\n{\n [ServiceContract]\n [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]\n public class CostService\n {\n [OperationContract]\n public double CostOfSandwiches(int quantity)\n {\n return 1.25 * quantity;\n }\n }\n}\n\n\nThe following error messages appear in the Web.config file:\n\n\n The\n 'contract' attribute is invalid - The value\n 'SandwichServices.CostService' is invalid according to its datatype\n 'serviceContractType' - The Enumeration constraint failed.\" \"The\n 'name' attribute is invalid - The value 'SandwichServices.CostService'\n is invalid according to its datatype 'serviceNameType' - The\n Enumeration constraint failed."
] | [
"c#",
"wcf",
"service"
] |
[
"Extract Interface from .NET Framework Class Using Resharper",
"Recently, I've been having to wrap a lot of dot net framework classes for better unit test coverage. Instead of doing this by hand, I was wondering if there was a way to extract an interface from an existing system class in the dot net framework using a tool like Reshaper (or something similar). \n\nOnce I have the interface I dont mind implementing the concrete class myself. But it would be great if I could automatically generate the interface."
] | [
"c#",
".net",
"visual-studio-2013",
"resharper",
"resharper-8.0"
] |
[
"Using two databases in Laravel",
"I wish to hide critical server access information as Laravel recommended, so I have setup config/database.php and .env as below, but these couldn't connect each one. which line was wrong?\n\nLaravel version: 5.4\n\nconfig/database.php\n\n'connections' => [\n 'master_db' => [\n 'driver' => 'mysql',\n 'host' => env('DB_HOST_MASTER', '127.0.0.1'),\n 'port' => env('DB_PORT_MASTER', '3306'),\n 'database' => env('DB_DATABASE_MASTER'),\n 'username' => env('DB_USERNAME_MASTER'),\n 'password' => env('DB_PASSWORD_MASTER'),\n 'unix_socket' => env('DB_SOCKET_MASTER'),\n 'charset' => 'utf8mb4',\n 'collation' => 'utf8mb4_unicode_ci',\n 'prefix' => '',\n 'strict' => true,\n 'engine' => null,\n ],\n\n 'slave_db' => [\n 'driver' => 'mysql',\n 'host' => env('DB_HOST_SLAVE', '192.1.0.2'),\n 'port' => env('DB_PORT_SLAVE', '3306'),\n 'database' => env('DB_DATABASE_SLAVE'),\n 'username' => env('DB_USERNAME_SLAVE'),\n 'password' => env('DB_PASSWORD_SLAVE'),\n 'unix_socket' => env('DB_SOCKET_SLAVE'),\n 'charset' => 'latin1',\n 'collation' => 'latin1_general_ci',\n 'prefix' => '',\n 'strict' => true,\n 'engine' => null,\n ],\n]\n\n\n.env\n\nDB_CONNECTION=master_db\nDB_HOST_MASTER=127.0.0.1\nDB_PORT_MASTER=3306\nDB_DATABASE_MASTER=db_master\nDB_USERNAME_MASTER=user_master\nDB_PASSWORD_MASTER=passwordmaster\n\nDB_CONNECTION=slave_db\nDB_HOST_SLAVE=192.1.0.2\nDB_PORT_SLAVE=3307\nDB_DATABASE_SLAVE=db_slave\nDB_USERNAME_SLAVE=user_slave\nDB_PASSWORD_SLAVE=passwordslave"
] | [
"php",
"laravel"
] |
[
"Using LDA Model to Obtain Topic Weights for Out-Of-Sample Documents in Python",
"I am using LDA in Python (https://pypi.python.org/pypi/lda) to obtain topics for a set of documents. I am able to obtain the topics and their weights for the documents that I use to train the model. Is there a way to apply the model to documents that were not included when estimating LDA? For example, if I used documents 1-100 to estimate the topics, can I apply the model to documents 101-200 to obtain topic weights for these out-of-sample documents? Is this possible with the LDA python package I'm using?\n\nIf you click on the link I provide above, it gives an example of how to obtain the topic weights for the in-sample documents:\n\ndoc_topic = model.doc_topic_\nfor i in range(10):\n print doc_topic[i]\n\n\nIs there a similar function that will apply to out-of-sample documents?"
] | [
"python",
"lda"
] |
[
"How to use git after enabling 2FA without writing the token at each operation",
"I had to active 2 factor authentication on my github account and now when I'm doing a push (git push) I need to write my github name and the token generated by 2FA.\nIs there a way to avoid writing the token all the time?"
] | [
"github",
"github-actions",
"two-factor-authentication"
] |
[
"Webscraping in BeautifulSoup is returning an empty list",
"I am trying to web scrape a table from basketball reference and it returns an empty list. I was hoping someone could help me debug or explain why. The page has many tables but it is the Miscellaneous Stats section in particular. Thanks in advance!\nfrom bs4 import BeautifulSoup\nimport requests\nimport time\nimport pandas as pd\nimport matplotlib as plt\nimport numpy as np\n\nurl = 'https://www.basketball-reference.com/leagues/NBA_2020.html#all_misc_stats'\nres = requests.get(url)\n\nsoup = BeautifulSoup(res.content,'lxml')\n\nsoup.find('div', {'id':'div_misc_stats'})"
] | [
"python",
"web-scraping",
"beautifulsoup"
] |
[
"Dynamic ComboBox Datasource Form Load",
"I'm creating a dynamic combo box and adding to a form. I'm trying to fill the combo box with a DataSource from an ArrayList and then selecting an item in the combo box based off a value from a property.\n\nProblem is, the combo box items don't get bound until after the Form_Load event has finished and the form is visible. So the combo box is empty when I try to set the selected index of the combo box. See code for what I'm doing in detail, and refer to comments in code:\n\nDim cboValues As New ComboBox\ncboValues.Width = fieldControlWidth\ncboValues.DropDownStyle = ComboBoxStyle.DropDownList\n\ncboValues.Name = \"cboResult\"\n\nFor Each d As SystemTaskResult In [Enum].GetValues(GetType(SystemTaskResult))\n Dim cv As New ComboBoxDisplayValue(d.ToString, d)\n arrValues.Add(cv)\nNext\n\ncboValues.DataSource = arrValues\ncboValues.DisplayMember = \"Display\"\ncboValues.ValueMember = \"Value\"\n\nDim val As SystemTaskResult = DirectCast(p.GetValue(Me.Task, Nothing), SystemTaskResult)\n\n'Was trying to get this to work, but commented out to try the below\n'cboValues.SelectedIndex = cboValues.Items.IndexOf(New ComboBoxDisplayValue(val.ToString, val))\n\n'Then this doesn't work because the combo box hasn't updated it's DataSource yet, which is probably the reason for the above not working as well.\nFor i = 0 To cboValues.Items.Count - 1\n cboValues.SelectedIndex = i\n If cboValues.SelectedValue = val Then\n Exit For\n End If\nNext\n\nholdPanel.Controls.Add(cboValues)\n\n\nHow to select the right selected index for combo box without a hack (Load timer or something stupid like that)?"
] | [
"c#",
"vb.net",
"winforms",
"combobox"
] |
[
"ImportError: cannot import name 'read_pdf' from partially initialized module 'tabula' (most likely due to a circular import)",
"import tabula\nfrom tabula import read_pdf\ndata = read_pdf(r'C:\\Users\\MANIRATHNAM\\Downloads\\data.pdf', pages = '1')\ntabula.convert_into(r'C:\\Users\\MANIRATHNAM\\Downloads\\data.pdf', "test.csv", output_format = "csv", pages = '1')\nprint(data)"
] | [
"tabula-py"
] |
[
"Date difference between rows in R with certain conditions from a different column",
"The data frame has three columns. First column is Machine name with multiple machine numbers(M1, M2..), second column is about the type of test which is test 1 and finally test date indicates when the test was performed.\n\nBelow is the data frame for reference :-\n\nName Test Test_Date \n M1 Test1 10/16/2011\n M1 Test1 1/29/2012\n M1 Test1 1/29/2012\n M2 Test1 7/26/2011\n M2 Test1 7/26/2011\n M2 Test1 5/12/2012\n M2 Test1 5/12/2012\n M2 Test1 10/29/2013\n M3 Test1 9/28/2011\n M3 Test1 1/8/2012\n M3 Test1 9/16/2012\n M3 Test1 6/3/2013\n M3 Test1 7/11/2013\n M3 Test1 8/10/2013\n M3 Test1 9/13/2013\n\n\nThe idea is to create a new column named \"issue\"(Yes/No) which indicates if a machine undergoes two or more tests(Test1) within a 48 week-span.\nLooked through multiple resources for this solution, but couldn't find an appropriate one."
] | [
"r",
"date"
] |
[
"ffmpeg video editing command in milliseconds timestamp",
"I am editing a video with ffmpeg where I have to keep in view the timestamp further deep from seconds to milliseconds. I know such command : ffmpeg -i a.ogg -ss 00:01:02 -to 00:01:03 -c copy x2.ogg. This uses seconds, but I want down to milliseconds."
] | [
"ffmpeg",
"command",
"html5-video",
"milliseconds"
] |
[
"Install RPM package with Python Yum API with --downloadonly",
"I am trying to install/download an RPM package through the Yum API with Python. But I am not able to supply the --downloadonly option, it seems to be ignored by the install method.\n\nHere is my code so far:\n\nimport yum\n\nyb = yum.YumBase()\nargs = {\"name\":\"git\", \"downloadonly\": True}\nyb.install(**args)\nyb.processDeps()\nyb.buildTransaction()\nyb.processTransaction()\n\n\nThis will install the package on the system, but not honor the downloadonly option.\n\nWhat is the proper way of telling Yum to only download a package through the Python Yum API?"
] | [
"python",
"yum"
] |
[
"WPF Combobox display entity name in dropdown instead of DisplayMemberPath",
"I have the following combobox:\n\n<ComboBox Name=\"cbBonusType\" \n DisplayMemberPath=\"BonusTypeName\" \n SelectedValuePath=\"ID\" Width=\"150\" Margin=\"10,0,0,0\" \n SelectionChanged=\"cbBonusType_SelectionChanged\"/>\n\n\nWhen running:\nWhen selecting an item, the combobox shows exactly the right string.\nBut while the droppbox is open, the named displayed in the droppbox are all set to the name of the entity: \"CaSaMa.WPF.UI.Competiotion.BonusType\". \n\nWhy is that and how do I fix it?"
] | [
"wpf",
"combobox"
] |
[
"HTML incrementing voting system",
"I' m pretty new to html, I am trying to show a value on my webpage that increments when a button is pressed.\n\nHere is my code \n\n<script type =\"text/javascript\">\n var likesSD = 0;\n var dislikesSD= 0;\n</script>\n <button class=\"like\" onclick=\"likes++\">I like!</button>\n<script>document.write(likesSD);</script>\n\n\nThe value on the screen does not change when the button is pushed. Is there a way I can do that without using a database."
] | [
"javascript",
"html",
"javascript-events"
] |
[
"Refer to wrongly named images in Android app",
"Is there any possibility to refer to wrongly named images in Android? I have bunch of images that have wrong names, for example IMG123456.jpg (u. c.), 1_img.jpg (number first) etc. It would be really hard to rename them all, cause I have JSON file that I load and there are also these names. \n\nSo my questions are:\n\n\nIs it possible to store these image files anywhere?\nIs it possible to refer to these images with Glide library?"
] | [
"android",
"android-glide"
] |
[
"Zend Framework single page form dealing with many to many relationships",
"I have a database that has a scenario where there is a many to many relationship between two tables (with a third 'associative' table between them):\n\nEg:\n\nTable 1 : user (primary key id)\nTable 2 : contact_info (primary key id)\nAssociative table: user_has_contact_info (primary key id, foreign keys: user_id and contact_info_id)\n\n\nNow the requirements for the application are to be able to add multiple 'contact_info' entries on the same page as creating a user record:\n\nEg: (Form)\n\nUserName: ___________\n\nContact Type Contact Detail\nPhone 123-4567\nEmail [email protected]\n\n_________V _______________ [Add Contact Button]\n\n... plus more fields for the user table ...\n\n\nSo in my example above, I have the username field (which would go in the user table), a table of all contact information records that relate to the user (in the username field), that would go into the contact_info table, and then the form elements for contact_type and contact_details (under their respective columns below the table) (with an add button?) which would add the contact information to the contact 'table'. Then below all that, more fields that belong to the user table.\n\nIf you are following me so far, the problem I am facing is the client wants this to show on a single form not multi page or separated in two forms, the flow must 'look' like a single form (even though the elements will belong to different database tables.\n\nSecond, it is simple enough to have the data put into the contact_info table, however there is no actual user_id generated until the rest of the 'user' fields are filled out and the user record is updated, and therefore, I am failing to see how to add the associative record in user_has_contact_info, without saving the user record first and adding the contact info second.\n\nFinally, the preference is to avoid javascript (though not completely ruled out, because pretty much any solution is going to require either javascript -or- page refreshes with partial form field data retention and possibly even validation and filter issues -- have not gotten that far yet)\n\nSo my ultimate question is, what is the best way to handle many-to-many database table relationships using Zend_Form in the scenario above. I might be overthinking this problem and missing the simple solution here, and look forward to different perspectives.\n\nPlease note, this is not a question about how to design the database, rather how to create the zend form to handle the database the way it is designed."
] | [
"mysql",
"forms",
"zend-framework",
"many-to-many"
] |
[
"Bitmap size appears different in different android device",
"Hello I am trying to set the image in the ImageView but after setting the image it is appearing different in size on different android device.\n\nSony Z Experia 4.3\n\n\n\nSamsung Y Dous 2.3 where it covered the entire image to the screen width\n\n\n\nHere is layout\n\n<ImageView\n android:id=\"@+id/logo\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"match_parent\"\n android:padding=\"5dip\"\n android:scaleType=\"fitStart\" />\n\n\nHow can I make such that it appear same as Sony Z Xperia. Any idea ?\n\nThanks in advance"
] | [
"android",
"android-layout"
] |
[
"Text from one textbox to another using JavaScript",
"I have a textbox as\n\n @Html.TextBoxFor(m => m.SingleUnitBarcode, new { @class = \"form-control\",@id=\"barcode1\", onblur = \"CloneData\" })\n\n\nAnd on losing focus from this textbox I want the text in it to be displayed in another textbox(with id =customerbarcode_field)\n\nI am using the javascript\n\n<script>\n function CloneData() { \n var value = document.getElementById(\"#barcode1\").value\n\n document.getElementById(\"#customerbarcode_field\").value = value;\n }\n</script>\n\n\nHowever the function is not being triggered when I lose focus from the first textbox.\n\nWhat did i miss ?"
] | [
"javascript",
"c#",
"asp.net-mvc",
"asp.net-mvc-4",
"textbox"
] |
[
"How to change background-color of an li tag with hover?",
"What's the best way to change the background-color of an li tag with onMouseOver?\nI tried it this way, but it won't work:\n\nCode generating the HTML:\n\necho \"<a href=\".$obj_players->Page.\" target=_parent>\n <li style=\\\"background-color:#FFFFFF;\\\"><span class=\\\"left\\\">\" . $obj_players->Name . \"</span><span class=\\\"right\\\">\" . $obj_players->Viewers . \"</span></li></a>\";\n\n\nCSS:\n\n#navlist li:hover {\n background-color:#2EA620;\n}\n\n#navlist li {\n width:175px;\n height:30px;\n text-align:center;\n line-height:30px;\n font:\"Myriad Pro\";\n font-size:14px;\n padding-left:10px;\n padding-right:10px;\n border-bottom:1px solid;\n border-color:#333;\n}\n\n\nExplanation: I have to declara the background color in the li tag because I have different li elements with different background colors. And li's are in a div with ID navlist.\n\nI also have the problem that I don't want every li to change background color with onmouseover, but I will solve this later, since I think I should be able to manage it on my own."
] | [
"html",
"css"
] |
[
"Is there a way to select data from one column in SQL table to get table with multiple columns?",
"So I have two SQL tables: one with id and in the other is meta value and meta_key. I joined them so it looks something like this:\n+------+------------+----------+\n| id | meta_value | meta_key |\n+------+------------+----------+\n| 1544 | product1 | 1 |\n| 1544 | 2 | 2 |\n| 1545 | product2 | 1 |\n| 1545 | 5 | 2 |\n| 1546 | product3 | 1 |\n| 1546 | 10 | 2 |\n+------+------------+----------+\n\nAnd I want to get a query that would show me a table like this:\n+------+------------+------------+\n| id | meta_value | meta_value |\n+------+------------+------------+\n| 1544 | product1 | 2 |\n| 1545 | product2 | 5 |\n| 1546 | product3 | 10 |\n+------+------------+------------+\n\nThe SQL query for first table looks like this:\nSELECT\n wprq_gf_entry.id,\n wprq_gf_entry_meta.meta_value,\n wprq_gf_entry_meta.meta_key \nFROM\n wprq_gf_entry \n INNER JOIN wprq_gf_entry_meta ON wprq_gf_entry.id = wprq_gf_entry_meta.entry_id \nWHERE\n wprq_gf_entry_meta.form_id = 6\n\nIs there a way to do this? ... Thank you!"
] | [
"mysql",
"sql"
] |
[
"PHP Spintax return array with all possibilities",
"I have a string: {Hello|Howdy|Hola} to you, {Mr.|Mrs.|Ms.} {Smith|Williams|Austin}!\n\nI wonder if someone can help me out with a function that will return an array with all the possibilities ? Or at least provide the logic on how to get them and what PHP functions to use ?\n\nThank you"
] | [
"php",
"spintax"
] |
[
"the record bigger than max_allowed_packet in migration",
"I have got a problem while making migration for sql server database to mysql via mysql workbench tells me the record is bigger than the (max_allowed_packet) .. I have increased the max_allowed_packet in my.ini file for phpmyadmin and workbench to (1G) and by writing the query :\nset global max_allowed_packet=1000000000\n\nbut I still have the same problem while migrating .. I have tried to restart xampp\nbut nothing happened .\n\nplease can you help me ."
] | [
"mysql",
"sql-server",
"migration"
] |
[
"Using google spreadsheets with mit2 app inventor",
"I want to use google spreadsheet with android. I Tried example program. I created new datasheet. I used example script code. I tried mit2 app program. This program is example program. I also used postman.\nPostman show me error.\nPostman error page.Postman connection error status 200 OK.\nPostman error message is:\n\n <!DOCTYPE html>\n <html>\n <head>\n <link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico">\n <title>ERROR</title>\n <style type="text/css" nonce="B6c+P2HTW+vClzlpE+anwg">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style>\n </head>\n <body style="margin:20px">\n <div>\n <img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png">\n </div>\n <div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">TypeError: Cannot read property &#39;getSheets&#39; of null (line: 15, file: &quot;denandroid&quot;)</div>\n </body>\n </html>\n\n\nscript code is :\n\n function doGet(e) {\n\n return ManageSheet(e);\n}\n\nfunction doPost(e) {\n return ManageSheet(e);\n}\n\n\nfunction ManageSheet(e) {\n\n //READ ALL RECORDS\n if ( e.parameter.func == "ReadAll") {\n var ss = SpreadsheetApp.getActive();\n var sh = ss.getSheets()[0]; // Postman problem line. \n var rg = sh.getDataRange().getValues(); \n var outString = '';\n for(var row=0 ; row<rg.length ; ++row){\n outString += rg[row].join(',') + '\\n'; \n }\n return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);\n }\n\n //DELETE SINGLE RECORD\n else if (e.parameter.func == "Delete") {\n var record = e.parameter.id;\n var ss = SpreadsheetApp.getActive();\n //var ss = SpreadsheetApp.openById(e.parameter.ID);\n var sh = ss.getSheets()[0];\n //var sh = ss.getSheetByName(e.parameter.SH);\n sh.deleteRow(parseInt(record) + 1); //makes the correct row to delete (because of header row)\n return ContentService.createTextOutput("Success, requested action completed");\n \n}\n \n}\n\n\npostman says problem line in script code line 15. ( var sh = ss.getSheets()[0]; // Postman problem line)\nAlso I am using turkish language on google sheets. english name Sheet1 turkish language Sayfa1\nI tried both names.\nbut unsuccess.\nI am using this line for the connection spreadsheet.\nhttps://script.google.com/macros/s/AKfycbyTt9oaz10WuKh0822hBncRoJZAw-D4hcGMwJwdy95l8H_mXfE/exec?ID=18NFZD7vZ-JySbbV7jiZMBpiBsoLJ4IQge9Wk9cL6Z4c&SH=Sheet1&func=ReadAll\nPlease help.\nThanks"
] | [
"google-sheets"
] |
[
"Why annotation based libraries are not so popular in Scala?",
"When I write Java code, I found annotation based libraries are very popular, e.g. hibernate, Jackson, Gson, Spring-MVC. But in Scala, most of the popular libraries are not providing annotations, or provided but recommend non-annotation approaches, e.g. squerly, slick, argonaut, unfiltered, etc.\n\nSometimes, I found the annotations are easier to read and maintain, but why people are not so interested in them?"
] | [
"scala",
"annotations"
] |
[
"C++ hierarchy print exercise",
"I'm learning C++ and I have a question about this exercise.\n\n#include<iostream>\nusing namespace std;\n\nclass B {\n public:\n int x;\n B(int z=1): x(z) {}\n};\n\nclass D: public B {\n public:\n int y;\n D(int z=5): B(z-2), y(z) {}\n};\n\nvoid fun(B* a, int size) {\n for(int i=0; i<size; ++i) cout << (*(a+i)).x << \" \";\n}\n\nint main(){\n fun(new D[4],4); cout << \"**1\\n\";\n B* b = new D[4]; fun(b,4); cout << \"**2\\n\";\n b[0] = D(6); b[1] = D(9); fun(b,4); cout << \"**3\\n\";\n b = new B[4]; b[0] = D(6); b[1] = D(9);\n fun(b,4); cout << \"**4\\n\";\n} \n\n\nIt prints:\n\n3 5 3 5 **1\n3 5 3 5 **2\n4 7 3 5 **3\n4 7 1 1 **4\n\n\nWhy before the **1 and before **2, it prints 3 5 3 5? I thought 3 3 3 3.\nBefore the **3 I thought 5 7 3 3, and before **4 I thought 4 7 3 3.\nCould you help me to better understand why it prints that way?\n\nThanks in advance!"
] | [
"c++",
"function",
"hierarchy"
] |
[
"Script piped into bash fails to expand globs during rm command",
"I am writing a script with the intention of being able to download and run it from anywhere, like:\nbash <(curl -s https://raw.githubusercontent.com/path/to/script.sh)\n\nThe command above allows me to download the script, run interactive commands (e.g. read), and - for the most part - Just Works. I have run into an issue during the cleanup portion of my script, however, and haven't been able to discern a fix\nDuring cleanup I need to remove several .bkp files created by the script's execution. To do so I run rm -f **/*.bkp inside the script. When a local copy of the script is run, this works great! When run via bash/curl, however, it removes nothing. I believe this has something to do with a failure to expand the glob as a result of the way I've connected the I/O of bash and curl, but have been unable to find a way to get everything to play nice\nHow can I meet all of the following requirements?\n\nDownload and run a script from a remote resource\nEnsure that the user's keyboard input is connected for use in e.g. read calls within the script\nCorrectly expand the glob passed to rm\nBonus points: colorize input with e.g. echo -e "\\x1b[31mSome error text here\\x1b[0m" (also not working, suspected to be related to the same bash/curl I/O issues)"
] | [
"bash",
"io",
"pipe"
] |
[
"Window resize and init run together",
"I know I read something about this somewhere around here, or maybe I'm wrong, but is there a way to say for example call a function, or run a code, both on init and on window resize, from one line?\nWhat I mean, instead of this:\n\nif (somecondition){\n console.logo('runs on init');\n};\n$(window).resize(function(){ \n if (somecondition){\n console.logo('same condition runs on resize');\n };\n};)\n\n\nCan be written somehow like this:\n\nwindow(init,resize){\n if (somecondition){\n console.logo('runs both on init and resize');\n };\n}\n\n\nDont know if this is at all possible, or even exists, was asking because it really gets annoying keeping a large chunk of code duplicating it all over the place, on init and on resize.\n\nThanks!"
] | [
"javascript"
] |
[
"Unable to print an array of numbers in ascending order when the list is generated",
"My code generates a matrix of numbers when the Ok symbol is selected. But, I want to add a sorting functionality to relist the matrix in an ascending order when the \"By result\" button is selected. Any suggestions on how I can do it ? \n\nHTML Code\n\n<div class=\"rightDiv\">\n<div id = \"pastcalcblock\"> \n <h3> PAST CALCULATIONS </h3>\n <input type = \"text\" size = \"1\" id = \"text1\"/>\n <input type = \"text\" size = \"1\" id = \"text2\"/>\n <input type = \"text\" size = \"1\" id = \"text3\"/>\n <input type = \"text\" size = \"1\" id = \"text4\"/><br>\n <input type = \"button\" value = \"Ok\" id = \"operation\" onClick = \"display()\"/>\n <div id = \"resultTab\">\n SORT<br>\n <input type = \"button\" value = \"As Entered\" id = \"enteredBut\">\n <input type = \"button\" value = \"By Result\" id = \"resultBut\" onClick() = \"sortDisplay()\"><br><br>\n <div id=\"expressions\">\n </div> \n </div>\n </div>\n\n\nJavascript Code\n\nfunction display()\n{\n var arrayOne =[document.getElementById('text1').value,document.getElementById('text2').value,document.getElementById('text3').value,document.getElementById('text4').value ];\n\n new_array=arrayOne.join(\" \");\n var para = document.createElement(\"p\");\n var t = document.createTextNode(new_array);\n para.appendChild(t)\n document.getElementById(\"expressions\").appendChild(para);\n\n}\n\nfunction sortDisplay()\n{\n function doSort() {\n var container = document.getElementById(\"expressions\");\n var elements = container.childNodes;\n var sortMe = [];\n for (var i=0; i<elements.length; i++) {\n\n\n }\n\n}"
] | [
"javascript",
"arrays",
"sorting",
"multidimensional-array"
] |
[
"rubymine error: You have already activated rake 10.0.3, but your Gemfile requires rake 0.9.6. Using bundle exec may solve this",
"When I run rspec from my rubymine editor,I get this error:\n\nYou have already activated rake 10.0.3, but your Gemfile requires rake 0.9.6. Using bundle exec may solve this.\n\n\nI also tried this:\n\ngem uninstall rake -v 10.0.3\n\n\nBut I get the following message:\n\nINFO: gem \"rake\" is not installed\n\n\nbundle update rake fixes the issue for the command line.\n\nBut I still get the \"already activated rake error\" when i run rspec through command line.\nI am not sure how to resolve this. I want to run 0.9.6\nDo i have to update the gem file. I cannot update it and push it to remote repo because this is a shared repo everybody will be using."
] | [
"ruby-on-rails",
"ruby-on-rails-3",
"ruby-on-rails-3.1",
"rubygems",
"rubymine"
] |
[
"Spring MVC Test In Fitnesse",
"I have a probleme with Fitnesse Integration with Spring MVC . \n\nMy use case to test is the authentication : \n\nI have a generic Fixture that load spring Context : \n\npublic abstract class GenericSpringFixture extends GenericBelFixture {\n\nprotected static AutowireCapableBeanFactory beanFactory;\nprotected static ClassPathXmlApplicationContext context;\n\nstatic {\n initSpring();\n}\n\npublic static void initSpring() {\n if ((context == null) || !context.isActive()) {\n context = new ClassPathXmlApplicationContext(\"classpath:spring/applicationContext-fitnesse-common.xml\");\n beanFactory = context.getAutowireCapableBeanFactory();\n }\n}\n\npublic GenericSpringFixture() {\n beanFactory.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);\n}\n\npublic static AutowireCapableBeanFactory returnBeanFactory() {\n return beanFactory;\n}\n}\n\n\nThe applicationContext-fitnesse-common.xml file is loading all dependencies of My plateform and this include my servlet(Spring Mvc Files) config . \n\nMy fixture code is : \n\npublic class IdentificationUtilisateur extends GenericSpringFixture{\n\n@Autowired\nprivate WebApplicationContext webApplicationContext;\n\n@Autowired\nprivate FilterChainProxy springSecurityFilterChain;\n\nprivate MockMvc mockMvc;\n\npublic void seLogerAvecIdentifiantEtMotDePasse(String identifiant,\n String motDePasse) {\n this.mockMvc = MockMvcBuilders\n .webAppContextSetup(this.webApplicationContext)\n .addFilters(this.springSecurityFilterChain).build();\n}\n\npublic void accesReussi() throws Exception{\n mockMvc.perform(\n post(\"/j_spring_security_check\")\n .param(\"j_username\", \"bilal\")\n .param(\"j_password\", \"Pa1234567\"));\n}\n}\n\n\nThe problem is that spring is not able to find any webApplicationContext . \n\n\n org.springframework.beans.factory.BeanCreationException: Error\n creating bean with name\n 'ma.awb.ebk.bel.web.fixture.authentication.IdentificationUtilisateur':\n Injection of autowired dependencies failed; nested exception is\n org.springframework.beans.factory.BeanCreationException: Could not\n autowire field: private\n org.springframework.web.context.WebApplicationContext\n ma.awb.ebk.bel.web.fixture.authentication.IdentificationUtilisateur.webApplicationContext;\n nested exception is\n org.springframework.beans.factory.NoSuchBeanDefinitionException: No\n qualifying bean of type\n [org.springframework.web.context.WebApplicationContext] found for\n dependency: expected at least 1 bean which qualifies as autowire\n candidate for this dependency. Dependency annotations:\n {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n\n\nThe only difference between My Slim fixture and my test Spring mvc is that in my test MVC , i am on a junit context and i have this annotation enabled on my Junit test : \n\n@WebAppConfiguration\n\n\nThanks for your Help ."
] | [
"spring",
"spring-mvc",
"fitnesse",
"spring-mvc-test"
] |
[
"Gradle sync failed: Could not initialize class org.jetbrains.kotlin.gradle.internal.KotlinSourceSetProviderImplKt",
"21:10 Gradle sync failed: Could not initialize class org.jetbrains.kotlin.gradle.internal.KotlinSourceSetProviderImplKt\n Consult IDE log for more details (Help | Show Log) (7s 78ms)\n\n\nhi guys, i've tried to invalidate cache and restart,sync project with gradle and file system,update latest stable kotlin, create new project and let the android studio download all update and still got this same error. can anyone help me ? sorry im really new in android stuff\n\nthis is my= app/build.gradle\n\napply plugin: 'com.android.application'\n\napply plugin: 'kotlin-android'\n\napply plugin: 'kotlin-android-extensions'\n\nandroid {\n compileSdkVersion 29\n defaultConfig {\n applicationId \"com.asusx.rogmode.rog\"\n minSdkVersion 27\n targetSdkVersion 29\n versionCode 1\n versionName \"1.0\"\n testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n }\n buildTypes {\n release {\n minifyEnabled false\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n }\n }\n}\n\ndependencies {\n implementation fileTree(dir: 'libs', include: ['*.jar'])\n implementation\"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version\"\n implementation 'com.android.support:appcompat-v7:29'\n implementation 'com.android.support.constraint:constraint-layout:1.1.3'\n testImplementation 'junit:junit:4.12'\n androidTestImplementation 'com.android.support.test:runner:1.0.2'\n androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'\n}\n\n\ngradle-wrapper.properties\n\n#Wed Jun 10 20:24:06 ICT 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-6.1.1-all.zip\n\n\nbuild.gradle\n\n// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n ext.kotlin_version = '1.2.30'\n repositories {\n google()\n jcenter()\n }\n dependencies {\n classpath 'com.android.tools.build:gradle:4.0.0'\n classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n\n // NOTE: Do not place your application dependencies here; they belong\n // in the individual module build.gradle files\n }\n}\n\nallprojects {\n repositories {\n google()\n jcenter()\n }\n}\n\ntask clean(type: Delete) {\n delete rootProject.buildDir\n}"
] | [
"android",
"android-studio",
"kotlin",
"gradle"
] |
[
"multiple bootstrap buttons not smoothly hover over",
"I have multiple bootstrap buttons, and their size gets bigger on hover over, but if I hover over them one after another, it is not smooth.\nHere is the jsfiddle.\n\nol, ul {\n margin-top: 13px;\n margin-bottom: 16px;\n}\nul#mylist li {\n display:inline;\n text-align:center;\n}\nul#mylist li i {\n display: block;\n}\n\nul#mylist li:last-child {\n margin-right: 0;\n}\n\n\nHow can I make it hover over smoothly like a wave?"
] | [
"javascript",
"jquery",
"html",
"css",
"twitter-bootstrap"
] |
[
"Mongoose userModel is not defined",
"I'm pretty new with nodejs and mongoDB. I have created a registration and user schema but it doesn't recognize this and send the following error:\n\n\n ReferenceError: userModel is not defined\n\n\nWhen I trace the error, I found that it doesn't recognize this keyword. \n\nHere is user.js code:\n\nvar mongoose = require('mongoose');\nvar Schema = mongoose.Schema;\n\nvar bcrypt = require('bcrypt');\n\nvar userSchema = new Schema({\n teamName: {\n type: String,\n unique: true,\n trim: true,\n required: true\n },\n faculty: {\n type: String,\n required: true\n },\n email: {\n required: true,\n unique: true,\n trim: true,\n type: String\n },\n password: {\n required: true,\n type: String\n },\n score: {\n type: Number,\n default: 0\n }\n});\n\nuserSchema.pre('save', function(next) {\n var user = this;\n bcrypt.hash(user.password, 10, (err, hash) => {\n if (err) return next(err)\n user.password = hash;\n next();\n });\n})\n\nvar userModel = mongoose.model('User', userSchema);\nmodule.exports = userModel;\n\n\nserver.js \n\nrouter.post('/register', (req, res) => {\n var newUser = {\n teamName: req.body.teamName,\n faculty: req.body.faculty,\n email: req.body.email,\n password: req.body.password\n }\n userModel.create(newUser, (err, user) => {\n if (err) {\n console.log('[Registratoin]: ' + err);\n } else {\n console.log(user)\n console.log('[Registration]: Done');\n // req.session.userID = user._id;\n res.redirect('/scoreboard')\n }\n });\n});"
] | [
"node.js",
"mongoose"
] |
[
"use `QNetworkAccessManager` post request",
"i use QNetworkAccessManager post request to a website:\n\n void Spider::getProducts()\n {\n connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(getProducts(QNetworkReply*)));\n\n request.setHeader(QNetworkRequest::ContentTypeHeader, \"application/x-www-form-urlencoded\");\n\n request.setUrl(QUrl(\"http://www.example.com/query\"));\n\n for(int i = 0; i < categories.size(); ++i)\n {\n if(categories[i].isCategory())\n {\n isSubCategory = false;\n\n emit manager.finished(reply);\n }\n else\n {\n for(int page_number = 0; page_number < categories[i].getPageCount(); ++i)\n {\n isSubCategory = true;\n\n QJsonObject json;\n\n json.insert(\"NValue\", categories[i].getNValue());\n json.insert(\"NodeId\", categories[i].getNodeId());\n json.insert(\"StoreId\", categories[i].getStoreId());\n json.insert(\"StoreType\", categories[i].getStoreType());\n json.insert(\"PageNumber\", ++page_number);\n json.insert(\"SubCategoryId\", categories[i].getSubCategoryId());\n\n QJsonDocument doc;\n\n doc.setObject(json);\n\n QByteArray request_body = doc.toJson();\n\n manager.post(request, request_body);\n }\n }\n }\n }\n\n\nwhen i run this program, at beginning, this program run normally, after running for a while, it will stop: neither terminated nor continue to run. i can not figure out why it behavior like this? is there anything that needed to be noticed when use QNetworkAccess? or i am refused by that website? ..."
] | [
"qt",
"network-programming"
] |
[
"VB ActiveX User Control fails to install on Windows 8 using IE10 with Code Download Error: (hr = 80070005) Access is denied",
"I have a VB VS2008 (.Net 2.0) ‘pure’ .NET based user control which used to be hosted in Internet Explorer.\nBecause that approach is no longer possible in VS2013 (.Net 4.5) I have converted it to an VB ActiveX user control.\nThis process involves digitally signing the user control DLL.\nCreating a setup project resulting in a setup.exe and MyUserControl.msi.\nDigitally signing both those components and then producing a cab file (which again is digitally signed).\nIE10 should then be able to install this using an object tag as follows\n\n\nIf I use the setup.exe and MyUserControl.msi directly on the client windows 8 machine before starting IE10 then the control is already installed (shows up in Programs and Features) and it works.\n\nIf I don't do this and let IE install the control then it doesn't work.\n\nWhat I see is the IE prompt \n\nThis website wants to install the following add-on: 'MyUserControl.cab'\n\nClicking on install produces the User Account Control MsgBox\n\nDo you want to allow the following program to make changes to this computer\n\nClicking yes doesn't install the control as expected"
] | [
".net",
"windows",
"activex",
"internet-explorer-10"
] |
[
"Explicit port number in HTTP Host header for AWS instance",
"I'm trying to send an HTTP request from my device to an AWS instance(with a load balancer), and it looks like it is not able to work without explicitly adding the port number (default - 443) to the Host header. I get a curt 400 BAD_REQUEST message. Per my understanding, if the port is the default, it is not required to be appended to the header. But clearly that is failing in my case. However, curl can send an identical request successfully to the same server. Upon monitoring the header, it does not have the port appended. I am not sure what might be causing this error on my device when my request is the same. Any ideas?"
] | [
"amazon-web-services",
"http",
"amazon-ec2",
"aws-load-balancer"
] |
[
"How to split a string into 2D array and apply operator to array element in rails 3.2?",
"Here is the string we have:\n\nstring = 'project_manager, foreman, buyer'\n\n\nWe would like to convert it into a 2D array like this:\n\n[[I18n.t('project_manager'), 'project_manager'], [I18n.t('foreman'), 'foreman'], [I18n.t('buyer'), 'buyer']]\n\nThe 2D array will be fed into rails view and create a drop-down list for selection. The I18n.t() is for translation of the word if language other than English is specified. \n\nMany thanks!"
] | [
"ruby-on-rails",
"ruby",
"arrays"
] |
[
"Fragment, RecyclerView: No adapter attached; skipping layout",
"I am using a Fragment to view a RecyclerView. But I always get this error \n\n\n E/RecyclerView: No adapter attached; skipping layout\n\n\nI have created an adapter for my recyclerview but the layout does not display. The php backend is working fine. Can somebody please help. Here are my codes for the fragment and adapter\n\nTips.java\n\npublic class Tips extends Fragment {\n\nConfiguration config = new Configuration();\nString HttpUrl = config.viewtips_url;\nList<TipModel> tipList;\nRecyclerView recyclerView;\n\n@Override\npublic View onCreateView(LayoutInflater inflater, ViewGroup container,\n Bundle savedInstanceState) {\n // Inflate the layout for this fragment\n View view = inflater.inflate(R.layout.fragment_tips, container, false);\n recyclerView = view.findViewById(R.id.recyclerView);\n recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));\n tipList = new ArrayList<>();\n loadTips();\n return view;\n}\n\nprivate void loadTips() {\n StringRequest stringRequest = new StringRequest(Request.Method.GET, HttpUrl,\n new Response.Listener<String>() {\n @Override\n public void onResponse(String response) {\n try {\n JSONArray jsonArray = new JSONArray(response);\n for (int i = 0; i < jsonArray.length(); i++) {\n JSONObject jsonObject = jsonArray.getJSONObject(i);\n tipList.add(new TipModel(\n jsonObject.getInt(\"id\"),\n jsonObject.getString(\"tip\")\n\n ));\n }\n TipAdapter tipAdapter = new TipAdapter(getActivity(), tipList);\n recyclerView.setAdapter(tipAdapter);\n } catch (JSONException e) {\n e.printStackTrace();\n }\n }\n },\n new Response.ErrorListener() {\n @Override\n public void onErrorResponse(VolleyError error) {\n\n }\n });\n Volley.newRequestQueue(getActivity()).add(stringRequest);\n}\n\n\nTipAdapter.java\n\npublic class TipAdapter extends RecyclerView.Adapter<TipAdapter.TipViewHolder> {\n\nprivate Context context;\nprivate List<TipModel> tipList;\n\npublic TipAdapter(Context context, List<TipModel> tipList) {\n this.context = context;\n this.tipList = tipList;\n}\n\n@Override\npublic TipViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {\n LayoutInflater inflater = LayoutInflater.from(context);\n View view = inflater.inflate(R.layout.itemlayout, null);\n return new TipViewHolder(view);\n}\n\n@Override\npublic void onBindViewHolder(TipViewHolder holder, int position) {\n TipModel tipModel = tipList.get(position);\n\n\n holder.textViewTip.setText(tipModel.getTip());\n\n}\n\n@Override\npublic int getItemCount() {\n return tipList.size();\n}\n\nclass TipViewHolder extends RecyclerView.ViewHolder {\n TextView textViewTip;\n\n public TipViewHolder(View view) {\n super(view);\n textViewTip = view.findViewById(R.id.textViewTip);\n }\n}"
] | [
"android",
"android-recyclerview"
] |
[
"How do I match records which have a certain entry IN their rdfs:label attribute?",
"I'm trying to query dbpedia for programming languages like D by name:\n\nhttp://dbpedia.org/page/D_(programming_language)\n\nAnd I figure rdfs:label is a good way to do this. But I'm having trouble coming up with syntax for searching by labels containing \"D (programming language)\". In dpbedia, rdfs:labels aren't simply strings, they're more like lists. How do I filter for records that have a certain entry IN the rdfs:label?"
] | [
"list",
"contains",
"sparql"
] |
[
"How to combine AVG, IF and GROUP BY in a query",
"I have a relational db with 3 tables. The first one, Categories has the type of items of a store like veggies, meat, cheeses. The second one, Clients has all the clients that had bought in the store. The last one, Cart, has a relation with the client id, category id and the amount of money a client spent in the store. \n\nI need to print a report, using MySQL to know how much spent each client in a category. The report should look like\n\n+--------+---------+------+---------+\n| Client | Veggies | Meat | Cheeses |\n+--------+---------+------+---------+\n| Tom | 1000 | NULL | 1500 |\n| John | NULL | NULL | 2000 |\n| Alice | 1000 | 1000 | 1000 |\n+--------+---------+------+---------+\n\n\nRight now, I'm using the following query \n\nSELECT client.name AS Client, \n category.name AS Category, \n AVG(cart.subtotal) AS Total \n FROM cart \n INNER JOIN category ON category.id = cart.id_category \n INNER JOIN clients ON clients.id = cart.id_client \n GROUP BY cart.id_client,\n cart.id_category\n\n\nBut I get this: \n\n+--------+----------+-------+\n| Client | Category | Total |\n+--------+----------+-------+\n| Tom | Veggies | 1000 |\n| Tom | Cheeses | 1500 |\n| John | Cheeses | 2000 |\n| Alice | Veggies | 1000 |\n| Alice | Meat | 1000 |\n| Alice | Cheeses | 1000 |\n+--------+----------+-------+"
] | [
"mysql"
] |
[
"VB.NET DES Decryption going wrong",
"I'm trying to decrypt an encrypted string in a simple program I created in VB.NET but it seems like the Decryption Part isn't working properly.\n\nHere's my code:\n\nImports System.Security.Cryptography\n\n Module Module1\n Dim data As String = \"1234567887654321\"\n Dim key As String = \"1111222233334444\"\n Dim output As String\n Dim bData() As Byte\n Dim bKey() As Byte\n Dim bEncrypted(7) As Byte\n Dim bDecrypted(7) As Byte\n Dim nullIV(7) As Byte\n Dim desprovider As New DESCryptoServiceProvider()\n\n Sub Main()\n bData = HexStringToBytes(data)\n bKey = HexStringToBytes(key)\n Console.WriteLine(\"Data: \" + data)\n Console.WriteLine(\"Key: \" + key)\n Encrypt()\n Console.WriteLine(\"Encryption Result :\" + GetHexString(bEncrypted))\n Decrypt()\n Console.WriteLine(\"Decryption Result :\" + GetHexString(bDecrypted))\n Console.ReadLine()\n End Sub\n\n Private Function GetHexString(ByVal bytes() As Byte, Optional ByVal len As Integer = -1, Optional ByVal spaces As Boolean = False) As String\n If len = -1 Then len = bytes.Length\n Dim i As Integer\n Dim s As String = \"\"\n For i = 0 To len - 1\n s += bytes(i).ToString(\"x2\")\n If spaces Then s += \" \"\n Next\n If spaces Then s = s.TrimEnd()\n Return s\n End Function\n\n Function HexStringToBytes(ByVal hexstring As String) As Byte()\n Dim out((hexstring.Length / 2) - 1) As Byte\n For i = 0 To (hexstring.Length / 2) - 1\n out(i) = Convert.ToByte(hexstring.Substring(i * 2, 2), 16)\n Next\n Return out\n End Function\n\n Sub Encrypt()\n Dim icryptT As ICryptoTransform = desprovider.CreateEncryptor(bKey, nullIV)\n icryptT.TransformBlock(bData, 0, bData.Length, bEncrypted, 0)\n End Sub\n\n Sub Decrypt()\n Dim icryptT As ICryptoTransform = desprovider.CreateDecryptor(bKey, nullIV)\n icryptT.TransformBlock(bEncrypted, 0, bEncrypted.Length, bDecrypted, 0)\n End Sub\n\nEnd Module\n\n\nHere's the output:\n\nData: 1234567887654321\n\nKey: 1111222233334444\n\nEncryption Result :cb8304b91ce6f9a1\n\nDecryption Result :0000000000000000\n\nAs you can see in the output, the Encrypt() subroutine works just fine but it all goes wrong with the decryption part. The decryption is supposed to return my original data but it seems like there's nothing happening in the Decrypt() subroutine of the program."
] | [
"vb.net",
"encryption",
"des"
] |
[
"SSL certificate acceptable by browsers",
"I followed this tutorial to setup HTTPS on AWS Ubuntu LAMP. I needed it to create Facebook canvas app. When ever someone else tries to load that app they get Failed to load resource: net::ERR_INSECURE_RESPONSE error.\n\nApeearantly Chrome and Edge don't deem my certificate trustworthy. Why is it? Can it be because I misspelled some info or do certificates have to issued by a thrid party?"
] | [
"ubuntu",
"amazon-web-services",
"https",
"lamp"
] |
[
"How to create a Map from a List with and inner list using Kotlin",
"so I have data classes like this:\n\ndata class Item(val name: String)\ndata class Order(val id: Int, val items: List<Item>)\n\n\nand I have a list of Orders.\n\nmy question is, how can I create a map with Item name as key and list of Orders with that item as value using Kotlin's collections API?"
] | [
"kotlin"
] |
[
"SSH connection with password and certificate with Jenkins",
"In our servers, we configured 2 types of authentication to ssh conections. We need a user with password and ssh certificate (tipical id_rsa.key).\n\nWe use Jenkins, and i want connect to this servers with \"publish over ssh\" plugin, but i don't know the way to make this connection.\n\nI know that i can make this conection with a \"Send files or execute commands over ssh\", but i would prefer to use the plugin.\n\nAnyone knows a possible method?\n\nThanks for the help :D"
] | [
"ssh",
"jenkins",
"passwords",
"certificate"
] |
[
"why are variables initialized in data class",
"According to the official doc, this is the way to declare a data class\n\ndata class User(val name: String, val age: Int) \n\n\nbut most cases i see where data class is declared thus,\n\ndata class User(var username: String? = \"\", var email: String? = \"\", var age: Int = 0)\n\n\nexplanation from the docs: On the JVM, if the generated class needs to have a parameterless constructor, default values for all properties have to be specified\n\ni don't understand, and what are the implications of the different methods\n\n2ndly, what is the best way of writing a data class containing complex object variables such as, ArrayList, Bitmap, Uri"
] | [
"android",
"kotlin"
] |
[
"Reading lines of text in unknown encoding",
"I need to read a text file line by line, and apply to each of them several CharsetDecoders, in order. Actually, I first try to decode line as if it's an UTF8-encoded one, and fallback to one-byte charset if UTF8 CharsetDecoder raises MalformedInputException.\n\nHowever, if I use InputStreamReader with default or specified charset, readLine function silently replaces with '?' all the bytes it thinks are invalid for the specified charset.\n\nI finally ended up writing my own function for reading lines, that reads from a stream byte by byte, seeks for line terminators and constructs lines. But this way it appears terribly slow.\n\nIs there any way to make Java to read lines without touching bytes?\n\nUPDATE:\nI've found out that there are charsets in which all 256 bytes are valid, two of them line terminators.\nSo it is possible to read raw byte stream line by line.\nExamples of such charsets are:\n\nIBM00858\nIBM437\nIBM775\nIBM850\nIBM852\nIBM855\nIBM860\nIBM861\nIBM862\nIBM863\nIBM865\nIBM866\nISO-8859-1\nISO-8859-13\nISO-8859-15\nISO-8859-2\nISO-8859-4\nISO-8859-5\nISO-8859-9\nKOI8-R\nKOI8-U\nwindows-1256\n\nThe question is now closed."
] | [
"java",
"character-encoding",
"decoding"
] |
[
"Flex Compile Time Constants - Timestamp",
"I'm trying to use Flex Compile Time Constants to include the date and time the SWF was built (source control revision/timestamp such as SVN:Keywords is not sufficient for our needs, we need to know the actual build time, not the commit time).\n\nI've tried using actionscript (like the documentation suggests you should be able to):\n\n-define+=COMPILE::Timestamp,\"new Date()\"\n\n\nBut this gives \"The initializer for a configuration value must be a compile time constant\"\n\nI've tried getting it to drop to shell and use the date command (using various single and double quote configurations), for example:\n\n-define+=COMPILE::Timestamp,`date +%Y%m%d%H%M%S` \n\n\nI can only get it to work with simple strings and simple constant expressions (eg, I can do 4-2 and it'll be 2 at runtime. But I can't get it to do anything whose value wouldn't be explicitly known at the time I declare the define.\n\nHas anyone had any luck with something like this?"
] | [
"apache-flex",
"flex3",
"flexbuilder"
] |
[
"Why does Scala use a reversed shebang (!#) instead of just setting interpreter to scala",
"The scala documentation shows that the way to create a scala script is like this:\n\n#!/bin/sh\nexec scala \"$0\" \"$@\"\n!#\n/* Script here */\n\n\nI know that this executes scala with the name of the script file and the arguments passed to it, and that the scala command apparently knows to read a file that starts like this and ignore everything up to the reversed shebang !#\n\nMy question is: is there any reason why I should use this (rather verbose) format for a scala script, rather than just:\n\n#!/bin/env scala\n/* Script here */\n\n\nThis, as far a I can tell from a quick test, does exactly the same thing, but is less verbose."
] | [
"bash",
"scala",
"sh"
] |
[
"Content security policy + Form plugin",
"I'm posting this question without code as I don't have access to it atm but the web page concerned can be view here:\n\nhttp://sensing-precision.com/equipment-hire/\n\nI have content in link-able DIVs which are wrapped in a DIV with \n\ndisplay:none\n\n\nset so that the content isn't visible. I'm using jQuery script to enable loading of the hidden content into the target DIV:\n\nITarget\n\n\nMy problem is the enquiry form. I'm using a plugin called Ninja Forms on Wordpress and the form works fine. I've tested it prior to embedding it on this page. However, for some reason, placing it in this \"hidden\" content section and loading it via jQuery when clicking on the link \"Enquiry Form\" is causing an error. Click on the submit button to see what I mean.\n\nNow I recently set the Content Security Policies via the .htaccess file and I get the feeling I'm not setting something that I need to be setting.\n\nI've included the\n\n'self' 'unsafe-inline' and 'unsafe-eval'\n\n\nin the Script-src among the specific external sites required for the website. But I can't fathom why if I embed this form simply on a page on its own, or even on the same page outside the hidden content DIV, it works fine. But hidding the form and loading it to the Target DIV causes a javascript error??"
] | [
"javascript",
"jquery",
"wordpress",
"content-security-policy"
] |
[
"Retrieving a document containing a subset of documents matching a query and the total number of matches",
"How would one query a collection to retrieve a limited number of documents matching a query and the amount of documents matching the said query at the same time.\n\nI'm looking for a result like this one:\n\n{\n result : [\n {\n _id:null,\n total:734, //there are 734 documents matching the query\n page:[ //limited to 3\n {_id:\"...\", someValue:30000}\n {_id:\"...\", someValue:30400}\n {_id:\"...\", someValue:31900}\n ]\n }\n ]\n}\n\n\nI'm trying to get this for paging purposes."
] | [
"javascript",
"node.js",
"mongodb",
"mongoose",
"aggregation-framework"
] |
[
"kubernetes lost ~/.kube/config",
"Unfortunately I lost my local \n\n\n ~/.kube/config\n\n\nwhere I had configuration for my namespace.\n\nIs there a way to get this config if I have access to master nodes?\n\nThanks in advance"
] | [
"kubernetes",
"devops"
] |
[
"Jquery/PHP : How do I load any html content by id/class from another website",
"Im trying to run a script for a project, the goal is simple :\n\nMy only issue is i can't find any way to get the number of result google find when you make research. For example you search for \"game\" on google and it shows xxxx results load in xx sec. My script would be something like :\n\n\nAn input : for the word/expression you want to know number of result\nA div/p/span : for display the number of result got from google\n\n\nIf any one has any clue on how to do that, with javascript if possible, jquery if javascript is not enought, and in the end PHP if really jquery can't.\n\nThanks for your answers."
] | [
"php",
"jquery",
"html",
"load"
] |
[
"Aligning button and textview components vertically android",
"I am trying to make my Button component and my TextView component aligned vertically and also centered. Also a bit of spacing between each other. Right now they are simply on top of each other. \n\n\n\nXML:\n\n<RelativeLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:id=\"@+id/dueDateSection\"\n android:layout_below=\"@+id/editSection\"\n android:paddingBottom=\"@dimen/activity_edit_item_layout_vertical_margin\"\n android:paddingTop=\"@dimen/activity_edit_item_layout_vertical_margin\"\n android:gravity=\"center_vertical\">\n\n <Button\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:id=\"@+id/btnDatePicker\"\n android:text=\"Select Date\"\n android:layout_alignParentTop=\"true\"\n android:layout_centerHorizontal=\"true\" />\n\n <TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_below=\"@id/btnDatePicker\"\n android:textSize=\"22sp\"\n android:gravity=\"center\"\n android:layout_alignParentTop=\"true\"\n android:layout_centerHorizontal=\"true\"\n android:layout_alignBottom=\"@id/btnDatePicker\" />\n\n </RelativeLayout>"
] | [
"android",
"android-layout",
"textview"
] |
[
"Properties file not found in classpath when using Tomcat with security manager enabled",
"I have a properties my web application needs, but it is not available at package time. So I put it in TOMCAT_HOME/lib and the application finds it with no problem. When I run Tomcat with security manager enabled, the file is never found. I have granted permission to read it, but it is still not found. I am not getting any security error messages, only that the file is missing.\n\nWhen Tomcat is run with security manager enabled, is the classpath different? Is it more restricted?"
] | [
"tomcat",
"classpath",
"securitymanager"
] |
[
"C++ copy Constructor and default constructor",
"i am learning c++ and have found a output which i dont really understand.\n\n#include <iostream>\nusing namespace std;\n\nclass A{\n public:\n A(){ cout << \"A+\" << endl;}\n A(const A&){ cout << \"A(A)\" << endl;}\n ~A(){cout << \"A-\" << endl;}\n};\n\nclass B{\n public:\n B(){ cout << \"B+\" << endl;}\n B(const B&){cout << \"B(B)\" << endl;}\n ~B(){cout << \"B-\" << endl;}\n private:\n A a;\n};\n\nclass C : public A{\n public:\n C(const B& b) : b1(b) { cout << \"C+\" << endl;}\n ~C(){ cout << \"C-\" << endl;}\n private:\n B b1,b2;\n};\n\nvoid test(A a){\n A m(a);\n}\n\nint main(){\n B b;\n C c(b);\n test(c);\n return 0;\n\n}\n\n\nthe output is \n\nA+\nB+\nA+\nA+\nB(B)\nA+\nB+\nC+\nA(A)\nA(A)\nA-\nA-\nC-\nB-\nA-\nB-\nA-\nA-\nB-\nA-\n\n\nI mean the first one, B goes to default sees a we got a member from type A and goes to A thats the \nA+ than goes back to B and print B+. Thats it with B b; than C c(b) it goes to C, see its public A goes to A and print A+ than goes back see we got a Member B b1,b2 goes to B and B have a member A and goes agean to A and print A+ and than i dont understand why B(B) ? after this B(B)i dont understand anything.. i try it to debugg but it didnt help me very much, maybe someone can explain why this works like this?"
] | [
"c++",
"class",
"constructor",
"derived-class"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.