texts
sequence
tags
sequence
[ "Javascript if this OR this statement - second condition ignored", "I have to show different divs based on what search terms are entered into my site. The URL will contain the search term entered, so I thought I could check for the string in the URL and show the div if there is a match. \n\nFor the Doufeu/doufeu part, the div will only show based on the first term. The code is below - it will only show if Doufeu is in the string, but not doufeu. Why?\n\nBased on what I read here and here, I have tried the code below, and also using && instead of || because the second link explains the second condition is only read if the first one is false. I found this and also tried separating with a comma. None work for me though. Here is where I am now:\n\n <script type=\"text/javascript\">\n $(document).ready(function(){\n\n if ((window.location.href.indexOf(\"searchTerm=Doufeu\" || \"searchTerm=doufeu\") > -1)){\n $(\"#learn-doufeu\").show();\n }\n\n else {\n $(\"#ci-guide\").show();\n }\n });\n </script>\n\n\nI know I could make a new if else condition and separate Doufeu from doufeu that way but surely there is a way to do it with OR." ]
[ "javascript", "jquery", "html", "if-statement", "conditional-statements" ]
[ "How to redirect a search term to a new page after a \"?\" is entered?", "I am building an engine with search and was wandering a way to have it redirect my query to an answer page once the user hits the \"?\" key.\n\nE.G.\n\n\nUser types in query. What is 4 + 4\nFollows up with a \"?\".\nTransition appears, then is redirected to new page with question and answer on it.\n\n\nHere is my code that I have so far:\n\nHTML:\n\n<form>\n <input type=\"text\" name=\"search\"></form>\n\n\nCSS:\n\ninput[type=text] {\n width: 50%;\n padding: 15px 20px;\n margin: 0px 0;\n border: none;\n background-color: #000;\n color: #fff;\n font-family: 'Roboto', sans-serif;\n font-size: 1.3em;\n border: 2px #000;\n border-radius: 5px;\n font-style: normal;\n text-align: center;\n}\n\n\nI'm unsure whether CSS, JS or another coding skill would work best with what I'm trying to acheive. Any help would be greatly appreciated!" ]
[ "javascript", "html", "css", "forms", "search" ]
[ "How to assign parameter values in a SparqlParameterizedString", "I'm playing around some with Dotnetrdf's sparql engine and I'm trying to create parametered queries with no success yet.\n\nSay I'm working on a graph g with a blank node identified as _:1690 with the code\n\nDim queryString As SparqlParameterizedString = New SparqlParameterizedString()\nqueryString.Namespaces.AddNamespace(\"rdfs\", UriFactory.Create(\"http://www.w3.org/2000/01/rdf-schema#\"))\n\nqueryString.CommandText = \"SELECT ?label { @context rdfs:label ?label } \"\nqueryString.SetParameter(\"context\", g.GetBlankNode(\"1690\"))\n\nDim result As VDS.RDF.Query.SparqlResultSet = g.ExecuteQuery(New SparqlQueryParser().ParseFromString(queryString))\n\n\nWhenever I run this, I get all nodes having a rdfs:label property instead of filtering the result on my blank node only.\n\nPlease, how to set the parameter's value properly so I get only one item in the result ?\n\nThanks in advance,\nMax." ]
[ "sparql", "parameterized", "dotnetrdf", "blank-nodes" ]
[ "Xunit test results to ELK stack - anyone tried this or know of projects?", "I am planning to put my organization's test run results into the ELK stack for analysis and have had no luck finding any code to leverage.\n\nI've downloaded and analyzed a variety of xunit xml outputs and have noted that there are variations in the format, which is kind of a bummer.\n\nI am using python and have found code to simply convert xml to json that works well (xmltodict). Perhaps I can just send whichever json-from-xml format I get to elastic search? I worry that I might not know how to make an elastic search index capable to handling a variable format.\n\nI guess I am looking at either sending them to elastic search 'as is' post conversion or I will need to find a way to make a common format from the various ones I am seeing out there... python xunit, .NET xunit, junit, etc\n\nAny ideas welcome. This sounded so easy before I really got a look at it :)" ]
[ "python", "python-2.7", "logstash", "deserialization", "elastic-stack" ]
[ "Should all properties necessarily influence a JavaBean's hashcode() and equals() method?", "For a class to be a valid Javabean (according to the JavaBeans Specification), should all of its properties be tested in its equals() method — and, accordingly, influence its hascode() implementation? Or some properties may be deliberately put aside?\n\nFor instance, a class Person with:\n\n\nid and name properties exposed in geters and setters\na no-args constructor \nequals and hashcode methods that only take id into account\n\n\nwould qualify as a valid JavaBean?" ]
[ "java", "javabeans", "equals", "hashcode", "specifications" ]
[ "Folding or concatMap-ing an Aeson Array via lenses", "I've been starting at https://www.stackage.org/haddock/lts-12.1/lens-aeson-1.0.2/Data-Aeson-Lens.html and https://www.stackage.org/haddock/lts-12.1/lens-4.16.1/Control-Lens-Fold.html trying to figure out how to write an expression that allows me to construct something of the following type:\n\nimport Data.Aeson as A\n\nfunctionIWant \n :: (Vector A.Value)\n -> (A.Value -> [a])\n -> [a]" ]
[ "haskell", "haskell-lens", "aeson" ]
[ "How Do I Make A Button Get An Alert View To Pop Up When Pressed And Go Back To The Main View Controller?", "NOTE: Apologies in advance for my lack of being able to explain easily, as well as being only half a semester of coding knowledge, high school\n\nSo, recently I have had a project I have to do for a class, and it's one of those basic \"Choose-Your-Own-Adventure\" (CYOA) type of stories. However, as of now, I only have the navigation controller. One of the things I am having trouble with is getting the button at the end to pop up an alert view when pressed, so to say something like \"Story finished! Go back to start!\" and then of course the \"Okay\" button part on the alert view.\n\nI know how to make an alert view, but only popping up because of a condition. We had a project called Tic-Tac-Toe, and when one wins, an alert view pops up. What I want to do with my CYOA app is make it so when you press the \"Go Back To Start\" button an alert view will pop up, as well as take you back to the initial view controller. The navigation controller will also be available in the app, so I do not want to take that out, however, having a \"Go Back To Start\" button at the end of each story line or path, will allow the user to not have to go back through the previous story line that they just came from, and rather save them a bit of taps.\n\nCode for my project\n\nThere (pictured above) is the code for one of the ends. However, I know I have messed up in making this code work. \n\nThe goBackOnTapped is referring to the \"Go Back To Start\" button.\n\nI am also willing to put up a copy of the file on an external site, of what I have so far if you would like to see otherwise into the code.\n\nYou can find the code here:\nLink to file via Canvas" ]
[ "ios", "swift", "xcode7-beta6" ]
[ "Laravel 5.1 - General error: 1005 Can't create table (mysql)", "I'm using laravel to migrate some data, but i'm having this message below:\n\n[Illuminate\\Database\\QueryException] \n SQLSTATE[HY000]: General error: 1005 Can't create table 'heinz.#sql-1e83_8' (errno: 150) (SQL: alter table `funcionarios` add constraint funcionarios_supervisor_id_foreign foreign key (`supervis \n or_id`) references `funcionarios` (`id`)) \n\n\nI tried a lot of thing, but didn't work.\n\nHere is the code of the migration file. (the relevant part).\n\nSchema::create('funcionarios', function (Blueprint $table) {\n\n// $table->engine = 'InnoDB';\n\n $table->increments('id');\n $table->string('nome', 60);\n $table->integer('matricula')->unsigned()->unique();\n $table->bigInteger('pis_pasep')->unsigned()->nullable();\n $table->date('data_admissao')->nullable();\n $table->date('data_demissao')->nullable()->default(null);\n $table->date('data_nascimento')->nullable();\n $table->string('apelido', 20)->nullable();\n $table->integer('supervisor_id')->nullable();\n $table->integer('coordenador_id')->nullable();\n $table->integer('gerente_id')->nullable();\n $table->integer('diretor_id')->nullable();\n $table->integer('sexo_id')->nullable();\n $table->integer('setor_id')->nullable();\n $table->integer('cargo_id');\n $table->integer('turno_id')->nullable();\n $table->timestamps();\n });\n\n Schema::table('funcionarios', function($table){\n\n $table->foreign('supervisor_id')->references('id')->on('funcionarios');\n $table->foreign('coordenador_id')->references('id')->on('funcionarios');\n $table->foreign('gerente_id')->references('id')->on('funcionarios');\n $table->foreign('diretor_id')->references('id')->on('funcionarios');\n $table->foreign('sexo_id')->references('id')->on('sexos');\n $table->foreign('setor_id')->references('id')->on('setores');\n $table->foreign('cargo_id')->references('id')->on('cargos');\n $table->foreign('turno_id')->references('id')->on('turnos');\n\n });" ]
[ "php", "mysql", "laravel", "laravel-5.1" ]
[ "Primitives and built-in functions in Racket", "Are primitives and built-in functions the same thing in Racket?\nIf no, what's the difference between them?" ]
[ "lisp", "racket", "primitive", "built-in" ]
[ "Can't deploy Parse background job", "I am trying to get a 'hello world' background job running on heroku and then extend upon that, however whenever I try to deploy it I get the following error: TypeError: undefined is not a function\n\nThe code is as follows, and I have regular cloud functions that work just fine so I know Parse is initialized etc, what am I doing wrong here?\n\nBroken background job\n\nParse.Cloud.job('myBackgroundJob', function(request, response)\n{\n console.log('Running background job');\n});\n\n\nWorking cloud code function\n\nParse.Cloud.define('sayHello', function(request, response)\n{\n console.log('hello world');\n});" ]
[ "javascript", "heroku", "parse-platform", "background-process", "parse-cloud-code" ]
[ "Spring batch writer append data from next to next line", "I am reading the data from DB and writing it to a plain text file using Spring batch. If I get 5 matching records, I am expecting to create a file with data in 5 lines. I am able to generate the file and everything works good except for the fact that each line is separated with a blank line in between.\nFor example:\nI am expecting the records to created as-\n\n1005 name1 lastname1 2017\n1006 name2 lastname2 2017\n1007 name3 lastname3 2017\n\nBut in actual file is getting created as-\n\n1005 name1 lastname1 2017\n\n1006 name2 lastname2 2017 \n\n1007 name3 lastname3 2017\n\nI am not sure why the extra line in between is coming up. Could anyone please help me resolve it?\n\nI am using below writer configuration:\n\n<bean id=\"flatFileItemWriter\" abstract=\"true\" class=\"org.springframework.batch.item.file.FlatFileItemWriter\">\n <property name=\"resource\" value=\"file:{fileLocation}\"/>\n <property name=\"lineAggregator\">\n <bean class=\"org.springframework.batch.item.file.transform.PassThroughLineAggregator\"/>\n </property>\n </bean>" ]
[ "spring", "spring-batch", "filewriter" ]
[ "Is there a prover just for propositional logic", "I tried to implement LTL logic syntactically using the axiomatization command, with the purpose of automatically finding proofs for theorems (motivation of proving program properties). \n\nHowever the automatic provers such as (cvc4, z3, e, etc) all use quantifiers of some sort. For example using FOL one could prove F(p)-->G(p) which is obviously false.\n\nMy question is if there exists a prover, just like the ones mentioned, but that is made for propositional logic, i.e. only has access to MP and the propositional logic axioms. \n\nI am rather new to isabelle so there might be an easier way of doing this im not seeing.\n\nEDIT: I am looking for a hilbert style deduction prover and not a SAT as this would defeat the problem of implementing it axiomatically" ]
[ "isabelle" ]
[ "IParameterInspector and Exception Handling", "In My WCF Service Methods I have an attribute defined. \nThis attribute class inherits from Attribute & IOperationBehavior and also adds IParameterInspector behavior. \nIParameterInspector Instantiated class provides BeforeCall & AfterCall methods.\n\nProblem: Any exceptions that are raised inside the method call from beforecall method are not caught.\nI have tried couple of solutions including IError available but none of them have worked.\n\nThis is my code: \nService Method:\n\n [OperationBehavior]\n [MyAuthorization(Role = Enums.PsoRoles.DiceQuote)]\n public List<Employee> GetEmployee(int eid)\n {\n try\n {\n return _empService.GetEmployee(eid);\n }\n catch (Exception ex)\n {\n _logger.Error(ex);\n throw new FaultException(ex.Message, new FaultCode(HttpStatusCode.InternalServerError.ToString()));\n } \n }\n\n public class MyAuthorization : Attribute, IOperationBehavior\n public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)\n {\n dispatchOperation.ParameterInspectors.Add(new MyAuthorizationParameterInspector());\n } \n\n public class MyAuthorizationParameterInspector : IParameterInspector\n public object BeforeCall(string operationName, object[] inputs)\n { ... } \n public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)\n { ... } \n\n\nThanks for your help." ]
[ "c#", "wcf" ]
[ "How to console custom radio value in angular", "I have created custom radio button.Here is the link Fiddle .\nEvery thing is working fine except when I try to console the value of radio in angular controller I am getting '(an empty string)'.\nThis is how I am trying to get radio value.\n\nconsole.log($scope.exist_popup);" ]
[ "javascript", "jquery", "angularjs" ]
[ "How to disable iPod Music Control when device screen is locked?", "I'm using MPMusicPlayerController in my app and it works fine in background.\n\nThe problem is I don't want user to control the song via iPod music app while device is locked?\n\nThank you for any helps." ]
[ "ios", "objective-c", "mpmusicplayercontroller" ]
[ "How to stop multiple post requests when user rapidly presses a submit button", "I am using flask and wtforms and if a user wants to rapidly press the submit button to send 10 or 15 post requests to the database the app will currently process all of the POST requests which is not cool. Is there a way to only process one post request for however many times the user should press the submit button within a certain time frame of the first submission, maybe? How do you handle this situation?" ]
[ "python", "flask", "wtforms" ]
[ "Can I pass all form data to a new popup window easily with javascript?", "I have a form that I would like to make printer friendly in a new popup window. To do this, I would need to pass all form data to the popup. Is there an easy way to do this, like passing the form itself? Any help is greatly appreciated." ]
[ "javascript", "forms", "popup" ]
[ "android getview of adapter class not called as ArrayList.size()", "hello all i have made one adpter class in that listCountry.size(); in getcount shows me the actual size that is of 500. But the getview call o*nly for 11 time*\n\npublic class ImageAdapter extends BaseAdapter {\n BitmapFactory.Options bmop;\n private ArrayList<String> listCountry;\n private Activity activity;\n\n public ImageAdapter(Activity activity, ArrayList<String> listCountry) {\n super();\n\n // this.listCountry = listCountry;\n this.listCountry = new ArrayList<String>();\n this.listCountry = listCountry;\n\n this.activity = activity;\n System.out.println(\"this is contry name \" + this.listCountry);\n\n }\n\n @Override\n public int getCount() {\n System.out.println(\"len \" + listCountry.size());// this shows 500\n return listCountry.size();\n }\n\n @Override\n public Object getItem(int position) {\n\n return listCountry.get(position);\n }\n\n @Override\n public long getItemId(int arg0) {\n // TODO Auto-generated method stub\n return arg0;\n }\n\n @Override\n public View getView(int arg0, View convertView, ViewGroup parent) {\n ViewHolder view;\n LayoutInflater inflator = activity.getLayoutInflater();\n if (convertView == null) {\n System.out.println(arg0+\" this is from Adpter \"+listCountry.get(arg0) );// this shows only first 11\n view = new ViewHolder();\n convertView = inflator.inflate(R.layout.item_grid_image, null);\n\n // Typeface typeface =\n // Typeface.createFromAsset(getAssets(),\"fonts/DroidSerif.ttf\");\n\n view.imgViewFlag = (ImageView) convertView\n .findViewById(R.id.image);\n view.pb = (ProgressBar) convertView\n .findViewById(R.id.progressBar1);\n\n // d.execute(\"http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png\");\n\n // view.imgViewFlag.setBackgroundResource(R.drawable.view_default);\n convertView.setTag(view);\n\n } else {\n view = (ViewHolder) convertView.getTag();\n }\n try {\n // view.txtViewTitle.setText(listCountry.get(position));\n // view.imgViewFlag.setImageResource(listFlag.get(position));\n //DownloadImageTask d = new DownloadImageTask(view.imgViewFlag);\n // d.execute(listCountry.get(arg0));\n\n } catch (Exception e) {\n System.out.println(\"this is error \" + e.getMessage());\n }\n\n return convertView;\n }\n\n }" ]
[ "android", "android-adapter" ]
[ "Why id function behaves differently with integer and float?", "I tried the following code and It gave me different output.\n\n>>> foo1 = 4\n>>> foo2 = 2+2\n>>> id(foo1)\n37740064L\n>>> id(foo2)\n37740064L\n\n>>> foo1 = 4.3\n>>> foo2 = 1.3+3.0\n>>> id(foo1)\n37801304L\n>>> id(foo2)\n37801232L\n>>>\n\n\nI am using python 2.7.2. Why id function return different value in case of float but same value in case of integers?" ]
[ "python", "python-2.7" ]
[ "AngularJS $crypto and ng-options", "I have the following code:\n\nAngular Code:\n\nvar app = angular.module('App',['mdo-angular-cryptography']);\n\napp.controller('AtvdCtrl', function($scope, $crypto, PassWD, $http){ \n\n $scope.frInEtAc = ''; //edited \n\n $scope.decriptar = function(dado){ \n return $crypto.decrypt(dado, $scope.PassWD.senha);\n }; \n\n //edited\n $scope.frnt = [];\n $http.get('myURL')\n .success(function(retorno){\n $scope.frnt = retorno;\n })\n .error(function(erro){\n console.log(erro); \n });\n\n $scope.Atvd = [];\n $http.get('myURL')\n .success(function(retorno){\n $scope.Atvd = retorno;\n })\n .error(function(erro){\n console.log(erro); \n });\n\n $scope.inicEtgaAc = [];\n $scope.acharInicAc = function(cd){\n $http.get('myURL' + cd)\n .success(function(returnoI){\n $scope.inicEtgaAc = returnIncEntregaA;\n })\n .error(function(erro){\n console.log(erro);\n });\n};\n};\n\n});\n\n\nHTML Code:\n\n<select id=\"nmFrInEtAc\" ng-options=\"opt.cdFrnt as (decriptar(opt.nmFrnt) | uppercase) for opt in frnt\" ng-model=\"frInEtAc\" ng-change='acharInicAc(frInEtAc)' ng-required='true'>\n <option style=\"display:none\" value=\"\"></option>\n</select>\n\n\nEspecifically in ng-options my function doesn't work.\n\nI have all the depencencies especified here: https://github.com/middleout/angular-cryptography\n\nIt does work in here:\n\n<div ng-repeat='atvd in Atvd>\n <span ng-bind='decriptar(atvd.nmAtvd)'/>\n<div/>" ]
[ "angularjs" ]
[ "Override the style sheet of a dependency in a maven project", "I have a dependency in a maven project which renders html pages. I want to change the style of a table since the view is getting cut off. How can I access the stylesheet of the table and inject rules into it? Using intellij as the IDE and the dependency is the FF4J package." ]
[ "maven", "dependency-injection", "overriding", "ff4j" ]
[ "VB.NET For each exception on custom controls", "in VB.NET i have 2 custom controls, one is a TextBox and second one is a ComboBox.\nThese have custom values like Bool _IsHidden and are added on runtime to a form.\n\nNow, at some point in the code I want to check if the _IsHidden is set to True or False and display that information. Since the user can edit this values when creating the control these are not set on creation.\n\nSo what I tried is:\n\n(all of this is on MDI Forms)\n\nFor Each frm as CustomForm in Main.MdiChildren\nIf frm.MyName = calledBy Then 'this part is just to know which form called the form to create the object\nFor Each cntrl as CustomTextBox in frm.Controls\n'DO Something\nNext\nEnd if\nNext\n\n\nNow.. if the first control is a custom ComboBox it thorws an error since it sees that it does not match the custom TextBox control.. \n\nhow do i get around this? By my understanding it should just go through all of the controls on the said form and just check those who match CustomTextBox control ?\n\nThank you" ]
[ "vb.net", "exception", "exception-handling", "for-loop", "each" ]
[ "Download image via webservice", "Hi there\nI have an IPhone application that is downloading data from a .net webservice.\nThe webservice uses the following:-\n\n[System.Web.Script.Services.ScriptService]\npublic class DownloadHelperService : System.Web.Services.WebService {\n\npublic DownloadHelperService () {\n\n //Uncomment the following line if using designed components \n //InitializeComponent(); \n}\n[WebMethod]\n[System.Web.Script.Services.ScriptMethod(UseHttpGet = false)]\npublic byte[] Download(string fileName)\n{\n return Facade.IOHelper.DownloadFileFromServer(fileName);\n}\n\n\n}\n\nThis method will in theory download an image file to the client. The issue is that this is being downloaded as Json which is inefficient.\nIf I take off the scriptmethod attribute and class level script then I cannot make the call from my IPhone application as it says that my method calls require the scriptmethod attributes.\n\nIf anyone can advise on the best route to download images from a webservice to an IPhone application using objective-c I would be eternally grateful" ]
[ "iphone", "asp.net", "objective-c", "web-services" ]
[ "Pythonic way to find the file with a given name closest to a specific directory location", "I'm currently in a project where I'm essentially trying to create a tree structure based on a number of scattered xml files that are, sadly, not very consistently organized. Specifically the point I'm at now is that given a number of files with a given file extension I want to be able to find the xml document that dictates their layout. Luckily the document always has the same name, but sadly the document isn't always in the same location relative to the media files I'm trying to link it to. The most sensible workaround I've found is looking for the closest file with a similar name in the directory structure. However, the only way I've managed to do this in Python is by going up directories and looking for the file in consideration by using os.walk. Sadly, this is pretty slow and I would like to be able to do this for a large number media files so I'm looking for a more elegant solution. Below is some example code showing my present approach:\n\nfrom os import listdir\nfrom os.path import isfile, join, realpath\n\ncurrent_directory = \"/path/to/example.mp3\"\nall_files = lambda path: [file for file in listdir(path) if isfile(join(path,file))]\n\nfilename = \"test.xml\"\nfound = False\nwhile found is False:\n current_directory = current_directory[:current_directory.rfind(\"/\")]\n current_files = all_files(current_directory)\n if filename in current_files:\n return current_files[current_files.index(filename)]\n\n\nThe directory structure isn't so bad that the above method will ever reach two file instances at once, but I still feel like the above method is not very pythonic and is a lot more convoluted than it really needs to be. Any ideas?" ]
[ "python", "directory", "traversal" ]
[ "Difference between ISession.Save/Update and ITransaction.Commit in NHibernate", "I have a piece of code that adds elements to entity collection (one-to-many relation). This is the version with ISession.Save\n\n using (ISession session = sessionFactory.OpenSession())\n {\n var package = session.QueryOver<Package>().Where(x => x.ID == selectedPackage).SingleOrDefault();\n foreach(var themeId in selectedThemes)\n {\n var selectedTheme = session.QueryOver<HBTheme>().Where(x => x.ID == themeId).SingleOrDefault();\n if (selectedTheme != null)\n {\n package.Themes.Add(new PackageTheme() { Package = package, Theme = selectedTheme });\n }\n }\n session.Save(package);\n }\n\n\nand that version didn't work for me. As I had test written with ITransaction, I changed it a little to the following:\n\n using (ISession session = sessionFactory.OpenSession())\n using (ITransaction transaction = session.BeginTransaction())\n {\n var package = session.QueryOver<Package>().Where(x => x.ID == selectedPackage).SingleOrDefault();\n foreach(var themeId in selectedThemes)\n {\n var selectedTheme = session.QueryOver<HBTheme>().Where(x => x.ID == themeId).SingleOrDefault();\n if (selectedTheme != null)\n {\n package.Themes.Add(new PackageTheme() { Package = package, Theme = selectedTheme });\n }\n }\n transaction.Commit();\n }\n\n\nand now it works. Elements in package.Themes collection are stored in database. How come? Thanks!" ]
[ "hibernate", "nhibernate" ]
[ "Lucene multiple categories facets with one query (facets graph)", "We have a website with multiple facets (types, codes, colors for simplicity) and we want to show numbers for each category. \n\nCategories are not really hierarchical but we would like to implement (we don't know if it is really wise to do so) a way to show numbers on sub selection without executing a new sub query that uses a filter with the selection.\n\nLet's do an example.\nWe have in the main page this layout:\n\nTYPE\nA (20)\nB (5)\n\nCOLORS \nred (10)\nblue(15)\n\nCODES\naa (10) \nbb (15)\n\n\nWhen we select Type A we now perform a new query to obtain the facets of the new configuration es:\n\nTYPE\nA (20)\n\nCOLORS \nred (8)\nblue(12)\n\nCODES\naa (6) \nbb (14)\n\n\nIs there a way to use hierarchical facets to get the number of the \"virtual sub categories\"? \n\nTheorically it would be like defininig facets with A/red/aa A/red/bb, A/blue/aa, A/blue/bb if we consider the type as first selection or creating a permutation of possible values to have a generic implementation of it.\n\nIs there an official way to achieve it? Is it better just to create a total new query instead of building this \"graph of facets\"?" ]
[ "lucene", "facets" ]
[ "Actionscript / CS5 font embedding problems", "I'm working on a very large Flash game project, and we've run across a problem that is extremely annoying.\n\nEvery third (or so) compilation, apparently randomly, CS5 doesn't embed the entire character set for a certain font into our application. We notice this when certain characters are missing in various places in the game. I can reproduce this problem by recompiling several times; sometimes the font will be embedded, sometimes not.\n\nHas anyone run into a similar issue, and if so, how did you solve it? Any ideas on how to figure out the cause of this problem?" ]
[ "flash", "actionscript-3", "actionscript", "fonts", "flash-cs5" ]
[ "how to assign parent class public variable to child class public variable in php", "I have created two class, Assigning public class variable to child class variable but not working properly.But the same variable assign working inside function correctly.I didn't get proper reason why like that.Please check below example.\n\n <?php\n Class pratice{\n public $a=4;\n }\n Class child extends pratice{\n //public $b =$this->a;//getting error with this assigment\n public function getValue(){\n $this->b = $this->a;//working fine with this\n echo $this->b;\n }\n }\n $obj = new child();\n $obj->getValue();\n ?>\n\n\nThanks in advance." ]
[ "php", "oop" ]
[ "How to extract table from a webpage", "I have been trying to extract the table from a webpage.\nI don't know what to do next here is what I wrote.\n\nimport requests\nfrom bs4 import BeautifulSoup\npage= requests.get('http://www.moneycontrol.com/financials/nmdc/ratios/NMD02')\nsoup = BeautifulSoup(page.text, 'html.parser')\ntable = soup.find(class_='tabns MR10')\n\n\nand now I don't know what to do. I can't find table." ]
[ "python", "html", "python-3.x", "beautifulsoup", "python-requests" ]
[ "Filter out substrings that include keywords in a text in Javascript with Regex", "I have a solve a complex problem: \nI want to filter out substrings from a possible long text. There are certain keywords that indicate a substring. Only if a keyword is preceeded by at least one character, which is not a white space or a different keyword, should match. Then also every character they keyword is preceeded by should be included in the match. I want to use a regex expression in JavaScript for this. \n\nMy keywords are: \":yellow:\", \":black:\", \":green:\", \":blue:\" \":red:\"\n\nFor example I have a Text like this: \" :green: aba :red: gd efg:blue: :yellow: sdg:red: sea gea e :black: \"\n\nNow I want to use match() on this string with a re that gives me these matches: \" aba :red:\", \"gd efg:blue\":, \"sdg:red:\", sea gea e :black: \n\n:green: at the start should not be matched, because it is not preceded by a character. :yellow: should also not be matched, because it is preceded by a different keyword (in this case :blue:) \n\nI have tried to use negative lookahead expressions (like (?!)) to prevent matching when keywords preceed other keywords. \nBut it didn't quite give me the results I am looking for.\n\n\r\n\r\n /((?!(:yellow:|:black:|:green:|:blue:|:red:))\\S+\\s*)+(:yellow:|:black:|:green:|:blue:|:red:)/g\r\n \r\n let ar1 = text1.match(re1);\r\n \r\n console.log(ar1);\r\n\r\n\r\n\n\nthis is my output: \n[ 'green: aba :red:',\n 'gd efg:blue: :yellow:',\n 'sdg:red: sea gea e :black:' ]\n\nbut i want this: \n\n[ ' aba :red:',\n 'gd efg:blue: ',\n 'sdg:red:',\n 'sea gea e :black:' ]" ]
[ "javascript", "regex" ]
[ "javascript ussing ssh to run server program", "Project: creating a webpage to connect to a server and execute any command or program and retrieve the output to the client web page.\n\nI have developed same functionality unsing Socket_io and node.js..\nBut every time I have to run first \"node file.js\" in client cmd and the open the webpage to execute the program from sever.\n\nI there any simple JavaScript which automatically run automatically web opening a webpage and connect to the server using ssh and retrieve the output of and executable file instead of running some extra files on cmd ,etc." ]
[ "javascript", "html", "node.js" ]
[ "delphi records and c structs", "Task:\n\nApplication written in Delphi accepts a structure (record in terms of Delphi) of three fields. I can send the pointer of this structure using SendMessage (Win32 API) function.\n\nSo a question is:\n\nHow to maintain certain structure representation in memory for Delphi in terms of Delphi?\n\nIt has type\n\nPWPModPostData = ^ TWPModPostData;\nTWPModPostData = record\n DataType: Integer;\n Data: PChar;\n Next: PWPModPostData;\nend;\n\n\nHow to define it in C? I mean, is there any hidden or service fields in Delphi structures?" ]
[ "c", "delphi", "struct", "record" ]
[ "How to overlay a directional mean to hexbin plot in Matplotlib?", "For Data Analysis purposes, I was trying to overlay information (like mean or median) over hexbin plots in Matplotlib.\nAs I did not encounter a solution on the web allowing to do so, I would like to share the solution that I'm using so far.\nAny suggestions or comments welcome. Same goes for a prettier or more pythonic solution :)\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef hexbin_red(mp_hex, ax="x", red_func=np.mean, mincnt=15):\n # Get x,y centers\n verts = mp_hex.get_offsets()\n cnts = mp_hex.get_array()\n \n # Prepare output arrays\n xx = []\n yy = []\n \n # Group by x or y value\n xvals = verts[:,int(0)]\n yvals = verts[:,int(1)]\n \n if ax=="x":\n aa = xvals\n bb = yvals\n elif ax=="y":\n aa = yvals\n bb = xvals\n else:\n raise ValueError(f"`ax` must be x or y not {ax}")\n \n a_unique = np.unique(aa)\n \n for k,val in enumerate(a_unique):\n xx.append(val)\n tmp_cnt = cnts[aa == val].astype(int)\n tmp_val = bb[aa == val]\n tmp = np.repeat(tmp_val, tmp_cnt)\n \n if len(tmp) > mincnt:\n yy.append(red_func(tmp))\n else:\n yy.append(np.nan)\n \n return np.array(a_unique), np.array(yy)\n \n\nnx = 3000 \nx = np.linspace(0,6.28,nx)\ny = np.sin(x)\nyn = y + np.random.rand(nx) * 0.5 - 0.25\nfig, ax = plt.subplots(figsize=(6,2))\nim = ax.hexbin(x,yn, mincnt=1,gridsize=40, cmap="terrain")\n\n# Horizontal avg\nx,y = hexbin_red(im,mincnt=3)\nax.plot(x,y,color="darkred",alpha=1,label="horzon. average",zorder=5)\n\n# Vertical avg\nx,y = hexbin_red(im,ax="y", mincnt=3)\nax.plot(y,x,color="blue",alpha=1,label="vertical average",zorder=5)\n\nax.legend()\nfig.savefig("hexbin_example.png", bbox_inches="tight")\nplt.show()" ]
[ "python", "matplotlib", "plot" ]
[ "Change title based on presence of params", "I currently have a project for data storage records.\n\nThere is a nested resource, disks -> works.\n\nI can then filter works index based the presence of params[:disk_id].\n\nThe h1 to the page is always \"Works\".\nI want it to change to \"Works in Disk x\", if there is a params[:disk_id] present.\n\nHaven't managed to get a simple DRY way to manage this. Any tips?" ]
[ "ruby-on-rails-3" ]
[ "hide before load completed -jquery", "I have tried this code to hide the body, and show when is loaded in totality. But I noticed that is not working well, because when the fade occurs, some images are not yet loaded.\n\nHow I can do this effect?\n\n<script type=\"text/javascript\">\n$(document).ready(function(){\n$('.nav').fadeIn(700);\n});\n</script>\n\n\n<body class=\"nav\" style=\"display: none\">" ]
[ "javascript", "jquery", "load", "hide", "fade" ]
[ "How can I configure ProxyPass in the case of both directory path only and with file path", "What I want is a redirect configuration like the following.\nhttps://example.com/abc => https://test.com\nhttps://example.com/abc/test.html => https://test.com/abc/test.html\n\nI am trying to do that but not working yet.\nProxyPassMatch ^/abc/$ https://test.com\nProxyPass /abc https://test.com/abc\n\nAny help will be appreciated." ]
[ "apache", "proxypass" ]
[ "Why Laravel provides default timestamps?", "When we create a new Model or database migration in Laravel we can use $table->timestamps(); which creates created_at and updated_at by default. Why does a project required these fields in the view of a best project structure?" ]
[ "php", "laravel-5.6", "laravel-5.7" ]
[ "Entity Framework save error on removed list items", "I'm getting a strange error when trying to save an object with a removed-from list of sub-objects using Entity Framework.\n\nSpecifically, I've got a list of objects of type 'a'. These objects connect with each other via a connection object of type 'b'. An 'a' object can hold many 'b' objects, and each 'b' object holds only a single 'a' object. So basically, I have a network of 'a' objects with 0 or more connections to other 'a' objects via 'b' objects.\n\nA given 'a' object's list of 'b' objects is variable; 'b' objects can be added or removed from an 'a' object's list. However, when a 'b' object is removed from an 'a' object's list, this sometimes causes Entity Framework to error out when trying to save the network of 'a' objects later on down the line. An 'a' object's 'b' object removal code looks like this:\n\npublic void RemoveConnection(b connectionObject)\n {\n myBObjects.remove(connectionObject);\n }\n\n\nThis method works fine when the code is running, and the 'a' objects have a correct list of 'b' objects at save time. The following is the save code:\n\nusing (var db = new PersistenceContext())\n {\n db.NetworkOfAs.Add(network);\n db.SaveChanges();\n }\n\n\nIf a 'b' object has never been removed from an 'a' object's list of 'b' objects, the above works just fine. If a 'b' object is removed from an 'a' object's list of 'b' objects but the list of 'b' objects remains greater or equal to length 1, the above also works fine. However, if a 'b' object was added and then removed from an 'a' object's list of 'b' objects such that the 'a' object's list of 'b' objects returns to length 0, I get the following error:\n\nThe INSERT statement conflicted with the FOREIGN KEY constraint \n\"FK_dbo.BObjects_dbo.AObjects_Id\". The conflict occurred in database \n\"NetworkDatabase.PersistenceContext\\\", table \\\"dbo.AObjects\\\", column 'Id'\n\n\nI've been digging into debugging this for several days now, and it seems pretty apparent that this is being caused by Entity Framework trying to save the 'b' objects which have been removed from a given 'a' object's list of 'b' objects. However, I have no idea how to prevent this, and can't seem to find anything describing this particular issue.\n\nAny help is much appreciated, and if this explanation is missing any necessary details please let me know." ]
[ "c#", "entity-framework" ]
[ "Error when creating a SQL script", "Here's the script:\n\ncreate procedure sp_DescuentoAlquiler\nas\ndeclare @IDAlquiler int, @NumeroPelicula int, @MontoTotal float\n\ndeclare cursorAlquiler cursor for\nselect a.ID, count(d.ID) as @NumeroPelicula \nfrom Alquiler a inner join DetalleAlquiler d on a.ID = d.IDAlquiler\ngroup by a.ID\n\nopen cursorAlquiler\n fetch next from cursorAlquiler into @IDAlquiler, @NumeroPelicula\n while @@FETCH_STATUS = 0\n begin\n if(@NumeroPelicula >= 3)\n begin\n select @MontoTotal = SUM(d.PrecioAlquiler)\n from DetalleAlquiler d where d.IDAlquiler = @IDAlquiler\n update Alquiler set MontoTotal = @MontoTotal * 0.3\n where ID = @IDAlquiler\n end\n fetch next from cursorAlquiler into @IDAlquiler, @NumeroPelicula\n end\n\nclose cursorAlquiler\ndeallocate cursorAlquiler\n\n\nI'm getting an error in Line 6 after count(d.ID), on @NumeroPelicula:\n\n\n Msg 102, Level 15, State 1, Procedure\n sp_DescuentoAlquiler, Line 6 Incorrect\n syntax near '@NumeroPelicula'.\n\n\nAny suggestions?" ]
[ "sql-server", "tsql" ]
[ "RecyclerView custom animation while scrolling", "I have a RecyclerView with multiple CardViews. These I expand and collapse by using this code in my onBindViewHolder:\n@Override\npublic void onBindViewHolder(final ViewHolder holder, int position) {\n \n    holder.cardView.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n            if (holder.hiddenLayout.getVisibility() == View.VISIBLE) {\n                TransitionManager.beginDelayedTransition(holder.cardView,\n                        new AutoTransition());\n                holder.hiddenLayout.setVisibility(View.GONE);\n            } else {\n                TransitionManager.beginDelayedTransition(holder.cardView,\n                        new AutoTransition());\n                holder.hiddenLayout.setVisibility(View.VISIBLE);\n            }\n        }\n    });\n}\n\nMy Problem is, when I scroll while the animation takes place the cards get badly brought up and become extremely warped. How can I avoid that to happen?" ]
[ "java", "android", "android-recyclerview", "android-animation" ]
[ "Custom primary key in database", "Context\nDesigning database for Automotive industry, client is asking me for a human intuitive ID like desired output.\nInput\n(in a readable non source specfic format)\nColumn car_id [pk, increment] = 1\n\nColumn country = "US"\n\nColumn make = "FORD"\n\nColumn model = "RANGER"\n\nDesired output\nColumn car_id [pk, increment] = US-FOR-1 # New\n\nColumn country = "US"\n\nColumn make = "FORD"\n\nColumn model = "RANGER"\n\nAdditional info\nI work with python's pandas library, output saved as .csv and uploaded to MySQL. Feeling insecure, is this a good approach for what i am doing? Data cleaning and query setup for final user." ]
[ "python", "mysql", "sql", "pandas", "database" ]
[ "Azure DevOps use module from another repository in different project", "I have my coding project in Azure DevOps and I would like to use Terraform modules I create. However I would like to keep terraform and my application each in different project.\nI am having issues when I want to use Terraform inside AZ Pipelines, I receive the following error when I run my pipeline:\n - task: Bash@3\n displayName: 'DEBUG'\n inputs:\n targetType: 'inline'\n script: |\n git config --get-all --global http.https://dev.azure.com/my-organization/Infra/_git/terraform-modules.extraheader "Authorization: bearer $SYSTEM_ACCESSTOKEN"\n terraform init\n env:\n SYSTEM_ACCESSTOKEN: $(System.AccessToken)\n\nOutput\nError: Failed to download module\n\nCould not download module "iam" (aws_ecs.tf:11) source code from\n"git::https://dev.azure.com/my-organization/Infra/_git/terraform-modules": error\ndownloading 'https://dev.azure.com/my-organization/Infra/_git/terraform-modules':\n/usr/bin/git exited with 128: Cloning into '.terraform/modules/iam'...\nfatal: could not read Username for 'https://dev.azure.com': terminal prompts\ndisabled\n\n\nModule source is configured like this:\n source = "git::https://dev.azure.com/my-organization/Infra/_git/terraform-modules//modules/ecs-iam"\n\nAZ DevOps settings (images):\n\nProjects Schema\nOrganization / Settings / Pipelines\nProject Settings / Pipelines / Settings\n\nOn the local machine, everything works fine, the module is cloned OK.\nI have tried to follow the official guide https://www.terraform.io/docs/modules/sources.html\nIs this even possible?" ]
[ "git", "azure", "azure-devops", "azure-pipelines" ]
[ "Powsershell reading server list from a text file", "I am having trouble with powershell reading my servers from a text file. When I declare a variable with get-content but when i call it, powershell doesnt read the server names. Here is the code.\n\n$Server = Get-Content C:\\servers.txt\n\nGet-WmiObject -Class Win32_PerfFormattedData_PerfOS_System -ComputerName $Server |\n Select-Object @{Name = “ComputerName”; Expression = {$_.__SERVER}},\n@{Name = “SystemUpTime”; Expression = {New-TimeSpan -Seconds $_.SystemUpTime}}| Export-CSV C:\\test2.txt.\n\n\nIf I change the $server to the list form It will work. Any ideas?" ]
[ "powershell" ]
[ "Is there a way to restrict Google Sign In to a certain email domain in Android?", "Is there a way to restrict Google signIn in the app to certain emails with domain @companyname.com? \n\nThe goal is to let only @companyname.com users only to gain access in the log in features.\n\nI have done some research but I have come up with nothing yet." ]
[ "java", "android", "google-signin", "googlesigninapi" ]
[ "Submenu with pure html and css disappears", "I am trying to make a dropdown menu with pure html and css, but the submenus disappear when the cursor leaves the parent li, thus preventing me from clicking on the submenu. Here is a link to the test site, link text\n\nI would really appreciate some help.\n\nRoland A." ]
[ "html", "css", "submenu" ]
[ "C++ how to make a class function a friend of another class in a different namespace", "My question is in relation to making a function in a class a friend of another class. Both classes are in different namespaces though. \n\nFor example the example below does not compile as it says that namespace o doesn't exist. \n\nnamespace m\n{\n class Value\n {\n friend std::vector<std::string> m::o::returnList();\n }\n}\n\n\nnamespace m\n{\n namespace o\n {\n class Operation\n std::vector<std::string> returnList() const;\n }\n}" ]
[ "c++" ]
[ "Initializing objected created in .NET CollectionEditor with a specific reference", "I need to initialize any new objects created with CollectionEditor with a specific reference. \n\nMore specifically, I have an object, Pipeline, that can be edited in the PropertyGrid. This object contains a collection of Markers. Markers need a reference to Pipeline in order to do some calculations. \n\nCurrently, the PropertyGrid for Pipeline has an entry for Markers. Clicking on the ellipse button brings up the CollectionEditor. Editing properties is fine, but I need to also set the current Pipeline for any new Markers created. I'm not sure of the best way to do that. Are there events I can monitor? Do I need to create a custom CollectionEditor (but how would it know anything about a specific Pipeline?)?" ]
[ ".net", "collectioneditor" ]
[ "I cannot get the accessibility working in the default 'Welcome to React Native!\" APP", "I cannot get the accessibility working in the default 'Welcome to React Native!\" APP. I added the accessibility attributes to my <View> tag. Then I run this App and enable VoiceOver, but it reads every Text alone and not together, as a block of Texts.\n\nIn the ReactNative Accessibility documentation says that: \"when a view is an accessibility element, it groups its children into a single selectable component\". I cannot understand why VoiceOver don´t read the Texts as a block.\n\nFuthermore, VoiceOver don´t read an \"accessibilityLabel\" attribute.\n\nI cannot found any solution to my problem on the internet. It seems like I am doing some wrong...\n\nThis is my code:\n\nrender() {\n return (\n <View style={styles.container} accessibility={true} accessibilityLabel=\"Say something!!\"> \n <Text style={styles.welcome} >\n Welcome to React Native!\n </Text>\n <Text style={styles.instructions}>\n To get started, edit index.ios.js\n </Text>\n <Text style={styles.instructions}>\n Press Cmd+R to reload,{'\\n'}\n Cmd+D or shake for dev menu\n </Text>\n </View>\n );\n }\n\n\nTest device: Iphone 6 iOS 9.2\n\nReact-Native-cli: 0.1.10\n\nReactNative version: 0.19.0" ]
[ "android", "ios", "accessibility", "react-native" ]
[ "Looking for a free SaaS for Text-to-Speech (TTS)", "I'm looking for a free web-based TTS engine, that I may use in a commercial project. I'm not saying there's one, but I hope somebody might know if there was.\n\nThanks!" ]
[ "text-to-speech", "saas" ]
[ "verify that my repo it's in fact a github repo URL in Go", "Is there a method in Go to verify that a repo type string is in fact an actual Github repo URL?\nI'm running this code that clones a repo, but before I run exec.Command("git", "clone", repo) and i want to make sure that repo is valid.\n package utils\n\n import (\n "os/exec"\n )\n\n //CloneRepo clones a repo lol\n func CloneRepo(args []string) {\n\n //repo URL\n repo := args[0]\n\n //verify that is an actual github repo URL\n\n //Clones Repo\n exec.Command("git", "clone", repo).Run()\n\n }" ]
[ "regex", "go", "package", "goland" ]
[ "R collapse and auto fill blanks in rows", "I have the following example dataset:\n\nID = c(123,123)\nNAmer = c(\"ABC\",\"ABC\")\nfield1 = c(1,NA)\nfield2 = c(NA,2)\nfield3 = c(NA,NA)\nfield4 = c(NA,NA)\nfield5 = c(NA,NA)\nIHave <- data.frame(ID,NAmer,field1,field2,field3,field4,field5)\nIwant <- c(123,\"ABC\",1,2,NA,NA,NA)\n\n\nHow do I go from IHave to Iwant using data.table or tidyverse?\n\nIn practice I have some 000 rows." ]
[ "r", "data.table", "tidyverse" ]
[ "onRun of android-priority-jobqueue not called", "I am trying to integrate android-priority-jobqueue in android but onRun is not called i dont know what i am doing wrong.\n\nHere is my Job class \n\npublic class UpdateAttachmentJob extends Job {\n\n long id;\n String token;\n private static final String GROUP = \"attachment\";\n public static final int PRIORITY = 1;\n\n public UpdateAttachmentJob(long id,String token) {\n super(new Params(PRIORITY).requireNetwork().persist());\n this.id=id;\n this.token=token;\n }\n\n @Override\n public void onAdded() {\n\n }\n\n @Override\n public void onRun() throws Throwable {\n\n AttachmentTable tableItem = QueryClass.getData(id);\n\n new UpdateAttachmentsService().updateAttachment(id, tableItem.Name, tableItem.Description, tableItem.filePath,token ,new ApiCallBack() {\n\n @Override\n public void onSuccess(Object object) {\n\n BaseClass baseClass = (BaseClass) object;\n if (baseClass.getStatus() == Constants.status) {\n QueryClass.deleteSyncTask(id);\n }\n\n }\n\n @Override\n public void onError(Object object, String message) {\n\n }\n });\n\n }\n\n @Override\n protected void onCancel() {\n\n }\n}\n\n\nHere is how i call the job\n\nif (mjobManager==null)\n mjobManager=new JobManager(context);\n\n mjobManager.addJobInBackground(new UpdateAttachmentJob(id,token));\n\n\nWhat am i doing wrong, how to make it work" ]
[ "android", "android-priority-jobqueue" ]
[ "Redirecting input and output of a child process in C", "I want to write a c program in which i create multiple child processes and redirect their inputs and outputs to different file descriptors .I googled a lot but couldn't find relevant results. Please help ." ]
[ "c", "process", "file-descriptor", "io-redirection", "child-process" ]
[ "Loop causes Firefox to crash", "So it seems like this javascript loop will sometimes cause my Firefox to overload and crash. I just don't understand why. \n\n //prep genresArray\n var genPrint = \"\"; //variable initialized to avoid \"undefined\" in print loop\n var GAL = movieListLocal[i].genresArray;\n for(var i=0; i<2; i++){\n genPrint = genPrint+GAL[i].name+\", \";\n }\n\n\ngenresArray contains a number of genre-objects, each one with a id and a name (such as adventure, horror etc). I simply want to turn into into a continuous string instead." ]
[ "javascript", "jquery", "loops", "firefox", "crash" ]
[ "How to pass long number through javascript?", "I want to convert numberLong date from the mongo db database into dd/mm/yyyy format in javascript. \n\nWhen I put direct hardcoded value like the following code, it gives me correct result: \n\nfunction getDateIfDate(d) {\n var m = d.match(/\\/Date\\((\\d+)\\)\\//);\n return m ? (new Date(+m[1])).toLocaleDateString('en-US', {month: '2-digit', day: '2-digit', year: 'numeric'}) : d;\n}\n\nconsole.log(getDateIfDate(\"/Date(1460008501597)/\"));\n\n\nHere is my code : \n\nfor(var i=0;i<keys;i++)\n {\n var tr=\"<tr>\";\n tr+= \"<td><input type='checkbox' name='record'></td>\"\n tr+=\"<td>\"+positionList[i][\"fromDate\"]+\"</td>\";\n var j = (positionList[i][\"fromDate\"]);\n console.log(\"value of j is ==========\"+j);\n console.log(getDateIfDate(\"/Date(j)/\")); // actual conversion should happen here\n}\n\n\nWhat changes I should make in my code to get the date in required format?" ]
[ "javascript", "jquery", "logic" ]
[ "Create draggables by dragging mouse", "I am new to JQuery library. I am currently trying to create a Draggable by mouse. Say, when I press the mouse it start to draw and then I drag the mouse to change the size and then I release the mouse to finalize the drawing.\n\nIs it possible to do this with JQuery?" ]
[ "javascript", "jquery", "draggable" ]
[ "How to get total to display on vue component from vuex store?", "I creating a cart system whereby my home component can add elements to my cart component and all this is persisted in my store. I would like to calculate the total of all products in cart, in my vuex store and present the value in the cart component. When i try doing this i get NaN. My code is below. How would i go about solving this?\n\nthis is within my cart component whereby cartdata is the array in which all the cart components are stored within the vuex store\n\ntotal: function(){\n let tot = 0;\n this.$store.state.cartdata.forEach(product => tot += \n this.$store.state.products.price);\n return tot;\n }\n\n\nThis is how i present the total in the vue component.\n\nCheckout ( Total: {{total}} )" ]
[ "javascript", "arrays", "vue.js", "store", "vuex" ]
[ "how to scanf when you have string and double variables", "I need to scanf data in this form: string whith spaces: 22.22kn 2.22L . (kn-kuna is croatian cuurency)\nSo I need to save it in one string an two double variables and I need to avoid colon, blank spaces,kn and L.\nI tried this: \n\n scanf(\" %[^:] %lfL %lfkn\\n\",tmpName,&tmpQuant,&tmpPrice)" ]
[ "c", "string", "double", "scanf" ]
[ "C++ Operator Overloading in expression", "I'm sure this has already been answered somewhere, but I don't know what to search for.\n\nI have the following situation. I made a Vector class and overloaded the \"*\" (multiply by escalar) and the \"+\" operators (add two vectors). Now, the following line of code:\n\nVector sum = (e_x*u_c) + (e_y*u_r);\n\n\nThis gives me the following error:\n\nerror: no match for 'operator+' in '((Teste*)this)->Teste::e_x.Vector::operator*(u_c) + ((Teste*)this)->Teste::e_y.Vector::operator*(u_r)'\n\n\nBut, if I replace this error line by:\n\nVector aux = (e_x*u_c);\nVector aux2 = (e_y*u_r);\nVector sum = aux + aux2;\n\n\nI get no errors at all. Why? Aren't those two expressions meant to be equivalent?\n\nEDIT:\nHere are my the definitions of \"*\" and \"+\":]\n\nVector Vector::operator+(Vector& right)\n{\n return Vector(x + right.x, y + right.y, z + right.z);\n}\ndouble Vector::operator*(Vector& right)\n{\n return this->scalar_product(right);\n}" ]
[ "c++", "expression", "overloading", "operator-keyword" ]
[ "Android Studio WebView shouldOverrideUrlLoading Toast Message Not Showing", "I want to show toast message when the link is loading... it's working when i'm replace the toast message into shouldOverrideUrlLoading but another activity isn't showing the toast. how to do this for all my webview activity?\n\nMy code is:\n\n @Override\n public boolean shouldOverrideUrlLoading(WebView view, String url) {\n Toast.makeText(Bdnews24.this, \"Loading...! Please Wait\", Toast.LENGTH_SHORT).show();\n view.loadUrl(url);\n return super.shouldOverrideUrlLoading(view, url);\n }" ]
[ "java", "xml", "android-studio", "toast", "android-toast" ]
[ "Can't access my website using IP/~account, showing not supported", "I can't access my temporary URL, it just shows \"Not Supported\". I uploaded laravel files. i've configured the index.php and .envshowing not supported" ]
[ "laravel", "cpanel" ]
[ "PHP file download empty", "Please help, this code downloads file but file is empty(0byte) but inside the folder its 1mb.\nfunction dowloadbooks($id){\n$allbooks ="SELECT * FROM books_table WHERE books_id = '$id' ";\n$result=$this->conn->query($allbooks);\n$row = array();\n\nif($result->num_rows >0){ \n\nwhile($res = $result->fetch_assoc()){\n\n$row = $res['book_upload'];\nheader('Content-Description: File Transfer');\nheader('Content-Type: application/octet-stream');\nheader('Content-Disposition: attachment; filename=' .$row.'');\nheader('Expires: 0');\nheader('Cache-Control: must-revalidate');\nheader('Pragma: public');\nheader('Content-Length: ' . filesize($row));\nreadfile($row); \n} \n} \nreturn $row;\n}" ]
[ "php" ]
[ "How to redirect after view rendering is complete in cakephp 2.3", "I am using cakephp 2.3 and required to redirect user after the excel sheet is downloaded successfully. I am using the cake $this->response->type for setting the view as excel sheet generator.\n\npublic function admin_export_excel($task_lists = array()) {\n $task_ids = $task_lists;\n $global_task_array = array();\n $this->loadModel('Task');\n //-> For each task-id run the loop for fetching the related data to generate the report.\n foreach ($task_ids as $index => $task_id) {\n //-> Check if the task exists with the specified id.\n $this->Task->id = $task_id;\n if (!$this->Task->exists())\n throw new NotFoundException('Task not found.');\n\n //-> Now check if the logged user is the owner of the specified task. \n $task_count = $this->Task->find('count', array('conditions' => array('Task.id' => $task_id,\n 'Task.user_id' => $this->Auth->user('id'))));\n if ($task_count == 0)\n throw new NotFoundException('Task not accessable.');\n\n $task_data = $this->Task->find('first', array(\n 'conditions' => array(\n 'Task.id' => $task_id\n ),\n 'contain' => array(\n 'TaskForm' => array(\n 'fields' => array('TaskForm.id', 'TaskForm.reference_table')\n ),\n 'Project' => array(\n 'fields' => array('Project.id', 'Project.project_name')\n ),\n 'User' => array(\n 'fields' => array('User.id', 'User.company_name')\n ),\n 'Timezone' => array(\n 'fields' => array('Timezone.id', 'Timezone.name')\n )\n )\n )\n );\n // debug($task_data);\n\n $global_task_array[$index] = $task_data;\n\n //-> End of Custom else conditions \n unset($task_data);\n }\n\n $this->set('global_task_array', $global_task_array);\n $this->response->type(array('xls' => 'application/vnd.ms-excel'));\n $this->response->type('xls');\n $this->render('admin_export_excel');\n}\n\n\nand my view file is\n\n $this->PhpExcel->createWorksheet();\n$this->PhpExcel->setDefaultFont('Calibri', 13);\n\n$default = array(\n array('label' => __('Task Id'), 'width' => 'auto'),\n array('label' => __('Unique Code'), 'width' => 'auto'),\n array('label' => __('Site Name'), 'width' => 'auto'),\n array('label' => __('Area'), 'width' => 'auto'),\n array('label' => __('Location'), 'width' => 'auto'),\n array('label' => __('Sub Location'), 'width' => 'auto'),\n array('label' => __('About Task'), 'width' => 'auto')\n );\n\n$this->PhpExcel->addTableHeader($default, array('name' => 'Cambria', 'bold' => true));\n$this->PhpExcel->setDefaultFont('Calibri', 12);\n foreach ($global_task_array as $index => $raw) {\n $data = array(\n $raw['Task']['id'],\n $raw['Task']['unique_code'],\n $raw['Task']['site_name'],\n $raw['Task']['area'],\n $raw['Task']['location'],\n $raw['Task']['sub_location'],\n $raw['Task']['about_task']\n );\n\n $this->PhpExcel->addTableRow($data);\n } \n $this->PhpExcel->addTableFooter();\n $this->PhpExcel->output('Task-' . date('d-m-Y') . '.xlsx');\n\n\nI have tried to use the cake afterFilter method for to redirect the user to other action after the excel sheet is generated but its not working.\n\npublic function afterFilter(){\n parent::afterFilter();\n\n if($this->request->params['action'] == 'admin_export_excel'){ \n $this->redirect(array('controller' => 'tasks', 'action' => 'index','admin' => true));\n }\n}\n\n\nAny help will be appreciated. Thanks" ]
[ "phpexcel", "cakephp-2.3" ]
[ "assign a running number on variables in python df", "evaluating calibration data\nFor a system calibration I need to compare reference ('ref') and test ('test') variables. df looks like this (section out of a df with >3000 variables):\n df=pd.read_csv(file)\n df\nTime ref test\nsec Q Q\n1 nan nan\n2 nan nan\n3 5,00 4,89\n4 5,08 5,00\n5 4,93 4,97\n6 nan nan\n7 nan nan\n8 14,83 14,96\n9 14,87 15,13\n10 14,72 14,83\n11 nan nan\n12 nan nan\n13 nan nan\n14 nan nan\n15 24,37 24,35\n16 24,29 24,39\n17 24,28 24,50\n18 24,26 24,41\n19 nan nan\n\nFor comparing the variables 'ref' and 'test' I need to extract the plains with hysteresis. Could do it manual:\n grades = []\n for row in df['ref']:\n if row < 5,5:\n grades.append('A')\n elif row < 15,5:\n grades.append('B')\n elif row < 26:\n grades.append('C')\n else:\n grades.append('Failed') \n df['Result_Ref'] = grades\n df.dropna(inplace=True)\n\nBut the function should evaluate the 'ref' and 'test' by an hysteresis (+-3%) and assign A, B, C,... automaticly. Result should look like this:\n df\nTime ref test Result_Ref\nsec Q Q\n3 5,00 4,89 A\n4 5,08 5,00 A\n5 4,93 4,97 A\n8 14,83 14,96 B \n9 14,87 15,13 B \n10 14,72 14,83 B\n15 24,37 24,35 C\n16 24,29 24,39 C\n17 24,28 24,50 C\n18 24,26 24,41 C\n\nas time and steps/plains (A, B, C, ....Z) are unlimited (up to 20), the function I'm searching for should search in the df ('ref', 'test') for next (big) step. Something like\nwhen x(i+1)>x(i)), than append('A:Z') \n\nand assign a running variable (1,2,3,.. or A, B, C,..) into column 'Result_Rev'.\nHere is the complete graph to this point\nfull calibration with extracted plains\nAs I'm quite new to python I have no clue about such a functiont ;) Thx in advance" ]
[ "python", "python-3.x", "pandas", "dataframe" ]
[ "How Do I display information from the joins table with the new Rails 3 query interface", "I have two models Horse and Race.\n\nclass Horse < ActiveRecord::Base\nhas_many :races\nend\n\nclass Race < ActiveRecord::Base\nbelongs_to :horse\nend\n\n\nNow I want to use the new rails 3 query interface to see the Horse name and all its races.\n\nHorse.joins(:races) # I get an active record relation that only displays horse data\n\nHorse.joins(:races).count #Yields 31 the exact number of races.\n\nHorse.joins(:races).all #Yields an Array of 31 Horse, but no race data\n\nHorse.joins(:races).all.select(\"horses.*, starters.*\") #Yields active record relation with only Horse data.\n\n\nQuestion 1: What's the correct query to yield complete horse and race records.\n\nQuestion 2: What's the correct query to yield the horse name and all of the race record.\n\nI know this is very basic, but I'm stumped. I sense I'd doing something wrong with the relation." ]
[ "ruby-on-rails-3", "activerecord", "join" ]
[ "Replace array elements based on another array (kinda like excel vlookup)", "I want to replace each element of my array (array A) with a list,\nbased on the value of the first element of the list set in the reference array.\nIt's kinda look like excel vlookup.\nBut currently I dont have pandas library in my machine,\ncan you tell me the solution by just using numpy.\nPlease help me...\nThis is what I have :\n>>>A=np.array([[[4],\n [2],\n [3],\n [1]],\n [[2],\n [1],\n [3],\n [3]]])\n \n \n>>>ref=np.array([[1,111,111,111],\n [2,222,222,222],\n [3,333,333,333],\n [4,444,444,444]])\n\nThis is my goal:\n [[[4,444,444,444],\n [2,222,222,222],\n [3,333,333,333],\n [1,111,111,111]],\n [[2,222,222,222],\n [1,111,111,111],\n [3,333,333,333],\n [3,333,333,333]]]\n\nI have used the solution from @Daniel F ,ref[A.squeeze() - 1] and it worked.\nBut if array A and ref I edit as follows.\n>>>A=np.array([[[4000], >>>ref=np.array([[1,111,111,111],\n [2], [2,222,222,222],\n [3], [3,333,333,333],\n [1]], [4000,444,444,444]])\n [[2],\n [1],\n [3],\n [3]]])\n\nThe result is an error.\nIndexError: index 3999 is out of bounds for axis 0 with size 8\n\nIs there a more flexible solution?" ]
[ "python", "numpy" ]
[ "Webpack loads unwanted file when passing string+variable to require()", "When running the following code I get an error when building with Webpack:\n\nconst name = 'Test';\nconst test = require(`./app/model/${name}`);\n\n\nHowever, with the following code I get no error:\n\nconst test = require('./app/model/Test');\n\n\nThe error received is:\n\nERROR in ./node_modules/express/lib/request.js\nModule not found: Error: Can't resolve 'net' in '/path/to/maestro/node_modules/express/lib'\n @ ./node_modules/express/lib/request.js 18:11-25\n @ ./node_modules/express/lib/express.js\n @ ./node_modules/express/index.js\n @ ./app/model/CommanderProgram.js\n @ ./app/model sync ^\\.\\/.*$\n @ ./web.js\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 2\nnpm ERR! [email protected] build: `webpack`\nnpm ERR! Exit status 2\nnpm ERR!\nnpm ERR! Failed at the [email protected] build script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /path/to/error/log/2019-12-09T16_19_45_494Z-debug.log\n\n\nThe contents of ./app/model/Test.js are:\n\n'use strict';\nmodule.exports = 'asdf';\n\n\nSo no dependencies. The error above mentions ./app/model/CommanderProgram.js, which absolutely should not be Webpack'd. Based on the fact that Test.js has nothing in it, Webpack should not be trying to include CommanderProgram.js, though. However, if I delete CommanderProgram.js then the error does NOT occur. Restoring CommanderProgram.js then renaming it to either AAA.js or ZZZ.js still DOES cause the problem (without updating references, so nothing could be importing AAA.js/ZZZ.js), so somehow Webpack is trying to include an un-referenced file.\n\nI also tried the following, showing it's not an issue with template literals:\n\nconst name = 'Test';\nconst test = require('./app/model/' + name);\n\n\nWhy does Webpack appear to include an un-referenced file when using variables in strings passed to require?\n\nEnvironment:\n\n\nNode: v10.16.3\nOS: Windows 10\nWebpack: 4.41.2\nWebpack-cli: 3.3.10\n\n\nSee code here: https://github.com/xOPERATIONS/maestro/blob/9d7977f52c1a08bc947666f3b1c85c30787cb831/web.js" ]
[ "javascript", "webpack" ]
[ "How to check if \"app\" is substring of \"gapple\" in progress openedge 4gl?", "I need to check if \"app\" is substring of \"gapple\" or not. I know I can do it using matches but I think its expensive. \n\nSeems lookup and can-do match the whole string?" ]
[ "string", "substring", "progress-4gl", "openedge" ]
[ "Search a part of string of datatype Mediumtext/Largetext", "I am working on mysql workbench and I want to search a part of string through entire database. The problem is, there are around 550 tables and I don't know which table and column has that data. I have a script that searches almost any datatype but is ineffective to mediumtext and longtext. I know these are different datatypes and conventional searches techniques such as 'like', '=', 'in', 'between' would not be used. \n\nSET @column_types_regexp = '^((var)?char|(var) binary|blob|text|longtext|mediumtext|enum|set)\\\\(';\n\nThe above script is from\nhttps://dba.stackexchange.com/questions/34856/how-to-search-whole-mysql-database-for-a-particular-string\n(note I have added longtext and mediumtext by my side)\nIf anyone could show me searching through mediumtext or longtext, that would be of great help. Thanks for your time." ]
[ "mysql", "sql", "mysql-workbench" ]
[ "How to manage Printers in Java", "At my school we have trouble connecting to the Printers properly. It's not that they are not on the network, we just don't really know how to interface with them through our laptops.\n\nMy idea was to maybe make some kind of application (using Java) which could be used to print out Documents and the likes from the schools printers.\n\nI've been looking at the tutorial that Oracle have made on printers (http://docs.oracle.com/javase/tutorial/2d/printing/index.html) but there are two things I'd like to have clarified first:\n\n\nThe printers on the school use a system (either FollowMe or\nFollowYou) to keep track of who prints what on the printers, and so\nthat you can tell a printer to print anywhere on the school, as long\nas you have your card to activate it. Does anyone know if this can\nbe interfaced with through Java?\nIs it possible to make an implementation in which I can right-click on a document in Windows (since that is what I use) and add a new option called \"Print using JPrinter\" to the list of options?\n\n\nThanks for your help!" ]
[ "java", "windows", "printing" ]
[ "Different colorbox calls depending on specific cookie", "I am trying to do two things here. \nIf someone visits the site and they have the cookie \"v_regUsr\" on their computer, the plan should open up normally when they click on the link in colorbox like in my html below.\n\nIf someone visits the site and they dont have the cookie \"v_regUsr\" it should open up a different colorbox window when the click on it with these settings:\n\n$.colorbox({width:\"480px\",height:\"290px\", iframe:true, href:\"test.php\"});\n\n\nmy html:\n\n<a href=\"plan.php\" class=\"iframeplan\"><img src=\"planbutton.png\" border=\"0\"/></a>\n\n\nmy script:\n\n<script type=\"text/javascript\">\nif (document.cookie.indexOf(\"v_regUsr\") >= 0) {\n // They've been here before.\n\n}\nelse {\n //They've not been here before.\n $.colorbox({width:\"480px\",height:\"290px\", iframe:true, href:\"test.php\"});\n}\n</script>\n\n\nis this possible?" ]
[ "javascript", "jquery", "ajax", "cookies", "colorbox" ]
[ "Google Tag Manager Data Layer on Magento Order Success page", "I have GTM installed on my Magento Enterprise e-commerce site. What is the procedure to implement a Data Layer to capture transaction order data on the checkout/success page?\n\nI would like to stay away from Magento extensions. Thank you for your time." ]
[ "magento", "google-tag-manager", "data-layer" ]
[ "UWP: Authenticate user using a smart card", "I need to write some UWP functionality that can authenticate a user from a TPM virtual smart card. Ideally I would like to utilize a popup like the one that occurs in the browser that asks you to select a certificate and then prompts you for a pin if it is tied to a smart card like the one below.\n\n\n\nI have the following code from the post found here: User login with Smart Card for Windows UWP app but I am experiencing the same issue when trying to sign \"Provider could not perform the action since the context was acquired as silent.\"\n\nReadOnlyList<Certificate> Certs;\n CertificateQuery CertQuery = new CertificateQuery();\n CertQuery.HardwareOnly = true;\n\n Certs = await CertificateStores.FindAllAsync(CertQuery);\n string strEncrypt = \"test\";\n IBuffer BufferToEncrypt = CryptographicBuffer.ConvertStringToBinary(strEncrypt, BinaryStringEncoding.Utf8);\n\n foreach (Certificate Cert in Certs)\n {\n Debug.WriteLine($\"Cert: {Cert.Subject}\");\n Debug.WriteLine($\"Storagename: {Cert.KeyStorageProviderName}\");\n if (Cert.HasPrivateKey && ((Cert.KeyStorageProviderName == \"Microsoft Base Smart Card Crypto Provider\") || Cert.KeyStorageProviderName == \"Microsoft Smart Card Key Storage Provider\"))\n {\n CryptographicKey Key = null;\n\n try\n {\n Key = await PersistedKeyProvider.OpenKeyPairFromCertificateAsync(Cert, HashAlgorithmNames.Sha1, CryptographicPadding.RsaPkcs1V15);\n Debug.WriteLine(\"Got keypair\");\n\n }\n catch (Exception ex)\n {\n // Could not open Smart Card Key Pair\n Debug.WriteLine(\"Could not open Smart Card Key Pair\");\n }\n\n if (Key != null)\n {\n try\n {\n // Try to Sign with Cert Private key \n IBuffer EncryptedBuffer = CryptographicEngine.Sign(Key, BufferToEncrypt); \n Debug.WriteLine(\"Signing successful\");\n }\n catch (Exception ex)\n {\n // Could not sign \n Debug.WriteLine(\"Could not sign\");\n Debug.WriteLine($\"Error: {ex.Message}\");\n }\n }\n }\n }\n\n\nIs there a way to produce the same popup? Do I have to build it myself? If not, If I choose a certificate programatically, how can I prompt for a pin and verify it?\n\nI'm looking for the functionality shown above that is also similar to the KeyChain.ChoosePrivateKeyAlias and IKeyChainAliasCallback that exists in Android that allows a user to pick a certificate if anybody is familiar with that as well.\n\nEdit 1\n\nChanging the line:\n\nIBuffer EncryptedBuffer = await CryptographicEngine.Sign(Key, BufferToEncrypt);\n\n\nto\n\nIBuffer EncryptedBuffer = await CryptographicEngine.SignAsync(Key, BufferToEncrypt);\n\n\ndoes prompt me for a pin but I still need to figure out the popup for the certificate selection vs. selecting it programmatically.\n\nEdit 2\nYou can show the \"Select a Certificate\" window by using\n\n CredentialPickerOptions options = new CredentialPickerOptions();\n options.AuthenticationProtocol = AuthenticationProtocol.Ntlm;\n options.Message = \"Please select your certificate\";\n options.Caption = \"Select a Certificate\";\n options.TargetName = \".\";\n options.CredentialSaveOption = CredentialSaveOption.Hidden;\n\n CredentialPickerResults credentialsPicked = await \n CredentialPicker.PickAsync(options);\n\n\nHowever, the CredentialPickerResults has a Credential field which is of type IBuffer. I am unclear what I am supposed to do with this to either obtain the certificate directly or use it to do a lookup in the certificate store to get the certificate that was selected." ]
[ "uwp", "certificate", "smartcard" ]
[ "Why my refreshing is slower after few secounds than immediately after start", "I am beginner in android and I am doing my test project. I have such a problem when I start the Handler method then let's say refreshing is approximately desired. But after few secounds this is slower than in the begin, immediately after clicking startGameButton\n\nThere are two handler nested to make screen refreshing.\n\nThe following code is nested in onCreate() method\n\n final Handler handler = new Handler();\n\n final Runnable runnable = new Runnable() {\n @Override\n public void run() {\n MainLoopClass mainLoop; \n mainLoop=newMainLoopClass(HelperMethods.context,HelperMethods.rl);\n handler.postDelayed(this, 100);\n }\n };\n\n ...\n\n startGameButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n handler.postDelayed(runnable, 100);\n }\n });\n\n\nMy desired effect is to make refresh every 700 milisecounds" ]
[ "java", "android", "handler" ]
[ "Scriban - list parsed expressions (variables)", "I'm wondering how to list all parsed expressions (variables) by using a simple code snippet:\n\nvar template = Template.Parse(@\"\n<ul id='products'>\n {{ for product in products }}\n <li>\n <h2>{{ product.name }}</h2>\n Price: {{ product.price }}\n {{ product.description | string.truncate 15 }}\n </li>\n {{ end }}\n</ul>\n\");\n\n\nI need to know the used variables in orde to fetch only data (DB data) I really need. Is there some built-in method or do I need to implement my own?" ]
[ "c#", "parsing", "scriban" ]
[ "Verify that an async method was called using NSubstitute throws exception", "When I try to verify that an async method was called using NSubstitute, I get an error message \n\n\n NSubstitute extension methods like .Received() can only be called on objects created using Substitute.For() and related methods\n\n\nHere's some example code to illustrate my point: \n\n public interface ISender\n {\n Task Send(string message);\n }\n public class Service\n {\n private readonly ISender _sender;\n\n public Service(ISender sender)\n {\n _sender = sender;\n }\n\n public async Task SendMessage(List<string> messages)\n {\n foreach (var message in messages)\n {\n await _sender.Send(message);\n }\n }\n }\n [Test]\n public async Task Test_Async_Method()\n {\n var mock = Substitute.For<ISender>();\n\n var service = new Service(mock);\n var messages = new List<string>{\"Foo\",\"Bar\"};\n await service.SendMessage(messages);\n\n mock.Send(Arg.Any<string>()).Received(2);\n }\n\n\nI understand that the problem is that I'm verifying Taskand not mock.Send(Arg.Any<string>()), but what can I do about it?" ]
[ "c#", ".net", "nsubstitute" ]
[ "Python : filter list items from list of dictionary", "names = ['vapp1', 'vapp3', 'vapp4', 'vapp2']\n\nvapps = [{'name':'vapp2', 'ip': '11.21.18.24', 'obj': 'obj523'}, {'name':'vapp3', 'ip': '11.21.18.27', 'obj': 'obj234'}, {'name':'vapp5', 'ip': '11.21.18.25', 'obj': 'obj246'}]\n\n\nresult = [vapp for vapp in vapps if vapp['name'] in names]\nprint result\n\n\nUsing this list/dict comprehension I am getting what I want in result. But I also want to print that vapp1 & vapp4 are not there in vapps . \n\nWhat is the most efficient way ? or How to avoid extra looping to achieve all of this so that I will get a filtered list of dictionary whose names are common in the list names. And also I can print those names which are not there." ]
[ "python", "list", "dictionary" ]
[ "About DataGridViewCellEventArgs", "I'm new for VB. Now, I'm using DataGridViewCellEventArgs on VB. I should change my value after editing; however, the value did not change. If I add second row, then I can change the value.\n\nPrivate Sub dgv_CellEndEdit(ByVal sender As Object, _\n ByVal e As DataGridViewCellEventArgs) _\n Handles dgv.CellEndEdit, dg.CellLeave\n Dim row As Integer = e.RowIndex\n Dim column As Integer = e.ColumnIndex\n\n If row > -1 Then\n sum = Val(Me.editSUM.Text)\n If Me.dgv.Item(4, row) Is DBNull.Value Then\n Me.dgv.Item(4, row).Value = 0\n End If\n\n If Me.dgv.Item(5, row) Is DBNull.Value Then\n Me.dgv.Item(5, row).Value = 0\n End If\n\n If Me.dgv.Item(4, row) Is DBNull.Value OrElse Me.dgv.Item(5, row) Is DBNull.Value Then\n Me.dgv.Item(6, row).Value = 0\n Else\n\n Me.dgv.Item(6, row).Value = CInt(Me.dgv.Item(4, row).Value) * CInt(Me.dgv.Item(5, row).Value)\n End If\n\n If IsDBNull(Me.dgv.Item(6, row)) = False Then\n sum += Me.dgv.Item(6, row).Value\n End If\n Else\n For i = 0 To Me.dgv.RowCount - 2\n If Me.dgv.Item(4, i) Is DBNull.Value Then\n Me.dgv.Item(4, i).Value = 0\n End If\n\n If Me.dgv.Item(5, i) Is DBNull.Value Then\n Me.dgv.Item(5, i).Value = 0\n End If\n\n If Me.dgv.Item(4, i) Is DBNull.Value OrElse Me.dgv.Item(5, i) Is DBNull.Value Then\n Me.dgv.Item(6, i).Value = 0\n Else\n\n Me.dgv.Item(6, i).Value = CInt(Me.dgv.Item(4, i).Value) * CInt(Me.dgv.Item(5, i).Value)\n End If\n\n If IsDBNull(Me.dgv.Item(6, i)) = False Then\n sum += Me.dgv.Item(6, i).Value\n End If\n Next\n End If\nEnd Sub\n\n\nWhat is the problem?" ]
[ "vb.net", "datagridview" ]
[ "Transforming web.config Transform files across environments and projects", "So here is my dilemma. I have a web.config file. I have FIFTEEN transform files, once for each environment (Lab1, Lab2, etc., Alpha, Beta, Prod, etc.). Now multiply that by 30 projects.\n\nRather than trying to maintain 15 transform files across 30 projects I would like:\n\nparse each transform file.\nFor each Environment/Configuration/Setting, store this data from the parsed file in a database.\nCreate a \"master\" transform file that is a merge of all the environment-specific transform files (assuming that web.release.config will have a majority of the transforms)\nAllow a user to run my c# program that accesses the database and based on the desired environment, takes the master transform file and replaces all the settings (ie \"value\") with the environment/configuration specific values from the DB.\n\nWhat I currently have:\na c# program that stores the env/config/setting in a DB. It can create and update.\na powershell program that calls the above to set or get a set of env/config/setting.\n\nwhat I need:\nA way to parse the transform file, identify each transform call, and store the env/config/setting value in the DB.\n\nThen\nthe best way to \"merge\" the 15 transform config files into a master transform file, making sure there is no duplication and clearly notating the values that need to be replaced. I was thinking that using square brackets - which are not used anyplace else in a config file, is a great way to do this:\n\nadd key=\"LabName\" value=[[REPLACE ME]]\n\ntransforms for the production environment into\n\nadd key=\"LabName\" value=\"Prod\"\n\nthanks in advance." ]
[ "c#", "powershell", "web-config", "app-config", "web.config-transform" ]
[ "Detect current current drawn when charging android phone", "I would like to develop a small app that shows the current current being drawn by the phone during a charge. eg The phone is plugged in via A/C and is pulling 1A.\n\nFrom my research there are the existing APIs:\n\nhttp://developer.android.com/reference/android/os/BatteryManager.html\nhttp://developer.android.com/training/monitoring-device-state/battery-monitoring.html\n\nHowever these will only tell you whether it is charging via USB or A/C and it's current status.\n\nI would like to do some tests to view the charge rate with different cables and A/C adaptors." ]
[ "android" ]
[ "Select a string text from .txt file then check the status", "I'm trying to check this file .txt, it's a disk health report.\n\nMy goal is to select a single Line: Health Status : Good (100 %)\n\nThen\n\nI have to check the status:\n\nIf -eq (100 %) write-host Ok\n\nIf -ne (100 %) write-host Errors on the disk !!!\n\n\nI wrote this, but then i don't know how to select (xxx %) value and check it\n\n$errorCounts = Get-Content c:\\b.txt | \nSelect-String \"Health Status : \" -AllMatches | \nSelect-Object -ExpandProperty Matches | \nForeach-Object { $_.Groups[0].Value }\n\nwrite-host $errorCounts" ]
[ "powershell" ]
[ "Why does std::tr1::function work with Objective-C Blocks?", "I was pretty surprised when I found that the following code actually works:\n\nstd::vector<int> list /*= ...*/;\nstd::tr1::function<void(int)> func = ^(int i) {\n return i + 1;\n};\n\nstd::for_each(list.begin(), list.end(), func);\n\n\nSeems like std::tr1::function is capable of being constructed from an Objective-C block, but I'm not sure quite how, since (last I checked), its implementation doesn't specifically handle blocks. Is it somehow implicitly sucking out the underlying function pointer? Also, is this behavior undefined and likely to change?" ]
[ "c++", "objective-c++", "objective-c-blocks" ]
[ "Xcode: +CoreDataProperties.swift issue", "I'm designing an app which is going well but I had an issue a while ago whereby I had to create a new model for CoreData because I made alterations to the Entities. I'm up to the fourth version and I had another issue with the app and I cleaned it. Now, this is what I'm getting:\n\nThe 'deleted' Attribute is set to NSDate \n\n\n\nbut after I try to build it again I get the following error:\n\n\n\nI thought if I made alterations to the Entity Xcode would pick that up and alter any files accordingly! But that doesn't seem to be the case!\n\nI've tried deleting the +CoreDataProperties.swift files and the 'Shopping List' swift file, recreating the 'Shopping List' swift file, under a different class name, and trying to build it again but I get the same error. This tells me its a CoreData issue, not a Swift issue. Obviously I need the attribute as NSDate but I'm not sure where to go from here!\n\nThe only way I can get the app to build is to comment out the 'deleted' attribute in the +CoreDataProperties.swift file and it runs fine.\n\nI have the app running on a test iPhone 6 and the last time I made changes to the Entity I lost all the data I entered manually on the phone because of errors. The only way to get the app back up and running was to delete the app off the phone and reinstall it. I seriously don't want to go down that route again because I have nearly 450 various records on the phone. \n\nIf I leave the 'deleted' Attribute commented out when its uploaded to the app store, will it fail to upload, and will it fail to work correctly if the upload is successful?\n\nI'd rather sort the issue before trying!" ]
[ "iphone", "swift", "xcode", "image", "ipad" ]
[ "Auto-Py-To-Exe - win32api - ModuleNotFoundError", "I have been attempting to compile a python project that uses these imports\n\nimport os\nimport numpy\nimport sys\nimport pytube\nimport time\nfrom moviepy.editor import *\n\n\nI have installed all of them via pip and I have also been looking around for trouble shooting tips but none of them seem to work. I keep getting this error when executing the built executable via Auto-py-to-exe.\n\nTraceback (most recent call last):\n File \"C:\\Users\\*****\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages\\PyInstaller\\loader\\rthooks\\pyi_rth_win32comgenpy.py\", line 49, in <module>\n import win32com\n File \"c:\\users\\*****\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\loader\\pyimod03_importers.py\", line 489, in exec_module\n exec(bytecode, module.__dict__)\n File \"site-packages\\win32com\\__init__.py\", line 5, in <module>\nModuleNotFoundError: No module named 'win32api'\n[17344] Failed to execute script pyi_rth_win32comgenpy\n\n\nAnyone know a way to fix it?" ]
[ "python", "winapi", "pyinstaller" ]
[ "Apache NiFi: MergeContent do not merges files properly", "I have the following flow:\n\nI get data from Salesforce but there is a lot of data (10000 records), so I have to use nextUrl attribute to get next batches with 1000 records. That is why the first file comes from one flow and all others are coming from another flow (using nextUrl attribute).\nIn general 1 file comes from the 1st flow and 8 files come from the 2nd flow, and then I split JSON, so there are 1000 records in the first flow and 8000 records in the second flow.\nThen I have to merge 1000 + 8000 records into 1 file. But in result there is not 1 file but 9 files (as it was in the beginning when JSON was not split yet). And only when I use one more MergeContent processor, finally I have 1 file instead of 9 files.\n\nI have the following configuration for MergeContent:\n\nMerge Strategy: Bin-Packing Algorithm;\nMerge Format: Binary Concatenation;\nAttribute Strategy: Keep Only Common Attributes.\n\nActually I tried other parameters as well but all data is combined into 1 file only using the second MergeContent.\nPlease help me to figure out why it happens and if there is a way to use only one MergeContent processor?\nIf you need any additional information, just let me know." ]
[ "merge", "salesforce", "apache-nifi" ]
[ "Segfault in C++ merge sort code", "Trying to get this to work.. GDB seems to indicate that the indexes might be off for some reason. I'm using a vector of a subclass called Record containing mainly population (int) and name (string) that needs to be sorted both ways. bt indicates null pointer at line 27 which is the 'if' statement in the isSmaller() function. This function works perfectly well with an insertion sort code in the same program, but not the merge sort, so I'm wondering what's wrong with the merge sort code. Please advise. Is something wrong with the algorithm?\n\nbt returns the following:\n\n#0 0x0000000000403160 in CensusData::isSmaller (this=0x7fffffffdd10, type=0, r1=0x609590, r2=0x0) at CensusDataSorts.cpp:27\n#1 0x0000000000403510 in CensusData::mergeIt (this=0x7fffffffdd10, type=0, list=..., p=0, q=1, r=2) at CensusDataSorts.cpp:96\n#2 0x0000000000403347 in CensusData::mergeSortIt (this=0x7fffffffdd10, type=0, list=..., p=0, r=2) at CensusDataSorts.cpp:70\n#3 0x0000000000403645 in CensusData::mergeSort (this=0x7fffffffdd10, type=0) at CensusDataSorts.cpp:113\n#4 0x0000000000401a50 in runMergeSorts (fp=...) at CensusSort.cpp:106\n#5 0x0000000000401e6f in main (argc=2, argv=0x7fffffffe068) at CensusSort.cpp:174\n\n\nCode appears below\n\nbool CensusData::isSmaller(int type, Record* r1, Record* r2)\n{\n if(type==POPULATION)\n {\n if(r1->population <= r2->population)\n return true;\n }\n\n else if(type==NAME)\n {\n if(*(r1->city) <= *(r2->city))\n return true;\n }\n\n return false; \n}\n\nvoid CensusData::mergeSortIt(int type, vector<Record*>& list, int p, int r)\n{\n if(p < r)\n {\n int q = floor((p+r)/2);\n mergeSortIt(type,list,p,q);\n mergeSortIt(type,list,q+1,r);\n mergeIt(type,list,p,q,r);\n } \n} \n\nvoid CensusData::mergeIt(int type, vector<Record*>& list, int p, int q, int r)\n{\n int n1=q-p+1;\n int n2=r-q;\n int i,j;\n\n vector<Record*> L(n1,0);\n vector<Record*> R(n2,0);\n\n for(i=0; i<n1; i++)\n L[i]=list[p+i];\n\n for(j=0; j<n2; j++)\n R[j]=list[q+j+1];\n\n i=0;\n j=0;\n\n for(int k=p; k<=r; k++)\n {\n if(isSmaller(type,L[i],R[j]))\n {\n list[k]=L[i];\n i++;\n }\n else\n {\n list[k]=R[j];\n j++;\n }\n }\n}\n\nvoid CensusData::mergeSort(int type)\n{\n mergeSortIt(type, data, 0, data.size()-1);\n}" ]
[ "c++", "sorting", "merge" ]
[ "(XML) PHP is not renaming all tags?", "I have a problem... I want to rename the tags in some XML files. An it works with this code:\n\n$xml = file_get_contents('data/onlinekeystore.xml');\nrenameTags($xml, 'priceEUR', 'price', 'data/onlinekeystore.xml');\n\n\nBut if I want to rename another XML file it doens't work with the SAME method...\nSee the example below. I have no idea why...\nDoes anybody has an idea and can help me?\n\n$xml = file_get_contents('data/g2a.xml');\nrenameTags($xml, 'name', 'title', 'data/g2a.xml');\n\n\nFunction Code:\n\nfunction renameTags($xml, $old, $new, $path){\n $dom = new DOMDocument();\n $dom->loadXML($xml);\n\n $nodes = $dom->getElementsByTagName($old);\n $toRemove = array();\n foreach ($nodes as $node) {\n $newNode = $dom->createElement($new);\n foreach ($node->attributes as $attribute) {\n $newNode->setAttribute($attribute->name, $attribute->value);\n }\n\n foreach ($node->childNodes as $child) {\n $newNode->appendChild($node->removeChild($child));\n }\n\n $node->parentNode->appendChild($newNode);\n $toRemove[] = $node;\n }\n\n foreach ($toRemove as $node) {\n $node->parentNode->removeChild($node);\n }\n\n $dom->saveXML();\n $dom->save($path);\n}\n\n\nonlinekeystore.xml Input:\n\n<product>\n <priceEUR>5.95</priceEUR>\n</product>\n\n\nonlinekeystore.xml Ouput:\n\n<product>\n <price>5.95</price>\n</product>\n\n\ng2a.xml Input:\n\n<products>\n <name><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></name>\n</products>\n\n\ng2a.xml Ouput:\n\n<products>\n <name><![CDATA[1 Random STEAM PREMIUM CD-KEY]]></name>\n</products>\n\n\nGreetings" ]
[ "php", "xml" ]
[ "Start Spring Boot App from other application", "I have a java application and a Spring Boot application. I want to MySpringBootApp.run() and MySpringBootApp.hereYouHaveSomeInfo(), so I want to call methods of the Spring Boot App but Spring Boot kind of processes my class and renames it, so I get a ClassNotFoundException in the other App.\n\nThanks for you help!" ]
[ "java", "spring", "spring-boot", "classnotfoundexception" ]
[ "Keyboard shortcuts for P4 Diff / P4 Folder Diff", "I have searched the P4 documentation and knowledge bases and I cannot find if there are any keyboard shortcuts to perform common actions when diffing files. \n\nI know about the next and previous change (CTRL+1 and CTRL+2 respectively) however there are more common actions. \n\nSo, are there any undocumented keyboard shortcuts that you know? \n\nFor example:\n\n\nMerge changes per line (i.e., select change on left or right, or revert to base).\nOpen the left or right for editing." ]
[ "keyboard-shortcuts", "perforce", "p4v" ]
[ "My added ringtone disappears when rebooting", "I add a ring tone from a raw file like this code below, and it works.\nOnce I added it, I can open Android System Ringtones list and it appears there, so I (or any other app) can use it.\nThe problem is that if I restart the phone then that entry from the list is gone.\nSo, is there a way to permanently add a ringtone?\nThanks\n\nI use this code for adding:\n\nprivate void AddRingTone() //I assume that sdcard directory exists and it is empty\n{ //We first copy the raw resource to sdcard:\n String sPath = Environment.getExternalStorageDirectory() + \"/AnyPath\"; //AnyPath already exists. \n File newSoundFile = new File(sPath, \"MyRingtone\");\n Uri mUri = Uri.parse(\"android.resource://\" + getPackageName()+ \"/\" + R.raw.myringtone);\n AssetFileDescriptor soundFile;\n try \n { soundFile= getContentResolver().openAssetFileDescriptor(mUri, \"r\");\n }catch (FileNotFoundException e)\n { soundFile=null; \n MessageBox(\"Cannot open \" + mUri.toString());\n }\n try\n { byte[] readData = new byte[1024];\n FileInputStream fis = soundFile.createInputStream();\n FileOutputStream fos = new FileOutputStream(newSoundFile);\n int i = fis.read(readData);\n while (i != -1)\n { fos.write(readData, 0, i);\n i = fis.read(readData);\n }\n fos.close();\n }catch(IOException io)\n { MessageBox(\"RingtoneManager:\\n\" + io.toString()); \n }\n\n\n //Now we add it to the system list:\n ContentValues values = new ContentValues();\n values.put(MediaStore.MediaColumns.DATA, newSoundFile.getAbsolutePath());\n values.put(MediaStore.MediaColumns.TITLE, \"my ring tone\");\n values.put(MediaStore.MediaColumns.MIME_TYPE, \"audio/oog\");\n values.put(MediaStore.MediaColumns.SIZE, newSoundFile.length());\n values.put(MediaStore.Audio.Media.ARTIST, \"me\");\n values.put(MediaStore.Audio.Media.IS_RINGTONE, true);\n values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);\n values.put(MediaStore.Audio.Media.IS_ALARM, false);\n values.put(MediaStore.Audio.Media.IS_MUSIC, false);\n Uri uri = MediaStore.Audio.Media.getContentUriForPath(newSoundFile.getAbsolutePath());\n Uri newUri = getContentResolver().insert(uri, values);\n\n\n}" ]
[ "android", "add", "ringtone" ]
[ "Form not displayed correctly", "i have a form consists of the following models\n\nEmployee.rb\n\nclass Employee < ActiveRecord::Base\n\n attr_accessible :employee_number, :joining_date, :first_name, :middle_name, :last_name,\n :gender, :job_title, :employee_department_id, :qualification, :experience_detail,\n :experience_year, :experience_month, :status_description, :date_of_birth, :marital_status,\n :children_count, :father_name, :mother_name, :husband_name, :blood_group, :nationality_id,\n :home_address_line1, :home_address_line2, :home_city, :home_state, :home_pin_code,\n :office_address_line1, :office_address_line2, :office_city, :office_state, :office_pin_code,\n :office_phone1, :office_phone2, :mobile_phone, :home_phone, :email, :fax, :user_id,\n :reporting_manager_id, :employee_grade_id, :office_country_id,\n :home_country_id, :employee_category, :employee_position_id\n\n belongs_to :employee_department\n\n has_many :counselor_supervisors\n belongs_to :employee_position\n\n def to_label\n full_name = first_name + \" \" + last_name\n end\n\n end\n\n\nEmployeeDepartment.rb\n\nclass EmployeeDepartment < ActiveRecord::Base\n attr_accessible :code, :name\n\n has_many :employees\n\n has_many :employee_positions\n\n has_many :counselor_supervisors\n\n has_many :batch_leadership_supervisors\n\n def to_label\n name\n end\n\n\n end\n\n\nCounselorSupervisor.rb\n\nclass CounselorSupervisor < ActiveRecord::Base\n attr_accessible :employee_id, :employee_department_id, :employee_position_id\n belongs_to :employee\n belongs_to :employee_department\n has_many :batch_counselor_supervisors\n\n def to_label\n employee.to_label\n end\n\n end\n\n\nBatchCounselorSupervisor.rb\n\nclass BatchCounselorSupervisor < ActiveRecord::Base\n attr_accessible :counselor_supervisor_id , :employee_department_id , :counselor_batch_id, \n :batch_counselor_advisors_attributes\n has_many :batch_counselor_advisors\n belongs_to :counselor_supervisor\n belongs_to :employee_department\n belongs_to :counselor_batch\n\n accepts_nested_attributes_for :batch_counselor_advisors\n\nend\n\n\nEmployee_position.rb\n\nclass EmployeePosition < ActiveRecord::Base\n attr_accessible :position_title, :employee_department_id\n\n has_many :employees\n belongs_to :employee_department\n\n def to_label\n position_title\n end\nend\n\n\nbatch_counselor_supervisors/new.html.erb (part of the form which related to my question)\n\n <%= simple_form_for(@batch_counselor_supervisor) do |f| %>\n <%= f.error_messages %>\n <%= f.association :employee_department, as: :select %>\n <%= f.input :counselor_supervisor_id , collection: EmployeeDepartment.all, as: :grouped_select, group_method: :counselor_supervisors %>\n<% end %>\n\n\nthe dropdown list appears like this:\n\n\n\nIf I added an employee which belongs to the first department \"Business Administration\", the form will be displayed correctly like this:\n\n\n\nUpdate: after adding label_method: :to_label, so my form became like this :\n\n <%= simple_form_for(@batch_counselor_supervisor) do |f| %>\n <%= f.error_messages %>\n <%= f.association :employee_department, as: :select %>\n <%= f.input :counselor_supervisor_id ,\n collection: EmployeeDepartment.all, as: :grouped_select, group_method: :counselor_supervisors, label_method: :to_label %>\n <% end %>\n\n\nthe employee name displayed correctly but still the department name not displayed correctly as the following image:\n\n\n\nIs this SQLite3 issue ? and What can I do in order to solve this if it sqlite3 issue or not." ]
[ "sql", "ruby-on-rails", "ruby", "ruby-on-rails-3", "sqlite" ]
[ "webapp security by id signing", "Suppose I write a web application that stores a lot of information in its database that should only be accessible to users with privileges. A post, for example, may only be readable by its author. For the sake of the example, suppose that each word in the post is assigned an id and must also be checked to see if the user actually has permission to use that word. When transmitting ajax requests to the server, the ids must all be sent to the server for the request (details of why aren't important). For security, I want to verify that the user is authorized to use each word to foil an attacker that is fabricating his own ajax request. I could query the SQL database for each word to check authorization which will probably involve one or more joins. This results in 100s of queries. I would like to avoid querying so much. (In my specific implementation, I'm not using posts and words, but I will need to handle ~100 database ids in some requests.)\n\nI came up with a possible solution and I would like some feedback. Instead of transmitting integers as ids to the web application, it encodes the id in a signed-id-placeholder. The signature works by assigning every session a secret key that is stored in the session table and not send to the client. To encode an id, the id, id type ('user_id', etc.), and the secret key are appended together and piped through a hash algorithm. A fixed length portion of this resulting hash is appended to the unencoded id and then sent to the client. To reduce its length, it's also encoded with 0-9,A-Z,a-z or base-62. The result is that the actual id is in clear-text (though slightly masked by the different base) and a signature is appended to it. This way, changing the id will invalidate the signature and the server will not honor the request. In my current implementation, I'm using a signature length of 56 bits for about 7.2x10^16 possible signatures.\n\nWhat are you reactions to this plan? Overkill? Flawed? Is there an accepted, better solution?\n\nHere is a code snipet in php of the signing function (excuse the use of magic numbers, this is a testing implementation):\n\npublic function signDbId( $id, $kind )\n{\n $id_seg = base62( $id );\n $hash = md5( $id_seg . $kind . $this->session_key );\n $signed = '';\n for ( $i = 0; $i < 2; ++$i )\n {\n $signed .= base62( intval( substr( $hash, $i*8, 7 ), 16 ), 5 );\n // pad to 5 chars\n }\n return $signed . $id_seg;\n}" ]
[ "security" ]
[ "Why this query is not working and returning false?", "I have been trying this query from long time but this query returns nothing, or let say rowCount returns 0 and if i try to fetchAll and prints it gives me empty array\n\npublic function Login($email, $password)\n {\n $stmt = $this->pdo->prepare(\"SELECT user_id from users where email = :email AND password = :password\");\n $stmt->bindParam(\":email\", $email, PDO::PARAM_STR);\n $stmt->bindParam(\":password\", $password, PDO::PARAM_STR);\n $stmt->execute();\n\n $user = $stmt->fetch(PDO::FETCH_OBJ);\n $count = $stmt->rowCount();\n\n if($count >0){\n $_SESSION['user_id'] = $user->user_id;\n header('Location:home.php');\n }else{\n return false;\n }\n }" ]
[ "php", "pdo" ]
[ "Bind Param fails with empty variable", "$query = \"INSERT INTO api_fails (file, code, url, date) VALUES (?, ?, ?, \".time().\")\";\n\n$stmt = $mysqli->stmt_init();\nif(!$stmt->prepare($query)) {\n echo(\"Failed to prepare statement.<br />\\n\");\n} else {\n $file = $_GET['f'];\n $code = $_GET['c'];\n $url = $_GET['u'];\n $stmt->bind_param(\"sis\", $file, $code, $url);\n if($stmt->execute()) {\n echo(\"Inserted.<br />\\n\");\n }else {\n echo(\"Didn't insert.<br />\\n\");\n }\n}\n\n\nI have found if any of the following variables are not set, the insert fails...\n\n $file = $_GET['f'];\n $code = $_GET['c'];\n $url = $_GET['u'];\n\n\nHow do I setup my insert so that if the variable isn't set it just inserts nothing into that field?" ]
[ "php", "mysql", "mysqli" ]
[ "Fitting Curve of Gamma Distribution in Hist", "When I run this:\n\nx<-c(73,6,77,81,91,120,150,61,65,68,18,20,23,12,14,18,23,26,26,27,2,3,3,40,41,41,6,10,11,12,37,38,38,6,73,6,51)\na<-1.286486;b<-30.59584\n\nhist(x,breaks=c(0,20,40,60,80,100,120,160),probability = T,xaxt=\"n\")\ncurve(dgamma(x,a,b),from=0,to=160,col=\"red\",lwd=2,add=T)\n\n\nIt should generate the curve of the Gamma Distribution on the histogram. Instead, it just makes a flat line along the x-axis. \n\n\n\nWhat am I doing wrong here?" ]
[ "r", "plot", "histogram", "curve-fitting" ]
[ "Rails 4 nested attributes with AngularJS", "I have been searching online and have not been able to come across an example. Does anyone know of any resources for using nested attributes with AngularJS?" ]
[ "angularjs", "ruby-on-rails-4" ]
[ "How to select elements from an array according its index", "I'm a newby and maybe this is very simple. But how could I select specific elements from an array according its index. I have an array with 108 elements. I need to select some of them according a few index positions that I already know. I guess I could do by concantenating '&', but there should be a better way. This is the code I've been trying\n\ndef first_position(entry)\n array_entry = entry.split('')\n spots_first_position = array_entry.select { |spot| spot.index = [0,1,2,28,29,30,55,56,57]}\nend" ]
[ "arrays", "ruby", "select" ]
[ "Which method faster/better - multiple equal or IN? SQL", "I want to know - which method is faster/better?\n\n$string = '';\n$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);\nfor($i = 0; $i < 10; $i++){\n if(!empty($string)){\n $string .= ' OR ';\n }\n $string .= ' `id` = '.$array[$id];\n}\n\n\nOr:\n\n$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);\n$string = implode(', ', $array);\n$string = '`id` IN ('.$string.')';\n\n\nIn SQL:\n\n'SELECT * FROM `table` WHERE '.$string" ]
[ "php", "sql" ]
[ "How to clear cached action [OutputCacheAttribute] when database change in Asp.net mvc", "I have a partialView, containing a dropdownlist which filled by data from database. I want to cache this partialview due to rare change data. So I add [outputcache] attribute to action to cache action but when data in database change, I can not update cached data. \n\nFirst I tried to remove cache for this action like this post :\n\n\n Clearing Page Cache in ASP.NET\n\n\nBut nothing happened and it showed old data. Then I Tried to Use SqlCacheDependency, but i find out that OutputCacheAttribute can not used for child actions.\n\nI don't know how to handle this. Can any one help me.\nThank you in advance" ]
[ "asp.net", "asp.net-mvc", "asp.net-mvc-4", "caching" ]
[ "access method from template in wpf", "I'm using WPF with the caliburn micro framework to implement a MVVM pattern.\nI've created a popup that gets filled with custom buttons inside a ListBox.\nNow I want to call a method in my ViewModel when one of these buttons is clicked, but each approach I tried so far failed.\n\nHere the code in comments works in the sense that it calls my method, but the parameter is always null.\n\n<ListBox x:Name=\"lst\" ItemsSource=\"{Binding OperatingModes}\" ItemTemplate=\"{DynamicResource DataTemplate_Level1}\" BorderThickness=\"0\" ScrollViewer.CanContentScroll=\"False\" ScrollViewer.HorizontalScrollBarVisibility=\"Disabled\" ScrollViewer.VerticalScrollBarVisibility=\"Disabled\">\n <ListBox.ItemsPanel>\n <ItemsPanelTemplate>\n <UniformGrid Columns=\"3\" />\n </ItemsPanelTemplate>\n </ListBox.ItemsPanel>\n <!--<i:Interaction.Triggers>\n <i:EventTrigger EventName=\"PreviewMouseLeftButtonDown\" >\n <cal:ActionMessage MethodName=\"SelectMode\">\n <cal:Parameter Value=\"{Binding ElementName=lst, Path=SelectedItem}\" />\n </cal:ActionMessage>\n </i:EventTrigger>\n </i:Interaction.Triggers>-->\n</ListBox>\n\n\nAnd this is the Template I'm using. Whenever I call this method, I'm getting \"No target found for method SelectMode.\" As you can see, I've tried different aproaches, although I'm not sure that I used the TargetWithoutContext call properly.\nAs far as I can tell I need to somehow bind my template to the data context of the \"normal\" xaml code, but I failed so far. How do I access my method properly?\n\n<DataTemplate x:Key=\"DataTemplate_Level1\" x:Name=\"myListTemplate\" >\n <ListBox ItemsSource=\"{Binding}\" BorderThickness=\"0\" ScrollViewer.CanContentScroll=\"False\" ScrollViewer.HorizontalScrollBarVisibility=\"Disabled\" ScrollViewer.VerticalScrollBarVisibility=\"Disabled\">\n <StackPanel Orientation=\"Vertical\" HorizontalAlignment=\"Center\" cal:Bind.Model=\"{Binding}\" cal:Action.TargetWithoutContext=\"{Binding DataContext, ElementName=lst}\">\n <Button Style=\"{StaticResource InformButton}\" Content=\"{Binding Path=Name}\" FontSize=\"11\" BorderBrush=\"BlueViolet\" cal:Message.Attach=\"SelectMode($dataContext)\">\n <!--<i:Interaction.Triggers>\n <i:EventTrigger EventName=\"MouseRightButtonDown\" >\n <cal:ActionMessage MethodName=\"SelectMode\">\n <cal:Parameter Value=\"{Binding ElementName=myListTemplate, Path=SelectedItem.Name}\" />\n </cal:ActionMessage>\n </i:EventTrigger>\n </i:Interaction.Triggers>-->\n </Button>\n </StackPanel>\n </ListBox>\n</DataTemplate>" ]
[ "wpf", "xaml", "caliburn.micro" ]