texts
sequence
tags
sequence
[ "cron file to update the database sequentially after every run", "im redesigning a mmorpg game and im in a bit of a pickle on this one.\ni have the following code on the daily cron file.\n\ndbn(\"update mygame set event = '11' where event = '10'\");\n\n\nnow...\n\nthis file runs once a day. i would like to update the database in a way such\nday 1 ----- event =10,\nday 2 ----- event =11,\nday 3 ----- event =12 ...etc,\nin other words,\nonce the event is set it will automatically update itself till it dies out.\nHence day 1\n\ndbn(\"update mygame set event = '10' where event = '9'\");\n\n\nday 2\n\ndbn(\"update mygame set event = '11' where event = '10'\");\n\n\nso on and so forth.\n\nAny ideas?\nThank you in advance for reading." ]
[ "php", "mysql", "tabs", "cron" ]
[ "javascript - sending a parameter to a function", "I have this:\n\nvar MyObject = {};\n\nMyObject.doStuff = function(someParam) {\n var webdav = new Webdav(\"addr\",\"port\"); \n\n var handler = {\n onSuccess: MyObject.Success,\n onError: MyObject.Fail\n }\n\n webdav.PUT(handler, filename, options);\n}\n\nMyObject.Success = function(result) {\n alert('status ' + result.status + result.statusstring);\n}\n\n\nI'm using exo platform javascript library for webdav access (if it matters)\n\nThe handler I'm creating will call MyObject.Success if webdav.PUT is done succesfully. How can i send the someParam to that function too?\n\nPut in another way, after a successful or failed operation, I'm interested in doing something with the someParam, depending of the result." ]
[ "javascript", "events", "parameters" ]
[ "Changing the page layout using Office Web Components", "I am using Office Web components to fill an Excel template with values. The template is in Excel xml format, containing all relevant fields and layout options including the page layout, landscape in this case. I'm filling this template with some real fields using the code below.\n\nSet objSpreadsheet = Server.CreateObject(\"OWC11.Spreadsheet\")\nobjSpreadsheet.XMLURL = Server.MapPath(\"xml\") & \"\\MR1_Template.xls\"\n\n'Fill cells with values here\nResponse.ContentType = \"application/vnd.ms-excel\"\nResponse.AddHeader \"Content-Disposition\", \"inline; filename=\" & strFileNaam\nResponse.write objSpreadsheet.xmlData\n\n\nAfter the new Excel file has been saved, the page layout options are gone. I've looked at the API documentation for the OWC but cannot find the option to specify the landscape page-layout" ]
[ "excel", "asp-classic", "automation" ]
[ "Cant format date from database to jsp", "I want to convert my date object from hibernate the format is as follow 2016-07-23 00:00:00.0 so im using a jstl format\n\n <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>\n <%@ taglib prefix=\"fn\" uri=\"http://java.sun.com/jsp/jstl/functions\" %>\n <%@ taglib prefix=\"fmt\" uri=\"http://java.sun.com/jstl/fmt\" %>\n\n <c:set var=\"now\" value=\"${vac.date}\"\n <fmt:formatDate value=\"${now}\" pattern=\"MM-dd-yyyy\"\n\n\nIm trying to format it but seems not to be working im getting this error\n\nWEB-INF/views/details.jsp (line: 34, column: 20) According to TLD or attribute directive in tag file, attribute value does not accept any expressions" ]
[ "spring", "jsp", "date", "model-view-controller", "format" ]
[ "Why my Process terminate?", "I have a Runnable object, that runs a ping operation - \n\nRunnable r1 = new Runnable() {\n @Override\n public void run() {\n try{\n List<String> commands = new ArrayList<String>();\n commands.add(\"ping\");\n commands.add(\"-c\");\n commands.add(\"10\");\n commands.add(\"google.com\");\n\n System.out.println(\"Before process\");\n ProcessBuilder builder = new ProcessBuilder(commands);\n Process process = builder.start();\n\n BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));\n String line = null;\n while ((line=reader.readLine()) != null){\n System.out.println(line);\n }\n process.waitFor();\n System.out.println(\"After process\");\n\n }catch (Exception ex){\n ex.printStackTrace();\n }\n }\n };\n\n\nIf I launch this in current thread like this:\n\nr1.run();\n\n\nI get this output:\n\nBefore process\nPING google.com (173.194.32.33): 56 data bytes\n64 bytes from 173.194.32.33: icmp_seq=0 ttl=53 time=34.857 ms\n64 bytes from 173.194.32.33: icmp_seq=1 ttl=53 time=39.550 ms\n64 bytes from 173.194.32.33: icmp_seq=2 ttl=53 time=44.212 ms\n64 bytes from 173.194.32.33: icmp_seq=3 ttl=53 time=38.111 ms\n64 bytes from 173.194.32.33: icmp_seq=4 ttl=53 time=39.622 ms\n64 bytes from 173.194.32.33: icmp_seq=5 ttl=53 time=41.391 ms\n64 bytes from 173.194.32.33: icmp_seq=6 ttl=53 time=41.280 ms\n64 bytes from 173.194.32.33: icmp_seq=7 ttl=53 time=39.645 ms\n64 bytes from 173.194.32.33: icmp_seq=8 ttl=53 time=35.931 ms\n64 bytes from 173.194.32.33: icmp_seq=9 ttl=53 time=38.245 ms\n\n--- google.com ping statistics ---\n10 packets transmitted, 10 packets received, 0.0% packet loss\nround-trip min/avg/max/stddev = 34.857/39.284/44.212/2.575 ms\nAfter process\n\n\nBut if I run it in a new thread like this: \n\n Thread thread = new Thread(r1);\n thread.start();\n\n\nI get this:\n\nBefore process\n\n\nWhy are the outputs different?" ]
[ "java", "multithreading", "process" ]
[ "Making .exe from the Python Script that uses GIS libraries such as geopandas, folium", "It's a very straightforward and broad question I know but I have very little time so I have to ask. I created an interface to do some GIS calculations and for that I used below libraries in backend.\n\nimport osmnx as ox, networkx as nx, geopandas as gpd, pandas as pd\nfrom shapely.geometry import LineString, Point\nfrom fiona.crs import from_epsg\nimport branca.colormap as cm\nimport folium\nfrom folium.plugins import MarkerCluster\nimport pysal as ps\n\n\nand these for frontend\n\nimport tkinter as tk\nfrom tkinter import ttk\nfrom tkinter.filedialog import askopenfilename, asksaveasfilename, \naskdirectory\nimport backend as bk\n\n\nI'm trying to make it an executable program and I've tried PyInstaller but it did not work because of the dependencies. Is there any way to do it with PyInstaller? or any other libraries? Or what should I do?\n\np.s : I'm using python 3.6\n\n2nd EDIT:\n\nI tried cx_freeze and created a setup.py and build it. After that, when I double click on the program It simply does nothing. No error messages, anything. My code is in below:\n\nimport cx_Freeze\nimport sys\nimport os \n\nPYTHON_INSTALL_DIR = os.path.dirname(sys.executable)\nos.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')\nos.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')\n\ninclude_files = [(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'), os.path.join('lib', 'tk86t.dll')),\n (os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'), os.path.join('lib', 'tcl86t.dll'))]\n\npackages = [\"pandas\", \"numpy\", \"tkinter\", \"matplotlib\", \"osmnx\", \"networkx\",\n \"geopandas\", \"shapely\", \"fiona\", \"branca\", \"folium\",\n \"pysal\"]\n\nbase = None\nif sys.platform == \"win32\":\n base = \"Win32GUI\"\n\nexecutables = [cx_Freeze.Executable(\"frontend.py\", base=base, icon=\"transport.ico\")]\n\ncx_Freeze.setup(\n name = \"Network_Analyst\",\n options = {\"build_exe\": {\"packages\":packages,\n \"include_files\":include_files}},\n version = \"0.01\",\n description = \"Network analyst\",\n executables = executables\n )\n\n\nMy program consists of two scripts which are frontend and backend. I'm importing backend on the frontend section, should I add it somewhere in the setup code? And one more thing, I'm working on an environment to do these processes, Is this has an effect on building a setup? \n\nI'm giving a sample from my code to make your understanding better:\n\nIn frontend part I'm calling backend as\n\nimport backend as bk\n\n\nand in the script:\n\nclass Centrality(tk.Frame):\n\n def degree_cent(self):\n print(\"Calculating Degree Centrality\")\n G = self.findG()\n try:\n bk.degree_cent(G, self.t3.get(\"1.0\",'end-1c'), self.t2.get(\"1.0\",'end-1c'))\n except:\n bk.degree_cent(G, self.t3.get(\"1.0\",'end-1c'))\n\n\nIn backend I don't use OOP, I just write the functions such as:\n\nimport osmnx as ox, networkx as nx, geopandas as gpd, pandas as pd\n\ndef degree_cent(G, outpath, *args):\n\n G_proj = ox.project_graph(G) \n nodes, edges = ox.graph_to_gdfs(G_proj)\n nodes[\"x\"] = nodes[\"x\"].astype(float)\n\n degree_centrality = nx.degree_centrality(G_proj)\n degree = gpd.GeoDataFrame(pd.Series(degree_centrality), columns=[\"degree\"])\n\n\nExecutable program still doesn't respond when I'm clicking on it. No respond at all. No any windows event (I've checked it from Windows Event Viewer)." ]
[ "python-3.x", "executable", "cx-freeze" ]
[ "HTTParty::Response is cast into Hash when passed as argument to another method", "I have a service method that makes api requests and if the response was not ok, it would notify Bugsnag. It looks like this:\n\ndef send_request\n @response = HTTParty.get(api_endpoint, options)\n return JSON.parse(@response.body, symbolize_names: true) if @response.ok?\n raise StandardError.new(JSON.parse(@response.body))\nrescue StandardError => exception\n BugsnagService.notify(exception, @response)\nend\n\n\nMy BugsnagService#notify looks something like this:\n\nclass BugsnagService\n def self.notify(exception, response = nil, **options)\n if response\n response_body = if valid_json?(response.body) # Error right here\n JSON.parse(response.body)\n else\n response.body\n end\n options[:response_body] = response_body\n options[:response_code] = response.code\n end\n\n # Raising exception in test and development environment, or else the exception will be\n # silently ignored.\n raise exception if Rails.env.test? || Rails.env.development?\n\n Bugsnag.notify(exception) do |report|\n report.add_tab(:debug_info, options) if options.present?\n end\n end\n\n def self.valid_json?(json_string)\n JSON.parse(json_string)\n true\n rescue JSON::ParserError => e\n false\n end\nend\n\n\nI set response = nil in my notify method because not every error is an API error, so sometimes I would just call BugsnagService.notify(exception).\n\nI found out that if I just call it like I am in the snippet above, it would raise an error saying it can't call .body on a Hash. Somehow, when I pass @response into BugsnagService#notify, the object turns from HTTParty::Response into Hash.\n\nBut if I pass something in for the **options parameter, it will work. So I can call it like this:\n\nBugsnagService.notify(exception, @response, { })\n\n\nI've been trying to figure this one out but I couldn't find anything that would explain this. I'm not sure if there's something wrong with the way I define my parameters or if this is some bug with the HTTParty gem. Can anyone see why this is happening? Thanks!" ]
[ "ruby-on-rails", "httparty" ]
[ "Dictionary of weak and non-weak references", "I have a custom type MyClass and a factory class Factory that creates objects of type MyClass upon request. \n\nThe Factory stores created objects in a dictionary because objects are expensive to create and there are times when same object can be asked to be created multiple times. Each object with the same tag must be created one time only.\n\nclass MyObject\n{\n // .. not important\n}\n\nclass Factory\n{\n private Dictionary<int, MyObject> m_objects = new Dictionary<int, MyObject>();\n\n public MyObject CreateObject(int tag, params object[] parameters)\n {\n MyObject obj;\n if (!m_objects.TryGetValue(tag, out obj))\n {\n obj = new MyObject();\n // .. some initialization\n m_objects.Add(tag, obj);\n }\n\n return obj;\n }\n}\n\n\nObjects might be and might be not stored somewhere outside Factory for unknown amount of time. Objects might be changed after creation. There are times when Factory stores reference to an object and the object is not stored anywhere else.\n\nNow I want let garbage collector to do its job. I want objects not stored anywhere outside Factory and not changed to be collected. \n\nMy first thought was to use weak references for values in dictionary inside Factory but it seems like this approach does not handle \"changed and unreferenced\" case.\n\nHow should I store created objects in a dictionary so they are:\n\n\nCould be garbage collected\nAre not garbage collected when not referenced but changed?" ]
[ "c#", ".net", "garbage-collection", "weak-references" ]
[ "How I get the user_id value in sfDoctrineGuard plugin?", "I'm working on one module based on sfGuard and I need to allow users to edit or delete records. This is how I get the users:\n\n$id_empresa = $this->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();\n$this->users = Doctrine_Core::getTable('sfGuardUser')->createQuery('u')->leftJoin('u.SfGuardUserProfile p')->where('idempresa = ?', $id_empresa)->execute();\n\n\nBut then in the view while I'm iterating I don't know how to access to user_id value. I checked BasesfGuardUser but no method for get the Id exists, any advice or help?\n\nAdded the code for the view\nThis is the code for the iteration:\n\n<?php foreach ($users as $user): ?>\n <tr>\n <td><?php echo $user->getFirstName() ?></td>\n <td><?php echo $user->getLastName() ?></td>\n <td><?php echo $user->getEmailAddress() ?></td>\n <td><?php echo $user->getUsername() ?></td>\n <td><?php echo $user->getIsActive() ?></td>\n <td>\n <a href=\"<?php echo url_for('guard/users/' . $user->get('id') . '/edit') ?>\" class=\"btn btn-success btn-mini\">Editar</a>\n <a href=\"<?php echo url_for('guard/users/' . $user->get('id')) ?>\" class=\"btn btn-danger btn-mini\">Eliminar</a>\n </td>\n </tr>\n<?php endforeach; ?>" ]
[ "symfony1", "symfony-1.4", "sfdoctrineguard" ]
[ "Invoke-AzureRmResourceAction : The pipeline has been stopped", "Occasionally when executing Invoke-AzureRmResourceAction poweshell command I get the following exception.\n\n\n Invoke-AzureRmResourceAction : The pipeline has been stopped.\n Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -R ...\n + CategoryInfo : CloseError: (:) [Invoke-AzureRmResourceAction], PipelineStoppedException\n + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.InvokAzureResourceAction \n Cmdlet\n\n\nHow should I treat this error? Do should I catch it and retry? It normally works to just rerun the command." ]
[ "powershell", "azure", "azure-resource-manager" ]
[ "Laravel form request messages not appearing when validation fails", "my store method\nthe FormRequest \nthe validation is working and I get the confirm message in controller but when the validation fails I get no error messages any advice?" ]
[ "laravel", "laravel-formrequest" ]
[ "Rails: Appending methods to activerecord (the right way?)", "I'm messing around with creating a rails gem and I'm having trouble adding methods to ActiveRecord. Let's say I want to do the following:\n\nclass DemoModel < ActiveRecord::Base\n custom_method :first_argument, :second_argument\nend\n\n\nIn order to make this work, I throw in the following:\n\nmodule DemoMethod\n\n def self.included(base)\n base.extend(ClassMethods)\n end\n\n module ClassMethods \n def custom_method(*fields)\n @my_fields = fields\n end\n end\n\nend\n\nActiveRecord::Base.send(:include, DemoMethod)\n\n\nSo far, so good.\n\nThe problem is, I then want to access that my_fields variable from the instance of the model. For example, I might open up form_for with something like:\n\nmodule ActionView::Helpers::FormHelper\n def fields_for(record_name, record_object, options = {}, &block)\n the_fields = record_object.<I WANNA ACCESS @my_fields HERE!!!>.html_safe\n # ...\n end\nend\n\n\nThe difficulty is, 'custom_method' only seems to work if I set the helper as a class method, but that means .self is now the Model (DemoModel) instead of the DemoModel object on which I want to work. I could pass in the object manually with \"custom_method self, :first_argument, :second_argument\", but it seems a little clumsy to ask the users of my wonderful \"custom_method\" gem to have to prepend 'self' to their list of arguments.\n\nSo, the question is, how would a wiser Rails person set values for a specific object through custom_method, and then retrieve them somewhere else, such as fields_for? \n\nAs always, any suggestions appreciated." ]
[ "ruby-on-rails", "ruby", "activerecord" ]
[ "Matlab: Random Number depending on another", "I need your help with my Matlab code... \n\nI want to set a random Number (between 0 and 1) in a loop:\n\n for i=1:20\nm1(i)= rand;\n\n\nand a second random number (n1(i) should be set depending on the first max 0.2 greater/smaller but at least 0.1 greater/smaller than m1(i) without negative values.\n\nSo in the end I want two vectors with numbers between 0 and 1, but element 1 in m1 and element 1 in n1 shouldn't be too different but also not too close to another...\n\nWould be so thankful for your tips, I don't get it..." ]
[ "matlab", "random", "dependencies", "intervals" ]
[ "Random walk rerouting issue using netlogo", "I created a small network using the following code and implemented a random walk algorithm. I used some nodes as targets, where the walker is initially placed on one-of node. I used a path (walker-own variable) list with the walker to save its location. \n\nQuestion: How to prevent the walker to not come back towards those nodes which are already visited and listed in its memory(list). \nI'm new to Netlogo and unable to implement this logic.\n\nbreed [nodes node]\nbreed [walkers walker]\n\nwalkers-own [location path] \nnodes-own [ target? visited? ] \n\nto setup\n clear-all\n set-default-shape nodes \"circle\"\n create-nodes 30 [ \n set color blue \n set target? false\n set visited? false\n ]\n ask nodes [ create-link-with one-of other nodes ]\n repeat 500 [ layout ]\n ask nodes [ \n setxy 0.95 * xcor 0.95 * ycor \n ]\n ask n-of 5 nodes [\n set target? true\n set color white\n ]\n\n create-walkers 1 [\n set color red\n set location one-of nodes\n move-to location\n set path (list location path)\n ]\n reset-ticks\nend\n\nto layout\n layout-spring nodes links 0.5 2 1\nend\n\nto go\n ask links [ set thickness 0 ]\n ask walkers [\n let new-location one-of [link-neighbors] of location\n move-to new-location\n set location new-location\n set path lput location\n ;; This gets turtles to ask their current location \n ;; to set visited and target to true.\n ask location [\n set visited? true\n if target? = true [\n set color red\n ]\n ]\n ]\n\n ;; Check for target nodes that have NOT been visited. \n ;; If there aren't any, stop the model.\n if not any? nodes with [ target? = true and visited? = false ] [\n print (\"All target nodes have been visited.\")\n stop\n ] \n tick\nend" ]
[ "netlogo" ]
[ "Get users from Active Directory in C#", "I'm trying to show, in a ComboBox control, the users from an Active Directory on the network. To do this, I've the next function:\n\npublic static List<Usuario> MostrarUsuariosDominio()\n {\n List<Usuario> rst = new List<Usuario>();\n\n try\n {\n\n DirectoryContext dc = new DirectoryContext(DirectoryContextType.Domain, Environment.UserDomainName);\n Domain domain = Domain.GetDomain(dc);\n DirectoryEntry de = domain.GetDirectoryEntry();\n\n DirectorySearcher adSearcher = new DirectorySearcher(de); \n\n adSearcher.Filter = \"(&(objectClass=user)(objectCategory=person))\";\n adSearcher.PropertiesToLoad.Add(\"samaccountname\");\n\n SearchResult result;\n SearchResultCollection iResult = adSearcher.FindAll();\n\n Usuario item;\n if (iResult != null)\n {\n for (int counter = 0; counter < iResult.Count; counter++)\n {\n result = iResult[counter];\n if (result.Properties.Contains(\"samaccountname\"))\n {\n item = new Usuario();\n\n item.Nombre = (String)result.Properties[\"samaccountname\"][0];\n\n rst.Add(item);\n }\n }\n }\n\n adSearcher.Dispose();\n }\n\n catch (Exception ex)\n {\n Usuario item = new Usuario();\n item.Nombre = \"No se pudo recuperar la lista de usuarios\";\n rst.Add(item);\n }\n\n return rst;\n }\n\n\nIf I run the application in the PC who's domain controller it works fine: the function returns to me all users. But if I run it on another PC, I get the exception:\n\n\n Specified domain does not exist or couldn't contact with it\n\n\nIs there any way to recover the users list from another PC?" ]
[ "c#", "active-directory", "visual-studio-2017" ]
[ "Installing Microsoft.Data.Analysis in VS2010", "I am trying to install Microsoft.Data.Analysis in VS2010 C# Winform project. However I am getting the following error.\n\r\n\r\nPM> Install-Package Microsoft.Data.Analysis -Version 0.4.0\nInstall-Package : Part URI cannot start with two forward slashes.\nAt line:1 char:1\n+ Install-Package Microsoft.Data.Analysis -Version 0.4.0\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentException\n + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand\r\n\r\n\r\n\nHow can I solve it?" ]
[ "c#", "visual-studio-2010", "c#-4.0" ]
[ "How can ngdoc be used to document a function declaration in an angular service?", "I would like to add ngdoc documentation to a function declaration within an angular service. How can I do this for myFunction in the example below?\n\nI reckon I need something like @closure, @functionOf or @functionIn.\n\nPlease note that (in contrast to myMethod) myFunction is not a method.\n\n/**\n * @ngdoc service\n * @name myApp.service:myService\n * @description\n * My application.\n */\nangular\n .module('myApp')\n .factory('myService', function() {\n 'use strict';\n\n var x = 0;\n\n /**\n * @ngdoc function\n * @name ?\n * @description\n * How can this be identified as being within the closure of \n * myService, and not be described as a constructor?\n */\n function myFunction (z) {\n x++;\n x += z;\n }\n\n return {\n /**\n * @ngdoc method\n * @name myMethod\n * @methodOf myApp.service:myService\n * @description\n * A method of myService.\n */\n myMethod : function (x) {\n myFunction(x);\n }\n };\n })" ]
[ "angularjs", "documentation", "ngdoc" ]
[ "Java map.get() method returning null", "I am creating a program in which I read the 50 states and their capitals from a .txt file. I then run a while loop and store each of the states in an ArrayList and each of the capitals in another ArrayList. I convert those two ArrayList's to regular arrays, and then run a for loop to store each state as a key in a map, and each capital as a value in the map. My issue is that when I use the map.get() method to return the capital of a particular state it simply returns \"null\" and I am not sure why that would be the case. Here is my code:\n\nimport java.util.*;\nimport java.io.File;\nimport java.io.FileNotFoundException;\n\n\n\npublic class ChapterOneBasics {\n public static void main(String[] args) throws FileNotFoundException {\n Map<String, String> usCapitals = new HashMap<String, String>();\n ArrayList<String> aList = new ArrayList<>();\n ArrayList<String> bList = new ArrayList<>();\n int x = 0;\n File file = new File(\"C:\\\\Private\\\\Private\\\\Private\\\\capitals.txt\");\n Scanner sc = new Scanner(file);\n while(sc.hasNextLine()) {\n if(x % 2 == 0) {\n aList.add(sc.nextLine());\n }\n else\n bList.add(sc.nextLine());\n x++;\n\n}\n String[] usStates = aList.toArray(new String[aList.size()]);\n String[] uSCapitals = bList.toArray(new String[bList.size()]);\n for(int y = 0; y < uSCapitals.length; y++) {\n usCapitals.put(usStates[y], uSCapitals[y]);\n\n }\n System.out.println(usCapitals.get(\"Montana\"));\n }\n}\n\n\nAs you can see, I have stored each state to the Map in string format, but whenever I call a state to look up a capital city I get this as the output:\n\nnull\n\n\nI am not sure what the issue is." ]
[ "java", "dictionary" ]
[ "How to get parent of UserControl in ViewModel", "I want to create help in my Widnows Store app. I'm using MVVM pattern. I found this:\nhttp://msdn.microsoft.com/en-us/library/windows/apps/jj649425.aspx\n\nI have completed control XAML, but i don't know how to do this:\n\nprivate void MySettingsBackClicked(object sender, RoutedEventArgs e)\n {\n if (this.Parent.GetType() == typeof(Popup))\n {\n ((Popup)this.Parent).IsOpen = false;\n }\n SettingsPane.Show();\n }\n\n\nin mvvm way." ]
[ "c#", "mvvm", "windows-8", "appsettings" ]
[ "Trying to oauth2 with a generic provider using http requests in Ionic2 and typescript", "I have been trying to find a useful library to authenticate with a generic provider using oauth2. I am new to Ionic, and coudln't find a library that could help me accomplish this easily. I also see that most of the libraries are limited to mobile devices so I decided to go the hard way and try to write the code myself. I apologize if the code lucks ugly or awfully wrong. I have done some PHP programming a long time ago and I am trying to get back to programming with this.\n\nI first generated a provider page with the command: ionic g provider MakeHttpRequest.\nHere is a what I wrote so far, just the first step in getting the token.\n\nimport { Injectable } from '@angular/core';\nimport { Http } from '@angular/http';\nimport 'rxjs/add/operator/map';\n\n/*\n Generated class for the MakeHttpRequest provider.\n\n See https://angular.io/docs/ts/latest/guide/dependency-injection.html\n for more info on providers and Angular 2 DI.\n*/\n@Injectable()\nexport class MakeHttpRequest {\n\nconstructor\n(\npublic http: Http,\nprivate client_name : string,\nprivate client_id : string,\nprivate client_secret : string,\nprivate end_point : string,\nprivate auth_uri : string,\nprivate redirect_uri : string\n) {\n console.log('Hello MakeHttpRequest Provider');\n this.client_name = 'Alex';\n this.client_id = 'lalala';\n this.client_secret = 'lalalalala';\n this.end_point = 'http://www.lalaland.com';\n this.auth_uri = 'https://services.lalaland.com/oauth/authorize';\n this.redirect_uri = 'http://localhost/callback';\n }\n\n public getcode(){\n this.http.get(\"${this.auth_uri}?client_id=${this.client_id}&redirect_uri=${this.redirect_uri}&response?type=code\")\n .map(res => res.json()).subscribe(data => {\n console.log(data);\n});\n\n }\n\n\n}\n\n\nthen imported the class as follows into home.ts:\n\nimport {MakeHttpRequest} from '../../providers/make-http-request';\n\n\ncreated the constructor still under home.ts as follows:\n constructor(public navCtrl: NavController, private platform : Platform, private MakeHttpRequest : MakeHttpRequest)\n\nand created the following function:\n\npublic button(){\n\n this.MakeHttpRequest.getcode()\n }\n\n\nthen added the button function to the home.html page.\n\nBut all I get is an error. Can someone tell me if I'm in the right direction or even close. Any help or comments are highly appreciated." ]
[ "angular", "typescript", "ionic2" ]
[ "pass variable through unobtrusive JavaScript", "I would like to pass variable from a button to an event handler, but I don't know how what's the right way to do that. Both line x and line y are no good. But I need something like that.\n\nin html head\n\nwindow.onload = function()\n{\n var myButton = document.getElementsByTagName(\"button\");\n\n for (var i = 0; i < myButton.length; i++)\n {\n myButton[i].onclick = function() // <-- line x\n { \n alert(myButton[i].data1); // <-- line y\n }\n }\n}\n\n\nin html body\n\n<button type = \"button\" data1 = \"John\" data2 = \"52\">Click Me</button>\n<button type = \"button\" data1 = \"Peter\" data2 = \"26\">Click Me</button>\n<button type = \"button\" data1 = \"Mary\" data2 = \"44\">Click Me</button>" ]
[ "unobtrusive-javascript" ]
[ "How do I optimize the speed of my python compression code?", "I have made a compression code, and have tested it on 10 KB text files, which took no less than 3 minutes. However, I've tested it with a 1 MB file, which is the assessment assigned by my teacher, and it takes longer than half an hour. Compared to my classmates, mine is irregularly long. It might be my computer or my code, but I have no idea. Does anyone know any tips or shortcuts into making the speed of my code shorter? My compression code is below, if there are any quicker ways of doing loops, etc. please send me an answer (:\n\n(by the way my code DOES work, so I'm not asking for corrections, just enhancements, or tips, thanks!)\n\nimport re #used to enable functions(loops, etc.) to find patterns in text file\nimport os #used for anything referring to directories(files)\nfrom collections import Counter #used to keep track on how many times values are added\n\nsize1 = os.path.getsize('file.txt') #find the size(in bytes) of your file, INCLUDING SPACES\nprint('The size of your file is ', size1,)\n\nwords = re.findall('\\w+', open('file.txt').read()) \nwordcounts = Counter(words) #turns all words into array, even capitals \ncommon100 = [x for x, it in Counter(words).most_common(100)] #identifies the 200 most common words\n\nkeyword = []\nkcount = []\nz = dict(wordcounts)\nfor key, value in z.items():\n keyword.append(key) #adds each keyword to the array called keywords\n kcount.append(value)\n\ncharacters =['$','#','@','!','%','^','&','*','(',')','~','-','/','{','[', ']', '+','=','}','|', '?','cb',\n 'dc','fd','gf','hg','kj','mk','nm','pn','qp','rq','sr','ts','vt','wv','xw','yx','zy','bc',\n 'cd','df','fg','gh','jk','km','mn','np','pq','qr','rs','st','tv','vw','wx','xy','yz','cbc',\n 'dcd','fdf','gfg','hgh','kjk','mkm','nmn','pnp','qpq','rqr','srs','tst','vtv','wvw','xwx',\n 'yxy','zyz','ccb','ddc','ffd','ggf','hhg','kkj','mmk','nnm','ppn','qqp','rrq','ssr','tts','vvt',\n 'wwv','xxw','yyx''zzy','cbb','dcc','fdd','gff','hgg','kjj','mkk','nmm','pnn','qpp','rqq','srr',\n 'tss','vtt','wvv','xww','yxx','zyy','bcb','cdc','dfd','fgf','ghg','jkj','kmk','mnm','npn','pqp',\n 'qrq','rsr','sts','tvt','vwv','wxw','xyx','yzy','QRQ','RSR','STS','TVT','VWV','WXW','XYX','YZY',\n 'DC','FD','GF','HG','KJ','MK','NM','PN','QP','RQ','SR','TS','VT','WV','XW','YX','ZY','BC',\n 'CD','DF','FG','GH','JK','KM','MN','NP','PQ','QR','RS','ST','TV','VW','WX','XY','YZ','CBC',\n 'DCD','FDF','GFG','HGH','KJK','MKM','NMN','PNP','QPQ','RQR','SRS','TST','VTV','WVW','XWX',\n 'YXY','ZYZ','CCB','DDC','FFD','GGF','HHG','KKJ','MMK','NNM','PPN','QQP','RRQ','SSR','TTS','VVT',\n 'WWV','XXW','YYX''ZZY','CBB','DCC','FDD','GFF','HGG','KJJ','MKK','NMM','PNN','QPP','RQQ','SRR',\n 'TSS','VTT','WVV','XWW','YXX','ZYY','BCB','CDC','DFD','FGF','GHG','JKJ','KMK','MNM','NPN','PQP',] #characters which I can use\n\nsymbols_words = []\nchar = 0\nfor i in common100:\n symbols_words.append(characters[char]) #makes the array literally contain 0 values\n char = char + 1\n\nprint(\"Compression has now started\")\n\nf = 0\ng = 0\nno = 0\nwhile no < 100:\n for i in common100:\n for w in words:\n if i == w and len(i)>1: #if the values in common200 are ACTUALLY in words\n place = words.index(i)#find exactly where the most common words are in the text\n symbols = symbols_words[common100.index(i)] #assigns one character with one common word\n words[place] = symbols # replaces the word with the symbol\n g = g + 1\n no = no + 1\n\n\nstring = words\nstringMade = ' '.join(map(str, string))#makes the list into a string so you can put it into a text file\nfile = open(\"compression.txt\", \"w\")\nfile.write(stringMade)#imports everything in the variable 'words' into the new file\nfile.close()\n\nsize2 = os.path.getsize('compression.txt')\n\nno1 = int(size1)\nno2 = int(size2)\nprint('Compression has finished.')\nprint('Your original file size has been compressed by', 100 - ((100/no1) * no2 ) ,'percent.'\n 'The size of your file now is ', size2)" ]
[ "python", "performance", "encryption", "optimization", "compression" ]
[ "Mouse button modifiers - Autohotkey", "I want to set up my mouse buttons to perform different functions if I press and hold them, or if I press them while holding down shift/alt/ctrl. \n\nAs some trivial examples:\n\n\nShift-leftMouseButton = \"back\" in firefox history?\nShift-rightMouseButton = go forward in firefox, \nPress-and-hold right mouse button = some other action in firefox (eg, move to opposite screen and maximize).\n\n\nEDIT:\n\nI forgot to mention I have 5 mouse buttons. (Microsoft Wireless Laser Mouse 6000)" ]
[ "autohotkey" ]
[ "What does nvprof output: \"No kernels were profiled\" mean, and how to fix it", "I have recently installed Cuda on my arch-Linux machine through the system's package manager, and I have been trying to test whether or not it is working by running a simple vector addition program.\nI simply copy-paste the code from this tutorial (Both the one using one and more kernels) into a file titled cuda_test.cu and run\n> nvcc cuda_test.cu -o cuda_test\n\nIn either case, the program can run, and I get no errors (both as in the program doesn't crash and the output is that there were no errors). But when I try to run the Cuda profiler on the program:\n> sudo nvprof ./cuda_test\n\nI get result:\n==3201== NVPROF is profiling process 3201, command: ./cuda_test\nMax error: 0\n==3201== Profiling application: ./cuda_test\n==3201== Profiling result:\nNo kernels were profiled.\nNo API activities were profiled.\n==3201== Warning: Some profiling data are not recorded. Make sure cudaProfilerStop() or cuProfilerStop() is called before application exit to flush profile data.\n\nThe latter warning is not my main problem or the topic of my question, my problem is the message saying that No Kernels were profiled and no API activities were profiled.\nDoes this mean that the program was run entirely on my CPU? or is it an error in nvprof?\nI have found a discussion about the same error here, but there the answer was that the wrong version of Cuda was installed, and in my case, the version installed is the latest version installed through the systems package manager (Version 10.1.243-1)\nIs there any way I can get either nvprof to display the expected output?\nEdit\nTrying to adhere to the warning at the end does not solve the problem:\nAdding call to cudaProfilerStop() (or cuProfilerStop()), and also adding cudaDeviceReset(); at end as suggested and linking the appropriate library (cuda_profiler_api.h or cudaProfiler.h) and compiling with\n> nvcc cuda_test.cu -o cuda_test -lcuda\n\nYields a program which can still run, but which, when uppon which nvprof is run, returns:\n==12558== NVPROF is profiling process 12558, command: ./cuda_test\nMax error: 0\n==12558== Profiling application: ./cuda_test\n==12558== Profiling result:\nNo kernels were profiled.\nNo API activities were profiled.\n==12558== Warning: Some profiling data are not recorded. Make sure cudaProfilerStop() or cuProfilerStop() is called before application exit to flush profile data.\n======== Error: Application received signal 139\n\nThis has not solved the original problem, and has in fact created a new error; the same happens when cudaProfilerStop() is used on its own or alongside cuProfilerStop() and cudaDeviceReset();\nThe code\nThe code is, as mentioned copied from a tutorial to test if Cuda is working, though I also have included calls to cudaProfilerStop() and cudaDeviceReset(); for clarity, it is here included:\n#include <iostream>\n\n#include <math.h>\n\n#include <cuda_profiler_api.h>\n\n// Kernel function to add the elements of two arrays\n\n__global__\nvoid add(int n, float *x, float *y)\n{\n int index = threadIdx.x;\n int stride = blockDim.x;\n for (int i = index; i < n; i += stride)\n y[i] = x[i] + y[i];\n}\n\n\nint main(void)\n\n{\n\n int N = 1<<20;\n\n float *x, *y;\n\n\n cudaProfilerStart();\n\n\n // Allocate Unified Memory – accessible from CPU or GPU\n\n cudaMallocManaged(&x, N*sizeof(float));\n\n cudaMallocManaged(&y, N*sizeof(float));\n\n\n\n // initialize x and y arrays on the host\n\n for (int i = 0; i < N; i++) {\n\n x[i] = 1.0f;\n\n y[i] = 2.0f;\n\n }\n\n\n\n // Run kernel on 1M elements on the GPU\n\n add<<<1, 1>>>(N, x, y);\n\n\n\n // Wait for GPU to finish before accessing on host\n\n cudaDeviceSynchronize();\n\n\n\n // Check for errors (all values should be 3.0f)\n\n float maxError = 0.0f;\n\n for (int i = 0; i < N; i++)\n\n maxError = fmax(maxError, fabs(y[i]-3.0f));\n\n std::cout << "Max error: " << maxError << std::endl;\n\n\n\n // Free memory\n\n cudaFree(x);\n\n cudaFree(y);\n \n cudaDeviceReset();\n cudaProfilerStop();\n\n \n\n return 0;\n\n}" ]
[ "cuda" ]
[ "BASH: \"local var=${3-16}\" meaning not clear", "Trying to understand some BASH script I encountered this line\n\nlocal var=${3-16}\n\n\nI understand the assignment part and the local part - my question is what does the dash indicate in \"${3-16}\". \n\nIf I try:\n\n $ maxi=${1-45}; echo $maxi\n 45 <-- result\n\n\nPlease explain the meaning of the dash. Thanks" ]
[ "linux", "bash", "shell" ]
[ "Is there a way to deprecate or hide system framework API in Swift?", "For some context, I am using SpriteKit. I created an extension for SKTexture:\npublic extension SKTexture {\n var sizeInPoint: CGSize {\n return CGSize(size().width/2, size().height/2)\n }\n}\n\nNow I would like to prevent accidental usage of size(), because texture.size() is in pixel, which is never what I want in my game.\nHow do I deprecate a system API? Or is it even possible?\nNote:\nI know when I subclass the SKTexture, I can mark size() as deprecated IN MY SUBCLASS. However, this is not ideal because the superclass SKTexture still has size() API.\nFor example, we can still get SKTexture from SKTextureAtlas:\nlet size = textureAtlas.textureNamed("dummy.png").size() // avoid this!" ]
[ "ios", "swift" ]
[ "ngTable filter only works for the first page", "Working on an ngTable that has more than 1000 records.\nEverything works fine, but the only problem I am facing is the filter.\nit only filters text in the active page.\nLets say I am in page 3, and if I search/filter something using a textbox it has to be from page 3 otherwise it will show nothing..\n\nmy code is as follow:\n\n $scope.$watch(\"filter.$\", function () {\n $scope.tableParams.reload();});\n\n\n $scope.tableParams = new ngTableParams({\n page: 1, // show first page\n count: 10, // count per page\n sorting: {\n schoolName: 'asc' // initial sorting\n }\n },\n\n{\n total: $scope.schoolInfo.length, // length of data\n getData: function ($defer, params) {\n var filteredData = {};\n\n\n //reason I am doing this is to get the data always filtered, no matter what\n var orderedData = $filter('orderBy')($scope.schoolName, params.orderBy());\n\n params.total(orderedData); // set total for recalc pagination\n\n $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));\n },$scope:$scope\n });\n\n\nthe sorting works perfect, but its the search only\n\nSearch: <input type=\"text\" ng-model=\"search.schoolName\">\nI also tried ng-model=\"search\"aswell\n\n<tr ng-repeat=\"mydata in $data | filter:search\"> \nI also tried search:strict\n\nnothing seems to help if someone can please help me?\n\nThanks in advance" ]
[ "javascript", "angularjs", "angularjs-ng-repeat", "angular-ui", "ngtable" ]
[ "Can glFenceSync be used cross thread or context boundary?", "May I create a glFenceSync in one thread, and wait for it in another thread?\n\nor \n\nMay I create a glFenceSync in one context and wait for it in another context?" ]
[ "opengl", "opengl-es" ]
[ "reverse output after loop in a c program", "i do this program \n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nint main(){\n char *str, c;\n int x = 0, y = 1;\n\n str = (char*)malloc(sizeof(char));\n\n printf(\"Inserisci stringa principale : \");\n\n while (c != '\\n') {\n // read the input from keyboard standard input\n c = getc(stdin);\n\n // re-allocate (resize) memory for character read to be stored\n str = (char*)realloc(str, y * sizeof(char));\n\n // store read character by making pointer point to c\n str[x] = c;\n\n x++;\n y++;\n }\n\n str[x] = '\\0'; // at the end append null character to mark end of string\n\n printf(\"\\nLa stringa inserita : %s\", str);\n\n char *sub, b;\n int w = 0, z = 1;\n\n sub = (char*)malloc(sizeof(char));\n\n printf(\"Immetti sottostringa da cercare : \");\n\n while (b != '\\n') {\n // read the input from keyboard standard input\n b = getc(stdin);\n\n // re-allocate (resize) memory for character read to be stored\n sub = (char*)realloc(sub, z * sizeof(char));\n\n // store read character by making pointer point to c\n sub[w] = b;\n\n w++;\n z++;\n }\n\n sub[w] = '\\0'; // at the end append null character to mark end of string\n\n char *p1, *p2, *p3;\n int i=0,j=0,flag=0, occurrences=0;\n\n p1 = str;\n p2 = sub;\n\n for(i = 0+1; i<strlen(str); i++)\n {\n if(*p1 == *p2)\n {\n p3 = p1;\n\n\n for(j = 0;j<strlen(sub);j++)\n {\n if(*p3 == *p2)\n {\n p3++;p2++;\n } \n else\n break;\n }\n p2 = sub;\n if(j + 1 == strlen(sub))\n {\n flag = 1;\n occurrences = occurrences + 1;\n printf(\"\\nnel numero di volte : %d\\n\",occurrences );\n printf(\"\\nSottostringa trovata all'indice : %d\\n\",i );\n }\n\n }\n p1++; \n }\n\n\n if(flag==0)\n {\n printf(\"Sottostringa non trovata\");\n }\n free(str);\n free(sub);\n return (0);\n }\n\n\nWhich searches for a given substring in a string, once it finds print the locations where the substring is found and the number of times it is found, at present for example if my string is aaooaaoo and my substring or output outputs the positions , 3 and 7 and last 2 (ie the number of occurrences) I would need to get first 2 and then the positions in reverse order, ie in this case should print next to the 2nd before the 7 and then the 3, How could you do it?" ]
[ "c", "string", "loops", "substring", "reverse" ]
[ "Domain Wide Editor Add-on not found in Marketplace", "I've published a domain-wide sheets add-on using this guide https://developers.google.com/gsuite/add-ons/how-tos/publish-for-domains\n\n\nThe GCP project is setup and the Visibility is set to \"My Domain\"\nIn the Chrome Web Store the project status is \"Published\" and \"GAM: Published\"\nIn the Chrome Web Store the visibility option is set to Private -> Everyone at [domain]\n\n\nI've received no errors and it's been 12 hours since publishing and the guide says it should be a few minutes to an hour.\n\nIn our domains admin panel I then goto Apps -> + -> Expand the Hamburger -> \"[Domain] Apps\" where domain-wide add-ons are found but there's no add-on listed. \n\n\n\nI'm not sure what to try next. Any help?" ]
[ "google-apps-script", "google-apps-marketplace", "gmail-addons" ]
[ "Looping over columns in data.table R", "I am trying to loop over columns in data.table package in R. I have been having trouble trying to get the for loop to accurately input the column when I subset the datatable.\n\nThe goal of my task is to get the number of rows for each subset of the datatable when the column condition of \"==1\" is met.\n\nHere is my code:\n\n\ndata <- data.table(va=c(1,0,1), vb=c(1,0,0), vc=c(1,1,1))\n\n\nnames <- c(\"va\", \"vc\")\n\nfor (col in names) {\n print(nrow(data[col == 1,]))\n print(col)\n}\n\n\nHere is the output I get\n\n[1] 0\n[1] \"va\"\n[1] 0\n[1] \"vc\"\n\n\n\nIs there something I am missing or a better way of doing this?" ]
[ "r", "datatable", "data.table" ]
[ "how can i further understand the compilation process used by gcc?", "I was trying to reverse engineer some psp programs developed using the free\npspsdk\n\nhttps://sourceforge.net/projects/minpspw/\n\nI noticed that i created a function to see how MIPS handles more than 4 arguments (a0-a4).\nEveryone i know has told me that they get passed onto the stack.\nTo my surprise, that 5th argument was actually passed to register t0 and to compiler didn't even use the stack!\n\nit also inlined a function without even having used a jal or jump to it. (obvious optimization).\nAltough there was indeed a space a memory and you could double check by using print with function pointer argument. That actual code that was executed was automatically inlined without the need of a function call instruction.\n\n^^ but that doesn't really benefit me for a reverse engineer attempt...\n\nthere is a man page for this version of gcc. and it takes seconds to install if anyone is able to provide it's man for compilation if there is one. \nIt's so long i don't even know how to reference information reliably" ]
[ "gcc", "compilation" ]
[ "How to configure Symfony 4 with Nginx proxy_pass", "I'm trying to deploy an application based on Symfony 4 on a server. The server runs other applications and for separating them I am using Nginx's proxy_pass, then for example I would configure:\n\nlocation /application {\n proxy_pass http://127.0.0.1:85/;\n}\n\n\nThe application runs but when Symfony generates paths for assets or redirects, these are all relative to / instead of /application/ as it doesn't know what the real path is. I've searched the documentation but I haven't found the way to inform this version of Symfony the real path (I'm assuming this sould be done application-level that it can't be solved on Nginx). Is there a way?" ]
[ "symfony", "nginx" ]
[ "Hook all command output within bash", "Just for fun I want to pipe all output text in a terminal to espeak. For example, after this is set up I should be able to type echo hi and hear \"hi\" spoken, or ls and hear my directory contents listed.\n\nThe only promising method to capture output I've found so far is from here: http://www.linuxjournal.com/content/bash-redirections-using-exec\n\nThis is what I have so far:\n\nnpipe=/tmp/$$.tmp\nmknod $npipe p\ntee /dev/tty <$npipe | espeak &\nespeakpid=$!\nexec 1>&-\nexec 1>$npipe\ntrap \"rm -f $npipe; kill $espeakpid\" EXIT\n\n\nIt works (also printing a bunch of \"Done\" jobs), but creating the named pipe, removing with trap and printing the output with tee all just seems a bit messy. Is there a simpler way?" ]
[ "bash", "terminal", "hook" ]
[ "How can get correct Column Name from Database with Npgsql?", "This is my table in database:\nCREATE TABLE public.test\n(\n id integer NOT NULL DEFAULT nextval('test_id_seq'::regclass),\n hc character varying(30),\n "Hc" character varying(30),\n "HC" character varying(30),\n f character varying(30),\n "F" character varying(30),\n f1 character varying(30),\n te numeric(2,2),\n CONSTRAINT test_pkey PRIMARY KEY (id)\n)\n\nIf i get a Table Definition by Npgsql from vb.net:\nselect * from test where null = null\n\nResult: some colums had changed name:\nEx: Hc => Hc1,HC => HC2\n\nHow can get correct Column Name from Database with Npgsql?" ]
[ "sql", ".net", "vb.net", "npgsql" ]
[ "Is it worth remaking an e-commerce website to use mySQL instead of Access?", "I am doing some work on an asp website that uses Access as its database. \n\nRecently, the site has been having unexplained downtime, and we are wondering if making a whole new site, and switching to PHP with mySQL would bring a big performance boost or not. \n\nIt is a fairly busy site with about max 80 people connected at once." ]
[ "mysql", "performance", "ms-access" ]
[ "Best way to make website for multiple languages", "I have made a website using(Asp.net, c#) and its content in English.\nNow i have a requirement to make this website in such a way that is support multiple languages ie (German,French). \nLable/Textbox/ string all values will display respective selected languages\nWhile searching i came to know there are some ways like\n\n\nUsing localization\nUse resource file.\nDatabase(every thing is saved in database for different language).\n\n\nfrankly speaking I am not agree with 3rd option.\n\nI want to know which is the best way to go or is there any other better way?\n\nNote:Current Website was built using .NET framework 4.0/ vs 2010. \n\nThanks" ]
[ "c#", "asp.net", ".net", "localization" ]
[ "WatiN - working with WatIn in winForm", "I start working with WatiN and I want to know, can I see the results without opening WatIn opening the browser automatically?\n\nI mean, when I do: \n\nusing (var browser = new IE(\"http://www.google.com\"))\n{\n browser.TextField(Find.ByName(\"q\")).Value = \"GOGOOG\";\n}\n\n\nit works great (and really fast), but I would like to see this inside a win Form without opening the browser.\n\nSo my real question is:\n\nCan I use WatiN with the WebBrowser object/Control in winForm?" ]
[ "c#", "winforms", "watin" ]
[ "convert jquery datatable date to specific format", "I am working with MVC and jquery datatable plugin for grid purpose.\nI am populating table in dynamically including table header and data. The column will be differ and I don't know what the column is coming and it's type.\n\nIn this case, Is there any option to change the date value to a specific format?\n\nJust, populating table header as below,\n\n<table class=\"display nowrap dataTable table reportData\" id=\"reportsTable\">\n <thead>\n <tr>\n @foreach (var row in Model.Columns)\n {\n <th>@row.Value</th>\n }\n </tr>\n\n </thead>\n\n <tbody>\n\n </tbody>\n </table>\n\n\nAnd binding data as below,\n\nvar table = $('#reportsTable').DataTable();\n\n$.ajax({\n url: urlContent + 'Reports/GetReportData',\n type: 'GET',\n contentType: 'application/json; charset=utf-8',\n beforeSend: function () {\n $(\"#reportsTable_processing\").css(\"visibility\", \"visible\").css('display', 'block').css('z-index',1);\n },\n success: function (data, textStatus, jqXHR) {\n ErrorHandler(data, function (data) {\n $.each(data, function (ix, item) {\n table.row.add(item);\n });\n\n table.columns.adjust().draw();\n });\n },\n complete: function () {\n $(\"#reportsTable_processing\").css(\"visibility\", \"hidden\").css('display', 'none');;\n }\n });\n\n\nI need to change the date to a specific format (MM/DD/YYYY) wherever the date occurs in the table." ]
[ "jquery", "asp.net-mvc", "datatables" ]
[ "Best way to store U.S. phone numbers ( NANP)", "I have requirement to store NANP(North American Numbering Plan) numbers. This means I don't care and no need to bother about international numbers. \n\nNumbering plan goes like this :\nNPA-NXX-XXXX\n\nI would filter & strip extra space or dash(-) to make into 10 digit correct format. Currently we use MySQL and CouchDB for some other stuff but would prefer to keep in MySQL DB as preferred storage system. \nI'm looking for fast read operation to match numbers during runtime and write can be little slow as mostly insert/update will happen in off hours. \n\nSince it is given that NPA & NXX will never start with 0 so if we can separate \nthem and they can be used as integer type in case of want to breakdown. \n\nFor NoSQL case, it is possible to generate separate document for each area code and then further isolate NXX & XXXX.\nFor RDBMS case, a full number can be stored as indexed integer for fast accessibility. \n\nWhat would be the best database design to store these numbers ? \n\nThanks in advance." ]
[ "mysql", "couchdb" ]
[ "Spring Boot project using only AWS free tier", "AWS has a list of free tier (non-expiring offers) here. I wonder if it is enough to deploy a small(less than 1 Gb in total) Spring Boot(+ mongo/postgres) hobby project using ONLY these features." ]
[ "java", "spring", "amazon-web-services", "spring-boot", "amazon" ]
[ "MongoDB return names of duplicate files", "This is my first project using mongodb, I doing a file upload website and everyhting is working smooth, now what I need is to get of names of file which are duplicate by checking there checksum. All the info is already on the database here is an example of how im saving the info\n\n{\n \"_id\" : ObjectId(\"58754c4257edd7263c678fb9\"),\n \"checksum\" : \"8473b6ba72ca7aa3041d3f473fb38e12\",\n \"destination\" : \"upload/\",\n \"fieldname\" : \"file[0]\",\n \"mimetype\" : \"application/x-zip-compressed\",\n \"size\" : 4531435,\n \"path\" : \"upload/1484082242254-file-1.5.zip\",\n \"filename\" : \"1484082242254-file-1.5.zip\",\n \"originalname\" : \"file-1.5.zip\"\n}\n\n\nnow what i need is a mongodb query which will return the filename and/or path of all the duplicate files with the same checksum\n\nthank you for your time and help" ]
[ "node.js", "mongodb", "mongoose" ]
[ "Redux-Observable dispatch multiple actions and wait for responses", "I'm trying to dispatch multiple actions, then perform a secondary step after every initial actions have completed. I'm able to dispatch multiple actions, but am unable wait for their responses. Instead of array of response actions, I'm receiving an array a request actions. With Redux-Observables, how can I dispatch multiple actions, wait for all of them to complete, then perform a secondary step with their responses? I've tried different operators, such as forkJoin, concat, but I ultimately end up with the same issue.\n\ninterface Action1ResponseType { \n id: string;\n name: string;\n address: Address;\n ...\n}\n\ninterface Action2ResponseType { \n id: string;\n addressId: string;\n addressValidation: AddressValidation;\n ...\n}\n\ninterface Action3ResponseType { \n id: string;\n addressId: string;\n addressHistory: AddressHistory\n ...\n}\n\ninterface PageLoaded {\n viewModels: [{\n addressToInspect: { \n id: string;\n address: Address;\n history: AddressHistory;\n validation: AddressValidation;\n ...\n }]\n }\n ...\n}\n\n\nimport { createAction } from 'typesafe-actions';\n\nconst action1 = () => createAction('ACTION1')<Action1ResponseType[]>();\nconst action2 = () => createAction('ACTION2')<Action2ResponseType[]>();\nconst action3 = () => createAction('ACTION3')<Action3ResponseType[]>();\n\n// Usage example:\nconst action1ToDispatch = action1({id: '123'});\n// action1ToDispatch (the request) will be:\n// {\n// type: 'ACTION1',\n// payload: {\n// id: '123'\n// }\n// }\ndispatch(action1ToDispatch);\n\n\nExample responses:\naction1:\nconst response1: Action1ResponseType[] = [\n {\n id: '456',\n name: 'helloworld',\n address: {\n id: '789'\n ...\n } \n }\n];\n\nconst response2: Action2ResponseType[] = [\n {\n id: '543',\n addressId: '789',\n addressValidation: {...}\n }\n];\n\nconst response3: Action3ResponseType[] = [\n {\n id: '321',\n addressId: '789',\n addressHistory: {...}\n }\n];\n\n\nexport const myEpic = (action$) => {\n return action$.pipe(\n ofType('myActionType'),\n switchMap((action) => {\n const x = ...; // Perform some initial work before API calls\n\n return forkJoin([\n action1(x),\n action2(x),\n action3(x),\n ]);\n }),\n // The following function is not correct. Instead of receiving an array of responses, an array of request actions are passed.\n map(results => {\n const [response1, response2, response3] = results;\n const pageLoadData = ...; // Iterate the various address that are returned and attempt to merge data from response1, response2, and response2.\n\n return {\n type: 'PageLoaded',\n data: pageLoadData,\n };\n })\n );\n};" ]
[ "redux-observable" ]
[ "Drag & drop hints are lost in Telerik's RadControls for ASP.NET AJAX", "I have a Telerik tree and drag & drop node move is in action. But then I applied a theme (bought from somewhere) to the overall design of my site, and now, the hint are gone. \nWhen you drag a node, some horizontal hint lines appear, so that you can understand that if you release your node (drop it) where it would be dropped." ]
[ "drag-and-drop", "tree", "telerik", "hint" ]
[ "Spring Injection & Globally initialized objects", "I have a spring injected service \n\n class A{\n List l = new ArrayList();\n\n public m1(){\n //do some additions in list \n }\n\n public m2(){\n //do some new additions in list\n }\n }\n\n\nNow because creating of objects of A, is in the hands of spring the behavior of program is not what is expected. (I expect list to be available empty always but not initialized by methods for some wired reason)\n\nWill Spring always create only one instance of A, so that list l will keep on growing, I have configured bean as singleton in application context.\n\nIf yes, naturally I must initialize the list inside the functions m1 & m2 or callee must past the reference, and in my case callee being struts2 actions they are not singleton so this issue can be solved?\n\nOr \n\nDoes spring provide any support in configuration to initialize member variables at every call or something else?\n\nMore generally what are best practices to have in writing services injected by spring about using member variables/ local variables for performance & efficiency." ]
[ "java", "spring", "dependency-injection" ]
[ "Use Settings File in Business Layer (BLL)", "I have a settings file in my UI layer, and I need to use its values in my business layer. My UI and business layers are in separate assemblies.\n\nI can't access the settings values in the business layer directly, so I currently pass them through the business layer constructor. I am considering making a class that contains all the settings file values and passing it through the business layer constructor.\n\nIs this the best way to access these values, or is there another way?" ]
[ "c#", "architecture", "settings", "bll" ]
[ "Public inheritance for all except one function", "Say I have the following classes:\nclass Car\n{\n ...\npublic:\n void drive(Direction direction);\n void open_door();\n void refuel();\n double get_speed();\n ...\n};\n\nclass SelfDrivingCar: public Car\n{\n CarDrivingProgram *driving_program;\n ...\n};\n\nclass CarDrivingProgram\n{\npublic:\n virtual void drive_car(Car *car) = 0;\n};\n\nclass ExampleCarDrivingProgram: public CarDrivingProgram\n{\n void drive_car(Car *car) override;\n ...\n};\n\nSelfDrivingCar is a Car in every way except the user is forbidden from manually driving it. Instead, CarDrivingProgram drives it via drive_car(...). Using public inheritance seems correct because most operations on a Car could also happen to a SelfDrivingCar. For example, the user might create an array of Cars and then refuel all the Cars in the array, some of which happen to be SelfDrivingCars.\nHowever, using public inheritance exposes the drive(...) method, which the user should not call on a SelfDrivingCar.\nOne solution would be to make the drive(...) method private in SelfDrivingCar, but that's messy, requires all CarDrivingPrograms to be friends in order to access drive(...), and can be circumvented if the user casts a SelfDrivingCar to a Car and then calls drive(...) from the Car.\nAnother solution would be to keep a boolean flag that indicates whether a Car is currently allowed to be driven or not and printing an error if drive(...) is called when the flag is set to "false". For a SelfDrivingCar, this flag would be "false" for most of the time, and CarDrivingProgram would temporarily set this to "true" for the duration of drive_car(...). However, this catches mistakes at runtime rather than at compile time, and the user can still toggle the flag and drive a SelfDrivingCar manually if they really want to.\nUsing protected/private inheritance would be another solution, but that prevents the user from doing something like adding SelfDrivingCars to an array of Cars that are to be later refuelled (described earlier).\nHow do I cleanly forbid the user from calling drive() on a SelfDrivingCar, ideally catching things at compile thing?\nFor clarification: The SelfDrivingCar class still needs a drive(...) function or something like it because CarDrivingProgram needs a way to tell SelfDrivingCar the direction to drive in. CarDrivingPrograms can drive any Car, not just SelfDrivingCars. I want CarDrivingProgram to be able to drive SelfDrivingCars but for the user to be unable to. For example, the user could have an array of pairs of CarDrivingPrograms and Cars, and call carDrivingProgram[i]->drive_car(car[i]) for each pair. I could make all CarDrivingPrograms friends but that's messy." ]
[ "c++", "inheritance" ]
[ "Setting user's timezone on session using devise in ruby on rails", "I have made a hidden field on login form which contain user timezone and now i want to set it on that user session. I'm using devise for authentication. When using params[:hiddenfieldname] values are not accessible in the controller where I'm redirecting the user to home page. Please tell me what are the steps I'm missing." ]
[ "ruby-on-rails", "ruby-on-rails-3", "devise", "timezone" ]
[ "Create dynamic drop down box", "I am trying to create a dependent dynamic drop down box on three input fields. At the moment the each input field is getting their data from their individual tables called tour_type, countries and destination. This is the form:\n\n <label>Tour Type </label>\n <select id=\"tourtype\" name=\"tourtype\" required> \n <option value=\"\" selected=\"selected\">--Select--</option>\n <?php\n\n $sql=mysql_query(\"Select tour_type_id,tour_name from tour_type\");\n while($row=mysql_fetch_array($sql))\n {\n $tour_type_id=$row['tour_type_id'];\n $name=$row['tour_name'];\n echo \"<option value='$tour_type_id'>$name</option>\";\n }\n ?>\n </select>\n\n\n <label>Country </label>\n <select id=\"country\" name=\"country\" class=\"country\" required>\n <option value=\"\" selected=\"selected\">-- Select --</option> \n <?php \n $sql=mysql_query(\"SELECT * FROM `countries` where `tour_type_id` = ?\"); //what should i put in here?\n while($row=mysql_fetch_array($sql))\n {\n $cid=$row['countries_id'];\n $name=$row['countries_name'];\n\n echo \"<option value='$cid'>\".$name.\"</option>\";\n }\n ?>\n </select>\n\n\n <label>Destination </label>\n <select id=\"destination\" name=\"destination\" class=\"destination\" required> \n <option value=\"\" selected=\"selected\">-- Select --</option>\n <?php \n $sql=mysql_query(\"SELECT * FROM `destination` where `countries_id` = ?\");//what should i put in here?\n\n\n while($row=mysql_fetch_array($sql))\n {\n $destination_id=$row['destination_id'];\n $name=$row['destination_name'];\n\n echo \"<option value='$destination_id'>\".$name.\"</option>\";\n }\n ?>\n\n </select>\n\n\nThis is the javascript at the top of the form\n\n<script type=\"text/javascript\">\n$(document).ready(function()\n{\n$(\".country\").change(function()\n{\nvar id=$(this).val();\nvar dataString = 'id='+ id;\n\n$.ajax\n({\ntype: \"POST\",\nurl: \"ajax.php\",\ndata: dataString,\ncache: false,\nsuccess: function(html)\n{\n$(\".destination\").html(html);\n} \n});\n\n});\n});\n</script>\n\n\nFinally these are the 3 tables i.e. tour_type, countries and destination respectively:\n\n\n\n\n\n\n\nCan anyone help me on this? \nHow do I make each drop down box dependable on each other? For e.g. If i select Culture on the 1st drop down, then only Holland and Belgium should show in the 2nd drop down. So now if i select Holland from 2nd drop down, then Amsterdam should show in the 3rd drop down.\n\nThis is the ajax.php which i am not too sure if it is right. \n\n<?php\ninclude('../config.php');\nif($_POST['']) //what should i put in here?\n{\n$id=$_POST['']; //what should i put in here?\n$sql=mysql_query //this is where i do not know what to put;\n\nwhile($row=mysql_fetch_array($sql))\n{\n//And what should i be placing here\n\n}\n}\n\n?>\n\n\nThis is what the web front end form looks like after implementing the code provided by dianuj. I still can not select the 2nd and 3rd drop down boxes:" ]
[ "php", "javascript", "ajax" ]
[ "NoMethodError: undefined method ascii_only? - Error with mail 2.5.4 and rails 4.0", "Please find below error message occured when I tried to deliver mails with mail 2.5.4 / rails 4.0.0 / ruby 1.9.3-p125 configuration. \n\nSubscriptionMailer.send_email(Subscription.last).deliver\n Subscription Load (0.6ms) SELECT `subscriptions`.* FROM `subscriptions` ORDER BY `subscriptions`.`id` DESC LIMIT 1\n User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1\n Rendered subscription_mailer/send_email.text.erb (0.6ms)\n Rendered subscription_mailer/send_email.html.haml (5.7ms)\nNoMethodError: undefined method `ascii_only?' for nil:NilClass\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/encodings.rb:68:in `param_encode'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:95:in `block in stringify'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:95:in `each'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:95:in `map'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:95:in `stringify'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:88:in `value'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:28:in `parse'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:24:in `initialize'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/field.rb:203:in `new'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/field.rb:203:in `new_field'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/field.rb:192:in `create_field'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/field.rb:149:in `update'\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/header.rb:170:in `[]='\n from /opt/blog/vendor/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:588:in `content_type='\n from /opt/blog/vendor/ruby/1.9.1/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:695:in `mail'\n from /opt/blog/app/mailers/subscription_mailer.rb:19:in `send_email'\n... 8 levels...\n from /opt/blog/vendor/ruby/1.9.1/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:497:in `initialize'\n from /opt/blog/vendor/ruby/1.9.1/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:480:in `new'\n from /opt/blog/vendor/ruby/1.9.1/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:480:in `method_missing'\n from (irb):4\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/app_rails_loader.rb:43:in `require'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/app_rails_loader.rb:43:in `block in exec_app_rails'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/app_rails_loader.rb:32:in `loop'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/app_rails_loader.rb:32:in `exec_app_rails'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/lib/rails/cli.rb:6:in `<top (required)>'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/bin/rails:9:in `require'\n from /opt/blog/vendor/ruby/1.9.1/gems/railties-4.0.0/bin/rails:9:in `<top (required)>'\n from bin/rails:16:in `load'\n from bin/rails:16:in `<main>'1.9.1 :005 >" ]
[ "ruby", "ruby-on-rails-4", "rubygems" ]
[ "How to extract content in between tags in Python?", "I have a text file of ~500k lines with fairly random HTML syntax. The rough structure of the file is as follows: \n\ncontent <title> title1 </title> more words \n\ntitle contents2 title more words <body> <title> title2 </title> \n\n<body><title>title3</title></body>\n\n\nI want to extract all contents in between the tags. \n\ntitle1\ntitle2 \ntitle3\n\n\nThis is what I have tried so far: \n\n content_list = []\n\nwith open('C://Users//HOME//Desktop//Document_S//corpus_test//00.txt', errors = 'ignore') as openfile2:\n for line in openfile2:\n for item in line.split(\"<title>\"):\n if \"</title>\" in item:\n content = (item [ item.find(\"<title>\")+len(\"<title>\") : ])\n content_list.append(content)\n\n\nBut this method is not retrieving all tags. I think this could be due to the tags that are connected to other words, without spaces. Ie. <body><title>. \n\nI've considered replacing every '<' and '>' with a space and performing the same method, but if I was to do this, I would get \"contents2\" as an output." ]
[ "python", "parsing" ]
[ "Python 3: User input random numbers to see if multiples of 5. Then get the sum of all the numbers that were multiples of 5", "I spent all day on this code. It failed. \n\ndef output (n):\n n = int(input('Enter a number: ')\n\nwhile n != 0:\n if n % 5 == 0:\n print(n, 'Yes')\n n = int(input('Enter a number: ')\n if n == 0\n output = range(1, int(input('Enter a number: '))+1)\n print (output)\noutput (n)\n\n\nQuestion is:\n\n\nlet user enter integers to determine if multiple of 5.\nIf it is then keep count that will keep a sum of all numbers that are multiples of 5.\nTask done using a loop in a function and the loop will terminate when a value of 0 is entered.\nwhen the loop terminates, return the count of how many numbers that were multiple of 5s.\n\n\nAfter complete, NEXT:\npass the variable sum_multiple_five to another function called print_result() and still\nprint the same message but now the print will be done in its own function." ]
[ "python" ]
[ "how to make a Command Line Interface from a given data model used for GUI", "HI, guys. I am developing a GUI to configure and call several external programs with Python and I use wxPython for the GUI toolkits. Basically, instead of typing commands and parameters in each shell for each application (one application via one shell), the GUI is visualizing these parameters and call them as subprocesses. I have built the data model and the relevant view/gui controls (mainly by using the observer pattern or try to separate model with the gui widgets), and it is OK. \n\nNow there is a request from my colleagues and many other people (even including myself), is it possible to have a command line interface for the subprocesses, or even for the whole configuration GUI, based on the data model I already have? This is due to the fact that many people prefer CLI, CLI is better in reliability, and also needs of programmer debugging and interfacing. \n\nAs I am rather new to developing a CLI, I really need some help from you. I appreciate any advice and information from you. \n\nto be more specific, \n\n\nIf I completely forget about the data model built for GUI, start from scratch. Is there some good materials or samples to have a reference?\nIf I still want to utilize the data model built for GUI, is it possible? If possible, what shall I do and any samples to follow? Do I need to refactor the data model?\nIs it possible to have the CLI and GUI at the same time? I mean, can I take the CLI as another view of the data model? Or there is other right approach? \n\n\nThank you very much for your help!!" ]
[ "python", "user-interface", "wxpython", "wxwidgets", "command-line-interface" ]
[ "Combinations with max repetitions per element", "I want to get a list of k-sized tuples with the combinations of a list of elements (let's call it elements) similar to what itertools.combinations_with_replacement(elements, k) would do. The difference is that I want to add a maximum to the number of replacements per element. \n\nSo for example if I run the following:\n\nelements = ['a', 'b']\nprint(list(itertools.combinations_with_replacement(elements, 3)))\n\n\nI get:\n\n[('a', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'b'), ('b', 'b', 'b')]\n\n\nI would like to have something like the following:\n\nelements = {'a': 2, 'b': 3}\nprint(list(combinations_with_max_replacement(elements, 3)))\n\n\nWhich would print\n\n[('a', 'a', 'b'), ('a', 'b', 'b'), ('b', 'b', 'b')]\n\n\nNotice that the max number of 'a' in each tuple is 2 so ('a', 'a', 'a') is not part of the result. \n\nI'd prefer to avoid looping through the results of itertools.combinations_with_replacement(elements, k) counting the elements in each tuple and filtering them out.\n\nLet me know if I can give any further info.\n\nThanks for the help!\n\nUPDATE\n\nI tried:\n\nelements = ['a'] * 2 + ['b'] * 3\nprint(set(itertools.combinations(elements, 3)))\n\n\nand get:\n\n{('a', 'b', 'b'), ('b', 'b', 'b'), ('a', 'a', 'b')}\n\n\nI get the elements I need but I lose the order and seems kind of hacky" ]
[ "python", "itertools" ]
[ "Left padding when set new data on BarChart View from MPAndroidChart library", "I’m using the MPAndroidChart for my project and I have the problem with that.\n\n\n\n\n\n\n\nIt’s look like, every time, when I set new data on BarChart View, even if i use clear() method, some of the reason, created left padding. plz, how can i fixed that?" ]
[ "android", "charts", "view", "padding", "mpandroidchart" ]
[ "Transparency with hole", "I have a simple JQuery carousel with an overlay (to \"blur\" out the inactive slides).\n\nI hope this image makes it clear:\n\n\nI use this HTML as overlay:\n\n<div class=\"l-overlay-wrapper clearfix\">\n <div class=\"l-overlay\">\n <div class=\"l-overlay-filter\"> </div>\n </div>\n</div>\n\n\nAnd I use this SASS to generate my overlay:\n\n.l-overlay-wrapper {\n background-color: $white;\n opacity: 0.5;\n position: absolute;\n width: 100%;\n z-index: 5;\n .l-overlay {\n @include rgba-background(rgba(0, 0, 0, 0.97));\n height: 500px;\n .l-overlay-filter {\n background-color: $white;\n height: 500px;\n margin: auto;\n opacity: 0.5;\n width: 640px;\n }\n }\n}\n\n\nWhere the .l-overlay-filter is the \"lighter\" filter and the .l-overlay is the background overlay.\n\nBut that's not what I want. I want the .l-overlay-filter to be 100% transparant. In other words, I want the original image to be shown, with no overlay. \n\nIs it possible to make this \"hole\" in a transparancy div?\nIt should be compatible up to IE8." ]
[ "css", "sass", "transparency" ]
[ "Node.js does not include exported PATH from .bashrc", "In my .bashrc I have conda exported:\n\nexport PATH=\"$HOME/miniconda3/bin:$PATH\"\n\n\nconda is working in a normal shell. But it is not working with exec() or spawn(). When printing the $PATH from node.js, the conda path is not included. In that case, I need to use the full path.\n\nThis is how I call the conda command and the script\n\n// fails with conda ENOENT \nconst p1 = spawn('conda');\n// calling a bash script which uses conda command fails with\n// stderr output of 'conda command not found'\nconst p2 = spawn('bash', ['setup.sh']);\n\n\nHow can I make node.js look at the .bashrc file for exported path, so I don't have to use the full path to the conda command?" ]
[ "node.js", "bash", "path" ]
[ "Weird binary signs when using pipe", "I am using this script to compile my program and to debug it on my embedded board: \n\n#!/bin/bash\n\n# Recompile:\nmake clean\nmake\n\n# Erase memmory and upload the program:\n{ echo 'connect';\n echo '';\n echo '';\n echo '';\n echo '';\n echo 'erase';\n echo 'loadbin program.bin , 0x0';\n echo 'r';\n echo 'q'; } | JLinkExe\n\n# Kill any JLinkExeGDBServer:\nkillall JLinkGDBServer\n\n# Set up the GDB server and connect with GDB:\nJLinkGDBServer -device LPC4088 & sleep 2s && \\\n{ echo 'dashboard -layout source';\n echo 'dashboard source -style context 14';\n echo 'file program.elf';\n echo 'target remote :2331';\n echo 'monitor reset';\n cat; } | arm-none-eabi-gdb\n\n\nAfter I run this script all of the commands are executed just fine, but there are some kind of binary signs in GDB (screenshot) and it looks like autocomplete in GDB isn't working at all. Furthermore, some of the GDB commands are totaly broken. If I use only arm-none-eabi-gdb without supplying it the commands through a pipe | GDB again works fine. \n\nBut I need to pass those commands...\n\nI am using ~/.gdbinit from GDB Dashboard but even if I remove it problem persists." ]
[ "shell", "gdb", "gdbserver" ]
[ "When step am I missing from moving a premade code from Codepen into my Brackets project?", "Here is the codepen I'm trying to get working: http://codepen.io/Bounasser-Abdelwahab/pen/ruiky\n\nHere is the head of my index.html file in my Brackets project:\n\n<head>\n <link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css\">\n <link type=\"text/css\" rel=\"stylesheet\" href=\"css/style.css\" />\n\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script>\n</head>\n\n\nWhen I try to run this, it runs about 90% correctly, but it's not a complete match. The menu is misaligned, and I can see bullet points that weren't there before, and the padding is all wrong. \n\nHow can I get a complete replication of the codepen code into my own project?\n\nEdit: here is an image of how mine is coming out: http://i.imgur.com/F3o0yQF.png\n\nEdit 2: \n\nHere is my slightly modified HTML. Problem is persisting. \n\n<!DOCTYPE html>\n<!--\n\n-->\n<html lang=\"en\">\n <head>\n <link type=\"text/css\" rel=\"stylesheet\" href=\"css/style.css\" />\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script>\n <script src=\"js/init.js\"></script>\n </head>\n\n\n\n <body>\n\n<ul class=\"navbar cf\">\n <li><a href=\"#\">item 2</a></li>\n <li><a href=\"#\">item 3</a>\n <ul>\n <li><a href=\"#\">sub item 1</a></li>\n <li><a href=\"#\">sub item 2</a></li>\n <li><a href=\"#\">sub item 3</a>\n <ul>\n <li><a href=\"#\">google</a></li>\n <li><a href=\"\">yahoo!</a></li>\n <li><a href=\"\">jQuery</a>\n <ul>\n <li><a href=\"#\">sub sub item 1</a></li>\n <li><a href=\"#\">sub sub item 2</a>\n <ul>\n <li><a href=\"#\">sub sub sub item 1</a></li>\n <li><a href=\"#\">sub sub sub item 2</a></li>\n <li><a href=\"#\">sub sub sub item 3</a>\n <ul>\n <li><a href=\"#\">sub item 1</a></li>\n <li><a href=\"#\">sub item 2</a></li>\n <li><a href=\"#\">sub item 3</a></li>\n </ul>\n </li>\n </ul>\n </li>\n <li><a href=\"#\">sub sub item 3</a></li>\n <li><a href=\"#\">sub sub item 4</a></li>\n <li><a href=\"#\">sub sub item 5</a>\n\n </li>\n </ul>\n </li>\n </ul>\n </li>\n <li><a href=\"#\">item a little longer</a></li>\n </ul>\n </li>\n <li><a href=\"#\">item 4</a></li>\n <li><a href=\"#\">item 5</a></li>\n </ul>\n\n\n\n\n\n </body>\n</html>" ]
[ "javascript", "jquery", "html", "css" ]
[ "Stored Procedure accept optional value SQL", "I have the following code - \n\nI am trying to create a procedure which takes in the products and an OPTIONAL start data and OPTIONAL end date. At the moment these dates cannot be left out\n\nIF OBJECT_ID(N'dbo.usp_Order') IS NOT NULL\n DROP PROCEDURE dbo.usp_Order\n GO\n CREATE PROCEDURE dbo.usp_Order\n AS\n SELECT\n o.OrderId\n o.product\n d.date\n\n FROM Order o\n\n INNER JOIN Dates d \n\n ON o.orderid=d.dateid \n\n WHERE \"DATE\" BETWEEN '09/16/2008' and '09/21/2016' \n\n GO\n\n execute usp_Order\n\n\nI have tried specifying @\"date\" date = null, and @\"date\" IS NULL in the where clause but doesnt work.\n\nAny ideas? Thank you" ]
[ "sql", "sql-server", "sql-server-2008" ]
[ "How do I figure out the percentage of elements in my array whose value is between 1 and 100?", "I'm using Ruby 2.4. I have a data array that has a bunch of strings ...\n\n[\"a\", \"1\", \"123\", \"a2c\", ...]\n\n\nI can check the percentage of elements in my array that are exclusively numbers using\n\ndata_col.grep(/^\\d+$/).size / data_col.size.to_f\n\n\nbut how do I check the percentage of elements taht are numbers and whose value falls between 1 and 100?" ]
[ "ruby-on-rails", "arrays", "ruby" ]
[ "How do I use a DisplayTemplate instead of a PartialView?", "I have created a SumFor extension method on HtmlHelper. The purpose is to take a property from a model and calculate the sum of all values and return it. This works, but the value is returned as a plain string. Eg:\n\n130.50\n\nI often use custom attributes on my properties such as\n\n<Percentage>\nPublic Property Amount As Decimal\n\n\nAnd\n\n<Currency>\nPublic Property Amount As Decimal\n\n\nWhich use DisplayTemplates Percentage.vbhtml and Currency.vbhtml in ~/Views/Shared/DisplayTemplates.\n\nThese render strings like:\n\n80%\n\n$130.50\n\n(Although a little more complex)\n\nThis is my currency approach:\n\n<Extension>\nPublic Function SumFor(Of TModel As IEnumerable(Of Object),\n TProperty As ModelMetadata) _\n (helper As HtmlHelper(Of TModel),\n expression As Expression(Of Func(Of TModel, TProperty))) _\n As IHtmlString\n Dim data As ModelMetadata\n Dim viewName As String = String.Empty\n Dim sum As String\n\n data = expression.Compile.Invoke(Nothing)\n sum = data.GetSum(helper.ViewData.Model)\n\n If data.DataTypeName IsNot Nothing Then viewName = data.DataTypeName\n If data.TemplateHint IsNot Nothing Then viewName = data.TemplateHint\n\n Return helper.Partial(viewName, sum)\nEnd Function\n\n\nAs you can see I'm trying to use the helper's Partial method to ensure that the correct display template is used. But I get an error saying that the view cannot be found. I want to have my sum value used like a normal DisplayFor so that a display template is chosen, but I don't know how to use the HtmlHelper with my sum string.\n\nI feel like I'm going about this the wrong way. What's the best solution here?" ]
[ "asp.net-mvc", "asp.net-mvc-4", "partial-views", "html-helper", "display-templates" ]
[ "Does pcap_t *pcap_open_offline(const char *fname, char *errbuf) from libpcap read the whole pcap file into memory?", "Does \n\npcap_t *pcap_open_offline(const char *fname, char *errbuf) \n\n\nfrom libpcap read the whole pcap file into memory? If not so, I have to use tcpslice or similar tools to split pcap file up?\n\nThanks." ]
[ "pcap", "libpcap" ]
[ "SolrIndexerJob: runtime error", "I'm trying to build a web crawler using Nutch 2.3 + Mongodb+ elasticsearch 1.7. I've configured mongodb store in nutch and it works perfectly. However when I run\n\n./bin/nutch index -all\n\n\nI get \n\n IndexingJob: starting\n SolrIndexerJob: java.lang.RuntimeException: job failed: name=apache-nutch-2.3.1.jar, jobid=job_local2085212843_0001\nat org.apache.nutch.util.NutchJob.waitForCompletion(NutchJob.java:119)\nat org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:154)\nat org.apache.nutch.indexer.IndexingJob.index(IndexingJob.java:176)\nat org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:202)\nat org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)\nat org.apache.nutch.indexer.IndexingJob.main(IndexingJob.java:211)\n\n\nBut I'm not even using Solr. My nutch-site.xml is configured for elastic search. \nnutch-site.xml\n\n<?xml version=\"1.0\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>\n<!-- Put site-specific property overrides in this file. -->\n\n<configuration>\n<property>\n <name>http.agent.name</name> \n <value>Nofrets Cwawler</value>\n</property>\n<property>\n <name>plugin.includes</name>\n <value>protocol-http|urlfilter-regex|parse-(html|tika)|index- (basic|anchor)|urlnormalizer-(pass|regex|basic)|scoring-opic|indexer-elastic</value>\n</property>\n<property>\n <name>storage.data.store.class</name>\n <value>org.apache.gora.mongodb.store.MongoStore</value>\n</property>\n\n<!--elastic search properties -->\n<property>\n<name>elastic.host</name>\n<value>localhost</value>\n<description>The hostname to send documents to using TransportClient.\nEither host and port must be defined or cluster.\n</description>\n</property>\n<property>\n<name>elastic.port</name>\n<value>9200</value>\n<description>\nThe port to connect to using TransportClient.\n</description>\n</property>\n\n<property>\n<name>elastic.cluster</name>\n<value>elasticsearch</value>\n<description>The cluster name to discover. Either host and potr must\n be defined or cluster.\n</description>\n</property>\n<property>\n<name>elastic.index</name>\n<value>nutch</value>\n<description>\nThe name of the elasticsearch index. Will normally be autocreated if it\ndoesn't exist.\n</description>\n</property>\n\n<property>\n<name>elastic.max.bulk.docs</name>\n<value>10</value>\n<description>\n The number of docs in the batch that will trigger a flush to\n elasticsearch.\n </description>\n</property>\n<property>\n<name>elastic.max.bulk.size</name>\n<value>2500</value>\n<description>\nThe total length of all indexed text in a batch that will trigger a\nflush to elasticsearch, by checking after every document for excess \nof this amount.\n</description>\n</property>\n\n\n\n\nAny help will be appreciated. Thanks." ]
[ "java", "mongodb", "elasticsearch", "solr", "nutch" ]
[ "Making Django Readonly ForeignKey Field in Admin Render as a Link", "I have a model exposed in Django's admin, which uses ModelAdmin's readonly_fields list to show a \"user\" field, which is a ForiegnKey linking to Django's User model. By default, readonly_fields causes this field to be rendered as simple text containing the user's email (e.g. [email protected]). How would I change this to render as a link to the associated admin page for that user? (e.g. <a href=\"/admin/auth/user/123/\">[email protected]</a>)" ]
[ "python", "django", "django-admin" ]
[ "setInterval breaks it's rhythm", "In cases when functions takes longer than delay mentioned in setInterval (like ajax call, which might it prevent from completing on time), I found that either functions have no breathing room or setInterval breaks it's rhythm.\n\nvar fakeCallToServer = function() {\n setTimeout(function() {\n console.log('returning from server', new \nDate().toLocaleTimeString());\n }, 4000);\n }\n\n\n\n setInterval(function(){ \n\n let insideSetInterval = new Date().toLocaleTimeString();\n\n console.log('insideSetInterval', insideSetInterval);\n\n fakeCallToServer();\n }, 2000);\n\n\nOutput: \n//insideSetInterval 14:13:47<br>\n//insideSetInterval 14:13:49<br>\n//insideSetInterval 14:13:51<br>\n//returning from server 14:13:51<br>\n//insideSetInterval 14:13:53<br>\n//returning from server 14:13:53 <br>\n//insideSetInterval 14:13:55<br>\n//returning from server 14:13:55<br>\n\n\nHow to fix it. Please provide some example." ]
[ "javascript", "html", "performance", "setinterval" ]
[ "Rails query for a social network feed", "The architecture of the model is simple. \n\nclass User < ActiveRecord::Base\n has_many :hunts, dependent: :destroy\n has_many :user_hunts, dependent: :destroy\nend\n\nclass Hunt < ApplicationRecord\n belongs_to :user\n has_many :user_hunts, dependent: :destroy\nend\n\nclass UserHunt < ApplicationRecord\n belongs_to :user\n belongs_to :hunt\nend \n\n\nUser can create hunts . Other Users can see these hunts in their feed. They can either accept it or reject it. This would create a row in UserHunt with hunt_id and user_id. So what I want is a result of Hunt which satisfy these onditions.\n\n\nHunt is not his own (hunt.user_id != id)\nUser has not seen the hunt before ( This is the part which I am finding difficult to implement)\n\n\nAfter lot of trials this is what I came up with.\n\nHunt.left_outer_joins(:user_hunts)\n .where('user_hunts.user_id != ? OR user_hunts.user_id is null AND hunts.user_id != ?',id,id)\n\n\nBut this has a problem of selecting hunts which other users have subscribed. \n\nThis is a common scenario in websites I believe. But I was not able to find any solution here. Thanks in advance." ]
[ "sql", "ruby-on-rails", "activerecord" ]
[ "Need to mask mobile number using regex", "I have used the following expression.\n\n.replaceAll(\"\\\\d(?=\\\\d{4})\", \"X\")\n\n\nIn android studio for the following.\n\nInput:- 1234567809\nExpected Output:- 12XXXXX809\n\n\nThe output which, I am getting after using the above expression:- XXXXXX7809\n\nKindly help to get expected output." ]
[ "java", "android", "regex" ]
[ "Multiple definition of error - CodeBlocks", "I have the the following files in my project:\n\ntable.h - signatures of methods used in link.c and hash.c\nlink.c - implements ALL methods in table.h\nhash.c - implements ALL methods in table.h\ntest.c - unit tests for link.c and hash.c\n\n\nI've used guards in my header file. Both link.c and hash.c have different implementations of the same set of methods.\n\nWhen I build and run my project, I get errors thrown for each method which says: \"multiple definition of \"\n\nI've tried declaring the methods extern, it does not solve the issue. \n\ntable.h\n\n#ifndef TABLE_H_INCLUDED\n#define TABLE_H_INCLUDED\n\ntypedef struct Table *Table_t;\n\nTable_t Table_new(void);\n\nvoid Table_free(Table_t oTable);\n\nint Table_getLength(Table_t oTable);\n\nint SymTable_put(SymTable_t oSymTable,\n const char *pcKey,\n const void *pvValue);\n\nvoid *Table_get(Table_t oTable,\n const char *key);\n\nint Table_contains(Table_t oTable,\n const char *key);\n\n\nvoid *Table_remove(Table_t oTable,\n const char *key);\n\n\nvoid *Table_replace(Table_t oTable,\n const char *key,\n const void *value);\n#undef TABLE_H_INCLUDED\n#endif\n\n\nError log:\n\nobj\\Debug\\table_link.o||In function `Table_new':|\n\nE:\\symbolTableProject\\table_link.c|33|multiple definition of `Table_new'|\n\nobj\\Debug\\table_hash.o:E:\\symbolTableProject\\table_hash.c|36|first defined here|\n\nHow do I resolve this?" ]
[ "c", "codeblocks" ]
[ "Leaflet Contextmenu - How to pass a marker reference when executing a callback function (non-geoJSON marker)", "I am having troubles with executing callback functions on markers (in my case they are circle and semiCircle markers). The marker context menu extends map's context menu with additional marker-specific operations. Map context menu callbacks are working properly. Marker additional menu options are shown, but I cannot execute the corresponding functions (for example getting Lat and Lon of a marker). The error in both variants that I tried (see below) is \"Uncaught TypeError: Cannot read property 'getLatLng' of undefined\".\n\nBelow is shown the code that I am using.\n\nMarkers are created from external JS file and stored in a layerGroup.\n\nVariant 1 - Using event \"contextmenu.show\" as suggested in contextMenu documentation.\n\nCreating layerGroups with Circle markers:\n\nfor(i in sites) {\nvar title = sites[i].ID, \n loc = sites[i].loc, \n object = sites[i].Type,\n marker = new L.circle(new L.latLng(loc), {radius: radsiteinit+50,color: 'gold', weight: 3, title: title, pane: \"sitePane\",\n contextmenu: true,contextmenuItems: [{text: 'Show Charts',index:0}, {separator: true, index: 1}]} ).\n bindPopup(object+': '+ title ).on('click', onClick);\n\n layerSites.addLayer(marker);\n}\n\n\n\"contextmenu.show\" event:\n\n mymap.on('contextmenu.show', function (event) {\n\n var latlngs = event.relatedTarget.getLatLng();\n\n});\n\n\nAs mentioned above produced error is \"Uncaught TypeError: Cannot read property 'getLatLng' of undefined\". Also event is fired before user gets the chance to select and option from context menu. What I need is to fire the event after user selects some marker-specific options from context menu.\n\nVariant 2 - With definition of callback function.\n\nCreating layerGroups with Circle markers - the difference here from above is that I added callback function is context menu definition:\n\nfor(i in sites) {\nvar title = sites[i].ID, \n loc = sites[i].loc, \n object = sites[i].Type,\n marker = new L.circle(new L.latLng(loc), {radius: radsiteinit+50,color: 'gold', weight: 3, title: title, pane: \"sitePane\",\n contextmenu: true,contextmenuItems: [{text: 'Show Charts',callback:showCharts,index:0}, {separator: true, index: 1}]} ).\n bindPopup(object+': '+ title ).on('click', onClick);\n\n layerSites.addLayer(marker);\n}\n\n\nCallback function definition:\n\nfunction showCharts(e) {\n\n var latlngs = e.relatedTarget.getLatLng();\n\n};\n\n\nThe same error here.\n\nI am very new to JavaScript, so I guess I do something wrong when I am trying to pass marker's reference to the function (var. 2) or event (var. 1).\n\nBecause I am stuck a lot, I would appreciate getting some advice.\n\nThank you in advance!\n\nEDIT\nIn the link you can find a JS Bin example of variant 2:\nJS Bin Example" ]
[ "javascript", "leaflet", "contextmenu" ]
[ "Laravel Search not working with error massage", "What i need is use this search which has a selectable dropdown.see the following screenshot.\n\n\nThese selected data are comes under trainee_division which is in registerdetails data table.here is the controller function i`m developing.\n\n$query = $request->search;\n $queryType = $request->institute;\n $items = DB::table('registerdetails');\n\n\n if($queryType == 'Operation' || $queryType == 'operation' ){\n $items = $items->where('Operation', '=',\"%$queryType%\");\n }\n\n $items = $items->get();\n return view('registeredusers.admindivisiondetails')->with('items',$items);\n\n\nRelevant view is like this\n\n<form action=\"divisiondetailsSearch\" method=\"post\" class=\"form-inline\"> \n <select name=\"institute\" id=\"institute\">\n <option selected=\"selected\" value=\"Operation\">Operation</option>\n <option value=\"NPA\">NPA</option>\n <option value=\"BTS-Kurunegala\">BTS-Kurunegala</option>\n <option value=\"INOC\">INOC</option>\n <option value=\"RNO\">RNO</option>\n <option value=\"Implementation\">Implementation</option>\n <option value=\"RAN\">RAN</option>\n <option value=\"CEE\">CEE</option>\n <option value=\"BTS-Jaffna\">BTS-Jaffna</option>\n <option value=\"BTS-Colombo\">BTS-Colombo</option>\n <option value=\"Transmission\">Transmission</option>\n <option value=\"BTS-Rathnapura\">BTS-Rathnapura</option>\n <option value=\"IBS\">IBS</option>\n <option value=\"NS\">NS</option>\n <option value=\"PCN\">PCN</option>\n <option value=\"SQ\">SQ</option>\n <option value=\"Pro-Transmission\">Pro-Transmission</option>\n <option value=\"BTS-Kandy\">BTS-Kandy</option>\n </select>\n\n <input type=\"hidden\" value=\"{{ csrf_token() }}\" name=\"_token\" />\n <input type=\"submit\" name=\"submit\" value=\"Search\">\n </form>\n\n\ni`m getting this error.\n\n\n\ncan anyone help me to get solved this one please." ]
[ "php", "laravel", "search", "laravel-5" ]
[ "How to change paperclip attachment path?", "So, i've got a file which is processed after upload in a certain way. After that processing it should be moved to another folder. I did it with help of FileUtils.mv (since i didn't find any appropriate methods in paperclip documentation), but the thing is, .path of attachment left the same, so i'm getting an error when i'm trying to reach the file. I also tried to change path like in this guide https://github.com/thoughtbot/paperclip/wiki/Changing-attachment-:path but it didn't work and i've got some errors instead:\n[paperclip] Trying to link /app/public/uploads/boxroom/development/90/original/90 to /tmp/8613985ec49eb8f757ae6439e879bb2a20201124-1-99na5g\n[paperclip] Link failed with Invalid cross-device link @ rb_file_s_link - (/app/public/uploads/boxroom/development/90/original/90, /tmp/8613985ec49eb8f757ae6439e879bb2a20201124-1-99na5g); copying link /app/public/uploads/boxroom/development/90/original/90 to /tmp/8613985ec49eb8f757ae6439e879bb2a20201124-1-99na5g\nCommand :: file -b --mime '/app/public/uploads/boxroom/development/90/original/90'\n[paperclip] Trying to link /tmp/8613985ec49eb8f757ae6439e879bb2a20201124-1-99na5g to /tmp/8613985ec49eb8f757ae6439e879bb2a20201124-1-1bzxm31\n\nconsidering that source path is "/app/public/tmp_uploads/boxroom/development/90/original/90" and destination path - "/app/public/uploads/boxroom/development/90/original/90", can someone tell me how to change .path of the attachment? Or probably another way to move it to another folder?" ]
[ "ruby-on-rails", "paperclip" ]
[ "Weird if/else behavior Android", "I'm trying to cacth done action which comes from softkeyboard. My code is like this;\n\n private TextView.OnEditorActionListener getDoneListener() {\n return new TextView.OnEditorActionListener() {\n @Override\n public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {\n if (actionId == EditorInfo.IME_ACTION_DONE) {\n nextPage();\n return true;\n }\n else {\n return false;\n }\n }\n };\n}\n\n\nHowever even though IDE evaluates \"(actionId == EditorInfo.IME_ACTION_DONE)\"as true, it's not calling nextPage(), returning false instead. If I cast expression like this, it works fine.\n\n private TextView.OnEditorActionListener getDoneListener() {\n return new TextView.OnEditorActionListener() {\n @Override\n public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {\n if ((boolean)(actionId == EditorInfo.IME_ACTION_DONE)) {\n processPayment();\n return true;\n }\n else {\n return false;\n }\n }\n };\n}\n\n\nAny idea what can cause this?" ]
[ "java", "android", "if-statement" ]
[ "MediaList play items with run time option", "I use the MediaList to play some movies and streams in a list.\n\nString[] paths = { \"\\tmp\\movie1.mp4\", \"\\tmp\\movie2.mp4\", \"http://stream.mp4\" };\nString[] options = { \"--run-time=2\", \"--run-time=5\", \"--run-time=10\" };\n\n\nThe initialization of the media list is as follows\n\nmediaListPlayer = factory.newMediaListPlayer(); \nmediaListPlayer.setMediaPlayer(mediaPlayer);\n\nMediaList mediaList = factory.newMediaList(); \nfor ( int i = 0; i < paths.length; i++ ) \n{\n if ( options[i].length() > 0 )\n {\n mediaList.addMedia(paths[i], options[i]);\n }\n else\n {\n mediaList.addMedia(paths[i]); \n }\n}\nmediaListPlayer.setMediaList(mediaList);\nmediaListPlayer.setMode(MediaListPlayerMode.LOOP);\nmediaListPlayer.play();\n\n\nThe media list player ignores the optons. What is wrong with the code? Any help is welcome, thanks" ]
[ "vlcj" ]
[ "How to link that \"logged in\" in \"you must be logged in to post a comment\" with custom login page on WordPress?", "How to link that \"logged in\" in \"you must be logged in to post a comment\" for a post on WordPress to custom login page. So that when the user clicks on that \"logged in\" gets redirected to the custom login page not to the wp-login.php. Please help." ]
[ "php", "redirect", "wordpress" ]
[ "Debuggin app published to IIS", "I have a problem with debugging app published to IIS.\n\nI'm publishing to IIS by filesystem. The process is following:\n\n\npublishing to filesystem\nlogging in to IIS machine\ncopy&paste published app to IIS folder\n\n\nWhen I publish using default settings it all works fine except I can't debug my app (I can attach to IIS process, but there is no debug data in my published app).\n\nI found out that there is option to precompile app before publishing and this option has option to emit debug data. I looked just what I needed, but it doesn't work. For example I can't log in to my app after publishing it that way.\n\nAm I missing something?" ]
[ "asp.net", "visual-studio", "debugging", "iis", "web-applications" ]
[ "C# find function problem (Can't highlight)", "I would like to ask why does my codes not work?\n\nCurrently, I am able to find the word the user input but it cannot highlight the word in the richTextBoxConversation.\n\nHow should I go about doing it?\n\nFollowing are my codes:\n\n private void buttonTextFilter_Click(object sender, EventArgs e)\n {\n string s1 = richTextBoxConversation.Text.ToLower();\n string s2 = textBoxTextFilter.Text.ToLower();\n\n if (s1.Contains(s2))\n {\n MessageBox.Show(\"Word found!\");\n richTextBoxConversation.Find(s2);\n }\n else\n {\n MessageBox.Show(\"Word not found!\");\n }\n }" ]
[ "c#", "winforms", "find", "richtextbox" ]
[ "Is there a way to ignore a node_module when running npm install", "Hi I have made some custom adjustments to a node_module's files to get it to meet client requirements. These changes obviously are not in the packages source code so I want to avoid overwritting them if I need to update npm packages. Is there a way to do this? Maybe something similar to a git ignore?" ]
[ "npm-install", "node-modules" ]
[ "Removing textbox using javascript dynamically", "I'm trying to add and remove textboxes dynamically. Adding of textbox is working fine, but removing the textbox is not working. I've defined the onclick method on button element itself. Am I missing anything? There should be a simple mistake. \n\nHere is my code \n\nvar container = document.getElementById('divArea');\nfunction RemoveTextBox(div) { \n document.getElementById(\"divArea\").removeChild(div.parentNode);\n}\n\nfunction addTextBox(value){ \n return '<input name=\"newTextBox\" type=\"text\" value = \"' + value + '\" />' +\n '<input type=\"button\" value=\"Remove\" class=\"removeTxtBox\" onclick = \"RemoveTextBox(this)\" />'\n}\n\ndocument.getElementById('btnAdd').onclick = function() {\n var res = document.getElementById('val').value; \n var div = document.createElement('DIV');\n div.innerHTML = addTextBox(res);\n container.appendChild(div);\n}\n\n\nMy JS Fiddle https://jsfiddle.net/2ddaw4zf/1/" ]
[ "javascript" ]
[ "accessing a column of dataframe after concatenating two dataframes", "I have concatenated two dataframes with below code:\ndf_stacked =pd.concat([df, df_kw], keys=["title","title"],axis= 1,\n join = "inner").reset_index(drop=True)\n\nand it looks like this:\ndf_stacked.iloc[:4,15:18]\n\n\nHow can I take out that upper title value ?\nBasically I want to be able to access the budget column by writing:\nbudget = df_stacked.budget" ]
[ "python", "pandas", "dataframe", "concatenation", "multiple-columns" ]
[ "when i try to run my angular project i get these error", "Error: node_modules/@angular/material/radio/radio.d.ts:184:9 - error TS2611: 'disabled' is defined as a property in class 'CanDisableRipple & HasTabIndex & MatRadioButtonBase', but is overridden here in '_MatRadioButtonBase' as an accessor.\n184 get disabled(): boolean;\n~~~~~~~~\nError: node_modules/@angular/material/table/cell.d.ts:42:5 - error TS2610: 'name' is defined as an accessor in class 'CdkColumnDef', but is overridden here in 'MatColumnDef' as an instance property.\n42 name: string;\n~~~~\n** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **" ]
[ "angular", "angular-material" ]
[ "Register click and pass it to underlying layer", "We wanted to track the clicks to some Dailymotion videos which we have added to our site. Unfortunately the Dailymotion javascript API does not provide any event which is called when the user clicks on the video. I thought that maybe I could add a transparent div layer on top of the Dailymotion video layer so that when it was clicked I would register the click and then pass the click to the underlying layer. I know how to do the first part (register the click) but I don´t know how to do the second part (pass the click to the underlying layer). I use jQuery, in case it helps" ]
[ "javascript", "jquery", "dailymotion-api" ]
[ "MySQL Forward Engineer - SQL giving error 121", "I'm currently trying to create my database using the Forward Engineer wizard of MySQL Workbench but I get this error:\n\nExecuting SQL script in server\nERROR: Error 1005: Can't create table 'microweb.users' (errno: 121)\n\n\nCREATE TABLE IF NOT EXISTS `microweb`.`users` (\n `user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,\n `role_id` INT UNSIGNED NOT NULL ,\n `username` VARCHAR(45) NOT NULL ,\n `password` VARCHAR(45) NOT NULL ,\n `email` VARCHAR(45) NOT NULL ,\n `salt` VARCHAR(45) NOT NULL ,\n `first_name` VARCHAR(45) NOT NULL ,\n `middle_name` VARCHAR(45) NULL ,\n `last_name` VARCHAR(45) NOT NULL ,\n `address_id` INT UNSIGNED NULL ,\n `registration_id` INT UNSIGNED NOT NULL ,\n `active` TINYINT(1) NOT NULL ,\n `banned` TINYINT(1) NOT NULL ,\n PRIMARY KEY (`user_id`) ,\n UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) ,\n UNIQUE INDEX `username_UNIQUE` (`username` ASC) ,\n UNIQUE INDEX `email_UNIQUE` (`email` ASC) ,\n UNIQUE INDEX `registration_id_UNIQUE` (`registration_id` ASC) ,\n CONSTRAINT `fk_user_role`\n FOREIGN KEY (`role_id` )\n REFERENCES `microweb`.`roles` (`role_id` )\n ON DELETE CASCADE\n ON UPDATE CASCADE,\n CONSTRAINT `fk_user_registration`\n FOREIGN KEY (`registration_id` )\n REFERENCES `microweb`.`registrations` (`registration_id` )\n ON DELETE CASCADE\n ON UPDATE CASCADE)\nENGINE = InnoDB\n\nSQL script execution finished: statements: 10 succeeded, 1 failed\n\n\nThe complete scripts contains a lot of foreign keys and 21 tables. The problem is that there's only 2 in phpMyAdmin after the execution when Workbench says there's 10 successful.\n\nIf someone need the complete model, just tell me." ]
[ "mysql", "foreign-keys", "mysql-workbench" ]
[ "Getting the index of matched value", "I've created online cluster in mongodb atlas then created mongodb stitch app, in the stitch javascript editor, how can I get the index of x when match it ? example :\n\n{\n\"_id\": 5646546,\n\"items\":[ {\"x\": 12, \"y\": 4} , {\"x\": 12, \"y\": 4} ]\n\n}\n\n\nso when x= 12 the index should be 0" ]
[ "mongodb", "mongodb-stitch" ]
[ "Unable to create basic database or scale from web database in azure", "When attempting to either create a new basic database or upgrade from the web database to a basic database I get an error - \"The operation is not supported for your subscription offer type.\"\n\nI recently upgraded from the free trial to the pay-as-you-go option and the current database is in the North Europe location.\n\nI have checked the preview features section but the ability to enable the premium database options are not there and I believe these are no longer in preview mode anyway.\n\nAny assistance would be appreciated." ]
[ "database", "azure", "azure-sql-database" ]
[ "Prolog error arguments are not instantiated", "When running this code:\nsigncheck(Sign1,Sign2):-(Sign1==clubs,Sign2==hearts);(Sign1==clubs,Sign2==spades)\n ;(Sign1==clubs,Sign2==diamonds);(Sign1==hearts,Sign2==spades)\n ;(Sign1==hearts,Sign2==diamonds);(Sign1==spades,Sign2==diamonds).\n lowercard(card(Num1,Sign1),card(Num2,_),card(Num1,Sign1)):- Num1<Num2.\n lowercard(card(Num1,Sign1),card(Num2,Sign2),card(Num1,Sign1)):- Num1==Num2,signcheck(Sign1,Sign2).\n lowercard(card(Num1,Sign1),card(Num2,Sign2),card(Num2,Sign2)):- Num1==Num2,signcheck(Sign2,Sign1).\n lowercard(card(Num1,_),card(Num2,Sign2),card(Num2,Sign2)):- Num1>Num2.\n lowest([card(X,Y)],card(X,Y)).\n lowest([X|XS],Z):- lowercard(X,Y,Z), lowest(XS,Y).\n\nwhen running the query:\nlowest([card(5, hearts),card(4,diamonds)], X)\n\nI get this error message:\nArguments are not sufficiently instantiated\nIn:\n [3] 5<_1600\n [2] lowercard(card(5,hearts),card(_1668,_1670),card(5,hearts)) at line 4\n [1] lowest([card(5,hearts),...],card(5,hearts)) at line 8\n\nWhy is this occouring?" ]
[ "prolog", "swish" ]
[ "The compilation of an array of conditions with numba.jit takes a long time", "If I try to compile a function, containing an array of conditions, with numba's jit-compiler, it takes very long. The program looks essentially like\n\nfrom numba import jit\nimport numpy as np\n\n@jit(nopython=True)\ndef foo(a, b):\n valid = [\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0),\n (a - 1 >= 0) and (b - 1 >= 0)\n ]\n\nfoo(1, 1)\n\n\nwhere I have excluded everything that will not alter the compilation time significantly. The problem arises if I use more than 20 elements. \n\n| elements | time |\n-------------------\n| 21 | 2.7s |\n| 22 | 5.1s |\n| 23 | 10s |\n| ... | ... |\n-------------------\n\n\nDespite that, the function workes well. Does anybody know, why it takes so long, to compile such function with numba? Creating arrays in a similar way with combinations of integers or floats causes no problem." ]
[ "python", "time", "conditional-statements", "jit", "numba" ]
[ "AutoCompleteBox and SearchText Clear", "This is not a question but my answer to a problem I could not find a solution to on the internet.\n\nI had a problem clearing the SearchText in an MVVM Silverlight application. I could clear clear the SelectedItem and Text but the SearchText was left behind. It is read only and cannot be changed by binding.\n\nExample: AutoCompleteBox with a list of Countries. When the user wants to enter Australia they enter 'au' at this point the list appers with Austria and Australia. The user can then select Australia and move on. At the end of editing they click on a 'Save' button. At this point it is likely that you would want to clear the data forn for entering new data.\n\nEven if you have bindings to the SelectedItem and the Text properties and you set them to 'null' and string.Empty respectively the SearchText property remains and the AutoCompleteBox will not clear but will contain 'au'." ]
[ "silverlight-4.0", "autocompletebox" ]
[ "Azure Data Factory Splitting Multiple JSON Objects In A Single File", "I'm using Azure Data Factory to monitor an AWS S3 bucket that will have files containing JSON objects that are written out by an AWS process. The process may combine multiple JSON objects into a single file with no CRLF or delimiters between the objects. I need Azure Data Factory to process each of these object individually to insert them into a SQL database. I'm not finding any examples of how to process this scenario. Sorry if this is rather basic in Azure Data Factory, however, I'm rather new to the product.\nHere is a sample of the file format:\n{\n "AWSInfoField1": "Test Record 1", \n "AWSInfoField2": "Just Another Field",\n "Attributes": { \n "Attribute1": 1, \n "Attribute2": "Another Attribute" \n }\n}\n{\n "AWSInfoField1": "Test Record 2", \n "AWSInfoField2": "Just Another Field In Record 2", \n "Attributes": { \n "Attribute1": 2, \n "Attribute2": "Another Attribute In Record 2" \n }\n }\n {\n "AWSInfoField1": "Test Record 3", \n "AWSInfoField2": "Just Another Field In Record 3", \n "Attributes": { \n "Attribute1": 3, \n "Attribute2": "Another Attribute In Record 3" \n }\n }" ]
[ "azure-data-factory", "azure-data-factory-2" ]
[ "How can I integrate regex into my MapHttpRoute for WebApi", "I currently have:\n\nconfig.Routes.MapHttpRoute(\n name: \"AccountApiCtrl\",\n routeTemplate: \"/api\" + \"/account/{action}/{id}\",\n defaults: new { controller = \"accountapi\", id = RouteParameter.Optional }\n );\n\n\nWhich sends /api/account/myaction requests to accountapi controller. (it works great :-))\n\nHowever, I'd rather not do this for each controller I have, is there a way I can use regex here so that I only have on declaration?\n\nI.E so:\n\n/api/account/action goes to controller: AccountApi\nand\n/api/user/action goes to controller: UserApi\n\ni.e something along the lines of:\n\nconfig.Routes.MapHttpRoute(\n name: \"ControllerApiMap\",\n routeTemplate: \"/api\" + \"/{controller}/{action}/{id}\",\n defaults: new { controller = \"{controller}+api\", id = RouteParameter.Optional }\n );" ]
[ "asp.net-mvc", "asp.net-web-api", "routing" ]
[ "Collection not Created in Firebase Console", "I have implemented a code to create a collection named \"Users\". the code is running properly but is not saving my data in the database of my console.\n\nHere is my code\n\nuser_profile.putFile(imageUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {\n @Override\n public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> uploadtask) {\n String download_url = uploadtask.getResult().getDownloadUrl().toString();\n\n if (uploadtask.isSuccessful()){\n Map<String,Object> userMap = new HashMap<>();\n userMap.put(\"name\",user);\n userMap.put(\"image\",download_url);\n firebaseFirestore.collection(\"Users\")\n .document(user_id).set(userMap)\n .addOnSuccessListener(new OnSuccessListener<Void>() {\n @Override\n public void onSuccess(Void aVoid) {\n Toast.makeText(RegistrationActivity.this, \"Uploaded Successfully\", Toast.LENGTH_SHORT).show();\n SendToMain();\n progressBar.setVisibility(View.INVISIBLE);\n }\n });\n } else {\n Toast.makeText(RegistrationActivity.this, \"error: \"+uploadtask.getException().getMessage(), Toast.LENGTH_SHORT).show();\n\n }\n }\n});\n\n\nI don't know what's going wrong and what's causing the problem. please help me for this. I am new to firebase by the way." ]
[ "android", "firebase", "google-cloud-firestore" ]
[ "db.SaveChanges(); Not Committing changes in database", "So i am a student learning Web API. I have developed a basic Web Api and when i use post method it gives me 500 iternal server error. The get methods are working fine. During debugging its hitting db.SaveChanges(); but returns a 500 error while hitting HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user); I am using mysql database with mysql connector 6.7.4.\n\nSTACKOVERFLOW is not lettting me post image, so here is the pic of my debug screen : http://i44.tinypic.com/25tyy3m.png\n\nI am using fidler to send post request :\n\nResponse Header: HTTP/1.1 500 Internal Server Error\n\nRequest Header: User-Agent: Fiddler Host: localhost:45379 Content-Type: application/jsonContent-Length: 41 Content-Length: 41\n\nRequest Body: {\"iduser\":\"44444888\",\"username\":\"oooooo\"}\n\nIts my code for POST Method:\n\n // POST api/User\n public HttpResponseMessage Postuser(user user)\n {\n if (ModelState.IsValid)\n {\n db.users.Add(user);\n db.SaveChanges();\n\n HttpResponseMessage response =R equest.CreateResponse(HttpStatusCode.Created, user);\n response.Headers.Location = new Uri(Url.Link(\"DefaultApi\", new { id = user.iduser }));\n return response;\n }\n else\n {\n return Request.CreateResponse(HttpStatusCode.BadRequest);\n }\n}" ]
[ "mysql", "asp.net", "asp.net-mvc-4", "asp.net-web-api" ]
[ "Nested onHover selector not working with styled-components", "I'm trying to change the style of a styled-components element when another element is hovered over, however it doesn't seem to apply those changes.\nThe piece of relevant code is,\nconst Logo = styled.div`\n . . .\n &:hover {\n color: red;\n\n ${TextStyled} {\n display: flex;\n }\n }\n`;\n\nThe color of the Logo component successfully changes to red on hover, however the display property of the TextStyled component doesn't seem to be affected.\nWhat am I doing wrong here? I've tried adding a tilde before ${TextStyled}, but that selector didn't work either.\nI've also tried applying the style through the parent Main component, but that didn't work either:\nconst Main = styled.div`\n height: 100vh;\n width: 100vw;\n background: #000;\n\n ${Logo} {\n &:hover {\n color: red;\n\n ${TextStyled} {\n display: flex;\n }\n }\n }\n`;" ]
[ "css", "reactjs", "styled-components" ]
[ "Windows Phone 8 Hanging on GetFolderAsync and OpenStreamForReadAsync", "I am making a windows phone 8 application. Part of this application requires state to be saved. I am saving it as a string of Json. If I open the application, save some data, exit the application and the load it again, it hangs on either GetFolderAsync or OpenStreamForReadAsync. It does not happen every time, but once it starts hanging, I have to kill the whole emulator and make a new one to start the application again.\n\nI have even tried just making an empty file with no data in it and the problem still persistes.\n\nBelow is the code I am using to save and load the data. It does not matter where I call the data load whether it be on application start or on the form load it still breaks.\n\n private async Task SaveLists()\n {\n //XmlSerializer serializer = new XmlSerializer(typeof(ListHolder));\n\n // Get the local folder.\n StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;\n\n // Create a new folder name DataFolder.\n var dataFolder = await local.CreateFolderAsync(\"DataFolder\",\n CreationCollisionOption.OpenIfExists);\n\n // Create a new file named DataFile.txt.\n var file = await dataFolder.CreateFileAsync(\"Lists.json\",\n CreationCollisionOption.ReplaceExisting);\n\n string json = JsonConvert.SerializeObject(Lists, Formatting.Indented);\n byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(json.ToCharArray());\n\n using (var s = await file.OpenStreamForWriteAsync())\n {\n s.Write(fileBytes, 0, fileBytes.Length);\n\n }\n }\n\n\n\n private async Task LoadLists()\n {\n\n\n // Get the local folder.\n StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;\n\n if (local != null)\n {\n try\n {\n // Get the DataFolder folder.\n\n var dataFolder = await local.GetFolderAsync(\"DataFolder\");\n\n // Get the file.\n var files = dataFolder.GetFilesAsync();\n var file = await dataFolder.OpenStreamForReadAsync(\"Lists.json\");\n\n string jsonString = \"\";\n // Read the data.\n using (StreamReader streamReader = new StreamReader(file))\n {\n jsonString = streamReader.ReadToEnd();\n }\n if (jsonString.Length > 0)\n {\n Lists = JsonConvert.DeserializeObject<List<ItemList>>(jsonString);\n } \n else\n {\n Lists = new List<ItemList>();\n } \n }\n catch (Exception ex)\n {\n Lists = new List<ItemList>();\n }\n\n }\n }" ]
[ "asynchronous", "windows-phone-8", "io" ]
[ "Delete multidimensional array by a specific key", "I have this multi-dimensional array and I want to delete completely if the [earnings] index are empty.\n\nArray\n(\n [0] => Array\n (\n [earnings] => \n [other] => Array()\n [ord] => 2\n [days] => 1\n [total] => 1\n )\n\n [1] => Array\n (\n [earnings] => The campaign was effectively ended in November 1917.\n [other] => Array\n (\n [campaign] => 1\n [novemb] => 1\n [today] => 1\n )\n [ord] => 1\n [days] => 8\n [total] => 1\n )\n)\n\n\nI like to output something like this:\n\n[1] => Array\n(\n [earnings] => The campaign was effectively ended in November 1917.\n [other] => Array\n (\n [campaign] => 1\n [novemb] => 1\n [today] => 1\n )\n [ord] => 1\n [days] => 8\n [total] => 1\n)\n\n\nI tried this but not doesn't work quite well:\n\n foreach($array as $key=>$test){\n\n foreach($test as $koval=>$user) { \n\n if( empty($user['earnings']) || !file_exists($staff['earnings'])) {\n unset($array[$key][$koval]); }}}" ]
[ "php", "arrays", "multidimensional-array" ]
[ "How to retrieve data using Entity Framework LINQ to Entities with self referencing table using includes and joins?", "Database table called Events that contains event templates from which any number of single events can be generated that have a foreign key relationship referencing the same Event table with the template event ID as the primary key, so a self referencing table. There is another table called EventRestriction which has a foreign key to both the Event table and a Customer table. The foreign key value to the Event table is the event ID of the event template record. What I am struggling to do is the following:\n\nFrom the Event table get ALL events whose event template ID matches the event ID in the EventRestriction table and where the customer ID in the EventRestriction table equals a specific customer.\n\nThis is using EF 6 code first approach against SQL Server 2012.\n\nThis is the existing query that I am trying to build on;\n\nvar query = Events\n .Include(x => x.Location)\n .Include(x => x.Facility)\n .Include(x => x.EventType)\n .Include(\"Tickets.WebSaleItem.Product\")\n .Include(\"Tickets.SeatingTemplateCategory\")\n .Include(\"Tickets.SeatReservations\")\n .Include(x => x.SeatingTemplate.SeatingUser)\n .Include(x => x.SeatingTemplate.SeatingTemplateCategories)\n .Include(\"Facilities.Facility\")\n .Include(\"EventCapacityDistributions.CapacityDistributionSource\")\n .Include(\"EventCapacityDistributions.EventCapacityUsages.WebSaleItem.Product\")\n .Include(\"EventCapacityUsages.Bookings.EventBookingFacilities.Facility\")\n .Include(\"EventCapacityUsages.EventBookingReservation.EventBookingFacilities.Facility\")\n .AsQueryable();\n\n\nI have to use this is a base query as all of the includes are required for further processing against the initial result set.\n\nI have tried the following so far.\n\nI have declared the routing relationship between Event, EventRestriction and Customer so there are many-to-many relationships and hashsets defined with the appropriate (I think) navigation properties.\n\nI added this to the above query\n\nquery = query.Where (x => x.EventRestriction.Any (tte => tte.CustomerID == customerID));\n\n\nThis returns the single template event based upon event ID and customer ID.\n\nI then tried this:\n\nquery = query.Where(x => x.EventRestriction.Any (tte => (tte.CustomerID == customerID && tte.EventID == x.EventID) || (tte.EventID == x.EventTemplate.EventID && tte.CustomerID == customerID)));\n\n\nMy thinking was that doing the OR would do it but no joy and I get the same result as previous with just the single event.\n\nI am thinking that I am going in the right direction but missing a vital element.\n\nOne thing that did work for me though was doing this before building query:\n\nList<Guid> ttEventIDs = new List<Guid>();\n\nttEventIDs = EventRestriction.Select(tte => tte.EventID).ToList();\n\n\nI then used the resulting list like this;\n\nquery = query.Where(x => ttEventIDs.Contains(x.EventTemplate.EventID));\n\n\nNow this did give me the results I was expecting BUT using a contains is not really going to work as the number of ID's could be huge!!!\n\nI am thinking a table join would work better?\n\nSo basically what I expect is that if Event table contains a template event from which 100 individual events have been generated with an EventTemplateID foreign keyed to the original template event ID AND EventRestriction table contains one single record that comprising of the 'CustomerID' and the EventID of the original template my query needs to return NOT the single event record BUT the 100 events whose EventTemplateID matches the EventRestriction event ID.\n\nI hope this makes sense? Any guidance will be greatly appreciated." ]
[ "entity-framework", "linq", "join", "code-first", "self-reference" ]
[ "Random tag being added to contentEditable div?", "I'm cloning the chat post from Tumblr:\n\nI'm using regex, range and getSelection() to wrap any text before the colon with a <span> element that bolds the interior font with css.\nConsider this situation: I type Me:, the text is correctly wrapped and bolded. I backspace, watching everything be deleted in google chrome developer tools. Once the entire div is empty I try typing again and all of a sudden a <b> tag has been added and is now wrapping all the text. If I continue to type and type Me: again, the text will be wrapped by the span tag inside of this errant <b> tag.\nI'd really appreciate any help on this. I'm about to throw my laptop out of the window. If you look at the code below I'm no longer creating any <b> tag. I was trying to create <b> tags previously and switched to <span>, so is there any possibility that some child has just never been cleared out of the relevant div? Beyond that I have no idea...\nHere's the code:\nconst ChatPostInput = () => {\n\n const regexChat = () => {\n var chatDiv = document.querySelector('.chatText')\n console.log(chatDiv.childNodes)\n \n var regexBold = new RegExp(/^(.*?:)/, 'gm')\n\n if (window.getSelection) {\n var sel = window.getSelection(),\n suffixNode, bold = document.createElement('span') //here I'm creating the span element\n bold.setAttribute('class', 'boldText')\n var range = sel.getRangeAt(0)\n range.deleteContents()\n \n var text = range.commonAncestorContainer.textContent\n var matched = text.match(regexBold)\n\n if (matched) {\n bold.innerText = range.commonAncestorContainer.textContent\n range.commonAncestorContainer.textContent = '';\n range.insertNode(bold)\n range.setEndAfter(bold)\n range.collapse(false)\n range.insertNode((suffixNode = document.createTextNode(' ')))\n range.setStartAfter(suffixNode);\n sel.removeAllRanges();\n sel.addRange(range)\n }\n }\n }\n\n return (\n <div\n className='chatText'\n contentEditable={true}\n onInput={e => {\n //this is a hack to simply skip regexChat() when hitting backspace\n if (e.nativeEvent.data !== null) {\n regexChat()\n }\n }}\n \n onKeyDown={e => {\n e.stopPropagation();\n if (e.key === 'Enter') {\n if (window.getSelection) {\n var selection = window.getSelection(),\n range = selection.getRangeAt(0),\n br = document.createElement('br'),\n br2 = document.createElement('br'),\n suffixNode\n range.deleteContents();\n range.insertNode(br);\n range.collapse(false)\n range.insertNode(br2);\n range.setEndAfter(br2);\n range.collapse(false);\n range.insertNode((suffixNode = document.createTextNode(' ')));\n range.setStartAfter(suffixNode);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n }}\n >\n </div>\n )\n}\n\nUPDATE 1\nI've just found a hacky fix where I override the value of the <b> tag to be font-weight: normal but I mean what in the actual !@$% is going on here? This hack will be fine for my purposes for now but if anyone could reproduce this issue I'd really appreciate it." ]
[ "javascript", "html", "css", "reactjs" ]
[ "Docker-compose Nuxtjs", "I am creating my first Nuxtjs app but I want to use Docker-compose. I was able to Dockerize my application following this tutorial: https://dockerize.io/guides/docker-nuxtjs-guide\nNow I want to bring it to the next level using compose but I'm not too familiar with Serverside-rendering and how this could affect my docker-compose file. Unfortunately I cannot find any guide on how to use docker-compose on NuxtJS apps. Do you know where I can find a good guide for it? Thanks.\nUPDATE:\nI created a docker-compose.yml file and is working but still I can't find any guide to see if it is a good yml file (best practices etc.)\nversion: '3'\n\nservices:\n web:\n build: .\n command: npm run dev\n ports:\n - '3000:3000'" ]
[ "docker-compose", "nuxtjs" ]
[ "Laravel Migration - column already exists", "Several months ago, I was working late and needed to create a new column for a postgres table. I added the column through the command line using the standard heroku/postgres commands. I quickly realized how silly this was, deleted the column and then created the necessary migration to add it.\n\nI recently took that laravel app and created a pipeline with it as the production app. I created a new staging app and set up a database for it. When I ran the migrations, I got an error saying that a column already existed. As you may have guessed, this is the same column that I had messed up before.\n\nSince the migration failed after the database was created, I was able to delete the column in question, rerun the migration, and everything was OK. I do not understand why the column already existed except to guess that it was some artifact of my adding it manually (there was no error in the migrations).\n\nI am worried that this same error will happen when I push the staging code to production and have to rerun my migrations. Obviously, in the production app I can't just delete the column in question as it has data. \n\nAny ideas as to why this would happen and what I could do to fix the issue if it arises when I push the code into production?" ]
[ "laravel", "heroku-postgres", "laravel-migrations" ]
[ "Convert assac to string in PHP", "I'm trying to convert JSON-Object like [{\"text\":\"hallo\"},{\"text\":\"hello\"}] into a string which should look like \"hallo hello\". \n\nAt the moment, I'm decoding the JSON-Object with json_decode($words, true);\n\nThe result is being sent to a function than, which looks like:\n\nfunction assocToString($assoc)\n{\n $ergString=\"\";\n\n foreach($assoc as $key => $value)\n {\n if($ergString==\"\")\n {\n $ergString = $value;\n }\n else\n {\n $ergString .= $value;\n }\n\n $ergString .= \" \";\n }\n\n return $ergString;\n}\n\n\nI get errors like \"Array to string conversion\" all the time, maybe someone of you could please as be as kind as to help me out?" ]
[ "php", "json", "string", "converter", "associative-array" ]