texts
list | tags
list |
---|---|
[
"FTPKit Abort (Cancel) FTP Operation",
"I am trying to use this Github library for iOS: https://github.com/PeqNP/FTPKit\n\nThe problem is, there is no cancel function for a request which is what I need. I am trying to implement my own cancel function however it doesn't work as it is crashing with a: \"write: Bad file descriptor\" EXC_BAD_ACCESS\n\nIn this file specifically: https://github.com/PeqNP/FTPKit/blob/master/Libraries/include/ftplib/src/ftplib.c\n\nI added this method all the way at the bottom, to use the \"ABOR\" command that FTP servers can use. However I am not sure if this was the right way of implementing it.\n\nGLOBALDEF void FtpAbort(netbuf *nControl)\n{\n if (nControl->dir != FTPLIB_CONTROL)\n return;\n FtpSendCmd(\"ABOR\",'2', nControl);\n net_close(nControl->handle);\n free(nControl->buf);\n free(nControl);\n}\n\n\nThen in the FTPClient.m I just made a method which calls this FtpAbort method on a netbuf * object (which can be a list, download, upload connection, etc..)\n\nDoes anyone see what I am doing wrong here?"
] | [
"ios",
"c",
"ftp"
] |
[
"Rails: Using .references on joins even though it is not required",
"I know that when you utilize includes and you specify a where clause on the joined table, you should use .references\n\nexample:\n\n# will error out or throw deprecation warning in logs\ncustomers = Customer.includes(:orders).where(\"Orders.cost < ?\", 100)\n\n\nOtherwise, in rails 4 or later, you will get an error like the following:\n\n\n Mysql2::Error: Unknown column 'Orders.cost' in 'where clause': SELECT\n customers.* FROM customers WHERE (Orders.cost < 100)\n\n\nOr you will get a deprecation warning:\n\n\n DEPRECATION WARNING: It looks like you are eager loading table(s)\n (one of: users, addresses) that are referenced in a string SQL\n snippet. For example: \n\nPost.includes(:comments).where(\"comments.title = 'foo'\")\n\n \n Currently, Active Record recognizes the table in the string, and knows\n to JOIN the comments table to the query, rather than loading comments\n in a separate query. However, doing this without writing a full-blown\n SQL parser is inherently flawed. Since we don't want to write an SQL\n parser, we are removing this functionality. From now on, you must explicitly\n tell Active Record when you are referencing a table from a string:\n \n Post.includes(:comments).where(\"comments.title = 'foo'\").references(:comments)\n \n If you don't rely on implicit join references you can disable the\n feature entirely by setting config.active_record.disable_implicit_join_references = true. (\n \n SELECT \"users\".\"id\" AS t0_r0, \"users\".\"name\" AS t0_r1, \"users\".\"email\" AS t0_r2, \"users\".\"created_at\" AS t0_r3,\n \"users\".\"updated_at\" AS t0_r4,\n \"addresses\".\"id\" AS t1_r0, \"addresses\".\"user_id\" AS t1_r1, \"addresses\".\"country\" AS t1_r2, \"addresses\".\"street\" AS t1_r3,\n \"addresses\".\"postal_code\" AS t1_r4, \"addresses\".\"city\" AS t1_r5,\n \"addresses\".\"created_at\" AS t1_r6, \"addresses\".\"updated_at\" AS t1_r7\n FROM \"users\" \n LEFT OUTER JOIN \"addresses\" ON \"addresses\".\"user_id\" = \"users\".\"id\" \n WHERE (addresses.country = 'Poland')\n\n\nMakes sense. Rails does not want to be an SQL parser when you utilize includes. So to make rails happy we do this:\n\n# No error and no deprecation warning because we are explicitly specifying what table is referenced within that where clause\ncustomers = Customer.includes(:orders).where(\"Orders.cost < ?\", 100).references(:orders)\n\n\nHowever, when you use joins and a where clause on the joined table: Rails does not error out, and rails also does not throw a deprecation warning as it does with includes:\n\n# No error and no deprecation warning. What????\ncustomers = Customer.joins(:orders).where(\"Orders.cost < ?\", 100)\n\n\nThis does not make sense to me. I would think that if rails does not want to be an SQL parser for includes, then it also would not want to be an sql parser for joins. I would think that rails would prefer me to use references like so:\n\ncustomers = Customer.joins(:orders).where(\"Orders.cost < ?\", 100).references(:orders)\n\n\nSo my question(s): \n\n\nAm I missing something? Is it absolutely fine to not specify references for joins with where clauses on joined tables, even though it is pretty much required for includes? If so: why this difference between includes and joins?\nShould I specify references on joins moving forward? Perhaps once rails' sql parser goes away all those joins with where clauses on joined tables will no longer work anymore?"
] | [
"ruby-on-rails",
"ruby"
] |
[
"How to prevent an Angular form submitting when the user presses return in a textarea?",
"I have a form wired up to an angular (10) form group like so\n<form [formGroup]="form" (ngSubmit)="submitForm()">\n <textarea\n id="address"\n formControlName="customerAddress"\n ></textarea>\n <button>Submit</button>\n</form>\n\nWhen the user hits return in the textarea, the form submits instead of adding a line break to the textarea. How can I prevent this?"
] | [
"angular10"
] |
[
"How do I install textfsm in python?",
"Context: Windows 7, spyder with python 3.6 and anaconda.\n\nCan't find textfsm on anaconda.org.\n\nCan find textfsm in pypi - https://pypi.org/project/textfsm/#files\n\nCan download textfsm-0.4.1.tar.gz and extract to textfsm-0.4.1\n\nDo I put it in C:...\\Anaconda3\\Lib\\site-packages?\n\nWhat next?"
] | [
"python",
"windows",
"installation"
] |
[
"Flask how to set the default request header for response.make_conditional to read",
"I have a flask route\[email protected]('/api/test', methods=['GET'])\ndef test_get():\n response = make_response(str(1))\n response.add_etag()\n return response.make_conditional(request)\n\nIf I make a request with an If-None-Match header with the Etag I got from the previous response, the flask seem to understand it and return 304 not modified.\nHowever, I would like to modify the default request header to something like Custome for the flask response.make_conditional to look for. is there a way to achieve it?"
] | [
"python",
"flask",
"request"
] |
[
"ORA-01109 Database not open error while running a script",
"I am running a script with SQLPlus in an Oracle DB which creates extra tablespaces. Here is the code of the script:\nCREATE TABLESPACE FAR_YELLOW_FISH\nDATAFILE\n '$ORADATA/node03/faryellowfish01.dbf' SIZE 200M,\n '$ORADATA/node03/faryellowfish02.dbf' SIZE 200M;\nCREATE TABLESPACE WET_BROWN_SOUP\nDATAFILE\n '$ORADATA/node01/wetbrownsoup01.dbf' SIZE 100M,\n '$ORADATA/node03/wetbrownsoup02.dbf' SIZE 100M;\nCREATE TABLESPACE EASY_ORANGE_DISK\nDATAFILE\n '$ORADATA/node03/easyorangedisk01.dbf' SIZE 100M,\n '$ORADATA/node03/easyorangedisk02.dbf' SIZE 100M,\n '$ORADATA/node02/easyorangedisk03.dbf' SIZE 100M,\n '$ORADATA/node02/easyorangedisk04.dbf' SIZE 100M;\nCREATE TABLESPACE WET_YELLOW_OVEN\nDATAFILE\n '$ORADATA/node01/wetyellowoven01.dbf' SIZE 100M;\n\nBefore this I run the following:\nsqlplus /nolog\nconnect / as sysdba\ncreate SPFILE from PFILE;\nstartup nomount\n\nand a script which creates main tablespaces - it works properly.\nWhen running the script, that I mentioned first, I get the following error: ORA-01109: database not open. It appears for each CREATE TABLESPACE expression.\nAs a solution I tried to run ALTER DATABASE OPEN; but the answer was ORA-01507: database not mounted.\nI guess, there is something wrong with the script, but not sure about that.\nHow can I solve it?"
] | [
"oracle",
"sqlplus"
] |
[
"Animated dots relocate after device rotation",
"I've created a button with three animating dots using SwiftUI. When the screen geometry changes somehow (device rotation, keyboard open, etc.) the animation gets messed up. See the attached video. How can I get the circles to stay in their position relative to the button?\n\nThis is my code:\nstruct ContentView: View {\n var body: some View {\n \n Button(action: {}, label: {\n AnimatedDot().frame(minWidth: 200, maxWidth: .infinity, minHeight: 20, maxHeight: 20)\n }).foregroundColor(Color.blue)\n .padding()\n .background(Color.gray)\n .cornerRadius(10.0)\n .frame(minWidth: 0, maxWidth: 350)\n \n }\n}\n\nstruct AnimatedDot: View {\n \n @State private var shouldAnimate = false\n \n var body: some View {\n HStack {\n Circle()\n .fill(Color.white)\n .frame(width: 15, height: 15)\n .scaleEffect(shouldAnimate ? 1.0 : 0.5)\n .animation(Animation.easeInOut(duration: 0.3).repeatForever())\n Circle()\n .fill(Color.white)\n .frame(width: 15, height: 15)\n .scaleEffect(shouldAnimate ? 1.0 : 0.5)\n .animation(Animation.easeInOut(duration: 0.3).repeatForever().delay(0.3))\n Circle()\n .fill(Color.white)\n .frame(width: 15, height: 15)\n .scaleEffect(shouldAnimate ? 1.0 : 0.5)\n .animation(Animation.easeInOut(duration: 0.3).repeatForever().delay(0.6))\n }\n .onAppear {\n self.shouldAnimate = true\n }\n }\n \n}"
] | [
"ios",
"swift",
"animation",
"swiftui"
] |
[
"installing surround.vim and getting an error message - E149 - no help for surround",
"I am trying to installing plugins on vim and i managed to install nerdtree and pathogen, now i'm trying to install surround.vim and i'm getting an error message such as E149 no help for surround command. I haven't added anything to the vimrc file but i don't know what i should add to it for this to work can someone please advise on this?"
] | [
"vim",
"vim-plugin"
] |
[
"Making new Numpy array with indexes of another Numpy array",
"I have an 10 x N array as follows:\n\n[[ 0. 1. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 1. 0. 0.]\n [ 1. 0. 0. ..., 0. 0. 0.]\n ..., \n [ 0. 0. 0. ..., 1. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 1.]\n [ 0. 0. 0. ..., 0. 0. 1.]]\n\n\nI want a Numpy array of the following 1 x N format, where each element in the new array is the value of the index filled with '1' in the 10 x N array.\n\nFor example, the process would convert the above into the array: \n\n[[ 1. 7. 0. ..., 7, 9. 9.]]\n\n\nI have had some success with using the function:\n\nnp.where(array > 0)[0][0]\n\n\nThis gives me a value for my final array but my attempts to fill the array in the required format have not worked. Furthermore, my implementations have not been very pythonic. Is there a pythonic solution to the above question?"
] | [
"arrays",
"numpy",
"element"
] |
[
"(0, _File.Function) is not a function",
"I am using React Native and am trying to give a Component access to a client while keeping it in a separate file. The code for that is:\nexport default function SearchFactory(restClient){\n return class Search extends Component {\n // regular component stuff, that references restClient\n }\n}\n\nWhen I try to access it in App.js, with the import being import {SearchFactory} from './screens/SearchFactory';\nand the code being const SearchView = SearchFactory(restClient);, I am getting the following error:\nTypeError: (0, SearchFactory.SearchFactory) is not a function. (In '(0, SearchFactory.SearchFactory)(restClient)', '(0, SearchFactory.SearchFactory)' is undefined)\n\nI have tried removing the client input, but the error persists."
] | [
"reactjs",
"react-native"
] |
[
"Bit not operation in PHP(or any other language probably)",
"Why does this code return -1 ?\n\n\n$a = 0; \necho ~$a;\n\n\nIsn't not suppose to revert the bits ?"
] | [
"php"
] |
[
"Access internet through 3G USB modem (ppp0) with wlan0 and eth0",
"I have a Raspberry Pi 3 B+ and a Huawei 3G USB modem. I would like to be able to connect to the internet using the eth0 and wlan0 interface, but all I was able to achieve is to connect via one or the other interface, but not both.\n\nI have setup the configuration to dial into the cell provider, as well as all the steps needed to configure a static ip address and doing all the configuration with the NAT as described in this post: https://www.benfreke.org/201712/raspberry-pi-3g-4g-hotspot/ (scroll to \"CREATING A WIFI HOTSPOT\"). However, this gives me access to access the internet through the Pi's wireless chip, but I have no way to access the internet through a wired connection using the ethernet (eth0). I would like to be able to do both, access through wlan0 but also when connecting an internet cable to the Pi. How can I achieve this? I can setup accessing the internet through the eth0 network, by simply replacing all the wlan0 configuration by eth0 in the tutorial, but then I don't have access to the wlan0 network. Is there a way to achieve both? Alternatively, I have a Apple's Airport Express wireless router, so if there is a way to configure the Pi so I can simply wire it to the Airport Express and then have the Express do the wireless, that would work too, but it does not seem to work when I follow the tutorial, and replace wlan0 by eth0. The code is all essentially the same as in the tutorial linked here."
] | [
"raspberry-pi3",
"raspbian"
] |
[
"How to create separate queue for each consumer I have in activemq?",
"I'm using activemq (pretty new to me) and I have one producer and several consumers.\n\nThing is, I want to address messages for specific consumers.\nI read about selectors but also read that it is a bad practice to use and also read about some alternatives.\n\nThe alternative sounds good for me, but I'm not sure how I can create these queues for each and every one of my slaves.\nEach of my slaves has an ID (uuid) that I can use when I'm creating the listener - like this:\n\n<jms:listener-container\n container-type=\"default\"\n connection-factory=\"jmsConnectionFactory\"\n acknowledge=\"auto\">\n <jms:listener destination=\"slave.tasks.${slave.id}\" ref=\"jmsActivityListener\" method=\"onMessage\" />\n</jms:listener-container>\n\n\nThis requires the slave.properties file to contain the following entry:\n\nslave.id=XXXXXXX\n\n\nMy questions are:\n\n1) Is that the way to do it (defining a queue per consumer)?\n\n2) How can I generate this salve.id value (I don't want the user to fill it as it has to be unique)?\n\nThanks"
] | [
"java",
"spring",
"jms",
"activemq"
] |
[
"ionic2 rc0 build error on ios device/simulator main.js",
"I updated from ionic2 beta 11 to rc0.\nEverything was working on beta 11, after creating a new project with rc0 I got the following errors:\n\n[12:35:30] bundle prod started ...\n[12:35:30] Error: Could not resolve entry (.tmp/app/main.prod.js)\nat /Users/MAC/myapp/node_modules/rollup/dist/rollup.js:8602:28\nat process._tickCallback (internal/process/next_tick.js:103:7)\n\n[12:35:30] sass started ...\n[12:35:32] sass finished in 2.28 s\n[12:35:32] minify started ...\n[12:35:32] cleancss started ...\n[12:35:32] uglifyjs started ...\n[12:35:32] Error: ENOENT: no such file or directory, open '/Users/MAC/myapp/www/build/main.js'\nat Error (native)\nat Object.fs.openSync (fs.js:634:18)\nat Object.fs.readFileSync (fs.js:502:33)\nat addFile (/Users/MAC/myapp/node_modules/uglify-js/tools/node.js:68:22)\nat /Users/MAC/myapp/node_modules/uglify-js/tools/node.js:79:17\nat Array.forEach (native)\nat Object.exports.minify (/Users/MAC/myapp/node_modules/uglify-js/tools/node.js:77:26)\nat runUglifyInternal (/Users/MAC/myapp/node_modules/@ionic/app-scripts/dist/uglifyjs.js:34:19)\nat runUglify (/Users/MAC/myapp/node_modules/@ionic/app-scripts/dist/uglifyjs.js:23:28)\nat Object.uglifyjs (/Users/MAC/myapp/node_modules/@ionic/app-scripts/dist/uglifyjs.js:9:12)\n\n\nI noticed that the problem is the main.js file is not being created.\nThank you\n\nI got this error in safari web developer:\n\nFailed to load resource: The requested URL was not found on this server.\nfile:///var/containers/Bundle/Application/12824002-C5CC-42CD-8173-4A472DC68C9E/myapp.app/www/build/main.js\n\n\nThe contents of main.prod.js are:\n\nimport { platformBrowser } from '@angular/platform-browser';\nimport { enableProdMode } from '@angular/core';\n\nimport { AppModuleNgFactory } from './app.module.ngfactory';\n\nenableProdMode();\nplatformBrowser().bootstrapModuleFactory(AppModuleNgFactory);\n\n\nThank you"
] | [
"ios",
"angular",
"ionic2"
] |
[
"Not able to create wcf service object/client for reference in xamarin android",
"i want to access a wcf service so i added it as a web reference in my xamarin android project but whenever i try to create its client it does not recognize it. \ni am attaching screenshots in a step by step order\n\nThis is the working wcf service\n\nI added it as a web refrence\n\nwhenever i try to create its object it shows an error\n\nWhen i right click on the web reference and select view in object browser it shows nothing\n\nI tried rebuilding my solution, disabling windows firewall..\nThe service is hosted on other computer. Shall i host this service on my system and then try again? or is there any other fix? i am in desperate help!!"
] | [
"android",
"wcf",
"xamarin",
"xamarin.android"
] |
[
"How do sockets and ethernet work together?",
"Say I have two computers connected with a single ethernet cable, using tcp/ip. If computer 1 connects to computer 2 using port 12345, and computer 2 connects to computer 1 with port 54321, what happens when both computers are sending a constant flow of data simultaneously?\n\nDo the computers each get half of the ethernet cable to use as one way pipes or do they take turns sending data through the ethernet cable so that only one piece of data is being transmitted through it at a time?"
] | [
"sockets",
"tcp",
"ethernet"
] |
[
"Possible to change the dialog right position in the style to the new value in jquery?",
"Just wandering will it be possible to change the dialog right position in the style to the new value in jquery?\n\nExample: \n\nI have the following dialog loaded on the page with the following set of style value:\n\n<dialog class=\"mdl-dialog test\" style=\"padding:0px;position:absolute;top:340px;right:183px;margin-right:0\">\n</dialog >\n\n\nAny way that I can change the dialog right position in the style to the new value in jquery as following :\n\n<dialog class=\"mdl-dialog test\" style=\"padding:0px;position:absolute;top:340px;right:1403px;margin-right:0\">\n</dialog >"
] | [
"jquery",
"dialog"
] |
[
"Regex to remove external links except provided domain related links php",
"I want regex to remove all external links from my content and just keep the links of provided domain.\n\nFor ex. \n\n$inputContent = 'Lorem Ipsum <a href=\"http://www.example1.com\" target=\"_blank\">http://www.example1.com</a> lorem ipsum dummy text <a href=\"http://www.mywebsite.com\" target=\"_blank\">http://www.mywebsite.com</a>';\n\n\nExpected output:\n\n$outputContent = 'Lorem Ipsum lorem ipsum dummy text <a href=\"http://www.mywebsite.com\" target=\"_blank\">http://www.mywebsite.com</a>';\n\n\nTried with this solution but it's not working.\n\n$pattern = '#<a [^>]*\\bhref=([\\'\"])http.?://((?<!mywebsite)[^\\'\"])+\\1 *>.*?</a>#i'; \n$filteredString = preg_replace($pattern, '', $content);"
] | [
"php",
"regex"
] |
[
"Sending data through Unwind Segues",
"I have a custom unwind segue issue. Let me explain my controller setup:\n\nI have a main screen which is a navigation controller with a cell view inside. Within this view, there is a button to add data, and in that view is 4 buttons for additional \"types\" of data to add. Once a user selects one of those four options, they are presented with a view controller specific to their choice that lets them enter data with a done button. The three screens respectively I will from now on refer to them as Main View, Options View, then Data View(all 4 options follow this convention).\n\nAfter some tutorials I made a custom unwind segue in Main View's controller class, as follows:\n\n@IBAction func unwindToTables(segue: UIStoryboardSegue) {\n //function proto for adding data here\n //populateTableWithData(data :ItemData)\n}\n\n\nIn the storyboard editor, anytime I control + click from any View Controller to it's exit, it lists my unwind segue properly and this works fine. \n\nI would now like to send data through the unwind. In Data View, I have a Done button that constructs and initializes a class of data, called ItemData to which I would like to pass through the segue.\n\nMost of the questions I found on SO or other sites with this deals with normal segues, and when I try to implement them anyways the application causes a runtime error / does not compile.\n\nHas anyone come into the issue before, and have a solution for said issue? Any help or points in the right direction would be much appreciated!\n\nEdit:\n\nI edited my unwind function as follows:\n\n@IBAction func unwindToTables(segue: UIStoryboardSegue) {\n let dataC = segue.sourceViewController as? DataVC\n let data : ItemData = dataC!.SubmittedData! //unwrapping error\n\n print(data.Name)\n\n\n //save data\n\n}\n\n\nand on top of every New{1-4}ViewController I have the following:\n\nimport UIKit\n\nclass New1ViewController: DataVC,\n\n\nand I made a new superclass DataVC:\n\nimport Foundation\n\nclass DataVC: UITableViewController {\n var SubmittedData: ItemData?\n}\n\n\nbut now I am getting an unwrapping issue... must I initialize SubmittedData prior?\n\nEdit 2:\n\nThought I might add the Done button press I am doing...\n\n@IBAction func DonePressed(sender: AnyObject) {\n\n let n = ...\n ...\n let d = ...\n\n super.SubmittedData = ItemData(FieldType: \"1\", CName: n!, CPhone: p!, CAddress: a!, ShouldBe: s!, Repeats: r!, Starts: b, RemindMe: m!, AdditionalNotes: d!)\n\n}"
] | [
"ios",
"uiviewcontroller",
"segue",
"unwind-segue"
] |
[
"How to separate Stata macro `varlist' with commas for using in mi( ) and inlist( )?",
"I want to store a list of variables in a macro and then call that macro inside a mi() statement. The original application is for a programme that uses data I cannot bring online for secrecy reasons, and which will include the following statement: \n\ngenerate u = cond(mi(`vars'),., runiform(0,1))\n\n\nThe issue being that mi() requires comma separated variable names but vars is delimited by spaces.\n\nI use the auto dataset and mark to illustrate my problem:\n\nsysuse auto\nlocal myvars foreign price\nmark missing if mi(`myvars')\n\n\nIn this example, mi() asks for arguments separated by commas, Stata stops and complains that it cannot find a foreignprice variable. Is there a utility function that will insert the commas between the macro elements?"
] | [
"stata",
"stata-macros"
] |
[
"HTML / PHP scrollbar not showing up on iPad but shows on desktops and laptops",
"scrollbar not showing up for the following textbox on the iPad when I fill it with text.\n\n<textarea type=\"text\" name=\"holyCow\" rows=\"30\" cols=\"120\"></textarea></p>"
] | [
"php",
"html",
"ipad"
] |
[
"iOS Objective-C Controlling Button Images",
"I have a button. Unsure if it is specifically a UIButton class type. This is a Button which was dragged from the Object library into my Main.Storyboard.\n\nI don't have text, instead I have an image. And I plan to use two images. One for \"loop on\" and the other for \"loop off\". I'm playing a sound and this button controls whether or not you will loop the sound. I'm all set with understanding how to do the looping versus not.\n\nI have set the \"loop off\" image as my default image under the Attributes inspector.\n\nSo when the button gets touched, I'll change the behavior of my playing sound to be \"loop forever\" and I'd like to change the image of the button from within my IBAction function.\n\nI can set a title for the button in the Attributes inspector.\n\nBut I don't see that title as a resource name (auto-typing-complete) from within my ViewController.m code.\n\nI know there are properties per state for images. I believe there's also just a \"setImage\" action for a UIButton.\n\nWhat I can't determine is how my Button is named in the code because this button was added via dragging it out of the Object library.\n\nAnyone have any knowledge of where these resources get named, like a reference file?\n\nA search found something close, the following link:\n\nhttp://ranga-iphone-developer.blogspot.com/2011/08/how-to-change-uibutton-image.html\n\nHowever the solution doesn't appear to reference a particular button name, title, or ID; unless the text \"button\" is supposed to be replaced with the specific resource name."
] | [
"ios",
"objective-c"
] |
[
"Jquery: UL LI does not display text if anchor is attached",
"I'm generating navigation menu from an XML file. Everything works fine expect one issue.\n\nWhen the menu is generated, the li nodes (with child nodes and anchor tag attached to it) will not display its text ( based on below example) like 'Web Design', 'Development'. It comes up blank only with list-style-image shown.\n\nBut, when I click on image('plusimageapply'), the child nodes are displayed and text \"Web Design \" is also comes up. Same issue is repeated with every child node that has sub nodes and anchor tag. Only the image shows up without Text. If node is expanded, Text shows up.\n\nWhen the node is collapsed, the Text disappear again. Image is not effected.\n\nThis issue does not happen if the node does not have a child node or if the node does not have a anchor link example like \"Design\". \n\nCan you please help. I have been going nuts not able to know why it is acting like this. \n\nI'm using IE 10.\n\nHTML Menu layout :\n\n<div id=Menu>\n\n<ul>\n <li class=\"category\">Design\n <ul>\n <li><A href=\"url...\" target=\"somelocation\">Graphic Design </A></li>\n <li class=\"category\"><A href=\"url...\" target=\"somelocation\">Web Design </A>\n <ul>\n <li>HTML</li>\n <li>CSS</li>\n </ul>\n </li>\n <li>Print</li>\n </ul>\n </li>\n <li class=\"category\"><A href=\"url...\" target=\"somelocation\">Development</A>\n <ul>\n <li>PHP</li>\n <li>Java</li>\n </ul>\n </li>\n </ul>\n</div>\n----------------------------------------------------------------\njQUERY: ( used from site:http://www.sendesignz.com/index.php/jquery/77-how-to-create-expand-and-collapse-list-item-using-jquery)\n\n// JavaScript Document\n$(document).ready(function () {\n\n $('li.category').addClass('plusimageapply');\n $('li.category').children().addClass('selectedimage');\n $('li.category').children().hide();\n\n\n $('li.category').each(\n function (column) {\n $(this).click(function (event) {\n if (this == event.target) {\n if ($(this).is('.plusimageapply')) {\n $(this).children().show();\n $(this).removeClass('plusimageapply');\n $(this).addClass('minusimageapply');\n }\n else {\n $(this).children().hide();\n $(this).removeClass('minusimageapply');\n $(this).addClass('plusimageapply'); \n }\n }\n });\n }\n ); \n});\n\n----------------------------------------------------------------------------------\nCSS:\n.plusimageapply\n{\n list-style-image: url(../Images/cicon12.png); \n cursor: pointer;\n vertical-align:middle;\n}\n.minusimageapply\n{\n list-style-image: url(../Images/cicon2.png);\n cursor: pointer;\n vertical-align:middle;\n\n}\n\n.selectedimage\n{\n list-style-image: url(../Images/cicon9.png);\n cursor: pointer;\n vertical-align:middle;\n\n}"
] | [
"jquery"
] |
[
"Architecture for dynamic tables to render reports/graph",
"I am using a SQL server database for storing data. I have created some dynamic tables those will store the per-calculated values. Dynamically created tables may have 2 columns, 3 columns or even more. Based on the filter selection i will identify the dynamic table to get the per-calculated result and render tabular report or graph in the screen (HTML). Creation of tables and populating values will be call at some given time using the SQL Job. \n\nAnyone can suggest what architecture should I use for my application? MVC or ASP.NET?\n\nThanks,"
] | [
"architecture",
"reporting"
] |
[
"Can I detect h264 support in code?",
"For an installer I'm building, I need to be able to warn the user if they don't have an h264 codec installed. At this point in the process I don't have any such video to play or anything, I just need to detect the ability to do so. Is this possible?\n\nUnfortunately I can't rely on the computer having anything much already installed, such as .Net or DirectX (other than whatever comes with plain Windows XP or later). The installer is written in C++."
] | [
"video",
"h.264"
] |
[
"How to initalize a array of string from a file data",
"I want to print the same data which is in the file.\nI have written this code. I am not getting the preferred data.\n#include <stdio.h>\n#include <string.h>\n\nint main() {\n char name[12][10];\n\n FILE *file = fopen("input.txt", "r");\n char line[100];\n int i = 0;\n while (fgets(line, sizeof(line), file)) {\n fscanf(file, "%s", &name[i]);\n i++;\n }\n\n fclose(file);\n\n for (i = 0; i < 12; i++) {\n printf("%s\\n", name[i]);\n }\n \n return 0;\n}\n\nThe output I am getting is:\n011073054\n10\n10\n10\n3.8 \nBadol\n011074509 \n10\n10\n10\n4.0\n\nIn my text file I have these lines:\nAlman\n011073054\n10 20 28 37\n10 18 30 35\n10 15 18 34\n3.8\nBadol\n011074509\n10 15 18 34\n10 20 28 37\n10 18 30 35\n4.0\n\nI am trying to store the lines in an array of strings. Then I want to print the string from that string array. But I don't know why the first line of the text file is not getting assigned in my string array. Where am I doing wrong?"
] | [
"arrays",
"c",
"string"
] |
[
"Automatic type recognition in Scala",
"I am learning Scala right now. I see that specifying type while assigning to new val is not necessary. But then consider the following code:\n\nobject MyObject {\n def firstResponse(r: Array[String]): String = r(0)\n def mostFrequent(r: Array[String]): String = { \n (r groupBy identity mapValues (_.length) maxBy(_._2))._1\n }\n def mostFrequent(r: Array[String], among: Int): String = { mostFrequent(r take among) }\n\n // throws compile error\n val heuristics = Array(\n firstResponse(_), mostFrequent(_, 3), mostFrequent(_, 4), mostFrequent(_, 5)\n )\n}\n\n\nIf I change the last line and specify the type explicitly, then the error is gone\n\nval heuristics: Array[Array[String] => String] = Array(\n firstResponse, mostFrequent(_, 3), mostFrequent(_, 4), mostFrequent(_, 5)\n)\n\n\nWhat's wrong here?\n\nEdit: As @mdm correctly pointed out, \n\n//This works\nval heuristics = Array(firstResponse(_), firstResponse(_))\n//This does not work\nval heuristics = Array(mostFrequent(_,1), mostFrequent(_,2))\n\n\nOpen question is, why Scala can determine the type of firstResponse(_) correctly while it has difficulty to do the same for mostFrequent(_,1)."
] | [
"scala",
"functional-programming",
"type-inference"
] |
[
"Actionscript 3 ExternalInterface, Pass variable to javascript?",
"How would I go about passing a variable to a javascript function using ExternalInterface?"
] | [
"actionscript-3",
"externalinterface"
] |
[
"Django-like URL Routing for PHP",
"I am looking for a way to provide URL routing similar to one in Django. I looked at a lot of resources online & I liked cobweb but the problem is I dont want to use the entire framework I just want to use the URL rerouting logic/code. Is there a good resource for just Django-like URL routing logic?"
] | [
"php",
"django",
"url-rewriting",
"url-routing"
] |
[
"Docker container networking - Kafka Producer",
"I would like to produce messages from a container A to a Kafka topic in a container B, but I am facing some weird issues with the networking of these containers. \nDo you have any idea on how I can connect those containers in a proper way?\nThe problem is that the collector service cannot see the kafka from the other container and cannot add messages to it.\nMore specifically I have the services below:\n\ndocker-compose.yml\n\nversion: '3.5'\nservices:\n zookeeper:\n image: confluentinc/cp-zookeeper:latest\n ports:\n - \"2181:2181\"\n environment:\n ZOOKEEPER_CLIENT_PORT: 2181\n ZOOKEEPER_TICK_TIME: 2000\n ADVERTISED_HOST: zookeeper\n ADVERTISED_PORT: 2181\n extra_hosts:\n - \"moby:127.0.0.1\"\n networks:\n - meetup-net\n\n kafka:\n image: confluentinc/cp-kafka:latest\n depends_on:\n - zookeeper\n ports:\n - \"9092:9092\"\n environment:\n KAFKA_BROKER_ID: 1\n KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181\n KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092\n KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1\n extra_hosts:\n - \"moby:127.0.0.1\"\n networks:\n - meetup-net\n\ncollector:\n image: collector:v1\n environment:\n - kafka-bootstrap-servers=docker_kafka_1.docker_meetup-net\n restart: always\n depends_on:\n - kafka\n networks:\n - meetup-net\nnetworks:\n meetup-net:\n driver: bridge\n\n\nand on the other side I have the application.conf file \n\nstreaming {\n window-size = 50\n window-interval = 5\n\n kafka-bootstrap-servers = ${?kafka-bootstrap-servers}\n kafka-bootstrap-servers = \"localhost:9092\"\n\n sink-topic = ${?source-topic}\n sink-topic = \"meetup\"\n\n key-value-json-path = ${key-value-json-path}\n key-value-json-path = \"./data/keyvalue\"\n\n source-topic-checkpoint-location = ${source-topic-checkpoint-location}\n source-topic-checkpoint-location = \"./target/source-topic\"\n\n sink-topic-checkpoint-location = ${sink-topic-checkpoint-location}\n sink-topic-checkpoint-location = \"./target/sink-topic\"\n}\n\nzookeeper.server = ${?zookeeper-server}\nzookeeper.server = \"localhost:2181\""
] | [
"docker",
"networking",
"apache-kafka",
"docker-compose",
"dockerfile"
] |
[
"How to parse result returned by `ls -l ` using shell command - Android",
"Pls I really need help on how to parse result returned by the \n\" ls -l \" Command\nI really need this to get list and details of private directories ( such as \"/data/data\" dir) in my file manager app after the user has been granted su access \n\nBelow is an example of result expected to be returned after executing the command \ngetRunTime().exec(\"ls -l /data/data\");\n\n> u0_a192@Infinix_X507:/ $ ls -l /storage/sdcard0\ndrwxrwx--- root sdcard_r 2015-08-14 22:23 2go\ndrwxrwx--- root sdcard_r 2015-08-15 11:26 360\ndrwxrwx--x root sdcard_r 2015-08-13 10:25 Android\ndrwxrwx--- root sdcard_r 2015-08-29 21:09 AppProjects\ndrwxrwx--- root sdcard_r 2014-01-01 00:00 Assistant\ndrwxrwx--- root sdcard_r 2015-08-18 10:44 Camera360\ndrwxrwx--- root sdcard_r 2015-08-11 21:29 DCIM\n-rw-rw---- root sdcard_r 808 2015-08-19 05:36 Document.txt\ndrwxrwx--- root sdcard_r 2015-08-30 07:19 Download\ndrwxrwx--- root sdcard_r 2015-08-17 19:25 FM Recording\ndrwxrwx--- root sdcard_r 2015-08-24 17:18 Flash Share\ndrwxrwx--- root sdcard_r 2015-08-24 10:03 KingMaster\ndrwxrwx--- root sdcard_r 2015-08-14 04:39 Kingroot\ndrwxrwx--- root sdcard_r 2015-08-21 06:49 ManifestViewer\ndrwxrwx--- root sdcard_r 2015-08-30 19:25 Movies\ndrwxrwx--- root sdcard_r 2015-08-30 19:25 Music\ndrwxrwx--- root sdcard_r 2015-08-13 06:55 OGWhatsApp\ndrwxrwx--- root sdcard_r 2015-08-23 14:00 OGWhatsApp Old\ndrwxrwx--- root sdcard_r 2015-08-11 17:00 Pictures\ndrwxrwx--- root sdcard_r 2015-08-23 10:59 Rec\ndrwxrwx--- root sdcard_r 2014-01-01 00:00 Ringtones\ndrwxrwx--- root sdcard_r 2015-08-24 17:18 ShareSDK\ndrwxrwx--- root sdcard_r 2015-08-21 14:41 Simple Android Server\ndrwxrwx--- root sdcard_r 2015-08-23 11:19 VidMate\ndrwxrwx--- root sdcard_r 2015-08-14 04:00 WhatsApp\ndrwxrwx--- root sdcard_r 2015-08-30 14:55 Wps\ndrwxrwx--- root sdcard_r 2015-08-30 17:19 bluetooth\ndrwxrwx--- root sdcard_r 2015-08-24 15:11 com.facebook.orca\n-rw-rw---- root sdcard_r 2999645 2015-08-30 14:55 demo.mp4\ndrwxrwx--- root sdcard_r 2015-08-29 17:11 dianxin\ndrwxrwx--- root sdcard_r 2015-08-29 21:29 documents\n-rw-rw---- root sdcard_r 112 2015-08-15 07:41 e_config\ndrwxrwx--- root sdcard_r 2015-08-18 07:00 iQuran\ndrwxrwx--- root sdcard_r 2015-08-23 14:00 icloudzone\ndrwxrwx--- root sdcard_r 2015-08-14 11:53 jamb_cbt_science\n-rw-rw---- root sdcard_r 112 2015-08-13 20:24 kr-stock-conf\ndrwxrwx--- root sdcard_r 2015-08-11 17:45 media\ndrwxrwx--- root sdcard_r 2015-08-23 14:00 mtklog\ndrwxrwx--- root sdcard_r 2014-01-01 01:00 obb\n-rw-rw---- root sdcard_r 1132508 2015-08-14 11:54 pq_commercial.pdf\n-rw-rw---- root sdcard_r 6 2015-08-23 13:44 qs.pid\ndrwxrwx--- root sdcard_r 2015-08-16 07:33 romtoolbox\ndrwxrwx--- root sdcard_r 2015-08-24 10:03 tbslog\ndrwxrwx--- root sdcard_r 2015-08-17 04:25 tencent\n-rw-rw---- root sdcard_r 69565980 2015-08-23 17:01 update.zip\ndrwxrwx--- root sdcard_r 2015-08-14 22:26 viber\n-rw-rw---- root sdcard_r 8514230 2015-08-30 10:43 vlc.apk\nu0_a192@Infinix_X507:/ $\n\n\nI have already seen a similar solution, but was in php using the ftp_rawlist() function, but I want a Java / Android solution please....\n\nI know this would require RegEx or Pattern...etc..\nYour help will be highly appreciated"
] | [
"android",
"shell-exec"
] |
[
"Query postgres database",
"I am doing the function of booking a hotel, when I get the rooms available by date by following\nSELECT * \nFROM oder \nWHERE\n startDate >= '2020-12-26 06:53:18.114+00' AND \n endDate <= '2020-12-30 06:53:18.114+00'\n\nbut it works when i enter the exact start and end date stored in the database, i want when i enter the start and end date time can be within the period stored in the database, I can also get the room that was booked.\nexample: I choose the startDate = 2020-12-27 and the endDate=2020-12-28is within the period of 2020-12-26 to 2020-12-30, I want the result to return like the above query\nSELECT * \nFROM oder \nWHERE\n startDate >= '2020-12-26 06:53:18.114+00' AND\n endDate <= '2020-12-28 06:53:18.114+00'"
] | [
"sql",
"postgresql"
] |
[
"How to make Post Request from Controller in Laravel?",
"I have 2 server, I want when I upload image to server 1 (S1), this image will be upload to server 2 (S2). So i think i need make a POST request from Controller on S1.\n\nFor upload image to another server: i have tried some way as curl, guzzle with no success.\n\nPlease let me know how to make a POST request."
] | [
"laravel",
"http-post"
] |
[
"Angular: Error to POST HTML form (Not ajax) via component after sending 1st Ajax hit? Error:Form submission canceled because the form is not connected",
"I want to submit form to external site by POSTing the input fields in old school way(non Ajax) on paypal.\n\ncode for answer worked for me. https://stackoverflow.com/a/49446910/3326275 . However what I am stuck with is that: I want to hit 1st ajax on My server. Then I have to post the whole form in old way on paypal on success of 1st ajax.\n\nI used following code in HTML(template)\n\n<form (submit)=\"onSubmit($event)\" method=\"POST\" [formGroup]=\"form\" *ngIf='form' action=\"https://www.sandbox.paypal.com/cgi-bin/webscr\" >\n....\n<button class=\"btn btn-green\" [formGroup]=\"form\" type=\"submit\">Pay</button>\n</form>\n\n\nAnd inside component I used m\n\nonSubmit(obj: any) {\n\n if (!this.form.valid) {\n this.helper.makeFieldsDirtyAndTouched(this.form);\n } else {\n this.loader = true;\n // save data in online_payment_ipn\n this.paymentService.saveOnlinePaymentIpn({}, 'paypal')\n .subscribe(response => {\n obj.target.submit();\n }, (err: any) => {\n this.loader = false;\n this.helper.redirectToErrorPage(err.status);\n });\n }\n}\n\n\nThanks in advance!\n\nNow first this form saves data in my site via normal reactive form post(ajax). Now after that I post to 3rd party like paypal whole form in Old way of submitting but I am getting\nWarning and form is not being submitted to paypal, it just does nothing. If I remove this ajax call and only use \n\nobj.target.submit(); \n\nIt works but I want to hit ajax call on my server 1st.\n\n\nForm submission canceled because the form is not connected \n\nAny help is appreciated."
] | [
"javascript",
"angular",
"post",
"angular2-forms",
"angular4-forms"
] |
[
"C/C++: Optimization of pointers to string constants",
"Have a look at this code:\n\n#include <iostream>\nusing namespace std;\n\nint main()\n{\n const char* str0 = \"Watchmen\";\n const char* str1 = \"Watchmen\";\n char* str2 = \"Watchmen\";\n char* str3 = \"Watchmen\";\n\n cerr << static_cast<void*>( const_cast<char*>( str0 ) ) << endl;\n cerr << static_cast<void*>( const_cast<char*>( str1 ) ) << endl;\n cerr << static_cast<void*>( str2 ) << endl;\n cerr << static_cast<void*>( str3 ) << endl;\n\n return 0;\n}\n\n\nWhich produces an output like this:\n\n0x443000\n0x443000\n0x443000\n0x443000\n\n\nThis was on the g++ compiler running under Cygwin. The pointers all point to the same location even with no optimization turned on (-O0).\n\nDoes the compiler always optimize so much that it searches all the string constants to see if they are equal? Can this behaviour be relied on?"
] | [
"c++",
"c",
"optimization",
"string",
"constants"
] |
[
"The complexity of divide-and-conquer algorithms",
"Assume that the size of the input problem increases with an integer n. Let T(n) be the time complexity of a divide-and-conquer algorithm to solve this problem. Then T(n) satisfies an equation of the form:\n\nT(n) = a T(n/b) + f (n).\n\nNow my question is: how can a and b be unequal?\n\nIt seems that they should be equal because the number of recursive calls must be equal to b (size of a sub-problem)."
] | [
"algorithm"
] |
[
"Python 3.4 - updating null values when combing csv (if there is an update)",
"I have written some early code to combine all .xls files in a folder into one csv. I want to run this program once a week to combine all the daily updated .xls reports together.\n\nMy problem is some fields are null until a later spreadsheet fill in the item. For example\n\nSpreadsheet from 24th Spreadsheet from 28th\n\nRepaired Status Repaired Status \nAbuse Abuse\nNFF NFF\n(null) Abuse\nNFF NFF\nAbuse Abuse\n(null) Abuse\n\n\nI thought maybe i should add each spreadsheet filename to a list when its added to csv, then ignore that file next time program runs, then the newest file would overwrite data from the last one. Not sure if this would work or how to do it?\n\nWill the above work or is there another way i can do this?\n\nEdit: As i have had no response, I decided to just not update the row if it had null values, this makes my data is out of date but accurate, \n\nWould still love to hear if anyone knows a way to achieve my question. Thanks."
] | [
"python",
"excel",
"csv",
"pandas",
"python-3.4"
] |
[
"Ionic push not working - user not registered",
"I just had my first contacts with the ionic framework. I've worked with Phonegap and AngularJS before however, so it was not all that new to me.\nI found out that there is this new feature to use Google Cloud Messaging push notifications in Ionic, through the Ionic Push feature (http://blog.ionic.io/announcing-ionic-push-alpha/).\n\nRelated lines of code from app.js\n\nangular.module('starter', ['ionic','ionic.service.core', 'starter.controllers', 'starter.services'])\n\n.run(function($ionicPlatform) {\n $ionicPlatform.ready(function() {\n // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard\n // for form inputs)\n if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {\n cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);\n cordova.plugins.Keyboard.disableScroll(true);\n\n }\n if (window.StatusBar) {\n // org.apache.cordova.statusbar required\n StatusBar.styleLightContent();\n }\n\n // enable push notifications\n Ionic.io(); \n\n // enable users (http://docs.ionic.io/docs/user-quick-start)\n // this will give you a fresh user or the previously saved 'current user'\n var user = Ionic.User.current();\n\n // if the user doesn't have an id, you'll need to give it one.\n if (!user.id) {\n user.id = Ionic.User.anonymousId();\n // user.id = 'your-custom-user-id';\n }\n console.log('user-id:' + user.id);\n\n //persist the user\n user.save();\n\n var push = new Ionic.Push({\n \"debug\": true,\n \"onNotification\": function(notification) {\n var payload = notification.payload;\n console.log(notification, payload);\n },\n \"onRegister\": function(data) {\n console.log(data.token);\n }\n });\n\n push.register(function(token) {\n console.log(\"Device token:\",token.token);\n });\n push.addTokenToUser(user);\n console.log('token added to user');\n\n });\n})\n\n\nLog from ionic serve\n\nionic $ 0 361081 log Ionic Core:, init\n1 361083 log Ionic Core:, searching for cordova.js\n2 361085 log Ionic Core:, attempting to mock plugins\n3 361155 log user-id:1cc3d21c-b687-4988-b944-ad07b1a677c8\n4 361158 log Ionic Push:, a token must be registered before you can add it to a user.\n5 361159 log Ionic Push:, token is not a valid Android or iOS registration id. Cannot save to user.\n6 361159 log token added to user\n7 361160 log Ionic Push:, register\n8 361160 error ReferenceError: PushNotification is not defined, http://localhost:8100/lib/ionic-platform-web-client/dist/ionic.io.bundle.min.js, Line: 2\n9 361526 log Ionic User:, saved user\n\n\nAny input is welcome, I am also more than happy to provide more information if needed.\n\nEDIT 10/05/2015:\n\n\nfound out that dev_push = false only works on physical devices, not in browser\nI tried to add token to user before even registering the user"
] | [
"android",
"angularjs",
"cordova",
"ionic-framework"
] |
[
"libgdx: using camera to test if object out of screen",
"I followed this example to create an object pool of snowflakes. It gets released when it's out of screen.\nMy problem is that I don't have access to the WorldRenderer's camera in order to use: pointInFrustrum(). I worked around that by making the camera static.\nIs there another way of finding out if the the snowflake is out of screen or to get the current positon of the camera? It just seems that this isn't a good solution.\n\nSnowflake.java:\n\n public void update (float delta){\n\n // update snowflake position\n position.add(0, -1*delta*5);\n\n // if snowflake is out of screen, set it to dead\n if(!WorldRenderer.cam.frustum.pointInFrustum(new Vector3(position.x, position.y, 0))) {\n alive = false;\n }\n}\n\n\nThe same problem in World's update method. I need to access the camera to find the y position: \n\n private void updateSnowflakes(float deltaTime) {\n spawnTime += deltaTime;\n if(spawnTime > spawnDelay) {\n spawnTime = 0;\n Snowflake item = snowflakePool.obtain();\n float x = rand.nextFloat() * Helper.FRUSTUM_WIDTH;\n float y = WorldRenderer.cam.position.y + Helper.FRUSTUM_HEIGHT/2;\n item.init(x, y);\n activesSnowflakes.add(item);\n }\n\n int len = activesSnowflakes.size;\n for (int i = len; --i >= 0;) {\n Snowflake item = activesSnowflakes.get(i);\n if (item.alive == false) {\n activesSnowflakes.removeIndex(i);\n snowflakePool.free(item);\n } else {\n item.update(deltaTime);\n }\n }\n}"
] | [
"java",
"libgdx"
] |
[
"iOS 5 remote notification when launching app from dashboard",
"since iOS 5, notifications are no more intrusive as previous. This is nice, but it seems that users prefer to tap directly on app icon from the Dashboard instead of the (small) banner area or notification center.\n\nIn such case, my app cannot get payload from notifications.. Even the 'application didReceiveRemoteNotification' method is not able to get the notification. \n\nHas anyone got the same issue? Do you have any advice?\n\nThanks"
] | [
"notifications",
"ios5",
"payload"
] |
[
"Reusable validation in Blazor WASM",
"I want to ask if there is a way for package the following code into a reusable component.\nThe code is in the event handler of HandleValidSubmit on form submission.\n _accountValidator.ClearErrors();\n if (!string.IsNullOrEmpty(SelectedAgreement.Account))\n {\n if (SelectedAgreement.ProvisionAccountTypeId == (int) ProvisionAccountTypeEnum.CD_IDENT &&\n SelectedAgreement.Account.Length != 5)\n {\n var errors = new Dictionary<string, List<string>>\n {\n {\n nameof(SelectedAgreement.Account),\n new List<string> {"CD Ident requires a 5 digit account number"}\n }\n };\n _accountValidator.DisplayErrors(errors);\n return false;\n }\n\n if (SelectedAgreement.ProvisionAccountTypeId == (int) ProvisionAccountTypeEnum.VP_Account &&\n SelectedAgreement.Account.Length > 15)\n {\n var errors = new Dictionary<string, List<string>>\n {\n {\n nameof(SelectedAgreement.Account),\n new List<string> {"VP Account number has a max length of 15"}\n }\n };\n _accountValidator.DisplayErrors(errors);\n return false;\n }\n }\n\nI know about fluent validation, but I have a lot of code using data attributes."
] | [
"validation",
"blazor-webassembly"
] |
[
"Changing Azure database port",
"Is it possible to change the port that the azure server uses? I currently only see the ability to add IP addresses that can be used to access the server. Or is it required that firewalls allow port 1433 outbound traffic?"
] | [
"azure",
"azure-sql-database"
] |
[
"Changing GMT to EST for Time in Crystal Reports",
"Right now all of my times on my reports are in GMT. Anybody know how to convert this into EST?"
] | [
"datetime",
"crystal-reports"
] |
[
"AVAssetWriter startWriting Cannot call method when status is 3",
"I am working with Video filtering.I used GPUImage from \nBradLarson. It perfect work on Images, but now I am trying to filter video file from Library it give me error [AVAssetWriter startWriting] Cannot call method when status is 3.\nI used IOS7\n\nheare is my code\n\n- (void)viewDidLoad\n{\n [super viewDidLoad];\n videoEditingPlayView = [[GPUImageView alloc] initWithFrame:CGRectMake(60,108,200,200)];\n\n [self.view addSubview:videoEditingPlayView];\n}\n\n-(IBAction)btnEffectsClick:(id)sender{\n NSURL *videoURl = [NSURL fileURLWithPath:self.strVideoURl];\n if (movieFile != nil) {\n videoFilter = nil;\n movieFile = nil;\n }\nmovieFile = [[GPUImageMovie alloc] initWithURL:videoURl];\nmovieFile.runBenchmark = YES;\nvideoFilter = [[GPUImageBrightnessFilter alloc] init];\n[(GPUImageBrightnessFilter *)videoFilter setBrightness:0.0];\n[movieFile addTarget:videoFilter];\nvideoEditingPlayView.hidden = NO;\n\nGPUImageView *filterView = (GPUImageView *)videoEditingPlayView;\n[videoFilter addTarget:filterView];\n\nNSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@\"Documents/Movie.m4v\"];\nNSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];\n\nmovieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480, 360)];\n[videoFilter addTarget:movieWriter];\n\n// movieWriter.\nmovieWriter.shouldPassthroughAudio = YES;\nmovieFile.audioEncodingTarget = movieWriter;\n[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];\n[filterView setFillMode:kGPUImageFillModePreserveAspectRatio];\nfilterView.transform = CGAffineTransformRotate(filterView.transform, 3.14159/2);\n\n\ndouble delayToStartRecording = 0.5;\ndispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, delayToStartRecording * NSEC_PER_SEC);\ndispatch_after(startTime, dispatch_get_main_queue(), ^(void){\n NSLog(@\"Start recording\");\n [movieWriter startRecording];\n\n **[movieFile startProcessing];** ***if I remove this line then it is working but not dispying video on videoEditingPlayView***\n\n\n double delayInSeconds = 30.0;\n dispatch_time_t stopTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);\n dispatch_after(stopTime, dispatch_get_main_queue(), ^(void){\n [filter removeTarget:movieWriter];\n [movieWriter finishRecording];\n\n [videoFilter removeTarget:movieWriter];\n\n movieWriter = nil;\n NSLog(@\"Movie completed\");\n });\n});\n}\n\n\nin coding if I remove this line\n\n[movieFile startProcessing]; \n\nthen app run smoothly, but not displaying video. if I put [movieFile startProcessing] then it crash and give me a error.\n\nI tried this one but can't solved crash.\n\nGPUImage terminates due to [AVAssetWriter startWriting] Cannot call method when status is 3'\n\nhttps://github.com/BradLarson/GPUImage/issues/1228\n\nBlends with GPUImageView are not giving expected result\n\nGPUImageMovieWriter - crashing with "Cannot call method when status is 2"\n\nAnd also other.\n\nThanks."
] | [
"ios",
"video-processing",
"gpuimage"
] |
[
"How I can solve this error on DiscordGuild() dsharpplus",
"I am making a discord bot and now I am making a ban command but I got an error on DiscordGuild().\nMy code looks like this:\n [Command("ban")]\n [Description("Ban user")]\n [RequirePermissions(Permissions.BanMembers)]\n [Hidden]\n public async Task Ban(CommandContext ctx,\n [Description("User banned")] DiscordMember member, \n [Description("How many days will ban take?")] int days, \n [RemainingText, Description("Reason")] string reason)\n {\n await ctx.TriggerTypingAsync();\n DiscordGuild guild = new **DiscordGuild()**;\n guild = member.Guild;\n try\n {\n await guild.BanMemberAsync(member, days, reason);\n await ctx.RespondAsync($"User @{member.Username}#{member.Discriminator} was excluded by the ADMIN {ctx.User.Username}");\n }\n catch (Exception)\n {\n await ctx.RespondAsync($"User {member.Username} cannot be blocked");\n }\n }\n\nand I have this error: 'DiscordGuild' does not contain a constructor that takes 0 arguments.\nWhat I have to do to make my code working?\nHelp me, please!"
] | [
"c#",
"discord"
] |
[
"openframeworks, addons, and mavericks on osx",
"I had developed an app in openframeworks for OSX Mountain Lion using the addons ofxUI, ofxFFT, and ofxXmlSettings. \n\nIt worked beautifully. But recently I switched over to OSX 10.9 and now my code still compiles but errors immediately upon running.\n\n2014-03-23 19:33:24.489 etaBasement_debug[47594:507] -[__NSCFError _cocoaErrorStringWithKind:]: unrecognized selector sent to instance 0x7b61a060\n\n\nI can't really find what I need on Google. If anyone knows how to fix this issue or if I need to give more information, please let me know."
] | [
"c++",
"macos",
"osx-mavericks",
"add-on",
"openframeworks"
] |
[
"excel formula, updating value and checking",
"I'm really new to excel but I have programming experience. I am trying to do the following function, but I dont really know how I could declare a variable and change it as I go. This would be a pseudocode. This is a hypothetical scenario to what I am trying to achieve:\nnewName = ""\n\nif (change == "yes")\nnewName = origName\ncolumn3 = newName\n\nif (origName contains newName && change != "yes")\ncolumn3 = newName\nelse\ncolumn3 = origName\n\n**What I mean by contain is that for example, if origName is "paper towel" and newName is "paper" then origName contains newName because of "paper"\nSo basically there are three columns containing strings: origName, change and Column3\nI want to create a program that keeps writing the same in origName in Column3 UNTIL change equals "YES". When this happens, I want to store the origName (in which changes equals "YES") into a variable name newName. After that, I want to keep checking the following rows if the origName contains the same name as newName, and write newName into Column3 if it does. It will keep checking rows until it gets to another row in which change will equal YES and newName will be set to the corresponding origName, and keep the process going. Something like this:"
] | [
"excel",
"vba",
"excel-formula"
] |
[
"i have a problem in calculating distance between starting and ending point",
"this is the code of simulating 3d random walking with self avoiding. I want to calculate Rg (root of square x plus z plus y) and then plot the log Rg-log N(number of steps). how can I fix the code?\n'\nclear all\nclc\na = 1 ; % Step size\nN = 2 ; % Number of Random Walks\nS = 100 ; % Number of steps\nrandWalkMat = [...\n 1 -1 0 0 0 0;\n 0 0 1 -1 0 0;\n 0 0 0 0 1 -1;\n ];\nX = zeros(S,N);\nY = X; \nZ = X; \nfor k = 1:N\n t = randi(6, 1, S);\n randWalk = randWalkMat(:, t);\n X(:,k) = randWalk(1,:);\n Y(:,k) = randWalk(2,:);\n Z(:,k) = randWalk(3,:);\nend\n% Now we have the data for N number individual random seeds, and\n% we have it for S number of steps:\n% we get N sets of data for S random steps:\nx_final = [[0,0];cumsum(X)];\ny_final = [[0,0];cumsum(Y)];\nz_final = [[0,0];cumsum(Z)];'"
] | [
"matlab"
] |
[
"files produced by asset:precompile don't match urls generated by stylesheet_link_tag (missing digest) in minimal rails 4 site",
"I'm using Ruby 2.0.0-p247 and Rails 4.0.0\n\nIf I make a minimal Rails 4 site like this:\n\nrails new minimal\ncd minimal\nrails generate controller home index\ntee config/routes.rb <<EOF\nMinimal::Application.routes.draw do\n root 'home#index'\nend\nEOF\n\n\nThen precompile the assets with\n\nrake assets:precompile\n\n\nIt generates assets like:\n\nI, [2013-09-04T17:05:36.992951 #3549] INFO -- : Writing /WORKINGDIR/minimal/public/assets/application-723d1be6cc741a3aabb1cec24276d681.js\nI, [2013-09-04T17:05:37.052303 #3549] INFO -- : Writing /WORKINGDIR/minimal/public/assets/application-f1a14051f17824976271b9c0460232f0.css\n\n\nBut if I start the server in production mode, with\n\nRAILS_ENV=production rails s\n\n\nThe generated URLs in the HTML don't point at the precompiled files:\n\n<link data-turbolinks-track=\"true\" href=\"/stylesheets/application.css\" media=\"all\" rel=\"stylesheet\" />\n<script data-turbolinks-track=\"true\" src=\"/javascripts/application.js\"></script>\n\n\nI would expect, rather:\n\n<link data-turbolinks-track=\"true\" href=\"assets/application-f1a14051f17824976271b9c0460232f0.css\" media=\"all\" rel=\"stylesheet\" />\n<script data-turbolinks-track=\"true\" src=\"/assets/application-723d1be6cc741a3aabb1cec24276d681.js\"></script>\n\n\nThe default config/environments/production.rb settings say to use digests:\n\nconfig.assets.digest = true\n\n\nBut it seems to be selectively ignored?\n\nAm I missing something?\n\nUPDATE:\n\nI just tested this in Rails 4.2.3 and this appears to be fixed, however we need to hand a few more environment variables into the rails s command to start in production mode:\n\nSECRET_KEY_BASE=$(rake secret) RAILS_SERVE_STATIC_FILES=true RAILS_ENV=production rails s"
] | [
"ruby-on-rails",
"asset-pipeline",
"ruby-on-rails-4"
] |
[
"Common supertype bound fails with type class resolution",
"When I have a generic class like this\n\ncase class C [E] (errors : Seq[E]){\n def merge [E1 <: EX, EX >: E] (errors1 : Seq[E1]) = Seq[EX]() ++ errors ++ errors1\n}\n\n\neverything works - it merges sequences of errors into a sequence of common supertype. However when I mix this with the type class pattern it does not infer the common supertype correctly. \n\nI have implemented HList application according to this approach and it works by itself. Now I want to use it for building argument list where each argument may fail. Finally I want to be able to apply this argument list to a function which may fail itself. So the output errors sequence type should be supertype of the list errors and function errors. (The next step would be to lift the restriction that the function must return ErrorProne and flatten it via some typeclass but I consider this a more simple case.) The failing argument list wrapper goes like this. Notice that the :: method works. \n\ncase class SuccessArgList [E, L <: HList[L]] (list : L) extends ArgList[E, L] {\n\n override def apply[S, E1 <: EX, EX >: E, F](fun : F)(implicit app : HApply[L, F, ErrorProne[E1, S]]) \n : ErrorProne[EX, S] = app.apply(list, fun)\n\n override def :: [A, E1 <: EX, EX >: E] (argument : ErrorProne[E1, A]) : ArgList[EX, A :: L] = argument match {\n case Success(a) => SuccessArgList(a :: list)\n case Failure(e) => FailureArgList(e)\n }\n\n}\n\n\nwhere E is type of error of current failing argument list, L is the the type of actual argument list, S is the function success value type, E1 is the function failure value type, EX should be common supertype of the errors and F is the function.\nThe fail list goes similarily and the ErrorProne container is like this (I could probably use Either but that should not be relevant)\n\nsealed trait ErrorProne[+F, +S]{\n def f[To] (implicit flatrener : FlattenErrorProne[ErrorProne[F, S], To]) = flatrener.flatten(this)\n}\n\ncase class Success [+F, +S] (result : S) extends ErrorProne[F, S]\n\ncase class Failure [+F, +S] (errors : Seq[F]) extends ErrorProne[F, S]\n\n\nWhen trying to use the apply method of the argument list type arguments are inferred wrong determining the E1 to E, therefore the application is not found. Can the inference be fixed? Are there materials on rules by which the inference goes? I cannot find any specification."
] | [
"scala",
"generics",
"type-inference",
"typeclass"
] |
[
"Pause and Resume CasperJS, PhantomJS Script",
"I am using in PHP the library PhantomJS with CasperJS for automatize a web workflow.\n\nHow Can I \"Pause\" the script, saving all the resource, do something with the content and after resume it?\n\nExample: \n1 - load a website.\n2 - get info of the page, exit the script and do your stuff in php for example.\n3 - go back to the same page without reloading it, and continue javascript and navigation.\n\nRight now I have to reask for the last page, and that is the problem."
] | [
"javascript",
"php",
"phantomjs",
"casperjs"
] |
[
"Run-time error 1004 when using Offset function",
"How do I retrieve the cell next to the one that has been defined? Cell \"A2\" stores AT and I want to display Austria which i have displayed in cell \"B2\" instead of AT. I need this functionality in a For loop.\n\nAT Austria\nIT Italy\nFR France\n\n\nI need to do the For loop using AT (for other purposes) but i want to write away the country name (Austria or Italy etc)\n\nThe macro below gives run-time error 424 Object required.\n\nSub test()\n Dim country\n Dim country_list\n Dim counter\n\n country_list = Worksheets(\"Sheet1\").Range(\"A2:A4\")\n counter = 1\n\n For Each country In country_list\n Worksheets(\"Sheet2\").Cells(counter, 1).Value = country.Offset(0, 1).Value\n counter = counter + 1\n Next country\nEnd Sub"
] | [
"vba"
] |
[
"Find the sum of all numbers between 1 and N divisible by either x or y",
"Say we have 3 numbers N, x and y which are always >=1.\n\nN will be greater than x and y and x will be greater than y.\n\nNow we need to find the sum of all number between 1 and N that are divisible by either x or y.\n\nI came up with this:\n\nsum = 0;\nfor(i=1;i<=N;i++)\n{\n if(i%x || i%y)\n sum += i;\n}\n\n\nIs there a way better way of finding the sum avoiding the for loop?\n\nI've been pounding my head for many days now but have not got anything better.\n\nIf the value of N has a upper limit we can use a lookup method to speedup the process.\n\nThanks everyone.\n\nI wanted a C/C++ based solution. Is there a built-in function to do this? Or do I have to code the algorithm?"
] | [
"c++",
"c",
"algorithm",
"puzzle"
] |
[
"How to select/highlight next row in TableView (JAVAFX)",
"I'm making a media player in JavaFX. I'm displaying the songs in a TableView object. And whenever I press the Skip button, I would like it to highlight the next row, so that the user can see which song from the playlist, that he is listening to. \n\nThis is the code for the TableView. \n\nI would like it to get the selected element, and then select/highlight the next element for me, whenever a certain method gets invoked. \n\n @FXML\nprivate TableView<Song> defaultTableView;\n\n// 1) Song Title\n\n@FXML\nprivate TableColumn<Song, String> songTitleColumn;\n\n// 2) Song artist\n\n@FXML\nprivate TableColumn<Song, String> songArtistColumn;\n\n// 3) Song album\n@FXML\nprivate TableColumn<Song, String> songAlbumColumn;"
] | [
"java",
"javafx",
"tableview"
] |
[
"How to determine what has gone wrong with apache",
"Hi all I have changed some apache configuration files and when I run rcapache2 restart it displays the error\nJob failed. See system logs and 'systemctl status' for details.\n\nI then run the command systemctl status httpd.service\nand it displays the error\n\n\n httpd.service\n Loaded: error (Reason: No such file or directory)\n Active: inactive (dead)\n\n\nHow do I find out which file or directory it can't find. I've looked at the error log but it doesn't say anything."
] | [
"apache"
] |
[
"Multiply arrays in a list",
"I have a list of arrays with the same shape, like this:\n\nmy_list = [arr_1, arr_2, arr_3, ...]\n\narr_1.shape\n(1988, 1221)\n...\n\n\nIs there a way to multiply every array in my list and get a final array with the same shape?\n\nI've tried this way but it doesn't work:\n\nfor i in my_list:\n arr_final = np.multiply(my_list[i])\n\n\n\nThe final array should be the same of every array in the initial list.\n\narr_final.shape\n(1988, 1221)"
] | [
"arrays",
"python-3.x",
"numpy"
] |
[
"Converting XML to JSON using GSON in PI Java Mapping",
"I am facing issue while converting the source xml into JSON using the GSON library. Please find below the code, source xml and output. I am implementing this in java mapping of SAP PI where i am getting source xml as input to this java code.\n\nSource XML:\n\n<data>\n<ERP>0080001</ERP>\n<Shiptoparty>0088000</Shiptoparty>\n<Shippingpoint>503</Shippingpoint>\n<Issuedate>20181102</Issuedate>\n<products>\n<Unit>L</Unit>\n<QTY>2.000 </QTY>\n<SKUno>000000000011</SKUno>\n</products>\n<products>\n<Unit>L</Unit>\n<QTY>0.000 </QTY>\n<SKUno>000000000011000078</SKUno>\n</products>\n</data>\n\n\nCode:\n\npackage xmlgsonjson;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\n\nimport com.google.gson.Gson;\nimport com.google.gson.GsonBuilder;\nimport com.sap.aii.mapping.api.AbstractTransformation;\nimport com.sap.aii.mapping.api.StreamTransformationException;\nimport com.sap.aii.mapping.api.TransformationInput;\nimport com.sap.aii.mapping.api.TransformationOutput;\n\npublic class MakeItJSONByGSON extends AbstractTransformation \n{\n\npublic String targetfile =\"\";\n\npublic MakeItJSONByGSON() {}\n\npublic void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException\n{\ntry {\n String sourcexml = \"\";\n\n String line = \"\";\n\n\n InputStream inputstream = in.getInputPayload().getInputStream();\n BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));\n OutputStream outputstream = out.getOutputPayload().getOutputStream();\n\n byte[] b = null;\n try {\n b = new byte[inputstream.available()];\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n try {\n inputstream.read(b);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n String inputContent = new String(b);\n\n\n\n\n sourcexml = inputContent;\n\n\n\n try {\n while ((line = br.readLine()) != null) {\n\n sourcexml = sourcexml + line;\n\n\n }\n } catch (IOException e1) {\n // TODO Auto-generated catch block\n e1.printStackTrace();\n }\n\n Gson gson = new GsonBuilder().setPrettyPrinting().create();\n\n String jsonPrettyPrintString = gson.toJson(sourcexml);\n\n\n targetfile = jsonPrettyPrintString;\n\n\nout.getOutputPayload().getOutputStream().write(targetfile.getBytes());\n}\ncatch (Exception e)\n{\ne.printStackTrace();\n}\n}\n}\n\n\nOutput:\n\n\"\\u003cdata\\u003e\\n \\u003cERP\\u003e0080001\\u003c/ERP\\u003e\\n \\u003cShiptoparty\\u003e0088000\\u003c/Shiptoparty\\u003e\\n \\u003cShippingpoint\\u003e503\\u003c/Shippingpoint\\u003e\\n \\u003cIssuedate\\u003e20181102\\u003c/Issuedate\\u003e\\n \\u003cproducts\\u003e\\n \\u003cUnit\\u003eL\\u003c/Unit\\u003e\\n \\u003cQTY\\u003e2.000 \\u003c/QTY\\u003e\\n \\u003cSKUno\\u003e000000000011\\u003c/SKUno\\u003e\\n \\u003c/products\\u003e\\n \\u003cproducts\\u003e\\n \\u003cUnit\\u003eL\\u003c/Unit\\u003e\\n \\u003cQTY\\u003e0.000 \\u003c/QTY\\u003e\\n \\u003cSKUno\\u003e000000000011000078\\u003c/SKUno\\u003e\\n \\u003c/products\\u003e\\n \\u003c/data\\u003e\"\n\n\nExpected Output:\n\n{\"data\": [\n {\n \"ERP\": 0080001,\n \"Issuedate\": 20181102,\n \"Shippingpoint\": 503,\n \"Shiptoparty\": 0088000,\n \"products\": [\n {\n \"Unit\": \"L\"\n \"QTY\": 2.000,\n \"SKUno\": 000000000011, \n },\n {\n \"Unit\": \"L\"\n \"QTY\": 0.000,\n \"SKUno\": 000000000011000078,\n\n }\n ]\n }\n\n]}\n\n\nKindly let me know how to resolve this issue."
] | [
"json",
"gson",
"sap",
"sap-xi",
"sap-pi"
] |
[
"PySpark: Groupby on multiple columns with multiple functions",
"I am running PySpark with Spark 2.0 to aggregate data. \nBelow is the raw Dataframe (df) as received in Spark. \n\nDeviceID TimeStamp IL1 IL2 IL3 VL1 VL2 VL3\n1001 2019-07-14 00:45 2.1 3.1 2.25 235 258 122\n1002 2019-07-14 01:15 3.2 2.4 4.25 240 250 192\n1003 2019-07-14 01:30 3.2 2.0 3.85 245 215 192\n1003 2019-07-14 01:30 3.9 2.8 4.25 240 250 192\n\n\nNow I want to apply groupby logic by DeviceID. There are several posts there in StackOverflow. Particularly, This and this links are of point of interest. With the help of those posts I created the following script\n\nfrom pyspark.sql import functions as F\ngroupby = [\"DeviceID\"]\nagg_cv = [\"IL1\",\"IL2\",\"IL3\",\"VL1\",\"VL2\",\"VL3\"]\nfunc = [min,max]\nexpr_cv = [F.f(F.col(c)) for f in func for c in agg_cv]\ndf_final = df_cv_filt.groupby(*groupby).agg(*expr_cv)\n\n\nThe above code is showing error as \n\nColumns are not iterable \n\n\nNot able to understand why such error is coming. When I am using the following code \n\nfrom pyspark.sql.functions import min, max, col\nexpr_cv = [f(col(c)) for f in func for c in agg_cv]\n\n\nThen the above code is running fine. \n\nMy question is: how can I fix the above mentioned error."
] | [
"python",
"apache-spark",
"pyspark"
] |
[
"How to print contents of a class object by field?",
"I have a POJO class, Location that is used to map a JSON file to a class using Jackson. The current implementation can print out every Location object in the class by calling,Location's toString() but I'm wondering how I can print for example, just the location with id= \"2\", which would be name=\"Desert\"\n\nAt the moment, I use a toString method like this to print all the contents of Location:\n\npublic String toString() {\n return \"Location [location=\" + Arrays.toString(location) + \", id=\" + id\n + \", description=\" + description + \", weight=\" + weight\n + \", name=\" + name + \", exit=\" + Arrays.toString(exit)\n +\"]\";\n }\n\n\nDoes anyone know how I can print specific locations within the Location object based on a field id?\n\nThis is an example of what is stored in the Location class when I call toString() on it:\n\nhttp://hastebin.com/eruxateduz.vhdl\n\nAn example of one of the Locations within the Location object:\n\n[Location [location=null, id=1, description=You are in the city of Tiberius. You see a long street with high buildings and a castle.You see an exit to the south., weight=100, name=Tiberius, exit=[Exit [title=Desert, direction=South]]]\n\n\nThis is the POJO location class I use to map the JSON fields to the class:\n\npublic class Location {\n\n private Location[] location;\n\n private int id;\n\n private String description;\n\n private String weight;\n\n private String name;\n\n private Exit[] exit;\n\n private boolean visited = false;\n private boolean goalLocation;\n private int approximateDistanceFromGoal = 0;\n private Location parent;\n\n\n\n\n public Location[] getLocation() {\n return location;\n }\n\n public void setLocation(Location[] location) {\n this.location = location;\n }\n\n\n public int getId() {\n return id;\n }\n\n public void setId(int id) {\n this.id = id;\n }\n\n public String getDescription ()\n {\n return description;\n }\n\n public void setDescription (String description)\n {\n this.description = description;\n }\n\n\n public String getWeight() {\n return weight;\n }\n\n public void setWeight(String weight) {\n this.weight = weight;\n }\n\n public String getName ()\n {\n return name;\n }\n\n public void setName (String name)\n {\n this.name = name;\n }\n\n public Exit[] getExit() {\n return exit;\n }\n\n public void setExit(Exit[] exit) {\n this.exit = exit;\n }\n\n\n public boolean isVisited() {\n return visited;\n }\n\n public void setVisited(boolean visited) {\n this.visited = visited;\n }\n\n public boolean isGoalLocation() {\n return goalLocation;\n }\n\n public void setGoalLocation(boolean goalLocation) {\n this.goalLocation = goalLocation;\n }\n\n public int getApproximateDistanceFromGoal() {\n return approximateDistanceFromGoal;\n }\n\n public void setApproximateDistanceFromGoal(int approximateDistanceFromGoal) {\n this.approximateDistanceFromGoal = approximateDistanceFromGoal;\n }\n\n public Location getParent() {\n return parent;\n }\n\n public void setParent(Location parent) {\n this.parent = parent;\n }\n\n @Override\n public String toString() {\n return \"Location [location=\" + Arrays.toString(location) + \", id=\" + id\n + \", description=\" + description + \", weight=\" + weight\n + \", name=\" + name + \", exit=\" + Arrays.toString(exit)\n +\"]\";\n }\n\n\n\n}"
] | [
"java",
"json",
"jackson",
"pojo"
] |
[
"Service property not updating consistently",
"So this one may be a little involved. The full app, if you get really stumped and want to run it for yourself, is on github. \n\n(If you do, you'll need to login, username and password is in API/tasks/populate.rake... just don't tell anyone else, k?)\n\nI'm using Ember State Services to keep track of the isClean state of an editor component (which is using hallo.js).\n\nHere's some sample code, with the scenario, and the problem I'm having with it:\n\nWhen the content in the editor is changed, hallo.js fires a hallomodified event. In the component's didInsertElement hook, I'm attaching a jquery event listener, which sets the isClean property to false, and logs it to the console so we can check it's actually working:\n\n\n\nJfEdit = Ember.Component.extend\n editorService: Ember.inject.service('jf-edit')\n editorState: Ember.computed('page', ->\n @editorService.stateFor(@page) # page is passed in to the component \n # in the route template\n ).readOnly()\n # ...\n didInsertElement: ->\n self = @\n @$().on(\"hallomodified\", -> \n console.log \"modified\"\n self.get('editorState.isClean') = false\n console.dir self.get('editorState') # -> Logs: Class -> __ember123456789:null, \n # isClean: false \n # in the console (but I have to click on \n # isClean to show the value)\n ).hallo(\n # ...\n )\n\n`export default JfEdit`\n# Full code is at https://github.com/clov3rly/JoyFarm/blob/master/app/app/components/jf-edit.em \n# (written in emberscript, which is an adaptation of coffeescript)\n\n\nThis seems to work, editorState.isClean = false in the console.\n\nSo then, when we attempt to transition away from the page, we check the editor state, in order to prompt the user to save.\n\nNewPostRoute = Ember.Route.extend\n model: ->\n @*.store.createRecord 'post', \n title: \"New Post\"\n content: \"Content here.\"\n editorService: Ember.inject.service('jf-edit')\n editorState: Ember.computed('model', ->\n @editorService.stateFor(@model)\n ).readOnly().volatile()\n actions:\n willTransition: (transition) ->\n model = @modelFor('posts/new')\n console.log \"editorState:\", @get('editorState.isClean')\n # -> logs true, after the log in \n # the file above logged false.\n console.dir @get('editorState') # -> Logs: Class ->\n # __ember123456789:null\n # (the same number as above) \n # but the isClean property is\n # not in the log statement\n # ... \n\n unless @get('editorState.isClean')\n confirm(\"Do you want to discard your changes?\") || transition.abort()\n\n# Full code at https://github.com/clov3rly/JoyFarm/blob/master/app/app/routes/posts/new.em\n\n\nSo now, editorState.isClean is returning false (and not showing up when logging the object itself). However, the first property of the object has the same key, which I'm assuming is an ember ID of some sort?\n\nThe template looks like this:\n\n{{{jf-edit page=model save=\"save\" class=\"blog editor\"}}}\n\n\nSo, page in the component/jf-edit file should be the same object as model in the routes/new file.\n\nThe service/state files are pretty simple, if you want to see them, you can find them in this gist (or in the repo itself)."
] | [
"javascript",
"jquery",
"ember.js",
"coffeescript"
] |
[
"Starting Sails.js inside a Docker container causes a Grunt error",
"I'm creating a Sails.js + MongoDB application and using Docker to run them locally. This is what my Docker setup looks like:\n\nDockerfile\n\nFROM node:8.9.3-alpine\nLABEL Name=web-service Version=1.0.0\n\n# Container configuration\nENV NODE_ENV development\nWORKDIR /usr/src/app\nCOPY [\"package.json\", \"npm-shrinkwrap.json*\", \"./\"]\nRUN npm install -g [email protected] grunt nodemon && npm install && mv node_modules ../\nVOLUME /usr/src/app\nEXPOSE 1337\nCMD nodemon\n\n\ndocker-compose.yml\n\nversion: '3.4'\n\nservices:\n web-service:\n image: web-service:latest\n build: .\n environment:\n NODE_ENV: development\n ports:\n - 1338:1337 # HOST_PORT is 1338 to avoid conflicts with other Sails.js apps running on host\n volumes:\n - type: volume\n source: .\n target: /usr/src/app\n read_only: true\n\n mongoDb:\n image: mongo:3.6\n ports:\n - 27018:27017 # HOST_PORT is 27018 to avoid conflicts with other MongoDB databases running on host\n volumes:\n - ./volumes/mongodb:/data/db\n\n\nMy image builds just fine however, when I run docker-compose up, I see the following error:\n\nweb-service_1 | [nodemon] starting `node app.js`\nweb-service_1 | info:\nweb-service_1 | info: .-..-.\nweb-service_1 | info:\nweb-service_1 | info: Sails <| .-..-.\nweb-service_1 | info: v0.12.4 |\\\nweb-service_1 | info: /|.\\\nweb-service_1 | info: / || \\\nweb-service_1 | info: ,' |' \\\nweb-service_1 | info: .-'.-==|/_--'\nweb-service_1 | info: `--'-------'\nweb-service_1 | info: __---___--___---___--___---___--___\nweb-service_1 | info: ____---___--___---___--___---___--___-__\nweb-service_1 | info:\nweb-service_1 | info: Server lifted in `/usr/src/app`\nweb-service_1 | info: To see your app, visit http://localhost:1337\nweb-service_1 | info: To shut down Sails, press <CTRL> + C at any time.\nweb-service_1 |\nweb-service_1 | debug: -------------------------------------------------------\nweb-service_1 |\nweb-service_1 | debug: :: Wed Jan 10 2018 18:37:23 GMT+0000 (UTC)\nweb-service_1 | debug: Environment : development\nweb-service_1 | debug: Port : 1337\nweb-service_1 | debug: -------------------------------------------------------\nweb-service_1 |\nweb-service_1 |\nweb-service_1 | error:\nweb-service_1 | ------------------------------------------------------------------------\nweb-service_1 | Fatal error: Unable to create directory \"/usr/src/app/.tmp\" (Error code: EROFS).\nweb-service_1 | Running \"less:dev\" (less) task\nweb-service_1 | ------------------------------------------------------------------------\nweb-service_1 | error: Looks like a Grunt error occurred--\nweb-service_1 | error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)\nweb-service_1 | error: Or if you're stuck, check out the troubleshooting tips below.\nweb-service_1 | error: Troubleshooting tips:\nweb-service_1 | error:\nweb-service_1 | error: *-> Are \"grunt\" and related grunt task modules installed locally? Run `npm install` if you're not sure.\nweb-service_1 | error:\nweb-service_1 | error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.\nweb-service_1 | error:\nweb-service_1 | error: *-> Or maybe you don't have permissions to access the `.tmp` directory?\nweb-service_1 | error: e.g., `/usr/src/app/.tmp` ?\nweb-service_1 | error:\nweb-service_1 | error: If you think this might be the case, try running:\nweb-service_1 | error: sudo chown -R YOUR_COMPUTER_USER_NAME /usr/src/app/.tmp\n\n\nIf I understand correctly, Grunt and my packages from package.json should be installed because the image builds just fine. Could this be an issue with permissions as it says in the error above? If yes, how do I CHOWN the folder inside my container? Thanks."
] | [
"node.js",
"docker",
"sails.js"
] |
[
"How to run app as jar in IDE, but package with maven as war?",
"I have an application with a normal main method, running as a normal jar within my IDE. It's a spring-boot application that runs on an embedded tomcat by default.\n\nTo package it as war file with maven is as simple as:\n\n<packaging>war</packaging>\n ...\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-tomcat</artifactId>\n <scope>provided</scope>\n </dependency>\n\n\nProblem: I'd still would like to run the app locally in my IDE embedded. Thus exclude the dependency above, and leave packaging to >jar<.\n\nQuestion: is it possible to eg define profiles in maven, so that by default the packaging is =jar, but when running a specific profile it is exchanged with war and the tomcat server dependency is included?"
] | [
"java",
"spring",
"maven",
"tomcat",
"spring-boot"
] |
[
"textFieldShouldReturn does not get called (textField loaded programmatically)",
"I'm currently loading a -UITextField programmatically and trying to make the keyboard go down once I click on 'Search'.\n\nI declare the -UITextFeild inside the .m file as \nUITextField *searchTextField;\n\nInside the .h file I do indeed declare the -UITextField's delegate\n\n@interface firstChannel : UIViewController<LBYouTubePlayerControllerDelegate, UITableViewDelegate,UITableViewDataSource, NSXMLParserDelegate, UITextFieldDelegate, AVPlayerItemOutputPullDelegate>{\n\n\nThis is how I add the UITextField programmatically.\n\n searchTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, -26, 300, 30)];\n searchTextField.borderStyle = UITextBorderStyleRoundedRect;\n searchTextField.font = [UIFont fontWithName:@\"Heiti TC\" size:13];\n searchTextField.autocorrectionType = UITextAutocorrectionTypeNo;\n searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing;\n searchTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;\n searchTextField.placeholder = @\"Search on the Channel\";\n searchTextField.borderStyle = UITextBorderStyleNone;;\n searchTextField.textAlignment = UITextAlignmentCenter;\n searchTextField.center = CGPointMake(160, 43);\n searchTextField.textColor = [UIColor colorWithRed:(232.0/255.0) green:(232.0/255.0) blue:(232.0/255.0) alpha:(100.0/100.0)];\n searchTextField.clearButtonMode = UITextFieldViewModeNever;\n searchTextField.returnKeyType = UIReturnKeySearch;\n [searchTextField setKeyboardAppearance:UIKeyboardAppearanceAlert];\n [self.view.window addSubview:searchTextField];\n [searchTextField becomeFirstResponder];\n\n\nI added the delegate inside -viewDidLoad\n\nsearchTextField.delegate = self;\n\n\nHowever when I click on \"Search\" on the keyboard nothing happens. I'm unsure why that's happening I've even debugged it by logging something once you hit returns but nothing happens."
] | [
"ios",
"objective-c",
"uitextfield"
] |
[
"C: Writing a loop to print the alphabet between two characters",
"I've been given the pretty simple task of writing a program that will take two characters and then print the letters inbetween them using a for() loop.\n\nHere's my code:\n\n#include <stdio.h>\nint main() {\nchar a, b;\n\nprintf(\"\\nEnter the first character: \");\nscanf(\"%c\", &a);\n\nprintf(\"\\nEnter the second character: \");\nscanf(\"%c\", &b);\n\nfor(char i = a; i <= b; i++) {\n printf(\"%c \", i);\n}\n\nreturn 0;\n}\n\n\nWhen I run it, I am prompted to enter the first character correctly but when I press enter it only runs the next printf() and then terminates.\n\nNo errors or warnings or anything on compilation. Another similar question I found that was apparently solved does not work for me either.\n\nThanks in advance."
] | [
"c"
] |
[
"Change color of h value",
"I set my mask from BGR2HSV. I have my image:\n\nHow I can change the white color in the mask? So I want to change the white parts with other colors.\nMat mask;\nmask = imread("C:\\\\Users\\\\...\\\\Desktop\\\\...\\\\mask.png");\nif (!img.data)\n{\n cout << "Could not find the image";\n return -1;\n}\n\ncvtColor(mask, mask, COLOR_BGR2HSV);\n\n\n\ncvtColor(mask, mask, COLOR_HSV2BGR);\n\n\nimshow("Ergebnis", mask);\nwaitKey(0);"
] | [
"c++",
"opencv",
"hsv"
] |
[
"Observer Pattern in networking",
"I can't figure out how observer pattern is used on the client-server program in java. Please who can give me information about this ."
] | [
"java",
"networking",
"client-server",
"observer-pattern"
] |
[
"Apostrophe cms copied widgets get lots of you were unable to take control errors",
"Most of the time Apostrophe behaves itself until you start to copy widgets or include pieces that have widgets embedded in them. I can't replicate this behaviour on demand but it comes soon enough if I copy a widget using the clone button on the apos control, have a copied widget or I insert a piece that has a bunch of cloned widgets within. \n\nIf I refresh the page problem goes away for a while then all of a sudden I can't take control of the document/widget/piece again. (always.js 289) To be clear I am the only one working on the page/widget/piece so it shouldn't be a locking issue although it presents itself as one.\n\nI designed on the basis that widgets can be stacked on other widgets and repeat as often as needed. Widgets can be replicated or added to a piece for use as \"Reusable Content with pieces\" this isn't working out like that at all! \n\nI feel almost certain that this question will require further clarification of as it would seem I can't communicate well enough for the Apostrophe team for any of the questions I have posed so far!\n\nHave I totally ignored something in the docs?\nWhy do I need to reload the page so often to make things act like they should?\n\nI really like the general design, but I'm feeling slightly worried about the lack of basic question understanding and the general; oh we join to so many things its too complicated responses I see all over the web."
] | [
"apostrophe",
"apostrophe-cms"
] |
[
"How to update inputs based on a modal selection",
"I'm currently working with Laravel Framework. I send all the records from one user about events, but if the user has more than one record of event then he needs to choose which event he would like to edit, i've already created the modal that shows all the events, but how can I obtain the selected event and fill all the inputs with that specific event? \nHere is my code\n\nController\n\npublic function dashboardEvents(){ \n//Brings all the info from the user events \n$data['events'] = UserEvent::where('user_id', Auth::user()->id)->get(); \n//This is to know if there's more than one record\nif(UserEvent::where('user_id', Auth::user()->id)->get()->count()>1) { \n $data['multiple'] = true; \n} else { \n $data['multiple'] = false; \n} \nreturn view('user-pages/my-events', $data); \n\n\n} \n\nView\n\n<title>User Dashboard</title>\n<body class=\"html not-front not-logged-in no-sidebars page-node page-\n\n<!-- Al the Inputs -->\n<select class=\"form-control\" style=\"margin-bottom: 15px;\" id=\"user_roles\">\n <option value=\"bride\">I am a bride</option>\n <option value=\"groom\">Im a groom</option>\n <option value=\"groomsman\">Im a guest</option>\n <option value=\"wedding_planner\">Im a wedding planner</option>\n</select>\n\n<input type=\"text\" class=\"form-control\" style=\"margin-bottom: 15px;\">\n <div class=\"input-group date\" data-provide=\"datepicker\" style=\"margin-bottom: 15px;\">\n <input type=\"text\" class=\"form-control\">\n <div class=\"input-group-addon\">\n <span class=\"glyphicon glyphicon-th\"></span>\n </div>\n</div>\n\n<select class=\"form-control\" style=\"margin-bottom: 15px;\" id=\"party-type\">\n <option id=\"wedding\">Wedding</option>\n <option id=\"party\">Party</option>\n <option id=\"prom\">Prom</option>\n</select>\n\n<select class=\"form-control\" style=\"margin-bottom: 15px;\" id=\"user-task\">\n <option>I am shopping for just Groomsmen</option>\n <option>I am shopping for me</option>\n</select>\n\n<input type=\"text\" class=\"form-control\" id=\"phone_number_user\" style=\"margin-bottom: 15px;\">\n\n<input type=\"text\" class=\"form-control\" id=\"usr\" style=\"margin-bottom: 15px;\" placeholder=\"New Password\">\n\n\nModal\n\n<div class=\"modal fade\" id=\"UserDashboardModal\" role=\"dialog\">\n <div class=\"modal-dialog\">\n <!-- Modal content-->\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\">&times;</button>\n <h4 class=\"modal-title\">Choose an Event to Edit</h4>\n </div>\n <div class=\"modal-body\">\n <select class=\"form-control\">\n @foreach($event as $key=>$cat)\n <option value=\"{{ $cat->user_event_id }}\">{{ $cat->name }}</option>\n @endforeach\n </select>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\" id=\"modalFromEventButton\">Select</button>\n </div>\n </div>\n</div>\n\n\n\n\nThe script to open the Modal\n\n<script>\n $(document).ready(function () {\n $('#UserDashboardModal').modal('show');\n });\n</script>\n\n\nHow can I obtain the selected event? And upload the inputs automatically wich the correct data?"
] | [
"javascript",
"jquery",
"twitter-bootstrap",
"laravel"
] |
[
"Multiple dll reference failure on nuget reinstall",
"I am getting multiple The referenced component <packagename> cannot be found when i do a nuget reinstall for my project. There are no build errors and i have to manually delete the erroneous references from the project to fix this 'annoyance'. Does anyone know why Im this is happening? (see screenshot). \n\nI am using visual studio 2017 and .NET 4.6.1 and netstandard2.0 is installed. The project type is class library and If i look in the bin folder, it seems there is an additional xml file for each erroneous reference."
] | [
"c#",
"nuget",
"visual-studio-2017",
".net-standard-2.0"
] |
[
"Recursively filter array of objects",
"Hitting a wall with this one, thought I would post it here in case some kind soul has come across a similar one. I have some data that looks something like this:\n\nconst input = [\n {\n value: 'Miss1',\n children: [\n { value: 'Miss2' },\n { value: 'Hit1', children: [ { value: 'Miss3' } ] }\n ]\n },\n {\n value: 'Miss4',\n children: [\n { value: 'Miss5' },\n { value: 'Miss6', children: [ { value: 'Hit2' } ] }\n ]\n },\n {\n value: 'Miss7',\n children: [\n { value: 'Miss8' },\n { value: 'Miss9', children: [ { value: 'Miss10' } ] }\n ]\n },\n {\n value: 'Hit3',\n children: [\n { value: 'Miss11' },\n { value: 'Miss12', children: [ { value: 'Miss13' } ] }\n ]\n },\n {\n value: 'Miss14',\n children: [\n { value: 'Hit4' },\n { value: 'Miss15', children: [ { value: 'Miss16' } ] }\n ]\n },\n];\n\n\nI don't know at run time how deep the hierarchy will be, i.e. how many levels of objects will have a children array. I have simplified the example somewhat, I will actually need to match the value properties against an array of search terms. Let's for the moment assume that I am matching where value.includes('Hit'). \n\nI need a function that returns a new array, such that:\n\n\nEvery non-matching object with no children, or no matches in children hierarchy, should not exist in output object\nEvery object with a descendant that contains a matching object, should remain\nAll descendants of matching objects should remain\n\n\nI am considering a 'matching object' to be one with a value property that contains the string Hit in this case, and vice versa. \n\nThe output should look something like the following: \n\nconst expected = [\n {\n value: 'Miss1',\n children: [\n { value: 'Hit1', children: [ { value: 'Miss3' } ] }\n ]\n },\n {\n value: 'Miss4',\n children: [\n { value: 'Miss6', children: [ { value: 'Hit2' } ] }\n ]\n },\n {\n value: 'Hit3',\n children: [\n { value: 'Miss11' },\n { value: 'Miss12', children: [ { value: 'Miss13' } ] }\n ]\n },\n {\n value: 'Miss14',\n children: [\n { value: 'Hit4' },\n ]\n }\n];\n\n\nMany thanks to anyone who took the time to read this far, will post my solution if I get there first."
] | [
"javascript",
"arrays",
"recursion",
"filter"
] |
[
"error LNK2019: unresolved external symbol \"__declspec(dllimport) private",
"The project runs correctly under VC6.0, however, after I updated it under VS2012, the following link errors occur:\n\nrevel.lib(BaseEncoder.obj) : error LNK2019: unresolved external symbol \n \"__declspec(dllimport) private: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Eos(unsigned int)\" \n (__imp_?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z) referenced in function \n \"protected: virtual void __thiscall Revel_BaseEncoder::Reset(void)\" (?Reset@Revel_BaseEncoder@@MAEXXZ)\n\n\nCan anyone help me with this problem? Thanks a lot!"
] | [
"c++"
] |
[
"NavigationBar title just changes once (not white again then going back)",
"I created a new project. I have a NavigationController. In the RootViewController I have a containerView with a table and just one cell. If I click on the cell I push a new UIViewController. So my Main.storyboard looks like this:\n\n\n\nWhat I want:\n\nI want first to have a white NavigationBartitle. Then pushing to secondVC I want to change the NavigationBarTitle to black. Then clicking on back the color should change back to a white title.\n\nWhat I've did:\n\nI did a custom NavigationViewController. There I was changing the func willShow viewController. In this I wrote the titleColor should change depending on which screen the navigationController changes to. \n\nMy code:\n\nimport UIKit\n\nclass SettingsNavigationViewController: UINavigationController {}\n\n// MARK: - Controller Lifecycle\nextension SettingsNavigationViewController {\n override func viewDidLoad() {\n super.viewDidLoad()\n\n self.delegate = self\n }\n\n override var preferredStatusBarStyle: UIStatusBarStyle {\n guard let child = self.childViewControllers.last else {\n return .lightContent\n }\n\n return child is ViewController ? .lightContent : .default\n }\n}\n\n// MARK: - NavigationController Delegate Implementation\nextension SettingsNavigationViewController: UINavigationControllerDelegate {\n func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {\n let isSettingsContainer = viewController is ViewController\n\n let backgroundColor = isSettingsContainer ? UIColor.cyan : UIColor.white\n let titleColor = isSettingsContainer ? UIColor.white : UIColor.black\n let image = isSettingsContainer ? UIImage() : nil\n\n navigationController.navigationBar.shadowImage = image\n navigationController.navigationBar.setBackgroundImage(image, for: .default)\n\n navigationController.transitionCoordinator?.animate(alongsideTransition: { (context) in\n navigationController.navigationBar.tintColor = titleColor\n navigationController.navigationBar.barTintColor = backgroundColor\n navigationController.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : titleColor]\n })\n }\n}\n\n\nWhat happened instead:\n\nIf I change the screen to seconndVC the navBarTitleColor changes black. If I click on back it stays black. But it should change to white.\n\nThe complete project I also uploaded to github: https://github.com/Sonius94/stackNaviTitle"
] | [
"ios",
"swift",
"uinavigationcontroller",
"uinavigationbar"
] |
[
"Using Flutter ChangeNotifierProvider for authentication",
"I am using ChangeNotifierProvider to handle app state for my flutter app.\nMy main.dart file\nimport 'package:flutter/material.dart';\nimport 'package:provider/provider.dart';\nimport 'package:flutter_app/services/auth.dart';\n\nFuture<void> main() async {\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp();\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return ChangeNotifierProvider<AuthService>(\n create: (context) => AuthService(), // initializes auth.dart file here\n child: MaterialApp(\n initialRoute: '/',\n onGenerateRoute: RouteGenerator.generateRoute,\n debugShowCheckedModeBanner: false,\n title: '...',\n home: WelcomeScreen(),\n ));\n }\n}\n\nI am trying to change the value of the uid field here in auth.dart\nauth.dart file\nimport 'package:flutter/material.dart';\nimport 'package:firebase_auth/firebase_auth.dart';\n\nclass AuthService with ChangeNotifier {\n final FirebaseAuth _auth = FirebaseAuth.instance;\n\n String uid = ""; //initial value of uid\n\n UserM _userFromFirebaseUser(User user) {\n return user != null ? UserM(uid: user.uid) : null;\n }\n\n Stream<UserM> get user {\n return null;\n }\n\n Future signInWithEmail(String email, String password) async {\n try {\n UserCredential result = await _auth.signInWithEmailAndPassword(\n email: email, password: password);\n User user = result.user;\n uid = user.uid; //trying to change uid here\n print('user id: $uid'); //new value is printed here\n notifyListeners();\n return _userFromFirebaseUser(user);\n } catch (e) {\n print(e.toString());\n return null;\n }\n }\n\nuid changes but then when i try to get the new value in another file, i still get the old value which is the empty string declared on top.\nThis is how i am trying to access it\nfinal auth = Provider.of<AuthService>(context, listen: true).uid;\nprint(auth);\n\nWhat am I doing wrong please?"
] | [
"firebase",
"flutter",
"authentication",
"dart",
"provider"
] |
[
"How to download Guava Libraries for Netbeans?",
"I want to use Guava TreeMultiset data structure in my java program. I use netbeans to code my program. However, I am a beginner and I don't know how I can include and import Guava libraries in netbeans. I've searched the web, but things were not clear to me. \n\nCan anyone please tell me how I can use Guava in Netbeans? \n\nAny help is appreciated. \n\nThank you."
] | [
"java",
"maven",
"netbeans",
"guava"
] |
[
"How do I bind command parameter in a context menu",
"I have a UserControl with a number of buttons that run applications on double click.\nThe button command is bound to the UserControl's ViewModel.LaunchApplicationCommand\nThe command is passed a parameter which is the viewmodel of the button.\nHere's the button command that works:\n<Button.InputBindings>\n <MouseBinding Gesture="LeftDoubleClick" Command="{Binding ViewModel.LaunchApplicationCommand, ElementName=UserControl}" CommandParameter="{Binding}" />\n</Button.InputBindings>\n\nWhat I'm trying to do is run the same command from a context menu on the button. I've tried to bind it to the best of my limited knowledge, but it doesn't work. What's the right way to do this?\n<Button.ContextMenu>\n <ContextMenu>\n <MenuItem Header="Run" Command="{Binding ViewModel.LaunchApplicationCommand, ElementName=UserControl}"\n CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>\n </ContextMenu>\n</Button.ContextMenu>"
] | [
"c#",
"wpf",
"xaml",
"data-binding"
] |
[
"websocket. how to trigger an onerror event?",
"I need to test WebSocket on the client: \n\n\r\n\r\nclass NotificationService {\r\n constructor() {\r\n this.socket = new WebSocket(`ws:${API_HOST}/ws`);\r\n\r\n this.socket.onerror = this._onError.bind(this);\r\n }\r\n \r\n _onError(event) {\r\n console.log(event);\r\n }\r\n}\r\n\r\n\r\n\n\nWhen an onerror event occurs and how to trigger it?\n\nWhat do you advise?"
] | [
"javascript",
"websocket"
] |
[
"SignalR hub method parameter serialization",
"I would need some guidelines from SignalR developers what is the best way to tweak HUB method's parameters serialization.\n\nI started migrating my project from WCF polling duplex (Silverlight 5 - ASP.NET 4.5) to SignalR (1.1.2). The message (data contract) is polymorphic based on interfaces. (Like IMessage, MessageA : IMessage, etc. - there is actually a hierarchy of interfaces implemented by classes but it is not of much significancy for the question).\n(I know polymorphic objects are not good for clients but the client will handle it as JSON and mapping to objects is done only on the server side or client if it is .NET/Silverlight)\n\nOn the hub I defined method like this:\n\npublic void SendMessage(IMessage data) { .. }\n\n\nI created custom JsonConverters and verified the messages could be serialized/deserialized using Json.NET. Then I replaced JsonNetSerializer in DependencyResolver with proper settings. Similarly on the Silverlight client-side. So far so good.\n\nBut when I sent the message from client to server (message got serialized to JSON correctly - verified in Fiddler), the server returned an error that the parameter cannot be deserialized.\nWith help of debugger, I found a bug in SignalR (JRawValue class responsible for deserialization of parameter creates internally its own instance of JsonSerializer ignoring the provided one). Seemed to be quite easy fix by replacing \n\nvar settings = new JsonSerializerSettings\n{\n MaxDepth = 20\n};\nvar serializer = JsonSerializer.Create(settings);\nreturn serializer.Deserialize(jsonReader, type);\n\n\nwith\n\nvar serializer = GlobalHost.DependencyResolver.Resolve<IJsonSerializer>();\nreturn serializer.Parse(jsonReader, type);\n\n\nbut I also found that the interface IJsonSerializer is going to be removed in a future version of SignalR. What I need, basically, is to get either raw JSON (or byte stream) from HUB method so I could deserialize it by myself or a possibility to tweak the serializer by specifying converters, etc.\n\nFor now, I ended up with defining the method with JObject parameter type:\n\npublic void SendMessage(JObject data)\n\n\nfollowed by manual deserialization of data using\n\nJObject.ToObject<IMessage>(JsonSerializer)\n\n\nmethod. But I would prefer to customize the serializer and having the type/interface on the hub method. What is the \"right way\" to do it regarding design of the next SignalR?\n\nI also found useful to have a possibility to send back to clients raw JSON from my code, i.e. so that the object is not serialized again by SignalR again. How could I achieve this?"
] | [
"c#",
"signalr",
"signalr-hub"
] |
[
"Multiprocessing: Passing a class instance to pool.map",
"I swear I saw the following in an example somewhere, but now I can't find that example and this isn't working. The __call__ class function never gets called.\n\nEDIT: Code updated \n\npool.map appears to start the QueueWriter instance and the __call__ function is reached. However, the workers never seem to start or at least no results are pulled from the queue. Is my queue set up the right way? Why do the workers not fire off? \n\nimport multiprocessing as mp\nimport os\nimport random\n\nclass QueueWriter(object):\n def __init__(self, **kwargs): \n self.grid = kwargs.get(\"grid\")\n self.path = kwargs.get(\"path\")\n\n def __call__(self, q):\n print self.path\n log = open(self.path, \"a\", 1)\n log.write(\"QueueWriter called.\\n\") \n while 1:\n res = q.get()\n if res == 'kill':\n self.log.write(\"QueueWriter received 'kill' message. Closing Writer.\\n\")\n break\n else:\n self.log.write(\"This is where I'd write: {0} to grid file.\\n\".format(res))\n\n log.close()\n log = None\n\nclass Worker(object):\n def __init__(self, **kwargs):\n self.queue = kwargs.get(\"queue\")\n self.grid = kwargs.get(\"grid\")\n\n def __call__(self, idx):\n res = self.workhorse(self, idx)\n self.queue.put((idx,res))\n return res\n\n def workhorse(self,idx):\n #in reality a fairly complex operation\n return self.grid[idx] ** self.grid[idx]\n\n\nif __name__ == '__main__':\n# log = open(os.path.expanduser('~/minimal.log'), 'w',1)\n path = os.path.expanduser('~/minimal.log')\n\n pool = mp.Pool(mp.cpu_count())\n manager = mp.Manager()\n q = manager.Queue()\n\n grid = [random.random() for _ in xrange(10000)] \n # in actuality grid is a shared resource, read by Workers and written\n # to by QueueWriter\n\n qWriter = QueueWriter(grid=grid, path=path)\n watcher = pool.map(qWriter, (q,),1)\n wrkr = Worker(queue=q,grid=grid)\n result = pool.map(wrkr, range(10000), 1)\n result.get()\n q.put('kill')\n pool.close()\n pool.join() \n\n\nSo the log does indeed print the initialization message, but then __call__ function is never called. Is this one of those pickling issues I've seen discussed so often? I've found answers about class member functions, but what about class instances?"
] | [
"python",
"class",
"multiprocessing"
] |
[
"Invalid Stream header with Stanford nlp library",
"I am working through this Stanford POS tagger tutorial. I am doing it in Scala but I do not think that this matters. \n\nThe line that produces the error is\n\nval tagger=new MaxentTagger(\"/Users/user1/Documents/taggers/left3words-wsj-0-18.tagger\")\n\n\nand the error is\n\nedu.stanford.nlp.io.RuntimeIOException: java.io.StreamCorruptedException: invalid stream header: 0003CBE8\n\n\nThe filepath is correct."
] | [
"java",
"scala",
"stanford-nlp"
] |
[
"Is it possible to create directories under Android/data/data/your_package/ files",
"I would like to save some files in different directories under Android/data/data/my_app_package/files directory. I am able to obtain the path to the \"files\" directory by calling context.getExternalFilesDir(null), but can't create a directory under the path returned. Does anyone know why?\n\nThanks,"
] | [
"android",
"directory"
] |
[
"EntityManager null when used in S",
"Consider following class: \n\npackage com.deluxe.common.dao;\n\nimport javax.ejb.Stateless;\nimport javax.ejb.TransactionManagement;\nimport javax.ejb.TransactionManagementType;\nimport javax.faces.bean.ManagedBean;\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\n\nimport com.deluxe.jpa.Customer;\n\n@ManagedBean(name=\"jpaBean\")\n@Stateless\n@TransactionManagement(TransactionManagementType.BEAN)\npublic class JpaDao {\n\n @PersistenceContext(unitName=\"EmployeeService\")\n EntityManager em;\n\n public EntityManager getEntityManager() {\n return em;\n }\n\n\n public void addEmployee(String name, String lastName) {\n\n Customer cust = new Customer();\n\n cust.setName(name);\n cust.setLastName(lastName);\n\n em.persist(cust);\n }\n\n}\n\n\nWhen I call a addEmployee through JSF managed bean then entitymanager is null but when I print entitymanager in jsf bean its shows up. Here is the code of jsf managed bean:\n\n@EJB JpaDao psb;\n\n public void addCustomer() {\n EntityManager em = psb.getEntityManager();\n JpaDao jpa = new JpaDao();\n jpa.addEmployee(\"Some..\", \"Thing..\"); // Throwing err, em in JpaDao is null.\n System.out.println(\"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"+em); //This line show em is there.\n Customer cust = new Customer();\n cust.setLastName(\"Krishnawat\");\n cust.setName(\"Nagendra\");\n em.persist(cust);\n }\n\n\nWhy it is so ? Am I missing something."
] | [
"hibernate",
"jsf",
"jpa",
"ejb"
] |
[
"Validating user's input for only int or double values",
"I need to validate the user's input so that the value entered is a double or an int; then store the int/double values in an array and show an error message if the user enters invalid data.\n\nFor some reason my code crashes if the user enters invalid data.\nCould you please review my code below and tell me what is possibly wrong?\n\npublic static double[] inputmethod() {\n double list[] = new double[10];\n Scanner in = new Scanner(System.in);\n double number;\n System.out.println(\"please enter a double : \");\n\n while (!in.hasNextDouble()) {\n in.next();\n System.out.println(\"Wrong input, Please enter a double! \");\n }\n for (int i = 0; i < list.length; i++) {\n list[i] = in.nextDouble();\n System.out.println(\"you entered a double, Enter another double: \");\n\n }\n return list;\n}"
] | [
"java",
"user-input"
] |
[
"Stata coefplot: plot coefficients and corresponding confidence intervals on 2nd axis",
"When trying to depict two coefficients from one regression on separate axes with Ben Jann's superb coefplot (ssc install coefplot) command, the coefficient to be shown on the 2nd axis is correctly displayed, but its confidence interval is depicted on the 1st scale.\nCan anyone explain how I get the CI displayed on the same (2nd) axis as the coefficient it belongs to? I couldn't find any option to change this - and imagine it should be the default, if not the only, option to plot the CI around the point estimate it belongs to.\nI use the latest coefplot version with Stata 16.\nHere is a minimum example to illustrate the problem:\nresults plot\nwebuse union, clear\neststo results: reg idcode i.union grade\ncoefplot (results, keep(1.union)) (results, keep(grade) xaxis(2))"
] | [
"stata",
"axis",
"confidence-interval",
"coefplot"
] |
[
"How to save variables with SharedPreferences",
"I have my own Objects which I need to store for later use. The User saves this object, it is turned into a JSON String, then when the User is connected to a network, the JSON String is turned back into the object operations are performed on it.\n\nMy problem is that, at run time, how do I know how to store the object? \n\ni.e\n\nGson gson= new Gson();\nString pointOfInterest = gson.toJson(point);\nSharedPreferences.Editor sharedprefEditor = application_shared_preferences.edit();\nsharedprefEditor.putString(?KEY?,pointOfInterest);\n\n\nWhat can I use for the value of KEY? If I use an index, it will get reset every time I open or close the app, and this will replace my Objects.\n\nEdit\nSorry I didn't make this clear enough, the method that the above code is in can be run an arbitrary number of times and there could be several pointsOfInterest to store."
] | [
"android",
"json",
"sharedpreferences",
"gson",
"state"
] |
[
"Changing configuration for other bundles using ConfigurationPlugin",
"I have some bundles started in karaf and want to change their configuration during start. I created class that implements ConfigurationPlugin and registered it in karaf. When I installed bundle, my configuration plugin was invoked and changed configuration, but blueprint set old config value to the bundle. \n\nHow can I use this ConfigurationPlugin for this goal?\n\nBlueprint is very simple:\n\n<blueprint xmlns=\"http://www.osgi.org/xmlns/blueprint/v1.0.0\"\n xmlns:cm=\"http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0\">\n\n <cm:property-placeholder persistent-id=\"my\" update-strategy=\"reload\">\n </cm:property-placeholder>\n <bean id=\"serviceBean\" class=\"com.mycompany.blueprint.MyServiceImpl\">\n <property name=\"prop\" value=\"${mydb.password}\" />\n </bean>\n</blueprint>\n\n\nConfiguration file contains only one encrypted property.\nIt should be somehow decrypted using another bundle during creation."
] | [
"configuration",
"osgi",
"karaf"
] |
[
"Need to have this repeat if a code is not received within x time",
"This portion of my code submits a request for sms verification. I want it to restart a portion of the script if the sms verification code is not received within 90 seconds, so it will restart that step and try for a new number.\n EC.presence_of_element_located((By.XPATH, "//*[@id='mobile-container']/div/div/form/div[2]/div[4]/div/div/div/div[2]/button")))\n time.sleep(0.5)\n addPn.click()\n time.sleep(1)\n numberBox = driver.find_element(By.XPATH, "//*[@type='tel']")\n\n global nId\n global num\n\n noNum = True\n while noNum:\n r = requests.get("https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=getNumber&service=ew&country=0")\n if "ACCESS_NUMBER" in r.text:\n info = r.text.split(":")\n nId = str(info[1])\n num = str(info[2])\n noNum = False\n\n c = driver.find_element(By.XPATH, "//*[@class='country']")\n c.click()\n z = driver.find_element(By.XPATH, "//*[@class='country']/option[38]")\n z.click()\n time.sleep(0.5)\n numberBox.click()\n\n for character in num[1:]:\n numberBox.send_keys(character)\n time.sleep(0.2)\n\n sendCode = driver.find_element(By.XPATH, "//*[@class='sendCodeButton']")\n sendCode.click()\n\n requests.get(f"https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=setStatus&status=1&id={nId}")\n\n code = ""\n\n noCode = True\n while noCode:\n r = requests.get(f"https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=getStatus&id={nId}")\n if "STATUS_OK" in r.text:\n code = r.text.split(":")[1]\n noCode = False\n\n codeBox = driver.find_element(By.XPATH, "//*[@type='number']")\n for character in code:\n codeBox.send_keys(character)\n time.sleep(0.5)\n check = driver.find_element(By.XPATH, "//*[@class='checkbox']")\n check.click()\n time.sleep(0.4)\n\n cont = driver.find_element(By.XPATH, "//*[@value='CONTINUE']")\n cont.click()"
] | [
"python",
"selenium"
] |
[
"How to return to the previous page in Angular?",
"My requirement is:\n\nAfter giving the search criteria, show the Search Result below and focus on the search results.\nThen after selecting a row from the Search-Result, and OPEN the RECORD in a different page replacing the old one. (Have used router.navigate() method).\nFrom the new page, if user selects BACK hyperlink, user should see the old SEARCH page with the Results.\n\nNow, the problem is, as mentioned above in PointNo 3, I am not able to navigate to the original 'parent page' with all the SEARCH-FORM data and the data; always the initial SEARCH-FORM is coming after navigation (returnToSearchResultsPage() method).\nYour headsup and help would be very much appreciated!\n\r\n\r\n-- 1. PARENT PAGE (Search Page):\n showResultsOnSubmit() {\n this.showSearchResults = true; \n }\n=============================================================\n-- 2. In results-list-component:\n openRecordDetails(): void {\n this.router.navigate(['individual-details']);\n }\n\n=============================================================\n\n-- 3. CHILD PAGE (In individual-details component):\n// Need to return to the search-options page with the search-results intact.\nreturnToSearchResultsPage() {\n //this.router.navigate(['search-options']);\n // this._location.back();\n window.history.go(-2); \n }\r\n-- 1. PARENT PAGE (Search Page):\n<div>\n <div>\n <h1> Search</h1>\n <form #searchCriteriaForm=\"ngForm\" (ngSubmit)=\"showResultsOnSubmit()\">\n . . .\n <button type=\"submit\" [disabled]=\"!searchCriteriaForm.valid\">Search</button>\n </form>\n </div>\n<!-- *** Display of the Results Form @START *** -->\n <div>\n <results-list [showMePartially]=\"showSearchResults\"></results-list>\n </div>\n<!-- **** Display of the Results Form @END *** -->\n</div>\n\n\n\n<!-- ** Display of the Results Form @START *** -->\n <div>\n <results-list [showMePartially]=\"showSearchResults\"></results-list>\n </div>\n<!-- *** Display of the Results Form @END ** -->\n\n\n</div>\n\n=============================================================\n-- 2. In results-list-component:\n <div>\n <button type=\"button\" (click)=\"openRecordDetails()\">Open Record</button>\n </div>\n\n=============================================================\n-- 3. CHILD PAGE (In individual-details component):\n<form>\n\n<a href=\"#\" style=\"margin-left:20px;\" *ngIf=\"isEditModeParent\" (click)=\"returnToSearchResultsPage()\"> Return to Search Page</a>\n \n. . . .\n\n</form>"
] | [
"angular",
"angular2-routing"
] |
[
"How to recursively implement a deep flatten on Iterable?",
"Having seen flatten, I was looking for something that would be a deepFlatten, i.e., it would work with not only Iterable<Iterable<T>> (it's pretty much the same for Arrays, but let's focus on Iterable now for brevity), but also with Iterable<Iterable<Iterable<T>>>, Iterable<Iterable<Iterable<Iterable<T>>>> and so on...\nOf course, the result would have to be List<T>, which the standard flatten() doesn't provide - it would return List<Iterable<T> (or a List with more nested Iterables).\nI was trying to work with reified generics:\ninline fun <reified E, T> Iterable<E>.deepFlatten(): List<T> = when(E::class) {\n Iterable<*>::class -> (this as Iterable<Iterable<*>>).flatten().deepFlatten()\n else -> flatten()\n}\n\nBut this obviously is flooded with errors:\n\nT seems pretty undeducable\nYou cannot have a ::class of an interface\nYou cannot recurse on an inline function\n\nAre there any workarounds on the above problems? Or, even better, is there a cleaner approach to the problem?\n\nTo demonstrate an example for completeness, I'd like to be able to do:\nfun main() {\n val data: List<List<List<Int>>> = listOf(\n listOf(listOf(1, 2, 3), listOf(5, 6), listOf(7)),\n listOf(listOf(8, 9), listOf(10, 11, 12, 13))\n )\n\n print(data.deepFlatten()) // 1 2 3 4 5 6 7 8 9 10 11 12 13\n}\n\nThe depth of nested Iterables (they need not be the same type - it's important that they are generically Iterable) can vary."
] | [
"kotlin",
"generics",
"recursion",
"flatten",
"kotlin-reified-type-parameters"
] |
[
"Android OpenGL-ES gradient background",
"I would like to have a gradient background in OpenGL\n\nI found these two links, but I cannot reproduce it:\n\nOpenGL gradient fill on iPhone looks striped\n\nOpenGL gradient banding on Android\n\nI tried the following of the first link:\n\n // Begin Render\n //IntBuffer redBits = null, greenBits = null, blueBits = null;\n //gl.glGetIntegerv (GL10.GL_RED_BITS, redBits); // ==> 8\n //gl.glGetIntegerv (GL10.GL_GREEN_BITS, greenBits); // ==> 8\n //gl.glGetIntegerv (GL10.GL_BLUE_BITS, blueBits); // ==> 8\n\n gl.glDisable(GL10.GL_BLEND);\n gl.glDisable(GL10.GL_DITHER);\n gl.glDisable(GL10.GL_FOG);\n gl.glDisable(GL10.GL_LIGHTING);\n gl.glDisable(GL10.GL_TEXTURE_2D);\n gl.glShadeModel(GL10.GL_SMOOTH);\n\n float[] vertices = {\n 0, 0,\n 320, 0,\n 0, 480,\n 320, 480,\n };\n FloatBuffer vertsBuffer = makeFloatBuffer(vertices); \n\n int[] colors = {\n 255, 255, 255, 255,\n 255, 255, 255, 255,\n 200, 200, 200, 255,\n 200, 200, 200, 255,\n };\n\n IntBuffer colorBuffer = makeIntBuffer(colors);\n\n gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertsBuffer);\n gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);\n gl.glColorPointer(4, GL10.GL_UNSIGNED_BYTE, 0, colorBuffer);\n gl.glEnableClientState(GL10.GL_COLOR_ARRAY);\n gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);\n // End Render\n\n\n\n\nprotected static FloatBuffer makeFloatBuffer(float[] arr) {\n ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4);\n bb.order(ByteOrder.nativeOrder());\n FloatBuffer fb = bb.asFloatBuffer();\n fb.put(arr);\n fb.position(0);\n return fb;\n}\n\nprotected static IntBuffer makeIntBuffer(int[] arr) {\n ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4);\n bb.order(ByteOrder.nativeOrder());\n IntBuffer ib = bb.asIntBuffer();\n ib.put(arr);\n ib.position(0);\n return ib;\n}\n\n\nBut it just shows a rectangle in the right upper corner. But I don't know if the\n\nglGetIntegerv\n\nwould have an effect? Any ideas/links how to make it run?\n\n===\nSOLUTION\n\n // set orthographic perspective\n setOrtho2D(activity, gl);\n\n gl.glDisable(GL10.GL_BLEND);\n //gl.glDisable(GL10.GL_DITHER);\n gl.glDisable(GL10.GL_FOG);\n gl.glDisable(GL10.GL_LIGHTING);\n gl.glDisable(GL10.GL_TEXTURE_2D);\n gl.glShadeModel(GL10.GL_SMOOTH);\n\n float[] vertices = {\n 0, 0,\n _winWidth, 0,\n 0, _winHeight,\n _winWidth, _winHeight\n };\n\n FloatBuffer vertsBuffer = makeFloatBuffer(vertices); \n\n float[] colors = {\n 1.0f, 1.0f, 1.0f, 1.0f,\n 1.0f, 1.0f, 1.0f, 1.0f,\n 0.2f, 0.2f, 0.2f, 1.0f,\n 0.2f, 0.2f, 0.2f, 1.0f\n };\n\n FloatBuffer colorBuffer = makeFloatBuffer(colors);\n\n gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertsBuffer);\n gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);\n gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);\n gl.glEnableClientState(GL10.GL_COLOR_ARRAY);\n gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);\n\n\nI forgot to comment the perspective line in again. I also changed the vertices order from \"U\" shape to the \"Z\" shape (Thanks Nick).\nNow it looks like this:"
] | [
"android",
"opengl-es",
"gradient"
] |
[
"how to use buttons in tab layout in android and use this button to call different fragments and place the tab layout at the bottom of the screen",
"I want to place buttons in a tab layout and use these buttons to call different fragments in a tab layout. Moreover I want to place some image in each button .Can anyone please help ??"
] | [
"android",
"layout",
"android-fragments",
"screens"
] |
[
"C-LinkedList Append Function, with Bad Memory Address error",
"I am trying to understand why the compiler detects a \"Bad Memory error\"\nTo my understanding (Pointer->next != null) should get me to the end of the tail, but why when it gets to the last node, it detects an error. \n\nvoid Append(Data* head, char* name, char* lastname) { \n Data* _newNode = (Data*)malloc(sizeof(Data));\n std::strcpy(_newNode->name, name);\n std::strcpy(_newNode->lastname, lastname);\n // Iretator\n Data* prt = head;\n if ((*name != '\\0') && (*lastname != '\\0')) {\n // find the last node in the list:\n //Special Case\n if (*head->name == '\\0') {\n std::strcpy(head->name, name);\n std::strcpy(head->lastname, lastname);\n } else {\n while ((int*)prt->next != NULL) {\n prt = prt->next;\n }\n prt = _newNode;\n }\n }\n}"
] | [
"c++"
] |
[
"Raphael.js perspective transformation",
"I'm working with Raphael.js and have a problem to create a perspective transformation. It should be a svg / raphael solution, because it's one step to create an image. Here is an image how it looks now: \n\n\n\nThe target is to use transform to skew it at the z-axis. It should looks like this image:\n\n\n\n\n\nCode:\n\npaper.setStart();\nObj=paper.path('M 2500 3750 L 2500 3481.9 L 0 3481.9 L 0 3750 L 2500 3750Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 3482.2 L 2500 3214.1 L 0 3214.1 L 0 3482.2 L 2500 3482.2Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 3214.3 L 2500 2946.2 L 0 2946.2 L 0 3214.3 L 2500 3214.3Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 2946.5 L 2500 2678.4 L 0 2678.4 L 0 2946.5 L 2500 2946.5Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 2678.6 L 2500 2410.6 L 0 2410.6 L 0 2678.6 L 2500 2678.6Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 2410.8 L 2500 2142.7 L 0 2142.7 L 0 2410.8 L 2500 2410.8Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 2142.9 L 2500 1874.9 L 0 1874.9 L 0 2142.9 L 2500 2142.9Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 1875.1 L 2500 1607 L 0 1607 L 0 1875.1 L 2500 1875.1Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 1607.3 L 2500 1339.2 L 0 1339.2 L 0 1607.3 L 2500 1607.3Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 1339.4 L 2500 1071.3 L 0 1071.3 L 0 1339.4 L 2500 1339.4Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 1071.6 L 2500 803.5 L 0 803.5 L 0 1071.6 L 2500 1071.6Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 803.8 L 2500 535.7 L 0 535.7 L 0 803.8 L 2500 803.8Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 535.9 L 2500 267.8 L 0 267.8 L 0 535.9 L 2500 535.9Z');\nObj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});\nObj=paper.path('M 2500 268 L 2500 0 L 0 0 L 0 268 L 2500 268Z');\nObj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});\n\nObj=paper.path('M 1237.1 597.3 C 1237.1 604.4 1242.9 610.2 1250 610.2 C 1257.1 610.2 1262.9 604.4 1262.9 597.3 C 1262.9 590.1 1257.1 584.4 1250 584.4 C 1242.9 584.4 1237.1 590.1 1237.1 597.3');\nObj.attr({'fill': line_color,'stroke':'none'});\nObj=paper.path('M 1262.9 3151.7 C 1262.9 3144.6 1257.1 3138.8 1250 3138.8 C 1242.9 3138.8 1237.1 3144.6 1237.1 3151.7 C 1237.1 3158.9 1242.9 3164.7 1250 3164.7 C 1257.1 3164.7 1262.9 3158.9 1262.9 3151.7');\nObj.attr({'fill': line_color,'stroke':'none'});\nObj=paper.path('...');\nObj.attr({'fill': line_color,'stroke':'none'});\nvar st = paper.setFinish();\n\n\n\n\nEDIT: Fiddle\n\nIs there any solution?"
] | [
"javascript",
"svg",
"raphael"
] |
[
"How to properly start a session using cookies, store it and access it in a Sinatra app using Rack sessions",
"I have a Sinatra app running on Heroku. I've had a really tough time properly setting up the cookies for my users. I've been looking at examples and documentation for a couple days now and just can't seem to crack the problem. I would like to have my users login with a email and password. If the login is successful, I want to create a cookie which expires after some set amount of time. I want the user to remain logged in if they close and re-open their browser or if I push new code to Heroku. I think that is just normal use of cookies, so if someone can help me get it going, I'd be very grateful.\n\nHere is how I think I'm supposed to setup the post '/login' route.\n\npost '/login/?' do\n\n #do_login is a helper method which checks if the user's credentials are correct\n\n if do_login\n use Rack::Session::Cookie, :key => 'rack.session',\n :domain => 'www.Feistie.com',\n :path => '/',\n :expire_after => 2592000,\n :secret => 'a_30_character_key',\n :user_id => params[:user_id]\n end\n\nend\n\n\nEven if that is correct, I don't really understand it. What is the :key? I'm assuming :domain should just be set to my website as I did. What about :path? Why is :path set to '/'? Is there a place I actually set the secret key for my Rack app? I'm not totally clear on how cookie security works. I'm also not sure if I can add :user_id to the hash the way I did.\n\nThen next part is setting up a helper \"logged_in?\" to see if someone is logged in?\n\ndef logged_in?\n !session.nil?\nend\n\n\nThat is probably wrong, but I figured I'd try. \n\nI also need to be able to check who the current user actually is. I used to do this by session[:user_id] == @user.id or something similar. The main question I have is how do I access the :user_id value in the cookie?\n\nFinally the logout.\n\npost '/logout/?' do\n session.clear\nend\n\n\nIf you guys could get me on track with all this, it would be amazing! Thanks in advance and if you need more info, I will be glad to provide."
] | [
"session",
"cookies",
"login",
"sinatra",
"rack"
] |
[
"Referencing associations with Ruleby on Rails",
"I've recently started messing with a gem called 'ruleby', a rule-engine for Ruby. The documentation for ruleby is a bit sparse, however, and I can't seem to figure out how to properly reference associations for the rule-writing bit. I'm stumped both the 'pattern' part of the rule and also in the executing block part of the rule. \n\nFor example, let's say I had a rule which would only be executed only when a user submitted a positive review. I could, for instance, write the following:\n\n rule :positive_review, [Review, :review, method.review_rating == \"positive\"] do |v|\n assert (store positive_review somehow)\n end\n\n\nSo it's at this point that I get lost. I would like to write a rule which would reference back to the user and check the total number of positive reviews that the user of this positive review and possibly execute certain actions based on this number. \n\nIf anyone could point me in the right direction, I would be greatly appreciative. Thanks."
] | [
"ruby-on-rails-3",
"rule-engine"
] |
[
"Cypress: Can I stub/mock the window.location.hostname in a test?",
"I have a component that should not appear on a list of hostnames, and want a cypress test to test the logic around that.\nI know with my Jest unit tests, I can use delete global.window.location.hostname then global.window.location.hostname = "whatever" but can't seem to find a Cypress equivalent.\n(Ref How to mock window.location.href with Jest + Vuejs)\nAny help appreciated."
] | [
"testing",
"mocking",
"cypress"
] |
[
"How to set a background to a listview item on click and change dynamically on other clicks",
"hi i am having a list view and on click i want to show a background image to the selected list item, and change the background if the selection is changed. i had been trying to implement this but was not able to do so. please help me with this and would be grateful so\n\nplease find the code i am using\n\n @Override\n public View getView(final int position, View convertView,\n ViewGroup parent) {\n View view = convertView;\n final int getstartedItemPos = position;\n Resources res = getResources();\n\n if (convertView == null) {\n view = LayoutInflater.from(parent.getContext()).inflate(\n R.layout.getting_starteditem, null);\n }\n synchronized (view) {\n TextView textTopic = (TextView) view\n .findViewById(R.id.indexItems);\n textTopic.setText(getStartedItems[getstartedItemPos]);\n textTopic.setTypeface(tf);\n view.setBackgroundColor(Color.TRANSPARENT);\n\n }\n return view;\n }\n\n};\n\nprivate OnItemClickListener getStartedListItem = new OnItemClickListener() {\n\n @Override\n public void onItemClick(AdapterView<?> arg0, View arg1, int position,\n long arg3) {\n // TODO Auto-generated method stub\n Intent myintent = new Intent(getApplicationContext(),GetStartedWebview.class);\n myintent.putExtra(\"SelectedItem\", getStartedItems[position]);\n startActivity(myintent);\n }\n};"
] | [
"android",
"listview"
] |
[
"How to query and update some record set in django models atomically?",
"I have some records in a django Model, and each time I want to query and update some of them.\nHow can perform this operation atomically?\n\ndef queryAndUpdate(count):\n entries = Model.objects.filter(...)[:count]\n for entry in entries:\n entry.count = F('count') + 1\n entry.save()\n return entries\n\n\nI tried QuerySet.select_for_update(), but it fails."
] | [
"python",
"django"
] |
[
"How to get cookie in magento 2 admin controller?",
"I create a grid listing to report data. I have created to field From date and to date for admin select to filter data. So I set cookies from_date and to_date. When I show grid it load two time, the first time it can get cookie value but the second time it can't get cookie value. Show the grid can't display right value.\nI also create a controller in Controller/Adminhtml/Report/MyController.php to export data to CSV. It work fine. But I can't get from_date and to_date from cookie to set it in my collection query.\n\nMy code as below:\n\npublic function __construct(\n $name,\n $primaryFieldName,\n $requestFieldName,\n CollectionFactory $collectionFactory,\n array $meta = [],\n array $data = [],\n \\Magento\\Framework\\App\\RequestInterface $request,\n \\Magento\\Framework\\Stdlib\\CookieManagerInterface $cookieManager\n ) {\n parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);\n\n $this->request = $request;\n $this->cookieManager = $cookieManager;\n\n $from = $this->cookieManager->getCookie('from_date');\n $to = $this->cookieManager->getCookie('to_date');\n $from_date = $this->request->getParam('from_date');\n $to_date = $this->request->getParam('to_date');\n}\n\n\nHow to get cookie in magento 2 admin controller?\n\nThanks & Best regards,\nBienHV"
] | [
"cookies",
"magento2"
] |
[
"How secure is the \"same origin policy\"?",
"I am aware that to read the contents of an iframe, the domains, protocols, and ports must match.\n\nHowever is this enough to guarantee that an \"unknown malicious website\" will not be able to get past this restriction?\n\nBasically I'm worried that a very smart anonymous hacker would be able to have an iframe on HIS website, pointing the iframe's url to my webpage, and extract the contents of my webpage."
] | [
"javascript",
"html",
"security",
"web"
] |
[
"Implementing Json schema in my django restframework",
"I'm new in DJango and I'm trying to Implement a log collector system, which gets logs in Json format from different systems. \n\n\nMy first challenge is that these systems generate different fields\nand I don't know how to define dynamic fields in my model for storing logs in my database which is PostGre. I mean that my json files define various fields in each request, so I can't use a single model for this purpose.\nThe second challenge is that before arrival of Json log, a scheme will be sent to system to define my Json files properties as follows. My question is that, how I can implement such a system to get these data and help me with storing Json files when they arrive?:\n\n{\n namespace: ‘string’,\n schema: {\n field_1: type1,\n field_2: type2,\n …\n }\n}\n\n\n\"namespace\" defines a specific structure in my system cause my system's clients can send multiple log types to my log collector.\n\nThank you for your time."
] | [
"python",
"json",
"django",
"postgresql"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.