texts
sequence | tags
sequence |
---|---|
[
"How to create unique ID and name created in a loop within Razor",
"I have a razor view, with a table of a simple shopping list. In the first column of the table there is a dropdown list in each row.\n\nHere is the code I am using to bring back each dropdown list\n\n@foreach (var food in shoppingList.Foods)\n{ \n <tr>\n <td>@Html.DropDownListFor(m => food , new SelectList(Model.Foods,\"FoodID\",\"Name\",@food.FoodID))</td>\n <td>@food.Name</td>\n <td>@food.Price</td>\n </tr>\n}\n\n\nWith this code I get the data as I need it, but I would like to provide a unique ID/name to each select. At the moment, this is the generated html.\n\nFIRST SELECT\n\n<td><select id=\"food\" name=\"food\">\n<option selected=\"selected\" value=\"1\">Chicken</option>\n<option value=\"2\">Milk</option>\n<option value=\"3\">Bread</option>\n<option value=\"4\">Apple</option>\n<option value=\"5\">Cake</option>\n<option value=\"6\">Ham</option>\n</select></td>\n\n\nSECOND SELECT\n\n<td><select id=\"food\" name=\"food\">\n<option value=\"1\">Chicken</option>\n<option selected=\"selected\" value=\"2\">Milk</option>\n<option value=\"3\">Bread</option>\n<option value=\"4\">Apple</option>\n<option value=\"5\">Cake</option>\n<option value=\"6\">Ham</option>\n</select></td>\n\n\nNotice they both have id=\"food\" name=\"food\". \n\nHow I can give these unique id's and names?"
] | [
"c#",
"asp.net-mvc-4"
] |
[
"How to use exceptions for different cases with python requests",
"I have this code\n\ntry:\n response = requests.post(url, data=json.dumps(payload))\nexcept (ConnectionError, HTTPError):\n msg = \"Connection problem\"\n raise Exception(msg)\n\n\nNow i want the following\n\nif status_code == 401\n login() and then try request again\nif status_code == 400\n then send respose as normal\nif status_code == 500\n Then server problem , try the request again and if not successful raise EXception\n\n\nNow these are status codes , i donn't know how can i mix status codes with exceptions. I also don't know what codes will be covered under HttpError"
] | [
"python",
"request"
] |
[
"What kind of parameter should a web-service function that accepts a json string from a jquery ajax call have?",
"I want to store the positions of some elements on the front-end(jQuery) in the Database. I'm adding these to an array, using json to stringify the array and then attempting to store this to the DB through a web service in .NET. However, if I remove the parameter from the web-service and just call it to check if it works, I can see that it does. However, as soon as I pass a parameter, I get a missing parameter error. I think this has to do with my web-service functions parameter data type being incorrect.\n\nThis is what the function looks like in the .asmx file\n\n[WebMethod]\n public void submitToDB(**Object jsonObj**) - not sure what the datatype here should be\n {\n string jsonOb = \"meghu\";\n string commandText = \"INSERT into HackDemo(JSONobj) VALUES (@jsonObject)\";\n string connectionString = \"Data Source=sqldeva05;Initial Catalog=IRNdev;Integrated Security=True;\";\n using (SqlConnection connection = new SqlConnection(connectionString))\n {\n SqlCommand command = new SqlCommand(commandText, connection); \n command.Parameters.AddWithValue(\"@jsonObject\", jsonOb);\n\n try\n {\n connection.Open();\n Int32 rowsAffected = command.ExecuteNonQuery();\n Console.WriteLine(\"RowsAffected: {0}\", rowsAffected);\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex.Message);\n }\n }\n } \n\n\nHeres what the ajax call from jquery looks like -\n\n $.ajax({\n type: 'POST', \n dataType: 'json',\n url: 'dbFunctions.asmx/submitToDB',\n data: JSON.stringify(myArray),\n success: function () { alert(\"success\"); },\n error: function (response) {\n alert(response.responseText);\n }\n });"
] | [
"jquery",
".net",
"ajax",
"json"
] |
[
"Storing data in the most significant bits of a pointer",
"I've found quite some information about tagged pointers, which (ab)use the alignment requirements of types to store bits of data in their unused least significant bits.\n\nI was wondering however, couldn't you do the same with the most significant bits on a 64 bit system? Even if you were to use the 16 most significant bits of a 64 bit pointer, you would still need more than 256 terabytes of RAM for them to overlap.\n\nI know that in theory this is undefined behavior, but how would this behave in practice on some of the common operating systems (Windows/Max/Linux)?\n\nAnd yes, I am aware that this is evil and dangerous, but that is not what this question is about. It is a \"what if\" question about pushing computer programs to their limits, not one about sane and portable software design."
] | [
"c++",
"c",
"pointers"
] |
[
"Symfony 2 form theme related entities",
"I'm using Symfony 2.4.\n\nI have 2 entities having OneToMany and ManyToOne relationship.\n\nI'm rendering the entities in a twig.\n\nclass SomeController extends Controller\n{\n\n /**\n * @return \\Symfony\\Component\\HttpFoundation\\Response\n */\n public function listAction()\n {\n $em = $this->getDoctrine()->getManager('some_manager');\n $entities = $em->getRepository('SomeBundle:SomeClass')->findAll();\n\n return $this->render('SomeBundle:list.html.twig', ['entities' => $entities]);\n }\n ...\n\n\nStraight forward stuff. Works fine, no issue there. It's more for completion.\n\n\n\nThe forms are like so:\n\nclass FirstType extends AbstractType\n{\n /**\n * Build the form elements\n *\n * @param FormBuilderInterface $builder\n * @param array $options\n */\n public function buildForm(FormBuilderInterface $builder, array $options)\n {\n $builder\n ->add('url', 'hidden')\n ->add('secondEntity', 'collection', ['type' => new SecondType()])\n ;\n }\n ...\n\nclass SecondType extends AbstractType\n{\n /**\n * Build the form elements\n *\n * @param FormBuilderInterface $builder\n * @param array $options\n */\n public function buildForm(FormBuilderInterface $builder, array $options)\n {\n $builder\n ->add('value')\n ->add('type')\n ;\n }\n\n\nAgain, works fine.\n\n\n\nThe twig\n\n{% block content %}\n\n <form method=\"post\" class=\"form form-horizontal\">\n {{ form_start(form) }}\n {{ form_row(form._token) }}\n\n {{ form_errors(form.url) }}\n {{ form_widget(form.url) }}\n\n {{ form_errors(form.secondEntityGetterName) }}\n {{ form_widget(form.secondEntityGetterName) }}\n\n <div class=\"form-actions\">\n <button type=\"submit\" class=\"btn btn-primary\">Submit</button>\n </div>\n\n {{ form_end(form) }}\n </form>\n{% endblock content %}\n\n\nEverything works good here too. However since they're related Symfony insists on displaying how many entities are related to it.\n\nSomething like this \n\nNotice the integers at the left side of the screenshot. I'd like to remove those and leave only the right side of the screenshot.\n\nI have RTFM but it doesn't specify anything about related entities.\n\nI've tried using various getters inside the twig in the hopes that I can render each element separately. So far it's more of a hassle rather than anything else.\n\nI'm sure there must be a better way."
] | [
"php",
"symfony",
"symfony-2.4"
] |
[
"File Upload - Add to existing Input",
"I have the following file input box that allows for multiple upload: \n\n<input name=\"filesToUpload[]\" id=\"filesToUpload\" type=\"file\" multiple=\"\" />\n\n\nMy users pick their files and they appear in a list. But say after picking their files a user wishes to add more files without overwriting the existing files chosen. Is it possible to add on to the list of existing files or would I need a new file input element?"
] | [
"javascript",
"file-upload"
] |
[
"Foursquare Android Hash Key generation",
"The new app creation page in foursquare asks me for Android HasKeys. It looks very similar to the SHA1 key. is it the same. Else How do I get a android Hash key?Attached pic from the website. The command also given below. How do I get mystore.keystore? Should I register in google developer site to get one? Please help \n\nkeytool -list -v -keystore mystore.keystore"
] | [
"android",
"foursquare"
] |
[
"Table field value to column (T-SQL)",
"I know, there are similar questions, but I can't understad it. I hope, you will help me to understand=)\nI have a 3 tables: \n\n\nContact (int ID, nvarchar Name) \nCity (int ID, nvarchar Name, int ContCount) \nAddress (int ID, int CityID, int ContactID, int Year)\n\n\nI need to make a table like this:\n\nCity | 2010 | 2011 | 2012 | 2013 |\n LA | 201 | 231 | 198 | 211 |\n\n\nWhere 2010-2013 - values from Address.Year and {201, 231, 198, 211} are from City.ContCount\nIs in SQL some way to do it? If is, can you tell me about it=) I'll be really grateful)\nI'm novice in SQL, so even simple questions are hard to me)"
] | [
"sql",
"sql-server",
"tsql",
"pivot"
] |
[
"getAllCellInfo() returns empty list on Nexus 5x",
"I read all posts about getAllCellInfo() and have a similar situation like this.\nThe code posted below runs well on Android 6 (OnePlus One) but returns an empty list of Cellinfo on Google Nexus 5x Android 8.1 API 27.\nI have set the Permission ACCESS CORSE LOCATION in the manifest and asking for permission when running the app first time.\n\nHere is a code snippet:\n\ntry {\n\n TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);\n String networkOperator = \"\";\n if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { \n networkOperator = tm.getNetworkOperator(); \n }\n\n if (!TextUtils.isEmpty(networkOperator)) { //is not empty with Nexus 5x\n mcc = networkOperator.substring(0, 3); \n mnc = networkOperator.substring(3);\n } else {\n mcc = \"Unbekannt\";\n mnc = \"Unbekannt\";\n }\n\n List<CellInfo> cell = tm.getAllCellInfo();\n System.out.println(\"List: \"+cell);\n if (cell != null) { //Always null with Nexus 5x\n // TODO\n } else {\n cellID = \"ERROR\";\n lac = \"ERROR\";\n }\n }\n catch(Exception ex) {\n mcc = \"No Permission\";\n mnc = \"No Permission\";\n cellID = \"ERROR\";\n lac = \"ERROR\";\n }\n}\n\n\nWhen trying other apps like \"Network Cell Info lite\" these apps get all the cellinformation :(\n\nAny Help is very appreciated."
] | [
"android",
"telephonymanager",
"cellinfo"
] |
[
"React Native Android: screenPhysicalPixels.width is undefined",
"I recently upgraded to RN 0.20 and I now have the following exception thrown when I try to load my app:\n\nundefined is not an object (evaluating 'screenPhyisicalPixels.width')\n<unknown>\nindex.android.bundle?platform=android& def=true:32950\nrequireImpl\nindex.android.bundle?platform=android& def=true:76\n_require\nindex.android.bundle?platform=android& def=true:36\n\n\nWhich apparently causes a JS error the following file:\n\nnode_modules/react-native/Libraries/Utilities/Dimensions.js at line 30\n\n\nFor info, I'm not using the Dimensions API in my app.\n\nAny tip on this?"
] | [
"android",
"reactjs",
"react-native"
] |
[
"Attachment is blank when sent first time but has data when sent second time through Apex contoller - SFDC NPSP",
"I am working on a requirement where I have to send pdf as an attachment through Apex class in SFDC NPSP. So following is my program structure – \n\n\n VisualForcePage1 has two inputs – input1 and input2. The page also has\n 3 buttons – Preview, Send Email and Cancel. Depending on values of\n input1 and input2, ApexClass1 computes values for say output1,\n output2, output3, output4 and output5 using method getOutputMethod().\n Values of these output1...5 variables are stored in a custom object\n say Custom_Object__c.\n\n\npublic void getOutputMethod() { \n // calculate values of output1...5 \n // store these values in Custom_Object__c \n}\n\n\nWhen user clicks on Preview button, method previewPDF() is called, which in turn calls getOutputMethod(). Output variables (output1...5) are stored in Custom_Object__c and then control is redirected to VisualForcePage2 which has attribute renderAs = ‘pdf’. The generated pdf has accurate data.\n\nWhen user clicks on Send Email button, method emailPDF() is called, which in turn calls getOutputMethod(). Output variables (output1...5) are stored in Custom_Object__c. However attachment pdf sent in the mail has no data first time. For the same input values, attachment pdf has data when Send Email button is hit second and subsequent trials. Following is the code snippet for sending pdf as email – \n\nMessaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); \n// Reference the attachment page and pass in the account ID \nPageReference pdf = Page.VisualForcePage2; \npdf.getParameters().put('paramater1',input1); \npdf.getParameters().put('paramater2',input2); \npdf.setRedirect(true); \n// Take the PDF content \nBlob b = pdf.getContentAsPDF(); \n// Create the email attachment \nString filename = 'myPage.pdf'; \nMessaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment(); \nefa.setFileName(filename); \nefa.setBody(b); \n// Sets the paramaters of the email \nString subject = 'Subject'; \nbody = 'Hello'; \nemail.setSubject(subject); \nemail.setToAddresses('[email protected]'); \nemail.setPlainTextBody(body); \nemail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); \n// Sends the email\nMessaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});\n\n\n\n ApexClass2 of VisualForcePage2 queries Custom_Object__c with input1\n and input2 as parameters as below –\n\n\npublic ApexClass2() { // constructor \n var1 = ApexPages.currentPage().getParameters().get('paramater1'); \n var2 = ApexPages.currentPage().getParameters().get('paramater2'); getCustomObject(); \n} \n\npublic List<Custom_Object__c> getCustomObject() { \n List<Custom_Object__c> coList = new List<Custom_Object__c>([\nSELECT field1, field2, field3, field4, field5 \nFROM Custom_Object__c\nWHERE field1 =: var1\nAND field2 =: var2 ]); \n return coList; \n} \n\n\nPlease suggest."
] | [
"pdf",
"salesforce",
"email-attachments",
"visualforce",
"apex"
] |
[
"MYSQL Different Server collecting report",
"I have 30 different websites set up on 30 different servers. I want to collect data from all 30 DB's to provide me with a daily report of total number of orders and total value of orders.\n\nHow hard that would be. Any idea."
] | [
"mysql",
"report"
] |
[
"How to get userstories and all its conversation post in 2.0rc1?",
"How to get userstories and all its conversation post in 2.0rc1\n\ni tried\n\nmodel:'HierarchicalRequirement',\nfetch:[Discussion]\n\n\nBut this is not returning any conversation post"
] | [
"rally"
] |
[
"Airplay output from RemoteIO pass through",
"To prove a concept I am trying to output the iDevice microphone over Airplay. I have modified the AurioTouch code to provide the pass through, and it works fine using Airplay Mirroring from 4S / iPad 2 to Apple TV.\n\nHowever, when I try to use standard Airplay, either from iPhone 4 / iPad 1 or to an Airport Express, the audio outputs from the device speaker, even if the Airplay device is selected using either the system output route selector or the MPVolumeView in my app.\n\nIs there anything I need to do to enable Airplay on my AudioUnit? According to the documentation:\n\n\n AirPlay support is built in to the AV Foundation framework and the Core Audio family of frameworks. Any audio content you play using these frameworks is automatically made eligible for AirPlay distribution. Once the user chooses to play your audio using AirPlay, it is routed automatically by the system.\n\n\nBut I don't seem to be having any joy."
] | [
"iphone",
"ios",
"core-audio",
"airplay",
"remoteio"
] |
[
"Why is my Excel not recognizing the numbers with dollar sign?",
"My other computers work just fine, doing all calculations with the numbers with the dollar sign but one of my computers cannot."
] | [
"excel",
"ms-office"
] |
[
"Haskell--List appending using Guards",
"I am working on a simulation for a checkers game currently. I have developed a function called onemove:\n\n onemove :: (Int,[Char],[[Char]],(Int,Int)) -> (Int,[Char],[[Char]])\n\n\nThis function takes a tuple as input and returns a tuple of modified information. I have defined the input variables as follows:\n\n onemove (a,b,c,(d,e))\n\n\nWhere c is a list of chars, ie, captured pieces. I am currently utilizing guards and a where clause to complete the move to be made from 'd' to 'e'. How do I append an element to the list b within the where clause, if even possible? My sample code is as follows:\n\n onemove :: (Int,[Char],[[Char]],(Int,Int)) -> (Int,[Char],[[Char]])\n\n onemove (a,b,c,(d,e)) \n | e <= 0 =(a-30,b,c)\n | (posFrom == 'r') && (posTo == '-') && ( leftOrRight == 9) = (a-15,b,removeWRightMan)\n | otherwise = (10000,b,c)\n where posFrom = getPos d c\n rightWGuy = d+4\n b ++ rightWGuy\n removeWRightMan = setPos rightWGuy sFPosTo '-'\n\n\nThe value rightWGuy is however an Int and I am attempting to pass it to a [char]..Does this need to be converted to a char before attepting to append to the list b? Thanks"
] | [
"list",
"haskell"
] |
[
"How to terminate wxWidgets message loop without destroying main frame?",
"I am beginer to wxWidgets. I have problem with standard way of terminating application by calling Destroy() in MyFrame::OnClose() event handler :\n\nIn MyApp::OnInit() i am creating MyFrame with constructor parameter loaded from configuration file (use of dependency injection). This parameter is stored inside MyFrame and can change during lifetime of MyFrame. \n\nWhen application exits i need to MyApp::OnExit() gets this parameter from MyFrame and saves it. So MyFrame must still exist in MyApp::OnExit(). \n\nI dont like to save this parameter in MyFrame::OnClose() because i dont want to MyFrame be dependent on configuration file functions - thats job of application class at higher level.\n\nI think if i am creating something, for example MyFrame in OnInit() then perfect place to destroy it is OnExit() right? So, exist some correct way to delay destroying of MyFrame to MyApp::OnExit() ?\n\nmyapp.cpp :\n\n#include <wx/wx.h>\n#include \"myframe.h\"\n\nclass MyApp : public wxApp {\npublic:\n virtual bool OnInit() override;\n virtual int OnExit() override;\n MyFrame* m_myframe;\n};\n\n\nIMPLEMENT_APP( MyApp );\n\nextern int LoadSettings();\nextern void SaveSettings( int param );\n\nbool MyApp::OnInit()\n{\n const int param = LoadSettings();\n m_myframe = new MyFrame( \"MyFrame title\", param );\n m_myframe->SetIcon( wxICON(aaaa) );\n m_myframe->Show();\n return true;\n}\n\nint MyApp::OnExit()\n{\n const int param = m_myframe->GetParameter();\n SaveSettings( param );\n m_myframe->Destroy();\n return 0;\n}\n\n\nmyframe.h:\n\n#include <wx/wx.h>\n\nclass MyFrame: public wxFrame {\npublic:\n MyFrame( const wxString& title, int param );\n int GetParameter() const { return m_param; }\n /* ... */\nprivate:\n void OnClose( wxCloseEvent& event );\n int m_param;\n};\n\n\nmyframe.cpp :\n\n#include \"myframe.h\"\n\nMyFrame::MyFrame( const wxString& title, int param )\n: wxFrame( nullptr, -1, title ),\n m_param( param )\n{\n Bind( wxEVT_CLOSE_WINDOW, &MyFrame::OnClose, this );\n}\n\nvoid MyFrame::OnClose( wxCloseEvent &event )\n{\n // Want to terminate message loop but without destroying this\n // Destroy();\n}"
] | [
"c++",
"dependency-injection",
"wxwidgets"
] |
[
"Code Complexity Analysis for c++ on unix which can generate xml output",
"I am looking for a code complxity analysis tool for c++ which can run on unix and generate output in the form of an xml file. \nsomething like this : http://www.blunck.info/ccm.html\nThis tool works on windows but i need something which runs on unix.\n\nthanks in advance"
] | [
"c++",
"c",
"xml",
"unix",
"complexity-theory"
] |
[
"Calculate the percentage",
"I need to find the Total # of Hires in a population.\nThen I need to find the percentage of that population where gender is female.\nI have tried :\n-- the Total # of Hires in a population\nselect count(Hires) from Employees for the employees \n\n-- percentage of the above population where gender is female.\nselect COUNT(Hires) from Employees\nWhere Gender='Female') * 100.0 / (select count (Hires) FROM employees \n\nbut it gives me a large percentage"
] | [
"sql",
"sql-server",
"average",
"where-clause",
"percentage"
] |
[
"How do I average the last 5 minutes of entries from a SQL database?",
"I have a table that stores time, heart_rate, and player_id. I need to somehow take an average of the heart rate data over the last five minutes and group each average by the player ID."
] | [
"sql",
"average"
] |
[
"Animation code doesnt animate?",
"I have a view with which I have a button calling the following method. The view hides/shows but without any animation\n\n- (void) displayEvent:(id)sender {\n\n [UIView beginAnimations:nil context:NULL];\n [UIView setAnimationDuration:2.5];\n modal.hidden = !modal.hidden;\n [UIView commitAnimations];\n}\n\n\nAny ideas?"
] | [
"iphone",
"objective-c"
] |
[
"Conda install all packages from one env in a new env",
"Let's say we have an environment env_og with a set of packages S_og installed.\nI want to create a new env env_new with:\n\nSome specified new packages S_new\nThe original packages S_og BUT I don't care about the versions\n\nSo no need to try solving the environment too seriously. Update all you need."
] | [
"conda"
] |
[
"How to convert List flutter",
"i'm new in flutter and need to help:\n\nI have already got \n\nfinal List<Genres> genres = [{1,\"comedy\"}, {2,\"drama\"},{3,\"horror\"}]\n\n\nfrom api.\n\nclass Genres {\n\n final int id;\n final String value;\n\n Genres({this.id,this.value});\n}\n\n\nIn another method I get genres.id.(2) How can I convert it to genres.value (\"drama\")?"
] | [
"flutter",
"dart"
] |
[
"What's the conceptual difference between bundle adjustment and structure from motion?",
"In my mind they both mean reconstructing 3D coordinates from matched points in 2D images. What's the difference between these concepts and multi-view stereo?\n\nWhich one do you call an algorithm that computes a sparse point cloud from keypoint matches, and requires both the cameras' external and internal parameters to be known a priori?"
] | [
"image-processing",
"computer-vision",
"stereo-3d",
"structure-from-motion"
] |
[
"Swagger, API Gateway using AWS Cloudformation",
"I am deploying a API which is mapped to a loadbalancer. I could test the API successfully on the console but while using the invoke link in the stage, I am getting a 403. The ELB is a http end point and the invoke url is https which is normal I would say. \n\nAlso if I use the ELB DNS Name, I could get the desired result. Looks like requests are not going through API Gateway.\n\nI am doing all of this using Cloudformation and swagger. Here is the relevant part\n\n EmployeeApi:\n Type: AWS::ApiGateway::RestApi\n Properties:\n BodyS3Location:\n Bucket: !Ref S3Bucket\n Key: \"swagger.yaml\"\n\n EmployeeApiDeployment:\n Type: AWS::ApiGateway::Deployment\n Properties: \n RestApiId: !Ref EmployeeApi\n\n EmployeeApiStage:\n Type: AWS::ApiGateway::Stage\n Properties:\n DeploymentId: !Ref EmployeeApiDeployment\n RestApiId: !Ref EmployeeApi\n StageName: dev\n Variables:\n employeeELB:\n Fn::ImportValue:\n !Sub ${NetworkStackName}-ELB\n\n EmployeeApiUsagePlan:\n Type: AWS::ApiGateway::UsagePlan\n Properties: \n ApiStages: \n - ApiId: !Ref EmployeeApi\n Stage: !Ref EmployeeApiStage \n UsagePlanName: Basic\n\n EmployeeApiKey:\n Type: AWS::ApiGateway::ApiKey\n Properties:\n Name: employee-api-key\n Enabled: true\n StageKeys:\n - RestApiId: !Ref EmployeeApi\n StageName: !Ref EmployeeApiStage\n\n\nRelevant part of my swagger file is\n\nswagger: \"2.0\"\ninfo:\nversion: 1.0.0\ntitle: employee-service\ndescription: Welcome to API documentation of Employee Service\n\nschemes:\n - https\nsecurityDefinitions:\n api_key:\n type: apiKey\n name: x-api-key\n in: header\nx-amazon-apigateway-request-validators:\n RequestValidator:\n validateRequestBody: true\n validateRequestParameters: true\nx-amazon-apigateway-request-validator: RequestValidator\n\npaths:\n /employees:\n get:\n\n security:\n - api_key: []\n x-amazon-apigateway-integration:\n responses:\n default:\n statusCode: \"200\"\n uri: http://${stageVariables.employeeELB}/employees\n passthroughBehavior: when_no_match\n httpMethod: GET\n contentHandling: \"CONVERT_TO_TEXT\"\n type: http_proxy"
] | [
"yaml",
"amazon-cloudformation",
"aws-api-gateway",
"swagger-2.0"
] |
[
"Is there any way to disable a service in docker-compose.yml",
"I find myself in the situation, that I want to disable a service temporarily in a docker-compose file. \n\nOf course I could comment it out, but is there any option to just say \"enabled: false\" ?"
] | [
"docker",
"docker-compose"
] |
[
"Resttemplate - how to post object with HAL representation?",
"When attempting to post to a Spring-Data-Rest web service via RestTemplate, the JSON representation of my domain object is being converted to a full blown JSON object that isn't in HAL representation. My assumption here is that I need to register the Jackson2HalModule as a deserializer though am not sure how to do that considering I register it to the objectMapper. The serialization works correctly when calling GET on the webservice, just not for POST/PUT:\n\nRequest outputBuffer field:\n\n{\n \"id\" : 1,\n \"name\" : \"Name\",\n \"description\" : \"\",\n \"childObject\" : {\n \"id\" : 1,\n \"name\" : \"test\"\n }\n} \n\n\nRest Template configuration:\n\n@Bean\npublic ObjectMapper objectMapper() {\n ObjectMapper objectMapper = new ObjectMapper();\n objectMapper.registerModule(new JodaModule());\n objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\n objectMapper.setDateFormat(new ISO8601DateFormat());\n objectMapper.enable(SerializationFeature.INDENT_OUTPUT);\n objectMapper.registerModule(new Jackson2HalModule());\n return objectMapper;\n}\n\npublic void configureMessageConverters(\n List<HttpMessageConverter<?>> messageConverters) {\n MappingJackson2HttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter();\n jsonMessageConverter.setObjectMapper(objectMapper());\n jsonMessageConverter.setSupportedMediaTypes(MediaType\n .parseMediaTypes(\"application/hal+json,application/json\"));\n messageConverters.add(jsonMessageConverter);\n}\n\n@Bean\npublic RestTemplate restTemplate() {\n RestTemplate restTemplate = new RestTemplate();\n List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();\n configureMessageConverters(messageConverters);\n restTemplate.setMessageConverters(messageConverters);\n return restTemplate;\n}\n\n\nRequest Headers:\n\n HttpHeaders headers = new HttpHeaders();\n headers.setContentType(MediaType.APPLICATION_JSON);\n\n\nCalling method:\n\nResponseEntity<DomainObject> responseEntity =\n restTemplate.exchange(this.getBaseUri() + resolveResource(), HttpMethod.POST, new HttpEntity(domainObject,createHttpHeaders(tenantId)), DomainObject.class);"
] | [
"spring",
"jackson",
"resttemplate",
"spring-hateoas",
"hal-json"
] |
[
"Angular UI Router - Named Nested Views Not Working",
"I have the following:\n\nRoutes\n\nfunction Config($stateProvider, $urlRouterProvider, USER_ROLES) {\n $stateProvider\n .state('dashboard', {\n url: '/dashboard',\n views: {\n 'header@': {\n templateUrl: 'partials/layout/sections/auth/header.html'\n },\n 'content@': {\n templateUrl: 'partials/dashboard/template.html'\n },\n 'centre-column@dashboard': {\n templateUrl: 'partials/dashboard/content.html'\n },\n 'left-column@dashboard': {\n templateUrl : 'partials/dashboard/left-column.html',\n controller : 'DashNavCtrl'\n }\n },\n layoutType: 'three-column'\n })\n .state('dashboard.recruiter', {\n views: {\n 'right-column@dashboard': {\n templateUrl : 'partials/dashboard/recruiter/right-column.html',\n controller : 'DashSidebarCtrl'\n }\n }\n })\n\n\ntemplate.html\n\n<!-- page-container -->\n<div class=\"page-container\">\n\n<!-- main-container -->\n<main class=\"main-container pad-e-2x\" role=\"main\" ui-view=\"centre-column\">\n\n</main>\n<!-- /main-container -->\n\n<div ui-view=\"left-column\"></div>\n\n<div ui-view=\"right-column\"></div>\n\n</div>\n<!-- page-container -->\n\n\nBut when I transitionTo 'dashboard.recruiter', it doesn't display both the right and left columns.\n\nCan anyone point me in the right direction?"
] | [
"angularjs",
"angular-ui-router"
] |
[
"How to fix Unsupported major.minor version 52.0 in SOAPUI",
"I am running a selenium script using the groovy script test step in SOAPUI but I am getting the following error? How to fix this?\n\njava.lang.UnsupportedClassVersionError: org/openqa/selenium/support/ui/ExpectedCondition : Unsupported major.minor version 52.0\n\n\nHere is the script I am running:\n\nimport org.openqa.selenium.WebElement\nimport org.openqa.selenium.firefox.FirefoxDriver\nimport org.openqa.selenium.support.ui.ExpectedCondition\nimport org.openqa.selenium.support.ui.WebDriverWait\n\n// Create a new instance of the Firefox driver\n// Notice that the remainder of the code relies on the interface, \n// not the implementation.\nWebDriver driver = new FirefoxDriver()\n\n// And now use this to visit Google\ndriver.get(\"http://www.google.com\")\n\n// Find the text input element by its name\nWebElement element = driver.findElement(By.name(\"q\"))\n\n// Enter something to search for\nelement.sendKeys(\"Cheese!\")\n\n// Now submit the form. WebDriver will find the form for us from the element\nelement.submit()\n\n// Check the title of the page\nlog.info(\"Page title is: \" + driver.getTitle())\n\n// Google's search is rendered dynamically with JavaScript.\n// Wait for the page to load, timeout after 10 seconds\n(new WebDriverWait(driver, 10)).until(new ExpectedCondition() {\n public Boolean apply(WebDriver d) {\n return d.getTitle().toLowerCase().startsWith(\"cheese!\")\n }\n});\n\n// Should see: \"cheese! - Google Search\"\nlog.info(\"Page title is: \" + driver.getTitle())\n\n//Close the browser\ndriver.quit()\n\n\nWhere I can make the change in the following soapui bat file?\n\n@echo off\n\nset SOAPUI_HOME=%~dp0\nif exist \"%SOAPUI_HOME%..\\jre\\bin\" goto SET_BUNDLED_JAVA\n\nif exist \"%JAVA_HOME%\" goto SET_SYSTEM_JAVA\n\necho JAVA_HOME is not set, unexpected results may occur.\necho Set JAVA_HOME to the directory of your local JDK to avoid this message.\ngoto SET_SYSTEM_JAVA\n\n:SET_BUNDLED_JAVA\nset JAVA=%SOAPUI_HOME%..\\jre\\bin\\java\ngoto END_SETTING_JAVA\n\n:SET_SYSTEM_JAVA\nset JAVA=java\n\n:END_SETTING_JAVA\n\nrem init classpath\nset OLDDIR=%CD%\ncd /d %SOAPUI_HOME%\n\nset CLASSPATH=%SOAPUI_HOME%soapui-5.2.1.jar;%SOAPUI_HOME%..\\lib\\*\n\"%JAVA%\" -cp \"%CLASSPATH%\" com.eviware.soapui.tools.JfxrtLocator > %TEMP%\\jfxrtpath\nset /P JFXRTPATH= < %TEMP%\\jfxrtpath\ndel %TEMP%\\jfxrtpath\nset CLASSPATH=%CLASSPATH%;%JFXRTPATH%\n\nrem JVM parameters, modify as appropriate\nset JAVA_OPTS=-Xms128m -Xmx1024m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -Dsoapui.properties=soapui.properties \"-Dsoapui.home=%SOAPUI_HOME%\\\" -splash:SoapUI-Spashscreen.png\n\nset JAVA_OPTS=%JAVA_OPTS% \"-Dsoapui.https.protocols=SSLv3,TLSv1.2\"\n\nif \"%SOAPUI_HOME%\" == \"\" goto START\n set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries=\"%SOAPUI_HOME%ext\"\n set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.listeners=\"%SOAPUI_HOME%listeners\"\n set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.actions=\"%SOAPUI_HOME%actions\"\n set JAVA_OPTS=%JAVA_OPTS% -Djava.library.path=\"%SOAPUI_HOME%\\\"\n set JAVA_OPTS=%JAVA_OPTS% -Dwsi.dir=\"%SOAPUI_HOME%..\\wsi-test-tools\"\nrem uncomment to disable browser component\nrem set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.browser.disabled=\"true\"\n\n:START\n\nrem ********* run soapui ***********\n\n\"%JAVA%\" %JAVA_OPTS% com.eviware.soapui.SoapUI %*\ncd /d %OLDDIR%"
] | [
"java",
"selenium",
"soapui"
] |
[
"Combining Serverside MVC with Backbone.js",
"I'm using .NET MVC for all my serverside logic and serving out initial pages, but my application is very heavy on the client-side so I have adopted Backbone.JS which is proving to be very useful.\n\nI'm unsure how to architect my system to incorporate both technologies though. The way I see it I have two options\n\n\nScrap the 'V' from MVC on the server-side, return JSON Data to the\nclient on pageload and use backbone clientside templates to build up\nthe GUI from the base JSON/Backbone Models. \nReturn the initial pages from the server fully rendered in .NET MVC.\nAlso return the data that was used to render them and call the\ncollection.reset({silent: true}) method to link up the\nreturned data to the view. Am I right in thinking that this will\nallow me to subsequently make changes to using the add/remove/change\nhandlers on the views?\n\n\n1 Troubles me as I'm afraid of letting go of any part of server-side MVC, its where my core skill lies.\n\n2 Troubles me as I'm concerned I might be introducing risk and work by having two different rendering methods on client server.\n\nWhats the correct way to combine Server-side MVC with backbone.js 1 or 2 or some other way?"
] | [
"asp.net-mvc",
"backbone.js"
] |
[
"jwPlayer with fancy box",
"Yes i know there is a bunch of similar questions but i didnt find them helpful for me.\nI have situation like this: (with included jwplayer.js and all stuf about fancyBox)\n\n< a class=\"jwVideo\" href=\"\" rel=\"group\" > Preview < /a >\n\n\n$(function() { \n $(\".jwVideo\").click(function() {\n $.fancybox({\n 'padding' : 0,\n 'autoscale' : false,\n 'transitionIn' : 'none',\n 'transitionOut': 'none',\n 'title' : this.title,\n 'width' : 640,\n 'height' : 385,\n 'href' : this.href,\n 'type' : 'swf',\n 'swf' : { 'wmode':'transparent', \n 'allowfullscreen':'true' \n }\n });\n return false;\n });\n });\n\n\nI need exactly this \"template\" of script so my question is how to adjust href attribute for playing video which is located on for example https://bla-bla.something1.amazon.com/video_1.mp4.\n\nThanks.\n\nEDIT:\nThanks JFK and Ethan on help, i solved problem so if anyone have similar problems here is the solution(worked for me):\n\nSolution: \n\n//html\n<a class=\"jwVideo\" href=\"https://bla-bla123.com/video_1.mp4\" rel=\"group\"> Preview </a>\n//js\n$(function() {\n $(\"a.jwVideo\").click(function() {\n var myVideo = this.href; // Dont forget about 'this'\n\n $.fancybox({\n padding : 0,\n content: '<div id=\"video_container\">Loading the player ... </div>',\n afterShow: function(){\n jwplayer(\"video_container\").setup({ \n file: myVideo,\n width: 640,\n height: 385 \n });\n }\n });\n return false;\n });\n});"
] | [
"jquery",
"fancybox",
"jwplayer"
] |
[
"PHP ucwords working on all but first word?",
"I have this simple string:\n\necho ucwords(\"<row><cell><chars class='subHeader'><value>how much time do you spend</value></chars></cell></row>\");\n\n\nBut its outputting like so:\n\n<row>\n<cell>\n<chars Class=\"subHeader\">\n<value>how Much Time Do You Spend</value>\n</chars>\n</cell>\n</row>"
] | [
"php"
] |
[
"Difference between R1 and Rz in Q#",
"As far as I know, both Rz and R1 operations in Q# rotate a qubit about the z-axis. In Q# API reference (https://docs.microsoft.com/en-us/qsharp) I found out that the only difference between them is that R1 also applies rotation about the "PauliI" axis, i.e. changes the global phase. In R operation reference (https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.r) they also say that "When called with pauli = PauliI, this operation applies a global phase. This phase can be significant when used with the Controlled functor". So the question: can you give an example, how can it be significant?"
] | [
"quantum-computing",
"q#"
] |
[
"how to persist text data in winforms app?",
"I am working on a winforms app using C# and wanted to add a save feature to a few parts where the user would be bale to enter text into a textbox and have it saved for next time. \n\nhow is this implemented in winforms?\nI am trying a local xml file and failing to persists the text while being able to read it. data.xml is the local file in my project root folder.\n\nXmlDocument xmlDoc = new XmlDocument();\nxmlDoc.Load(@\"(full path)\\visual studio 2015\\Projects\\My_helper\\data.xml\");\n\nstring subject = xmlDoc.DocumentElement.SelectSingleNode(@\"./content/reminder_email/subject\").InnerText.ToString();\n\nstring body = xmlDoc.DocumentElement.SelectSingleNode(@\"./content/reminder_email/body\").InnerText.ToString();"
] | [
"c#",
"winforms"
] |
[
"Sliding a sliding window \"intelligently\"?",
"In sliding window object detectors, is it possible to do object detection \"intelligently\"? For example, if a human is looking for a vehicle, they're not going to look into the sky for a car. But an object detector that uses a sliding window is going to slide the window across the entire image (including the sky) and run the object classifier on each window, resulting in a lot of wasted time. Are there are any techniques out there to make sure it only looks in reasonable places? \n\nEdit\n\nI understand we'll have to look through everything at least once, but I wouldn't want to run a heavy complicated classifier on each window. A pre-classification classifier of sorts, perhaps?"
] | [
"python",
"image-processing",
"computer-vision",
"classification"
] |
[
"How to slice numpy rows using start and end index",
"index = np.array([[1,2],[2,4],[1,5],[5,6]])\nz = np.zeros(shape = [4,10], dtype = np.float32)\n\n\nWhat is the efficient way to set z[np.arange(4),index[:,0]], z[np.arange(4), index[:,1]] and everything between them as 1?\n\nexpected output:\n\narray([[0, 1, 1, 0, 0, 0, 0, 0, 0, 0],\n [0, 0, 1, 1, 1, 0, 0, 0, 0, 0],\n [0, 1, 1, 1, 1, 1, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 1, 1, 0, 0, 0]])"
] | [
"python",
"numpy",
"array-broadcasting"
] |
[
"Javascript-Event: Start it when visible in Browser-Window?",
"i iam looking for a solution for a Problem like this:\n\nRun script when div is visible in browser window\n\nMy problem is: My DIV are stacked! You maybe know a solution? \n\n\n\nEDIT:\n\nI did try it like this: And it works! ... more or less :)\n\nMy Problem at the moment: \n\n\nIf loadcontent() loads fast = it works! \nIf it loads slow it doesn't! \n\n\nIs there some way to solve this? \n\n\r\n\r\nfunction checkContentLoad(divId){\r\n \r\n if (divId == 'faq')\r\n { if($('#contentbox-faq').is(':visible'))\r\n { loadcontent('faq', '0', '0');\r\n }}\r\n \r\n if (divId == 'kontakt')\r\n { if($('#contentbox-kontakt').is(':visible'))\r\n { loadcontent('kontakt', '0', '0');\r\n }}\r\n}\r\n<div id=\"contentbox-faq\" class=\"contentbox-faq\">\r\n\r\n<script>\r\ncheckContentLoad('faq');\r\n</script>\r\n\r\n</div>"
] | [
"javascript",
"css"
] |
[
"Using IoC to provide a custom ModelMetadataProvider in MVC3",
"I'm currently overriding the default ModelMetadataProvider in the Global.asax file using this\n\nModelMetadataProviders.Current = new RedSandMetadataProvider(ModelMetadataProviders.Current);\n\n\nand this works perfectly. But I'd like to use the IDependancyResolver feature of MVC3 to let IoC provide the ModelMetadataProvider implementation instead. I'm using StructureMap to do it (Just installed it into the project using NuGet) but for some reason it not behaving as expected.\n\nx.For<ModelMetadataProvider>().Use(new RedSandMetadataProvider(ModelMetadataProviders.Current));\n\n\nI put a breakpoint on the constructor of RedSandMetadataProvider() and it is getting hit. And I also put a breakpoint on the GetServices() function of the automatically added SmDependencyResolver.cs file to make sure it was IoC that was calling my constructor, and everything seems fine, the constructor gets called on the second page load I think, but it never calls my GetMetadataForProperty() function of my MetadataProvider. Now I KNOW this gets called correcetly when I set it up in the Global.asax, but every time I try to achieve the same result using IoC, I see the constructor called on my class and that's it. I tried adding a .Singleton() to the StrctureMap registration of the type and that causes my constructor to get called much sooner but it still never actually USES the object after it's constructed.\n\nAm I missing something?"
] | [
"asp.net-mvc",
"asp.net-mvc-3",
"structuremap",
"modelmetadataprovider"
] |
[
"Loading RWeka on RStudio causes fatal error",
"require(RWeka)\n\n\nand\n\nlibrary(RWeka)\n\n\nis creating a fatal error in R session.Restart the session.\nAny reasons or solutions for the same??"
] | [
"r",
"rstudio",
"rweka"
] |
[
"Video loop is freezing my iOS app at some point",
"I have an application that is running on a Kiosk, open all day looping videos. Eventually, after around 1 day, the application freezes. \n\nHere is an Instruments session after 14 hours of running:\n\n\n\n\n\nI'm not very familiar with Instruments yet, and although the Live Bytes stay consistent and are low, the other values do seem like very high. But again, I'm not sure if that's normal or not.\n\nThis is how I create the video player:\n\n- (void)setupInitialContentWithBounds:(CGRect)externalScreenBounds\n{ \n avPlayer = [[AVPlayer alloc] init];\n avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];\n avPlayerLayer.frame = externalScreenBounds;\n [self.externalWindow.layer addSublayer:avPlayerLayer];\n avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;\n [[NSNotificationCenter defaultCenter] addObserver:self\n selector:@selector(playerItemDidReachEnd:)\n name:AVPlayerItemDidPlayToEndTimeNotification\n object:[avPlayer currentItem]];\n\n [self playVideo:@\"Idle\"];\n}\n\n\nHere is the playVideo method:\n\n- (void)playVideo:(NSString *)name\n{\n currentVideo = name;\n NSString *filepath = [[NSBundle mainBundle] pathForResource:name ofType:@\"mp4\"];\n NSURL *fileURL = [NSURL fileURLWithPath:filepath];\n AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:fileURL];\n [avPlayer replaceCurrentItemWithPlayerItem:playerItem];\n [avPlayer play];\n}\n\n\nAnd here the notification listener for when the video finishes:\n\n- (void)playerItemDidReachEnd:(NSNotification *)notification\n{\n if([currentVideo isEqualToString:@\"Idle\"])\n {\n //Keeps looping the Idle video until another one is selected\n AVPlayerItem *p = [notification object];\n [p seekToTime:kCMTimeZero];\n }\n\n else\n {\n NSLog(@\"Just finished a different video, so go back to idle\");\n [self playVideo:@\"Idle\"];\n }\n}\n\n\nEDIT: At first my client told me it crashed, but it looks like it actually freezes, the video stops playing and the app is unresponsive. Any ideas?"
] | [
"ios",
"objective-c",
"memory-management",
"instruments",
"avplayer"
] |
[
"Orchard multiple cultures",
"I have site working on orchard CMS. Site has 2 cultures : en-Us and ru-RU. All pages has translations. For example page has path\n\n\n http://examplesite.com/{culture}/company-contacts\n\n\nwhere culture en or ru.\nBut i see in browser, that waiting of responce (html) fo ru culture in 2 times bigger than fo en culture.\nWaiting for ru-945 ms and for en -430 ms. All ru pages slowwer than en pages.\nContent Localization module and Content Picker module are enabled.\norchard version 1.10.2"
] | [
"c#",
"asp.net-mvc",
"orchardcms",
"orchard-modules"
] |
[
"Side-nav doesn't work in material design based mobile app",
"I wrote a simple page with side-nav functionality. However side-nav fails to open up when clicked on top left corner. My code:\nHtml: \n\n<nav>\n <ul class=\"right hide-on-med-and-down\">\n <li><a href=\"#!\">First Sidebar Link</a></li>\n <li><a href=\"#!\">Second Sidebar Link</a></li>\n </ul>\n <ul id=\"slide-out\" class=\"side-nav\">\n <li><a href=\"#!\">First Sidebar Link</a></li>\n <li><a href=\"#!\">Second Sidebar Link</a></li>\n </ul>\n <a href=\"#\" data-activates=\"slide-out\" class=\"button-collapse\"><i class=\"mdi-navigation-menu\"></i></a>\n </nav>\n\n\n <div class=\"row\">\n <div class=\"card logincard\">\n <form class=\"col s12\">\n <h5>Enter your mail id to reset your password: </h5>\n <div class=\"row\">\n <div class=\"input-field col s12\">\n <input id=\"mail\" type=\"email\" class=\"validate\">\n <label for=\"mail\">Mail</label>\n </div>\n </div>\n <div class=\"row\">\n <a class=\"waves-effect waves-light btn\" style=\"background: #4099FF;\">Submit</a>\n </div>\n </form>\n </div>\n </div> \n\n\nJS: \n\n(function($){\n $(function(){\n\n $('.button-collapse').sideNav();\n\n }); // end of document ready\n })(jQuery); // end of jQuery name space \n\n\nJSFiddle link is: https://jsfiddle.net/0hq4g3f1/\nHow can I fix it?"
] | [
"javascript",
"jquery",
"html",
"css",
"material-design"
] |
[
"convert_tz returns null even after loading time zone tables",
"I have a MySQL database (hosted on Ubuntu) that has a table with a time zone. This date is in the UTC time zone. I have an application that is using this data but needs to convert the time from UTC to PST to display the data in a useful format. \n\nThis can probably be changed on the application level, but I don't have the time to do that currently, so what I want to do is use convert_tz to get the correct time zone until I have time to change the application to convert the time zone.\n\nHowever, whenever I do something like\n\nSELECT id, \n category, \n convert_tz(create_datetime, 'UTC', 'PST') as create_datetime\nFROM table\n\n\nI get a result like\n\n1, category, NULL\n\n\nI know that I need to load the time zone tables, so I did, running this command:\n\nmysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql\n\n\nAfter that I restarted the mysql service. However, convert_tz still returns NULL. Can someone give me a hand?\n\nThanks!"
] | [
"mysql",
"sql"
] |
[
"@Value - always null",
"I'm using the @Value annotation to assign variables a value from the properties file. \n\n@Configuration\npublic class AppConfig {\n @Value(\"${db.url}\")\n private String url;\n\n @Value(\"${db.username}\")\n private String username;\n\n @Value(\"${db.password}\")\n private String password;\n\n //Code \n}\n\n\nThe class is annotated with @Configuration, and is 'initialized' via web.xml, where the directory for the environment file is also set. \n\n<context-param>\n <param-name>envir.dir</param-name>\n <param-value>/path/to/environment/variables/</param-value>\n</context-param>\n <context-param>\n <param-name>contextClass</param-name>\n <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>\n </context-param>\n\n <context-param>\n <param-name>contextConfigLocation</param-name>\n <param-value>eu.nets.bankid.sdm.AppConfig</param-value>\n </context-param>\n\n <listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n </listener>\n\n\nOn startup all the values are 'null'. Is there something I'm missing?"
] | [
"java",
"spring",
"null",
"config"
] |
[
"parse empty string using json",
"I was wondering if there was a way to use json.loads in order to automatically convert an empty string in something else, such as None.\n\nFor example, given:\n\ndata = json.loads('{\"foo\":\"5\", \"bar\":\"\"}')\n\n\nI would like to have:\n\ndata = {\"foo\":\"5\", \"bar\":None}\n\n\nInstead of:\n\ndata = {\"foo\":\"5\", \"bar\":\"\"}"
] | [
"python",
"json",
"string",
"python-3.x",
"dictionary"
] |
[
"'d3.nest()' cannot read property of undefined",
"I'm trying to use very simple d3.nest() functionality but get failed with the error 'Cannot read property of undefined' related to one of the data columns.\n\nFirst I tried to process the stand alone txt file and got stuck. Second I tried to process a simple variable created inside the code and didn't succeeded.\n\nI understand that the problem I'm posting could have been discussed not once. But I searched and didn't find any responses just for my case. Think I'm doing incorrectly something that is peculiar for a hole newbie only.\n\nHere's the code:\n\nconst db = [\n {\n 'net': '36,6',\n 'lon': '30',\n 'lat': '50'\n },\n {\n 'net': 'erka',\n 'lon': '40',\n 'lat': '55'\n },\n {\n 'net': 'erka',\n 'lon': '40',\n 'lat': '70'\n }\n ];\n\n console.log(db); //output looks fine with all three columns needed \n\n const nest = d3.nest(db)\n .key(function(d) {return d.net;}) //triggers the error\n .entries(function(d) {return d.lon;});\n\n\nThe error is:\n\n\n Cannot read property 'net' of undefined"
] | [
"javascript",
"d3.js"
] |
[
"How to find the root cause of HTTP Request Node - Intermittently throwing SocketException: Connection reset?",
"HTTP Request node connecting to a third party REST API, which is hosted on AWS intermittently throwing SocketException : Connection reset. I would like to know why is it happening intermittently and how to find root cause of this issue. \n\nHTTP Request Node Settings:\nProtocol - TLSv1.2\n\nIBM Integration Bus v10.0.0.8"
] | [
"ibm-integration-bus"
] |
[
"Regex with new line character is matching string",
"I've got a regex expression in a Mongo Meteor query:\n\n Programs.find({ Notes: { $regex: '^((?!REFUNDED).)*$' }}).fetch()\n\n\nThis should read, 'Return all documents where the 'Notes' field (a string field) doesn't contain the string \"REFUNDED\"'. \n\nI'm finding a problem when the text in the Notes field contains a new line character '\\n'. When it does find a new line character, it renders the statement true. \n\nFor example, if document 1's Notes field was the string \"Line one. \\nLine two\", document 1 would not be returned, even though \"REFUNDED\" isn't in the string. \n\nWhat's the best way around this?"
] | [
"regex",
"mongodb",
"meteor"
] |
[
"Android Marshmallow 6.0 , check running app in background",
"In Marshmallow, even if application in not in backgounnd and foreground . i am getting as \"application is running\".\ncode i use is\n\nActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);\n List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();\nfor (int i = 0; i < appProcesses.size(); i++) {\n if (appProcesses.get(i).processName.equals(\"com.alive.moraribapuapp\")) {\n Log.d(TAG, \"com.alive.moraribapuapp is true(running)\");\n\n return true;\n } else {\n Log.d(TAG, \"com.alive.moraribapuapp is false(Not running)\");\n return false;\n }\n }\n\n\nthis giving me true even if application closed in Marshmallow."
] | [
"java",
"android",
"android-6.0-marshmallow",
"activity-manager"
] |
[
"R - co-locate columns with the same name after merge",
"Situation\n\nI have two data frames, df1 and df2with the same column headings\n\nx <- c(1,2,3)\ny <- c(3,2,1)\nz <- c(3,2,1)\nnames <- c(\"id\",\"val1\",\"val2\")\n\ndf1 <- data.frame(x, y, z) \nnames(df1) <- names\n\na <- c(1, 2, 3)\nb <- c(1, 2, 3)\nc <- c(3, 2, 1)\n\ndf2 <- data.frame(a, b, c)\nnames(df2) <- names\n\n\nAnd am performing a merge\n\n#library(dplyr) # not needed for merge\njoined_df <- merge(x=df1, y=df2, c(\"id\"),all=TRUE)\n\n\nThis gives me the columns in the joined_df as id, val1.x, val2.x, val1.y, val2.y\n\nQuestion\n\nIs there a way to co-locate the columns that had the same heading in the original data frames, to give the column order in the joined data frame as id, val1.x, val1.y, val2.x, val2.y?\n\nNote that in my actual data frame I have 115 columns, so I'd like to stay clear of using joned_df <- joined_df[, c(1, 2, 4, 3, 5)] if possible.\n\nUpdate/Edit: also, I would like to maintain the original order of column headings, so sorting alphabetically is not an option (-on my actual data, I realise it would work with the example I have given).\n\nMy desired output is\n\n id val1.x val1.y val2.x val2.y\n1 1 3 1 3 3\n2 2 2 2 2 2\n3 3 1 3 1 1\n\n\nUpdate with solution for general case\n\nThe accepted answer solves my issue nicely. \nI've adapted the code slightly here to use the original column names, without having to hard-code them in the rep function. \n\n#specify columns used in merge\nmerge_cols <- c(\"id\")\n\n# identify duplicate columns and remove those used in the 'merge'\ndup_cols <- names(df1) \ndup_cols <- dup_cols [! dup_cols %in% merge_cols]\n\n# replicate each duplicate column name and append an 'x' and 'y'\ndup_cols <- rep(dup_cols, each=2)\nvar <- c(\"x\", \"y\") \nnewnames <- paste(dup_cols, \".\", var, sep = \"\")\n\n#create new column names and sort the joined df by those names\nnewnames <- c(merge_cols, newnames)\njoined_df <- joined_df[newnames]"
] | [
"r",
"merge"
] |
[
"Compiler error in newer version of gcc",
"Following code compiles fine with g++ 4.4.5 but reports error with g++ 4.5.3 . Is it the compiler behavior that has changed. If so, what got changed?\n\n#include <iostream>\nusing namespace std;\n\nclass A\n{\n public:\n A() {}\n};\n\nint main()\n{\n new A::A();\n return 0;\n}"
] | [
"c++"
] |
[
"Cannot get specific data off the internet",
"I am encountering a problem in my Android application where I get all the content on the page, but I only want part of it. Here is part of my code:\n\nspinner.setOnItemSelectedListener(new OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {\n String text1 = spinner.getSelectedItem().toString().trim();\n\n if (text1.equals(\"US Dollar - USD\")) { \n try {\n\n Document doc = Jsoup.connect(\"http://www.google.com/finance/market_news?ei=_FLfUbD4JrG90QGf6wE\").get();\n String body = doc.body().text();\n textView1.setText(body);\n\n } catch (IOException e) {\n\n\n }\n\n\nHere is what I am getting in my application:\n\nhttp://oi41.tinypic.com/343kmwx.jpg\n\nThe stuff I want in my application starts from \"An Ethiopian Airlines........ on 767 Dreamliner fire.\n\nWhat do I need to do? I am not experienced in CSS, Javascript, or HTML. I have checked all over google too. Any help would be greatly appreciated."
] | [
"javascript",
"android",
"html",
"css"
] |
[
"Best way to compare *nix timestamps in bash",
"I want to compare two Unix/Linux timestamps as fast as possible in bash:\n\n TIMESTAMP_A=1472680800\n TIMESTAMP_B=1458687600\n\n if [[ ${TIMESTAMP_A} -lt ${TIMESTAMP_B} ]]; then\n echo \"Timestamp A is younger!\";\n else\n echo \"Timestamp B is younger!\";\n fi\n\n\nDoes my solution always work or do I need to take care of some special cases?"
] | [
"linux",
"bash",
"timestamp",
"comparison"
] |
[
"call jquery function wordpress",
"Below code is jquery function\n\n$(document).ready(function () {\n $('#access').accordion({\n create: function (event, ui) {\n $('div#access> div').each(function () {\n var id = $(this).attr('id');\n $(this).load(id+'.html', function () {\n $('#access').accordion('resize');\n });\n });\n }\n});\n});\n\n\nwhere access is the div id i have used for menu items in header.\n\nbelow code is header.php page code\n\n<div id=\"access\" >\n <ul> \n <?php wp_list_pages('depth=1&title_li=');?>\n </ul>\n</div>\n\n\nwhat i want is onclick of the menu item the javascript function should be called..\n\nhow to call function from php file?"
] | [
"php",
"jquery",
"wordpress"
] |
[
"ReSharper color identifiers screw up with Visual Studio 2012 dark theme",
"We're experiencing an annoying problem issues with ReSharper's color identifiers feature when Visual Studio 2012 is set to the built-in dark theme.\n\nWith ReSharper's color identifiers disabled, the code looks fine:\n\n\n\nThen, we enable ReSharper's color identifiers:\n\n\n\nAnd now the code is completly unreadable:\n\n\n\nThe curious thing, on a colleague's machine, the same code, with the same Visual Studio and ReSharper settings... looks right:\n\n\n\nWe tried reinitializing both Visual Studio and ReSharper settings, disabling add-ons and extensions and other voodoos to no avail.\n\nHere are our setups:\n\n\nMy add-ins - His add-ins\nMy extensions - His extensions\nMy system informations - His system informations"
] | [
"visual-studio",
"visual-studio-2012",
"resharper",
"resharper-7.1"
] |
[
"Mock method that returns Task",
"I have unit test for a method that returns dynamic and when I try to setup and returns a dynamic value it gets an error on running the test saying\n\nThe best overloaded method match for 'Moq.etc' has some invalid arguments\n\n_managerMock.Setup(x => x.someMethod(It.IsAny<int>()))\n .Returns(Task.FromResult(resource));"
] | [
"c#",
"unit-testing",
"mocking",
"task",
"moq"
] |
[
"When hovering over child element, parent element thinks I'm doing mouseleave()",
"This is clearly not the case though.\n\nMy JS :\n\n$(\".job_charge.item-block\").live({\n mouseenter: function(){\n $(this).find('.edit-and-delete').stop(true,true).fadeIn();\n },\n mouseleave: function(){\n $(this).find('.edit-and-delete').stop(true, true).fadeOut();\n }\n});\n\n\nmy HTML :\n\n<div id=\"job_charge_2244\" class=\"item-block job_charge\">\n <div class=\"edit-and-delete right\">\n </div>\n</div>\n\n\nThe CSS :\n\n.item-block.job_charge\n border-bottom: 1px dotted #ccc\n display: inline-block\n padding-bottom: 15px\n width: 650px\n\n .edit-and-delete\n position: relative\n display: none\n top: 25px\n right: 5px\n float: right\n a\n margin-right: 8px\n\n\nI've gone bananas. When I mouse over the links in my inner div, then immediately, it triggers a mouse-leave function and they hide. This div is naturally in position: relative, but I have also placed it in block and it still has the same issue.\n\nThe parent div is in inline-block."
] | [
"jquery"
] |
[
"Android Canvas OpenGL Renderer is out of memory",
"I develop android library for drawing chart at view, using canvas.\nHowever, the following errors occur frequently. \n\nLogCat:\n\nD/NvOsDebugPrintf(11526): NvRmChannelSubmit: NvError_IoctlFailed with error code 12\nD/NvOsDebugPrintf(11526): NvRmChannelSubmit failed (err = 196623, SyncPointValue = 94008102)\n(87 times repeat)\nD/OpenGLRenderer(11526): GL error from OpenGLRenderer: 0x505\nE/OpenGLRenderer(11526): OpenGLRenderer is out of memory!\n\n\nSolution is not found although I am groping for various causes and solution. \nSo, please tell me about what can become a cause which such an error generates?\nAnd how can solve this problem.\n\nI beg your kindness. Finally my sincere apologies for my poor English."
] | [
"android",
"android-layout",
"android-canvas",
"android-view"
] |
[
"Stopping an RDS instance via CLI",
"I am trying to use one of AWS's latest features where it allows you to stop an RDS instance.\n\nI followed this doc where it explains that I need to run the command:\naws rds stop-db-instance --db-instance-identifier mydbinstance however, when I do that I get this:\n\nusage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]\nTo see help text, you can run:\n\n aws help\n aws <command> help\n aws <command> <subcommand> help\naws: error: argument operation: Invalid choice, valid choices are:\n\nadd-role-to-db-cluster | add-source-identifier-to-subscription\nadd-tags-to-resource | apply-pending-maintenance-action\n\n\nand it continues to list other RDS commands but not including stop-db-instance.\nI updated my CLI and the current version that I have is: aws-cli/1.11.11 Python/2.7.9 Windows/8 botocore/1.4.68\n\nWhat am I missing?\n\nUPDATE\n\nI tried to upgrade the aws cli again but what I'm getting back is that everything is up to date:\n\nC:\\Users\\n.ihab>aws --version\naws-cli/1.11.11 Python/2.7.9 Windows/8 botocore/1.4.68\n\nC:\\Users\\n.ihab>pip install awscli --upgrade\nRequirement already up-to-date: awscli in c:\\python34\\lib\\site-packages\nRequirement already up-to-date: rsa<=3.5.0,>=3.1.2 in c:\\python34\\lib\\site-packages (from awscli)\nRequirement already up-to-date: colorama<=0.3.7,>=0.2.5 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from awscli)\nRequirement already up-to-date: docutils>=0.10 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from awscli)\nRequirement already up-to-date: botocore==1.5.72 in c:\\python34\\lib\\site-packages (from awscli)\nRequirement already up-to-date: PyYAML<=3.12,>=3.10 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from awscli)\nRequirement already up-to-date: s3transfer<0.2.0,>=0.1.9 in c:\\python34\\lib\\site-packages (from awscli)\nRequirement already up-to-date: pyasn1>=0.1.3 in c:\\python34\\lib\\site-packages (from rsa<=3.5.0,>=3.1.2->awscli)\nRequirement already up-to-date: python-dateutil<3.0.0,>=2.1 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from botocore==1.5.72->awscli)\nRequirement already up-to-date: jmespath<1.0.0,>=0.7.1 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from botocore==1.5.72->awscli)\nRequirement already up-to-date: six>=1.5 in c:\\users\\n.ihab\\appdata\\roaming\\python\\python34\\site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.5.72->awscli)\n\nC:\\Users\\n.ihab>aws --version\naws-cli/1.11.11 Python/2.7.9 Windows/8 botocore/1.4.68\n\n\nIs there something else I need to upgrade prior to this step?"
] | [
"amazon-web-services",
"aws-cli",
"rds"
] |
[
"How to use nsITimer in a Firefox Extension?",
"I am working on a Firefox extension, and wish to make use of a timer to control posting of data every 60 seconds.\n\nThe following is placed inside an initialization function in the main .js file:\n\nvar timer = Components.classes[\"@mozilla.org/timer;1\"].createInstance(Components.interfaces.nsITimer);\ntimer.init(sendResults(true), 60000, 1);\n\n\nHowever, when I try to run this I get the following error in the Firefox console:\n\n\"Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsITimer.init]\" nsresult: \"0x80004003\"...\n\n\nAnd so on. What did I do wrong?\n\nUPDATE:\n\nThe following works for my needs, although the initial problem of using nsITimer instead still remains:\n\nvar interval = window.setInterval(function(thisObj) { thisObj.sendResults(true); }, 1000, this);\n }\n\nUseful links that explain why this works (documentation on setInterval/sendResults, as well as solution to the 'this' problem:\n\nhttps://developer.mozilla.org/En/DOM/window.setTimeout\nhttps://developer.mozilla.org/En/Window.setInterval (won't let me post more than two hyperlinks)\n\nhttp://klevo.sk/javascript/javascripts-settimeout-and-how-to-use-it-with-your-methods/"
] | [
"javascript",
"firefox-addon",
"settimeout",
"setinterval",
"firefox4"
] |
[
"How to install pip packages via --no-build-isolation when they are mentioned in requirements.txt?",
"Context :\nThis is the problem https://github.com/pypa/pip/issues/6717#issue-468204416 I'm facing\nand trying to solve via\nhttps://github.com/pypa/pip/issues/6717#issuecomment-511652167\n\nI want to use \n\n--no-build-isolation\n\n\nIn a py2.7 venv If I do:\n\npip install bottleneck==1.2.1 --no-build-isolation\n\nCollecting bottleneck==1.2.1\nCollecting numpy (from bottleneck==1.2.1)\n Downloading https://files.pythonhosted.org/packages/d7/b1/3367ea1f372957f97a6752ec725b87886e12af1415216feec9067e31df70/numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB)\n 100% |████████████████████████████████| 17.0MB 1.2MB/s \nInstalling collected packages: numpy, bottleneck\nSuccessfully installed bottleneck-1.2.1 numpy-1.16.5\nYou are using pip version 18.0, however version 19.2.3 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n\n\n\nIt installs fine\n\n$ cat abc.txt \nbottleneck==1.2.1, --no-build-isolation\n\n\nbut\n\n$pip install -r abc.txt\nUsage: pip [options]\n\nInvalid requirement: bottleneck==1.2.1, --no-build-isolation\npip: error: no such option: --no-build-isolation\n\nYou are using pip version 18.0, however version 19.2.3 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n\n\n\n\nand\n\n$ pip install -r abc.txt\nUsage: pip [options]\n\nInvalid requirement: bottleneck==1.2.1 --no-build-isolation\npip: error: no such option: --no-build-isolation\n\nYou are using pip version 18.0, however version 19.2.3 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n\n\n\ndon't work. \n\nHow do I go about it.\n\nI also tried bottleneck tries to install numpy release candidate but it doesn't help."
] | [
"python",
"python-2.7",
"pip"
] |
[
"If I can't use aggregate in a where clause, how to get results",
"Ok I have a query where I need to ommit the result if the first value of an array_agg = natural so I thought I can do this:\n\nselect\n visitor_id,\n array_agg(code\n order by session_start) codes_array\nfrom mark_conversion_sessions\nwhere conv_visit_num2 < 2\n and max_conv = 1\n and (array_agg(code\n order by session_start))[1] != 'natural'\ngroup by visitor_id\n\n\nBut when I run this I get the error:\n\nERROR: aggregate functions are not allowed in WHERE\nLINE 31: and (array_agg(code\n\n\nSo is there a way I can reference that array_agg in the where clause?\n\nThank you"
] | [
"postgresql"
] |
[
"Django DRF nested serializer",
"I'm new to DRF and trying to write a prototype of API for storing rectangle labels on a photo.\nmy models:\nclass Image(models.Model):\n file = models.FileField(blank=False, null=False)\n\nclass Label(models.Model):\n image = models.ForeignKey(Image, blank=True, on_delete=models.CASCADE)\n start_x = models.IntegerField(default=0)\n start_y = models.IntegerFIeld(default=0)\n end_x = models.IntegerField(default=0)\n end_y = models.IntegerField(default=0)\n\nmy serializers:\nfrom rest_framework import serializers\n\nclass LabelSerializer(serializers.ModelSerializer):\n class Meta:\n model = Label\n fields = ['id', 'image', 'start_x', 'start_y', 'end_x', 'end_y']\n\nclass ImageSerializer(serializers.ModelSerializer):\n labels = LabelSerializer(many=True, read_only = True)\n class Meta:\n model = Image\n fields = ['id', 'file', 'labels']\n\nWhen creating new image object in the following view I get image object, but no Labels objects created :\nfrom .serializers import ImageSerializer\n\nclass ImageView(APIView):\n parser_classes = (MultiPartParser, FormParser)\n\n def post(self, request, *args, **kwargs):\n serializer = ImageSerializer(data=request.data)\n if serializer.is_valid():\n serializer.save()\n response_data = {'id': serializer.data['id']}\n return Response(response_data,\n status=status.HTTP_201_CREATED)\n else:\n return Response(serializer.errors,\n status=status.HTTP_400_BAD_REQUEST)\n\nAPI call:\ncurl -i -X POST -H "Accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@~/test.jpg" --form-string 'labels={[{"start_x": 0, "start_y": 0, "end_x": 100, "end_y": 200}]}' http://127.0.0.1:8000/api/create/\nHow should I modify ImageSerializer for making possible to create image with labels with one API call?"
] | [
"python",
"django",
"django-rest-framework"
] |
[
"How to initilize Spring bean using factory method in Java config?",
"I am using Spring in Java based config. I want to initialize a bean using a factory method. In XML, it is done as such:\n\n<bean id=\"repositoryService\" factory-bean=\"processEngine\" factory-method=\"getRepositoryService\" />\n\n\nHow do I do the same thing in Java?"
] | [
"java",
"spring"
] |
[
"JavaFX 1 first column in gridpane is spaced out much farther than the rest",
"In my program, I try to output an HBox filled with CheckBoxes onto the screen. However, when I run the program, CheckBox \"A\" is spaced out much further compared to the rest of the checkboxes.\n\nHere is my code:\n\nprivate Scene assets (Stage primaryStage){\n\n GridPane gp = new GridPane();\n gp.setVgap(5);\n gp.setPadding(new Insets(25, 25, 25, 25));\n\n Text title = new Text(\"Assets\");\n title.setFont(Font.font(\"Arial\", FontWeight.BOLD, 14));\n gp.add(title, 0, 0);\n\n Text description = new Text(\"Please select all assets you would like to include in your budget\");\n gp.add(description, 0, 1);\n\n String [] optionsString = new String []{\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"};\n\n for (int i = 0; i < optionsString.length; i++) {\n final int column = i;\n final int row = i;\n String option = optionsString[i];\n CheckBox checkBox = new CheckBox(option);\n\n HBox checkboxContainer = new HBox(checkBox);\n checkboxContainer.setSpacing(20);\n\n ChoiceBox<Integer> choice = new ChoiceBox<>();\n Label label = new Label(\"How many \" + optionsString[i] + \" options do you have?\");\n choice.getItems().addAll(1, 2, 3, 4, 5);\n\n HBox choiceContainer = new HBox(label, choice);\n\n checkBox.selectedProperty().addListener((o, oldValue, newValue) -> {\n if (newValue) {\n gp.add(choiceContainer, 0, row + 4);\n } else {\n gp.getChildren().remove(choiceContainer);\n }\n });\n gp.add(checkboxContainer, column, 3);\n }\n\n assets = new Scene (gp, 1280, 720);\n\n return assets;\n }\n\n\nEDIT: Here is a screenshot of what I am talking about"
] | [
"java",
"javafx"
] |
[
"Why can't I use DefaultTableModel? Am I missing something Obvious? (Java)",
"Here is my code:\n\nimport javax.swing.*; \nimport java.awt.*; \nimport java.awt.event.*;\n\n class Test{ \n static CardLayout cardLayout; \n static JPanel card = new JPanel();\n\n public static void main(String[] args) {\n JFrame frame = new JFrame(\"AddressBook\");\n JPanel contentPane = (JPanel)frame.getContentPane();\n card.setLayout(cardLayout = new CardLayout()); \n\n JPanel cardTop = new JPanel();\n DefaultTableModel model = new DefaultTableModel();\n model.addColumn(\"Name\");\n model.addColumn(\"Number\");\n String[] John = {\"John\", \"1234\"};\n model.addRow(John);\n String[] Beth = {\"Beth\", \"4444\"};\n model.addRow(John);\n JTable table = new JTable(model); \n JScrollPane jsp = new JScrollPane(table);\n cardTop.add(jsp);\n\n\n card.add(\"Card Top\", cardTop);\n contentPane.add(card);\n\n frame.setVisible(true);\n frame.setSize(507, 191);\n frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n frame.setResizable(false);\n }\n }\n\n\nWhen I try to compile, it says it doesn't recognize DefaultTableModel. Also, the code above is part of my main and I'm sure I've imported the right libraries.\n\nHere is the error:\n\nTest.java:15: error: cannot find symbol\n DefaultTableModel model = new DefaultTableModel();\n ^\n symbol: class DefaultTableModel\n location: class Test\nTest.java:15: error: cannot find symbol\n DefaultTableModel model = new DefaultTableModel();\n ^\n symbol: class DefaultTableModel\n location: class Test\n2 errors\n\n\nHelp please?"
] | [
"java",
"swing",
"jtable",
"defaulttablemodel"
] |
[
"How to use a single query to check if a value exists in two tables",
"Using EF Core 2.2.2, I have these two simple queries with the goal of determining if a Color is in use in either the CollectionItem or PuzzleColor table:\n\nvar isACollectionItem = _applicationDbContext.CollectionItem.Any(collectionItem => collectionItem.ColorId == color.Id);\nvar isAPuzzleItem = _applicationDbContext.PuzzleColor.Any(puzzleColor => puzzleColor.ColorId == color.Id);\nvar eitherOr = \n _applicationDbContext.CollectionItem.Any(collectionItem => collectionItem.ColorId == color.Id)\n || _applicationDbContext.PuzzleColor.Any(puzzleColor => puzzleColor.ColorId == color.Id);\n\n\nThe first two lines generate two separate queries that look like:\n\nSELECT CASE\n WHEN EXISTS (\n SELECT 1\n FROM [CollectionItem] AS [collectionItem]\n WHERE [collectionItem].[ColorId] = @__color_Id_0)\n THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)\nEND\n\n\nPutting them together with an || operator means it will run both in the event the first isn't true, otherwise it will only run the first query.\n\nIs it possible to merge both checks into a single query with EF?"
] | [
"c#",
"entity-framework-core"
] |
[
"UIImageView pixel-perfect `touches began` for non-transparent parts of UIImage",
"developing iphone app, I have used a UIImageview and i have set an image of irregular shape\n\n// uiimageview type shutter\nshutter = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,32.5)];\n\n//setting image on shutter\nUIImage* shutterimg = [UIImage imageNamed:@\"trayshutter.png\"];\n[shutter setImage:shutterimg];\n// User interaction\nshutter.userInteractionEnabled=YES;\n\n\nand i get touches using touchesbegan\n\neverything is fine, but issue is I also get events in all the rectangle area occupied by the CGRectMake (i.e. 0,0,320,32.5) of imageview, whereas i require events only on the image (which is of shape of -----|||||-----).\n\nHow can i make sure that i get events only on the image and not on the rest of area covered by cgrectmake ?"
] | [
"iphone",
"uiimageview",
"uiimage",
"touchesbegan",
"user-interaction"
] |
[
"How fix google tag manager trigger not tracking element visibility event for id's created during A/B testing of google optimise.?",
"I have setup google tag manager triggers a page where id's are used for triggering visibility of elements events. There are 2 versions of the page. I'm performing A/B testing for the both versions. To track events in variation separately I used different ID names by editing in google optimise. On testing the google tag manager the visibility events related to variant are not being triggered. \n\nFor Example:\nI have used id=\"tech-pro\" for an element in original website and changed it to id = \"tech-pro-v1\" using google optimise a/b testing. The visibility event for the element with id = \"tech-pro-v1\" is not being triggered when it appears in A/B testing.\n\nPlease Help"
] | [
"google-analytics",
"google-tag-manager",
"event-tracking",
"ab-testing",
"google-optimize"
] |
[
"Defer return of factory until loop is completely finished angularjs",
"I'm trying to make a method that returns an array of objects after getting the objects from an API. The problem is that the return from the factory happens before all the calls are finished. I've tried to use $q.defer but it still sends the return before it's ready to ship. \nThis is what I've come up with so far.\n\nangular.module('watchList').factory('storageService', ['$http', '$q', function ($http, $q) {\nstorage = {};\n\nstorage.getMovies = function () {\n\n var movies = localStorage.getItem('movies');\n var movieArray = angular.fromJson(movies);\n var newArray = [];\n var defer = $q.defer();\n\n angular.forEach(movieArray, function (id) {\n newArray.push($http.get(api + id));\n });\n $q.all(newArray).then(function (response) {\n defer.resolve(response);\n });\n\n return defer.promise;\n}\n\n\nThis is the controller that I'm trying to make the call from\n\nangular.module('watchList').controller('watchListController', ['$scope', 'storageService', function ($scope, storageService) {\n$scope.movies = storageService.getMovies();\n\n\nI want the loop to finish everything before it returns the array."
] | [
"javascript",
"angularjs",
"angularjs-factory"
] |
[
"How to get entire MongoDB collection with PHP",
"Using the following code, I can grab a node from a collection:\n\n<?php\n\n$user = \"xxxx\";\n$pwd = 'xxxx';\n\nif (isset($_POST['needleID'])) {\n $needleID = $_POST['needleID'];\n} else {\n echo \"needle ID not set\";\n}\n\n//Manager Class\n$connection = new MongoDB\\Driver\\Manager(\"mongodb://${user}:${pwd}@localhost:27017\");\n\n// Query Class\n$filter = ['id'=> $needleID];\n$query = new MongoDB\\Driver\\Query($filter);\n\n// Output of the executeQuery will be object of MongoDB\\Driver\\Cursor class\n$rows = $connection->executeQuery('DBNAME.DBCOLLECTION', $query);\n\n// Convert rows to Array and send result back to javascript as json\n$rowsArr = $rows->toArray();\necho json_encode($rowsArr);\n\n?>\n\n\nHowever, what I'm really looking to do is get everything from the DBCOLLECTION.\n\nI'm kind of at a loss on how to do this. A few searches either go over my head or are for older versions of the PHP driver, such as this one fetch all data from mongodb collection"
] | [
"php",
"mongodb"
] |
[
"Github action install package from github packages return 409 Conflict",
"I separated part of my main app to private repo, packaged it into github package and I need to use it into my main app by npm install.\nLocally it works but when I use Github Actions it fails with\nnpm ERR! code E409 npm ERR! 409 Conflict - GET https://npm.pkg.github.com/download/@se...\nWhen I am going into url from error I can see\n{"error":"Package file checksum mismatch"}\nThis is my workflow\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v2\n\n - name: Use Node.js 14.15.0\n uses: actions/setup-node@v1\n with:\n node-version: 14.15\n registry-url: 'https://npm.pkg.github.com'\n\n - name: Install dependencies\n run: npm install\n env:\n NODE_AUTH_TOKEN: ${{secrets.PACKAGE_TOKEN}}\n\n - name: Lint\n run: npm run lint"
] | [
"github",
"npm",
"package",
"github-actions",
"github-package-registry"
] |
[
"How do I regenerate imagecache thumbnails in drupal 6?",
"My thumbnails images are all missing from my hosting account causing my gallery images to show broken as shown in screenshot.\n\n\n\nI have tried creating a new gallery and uploading images to the gallery hoping it would rebuild the thumbnails however this has failed as well. So somehow image cache is not creating the thumbnails anymore and removed what was there completely."
] | [
"drupal",
"drupal-6",
"thumbnails"
] |
[
"Increase device's Wi-Fi transmitting power",
"I would like to ask if it is possible to increase or decrease Android device Wi-Fi transmitting power programmatically without rooting the device? Thanks!"
] | [
"android",
"wifi"
] |
[
"convert array to observable array",
"Is there any way to convert observable to observable array?\n\nI am asking this because there is one function in my code which expect observable array because the function uses ko.utils.arrayForEach\n\nI have try to google but couldnt find anything.\n\nUpdate\n\ni checked what i am passing using var test = isObservable(item). its not observable that i am passing because i get false in variable test Its normal array.\n\nSo i want to convert array to observable array"
] | [
"knockout.js",
"observable"
] |
[
"PrettyPhoto Last Image in Gallery Loading First",
"http://2012.delineamultimedia.com/#home_portfolio\n\nIf you click on the Icon that jumps when you hover over BRIAN GUEHRING's gallery. You will activate the prettyPhoto pop-up gallery. For some reason it starts with the last image in the gallery. Is there a way to fix this so it starts with the first image in the gallery? \n\n<script type=\"text/javascript\" charset=\"utf-8\">\n$(document).ready(function(){\n $(\"a[rel^='prettyPhoto']\").prettyPhoto();\n});\n</script>\n\n\nThis is the script I'm using to start prettyPhoto, I'm scared another script might be screwing this up somehow. \n\nThank you in advance for your time! I really appreciate it!"
] | [
"javascript",
"jquery",
"plugins",
"prettyphoto",
"portfolio"
] |
[
"How to adjust GridLayout row height dynamically?",
"I am using Vaadin, and I have set of data in given GridLayout. \n\nInside Grid I have Labels as Key and Value: \n\n\n\nRequirement is: \n\n \n\nSituation is, now Value i.e. Label could have longer text which I can wrap text but I also want to dynamically increase that particular row height accordingly. How it can be done using GridLayout? I have tried setRowExpandRatio() but didn't helped."
] | [
"java",
"vaadin",
"grid-layout"
] |
[
"Rails, creating associated records along with parent object?",
"Maybe I don't know how to ask/search for this particular thing, but basically I want to create a few associated models when I create the parent object... say I have the following situation:\n\nI have a Recipe which has_many Ingredient models... is there a way to make them all at once, say this is part of my seed task for example:\n\nRecipe.create({\n :title => 'apple pie',\n :description => 'just apple pie',\n :ingredients => {\n [0] => {:title => 'apples'},\n [1] => {:title => 'sugar'},\n [2] => {:title => 'pie crust'}\n }\n})\n\n\nOr like am I totally crazy? There must be some sort of way to do this similarly, without creating the parent model, then all the children... etc, etc."
] | [
"ruby-on-rails",
"nested-attributes"
] |
[
"Error in dropping database?",
"I tried the following mysql query to drop the database.Here am getting the following error in dropping with database.How can I solve it?\n\nmysql> drop database xample;\nERROR 1010 (HY000): Error dropping database (can't rmdir './xample/', errno: 17)"
] | [
"mysql"
] |
[
"Adding a listener to a button inside a custom alertdialog crashes my app",
"I have in my application a button which allows me to open an custom alertdialog. This alert dialog gets its content from an XML file: I have in it a button (called filterButton), radio button and a slider bar. Programatically, there are two more buttons added (OK, Cancel).\nWhen I open my dialog alert, the content is perfectly displayed but no events are created so far. (so no problem opening the alertdialog and displaying content)\n\nNow, I want to add a listener for my \"filterButton\". So as always, I declared my button (Button filterButton;), setOnClickListener this way (in my onCreate) : \n\nfilterButton = (Button) findViewById(R.id.filter_button); \nfilterButton.setOnClickListener(filter_listener);\n\n\nThen I define my listener : \n\nOnClickListener filter_listener = new OnClickListener() {\n\n @Override\n public void onClick(View v) {\n// showPopupMenu(v);\n } }; \n\n\nI commented out the method inside to make sure the problem doesn't come from this method. And so since I did this, when I try to run my app it just crashes when I try to open the activity where the button opening the alertdialog is. When I take off these few lines, it works again. I don't understand, it doesn't make sense, it's just a button with a listener, I have dozens like this and no problem so why is it problematic when it's in my alertdialog ? \n\nps: my logcat is useless as usual, just saying Fatal Error and nullpointerexception with no details. \n\nEDIT: I changed as suggested below to this : \n\nfilterButton = (Button) alertDialog.findViewById(R.id.filter_button);\nfilterButton.setOnClickListener(filter_listener); \n\n\nI put this here as it was underlining alertDialog in red if put at the beginning of the program, but it still crashes : \n\nOnClickListener dialog_listener = new OnClickListener() {\n\n @Override\n public void onClick(View v) {\n\n LayoutInflater myLayout = LayoutInflater.from(context);\n View dialogView = myLayout.inflate(R.layout.alertdialog_filter, null);\n\n AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(\n context);\n\n\n Bundle bundle = getIntent().getExtras();\n int filterVariable = bundle.getInt(\"filterVariable\");\n\n alertDialogBuilder.setTitle(\"Filter Mode\");\n\n alertDialogBuilder.setPositiveButton(\"OK\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int which) {\n\n }\n });\n\n\n alertDialogBuilder.setNegativeButton(\"Cancel\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int which) {\n\n }\n }); \n\n // set alertdialog_filter.xml to alertdialog builder\n alertDialogBuilder.setView(dialogView);\n\n // create alert dialog\n AlertDialog alertDialog = alertDialogBuilder.create();\n\n filterButton = (Button) alertDialog.findViewById(R.id.filter_button);\n filterButton.setOnClickListener(filter_listener);\n\n\n\n // show it\n alertDialog.show();\n }\n}; \n\n\nThe difference is, now it doesn't crash when I open the activity but when I click on the button supposed to open the alertdialog."
] | [
"android",
"listener",
"android-alertdialog",
"onclicklistener"
] |
[
"Unable to download variable to file in any browser other than Chrome using AngularJS",
"I need to allow users to download a CSV file, I have the CSV as a string value. The following function works in Chrome, but not for IE 10/11, Edge or Firefox. \n\nfunction downloadCSV(CSV, fileName) {\n var data = \"data:text/json;charset=utf-8,\" + encodeURIComponent(CSV);\n var downloader = document.createElement('a');\n\n downloader.setAttribute('href', data);\n downloader.setAttribute('download', fileName+'.csv');\n downloader.click();\n };\n\n\nThis works flawlessly in Chrome.\n\nOther browsers are able to see the CSV variable in a console.log, but won't download. Edge will output a warning in console with a giant link containing the CSV contents which if I click with show the CSV as a string variable in the Debugger window. Firefox gives no error or warning when the above function is triggered. \n\nI've tried adding compatibility for different browsers, but it doesn't change anything. \n\n<system.webServer>\n <httpProtocol>\n <customHeaders>\n <clear />\n <!--<add name=\"X-UA-Compatible\" value=\"IE=10\" />\n <add name=\"X-UA-Compatible\" value=\"IE=11\" />-->\n <add name=\"X-UA-Compatible\" value=\"IE=edge\" />\n </customHeaders>\n </httpProtocol>\n</system.webServer>"
] | [
"angularjs",
"download",
"createelement",
"encodeuricomponent"
] |
[
"CSS li list, margin from the left",
"I don`t understand why I have margin from the left:\n\nCSS:\nhtml, body {\n font-family:Myriad Pro, sans-serif;\n font-size:18px;\n color:#000;\n margin:0px;\n padding:0px;\n background: url('./images/background.png');\n}\n\n#container {\n width:890px;\n height:530px;\n margin:36px auto;\n}\n\n#userList {\n width:228px;\n height:355px;\n float:right;\n border:1px solid #cccccc;\n}\n\n.users li {\n list-style-type:none;\n background-color: #f2f2f2;\n width:100%;\n height:50px;\n border-bottom: 1px solid #cccccc;\n}\n\nHTML:\n<div id="userList"><ul class="users"><li><img src="./pic/none.png">Piet van Meerdijk</li><li><img src="./pic/none.png">Henk v/d Wal</li></ul></div>\n\nWhen I put margin-left:-40px; in the CSS code the li item will be on the left now, but then have I a margin on the right. Why?\nJSfiddle: http://jsfiddle.net/8Cwcy/"
] | [
"html",
"css",
"margin"
] |
[
"stream wrapper and writing to php://memory results in internal server error 500",
"I'm trying to write a custom wrapper in PHP using the Stream Wrapper class. What I have now is pretty much simple and straight forward.\n\nclass Stream\n{\n public $resource;\n\n public static function wrap()\n {\n stream_wrapper_unregister(self::PROTOCOL);\n stream_wrapper_register(self::PROTOCOL, __CLASS__);\n }\n\n public static function unwrap ( )\n {\n stream_wrapper_restore(self::PROTOCOL);\n }\n\n public function stream_open ( $path, $mode, $options, &$openedPath )\n {\n $this->unwrap();\n\n // Open memory\n $this->resource = fopen('php://memory', 'rb+');\n $code = file_get_contents ( $path );\n\n // Write code to memory\n fwrite($this->resource, $code);\n rewind($this->resource);\n\n $this->wrap();\n\n return $this->resource !== false;\n }\n\n // Left out the other methods that the stream wrapper needs \n // to keep this example simple\n // ...\n}\n\n\nIn the beginning of my code I open the stream by calling: Stream::wrap().\n\nThen it basically reads any file that is require'ed or include'ed throughout my application. The code is then put into php://memory and that's it. Nothing special yet.\n\nBottom line is, is that this piece of code should work. But it throws an Internal Server Error when I try to run my application. I have a Linux hosting provider (PHP 5.4.21) where my code is currently hosted.\n\nBut when I move my code from my current hoster to some other Linux hosting company (PHP 5.5.x), then everything works fine.\n\nWhen I even move the code to my local computer (PHP 5.4.6) and run it, then everything works fine as well.\n\nSo obviously the problem lies at the hosting company that I currently have. I know I have to mail them. But I have no clue what is causing the problem exactly. It would be good if I could at least point them in a certain direction. All I have now is \n\n\n my code isn't working on your servers which is working fine on some\n other server\n\n\nI'm afraind that that isn't enough information for them.\n\nI have checked the php://memory limit which is set to 256M. That should be more than enough. So I have no clue what else to look for. The Apache log didn't had any information either.\n\nSo I was hoping anyone here had an idea of what could be causing this problem. Perhaps some permission issue somewhere or something?"
] | [
"php",
"linux",
"stream-wrapper",
"php-stream-wrappers"
] |
[
"How to find year from year-month variable",
"I have a dataframe with a date vector. I would like to replace it with a year-month variable. I did so following the code below.\ndates <- as.Date("2004-02-06")\nym <- format(dates, "%Y-%m")\n\nI would like to be able to find the year (or month) using the ym variable but year(ym) and month(ym) don't work. How could I go about it?"
] | [
"r",
"date"
] |
[
"missing left parenthesis, i cant find a mistake. can someone help me?",
"CREATE TABLE PRESCRIPTION\n(\n prescription_no NUMBER (7), \n CONSTRAINT prescription_no_pk PRIMARY KEY,\n pr_patient_no VARCHAR2(6), \n CONSTRAINT pr_patient_no_fk FOREIGN KEY(patient) REFERENCES (patient_no),\n pr_drug_no NUMBER(5), \n CONSTRAINT pr_drug_no_fk FOREIGN KEY (drug) REFERENCES (drug_no),\n drug_start_date DATE,\n units_per_day NUMBER(3,2),\n drug_end_date DATE\n);"
] | [
"sql",
"oracle-sqldeveloper"
] |
[
"SQL Remove duplicate records with MAX",
"My query returns some duplicate records. I've figured out the reason is some assets have 2 records in the PS_ASSET_ACQ_DET table. This is due to the way assets are set up by a certain group of users.\n\nIn the PS_ASSET_ACQ_DET table, there is a field called \"seq_nbr_6\" that gets incremented with each new record. I would like to select record with the greatest value in this table for each asset.\n\nI tried using MAx (seq_nbr_6) in the SELECT statement and then using a GROUP BY on all of the other fields in the SELECT statement but that didn't work for me.\n\nI'm looking for a way to only return 1 record from the PS_ASSET_ACQ_DET table. Thanks for your help and taking the time to look at this question....\n\nSELECT \npdr.ACCOUNT_FA AS acct,\nir.ERAC_BRANCH_LGCY_CD AS gpbr,\npdr.DEPTID,\npa.ASSET_ID,\npa.serial_id,\npa.tag_number,\npa.asset_type,\npa.DESCR,\npb.IN_SERVICE_DT,\npb.LIFE,\npdr.COST,\npant.ACCUM_DEPR AS accum_depr,\npant.NET_BK_VALUE AS net_book_value,\npdr.FISCAL_YEAR AS fy,\npdr.ACCOUNTING_PERIOD AS ap,\npdr.category,\npad.voucher_id,\npad.po_id,\npdr.location AS loc1,\npant.location AS loc2\n\nFROM PSFS.PS_ASSET pa\n\nINNER JOIN PSFS.PS_BOOK pb ON pb.ASSET_ID= pa.ASSET_ID AND pb.BUSINESS_UNIT = pa.BUSINESS_UNIT \n\nINNER JOIN PSFS.PS_DEPR_RPT pdr ON pdr.ASSET_ID= pb.ASSET_ID AND pdr.BUSINESS_UNIT = pb.BUSINESS_UNIT AND pdr.BOOK = pb.BOOK\n\nINNER JOIN PSFS.PS_ASSET_ACQ_DET pad ON pad.ASSET_ID= pb.ASSET_ID AND pad.BUSINESS_UNIT = pb.BUSINESS_UNIT AND pdr.BOOK = pb.BOOK\n\nINNER JOIN PSFS.PS_ASSET_NBV_TBL pant ON pant.BUSINESS_UNIT = pb.BUSINESS_UNIT\nAND pant.ASSET_ID = pb.ASSET_ID\nAND pant.BOOK = pb.BOOK\n\nINNER JOIN INTGRT_RPT.DIM_LOCATION IR ON pdr.deptid = ir.erac_branch_ps_org_cd AND ir.curr_lrd_row_flg = 1\n\nWHERE pdr.ACCOUNT_FA IN ('130','150','315',330','350')\nAND pdr.FISCAL_YEAR =2016\nAND pdr.ACCOUNTING_PERIOD =3\nAND pdr.GROUP_ASSET_FLAG <> 'M'"
] | [
"sql",
"duplicates",
"max"
] |
[
"Apply calculation to a 2d array in vb.net",
"I have a 2d array and I want to do a calculation on each element in the array and then return the index which results in the smallest value. \n\nI have tried iterating through each element in the 2d array and running the calculation. If the calculated result is smaller than the currently stored minimum I set that to the minimum. \n\nThis works but it runs so slowly it makes the solution a non starter. It performs each calculation quickly but because of the number of elements in the array the calculation for the whole array is stupidly long. \n\nAny advice would be helpful."
] | [
"vb.net",
"arrays"
] |
[
"Separate a Table into multiple database Based on a field in mySQL",
"I have a News Feeds application, that Hundreds user send query to server and get news. For better performance in database connection (more rapid), Is it rational that separate news in multiple database Based on news Type field (total news,province news)?"
] | [
"php",
"mysql",
"database"
] |
[
"Smartface adding buttons that navigate to another page in the app",
"I tried adding buttons that redrict to certain pages however every time I change one button it changes all the other buttons as to where the page would navigate.\nThis is what happens...\n what the script editor shows\n what happens to other buttons when I change just one button"
] | [
"jquery",
"smartface.io"
] |
[
"While loop not quitting",
"My program is supposed to calculate the miles per gallon for a trip.\n\nThe program runs fine until I try to quit when I'm inside the loop. It's supposed to quit when the user types in \"quit\" at any point in the three inputs but it just goes to the next input. Even when I type in quit in all three inputs, it just crashes. \n\nThings I've tried:\n\n\nTyping quit in all three inputs\nUsing only 1 condition for the loop instead or three\nPutting strBeginningOdometerReading.ToUpper() != 1-10000000\nChanging all the || to &&\nChanging QUIT to a string variable\n\n\nusing System;\n\nnamespace MPG\n{\n class Program\n {\n static void Main()\n {\n //Declare the variables\n string strBeginningOdometerReading, strEndingOdometerReading, strNumberOfGallons;\n double dblBeginningOdometerReading, dblEndingOdometerReading, dblNumberOfGallons, dblMilesPerGallon, dblMilesTravelled;\n\n //Priming prompt & read\n Console.Write(\"Enter the beginning odometer reading: \");\n strBeginningOdometerReading = Console.ReadLine();\n Console.Write(\"Enter the ending odometer reading: \");\n strEndingOdometerReading = Console.ReadLine();\n Console.Write(\"Enter the number of gallons purchased for six fill-ups during the trip.\");\n strNumberOfGallons = Console.ReadLine();\n\n //Convert\n dblBeginningOdometerReading = Convert.ToDouble(strBeginningOdometerReading);\n dblEndingOdometerReading = Convert.ToDouble(strEndingOdometerReading);\n dblNumberOfGallons = Convert.ToDouble(strNumberOfGallons);\n\n //Calculations\n dblMilesTravelled = dblEndingOdometerReading - dblBeginningOdometerReading;\n dblMilesPerGallon = dblMilesTravelled / dblNumberOfGallons;\n\n //Display\n Console.WriteLine(\"Miles Travelled: \\t\\t\\t {0:n2} miles\", dblMilesTravelled);\n Console.WriteLine(\"Number of Gallons Purchased for 6 fill-ups: {0:n2} gallons\", dblNumberOfGallons);\n Console.WriteLine(\"Miles per Gallon (MPG): \\t\\t\\t {0:n2} mpg\", dblMilesPerGallon);\n\n //While loop\n while (strBeginningOdometerReading.ToUpper() != \"QUIT\" || strEndingOdometerReading.ToUpper() != \"QUIT\" || strNumberOfGallons.ToUpper() != \"QUIT\")\n {\n\n Console.WriteLine(\"Enter QUIT at any time to exit.\");\n Console.Write(\"Enter the beginning odometer reading: \");\n strBeginningOdometerReading = Console.ReadLine();\n Console.Write(\"Enter the ending odometer reading: \");\n strEndingOdometerReading = Console.ReadLine();\n Console.Write(\"Enter the number of gallons purchased for six fill-ups during the trip: \");\n strNumberOfGallons = Console.ReadLine();\n\n //Convert\n dblBeginningOdometerReading = Convert.ToDouble(strBeginningOdometerReading);\n dblEndingOdometerReading = Convert.ToDouble(strEndingOdometerReading);\n dblNumberOfGallons = Convert.ToDouble(strNumberOfGallons);\n\n //Calculations\n dblMilesTravelled = dblEndingOdometerReading - dblBeginningOdometerReading;\n dblMilesPerGallon = dblMilesTravelled / dblNumberOfGallons;\n\n //Display\n Console.WriteLine(\"Miles Travelled: \\t\\t\\t {0:n2} miles\", dblMilesTravelled);\n Console.WriteLine(\"Number of Gallons Purchased for 6 fill-ups: {0:n2} gallons\", dblNumberOfGallons);\n Console.WriteLine(\"Miles per Gallon (MPG): \\t\\t\\t {0:n2} mpg\", dblMilesPerGallon);\n } // end while\n } //end Main\n } //end class\n} //end namespace"
] | [
"c#"
] |
[
"How to quickCheck all possible cases for a type that is both Enum and Bounded?",
"I have a quickCheck property which involves generating elements for a sum type which has only two elements.\n\nClearly the default number of test cases, 100, is too many for this case, and so I've used withMaxSuccess to reduce the number of cases to 3. This runs quickly but is not ideal for two reasons. Firstly, the three test cases run are more than the two required. And secondly, the three cases are not comprehensive due to the 1-in-4 chance that all three involve the same element, to the exclusion of the other one.\n\nI have tried QuickCheck's forAll modifier, which seemed like it might do what I am looking for, but the number of test cases run was still 100.\n\nIf I have a type with a finite number of elements to be the generator for a QuickCheck test, is there a way to set QuickCheck to test the property comprehensively over the type by running it with each element once?\n\nTo qualify whether the type has a finite number of elements, perhaps it can be qualified by both the Enum and Bounded typeclasses."
] | [
"haskell",
"quickcheck"
] |
[
"Zend PDO issue after Ubuntu 15.04",
"I have a LAMP server set up on Ubuntu. Many Magento and MediaWiki installations were working well before I upgraded to Ubuntu 15.04. \n\nAfter the upgrade, attempting to load one of the pages served by my localhost raises the error The PDO extension is required for this adapter but the extension is not loaded \n\nI typed php -m and saw that PDO and pdo_mysql are both loaded. My php version is 5.6.4. None of the installations use an individual php.ini file. I tried to add \n\nextension=pdo.so\nextension=pdo_mysql.so\n\n\nto /etc/php5/apache2/php.ini but this did not affect my situation. I have also verified that the latest version of php5-mysql is installed. \n\nHas anyone else seen this problem? Is it specific to the Ubuntu upgrade, or am I just missing a configuration setting somewhere? \n\nEdit: php info\n\nAfter reading Lea's answer below, I am to the point where php -i | grep -i pdo produces the output:\n\n/etc/php5/cli/conf.d/10-pdo.ini,\n/etc/php5/cli/conf.d/20-pdo_mysql.ini,\nPDO\nPDO support => enabled\nPDO drivers => mysql\npdo_mysql\nPDO Driver for MySQL => enabled\npdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock\n\n\nThe test script also runs successfully."
] | [
"php",
"ubuntu",
"pdo"
] |
[
"Curl error protocol not supported",
"I am trying to delete components from nexus repository created component for delete by generating REST API \n\ncurl -X DELETE --header 'Accept: application/json' 'http://localhost:8081/service/siesta/rest/beta/components/sam'\n\n\nI get these errors:\n\ncurl: (6) Could not resolve host: application\ncurl: (1) Protocol \"'http\" not supported or disabled in libcurl"
] | [
"curl",
"cmd"
] |
[
"Sandbox and running /usr/bin/purge using system()",
"In an app that is on the Mac App Store, I was doing the following:\n\nsystem(\"/usr/bin/nice -n 20 /usr/bin/purge &> /dev/null &\");\n\n\nThis worked fine, but now I'm trying to submit a new version, and they're forcing me to enable the Sandbox. However, with the sandbox, that call fails, giving messages like this in the Console:\n\n7/20/13 12:58:59.000 AM kernel[0]: Sandbox: sh(28537) deny file-read-data /dev/ttys000\n7/20/13 12:58:59.968 AM purge[28538]: bootstrap_look_up(): Permission denied\n7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny mach-lookup com.apple.appleprofilepolicyd\n7/20/13 12:59:00.521 AM purge[28538]: <CPDevice.m:3813> Unable to create new counter client.\n7/20/13 12:59:00.523 AM purge[28538]: <CPOSX.m:1188> Unable to get user client so as to poke the kernel.\n7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny iokit-open ApplePerformanceCounterManagerUserClient\n7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny iokit-open AppleProfileUtilitiesUserClient\n7/20/13 12:59:00.000 AM kernel[0]: AppleProfileUtilitiesUserClient: bad busy count (0,-1)\n7/20/13 12:59:00.000 AM kernel[0]: Backtrace 0xffffff802d22d4d2 0xffffff802d231fc9 0xffffff802ceb3137 0 0 0 0\n\n\nIs there any way to work around this?"
] | [
"objective-c",
"cocoa",
"osx-mountain-lion",
"sandbox"
] |
[
"Is there a way with htaccess to redirect a URL if URL contains foo or bar?",
"Is there a way with htaccess to always redirect a URL to the home page if URL contains foo or bar?\n\nI think I just need to be a bit more clear on what I am trying to accomplish. I am trying to do this with a Wordpress website. I have tried a few different redirects, but none seem to be working.\n\nWhat I am trying to do is if a URL such as:\nhttp://www.domain.com/folder/RandomPartOfURL-xxx/\nor\nhttp://www.domain.com/folder/RandomPartOfURL-yyy/\n\nThe system redirects the user back to another page. The xxx or yyy on the end of the URL will always be the same 2 or 3 things, but the random part is always random. The URL's that I need to redirect will always be in this format and all of the URL's that meet this structure just need to get directed to the same exact \"catch all\" URL.\n\nI just dont have enough of a grasp on htaccess to get this to work the way I want yet. I can get it to work where all URL's accessed within the folder redirect, but most of the URL's within that folder structure still need to work correctly.\n\nThanks again for the help."
] | [
"regex",
".htaccess",
"redirect"
] |
[
"Get data from PLC (micrologix 1100) to python",
"I\"m looking for get data of a PLC with python to make a lot of work with it.I only need get the \"0\" and \"1\" value. I found this python library pycomm ( https://pypi.python.org/pypi/pycomm/1.0.7 ) where is this snippet too:\n\nfrom pycomm.ab_comm.slc import Driver as SlcDriver\n\n\nif __name__ == '__main__':\n c = SlcDriver(True, 'delete_slc.log')\n if c.open('172.16.2.160'):\n\n print c.read_tag('S:1/5')\n print c.read_tag('S:60', 2)\n\n print c.write_tag('N7:0', [-30, 32767, -32767])\n print c.write_tag('N7:0', 21)\n print c.read_tag('N7:0', 10)\n\n print c.write_tag('F8:0', [3.1, 4.95, -32.89])\n print c.write_tag('F8:0', 21)\n print c.read_tag('F8:0', 3)\n\n print c.write_tag('B3:100', [23, -1, 4, 9])\n print c.write_tag('B3:100', 21)\n print c.read_tag('B3:100', 4)\n\n print c.write_tag('T4:3.PRE', 431)\n print c.read_tag('T4:3.PRE')\n print c.write_tag('C5:0.PRE', 501)\n print c.read_tag('C5:0.PRE')\n print c.write_tag('T4:3.ACC', 432)\n print c.read_tag('T4:3.ACC')\n print c.write_tag('C5:0.ACC', 502)\n print c.read_tag('C5:0.ACC')\n\n c.write_tag('T4:2.EN', 0)\n c.write_tag('T4:2.TT', 0)\n c.write_tag('T4:2.DN', 0)\n print c.read_tag('T4:2.EN', 1)\n print c.read_tag('T4:2.TT', 1)\n print c.read_tag('T4:2.DN',)\n\n c.write_tag('C5:0.CU', 1)\n c.write_tag('C5:0.CD', 0)\n c.write_tag('C5:0.DN', 1)\n c.write_tag('C5:0.OV', 0)\n c.write_tag('C5:0.UN', 1)\n c.write_tag('C5:0.UA', 0)\n print c.read_tag('C5:0.CU')\n print c.read_tag('C5:0.CD')\n print c.read_tag('C5:0.DN')\n print c.read_tag('C5:0.OV')\n print c.read_tag('C5:0.UN')\n print c.read_tag('C5:0.UA')\n\n c.write_tag('B3:100', 1)\n print c.read_tag('B3:100')\n\n c.write_tag('B3/3955', 1)\n print c.read_tag('B3/3955')\n\n c.write_tag('N7:0/2', 1)\n print c.read_tag('N7:0/2')\n\n print c.write_tag('O:0.0/4', 1)\n print c.read_tag('O:0.0/4')\n\n c.close()\n\n\nExcuse me for my unknown, but the only thing what i need know if is enought \"Change\" the (172.16.2.160) ip to link to the PLC, right?\n\n\"And select the correct tags\"\n\nThank you for the future help and sorry for this \"rare question\" i can\"t test the code with a PLC right now. (maybe in few weeks) So i cannot try succesfully this part of the code. And i need start to work in the other part.(Only for be sure what i can get the data with python. If you know another library in python please tell me that option)"
] | [
"python",
"plugins",
"plc"
] |
[
"html email with inline image shows junk character in IPhone6s but not in Iphone5s,sending email through JAVA",
"I am sending inline image email through java,which is working in gmail,yahoo email,except apple mail(9.3.2),working in apple mail(9.0).It is showing junk character in apple mail(9.3.2).\nCan any one suggest why it is happening?\n\nMimeBodyPart messageBodyPart = new MimeBodyPart();\nmessageBodyPart.setContent(htmlBody,\"text/html; charset=UTF-8\");\n\n // creates multi-part\n Multipart multipart = new MimeMultipart();\n multipart.addBodyPart(messageBodyPart);\n\n // adds inline image attachments\nif (mapInlineImages != null && mapInlineImages`*enter code here*`.size() > 0) {\n\n Set<String> setImageID = mapInlineImages.keySet();\n\n for (String contentId : setImageID) {\n MimeBodyPart imagePart = new MimeBodyPart();\n imagePart.setHeader(\"Content-ID\", \"<\" + contentId + \">\");\n imagePart.setDisposition(MimeBodyPart.INLINE);\n String imageFilePath = mapInlineImages.get(contentId);\n try {\n imagePart.attachFile(imageFilePath);\n } catch (IOException ex) {\n log.error(ex.getMessage());\n }\n\n multipart.addBodyPart(imagePart);\n }\n }\n if(attachments!=null){\n multipart.addBodyPart(messageBodyPart1);\n }\n message.setContent(multipart);\n\n Transport.send(message);"
] | [
"java",
"phantomjs",
"html-email"
] |
[
"Quickbooks: Unable to connect with non Sandbox company",
"I am being unable to get access token for the company my account is part of. It is rather connecting with Sandbox companies only. How do I remove it? Below is screen of oAuth Playground\n\nAs you can see it is only showing Sandbox companies once I made a couple while exploring.\n\n\n\nUpdate\n\nError while generating tokens for production key:"
] | [
"quickbooks",
"quickbooks-online"
] |
[
"Yet another NoClassDefFoundError puzzle",
"I created two jar files, my.common.jar which contain helper classes and methods (mostly static methods). I also created a jar file, test.jar with a main method that calls a static method in a class in my.common.jar.\n\nEverything works fine when I launch main like this:\n\njava -classpath path/to/myjars/my.common.jar:./test.jar test.Tester\n\n\nTester is the class in test.jar that contains method main.\n\nBut I get NoClassDefFoundError my/common/Myclass when I run it this way:\n\njava -classpath path/to/myjars/my.common.jar -jar test.jar\n\n\nI tried so hard, but I am not able to figure out why it fails or how to resolve this issue. I do appreciate your help.\n\n----- addendum ----\nI forgot to mention that the manifest file in test.jar looks like so:\n\n Manifest-Version: 1.0\n Build-Jdk: 1.6.0_13\n Created-By: Apache Maven\n Main-Class: test.Tester\n Archiver-Version: Plexus Archiver"
] | [
"java",
"noclassdeffounderror"
] |
[
"change value of name attribute using jquery",
"I print data in table and try to change name of specific hidden field but i cant my code is as below \n\n <table class=\"table table-hover\">\n <thead>\n <tr>\n <th>\n <input type=\"checkbox\">\n </th>\n <th>sr no</th>\n <th>seller</th>\n <th>shape</th>\n <th>size</th>\n <th>color</th>\n <th>discount</th>\n <th>client</th>\n </tr>\n </thead>\n <tbody>\n @foreach($cod_details as $cod)\n <tr>\n <td>\n <input type=\"checkbox\" name=\"ids[]\" id=\"{{ $cod->id }}\" value=\"{{ $cod->id }}\">\n <input type=\"hidden\" value=\"{{ $cod->report_no }}\" id=\"{{ $cod->report_no }}\" name=\"\" class=\"report\">\n </td>\n <td>{{ $cod->id }}</td>\n <td>{{ $cod->seller }}</td>\n <td>{{ $cod->shape }}</td>\n <td>{{ $cod->size }}</td>\n <td>{{ $cod->color }}</t\n <td>{{ $cod->discount }}</td>\n <td>{{ $cod->client }}</td>\n </tr>\n @endforeach\n </tbody>\n </table>\n\n\nthis shows all details in table and working perfect.\n\n$(document).ready(function(e){\n $('input[type=\"checkbox\"]').click(function(){\n if($(this).prop(\"checked\") == true){\n $(this).closest('input[type=\"hidden\"]').attr('name','report_no[]');\n\n }\n else{\n\n }\n });\n });\n\n\nI try to add name = report_no[] on checked of checkbox but i cant."
] | [
"javascript",
"jquery"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.