texts
sequence | tags
sequence |
---|---|
[
"Apply a function to all combinations of two lists in R",
"I am trying to find a concise way to apply a function over combinations of lists - with the possible extension of do parallel computing. It seems to me that cross() function from the purrr package is not able to return lists as output.\n\nI tried a nested lapply.\n\ndata1 <- list(a = xts(rep(2, 10), as.Date(1:10)), b = xts(rep(3, 10), as.Date(1:10)), c = xts(rep(4, 10), as.Date(1:10)))\ndata2 <- list(a = xts(rep(1.5, 10), as.Date(1:10)), b = xts(rep(2.5, 10), as.Date(1:10)), c = xts(rep(3.5, 10), as.Date(1:10)), d = xts(rep(4.5, 10), as.Date(1:10)))\ndata <- lapply(data1, function(x) lapply(data2, function(y) y+x))\ndata <- rlist::list.flatten(data)\nsapply(data, first)\n# similar to\n# outer(c(2,3,4), c(1.5,2.5,3.5,4.5), '+')\n# but returns new lists as output\n\n\nThe optimal case would be a fast parallel solution. My actual lists contain around 2000 elements each, and each xts in it is around 15 years long."
] | [
"r",
"list",
"purrr"
] |
[
"How to define the stored procedure input data types , to be based on other columns data types",
"I have created a stored procedure in SQL Server 2008 R2 to perform an advanced search like this:\n\nALTER PROCEDURE [dbo].[AdvanceSearch]\n -- Add the parameters for the stored procedure here\n @SearchType nvarchar(10) = null,\n @SerialNumber varchar(50) = null,\n//code goes here\n\n\nCurrently the @SerialNumber variable represents a real column inside a table named Assets. The serial number column has a data type of varchar(50) and it allows null values. \n\nSo what I did is that i manually define the same datatype which is varchar(50). But my question is what will happen if in the future I change the datatype for the SerialNumber column inside the Assets table, then I have to change the type in my stored procedure. \n\nIs there a way to define the datatype for the @SerialNumber parameter inside the stored procedure to be the same as the datatype of a column inside another table? So that if the column type changes the stored procedure parameter will have the new datatype? \n\nThanks"
] | [
"sql",
"sql-server",
"stored-procedures",
"sql-server-2008-r2"
] |
[
"Move a rotating object in a HTML Canvas",
"I have an HTML canvas. Inside it I've drawn a hexagon. The hexagon rotates in place.\nWell now I want this rotating hexagon to move along a set path. I want to be able to track it's location.\n\nNormally when you want to move an object you say: (object.x+howmuchtomove) and it will simply\nmove by that much, and you can track it's whereabouts by just adding object.x+howmuchtomove to get the x coord.\n\nWell in this case I'm using translate and rotate to give it the rotating effect. So adding +2 to it's x location simply makes it rotate in a bigger circle.\n\nHere is what I've got, thanks!\n\n retObject.draw = function() { \n // Wipe the canvas \n ctx.fillStyle = \"rgba(0, 0, 0, 1)\"; \n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n // Draw rotating shape\n ctx.save(); // Don't rotate everything\n ctx.strokeStyle=\"red\"; // Set Color \n ctx.translate(356.5, 700); // Center pivot inside hexagon\n ctx.rotate(rotValue*(Math.PI/180)); // Rotate \n ctx.translate(-356.5, -700); // Un-Translate \n for (i=0;i<3;i++) {\n ctx.beginPath(); \n ctx.moveTo(300, 700); \n ctx.lineTo(330, 650);\n ctx.lineTo(383, 650);\n ctx.lineTo(413, 700);\n ctx.lineTo(383, 750);\n ctx.lineTo(330, 750);\n ctx.lineTo(300, 700);\n ctx.stroke(); // Draw Hexagon\n }\n ctx.restore(); // Get back normal\n }\n\n\nNote that draw() is inside of a loop so that it gets called every frame.\n\nSo, for simplicity sake, say I just want this rotating hexagon to drop straight down.\nBasically I'm wanting to add +1 to it's y coordinate every frame."
] | [
"javascript",
"html",
"canvas"
] |
[
"How to send a facebook notification to a user using curl without facebook SDK",
"I tried the following with the following output from Facebook since this requires a post.\n\n$ch = curl_init('https://graph.facebook.com/appUserId/notifications?access_token=*****&href=index.php&template=test');\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\ncurl_setopt($ch,CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\ncurl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);\n$response = curl_exec($ch);\nvar_dump($response);\nvar_dump(json_decode($response));\n\n\nThen from this i get the following, What might i be doing wrong?\n\nstring '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"\n xml:lang=\"en\" lang=\"en\" id=\"facebook\">\n <head>\n <title>Facebook | Error</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n <meta name=\"robots\" content=\"noindex,nofollow\" />\n <style type=\"text/css\">\n html, body {\n margin: '... (length=2131)\nnull"
] | [
"php",
"facebook",
"http",
"facebook-graph-api",
"curl"
] |
[
"How to perform mass delete on Laravel from Vue?",
"I'm trying to make a massive delete function for a website to delete a list of products at the same time. I insert the data through an excel.\n\nController function\n\npublic function destroy(Request $request)\n{\n ini_set('max_execution_time', 300);\n $products = $request->all();\n\n try {\n DB::beginTransaction();\n foreach ($products as $product) {\n $dbProduct = $this->getProduct($product['SKU']);\n Log::error($dbProduct);\n $dbProduct->delete();\n }\n DB::commit();\n } catch (Exception $e) {\n DB::rollBack();\n throw new HttpException(500, 'Sucedio un error eliminando la información favor intentar de nuevo');\n }\n}\n\nprivate function getProduct($sku)\n{\n $product = Product::where('sku', $sku)->first();\n return $product;\n}\n\n\nI\"m not sure how to do the @click method on the vue part, right now i have this, but this is used to upload on other page, not sure what to change to make it delete instead. It's receiving an array that has been separated into groups of 50, thats the (data, index).\n\nsendData(data, index) {\n this.loading = true;\n this.error = {};\n this.$http.post(this.baseUrl, data, this.params).then(\n () => {\n this.successAction();\n this.statuses[index] = 1;\n this.errorDis = false;\n },\n res => {\n this.showErrors(res);\n this.statuses[index] = 2;\n this.errorDis = true;\n }\n );\n}\n\n\nCurrently i get a success status but it's not deleting the products"
] | [
"php",
"laravel",
"vue.js"
] |
[
"Creating a endpoint to return a list of objects from a database using Spring",
"I have a database and I want to use a endpoint to get the data. But I want to filter the data so that only certain values are returned. What I want is to call the endpoint and then get the data that I wanted out of it. I have made two methods one for calling all the data and another for calling only 1 record in the database. they both working good, but I want to now get multiple records from the database. This is what I have so far:\n\n //This get every record\n @RequestMapping(\n value = API_PREFIX_1_0 + ENDPOINT_coupon + \"/getCoupon\",\n method = RequestMethod.GET)\npublic Collection<Coupon> couponGetAll()\n{\n return couponService.getAll();\n}\n\n//this get only one record based on the ID of the table\n@RequestMapping(\n value = API_PREFIX_1_0 + ENDPOINT_coupon + \"/{id}\", \n method = RequestMethod.GET)\npublic Coupon couponGetById(@PathVariable(value = \"id\") final long id) {\n return couponService.getById(id);\n}\n\n\nWhat I want to do is use an array or a list of id to get the data from the server.\nThank you for any help with this"
] | [
"java",
"spring",
"endpoint"
] |
[
"Displaying custom font icon code in Swift dynamically",
"I need to display icons dynamically from a custom font in swift.\nThe icon format is like: \\u{code} example: \\u{e054}.\nThe dynamic value of the icon contains only the code and doesn't include \\u{ and } therefore I need a way to build the string and concatenate things.\nI made it working and I can see the icons but only if I hardcode them, so this works and displays the icon:\n// works and displays and icon something like \nText("\\("\\u{e054}")")\n .font(.custom("custom-font", size: 30))\n\nBut I need to display it dynamically and all the solution below didn't work and displays the bar text but not the icon:\n// doesn't work and displays \\u{e054} instead of the icon\nText("\\\\u{\\(icon_code)}")\n .font(.custom("custom-font", size: 15))\n\n// also doesn't work and displays \\u{e054} instead of the icon\nText( #\\u{\\#(icon_code)}#)\n .font(.custom("custom-font", size: 15))"
] | [
"swift",
"fonts",
"swiftui"
] |
[
"Error while running Django app",
"When I run django project in pycharm or cmd, I get this error. What Should I do?\n\n\"C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\bin\\runnerw.exe\" C:\\Python34\\python.exe C:/Users/admin/PycharmProjects/untitled/manage.py runserver 8000\n Validating models...\n\n0 errors found\nAugust 15, 2014 - 13:58:27\nDjango version 1.6.5, using settings 'untitled.settings'\nStarting development server at http://127.0.0.1:8000/\nQuit the server with CTRL-BREAK.\nUnhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x022A32B8>\nTraceback (most recent call last):\n File \"C:\\Python34\\lib\\site-packages\\django\\utils\\autoreload.py\", line 93, in wrapper\n fn(*args, **kwargs)\n File \"C:\\Python34\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py\", line 127, in inner_run\n ipv6=self.use_ipv6, threading=threading)\n File \"C:\\Python34\\lib\\site-packages\\django\\core\\servers\\basehttp.py\", line 167, in run\n httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)\n File \"C:\\Python34\\lib\\site-packages\\django\\core\\servers\\basehttp.py\", line 109, in __init__\n super(WSGIServer, self).__init__(*args, **kwargs)\n File \"C:\\Python34\\lib\\socketserver.py\", line 429, in __init__\n self.server_bind()\n File \"C:\\Python34\\lib\\site-packages\\django\\core\\servers\\basehttp.py\", line 113, in server_bind\n super(WSGIServer, self).server_bind()\n File \"C:\\Python34\\lib\\wsgiref\\simple_server.py\", line 50, in server_bind\n HTTPServer.server_bind(self)\n File \"C:\\Python34\\lib\\http\\server.py\", line 135, in server_bind\n self.server_name = socket.getfqdn(host)\n File \"C:\\Python34\\lib\\socket.py\", line 460, in getfqdn\n hostname, aliases, ipaddrs = gethostbyaddr(name)\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 6: invalid continuation byte"
] | [
"python",
"django",
"python-3.x",
"django-forms"
] |
[
"restoring deleted file using bash in unix",
"good evening\n\ni have a task to complete and have tried the following but does not work\n\n#!/bin/bash\n\nFPath=$(grep $1 $HOME/.restore.info | cut -d\":\" -f2)\nFName=$(grep $1 $HOME/.restore.info | cut -d\":\" -f1)\nif [ $# -eq 0 ]\nthen\n echo \"No input detected\"\n exit $?\n\nelif [ \"$FName\" = $1 ]\nthen\n echo \" Match found and restored to its original location\"\n mv ~/deleted/$1 $FPath\nelse\n echo \"File does not exist\"\n exit $?\nfi\n\n\nit is supposed to restore deleted files in a specific folder to its original location\n\nhowever, it keeps saying file does not exist, even though the file exists.\n\ni also need to create a case for the existing files and if user chooses to over write the existing files. please help me with this too\n\ni appreciate your assistance"
] | [
"linux",
"bash",
"shell",
"ubuntu",
"unix"
] |
[
"New to JS, want to display strings",
"Say I have JSON object with data like this (in a separate .json file):\n\nevidenceStrings = [\n{\"jokeid\": 0, \"evidence\": [\"\\My God you're right! I never would've thought of that!\", \"this look that says \\My God you're right! I never would've thought of that!\\\", \" \\My God you're right! I never would've thought of that!\\\"]},\n{\"jokeid\": 1, \"evidence\": [\"the man didn't have to watch\"]},\n{\"jokeid\": 2, \"evidence\": [\"knocking down trees with your face\", \"knocking down trees with your face. \", \" knocking down trees with your face. \", \"with your face.\", \"knocking down trees with your face\"]}\n]\n\n\nI want to display the \"evidence\" in an HTML file. The problem is that I'm reading content from another .js file and displaying it's content using a for loop.\n\nfor(var i = 0; i < jokes.length; i++) {\n // display string at index 0 of an array in a .js file\n\n\ni here refers to the jokeid in the JSON object. Now what I want is, that for the given i, extract my evidence from the JSON object, and display it (preferably with a newline after every string."
] | [
"javascript"
] |
[
"Google Form - Filling one of the fields automatically from the email body",
"I have a google form that is sent out each time a customer makes a purchase. The form has the below fields:\n\n\nbill_no\ncustomer_name\nage\nphone_number\n\n\nThis is sent out as an email with the bill_no and a google form link in the email body which the customer opens to fill the form. \n\nI am trying to check if its possible to directly pass the bill_no that is present in the email body to the first question in the google form which asks for the bill_no. I do not want the customer to manually enter this bill_no but rather trying to see if it can be auto populated and the customer fills the remaining questions in the form."
] | [
"email",
"google-forms"
] |
[
"how set up an array and load the contenta using silex and twig",
"I am looking to load an array of text into a twig template using silex,\n\nHow would I go about this? Would I set the array up as standard below?\n\n(basic example)\n\n$users = array(\n'Username' => array(\n 1 => 'Mike',\n 2 => 'Sam',\n 3 => 'Charlotte'\n ),\n);\n\n\nOr would I create it using silex along the lines of:\n\n(example taken from silex documentation)\n\n$blogPosts = array(\n1 => array(\n 'date' => '2011-03-29',\n 'author' => 'igorw',\n 'title' => 'Using Silex',\n 'body' => '...',\n ),\n);\n\n $app->get('/blog', function () use ($blogPosts) {\n $output = '';\n foreach ($blogPosts as $post) {\n $output .= $post['title'];\n $output .= '<br />';\n}\n\n return $output;\n});\n\n\nIf I were to do it like that how would I go about loading that information into a twig template?"
] | [
"php",
"arrays",
"twig",
"silex"
] |
[
"Bitmap Memory Error Android",
"I am making an Android game, but when I load my Bitmaps, I get a memory error. I know that this is caused by a very large Bitmap (it's the game background), but I don't know how I could keep from getting a \"Bitmap size extends VM Budget\" error. I can't rescale the Bitmap to make it smaller because I can't make the background smaller. Any suggestions?\n\nOh yeah, and here's the code that causes the error:\n\nspace = BitmapFactory.decodeResource(context.getResources(),\n R.drawable.background);\n space = Bitmap.createScaledBitmap(space,\n (int) (space.getWidth() * widthRatio),\n (int) (space.getHeight() * heightRatio), false);"
] | [
"java",
"android",
"memory",
"bitmap"
] |
[
"ORA-00905: missing keyword during Merge statement in Oracle",
"I'm getting this error help me:- ORA-00905: missing keyword\n\nMerge statement in sql\n\nMERGE INTO TEMP1 T\nUSING (SELECT CHAR_VAR,VCHAR,VAR_CHAR2 FROM VAR_CHECK WHERE CHAR_VAR='Steven' AND VCHAR='King') S\nON (T.AUTHOR=S.CHAR_VAR)\nWHEN MATCHED THEN \nUPDATE SET T.SNAME=S.VAR_CHAR2\nWHEN NOT MATCHED\nINSERT (T.AUTHOR,T.TOPIC,T.SNAME) VALUES (S.CHAR_VAR,S.VCHAR,S.VAR_CHAR2);"
] | [
"oracle",
"oracle11g",
"oracle10g",
"oracle-sqldeveloper"
] |
[
"How to check if an object member exists in array by property?",
"Can't get my head around how to check if an object member exists in array by property.\n\nI have the following object:\n\nPS> $siteUser\n\nId Title LoginName Email\n-- ----- --------- -----\n1305 [email protected] i:0#.f|membership|urn%3aspo%3aguest#[email protected] [email protected]\n\n\nI would like to check if the string membership from the property LoginName exists within the array:\n\nfederateddirectoryclaimprovider\ntenant\nmembership\n\n\nI've gotten only as far as getting a match by specifying the array index for membership:\n\n$siteUsers.LoginName | Where-Object {$_ -match $inclusionObjects[2]}\n\n\nHowever, this requires that I know the array index for the matching string in advance.\n\nAnother thing I've tried but that yields no results is:\n\n$siteUsers | Where-Object {$inclusionObjects | ForEach-Object {$_ -match $_.LoginName}}\n\n\nIs there a way to kind of go through each item in the array?"
] | [
"arrays",
"powershell",
"object",
"properties"
] |
[
"Django - from function view to generic class view",
"I had this function based view and i'm trying to transform it in a generic class view as such:\n\n\n Original:\n\n\ndef view_events (request):\n\n template ='appform/view_events.html'\n items = Event.objects.filter(owner=request.user)\n pages = pagination(request,items, num = 10)\n print(pages)\n context = {\n 'items': pages[0],\n 'page_range': pages[1],\n }\n return render(request, template, context)\n\n\n\n Generic Class view:\n\n\nclass ViewEvents(generic.ListView):\n\n template_name = 'app/view_events.html'\n model = Event\n context_object_name = 'events'\n pagination = ???\n\n def get_queryset(self):\n\n return Event.objects.filter(owner = self.request.user)\n\n\nEDIT : i've used this for the pagination, which is a custom paginator. the question i'm trying to ask is how do i implement it in a generic class view?\n\nLater EDIT: This got it working, in case it might ever be of use to someone:)\n\nclass ViewEvents(generic.ListView):\n\n template_name = 'app/view_events.html'\n model = Event\n context_object_name = 'items'\n\n def get_queryset(self):\n\n return Event.objects.filter(owner = self.request.user)\n\n\n def get_context_data(self, **kwargs):\n\n context = super(ViewEvents, self).get_context_data(**kwargs)\n objects_all = Event.objects.filter(owner = self.request.user)\n pages = pagination(self.request, objects_all, num = 10)\n context['items'] = pages[0]\n context['page_range'] = pages[1]\n\n return context"
] | [
"django",
"django-views"
] |
[
"I am getting Undefined response in node.js for the request as",
"i am creating simple node.js application , following are the 4 files created .\nFile1: index.js\n\nvar server = require(\"./server\");\nvar router = require(\"./router\")\nvar requestHandlers = require(\"./requestHandlers\");\n\nvar handle = {}\nhandle[\"/\"] = requestHandlers.start;\nhandle[\"/start\"] = requestHandlers.start;\nhandle[\"/upload\"] = requestHandlers.upload;\nserver.start(router.route , handle);\n\n\nFILE2:SERVER.js\n\nvar http = require(\"http\");\nvar url = require(\"url\")\n\nfunction start(route, handle)\n{\n function onRequest(request,response)\n {\n var pathname = url.parse(request.url).pathname;\n console.log(\"request for\" + pathname + \"recieved\");\n\n response.writeHead(200,{\"Content-Type\":\"text/plain\"});\n\n var content = route(handle, pathname)\n console.log(\"Contents Is\" + content);\n\n response.write(\"Content is \" +content);\n response.end();\n }\n\n http.createServer(onRequest).listen(8888)\n console.log(\"server has started\");\n}\n\nexports.start = start;\n\n\nFILE 3:ROUTER.JS\n\nfunction route(handle, pathname)\n{\n console.log(\"About to route a request for\" + pathname);\n\n if (typeof handle[pathname] === 'function')\n {\n return handle[pathname]();\n }\n else\n {\n console.log(\"No Request handler found for \"+ pathname);\n return \"404 Not Found\";\n }\n}\n\nexports.route = route;\n\n\nFILE 4:requestHandlers.js\n\nfunction start()\n{\n console.log(\"Request handler 'start' was called \");\n return \"Hello Start\";\n}\n\nfunction upload()\n{\n console.log(\"Request handler 'upload' was called\");\n return \"Hello Upload\";\n}\n\n\n//This allows us to wire the request handlers into the router, giving our router something to route to\nexports.start = start;\nexports.upload = upload;\n\n\nNow when i start index.js on terminal and request http://localhost:8888/start on my browser i am getting output as:\n\n\n$ node index.js\nserver has started\nrequest for/recieved\nAbout to route a request for/\nRequest handler 'start' was called \nContents Isundefined\n\n\nso in server.js line //var content = route(handle, pathname) is not returning proper value \"Hello Start\" .\ni have just started leaning please any one can tell what is wrong ?"
] | [
"javascript",
"node.js"
] |
[
"force redirect non www url to www",
"I'm going straight to the point here.\nI actually install a wordpress site on a windows server.\nhowever, when I visit the site on my browser using \"sample.com.ph\" it shows me The connection has timed out however when I visit the \"www.sample.com.ph\" it work just fine.\n\nHere's my web.config file.\nI am really new to this so please bear with me.\nwhat I want is to force it to redirect to a www..\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n <system.webServer>\n <rewrite>\n <rules>\n <rule name=\"WordPress: http://www.sample.com.ph\" patternSyntax=\"Wildcard\">\n <match url=\"*\"/>\n <conditions>\n <add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\"/>\n <add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\"/>\n </conditions>\n <action type=\"Rewrite\" url=\"index.php\"/>\n </rule></rules>\n </rewrite>\n </system.webServer>\n</configuration>"
] | [
"wordpress",
"web-config"
] |
[
"Emulating native iphone maps as a web app with location based service",
"I'm wireframing an app quickly just to serve as a design mockup. I'm wondering if it is possible to emulate the location feature in the native apps map, specifically the blue pinpoint with the opaque perimiter eminating from it. I've visited the google maps mobile site, but the location button doesn't pin point your location precisely nor does it show any indication of doing so."
] | [
"iphone",
"maps",
"location"
] |
[
"Add BIRT Viewer to a Spring Project",
"I'm new to BIRT and I have been successful in running a birt report with data from my spring application. I'm now trying to embed the Viewer in my jsp so that when the report is executed, it's shown to the user in the Birt viewer.\nUnfortunately, I'm unable to embed the Viewer into my jsp.\nCould someone please give me a brief step by step path to achieve this?"
] | [
"spring",
"spring-boot",
"report",
"birt"
] |
[
"Methods to install custom style properties in GTK+-widgets",
"I'm writing custom GtkWidgets for a small library and therefore need custom style properties. I usually use the gtk_widget_class_install_style_property-function during the class-initialisation to do that. However I could not find a way to install a color-property, such as a GdkRGBA or a GdkColor for a widget. How could I do that?\n\nMost of the available functions for installing or registering style-properties are deprecated since the move to the CssProvider for style-handling and it is sometimes hard to get the best way of handling with style-properties in gtk from the reference manuals.\n\nIs there a different way to install such properties? Furthermore is there a documentation how the CssStyleProvider works internally and how properties are parsed from a css-file to the actual widget or GtkStyleContext?"
] | [
"css",
"c",
"gtk",
"gnome",
"gdk"
] |
[
"Devise: How to only authenticate users whom has a relation with another model?",
"I've the following tables:\n\nusers\n======\nid\nemail\npassword\n..device columns..\n\nproviders\n==========\nuser_id\n..irreverent columns..\n\nconsumers\n==========\nuser_id\n..irrelevant columns.. \n\n\nBoth consumers and providers belong to the users table, we're using this design because there are areas of the web app that both parties can access, however, sometimes there are provider-specific areas which consumers shouldn't be at, such as providers management panel. \n\nSo this raised the following question, how do I get Devise to just authenticate providers and not consumers on provider-specific namespaces when it only knows about the users table and not providers/consumers? \n\nHere's what I think I should be doing: \n\ncontrollers/provider/base_controller.rb:\n\n before_action :authenticate_provider!\n\n private\n #A modified wrapper around authenticate_user!\n def authenticate_provider! \n authenticate_user!\n redirect_to sign_in_path unless Provider.find_by(user: current_user)\n end"
] | [
"ruby-on-rails",
"ruby",
"activerecord",
"devise"
] |
[
"How to Edit a row in the datatable",
"I have created a data table. It has 3 column Product_id, Product_name and Product_price\n\n Datatable table= new DataTable(\"Product\");\n\n table.Columns.Add(\"Product_id\", typeof(int));\n table.Columns.Add(\"Product_name\", typeof(string));\n table.Columns.Add(\"Product_price\", typeof(string));\n\n table.Rows.Add(1, \"abc\", \"100\");\n table.Rows.Add(2, \"xyz\", \"200\");\n\n\nNow I want to find by index, and update that row.\n\nsay for e.g. \n\nI want to change value of Product_name column to \"cde\" that has the Product_id column value : 2."
] | [
"c#",
"datatable"
] |
[
"What is the difference between 0 << 16 and 0 << 20?",
"What is the difference between 0 << 16 and 0 << 20? I found it in UIViewAnimationOptions."
] | [
"objective-c",
"c"
] |
[
"Woocommerce won't add products to cart",
"I'm not sure what I did to break this because it was working fine for a while but I can no longer add products to the WooCommerce cart in the site I'm working on. On every attempt I get the \"Please choose product options\" message in return.\n\nI have a selected price for each variable yet it still doesn't work. I'm thinking it could have something to do with the quantity selector of that could possibly not be going through.\n\nThere may also be a conflict with some jQuery libraries and I have been told to check for errors but I have tried countless times to approach this and I just can't find the solution and this really needs to be fixed as soon as possible. \n\nAny information or help anyone can provide would be greatly appreciated.\n\nHere's an example page of a product to test it \nhttp://www.coreytegeler.com/bolivares/shop/marquez-button-down-cardigan-2/"
] | [
"javascript",
"jquery",
"wordpress",
"woocommerce"
] |
[
"Vue + SSR webpackJsonp is not defined",
"I am working on a Laravel Project wich uses VueJS.\nbefore I was developing only in pre-rendering way. now project almost done.\nbut I wanted to support SEO, so starting to change to SSR.\nI have done V8js PHP extension.\nbut the problem is in webpack.mix.js\n\nconst { mix } = require('laravel-mix');\nlet webpack = require('webpack');\nmix.setPublicPath('public');\n\nmix\n.js('./src/Packages/Front/Resource/assets/js/client.js', 'public/js')\n.js('./src/Packages/Front/Resource/assets/js/server.js', 'public/js')\n\n\nin this code, SSR no error.\n\nbut if i add .extract(['jQuery' ]) after the mix.js() error will be come up like this.\n\nV8Js::compileString():1: ReferenceError: webpackJsonp is not defined\n\n\nof course, i added in this order the files\n\n<script src=\"{{ mix('/js/manifest.js','uyghur') }}\" type=\"text/javascript\"></script>\n\n <script src=\"{{ mix('/js/vendor.js','uyghur') }}\" type=\"text/javascript\"></script>\n <script src=\"{{ mix('/js/client.js','uyghur') }}\" type=\"text/javascript\"></script>\n\n\ndose anyone know what exactly this error?\n\nit is taking my lots of time. already takes 3 days.\nI am stuck here."
] | [
"javascript",
"webpack",
"laravel-mix",
"server-side-rendering"
] |
[
"Send PUSH notification to specific user in Android using parse.com with PHP",
"I need my PHP system to send a Push notification to certain user identified by a userID.\n\nI tried this code and it just won't work:\n\n$APPLICATION_ID = \"XXXXXX\";\n$REST_API_KEY = \"XXXXXXX\";\n$MESSAGE = \"your-alert-message\";\n\n$url = 'https://api.parse.com/1/push';\n$data = array(\n 'type' => 'android',\n 'where' => array(\n 'userID' => 102102\n ),\n 'data' => array(\n 'alert' => 'greetings programs',\n ),\n);\necho $_data = json_encode($data);\n$headers = array(\n 'X-Parse-Application-Id: ' . $APPLICATION_ID,\n 'X-Parse-REST-API-Key: ' . $REST_API_KEY,\n 'Content-Type: application/json',\n 'Content-Length: ' . strlen($_data),\n);\n\n$curl = curl_init($url);\ncurl_setopt($curl, CURLOPT_POST, 1);\ncurl_setopt($curl, CURLOPT_POSTFIELDS, $_data);\ncurl_setopt($curl, CURLOPT_HTTPHEADER, $headers);\necho curl_exec($curl);\n\n\nWhere am I wrong?"
] | [
"php",
"android",
"parse-platform",
"push"
] |
[
"Communication between processor and high speed perihperal",
"Considering that a processor runs at 100 MHz and the data is coming to the processor from an external device/peripheral at the rate of 1000 Mbit/s (8 Bits/Clockcycle @ 125 MHz), which is the best way to handle traffic that comes at a higher speed to the processor ?"
] | [
"interface",
"embedded",
"operating-system",
"processor",
"rtos"
] |
[
"Rails: simple_format alternatives?",
"I am creating a blog/news site and I am looking for better formatting options than simple_format. I'm happy that simple_format creates paragraphs, for better readability, but I am looking for just a little more. I'd like to give editors an option to create headers over their paragraphs, add links and perhaps a few more basic formatting options.\n\nSimple_format\n\n<%= simple_format(@post.body) %>"
] | [
"ruby-on-rails"
] |
[
"Button click event firing alternativly using event and delegate",
"I am using delegates.\n\nIn my code, i am calling button event through delegates. But button click is firing alternatively...\n\nIn each button click, it is go to page load, but not going to button click event function.\nIt go to event function alternate."
] | [
"c#",
"asp.net",
"events",
"button",
"delegates"
] |
[
"SQL Concatenation Many to Many",
"I have three tables like this:\n\nItems:\n\n\n\nCategories\n\n\n\nand a simple MtM table to connect them\n\n\n\nFor reporting purposes I've been wondering if it would be possible to create a field with the concatenation of all categories the item belongs to. For example, if item ID=1 would belong to categories ID=1 and ID=2; I could do a select on Items and get a field 'Categories' with the value 'Schuhe; Hemde'\n\nIs this possible with SQL alone at all?\n\nThe best I could come up with\n\nSELECT Items.*, Categories.CategoryName\nFROM (CategoryItemAffinities \n INNER JOIN Categories ON CategoryItemAffinities.CategoryID = Categories.ID) \nINNER JOIN Items ON CategoryItemAffinities.ItemID = Items.ID;\n\n\nBut this obviously yields more than one result per item\n\n[edit]\nJust to specify, ms access is merely the db engine, I'm not using access forms/reports etc per se. I need this for a C# app"
] | [
"sql",
"ms-access"
] |
[
".NET WebSocket closing for no apparent reason",
"I am testing how .NET WebSockets work when the client can't process data from the server side fast enough. For this purpose, I wrote an application that sends data continuously to a WebSocket, but includes an artificial delay in the receive loop. As expected, once the TCP window and other buffers fill, the SendAsync calls start to take long to return. But after a few minutes, one of these exceptions is thrown by SendAsync:\n\n\n System.Net.HttpListenerException: The device does not recognize the command\n System.Net.HttpListenerException: The I/O operation has been aborted because of either a thread exit or an application request.\n\n\nWhat's weird is, that this only happens with certain message sizes and certain timing. When the client is allowed to read all data unrestricted, the connection is stable. Also, when the client is blocked completely and does not read at all, the connection stays open.\n\nExamining the data flow through Wireshark revealed that it is the server that is resetting the TCP connection while the client's TCP window is exhausted.\n\nI tried to follow this answer (.NET WebSockets forcibly closed despite keep-alive and activity on the connection) without success. Tweaking the WebSocket keep alive interval has no effect. Also, I know that the final application needs to be able to handle unexpected disconnections gracefully, but I do not want them to occur if they can be avoided.\n\nDid anybody encounter this? Is there some timeout tweaking that I can do? Running this should produce the error between a minute and half to three minutes:\n\nclass Program\n{\n static void Main(string[] args)\n {\n System.Net.ServicePointManager.MaxServicePointIdleTime = Int32.MaxValue; // has no effect\n\n HttpListener httpListener = new HttpListener();\n httpListener.Prefixes.Add(\"http://*/ws/\");\n Listen(httpListener);\n\n Thread.Sleep(500);\n Receive(\"ws://localhost/ws/\");\n\n Console.WriteLine(\"running...\");\n Console.ReadKey();\n }\n\n private static async void Listen(HttpListener listener)\n {\n listener.Start();\n while (true)\n {\n HttpListenerContext ctx = await listener.GetContextAsync();\n\n if (!ctx.Request.IsWebSocketRequest)\n {\n ctx.Response.StatusCode = (int)HttpStatusCode.NotImplemented;\n ctx.Response.Close();\n return;\n }\n\n Send(ctx);\n }\n }\n\n private static async void Send(HttpListenerContext ctx)\n {\n TimeSpan keepAliveInterval = TimeSpan.FromSeconds(5); // tweaking has no effect\n HttpListenerWebSocketContext wsCtx = await ctx.AcceptWebSocketAsync(null, keepAliveInterval);\n WebSocket webSocket = wsCtx.WebSocket;\n\n byte[] buffer = new byte[100];\n while (true)\n {\n await webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Binary, true, CancellationToken.None);\n }\n }\n\n private static async void Receive(string serverAddress)\n {\n ClientWebSocket webSocket = new ClientWebSocket();\n webSocket.Options.KeepAliveInterval = TimeSpan.FromSeconds(5); // tweaking has no effect\n\n await webSocket.ConnectAsync(new Uri(serverAddress), CancellationToken.None);\n\n byte[] receiveBuffer = new byte[10000];\n while (true)\n {\n await Task.Delay(10); // simulate a slow client\n\n var message = await webSocket.ReceiveAsync(new ArraySegment<byte>(receiveBuffer), CancellationToken.None);\n if (message.CloseStatus.HasValue)\n break;\n }\n}"
] | [
"c#",
".net",
"tcp",
"websocket"
] |
[
".on(\"ready\") define guild id with mysql",
"I trying to code a simple customize statistic with command trought data base \"mysql\" and i have problem about define guildID in \"Ready\" function is the anyway to define it or i need search other solutions \n\nconst Discord = require(\"discord.js\")\nconst { bot } = require('../index');\nconst { mysql } = require('../index')\n\nbot.on('ready', async () => {\n setInterval(function() {\n let sql = 'SELECT * FROM stats WHERE guildID = ?'\n mysql.query(sql, [guild.id], (err, results) => {\n let allchannels = results.channelID\n let guildid = results.guildID\n setInterval(() => {\n const guild = bot.guild.get(`${guildid}`)\n var userCount = guild.memberCount;\n const totalUsers = bot.channels.get(`${allchannels}`)\n totalUsers.setName(`total members = ${userCount}`)\n }, 20000);\n }) \n }, 15000);\n})\n\n\n\n connection.query(sql, [guild.id], (err, results) => {\n ReferenceError: guild is not defined\n\n\ni want to code a statistic like StartIT v4 bot but idk is it possible in ready? i dont want on any restart my bot use command like !start statistic etc,\nim glad if someone know how to fix it or have any solution"
] | [
"mysql",
"node.js",
"discord.js"
] |
[
"Stringstream tellg is zero",
"I am working on some file reading and writing. I am reading a file like this:\n\nstd::stringstream file;\nstd::fstream stream;\nstream.open(fileName, std::fstream::in);\nfile << stream.rdbuf();\nstream.close();\n\n\nThe problem is, that calling tellg() on file returns 0 but the str() function returns the real content of the file without problems.\n\nAs far as I know this code has worked in the past, before I updated my OS from MacOS 10.14 to 10.15.4 so maybe this is the problem."
] | [
"c++",
"macos-catalina"
] |
[
"Ensuring with-statement calls __exit__() when KeyboardInterrupt during await",
"Consider the following code:\nimport asyncio\n\n\nclass Resource:\n def __enter__(self):\n print("-- enter --")\n return self\n\n def __exit__(self, exc_type, exc_value, traceback):\n print("-- exit --")\n\n\nasync def main():\n with Resource():\n await asyncio.sleep(10)\n\n\nif __name__ == "__main__":\n loop = asyncio.get_event_loop()\n loop.run_until_complete(main())\n\nI expect __exit__() is called even when I press Ctrl+C during awaiting sleep(10), but it isn't. How to ensure the cleanup?"
] | [
"python",
"python-asyncio",
"with-statement"
] |
[
"Printng row in Python",
"I have used cursors to create a new attribute table with python and arcpy however when I try to print the rows from the attribute data such as the country, city, & population only one city will be printed.\n\narcpy.CopyRows_management (folder_path + '\\NA_Cities.shp', folder_path + '\\Select_Cities.dbf')\nfc = folder_path + '\\Select_Cities.dbf'\n\nThe_cursor = arcpy.da.UpdateCursor(fc, ['CNTRY_NAME', 'Population'])\nfor row in The_cursor:\n if row[0] == 'United States' and row[1] < 8000000:\n The_cursor.deleteRow()\n elif row [0] == 'Mexico' and row[1] < 8000000:\n The_cursor.deleteRow()\n elif row[0] == 'Canda' and row[1] < 3000000:\n The_cursor.deleteRow()\nprint row\n\n\nHere is my result\n\nSelecting locations\n\nPlease Stand By...\n\nRemoving the data that does not meet the requirements\n\n[u'Canada', 25000.0]\n\nFinished identifying the cities\n\n\nThanks in advance for any advice!"
] | [
"python",
"cursor",
"arcpy"
] |
[
"can not print global objects in gdb",
"I have this simple c++ code :\n\n#include<bits/stdc++.h>\n\nusing namespace std;\nvector<string> q;\n\nint main()\n{\n q.push_back(\"test1\");\n q.push_back(\"test2\");\n cout<<q.front();\n return 0;\n}\n\n\nWhen I use gdb to print variable q I get following error:\n\nNo symbol \"q\" in current context.\n\n\nI compile my program using g++ like this:\n\n g++ -g a.cpp\n\n\nAnd here is my gdb commands:\n\ngdb a.out \nGNU gdb (GDB) 7.12\nCopyright (C) 2016 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"x86_64-pc-linux-gnu\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n<http://www.gnu.org/software/gdb/bugs/>.\nFind the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\"...\nReading symbols from a.out...done.\n(gdb) b 6\nBreakpoint 1 at 0x400c6f: file a.cpp, line 6.\n(gdb) r\nStarting program: /home/mohammad/Desktop/a.out \n\nBreakpoint 1, main () at a.cpp:9\n9 q.push_back(\"test\");\n(gdb) print q\nNo symbol \"q\" in current context."
] | [
"c++",
"gdb",
"global-variables"
] |
[
"Passing values from custom NSView to NSCollectionViewItem",
"I have an NSTabView inside my custom NSView that is used as the prototype for the NSCollectionView. In the second tab I have NSButton button and NSImageView objects.\n\nNSButton is a \"Browse\" button that triggers the NSOpenPanel.\n\nI have connected the button's selector to IBAction in MyCustomView which performs the following:\n\n// MyView.h\n\n@interface MyView : NSView \n{\n IBOutlet NSTabView *tabView;\n IBOutlet NSImageView *myImageView;\n IBOutlet NSButton *browseButton;\n}\n\n-(IBAction)openBrowseDialog:(id)sender;\n\n\n@end\n\n\n// MyView.m\n\n-(IBAction)openBrowseDialog:(id)sender\n{\n\n NSOpenPanel* openDlg = [NSOpenPanel openPanel];\n\n [openDlg setCanChooseFiles:YES];\n [openDlg setCanChooseDirectories:NO];\n [openDlg setAllowsMultipleSelection:NO];\n [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@\"png\", @\"jpg\", @\"jpeg\", @\"gif\", nil]];\n\n\n if ( [openDlg runModal] == NSOKButton )\n {\n\n NSArray* files = [openDlg URLs];\n NSURL* fileURL = [files objectAtIndex:0];\n NSData *imageData = [NSData dataWithContentsOfURL:fileURL];\n\n if( imageData != nil )\n {\n NSImage *image = [[NSImage alloc] initWithData:imageData];\n myImageView.image = image;\n [image release];\n }\n\n }\n\n}\n\n\nWhen I run this \"myImageView\" traces \"null\" in the Console even though I connected it as IBOutlet in Interface Builder. Could you explain why? How should I do this instead? I also need to pass the \"fileURL\" value to \"representedObject\" in my NSCollectionViewItem object but I don't know how to access that from here?"
] | [
"cocoa",
"nscollectionviewitem",
"nstabview"
] |
[
"Socket.io and Node.Js multiple servers",
"I'm new to Web Sockets in general, but get the main concept.\n\nI am trying to build a simple multiplayer game and would like to have a server selection where I can run sockets on multiple IPs and it will connect the client through that, to mitigate connections in order to improve performance, this is hypothetical in the case of there being thousands of players at once, but would like some insight into how this would work and if there are any resources I can use to integrate this before hand, in order to prevent extra work at a later date. Is this at all possible, as I understand it Node.Js runs on a server and uses the Socket.io dependencies to create sockets within that, so I can't think of a possible solution to route it through another server unless I had multiple sites running it separately."
] | [
"javascript",
"node.js",
"sockets",
"socket.io",
"server"
] |
[
"undefined method `...' for nil:NilClass in Rails ActiveRecord",
"I am not sure what's wrong with my code here:\n\nclass ZombieController < ApplicationController\n def index\n @zombies = Zombie.all\n\n respond_to do |format|\n #format.json {render json: @rotting_zombies}\n format.html\n end\n\n end\nend\n\n\nclass Zombie < ActiveRecord::Base\n attr_accessible :name, :rotting, :age\n has_many :tweets\n has_one :brain, dependent: :destroy\n scope :rotting, where(rotting: true)\n scope :fresh, where(\"age < 30\")\n scope :recent,order('created_at desc').limit(3)\n\nend\n\nclass Brain < ActiveRecord::Base\n attr_accessible :flavor, :status, :zombie_id\n belongs_to :zombie\nend\n\n\nOn Zombie index view I render the zombie name with brain flavour as follows:\n\n<h1>List</h1>\n<table>\n<tr>\n<td>Name</td>\n<td></td>\n<td>Flavor</td>\n</tr>\n\n\n<% @zombies.each do |zombie|%>\n<tr>\n <td><%= zombie.name %></td>\n <td><%= zombie.brain.flavor %></td>\n</tr>\n<% end %>\n\n\n\n\n</table>\n\n\nThe errors I am receiving are undefined methodflavor' for nil:NilClass.`\nwhat might be wrong here? As far as I know I correctly defined the relationship both for zombie and brain model."
] | [
"ruby-on-rails",
"rails-activerecord"
] |
[
"Replace '&' with an image using jQuery/CSS?",
"Is there a way I can change the basic text version of '&' and replace it with an image? I was thinking can we do it in jQuery? I don't want to use php for this.\n\nOr is there a way to target it using css?\n\nThanks."
] | [
"jquery",
"css",
"image-replacement"
] |
[
"Send only key value when using find method on a json array in JS",
"I would get a value from JSON array, so I use the find method:\n\nlet actualElm = this.initialData.find(elm => {\n if (elm.identifiant == this.actualId) {\n return elm.country;\n }\n});\n\n\nThe problem with find is that it's returning all of the object ( elm object ) I would only get elm.country.\n\nHow can I proceed ?"
] | [
"javascript",
"typescript"
] |
[
"Is it possible to change display property of div every time page opens",
"Is is possible to do change display: block; to none; with javascript. I would like to show 2 of them everytime page opens. But I want it to be random and change everytime page opens.\n\nAnybody can help me with this ?\n\nhttp://jsfiddle.net/WcxdR/1/"
] | [
"javascript"
] |
[
"Is there a way to create a docker volume that isn't in the default location?",
"We currently run our docker ELK on dedicated slaves. Docker is taking up too much space due to indexes in ELK etc so we are looking to create a volume on a shared folder on the slave which has a much larger storage capacity. This is our docker-compose config \n\nversion: '3.2'\n\nservices:\n elasticsearch:\n build:\n context: elasticsearch/\n args:\n ELK_VERSION: $ELK_VERSION\n volumes:\n - type: bind\n source: ./elasticsearch/config/elasticsearch.yml\n target: /usr/share/elasticsearch/config/elasticsearch.yml\n read_only: true\n - type: volume\n source: elasticsearch\n target: /usr/share/elasticsearch/data\n ports:\n - \"9200:9200\"\n - \"9300:9300\" \n environment:\n ES_JAVA_OPTS: \"-Xmx1g -Xms1g\" \n networks:\n - elk\n\n logstash:\n build:\n context: logstash/\n args:\n ELK_VERSION: $ELK_VERSION\n volumes:\n - type: bind\n source: ./logstash/config/logstash.yml\n target: /usr/share/logstash/config/logstash.yml\n read_only: true\n - type: bind\n source: ./logstash/pipeline\n target: /usr/share/logstash/pipeline\n read_only: true\n ports:\n - \"5000:5000\"\n - \"9600:9600\"\n - \"5044:5044\"\n environment:\n LS_JAVA_OPTS: \"-Xmx256m -Xms256m\"\n networks:\n - elk\n depends_on:\n - elasticsearch\n\n kibana:\n build:\n context: kibana/\n args:\n ELK_VERSION: $ELK_VERSION\n volumes:\n - type: bind\n source: ./kibana/config/kibana.yml\n target: /usr/share/kibana/config/kibana.yml\n read_only: true\n ports:\n - \"5601:5601\"\n networks:\n - elk\n depends_on:\n - elasticsearch\n\n\nnetworks:\n elk:\n driver: bridge\n\nvolumes:\n elasticsearch:\n\n\n\nI am having real trouble finding anything about this online or in the docs. Thanks in advance."
] | [
"docker",
"docker-compose",
"elastic-stack",
"elk"
] |
[
"xlwings hide worksheets from python and book not visible",
"I'm using xlwings to control a workbook because I need to keep existing charts in tact (otherwise I'd use openpyxl). Is there a way to make the sheets hidden and to open a book within an app that is not visible?\n\nto hide a sheet I've tried:\n\n wb.sheets[ws].Visible = False\n wb.sheets[ws].hidden= True\n wb.sheets[ws].Visible= xlveryhidden #vba syntax - bombs\n\n\nThe top two run, but don't do anything, the third bombs out.\n\nI can create a new excel app and I can create a new book (which creates is new app). However, I want to open a specific book, but Book doesn't take a visible parameter - how do I open an existing workbook and not have it be visible?\n\nexcel = xw.App(visible = False) #creates a new app that is visible\nwb= xw.Book(filepath) #opens the already existing workbook, but it is visible - how do I make it part of the app above?"
] | [
"python",
"xlwings"
] |
[
"How to use custom version of List: `data List a = Nil | Cons a (List a)`?",
"This question is based on an example from the chapter "Declaring Types and Classes" of the book "Programming in Haskell" by Graham Hutton, second edition.\nThe data declaration is:\ndata List a = Nil | Cons a (List a)\nThe example function that uses this declaration is:\nlen :: List a -> Int\nlen Nil = 0\nlen (Cons _ xs) = 1 + len xs\n\nBut no matter what I've tried, I can't seem to use the function len:\n\nlen Cons 1 Cons 2 Cons 3\nlen 1\nlen Cons\nlen (1)\nlen [1,2]\nlen Cons [1]\nlen (1,2)\nlen Cons (1,2)\nlen Cons 1 2\nlen (Cons (1,2))\nlen (Cons 1 2)\n\nDid I miss out any permutation of len and Cons? Or is the example simply unworkable?"
] | [
"list",
"haskell",
"types",
"syntax",
"custom-data-type"
] |
[
"Issue trying filter within Powershell",
"I am finishing a last piece of this mini-app where I'm pulling names from a text file. When pulling the names from a ..txt I am filtering out certain prefixes like *eft, *nsm with code like below. \n\n$lines = (Get-Content C:\\temp\\PROD\\Repeat.txt -totalcount 200)\n\n$flines = $lines|?{$_ -notlike \"*eft\", \"nsm*\", \"*\" , \"*\" .... }\n\n$objOutputBox.Text = $flines\n\n\nThe problem I'm having is that it is only grabbing the \"*eft\" and not the rest of them. I thought I could filter an array of strings with this structure? What am I missing here if you do not mind?\n\nThanks"
] | [
"powershell"
] |
[
"How to extract numbers from string in c?",
"Say I have a string like ab234cid*(s349*(20kd and I want to extract all the numbers 234, 349, 20, what should I do ?"
] | [
"c",
"string"
] |
[
"JSP - Value from tag attribute",
"I've got a problem with getting the value in <jsp:body> of ttt attribute. The following code does not work. I have spend too long on this, so I'm asking here. Can someone show me the proper way?\n\ncode fragment:\n\n<jsp:element name=\"h3\">\n <jsp:attribute name=\"ttt\">\n ${param.txt}\n </jsp:attribute>\n <jsp:body>\n ${ttt} <-- this displays nothing\n </jsp:body>\n</jsp:element>"
] | [
"java",
"xml",
"jsp"
] |
[
"How do I have python check for a specific length to a string?",
"I was doing some homework and I'm kinda stumped. part of my assignment is that I need to have a If statement that checks if a number that was entered is 16 characters long or not, this is the code I have so far:\n\n#the input\nCreditCardNum = input(\"Input a credit card number(no spaces/hyphens): \")\n\n#The if statements\nif str(CreditCardNum) != len(16):\n print(\"This is not a valid number, make sure the number is 16 characters.\")\nelif str(CreditCardNum) == len(16):\n if str(CreditCardNum[0:]) == 4:\n print(\"The Card is a Visa\")\n elif str(CreditCardNum[0:]) == 5:\n print(\"The Card is a Master Card\")\n elif str(CreditCardNum[0:]) == 6:\n print(\"The Card is a Discover Card.\")\n else:\n print(\"The brand could not be determined.\")"
] | [
"python",
"string",
"python-3.x"
] |
[
"Auto scroll a chatbox with css",
"I am making a small chat functionality to so that my users can make comments during a video call session. I have a chatbox with the following function onkeypress which enable them to send the message.\n\nI am unable to figure out one thing only now, that is how to make the chatbox auto scroll when each message is appended to the media.\n\nvar userMessage = function (name, text) {\n return ('<li class=\"media\"> <div class=\"media-body\"> <div class=\"media\">' +\n '<div class=\"media-body\"' +\n '<b>' + name + '</b> : ' + text +\n '<hr/> </div></div></div></li>'\n );\n};\n\nvar sendMessage = function () {\n var userMessage = $('#userMessage').val();\n socket.emit('chatMessage', { message: userMessage, username: username });\n $('#userMessage').val(\"\");\n};\n\n$('#userMessage').keypress(function (event) {\n\n var keycode = (event.keyCode ? event.keyCode : event.which);\n if (keycode == '13') {\n sendMessage();\n }\n\n});\nsocket.on('chatMessage', function (data) {\n $('#chatbox-listMessages').append(userMessage(data.username, data.message));\n});\n\n\nI have my html in handlebars template to render the chat messages:\n\n<!-- CHAT ROOM -->\n <div class=\"panel-heading\">\n CHAT ROOM\n <span class=\"pull-right\" id=\"chatbox-username\">\n {{#if user}}\n {{user.name}}\n {{/if}}\n </span>\n </div>\n <div class=\"panel-body\">\n <ul class=\"media-list\" style=\"height: 200px; overflow-y: scroll\" id=\"chatbox-listMessages\">\n\n </ul>\n </div>\n <div class=\"panel-footer\">\n <div class=\"input-group\">\n <input type=\"text\" class=\"form-control\" placeholder=\"Type message and press Enter\" id=\"userMessage\" />\n <span class=\"input-group-btn\">\n {{!-- <button type=\"button\" class=\"btn btn-primary\" onclick=\"sendMessage()\">SEND</button> --}}\n </span>\n </div>\n </div>\n\n\nThis so far works perfectly for me, when the user enters a message in the input and presses the enter key, the message is sent.\n\nThe problem I am having is how can I make the messages in the chatbox scroll up on each new message so that the the most recent message on the bottom is visible to the user."
] | [
"javascript",
"jquery",
"html",
"css"
] |
[
"Automate Screenshots for IOS",
"I am trying to build a tool that downloads an app from the market or App Store and run it on a device and take screenshots.\n\nI have been successful in doing this on android devices by using monkey runner tool.\n\nIs the same possible for iOS?"
] | [
"ios",
"ios5",
"automation",
"ios-simulator",
"ios-ui-automation"
] |
[
"ruby regex match from end of string",
"I've read somewhere today that regex tag in SO gets most \"give me ze code\" type questions, so I was cautious in asking... I tried, but if this is a duplicate please let me know so I can delete.\n\n[First]sometext[Second]\n\n\nI would like to use Regex in Ruby to return value between second []:\n\nSecond\n\n\nI so far have:\n\n(?<=\\[)(.*)(?=\\])\n\n\nwhich returns \n\nFirst]sometext[Second\n\n\\[.*?(\\[)\n\n\nthis grouping will return \n\n[First]sometext[\n\n\nso I've been struggling to somehow mix the two but no luck.. hope someone can help.\n\nThe closest reference I can find in SO was searched with \"match second or nth occurence in regex\" which I couldn't get it to work on my issue.\n\nmy workaround was to use gsub to replace the [First] with \"\" to the initial string with:\n\n\\[(.*?)\\]\n\n\nand then do another match.. but I would like know how it can be done with on regex usage."
] | [
"ruby",
"regex"
] |
[
"use enter key to submit form with numeric keypad of android / phonegap",
"Having trouble with the soft \"NUMERIC\" keyboard on my android/phonegap application.\n\nMy goal: create a simple form on a html5 page (that I will use with phonegap), where the user enters a number using 0-9 characters. To do this, I have used an input field with type = number, and this generates the correct soft keyboard on my android phone.\n\nUnfortunately, I've felt a huge amount of frustration trying to detect when the enter key is pressed on the numeric keyboard. Usually when pressed, instead of submitting the form, the keyboard just goes away. However, if I change the type of the input to \"text\" then the enter key works as expected and submits the form.\n\nHow can I reproduce form submission using the numeric keyboard? \n\nFor reference see:\nhttp://jsfiddle.net/Ua9yw/13/\n\nWORKING ENTER SUBMISSION BEHAVIOR:\n\n<form> <input type=\"text\"/> </form>\n\n<form id=\"form1\">\n <input type=\"text\"/>\n <input type=\"submit\"/>\n</form>\n\n\nNOT WORKING ENTER BUTTON BEHAVIOR:\n\n<form> <input type=\"number\"/> </form>\n<form id=\"form1\">\n <input type=\"number\"/>\n <input type=\"submit\"/>\n</form>"
] | [
"android",
"html",
"cordova"
] |
[
"Interactive choropleth map with leaflet inaccurately mapping data",
"First post, I'll try to do my best.\n\nI'm trying to make an interactive choropleth map with leaflet in R, based off this\ntutorial. It all goes great until I compare the data represented on the map with the data in my data frame.\n\nI'm using the same data as the person who wrote the tutorial. It is a Large Spatial Polygons Dataframe called world_spdf with 246 rows of world_spdf@data and world_spdf@polygons as well as three other objects I have no idea about. The data is essentially countries with long and lat. I don't know anything about spatial data, but I'm assuming it's responsible for the shapes of the countries on a rendered map.\n\nI also have a data frame called results that initially has 234 rows, also about countries and some additional data for each country. This is how head(results) looks like (it goes on like this, and there are no NAs):\n\n ISO2 v1 v2 v3\n <chr> <dbl> <dbl> <dbl>\n1 AD 0.118 0.880 0.001 \n2 AE 0.226 0.772 0.0016 \n3 AF 0.197 0.803 0.0001 \n4 AG 0.0884 0.911 0.0009 \n5 AI 0.172 0.827 0.00120\n6 AL 0.107 0.891 0.0022 \n\n\nI am merging the two dataframes by ISO2 column which contains country codes. Everything is fine so far, the data in the merged dataframe is correctly assigned to the country. \n\nworld_spdf@data = merge(world_spdf@data, results, by = \"ISO2\")\n\n\nHowever, when I try to plot the data, the resulting interactive map presents the data in a \"wrong order\", for example, data for Poland for Nigeria etc. \n\nWhat I tried was to find the missing countries in the smaller dataframe like this:\n\ndifferences = c(setdiff(world_spdf@data$ISO2, results$ISO2)\n\n\nAnd then add rows with NAs to the dataframe so that all the countries in the spatial dataframe are represented with NAs at least. But this didn't help.\n\nI am clueless as to why this occurs. Please help!"
] | [
"r",
"leaflet",
"maps",
"data-visualization",
"geospatial"
] |
[
"CSS navigationsbar position fixed section go under",
"I created a little page with a navigationbar and a section. I want to set the navigationbar position: fixed; but if i do this, the section go`s under the navigationsbar. Thats the problem. Any ideas to solve this problem?\n\n\r\n\r\n*{\r\n margin: 0px;\r\n padding: 0px;\r\n font-family: 'Oswald', sans-serif;\r\n}\r\n\r\nbody{\r\n background-color: rgb(29, 29, 29);\r\n height: 2000px;\r\n}\r\n\r\nnav{\r\n width: 100%;\r\n background-color: rgb(14, 14, 14);\r\n overflow: hidden;\r\n border-bottom: 2px solid black;\r\n margin-bottom: 5px;\r\n position: fixed;\r\n top: 0;\r\n}\r\n\r\n.nav-top-ul{\r\n font-size: 0px;\r\n width: 930px;\r\n margin: 0px auto;\r\n}\r\n\r\n.nav-top-li{\r\n display: inline-block;\r\n}\r\n\r\n.nav-top-a{\r\n display: block;\r\n font-size: 16px;\r\n padding: 10px 20px;\r\n color: #C1C1C1;\r\n transition: all 0.5s;\r\n text-decoration: none;\r\n}\r\n\r\n.nav-top-a:hover{\r\n color: white;\r\n}\r\n\r\n.left{\r\n float: left;\r\n}\r\n\r\nsection{\r\n margin: 0px auto;\r\n width: 930px;\r\n background-color: orange;\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <title>Seite</title>\r\n <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>\r\n \r\n </head>\r\n <body>\r\n <nav>\r\n <ul class=\"nav-top-ul\">\r\n <div class=\"left\">\r\n <li class=\"nav-top-li\"><a class=\"nav-top-a\" href=\"index.php?content=home\">NameDerSeite</a></li>\r\n </div>\r\n </ul>\r\n </nav>\r\n \r\n <section>\r\n Cras mattis consectetur purus sit amet fermentum. Nulla vitae elit libero, a pharetra augue. Maecenas sed diam eget risus varius blandit sit amet non magna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.\r\n\r\nDonec sed odio dui. Curabitur blandit tempus porttitor. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Maecenas sed diam eget risus varius blandit sit amet non magna. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.\r\n </section>\r\n </body>\r\n</html>"
] | [
"html",
"css"
] |
[
"How to Enable CSV Logger in Eclipse STEM",
"I am new to Eclipse STEM. I have been searching for a way to import time series generated in STEM Simulation to my system. I found a function called CSV Logger to achieve my goal but it is not available in my version. Can any body help me out."
] | [
"eclipse",
"time-series",
"simulation"
] |
[
"Disable Quartz Job(s) For Specific Server",
"Our application is deployed to 2 web servers for load balancing and redundancy. We have a couple of Quartz jobs that run once every day. The job only needs to execute on one of the web servers, not both. Eventually, we will probably move these jobs to a job server but for now, is there a way via config or environment variable or something that I can do so that the jobs only run on one of my servers?"
] | [
"grails",
"tomcat6",
"quartz-scheduler"
] |
[
"Improve ffmpeg video capture performance?",
"I'm running Debian on my Intel Edison and attempting to capture video through a USB webcam using ffmpeg. The command I am using is:\n\nffmpeg -f video4linux2 -i /dev/video0 -preset ultrafast -crf 22 -y test.mov\n\n\nI end up with an output similar to the following:\n\nframe= 356 fps= 9 q=8.0 size= 1958kB time=35.50 bitrate= 451.9kbits/s du\nframe= 658 fps= 10 q=8.0 size= 3403kB time=65.70 bitrate= 424.3kbits/s du\nframe= 1282 fps= 11 q=8.0 size= 5571kB time=128.10 bitrate= 356.3kbits/s d\nframe= 1285 fps= 11 q=17.0 size= 5783kB time=128.40 bitrate= 369.0kbits/s \nframe= 1288 fps= 11 q=19.0 size= 5951kB time=128.70 bitrate= 378.8kbits/s \n\n\nwhere the first frame wasn't even taken until 35.5 seconds had passed. It claims fps = 9, but I was only able to acquire those five frames after two minutes.\n\nI would like to know if there is any way to improve the performance (e.g., frame rate) of ffmpeg."
] | [
"video",
"ffmpeg",
"debian",
"intel-edison"
] |
[
"Possible to build a dynamic array of streamwriters in Powershell?",
"I have a very large file I need to process (> 10 GB). Hence my use of StreamReader and StreamWriter. My file contains a financial series of market prices in CSV format like this:\n\nDate,Time,Open,High,Low,Close,UpVol,DownVol\n\nThe file contains years of data, and I want to create one file per year, and remove the last two columns. I have a script which does this if I pass in the Year as a parameter. I thought of calling this script multiple times, but it would have to read the very large file multiple times. So, I only want to read the file once, and stream the processed data out to different files dynamically line by line. Here's my Single-Year script:\n\nparam ( \n [String]$file=$(throw \"Supply a file name to convert\"),\n [String]$year\n );\n\n$extension = [System.IO.Path]::GetExtension($file);\n$outFile = $file.Substring(0, $file.LastIndexOf('.')) + \"-\" + $Year + $extension; \n\n$reader = [System.IO.File]::OpenText($file);\n$writer = New-Object System.IO.StreamWriter $outFile;\n$reader.ReadLine() > $null # skip first line (old header)\n$writer.WriteLine(\"Date,Time,Open,High,Low,Close\"); # write required header\nwhile (($line = $reader.ReadLine()) -ne $null) {\n $data = $line.Split(\",\");\n if ($data[0] -match $year) {\n $writer.WriteLine($data[0] + \",\" + $data[1] + \",\" + $data[2] + \",\" + $data[3] + \",\" + $data[4] + \",\" + $data[5]);\n }\n}\n$reader.Close();\n$writer.Close();\n\n\nSo, I'm thinking is it possible to look at $data[0] (the date), find the year with something like this:\n\n$thisYear = $data[0].Split(\"/\")[2];\n\nand then dynamically create a StreamWriter for each year that's found? Should I create an array of StreamWriters? Snag is, I don't know how many years or which years are in the files before I read them. It has to be done \"on the fly\". If the file I am reading contains ten years of data, I would expect ten streamwriters to be created with ten extra files at the end with the respective year's data in it."
] | [
"powershell",
"streamreader",
"streamwriter"
] |
[
"My font awesome icon is stuck at the bottom",
"I want to position vertically my font awesome icon, but I can not. It should look like a circle which it does, but the icon is on the bottom of it and it should be in the middle. How do I do this? I searched for a solution, but none worked for me. :(\n\r\n\r\n .container {\n text-align: center;\n margin-top: 60px;\n margin-right: auto;\n margin-left: auto;\n padding-left: 15px;\n padding-right: 15px;\n}\n \n.flexing {\n display: flex;\n}\n\n.aboutus i {\n width: 150px;\n border-radius: 50%;\n background: whitesmoke;\n text-align: center;\n padding-top: 25%;\n font-size: 60px;\n color: grey;\n \n}\n\n.aboutus i:hover {\n background: lightgreen;\n color: white;\n transition: all 0.5s;\n}\r\n<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\">\n\n<div class=\"container\">\n <h2>About us</h2>\n <hr>\n <h5>Lorem ipsum dolor sit amet consectetur adipisicing elit.</h5>\n <section class=\"item flexing\">\n <div>\n <i class=\"fa fa-rocket\" aria-hidden=\"true\" ></i>\n <h3>Lorem ipsum</h3>\n <p>Nam varius accumsan elementum. Aliquam fermentum eros in suscipit scelerisque.</p>\n </div>\n <div>\n <i class=\"fa fa-sun-o\" aria-hidden=\"true\"></i>\n <h3>Lorem ipsum</h3>\n <p>Nam varius accumsan elementum. Aliquam fermentum eros in suscipit scelerisque.</p>\n </div>\n <div>\n <i class=\"fa fa-google-wallet\" aria-hidden=\"true\"></i>\n <h3>Lorem ipsum</h3>\n <p>Nam varius accumsan elementum. Aliquam fermentum eros in suscipit scelerisque.</p>\n </div>\n <div>\n <i class=\"fa fa-trophy\" aria-hidden=\"true\"></i>\n <h3>Lorem ipsum</h3>\n <p>Nam varius accumsan elementum. Aliquam fermentum eros in suscipit scelerisque.</p>\n </div>\n \n </section>\n <div class=\"item\">\n <div>\n <a href=\"#\" >Learn more</a>\n </div>\n </div>\n </div>"
] | [
"html",
"css"
] |
[
"How to change the disassembly syntax to intel using gdb?",
"(gdb) set disassemble intel\nAmbiguous set command \"disassemble intel\": disassemble-next-line, disassembler-options.\n\n\nWhen i set the disassembly syntax to intel, it show this error."
] | [
"c",
"gdb"
] |
[
"Angular 4:PrimeNg DoughnutChart dynamic data issue.",
"I have recently been working on primeng charts, and I am using DoughnutChart provided by PrimeNG. I want to pass a number value stored in a variable as data in the ts file for this chart, but it will not show anything in the UI,where as if data is static it works absolutely fine.This is the code for the same:\n\n1.)Working one:-\n\nthis.invoicedata = {\n labels: ['InvoiceQty', 'TotalQty'],\n datasets: [\n {\n data: [50, 50],\n backgroundColor: [\n \"#ff9800\",\n \"#ffffff\",\n\n ],\n hoverBackgroundColor: [\n \"#ff9800\",\n \"#ffffff\",\n\n ]\n }]\n }\n\n\n2.)Non-working one:-\n\n this.invoicedata = {\n labels: ['InvoiceQty', 'TotalQty'],\n datasets: [\n {\n data: [this.pICompletionPercentage, this.PIPendingpercent],\n backgroundColor: [\n \"#ff9800\",\n \"#ffffff\",\n\n ],\n hoverBackgroundColor: [\n \"#ff9800\",\n \"#ffffff\",\n\n ]\n }]\n }\n\n\nThis is HTML for the same:-\n\n <div class=\"row\">\n <p-chart type=\"doughnut\" [data]=\"invoicedata\" width=\"150px\"></p-chart>\n <p class=\"text-center\">Invoiced- {{pICompletionPercentage}}%</p>\n </div>"
] | [
"angular",
"typescript",
"chart.js",
"angular2-forms",
"primeng"
] |
[
"pgadmin connect to linux server - database",
"Im trying to connect to linux server which has a ssh connection. Im trying to do the same with pgadmin but I dont see the sshtunnel option in my \"New Server Registration\" window.\n\nTHe only I see is,\n\n\nProperties\nSSL \nAdvanced"
] | [
"postgresql"
] |
[
"Custom content negotiation feature is not working",
"I have implemented a custom content negotiation feature to decrypt incoming requests. But when I call call.receiveText() the convertForReceive() function is not called in the pipeline, So I still receive encrypted content in my route controller.\n\nHere is how I register the feature:\n\nfun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)\n\[email protected]\nfun Application.module(testing: Boolean = false) {\n install(DefaultHeaders)\n install(CallLogging)\n install(ConditionalHeaders)\n install(Compression)\n install(ContentNegotiation) {\n register(ContentType.Any, CryptoFeature())\n }\n\n install(Routing) {\n user()\n }\n}\n\n\nAnd the feature definition:\n\nclass CryptoFeature : ContentConverter {\n override suspend fun convertForSend(\n context: PipelineContext<Any, ApplicationCall>,\n contentType: ContentType,\n value: Any\n ): Any? {\n return TextContent(value as String, contentType.withCharset(context.call.suitableCharset()))\n }\n\n override suspend fun convertForReceive(context: PipelineContext<ApplicationReceiveRequest, ApplicationCall>): Any? {\n val request = context.subject\n val channel = request.value as? ByteReadChannel ?: return null\n val encryptedBody = channel.toInputStream().reader(context.call.request.contentCharset() ?: Charsets.UTF_8).readText()\n\n val decryptedString = CryptoHelper.decrypt(encryptedBody)\n return decryptedString\n }\n}"
] | [
"kotlin",
"ktor"
] |
[
"Problem with Keras to learn multiplication by two",
"I'm just trying to play around with Keras, but I'm running into some trouble trying to teach it a basic function (multiply by two). My setup is as follows. Since I'm new to this, I added in comments what I believe to be happening at each step.\n\nx_train = np.linspace(1,1000,1000)\ny_train=x_train*2\nmodel = Sequential()\nmodel.add(Dense(32, input_dim=1, activation='sigmoid')) #add a 32-node layer\nmodel.add(Dense(32, activation='sigmoid')) #add a second 32-node layer\nmodel.add(Dense(1, activation='sigmoid')) #add a final output layer\nmodel.compile(loss='mse',\n optimizer='rmsprop') #compile it with loss being mean squared error\n\nmodel.fit(x_train,y_train, epochs = 10, batch_size=100) #train \nscore = model.evaluate(x_train,y_train,batch_size=100)\nprint(score)\n\n\nI get the following output:\n\n1000/1000 [==============================] - 0s 355us/step - loss: 1334274.0375\nEpoch 2/10\n1000/1000 [==============================] - 0s 21us/step - loss: 1333999.8250\nEpoch 3/10\n1000/1000 [==============================] - 0s 29us/step - loss: 1333813.4062\nEpoch 4/10\n1000/1000 [==============================] - 0s 28us/step - loss: 1333679.2625\nEpoch 5/10\n1000/1000 [==============================] - 0s 27us/step - loss: 1333591.6750\nEpoch 6/10\n1000/1000 [==============================] - 0s 51us/step - loss: 1333522.0000\nEpoch 7/10\n1000/1000 [==============================] - 0s 23us/step - loss: 1333473.7000\nEpoch 8/10\n1000/1000 [==============================] - 0s 24us/step - loss: 1333440.6000\nEpoch 9/10\n1000/1000 [==============================] - 0s 29us/step - loss: 1333412.0250\nEpoch 10/10\n1000/1000 [==============================] - 0s 21us/step - loss: 1333390.5000\n1000/1000 [==============================] - 0s 66us/step\n['loss']\n1333383.1143554687\n\n\nIt seems like the loss is extremely high for this basic function, and I'm confused why it's not able to learn it. Am I confused, or have I done something wrong?"
] | [
"keras",
"neural-network",
"deep-learning"
] |
[
"How to disable Auto Fetch in PhpStorm?",
"How to disable Git Auto Fetch in PhpStorm?\nI think this is default function of PhpStorm, it will open a Login Popup every 5 minutes if I don't login, which really annoying."
] | [
"git",
"phpstorm",
"jetbrains-ide"
] |
[
"Why list interface is returned instead of ArrayList interface implementation after explicit implementation",
"I know what is going on inside of my code, and how to fix an error. However, I do not understand why things happen the way they do. Specifically, why my method returns interface List instead of ArrayList interface implementation?\nWhat confuses me the most is after implementing moons as ArrayList, it still returns the interface.\nThanks in advance!\n private static ArrayList<HeavenlyBody> makingSetOfMoons(){\n List<HeavenlyBody> moons = new ArrayList<>();\n for(HeavenlyBody planet : Main.planets){\n moons.addAll(planet.getSatellites());\n }\n return moons;\n }\n\nError output:\nIncompatible types. Found: 'java.util.List<com.practice.HeavenlyBody>', required: 'java.util.ArrayList<com.practice.HeavenlyBody>'"
] | [
"java",
"list",
"generics",
"interface",
"return"
] |
[
"Set-AzureSubscription : A parameter cannot be found that matches parameter name 'DefaultSubscription'",
"I am setting azure subscription in powershell with \"Set-AzureSubscription –DefaultSubscription $SubscriptionID\" API. \n\nBut it is giving me error as \"Set-AzureSubscription : A parameter cannot be found that matches parameter name 'DefaultSubscription'.\" \n\nPlease guide me on if there is change in azure powershell API's."
] | [
"azure",
"powershell-2.0"
] |
[
"TSV with Excel clipping off seconds when I save",
"I am trying to edit a TSV file in excel. When I simply open it and then ctrl-s to save it, I notice when I open it in a text editor that the seconds has been clipped off. Before opening the file I have: 08/15/2015 18:26:07 but after I have 8/15/15 18:26. It's okay that it is clipping off the preceding zeros, but I need the seconds to remain intact for my program.\n\nAny suggestions/ideas? I'd prefer to use excel if possible."
] | [
"excel",
"datetime",
"tsv"
] |
[
"Min length for SQL Name/Identifier in PostgreSQL?",
"I need to parse an SQL name for PostgreSQL, and to be sure it is always compliant.\n\nI know that, for example, an SQL name/identifier can even consist of a single white space.\n\nWhat I'm trying to find out is - is there a single use case within the entire PostgreSQL syntax where it is possible to pass in an empty \"\" SQL name/identifier and still to be considered valid?\n\nI want to know whether I should parse \"\" as always invalid in PostgreSQL or not."
] | [
"postgresql"
] |
[
"FirebaseListAdapter Access to key",
"Im using Google Firebase and FirebaseUI\n\nI am passing a list of values to a FirebaseListAdapter like so\n\n ref.addValueEventListener(new ValueEventListener() {\n @Override\n public void onDataChange(DataSnapshot snapshot) {\n for (DataSnapshot requestSnapshot: snapshot.getChildren()) {\n requestList request = requestSnapshot.getValue(requestList.class);\n Log.i(\"Chat\", request.getTitle()+\": \"+request.getDescription()+\" \"+request.getKey());\n }\n\n\nI want to store the index of the record (Key) along with the information within. However as the fields automatically map themselves if they are the same name, this leaves my unable to work it out.\n\nI have tried calling the properties of the \"key\" methods within the requestList class by the name \"key\" however this hasnt worked\n\nThe returned data structure looks like this\n\n Key:{\n \"RequestTitle\":\"Value\",\n \"RequestDescription\":\"description\",\n \"RequestItems\":{ item 1 item 2}\n}\n\n\nThe requests class looks like this\n\npublic class requestList {\n\n String RequestTitle;\n String RequestDescription;\n String key;\n\n public requestList() {\n }\n\n public requestList(String RequestTitle, String RequestDescription, String key) {\n this.RequestTitle = RequestTitle;\n this.RequestDescription = RequestDescription;\n this.key = key;\n }\n\n public String getTitle() {\n return RequestTitle;\n }\n\n public String getKey() {\n return key;\n }\n\n public String getDescription() {\n return RequestDescription;\n }\n}"
] | [
"android",
"firebase",
"firebase-realtime-database",
"firebaseui"
] |
[
"mysql_query minus 1 everything",
"I have a table, 3 columns, \n\nID (prmiary, auto-inc),counter (UNSIGNED INT), text (VARCHAR)\n\nThere are 1 million rows.\n\nI would like to go through the table and minus 1 from the counter value for each row (also, what happens if it is 0 and -1 happens [i set it as unsigned when I made the table? can a query handle this?). \n\nWhat is the best mysql_query to do this using php?"
] | [
"php",
"mysql"
] |
[
"create dictionary from list",
"I am trying to make a dictionary with two lists using map function. But something doesn't seem right. \n\nI know there is already zip and dict to do this job, but I am wondering why this code went wrong and where.\n\ncountry = ['India', 'Pakistan', 'Nepal', 'Bhutan', 'China', 'Bangladesh']\ncapital = ['New Delhi', 'Islamabad','Kathmandu', 'Thimphu', 'Beijing', \n'Dhaka']\n\ncountry_capital={}\n\ndef mydict(x,y):\n country_capital[x]=y\n return country_capital\nnational_info=map(mydict,country,capital)\nprint (list(national_info))\n\n\nwhy it prints as below:\n\n[{'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}, {'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}, {'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}, {'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}, {'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}, {'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': \n'Beijing', 'Bangladesh': 'Dhaka'}]\n\nI wanted like this:\n\n[{'India': 'New Delhi', 'Pakistan': 'Islamabad', 'Nepal': 'Kathmandu', 'Bhutan': 'Thimphu', 'China': 'Beijing', 'Bangladesh': 'Dhaka'}]"
] | [
"python",
"python-3.x"
] |
[
"Extract data from current URL and use it in ajax call as a paramenter",
"I am developing a website in which only 1 html page is there in which I first fethch the url & gets the id from url and send it to api using ajax call. On success, I displays data of the given id from url.My code is as- \n\n <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script>\n\n <script type=\"text/javascript\">\n $(document).ready(function () {\n $('#main').hide();\n\n var url = window.location.href;\n var formno = url.substr(url.lastIndexOf('/') + 1);\n\n if (formno != 'Login.html') { \n var apiUrl = 'http://localhost:801/api/api/Patient/Get'; \n $.ajax({\n url: apiUrl,\n crossDomain: true,\n contentType: \"application/json\",\n type: 'GET',\n data: { formNo: formno },\n success: function (result) { \n $('#main').show();\n alert(\"Success\" + result)\n },\n error: function (result) {\n alert(\"error :: \" + JSON.stringify(result))\n }\n }); \n } \n }); \n </script>\n\n\nwhen I use the url as abc.in#1 it displays the success alert but I want to give the url in format abc.in/1 at that time it gives\n\nHTTP Error 404.0 - Not Found\nThe resource you are looking for has been removed, had its name changed, or is temporarily unavailable.\n\n\nWhy it can not find the page? Is there any solution for this?\nI want to give plain url as abc.in/1 where 1 is id and which is dynamic.\nIs there any solution?"
] | [
"javascript",
"jquery",
"html",
"ajax",
"url"
] |
[
"ReferenceError: window is not defined when building pages",
"I'm using vue/nuxt/node js, using npm run generate to deploy the website and getting this error:\nReferenceError: window is not defined\n at plugins_ga (plugins/ga.js:23:0)\n at createApp (.nuxt/index.js:183:0)\n at runNextTicks (internal/process/task_queues.js:62:5)\n at listOnTimeout (internal/timers.js:518:9)\n at processTimers (internal/timers.js:492:7)\n at async module.exports.__webpack_exports__.default (.nuxt/server.js:81:0)\n\nTo my understanding you do: npm run generate -> copy dist folder to zip file -> upload to hosting. What is this error? The error occurred when generating pages eg /about /index. None of the pages are being output to the dist folder."
] | [
"node.js",
"vue.js",
"nuxt.js"
] |
[
"i can't declare a 2 dimentionnal array with sfml Vector2f's data type",
"i just started on making my first game with sfml and c++ and the issue is as title says\nthe error shows on the last line where i declare the 2 dimentional array "scene"\nit says "this array cannot contain elements of this type"\nhere's the code :\nVector2f playerpos;\nVector2f physicsBasedObjects[] = {Vector2f(0,0),Vector2f(100,-200),playerpos};\nVector2f staticobjects[] = {Vector2f(0,-10),Vector2f(10,-10)};\nVector2f scene[][] = {staticobjects,physicsBasedObjects };"
] | [
"c++",
"arrays",
"sfml"
] |
[
"pandas box plot for multiple column",
"My data frames (pandas's structure) looks like above\n\n\nNow I want to make boxplot for each feature on separate canvas. The separation condition is the first column. I have similar plot for histogram (code below) but I can't make working version for the boxplot. \n\n hist_params = {'normed': True, 'bins': 60, 'alpha': 0.4}\n# create the figure\nfig = plt.figure(figsize=(16, 25))\nfor n, feature in enumerate(features):\n # add sub plot on our figure\n ax = fig.add_subplot(features.shape[1] // 5 + 1, 6, n + 1)\n # define range for histograms by cutting 1% of data from both ends\n min_value, max_value = numpy.percentile(data[feature], [1, 99])\n ax.hist(data.ix[data.is_true_seed.values == 0, feature].values, range=(min_value, max_value), \n label='ghost', **hist_params)\n ax.hist(data.ix[data.is_true_seed.values == 1, feature].values, range=(min_value, max_value), \n label='true', **hist_params)\n ax.legend(loc='best')\n\n ax.set_title(feature)\n\n\nAbove code produce such output as (attached only part of it):"
] | [
"python",
"pandas",
"boxplot"
] |
[
"Checking if two int arrays have duplicate elements, and extract one of the duplicate elements from them",
"I'm trying to write a method, union(), that will return an int array, and it takes two int array parameters and check if they are sets, or in other words have duplicates between them. I wrote another method, isSet(), it takes one array argument and check if the array is a set. The problem is I want to check if the two arrays in the union method have duplicates between them, if they do, I want to extract one of the duplicates and put it in the unionArray[] int array. This is what I tried so far.\npublic int[] union(int[] array1, int[] array2){\n \n int count = 0;\n if (isSet(array1) && isSet(array2)){\n for (int i = 0; i < array1.length; i++){\n for (int j = 0; j < array2.length; j++){\n if (array1[i] == array2[j]){ \n System.out.println(array2[j]);\n count ++;\n }\n }\n }\n }\n int[] array3 = new int[array2.length - count];\n \n int[] unionArray = new int[array1.length + array3.length];\n int elementOfUnion = 0;\n \n for (int i = 0; i< array1.length; i++){\n unionArray[i] = array1[i];\n elementOfUnion = i + 1 ;\n }\n int index = 0;\n for (int i = elementOfUnion; i < unionArray.length; i++){\n unionArray[i] = array3[index];\n index++;\n }\n \n \n return unionArray;\n}\n\n\npublic boolean isSet(int[] array){\n boolean duplicates = true;\n \n for (int i = 0; i < array.length; i++){\n for(int n = i+1; n < array.length; n++){\n if (array[i] == array[n])\n duplicates = false;\n }\n }\n \n return duplicates;\n}\n\nWhat I was trying to do is to use all of array1 elements in the unionArray, check if array2 has any duplicates with array1, and then move all the non-duplicate elements from array2 to a new array3, and concatenate array3 to unionArray."
] | [
"java",
"arrays",
"unique"
] |
[
"Refactor if statement with object-oriented style",
"I've this block of code:\n\nif (memo.isEmail)\n doSomething();\nif (memo.isSMS)\n doAnotherAction();\nif (memo.isRecursive)\n doUpdateData();\n\n\nA object \"memo\" can be either \"mail\" and \"SMS\", then the three conditions tested may all be true\n\nHow can I turn this procedural code in OO code? \nIs there a pattern to solve this?"
] | [
"c#",
"oop",
"design-patterns",
"refactoring"
] |
[
"change background color given word in URL",
"I'm looking to change the background color of all pages with /cutticket in the URL using jquery. \n\nRight now I have the following but I am not seeing any visible change. No console errors at the moment. \n\nif (window.location.href.indexOf(\"/cutticket\") > -1) {\n document.body.style.backgroundColor = \"red\";\n}"
] | [
"javascript",
"jquery"
] |
[
"System.IO.FileInfo cannot determine that a file exists on a server at the other end of a network",
"This is my Visual Basic 2005 .NET code:\n\nDim imgflnm as string = \"c:\\testfolder\\testdoc.txt\"\nDim fltotest As New System.IO.FileInfo(imgflnm)\nDim tsrslt As Boolean\ntsrslt = fltotest.Exists\nSystem.Web.HttpContext.Current.Response.Write(\"source file exists result=\" & tsrslt & \"<br/>\")\n\n\nThe above code returns tsrslt as true when it sees the file in question on a local drive-- same drive as the application. But on a mapped drive letter it cannot see the file and so tsrslt is evaluating as false.\n\nI have tried the following:\n\nDNS path\n\n\\\\DPATSERVER\\testfolder\\testdoc.txt\n\n\nip path\n\n\\\\192.xxx.yyy.zz\\testfolder\\testdoc.txt\n\n\ndns path on a non-standard drive\n\n\\\\DPATSERVER\\e\\testfolder\\testdoc.txt\n\n\nip path on a non-standard drive (as above using ip instead of dns)\ndns & ip on non-standard drive using $ after drive letter.\n\nNone of the above can see the file on the remote server. Any suggestions would be appreciated."
] | [
"vb.net",
"system.io.fileinfo"
] |
[
"The usage of Pattern, Matcher, replace",
"I want to remove quotation marks of sentences.\n\nex)\nSackler Gallery postpones controversial “Shipwreck” show\n-> Sackler Gallery postpones controversial Shipwreck show\n\nI know that's possible using Patter - Matcher - replace.\nBut I don't know how to use it.\n\n\nstatic String getText(String content) {\n Pattern NOQMARK = Pattern.compile(\"A\");\n Matcher m;\n m = SCRIPTS.matcher(content); \n content = m.replaceAll(\"\");\n\n return content\n}\n\n\nWhat should I put in \"A\"?\n\nAny suggestion would be helpful for me.\nThanks."
] | [
"java",
"design-patterns",
"matcher"
] |
[
"Provided bucket: version00-d20e4.appspot.com does not match the Storage bucket of the current instance error",
"I have tableview that contain image I retrieve image from Storage by URL I store it database but occasionally I get this error : \n\n'NSInvalidArgumentException', reason: 'Provided bucket: version00-d20e4.appspot.com does not match the Storage bucket of the current instance: myprojectname-d2551.appspot.com'\n\n(I got this image in another view using collectionview so I am sure I use right GoogleService-Info.plist)\nlast time I get this error I delete all related node form database and all my storage, add it again then its work. \nwhat is wrong happen? \nMy code to re\n\n if let ProductImageURL = product.ProductImageURL{\n let imageStorageRef = Storage.storage().reference(forURL:ProductImageURL)\n imageStorageRef.getData(maxSize: 2*1024*1024, completion:{ [weak self](data,error)in\n if error != nil {\n print(error)\n }else{\n DispatchQueue.main.async {\n cell.ProductImage?.image = UIImage(data:data!)\n }\n }\n })//.resume()\n }"
] | [
"ios",
"swift",
"firebase",
"google-cloud-storage"
] |
[
"Multer Muti Upload Image With Express",
"I use React and Express for create Mutiupload Image\nmulter.js\nconst multer = require('multer');\n\nconst storage = multer.diskStorage({\n destination: function (req, file, cb) {\n cb(null, './public/')\n },\n filename: function (req, file, cb) {\n cb(null, new Date().toISOString() + '-' + file.originalname)\n }\n})\n\n\nconst fileFilter = (req, file, cb) => {\n if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') {\n cb(null, true)\n } else {\n //reject file\n cb({message: 'Unsupported file format'}, false)\n }\n}\n\nconst upload = multer({\n storage: storage,\n limits: { fileSize: 1024 * 1024 },\n fileFilter: fileFilter\n})\n\nmodule.exports = upload;\n\npost.controller.js\n async onInsert(req, res) {\n try {\n\n let result = await Service.insert(req.body)\n res.success(result, 201);\n } catch (error) {\n res.error(error.message, error.status)\n }\n },\n\n\n\npost.service.js\n insert(data) {\n return new Promise(async(resolve, reject) => {\n try {\n const obj = new Post(data)\n let inserted = await obj.save()\n resolve(inserted)\n } catch (error) {\n reject(methods.error(error.message, 400))\n }\n });\n },\n\n\nI try to implements Multer on this controller but it can't upload anyway . so how to implements mutiple upload image with this code thank\nI use mongoose by the way"
] | [
"node.js",
"express"
] |
[
"Visual Studio Android Emulator Display Keyboard",
"How can I display keyboard on VS Android Emulator?\nIn AVD I can setup it from emulator configurator, but there is no way in VS."
] | [
"android",
"emulation",
"visual-studio-2015"
] |
[
"SQL Server 2008 R2 Mirroring for Deployment?",
"I am wondering if this is possible and to what degree of expertise I would need to accomplish it. I have 3 databases all built on the SQL Server 2k8R2 platform. 2 are on the same server and 1 is on another server linked to the same network. One is for development (you know the awesome one that you can break, bite, kick when no one is looking etc...) The other is a stage, and finally production. I am wondering if I could set-up some type of mirroring that would allow me to persist programmatic changes across all 3 of them. For example If I were to develop a new table, and SPROC on my dev database. Test and make sure all was well and working, is there a way when i commit my changes to have that table along with its key's, indexes, FK's, and the SPROC i created to be automatically generated in the other 2 databases without me having to re-script and run them. Forgive my ignorance, I know i can script the changes and just load up each one and run the script to generate all of the things I created, but I want to be able to do this in real time on the fly. Is this something that is a painless process which can be done easily? I do not care to replicate the data inside the table(s) only the programmatic bits of code. Any help is greatly appreciated. \n\nThanks much, \nJohn"
] | [
"sql",
"database-design",
"sql-server-2008-r2"
] |
[
"Mobile menu - hamburger icon - 'hover' color not changing and 'focus' on links not working",
"I would like my hamburger icon on my mobile menu to turn black on Hover and my links on my dropdown menu to turn black in Focus mode so people could see which page is active.\n\nThis is the first website I have ever attempted, it is my own website (small business). I used wordpress and oceanwp as the theme. Also used Elementor to style the pages.\nI have learned a lot about css and managed to use it for other details.\nI also learned how to inspect elements with google Chrome inspect, and this is the method I was trying to use to get the css required to fix these issues.\nI have been trying for a long while now and I could not manage, so that is why I have decided to seek help through this forum.\nPlease, please could some one inspect my website in google Chrome and find out how to fix it? My website is:\n\nsantacruzingeniorkonsulent.no\n\nThank you so much in advance."
] | [
"css",
"wordpress",
"mobile",
"menu"
] |
[
"Error while trying to open CSV file in python",
"Python rookie here. Trying to use the CSV module, but I get an error:\n\nIOError: [Errno 2] No such file or directory: 'books.csv'\n\n\nThe actual CSV file is stored on my desktop. I suppose this means Python can't find the file? If so, how can I fix this?\n\nMany thanks in advance!"
] | [
"python",
"csv"
] |
[
"vim does not execute autocommands on startup, but .vimrc is read",
"To save time when creating new scripts I have added the following alias to my .cshrc file:\n\nalias skript 'touch \\!^; chmod +x \\!^; vim \\!^'\n\n\nThis will create the file I gave as an argument to skript, make this file executable, and then open the file in vim. \n\nAll this works well, apart from one thing: the autocmd lines in my .vimrc file are not executed, even though the settings specified in .vimrc are all in place. If I start vim directly, i.e. not using above alias, everythings works as expected.\n\nIn case this is relevant, the autocmd lines produce a default header for files with a certain extension, a process during which a template text file has to be read.\n\nIn case any of you could help me with getting the header to be produced in files created using my skript alias that would be great!\n\nThanks a lot for your time.\n\nEDIT\n\nHere are the autocmd lines from my .vimrc file:\n\nautocmd bufnewfile *.pl so /home/my_home/Templates/perl_template.txt\nautocmd bufnewfile *.pl exe \"1,\" . 10 . \"g/creation date:.*/s//creation date: \" .strftime(\"%d-%m-%Y\")\nautocmd Bufwritepre,filewritepre *.pl execute \"normal ma\"\nautocmd Bufwritepre,filewritepre *.pl exe \"1,\" . 10 . \"g/last modified:.*/s/last modified:.*/last modified: \" .strftime(\"%c\")\nautocmd bufwritepost,filewritepost *.pl execute \"normal `a\""
] | [
"unix",
"shell",
"vim"
] |
[
"Replacing flask internal web server with Apache",
"I have written a single user application that currently works with Flask internal web server. It does not seem to be very robust and it crashes with all sorts of socket errors as soon as a page takes a long time to load and the user navigates elsewhere while waiting. So I thought to replace it with Apache. \n\nThe problem is, my current code is a single program that first launches about ten threads to do stuff, for example set up ssh tunnels to remote servers and zmq connections to communicate with a database located there. Finally it enters run() loop to start the internal server. \n\nI followed all sorts of instructions and managed to get Apache service the initial page. However, everything goes wrong as I now don't have any worker threads available, nor any globally initialised classes, and none of my global variables holding interfaces to communicate with these threads do not exist. \n\nObviously I am not a web developer. \n\nHow badly \"wrong\" my current code is? Is there any way to make that work with Apache with a reasonable amount of work? Can I have Apache just replace the run() part and have a running application, with which Apache communicates? My current app in a very simplified form (without data processing threads) is something like this:\n\ncomm=None\napp = Flask(__name__)\n\nclass CommsHandler(object):\n __init__(self):\n *Init communication links to external servers and databases*\n def request_data(self, request):\n *Use initialised links to request something*\n return result\n\[email protected](\"/\", methods=[\"GET\"]):\ndef mainpage():\n return render_template(\"main.html\")\n\[email protected](\"/foo\", methods=[\"GET\"]):\ndef foo():\n a=comm.request_data(\"xyzzy\")\n return render_template(\"foo.html\", data=a)\n\ncomm = CommsHandler()\n\napp.run()\n\n\nOr have I done this completely wrong? Now when I remove app.run and just import app class to wsgi script, I do get a response from the main page as it does not need reference to global variable comm. \n\n/foo does not work, as \"comm\" is an uninitialised variable. And I can see why, of course. I just never thought this would need to be exported to Apache or any other web server. \n\nSo the question is, can I launch this application somehow in a rc script at boot, set up its communication links and everyhing, and have Apache/wsgi just call function of the running application instead of launching a new one? \n\nHannu"
] | [
"python",
"apache",
"flask",
"wsgi"
] |
[
"Would it be possible to create a file explorer for Windows Phone?",
"I've looked around for a file explorer in windows' phone's marketplace, and couldn't find any (i'm speaking the kind of file explorer you get on Android to well... explore your files).\nWould this be because Microsoft put a restriction on such applications?\n\nIf so, would you assume they just wouldn't accept it on the marketplace, or are there native restrictions to stop it from developing and using it on your phone?\n\nAnticipated thanks :)"
] | [
"c#",
"vb.net",
"windows-phone-7"
] |
[
"Access Denied with $http request in Angular and IE8",
"I am trying to get my angular app to do an $http.get request. Works everywhere but IE8. I am using latest Angular (1.0.6 I think). The only message IE gives is:TypeError: \n\nAccess is denied.\n undefined (in previous angular this was )\n\nMy host (nodejs)is set to send cors headers:\n\nres.header('Access-Control-Allow-Origin', '*'); //config.allowedDomains\nres.header('Access-Control-Allow-Credentials', true);\nres.header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, X-Requested-By');\nres.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');\n\n\nI have tried to get more info about the error using debug tools but:\n\nFiddler: doesn't show xmlhttprequests - seems you can hack your NET app to fix that but not sure what to do with my web page.\nDebugBar: doesn't show these requests either\nFirebugLite: 2 version I tried are broken - just random errors and doesn't load\n\nChanging the hosts to same origin clears the issue so I assume it's trying something but man it's hard to debug.\n\nAngular posts on this seem outdated and I am not sure what to do from here."
] | [
"javascript",
"node.js",
"internet-explorer-8",
"angularjs"
] |
[
"How to get a client's computer name in asp.net core",
"I've tried with\n\nSystem.Net.Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress.ToString()).ToString();\n\n\nbut that didn't work.\nI've also tried to use\n\nPCName = Dns.GetHostEntry(Request.ServerVariables[\"REMOTE_ADDR\"]).HostName; \n\n\nbut this seems to be deprecated for Core"
] | [
"c#",
"model-view-controller",
"asp.net-core"
] |
[
"How to print tree structure with java?",
"I have a question, if the provided data list looks like this: (There are three columns, the first column is ‘id’, the second column is ‘parent_id’, and the third column is ‘name’)\nid parent_id name 1 0 AA 2 1 BB 3 1 CC 4 3 DD 5 3 EE 6 2 FF 7 2 GG 8 4 HH 9 5 II 10 0 JJ 11 10 KK 12 10 LL\nThen how to print on the console in an indented tree structure, indented by spaces. How to do? I tried several versions, but it still doesn't work. How can this be done? How to write to meet this condition。\nSpecifically, I need to represent the following:\nThe effect of the tree structure is like this, there are bb and cc under aa, dd and ee under cc, and ff and gg under bb.\nI wrote this code: (The tree structure has been defined)\npublic class Tree{\n static class Node{\n int id;\n int parentId;\n String name;\n public Node(int id,int parentId,String name){\n this.id=id;\n this.name=name;\n this.parentId=parentId;\n }\n }\n\n public static void main(String[] args) {\n List<Node>nodeList = Arrays.asList(\n new Node(1,0,"aa"),\n new Node(2,1,"bb"),\n new Node(3,1,"cc"),\n new Node(4,3,"dd"),\n new Node(5,3,"ee"),\n new Node(6,2,"ff"),\n new Node(7,2,"gg"),\n new Node(8,4,"hh"),\n new Node(9,5,"ii"),\n new Node(10,0,"jj"),\n new Node(11,10,"kk"),\n new Node(12,10,"ll"));\n print(nodeList);\n }\n\n public static void print(List<Node>nodeList) {\n //todo\n\n }\n}"
] | [
"java",
"algorithm",
"tree",
"binary-tree"
] |
[
"Python entry point commandline script not found when installing with --user flag",
"I recently wrote a package which comes with a command line tool. The setup.py looks something like this\n\nfrom setuptools import setup\n\nsetup(...\n entry_points = {\n 'console_scripts': [\n 'cmdname = modulename.binary:main',\n ],\n },\n ...)\n\n\neverything is fine when I install it without the --user flag via\n\n$ sudo python setup.py install\n$ cmdname\nYes, I'm here! Give me a command!\n\n\nhowever, installing it without root access gives\n\n$ python setup.py install --user\n$ cmdname\n-bash: cmdname: command not found\n\n\nI guess there should be a directory where user scripts are linked to that should be exported to the PATH? How can I achieve that setuptools links to the entry point anyway? Or is that not possible?"
] | [
"python",
"installation",
"setuptools",
"entry-point"
] |
[
"Is it possible to create an MS Access Web App using a pre-existing SQL Server database?",
"We need to building a typical maintenance front end (read, update, create, delete) for an existing relational database, and I have heard that Access Web Apps must \"own\" the SQL server database it uses. \n\nIs it possible to create an MS Access Web App using a pre-existing SQL Server database?\n\nSources say the following:\n\n\n In the process launching the app to SharePoint, a SQL database is\n provisioned that will house all the objects and data that the app\n requires. The database that is created is specific to your app and by\n default not shared with other apps."
] | [
"sql-server",
"ms-access",
"frontend"
] |
[
"What is the best way for customization of multiple TestExecutionListeners methods invoking for TestSuite?",
"For optimizing purpose I need to customize TestExecutionListeners invoking logic\n\nIn my case I have one ApplicationContext and two types of tests:\n\n\nOnes which use WebDriver (let’s call it ObservableTest)\nOnes which use RestTemplate and JdbcTemplate (let’s call it ApiTest)\n\n\nEach type uses its own TestExecutionListener:\n\n\nObservableTest - ObservableTestListener\nApiTest - ApiTestListener\n\n\nBoth ObservableTestListener and ApiTestListener extend TestListener where prepareTestInstance() is defined\n\nObservableTestListener implements beforeTestClass() and afterTestClass() methods as well as ApiTestListener does\n\nI need combine test types above in one JUnit TestSuite in the next way:\n\n\nFor each test prepareTestInstance() is invoked\nAs soon as first ObservableTest is about to be instantiated, beforeTestClass() of ObservableTestListener is executed\nThe same with ApiTest\nafterTestClass() of ObservableTestListener is invoked when last ObservableTest is finished in current Suite\nThe same with ApiTest\n\n\nThings got even more complicated as each test may be run in one suite and in different ApplicationContexts (due to different profiles usage)\n\nI would be very grateful for any hint and digging direction to implement such logic properly\n\nI have two ideas so far:\n\n\nImplementing custom Runner (I'm not confident it is even possible)\nNotify TestContextManager somehow that particular method (beforeTestClass() or afterTestClass()) should or should not be invoked. I have a feeling that @BootstrapWith custom SpringClassRule should help me in that\n\n\nThanks!"
] | [
"java",
"spring",
"junit",
"spring-test"
] |
[
"Adding List to Object in Django View",
"I have searched and read through the internet trying to figure out this problem. Thank you for any advice on this issue.\n\nI have been having problems adding a list of objects to another object in Django. I have an object 'category' and a list of objects 'subcategory', but when I try to put them together as a package 'ad', there is a TypeError: 'subcategory' is an invalid keyword argument for this function.\n\nHere is the view:\n\ndef create_in_category(request, slug):\n category = get_object_or_404(Category, slug=slug)\n subcategory = SubCategory.objects.all()\n\n ad = Ad.objects.create(category=category, subcategory=subcategory, user=request.user,\n expires_on=datetime.datetime.now(), active=False)\n ad.save()\n\n\nWhat am I missing to be able to get all of these elements together? Thanks very much for sharing your knowledge.\n\n\n\nEdit: added the models. \n\nclass Category(models.Model):\n name = models.CharField(max_length=200)\n slug = models.SlugField()\n\n def __unicode__(self):\n return self.name + u' Category'\n\nclass SubCategory(models.Model):\n name = models.CharField(max_length=50, unique=True)\n category = models.ManyToManyField(Category)\n\n def __unicode__(self):\n return self.name + u' SubCategory'"
] | [
"python",
"django",
"views"
] |
[
"Node.js cannot find mysql-database service",
"I'm trying to follow the tutorial noted below:\n\nhttp://www.ibm.com/developerworks/cloud/library/cl-bluemix-nodejs-app/\n\nBut when I push my app, I see the following:\n\nUsing manifest file /mytests/bluemix-node-mysql-upload/manifest.yml\n\nUpdating app jea-node-mysql-upload in org [email protected] / space dev as [email protected]...\nOK\n\nUploading jea-node-mysql-upload...\nUploading app files from: /mytests/bluemix-node-mysql-upload/app\nUploading 53.6K, 11 files\nDone uploading \nOK\nFAILED\nCould not find service mysql-database to bind to jea-node-mysql-upload\n\n\nIs there a problem with the node.js buildpack or is the documentation faulty?"
] | [
"node.js",
"ibm-cloud"
] |
Subsets and Splits