texts
sequence | tags
sequence |
---|---|
[
"CONVERT not working for VARCHAR to DATETIME",
"I've tried everything I can find (CAST, CONVERT, converting on import, checking default language settings) but I cannot find a working solution to convert my VARCHAR values to DATETIME. I'd like to insert a conversion of this field into a new table where that column is set up as DATETIME. \n\nWhen I run: \n\nSELECT CONVERT(VARCHAR, [first air date], 121) \nFROM mytable\n\n\nthe results are returned fine and error free. However, when I run:\n\nINSERT INTO newtable\n SELECT ID, column1, column2, \n CONVERT(VARCHAR, [first air date], 121) \n FROM mytable\n\n\nI get this error:\n\n\n Msg 242, Level 16, State 3, Line 1\n The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.\n\n\nWhy am I getting results (as in the first query) but it won't insert them into another table?\n\nThe data looks like this: '2004-02-23 00:00:00.000' (I know the dashes aren't best practice but I have no wiggle room on that because this format has been determined by other colleagues).\n\nI'm importing the data via .csv and this column is set as date format in Excel.\n\nCorrection\nI now realise it should be CONVERT(DATETIME, [first air date], 121). However, this does not solve the actual problem at hand, which is converting to DATETIME from VARCHAR without the 'out of range' error."
] | [
"sql",
"sql-server",
"tsql"
] |
[
"SQLNCLI10 Error when executing stored procedure in SQL Server",
"I have a job running in one of my server and which uses a linked server and the linked server changed as part of upgrade and now my job fails everyday.\nI am getting the following error\n\n\n OLE DB provider \"SQLNCLI10\" for linked server \"linked server\" returned message \"No transaction is active.\".\n \n Msg 7391, Level 16, State 2, Line 6\n The operation could not be performed because OLE DB provider \"SQLNCLI10\" for linked server \"linked server\" was unable to begin a distributed transaction.\n\n\nAnd if I directly execute the procedure in linked server from my server then, for the first time it shows this error and for the second time it execute with out any problem.\n\nMy new linked server is 2012 version and the other one is 2008 R2 version\n\nPlease let me know your thoughts?\n\nThanks,\nSivajith"
] | [
"sql-server",
"linked-server",
"sql-job"
] |
[
"Data validation in Spark Structured Streaming - ETL",
"I am new to Structured Streaming Programming and I want to perform ETL.\nI have some validation/sanity check, help to deside BAD records.\n\n\n\nMy Code:\n\n val schema = StructType(Array(StructField(\"id\",StringType,true),StructField(\"lastName\",StringType,true),StructField(\"age\",StringType,true),StructField(\"dept\",StringType,true),StructField(\"sal\",StringType,true),StructField(\"gender\",StringType,true),StructField(\"status\",StringType,true))) \nval path : String = \"F:/Hadoop/Data\"\nimport spark.implicits._\n//RegEx expression to check input data\nval col1p = \"\\\\d{3}\".r\nval col2p = \"[a-zA-Z]\".r\nval col3p = \"\\\\d{3}\".r\nval col4p = \"[10|20|30]\".r\nval col5p = \"[0-9]\".r\nval col6p = \"[M|F]\".r\nvar st : String = \"1\" //Good Record\n\n//Read input file\nval empRaw = spark\n.readStream\n.option(\"sep\", \"~\")\n.schema(schema)\n.csv(path)\n\n//Write output\nempRaw.writeStream\n.outputMode(\"Append\")\n.format(\"console\")\n.option(\"checkpointLocation\", \"F:/Hadoop/Data/log0\")\n.start()\n\nspark.streams.awaitAnyTermination()\n\n\nBelow is sanity check/ETL check. Not sure where to apply.\nOr is there any other way to do the same.\n\nempRaw.rdd.map(r => {if (col1p.findFirstMatchIn(r(0).toString()).isEmpty || \n (col1p.findFirstMatchIn(r(1).toString()).isEmpty) ||\n (col1p.findFirstMatchIn(r(2).toString()).isEmpty) ||\n (col1p.findFirstMatchIn(r(3).toString()).isEmpty) ||\n (col1p.findFirstMatchIn(r(4).toString()).isEmpty) ||\n (col1p.findFirstMatchIn(r(5).toString()).isEmpty)) \n {st = \"0\"}\n Row(r(0).toString().toInt,r(1).toString(),r(2).toString().toInt,r(3).toString().toInt,\n r(4).toString().toInt,r(5).toString(),st)})"
] | [
"scala",
"apache-spark",
"spark-streaming",
"spark-dataframe"
] |
[
"NULL entry at id field in Phpmyadmin",
"I exported the sql from one phpmyadmin db and imported same at another phpmyadmin db.\n\nThe create table statement is as follows\n\nCREATE TABLE IF NOT EXISTS `h_stats` (\n `Id` int(11) DEFAULT NULL,\n `Category` varchar(50) DEFAULT NULL,\n `Success` int(11) DEFAULT NULL,\n `OutcomeFailure` int(11) DEFAULT NULL,\n `ThCount` int(11) DEFAULT NULL,\n `OCount` int(11) DEFAULT NULL,\n `HDate` varchar(50) DEFAULT '0',\n `Count` int(11) DEFAULT '0'\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n\nThe insert sql file also I have exported it as follows\n\nINSERT INTO `h_stats` (`Id`, `Category`, `Success`, `Failure`, `ThCount`, `OCount`, `HDate`, `Count`) VALUES\n(13, 'Hits', 31303, 8828, 8893, 30372, '2015-04-07', 40151), \n\n\nNote : \n\nWhen I try to insert new rows at the place of id NULL value is coming.\nCan anyone suggest me what to change in create table statement."
] | [
"php",
"mysql",
"phpmyadmin"
] |
[
"is it posible use variable css in lightness() function?",
"i tried to create mixin/function on sass like this\n@function background-set-text-color($color)\n @if (lightness( $color ) > 40)\n @return black\n @else\n @return white\n\nand i use this function on my class .button-filled\n.button-filled\n background: var(--bg-primary)\n padding: var(--p-1p5) var(--p-3)\n font-weight: 500\n color: background-set-text-color(var(--primary))\n border: solid 2px\n\nbut it show error like this\n./src/assets/sass/master.sass (./node_modules/css-loader/dist/cjs.js??ref--9-oneOf-3-1!./node_modules/postcss-loader/src??ref--9-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--9-oneOf-3-3!./src/assets/sass/master.sass)\nModule build failed (from ./node_modules/sass-loader/dist/cjs.js):\nSassError: argument `$color` of `lightness($color)` must be a color\n on line 2 of src/assets/sass/abstracts/_functions.sass, in function `lightness`\n from line 2 of src/assets/sass/abstracts/_functions.sass, in function `background-set-text-color`\n from line 5 of src/assets/sass/components/_button-filled.sass\n from line 14 of src/assets/sass/master.sass\n>> @if (lightness( $color ) > 40) {\n\n -------^\n\nany solution guys? Thank you :) Have nice weekend guys :)"
] | [
"css",
"sass"
] |
[
"Why we need to specify jar dependency in MANIFEST file",
"When deploying an EJb jar as part of the EAR, i understand that the runtime jar dependencies of the EJb (i.e log4j) need to be specified in the EJB jar's MANIFEST.MF. But why is this? If I put the log4j in the same directory as the ejb jar, then it should automatically be included in the runtime classpath, no? \n\nWhy do i need to specify the log4j in the MANIFEST.MF again? On the same vein, what jars are automatically available to my EJB jar at runtime without having to specify them in MANIFEST? Just the jars shipped with websphere?"
] | [
"jar",
"websphere",
"manifest"
] |
[
"How to use the value of textbox in mvvm commands",
"I'm still figuring out mvvm and I want to make my app the right way by splitting up model viewmodel and view. In the past I always took the value of the textbox in the view directly by using mytextbox.Text.\n\nI created a command in the viewmodel to add a new person to the network. but I can't get the values of the textboxes into the command in the viewmodel.\n\nThis is the code I have so far\nin model \n\npublic class Person : INotifyPropertyChanged\n{\n public Person()\n { }\n\n public Person(String FirstName)\n {\n this._firstName = FirstName;\n }\n\n public event PropertyChangedEventHandler PropertyChanged;\n private string _firstName;\n\n public string FirstName // the Name property\n {\n get { return this._firstName; }\n set { this._firstName = value; NotifyPropertyChanged(\"FirstName\"); }\n }\n}\n\n\nin the viewmodel I have\n\npublic class NetworkViewModel: INotifyPropertyChanged\n{\n\n private ObservableCollection<Person> _networkList1 = new ObservableCollection<Person>();\n public ObservableCollection<Person> NetworkList1 //Binds with the listbox\n {\n get { return _networkList1; }\n set { _networkList1 = value; RaisePropertyChanged(\"NetworkList1\"); }\n }\n\n public NetworkViewModel() \n {\n AddPersonCommand = new RelayCommand(AddPerson);\n }\n\n private ICommand _addPersonCommand;\n public ICommand AddPersonCommand // Binding with view\n {\n get { return _addPersonCommand; }\n set { _addPersonCommand = value; }\n }\n\n public void AddPerson(object obj)\n {\n\n if(cb_group.Text.ToUpper() == \"PRIMARY\")\n {\n _networkList1.Add(new Person(){ FirstName = tb_firstName.Text,});\n }\n}\n\n\nin XAML\n\n <TextBox x:Name=\"tb_firstName\" Text=\"{Binding Path=FirstName}\"/>\n\n\n\n\n<Button x:Name=\"btn_add\" Command=\"{Binding AddPersonCommand }\"/>\n\n\nWhat I would like is to make the value of tb_firstname and cb_group to be used in the viewmodel so I can make the command work.\nThanks for all your help. I'm just learning as I go."
] | [
"c#",
"wpf",
"xaml",
"mvvm",
"icommand"
] |
[
"Windows Event Viewer Error Code After Crash",
"Error code 10000050, parameter1 e60c0000, parameter2 00000001,\n parameter3 bf04963f, parameter4 00000001\n\n\nI have a computer that is repeatedly blue screening and this is the only error in the system logs that seemed abnormal. Any help would be greatly appreciated!"
] | [
"windows",
"crash",
"event-log"
] |
[
"Find the count of \"date\" appearing in a string using vba",
"I have a string that contain dates many times.\n\nfor example\n\n\n 2016-01-23 AKS Could you please check 2015-11-23 AKS Could you please check .2015-10-06 RM I added the remarks 2015-04-22 RM - Save your list here2014-12-21 SV See word.\n\n\nI need to count the number of occurrence of date.\nthe above example the count is 5"
] | [
"ms-access",
"vba"
] |
[
"Android trial program with same codebase as full version",
"I have a application already in Android Market. I want to create a trial application that is based on the same code base and then add some new code to limit some key features. Is there any good tutorials, blogs, stack posts, etc. that discuss how to do this in eclipse with one code base to maintain. \n\nOne of the problems that I am having is when I access resources in the code you have to reference them such as packageName.R.whatever and two apps cannot have the same packageName. So my trial version could not reuse the code base because all the resource references would not work. Has anyone found ways around these issues? I have tried a lot of searching but am not coming up with a lot of answers.\n\nThank you for your help"
] | [
"android",
"demo",
"trialware"
] |
[
"How to Configuration openapi.json on GCP Endpoints",
"I'm getting exception while configuring Openapi.json on gcp Endpoints \n\n\n ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot \n convert to service config. \n 'location: \"unknown location\" \n kind: ERROR \n message: \"Invalid OpenAPI file. Please fix the schema errors:\\n\\\"\\\": \n domain: validation; keyword: additionalProperties; message: additional \n properties not permitted; unwanted:\n\n\nCan you please help in identifying those"
] | [
"google-cloud-platform",
"google-cloud-endpoints"
] |
[
"Django_like traceback",
"I am using django like..to search model in Django application it was working fine ..but when I tried to deploy it on remote machine it is error...\n\nTraceback (most recent call last):\n File \"/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py\", line 255, in __call__\n response = self.get_response(request)\n File \"/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 178, in get_response\n response = self.handle_uncaught_exception(request, resolver, sys.exc_info())\n File \"/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 220, in handle_uncaught_exception\n if resolver.urlconf_module is None:\n File \"/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 342, in urlconf_module\n self._urlconf_module = import_module(self.urlconf_name)\n File \"/usr/local/lib/python2.7/site-packages/django/utils/importlib.py\", line 35, in import_module\n __import__(name)\n File \"./couponRestApi/urls.py\", line 9, in <module>\n admin.autodiscover()\n File \"/usr/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py\", line 25, in autodiscover\n mod = import_module(app)\n File \"/usr/local/lib/python2.7/site-packages/django/utils/importlib.py\", line 35, in import_module\n __import__(name)\n File \"/usr/local/lib/python2.7/site-packages/django_like/__init__.py\", line 7, in <module>\n QUERY_TERMS['like'] = None\n\n\nSo try to install django_like but it is already installed...\n\nsudo pip install django_like\nRequirement already satisfied (use --upgrade to upgrade): django-like in /usr/local/lib/python2.7/site-packages\nCleaning up...\n\n\nCan some one please help me? Why I am getting this error?"
] | [
"python",
"django"
] |
[
"Need to find web.xml in glassfish server",
"I am new to glassfish server.I have used apache tomcat and changed the Built In Servlet Definitions(with param-name=listings) in web.xml like \n\n<servlet>\n <servlet-name>default</servlet-name>\n <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>\n <init-param>\n <param-name>debug</param-name>\n <param-value>0</param-value>\n </init-param>\n <init-param>\n <param-name>listings</param-name>\n <param-value>false</param-value>\n </init-param>\n <load-on-startup>1</load-on-startup>\n </servlet>\n\n\nfrom false to true to list the files in my html iframe.\n\nHow to do it in glassfish server. which file property i have to modify.Thanks in advance"
] | [
"glassfish-3",
"netbeans-6.9",
"tomcat"
] |
[
"How make a spesific Java TreeNode",
"I want to create a structure with:\n\nClass Message\n{private String text;\n ...\n}\nClass Folder\n{....\n}\n\n\nA folder can contain several messages and other sub folder\n\nQuestion:\n\nhow I can make this structure?"
] | [
"java",
"arrays",
"sorting"
] |
[
"Return object type C",
"So i am working on my assignment and i got stuck on a piece of code. \n\nstruct image* createImg(unsigned int dim1, unsigned int dim2){\n\n int **a=NULL;\n int j;\n a=malloc(dim1*sizeof(int*));\n for (int i=0;i<dim1;i++)\n {\n a[i]=malloc(dim2*sizeof(int));\n for (j=0;j<dim2;j++)\n a[i][j]=0;\n }\n return a; //error here\n//return 0; \n}\n\n\nThe return type is an image Object. I am to compute width/height for a 2D array in this particular function. How can i return this value?\n\nThis is done in C\n\nUpdate:\n\nheader file\n\nstruct image{\n int **a;\n};\n\nand i changed a bit of the implementation\n\nstruct image* createWhiteimg(unsigned int dim1, unsigned int dim2){ \n\n\n struct image img;\n img.a = NULL;\n\n\n // int **a=NULL;\n int j;\n img.a=malloc(dim1*sizeof(int*));\n for (int i=0;i<dim1;i++)\n {\n img.a[i]=malloc(dim2*sizeof(int));\n for (j=0;j<dim2;j++)\n img.a[i][j]=0;\n }\n return &img;\n}"
] | [
"c"
] |
[
"Batch Script - Findstr \"/n\" flag?",
"I found a example of what I wanted to do online, which was search a text file for a string and replace only that string and write out to a file. Which sort-of works...\n\nThe script does replace the correct text. But, its printing line numbers, which I don't want. However, if I remove the \\n flag from findstr, it only prints lines containing data, and lines that aren't comments *(i.e. beginning with \";;\").\n\nHow do I use findstr to print all the lines without the line numbers?\n\n@echo off &setlocal\n\nset \"search=string to replace\"\nset \"replace=replace string with me\"\nset \"textfile=input.ini\"\nset \"newfile=output.ini\"\n\n(for /f \"delims=\" %%i in ('findstr /n \"^\" \"%textfile%\"') do (\n set \"line=%%i\"\n setlocal enabledelayedexpansion\n set \"line=!line:%search%=%replace%!\"\n echo(!line!\n endlocal\n))>\"%newfile%\"\ntype \"%newfile%\""
] | [
"batch-file",
"replace"
] |
[
"Highcharts showing December instead of November in x-axis",
"Why is highcharts showing december instead of november in my x-axis?\n\npointStart: Date.UTC(2014,11,15,19,0)\n\n\nJSFiddle"
] | [
"highcharts"
] |
[
"Table naming convention for configuring a jdbcRealm in GlassFish",
"I am trying to configure a jdbcRealm in GlassFishV3 using existing tables that have a naming convention other than \"users\" and \"groups\"; the realm does not appear to work unless the tables are named this way. My question is, why the limitation? Is there a work around other than renaming my existing tables?"
] | [
"java",
"naming-conventions",
"glassfish",
"glassfish-3",
"jdbcrealm"
] |
[
"RoR: select join model by condition on child table",
"I've got the following schema:\n\nfoo:\n id: integer\n\nbar:\n id: integer\n condition: boolean\n\nfoo_bar:\n id: integer\n foo_id: integer\n bar_id: integer\n\n\nBoth model and schema look like this. Given an instance of foo, I'd like to get an instance of foo_bar where the corresponding bar.condition is true. \n\nIs there a RoR-friendly way to do this?"
] | [
"ruby-on-rails",
"activerecord"
] |
[
"JavaScript Confirm Box not working when click confirm",
"I try to make a confirm box to inform user if they really want to show password field in table. But it not working when click Confirm.\nHere's my code:\nHTML\n<span onclick="myFunction()" class="fa fa-fw fa-eye fa-eye-slash field-icon toggle-password"></span>\n<span style="display:none;" id="password-field">123456</span>\n\nJS:\nfunction myFunction() {\n \n if (confirm("Are you sure you want to show your password on the screen?)) {\n \n $(".toggle-password-<?=$model->id?>").click(function() {\n\n $(this).toggleClass("fa-eye-slash");\n \n });\n \n\n $(document).ready(function(){\n $(".toggle-password-<?=$model->id?>").click(function(){\n $("#password-field-<?=$model->id?>").toggle();\n });\n }); \n \n } else {\n //do nothing\n }\n \n }\n\nPlease help me with this.\nThank you!"
] | [
"javascript",
"jquery"
] |
[
"Sort an array based on string size",
"I'm completely stuck on this. My aim is to create a method which lets me sort an array based on the length of the string. \n\nI manage to sort it descending but it can't get to sort depending on the string size.\n\ndef sort_by_length(anArray)\n anArray.sort { |x,y| y <=> x }\nend\n\na = [\"twoish\",\"one\", \"treeishish\"]\nsort_by_length(a)"
] | [
"ruby-on-rails",
"ruby"
] |
[
"Replacing all existing data in table",
"I'm trying to replace all data in a table with a specified field (for example user_id=some_number). I've tried DELETE followed by INSERT, but that seems to do some problems and am looking for a better solution to do that. In addition, most of the rows are still the same, so it this approach is probably not too efficient. I've ran into INSERT ON DUPLICATE KEY / REPLACE but those will keep the some of the old data and not delete it, if I understand it correctly. I've thought about doing a SELECT and comparing the values in PHP but thought mysql might have implemented this for me. Is there an option to do that with a query?\n\nUPDATE: \nTo be clearer, Lets say I have inside table my_table these values: \n\ncol1 col2 col3 \nv1 v2 v3 \nv1 v4 v5 \nv1 v6 v7\nv2 v8 v9\n\n\nI would like to up replace all col1=v1 rows with this data:\n\ncol1 col2 col3 \nv1 v10 v11 \nv1 v4 v5 \n\n\nSo I should end up deleting one row, keeping one the same, and updating another.\nSo the table will look like this at the end of the operation:\n\ncol1 col2 col3 \nv1 v10 v11 \nv1 v4 v5 \nv2 v8 v9\n\n\nDid this clear things up?"
] | [
"php",
"mysql",
"sql"
] |
[
"How can I prevent external MSBuild files from being cached (by Visual Studio) during a project build?",
"I have a project in my solution which started life as a C# library project. It's got nothing of any interest in it in terms of code, it is merely used as a dependency in the other projects in my solution in order to ensure that it is built first. One of the side-effects of building this project is that a shared AssemblyInfo.cs is created which contains the version number in use by the other projects.\n\nI have done this by adding the following to the .csproj file:\n\n<ItemGroup>\n <None Include=\"Properties\\AssemblyInfo.Shared.cs.in\" />\n <Compile Include=\"Properties\\AssemblyInfo.Shared.cs\" />\n <None Include=\"VersionInfo.targets\" />\n</ItemGroup>\n<Import Project=\"$(ProjectDir)VersionInfo.targets\" />\n<Target Name=\"BeforeBuild\" DependsOnTargets=\"UpdateSharedAssemblyInfo\" />\n\n\nThe referenced file, VersionInfo.targets, contains the following:\n\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n <PropertyGroup>\n <!--\n Some properties defining tool locations and the name of the\n AssemblyInfo.Shared.cs.in file etc.\n -->\n </PropertyGroup>\n <Target Name=\"UpdateSharedAssemblyInfo\">\n <!--\n Uses the Exec task to run one of the tools to generate\n AssemblyInfo.Shared.cs based on the location of AssemblyInfo.Shared.cs.in\n and some of the other properties.\n -->\n </Target>\n</Project>\n\n\nThe contents of the VersionInfo.targets file could simply be embedded within the .csproj file but it is external because I am trying to turn all of this into a project template. I want the users of the template to be able to add the new project to the solution, edit the VersionInfo.targets file, and run the build.\n\nThe problem is that modifying and saving the VersionInfo.targets file and rebuilding the solution has no effect - the project file uses the values from the .targets file as they were when the project was opened. Even unloading and reloading the project has no effect. In order to get the new values, I need to close Visual Studio and reopen it (or reload the solution).\n\nHow can I set this up so that the configuration is external to the .csproj file and not cached between builds?"
] | [
"visual-studio",
"msbuild",
"csproj"
] |
[
"TextField used in iOS message app",
"I want a text field similar to the stock messaging app in the iPhone. Text field should have the same look and should be expandable to allow multi-line editing. Could you please suggest a method to get this in my app? \n\nThanks."
] | [
"ios",
"messaging",
"textfield"
] |
[
"Website saved to homescreen (ios) force open in safari",
"I am working on somewhat of a webapp, the client would like the ability to save to homescreen (default behavior) but when the end user opens the app saved to the homescreen it opens in safari rather then in \"webapp\" mode.\n\nAn example of such is on espn's mobile site:\nhttp://m.espn.go.com/\n\nNote by saving to homescreen, then accessing... It opens in safari.\n\nThanks!!"
] | [
"javascript",
"ios",
"iphone-web-app"
] |
[
"Click image to advance",
"I'm wondering how to improve a thumbnail gallery by making it so one could click the main image to advance to the next image in the list. The main image is in the #image div. Right now you can only click the thumbnail (.image) to select an image. Below is how it is setup right now. Any help would be greatly appreciated.\n\n<ul class=\"thumb\">\n\n<li><a href=\"images/1.png\" class=\"image\"><img src=\"images/t1.png\"border=\"0\"/></a></li>\n<li><a href=\"images/2.png\" class=\"image\"><img src=\"images/t2.png\"border=\"0\"/></a></li>\n\n <div id=\"container\"><div id=\"image\"></div> \n</div>\n\n\n\n$(function() {\n$(\".image\").click(function() {\nvar image = $(this).attr(\"href\");\n\n$('#image').hide();\n$('#image').fadeIn();\n$('#image').html('<img src=\"' + image + '\">'); \n\nreturn false;\n });\n (location.attr)? $(\"a [rel=\"+location.attr+\"]\").click():$(\".thumb a:first\").click();\n\n});"
] | [
"jquery"
] |
[
"Cannot import csv file using neo4j-admin",
"Hello i am trying to import csv file using neo4j-admin tool but i am receiving this error graph.db' already contains a database \n\nDoes this mean that i need to create new database every new import ?"
] | [
"neo4j"
] |
[
"Node.js Mongoose: Value does not represent the set data, yet database has changed",
"When I call findOneAndUpdate and set shared.warningMessage to '', I can see the database has got the change, but when I logout console.log(saved.shared.warningMessage); the changes have not been reflected.\n\nSo do I need to call the database again to get the set value? Or is there some way of getting the set value back at the same time as setting it?\n\n const saved = await userModel\n .findOneAndUpdate(\n { 'email.confirmationCode': confirmationCode },\n {\n $set: { 'shared.warningMessage': '', 'email.confirmed': true },\n $unset: { 'email.confirmationCode': '' },\n }\n )\n .exec();\n if (!saved) throw new Error('Invalid confirmation code');\n console.log(saved.shared.warningMessage);\n\n\nI dont want to remove the key and value for shared.warningMessage I just want it to have no value hence ''"
] | [
"mongodb",
"mongoose"
] |
[
"Change Event Within Date Range",
"I am trying to write PHP code to check if a date/time falls within a certain range to render some HTML, and if it doesn't, render some other HTML. Below is my code. If I set the comparisons to a future date, it seems to work fine, & the flag status goes to half staff & then back to full staff according to the parameters. However the next day, about 2-3 hours after the status is set back to full staff, it automatically reverts back to half staff status.\n\nif(date('Y-n-j-G-i') >= '2013-10-9-12-00' && date('Y-n-j-G-i') <= '2013-10-10-5-00' ) {\n\n echo \"<span style='font-size:1.1em'>Governor's Flag Status:</br> <span style='color:#f00'>Half Staff</span></span>\";\n}\nelse {\n echo \"<span style='font-size:1.1em'>Governor's Flag Status:</br> <span style='color:#333'>Full Staff</span></span>\";\n}\n\n\nI have tried to 'think' through the logic, but it appears I am missing something. Any help would be appreciated."
] | [
"php",
"date"
] |
[
"Java PL/SQL 'Execute Immediate'",
"I am programming Java application on Oracle database. The PL/SQL statement I am using is:\n\nDECLARE\nUSER_COUNT INTEGER;\nBEGIN\n SELECT COUNT(*) INTO USER_COUNT FROM dba_users WHERE username=?;\n IF (USER_COUNT = 0) THEN\n EXECUTE IMMEDIATE 'CREATE USER ? IDENTIFIED BY ?';\n EXECUTE IMMEDIATE 'GRANT CREATE SESSION, CREATE TABLE, CREATE ANY INDEX TO ?';\n ELSE\n raise_application_error(-20101, 'User ? already exists. Please drop it or choose another username.');\n END IF;\nEND;\n/\n\n\nBut I got a lot of 'invalid column index' errors if there are quotes around question marks. For instance:\n\n EXECUTE IMMEDIATE 'CREATE USER ? IDENTIFIED BY ?';\n\n\nis not working, but\n\n EXECUTE IMMEDIATE CREATE USER ? IDENTIFIED BY ?;\n\n\nis good.\n\nHowever if I choose to use second form, I got another syntax error:\n\njava.sql.SQLException: ORA-06550: line 6, column 23:\nPLS-00103: Encountered the symbol \"CREATE\" when expecting one of the following:\n\n ( - + case mod new not null <an identifier>\n <a double-quoted delimited-identifier> <a bind variable>\n continue avg count current exists max min prior sql stddev\n sum variance execute forall merge time timestamp interval\n date <a string literal with character set specification>\n <a number> <a single-quoted SQL string> pipe\n <an alternatively-quoted string literal with character set specification>\n <an alternat\n\n\nPlease advise what to do."
] | [
"java",
"sql",
"oracle",
"plsql"
] |
[
"format Date in pandas style render",
"I have a pandas dataframe with three columns of which the first is the Date. To produce a html output I use this: \n\nhtml_string = df.style.format({'second': \"{:0,.0f}\",third: \"{:0,.0f}\"}).set_table_styles(styles).render()\n\n\nhow is it possible to specifiy the format of the Date as well...something like:\n\nhtml_string = df.style.format({'Date': \"%Y.%m\",'second': \"{:0,.0f}\",third: \"{:0,.0f}\"}).set_table_styles(styles).render()"
] | [
"python",
"pandas"
] |
[
"SPI fails to read first 6 bytes",
"I'm having a lot of issues with SPI module on my STM32F051 MCU. I've got it configured as a master to drive a slave flash memory module (that doesn't really matter).\n\nI'm trying to read 8 bytes from memory, this is how the 'read data' message is structured:\n\nFirst 4 bytes of the message are transmitted, next 8 are received.\nFirst byte is 'read data' opcode, three following are data address and equal 0 in this case.\n\nCode:\n\nmemset(out, 0x00, 256);\nmemset(in, 0x00, 256);\nout[0] = OPCODE_READ;\nout[1] = 0x00;\nout[2] = 0x00;\nout[3] = 0x00;\nuint32_t len = 4 + size; // size == 8\n\nspi_select(M25P80);\nHAL_SPI_TransmitReceive(&hspi1, out, in, len, TIMEOUT);\ndelay_ms(BYTE_SPEED_MS * 5); // Needed because ^ finishes before physically \n // transmitting the data. Nevermind the 5, it \n // was picked experimentally \nspi_deselect(M25P80);\n\n\nSignal (yellow - clock, red - miso):\n\n\n\nAt 488 bits/s transmitting 4 bytes takes 4 * 1E3 / (488 / 8) = 65.5 ms. Then the reception starts. Memory starts transmitting [0xFF...0xFF] right away, but contents of the 'in' buffer are:\n\n[0x00 0x00 0x00 0x00] [0x00 0x00 0x00 0x00 0x00] 0xFF 0xFF 0x00...0x00\n^ zero because this ^ should be 0xFF ^ correct data\n is the part where\n data was being sent\n to the memory\n\n\nSo first six bytes of data are just lost. Am I the only one who's having such a hard time with STM's SPI module?\n\nEDIT:\n\nI've gotten myself a different eval board with a slightly different MCU (STM32F030) and it gets even weirder:\n\n[0x02 0x02 0x02 0x02] \n0x00 0x02 0x00 0x00 0xFF 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00...0x00\n\n\nAlthough I must mention that I'm using a different compiler with this MCU.\n\nEDIT 2:\n\nThe way I partially got it to work is using 16-bit mode with SPI. This fixed this particular bug, but there are more similar oddities with STM32's SPI.\n\nEDIT 3:\n\nSPI initialisation code:\n\nvoid MX_SPI1_Init(void)\n{\n\n hspi1.Instance = SPI1;\n hspi1.Init.Mode = SPI_MODE_MASTER;\n hspi1.Init.Direction = SPI_DIRECTION_2LINES;\n hspi1.Init.DataSize = SPI_DATASIZE_16BIT;\n hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;\n hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;\n hspi1.Init.NSS = SPI_NSS_SOFT;\n hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;\n hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;\n hspi1.Init.TIMode = SPI_TIMODE_DISABLED;\n hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;\n hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLED;\n HAL_SPI_Init(&hspi1);\n\n}"
] | [
"stm32",
"spi"
] |
[
"Best practice: multiple entities to single entity",
"This is a very hard to explain question and I hope my code extract explains most of it.\nLet's say you have the following database design:\nmusicstyle relations http://img190.yfrog.com/img190/2080/musicstylerelations.jpg\nAnd you want to build one generic interface to modify the musicstyle relations between all three entities. Currently I have created a MusicStyleController which requires the type of Entity it is related to (Member, Event or Band).\n[AcceptVerbs(HttpVerbs.Post)]\npublic JsonResult DeleteMusicStyle(int id, string type, int typeid)\n{\n if (!(Session["MemberLoggedIn"] is Member)) return Json(string.Empty);\n Member member = (Member)Session["MemberLoggedIn"];\n\n switch (type) { \n case "member":\n _memberService.DeleteMusicStyle(member, id);\n break;\n case "band":\n Band band = _bandService.GetBand(typeid);\n _bandService.DeleteMusicStyle(band, id);\n break;\n case "event":\n Event @event = _eventService.GetEvent(typeid);\n _bandService.DeleteMusicStyle(@event, id);\n break;\n }\n return SelectedMusicStyles();\n}\n\nI make myself sick writing such code, but can't find another, more elegant way.\nNote that this function is called using jquery.post().\nThe question\nHow would you refactor this code, and would you normalize the database even more? Keep in mind that I'm using the Entity Framework as a data model."
] | [
"c#",
"asp.net-mvc",
"entity-framework"
] |
[
"Where is the \"from __future__ import braces\" code?",
"I was wondering what is exactly the code that executed on the command:\n\n>>> from __future__ import braces\nSyntaxError: not a chance\n\n\nso, since python is open-sourced I opened C:\\Python27\\Lib\\__future__.py and looked.\nsurprisingly, I found nothing there that handle importing braces module.\n\nso, my question is, where is the code that handle this? what happen when I run that command?"
] | [
"python",
"python-2.7",
"python-internals"
] |
[
"An additional resource group, NSG, DNS Zone is created when deploying AKS terraform",
"While creating aks cluster by using terraform and using existing values like resource group, vnet, subnet, network security group,\nDeployment creating additional resource group, network security group, dns zone.\nDo you have any idea how to stop that or disable?\nCreating new RG with name MC_RG_XXXXXXXX\nGood things:\nCluster getting created by using existing Vnet, subnet, cluster linked with existing RG but its creating network security Group and DNS Zones with new RG.\nAny idea?"
] | [
"terraform",
"azure-aks"
] |
[
"Why is the form data not saving to localstorage in react?",
"I have written this simple code to save my data to local storage but sometimes it works and sometimes it doesn't(no change to code). And it mostly saves empty data. what is going on here? Also the data is erased when the chrome window is closed, reopened and new data is entered.\n\nThis is the content inside return method.\n\n<div className=\"wrapper\">\n <div className=\"content\">\n <h1>Get in touch!</h1>\n <p>Connect with us by sending your views.</p>\n </div>\n <div className=\"form\">\n <div className=\"top-form\">\n <div className=\"inner-form\">\n <div className=\"label\">Name</div>\n <input\n type=\"text\"\n placeholder=\"Enter your name\"\n id=\"contname\"\n />\n </div>\n <div className=\"inner-form\">\n <div className=\"label\">Email</div>\n <input\n type=\"text\"\n placeholder=\"Enter your email\"\n id=\"contemail\"\n />\n </div>\n <div className=\"inner-form\">\n <div className=\"label\">Phone</div>\n <input\n type=\"text\"\n placeholder=\"Enter your phone no.\"\n id=\"contph\"\n required\n />\n </div>\n </div>\n <div className=\"middle-form\">\n <div className=\"inner-form\">\n <div className=\"label\">Subject</div>\n <input\n type=\"text\"\n placeholder=\"Enter the subject\"\n id=\"contsub\"\n />\n </div>\n </div>\n <div className=\"bottom-form\">\n <div className=\"inner-form\">\n <div className=\"label\">Message</div>\n <textarea\n placeholder=\"Enter your message\"\n id=\"contmessage\"\n ></textarea>\n </div>\n </div>\n <div className=\"btn\" id=\"sendmessage\" onClick={ev => { this.addData(ev) }}>\n Continue\n </div>\n </div>\n\n\nand this is the portion to save data:\n\nvar contactData = [];\nexport default class Contact extends Component {\n componentDidMount() {\n window.scrollTo(0, 0)\n }\n\n addData = (ev) => {\n ev.preventDefault();\n let cdata = {\n contactname: document.getElementById(\"contname\").value,\n contactphno: document.getElementById(\"contph\").value,\n contactemail: document.getElementById(\"contemail\").value,\n contactsubject: document.getElementById(\"contsub\").value,\n contactmessage: document.getElementById(\"contmessage\").value\n };\n contactData.push(cdata);\n localStorage.setItem(\"Contactinfo\", JSON.stringify(contactData));\n alert(\"Data Submitted succesfully!\");\n };"
] | [
"javascript",
"html",
"reactjs"
] |
[
"Spring security intercept-url with combined multiple roles",
"I am quite new to Spring and meet some difficulties configuring Spring security rules.\n\nHere are my rules :\n\n<intercept-url pattern=\"/administration/**\" access=\"ROLE_ADMINISTRATION\" />\n<intercept-url pattern=\"/programmation/**\" access=\"ROLE_ADMINISTRATION, ROLE_SAISIE, ROLE_CONSULTATION\" />\n<intercept-url pattern=\"/programmation/validate\" access=\"hasAnyRole('ROLE_ADMINISTRATION', 'ROLE_SAISIE', 'ROLE_CONSULTATION') and hasAnyRole('ROLE_NATIONAL', 'ROLE_REGIONAL')\" />\n<intercept-url pattern=\"/restitution/**\" access=\"ROLE_ADMINISTRATION, ROLE_RESTITUTION\" />\n<intercept-url pattern=\"/**\" access=\"ROLE_ADMINISTRATION, ROLE_SAISIE, ROLE_CONSULTATION, ROLE_RESTITUTION\" />\n\n\nI just added the third one, and when starting the server, it yield a quite strange Exception from my point of view : \n\njava.lang.IllegalArgumentException: Unsupported configuration attributes: [hasAnyRole('ROLE_ADMINISTRATION', 'ROLE_CONSULTATION') and hasAnyRole('ROLE_NATIONAL', 'ROLE_REGIONAL'), 'ROLE_SAISIE']\n at org.springframework.security.access.intercept.AbstractSecurityInterceptor.afterPropertiesSet(AbstractSecurityInterceptor.java:156) [spring-security-core-3.2.5.RELEASE.jar:3.2.5.RELEASE]\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) [spring-beans-4.0.1.RELEASE.jar:4.0.1.RELEASE]\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) [spring-beans-4.0.1.RELEASE.jar:4.0.1.RELEASE]\n ... 49 more\n\n\nAs you can see, it come from\n\nhasAnyRole('ROLE_ADMINISTRATION', 'ROLE_SAISIE', 'ROLE_CONSULTATION') and hasAnyRole('ROLE_NATIONAL', 'ROLE_REGIONAL')\n\n\nto\n\nhasAnyRole('ROLE_ADMINISTRATION', 'ROLE_CONSULTATION') and hasAnyRole('ROLE_NATIONAL', 'ROLE_REGIONAL'), 'ROLE_SAISIE'\n\n\nI suppose there is a kind of bad interraction between the rules, but I can't figure out what happens exactly."
] | [
"java",
"spring",
"spring-mvc",
"spring-security"
] |
[
"How to populate a column with random date in a table which falls between 2 dates from another table",
"I have two tables like patient_record and surgery_record. I want to populate the surgery_Date column in surgery_record table with a random date which falls between the Beg_Date and End_Date values in the patient_record table (Beg_Date and End_Date are the dates of patient admittance and discharge respectively. Currently I have the following query. Thanks in advance\n\npatient_record:\n\nBeg_Date = DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 365), '01/01/2000')\nEnd_Date = DATEADD(DAY, 85 + ABS(CHECKSUM(NEWID()) % 11), Beg_Date)\n\n\nsurgery_record:\n\nupdate Surgery_Record\nset Surgery_Date = DATEADD(DAY, 85 + ABS(CHECKSUM(NEWID()) % 11), patient_record.Beg_Date)\n\n\nBut I get the following error:\n\nMsg 4104, Level 16, State 1, Line 2\nThe multi-part identifier \"patient_record.Beg_Date\" could not be bound.\n\n\nI understand that I must have a relationship between these two tables to use the attributes commonly and I already have a foreign key constraint on a different attribute. If this is not enough please advice."
] | [
"sql",
"sql-server",
"sql-server-2012"
] |
[
"Jquery, 'is not a function', extension-function not working",
"I get this error in the console of Firefox:\n\n$spinner.setupSpinner is not a function\n[Break On This Error] \n\n$spinner.setupSpinner();\n\n\ned247.base.js (line 116)\n\nPostliste.aspx loads these files:\n\njquery-1.9.0.js\"\njquery-ui-1.9.0.js\njquery.ui.datepicker-no.js\njquery-scrollTo-min.js\ned247.base.js\n\n\nExcerpt of ed247.base.js :\n\n jQuery.fn.setupSpinner = function () {\n $(this)\n .ajaxStart(function () {\n $(this).show();\n })\n .ajaxStop(function () {\n $(this).hide();\n })\n ;\n return this;\n };\n\n // init\n function init() {\n // cache jquery objects\n $item = $(config.ids.item);\n $searchResult = $(config.ids.searchResult);\n $spinner = $(config.ids.spinner);\n $datepicker = $(config.ids.datepicker);\n $todatepicker = $(config.ids.todatepicker);\n $searchButton = $(config.ids.searchButton);\n $searchItemTemplate = $(config.templateids.searchItemTemplate);\n $searchHeaderTemplate = $(config.templateids.searchHeaderTemplate);\n $itemTemplate = $(config.templateids.itemTemplate);\n $attachmentsTemplate = $(config.templateids.attachmentsTemplate);\n $backLinks = $(config.classes.backLinks);\n $checkout = $(config.ids.checkout);\n\n\n $backToStep1 = $backLinks.find(\"li:nth-child(1)\");\n $backToStep2 = $backLinks.find(\"li:nth-child(2)\");\n\n $spinner.setupSpinner();\n\n\nHere is the URL to the page: Link\n\nThe problem seems to be that the extension function isn't found?\nHow do I solve this?"
] | [
"jquery",
"jquery-ui",
"spinner"
] |
[
"Best way to store uploded documents on web application",
"I have one web application where user can upload multiple files( one file size up to 20MB) for one record.\nCurrently, storing files on file system. But still wanted to know which is the best way.\n**Architecture **\nAuth , business logic and user interface are on different computers. A request travel through all these servers. user interface does have file system access .\nWhen the user download a file, UI request auth , auth ask BL and BL will give db path only, and then auth will encode this file and give it to UI.\nIs it a correct way? What are the other options?"
] | [
"file-upload",
"architecture"
] |
[
"Customising meta_form() in wp-admin/includes/template.php",
"Hi all I'm a WordPress noob so please bear with me. So in template.php I need the functionality of the meta_form() function to change based on a few conditions. Here's what it looks like:\n\nOriginal code:\n\n function meta_form() {\n global $wpdb;\n $limit = (int) apply_filters( 'postmeta_form_limit', 30 );\n $keys = $wpdb->get_col( \"\n SELECT meta_key\n FROM $wpdb->postmeta\n GROUP BY meta_key\n HAVING meta_key NOT LIKE '\\_%'\n ORDER BY meta_key\n LIMIT $limit\" );\n if ( $keys )\n natcasesort($keys);\n ?>\n\n\nCustomized version:\n\nfunction meta_form() {\n global $wpdb;\n\n if ( isset($_GET['post']) )\n $post_id = (int) $_GET['post'];\n elseif ( isset($_POST['post_ID']) )\n $post_id = (int) $_POST['post_ID'];\n else\n $post_id = 0;\n\n if ( $post_id ) {\n $post_ = get_post($post_id);\n\n }\n\n if ($post_->post_type == 'video_photo' ){\n $limit = (int) apply_filters( 'postmeta_form_limit', 30 );\n $keys = $wpdb->get_col( \"\n SELECT meta_key\n FROM $wpdb->postmeta\n where meta_key like 'tqmcf_%'\n GROUP BY meta_key\n HAVING meta_key NOT LIKE '\\_%'\n ORDER BY meta_key\n LIMIT $limit\" );\n }else{\n $limit = (int) apply_filters( 'postmeta_form_limit', 30 );\n $keys = $wpdb->get_col( \"\n SELECT meta_key\n FROM $wpdb->postmeta\n GROUP BY meta_key\n HAVING meta_key NOT LIKE '\\_%'\n ORDER BY meta_key\n LIMIT $limit\" );\n }\n\n if ( $keys )\n natcasesort($keys);\n?>\n\n\nWhat's the best way to overwrite the meta_form function? Would I have to create a plugin or something? I can't seem to find a clean answer. (p.s. I didn't write this code, I'm just the one fixing it)."
] | [
"wordpress"
] |
[
"onsen dialog have limited access to parent scope",
"I'm looking for some help on using onsen-ui's dialog component. It seems to be a scope issue.\n\nIn my HTML file, I have a dialog template looks like this.\n\n<ons-template id=\"report.html\">\n <ons-dialog var=\"dlg\" cancelable>\n <h1>{{clicked.name}}</h1>\n <ons-button onclick=\"clickButton()\">Click</ons-button>\n </ons-dialog>\n</ons-template>\n\n\nAnd in my controller, I have \n\n$scope.clickButton = function(){\n dlg.hide();\n}\n$scope.dialogs = {};\n\n$scope.show = function(dlg) {\n $scope.clicked = {'name':\"bar\"};\n if (!$scope.dialogs[dlg]) {\n ons.createDialog(dlg, {parentScope: $scope}).then(function(dialog) {\n $scope.dialogs[dlg] = dialog;\n dialog.show();\n });\n } else {\n $scope.dialogs[dlg].show();\n }\n}\n\n\nThe weird part is that I can access \"clicked\" in the dialog scope, but not \"reportButton\", they are in the same scope, or at least I can tell.\n\nHere is the codepen link\n\nThanks in advance!"
] | [
"angularjs",
"angularjs-scope",
"onsen-ui"
] |
[
"Firebase RemoteConfig crashes app with signal 11 (SIGSEGV)",
"I have a Unity app and I use a bunch of plugins provided by Google: Play Games Services, AdMob, Firebase Analytics. They all work perfectly fine. Now I want to add Firebase RemoteConfig. But I can't because my app is constantly crashing (on android device) when I try to do anything with RemoteConfig. I trying googling but didn't find anything similar.\nMy code looks something like this:\n\npublic class RemoteConfigManager\n{\n void Start()\n {\n Debug.Log(\"Start\");\n var dependencyStatus = Firebase.FirebaseApp.CheckDependencies();\n if (dependencyStatus != Firebase.DependencyStatus.Available)\n {\n Debug.Log(\"Trying to fix dependencies\");\n Firebase.FirebaseApp.FixDependenciesAsync().ContinueWith(task =>\n {\n dependencyStatus = Firebase.FirebaseApp.CheckDependencies();\n if (dependencyStatus == Firebase.DependencyStatus.Available)\n {\n Debug.Log(\"Fixed dependencies\");\n SetDefaults();\n }\n else\n {\n Debug.LogError(\"Could not resolve all Firebase dependencies: \" + dependencyStatus);\n }\n });\n }\n else\n {\n Debug.Log(\"Dependencies ok\");\n SetDefaults();\n }\n }\n\n void SetDefaults()\n {\n Debug.Log(\"Set defaults\");\n var configuration = ConfigurationManager.Instance.Configuration;\n var defaults = new Dictionary<string, object>();\n defaults.Add(\"some_key\", 1);\n FirebaseRemoteConfig.SetDefaults(defaults);\n }\n}\n\n\nSIGSEGV happens when FirebaseRemoteConfig.SetDefaults() is called. Stack trace looks like this:\n\n06-20 17:10:38.929: I/DEBUG(30994): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n06-20 17:10:38.929: I/DEBUG(30994): Build fingerprint: 'htc/htc_europe/m7:5.0.2/LRX22G/482424.51:user/release-keys'\n06-20 17:10:38.929: I/DEBUG(30994): Revision: '3'\n06-20 17:10:38.929: I/DEBUG(30994): ABI: 'arm'\n06-20 17:10:38.929: I/DEBUG(30994): pid: 29950, tid: 29973, name: UnityMain\n06-20 17:10:38.929: I/DEBUG(30994): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0\n06-20 17:10:38.969: I/DEBUG(30994): r0 00000000 r1 00000008 r2 affc42f0 r3 915dc8f8\n06-20 17:10:38.969: I/DEBUG(30994): r4 ba252920 r5 00000008 r6 ba252920 r7 00000008\n06-20 17:10:38.969: I/DEBUG(30994): r8 00000000 r9 9744f118 sl 00000000 fp affc4308\n06-20 17:10:38.969: I/DEBUG(30994): ip 00000001 sp affc42b8 lr 9158e7d1 pc 91598354 cpsr 600b0030\n06-20 17:10:38.969: I/DEBUG(30994): backtrace:\n06-20 17:10:38.969: I/DEBUG(30994): #00 pc 00064354 /data/app/com.myapp-1/lib/arm/libApp.so (firebase::App::GetInstance(char const*)+3)\n06-20 17:10:38.969: I/DEBUG(30994): #01 pc 0005a7cd /data/app/com.myapp-1/lib/arm/libApp.so (firebase::remote_config::SetDefaults(firebase::remote_config::ConfigKeyValue const*, unsigned int)+12)\n06-20 17:10:38.969: I/DEBUG(30994): #02 pc 00059357 /data/app/com.myapp-1/lib/arm/libApp.so (firebase::remote_config::SetDefaultsInternal(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::\n06-20 17:10:38.969: I/DEBUG(30994): #03 pc 00059821 /data/app/com.myapp-1/lib/arm/libApp.so (Firebase_RemoteConfig_CSharp_SetDefaultsInternal__SWIG_1+84)\n06-20 17:10:38.969: I/DEBUG(30994): #04 pc 0000516c <unknown>\n\n\nI tried different variants but always get this SIGSEGV. Any ideas?"
] | [
"android",
"firebase",
"unity3d",
"segmentation-fault",
"firebase-remote-config"
] |
[
"HAML - how do I make a path that makes the browser go back in a button?",
"I currently have a button like this:\n\n= button_to \"Go Back\" , mobile_disclosures_url , :method => :get\n\n\nBut I am not sure what path to give it so that it makes the browser go back. Any help? :)\n\nThanks!"
] | [
"haml"
] |
[
"How can I use Express to render dynamic files?",
"I'm looking to use Express to render raw strings as HTML, with the ability to reference static files in a specified directory (CSS, images, and other resources).\n\nI've done a lot of research, but I haven't seen anything that approaches what I'm trying to do. For example, I thought perhaps writing a custom templating engine that only pretended to load a file would cut it, but that doesn't seem to do the trick.\n\nWhat's the best way to approach this?"
] | [
"node.js",
"dynamic",
"express"
] |
[
"How to build a dataframe comparing predicted and actual results from a regression model",
"I would like to build a dataframe that compares the predicted results of a regression model (y_hat) with the test data (y_test). I have two access methods for selecting the test data. Access method 1 works but Access method 2 doesn't when I try to build the comparison dataframe.\nAccess method 1:\nX_data = df_scores[['Hours']]\ny_data = df_scores['Scores']\nX_train, X_test, y_train, y_test = train_test_split(X_data, y_data, test_size=0.20, random_state=0)\nlm = LinearRegression()\nlm.fit(X_train, y_train)\ny_hat = lm.predict(X_test)\n\nThis dataframe works:\ndf_scores_comp = pd.DataFrame({'Actual':y_test, 'Predicted':y_hat})\ndf_scores_comp\n\nAccess method 2:\nBut if I want to use the following way to access X_data and y_data ...\nX_data = df_scores.loc[:, ['Hours']]\ny_data = df_scores.loc[:, ['Scores']]\n\nI get the following error ...\nIf using all scalar values, you must pass an index\n\nWhen using either access method, y_hat is an array and X_data is a dataframe. But y_data is a series using the first access method and a dataframe in the second access method. I thought the clue might be in there somewhere with lm.predict but I can't figure it out.\nWhen I tried the solution offered here (Constructing pandas dataframes...) by wrapping the dictionary in a list, I don't get an error. But the result isn't right: the y_hat (predicted) elements are in the correct column, but are squeezed into one row. And the y_test (Actual) elements and the index values are mixed up in the wrong columns and are squeezed into one row as well. Something like this:\n Actual Predicted\n0 Scores 5 20 2 27 19 69 16... [[16.884144762398048], [33.73226077948985], [7...\n\nIt should look like this (which is does using the first access method):\nActual Predicted\n5 20 16.884145\n2 27 33.732261\n19 69 75.357018\n16 30 26.794801\n11 62 60.491033"
] | [
"python",
"pandas",
"dataframe",
"linear-regression",
"predict"
] |
[
"css fixed position on top within wrapper?",
"I have a #wrapper { margin: 0 auto } centered in the middle. \nI want to align a div.version inside of that wrapper at the top right corner (of this wrapper). So the .version div should still be inside of the #wrapper.\n\nWhich position value do I have to use here?"
] | [
"css",
"wrapper"
] |
[
"How to check within an app if the device is connected to a power supply?",
"I see many reasons why an app should behave different if the device is connected to a power supply, via USB cable ore otherwise.\nFor example, with power on and effectively charging, it could be used as an image viewer, which would be prohibitive if running on battery.\nSo, how to let an app check if power supply is on, and, if the battery is charging or still running low (due to other power consuming processes or perhaps just because it's old and leaking).\nEdit: in view of the comment that points to a method to get noticed of changes of power supply:\nThis is valuable, maybe for other applications, but I'm asking for actual power supply minus battery need for recharging."
] | [
"android",
"battery",
"batterylevel"
] |
[
"Altering data types within a table using SQL command ALTER",
"I have researched how to alter table data types and I understand how to do it but I cannot get it to work. I am trying to update my table Person within APP using the following command:\n\nALTER TABLE APP.PERSON ALTER uName varchar;\n\n\nWhat I have tried so far:\n\n\nusing Modify but realised that, after I received errors, this should indeed be ALTER.\nchanging uName to UNAME.\nchanging it to a data type of varchar2.\nadding in the size of the data type '(20)' and 'NOT NULL' at the end.\n\n\nWhere am I going wrong? I am using Netbeans 7.3 Beta 2 running on Mac OS X, this is all being done within the SQL Commands section of Netbeans, using Java-DB as my database if any of that matters."
] | [
"sql",
"netbeans",
"sqlcommand",
"alter"
] |
[
"\"Undefined\" when trying to reproduce a functional pipe in Javascript",
"I just started studying functional programming today and I am trying to create an example using a pipe:\nconst pipe = (...fns) => x => fns.reduce((acc, f) => f(acc), x)\nconst buffs = [{ power: 5, type: 'SPEED' }, { power: 2, type: 'SPEED' }]\nlet pos = { x: 0, y: 0 }\n\nconst addToPos = pos => amount => ({ ...pos, x: pos.x + amount })\nconst add1ToPos = pos => addToPos(pos)(1)\nconst add2ToPos = pos => addToPos(pos)(2)\nconst addAll = pos => pipe(\n add1ToPos,\n add2ToPos,\n)(pos)\n\npos = addAll(pos)\nconsole.log(pos) // returns { x: 3, y: 0 } as expected\n\nHowever, when I try to add all these powers from buffs inside my pipe, like so:\nconst addAll = pos => pipe(\n add1ToPos,\n add2ToPos,\n addToPos(buffs.reduce((a, b) => a + b.power, 0))\n)(pos)\n\nI get\n{ x: undefined[object Object] }\n\nI really don't know why this is happening since this works perfectly:\nconst numbers = [{ num: 4, color: 'blue' }, { num: 5, color: 'red' }]\nlet total = 0\n\nconst addToTotal = total => amount => total + amount\nconst add1ToTotal = total => addToTotal(total)(1)\n\nconst addAll = total => pipe(\n add1ToTotal,\n addToTotal(numbers.reduce((a, b) => a + b.num, 0))\n)(total)\n\ntotal = addAll(total) // returns 10 as expected\n\nWhat am I doing wrong?"
] | [
"javascript",
"functional-programming",
"undefined"
] |
[
"What's the best way to add colored-sytax code snippets to a web page?",
"Is there a web gadget or service or some open source solution for doing this?\n\nOr do people just hand-code this in the HTML?\n\nI need to add some Ruby and Python code to a web page."
] | [
"html",
"web",
"syntax-highlighting"
] |
[
"How can I limit the rows to one in database?",
"I have a table named profit model:\n\nI would like to active different profitmodel, and the data in table will be updated.\n\nNow I am using UpdateAsync, but it doesn't work... How can I achieve this?\n\nasync void Active_Clicked(object sender, System.EventArgs e)\n {\n var profitmodel = (sender as Button).CommandParameter as ProfitModel;\n\n await conn.CreateTableAsync<ProfitModelInUsed>();\n\n //System.Diagnostics.Debug.WriteLine(product.ProductName);\n\n var profitmodelInUsed = new ProfitModelInUsed\n {\n ProfitModel_ID = profitmodel.ProfitModel_ID,\n ProfitModel_Name = profitmodel.ProfitModel_Name,\n ExchangeRate = profitmodel.ExchangeRate,\n Profit = profitmodel.Profit\n };\n\n await conn.UpdateAsync(profitmodelInUsed);\n\n await DisplayAlert(\"This ProfitModel is Applied\", profitmodelInUsed.ProfitModel_Name, \"OK\");\n }\n\n\nAnd I don't want to have more than one rows in this table."
] | [
"xamarin",
"sqlite",
"xamarin.forms"
] |
[
"I want to upload image on localhost with text and delete or search that using searchbar",
"I have implemented the uploading image and showing the image on a webpage. I want to add some text description with it while uploading and after uploading that, from the search bar, I want to search the image description. For example if I upload 4 images:\n\n\n 1st image with abc text\n 2nd image with agh text\n 3rd image with xyz text\n 4th image with aaa text\n\n\nAfter entering a in search input text, it should show 1,2 and 4 images, it should hide 3rd images.\n\nvar get = function(id) {\n return document.getElementById(id);\n}\n\nvar uploadedImg = uploadedImg || {};\nuploadedImg.handleFileSelect = function(evt) {\n var files = evt.target.files; // FileList object.\n\n // Loop through the FileList and render image files as thumbnails.\n for (var i = 0, f; f = files[i]; i++) {\n\n // Only process image files.\n if (!f.type.match('image.*')) {\n continue;\n }\n\n var reader = new FileReader();\n\n //closure to capture the file information.\n reader.onload = (function(theFile) {\n return function(e) {\n // Render thumbnail.\n var span = document.createElement('span');\n span.innerHTML = ['<img class=\"thumb\" src=\"', e.target.result, '\" title=\"', escape(theFile.name), '\"/>'].join('');\n get('thumbnails').insertBefore(span, null);\n };\n })(f);\n\n // Read in the image file as a data URL.\n reader.readAsDataURL(f);\n }\n}\nget('imageUploaded').addEventListener('change', uploadedImg.handleFileSelect, false);\n\n\nhttps://jsfiddle.net/mohitpatil/c6vrag5z/3/"
] | [
"javascript",
"jquery",
"html",
"image"
] |
[
"How to restore accidentally deleted code block (chunk) in visual studio code notebook",
"I accidentally deleted my code block or chunk in visual studio code. Unfortunately I didn't connect it to my github. Can anyone please help me how I can retract my code? Is it possible to undo my deletion. CTRL+Z doesnt work as i deleted the whole code block or chunk."
] | [
"python",
"visual-studio-code",
"undo"
] |
[
"loop through directory names using a batch file?",
"Assume I have this structure:\n\nd:/\n -- /alpha/\n -- /beta/\n -- /gamma/\n -- /delta/\n\n\nI'm trying to execute a batch file that goes through those folders (but not through sub-folders within them).\n\nHow do I get this result using a FOR LOOP (assuming I don't know the name and quantity of the folders):\n\nren alpha alpha1\nren beta beta1\nren gamma gamma1\nren delta delta1"
] | [
"loops",
"batch-file"
] |
[
"Convert Long number into Date in access vba",
"I am having a field which contains date in the form of number and need to convert into equivalent date for further operations such as checking between the date with other date variables.\n\nFor example : My long number variable is \n\nDim ndate as Long\nndate=20140901\n\n\nI need to get this ndate as date variable such as 01/09/2014 (dd/mm/yyyy)\n\nThanks in advance"
] | [
"date",
"ms-access",
"vba"
] |
[
"It is legal to optimize out memory allocations?",
"Given a program:\n\n#include <cstdlib>\n#include <memory>\n\nbool test() {\n int* ptr = (int *)malloc(sizeof(int));\n bool result = ptr != nullptr;\n free(ptr);\n return result;\n}\n\nbool test2() noexcept {\n int * ptr;\n try {\n ptr = new int;\n }\n catch (const std::bad_alloc&) {\n return false; \n }\n bool result = ptr != nullptr;\n delete ptr;\n return result;\n}\n\nint main()\n{\n return test();\n}\n\n\nClang optimizes both functions to simple \n\n{\n return true;\n}\n\n\nSee on godbolt. GCC 6.1 does not do this. Clang do this even with -O1 level of optimization.\n\nIs it legal in terms of C++ Standard?"
] | [
"c++",
"memory",
"compiler-optimization"
] |
[
"What does NotImplementedError mean in pypy for numpy.load() method?",
"My question is about a Pypy error. Totay I intended to start using pypy. However when I run my former python code it gave me a strange error message. \nHere is my code:\n\nimport numpy as np\n\nk = np.load('alldata.npy')\n\nprint k.shape\n\n\nwhen I use python2 ./p.py it gives me; \n\n(942962, 64) however when I run my code with pypy ./p.py it gives me this:\n\nTraceback (most recent call last):\n File \"./p.py\", line 5, in <module>\n k = np.load('bA1024.npy')\n File \"/usr/local/lib/pypy2.7/dist-packages/numpy/lib/npyio.py\", line406, in load\n pickle_kwargs=pickle_kwargs)\n File \"/usr/local/lib/pypy2.7/dist-packages/numpy/lib/format.py\", line 649, in read_array\n array = numpy.fromfile(fp, dtype=dtype, count=count)\n File \"/usr/local/lib/pypy2.7/dist- packages/numpy/core/multiarray.py\", line 83, in tmp\n raise NotImplementedError(\"%s not implemented yet\" % func)\nNotImplementedError: fromfile not implemented yet"
] | [
"python",
"pypy"
] |
[
"Apple review: section 11.14 of review guidelines to play content",
"I have developed an app containing medical documents. This app is going to be distributed through the app store for free. \n\nThe app can not be used by everyone, but it can be used only by doctors. For this reason I have put a form in the home screen of the app asking for a password. This password will be distributed for free by e-mail to all doctors, together with a link to Apple Store asking them to download the app.\n\nI have submitted app for review, but it has been rejected for this reason:\n\"We found your app inappropriately unlocks or enables additional functionality with mechanisms other than the App Store, which is not in compliance with the App Store Review Guidelines.\nSpecifically, we found that your app requires a code in order to work.\nIt would be more appropriate to revise or remove this feature.\"\n\nAfter some messages sent to review team, they have confirmed that app is in compliance with section 11.14 of review guidelines \n\n\"11.14 Apps can read or play approved content (specifically magazines, newspapers, books, audio, music, and video) that is subscribed to or purchased outside of the App, as long as there is no button or external link in the App to purchase the approved content. Apple will not receive any portion of the revenues for approved content that is subscribed to or purchased outside of the App\"\n\nbut not with section 11.1 \"11.1 Apps that unlock or enable additional features or functionality with mechanisms other than the App Store will be rejected\"\n\nSo, my question is: how can I let user read or play reserved content without using a password or code? Please not that the content is free, it does not need to be purchased outside the app."
] | [
"ios",
"app-store",
"appstore-approval"
] |
[
"Create a queue to send data to PHP server from Android",
"There I am getting data from SQLite and send it to the server using Volley.\nfor now, I am sending all the data at a time.\nI just want to know how can I create a queue that first data of one vehicle, gets its response and then send another one.\n\ncursor=helperClass.readAllData();\n if (cursor!=null)\n {\n while (cursor.moveToNext())\n {\n modelClass=new ModelClass(cursor.getInt(0),cursor.getString(1),\n cursor.getString(2),cursor.getString(3),\n cursor.getString(4),cursor.getString(5));\n modelClasses.add(modelClass);\n }\n\n sizeOfArray=modelClasses.size();\n\n for (int i=0; i<sizeOfArray;i++)\n {\n name = modelClasses.get(i).getName();\n model=modelClasses.get(i).getModelName();\n number=modelClasses.get(i).getEngineNumber();\n image=modelClasses.get(i).getImageBase64();\n hdimage=modelClasses.get(i).getHdimageBase64();\n uploadData(name, model, number, image, hdimage);\n Toast.makeText(UploadDataServiceClass.this, String.valueOf(sizeOfArray), Toast.LENGTH_SHORT).show();\n Toast.makeText(UploadDataServiceClass.this, String.valueOf(i), Toast.LENGTH_SHORT).show();\n }\n\n }\n\n\nuploadData(name,model,number,image,hdimage)\n\n RequestQueue requestQueue=Volley.newRequestQueue(UploadDataServiceClass.this);\n StringRequest stringRequest=new StringRequest(Request.Method.POST, showURL, new Response.Listener<String>()\n {\n @Override\n public void onResponse(String response)\n {\n try\n {\n Log.d(TAG, \"onResponse: \" + response);\n JSONObject jsonObject = new JSONObject(response);\n\n }\n catch (JSONException e)\n {\n e.printStackTrace(); \n }\n }\n }, new Response.ErrorListener()\n {\n @Override\n public void onErrorResponse(VolleyError error)\n { }\n }\n )\n {\n @Override\n protected Map<String, String> getParams()\n {\n Map<String, String> parameters = new HashMap<String, String>();\n parameters.put(\"name\", name);\n parameters.put(\"model\", model);\n parameters.put(\"number\", number);\n parameters.put(\"image\", image);\n parameters.put(\"hdimage\", hdimage);\n parameters.put(\"crud_type\", \"insert\");\n return parameters;\n }\n };\n requestQueue.add(stringRequest);"
] | [
"android",
"android-volley"
] |
[
"How do you create SPSS syntax files (.sps) using a system other then SPSS?",
"I have a python script that generates text files containing SPSS syntax. Currently I have to copy the syntax from the text file and paste into an empty .sps file in order to run the syntax. I need to automatically generate .sps files, either using a python script, or any other automated method, because I have thousands of analyses to run.\n\nI tried to generate a single large SPSS syntax file via my python script and then paste that into a single SPSS syntax file, but that doesn't solve the issue because the resulting syntax file is to large and crashes SPSS, so I need to be able to create multiple seperate files.\n\nHow do you create SPSS syntax files (.sps) outside of the SPSS GUI?"
] | [
"python",
"spss"
] |
[
"updating a column with avg data from another table column",
"i wrote a command like this to update a column in one table with avg of columns from another table.. its giving errors \n\nUPDATE college_rating,products set \nproperty1_avg = avg(college_rating.rating1),\nproperty2_avg = avg(college_rating.rating2),\nproperty3_avg = avg(college_rating.rating3),\nproperty4_avg = avg(college_rating.rating4),\nproperty5_avg = avg(college_rating.rating5),\nproperty6_avg = avg(college_rating.rating6),\nproperty7_avg = avg(college_rating.rating7),\nproperty8_avg = avg(college_rating.rating8),\nproperty9_avg = avg(college_rating.rating9),\nproperty10_avg = avg(college_rating.rating10),\nproperty11_avg = avg(college_rating.rating11),\nproperty12_avg = avg(college_rating.rating12),\nproperty13_avg = avg(college_rating.rating13),\nproperty14_avg = avg(college_rating.rating14),\nproperty15_avg = avg(college_rating.rating15) \nwhere products.alias = concat(college_rating.property1,'-',college_rating.property2,'-',college_rating.property3) \ngroup by college_rating.property1,college_rating.property2, college_rating.property3"
] | [
"mysql"
] |
[
"Dynamic programming Topdown approach - minimum cost in a matrix (in python)",
"I have to implement some functions in python to find the minimum cost in a matrix.We must go down or right and to an adjacent number so at each step we have only two possible choices.\n\ni wrote the fisrt version (naive one) which works:\n\ndef minimal_trajectorry_helper(matrix, m, n):\n if ( (n > len(matrix) -1 ) or (m > len(matrix) -1)):\n return 1000000000\n\n elif ((m == len(matrix) - 1) and (n == len(matrix) - 1)):\n return matrix[m][n]\n\n else:\n result = matrix[m][n] + min(minimal_trajectorry_helper(matrix, m+1, n),\n minimal_trajectorry_helper(matrix, m, n+1) )\n return result\n\n\nBut when i want to optimize it using memoization i can't find the right answer.\nI tried different ways but i wasn't able to do it correctly. Here is what i wrote:\n\ndef dptd_minimal_trajectorry_helper(matrix, m, n, track):\n if ( (n > len(matrix) -1 ) or (m > len(matrix) -1)):\n return 1000000000\n\n elif ((m == len(matrix) - 1) and (n == len(matrix) - 1)):\n return matrix[m][n]\n\n elif (track[m][n] != -1):\n return track[m][n] \n\n else:\n result = matrix[m][n] + min(dptd_minimal_trajectorry_helper(matrix, m+1, n, track),\n dptd_minimal_trajectorry_helper(matrix, m, n+1, track) \n track[m][n] = result\n return result\n\n\nHere is an example :\n\n [2,3,1,1,6]\n [1,4,4,1,4]\n [7,1,2,2,5]\n [2,1,3,8,3]\n [2,4,3,2,1]\n\n\nThe naive version gives me the right anwser which is 18 -> 2,1,4,1,1,3,3,2,1\nBut the second one gives me 12\n\nThanks in advance for any help :) \n\nEDIT : I call the naive version like minimal_trajectorry_helper(matrix, 0, 0) and the optimized one like dptd_minimal_trajectorry_helper(matrix, m, n, track) where track is initialized by : track = [[-1]*5]*5"
] | [
"python",
"dynamic",
"memoization",
"topdown",
"top-down"
] |
[
"imap: decode file name from attachment",
"How to decode file name from attachement in email?\n\nIf the filename contains special charactors it looks something like this..\n\nISO-8859-1''%56%61%72%65%6B%F8%62%20%45%55%20%2D%20%4D%61%78"
] | [
"php",
"imap"
] |
[
"Nifi, CSV to Avro ValidateRecord - routing flowfile to failure because of double quote in field value",
"I am trying to validate CSV to Avro using ValidateRecord processor. The Record Reader property of ValidateRecord processor is set to CSVReader controller service. Quote Character is set as double quotes (\") for this CSVReader controller service.\n\nWhen I try to validate flowfiles, few of the flowfiles are redirecting to failure relationship because of double quotes present in field value. \n\nSample csv row from flowfile content :\n\n\"ICUA\",\"01/22/2019\",\"08:48:18\",394846,\"HAVE YOU REMOVED THE KEY?\",\"YES---select \"Accept Response\" and continue with the remove\",\"\",\"\",\"1\"\n\nI thought to use ReplaceText but this would tamper the actual value of the field. \n\nIt would be really helpful if somebody could provide the approach to deal with this situation. \n\nThanks!"
] | [
"apache-nifi"
] |
[
"ANTLR4 lexer rules don't work as expected",
"I want to write a lexer rule about the month and the year, the rule is(with regular expression):\n\n\"hello\"[0-9]{1,2}\"ever\"([0-9]{2}([0-9]{2})?)?\n\n\nthe \"hello\" and \"ever\" literals are just for debuging.\n\nthat's say, one or two digits for month, and two or four digits for year. And what's more, the year part could be bypass.\n\nsuch as:\n Aug 2015 ->hello08ever2015 or hello8ever2015 or hello8ever15 or hello8ever or hello08ever; \n Oct 2015 -> hello10ever2015 or hello10ever15 or hello10ever;\n\nand my lexer rules are as follow(ANTLR4):\n\ngrammar Hello;\nr : 'hello' TimeDate 'ever' TimeYear? ; \n\nTimeDate : Digit Digit?;\n\nTimeYear : TwoDigit TwoDigit?;\n\nTwoDigit : Digit Digit;\n\nDigit : [0-9] ; \n\nWS : [ \\t\\r\\n]+ -> skip ; // skip spaces, tabs, newlines\n\n\nBut it seems not working.\nHere're some logs for my testing:\n\nC:\\antlr\\workspace\\demo>java org.antlr.v4.runtime.misc.TestRig Hello r -tree -gui\nhello20ever2014\n^Z\n(r hello 20 ever 2014)\n\nC:\\antlr\\workspace\\demo>grun Hello r -tree -gui\n\nC:\\antlr\\workspace\\demo>java org.antlr.v4.runtime.misc.TestRig Hello r -tree -gui\nhello2ever20\n^Z\n(r hello 2 ever)\n\nC:\\antlr\\workspace\\demo>grun Hello r -tree -gui\n\nC:\\antlr\\workspace\\demo>java org.antlr.v4.runtime.misc.TestRig Hello r -tree -gui\nhello20ever14\n^Z\n(r hello 20 ever)\n\nC:\\antlr\\workspace\\demo>grun Hello r -tree -gui\n\nC:\\antlr\\workspace\\demo>java org.antlr.v4.runtime.misc.TestRig Hello r -tree -gui\nhello2ever2014\n^Z\n(r hello 2 ever 2014)\n\n\nfor input: hello2ever20, it can't identify the year part '20';\nfor input: hello20ever14, it can't identify the year part '14';\n\nAnyone could help on this???\n\nthanks!!"
] | [
"antlr4"
] |
[
"different cases about using List(List[A]()) and List[List[A]]() in scala?",
"I was trying scala-99 P09.\n\nThe answer given by author is:\n\nobject P09 {\n def pack[A](ls: List[A]): List[List[A]] = {\n if (ls.isEmpty) List(List())\n else {\n val (packed, next) = ls span { _ == ls.head }\n if (next == Nil) List(packed)\n else packed :: pack(next)\n }\n }\n}\n\n\nIt gives that:\n\npack(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e))\n// res0: List[List[Symbol]] = List(List('a, 'a, 'a, 'a), List('b), List('c, 'c), List('a, 'a), List('d), List('e, 'e, 'e, 'e))\n\n\nand \n\npack(List[Int]()) // => res1: List[List[Int]] = List(List())\n\n\nBut, I think it should be List[List[Int]] = List()\n\nFor what reason, the author makes it return List(List()) instead of List()?\n\nAdded\n\nToday, I come across P26(Generate the combinations of K distinct objects chosen from the N elements of a list.), which I gave the following solution at first:\n\ndef combinationsOf[A](n: Int, ls: List[A]): List[List[A]] = {\n if (n < 0 || n > ls.length) throw new IllegalArgumentException\n else if (n == 0) List.empty[List[A]]\n else if (n == ls.length) List(ls)\n else combinationsOf(n - 1, ls.tail).map(ls.head :: _) ::: combinationsOf(n, ls.tail)\n}\n\n\nBut when given K = 3, and List(1,2,3,4), It only outputs (1,2,4), (1,3,4), (2,3,4), which is wrong. I know what's wrong in my code. So I make it right:\n\ndef combinationsOf[A](n: Int, ls: List[A]): List[List[A]] = {\n if (n < 0 || n > ls.length) throw new IllegalArgumentException\n else if (n == 0) List(Nil)\n else if (n == ls.length) List(ls)\n else combinationsOf(n - 1, ls.tail).map(ls.head :: _) ::: combinationsOf(n, ls.tail)\n}\n\n\nWhat I cannot understand stands still. Why List(Nil) is needed when List() seems to be more suitable ?"
] | [
"scala"
] |
[
"h5p Interactive Content and Video Display in Flutter",
"I am trying to display and implement Interactive Content and Interactive Video and Quiz. But I can't able any way in the flutter platform. I have also checked the dart package but I didn't found anyone support package like the H5P. Anyone know then please suggest me and help me.\nThank you in advance"
] | [
"flutter",
"dart"
] |
[
"How send a structure through fifo",
"HI!\n\nI am trying to pass whole structure from one program and read it in another using fifo. \nI'm using read and write functions. I had a problem with putting my structure into this functions. When I did it and tried to send and receive I get an error (core dump) or I recived some trash. I dont know exactly, where my problem take place (in receiver or sender). How can I send/receive my structure, or what i have wrong in my code.Here is my code...Receiver\n\nstruct data\n{\n char* message;\n int size;\n vector <times> prog;\n};\n\nint if_fifo(char* name)\n{\n struct stat info;\n int score = stat(name,&info);\n if(S_ISFIFO(info.st_mode))\n {\n return 1;\n }\n else\n {\n return 0;\n }\n}\n\nint fifo_in(char* name)\n{\n data msg;\n int pip;\n pip = open(name, O_RDONLY | O_NONBLOCK);\n while(1)\n {\n int hr = read(pip,&msg,sizeof(msg));\n if(hr != 0)\n {\n cout << \"Message: \" << msg.message << endl;\n }\n }\n cout << \"O.K.\" << endl;\n return 0;\n}\n\nint main(int argc, char** argv) {\nint c, status_in, status_out;\nchar* input;\nchar* output;\nfloat del;\n\nif(argc < 5)\n{\n cout << \"Za malo podanych parametrow\" << endl;\n return 1;\n}\nelse\n{\n while ((c = getopt(argc, argv, \"iod:\")) != -1)\n {\n switch (c)\n {\n case 'i':\n input = argv[2];\n status_in = if_fifo(input);\n break;\n case 'o':\n output = argv[3];\n status_out = if_fifo(output);\n break;\n case 'd':\n del = atof(argv[4]);\n break;\n case '?':\n printf(\"UKNOWN\");\n }\n }\n}\n\nif(status_in == 1)\n{\n return fifo_in(input);\n}\nelse\n{\n cout << \"It isnt fifo!!\" << endl;\n}\n\nreturn 0;\n}\n\n\nAnd sender:\n\nstruct data\n{\n char* message;\n int size;\n vector <times> prog;\n}msg;\n\nint if_fifo(char* name)\n{\n struct stat info;\n int score = stat(name,&info);\n if(S_ISFIFO(info.st_mode))\n {\n return 1;\n }\n else\n {\n return 0;\n }\n}\n\nint fifo_out(char* name)\n{\n msg.message = \"To jest to!!\";\n msg.size = sizeof(msg.message);\n int pip;\n pip = open(name, O_WRONLY);\n if( pip == -1 )\n {\n perror(\"Error: open( ): \");\n return 1;\n }\n write(pip,&msg,sizeof(msg));\n return 0;\n}\n\nint main(int argc, char** argv) {\n int c, status_out;\n char* output;\n\n if(argc < 3)\n {\n cout << \"Za malo podanych parametrow\" << endl;\n return 1;\n }\n else\n {\n while ((c = getopt(argc, argv, \"o:\")) != -1)\n {\n switch (c)\n {\n case 'o':\n output = argv[2];\n status_out = if_fifo(output);\n break;\n case '?':\n printf(\"UKNOWN\");\n }\n }\n }\n\n if(status_out == 1)\n {\n return fifo_out(output);\n } \n return 0;\n}"
] | [
"c++",
"linux",
"fifo"
] |
[
"What are reasons for Durandal/Hot Towel template setting body max-width to 1100px when using Bootstrap fluid styles?",
"It's noticeable when using the \"Hot Towel\" SPA template with Durandal that the views sit in a middle window that's 1100 pixels in width rather than using all the available space.\n\nAnd yet all the views within the applicationHost are set to use the Bootstrap from Twitter \"fluid\" styles. Effectively a hard-coded max-width set on the body tag is making all these fluid styles redundant and rather meaningless.\n\nIt's easy enough to over-ride the body style set in app.css (assumming there will be no side effects to setting it to a ridiculously high value) but I was just wondering if anybody knew the reason for setting it this way in the template, given that it's undoing all the good work of trying to implement a responsive design that all those Bootstrap \"*-fluid\"styles are trying to implement."
] | [
"css",
"durandal",
"hottowel"
] |
[
"Add new SalesLine to existing SalesOrder - MS Dynamics AX 2012 - AIF (C#)",
"I need to add SalesLine to an existing SalesOrder. SalesOrder do not have any SalesLine yet. I am using AIF in CSharp (C#). I am using following code but I am getting following exceptions (checked through Dynamics AX Exceptions window) .\n\n\nError found when validating record. \nUpdate has been canceled.\n\n\nHere is my code.\n\nprotected void Page_Load(object sender, EventArgs e)\n{\n try\n {\n SalesOrderCreateReadFindUpdateDelete.KeyField keyField = new SalesOrderCreateReadFindUpdateDelete.KeyField() { Field = \"SalesId\", Value = \"SO-015749\" };\n SalesOrderCreateReadFindUpdateDelete.EntityKey entityKey = new SalesOrderCreateReadFindUpdateDelete.EntityKey();\n entityKey.KeyData = new SalesOrderCreateReadFindUpdateDelete.KeyField[1] { keyField };\n SalesOrderCreateReadFindUpdateDelete.EntityKey[] entityKeys = new SalesOrderCreateReadFindUpdateDelete.EntityKey[1] { entityKey };\n SalesOrderCreateReadFindUpdateDelete.SalesOrderServiceClient _Client;\n using (_Client = new SalesOrderCreateReadFindUpdateDelete.SalesOrderServiceClient())\n {\n SalesOrderCreateReadFindUpdateDelete.CallContext _callContext = new SalesOrderCreateReadFindUpdateDelete.CallContext();\n _callContext.Company = \"ART\";\n SalesOrderCreateReadFindUpdateDelete.AxdSalesOrder _SalesOrderList = _Client.read(_callContext, entityKeys);\n SalesOrderCreateReadFindUpdateDelete.AxdEntity_SalesTable _SalesOrderTable = _SalesOrderList.SalesTable.First();\n SalesOrderCreateReadFindUpdateDelete.AxdEntity_SalesLine salesLine = new SalesOrderCreateReadFindUpdateDelete.AxdEntity_SalesLine();\n\n salesLine.ItemId = \"PF507028\";\n salesLine.SalesQty = 1;\n salesLine.SalesUnit = \"ea\";\n salesLine.SalesId = \"SO-015749\";\n salesLine.RecId = _SalesOrderTable.RecId;\n salesLine.RecVersion = _SalesOrderTable.RecVersion;\n\n SalesOrderCreateReadFindUpdateDelete.AxdEntity_InventDim inventDim = new SalesOrderCreateReadFindUpdateDelete.AxdEntity_InventDim();\n inventDim.InventSiteId = \"1\";\n inventDim.InventLocationId = \"13\";\n\n salesLine.InventDim = new SalesOrderCreateReadFindUpdateDelete.AxdEntity_InventDim[1] { inventDim };\n _SalesOrderTable.SalesLine = new SalesOrderCreateReadFindUpdateDelete.AxdEntity_SalesLine[1] { salesLine };\n\n _Client.update(_callContext, entityKeys, _SalesOrderList);\n lblOutput.Text += \"<br />Success\";\n }\n }\n catch (Exception ex)\n {\n lblOutput.Text += \"<br />Exception: \" + ex.Message;\n }\n}\n\n\nAm I missing something or doing something wrong? If I have to provide more fields then where can check these required fields in MS Dynamics. I am new to MS Dynamics.\n\nPlease Help! Thank you."
] | [
"c#",
"web-services",
"microsoft-dynamics",
"dynamics-ax-2012",
"aif"
] |
[
"Not Found (#404) Page not found.Yii2",
"Hello I have some issue with redirecting in Yii 2 , I have\n\n ['label' => 'Home', 'url' => ['/site/index']],\n ['label' => 'About', 'url' => ['/site/about']],\n ['label' => 'Contact', 'url' => ['/site/contact']],\n ['label' => 'Tractor Models', 'url' => ['#']],\n ['label' => 'Components', 'url' => ['#']],\n ['label' => 'Users', 'url' => ['/loginuser/index']],\n\n\nand I have file that is made in LoginUser folder that have index , generated by Gii ,and the redirecting dont work,I I have problem with trying to \"redirect\" and other pages that I want . Can someone give me some clue about that problem ?"
] | [
"php",
"url",
"yii2"
] |
[
"Initilizing Add-in Application when creating excel add-in in c#",
"I am creating an Excel Add-Ins for Office 2010.\nEarlier i was doing code in Visual Studio 2010, .net framework 3.5 on ThisAddIn_Startup like\n\nprivate void ThisAddIn_Startup(object sender, System.EventArgs e)\n{\n this.Application = (Excel.Application)Microsoft.Office.Tools.Excel.\n ExcelLocale1033Proxy.Wrap(typeof(Excel.Application), this.Application);\n\n CreateCommandBar();\n}\n\n\nBut now the project is shifted on .net framework 4.0 then ExcelLocale1033Proxy is obsolete here.\n\nWhat should i use here?\nPlease guide."
] | [
"c#",
"excel"
] |
[
"How play a private track with soundcloud Javascript SDK",
"I have a problem with my privates tracks. I have public track and privates tracks in my soundcloud account. When a track is public is correcte, but when i'm a private track the api return an 404 error :\nGET http://api.soundcloud.com/tracks/123?client_id=xxxxx&format=json&_status_code_map[302]=200 404 (Not Found) in my console. \n\nHere my function for to play a track :\n\n// Play a Single track \n$('#app').on('click','.play_btn_single',function(event){\n event.preventDefault();\n var el = $(this);\n var id = el.attr('id');\n\n\n SC.stream('/tracks/'+id,function(sound){\n sound.play();\n });\n\n\n});\n\n\nThank you of your help."
] | [
"javascript",
"api",
"soundcloud"
] |
[
"How to have multiple groups by user",
"How to have different groups for a user\n\nwith one user and one group, I have the test :\n\nungroupe = Group.objects.get(user= current_user)\n\n\nHow to do the test if I have one user and two groups ?"
] | [
"django"
] |
[
"Subviews added with storyboard over hand-added subviews?",
"I have a little issue about subviews with x-code with storyboards.\n\nI want to do a little application with balls. You have to click on them and they simply disappear.\nI also wanted to have a pause menu.\n\nSo i made a viewController with 1 view (the general view), 1 subview (the pause menu), made with the storyboard (so i don't see them in the code)\n\nI wanted to had a EAGLView in this viewController so i did this:\n\nself.director = [CCDirector sharedDirector];\nself.myglView = [EAGLView viewWithFrame:CGRectMake(0, 60, 320, 420)\n pixelFormat:kEAGLColorFormatRGBA8\n depthFormat:0 \n preserveBackbuffer:NO\n sharegroup:nil\n multiSampling:NO\n numberOfSamples:0 ];\n}\n\n[self.director setOpenGLView:self.myglView];\n\nglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);\nglClearColor(0.0, 0.0, 0.0, 0.0);\nglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\nself.myglView.opaque = NO;\nself.myglView.backgroundColor = [UIColor clearColor];\n[self.view addSubview:self.myglView];\n\n\nI added some body(balls) in the 2D world created in this eaglview, this is working but now when i want to put the game on pause.\n\nI make \"pop\" the pause menu with this:\n\nself.pauseView.hidden = false;\n\n\nthe pause menu appear but all the balls are ON the pause menu :/\n\nSomeone see what my issue is ? ^^'\nIs there something like layers or priority subviews ?\n\nThanks a lot for reading and helping me :)"
] | [
"iphone",
"objective-c",
"ios",
"xcode",
"storyboard"
] |
[
"tm Bigrams workaround still producing unigrams",
"I am trying to use tm's DocumentTermMatrix function to produce a matrix with bigrams instead of unigrams. I have tried to use the examples outlined here and here in my function (here are three examples):\n\nmake_dtm = function(main_df, stem=F){\n tokenize_ngrams = function(x, n=2) return(rownames(as.data.frame(unclass(textcnt(x,method=\"string\",n=n)))))\n decisions = Corpus(VectorSource(main_df$CaseTranscriptText))\n decisions.dtm = DocumentTermMatrix(decisions, control = list(tokenize=tokenize_ngrams,\n stopwords=T,\n tolower=T,\n removeNumbers=T,\n removePunctuation=T,\n stemming = stem))\n return(decisions.dtm)\n}\n\nmake_dtm = function(main_df, stem=F){\n BigramTokenizer = function(x) NGramTokenizer(x, Weka_control(min = 2, max = 2))\n decisions = Corpus(VectorSource(main_df$CaseTranscriptText))\n decisions.dtm = DocumentTermMatrix(decisions, control = list(tokenize=BigramTokenizer,\n stopwords=T,\n tolower=T,\n removeNumbers=T,\n removePunctuation=T,\n stemming = stem))\n return(decisions.dtm)\n}\n\nmake_dtm = function(main_df, stem=F){\n BigramTokenizer = function(x) unlist(lapply(ngrams(words(x), 2), paste, collapse = \" \"), use.names = FALSE)\n decisions = Corpus(VectorSource(main_df$CaseTranscriptText))\n decisions.dtm = DocumentTermMatrix(decisions, control = list(tokenize=BigramTokenizer,\n stopwords=T,\n tolower=T,\n removeNumbers=T,\n removePunctuation=T,\n stemming = stem))\n return(decisions.dtm)\n}\n\n\nRather unfortunately, however, each of these three versions of the function produces the exact same output: a DTM with unigrams, rather than bigrams (image included for simplicity):\n\n\n\nFor your convenience, here is a subset of the data that I am working with:\n\nx = data.frame(\"CaseName\" = c(\"Attorney General's Reference (No.23 of 2011)\", \"Attorney General's Reference (No.31 of 2016)\", \"Joseph Hill & Co Solicitors, Re\"),\n \"CaseID\"= c(\"[2011]EWCACrim1496\", \"[2016]EWCACrim1386\", \"[2013]EWCACrim775\"),\n \"CaseTranscriptText\" = c(\"sanchez 2011 02187 6 appeal criminal division 8 2011 2011 ewca crim 14962011 wl 844075 wales wednesday 8 2011 attorney general reference 23 2011 36 criminal act 1988 representation qc general qc appeared behalf attorney general\", \n \"attorney general reference 31 2016 201601021 2 appeal criminal division 20 2016 2016 ewca crim 13862016 wl 05335394 dbe honour qc sitting cacd wednesday 20 th 2016 reference attorney general 36 criminal act 1988 representation\",\n \"matter wasted costs against company solicitors 201205544 5 appeal criminal division 21 2013 2013 ewca crim 7752013 wl 2110641 date 21 05 2013 appeal honour pawlak 20111354 hearing date 13 th 2013 representation toole respondent qc appellants\"))"
] | [
"r",
"tm",
"n-gram"
] |
[
"Getting result from SQL Server Stored Procedure",
"I need to get the result from a stored procedure in a MSSQL Server database. I tried different ways:\n\n\nUsing a Table Input Step, with this query: exec dbo.storedproc @param1 = 5, @param2 = 12, @param3 = null, @param4 = null, @param5 = '2017/08/29', @param6 = 1. When I right click on it -> Show output fields, it shows me the output fields from the stored procedure, but I don't know how to get the results and dump them into another table.\nUsing the Call DB Procedure step. With this one, I set up the input parameters, and tried to pass them through a Generate Rows step. But, With this one I don't even get the output parameters. \n\n\nPlease help me figure out how to do this.\nWith regards,"
] | [
"pentaho",
"pentaho-spoon",
"data-integration",
"pentaho-data-integration"
] |
[
"JDL: Found groupable relationship \"OneToOne\"",
"I am new to JHipster and am creating a new project with the following Entity definition:\n\nenum AccountType {\n CHECKING, SAVINGS\n}\n\nenum TransactionType {\n CHECK, DEPOSIT, WITHDRAWAL\n}\n\nenum EnvelopeType {\n INCOME, EXPENSE\n}\n\n// The name 'Account' is a reserved keyword and can not be used as an entity class name.\nentity Ledger {\n name String required\n type AccountType\n memo String\n accountNumber String\n routingNumber String\n}\n\nentity Envelope {\n name String required\n type EnvelopeType\n memo String\n}\n\nentity Transaction {\n name String required\n type TransactionType\n memo String\n amount BigDecimal\n}\n\nrelationship OneToOne {\n Transaction to Envelope\n}\n\nrelationship OneToMany {\n Ledger to Transaction\n}\n\n\nWithin VS Code, I get the following warnings:\n\n\nFound groupable relationship \"OneToOne\"\nFound groupable relationship \"OneToMany\"\n\n\nIt is unclear what each of these relationships can be grouped with to quash the warnings."
] | [
"visual-studio-code",
"jhipster",
"jdl"
] |
[
"wp_insert_attachment not uploading images to Media Library or Uploads Folder",
"Im trying to creating my own custom image/file uploader on the front-end of my WordPress site. When I upload a file it gets to my database just fine but in the Media Library the file doesn't upload fully and when I check my wp-content/uploads folder nothing is there how do I correct this.\n\nImage of file in Media Library \nunfinished upload file in Media Library\n\n<form method=\"post\" enctype=\"multipart/form-data\">\n Select image to upload:\n <input type=\"file\" name=\"img-upload\" id=\"img-upload\" />\n <input type=\"submit\" value=\"Upload Image\" name=\"submit\">\n</form>\n\nrequire_once(ABSPATH . \"wp-admin\" . '/includes/image.php');\nrequire_once(ABSPATH . \"wp-admin\" . '/includes/file.php');\nrequire_once(ABSPATH . \"wp-admin\" . '/includes/media.php');\n\n$image = $_POST['img-upload'];\n$upload_dir = wp_upload_dir();\n\n$file_name = basename($image);\n//$file_data = file_get_contents($file);\n\n$file_dir = $upload_dir['basedir'] . \"/\" . basename($image);\n$file_type = wp_check_filetype($image,null);\n\n$attachment = array(\n 'guid' => $file_dir,\n 'post_mime_type' => $file_type['type'],\n 'post_title' => preg_replace('/\\\\.[^.\\\\s]{3,4}$/', '', $image),\n 'post_content' => '',\n 'post_status' => 'inherit'\n );\n\n$attach_id = wp_insert_attachment( $attachment, $image,0 );\nrequire_once(ABSPATH . 'wp-admin/includes/image.php');\n\n$attach_data = wp_generate_attachment_metadata($attach_id, $file_dir);\nwp_update_attachment_metadata($attach_id, $attach_data);"
] | [
"php",
"html",
"wordpress",
"file-upload"
] |
[
"Salting passwords PHP, MySQL",
"Is the following a good way to salt passwords?\n\nhash('sha256', $_POST['password'], $_POST['email'])\n\n\nI am using the user email as a salt. Some people do not use emails, some others say to use a random number.\n\nEven if I use a random number then I will still need to store it on my MySQL table, so the salt will still be known anyway, and with the added benefit of using emails is that the possibility of rainbow tables is greatly decreased, even if I was to use a 16-bit integer?"
] | [
"php",
"mysql",
"security"
] |
[
"xml tool design problem",
"I have been asked this question at an interview. Ofcourse there are many approaches to the solution but just wanted to know if there is some really best approach that stands out. There is a huge xml file of 2gb that is stored in the hard disk of a low end PC having a 512 mb RAM.\nThe xml file stores timestamps and corresponding string values. I have to design a tool that parses the xml file to get specific information, such as a string in a particular timestamp. The interviewer is not concerned about the searching technique in the tool. He wants to get a high level approach as to the design of the tool, considering only 512mn RAM and only 2GB size of the tool. Are there any interesting design appraches to this ?"
] | [
"java",
"xml",
"cpu",
"ram"
] |
[
"Howto model named parameters in method invocations with Scala macros?",
"There are use cases where it is useful to create a copy of an object which is an instance of a case class of a set of case classes, which have a specific value in common.\n\nFor example let's consider the following case classes:\n\ncase class Foo(id: Option[Int])\ncase class Bar(arg0: String, id: Option[Int])\ncase class Baz(arg0: Int, id: Option[Int], arg2: String)\n\n\nThen copy can be called on each of these case class instances:\n\nval newId = Some(1)\n\nFoo(None).copy(id = newId)\nBar(\"bar\", None).copy(id = newId)\nBaz(42, None, \"baz\").copy(id = newId)\n\n\nAs described here and here there is no simple way to abstract this like this:\n\ntype Copyable[T] = { def copy(id: Option[Int]): T }\n\n// THIS DOES *NOT* WORK FOR CASE CLASSES\ndef withId[T <: Copyable[T]](obj: T, newId: Option[Int]): T =\n obj.copy(id = newId)\n\n\nSo I created a scala macro, which does this job (almost):\n\nimport scala.reflect.macros.Context\n\nobject Entity {\n\n import scala.language.experimental.macros\n import scala.reflect.macros.Context\n\n def withId[T](entity: T, id: Option[Int]): T = macro withIdImpl[T]\n\n def withIdImpl[T: c.WeakTypeTag](c: Context)(entity: c.Expr[T], id: c.Expr[Option[Int]]): c.Expr[T] = {\n\n import c.universe._\n\n val currentType = entity.actualType\n\n // reflection helpers\n def equals(that: Name, name: String) = that.encoded == name || that.decoded == name\n def hasName(name: String)(implicit method: MethodSymbol) = equals(method.name, name)\n def hasReturnType(`type`: Type)(implicit method: MethodSymbol) = method.typeSignature match {\n case MethodType(_, returnType) => `type` == returnType\n }\n def hasParameter(name: String, `type`: Type)(implicit method: MethodSymbol) = method.typeSignature match {\n case MethodType(params, _) => params.exists { param =>\n equals(param.name, name) && param.typeSignature == `type`\n }\n }\n\n // finding method entity.copy(id: Option[Int])\n currentType.members.find { symbol =>\n symbol.isMethod && {\n implicit val method = symbol.asMethod\n hasName(\"copy\") && hasReturnType(currentType) && hasParameter(\"id\", typeOf[Option[Int]])\n }\n } match {\n case Some(symbol) => {\n val method = symbol.asMethod\n val param = reify((\n c.Expr[String](Literal(Constant(\"id\"))).splice,\n id.splice)).tree\n c.Expr(\n Apply(\n Select(\n reify(entity.splice).tree,\n newTermName(\"copy\")),\n List( /*id.tree*/ )))\n }\n case None => c.abort(c.enclosingPosition, currentType + \" needs method 'copy(..., id: Option[Int], ...): \" + currentType + \"'\")\n }\n\n }\n\n}\n\n\nThe last argument of Apply (see bottom of above code block) is a List of parameters (here: parameters of method 'copy'). How can the given id of type c.Expr[Option[Int]] be passed as named parameter to the copy method with the help of the new macro API?\n\nIn particular the following macro expression\n\nc.Expr(\n Apply(\n Select(\n reify(entity.splice).tree,\n newTermName(\"copy\")),\n List(/*?id?*/)))\n\n\nshould result in\n\nentity.copy(id = id)\n\n\nso that the following holds\n\ncase class Test(s: String, id: Option[Int] = None)\n\n// has to be compiled by its own\nobject Test extends App {\n\n assert( Entity.withId(Test(\"scala rulz\"), Some(1)) == Test(\"scala rulz\", Some(1)))\n\n}\n\n\nThe missing part is denoted by the placeholder /*?id?*/."
] | [
"scala",
"scala-macros"
] |
[
"Exiting a tree of recursive calls when a solution is found",
"I have this problem, given a set of numbers S and a number N find some combination of numbers S that sum to N such that the solution uses the minimal amount of numbers. ie minimize |Solution| \n\nSo for example say S = {1000, 500, 250, 100}, and A = 900 then Solution = {500, 100, 100, 100, 100}\n\nThis was my attempt\n\nnumbers = [1000, 500, 250, 100]\namount = 900\n\ndef solve(numbers, amount, sum, solution):\n for num in numbers:\n if sum + num <= amount:\n if sum + num == amount:\n print(solution + [num])\n return\n solve(numbers, amount, sum + num, solution + [num])\n\nsolve(numbers, amount, 0, [])\n\n\nAnd it works! Sort of, I get the right answer and its always the first value I print (Since I ensure the set of numbers is in decreasing order). But the algorithm goes on to print every other correct answer (correct here meaning in sum not minimizing the |Solution|)\n\n\n [500, 100, 100, 100, 100] [250, 250, 100, 100, 100, 100] [250, 100,\n 250, 100, 100, 100] [250, 100, 100, 250, 100, 100] [250, 100, 100,\n 100, 250, 100] [250, 100, 100, 100, 100, 250]\n\n\nand so on\n\nHow could I exit this algorithm when I find the first answer?"
] | [
"python",
"algorithm"
] |
[
"EditText vs TextView",
"I read the API's and see that TextView is a super class to EditText, but I have a short and simple question: Generally speaking, EditText is used when the text displayed is subject to change, whether it's from the user or the app. TextView is used when the text displayed is to be constant/same forever. Is this correct?"
] | [
"android",
"android-edittext",
"textview"
] |
[
"Apache SOLR edisMAX, Multiple keywords and sequence of those keywords yielding different results",
"I am trying to understand the root cause of an issue with my SOLR search query. Below code is SOLRJ client code.\n\nquery.setStart(0);\nquery.setRows(1000);\nquery.set(\"debugQuery\", true);\nquery.set(\"defType\", \"edismax\");\nquery.setQuery(\"title:business OR statistics) OR (name:business OR statistics)\"); \nquery.add(\"fq\", \"bsuiness_id:(101 102)\");\nquery.add(\"tie\", \"0.1\");\nquery.set(\"bq\",\"weight:[0 TO 500]^1 weight:[501 TO 1000]^3\");\n\n\nreturns 200 search results\n\nquery.setStart(0);\nquery.setRows(1000);\nquery.set(\"debugQuery\", true);\nquery.set(\"defType\", \"edismax\");\nquery.setQuery(\"title:statistics OR business) OR (name:statistics OR business)\"); \nquery.add(\"fq\", \"bsuiness_id:(101 102)\");\nquery.add(\"tie\", \"0.1\");\nquery.set(\"bq\",\"weight:[0 TO 500]^1 weight:[501 TO 1000]^3\");\n\n\nreturns 100 search results\n\nMy understanding is keyword \"business statistics\" and \"statistics business\" should yield same results. However, you may notice above that they are not.\n\nCan someone please provide any pointers about what is missing?"
] | [
"solr"
] |
[
"scale to a particular coordinate on HTML5 canvas (Fabric js)",
"i need to zoom to a particular coordinate(X,Y) on the canvas in fabrics js.\n\nI know that there will be 2 functions being called\n1. Scaled (x times)\n2. Move the image to some x,y location so that the image appears to be at that coordinate.\n\nAlso i need that once zoomed in , i specify some other coordinate and it should zoom to that new coordinate. Any tips"
] | [
"javascript",
"canvas",
"html5-canvas",
"fabricjs"
] |
[
"Alternatives to jQuery FlexBox?",
"Are there any good alternatives to jQuery FlexBox? I need the functionality to select from auto-suggest drop down list and input new values like on a textbox."
] | [
"jquery-ui",
"jquery-autocomplete",
"jquery-ui-autocomplete",
"jquery-flexbox"
] |
[
"Codedom Resources File",
"I'm using codedom to build another application, but I get this error:\n\n\n 'Resources' is not a member of 'My' \n\n\nCan you help me ? Thanks"
] | [
"vb.net",
"resources",
"codedom"
] |
[
"Dropdown List multiselection in yii2",
"I need multiselection in dropdown list. \nThis my dropdown list\n\n<?= $form->field($model, 'receiver_id')->dropDownList(\n ArrayHelper::map(User::find()->all(),'id','username'),\n ['prompt' => 'Select receiver...']\n) ?>\n\n\nBut it's only for one receiver. I want to choose some receivers and display them in textfield of this list separated by commas. Could you help with this problem?\nThank you in advance for any help you can provide."
] | [
"php",
"drop-down-menu",
"yii2",
"multi-select"
] |
[
"matplotlibe ticker trouble: MaxNLocator doesnt seem to have the right attributes",
"When I try to run the example script at \nhttp://matplotlib.org/examples/images_contours_and_fields/pcolormesh_levels.html \nin ipython, I get \n\nIn [1]: %run cmap.py\n---------------------------------------------------------------------------\nAttributeError Traceback (most recent call last)\n/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)\n 173 else:\n 174 filename = fname\n--> 175 __builtin__.execfile(filename, *where)\n\n/home/qlnr92/Dropbox/bin/cmap.py in <module>()\n 11 cmap = plt.get_cmap('PiYG')\n 12 \n---> 13 levels = MaxNLocator(nbins=15).tick_values(z.min(), z.max())\n 14 norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)\n 15 \n\nAttributeError: MaxNLocator instance has no attribute 'tick_values'\n\n\nalso \n\nIn [18]: dir(levels)\nOut[18]: \n['DummyAxis',\n'MAXTICKS',\n'__call__',\n'__doc__',\n'__init__',\n'__module__',\n'_integer',\n'_nbins',\n'_prune',\n'_steps',\n'_symmetric',\n'_trim',\n'autoscale',\n'axis',\n'bin_boundaries',\n'create_dummy_axis',\n'default_params',\n'pan',\n'raise_if_exceeds',\n'refresh',\n'set_axis',\n'set_bounds',\n'set_data_interval',\n'set_params',\n'set_view_interval',\n'view_limits',\n'zoom']\n\n\nI'm pretty new to matplotlib so I'm not sure where I'm going wrong. I'm pretty sure all the packages are okay because if I comment out anything containing the levels variable (which is the object to which the output of the tick_values method is assigned) then the plots come out nicely. However, I'd like to know what's going wrong.\n\n(to be on the safe side, here's the slightly edited script i've used in ipython --pylab\n\nimport matplotlib.pyplot as plt\nfrom matplotlib.colors import BoundaryNorm\nfrom matplotlib.ticker import MaxNLocator\nimport numpy as np\n\n\ndx, dy = 0.05, 0.05\n\ny, x = np.mgrid[slice(1, 5 + dy, dy),\n slice(1, 5 + dx, dx)]\n\nz = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)\n\nz = z[:-1, :-1]\nlevels = MaxNLocator(nbins=15).tick_values(z.min(), z.max())\n\ncmap = plt.get_cmap('PiYG')\nnorm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)\n\nplt.subplot(2, 1, 1)\nim = plt.pcolormesh(x, y, z, cmap=cmap, norm=norm)\nplt.colorbar()\nplt.axis([x.min(), x.max(), y.min(), y.max()])\nplt.title('pcolormesh with levels')\n\nplt.subplot(2, 1, 2)\nplt.contourf(x[:-1, :-1] + dx / 2.,\n y[:-1, :-1] + dy / 2., z, levels=levels,\n cmap=cmap)\nplt.colorbar()\nplt.title('contourf with levels')\n\nplt.show()\n\n\n)"
] | [
"python",
"matplotlib"
] |
[
"Linking problems using JsonCpp and Boost",
"I have a project and I need to work with JsonCpp and boost/thread in VS2010\nBut I have a problem with linking:\n\n\nJsonCpp need to be compiled with runtime lib set to MultiThread (/MT)\nI think I have compiled boost/thread in static, MT because I have:\n\nlibboost_thread-vc100-mt-1_48.lib\nlibboost_thread-vc100-mt-s-1_48.lib\n\n\n\nNow, I have the following linking error:\n\n\n LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts\n with use of other libs; use /NODEFAULTLIB:library\n\n\nIf I use /NODEFAULTLIB:MSVCRT, I have other linking errors...\n\nMaybe I didn't compile boost correctly, I used their jam script with:\n\n\n runtime-link=static\n\n\nThank you :-)"
] | [
"c++",
"visual-studio-2010",
"boost",
"jsoncpp"
] |
[
"Zooming a JPanel similar to Microsoft Office Power Point",
"I made a JPanel and JSlider for zooming the JPanel in java .\n\nNow What my problem is zooming has to be done similar to the MS Office power point Slide Screen zooming\n\nThe JSlider is outside of the JScrollPane that holds the JPanel. As the JSlider is moved to the right, the JPanel expands in size. As the JSlider is moved to the left, the JPanel reduces in size. At any zoom size, the contents of the JPanel have to remain editable.\n\nI am little bit weak in using paint method or affine transform in Java.\n\nPlease help me."
] | [
"java",
"swing",
"jpanel",
"jslider",
"affinetransform"
] |
[
"How to alias attributes in XStream with annotations?",
"I have the following piece of code\n\n@XStreamAlias(\"Pa\")\npublic class Pa {\n\n @XStreamAsAttribute\n private String ms;\n\n @XStreamAsAttribute\n private String co;\n\n @XStreamAsAttribute\n private String house;\n\n @XStreamAsAttribute\n private String street;\n\n // Getters and Setters\n}\n\n\nI want my attributes names to be different from the variable names when my XML is constructed. \n\nI know I can do it to classes with the following annotation\n\n@XStreamAlias(\"ExampleClass\")\nprivate ExClass exClass;\n\n\nThe above code will result in a tag with the name \n\n<ExampleClass/>\n\n\nHowever, I cannot find any annotation that changes the name of the attribute without creating a separate tag.\n\nWhat I want is the following: \n\n<Pa milliseconds=\"\" co =\"\"/>\n\n\nBut using \n\n@XStreamAlias(\"Milliseconds\")\nprivate String ms; \n\n\nis creating a new tag with the given name. It no longer stays an attribute of the tag.\n\nDoes such an annotation exist? I need to do it only using annotations, not at runtime using Java code.\n\nThank you for your time."
] | [
"java",
"spring",
"xstream"
] |
[
"CSS Styles accidentally removes my scrollbar in wordpress",
"I'm having trouble with my css styles in wordpress. Chrome is removing my scrollbar, while in IE my page is fixed and doesn't scroll at all. I've disabled my admin bar because it seemed to be causing some trouble, but I still can't see my scrollbar.\n\nHere's my page http://www.kareemkwong.me/\n\nThanks for your help!"
] | [
"css",
"wordpress",
"scrollbar",
"wordpress-theming"
] |
[
"Scroll view problem?",
"I arranged imageview in the scrollview if the image is larger than the display, it shows blur edges (not sharp edges).\n\n <ScrollView \n android:layout_marginTop=\"35dip\"\n android:id=\"@+id/sv\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"> \n\n <HorizontalScrollView \n android:id=\"@+id/hsv\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"> \n\n <FrameLayout \n android:id=\"@+id/framelayout\"\n android:layout_marginTop=\"30dip\"\n android:layout_height=\"fill_parent\" \n android:layout_width=\"fill_parent\">\n\n <ImageView \n android:id=\"@+id/ImageView01\"\n android:layout_alignParentTop=\"true\"\n android:layout_height=\"wrap_content\" \n android:layout_width=\"wrap_content\"/>\n\n\nsee the image at edges right and down : http://dl.dropbox.com/u/38493970/device-2011-09-07-144456.png"
] | [
"android",
"imageview",
"scrollview"
] |
[
"C* Modeling a timeLine",
"Just for fun I am building a tweeter clone to get a better understanding of C*\n\nAll the suggested C* schemes that I have seen around are using more or less the same modeling technique. The issue is that I have my doubts about the scalability of modeling the twitter timeline in this fashion.\n\nThe problem:\nWhat will happen if I have a userA (rock star) or more that is extremely popular and is followed by 10k+ users?\nEach time the userA publishes a tweet we will have to insert into the timeline table 10k+ tweets for each of his followers.\n\nQuestions:\nWill this model really scale?\nCan anyone suggest me an alternative ways of modeling the timeline that can really scale?\n\nC* Schema:\n\nCREATE TABLE users (\n uname text, -- UserA\n followers set, -- Users who follow userA\n following set, -- UserA is following userX\n PRIMARY KEY (uname)\n);\n-- View of tweets created by user\nCREATE TABLE userline (\n tweetid timeuuid,\n uname text,\n body text,\n PRIMARY KEY(uname, tweetid)\n);\n-- View of tweets created by user, and users he/she follows\nCREATE TABLE timeline (\n uname text,\n tweetid timeuuid,\n posted_by text,\n body text,\n PRIMARY KEY(uname, tweetid)\n);\n\n\n-- Example of UserA posting a tweet:\n-- BATCH START\n-- Store the tweet in the tweets\nINSERT INTO tweets (tweetid, uname, body) VALUES (now(), 'userA', 'Test tweet #1');\n\n-- Store the tweet in this users userline\nINSERT INTO userline (uname, tweetid, body) VALUES ('userA', now(), 'Test tweet #1');\n\n-- Store the tweet in this users timeline\nINSERT INTO timeline (uname, tweetid, posted_by, body) VALUES ('userA', now(), 'userA', 'Test tweet #1');\n\n-- Store the tweet in the public timeline\nINSERT INTO timeline (uname, tweetid, posted_by, body) VALUES ('#PUBLIC', now(), 'userA', 'Test tweet #1');\n\n-- Insert the tweet into follower timelines\n-- findUserFollowers = SELECT followers FROM users WHERE uname = 'userA';\nfor (String follower : findUserFollowers('userA')) {\nINSERT INTO timeline (uname, tweetid, posted_by, body) VALUES (follower, now(), 'userA', 'Test tweet #1');\n}\n-- BATCH END\n\n\nThanks in advance for any suggestions."
] | [
"twitter",
"nosql",
"cassandra",
"data-modeling",
"cql"
] |
[
"Backbone model extending",
"I would like to add some JSON to my existing backbone model. What is best approach to achieve this?\n\nI tried following:\n\nnextClick: function(event) { \n //this.getPostData returns some JSON that I want to add in existing model\n this.model = new Backbone.Model.extend( this.getPostData() );\n}\n\n\nIt doesn't work, this.model gives me following output in console:\n\nconsole.log(this.model);\n//output: function (){ parent.apply(this, arguments); }"
] | [
"javascript",
"backbone.js"
] |
[
"How can I make the CSS attribut of a Div to change when there is a text overflow on another Div?",
"I'm building a Div with column-count = 2, column-fill = auto, and a height = 100%.\n\nThis Div will contain some other Div with text inside.\nHowever, I want my page to be fluid and adapt automatically when the window get shorter in order that overflowing text could be read on the 2 columns by using the browser scrollbar.\n\nSo I need my Div to remove height = 100% and replace it with min-height = 100% in order that a scrollbar appear on the browser to allow to read below the overflowing text on 2 column instead of having the overflowing text appearing on third column (despite column-count = 2).\n\nIs there a way to achieve this with CSS only or should I need Javascript, and how ?\n\nMany Thanks"
] | [
"html",
"css",
"overflow",
"css-multicolumn-layout"
] |
[
"cocoapods lib lint error [iOS] xcodebuild: Returned an unsuccessful exit code",
"when i use a framework in my podspec appear this error, how can i fix it ???\n\nld: illegal text-relocation to 'cstring' in /Users/XY/Desktop/AJKPlayer/AJKPlayer/Frameworks/wplayer.framework/wplayer(alphablend.o) from '_ff_sws_alphablendaway' in /Users/XY/Desktop/AJKPlayer/AJKPlayer/Frameworks/wplayer.framework/wplayer(alphablend.o) for architecture i386\nclang: error: linker command failed with exit code 1 (use -v to see invocation)"
] | [
"ios",
"objective-c",
"cocoapods",
"podspec"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.