texts
sequence
tags
sequence
[ "Duplicate Rows when Data Binding with LINQ to Entities", "I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView to the results of the following LINQ to entities query. In both cases the grids contain the correct number of rows, but the data from only the first handful of rows is duplicated in all the other rows. I'm directly assigning the return value from this code the the DataSource property on the grids.\n\npublic IEnumerable<DirectoryPersonEntry> FindPersons(string searchTerm)\n{\n DirectoryEntities dents = new DirectoryEntities();\n return from dp in dents.DirectoryPersonEntrySet\n where dp.LastName.StartsWith(searchTerm) || dp.Extension.StartsWith(searchTerm)\n orderby dp.LastName, dp.Extension\n select dp;\n}\n\n\nADDED: This is the alternate plain ADO.NET code that works:\n\n DataTable ret = new DataTable();\n using (SqlConnection sqn = new SqlConnection(ConfigurationManager.ConnectionStrings[\"WaveAdo\"].ConnectionString))\n {\n SqlDataAdapter adap = new SqlDataAdapter(\"select * from DirectoryPersonList where LastName like '\" + searchTerm + \"%' order by LastName \", sqn);\n sqn.Open();\n adap.Fill(ret);\n }\n return ret;\n\n\nMORE: \n\n\nThe query sent to SQL Server by LINQ works. \nIterating the LINQ query results before returning them results in the same duplications.\nIterating the LINQ results in the calling method, before binding, results in the same duplications.\n\n\nUPDATE:\nBased on the very logical and fitting advice from Marc Gravel below, I found that the EF designer had made a very uneducated guess at an Entity Key for my entity class, the first field in its list of fields, Department, of which there are only about seven entries shared across all other records. \n\nThis is indeed the cause of the duplication. If only I could change or remove the entity key, but this EF designer with all the business logic of an Etch-a-Sketch is admirably committed to repeating it's retarded choice of key while laughing at me locked outside begging to change the key." ]
[ ".net", "asp.net", "linq" ]
[ "Using destructuring within import statement", "I have two files- /utils/BroadcasterEmbed.js and /commands/broadcaster.js. Importing BroadcasterEmbed.js to broadcaster.js is the goal. When I test the below code, however, I get the following error TypeError: BroadcasterEmbed is not a constructor\n\nI know this is possible considering an open source implementation I came across. Am I missing something?\n\nBroadcasterEmbed.js\n\nconst { RichEmbed } = require('discord.js');\n\nmodule.exports = class BroadcasterEmbed extends RichEmbed {\n constructor(data = {}) {\n super(data);\n }\n}\n\n\nbroadcaster.js\n\nconst { BroadcasterEmbed } = require('../')\n\nexports.run = (client, message, args) => {\n ...\n\n message.channel.send(new BroadcasterEmbed().setDescription('hello'));\n\n ...\n}" ]
[ "javascript", "discord.js" ]
[ "Lua/Corona Pause Button working outside the button", "Anybody have any ideas as to why my pause button won't work?... If you click anywhere on the screen it pauses when it should be confided to just the button.\n\ncode:\n\nfunction pauseIt(event)\n if event.phase == \"began\" then\n if paused == false then\n audio.play(sound_pause)\n physics.pause()\n paused = true\n elseif paused == true then\n\n physics.start()\n audio.play(sound_pause)\n paused = false\n end\n end\nend\n\npaused = false\nRuntime:addEventListener(\"touch\", pauseIt)\n\n\n\n pause = display.newImage( screenGroup, \"pause.png\" )\n pause.x = _W * 0.12\n pause.y = _H * 0.06\n pause.xScale = 0.2\n pause.yScale = 0.2\n pause.touch = pauseIt" ]
[ "lua", "coronasdk" ]
[ "Releasing memory for array of pointers?", "I have classes Deck and PlayingCard. A Deck object must have a dynamically allocated array of pointers to PlayingCard objects:\n\nPlayingCard** _playing_cards;\n\n\nTo initialise this array, the Deck's constructor and build() functions are called:\n\nDeck::Deck(int size)\n{\n _total_playing_cards = size;\n _deal_next = 0;\n build();\n}\n\nvoid Deck::build()\n{\n _playing_cards = new PlayingCard*[_total_playing_cards];\n for(int i = 1; i <= _total_playing_cards; ++i)\n {\n _playing_cards[i-1] = new PlayingCard(i % 13, i % 4);\n }\n}\n\n\nReleasing the memory allocated with 'new' is handled in the destructor:\n\nDeck::~Deck()\n{\n for(int i = 0; i < _total_playing_cards; ++i)\n {\n delete[] _playing_cards[i];\n }\n delete[] _playing_cards;\n}\n\n\nI then have a separate file, deck_test.cpp, which has a main() to simply construct and destruct a Deck object:\n\nint main()\n{\n Deck deck(52);\n deck.~Deck();\n return 0;\n}\n\n\nThis compiles fine, but when debugging, Visual Studio reports \"Unhandled exception at 0x5ab159da (msvcr100d.dll) in Playing Cards.exe: 0xC0000005: Access violation reading location 0xfeeefee2.\" When looking at the call stack, the problem appears to be occurring where I use the 'delete[]' operator in the 'for' loop within the destructor. Is this not the correct way to release memory from an array of pointers?" ]
[ "arrays", "pointers", "visual-c++", "dynamic", "delete-operator" ]
[ "scapy passing arguments to a PacketList field", "I was wondering how to craft a packet which has a PacketlisField in it.\n\nI want to craft a Packet which is an instance of TestPL2 and pass a value to plist.\n\nclass TestPkt(Packet):\n fields_desc = [ ByteField(\"f1\",65),\n ShortField(\"f2\",0x4244) ]\n def extract_padding(self, p):\n return \"\", p\n\nclass TestPLF2(Packet):\n fields_desc = [ FieldLenField(\"len1\", None, count_of=\"plist\",fmt=\"H\", adjust=lambda pkt,x:x+2),\n FieldLenField(\"len2\", None, length_of=\"plist\",fmt=\"I\", adjust=lambda pkt,x:(x+1)/2), \n PacketListField(\"plist\", None, TestPkt, length_from=lambda x:(x.len2*2)/3*3) ]\n\n>>> pkt=TestPLF2()\n>>> pkt.show()\n###[ TestPLF2 ]###\n len1= None\n len2= None\n \\plist\\\n\n>>> pkt=TestPLF2(['f1=75,f2=76'])\nTraceback (most recent call last):\n File \"<console>\", line 1, in <module>\n File \"/usr/local/lib64/python2.6/site-packages/scapy/base_classes.py\", line 199, in __call__\n i.__init__(*args, **kargs)\n File \"/usr/local/lib64/python2.6/site-packages/scapy/packet.py\", line 80, in __init__\n self.dissect(_pkt)\n File \"/usr/local/lib64/python2.6/site-packages/scapy/packet.py\", line 579, in dissect\n s = self.do_dissect(s)\n File \"/usr/local/lib64/python2.6/site-packages/scapy/packet.py\", line 553, in do_dissect\n s,fval = f.getfield(self, s)\n File \"/usr/local/lib64/python2.6/site-packages/scapy/fields.py\", line 74, in getfield\n return s[self.sz:], self.m2i(pkt, struct.unpack(self.fmt, s[:self.sz])[0])\nerror: unpack requires a string argument of length 2\n>>>" ]
[ "python", "scapy" ]
[ "DS registered EventHandler misses event", "I have two EventHandlers registered via DS (declarative services).\nNow, there is another DS service calling EventAdmin.sendEvent().\nIt happens that only one of the EventHandlers receives the event as one of them seems to not be ready when the event is fired.\nAs a consequence, when the second EventHandler becomes available, it is too late as the event is already consumed.\nBoth EventHandlers have immediate=true set in the @Component annotation.\n\nIs there an \"elegant\" way to solve this scenario?" ]
[ "osgi", "equinox" ]
[ "Display an Image from Oracle 11g ex Database using Generic Handler", "I have accomplished inserting an image into the Oracle database. Now I am trying to display it. \n\nMy handler code is : \n\n public void ProcessRequest(HttpContext context)\n {\n OracleDataReader dr = null;\n OracleCommand cmd = null;\n OracleConnection conn = new OracleConnection(\"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVER_NAME=XE)));User Id=sakthi_studdb;Password=sakthi;\");\n try\n {\n cmd = new OracleCommand\n (\"select IMAGE from IMAGETBL where ID=\" +\n context.Request.QueryString[\"imgid\"], conn);\n conn.Open();\n dr = cmd.ExecuteReader();\n while (dr.Read())\n {\n context.Response.ContentType = \"image/jpg\";\n context.Response.BinaryWrite((byte[])dr[\"IMAGE\"]);\n }\n if (dr != null)\n dr.Close();\n }\n finally\n {\n if (conn != null)\n conn.Close();\n }\n }\n\n\nAnd my aspx image control is :\n\n <div>\nThis is the student image requested:\n\n <asp:Image ID=\"picone\" ImageUrl=\"~/Handler1.ashx?imgid=299\" runat=\"server\" />\n</div>\n\n\nWhen the run the aspx, I don't find any errors. But the image is not displaying. You can find the screen shot of the output I get below.\n\n\n\nI want to know what is wrong.\n\n public void ProcessRequest(HttpContext context)\n {\n OracleConnection conn = new OracleConnection(\"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVER_NAME=XE)));User Id=sakthi_studdb;Password=sakthi;\");\n try\n {\n long imageId = Convert.ToInt64(context.Request.QueryString[\"imgid\"]);\n\n using (OracleCommand cmd = new OracleCommand(\"select IMAGE from IMAGETBL where ID=:ID\", conn))\n {\n cmd.Parameters.Add(\":ID\", OracleDbType.Int64).Value = imageId;\n conn.Open();\n context.Response.ContentType = \"image/gif\";\n context.Response.BinaryWrite((byte[])cmd.ExecuteScalar());\n } \n\n }\n finally\n {\n if (conn != null)\n conn.Close();\n }\n }\n\n\nEven this din't work" ]
[ "c#", "asp.net", "oracle", "blob", "generic-handler" ]
[ "cakephp211 saving data erros (associated tables)", "I have two associated tables (customers hasmany commands) and this is my form:\n\n<?php echo $this->Form->create('Customer');?>\necho $this->Form->input('Client.name', array('disabled' => true,'value' => 'francis')); \necho $this->Form->input('Command.0.the_date');\necho $this->Form->end(__('save'));?>\n\n\nand this is my function:\n\npublic function add() {\n if (!empty($this->request->data)) {\n unset($this->Customer->Command->validate['customers_id']);\n $this->Customer->saveAssociated($this->request->data); \n }\n}\n\n\nBut when i process to save data, nothing happens! \nWhy?\nThanks!" ]
[ "cakephp-2.1" ]
[ "MySql.Data.MySqlClient.MySqlException in Xamarin iOS C#", "I have searched on stackoverflow but cannot find any solution.\nI use a mysql server from a hosting.\nI am developing a product for my graduation. \nwe will use a mysql server, a raspberry pi and an iOS device.\nraspberry can connect mysql server via Java code and its working fine. But I cannot connect my Xamarin solution to mysql server.\nwhat can I do ?\n\nIf anyone can help me, I will be very happy. :)\n\nI use same code of example of library as a connection string: https://components.xamarin.com/view/mysql-plugin\n\n// imports:\nusing UIKit;\nusing MySql.Data.MySqlClient;\nusing System.Data;\n\n// CONNECTION PART OF THE CODE \ntry{\n MySqlConnection sqlconn;\n String connsqlstring = \"Server=myip;Port=3306;database=mydbname;User Id=myusername;Password=mypassword;charset=utf8\";\n sqlconn = new MySqlConnection(connsqlstring);\n sqlconn.Open(); // EXCEPTION IS HERE !!!!\n}catch(MySqlException e){. //SOME CODES }\n\n\n\n MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the\n specified MySQL hosts. ---> System.Net.Sockets.SocketException: Could\n not resolve host '...' at System.Net.Dns.Error_11001\n (System.String hostName) [0x00000] in\n /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/System/System.Net/Dns.cs:308\n at System.Net.Dns.GetHostByAddressFromString (System.String address,\n System.Boolean parse) [0x00034] in\n /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/System/System.Net/Dns.cs:377\n at System.Net.Dns.GetHostEntry (System.Net.IPAddress address)\n [0x0000e] in\n /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/System/System.Net/Dns.cs:404\n at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress)\n [0x0004b] in\n /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/System/System.Net/Dns.cs:394\n at MySql.Data.Common.MyNetworkStream.GetHostEntry (System.String\n hostname) [0x0000c] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.Common.MyNetworkStream.CreateStream\n (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings,\n System.Boolean unix) [0x00008] in <5e4982151d314701bcfe1f0a397fe0db>:0\n at MySql.Data.Common.StreamCreator.GetTcpStream\n (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings)\n [0x00000] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.Common.StreamCreator.GetStream\n (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings)\n [0x0000b] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.NativeDriver.Open () [0x00007] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 --- End of inner exception\n stack trace --- at MySql.Data.MySqlClient.NativeDriver.Open ()\n [0x00027] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.Driver.Open () [0x0000b] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.Driver.Create\n (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings)\n [0x00036] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection ()\n [0x00000] in <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x00083] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x00042] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.MySqlPool.GetConnection () [0x0001c] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySql.Data.MySqlClient.MySqlConnection.Open () [0x000ad] in\n <5e4982151d314701bcfe1f0a397fe0db>:0 at\n MySQLDemo2.ViewController.LoginButton_TouchUpInside (UIKit.UIButton\n sender) [0x00063] in\n /Users/magoya/Projects/MySQLDemo2/MySQLDemo2/ViewController.cs:36" ]
[ "c#", "ios", "mysql", "xamarin" ]
[ "Segmentation fault while executing shell in assembly code", "I'm a newbie to assembly programming. I'm getting a segmentation fault in the following program. Any help would be appreciated. \nThe program essentially executes a bash shell using the execv system call (system call no 11).\n\n.text\n.globl _start\n\n _start:\n jmp callshell\n\n shellcode:\n popl %esi\n xorl %eax, %eax\n movb $0,%al\n movb %al,0x9(%esi)\n movl %esi,0xa(%esi)\n movl %eax,0xe(%esi)\n movb $11, %al\n movl %esi, %ebx\n leal 0xa(%esi),%ecx\n leal 0xe(%esi),%edx\n int $0x80\n\n callshell:\n call shellcode\n shellvariables:\n .ascii \"/bin/bashABBBBCCCC\"" ]
[ "assembly", "segmentation-fault", "buffer-overflow" ]
[ "ithit ajaxbrowser not open webdav folder, but response data is correct", "request(google-chrome console):\n\nRequest URL:https://<name>:5553/myproxy.cgi?5443/\n\nRequest Method:PROPFIND\nStatus Code:207 Multi-Status\nRequest Headersview source\nAccept:*/*\nAccept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3\nAccept-Encoding:gzip,deflate,sdch\nAccept-Language:en-US,en;q=0.8\nAuthorization:Basic dmJveDp2Ym94\nConnection:keep-alive\nContent-Length:241\nContent-Type:text/xml; charset=\"UTF-8\"\nCookie:settingsCookie=5-9-5-0; Auth=Basic%20dmJveDp2Ym94; testCookie=test\nDepth:0\nHost:<name>:5553\nOrigin:https://<name>:5553\nReferer:https://<name>:5553/Browser/index.html\nUser-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.70 Safari/537.17\nQuery String Parametersview sourceview URL encoded\n5443/:\nRequest Payload\n<?xml version=\"1.0\"?><propfind xmlns=\"DAV:\"><prop><resourcetype/><displayname/><creationdate/><getlastmodified/><getcontentlength/><getcontenttype/><supportedlock/><lockdiscovery/><quota-available-bytes/><quota-used-bytes/></prop></propfind>\nResponse Headersview source\nCache-Control:max-age=0\nConnection:Keep-Alive, Keep-Alive\nContent-disposition:attachment; filename=\nContent-Encoding:gzip\nContent-Length:449\nContent-Type:text/xml; charset=\"utf-8\"\nDate:Wed, 20 Feb 2013 05:37:37 GMT\nExpires:Wed, 20 Feb 2013 05:37:37 GMT\nKeep-Alive:timeout=15, max=59\nServer:Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/1.0.1c DAV/2\nVary:Accept-Encoding\n\n\nresponce data:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<D:multistatus xmlns:D=\"DAV:\" xmlns:ns0=\"DAV:\">\n<D:response xmlns:lp1=\"DAV:\" xmlns:lp2=\"http://apache.org/dav/props/\" xmlns:g0=\"DAV:\">\n<D:href>/</D:href>\n<D:propstat>\n<D:prop>\n<lp1:resourcetype><D:collection/></lp1:resourcetype>\n<lp1:creationdate>2013-02-18T12:59:45Z</lp1:creationdate>\n<lp1:getlastmodified>Mon, 18 Feb 2013 12:59:45 GMT</lp1:getlastmodified>\n<D:supportedlock>\n<D:lockentry>\n<D:lockscope><D:exclusive/></D:lockscope>\n<D:locktype><D:write/></D:locktype>\n</D:lockentry>\n<D:lockentry>\n<D:lockscope><D:shared/></D:lockscope>\n<D:locktype><D:write/></D:locktype>\n</D:lockentry>\n</D:supportedlock>\n<D:lockdiscovery/>\n</D:prop>\n<D:status>HTTP/1.1 200 OK</D:status>\n</D:propstat>\n<D:propstat>\n<D:prop>\n<g0:displayname/>\n<g0:quota-available-bytes/>\n<g0:quota-used-bytes/>\n</D:prop>\n<D:status>HTTP/1.1 404 Not Found</D:status>\n</D:propstat>\n</D:response>\n</D:multistatus>\n\n\nstatus and data are correct but it throw error NotFoundLocation. \nI suppose that problem maybe in comparing send/receive \"folder\" non identical.\nplease, post your opinions." ]
[ "webdav", "ithit-ajax-file-browser" ]
[ "mustache js - Can't access array value using tables", "I am having a problem with Mustache.js accessing to the values of a json array and I need some help.\n\nThe problem is when I want to access to the values using a table. It always shows [object Object], when it should show the array content.\n\nBelow is a working and a non-working example:\n\n<!DOCTYPE html>\n<html>\n<head>\n <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\n <script src=\"https://raw.github.com/janl/mustache.js/0.7.2/mustache.js\"></script>\n</head>\n<body>\n<div id=\"template\" style=\"display:none\">\n <p>Works but not what I need:</p>\n <p>{{#numbers}} {{.}} {{/numbers}} </p>\n <p>Doesn't work:</p>\n <table>\n <tr>\n {{#numbers}} <th> {{.}} </th> {{/numbers}}\n </tr>\n </table>\n</div>\n<div id=\"rendered\"></div>\n<script>\nvar json = {\n \"numbers\": [ 1, 2, 3 ]\n };\nvar compiledTemplate = Mustache.to_html($('#template').html(), json).replace(/^\\s*/mg, '');\n$('#rendered').html(compiledTemplate);\n</script>\n</body>\n</html>\n\n\nOutput is:\n\nWorks but not what I need:\n1 2 3\nDoesn't work:\n[object Object] \n\n\nIs there any way to solve this problem or to print the object attributes using mustache.js?\n\nThe issue was already asked in their issue system, no replies yet:\nhttps://github.com/janl/mustache.js/issues/295\n\nThanks,\nMariano." ]
[ "javascript", "templates", "mustache" ]
[ "CSS floating elements causes other element background colors to disappear", "I am testing out CSS and seeing how it works with floating elements in a horizontal menue:\n\n<ul id=\"navlist\">\n <li><a href=\"#\">Item one</a></li>\n <li><a href=\"#\">Item two</a></li>\n <li><a href=\"#\">Item three</a></li>\n</ul>\n\nul#navlist {\n list-style-type: none;\n margin: 0;\n padding: 0;\n background-color: cyan;\n}\nul#navlist li {\n display: inline;\n background-color: pink;\n}\n\n/*ul#navlist li a {\n float:left;\n}*/\n\n\nI use the background colors to visually see what is affected. Here is the output:\n\noutput\n\nNotice the left gap between the list items. Now when I un-comment/insert the the following line:\n\nul#navlist li a {\n float:left;\n }\n\n\nThe gap disappears (what I intended) but the background colors for both ul and li disappear. Output Why is this?" ]
[ "html", "css" ]
[ "How to debug lost events posted from non-GUI thread in Qt?", "As the subject says, I'm posting events from non-GUI thread (some GStreamer thread, to be precise). Code looks like this:\n\nGstBusSyncReply on_bus_message(GstBus* bus, GstMessage* message, gpointer data)\n{\n bool ret = QMetaObject::invokeMethod(static_cast<QObject*>(data), \"stateChanged\", Qt::QueuedConnection);\n Q_ASSERT(ret);\n\n return GST_BUS_PASS;\n}\n\n\nThe problem is, stateChanged (doesn't matter whether it is a slot or signal) is not called. I've stepped into QMetaObject::invokeMethod with debugger, followed it till it called PostMessage (it is Qt 4.6.2 on Windows, by the way) – everything seemed to be OK.\n\nObject pointed to by data lives in GUI thread, I've double-checked this.\n\nHow can I debug this problem? Or, better, maybe sidestep it altogether?" ]
[ "qt", "events", "multithreading", "gstreamer" ]
[ "Remove backslash in string with ansible", "Im struggling with removing backslash in a string like this :\n- name: Set var\nset_fact:\n var: "{{ _var.stdout_lines[0].replace('\\\\\\\\', ' ').split(' ')[1] }}"\n\nwhere _var is :\n "_var": {\n "changed": true,\n "delta": "0:00:00.406263",\n "end": "2020-10-20 09:03:36.332342",\n "failed": false,\n "rc": 0,\n "start": "2020-10-20 09:03:35.926079",\n "stderr": "",\n "stderr_lines": [],\n "stdout": "MYSERVER\\\\myuser\\r\\n",\n "stdout_lines": [\n "MYSERVER\\\\myuser"\n ]\n}\n\nAs Im looking to catch only myuser as a result." ]
[ "ansible" ]
[ "How to get image matrix from axes content", "Is there a way to get the content of a contourf plot as an image matrix? I want rasterize only the content, not the axes, labels and the empty space of the entire figure.\n\nMy goal is to overlay a transparent, colored contour plot over a grayscale image and I don't see another way, since MATLAB has only one colormap per figure." ]
[ "matlab", "matlab-figure" ]
[ "RoR && \"coming soon\" page", "I am looking for a simple way to implement simple \"coming soon\" (pre-launch) page for my project on Ruby on Rails. \nUser should be able to leave an email in order to be notified when project is launched.\n\nIs there such a plugin\\gem? Or I should do it myself..." ]
[ "ruby-on-rails", "ruby", "ruby-on-rails-plugins" ]
[ "How to add a file to ClearCase database, but not in source control?", "On my project I have some files that are generated automatically, so you'd normally don't put those in Source Control.\n\nBut since this process takes a long time and they change quite periodically, I'd rather keep them in Clear Case database to not impose this process to every one that desires to compile the source that isn't directly related to these files.\n\nSo, is there a way that I could add files on ClearCase UCM without creating a version tree?\n\nMore directly, I'd like to know if there a way to only one version per branch. As if when delivering this file to the main branch, it would delete the old version an replace it by the new one.\n\nI know that this is a bit unorthodox, but I ask this because I'm not interested by the generated files history and I'd like to save space in the server." ]
[ "version-control", "clearcase", "clearcase-ucm" ]
[ "jquery css property top and left not working", "I have following jquery code .\n\nif(bubble.label != undefined){\n console.log(bubble.label.attr('style'));\n var bubbleStyle = bubble.label;\n bubbleStyle.css({\n color: 'red', \n left: 0+'px',\n top: -660+'px'\n });\n}\n\n\nIn above code css property color: 'red', applies but not left and top . I have tried it with giving position : 'absolute' but it still not works . Please help me on this .Thanks." ]
[ "jquery", "css" ]
[ "Multiple Automatic Reports with Subgroup Loop in R", "I'm trying to create automated PDF RMarkdown reports for fitness testing data based on the training hub city.\nI believe I'm very close by following the outline here:\nR Knitr PDF: Is there a posssibility to automatically save PDF reports (generated from .Rmd) through a loop?\nHowever, this is creating reports with the same data for only 1 hub despite both being named differently (report.A.pdf and report.B.pdf). How can I get the subgroup to loop properly to show data from the different hubs?\nSample data:\n Date Athlete Test Average Hub\n1 2019-06-03 Athlete1 Broad_Jump 175.000000 A\n2 2019-06-10 Athlete1 Broad_Jump 187.000000 A\n3 2019-06-10 Athlete2 Broad_Jump 200.666667 B\n4 2019-06-10 Athlete3 10m_Sprint 1.831333 B\n5 2019-06-10 Athlete2 10m_Sprint 2.026667 B\n6 2019-06-17 Athlete1 Broad_Jump 191.500000 A\n7 2019-06-17 Athlete2 Broad_Jump 200.666667 B\n8 2019-06-17 Athlete3 10m_Sprint 1.803667 B\n9 2019-06-17 Athlete2 10m_Sprint 2.090000 B\n10 2019-06-24 Athlete1 Broad_Jump 192.000000 A\n\nR Script for Rendering RMarkdown\nWT <- read.csv("WT.csv")\nfor (hub in unique(WT$Hub)){\n subgroup <- subset(WT, Hub == hub)\n render("Hub_Test.rmd",output_file = paste0('report.', hub, '.pdf')) \n}\n\nRMarkdown File (Hub_Test.rmd):\nWT <- read.csv("WT.csv")\n\nfor (hub in unique(WT$Hub)){\n subgroup <- subset(WT, Hub == hub)\n}\n\nsummary(subgroup)\n\n\nThis set up creates 2 PDFs in my working directory with ONLY A data. I must be missing something." ]
[ "r", "for-loop", "pdf", "r-markdown", "render" ]
[ "When using truncate I get the following error \"index 113257 out of string\"", "What does this error mean? Here is the line of code that generates it\n\n apts[ndex] = truncate(results[ndex][:public_note].to_s,:length => 300)\n\n\nresults is an array of activerecord objects" ]
[ "ruby-on-rails", "ruby", "truncate" ]
[ "How to change cloudfront request url to work with elasticbeanstalk API", "I'm new to amazon aws, but I have a question.\nI hosted a react app with a amazon S3 bucket and distribution and a spring boot backend with elastic beanstalk.\nThey are both running and working, but when I try to communicate from the hosted react app with the hosted backend. The request url is wrong.\nIt uses the url of my hosted react app instead of the url of the hosted api.\nLet's say my frontend is "frontend.com" and my backend is "backend.com"\nFor example I have a request in the backend /rest/items/all, the react app will call "frontend.com/rest/items/all" instead of "backend.com/rest/items/all"...\nIs there any way to fix this?" ]
[ "amazon-web-services", "amazon-elastic-beanstalk", "amazon-cloudfront" ]
[ "How to rotate elements with SVG Salamander", "I use SVG Salamander to display and manipulate SVG images in Java. I managed to change fill, stroke or text of elements and display the changes.\n\nNow I want to rotate an element. So I tried to manipulate the transformation matrix:\n\nSVGElement e = diagram.getElement(\"path4150\");\nSystem.out.println(e.getPresAbsolute(\"transform\").getStringValue());\nStyleAttribute t = e.getPresAbsolute(\"transform\");\ndouble[] d = t.getDoubleList();\nd[0] = -0.39394618;\nd[1] = -0.91913346;\nd[2] = 0.91913357;\nd[3] = -0.39394618;\nd[4] = -429.42706;\nd[5] = 1513.019;\nt.setStringValue(\"matrix(\" + Joiner.on(\",\").join(Doubles.asList(d)) + \")\");\nSystem.out.println(e.getPresAbsolute(\"transform\").getStringValue());\ndiagram.render(graphics);\n\n\nOutput:\n\n\n matrix(0.87615346,0.48203226,-0.48203232,0.87615346,468.09264,-25.725313)\n matrix(-0.39394618,-0.91913346,0.91913357,-0.39394618,-429.42706,1513.019)\n\n\nAs I can see in the output, the matrix is changed. But the element is not rotating in the picture." ]
[ "java", "svg", "svg-salamander" ]
[ "How to refer to entire pipeline object without a script block", "With the advent of PowerShell V3 instead of having to write:\n\nGet-Process | Where { $_.ProcessName -match \"win\" }\n\n\n...one could now write the more terse:\n\nGet-Process | Where ProcessName -match \"win\"\n\n\n... a clear win (ahem) for shell use.\n\nNow let's say I had a simple array of strings, call it $stuff. Is it possible to reduce this:\n\n$stuff | Where { $_ -match \"win\" }\n\n\n...in an analogous way to the first example, i.e. removing the script block and referring to the entire object, in this case?" ]
[ "powershell", "scriptblock" ]
[ "How to delete azure artifact symbol packages", "I have created a local feed for NuGet packages on our Azure DevOps Service (not Server!). \n\nI use a Pipeline to generate automatically the NuGet packages and use a \"Index sources and publish symbols\"-Task to publish the Symbols to \"Symbol Server in this organization/collection (require azure artifacts)\".\n\nI know how to delete old NuGet packages from artifacts (space requirement 0,22 GB), but obviously the symbol packages are not deleted with them (space requiremend 2,49 GB) (local created on my PC both need around 220 MB / 250 MB).\n\nMy Question is, is there any way to delete published NuGet Symbol Packages from Azure Artifacts by hand?\n\nKind regards\n\nMirko \n\nedit: deleted old published packages from azure artifacts feed, reduces space consumption of the packages itself, but not of the symbols.\n\nSolution: Deleting old Runs of the Pipeline frees the Space within the next 24 hours." ]
[ "azure", "azure-devops", "debug-symbols" ]
[ "SQLite database connection problems java/eclipse", "import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\n\npublic class GestorBase\n{\nprivate ResultSet resultset;\nprivate static Connection con;\nprivate Statement sentencia;\n\npublic static void main(String[] args) throws SQLException, ClassNotFoundException\n {\n\n Class.forName(\"org.sqlite.JDBC\");\n\n con = DriverManager.getConnection(\"jdbc:sqlite:db/Freepark.sqlite\");\n\n System.out.println(\"error al buscar la base de datos\");\n\n Statement sentencia = con.createStatement();\n\n String query = \"SELECT * FROM Restaurantes\";\n\n ResultSet resultset = sentencia.executeQuery(query);\n\n\n while(resultset.next())\n {\n String nombre = resultset.getString(\"NOMBRE\");\n String calle = resultset.getString(\"CALLE\");\n int codigo = resultset.getInt(\"CODIGO\");\n System.out.println(\"Codigo de restaurante: \"+ codigo +\" Nombre de restaurante: \"+ nombre +\" Calle del restaurante: \"+ calle);\n }\n\n\n\n }\n}\n\n\nI am trying to connect to a sqlite database in Java but I get this console log:\n\nException in thread \"main\" java.sql.SQLException: out of memory\nat org.sqlite.DB.throwex(DB.java:288)\nat org.sqlite.NestedDB._open(NestedDB.java:73)\nat org.sqlite.DB.open(DB.java:77)\nat org.sqlite.Conn.<init>(Conn.java:88)\nat org.sqlite.JDBC.connect(JDBC.java:64)\nat java.sql.DriverManager.getConnection(Unknown Source)\nat java.sql.DriverManager.getConnection(Unknown Source)\nat GestorBase.main(GestorBase.java:21)" ]
[ "java", "sql", "eclipse" ]
[ "Xcode AppDelegate wont link to textfields", "I am following along in a book to learn swift and I am building a basic loan calculator for OS-X using XCode. I am getting two errors in my code and it wont allow me to attach the Outlets to my textfields. The errors are:\n\n\nLine 16 - Use of Undeclared type \"NSTestField\" but I changed it to NSTextField and it still shows an error under the mistyped var name.\nLine 35 - Postfix \".\" is reserved. The error carrot is on the dot between loanAmountField and doubleValue.\n\n\nAlso, it wont allow me to drag the outlets into my app. I am guessing I did not attach the appdelegate file to the right window since the window option is not marked but I cant figure out how to do that. The book just says it should already be marked.\n\nMy code showing errors\n(Sorry, I tried using the \"code sample\" button when posting this but even after indenting 4 spaces and pasting my code it continued to tell me I did not indent.)\n\nThe appdelegate showing that \"window\" isnt marked" ]
[ "appdelegate" ]
[ "Django Across All Apps", "I am creating a rather large django project which will require two things. 1) I need a few template files to be accessible across all apps. 2) I need a model to be accessible across all apps. How do I go about doing that? \n\nAs far as the templates are concerned, it seems adding it to the TEMPLATES directive doesn't work.\n\nAs far as the models are concerned, can I have a models.py in the project/project folder or something like that to be accessible by all apps?\n\nDjango 1.10 and Python 3.5\n\nTEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': ['templates'],\n 'APP_DIRS': True,\n 'OPTIONS': {\n[...]" ]
[ "python", "django" ]
[ "Java simple for loop does not iterate", "During execution the method is called and the integer i displays as 0 on screen. However, no output is forthcoming from inside the for loop, suggesting the for loop doesnt execute. I have also tested this with breakpoints, and have obtained the same results. Any help is appreciated. \n\nprivate void decrypt_btnActionPerformed(java.awt.event.ActionEvent evt) {\n int ciphertext_length = Ciphertext().length();\n String decrypted_char = \"\";\n int i = 0;\n\n System.out.println(\"increment\" + i); \n\n try {\n for (i = 0; i == ciphertext_length; i++) {\n\n System.out.println(\"test\" + i);\n\n String cipher_current_char = getLetterAtIndex(Ciphertext(), i);\n int pos_char_in_alphabet = getIndexAtLetter(Alphabet(), cipher_current_char);\n\n decrypted_char = decrypted_char +\n getLetterAtIndex(Alphabet(), pos_char_in_alphabet - 5);\n\n status_label.setText(100 / i + \"%\");\n }\n } catch (Exception e) {\n e.getMessage();\n }\n\n plain_ta.setText(decrypted_char);\n}" ]
[ "java", "for-loop", "loops" ]
[ "What does seq actually do in Haskell?", "From Real World Haskell I read\n\nIt operates as follows: when a seq expression is evaluated, it forces its first argument to be evaluated, then returns its second argument. It doesn't actually do anything with the first argument: seq exists solely as a way to force that value to be evaluated.\n\nwhere I've emphasised the then because to me it implies an order in which the two things happen.\nFrom Hackage I read\n\nThe value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.\nA note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. […]\n\nFurthermore, if I click on the # Source link from there, the page doesn't exist, so I can't see the code of seq.\nThat seems in line with a comment under this answer:\n\n[…] seq cannot be defined in normal Haskell\n\nOn the other hand (or on the same hand, really), another comment reads:\n\nThe 'real' seq is defined in GHC.Prim as seq :: a -> b -> b; seq = let x = x in x. This is only a dummy definition. Basically seq is specially syntax handled particularly by the compiler.\n\nCan anybody shed some light on this topic? Especially in terms of:\n\nWhat source is right?\nIs seq's implementation really not writable in Haskell?\n\nIf so, what does it even mean? That it is a primitive? What does this tell me about what seq actually does?\n\n\nIn seq a b is a guaranteed to be evaluated before b at least in the case that b makes use of a, e.g. seq a (a + x)?" ]
[ "haskell", "functional-programming", "lazy-evaluation", "order-of-execution", "weak-head-normal-form" ]
[ "how to pick 2nd last child by css", "I want to select 2nd last-child.\nwhich is the product, Kindly suggest me. \n\n<ul>\n<li><a href=\"#\">Home</a></li><li><a href=\"#\">About</a></li>\n<li><a href=\"#\">Setting</a></li>\n<li><a href=\"#\">Product</a></li>\n<li><a href=\"#\">COntact US</a></li>\n</ul>\n\n<style>\nul li a{\ncolor: black;\n}\nul li a:nth-child(n-1) {\ncolor:red;\n}\n</style>" ]
[ "css-selectors" ]
[ "MySQL - Fetching users who sent the most recent messages", "I have a messages table as follows:\n\n\n\nBasically what I want is, I want to fetch n users who sent the most recent messages to a group. So it has to be grouped by from_user_id and sorted by id in descending order. I have the following query:\n\nSELECT `users`.`id` AS `user_id`, `users`.`username`, `users`.`image` \nFROM `group_messages`\nJOIN `users` ON `users`.`id` = `group_messages`.`from_user_id`\nWHERE `group_messages`.`to_group_id` = 31\nGROUP BY `users`.`id`\nORDER BY `group_messages`.`id` DESC;\n\n\nThe problem with this is, when I group by user.id, the row with the smallest id field is taken into account. Therefor what I get is not in the order which id is descending. \n\nSo is there a way to group by, taking the greatest id into account ? Or should I approach it another way ?\n\nThanks in advance.\n\n\n\nEdit: I think I got it.\n\nSELECT `x`.`id`, `users`.`id` AS `user_id`, `users`.`username`, `users`.`image` \nFROM (SELECT * FROM `group_messages` ORDER BY `group_messages`.`id` DESC) `x`\nJOIN `users` ON `users`.`id` = `x`.`from_user_id`\nWHERE `x`.`to_group_id` = 31\nGROUP BY `users`.`id`\nORDER BY `x`.`id` DESC;\n\n\nJust had to make a select from an already ordered list." ]
[ "mysql", "sql", "database" ]
[ "Find boolean mask by pattern", "I have array:\n\narr = np.array([1,2,3,2,3,4,3,2,1,2,3,1,2,3,2,2,3,4,2,1])\nprint (arr)\n[1 2 3 2 3 4 3 2 1 2 3 1 2 3 2 2 3 4 2 1]\n\n\nI would like find this pattern and return booelan mask:\n\npat = [1,2,3]\nN = len(pat)\n\n\nI use strides:\n\n#https://stackoverflow.com/q/7100242/2901002\ndef rolling_window(a, window):\n shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)\n strides = a.strides + (a.strides[-1],)\n c = np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)\n return c\nprint (rolling_window(arr, N))\n[[1 2 3]\n [2 3 2]\n [3 2 3]\n [2 3 4]\n [3 4 3]\n [4 3 2]\n [3 2 1]\n [2 1 2]\n [1 2 3]\n [2 3 1]\n [3 1 2]\n [1 2 3]\n [2 3 2]\n [3 2 2]\n [2 2 3]\n [2 3 4]\n [3 4 2]\n [4 2 1]]\n\n\nI find positions of first values only:\n\nb = np.all(rolling_window(arr, N) == pat, axis=1)\nc = np.mgrid[0:len(b)][b]\nprint (c)\n[ 0 8 11]\n\n\nAnd positions another vals:\n\nd = [i for x in c for i in range(x, x+N)]\nprint (d)\n[0, 1, 2, 8, 9, 10, 11, 12, 13]\n\n\nLast return mask by in1d:\n\ne = np.in1d(np.arange(len(arr)), d)\nprint (e)\n[ True True True False False False False False True True \n True True True True False False False False False False]\n\n\nVerify mask:\n\nprint (np.vstack((arr, e))) \n[[1 2 3 2 3 4 3 2 1 2 3 1 2 3 2 2 3 4 2 1]\n [1 1 1 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0]]\n 1 2 3 1 2 3 1 2 3 \n\n\nI think my solution is a bit over-complicated. Is there some better, more pythonic solution?" ]
[ "python", "arrays", "numpy", "boolean", "stride" ]
[ "Convert CString to std::wstring", "How can I convert from CString to std::wstring?" ]
[ "c++", "string", "wstring" ]
[ "aiokafka ProducerClosed error while producing messages asynchronously", "I am using aiokafka to produce messages asynchronously. I have an Api using django which is producing messages to kafka queue. It was working fine. Now When I have converted the same api to use aiohttp server then following error is coming:-\n\n\n aiokafka.errors.ProducerClosed: ProducerClosed\n\n\nFirst message is getting produced successfully. Above error is coming on 2nd message production.\n\nloop = asyncio.get_event_loop()\nproducer = AIOKafkaProducer(\n loop=loop,\n bootstrap_servers=\"127.0.0.1:9092\"\n)\nawait producer.start()\nresponse = await producer.send_and_wait(queue_name, msg)\nawait producer.stop()\n\n\nThere is no information regarding this error in aiokafka docs. Please help.\n\nEdit:\nI am shaing this producer among handers. If I leave the producer open, will it cause any issues? When the producer will be closed automaticaly?" ]
[ "python-asyncio", "python-3.7" ]
[ "How to get Resource(int) from String - Android", "Possible Duplicate:\n Android, getting resource ID from string? \n\n\n\n\nString res = \"R.drawable.image1\";\n\n\nI need to get it's INT id. Please help me!" ]
[ "java", "android", "string", "resources", "int" ]
[ "word2vec: user-level, document-level embeddings with pre-trained model", "I am currently developing a Twitter content-based recommender system and have a word2vec model pre-trained on 400 million tweets.\n\nHow would I go about using those word embeddings to create a document/tweet-level embedding and then get the user embedding based on the tweets they had posted? \n\nI was initially intending on averaging those words in a tweet that had a word vector representation and then averaging the document/tweet vectors to get a user vector but I wasn't sure if this was optimal or even correct. Any help is much appreciated." ]
[ "python", "twitter", "nlp", "word2vec", "word-embedding" ]
[ "Instantiating similar webpages with different content", "To begin, I'm sorry if the title is misleading. I find it hard to put it into words.\n\nMy question is regarding websites that have a lot of pages that are structurally identical, but the content is different.\n\nTake Facebook as an example. Every person's profile is a \"/profile.php\" of some sort, but depending on whose profile you're viewing, the content is different.\n\nIt seems to me like there is one single .php-file for a profile, which loads content based on a profile ID in the database.\n\nSo, the question:\nCertain types of CMS, like Drupal, do this. You create a node, and it has some content. You create another node of the same type, with different content, but it certainly doesn't create a brand new .php-file on your server for every single node, right? What's the process here? Can I program this using PHP?\n\nI'm very much a beginner at PHP, but I'd very much like to learn how to achieve this practically.\n\nAlso, before any sarcastic \"just use Drupal\" comments arise, keep in mind that I do use that already, but again, I want to see if I can learn how to do this myself." ]
[ "php", "content-management-system" ]
[ "How do I call a function on a PHP page from an JS Axios request", "I have a JS frontend where I make an Axios request to a BE php index page. The BE page has two functions getAllData() and getSortedData().\n\ngetSortedData needs 2 params passing in sortBy and sortType.\n\nHow do I call the relevant function and pass the params in?\n\nI have tried this:\n\naxios({\n method: 'post',\n url: 'http://localhost/BE/index.php?f=getAllData',\n timeout: 4000, // 4 seconds timeout \n })\n .then(response => {\n return response.data;\n}) \n.catch(error => console.error('timeout exceeded'));\n\n\nbut that doesn't work and I need to pass the params in for the second function.\n\nHere is my PHP index page that has the 2 methods in\n\n<?php\n header(\"Access-Control-Allow-Origin: *\");\n\n include_once 'GameListClass.php';\n include_once 'DataClass.php';\n include_once 'Classes/SortedDataClass.php';\n\n\n function getSortedData($sortby, $asc) {\n $json_games_list = getAllData();\n $sorted_game_list = new SortedData();\n return print_r(json_encode($sorted_game_list->getSortedJSONData($json_games_list, $sortby, $asc)));\n }\n\n function getAllData() {\n $game_list = new GameList(); \n return peint_r(json_encode($game_list->getData()));\n }\n\n\nEdit\n\nIs there a more elegant way than adding the function name and any params as a query string i.e \n\n?f=getAllData,\n\n\nCan I pass as params?\n\nExample:\n\naxios({\n method: 'post',\n url: 'http://localhost/BE/index.php,\n params: {\n func: 'getAllData',\n sortBy: 'name'\n },\n timeout: 4000, // 4 seconds timeout \n})\n.then(response => {\n return response.data;\n}) \n.catch(error => console.error('timeout exceeded'));" ]
[ "javascript", "php", "parameters", "axios" ]
[ "Proper escape when using regex in JSON (trying to create a spaCy pattern matching file)", "how can I get the JSON for this string to accept the regex expression that also includes a special character ("\\")? I have tried a few things and I can't seem to get it to work. I am trying to create a spaCy pattern jsonl file but it keeps puking on this line due to that regx and special character. It is just cases like this that are not working. Obviously user error, I just can't seem to figure out how to properly escape it so it will parse properly. Any input or help would be appreciated.\nFor this part (?i)SER+-\\d+ I have tried escaping (?i)SER+-\\\\d+ or (?i)SER+-\\\\\\d+ but it doesn't work. \n\nimport json\n\ns = '{"label":"PRODUCT", "pattern": [{"TEXT": {"TEXT": {"REGEX": "(?i)SER+-\\d+"}}]}'\n\nprint(s)\n# parse x:\ny = json.loads(s)" ]
[ "python", "json", "regex", "spacy" ]
[ "\"Import Error: No module named urls\" with Django 1.8 and Rest Framework 3.7", "I'm using django==1.8, rest_framework=3.7.7, python==2.7.12\n\nurls.py\n\nurlpatterns += [\n url(r'^api/core/', include('core.urls')),\n]\n\n\ncore/urls.py\n\nurlpatterns=[\n url(r'^/users/', core_view.userlist),\n]\n\n\nviews.py\n\nclass UserList(generics.ListAPIView):\nqueryset = User.objects.all()\nserializer_class = UserSerializer\nuserlist = UserList.as_view()\n\n\nWhen I'm navagating to: http://localhost:8000/api/core/users I'm getting the following error:\n\nImportError at /api/core/users\nNo module named urls\nRequest Method: GET\nRequest URL: http://localhost:8000/api/core/users\nDjango Version: 1.8\nException Type: ImportError\nException Value: \nNo module named urls\nException Location: /usr/local/lib/python2.7/dist-packages/rest_framework/compat.py in <module>, line 26\nPython Executable: /usr/bin/python\nPython Version: 2.7.12\n\n\nwhat is wrong in configuration?" ]
[ "python", "django", "django-rest-framework", "django-urls" ]
[ "How to get audit record details using FetchXML", "Using this query im able to retrieve audit records in Microsoft Dynamics CRM online\n\n<fetch version=\"1.0\" >\n <entity name=\"audit\" >\n <all-attributes/>\n </entity>\n</fetch>\n\n\nBut this lacks the info about what happened in the operation, more specificly the old value and new value of the column changed. This data is shown when i use the audit tool in the settings of the regular interface, so the data is present. Does anyone know how to fetch it? Is there another entity im missing?" ]
[ "dynamics-crm", "fetchxml" ]
[ "ActivityMock for Fragment in test project", "I have Activity that contains few Fragments, now I would like to test one of this Fragment but I would like to separate test and test only core functionality of selected Fragment not bothering what is happening in main Activity. \n\nMy idea is to create a mock Activity which will just add Fragment in onCreate() method. Then I will make some tests. But I would not like to include mock Activity to my main project, I would rather include it to test project. So I did something like this:\n\n\nI have created MockActivity:\n\npublic final class ActivityMock extends Activity {\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n FragmentTransaction t = getFragmentManager().beginTransaction();\n MyFragment f = new MyFragment();\n t.add(f, \"MY_FRAGMENT\");\n t.commit();\n }\n}\n\nI want to test it like this:\n\npublic final class MyFragmentTest extends\nActivityInstrumentationTestCase2<ActivityMock> {\n\n public MyFragmentTest() {\n super(ActivityMock.class);\n }\n\n public void testSomething() {\n ActivityMock mActivity = getActivity();\n //do some assertions\n }\n}\n\n\n\nThe problem is that I I get error:\n\n java.lang.RuntimeException: Unable to resolve activity for: Intent {\n act=android.intent.action.MAIN flg=0x10000000 \n cmp=com.example/.test.ActivityMock }\n\n\nOk next I tried to modify test project AndroidManifest.xml\n\n <activity android:name=\".ActivityMock\" />\n\n\nBut I got same error. I think that is because anyway during test run main project is searched for ActivityMock. So I tried to add \n\n <instrumentation\n android:name=\"android.test.InstrumentationTestRunner\"\n android:targetPackage=\"com.example.test\" />\n\n\nI don know if it is a good idea, but main thought is that test project will be able to test (instrument) itself. But now I get:\n\n junit.framework.AssertionFailedError: Exception in constructor: testSomething \n (java.lang.NoClassDefFoundError: com.example.test.ActivityMock\n\n\nSo I think that modified AndroidManifest.xml worked but still ActivityMock class is being searched in main project, though it is in test project.\nI assume that getActivity() method always look for activity class in main project.\n\nDoes anybody tried to test Fragment this way and was able to create Activity mock?\n\nCheers" ]
[ "android", "android-testing" ]
[ "Dynamic loading of stylesheet using YUI3", "I am dynamically loading stylesheets using YUI3 'Get'. which is working flawlessly however, as far as I can tell it doesn't give me any way to set id's for these new stylesheets which is causing the stylesheet to be loaded multiple times as the user navigates around the site.\n\nvar css_obj = Y.Get.css(location.pathname+\"/../css/\"+jta[\"iss\"]+\".css\");\n\n\nDoes anyone have any other way of doing this so that I can test prior to loading the css, if it has already been loaded?\n\nThanks" ]
[ "css", "yui" ]
[ "c# winform Facebooksdk Post vs PostTaskAsync", "I'm quite new with facebooksdk, but I have a winform project in c# to perform simple status posting & photo upload using it.\n\nSo far so good with the SDK, however, what's the difference between FacebookClient.Post & FacebookClient.PostTaskAync?\n\nI used the following code to post photo to my facebook account:\n\npublic static void uploadPhoto(string fPath, string userMsg, string imgType = \"\")\n{\n var fb = new FacebookClient(AccessToken);\n if (imgType.Equals(\"\"))\n imgType = \"image/jpeg\";\n\n using (var file = new FacebookMediaStream\n {\n ContentType = imgType,\n FileName = Path.GetFileName(fPath)\n }.SetValue(File.OpenRead(fPath)))\n {\n dynamic result = fb.Post(\"me/photos\",\n new { message = userMsg, file });\n }\n}\n\n\nBut, when the file size is huge, the above method will \"hang\" my system as the main thread is still working, so I tried the following:\n\ndynamic result = fb.PostTaskAsync(\"me/photos\",\n new { message = userMsg, file });\n\n\nbut it just doesn't work (at least the photo is not being uploaded to my fb account)...\n\nWhat I want actually is to avoid the \"hanging\" feeling on my system, and I've even tried \"Application.DoEvents()\" but with NO luck.\n\nAny suggestion to handle for this issue?\nShall I use another Thread to handle this photo upload?\nOr?\n\nThanks for all the answers & comments." ]
[ "c#", "facebook", "winforms" ]
[ "Ionic 4/Angular loops in router history", "If I navigate from one page to another and back multiple times , I am able to navigate through the whole router history via the hardware- or the browser back button.\n\nI want to achieve that the hardware back button brings me to the same page as the ion-back-button in my toolbar.\n\nExample\n\nPage 1 > Page 2 > Page 3\n\nI navigate from Page 1 to Page 2. Then I navigate from Page 2 to Page 3 and back via ion-back-button multiple times. If I then press the hardware/browser back button, I get to Page 2 and Page 3 again in a loop. Instead I want the hardware/browser back button to navigate to Page 1 if I press it on Page 2." ]
[ "angular", "ionic-framework", "routing", "angular2-routing", "ionic4" ]
[ "TestNG DataProvider reading test data from the testng.xml config file?", "Is it possible for a TestNG DataProvider to read test data from the testng.xml config file? Or is this unrealistic for some reason? I would like to be able to read test data from that file at the suite level and class level.\n\nSo, given a testing.xml file like this (which I am unsure is realistic or not), how would I do this? I have written a DataProvider using XStream (or Jackson) before and so I am well versed in my own custom .xml format, but sticking to the strict format of the testing.xml is where I am worried about this.\n\nThe following testing.xml is obvious invalid but I am just trying to show the kind of thing I would like to do:\n\n<!DOCTYPE suite SYSTEM \"http://testng.org/testng-1.0.dtd\" > \n<suite name=\"TestAll\"> \n <parameter name=\"hubUrl\" value=\"http://localhost:4444/wd/hub\"/>\n <parameter name=\"reportFile\" value=\"CustomReport.html\"/>\n <test name=\"etsy\">\n <parameter name=\"reportFile\" value=\"CustomReport.html\"/>\n <classes>\n <class name=\"qa.examples.suite.TestSearch\">\n <parameter name=\"appUrl\" value=\"http://etsy.com\" type=\"java.lang.String\"/> \n <parameter name=\"browser\" value=\"Firefox\" type=\"java.lang.String\"/> \n <parameter name=\"testEnabled\" value=\"true\" type=\"java.lang.Boolean\"/> \n <methods> \n <include name=\"testEtsySearch\"/>\n <tests>\n <test>\n <parameter name=\"testNum\" value=\"1\" type=\"java.lang.Integer\"/>\n <parameter name=\"searchTerm\" value=\"cell phone\" type=\"java.lang.String\"/>\n <parameter name=\"searchTerm\" value=\"batteries\" type=\"java.lang.String\"/>\n </test>\n <test>\n <parameter name=\"testNum\" value=\"2\" type=\"java.lang.Integer\"/>\n <parameter name=\"searchTerm\" value=\"buttons\" type=\"java.lang.String\"/>\n <parameter name=\"searchTerm\" value=\"metal\" type=\"java.lang.String\"/>\n </test>\n </tests>\n </include> \n </methods> \n </class>\n <class name=\"qa.examples.suite.TestFilters\" />\n </classes>\n </test> \n</suite>\n\n\nSo, is something like this possible? If so, how would you do it?" ]
[ "testing", "testng" ]
[ "Double Click of the browser back button not working", "Is there a way that I can detect and stop the double click of the browser back button? \n\nRight now I have a scenario where, I am using Backbone.js for routing aspects. When the user clicks the browser back button, it routes to the proper url/page. Whereas , if he double clicks, the session expires.\n\nCan anybody throw some light on this. All so it must be noted that the page reload even on double click shows the user session as logged in(correct behaviour)" ]
[ "javascript", "backbone.js", "url-routing" ]
[ "CoronaSDK: display object static X (ignoring X impulses/forces) but changing Y", "I am making a display object stay in one column on the screen in portrait mode with an anchor point such as \n\nball.anchorX = 0.5\n\n\nball is dynamic. Is there a way for it to stay in that X plane and so forces and impulses won't affect the ball.x value but do affect the ball.y value? If the ball hits a corner/ other object it will bounce off at an angle. I want the ball.x value to remain constant as I have obstacles approach the ball from the right and the ball must jump, thus I don't want to have to deal with X movement, only Y movement." ]
[ "lua", "coronasdk", "anchorpoint" ]
[ "Keyboard only appears when user clicks on EditText", "I have the following xml file in my android app. When user opens the app, the keyboard becomes active at the same time. Even though user has not even started in the EditText. \n\nHow could I control keyboard? I want keyboard to appear when a user tap on the EditText.\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:orientation=\"vertical\"\n android:layout_width=\"fill_parent\"\n android:layout_height=\"fill_parent\"\n android:id=\"@+id/mList\"\n android:minWidth=\"25px\"\n android:minHeight=\"25px\">\n <EditText\n android:minWidth=\"25px\"\n android:minHeight=\"25px\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:id=\"@+id/search\" />\n <ListView\n android:layout_width=\"match_parent\"\n android:layout_height=\"0dp\"\n android:layout_weight=\"1\"\n android:id=\"@+id/mListView\" />\n </LinearLayout>" ]
[ "android", "xml", "xamarin", "keyboard" ]
[ "Bootstrap 3 how to remove or move offset below in small devices(tablet, smartphone)?", "this is my main div in my web app view (in Rails 5):\n\n<nav class=\"navbar navbar-inverse navbar-fixed-top\" >\n my navbar\n</nav>\n<div class=\"col-md-6 col-md-offset-3\">\n the main content of my web app\n</div>\n\n\nthis looks good in pc browser, but i want that the col-md-offset-3 disappear in small devices cause it generates white space at both sides and the content gets smaller, so that this div class col-md-6 can occupy the entire width of the small device. Or for different but better solution: Is it possible to create \n\n<div class=\"col-md-3/> <div class=\"col-md-6\"> <div class=\"col-md-3/>\n\n\nand when i execute in small devices the divs col-md-3 move at the bottom (below) the div class=\"col-md-6. How i can do this behaviour?" ]
[ "html", "css", "twitter-bootstrap-3", "responsive-design" ]
[ "Image manipulation and texture mapping using HTML5 Canvas?", "In a 3D engine I'm working on I've succesfully managed to draw a cube in 3D. The only method to fill the sides is using either a solid color or gradient as far as I'm concerned. To make things more exciting, I'd really love to implement texture mapping using a simple bitmap.\n\nThe point is that I can hardly find any articles or code samples on the subject of image manipulation in JavaScript. Moreover, image support in HTML5 canvas seems to be restricted to cropping.\n\nHow could I go about stretching a bitmap so that a rectangular bitmap can fill up a unregular cube face? In 2D, a projected square cube face is, due to perspective, not of a square shape, so I'll have to stretch it to make it fit in any quadrilateral.\n\nHopefully this image clarifies my point. The left face is now filled up with a white/black gradient. How could I fill it with a bitmap, after it has been texture-mapped?\n\n\n\nDoes anyone have any tips on perspective texture mapping (or image manipulation at all) using JavaScript and HTML5 Canvas?\n\nEdit: I got it working, thanks to 6502!\n\nIt is, however, rather CPU intensive so I'd love to hear any optimization ideas.\n\nResult using 6502's technique - Texture image used" ]
[ "javascript", "html", "3d", "texture-mapping", "html5-canvas" ]
[ "Request headers only using Ruby HTTPClient returns 405 http status code (Method not allowed) in Ruby on Rails", "My Ruby on Rails application (ruby 2.6.6; rails 5.2) makes a header only request using HTTPClient, for a Google Drive direct download link. This is to check if the file is really there.\nThe code is:\nresponse = client.head(<google_drive_direct_download_url>, follow_redirect: true)\n\nThis results in 405 status code.\nBut, at the same time, I can make a normal request to the same URL using\nresponse = client.request('GET', <google_drive_direct_download_url>, follow_redirect: true)\n\nobtaining status code 200.\nThere is a post saying there is a chance that the URL endpoint doesn't accept header only requests.\nBut I do can make a header only request using httpie receinving 200:\n$ http <google_drive_direct_download_url> -h --follow\n\nWould be a matter of outdated version, or there's an issue with HTTPClient?" ]
[ "ruby-on-rails", "ruby", "http", "google-drive-api", "http-status-code-405" ]
[ "cakephp bake view Errors", "Possible Duplicate:\n mysql_fetch_array() expects parameter 1 to be resource, boolean given in select \n\n\n\n\nI have previously baked a controller for a model that I have created.\n\nWhen attempting to bake the view using cakephp I get the following errors:\n\nInteractive Bake Shell\n---------------------------------------------------------------\n[D]atabase Configuration\n[M]odel\n[V]iew\n[C]ontroller\n[P]roject\n[Q]uit\nWhat would you like to Bake? (D/M/V/C/P/Q) \n> v\n---------------------------------------------------------------\nBake View\nPath: /Applications/MAMP/htdocs/app/views/\n---------------------------------------------------------------\nPossible Controllers based on your current database:\n1. Dealers\n2. Products\n3. Users\nEnter a number from the list above, type in the name of another controller, or 'q' to exit \n[q] > 2\nWould you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models). (y/n) \n[n] > y\nWould you like to create the views for admin routing? (y/n) \n[y] > n\n\nWarning: mysql_query() expects parameter 2 to be resource, boolean given in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 500\n\nWarning: mysql_errno() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 576\n\nWarning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 102\n\nWarning: array_keys() expects parameter 1 to be array, boolean given in /Applications/MAMP/htdocs/cake/console/libs/tasks/view.php on line 263\n\nWarning: mysql_query() expects parameter 2 to be resource, boolean given in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 500\n\nWarning: mysql_errno() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 576\n\nWarning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/cake/libs/model/datasources/dbo/dbo_mysql.php on line 102\n\nWarning: array_keys() expects parameter 1 to be array, boolean given in /Applications/MAMP/htdocs/cake/console/libs/tasks/view.php on line 382\n\nCreating file /Applications/MAMP/htdocs/app/views/products/index.ctp\nWrote /Applications/MAMP/htdocs/app/views/products/index.ctp\n\nCreating file /Applications/MAMP/htdocs/app/views/products/view.ctp\nWrote /Applications/MAMP/htdocs/app/views/products/view.ctp\n\nCreating file /Applications/MAMP/htdocs/app/views/products/add.ctp\nWrote /Applications/MAMP/htdocs/app/views/products/add.ctp\n\nCreating file /Applications/MAMP/htdocs/app/views/products/edit.ctp\nWrote /Applications/MAMP/htdocs/app/views/products/edit.ctp\n---------------------------------------------------------------\n\nView Scaffolding Complete.\n\n\nAnybody know why? Google hasn't been a whole lot of help.\n\ncakephp 1.2.6 under MAMP on OSX 10.6.2\n\nDatabase config:\n\nclass DATABASE_CONFIG {\n\n var $default = array(\n 'driver' => 'mysql',\n 'persistent' => false,\n 'host' => 'localhost',\n 'login' => 'root',\n 'password' => 'root',\n 'database' => 'cs_db',\n 'prefix' => '',\n 'port' => '/Applications/MAMP/tmp/mysql/mysql.sock',\n );" ]
[ "php", "cakephp", "mamp", "cakephp-bake" ]
[ "how to call PowerShell script with a GithubActions workflow?", "I'm calling .\\build.ps1 and it seems to hang:\n\nhttps://github.com/nblockchain/ZXing.Net.Xamarin/runs/232358091\n\nDo I need something special? In AzureDevOps this was working out of the box." ]
[ "powershell", "github-actions" ]
[ "Only show one row per title in SQL query", "I have the following query: \n\nselect distinct p.title, e.first_name, e.last_name, max(e.salary)\n from employees as e\n inner join employees_projects as ep\n on e.id = ep.employee_id\n inner join projects as p\n on p.id = ep.project_id\n group by 1,2,3\n order by p.title\n\n\nWhich returns multiple rows per title. I only want the max salary for each title. \n\n title | first_name | last_name | max \n--------------------------+------------+-----------+-------\n Build a cool site | Cailin | Ninson | 30000\n Build a cool site | Ian | Peterson | 80000\n Build a cool site | Mike | Peterson | 20000\n Design 3 New Silly Walks | Ava | Muffinson | 10000\n Update TPS Reports | John | Smith | 20000\n\n\nTweaked @zealous code and this works:\n\n select\n title,\n first_name, \n last_name,\n salary\nfrom\n(select \n distinct p.title, \n e.first_name, \n e.last_name,\n e.salary,\n dense_rank() over (partition by p.title order by e.salary desc) as rnk\n from employees as e\n inner join employees_projects as ep\n on e.id = ep.employee_id\n inner join projects as p\n on p.id = ep.project_id\n group by 1,2,3, 4\n ) t\n where rnk = 1\n order by title" ]
[ "sql", "postgresql" ]
[ "How to access Flutter Back button functionality?", "I would like to present an AdWords interstitial before the user returns to the previous page. How can I do this when the return button is pressed?" ]
[ "function", "dart", "flutter" ]
[ "Error when importing files within breakpoint-sass mixin", "I'm trying to import a set of files using breakpoint-sass but am getting an error \n\nfilenames.scss (Line 99: Import directives may not be used within control directives or mixins.)\n\nThe code im using is:\n\n@include breakpoint($breakpoint2) {\n @import \"path/to/sassfilename\";\n}\n\n\nIs this even allowed? Can I import files in breakpoint? I couldn't see anything documentation to say otherwise so I'm assuming it is possible to import files instead of inlining all the css." ]
[ "sass", "breakpoint-sass" ]
[ "Oracle table incremental import to HDFS", "I have Oracle table of 520 GB and on this table insert, Update and delete operations are performed frequently.This table is partitioned on ID column however there is no primary key defined and also there is no timestamp column available.\n\nCan you please let me know what is best way I can perform incremental import to HDFS on this table." ]
[ "hadoop", "hive", "hdfs", "sqoop" ]
[ "Is it possible to change the font of a JavaScript from HTML?", "Is it possible to change the font in a JavaScript from a snippet of html-code? \n\nI want to \"force\" the JS to display a local font, but I can't change the JS (it's not my script, and it's chaotic).\n\nThe JS is generated by a crossword program that only lets you choose between \"times new roman\" and \"Sans serif\" when you export the files to web-pages. Everything is exported in lower-case, which I was able to fix by using \"text-transform: uppercase\" to make all the letters upper-case. Why is it not possible to do the same with a font? (And yes; it works everywhere else on the page). \n\nHere's the full code:\n\n<HTML>\n<HEAD>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n<meta NAME=\"Generator\" CONTENT=\"Crossword Compiler (www.crossword-compiler.com)\">\n\n//this is my stylesheet to call @font-face.\n<link rel=\"stylesheet\" href=\"stylesheet.css\" type=\"text/css\" charset=\"utf-8\" /> \n\n//this is from the original code. I've only added 'fatalityregular':\n<STYLE TYPE=\"text/css\"\n{ \"font-family: fatalityregular, Arial, Times, sans-serif\";\n}></STYLE>\n\n//this whole section looks like this when you export the puzzle to web:\n<!--\nBODY, .Clues, .GridClues { font-size: -3pt; font-family: 'fatalityregular', Arial, Times, sans-serif;}\n-->\n<!--\n.PuzTitle {\nfont-size: 15pt; color: #800000; font-weight: bold;\n }\n.CopyTag {\nfont-size: 10pt; color: #000000\n }\n-->\n\n</HEAD>\n\n<BODY TEXT=\"#000000\" BGCOLOR=\"#ffffff\">\n//this is what I use to fix Times/Arial. With MYFONT I won't need this (it's all uppercase):\n<span style=\"text-transform: uppercase\"> \n\n<script src=\"CrosswordCompilerApp/jquery.js\"></script>\n<script src=\"CrosswordCompilerApp/raphael.js\"></script>\n<script src=\"CrosswordCompilerApp/crosswordCompiler.js\"></script>\n<script src=\"MyCrossword.js\"></script> //This is where I want MYFONT to be used.\n<script>\n$(function(){\n$(\"#CrosswordCompilerPuz\").CrosswordCompiler(CrosswordPuzzleData,null, \n{SUBMITMETHOD:\"POST\",PROGRESS : \"\" , ROOTIMAGES: \"CrosswordCompilerApp/CrosswordImages/\" } );});\n</script>\n<div id=\"CrosswordCompilerPuz\"></div>\n\n</span>\n\n</BODY>\n</HTML>" ]
[ "javascript", "fonts" ]
[ "Imagemaps and Statelessness - is it possible?", "I created a clickable tag cloud generator. The tool generates a nice image which is the actual tag cloud, and also to make it clickable and hover-able (interactive), the tool (essentially a method in a class) also returns some HTML.\n\nSince the image and HTML are both generated in the same action method, in my MVC project, I am wondering whether to return a ViewResult (with HTML) or an FileResult (with the Image). I do not want to use the session, and i have <sessionState mode=\"OFF\"> in my App.\n\nRight now, I have a partial solution, where I save the image to the filesystem and send back the HTML ViewResult with the <img> tag in it pointing to the saved image. This obviously will not work with concurrent users (each user may overwrite the file, and interfere with each other)\n\nEssentially what is the best way to send the image and HTML to the browser, without using server-side session? And without using an elaborate filesystem based store for the images?\nI'm aware of the <img src=\"data: .. \" /> and since it does not work IE7 and less, and since the image is quite big, its not an option.\n\nThanks in advance!" ]
[ "asp.net", "asp.net-mvc-3", "rest" ]
[ "Missing GPSTimeStamp , GPSDateStamp when select image from gallery iOS 13", "When select image from gallery iPhone version 13.1.2 , i see meta data GPS location missing GPSTimeStamp , GPSDateStamp .\nHow can I interpret this? Thank you !\n\n ALAssetRepresentation* representation = [info \n defaultRepresentation];\n NSDictionary *metadata = representation.metadata;\n LogInfo(@\"****metadata = %@ *****\",metadata)\n =>This is log result :\n \"{GPS}\" = {\n Altitude = \"6.885073656845754\";\n AltitudeRef = 0;\n DestBearing = \"20.69101142995269\";\n DestBearingRef = T;\n HPositioningError = 10;\n ImgDirection = \"20.69101142995269\";\n ImgDirectionRef = T;\n Latitude = \"10.32532833333333\";\n LatitudeRef = N;\n Longitude = \"106.4042966666667\";\n LongitudeRef = E;\n Speed = 0;\n SpeedRef = K;\n};" ]
[ "ios", "objective-c", "image", "metadata" ]
[ "Find elements surrounding an element in an array", "I have a multidimensional array, I want to get the elements surrounding a particular element in that array. \n\nFor example if I have the following:\n\n[[1,2,3,4,5,6]\n [8,9,7,5,2,6]\n [1,6,8,7,5,8]\n [2,7,9,5,4,3]\n [9,6,7,5,2,1]\n [4,7,5,2,1,3]]\n\n\nHow do I find all the 8 elements around any of the above elements? And how do I take care of elements at the edges? \n\nOne way I figured out is, to write a 9 line code for this , which is obvious, but is there a better solution?" ]
[ "java", "arrays", "multidimensional-array" ]
[ "InnoDB: UNIQUE IF NOT NULL", "Does InnoDB support a \"UNIQUE IF NOT NULL\" index? I.e. a UNIQUE index which allows multiple NULL values?\n\n(I guess no since I wasn't able to find anything about that — found a lot of kinda-related things but not a definitive answer)" ]
[ "indexing", "innodb", "unique" ]
[ "Acess properties with ID Widget", "I want to change a text property in the widget of a class I created, but this widgets were created from a loop\nI was trying to access the id, but I could not.\nSomeboy can save me??\n\nHere is the code:\n\n:\n\n boxin = BoxLayout(orientation='vertical')\n cont = BoxLayout(orientation='horizontal')\n for x in compras:\n boxin.add_widget(Line(text=x, id=compras.index(x)))\n boxin.add_widget(tot)\n cont.add_widget(finalizar)\n cont.add_widget(cancelar)\n\n boxin.add_widget(cont)\n pop = Popup(title='Carrinho', content=boxin, size_hint=(None, None), size=(350, 500))\n\n pop.open()\n\nclass Line(BoxLayout):\n\n def __init__(self, text='', **kwargs):\n super().__init__(**kwargs)\n self.ids.label1.text = text\n self.ids.label2.text = str(qtd[compras.index(text)])\n self.ids.label3.text = \"R$\"+str(qtd[compras.index(text)]*value[compras.index(text)])\n\n def remove(self):\n self.ids.lin.ids.label2.ids['text'].text= \"aaa\"\n\n\nThe function remove would be the button that would change the label2 text of the given instance of the Line class\n\nHow i can get it?\n\n <Kv>\n\n <Line>:\n orientation: 'horizontal'\n id: lin\n Button:\n id: menos\n size_hint: None , None\n pos_hint: {'center_x':0.47, 'center_y': 0.47}\n width: 20\n height: 20\n on_press: root.remove()\n Label:\n id: label1 #descrição do item\n font_size: 15\n Label:\n id: label2 #quantidade\n font_size: 15\n Label:\n id: label3 #valor\n font_size: 15\n Button:\n id: mais\n size_hint: None, None\n pos_hint: {'center_x':0.47, 'center_y': 0.47}\n width: 20\n height: 20" ]
[ "python", "kivy", "kivy-language" ]
[ "Coordinating multiple VMs in a VPC", "I'm using a CloudFormation stack that deploys 3 EC2 VMs. Each needs to be configured to be able to discover the other 2, either via IP or hostname, doesn't matter.\n\nAmazon's private internal DNS seems very unhelpful, because it's based on the IP address, which can't be known at provisioning time. As a result, I can't configure the nodes with just what I know at CloudFormation stack time.\n\nAs far as I can tell, I have a couple of options. All of them seem to me more complex than necessary - are there other options?\n\n\nUse Route53, set up a private DNS hosted zone, make an entry for each of the VMs which is attached to their network interface, and then by naming the entries, I should know ahead of time the private DNS I assign to them.\nStand up yet another service to have the 3 VMs \"phone home\" once initialized, which could then report back to them who is ready.\nCome up with some other VM-based shell magic, and do something goofy like using nmap to scan the local subnet for machines alive on a certain port.\n\n\nOn other clouds I've used (like GCP) when you provision a VM it gets an internal DNS name based on its resource name in the deploy template, which makes this kind of problem extremely trivial. Boy I wish I had that.\n\nWhat's the best approach here? (1) seems straightforward, but requires people using my stack to have extra permissions they don't really need. (2) is extra resource usage that's kinda wasted. (3) Seems...well goofy." ]
[ "amazon-web-services", "amazon-ec2", "amazon-cloudformation" ]
[ "Wav File in Minim plays too fast", "I'm trying to load a wav file into a FilePlayer using Processing and Minim Library (later I want to patch a Delay on it). However, the wav file I was given plays too fast, at least at double the speed it is supposed to and it is very high pitched. The file sounds like it is supposed to if I play it in VLC Media Player or in WMP. It is 5 seconds long at a Bit Rate of 20kbps, but the code prints out it is 2299ms long.\n\nCode:\n\nimport ddf.minim.*;\nimport ddf.minim.ugens.*;\nimport ddf.minim.spi.*; \n\nMinim minim;\nAudioOutput out;\nFilePlayer filePlayer; \n\nDelay myDelay;\n\nvoid setup() {\n size(100, 100);\n\n minim = new Minim(this);\n\n AudioRecordingStream myFile = minim.loadFileStream( \"audio1.wav\", 1024, true);\n\n filePlayer = new FilePlayer( myFile );\n\n filePlayer.play();\n filePlayer.loop();\n out = minim.getLineOut();\n\n\n // patch the file player to the output\n filePlayer.patch(out);\n\n println(filePlayer.length()); //This prints out 2299\n}\n\nvoid draw()\n{\n background( 0 );\n\n\n}" ]
[ "audio", "processing", "wav", "multimedia", "minim" ]
[ "Assigning results of getJson to array", "What is the best way to assign the results of a getJson call to an array. For instance, lets say one could hard code this:\n\n var users = [\n { id: 'Jack', name: 'Jack Smith' },\n { id: 'Jill', name: 'Jill Jones' },\n { id: 'Jane', name: 'Jane Chung' }\n ];\n\n\nbut I want to call the following service and and assign it to the the users array.\n\n function user(id, name) {\n var self = this;\n\n self.Id = id;\n self.Name = name;\n\n }\n\n\n $.getJSON(\"/api/users/\", function (data) {\n $.each(data, function (key, val) {\n self.users.push(new user(val.id, val.name));\n });\n });" ]
[ "knockout.js" ]
[ "Help with looping for an array with key and value", "I am trying to make this function that extracts text from html for multiple steps but I cant figure out how to make a loop form it.\n\nThis is the task. I have this array\n\n$arr = array(\"<div>\" => \"</div>\", \"<p>\" => \"</p>\", \"<h3>\" => \"</h3>\");\n\n\nThe existing working function cut($a, $b, $c) that gets the content in between in this case $a = \"<div>\", $b=\"</div>\" and $c = the html.\n\nWhat i am trying to do is to make this: \n\n\nStep 1 - cut from div to div\nStep 2 - foreach results from step1,\ncut from p to p\nStep 3 - foreach results from step2,\ncut from h3 to h3\nStep n where n is array length.\n\n\nAlthough I know that I can use foreach to get the results and apply step two, I cant generalize this.\n\nEDIT\n\nI have an existing function called cut that has been described above. I want to create a new function called cutlayer($arr, $html) where $arr is arr from above. I need the cutlayer function to use the cut function and do the following steps mentioned above but I cant figure out how to do that.\n\nThanks" ]
[ "php", "arrays" ]
[ "Why/when do some elements are added to my dictionary?", "I have this code snippet, which finds the most frequent strings given a length k.\n\ndef FrequentWords(Text, k):\n patternDict = {}\n\n for i in range((len(Text)-k+1)):\n if Text[i:i+k] in patternDict:\n patternDict[Text[i:i+k]] += 1\n else:\n patternDict[Text[i:i+k]] = 1\n\n\nThe code works, but, I don't understand why Keys and Values start to be added to the initially empty dictionary 'patternDict'. I understand that patternDict[Text[i:i+k]] = x looks for the Key Text[i:i+k] and assign x to the respective Value but to me that line doesn't indicate that any element has to be added to the dictionary as indeed does.\n\nTo clarify, I understand what the code does, it is just the \"adding action\" of the lines \npatternDict[Text[i:i+k]] = x what I don't understand, because to me what any of those lines are saying is \"look for this Key and on its respective value.\"" ]
[ "python", "dictionary" ]
[ "wordpress \"leave a comment\"", "I'm a bit lost...\nI am building a theme from scratch in WordPress, and I'm using a plugin which includes \"leave a comment\", but when I click in the link, it does nothing (well, it just goes to the full post instead of the excerpt), but there is not any space where you can actually leave a comment. I suppose, because I am building the theme from scratch, I should include a function for it in functions.php but.... I don't know how to start and less make the relation with the \"leave a comment\" from the plugin.\n\nSo, that is the part where the plugin includes the sentence:\n\ncase 'comment':\n if ( !post_password_required() && ( comments_open() || get_comments_number() ) ) :\n // Get comment wrapper class\n $comment_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_class', 'comments-link', 'comment' );\n $prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', '', 'comment' );\n\n ob_start();\n comments_popup_link( __( 'Leave a comment', PT_CV_DOMAIN ), __( '1 Comment', PT_CV_DOMAIN ), __( '% Comments', PT_CV_DOMAIN ) );\n $comment_content = ob_get_clean();\n $html[ 'comment' ] = sprintf( '<span class=\"%s\">%s %s</span>', esc_attr( $comment_class ), balanceTags( $prefix_text ), $comment_content );\n endif;\n break;\n\n\nThen.... should I create a function in functions.php called comments_popup_link?????\n\nAny help or any clarification for my head will be very helpful. \n\nThanks a lot!!" ]
[ "wordpress", "function", "comments" ]
[ "Check variable is not less than zero", "I need to Check variable is not less than zero\n\nif ( $currentUserLimits >= 0 ) {\n //do something\n} elseif($currentUserLimits < $totalPurchaseUnitCount && $currentUserLimits not less then 0) {\n //do something else.\n} else {\n //do something else.\n}\n\n\n\n Clear my question\n\n\nThis is all about offers apply on products and each customer have a purchases limit I have 2 variables and 3 cases.\n\n\nvar1 $currentUserLimits which will return the current customer limits.\nvar2 $totalPurchaseUnitCount which will return the current purchases.\n\n\nMy 3 cases.\n\n\nCase 1: if the $currentUserLimits still > 0 means the customer still have units in offer. Ex. $currentUserLimits = 15 and the $totalPurchaseUnitCount = 10 still the customer has 5 in his $currentUserLimits.\nCase 2: if the customer has half of his $totalPurchaseUnitCount in offer and the order half outside the offer. Ex. $currentUserLimits = 5 and the $totalPurchaseUnitCount = 10.\nCase 3: if the customer finishes his limits completely so the $currentUserLimits is 0 or less then 0.\n\n\nSorry making y'all read all this stuff but really the 3 cases confuses me.\n\nhow to write not less than 0" ]
[ "php" ]
[ "HTML Multidimensional input name for complex inputs", "Selected items must have their discounts aligned with them.\nI want to ignore the item if it is not selected. \n\nThis is my setup for my table of inputs.\n\n\nitem | amount | buy (yes, no) | discount( No Discount, 50%, 100%, 100.00 )\n\n\n\napple | 100.00 | yes | 50%\n\n\n\nbanana | 500.00 | no | 0%\n\n\n\npie | 250.00 | yes | 50%\n\n\n<tr>\n <input name='item[]' type='checkbox' value='1'>\n <select name='discount[]' >\n <option value=\"1\"> No discount </option>\n <option value=\"2\"> 50% </option>\n </select>\n</tr>\n\n\nIf I use item[] for the items and discount[] for the discount, my server will get: \n\nitem[ \"1\", \"3\"]\ndiscount[ \"2\", \"1\", \"2\" ]\n\n\nHow could I connect the items to thier discount?" ]
[ "php", "html", "forms", "multidimensional-array", "input" ]
[ "spring integration to register dynamic ServerWebSocketContainer paths so different integration flows can be created with different paths", "@Component\npublic class WebSocketRegistration {\n\n @Autowired\n GenericWebApplicationContext context;\n @Autowired\n private IntegrationFlowContext flowContext;\n\n public String registerServerEndpoint(String beanName, String endPoint) {\n context.registerBean(beanName, ServerWebSocketContainer.class,\n () -> new ServerWebSocketContainer(endPoint).withSockJs(),\n beanDefinition -> beanDefinition.setAutowireCandidate(true));\n return beanName;\n }\n\n public StandardIntegrationFlow webSocketFlow(String beanName) {\n ServerWebSocketContainer serverWebSocketContainer = (ServerWebSocketContainer) context\n .getBean(beanName);\n WebSocketOutboundMessageHandler webSocketOutboundMessageHandler = new WebSocketOutboundMessageHandler(\n serverWebSocketContainer);\n StandardIntegrationFlow flow = IntegrationFlows.from("stringChannel")\n .split(new AbstractMessageSplitter() {\n @Override\n protected Object splitMessage(Message<?> message) {\n\n return serverWebSocketContainer\n .getSessions()\n .keySet()\n .stream()\n .map(s -> {\n System.out.println(message.getPayload().toString() + " and key " + s);\n return MessageBuilder.fromMessage(message)\n .setHeader(SimpMessageHeaderAccessor.SESSION_ID_HEADER, s)\n .build();\n })\n .collect(Collectors.toList());\n }\n })\n .handle(webSocketOutboundMessageHandler).get();\n\n String id = flowContext.registration(flow).register().getId();\n System.out.println(id);\n return flow;\n }\n}\n\nThis is sample code to register integration flow so that websocket can publish data to specified endpoint at runtime. i am not sure if spring websocket allows it but it does not throw any errors while i register a flow at runtime with different websocket urls." ]
[ "java", "spring-integration", "spring-websocket" ]
[ "Need help for bit data type", "i want to write a generic sql where i want show yes or not if field data type is bit. here i need to check the data type if data type is bit then it should show yes or no based on value 0 or 1. \n\nselect stock_code,makeid,modelid,enginesize,automatic,semiautomatic,manual from VehicleInfoForParts\n\n\nso in my above sql there is bit type fields are automatic,semiautomatic,manual. so here i need to show yes/no but i dont want to hard code anything.\nso please guide me what would be the best approach for generic sql statement. \n\ncan i join my table with system table called information_schema.columns to fetch filed name , value and data type.\nso result would be like\n\nColumn_Name Value datatype\n\n\n------------- ------- -------------- \n\nstock_code A112 varchar\n\nautomatic 1 bit\n\nsemiautomatic 0 bit\n\nmanual 1 bit\n\nthis type of output can we have just joining my sql with information_schema.columns. if possible then please provide me the right sql which will give me the above sort of output.\nthanks\n\nplease guide. thanks" ]
[ "sql", "sql-server" ]
[ "How to increase the maximum connections number of a Serversocket?", "I want to test the limit connections of the ServerSocket.\n\nThis is my Server:\n\nimport java.net.ServerSocket;\nimport java.net.Socket;\nimport java.util.ArrayList;\n\npublic class Server{\n public static void main(String[] args) throws Exception{\n ServerSocket server = new ServerSocket(8088);\n ArrayList<Socket> connsList = new ArrayList<Socket>();\n while(true){\n connsList.add(server.accept());\n System.out.println(connsList.size());\n }\n }\n}\n\n\nthis is my Client:\n\nimport java.net.Socket;\nimport java.util.*;\n\npublic class Client{\n public static void main(String[] args) throws Exception{\n for(int i = 3000; i < 60000; i++){\n try{\n Socket con = new Socket(\"localhost\", 8088);\n }catch(Exception e){\n }\n }\n }\n}\n\n\nAfter run this code, when the connections increase, Server was shutdown when ArrayList's size is about 4000.\n\n...\n4031\n4032\n4033\n4034\n4035\n4036\n4037\n4038\nException in thread \"main\" java.net.SocketException: Too many open files in system (Accept failed)\n at java.base/java.net.PlainSocketImpl.socketAccept(Native Method)\n at java.base/java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:459)\n at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:551)\n at java.base/java.net.ServerSocket.accept(ServerSocket.java:519)\n at Server.main(Server.java:11)\n\n\nIt seems one server can only hold about 4k connections.\n\nIs there some to increase this number?\n\nEnv\n\n$ java --version\njava 10 2018-03-20\nJava(TM) SE Runtime Environment 18.3 (build 10+46)\nJava HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)\n\n\non macOS." ]
[ "java", "serversocket" ]
[ "How to prevent ionic 3 app from freezing?", "My ionic 3 app's scroll on some pages gets stuck on latest ios version only and works again after minimize, I can not upgrade the app to ionic 4 as the app is huge and we don't have time. Is there a way to tackle this problem or a workaround to fix this in ionic 3? Any help would be appreciated, Thank you\n\nHere is my project's info\n\nIonic:\n\nionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic) \nIonic Framework : ionic-angular 3.9.2 \n@ionic/app-scripts : 3.1.8\n\n\nCordova:\n\ncordova (Cordova CLI) : 9.0.0 ([email protected])\nCordova Platforms: android 6.4.0, ios 4.5.4 \nCordova Plugins: cordova-plugin-ionic-keyboard 2.0.5, \ncordova-plugin: ionic-webview : 1.2.1, (and 12 other plugins)\n\n\nSystem:\n\nAndroid SDK Tools : 26.1.1 (/Users/macbook/Library/Android/sdk)\nNodeJS : v8.15.1 (/usr/local/bin/node)\nnpm : 6.4.1\nOS : macOS Mojave\nXcode : Xcode 10.2.1 Build version 10E1001" ]
[ "ios", "cordova", "ionic-framework", "ionic3", "ionic4" ]
[ "Codeigniter controller didn't load view as well error message", "I was just making a simple room reservation system for my hotel using Codeigniter as framework. In my localhost the controller and its methods are working as expected, but when I upload the files to a testing server of mine, one of my controller became unaccessible. Neither it shows loaded view pages nor error. I've tried with url like www.mydomain.com/testing/index.php/room_booking and www.mydomain.com/testing/index.php/room_booking/post_action too but nothing is shown and then I've tried using die ('my code is not executed'), but it didn't print die either. So it made me go crazy and I elapsed my whole day.\n\nMy Controller is as:\n\nheader(\"Access-Control-Allow-Origin: *\");\nif (!defined('BASEPATH'))\n exit('No direct script access allowed');\n\nclass room_booking extends CI_Controller {\n\n function __construct() {\n parent::__construct();\n $this->load->library('session');\n $this->load->model('dbmodel');\n $this->load->model('api_model');\n $this->load->model('dashboard_model');\n $this->load->model('booking_room');\n $this->load->helper('url');\n\n $this->load->helper(array('form', 'url'));\n $this->load->library(\"pagination\");\n }\n\n public function index() {\n $this->load->view('template/header');\n $this->load->view('template/imageDiv');\n $this->load->view('template/reservation_template');\n //$this->load->view('login/test');\n $this->load->view('template/footer');\n }\n\n function post_action() {\n\n $this->load->helper('availableroom');\n die('here i used die function for test'); \n if ($_POST) {\n\n $data['abc'] = array(\n 'checkin' => $_POST['checkin'],\n 'checkout' => $_POST['checkout'],\n 'adult' => $_POST['adult'],\n 'child' => $_POST['child'],\n 'hotelId' => $_POST['hotelId'],\n 'title' => $_POST['title']\n );\n\n $this->session->set_userdata($data['abc']);\n $hotel = $_POST['hotelId']; // form top it got hotel name \n $hotels = $this->dashboard_model->get_hotel_id($hotel);\n if (!empty($hotels)) {\n foreach ($hotels as $hotelData) {\n $hotelId = $hotelData->id;\n }\n } else {\n $hotelId = $_POST['hotelId'];\n }\n $data['query'] = $this->dashboard_model->booking_room($hotelId);\n $data['json'] = json_encode($data['query']);\n $this->load->view('ReservationInformation/room_booking', $data);\n } else {\n $this->load->view('ReservationInformation/room_booking_empty_view'); \n }\n }\n}\n\n\nAm I doing any mistake here? In post_action method I passed a value from ajax call. How can I have it solved in server?" ]
[ "php", "html", "css", "codeigniter" ]
[ "Sort list with multiple criteria in python", "Currently I'm trying to sort a list of files which were made of version numbers. For example:\n\n0.0.0.0.py\n1.0.0.0.py\n1.1.0.0.py\n\n\nThey are all stored in a list. My idea was to use the sort method of the list in combination with a lambda expression. The lambda-expression should first remove the .py extensions and than split the string by the dots. Than casting every number to an integer and sort by them.\n\nI know how I would do this in c#, but I have no idea how to do this with python. One problem is, how can I sort over multiple criteria? And how to embed the lambda-expression doing this?\n\nCan anyone help me?\n\nThank you very much!" ]
[ "python", "list", "sorting", "lambda" ]
[ "Comparing values of two different columns with a unique condition", "Image\nAssume column position is not fixed firstly both column must be automatically searched and then perform the below task.\nCases:-\n\nIn column 'C' a two digit value is present which leads to a seven digit value in column 'F'.\nIn column 'C' a three digit value is present which leads to a eight digit value in column 'F'.\nI want to validate whether 'F2' and 'F3' start with 21 and if no Msgbox 'Error in this row'. and whether 'F6' and 'F7' start with and 228 and if no Msgbox 'Error in this row'.\n\nThanks.\n++ Code\n\n Sub CompareColumns()\n Dim lr As Long, n As Long\n Dim rng As Range, cell As Range\n Dim strA As String, strB As String, str As String\n Dim NotMatched As Boolean\n\n lr = Cells(Rows.Count, 1).End(xlUp).Row\n\n 'Assuming your data starts from Row2\n Set rng = Range(\"B2:B\" & lr)\n str = \"The following cells don't match.\" & vbNewLine & vbNewLine\n For Each cell In rng\n If cell <> \"\" Then\n n = Len(cell.Offset(0, -1))\n If n > 0 Then\n strA = cell.Offset(0, -1).Text\n strB = Left(cell, n)\n If strA <> strB Then\n NotMatched = True\n str = str & cell.Offset(0, -1).Address(0, 0) & \" : \" & \n cell.Offset(0, -1).Value & vbTab & cell.Address(0, 0) & \" : \" & cell.Value & \n vbNewLine\n End If\n Else\n str = str & cell.Offset(0, -1).Address(0, 0) & \" : \" & cell.Offset(0, -1).Value & vbTab & cell.Address(0, 0) & \" : \" & cell.Value & vbNewLine\n End If\n End If\n n = 0\n strA = \"\"\n strB = \"\"\n Next cell\n If NotMatched\n MsgBox str, vbInformation\nElse\n MsgBox \"Both columns match.\", vbInformation\nEnd If\nEnd Sub" ]
[ "vba", "excel" ]
[ "'Ascii' codec can't encode character u'\\u201d' in position 186: ordinal not in range(128)", "for key, value in supportProjectDict.iteritems():\n line = re.sub(r'%s,' % key, r'%s,' % value, line.decode('utf-8'), flags=re.UNICODE)\n\n\nTrying to do a regex substitution by replacing any found keys of a dictionary with their corresponding values, but get this error once it runs into a non-ASCII character:\n\nUnicodeEncodeError: 'ascii' codec can't encode character u'\\u201d' in position 186: ordinal not in range(128)\n\n\nShouldn't the usage of the re.UNICODE flag be preventing this?" ]
[ "python", "regex", "python-2.7", "unicode" ]
[ "How to delete the dynamically created image in the following code?", "This is where I dynamically create an image:\n\nfunction handleFileSelect(evt) {\n var files = evt.target.files; // FileList object\n // Loop through the FileList and render image files as thumbnails.\n for (var i = 0, f; f = files[i]; i++) {\n // Only process image files.\n if (!f.type.match('image.*')) {\n continue;\n }\n fileNames.push(f.name);\n var reader = new FileReader();\n // Closure to capture the file information.\n reader.onload = (function(theFile) {\n return function(e) {\n // Render thumbnail.\n var span = document.createElement('span');\n span.innerHTML = ['<img class=\"thumb\" id=\"',escape(theFile.name),'\" src=\"',e.target.result,\n '\" title=\"', escape(theFile.name), '\"/><input class=\"delete\" type=\"button\" value=\"delete\" name=\"',escape(theFile.name),'\"/>'].join('');\n document.getElementById('list').insertBefore(span, null);\n };\n })(f);\n // Read in the image file as a data URL.\n reader.readAsDataURL(f);\n }\n\n\nAnd this is where I want to delete the image when I press the button:\n\n$('#list').on(\"click\",\".delete\",function(e){\n $(e.target).remove();\n\n });" ]
[ "jquery" ]
[ "Get property value to use within custom attribute", "I have been looking for an example of how to get a property's value from within a custom attribute's code.\n\nExample for illustration purposes only: We have a simple book class with only a name property. The name property has a custom attribute:\n\npublic class Book\n{\n [CustomAttribute1]\n property Name { get; set; }\n}\n\n\nWithin the custom attribute's code, I would like to get the value of the property on which the attribute has been decorated:\n\npublic class CustomAttribute1: Attribute\n{\n public CustomAttribute1()\n {\n //I would like to be able to get the book's name value here to print to the console:\n // Thoughts?\n Console.WriteLine(this.Value)\n }\n}\n\n\nOf course, \"this.Value\" does not work. Any thoughts?" ]
[ "c#", "reflection", "attributes", "custom-attributes" ]
[ "Getting TypeError: not all arguments converted during string formatting", "I'm new to Python and I am solving an exercise and I got this error:\nTypeError: not all arguments converted during string formatting\nI tried reading some explanations but didn't get where I am wrong in my code\n\ndef reverse(num):\n r=0\n while(num!=0):\n r=(r*10)+(num%10)\n num //= 10\n return r\n\nnum=input(\"Enter a number: \")\nn=reverse(num)\nnumOdd=[]\nnumEven=[]\nc=1\nwhile(n!=0):\n if (c%2==0):\n numEven.append(n%10)\n else:\n numOdd.append(n%10)\n n//= 10\n c += 1\nsortedEven=True\nsortedOdd=True\nfor i in range(len(numOdd)-1):\n if(numOdd[i]>numOdd[i+1]):\n sortedOdd=False\nfor i in range(len(numEven)-1):\n if(numEven[i]<numEven[i+1]):\n sortedEven=False\n\nif(sortedOdd==True and sortedEven==True):\n print (\"True\")\nelse:\n print (\"False\")" ]
[ "python-3.x" ]
[ "Identity Column Inserting Null With MVC Code First", "I am using MVC to generate my database. I have the following code structure in my UserProfile class:\n\n[KeyAttribute()] \n[DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]\npublic int UserId { get; set; }\npublic string UserName { get; set; }\npublic string FirstName { get; set; }\npublic string LastName { get; set; }\npublic string EmailAddress { get; set; }\n\n\nThis generates the database fine, but when I try to insert a record it says UserId cannot be null. I cannot figure out why it isn't auto generating an Id integer." ]
[ "sql", "asp.net-mvc", "ef-code-first" ]
[ "Why cast the NSNumber contents of an NSMutableArray when retrieving the intValue?", "In some sample code, an NSNumber is added to a mutable array:\n\n// In the .h, as an instance variable:\nNSMutableArray *sequence;\n\n// In the .m file:\nsequence = [[NSMutableArray alloc] initWithCapacity:100];\n\n[sequence addObject:[NSNumber numberWithInt:123]];\n\n\nThen later on, when the integer is needed, it uses:\n\n[(NSNumber *)[sequence objectAtIndex:aCounter] intValue]\n\n\nI just wonder why the cast (NSNumber *) is needed? Because the program runs fine without it, too. Is it just a good practice? If so, what can it prevent from happening? If there is a bug so that one element is not an NSNumber *, then casting it can create strange behavior too." ]
[ "objective-c", "types", "casting", "nsarray" ]
[ "How to write MongoDB queries for User-Visit-WebPage behavior?", "I want to write queries for users visiting Web Page in MongoDB. The User and Website object looks like this:\n\nUser\n{\n Integer _id,\n String Name,\n ....\n}\n\nWebPage:\n{\n Integer _id,\n String URL,\n Integer CountOfVisitor,\n Visitors:\n [\n {\n Integer Visitor_id, //this field is consistent with the User._id field\n Integer VisitTime\n }\n ....\n ]\n}\n\n\nA sample of Web Page collection is\n\n {\n {1, \"http://stackoverflow.com/\",10000, [{1,1},{2,13},{5,32}....}],\n {2, \"http://codeproject.com/\",5000, [{2,6},{4,23},{12,32}....}],\n .....\n }\n\n\nThe scenario is that when a new user visits a web page, a new object will be inserted into the Vistors array of the correspond WebPage object and the CountOfVisitor field will be incremented by 1. When a old user visit a web page, the VisitTime field of the correspond object in the Visitors array will be incremented by 1 (the initial value is 1) and the CountOfVisitor field doesn't change.\nSo how to write one or more queries to implement such behavior?" ]
[ "mongodb", "database", "nosql" ]
[ "Javascript 'new' keyword within function", "var steve = function() {\n this.test = new function() {\n console.log('new thing');\n }\n\n this.test_not_repeating = function() {\n console.log('not repeating');\n }\n}; \n\nsteve.prototype.test = function() {\n console.log('test');\n};\n\nfor (var i = 0; i < 100; i++) {\n var y = new steve();\n}\n\n\nWhy does the new keyword force the function to be evaluated X times, where not using the new keyword doesn't? My rudimentary understanding of javascript is, if you do not put the function on the prototype it will be evaluated X times regardless of the new keyword or not." ]
[ "javascript" ]
[ "IdentityServer4 Offline Access and Refreshing Access Token", "I have a fairly standard requirement for an oAuth2 service which allows the client to request the offline_access token and exchange the refresh token for an access token when it has expired.\nAlthough this doesn't seem to be working at all. My client is integrating into Zapier. The zapier client is able to authenticate fine. However, after an hour the token seems to have expired BUT the client hasn't been able to retrieve a new token for whatever reason.\nThe following shows my persisted grants table showing that (I think) the refresh token has been accessed or created although the expiry time seems to be before the creation time??:\n\nand my client looks like this - details extracted:\n\nOnly another thing in the Identityserver4 logs is the following:\n\nI'm not sure why this could be the case?\nUPDATE\nZapier definitely reach out and do the refresh:" ]
[ "identityserver4" ]
[ "How to ensure resources are released using Google Dagger 2", "Google Dagger 2 is all about object scopes e.g. when you need objects just during an http request you annotate your provider methods with @RequestScope.\n\nBut some provided resources need to be released for example a CloseableHttpClient needs to be closed or an ExecutorService needs to be shutdown.\n\nHow can I specify which actions have to be taken in order to release an object when it goes out of scope using Google Dagger 2?" ]
[ "java", "dependency-injection", "scope", "dagger", "dagger-2" ]
[ "Cakephp join not working on linux", "I have one model Portfolio in which I have define join like\n\npublic $belongsTo = array(\n 'Category' => array(\n 'className' => 'Category',\n 'foreignKey' => 'category_id',\n 'conditions' => '',\n 'fields' => '',\n 'order' => ''\n )\n );\n\n\nnow when I am using code in controller like:\n\n$this->Portfolio->recursive = 0;\n $this->paginate = array(\n 'fields' => array('Portfolio.id', 'Portfolio.application_name','Portfolio.category_id','Portfolio.description','Portfolio.screenshots','Portfolio.icon','Portfolio.bg_color_code','Portfolio.created','Category.title','Category.id'),\n 'limit' => 10,\n 'order' => array(\n 'Portfolio.id' => 'asc'\n )\n );\n\n\nso its working fine on my window 7 but its giving me error on linux server like:\n\nDatabase Error\n\nError: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Category.title' in 'field list'\n\nSQL Query: SELECT `Portfolio`.`id`, `Portfolio`.`application_name`, `Portfolio`.`category_id`, `Portfolio`.`description`, `Portfolio`.`screenshots`, `Portfolio`.`icon`, `Portfolio`.`bg_color_code`, `Portfolio`.`created`, `Category`.`title`, `Category`.`id` FROM `portfolios` AS `Portfolio` WHERE 1 = 1 ORDER BY `Portfolio`.`id` asc LIMIT 10\n\nNotice: If you want to customize this error message, create app/View/Errors/pdo_error.ctp\n\n\nand my category model contains\n\nvar $hasMany = array(\n 'Portfolio' => array(\n 'className' => 'Portfolio',\n 'foreignKey' => 'category_id',\n )\n\n );\n\n\nmy table\n\nCREATE TABLE IF NOT EXISTS `categories` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `title` varchar(255) NOT NULL,\n `parent_id` int(11) NOT NULL DEFAULT '0',\n `status` enum('1','2') NOT NULL COMMENT '''1''=active,''2''=inactive',\n PRIMARY KEY (`id`)\n) \n\n\nI have tested in debug result its showing\n\nIncluded Files\nInclude Paths\n 0/home/reviewpr/public_html/imobdevnew/lib\n 2/usr/lib/php\n 3/usr/local/lib/php\n 4-> /home/reviewpr/public_html/imobdevnew/lib/Cake/\nIncluded Files\n core\n app\n Config\n Controller\n Model\n 0APP/Model/AppModel.php\n Other\n 0APP/webroot/index.php\n plugins\n\n\nwhere in local its showing\n\nIncluded Files\nInclude Paths\n 0C\n 1\\wamp\\www\\imobdevnew\\lib;.;C\n 2\\php\\pear\n 3-> C:\\wamp\\www\\imobdevnew\\lib\\Cake\\\nIncluded Files\n core\n app\n Other\n 0APP/webroot\\index.php\n 1APP/Config\\core.php\n 2APP/Config\\bootstrap.php\n 3APP/Config\\config.php\n 4APP/Config\\routes.php\n 5APP/Controller\\PortfoliosController.php\n 6APP/Controller\\AppController.php\n 7APP/Model\\portfolio.php\n 8APP/Model\\AppModel.php\n 9APP/Config\\database.php\n 10APP/Model\\category.php\n plugins\n\n\nthat means its not loading models.\n\nPlease help me..." ]
[ "php", "mysql", "cakephp", "join", "cakephp-2.0" ]
[ "Listview adds items twice", "I want to add single row to my ListView. When I run the code below, there are 2 lines added, one with the text I want to add, and an empty one. Why is the empty one added? (lines[0] is a file with (for now) 1 line in it)\n\nlistAdapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.listviewrow, R.id.txt_listviewItem, lines){\n @Override\n public View getView(int position, View convertView, ViewGroup parent){\n View myView = convertView;\n\n if (myView == null) {\n LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n myView = li.inflate(R.layout.listviewrow, null);\n } else {\n TextView txt_listviewItem = (TextView)myView.findViewById(R.id.txt_listviewItem);\n txt_listviewItem.setText(lines[0]);\n\n }\n return myView;\n };\n\n... \n\nlistView.setAdapter(listAdapter);\n\n\nWhen I debug, listview.setAdapter(listAdapter) is called before AND after the getView code runs. Why? I only call it once." ]
[ "java", "android", "listview" ]
[ "Java Regex to match a specific string or another specific string, or not at all?", "Imagine capturing the input with a regex:\n\n2.1_3_4\n3.2.1\n3.2.1.RELEASE\n3.2.1.SNAPSHOT\n\n\nThe numbers and the dots are easy enough to get\n\n([0-9\\._]+)\n\n\nBut how do you capture that plus \"RELEASE\" or \"SNAPHOT\" or none of those?\n\nI played around with the or operator to no avail...\n\n([0-9\\._]+RELEASE||SNAPSHOT) // no worky\n\n\nbtw, this is a nice regex tester: http://java-regex-tester.appspot.com/" ]
[ "java", "regex" ]
[ "How to zip a folder in vb", "I'm doing a project related to stenography. I need to hide multiple files inside a single image. I managed to bring all the files required to hide into a single folder. Now I need to zip this file and convert it to byte array so that I can pick bit by bit and hide it in LSB bit of an image.\n\nHow can I zip a folder in vb and convert it to byte array.\nAlso which compression mode should I use? Time is not a big factor for me, but I need the data exactly as before it was zipped. I must not loose a single bit." ]
[ "arrays", "vb.net", "zip" ]
[ "Decoding Opus audio data file to raw data file Node JS", "I am trying to decode an Opus file back to raw data file which library should I use." ]
[ "javascript", "node.js", "opus", "raw-data" ]
[ "Generate Python templates with parameters", "I have used JET with Eclipse before to generate Java files from models. I am new to Python and I am searching for a way to generate python modules automatically based on parameters (data) read from the user -for educational purposes. \n\n\n For example, a student will be guided to a webpage, where he/she enters the name of a project, select different control statements (ie.a while loop), enter a boolean expression, and the loop body, and hit generate. The webpage will generate a .py module for him/her that could be used for educational purposes. \n\n\nAfter research, I found many python generators out there, and I guess Jinja is one of the most popular ones. But I would like to know if I am going the right direction before making a decision. \n\nSo my questions are as:\n\n\nWhat is the best python code generator that fits my project idea\nthe most?\nShould I build the web interface of such a project\nusing a Python platform, or something else like PHP?" ]
[ "python", "code-generation" ]
[ "How to pivot on more than one column for a spark dataframe?", "How can we pivot on more than one column in a dataframe.\ne.g. The example mentioned here,\nhttps://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-pivot.html\nSELECT * FROM person\n PIVOT (\n SUM(age) AS a, AVG(class) AS c\n FOR (name, age) IN (('John', 30) AS c1, ('Mike', 40) AS c2)\n );\n\nHere Pivot is done on (name,age).\nWe can't pass more than one parameter in Spark scala's pivot method as it only expects one column name as parameter.\nHow can we do the similar operation for a dataframe?" ]
[ "java", "scala", "apache-spark", "apache-spark-sql", "pivot" ]
[ "Laravel 5: Collective html not working (localhost)", "I was trying to install laravel Collective form class as instructed in http://laravelcollective.com/docs/5.1/html. I added the lines in provider and alias arrays. But it still returning error 'FatalErrorException in 35d2ebae68816953807290e20156144f line 7:\nClass 'HTML' not found'\n\nfull error\n\nMy installation commands- \n\n\nMy Composer.json file\n\nMy config->app.php file" ]
[ "php", "laravel", "composer-php", "laravel-5.1", "laravel-form" ]
[ "How to send constantly updates using .Net Core SignalR?", "I am new to SignalR and I would like to build such app -- every second a hub sends current time to all connected clients.\n\nI found tutorial, but it is for .Net Framework (not Core): https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-high-frequency-realtime-with-signalr So on one hand I don't know how to translate it to .Net Core SignalR, on the other hand I don't know how to write it from scratch (the limiting condition is the fact a hub is a volatile entity, so I cannot have state in it).\n\nI need something static (I guess) with state -- let's say Broadcaster, when I create some cyclic action which in turn will send updates to clients. If such approach is OK, how to initialize this Broadcaster?\n\nCurrently I added such static class:\n\npublic static class CrazyBroadcaster\n{\n public static void Initialize(IServiceProvider serviceProvider)\n {\n var scope = serviceProvider.CreateScope();\n var hub = scope.ServiceProvider.GetRequiredService<IHubContext<ChatHub>>();\n var sub = Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(_ => hub.Clients.All.SendAsync(\"Bar\", DateTimeOffset.UtcNow));\n }\n}\n\n\nYes, I know it is leaky. I call this method at the end of Startup.Configure, probably tons of violations here, but so far it is my best shot." ]
[ "asp.net-core", "signalr-hub" ]
[ "Unable to communicate to a machine in the network(outside of the k8s cluster) with cidr 10.0.x.0/24 from within the pod", "I have two machines within my netwrok which I want communicate from the pod. \n\nIps are as follows : \n\n10.0.1.23 - Lets call it X\n\n13.0.1.12 - Lets call it Y\n\n\nWhen I ssh into the master node or agent node and then do a ping to X or Y, the ping is successful. \nTherefore the machines are reachable. \n\nNow I create a deployment, I log into the shell of the pod using (kubectl exec -it POD_NAME — /bin/sh). \n\nPing to Y is successful. But ping to X fails. \n\nCIDR details : \n\nMaster Node : 14.1.255.0/24\nAgent Node: 14.2.0.0/16\nPod CIDR: \n Agent : 10.244.1.0/24\n Master: 10.244.0.0/24\n\n\nMy understanding on what could be the issue : \n\n\n acs-engine has kube-proxy setup the service network with 10.0.0.0/16\n If this is the problem how do i change the kube-proxy cidr?\n\n\nAdditional Info: \n\nI am using acs-engine for my deployment of cluster.\n\nOutput for ip route \n\ndefault via 10.244.1.1 dev eth0 \n10.244.1.0/24 dev eth0 src 10.244.1.13\n\nAnother suspect: On running iptables-save I see \n\n-A POSTROUTING ! -d 10.0.0.0/8 -m comment --comment \"kubenet: SNAT for outbound traffic from cluster\" -m addrtype ! --dst-type LOCAL -j MASQUERADE" ]
[ "azure", "kubernetes", "acs", "azure-container-service" ]