texts
sequence | tags
sequence |
---|---|
[
"Undefined Symbols for Architecture i386?",
"When building in xCode, it works in simulator for iPhone 5s, 6, 6s, etc. but when building for iPhone 5, I get a \"Build Failed\" with the following error:\n\n\n Undefined symbols for architecture i386:\n \"_OBJC_CLASS_$_MyGameCenterManager\", referenced from:\n objc-class-ref in AppDelegate.o\n objc-class-ref in CompleteScene.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1\n (use -v to see invocation)\n\n\nAny fix of this? Your responses are greatly appreciated. :-)"
] | [
"ios",
"objective-c",
"xcode"
] |
[
"call of overloaded is ambiguous, how to deal with that?",
"I really don't understand this, I thought that compiler first executes what is in braces and then gives the result to the most appropriate function. Here it looks like it gives the function an initializer list to deal with it...\n\n#include <string>\n#include <vector>\nusing namespace std;\n\nvoid func(vector<string> v) { }\n\nvoid func(vector<wstring> v) { }\n\nint main() {\n func({\"apple\", \"banana\"});\n}\n\n\nerror:\n\n<stdin>: In function 'int main()':\n<stdin>:11:27: error: call of overloaded 'func(<brace-enclosed initializer list>)' is ambiguous\n<stdin>:11:27: note: candidates are:\n<stdin>:6:6: note: void func(std::vector<std::basic_string<char> >)\n<stdin>:8:6: note: void func(std::vector<std::basic_string<wchar_t> >)\n\n\nWhy isn't my func(vector<string> v) overload called, and can I make it so?"
] | [
"c++",
"c++11",
"initializer-list",
"ambiguous"
] |
[
"Premature end of file error while generating well-formed XML document",
"Following is my problem statement:\n\nXYZ school wants to store the details of student \nand staff in a xml file. The following scenario \nhelps in designing the XML document.persons will be the root tag. persons will havethe entry of each person with name, age, gender, address.\nA person can be either a student or staff. Student will have rollno, standard and section. If staff, then staffid and subject.\nEvery person must have an address with the following entry\n- doorno,street,city and state.\n\nThe code which I wrote is as follows:\n\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE persons\n[\n<!ELEMENT name (#PCDATA)>\n<!ELEMENT age (#PCDATA)>\n<!ELEMENT gender (#PCDATA)>\n<!ELEMENT address (doorno,street,city,state)>\n<!ELEMENT student (rollno,standard,section)>\n<!ELEMENT rollno (#PCDATA)>\n<!ELEMENT standard (#PCDATA)>\n<!ELEMENT section (#PCDATA)>\n<!ELEMENT staff (staffid,subject)>\n<!ELEMENT staffid (#PCDATA)>\n<!ELEMENT subject (#PCDATA)>\n<!ELEMENT doorno (#PCDATA)>\n<!ELEMENT street (#PCDATA)>\n<!ELEMENT city (#PCDATA)>\n<!ELEMENT state (#PCDATA)>\n\n\n]> \n\nIt gives the error- Exception:Premature end of file. I am quite new at XML and hence having a hard time. Help would be appreciated"
] | [
"xml"
] |
[
"my loop will run into negative numbers even when I am an if statement telling not to",
"this is a simple program where I am getting input as change owed in $, and I have to return the total amount of coins. My program runs correctly until it comes down to counting pennies. Can someone see, Why does it give negative output, even when I told the program with an if statement not to run after it comes to 0.\nimport sys\nimport cs50\n\n\nval = cs50.get_float(("Change owed: "))\n\ncount = 0\nnewVal = val\n\nwhile newVal > .25:\n newVal = round(newVal - 0.25, 2)\n print(newVal)\n count +=1\n if newVal == 0.25:\n newVal = round(newVal - 0.25, 2)\n print(newVal)\n count +=1\n elif newVal < 0.25:\n newVal = round(newVal - 0.10, 2)\n print(newVal)\n count +=1\n if newVal < 0.10:\n newVal = round(newVal - 0.05, 2)\n print(newVal)\n count +=1\n if newVal < 0.05:\n newVal = round(newVal - 0.01, 2)\n print(newVal)\n count +=1\n if newVal < 0:\n break\n \n \nprint(count)"
] | [
"python",
"if-statement",
"while-loop",
"cs50"
] |
[
"Blank white bar in the layout without reason",
"I have a big blank white bar at the bottom of my layout and i don't know why. It is really anoying and i really don't love it :D Please help me to delete it!\n\n\nMy layout code:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:orientation=\"vertical\">\n\n\n <ScrollView\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:background=\"#ededed\">\n\n <LinearLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:orientation=\"vertical\">\n\n <android.support.design.card.MaterialCardView\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_margin=\"10dp\"\n app:cardBackgroundColor=\"@android:color/white\"\n app:cardCornerRadius=\"10dp\"\n app:cardElevation=\"2dp\"\n app:cardPreventCornerOverlap=\"true\">\n\n <ImageView\n android:id=\"@+id/image\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"200dp\"\n android:background=\"@drawable/ic_menu_camera\" />\n </android.support.design.card.MaterialCardView>\n\n <LinearLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:layout_marginLeft=\"10dp\"\n android:layout_marginRight=\"10dp\"\n android:background=\"@drawable/text_style_header\"\n android:orientation=\"vertical\">\n\n <TextView\n android:id=\"@+id/heading\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:text=\"Heading....\"\n android:textAppearance=\"?attr/textAppearanceHeadline6\"\n android:textSize=\"20sp\" />\n\n <TextView\n android:id=\"@+id/description_short\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:layout_marginTop=\"2dp\"\n android:background=\"@drawable/text_style_desc\"\n android:text=\"Desc\" />\n\n <LinearLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:layout_marginTop=\"12dp\"\n android:background=\"@drawable/text_style_desc\"\n android:orientation=\"vertical\">\n\n <TextView\n android:id=\"@+id/description\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:layout_marginTop=\"2dp\"\n android:background=\"@drawable/text_style_desc\"\n android:text=\"text text text tex\" />\n </LinearLayout>\n </LinearLayout>\n </LinearLayout>\n </ScrollView>\n</LinearLayout>\n\n\nIn the preview of android studio there is showing nothing, but if i build and run the app it shows the bar. Is this bar from \n\nSOLUTION: This layout was from a ViewPager layout which had a blank space for adding dots. This was the problem. \n\nThank you all!"
] | [
"android",
"android-studio",
"android-layout"
] |
[
"How to list all contacts from BlackBerry-10 contacts list?",
"I am creating an SMS chat application for blackberry 10.So i want list list all contacts from blackberry database and list it to user so that user can easily select recipient's mobile numbers easily.Is there any way to do it using html5/webworks.I just want get all contact's name and mobile number into an array or something like that.Anyone can help ??\nThanks in advance.\n\nhttps://developer.blackberry.com/html5/apis/blackberry.pim.contacts.contact.html"
] | [
"html",
"blackberry-webworks",
"blackberry-10"
] |
[
"Reactive Form Data Binding with Angular Service",
"I have 5 forms so I am implementing data service to connect them. Service working fine and I am getting data in service but when I will go from one page to the second page and click on next them I will only get second form data but I want first form data also\nSo that in final stage I can send all collected data to API.\nthis is the my code\n`import { Injectable } from '@angular/core';`\n`import { AddBusinessMutation} from 'src/app/graphql'`\n`import{FormGroup, FormControl, Validators,FormArray} from '@angular/forms'`\n\n`@Injectable({\n providedIn: 'root'\n})`\n`export class AddbusinessService {`\n `business: AddBusinessMutation;`\n `businesses: [];`\n `setGeneralFormData(data) {`\n `// this.businesses = data.socialLinks;\n // this.business = data.frmData;`\n `console.log(data)\n }`\n`constructor(){`\n `}`\n`}`"
] | [
"angular",
"angular-services",
"reactive",
"angular-service-worker"
] |
[
"How to Bloat embedded youtube video frame on website when I click on play?",
"I have embedded youtube videos on my website(HTML5 and CSS). I have 3 videos which shows up next to each other to fit in the margin of the website. But when I click on play, the frame doesn't expand and hence plays in the same frame but that is too small for viewers. \n\nExpectation: Its ok to have it in small frame in website but when the user clicks on \"Play\" button, the frame must expand to say 1100 * 450 and go back to fit in its small frame when its done or when the user clicks elsewhere in the page.\nI don't want to use the \"Full screen\" option since that covers the entire webpage. \n\nAny ideas how I can do it?"
] | [
"css",
"html",
"youtube",
"web"
] |
[
"How to do Cross validation in sparkr",
"I am working with movie lens dataset, I have a matrix(m X n) of user id as row and movie id as columns and I have done dimension reduction technique and matrix factorization to reduce my sparse matrix (m X k, where k < n ). I want to evaluate the performance using the k-nearest neighbor algorithm (not library , my own code) . I am using sparkR 1.6.2. I don't know how to split my dataset into training data and test data in sparkR. I have tried native R function (sample, subset,CARET) but it is not compatible with spark data frame. kindly give some suggestion for performing cross-validation and training the classifier using my own function written in sparkR"
] | [
"r",
"cross-validation",
"sparkr"
] |
[
"Custom TreeViewItem style doesn't work (is ignored)",
"I'm trying to modify the style of TreeViewItem, but my changes are ignored. In the following example items are added in code-behind and setting font color doesn't work.\n\n<UserControl ...>\n <Grid>\n <TreeView x:Name=\"myTree\">\n\n <TreeView.Resources>\n <Style TargetType=\"{x:Type TreeViewItem}\">\n <Setter Property=\"Foreground\" Value=\"Orange\"/>\n </Style>\n </TreeView.Resources>\n\n <TreeView.ItemTemplate>\n <HierarchicalDataTemplate ItemsSource=\"{Binding Items}\">\n <TextBlock Text=\"{Binding Title}\" />\n </HierarchicalDataTemplate>\n </TreeView.ItemTemplate>\n </TreeView>\n </Grid>\n</UserControl>\n\n\nIt's a part of complex project. Is it possible that some global settings override my local resources? I can't figure out what's the problem.\n\nI note that if I set this style explicitly using x:Key value, it works for all nodes except root.\n\n<TreeView.Resources>\n <Style x:Key=\"myStyle\" TargetType=\"{x:Type TreeViewItem}\">\n ...\n\n<TreeView.ItemTemplate>\n <HierarchicalDataTemplate ItemContainerStyle=\"{StaticResource myStyle}\" ItemsSource=\"{Binding Items}\">\n ...\n\n\nCan I set my style explicitly using x:Key value for all nodes?"
] | [
"wpf",
"treeview"
] |
[
"How can I execute multiple transactions under same connection?",
"Here my requirement is like this:\n\n\nInitially I execute a stored procedure to insert\\update a record in DB, under one transaction.\nIn case the SP execution fails due to some issue, I must be able to re-invoke the SP again under different transaction.\nEven if the re-invocation of SP fails then only, I should throw error to calling function.\n\n\nHere is the sample code. Is this the proper way of handling transactions and errors, or is there a better way to do this?\n\npublic void InsertUser(string code)\n{ \n bool bRetry=false;\n SqlTransaction transaction = null;\n Exception RetrunEx = null;\n using (SqlConnection sqlConnection = new SqlConnection(this.connectionString))\n {\n sqlConnection.Open();\n\n SqlCommand sqlCommand = new SqlCommand(\"InsertUser\", sqlConnection);\n sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;\n SqlParameter param = sqlCommand.Parameters.Add(\"@UserCode\", SqlDbTypes.VarChar);\n param.Value = code;\n\n //Is this the proper place to begin a transaction?\n SqlTransaction transaction = connection.BeginTransaction();\n sqlCommand.Transaction = transaction; \n\n try\n { \n sqlCommand.ExecuteNonQuery();\n transaction.Commit();\n\n } \n catch(SqlException SqlEx)\n {\n transaction.Rollback();\n bRetry = true;\n RetrunEx = SqlEx;\n }\n catch(Exception ex)\n {\n transaction.Rollback();\n RetrunEx = ex;\n }\n\n //Will this be treated as new transaction?\n //Is there any best way of doing this?\n transaction = connection.BeginTransaction();\n sqlCommand.Transaction = transaction;\n\n try\n { \n if (bRetry) \n {\n sqlCommand.ExecuteNonQuery();\n transaction.Commit();\n ReturnEx = null;\n }\n\n } \n catch(Exception Ex)\n {\n transaction.Rollback();\n RetrunEx = Ex;\n }\n\n //When both the trials fails then throw exception\n if (RetrunEx != null)\n {\n throw RetrunEx;\n }\n }\n}"
] | [
"c#"
] |
[
"Using Futures to load config.json in Flutter",
"Being new to Dart/Flutter I am using this snippet to try and load a config.json file that I have stored in my assets folder. In trying to read this file, I am using models on the Dart language Futures documentation and in the Flutter docs on reading local text files:\n\nimport 'dart:async' show Future;\nimport 'package:flutter/services.dart' show rootBundle;\nimport 'dart:convert';\n\nFuture<List> loadAsset() async {\n String raw = await rootBundle.loadString('assets/config.json');\n List configData = json.decode(raw);\n return configData;\n}\n\n\nThen, inside my class, I try to load the config into a List, like this:\n\nFuture<List> configData = loadAsset();\nprint(configData.toString());\n// prints out: Instance of 'Future<List<dynamic>>'\n\n\nThe result of all this seems to work. Yet I can find no way of using the data I have loaded. Any effort to access elements in the List, e.g. configData[0] results in an error:\n\nThe following _CompileTimeError was thrown building \nHomePage(dirty, state: HomePageState#b1af8):\n'package:myapp/pages/home_page.dart': error: \nline 64 pos 19: lib/pages/home_page.dart:64:19:\nError: The method '[]' isn't defined for the class \n'dart.async::Future<dart.core::List<dynamic>>'.\nTry correcting the name to the name of an existing method, \nor defining a method named '[]'.\n\n\nI would like to convert the configData Future into a normal object that I can read and pass around my app. I am able to do something very similar, and to get it to work inside a widget's build method, using a FutureBuilder and the DefaultAssetBundle thus...\n\nDefaultAssetBundle\n.of(context)\n.loadString('assets/config.json')\n\n\n...but I don't want the overhead of reloading the data inside all the widgets that need it. I would like to load inside a separate Dart package and have it available as a global configuration across all my app. Any pointers would be appreciated. \n\n\n\nI have tried the suggestion by Rémi Rousselet:\n\nList configData = await loadAsset();\nprint(configData[0]);\n\n\nIn this case, I get a compiler error:\n\ncompiler message: lib/pages/home_page.dart:55:21: Error: Getter not found: 'await'.\ncompiler message: List configData = await loadAsset();\ncompiler message: ^^^^^"
] | [
"dart",
"flutter"
] |
[
"Zurb Foundation 4 foundation method call contains code that conflicts with Prototype.js",
"I am using Magento 1.7.2, jQuery 1.9.1 and Prototype.js 1.7, and Zurb Foundation 4 javascript plugins, namely the joyride plugin. \n\nWell after installing the joyride plugin using the foundation.js and foundation.joyride.js files, I found that prototypejs creates a property Function.prototype.bind= function(){...}, and this is being called from foundation.js under a function called init_lib or lib_init (can't remember) that calls the bind method, probably the ecmascript5 version of bind. \n\nWhen debugging the code, I saw it step into prototypejs bind from init_lib in foundation.\n\nHow can I fix this conflict without having to rename all prototypejs uses/calls of bind to some other name?\n\nThe $.foundation() method is called when the dom is ready so this is after prototypejs objects are initialized.\n\nThank you for any help."
] | [
"jquery",
"magento",
"prototypejs",
"zurb-foundation",
"zurb-joyride"
] |
[
"Dynamic audit table creation via Migrations",
"Using .Net Core 2.1 and Audit.NET EF 12.1.10, I'm trying to add a migration that includes the audit tables but when invoking Add-Migration, no audit tables are generated in the migration. I assumed that using the \"dynamic\" audit will do this automagically. I don't have any audit interfaces-- I am leaving this up to Audit.NET. Below is in my Startup:\n\nvar serviceProvider = services.BuildServiceProvider();\n\n Audit.EntityFramework.Configuration.Setup()\n .ForContext<MainDbContext>(config => config\n .IncludeEntityObjects()\n .AuditEventType(\"{context}:{database}\"))\n .UseOptOut()\n .IgnoreAny(entity => entity.Name.StartsWith(\"AspNet\") && entity.Name.StartsWith(\"OI\"));\n\n\n Audit.Core.Configuration.Setup()\n .UseEntityFramework(ef => ef\n .AuditTypeNameMapper(typeName => \"Audit_\" + typeName)\n .AuditEntityAction((evt, entry, auditEntity) =>\n {\n // Get the current HttpContext \n var httpContext = serviceProvider.GetService<IHttpContextAccessor>().HttpContext;\n\n // Store the identity name on the \"UserName\" property of the audit entity\n ((dynamic)auditEntity).UserName = httpContext.User?.Identity.Name;\n ((dynamic)auditEntity).AuditDate = DateTime.UtcNow;\n ((dynamic)auditEntity).AuditAction = entry.Action;\n }));\n\n\nMy DbContext extending from AuditIdentityDbContext:\n\npublic class MainDbContext : AuditIdentityDbContext<User, Role, string>\n\n\nI only have one entity so far, called Activity, just to test this out and I would expect Add-Migrations to include an Audit_Activity table as well as the Activity table, but I only got the latter. Not sure what I'm doing wrong here."
] | [
"entity-framework-core-2.1",
"audit.net"
] |
[
"Is UEFI required to map 4k pages on x64?",
"I am creating a kernel for x64 which is booting with UEFI. While the kernel has to be loaded at a low-ish address (I believe, because UEFI requires identity mapped pages so it cannot be mapped higher than the highest physical address), I want to relocate up to the end of memory. During this process I intend on creating new paging structures and in order to reduce memory consumption, I wanted to reuse the page tables used to map the image in the lower half. However, these page tables will only exist if 4k paging is used by UEFI, so my question is whether or not UEFI is required to use 4k paging on x64. I believe the answer is no, but I hope otherwise and wanted to see if this is true.\nNow I understand UEFI allocates memory via BootServices->AllocatePage in 4k chunks it refers to as pages, but is this required to translate to the actual mapping structure used? I noticed that in section 2.3.6 of the UEFI 2.8 specification, the section referring to AArch64 calling conventions, it states\n\nMMU configuration: Implementations must use only 4k pages [...]\n\nThere is no similar denotation in section 2.3.4, on the x64 calling conventions, which is why I believe the answer is no.\nEDIT:\nBased upon what I've already seen and the comment by Peter Cordes, I believe the standard does not specify exactly what it should be. Thus a revised version of the question is: Does the standard specify 4k translation granularity? If not, do most UEFI vendors on x64 use 4k pages?"
] | [
"x86-64",
"osdev",
"uefi",
"page-tables",
"huge-pages"
] |
[
"API to get metrics for HBase regions",
"I'd like to get the region metrics for all the regions on a particular region server. In particular, I'm after the readRequestsCount and writeRequestsCount. I see those values in the region server web interface, but I haven't been able to locate the API access to those values."
] | [
"hbase"
] |
[
"Is there an iOS-accessible API to detect a drunk person?",
"Is it possible to detect if a person is drunk via image recognition or face-scanning? If it's possible, is there an API available for that?"
] | [
"iphone",
"ios"
] |
[
"Widgets in game programming",
"friends!\nI am novice in game programming.\nI work with PopCap Framework v1.3.\nI read some tutorials about it and all the time I see word \"widget\".\nWhat does word \"widget\" mean within PopCap Framework? Does word \"widget\" mean the same within entire game-development?"
] | [
"widget"
] |
[
"Can SimpleDateFormat format the date based on a string?",
"I know how SimpleDateFormat works, by grabbing sdfDateTime.format(new Date(System.currentTimeMillis())); which is today's date from the System. Can SimpleDateFormat format a date by grabbing a string? Let's say you had a string: String dateStr = \"04/05/2012\"; how would you format that into: \"April 5, 2012\"?"
] | [
"android",
"simpledateformat"
] |
[
"How pass the current data with converter?",
"How can i send the current element of my Actors list to my converter? and as well i need pass a parameter with ConverterParameter\n\n<ListView x:Name=\"Actors\" ItemsSource=\"{Binding Actors}\">\n <ListView.ItemTemplate>\n <DataTemplate>\n <ViewCell>\n <ViewCell.ContextActions> \n Source=\"\" IsVisible=\"{Binding ., Converter={StaticResource ListConverter}, ConverterParameter={Binding ActorCurrent}}\"}\"/>\n </Grid>\n </ViewCell>\n </DataTemplate>\n </ListView.ItemTemplate>\n </ListView>\n\n\nthis Actor exist in my view movel, i need to pass as parameter\n\nprivate Actor _actorCurrent;\n public Actor ActorCurrent\n {\n get => _actorCurrent;\n set\n {\n _actorCurrent = value;\n RaisePropertyChanged(() => ActorCurrent);\n }\n }\n\n\ni tried with dot, but dont work\n\nIsVisible=\"{Binding . // in my Converter class i dont nothing\n\n\nEDIT 1:\n\ni have as well this \n\n public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n {\n// i want to value = will be {Binding .,\n// and parameter = will be ActorCurrent\n// then i want to compare value with parameter and return a bool\n\n }\n\n\nOr can i use triggers?\n\n<DataTrigger TargetType=\"Image\" Binding=\"{Binding Name}\" Value=\"{Binding ActorCurrent.name}\">"
] | [
"xamarin.forms"
] |
[
"I am getting an error: stat_count() can only have an x or y aesthetic",
"I am attempting to plot variables from a dataset, but I am getting an error in the last line of code saying that stat_count() can only have an x or y aesthetic.\nI am completely lost, please help.\nthis is my code chunk:\nlibrary(patchwork)\n\nplt_srh <- ggplot(Data, aes(x = srh)) +\n geom_density() +\n geom_boxplot(width = 0.001)\n labs(x = 'srh')\n\nplt_location <- ggplot(Data, aes(x = location)) +\n geom_bar() +\n labs(x = 'location')\n\nplt_joint <- ggplot(Data, aes(x = location, y = srh)) +\n geom_bar() +\n labs(x = 'location', y = 'srh')\n\nplt_srh | plt_location | plt_joint"
] | [
"r"
] |
[
"(JS) Unable to change audio's volume with new Audio() variables",
"I've made some variables which contain audio files, as seen below:\n\nvar SFX = {\n 'button_click': new Audio(),\n 'button_remove': new Audio(),\n 'earn_coins': new Audio(),\n 'earn_coins_short': new Audio(),\n}\n\nSFX.button_click.src = \"navigation/sound_effects/add_button.wav\";\nSFX.button_remove.src = \"navigation/sound_effects/remove_button.wav\";\nSFX.earn_coins.src = \"navigation/sound_effects/earn_coins.mp3\";\nSFX.earn_coins_short.src = \"navigation/sound_effects/earn_coins_short.mp3\";\n\nSFX.button_click.volume = 0.2; //NOT WORKING\n\n\nThe last line doesn't work for some reason. Do you know what's the code for changing the volume?"
] | [
"javascript",
"audio"
] |
[
"Implications of Instantiating Objects with Dynamic Variables in PHP",
"What are the performance, security, or \"other\" implications of using the following form to declare a new class instance in PHP\n\n<?php\n $class_name = 'SomeClassName';\n $object = new $class_name;\n?>\n\n\nThis is a contrived example, but I've seen this form used in Factories (OOP) to avoid having a big if/switch statement.\n\nProblems that come immediately to mind are \n\n\nYou lose the ability to pass arguments into a constructor (LIES. Thanks Jeremy)\nSmells like eval(), with all the security concerns it brings to the table (but not necessarily the performance concerns?)\n\n\nWhat other implications are there, or what search engine terms other than \"Rank PHP Hackery\" can someone use to research this?"
] | [
"php",
"performance",
"oop"
] |
[
"How to configure FCM for a test system and a production system",
"I have an app with package name "com.example.home" that connects to a web service; in Visual Studio Debug mode, it is configured to connect to a test web service (test system) and in Release mode, it is configured to connect to the production web service (production system).\nNow I want to add FCM to the app so that the user gets notified when the web service has new data.\nHow do I configure FCM in the Firebase Console in a way that the same package name can be used once for the test system and once for the production system, by e.g. creating two FCM projects with the same package name? Or isn't this possible?"
] | [
"android",
"xamarin.android",
"firebase-cloud-messaging"
] |
[
"SQL Server Openjson to fetch details into a table",
"I have the following JSON and expecting a table out of it.\n\n{\n \"Response\": [\n {\n \"questionId\": 1,\n \"answer\": [\n \"5\",\"6\"\n ]\n },\n {\n \"questionId\": 2,\n \"answer\": [\n \"5\"\n ]\n }\n ]\n}\n\n\nAnd the expected table...\n\n\n\nI tried with the following, but didn't the exact output that i'm looking for.\n\nSELECT QuestionId,Answer FROM OPENJSON(@responseJson, N'$.Response') r\n CROSS APPLY OPENJSON (r.value) WITH ( QuestionId varchar(200) '$.questionId', Answer nvarchar(max) '$.answer')"
] | [
"sql-server",
"open-json"
] |
[
"Time.new time zone is different than system or config.time_zone?",
"As the title suggests, I have no idea what's going on. My system's time zone is CST. In Rails' application.rb file, I set the time_zone to CST (-6):\n\n# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.\n# Run \"rake -D time\" for a list of tasks for finding time zone names. Default is UTC.\nconfig.time_zone = 'Central Time (US & Canada)'\n\n\nBut check out this string of commands... pretty self explanatory. The third line (Time.new) is showing up as having a -5 offset (aka Eastern Time)?? However, calling utc_offset shows it being -6 offset (Central, which would be correct)? So confused. help?\n\n2.1.0 :001 > Time.now\n => 2014-12-10 12:10:32 -0600 \n2.1.0 :002 > Time.zone.now\n => Wed, 10 Dec 2014 12:10:37 CST -06:00 \n2.1.0 :003 > Time.new(2011, 3, 20)\n => 2011-03-20 00:00:00 -0500 \n2.1.0 :004 > Time.new(2011, 3, 20).utc_offset\n => -18000"
] | [
"ruby-on-rails",
"timezone"
] |
[
"Aurelio fetch infinite loop",
"I'm working on my first Aurelia app with the skeleton for typescript+asp.net core. However, the fetch operation is going into an infinite loop and I dont know why.\n/api/Hierarchy/Tree?id=0 keeps getting requested infnitely. However there is no use of id=0 and I dont know why it would request anything more than once on activation of the view.\n\nTree.ts\n\nimport {autoinject} from 'aurelia-framework';\nimport {HttpClient} from 'aurelia-fetch-client';\nimport 'fetch';\n\n@autoinject\nexport class Tree {\n heading = 'Tree';\n Tree = [];\n\n constructor(private http: HttpClient) {\n http.configure(config => {\n config\n .useStandardConfiguration()\n .withBaseUrl('/');\n });\n }\n\n update(id: string)\n {\n if (id == null)\n {\n id = \"1\"; \n }\n\n return this.http.fetch('api/Hierarchy/Tree?id=' + id)\n .then(response => response.json())\n .then(Tree => this.Tree = Tree);\n }\n\n activate() {\n return this.http.fetch('api/Hierarchy/Tree?id=1')\n .then(response => response.json())\n .then(Tree => this.Tree = Tree);\n }\n}\n\n\nTree.html\n\n<template>\n <div class=\"messageHierarchy-wrapper\">\n <div class=\"message parents\">\n <h4 class=\"parent\" click.bind=\"update(Tree.parent.id)\" value.bind=\"Tree.parent.id\"></h4>\n </div>\n <div class=\"message current\">\n <h4 class=\"current\" value.bind=\"Tree.current.id\"></h4>\n </div>\n <div class=\"message children\">\n <h4 class=\"child\" repeat.for=\"aChild of Tree.children\" click.bind=\"update(aChild.id)\" value.bind=\"aChild.id\">\n\n </h4>\n </div>\n\n </div>\n</template>\n\n\nController\n\n[Route(\"api/[controller]\")]\n public class HierarchyController : Controller\n {\n [HttpGet(\"{id}\")]\n // GET: Hierarchy/Tree/5\n public IActionResult Tree(int id)\n {\n List<MessageViewModel> _items = new List<MessageViewModel>()\n {\n new MessageViewModel() { ID=1, CorrelationID=1, PreCorrelationID = 1 },\n new MessageViewModel() { ID=2, CorrelationID=2, PreCorrelationID = 1 },\n new MessageViewModel() { ID=3, CorrelationID=3, PreCorrelationID = 2 },\n new MessageViewModel() { ID=4, CorrelationID=4, PreCorrelationID = 2 },\n new MessageViewModel() { ID=5, CorrelationID=5, PreCorrelationID = 2 },\n new MessageViewModel() { ID=6, CorrelationID=6, PreCorrelationID = 3 },\n new MessageViewModel() { ID=7, CorrelationID=7, PreCorrelationID = 3 }\n };\n\n MessageHierarchyViewModel aTree = new MessageHierarchyViewModel();\n MessageViewModel aCurrentItem = _items.FirstOrDefault(x => x.CorrelationID == id);\n aTree.Current = aCurrentItem;\n\n if (aCurrentItem != null)\n {\n aTree.Parent = _items.FirstOrDefault(y => y.CorrelationID == aCurrentItem.PreCorrelationID);\n }\n else\n {\n aTree.Parent = _items.FirstOrDefault(y => y.CorrelationID == 1);\n }\n\n aTree.Children = _items.Where(x => x.PreCorrelationID == id).ToList();\n\n return Ok(aTree);\n }\n }"
] | [
"asp.net",
"aurelia"
] |
[
"Seeding from Enum - Duplicate Primary Key error",
"I have followed the accepted answer on this question, and all works perfectly fine... I get my table generated with my Enum values from the overriden Seed function in my initializer. However, when I then add further code into the seed function to populate another table making use of the Enum, I am finding it is trying to re-insert (the used enum) into the new enum-based table causing primary key validation errors. Here is the enum I am using:\n\npublic enum ComponentTypeEnum\n{\n template,\n section,\n header,\n footer,\n body,\n label,\n text,\n image,\n TOC,\n Table,\n TableColumn,\n TableRow,\n TableCell,\n List\n};\n\n\nand I have a corresponding class called ComponentType:\n\npublic class ComponentType\n{\n private ComponentType(ComponentTypeEnum @enum)\n {\n Id = (int)@enum;\n Name = @enum.ToString();\n }\n\n protected ComponentType()\n {\n }\n\n [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]\n public int Id { get; set; }\n\n [Required, MaxLength(100)]\n public string Name { get; set; }\n\n public static implicit operator ComponentType(ComponentTypeEnum @enum) => new ComponentType(@enum);\n\n public static implicit operator ComponentTypeEnum(ComponentType faculty) => (ComponentTypeEnum)faculty.Id;\n}\n\n\nIn my Initializer I have the following:\n\n protected override void Seed(DocumentPDFDbContext context)\n {\n context.ComponentType.SeedEnumValues<ComponentType, ComponentTypeEnum>(@enum => @enum);\n context.SaveChanges();\n\n var testItems = new List<ItemData>\n {\n new ItemData{Id = 1, ParentId = null, ComponentType = ComponentTypeEnum.template, Content = null, SortOrder = 1,},\n new ItemData{Id = 2, ParentId = 1, ComponentType = ComponentTypeEnum.section, Content = null, SortOrder = 1,},\n };\n\n testItems.ForEach(t => context.ItemData.Add(t));\n context.SaveChanges();\n }\n\n\nBefore I added in the testItem code it was working fine and generating my lookup table fromt he Enum fine, with the above testItems code added it seems to be trying to re-insert whichever ComponentTypeEnum is being included in the data.\n\nIm hoping this is just a simple EF thing that I am just unaware of."
] | [
"c#",
"entity-framework",
"enums",
"seed"
] |
[
"Append text to the beginning of a distribution group display name in Active Directory",
"I would like to append a suffix to the display name in an Active Directory distribution group. So right now I have two groups called \"Developers\" and \"Testers\" and would like to rename them to \"Seattle_Developers\" and \"Seattle_Testers\" respectively.\n\nComplete AD and powershell newbie\n\nWhat I've done so far is:\n\n #Returns all the Distribution Groups found in the specified \n #relational distinguished name\n $groups=Get-ADGroup -Filter {GroupCategory -eq 'Distribution'} - \n searchbase \"OU=Distribution Groups,OU=Groups,DC=techno,DC=com\" - \n Properties Members\n\n foreach ($group in $groups)\n {\n $group.name\n }\n\n\nHowever I'm not sure how to go trough the two objects inside the OU and update the names.\n\nThanks for the help.\n\nI expect the names of the objects to be changed by adding a prefix to the current display name."
] | [
"powershell"
] |
[
"Why jquery append function does not works inside sendMessage function?",
"I have the following code. I need to run an append() jquery instruction inside sendMessage() function but it does not work as you can see from the code. It works perfectly outside the function, one row below (book.html.append(\"TEST)). \n\nHow can I solve? (attached image)"
] | [
"javascript",
"html"
] |
[
"How To Get User Friends List Using Facebook C# SDK?",
"How can I retrieve User friends list using facebook c# sdk ? \nAnd I need To know what permissions allow me to get that information.\nBelow is my own attempt, but it didn't work:\n\n\n\n //retrieve all user friends ids & names in 2D array \n public static string[,] getFriends(string accessToken)\n {\n string[,] friends;\n FacebookClient fb = new FacebookClient(accessToken);\n dynamic friend = fb.Get(\"me/friends\");\n int count = (int)friend.data.Count;\n friends = new string[count, 2];\n for (int i = 0; i <count; i++)\n {\n friends[i, 0] = friend.data[i].id;\n friends[i, 1] = friend.data[i].name;\n }//end for \n return friends;\n }//end get friends"
] | [
"c#",
"facebook",
"facebook-c#-sdk"
] |
[
"Sharepoint adds unneded code to uploaded files",
"Playing with SharePoint 2010 and have noticed a very strange behavior.\nWhen uploading html or css file to the document library (by user and by C# code), SharePoint automatically adds such code into the files:\n\n<html xmlns:mso=\"urn:schemas-microsoft-com:office:office\" xmlns:msdt=\"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882\"><head>\n<!--[if gte mso 9]><xml>\n<mso:CustomDocumentProperties>\n******************************\n</mso:CustomDocumentProperties>\n</xml><![endif]-->\n</head>\n\n\nThat's really undesired behavior, cause uploaded files will be used later for validation purposes by custom library.\n\nIs there any possibility to avoid such behavior at SharePoint side? It's not desired to modify the validation lib.\n\nThanks in advance."
] | [
"c#",
"sharepoint",
"sharepoint-2010"
] |
[
"jQuery animation displayed only if page is loaded centered on the element",
"I have this jQuery snippet:\n\n$(window).one('scroll', function(){\n // scroll\n $('.hidemenot').each( function(i){\n\n var bottom_of_object = $(this).offset().top + $(this).outerHeight();\n var bottom_of_window = $(window).scrollTop() + $(window).height();\n\n /* If the object is completely visible in the window, fade it it */\n\n\n if( bottom_of_window > bottom_of_object ){ \n $(this).css('opacity', 0).one()\n .slideDown('slow')\n .animate(\n { opacity: 1 },\n { queue: false, duration: 'slow' }, 1500\n );\n }\n\n });\n });\n\n\nWhich is supposed to slidedown + fadeIn some elements the first time the user scrolls. However, if I load the page normally, nothing shows up. But when I scroll to the section where it's supposed to be, and then reload, it shows up with the animation because I'm already on the section.\n\nWhat did I do wrong here ? the $(window).one('scroll' is supposed to handle scrolling."
] | [
"jquery",
"jquery-ui"
] |
[
"How To Solve The React Hook Closure Issue?",
"import React, { useState} from "react";\nimport ReactDOM from "react-dom";\n\nfunction App() {\n const [count, setCount] = useState(0);\n\n function handleAlertClick(){\n return (setTimeout(() => {\n alert("You clicked on: " + count);\n}, 3000))\n }\n\n\n return (\n <div>\n <p>You clicked {count} times</p>\n <button onClick={() => setCount(count + 1)}>Click me</button>\n <button onClick={handleAlertClick}>Show alert</button>\n </div>\n );\n}\n\nI just want to know if this works the way that I think it does, or if there is a better explanation!\nWhenever the setState method is called the state gets a new reference. This means the original state doesn't have a new value, but we instead create a new state with a new value. When we click on the second button, the event handler function captures the reference of the original state. Even if we click the first button many times, when the alert is displayed it will show the value of the state that the event handler captured its reference.\nIs this correct?"
] | [
"javascript",
"reactjs",
"closures",
"use-state"
] |
[
"My EC2 server instance is running on a infinite loop in PHPU. How do I stop it?",
"My server is running on 100% CPU. It is running on a infinite loop in PHP how do I kill the loop? can I reboot without loosing any data?"
] | [
"php",
"amazon-ec2"
] |
[
"ExecutionException thrown but without a cause",
"I have a futures task that is doing some I/O operations over the socket to a server. When I use the get() method of the task to retrieve the result, I am getting ExecutionException, but with no cause i.e. getCause() returns null. In what scenario does this happen? I mean, I'm getting this exception since the task threw some exception right , but how can it go missing?"
] | [
"java",
"exception",
"executorservice",
"futuretask"
] |
[
"Why my VBA code creates line plot instead of scatter plot?",
"I'm trying to generate scatter plot from 2 data-columns, but instead I get a line plot where data of the first column is ignored (i.e.: if I have 1000 points, on x-axis I see values from 1 to 1000, regardless of the data stored in 1st column). I can't find the error in my code. What's wrong?\n\nPublic Sub Graph_Refresh()\n\n Dim cht As Chart\n Dim i As Integer\n Dim seriesIndex As Integer\n Set cht = Sheets(\"Graph\").ChartObjects(\"Chart 1\").Chart\n seriesIndex = 0\n\n ' ***** CLEAR OLD CONTENT *****\n cht.ChartArea.ClearContents\n\n ' ***** NON CHANGEABLE PARAMETERS *****\n 'Format Font Type and Size\n cht.ChartType = xlXYScatterLinesNoMarkers ' scatter plot\n cht.ChartArea.Format.TextFrame2.TextRange.Font.Name = \"Arial\"\n cht.ChartArea.Format.TextFrame2.TextRange.Font.Size = 12\n cht.HasTitle = False ' No chart title\n 'cht.SetElement (msoElementPrimaryValueGridLinesMajor) 'Gridlines\n\n 'Adjust x-axis\n cht.HasAxis(xlCategory, xlPrimary) = True\n cht.Axes(xlCategory, xlPrimary).HasTitle = True\n cht.Axes(xlCategory).AxisTitle.Text = \"Frequency [MHz]\"\n cht.Axes(xlCategory).MinimumScale = Sheets(\"Graph\").Range(\"AI7\").Value\n cht.Axes(xlCategory).MaximumScale = Sheets(\"Graph\").Range(\"AI8\").Value\n\n 'Adjust y-axis\n cht.HasAxis(xlValue, xlPrimary) = True\n cht.Axes(xlValue, xlPrimary).HasTitle = True\n cht.Axes(xlValue).AxisTitle.Text = \"S-Parameters [dB]\"\n cht.Axes(xlValue).MinimumScale = Sheets(\"Graph\").Range(\"AI9\").Value\n cht.Axes(xlValue).MaximumScale = Sheets(\"Graph\").Range(\"AI10\").Value\n cht.Axes(xlValue).CrossesAt = -100\n\n ' Data Series\n For i = 1 To 5\n seriesIndex = seriesIndex + 1\n cht.SeriesCollection.NewSeries\n With Sheets(\"Graph\")\n cht.SeriesCollection(seriesIndex).Name = .Cells(6 + (i - 1) * 4).Value & \" S11\"\n End With\n cht.SeriesCollection(seriesIndex).XValues = \"='\" & Sheets(\"Data\" & CStr(i)).Name & \"'!$K$4:$K$10004\"\n cht.SeriesCollection(seriesIndex).Values = \"='\" & Sheets(\"Data\" & CStr(i)).Name & \"'!$L$4:$L$10004\"\n ' Set line size and color\n With cht.SeriesCollection(seriesIndex)\n .Format.Line.Weight = 2.25\n .Format.Line.Visible = msoFalse\n .Format.Line.Visible = msoTrue\n .Format.Line.ForeColor.RGB = RGB(255,0,0)\n .MarkerStyle = xlMarkerStyleNone\n End With\n\n Next i\n\n\n ' Legend\n\n\nEnd Sub\n\n\nData are stored in sheets \"Data1\" - \"Data5\", and the range should be ok. Chart \"Chart 1\" already exists (that's why I don't create it).\n\nThanks in advance for help!"
] | [
"excel",
"vba"
] |
[
"angular 2 want to define an array inside the object so that i can push some value",
"I want to define array inside the object I am using dot notation \nbut it is always showing undefined\n\nmy HTML code \n\n<mat-checkbox *ngFor=\"let q1 of question.checkboxes;\" (change)=\"checkboxSelected(q1,question,$event)\"> {{q1.name}} </mat-checkbox>\n\n\nmy ts code \n\ncheckboxSelected(selected,obj,event){obj.box.push('somecondition') }\n\n\nit is showing an error that \n\nERROR TypeError: Cannot read property 'push' of undefined"
] | [
"javascript",
"angular",
"typescript"
] |
[
"UiSlider should be updated inside UITableviewCell every second",
"I have a requirement where I need to show the slider in the UITableview's cell. It is basically a download table view where audio items keep downloading, the progress of download is captured and shown in tableview's cell. Every time the download of item happens, I receive a delegate method and that I call reload table to update the table view. This is leading to a scrolling issue where table doesn't scroll smoothy as it will reloading the cell for item download. How can I solve this problem?\n\nThanks"
] | [
"ios",
"uitableview"
] |
[
"Why do i always get a whole black picture which screenshoot by GLSurfaceView?",
"I use the GLSurfaceView as the view to display the camera preview data. I use createBitmapFromGLSurface aim at grabPixels and save it to Bitmap.\n\nHowever, I always get a whole black picture after save the bitmap to file. Where am i wrong?\n\nFollowing is my code snippet.\n\n@Override\npublic void onDrawFrame(GL10 gl) {\n if (mIsNeedCaptureFrame) {\n mIsNeedCaptureFrame = false;\n createBitmapFromGLSurface(width, height);\n }\n}\n\nprivate void createBitmapFromGLSurface(int w, int h) {\n ByteBuffer buf = ByteBuffer.allocateDirect(w * h * 4);\n buf.position(0);\n buf.order(ByteOrder.LITTLE_ENDIAN);\n GLES20.glReadPixels(0, 0, w, h,\n GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buf);\n buf.rewind();\n\n Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);\n bmp.copyPixelsFromBuffer(buf);\n\n Log.i(TAG, \"createBitmapFromGLSurface w:\" + w + \",h:\" + h);\n mFrameCapturedCallback.onFrameCaptured(bmp);\n}\n\n\nUpdate:\n\npublic void captureFrame(FrameCapturedCallback callback) {\n mIsNeedCaptureFrame = true;\n mCallback = callback;\n}\n\npublic void takeScreenshot() {\n final int width = mIncomingWidth;\n final int height = mIncomingHeight;\n EglCore eglCore = new EglCore(EGL14.eglGetCurrentContext(), EglCore.FLAG_RECORDABLE);\n OffscreenSurface surface = new OffscreenSurface(eglCore, width, height);\n surface.makeCurrent();\n Bitmap bitmap = surface.captureFrame();\n\n for (int x = 0, y = 0; x < 100; x++, y++) {\n Log.i(TAG, \"getPixel:\" + bitmap.getPixel(x, y));\n }\n surface.release();\n eglCore.release();\n mCallback.onFrameCaptured(bitmap);\n}\n\n@Override\npublic void onDrawFrame(GL10 gl) {\n\n mSurfaceTexture.updateTexImage();\n\n if (mIsNeedCaptureFrame) {\n mIsNeedCaptureFrame = false;\n takeScreenshot();\n return;\n }\n ....\n }\n\n\nThe logs are following:\n\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\ngetPixel:0\n..."
] | [
"android",
"bitmap",
"android-bitmap",
"glsurfaceview",
"egl"
] |
[
"Why is unity OnApplicationPause called twice on android?",
"I have a simple game object (the main UI object) with OnApplicationPause that prints out the Pause status (true/false) in the debug log.\nWhen I run it on android, and press the Home Button to leave the app, I see that the OnApplicationPause() is called twice in a row, with the same pauseStatus (true). The same happens when I reopen the app: the OnApplicationPause is called twice with Pause status false.\n\nWhy is it being called twice and can I avoid it? Am I doing anything wrong?\n\nI also tried to create a separate GameObject, that includes the same debug code. The issue doesn't occur there - only in my main UI object."
] | [
"android",
"unity3d",
"duplicate-removal",
"onresume",
"onpause"
] |
[
"Google API GPS location Android available to all activities",
"I am able to get the user location by using Google API and Location services. That location is then saved to an online database. However, how would I go about making the location update every X amount of time (lets say 10 minutes). Also, the Google API and location services is linked specific activity. How would I make the location services available to all activities, meaning that once the user is logged in, no matter what activity the user is in, the location would be updated and saved to my database? Finally, if the phone is in sleep mode or the app is running in the background, would the location still be updated? \nThanks, any suggestions or pointers are appreciated!"
] | [
"android",
"google-api",
"google-location-services"
] |
[
"Xcode 8 - Make the keyboard go away when a user clicks on the background",
"I have used this in the past.\n\noverride func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) \n{\n self.view.endEditing(true)\n}\n\n\nBut now in Xcode 8 beta I get this error:\n\nDeclaration touchBegan(touches:withEvent) has different argument names from any potential overrides.\n\nAny thoughts?"
] | [
"ios",
"xcode",
"swift",
"beta",
"xcode8"
] |
[
"matching values of a node with the following sibling nodes if any",
"I need to know if there is any way to match the value of a particular node with all other values of that particular node in all other following sibling nodes.\nTo make it clear, if the scenario is like this \n\n<A>\n<name>tom</name>\n<age>21</age>\n</A>\n<A>\n<name>tom</name>\n<age>24</age>\n</A>\n\n\nwhat if Node A may repeat any number of times and i need to check if there is any other value of the node Tom i.e. Whichever value comes in first node. If there is any other value of the node i need to pass 'Too many names' hard coded in the node .\n\nI am very new to xslt. Is there any way out to solve this ? \nThanks in advance .."
] | [
"xpath"
] |
[
"SearchResultsUpdating not updating",
"Ok so I have a UITableViewController and created a SearchViewController to search through an array of investments I made. The investments display in the UITableView (by alphabetical order), but when I click search and type in some letters, there in no updating to show investments with those letters. \n\nI feel like this is a simple mistake I made and it would really help if I could get some tips and help. \n\nHere are a couple images of the code I have right now. (Sorry if I included some unnecessary code) \n\n\n\nand also this one:\n\n\n\nThanks guys and hope that it can be solved."
] | [
"swift",
"xcode",
"uitableview",
"io"
] |
[
"Role environment . FAILED TO INITIALIZE",
"I have a number of Azure Web Sites running on single-instance, Standard S2 tiers (each site on it's own instance). The sites are in different regions and they run completely different and independent code. I have noticed that if I view the eventlog.xml file on any of my sites, I see a number of Role environment . FAILED TO INITIALIZE events showing up. Here is an extract from the file:\n\n<Event>\n <System>\n <Provider Name=\"Windows Azure Runtime 2.5.0.0\"/>\n <EventID>1013</EventID>\n <Level>0</Level>\n <Task>0</Task>\n <Keywords>Keywords</Keywords>\n <TimeCreated SystemTime=\"2015-05-06T07:07:35Z\"/>\n <EventRecordID>976923406</EventRecordID>\n <Channel>Application</Channel>\n <Computer>RD000XXXXXE</Computer>\n <Security/>\n </System>\n <EventData>\n <Data>4008</Data>\n <Data>w3wp</Data>\n <Data>Role environment . INITIALIZING</Data>\n </EventData>\n</Event>\n<Event>\n <System>\n <Provider Name=\"Windows Azure Runtime 2.5.0.0\"/>\n <EventID>1013</EventID>\n <Level>0</Level>\n <Task>0</Task>\n <Keywords>Keywords</Keywords>\n <TimeCreated SystemTime=\"2015-05-06T07:07:36Z\"/>\n <EventRecordID>976923937</EventRecordID>\n <Channel>Application</Channel>\n <Computer>RD000XXXXXE</Computer>\n <Security/>\n </System>\n <EventData>\n <Data>4008</Data>\n <Data>w3wp</Data>\n <Data>Role environment . INITIALED RETURNED. HResult=-2147024891</Data>\n </EventData>\n</Event>\n<Event>\n <System>\n <Provider Name=\"Windows Azure Runtime 2.5.0.0\"/>\n <EventID>1015</EventID>\n <Level>3</Level>\n <Task>0</Task>\n <Keywords>Keywords</Keywords>\n <TimeCreated SystemTime=\"2015-05-06T07:07:36Z\"/>\n <EventRecordID>976924062</EventRecordID>\n <Channel>Application</Channel>\n <Computer>RD000XXXXXE</Computer>\n <Security/>\n </System>\n <EventData>\n <Data>4008</Data>\n <Data>w3wp</Data>\n <Data>Role environment . FAILED TO INITIALIZE. hr: -2147024891</Data>\n </EventData>\n</Event>\n\n\nI have also noticed that these events coincide with a brief outage of the site (just a minute or two). These events seem to be random. Sometimes there can be 20 events in an hour. Other times it can go for days without a single event.\n\nI am trying to understand what is causing these events and how (or if) I can prevent them. I would prefer not to have my sites go down at all. I can probably mitigate the issue by having multiple instances for each site but even so, I would at least like to have a good answer as to what is going on here.\n\nNote: these sites are deployed to Azure Websites, not Cloud Services (i.e. not Web or Worker Roles)."
] | [
"azure-web-app-service"
] |
[
"Cannot use Image Validation library in validation rule in Laravel",
"I am developing a project using Laravel 5.2. I am working with uploading images. So I need to validate image dimension. So i found a library, https://github.com/cviebrock/image-validator . So I installed that library as follow using composer.\n\nI run this command in terminal:\n\ncomposer require \"cviebrock/image-validator:^2.0\"\n\n\nSo this is auto-added to my composer require:\n\n\"cviebrock/image-validator\": \"^2.0\"\n\n\nThen I added this to provider section in config/app.php\n\nCviebrock\\ImageValidator\\ImageValidatorServiceProvider::class\n\n\nThen I validate like this in controller\n\n$validator = Validator::make($request->all(), [\n 'imge_file'=>'image|image_size:300,300',\n ]);\n\n\nBut validation never fails even I upload image with invalid dimension. What is wrong with my code?"
] | [
"php",
"laravel",
"laravel-5.2"
] |
[
"ParseError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file. (read_csv)",
"I cannot use read_csv method of pandas properly on kaggle. Error that I get is:\nParseError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.\nI found some suggestions about this (read_excel, read by column). However, they do not help me to solve this error."
] | [
"python",
"python-3.x",
"pandas",
"dataframe",
"data-science"
] |
[
"HTML special characters encoding doesn't work after Ajax -> PHP -> MySQL",
"I have a setup which loads data from MySQL with PHP and displays it in HTML. It works so far. All the characters are displayed how they should. But when I click a button to refresh a certain part of the site with $.ajax which calls PHP to refresh MySQL data, some characters are displayed as ?-marks, these are the characters which are MySQL data.\n\nHOME\n\n<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\">\n <script type=\"text/javascript\" src=\"js/jquery.js\"></script>\n <script type=\"text/javascript\">\n $(function() {\n $(\"div#click input\").live(\"click\", function() {\n $(\"div#main\").load(\"main.php\");\n });\n });\n </script>\n </head>\n\n <body>\n <div id=\"main\">\n é¨ûåa\n </div>\n\n <div id=\"click\">\n <input type=\"button\" value=\"click\" onclick=\"return false;\" />\n </div>\n </body>\n</html>\n\n\nMain.php\n\n<?php\n$a = mysql_connect('localhost', 'root', '');\nmysql_select_db('link', $a);\n\n?>\n<div id=\"main\">\nééîüåaa\n\n</div>\n\n<?php\n$r = mysql_query(\"SELECT * from promo;\");\n\nwhile ($row = mysql_fetch_object($r)) {\n $name = $row->name;\n echo $name;\n}\nmysql_close($a);\n?>\n\n\nMySQL table:\n\nCREATE TABLE `promo` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `name` varchar(255) NOT NULL DEFAULT '',\n `link` tinytext NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;"
] | [
"php",
"mysql",
"encoding"
] |
[
"Angular Material Grid Layout",
"What are predefined classes for grid layout in Angular Material? We have \"row\",\"col-sm-4\" etc.. classes in bootstrap. Do we have these type of classes in Angular Material 2?\nThanks."
] | [
"angular",
"material-design",
"angular-material2"
] |
[
"Regex pattern not being detected properly in C#",
"I have a specific pattern I want to follow but the extraction process is not working as expected. I assume the pattern I developed is not correct, but I can't find the issue in it.\n\nI have the string string test1 = \"R1 0.1uF\" and the pattern\n\n\"(?<des>^[a-zA-Z]+)|(?<number>\\d+\\s+)|(?<val>[0-9]*.?[0-9]+)|(?<units>[^,]*)\";\n\nI want it to be extracted as follows:\n\ndes: R\n\nnumber: 1\n\nval: 0.1\n\nunits: uF\n\nCurrently, des is working properly and it's finding R but the others return an empty string.\n\nHere's my code\n\nconst string pattern = @\"(?<des>^[a-zA-Z]+)|(?<number>\\d+\\s+)|(?<val>[0-9]*.?[0-9]+)|(?<units>[^,]*)\";\n\nstring test1 = \"R1 0.1uF\";\n\nRegex r = new Regex(pattern, RegexOptions.Compiled);\n\nMatch m = r.Match(test1);\nstring des = m.Groups[\"des\"].Value;\nstring number = m.Groups[\"number\"].Value;\nstring val = m.Groups[\"val\"].Value;\nstring units = m.Groups[\"units\"].Value;"
] | [
"c#",
"regex"
] |
[
"Look for Table inside a HTML VBA",
"Have the below block of code ...I have 5 tables this responds with but I am interested only in one of the table in the page ...I needed only one table data (a specific one) which the below responds .\n\nI tried \"For Each tbl In ie.Document.getElementsByClassName(\"rgMasterTable\") to get that specific table but this gives me object not supported run time error . How will you get a specific table from a HTMl page which has multiple \"TABLE\" tags\n\n For Each tbl In ie.Document.getElementsByTagName(\"TABLE\")\n tabno = tabno + 1\n nextrow = nextrow + 1\n Set rng = ws.Range(\"B\" & nextrow)\n rng.Offset(, -1) = \"Table \" & tabno\n For Each rw In tbl.Rows\n For Each cl In rw.Cells\n rng.Value = cl.outerText\n Set rng = rng.Offset(, 1)\n I = I + 1\n Next cl\n nextrow = nextrow + 1\n Set rng = rng.Offset(1, -I)\n I = 0\n Next rw\n Next tbl\n\n ws.Cells.ClearFormats\n\n\nThe HTML code looks like this \n\ntable class=\"rgMasterTable\" border=\"0\" id=\"ctl00_ContentBody_rgridCDPList_ctl00\" style=\"width:100%;table-layout:auto;empty-cells:show;\""
] | [
"vba"
] |
[
"Applescript: number each sublist of a list containing a word according to the occurrence of that word in the list",
"I have a list like this:\n\n {{\"269\", \"It\"}, {\"439\", \"was\"}, {\"509\", \"the\"}, {\"829\", \"best\"}, {\"1059\", \"of\"}, {\"1350\", \"times\"}, {\"1449\", \"it\"}, {\"2089\", \"was\"}, {\"2659\", \"the\"}, {\"3250\", \"worst\"}, {\"3429\", \"of\"}, {\"3529\", \"times\"}, {\"4219\", \"it\"}, {\"4519\", \"was\"}, {\"5210\", \"the\"}, {\"5629\", \"age\"}, {\"6049\", \"of\"}, {\"6279\", \"wisdom\"}, {\"6599\", \"it\"}, {\"6659\", \"was\"}, {\"6839\", \"the\"}, {\"7399\", \"age\"}, {\"of\"}, {\"7639\", \"foolishness\"}, {\"8019\", \"it\"}, {\"8619\", \"was\"}, {\"9369\", \"the\"}, {\"9477\", \"epoch\"}, {\"9682\", \"of\"}, {\"9897\", \"belief\"}}\n\n\nand I want it to also have number associated with each occurrence of each word in sequence:\n\n{{\"269\", \"It\", 1}, {\"439\", \"was\", 1}, {\"509\", \"the\", 1}, {\"829\", \"best\", 1}, {\"1059\", \"of\", 1}, {\"1350\", \"times\", 1}, {\"1449\", \"it\", 2}, {\"2089\", \"was\", 2}, {\"2659\", \"the\", 2}, {\"3250\", \"worst\", 1}, {\"3429\", \"of\", 2}, {\"3529\", \"times\", 2}, {\"4219\", \"it\", 3}, {\"4519\", \"was\", 3}, {\"5210\", \"the\", 3}, {\"5629\", \"age\", 1}, {\"6049\", \"of\", 3}, {\"6279\", \"wisdom\", 1}, {\"6599\", \"it\", 4}, {\"6659\", \"was\", 4}, {\"6839\", \"the\", 4}, {\"7399\", \"age\", 2}, {\"of\" 4}, {\"7639\", \"foolishness\", 1}, {\"8019\", \"it\", 4}, {\"8619\", \"was\", 5}, {\"9369\", \"the\", 5}, {\"9477\", \"epoch\", 1}, {\"9682\", \"of\", 5}, {\"9897\", \"belief\", 1}}\n\n\nI tried to modify the script mklement0 gave me like this:\n\nset inList to {{\"269\", \"It\"}, {\"439\", \"was\"}, {\"509\", \"the\"}, {\"829\", \"best\"}, {\"1059\", \"of\"}, {\"1350\", \"times\"}, {\"1449\", \"it\"}, {\"2089\", \"was\"}, {\"2659\", \"the\"}, {\"3250\", \"worst\"}, {\"3429\", \"of\"}, {\"3529\", \"times\"}, {\"4219\", \"it\"}, {\"4519\", \"was\"}, {\"5210\", \"the\"}, {\"5629\", \"age\"}, {\"6049\", \"of\"}, {\"6279\", \"wisdom\"}, {\"6599\", \"it\"}, {\"6659\", \"was\"}, {\"6839\", \"the\"}, {\"7399\", \"age\"}, {\"of\"}, {\"7639\", \"foolishness\"}, {\"8019\", \"it\"}, {\"8619\", \"was\"}, {\"9369\", \"the\"}, {\"9477\", \"epoch\"}, {\"9682\", \"of\"}, {\"9897\", \"belief\"}}\nset word_list to {}\nrepeat with i from 1 to (length of inList)\n set the_word to item i of inList\n if item 2 of the_word is word then\n set outList to outList & {{contents of the_word, 1 + (my countOccurrences(contents of inList, word_list))}}\n end if\nend repeat\n\n\nIt give me an error:\n \"Can’t get item 2 of {\\\"of\\\"}.\" number -1728 from item 2 of {\"of\"}\n\nClearly I don't even know where to start for this one. \n\nAny help would be hugely appreciated."
] | [
"applescript"
] |
[
"IndexError: pop index out of range (python)",
"I wrote the following merge sort code:\n\ndef merge_sort(self,a):\n\n #console.log(len(a))\n if len(a) <= 1:\n return a\n left = []\n right = []\n result = []\n middle = int(len(a)/2)\n print middle\n\n left = a[:middle] #set left equal to the first half of a\n right = a[middle:] #set right equal to the second half of a\n print left\n print right\n\n left = self.merge_sort(left)\n right = self.merge_sort(right)\n result = self.merge(left, right)\n\n return result\n\n\nAnd then merging code:\n\ndef merge(self, left, right):\n result = []\n while len(left) > 0 or len(right) > 0:\n\n if len(left) > 0 and len(right) > 0:\n if left[0] <= right[0]:\n result.append(left[0])\n left = left.pop(1) #remove the first element from left\n\n elif len(left) > 0:\n result.append(left[0])\n left = left.pop(1) #remove the first element from left\n\n elif len(right) > 0:\n result.append(right[0])\n right = right.pop(1) #remove the first element from right\n\n else:\n result.append(right[0])\n right = right.pop(1)\n return result\n\n\nI send it the array:\n a = [12,0,232]\n\nAnd I get the following outputs (different iterations) and at the last output I get the error, Please help I don't understand exactly why the error is there thank you!:\n\n(1\n[12]\n[0, 232])\n(1\n[0]\n[232])\n\nTraceback (most recent call last):\n...\\Sort_Class.py\", line 116, in merge\n left = left.pop(1) #remove the first element from left\nIndexError: pop index out of range"
] | [
"python",
"sorting",
"merge"
] |
[
"Mobile app using cordova-plugin-firebase receives push notifcations on iOS only the second time it's opened",
"I'm developing a mobile app for Android and iOS with PhoneGap Build. The app should be able to communicate with Firebase and receive push notifications from there, so im using this plugin https://www.npmjs.com/package/cordova-plugin-firebase.\nOn Android, everything works fine, but on iOS, push notifications are not received until I close the app and open it a second time.\n\nWhen I open the app for the first time, the FirebasePlugin.grantPermission() method works, so there's a message asking for permission to receive notifications, and when I use\n\nwindow.FirebasePlugin.hasPermission(function(data){\n console.log(data.isEnabled);\n});\n\n\ndata.isEnabled equals true. So, the plugin seems to be running, but no notifications are being received.\n\nI found this related question: Cordova plugins only work in iOS the second time its opened with a THREAD WARNING. How do you get plugins to initialize onload?, but none of the suggested solutions worked for me.\nAs mentioned there, I added\n\ncordova.exec.setJsToNativeBridgeMode(cordova.exec.jsToNativeModes.XHR_NO_PAYLOAD);\n\n\nat the beginning of the deviceReady callback, but the setJsToNativeBridgeMode method as well as jsToNativeModes.XHR_NO_PAYLOAD do not exist.\nI also added gap: gap://ready after both default-src and frame-src inside the <meta http-equiv=\"Content-Security-Policy\" tag in index.html, but it didn't work.\n\nDoes someone have any idea how to explain and prevent this strange behavior? I'd really appreciate some help."
] | [
"ios",
"cordova",
"firebase",
"cordova-plugins",
"firebase-cloud-messaging"
] |
[
"How to correctly float lists",
"I'm having a hard time with floats. I am trying to float the list on the header and footer to the right and keep the image on the left. \n\nhttp://jsfiddle.net/spadez/KYdnJ/21/\n\nWhen I add in the floats the layout goes all screwy. This is the CSS which is relevant:\n\n#header {\n line-height: 50px;\n background-color: #F2F2F2;\n border-bottom: solid 1px #E8E8E8;\n padding: 0px 20px 0px 20px;\n}\n#header li { \n font-family: arial, sans-serif; \n background-color: #D3D3D3; \n display: inline-block; \n font-weight: bold; \n line-height: 28px; \n padding: 0px 9px 0px 9px; \n font-size: 12px;\n float: right;\n}\n#header img {\n height: 40px;\n float: left;\n}\n\n\nCan anyone tell me where I am going wrong please?"
] | [
"html",
"css"
] |
[
"Moving Average Time Series Minutes Pandas",
"In this problem, I am trying to get moving averages in this dataframe.\nThere are different number of transactions happening each minute. Corresponding to each transaction, i am trying to get MA of all the flow values happening in previous 2 minutes of that transaction( Assume at time t)\n\nm = timedelta(minutes = 1)\nfor dt in df.DateTime: # for dt time row in datetime column\n obs(dt-m)= Flow(df.iloc[dt-m,1]).mean #Calculate mean of flow values happening at one minute before dt time\n obs(dt-m*2)= GPL_Density(df.iloc[dt-m*2,1]).mean #Calculate mean of flow values happening at two minutes before dt time\n df.loc[df.GPL_Density]= (obs(dt-m),obs(dt-m*2)).mean\n\n\nDateTime Flow\n1/11/2017 6:01 600\n1/11/2017 6:01 600\n1/11/2017 6:02 600\n1/11/2017 6:02 600\n1/11/2017 6:02 600\n1/11/2017 6:02 600\n1/11/2017 6:03 780\n1/11/2017 6:03 780\n1/11/2017 6:03 780\n1/11/2017 6:04 480\n\n\n\n\n\n````````````````````````````````````````````````````````````````````"
] | [
"python",
"pandas",
"time-series",
"moving-average"
] |
[
"Unable to switch language in Firefox only in input-password",
"Have a very strange issue that I haven't encountered before, \n\nTake for example: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_submit and replace the input type=text to password like this:\n\n<form action=\"/action_page.php\">\nFirst name: <input type=\"text\" name=\"FirstName\" value=\"Mickey\"><br>\nLast name: <input type=\"password\" name=\"LastName\" value=\"Mouse\"><br>\n<input type=\"submit\" value=\"Submit\">\n</form>\n\n\nFor some reason, in Firefox only I'm unable to switch the languages for the input[type=password], therefor, my passwords don't work in the app, in every other browser the password input works fine with switching the language ...\n\nAlso, in FF, if I change the input back to text - then I'm able to switch languages ...\n\nI'm using MacOSX & Firefox Quantum 65.0.1 (64-bit)\n\nAny ideas ?"
] | [
"firefox"
] |
[
"reading header of each part in multipart request in Scala Play",
"I am trying to extract headers of each part in multipart request using Scala play.\nThe inbuilt multipart handler parses data in Filepart. Filepart doesn't have any option to read individual headers of each part. It only has access to content type header.\n\nIs there any ready to use API for this? OR is there simple way to handle it rather in writing a new custom BodyParser."
] | [
"scala",
"playframework",
"multipart",
"mixed"
] |
[
"Reading Serial Port Data",
"I am trying to read in serial port data in C on Mac OS. Configuration of serial port is done in separate Arduino IDE.\n\nI am able to read partial data, but then the printed data repeats itself and starts reading zeros as seen below. If I remove O_NONBLOCK, the program just hangs. What can I do to fix this problem? Secondly, given that I am reading in data in a for loop, how do I make sure the read rate corresponds with the baud rate?\n\nSeen data: \n296 310 0\n\n320 295 311\n\n320 295 311\n\n9 296 311\n\n320 295 311\n\n320 295 311\n\n9 296 311\n\n...\n\n0 0 0\n\n0 0 0\n\n0 0 0\netc.\n\n#include <stdio.h>\n#include <string.h>\n#include <unistd.h>\n#include <fcntl.h>\n\nint buffer[300];\n\nint main(int argc, const char* argv[])\n{\n\n // open serial port\n int port;\n port = open(\"/dev/tty.usbmodem1411\", O_RDONLY | O_NONBLOCK);\n if (port == -1)\n {\n printf(\"Unable to open serial port.\\n\");\n return 1;\n }\n\n // instantiate file\n FILE* file = fdopen(port, \"r\");\n if (file == NULL)\n {\n printf(\"Unable to instantiate file.\\n\");\n close(port);\n return 2;\n }\n\n for (int j = 0; j < 200; j++)\n {\n\n fscanf(file, \"%d %d %d\", &buffer[3*i], &buffer[3*i+1], &buffer[3*i+2]);\n printf(\"%d %d %d\\n\", buffer[3*i], buffer[3*i+1], buffer[3*i+2]);\n\n i = (i + 1) % 100;\n\n usleep(10000);\n\n }\n\n fclose(file);\n close(port);\n\n return 0;\n\n}"
] | [
"c",
"file-io",
"serial-port",
"arduino",
"arduino-ide"
] |
[
"How to store multiple values in one field of a MySQL table column?",
"I want to create table stops for all stops with these columns id, name,route, lat, long, arrivaltime but I dont know how can I manage it to get the route column in the stops table? since the one route has many numbers?\n\n{\n \"id\": 1\n \"stops_name\": \"Amersham \",\n \"route\": \"8,4,7,34,45,8017, 57, 20,......... 30 entries\"\n \"arrival_time\": {\n \"mon-fri\": [ \"05:38\", \"06:07\",\"06:37\",.....50 entries],\n \"sat\": [\"05:34\",\"06:01\",\"06:31\",...........50 entries],\n \"son\": [\"06:02\",\"06:34\",\"07:04\",...........50 entries]\n },\n \"stops_lat\": 83.837994,\n \"stops_long\": 18.700423\n }\n\n\n\nstt.execute(\"CREATE TABLE IF NOT EXISTS stops\"\n + \"(stop_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, \"\n + \" name varchar(30) NOT NULL, \"\n + \" route INT(11) NOT NULL, \"\n + \" lat double(10,6) NOT NULL, \"\n + \" longi double(10,6)NOT NULL) \" );\n\nstt.execute(\"CREATE TABLE IF NOT EXISTS arrivaltimes(id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\"\n + \" weekday VARCHAR(20) NOT NULL,\"\n + \"arrivaltime time NOT NULL,\"\n + \" stop_id INT, FOREIGN KEY fk_stop_id(stop_id) REFERENCES stops(stop_id) )\" );"
] | [
"java",
"mysql",
"sql",
"jdbc"
] |
[
"Power BI Dax Error - The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value",
"I'm effectively trying to accomplish what is demonstrated in this how to video, except to calculate production line down time data between stops/starts, but the logic gives the subject error. This error does not occur in the demonstration, so I don't understand where the issue is.\nCan someone please help advise, or is there a better way to accomplish the above task relative to the data example provided below? There are ~27 unique events that will always have a stop/start before a new event can take place and I need to calculate the downtime between each stop/start.\nhttps://www.youtube.com/watch?v=Q8iri3G1_x4\ntimeDurations = \nVAR indexNumber = MAX(Data[Index])\nVAR previousIndexNumber = CALCULATE( MAX(Data[Index]), FILTER( ALLSELECTED(Data), Data[Index] < indexNumber))\nVAR stopTime = VALUE( SELECTEDVALUE(Data[TimeStamp]))\nVAR startTime = VALUE( CALCULATE( SELECTEDVALUE(Data[TimeStamp], FILTER( ALL(Data), Data[Index] = previousIndexNumber))))\n\nRETURN\nIF( indexNumber = CALCULATE( MIN(Data[Index], ALLSELECTED(Data))), \n 0,\n stopTime - startTime)"
] | [
"powerbi",
"dax"
] |
[
"redirect CreateProcess output to Shared Memory created Using CreateFileMapping VC++",
"I have a Main VC++ application which is creating the shared memory as in below code:\n\nif (m_hMapFile == NULL)\n{\n SECURITY_ATTRIBUTES structSecurityAttr = { 0 };\n\n m_hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, &structSecurityAttr, PAGE_READWRITE | SEC_COMMIT, 0, BUF_SIZE, (LPCSTR)(LPCTSTR)szName);\n\n if (m_hMapFile == NULL)\n {\n DWORD dwError = GetLastError();\n CString strError;\n strError.Format(_T(\"%lu\"), dwError);\n return FALSE;\n }\n\n pSharedMemBuf = (LPTSTR)MapViewOfFile(m_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE);\n if (pSharedMemBuf == NULL)\n {\n return FALSE;\n }\n //Initialize the Shared Memory. \n ZeroMemory((void *)pSharedMemBuf, BUF_SIZE);\n}\n\n\nFrom a thread of this main process I am mapping to the shared memory as below:\n\nif (m_hMapFile == NULL)\n{\n //Open the Named Shared Memory \n m_hMapFile = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE | FILE_MAP_COPY, TRUE, (LPCSTR)(LPCTSTR)szName); //FILE_MAP_ALL_ACCESS\n if (m_hMapFile == NULL)\n {\n return FALSE;\n }\n\n //Get the Shared Memory Buffer Pointer.\n pSharedMemBuf = (LPTSTR)MapViewOfFile(m_hMapFile, FILE_MAP_READ | FILE_MAP_WRITE | FILE_MAP_COPY/*FILE_MAP_ALL_ACCESS*/, 0, 0, BUF_SIZE);\n\n DWORD error = GetLastError();\n\n //If Shared Memory Buffer is NULL then return the control\n if (pSharedMemBuf == NULL)\n {\n CString strSize;\n strSize.Format(_T(\"Error is %d\"), error);\n return FALSE;\n }\n}\n\n\nNow, I want to redirect the output of the CreateProcess call to this shared memory. I am giving the FileMapping's STARTUPINFO as below:\n\nsi.hStdOutput = m_hMapFile;\nsi.hStdError = m_hMapFile;\n\n\nThen creating the process as below:\n\nCreateProcess( NULL, szCombinedCmd, &saAttr, NULL, TRUE, \n dwCreateFlags, NULL, pszCurrentDirectory, &si, &pi );\n\n\nBut, When I am trying to read the shared memory I am not getting the output into the buffer. Please help me how to achieve this."
] | [
"visual-c++",
"mfc",
"createprocess"
] |
[
"Generate array[0-k] for number of distinct sub-strings that are exactly 0 to k-repeated of a string using Suffix Array + LCP",
"I search over the internet: I found many solutions of k-repeated substrings usinf Suffix tree but not using Suffix array.\n\nGiven string: abaababb\nMaximum number of repeated sub-strings ,k = length of string = 6\n\ninitially a[0..k]={0}\n\nFrequency of sub-string: \"a\"= 4\ntherefore a[4]=1;\n\nFrequency of sub-string: \"ab\"= 3\ntherefore a[3]=1;\n\nFrequency of sub-string: \"b\"= 4\ntherefore a[4]= a[4]+1 = 2;\nand so on..\n\nComplexity: < O(nlogn) for array generation.\n\nUsing Suffix array:\n\nSuffixes of \"abaababb\":\n\nLCP INDEX\n\n0 2 aababb\n\n1 0 abaababb\n\n3 3 ababb\n\n2 5 abb\n\n0 7 b\n\n1 1 baababb\n\n2 4 babb\n\n1 6 bb"
] | [
"string",
"suffix-array"
] |
[
"Add class properties to a provided Bundle : how to?",
"Our team is having a bit of a headache while modifying our core model.\n\nOur problem :\n\nWe have a bundle, let's name it COREBundle. We load it via composer on every app to get the very basic required to boot our system.\n\nThe COREBundle provides a Customer Entity. \nEach app has some special customer properties that we want to add : how to proceed ?\nOf course the complexity here is to make everything work with the COREBundle provided. \n\nWe are exploring the idea of having some MappedSuperClasses but it means we will need to modify all our entities in ALL our apps, which will be extremely time-consuming.\n\nHelp? Thank you!"
] | [
"php",
"symfony",
"doctrine-orm",
"doctrine",
"symfony-2.3"
] |
[
"Reading the first UVarInt of a net.Conn buffer",
"I have a TCP packet connection (net.Conn) set up by listening on a port.\n\nconn, err := ln.Accept()\n\n\nI need to read the first UVarInt of the Conn.Read([]byte) buffer, which starts at index 0.\n\nPreviously, I would only need the first byte, which is easy to do using\n\npacketSize := make([]byte, 1)\nconn.Read(packetSize)\n// Do stuff with packetSize[0]\n\n\nHowever, as previously mentioned, I need to get the first UVarInt I can reach using the net.Conn.Read() method. Keep in mind that a UVarInt can have pretty much any length, which I cannot be sure of (the client doesn't send the size of the UVarInt). I do know however that the UVarInt starts at the very beginning of the buffer."
] | [
"go",
"tcp",
"tcpserver"
] |
[
"Is time.sleep(n) a good way to wait in a python script or should I use an external module?",
"Just wondering if I should use that, or an external script like TwistedSheduler for \"suspending\"\n\nthanks"
] | [
"python-3.x"
] |
[
"How to hide a tab in Angular Bootstrap UI using ng-show/ng-hide",
"I am using Angular Bootstrap UI to show a tabset. The script I include is ui-bootstrap-tpls-0.6.0.min.js and some template html files.\n\nhere is my markup:\n\n<tabset>\n <tab ng-hide=\"!hideme\">\n <tab-heading>\n tab1\n </tab-heading>\n <div>\n tab content 1\n </div>\n </tab>\n <tab ng-hide=\"hideme\">\n <tab-heading>\n tab2\n </tab-heading>\n <div>\n tab content 2\n </div>\n </tab>\n</tabset>\n\n\nhere is my controller\n\nfunction myController($scope) {\n $scope.hideme = true;\n});\n\n\nThis code does not work (the 2nd tab does not hide).\nWhat is the catch to apply ng attribute to a custom directive?"
] | [
"twitter-bootstrap",
"angularjs",
"angularjs-directive"
] |
[
"Is there a delay after a full garbage collection before WeakReference.IsLive() becomes false?",
"I have written a unit test to comfirm the “Dispose” on my class does unhooks all events and disposes a timer that references the object. \n\nHowever sometimes WeakReference.IsLive() returns true when I would expect it to return false?\n\nSo is there a delay after a full GC before WeakReference.IsLive() is updated?\n\nIf not, can you think of anything else that would be giving me unrepeatable results?\n\nWeakReference weekJobWatchDog = new WeakReference(jobWatchDog);\njobWatchDog = null;\n\n// not collected before Dispose called due to timer and events etc\nGC.Collect(); GC.Collect();\nAssert.IsTrue(weekJobWatchDog.IsAlive);\n\n((IDisposable)weekJobWatchDog.Target).Dispose();\n\n// is now collected as Dispose unlocked all events and dispoed the timer\nGC.Collect(); GC.Collect();\nAssert.IsFalse(weekJobWatchDog.IsAlive); // sometimes this fails, about 1 in 4 runs\n\n\n\n\nSee also Testing Finalizers and IDisposable for a related but different question.\n\nHow can I write a unit test to determine whether an object can be garbage collected? has a soltuion that includes calling GC.WaitForPendingFinalizers(), however I rather not call GC.WaitForPendingFinalizers() as I wish to prove that my dispose works and if it worked there will be no need for any finalizers to run."
] | [
".net",
"unit-testing",
"garbage-collection",
"dispose"
] |
[
"Want to designate name of created data frames in for loop",
"I am trying to remove certain rows from each of my created data frames. I want to perform the same commands on each data frame by using a for loop. I have data frames named participant1, participant2, participant3, ... . Each data frame has the same name with ascending numbers at the end. My code works if I input the name of each individual data frame in it. I just want to create a loop that will do it for all the data frames at once (and maintain every data frame in the process). Each data frame has the same dimensions.\nlazy = numeric()\nfor (x in 1:nrow(participant1){\n if (participant1[x, 1] == participant1[x, 3]){\n lazy <- c(lazy, as.numeric(x))\n }else if (participant1[x, 3] == 0){\n lazy <- c(lazy, as.numeric(x))\n }\n}\nparticipant1 <- participant1[-(lazy), ]\n\nEvery place where I have "participant1" I want to be able to substitute it for each data frame I have (participant2, participant3...)."
] | [
"r",
"loops"
] |
[
"Trying to save different model before creation?",
"I am trying to add a user role according to Rolify gem in my devise User model.\n\nWhat I basically want to achieve is that, if the user has selected that he is a student or a teacher in the registration page itself, after the creation of the user, it should add the required roles to the user.\n\nPlease note that I am not storing the 'role' in the User table. I am just using attr_accessor to send me an initial value to compare.\n\nThis is my User model code :\n\n# == Schema Information\n#\n# Table name: users\n#\n# id :integer not null, primary key\n# email :string(255) default(\"\"), not null\n# encrypted_password :string(255) default(\"\"), not null\n# reset_password_token :string(255)\n# reset_password_sent_at :datetime\n# remember_created_at :datetime\n# sign_in_count :integer default(0), not null\n# current_sign_in_at :datetime\n# last_sign_in_at :datetime\n# current_sign_in_ip :string(255)\n# last_sign_in_ip :string(255)\n# created_at :datetime not null\n# updated_at :datetime not null\n# avatar :string(255)\n# username :string(255)\n#\n\nclass User < ActiveRecord::Base\n # This is for the user roles.\n rolify\n # Include default devise modules. Others available are:\n # :confirmable, :lockable, :timeoutable and :omniauthable\n devise :database_authenticatable, :registerable,\n :recoverable, :rememberable, :trackable, :validatable\n\n attr_accessor :role\n # Adding the carrierwave uploader\n mount_uploader :avatar, AvatarUploader\n\n\n before_create :add_specified_role\n\n def add_specified_role\n if self.role == 0\n # I am sure I am messing it up here and this is not the way.. :/\n after_create :add_student_role\n elsif self.role == 1\n after_create :add_teacher_role\n end\n end\n\n\n def add_student_role\n self.add_role(:student) if self.roles.blank?\n end\n\n\n def add_teacher_role\n self.add_role(:teacher) if self.roles.blank?\n end\n\n\nend\n\n\nHowever, it does not seem to be working as when I check the roles, the role has not been added and I am sure I am doing something wrong. \n\nWhat is the correct way to achieve the above task?"
] | [
"ruby-on-rails",
"ruby",
"devise",
"rolify"
] |
[
"How to put data in gundb at server side as a peer",
"I thought gun instance in the server was also one of the peers.\nBut when I put data on the server, the peer can't get the data.\n\nHere is my simple test code.\n\nglobal.gun.get('servertest').put('yes'); // at server side\n\n\ngun.get('servertest').once(console.log); // at client side\n\n\nAnd it prints undefined. \nplease, let me know how to use a gun instance on server side."
] | [
"gun",
"gundb"
] |
[
"Stop task when there is an exception thrown in ItemProcessor",
"I am designing a Spring Batch, which reads multiple csv files. I have used partitioning to read each file in chunk and process it to decrypt a certain column in the csv. Before decrypting if i encounter any validation error , i throw custom exception.\n\nNow what i want is if the processing finds any validation error in the first line, the other lines should not be processed, and the job should end.\nHow can i achieve this? I tried to implement ProcessorListener too but it has no StepExecution object so that i can call SetTerminateOnly() or ExitStatus=Failed\n\nAlso note that i have multiple thread accessing the file in different lines.I want to kill all threads in the event of the first encountered error.\n\nThanks in advance"
] | [
"spring-batch",
"batch-processing"
] |
[
"How to Show Disk Usage via PHP?",
"Does anyone have a PHP script to share that displays current server disk usage?\n\nThanks."
] | [
"php",
"diskspace"
] |
[
"Receiving change notification from AD in LDAP(JAVA)",
"Help me in receiving change notification in LDAP(Java).When an object(user modifies their entry) I've Searched several resources but unable to move further."
] | [
"java",
"active-directory",
"ldap",
"change-notification"
] |
[
"ffmpeg build for android.error:./obj/local/arm64-v8a/libavcodec.so: error adding symbols: File in wrong format",
"Android.mk:\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := avcodec\nLOCAL_SRC_FILES := libavcodec.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := avdevice\nLOCAL_SRC_FILES := libavdevice.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := avfilter\nLOCAL_SRC_FILES := libavfilter.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := avformat\nLOCAL_SRC_FILES := libavformat.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := avutil\nLOCAL_SRC_FILES := libavutil.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := swresample\nLOCAL_SRC_FILES := libswresample.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := swscale\nLOCAL_SRC_FILES := libswscale.so\ninclude $(PREBUILT_SHARED_LIBRARY)\n\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := ffmpeg_main\nLOCAL_SRC_FILES := com_piyingke_app_common_ffmpeg_FFmpegUtil.c \\\n com_piyingke_app_common_ffmpeg_FFmpegUtil.h\nLOCAL_C_INCLUDES += $(LOCAL_PATH)/include\nLOCAL_LDLIBS := -llog -lz\nLOCAL_SHARED_LIBRARIES := avcodec avdevice avfilter avformat avutil swresample swscale\ninclude $(BUILD_SHARED_LIBRARY)\n\nAnd i get an error :\n\n./obj/local/arm64-v8a/libavcodec.so: error adding symbols: File in wrong format\nclang++: error: linker command failed with exit code 1 (use -v to see invocation)\nmake: *** [obj/local/arm64-v8a/libffmpeg_main.so] Error 1\n\nWhat should i do?Who can help me."
] | [
"android",
"ffmpeg"
] |
[
"Use Cases of UIImagePickerController and ALAssetsLibrary",
"I'm just wondering that, In which cases we should use UIImagePickerController and ALAssetsLibrary. \n\nI gone through ALAssetsLibrary class reference and UIImagePickerController class reference and \nI found that \n\n\nUIImagePickerController can capture image/video on the fly as well and ALAssetsLibrary can only list media and photo.\nALAssetsLibrary can list photos coming from iTunes, and those that were directly imported into the device.\nWith the help of UIImagePickerController you can choose media as well.\n\n\nBut still I'm not clear about the use cases of these two classes. I mean if I can list photos/media and choose those by using UIImagePickerController, than what's the real use of ALAssetsLibrary. Any Ideas?"
] | [
"ios",
"cocoa-touch",
"uiimagepickercontroller",
"alassetslibrary"
] |
[
"What is the SQLite command for getting the data between a start and end time?",
"Let's say my database is called \"data\" and its second column is called \"datetime\". The format of my datetime is \"7/22/2011 12:00:00\". If I want to get the the information between 12:00 and 13:00 today, how do I do that?\n\nSELECT * FROM data WHERE \nstrftime('%m/%d/%Y %H:%M:%S', datetime) > strftime('%m/%d/%Y %H:%M:%S', '7/22/2011 12:00:00') \nAND \nstrftime('%m/%d/%Y %H:%M:%S', datetime) < strftime('%m/%d/%Y %H:%M:%S', '7/22/2011 13:00:00')\n\n\ndoesn't do the trick."
] | [
"database",
"sqlite",
"strftime"
] |
[
"portable python 3.x and pygame",
"I am looking for version (custom/beta?) of portable python that is python 3.x and includes pygame. I know pygame hasn't been fully converted to 3.x yet, but for what I need it for it works perfectly."
] | [
"python",
"python-3.x",
"pygame",
"portable-executable"
] |
[
"Receiving this error. No visible @interface for 'UIViewController' declares the selector 'presentViewController'",
"The problem is at the if ([[topViewController presentViewController] line:\n\n(void)sessionStateChanged:(FBSession *)session\n state:(FBSessionState) state\n error:(NSError *)error\n{\n switch (state) {\n case FBSessionStateOpen: {\n UIViewController *topViewController =\n self.navController topViewController];\n\n if ([[topViewController presentViewController]\n isKindOfClass:[PBLoginViewController class]]) {\n [topViewController dismissViewControllerAnimated:YES completion:nil];"
] | [
"selector",
"viewcontroller",
"visible"
] |
[
"Find Autosys jobs which were put ON_HOLD and ON_ICE last 24hrs",
"Can you please advise how we can filter our jobs which were put ON_HOLD and ON_ICE last 24hrs/2 days and still not released without access to autosys database.\nI have tried using\nautotrack -v -J MY_APP% -F '02/15/2021 00:00'\nBut it listing all type of changes ( JIL change, Calendar change)\nalso the Can we list out job names alone.\nRegards,\nVeera"
] | [
"autosys"
] |
[
"How to get data in express js",
"For the first time ever i am trying to understand expressJs and I have testing route which returns simple test sentence as JSON, but i can't get in in expressJs.\n\ntest.js\n\nvar express = require('express');\nvar router = express.Router();\n\n/* GET home page. */\nrouter.get('https://mysite.ccc/api/test', function(req, res, next) {\n res.json(data)\n});\n\nmodule.exports = router;\n\n\napps.js\n\nvar createError = require('http-errors');\nvar express = require('express');\nvar path = require('path');\nvar cookieParser = require('cookie-parser');\nvar logger = require('morgan');\n\nvar indexRouter = require('./routes/index');\nvar testRouter = require('./routes/test'); ////////////////////////////////////////////////////////here\n\nvar app = express();\n\n// view engine setup\napp.set('views', path.join(__dirname, 'views'));\napp.set('view engine', 'jade');\n\napp.use(logger('dev'));\napp.use(express.json());\napp.use(express.urlencoded({ extended: false }));\napp.use(cookieParser());\napp.use(express.static(path.join(__dirname, 'public')));\n\napp.use('/', indexRouter);\napp.use('/test', testRouter); ////////////////////////////////////////////////////////here\n\n// catch 404 and forward to error handler\napp.use(function(req, res, next) {\n next(createError(404));\n});\n\n// error handler\napp.use(function(err, req, res, next) {\n // set locals, only providing error in development\n res.locals.message = err.message;\n res.locals.error = req.app.get('env') === 'development' ? err : {};\n\n // render the error page\n res.status(err.status || 500);\n res.render('error');\n});\n\nmodule.exports = app;\n\n\nI'm not sure but i guess it suppose to show my api sentence in http://127.0.0.1:3000/test instead with:\n\nthis command: set DEBUG=myapp:* & npm start it says: 404 not found\n\nand with this command npm start it says request is not defined\n\nwhat did i do wrong?"
] | [
"node.js",
"express"
] |
[
"Magento addCc in transactional email",
"I am trying to send CC to another email using the previously-mentioned code,\n\nand I am getting the following error:\n\nVarien_Exception Object ( [message:protected] => Invalid method Mage_Core_Model_Email_Template::addCc(Array ( [0] => [email protected] ) ) [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/domains/alldaychemist/lib/Varien/Object.php [line:protected] => 652 [trace:Exception:private] => Array ( [0] => Array ( [file] => /var/domains/alldaychemist/adminuser.php [line] => 59 [function] => __call [class] => Varien_Object [type] => -> [args] => Array ( [0] => addCc [1] => Array ( [0] => [email protected] ) ) ) [1] => Array ( [file] => /var/domains/alldaychemist/adminuser.php [line] => 59 [function] => addCc [class] => Mage_Core_Model_Email_Template [type] => -> [args] => Array ( [0] => [email protected] ) ) ) [previous:Exception:private] => )\n\n\nWhen ever I send the email using the below code I get this error, \n\n-Invalid method Mage_Core_Model_Email_Template::addCc\n\n\nMy code looks like this:\n\n$templateId = 15;\n\n// Set sender information\n$senderName = Mage::getStoreConfig('trans_email/ident_support/name');\n$senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');\n$sender = array('name' => $senderName,\n 'email' => $senderEmail);\n\n// Set recepient information\n$recepientEmail = 'adcc@gmailcom';\n$recepientName = 'John Doe'; \n\n// Get Store ID\n$store = Mage::app()->getStore()->getId();\n\n// Set variables that can be used in email template\n$vars = array('customerName' => '[email protected]',\n 'customerEmail' => 'Mr. Nil Cust');\n\n$translate = Mage::getSingleton('core/translate');\n\n// Send Transactional Email\ntry{\nMage::getModel('core/email_template')\n->addCc('[email protected]')\n->addBcc('[email protected]')\n->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);\n}\ncatch(Exception $e){\n print_r($e);\n} \n\n$translate->setTranslateInline(true);"
] | [
"php",
"magento",
"magento-1.7",
"magento-1.8",
"magento-1.9.1"
] |
[
"Access Token for Dockerhub",
"I created a repository on hub.docker.com and now want to push my image to the Dockerhub using my credentials. I am wondering whether I have to use my username and password or whether I can create some kind of access token to push the docker image.\n\nWhat I want to do is using the docker-image resource from Concourse to push an image to Dockerhub. Therefore I have to configure credentials like:\n\ntype: docker-image\nsource:\n email: {{docker-hub-email}}\n username: {{docker-hub-username}}\n password: {{docker-hub-password}}\n repository: {{docker-hub-image-dummy-resource}}\n\n\nand I don't want to use my Dockerhub password for that."
] | [
"authentication",
"docker",
"docker-registry",
"concourse"
] |
[
"Reading Input and Error Streams Concurrently using BufferedReaders Hangs",
"First off let me apologize to the SO community for coming to you with something that ought to be so trivial. But I've been at this all day and I'm at the end of my rope.\n\nThere is a section of my program that needs pull text from an input stream and an error stream from a process that is launched using Runtime.getrunTime().exec() and pass it through to standard input and output in an orderly manner. I have a function that near as I can tell should work. But it seems to be getting caught in a catch-22 where it's waiting for the stream to report ready - but the stream has finished and is not reporting. I'm baffled. I can't think of another way to do this that fits my constraints and I'm rather skeptical that such a catch-22 can exist. \n\nHere is my code:\n\nprivate void forwardStreamtoStd(InputStream in, InputStream err) \nthrows IOException {\n int c = -1;\n BufferedReader inReader = new BufferedReader(\n new InputStreamReader(in, \"US-ASCII\"));\n BufferedReader errReader = new BufferedReader(\n new InputStreamReader(err, \"US-ASCII\"));\n boolean inFinished = false, errFinished = false;\n\n try {\n System.out.println(\"Begin stream read loop...\");\n while (!inFinished && !errFinished) {\n if (!inFinished) {\n while (inReader.ready()) {\n if ((c = inReader.read()) == -1) {\n inFinished = true;\n } \n else {\n System.out.print((char) c);\n }\n }\n }\n\n if (!errFinished) {\n while (errReader.ready()) {\n if ((c = errReader.read()) == -1) {\n errFinished = true;\n } \n else {\n System.err.print((char) c);\n }\n }\n }\n }\n System.out.println(\"End stream read loop.\");\n } \n catch (IOException e) {\n throw e;\n } \n finally {\n errReader.close();\n inReader.close();\n }\n}\n\n\nThe problem seems to be that the reading loops are waiting for the streams to report ready, and as a result aren't seeing the -1 returned by read telling them that it's time to quit. I'm trying to avoid having either stream blocking, so that I can pull from both in turn when they are prepared. However, how can I catch the process's end of stream? Am I missing something? Shouldn't read report that it's read when it has an end of stream -1? The processes are finishing, and so their streams should be dying. What am I doing wrong here?"
] | [
"java",
"input",
"runtime"
] |
[
"Resetting generated widget count in Python with Tkinter",
"Using Python 3.7 - Working in Pycharm\n\nI am currently working on a project where I am constantly generating new widgets and removing them to show different things, and I came across a fairly annoying problem that I can't seem to figure out, let alone find information on.\nWhen the top widget(frame) in a row of frames has been made 255 times it crashes. I guess it has something to do with how it stores the information in bytes.\n\nEdit*\n\nI realize that my initial explaination was more complicated than it need to so here is a simplified version:\n\nfrom tkinter import *\n\nlist = []\nfor x in range(1):\n e = Frame()\n list.append(e)\nprint(list) #Prints .!frame\n\nlist.clear()\nprint(list) #Prints [], the list is now empty\n\nfor x in range(1):\n e = Frame()\n list.append(e)\nprint(list) #Prints .!frame2, which is one step up from the previous one even the list started empty\n\nlist[0].destroy()\nlist[0].forget()\nprint(list) #.!frame2 is still there\n\nlist.clear()\n\nprint(list) #list is now empty again\n\nfor x in range(1):\n e = Frame()\n list.append(e)\nprint(list) #Prints .!frame3, and it still remembers.\n\n\nAs you can see, it keeps adding to the .!frame number.\n\nWhat I am looking for is a way to keep it from reaching .!frame255"
] | [
"python",
"list",
"tkinter",
"widget"
] |
[
"MongoDB DataSource Configuration In JBoss Server",
"How to configure MongoDB DataSource JNDI in JBoss Server.\nI downloaded MongoDB jar (mongo-java-driver-3.4.2.jar) and deployed using admin console, it got successfully deployed but when I went to add Datasource in customize option I am not able to see MongoDB driver, the only one option available was h2. Why so? Do I have to do any other configuration change or am I missing any step?\n\nI Even tried to manually create the MongoDB driver and datasource but that is also not working.\nI placed module.xml and mongo-java-driver- 3.4.2.jar to the following path \n..\\devstudio\\runtimes\\jboss-eap\\modules\\system\\layers\\base\\org\\mongodb\\main\n\n--------- module.xml ---------------------\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module xmlns=\"urn:jboss:module:1.0\" name=\"org.mongodb\">\n<resources>\n<resource-root path=\"mongo-java-driver-3.4.2.jar\"/>\n</resources>\n<dependencies>\n<module name=\"javax.api\"/>\n<module name=\"javax.transaction.api\"/>\n</dependencies>\n</module>\n\n--------------standalone.xml ------------\n\n<datasource jndi-name=\"java:jboss/datasources/mongodb\" pool-name=\"mongodb\" \nenabled=\"true\" use-java-context=\"true\">\n <connection-url>jdbc:mongodb://127.0.0.1:27017/example;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>\n <driver>mongodb</driver>\n </datasource>\n<driver name=\"mongodb\" module=\"org.mongodb\">\n <xa-datasource-class>mongodb.jdbc.MongoXADataSource</xa-datasource-class>\n </driver>\n\n\nI was getting the following error when i started the server \n\n(\"subsystem\" => \"datasources\"),\n(\"data-source\" => \"mongodb\")\n]) - failure description: {\"WFLYCTL0180: Services with missing/unavailable \ndependencies\" => [\n\"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]\",\n\"jboss.driver-demander.java:jboss/datasources/mongodb is missing \n[jboss.jdbc-driver.mongodb]\"\n]}\n23:51:44,277 ERROR [org.jboss.as.controller.management-operation] \n(Controller Boot Thread) WFLYCTL0013: Operation (\"add\") failed - address: ([\n(\"subsystem\" => \"datasources\"),\n(\"data-source\" => \"mongodb\")\n]) - failure description: {\"WFLYCTL0180: Services with missing/unavailable \ndependencies\" => [\n\"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]\",\n\"jboss.driver-demander.java:jboss/datasources/mongodb is missing \n[jboss.jdbc-driver.mongodb]\",\n\"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]\"\n]}\n\n\nCould you let me know how to do JNDI Datasource configuration in JBoss Server ?? Please explain in detail as I am new for JNDI Configuration"
] | [
"java",
"mongodb",
"jboss",
"datasource",
"jndi"
] |
[
"Any good tutorials about 2d drawing and painting?",
"I'm trying to code raster graphics editor, but I can't find any good tutorials about 2d drawing in the Internet.\nAll that I found is Lode's Computer Graphics Tutorial\n\nIt shows how to implement pencil, brush, flood fill, etc. But that's not enough. I find myself trying to re-invent the wheel, you know. :)\nI'm pretty sure there're a lot of algorithms, but I can't find them. Where can I find them? Language is not very important(but I'm writing on C++ with Qt), just need to know basics."
] | [
"c++",
"qt",
"graphics",
"image-processing",
"drawing"
] |
[
"Problems with icon_drawable in navegation Drawable",
"I am trying to show Icon_drawble in a ActionBar, but when R.drawable.ic_drawer is in the first position show return arrow in actionbar.\n\nlike this:\n\n\n\nmDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);\n mDrawerToggle = new ActionBarDrawerToggle(\n this,\n mDrawerLayout,\n R.drawable.ic_drawer,\n R.string.drawer_open, \n R.string.drawer_close\n\n ) { \n\n\nI need to show something like this, but the code above It doesnt work.\n\n\n\nIf I change R.drawable.ic_drawer to another position,it give me the follow logcat error.\n\nmDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);\n mDrawerToggle = new ActionBarDrawerToggle(\n this,\n mDrawerLayout,\n\n R.string.drawer_open,\n R.drawable.ic_drawer,//another position\n R.string.drawer_close \n\n ) \n\n\nLogcat:\n\njava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navegatiodrawer/com.example.navegatiodrawer.MainActivity}: android.content.res.Resources$NotFoundException: File Open navigation drawer from drawable resource ID"
] | [
"android",
"android-actionbar"
] |
[
"how to rename image names in finder with a custom list of names from an .txt/.mat/excel, etc file (OS X)?",
"I download this training data from \nhttp://ai.stanford.edu/~jkrause/cars/car_dataset.html. However, the training data is not named per category. \n\nThe data is named 00163.jpg,00463.jpg,00522.jpg, 00707.jpg, etc. I do have a .mat data file that has (1) class and (2) fname. How can I map these class names + respective file name over the actual image names in mac? \n\nI tried manually renaming the files one at a time, but there are ~2500 images."
] | [
"python",
"image",
"deep-learning",
"caffe"
] |
[
"How to run adb command in android,I run sendevent is fail",
"When I run the command in cmd one by one it is ok, \nlike this:\n\n\n\nbut when I used command in my android code,run in my phone is fail...\nlook at my code:\n\npublic class MainActivity extends AppCompatActivity {\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n sendKeyCode();\n}\n\nprivate void sendKeyCode(){\n try{\n\n //1\n String one = \"sendevent /dev/input/event2 0001 0114 00000001\";\n //2\n String two = \"sendevent /dev/input/event2 0000 0000 00000000\";\n\n //2.5\n String delay = \"timeout 3\";\n\n //3\n String three = \"sendevent /dev/input/event2 0001 0114 00000000\";\n\n //4\n String four = \"sendevent /dev/input/event2 0000 0000 00000000\";\n\n String all = one+\";\"+two+\";\"+three+\";\"+four;\n\n Runtime.getRuntime().exec(all);\n\n\n } catch(Exception e){\n Log.e(\"tpnet\",\"fail to run adb command\");\n }\n}\n\n}\n\n\nhelp me please"
] | [
"android"
] |
[
"Why does using a fundamental type as a base-class compile sometimes?",
"This compiles (tested with GCC 9 and Clang 9):\n\ntemplate<typename U>\nstruct inherit : U { };\n\nint test(inherit<int> arg);\n\n\nBut this does not:\n\nint test(inherit<int> arg) { }\n\n\nWhy does the first one compile?"
] | [
"c++",
"templates",
"sfinae"
] |
[
"Expandable jQuery content opens when reloading",
"I built in a jQuery collapsible plugin into my fixed header. (You can click the button in the right upper corner to open it)\n\nMy problem is as following, when I open the page, reload or click on a link it automatically opens for a second. I would like it stops doing that and instead only opens when someone actually clicks on the button. \n\nI don't know which part of my code to add here so I uploaded both files.\n\nHere is the code to the php file\n\nHere is the code to the jQuery file\n\nI'm sorry for the inconvenience. I am new to this website and I just started building my own website but I'm willing to learn.\n\nRegards"
] | [
"php",
"jquery",
"wordpress",
"jquery-plugins"
] |
[
"Run a second function only after the first function is completely finished",
"Hi everyone I have such a problem,\nI have 2 asynchronous functions.\nI want only after the first is completely over, to run the second.\nThis is what I tried to do:\n\r\n\r\n run2functions = async () => {\n await firstFunc();\n await secondFunc();\n };\n \n firstFunc = () => {\n console.log(\"first one\");\n //Api code for information from any server\n\n }\n \n secondFunc = () => {\n console.log(\"second one\");\n //Api code for information from any server\n\n }\n \n run2functions();\r\n\r\n\r\n\nBut it does not always work, sometimes the code of the second function runs before the code of the first function, I'm not sure why, I used await to force the second to be only after the first one ends.\nI only want the first function to end now to activate the second function."
] | [
"javascript",
"asynchronous",
"async-await"
] |
[
"Text.Json custom JsonConverter ignored",
"I have two Json Converters, one converts dates as MM/dd/yyyy, and another as MM/dd/yy. Second converter (listed in the code example first) is always ignored, and the first one used.\nIs there a way to have multiple converters for DateTime, and use one on some pages, and another on other pages.\npublic class MmddyyDateConverter : JsonConverter<DateTime>\n {\n public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n {\n return DateTime.Parse(reader.GetString());\n }\n\n public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)\n {\n writer.WriteStringValue(value.ToString("MM/dd/yy"));\n }\n }\n\n public class ShortDateConverter : JsonConverter<DateTime>\n {\n public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n {\n return DateTime.Parse(reader.GetString());\n }\n\n public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)\n {\n writer.WriteStringValue(value.ToShortDateString());\n }\n }\n\ntypeof(ShortDateConverter) is used, and typeof(MmddyyDateConverter) is ignored here:\n[JsonConverter(typeof(MmddyyDateConverter))]\npublic DateTime? OfferDate { get; set; }"
] | [
".net-core-3.0",
"system.text.json",
"jsonconverter"
] |
[
"Configuration Settings Strategy",
"In a CMS I've developed in PHP, I have configuration settings. They are kept in constants. I chose this approach because constants always have global scope, are easy to see in code when following the all caps convention, and can't be accidentally overwritten. It is also my understanding that references to constants are very efficient; is that true?.\n\nThere are two subsets of these constants. Some are hard-coded because they have to do with my code or security. Others are stored in a settings table (MySQL) and on initialziation are read into constants.\n\nI'm concerned that the number of these constants is rising and that I might have a conflict with a third-party PHP module that I use in the future.\n\nI'm wondering if there is better way to handle such settings.\n\nThe main idea I had was to create one global variable (e.g., $settings), an associative (key-value) array that would correspond one-to-one with the constants I now have. Thus instead of \n\n define('MY_SETTING, 'setting value');\n\n\nI would have\n\n $setting['my_setting'] = 'setting value';\n\n\nThere are two ways to access this, of course. The simplest is to reference the $setting array directly, which would require a global statement in every function that accessed settings (and that's at least a majority of them). The other way is to have a single function (e.g., setting('my_setting)) that would reference the global array to return the value. Both are syntactically compact although not as compact as constants. \n\nThe final thought I had was to add a constant prefix to every constant in my system. MY_SETTING would become XY_MY_SETTING. This at least reduces the risk of collision.\n\nAre there other approaches that you would recommend? Any comments about what I've done so far?\n\nThanks.\n\nAdditional Info: I decided to run a quick performance test of four methods of access. Results (numbers shown are relative measures):\n\n\nConstants: 32\nDirect reference to associative array: 29\nFunction call to access associative array: 91\nGet Method for class: 103\n\n\nClearly the overhead of dealing with a function or method is high and the difference between constants and array references is negligible."
] | [
"php"
] |
[
"Unexpected token error using async when running node.js app through systemctl only",
"I have a node.js app which runs perfectly well when started through npm start.\nBut when I use a systemctl service to run it, I got an "SyntaxError: Unexpected token (" error after the async keyword\nI checked if the node version was the same using sudo or not, and it is (10.2.1)\nA previous version of the app containing async keywords ran fine through systemctl, so I checked the new code, to no avail (again, the new code runs perfectly through npm start).\nAny idea ?\nMy .service file :\n[Unit]\nDescription=CRM v2\n\n[Service]\nExecStart=/var/www/html/crmv2/bin/www\nRestart=always\nUser=nobody\nGroup=nogroup\nEnvironment=PATH=/usr/bin:/usr/local/bin\nEnvironment=NODE_ENV=production\nWorkingDirectory=/var/www/html/crmv2\n\n[Install]\nWantedBy=multi-user.target\n\npackage.json scripts section :\n"scripts": {\n "dev": "NODE_ENV=development nodemon ./bin/www",\n "start": "NODE_ENV=production ./bin/www",\n "test:int": "NODE_PATH=. NODE_ENV=test mocha --timeout 0 --recursive tests/int/ --exit"\n},\n\nthe .bin/www script is an executable file containing JavaScript code and beginning with :\n#!/usr/bin/env node\n\nA setup which previously worked fine"
] | [
"node.js",
"systemctl"
] |
[
"How to check if the file got deleted on AWS S3 Bucket",
"I have the following service method which deletes the file from the AWS S3 bucket. It is returning "true" for a non-exists file on the s3 bucket. I believe it is returning status if the service call is a success but not checking whether the actual file got deleted.\nHow do I check if the file actually got deleted when I invoke the deleteObject on S3Ojbect?\nBelow is my method code\npublic boolean deleteS3Object(String multipartKey) {\n \n if(StringUtils.isNotBlank(multipartKey)) { \n DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder().bucket("S3Bucket1").key(multipartKey).build();\n DeleteObjectResponse deleteObjectResponse = s3Client.deleteObject(deleteObjectRequest);\n if (deleteObjectResponse != null && deleteObjectResponse.sdkHttpResponse() != null) {\n return deleteObjectResponse.sdkHttpResponse().isSuccessful();\n }\n }\n return false;\n }"
] | [
"java",
"amazon-web-services",
"amazon-s3"
] |
[
"Multiple records in a details view",
"I have a database with a table called Patient. In my view I have:\n\n<h2>Search by Patient_Name</h2>\n\n@using (@Html.BeginForm(\"DetailsbyName\", \"Patient\"))\n{ \[email protected](\"First Name\")\[email protected](model => model.First_Name)\n<br />\[email protected](\"Last Name\")\[email protected](model => model.Last_Name)\n\n<input type=\"submit\", value=\"Submit\"/>}\n\n\nIn my controller is the following method:\n\npublic ActionResult DetailsbyName(Patient _patient)\n {\n string Fname = _patient.First_Name;\n string Lname = _patient.Last_Name;\n\n try\n {\n Patient patient = db.Patients.Single(p => p.First_Name == Fname);\n patient = db.Patients.Single(p => p.Last_Name == Lname);\n\n return View(patient);\n }\n catch\n {\n return RedirectToAction(\"About\", \"Home\");\n }\n }\n\n\nWhen a user enters a first or last name that occurs more than once in the Database table, the db.Patients.Singlethrows an exception. What might I use other than .Single to handle this?\n\nFor instance a user enters First Name: John\n Last Name: Smith\nIf the DB has more than once \"John\" I currently get an exception. Or if the DB has more than one \"Smith\" as a last name I get an exception.\n\nThanks.\n\nGot it working with this:\n\nList<Patient> patientList = db.Patients.Where(p => p.Last_Name == Lname || p.First_Name == Fname).ToList(); \n\n return View(patientList);\n\n\nThanks for the help!"
] | [
"database",
"asp.net-mvc-3",
"controller",
"detailsview"
] |
[
"Batch window opens and shuts immediately?",
"I have this code in my batch file, but when I open it, it closes itself immediately. What do I do? It should work without adding any pauses.\n\n\n@echo off\ncolor f0\n:start1\ncls\nset /a wait=50000\nset /a limit=2147483646\nset /a current=0\necho WAITING ROOM SIMULATOR 2014\necho Current Number:%current%\necho Your number is 2,147,483,647\ngoto loop1\n:loop1\nset /a wait=%wait%-50000\nset /a current=%current%+1\nif current=limit goto pause1\ngoto start2\n:loop2\nset /a wait=%wait%+1\nif %wait%=50000 goto loop1\n:start2\ncls\necho WAITING ROOM SIMULATOR 2014\necho Current Number:%current%\necho Your number is 2,147,483,647\ngoto loop2\n:pause1\ngoto pause2\n:pause2\ngoto pause1"
] | [
"batch-file",
"window"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.