texts
sequence
tags
sequence
[ "Dynamic styles not being applied to elements with `makeStyles`", "The makeStyles hook does not dynamically update the styles based on values that are passed to it, if one of the values is undefined, (code and Codesandbox below).\nI'm trying to figure out if this is a bug with @material-ui v5 or if I'm doing something from.\nI have a simple DatePicker component (I've tested this with a simple TextField as well, and it has the same issue). I'm trying to change the color of the SVG icon based on whether or not there is a valid value in the input.\nHere is my code:\nimport React from "react";\nimport {\n Theme,\n makeStyles,\n TextField as MuiTextField\n} from "@material-ui/core";\nimport AdapterDateFns from "@material-ui/lab/AdapterDateFns";\nimport MuiDatePicker from "@material-ui/lab/DatePicker";\nimport LocalizationProvider from "@material-ui/lab/LocalizationProvider";\n\nimport { localeMap, maskMap, maxDate, minDate } from "./utils";\n\nconst useStyles = makeStyles<Theme, { selection: boolean; error: boolean }>(\n (theme) => ({\n input: ({ selection, error }) => ({\n minWidth: 220,\n height: 70,\n "& svg": {\n color: selection && !error ? "green" : undefined\n },\n "& .MuiOutlinedInput-notchedOutline": {\n border: selection ? `2px solid green` : undefined\n }\n })\n })\n);\n\nconst DatePicker = React.memo(\n ({ name = "date", id = "date", value = "" }: any) => {\n const [locale] = React.useState<keyof typeof maskMap>("ru");\n const [selection, setSelection] = React.useState<null | Date>(null);\n const [error, setError] = React.useState(false);\n\n const classes = useStyles({ selection: !!selection, error });\n\n React.useEffect(() => {\n // setSelection(value);\n }, []);\n\n const handleError = React.useCallback(\n (err) => {\n console.log("error executed", err !== null);\n setError(err !== null);\n if (err === null) {\n // There was previously an error, so fetch\n handleOnAccept(selection);\n }\n },\n [selection]\n );\n\n const handleSelection = React.useCallback((date: Date | string | null) => {\n setSelection(date as Date | null);\n }, []);\n\n const handleOnAccept = React.useCallback((date) => {\n console.log("date", date);\n // setSelection(date as Date | null);\n // handleFilterChange({ id, value: date });\n }, []);\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDateFns}\n locale={localeMap[locale]}\n >\n <MuiDatePicker\n mask={maskMap[locale]}\n value={selection}\n minDate={minDate}\n maxDate={maxDate}\n onError={handleError}\n onChange={handleSelection}\n onAccept={handleOnAccept}\n renderInput={(params) => {\n const { helperText, inputProps, ...rest } = params;\n // @ts-ignore\n const { placeholder, ...restInputProps } = inputProps;\n return (\n <MuiTextField\n variant="outlined"\n className={classes.input}\n helperText="дд.мм.г"\n placeholder="дд.мм.г"\n inputProps={restInputProps}\n {...rest}\n />\n );\n }}\n />\n </LocalizationProvider>\n );\n }\n);\n\nexport default DatePicker;\n\nWhat's weird is that if I change this,\n"& svg": {\n color: selection && !error ? "green" : undefined\n},\n\nto this,\n"& svg": {\n color: selection && !error ? "green" : "red"\n},\n\nthen it works.\nWhat's going on here?" ]
[ "reactjs", "material-ui" ]
[ "pysnmp - nextCmd - not retrieving next element", "I'm new to python. I'm trying to understand the usage of pysnmp.\n\nI tried the following:\n\nimport asyncio\nfrom pysnmp.hlapi.asyncio import *\nfrom pysnmp import debug\n\[email protected]\ndef run():\n snmpEngine = SnmpEngine()\n while True:\n errorIndication, errorStatus, errorIndex, varBinds = yield from nextCmd(\n snmpEngine,\n CommunityData('public', mpModel=1),\n UdpTransportTarget(('giga-int-2', 161)),\n ContextData(),\n ObjectType(ObjectIdentity('1.3.6.1.2.1.31.1.1.1.1')),\n lexicographicMode=False\n )\n\n if errorIndication:\n print(errorIndication)\n break\n elif errorStatus:\n print('%s at %s' % (\n errorStatus.prettyPrint(),\n errorIndex and varBinds[int(errorIndex) - 1][0] or '?')\n )\n else:\n for varBind in varBinds:\n for v in varBind:\n print(' = '.join([x.prettyPrint() for x in v]))\n\n snmpEngine.transportDispatcher.closeDispatcher()\n\nasyncio.get_event_loop().run_until_complete(run())\n\n\nAs result I get always the same interface. What's wrong? Why is it not retrieving the next element?\n\nSNMPv2-SMI::mib-2.31.1.1.1.1.1 = sc0\nSNMPv2-SMI::mib-2.31.1.1.1.1.1 = sc0\nSNMPv2-SMI::mib-2.31.1.1.1.1.1 = sc0" ]
[ "python", "python-3.x", "pysnmp" ]
[ "Python map two list based on condition true", "I have two lists:\n\nA: [ True True True False True False True ]\nB: ['A', 'B', 'C', 'D', 'E', 'F', 'G']\n\n\nI want to get only those values from list B where list A is True.\n\nDesired output: \n\n['A', 'B', 'C', 'E', 'G']" ]
[ "list", "python-2.7" ]
[ "Where should I place certificate serial number in project?", "I have a project that pulls a security certificate from the sever, I am using the certificate serial number to grab at the one I need.\n\nMy question is, where should I place the serial number in the project?\n\n\nShould it be hardcoded in the app? (that does not seem right??)\nIn the config? (does not seem safe)\n\n\nAlso the serial number could change depending on environments, development or production.\n\nWhat do enterprise level apps do in this case?\nAny guidance would be appreciated, thanks!" ]
[ "c#", ".net", "vb.net", "x509certificate", "client-certificates" ]
[ "Visual Studio 2019 DataSets not found in Forms Designer", "I have two datasets in my Project with TableAdapters etc, all created with the windows forms designer.\nSuddenly opening the forms designer shows up 10 Errors, that all dataSets and tableAdapters are not found.\nFurthermore the DataSources Tab stay empty.\nI can do coding normaly. Build, Debug etc all fine. Only using the Designer doesn't work.\nHow do I fix the designer ?\nDer Typ "UPLinkSammler2.DatabaseDataSet" wurde nicht gefunden. Stellen Sie sicher, dass auf die Assembly, die diesen Typ enthält, verwiesen wird. Wenn dieser Typ Teil Ihres Entwicklungsprojekts ist, stellen Sie sicher, dass das Projekt mithilfe der Einstellungen für die aktuelle Plattform oder eine beliebige CPU erstellt wurde. Die Variable databaseDataSet wurde nicht deklariert oder nicht zugeordnet. Der Typ "UPLinkSammler2.DatabaseDataSetTableAdapters.ClientsTableAdapter" wurde nicht gefunden. Stellen Sie sicher, dass auf die Assembly, die diesen Typ enthält, verwiesen wird. Wenn dieser Typ Teil Ihres Entwicklungsprojekts ist, stellen Sie sicher, dass das Projekt mithilfe der Einstellungen für die aktuelle Plattform oder eine beliebige CPU erstellt wurde." ]
[ "visual-studio", "winforms" ]
[ "Using MediaWiki api to search for events on a specific date", "I'm trying to use mediawiki api to get all people whose born or death on specific date.\n\nI wonder how I can make a query like this and what are the title and the prop for this kind of query?\n\nI'm tried to use multiple titles but that doesn't work.\nIt takes each title and makes it as simple query but doesn't use all titles in same query.\n\nhttp://en.wikipedia.org/w/api.php?action=query&titles=born|in|1991&prop=info&format=jsonfm" ]
[ "wikipedia", "wikipedia-api", "mediawiki-api" ]
[ "Populate data from multi-dimensional object into ng-repeat list", "I get the following data from a database in my ionic application. I am saving it to $scope.dbCustomersArray:\n\n [ \n { \n \"customer_id\":1,\n \"customer_name\":\"Test Company\",\n \"customer_address\":\"17 Morena Blvd Camarillo\",\n \"customer_city\":\"Ventura\",\n \"customer_contactnumber\":\"805-832-6163\",\n \"Company_id\":1\n },\n { \n \"customer_id\":2,\n \"customer_name\":\"Another test company\",\n \"customer_address\":\"2742 Distribution Way Metairie\",\n \"customer_city\":\"Jefferson\",\n \"customer_contactnumber\":\"504-979-9175\",\n \"Company_id\":1\n },\n { \n \"customer_id\":3,\n \"customer_name\":\"Final test company\",\n \"customer_address\":\"775 W 17th St San Antonio\",\n \"customer_city\":\"Bexar\",\n \"customer_contactnumber\":\"210-812-9597\",\n \"Company_id\":1\n }\n]\n\n\nI am trying to loop through it in my html.\n\n<label class=\"item item-input\" style=\"padding: 0px\">\n <div class=\"row\">\n <label class=\"item item-input item-select col\">\n <div class=\"input-label\" style=\"visibility: hidden\">\n Customer\n </div>\n <select>\n <option> -- Customer -- </option>\n\n <ion-item ng-repeat=\"customer in $scope.dbCustomersArray\">\n <option> Hello, {{customer.customer_name}}! </option>\n </ion-item>\n\n </select>\n\n </label>\n </div>\n </label>\n\n\nI am returning no values and not getting any errors in my logs. I have tried to loop through $scope.dbCustomersArray using the following code, but the only values that are printed out are: 0, 1 and 2 repspectively.\n\nfor (var customer in $scope.dbCustomersArray) {\n console.log(\"LOGGING A CUSTOMER - \" + customer.customer_name);\n}\n\n\nPlease help me with this problem. I don't see where I am going wrong. Thank you in advance.\n\nEDIT\n\nI cant see the values in my array in my ionic application when I tap on the customers select list." ]
[ "angularjs", "ionic-framework" ]
[ "LWJGL Mouse.getDX Always returns 0", "This is using LWJGL version 2.9.1, I am on windows 8.1 using a razer deatheradder mouse.\n\nWhenever I call Mouse.getDX() or Mouse.getDY() it always returns 0 no matter how fast I move my mouse or how far. \n\nMouse.getX() works and Mouse.getY() works but getDX and getDY do not.\n\nI have been attempting to recreate getDX and getDY for awhile but want to put this question up to see if it can get answered before I finish it." ]
[ "java", "lwjgl", "mousemove" ]
[ "how to uncompress and view hadoop file", "In my project normal files are being moved to HDFS Location and file is stored as \n\nB6p.3ED.UXHq_wLG_B06b.n.aw3AHOYL.eST.lzoe. This is something obfucated file and .lzoe means file is compressed. Can you please let me know if any way to uncompress this file in hadoop and view its content." ]
[ "hadoop" ]
[ "Data table subset using a condition, and only specific rows from that subset", "I have a big data table that is rendered in a plotly plot, and the user can select points in the scatter plot with a region (rectangular or polygon). After processing this select element, I get a dataframe with a list of the 'cluster' each point in the selection belongs to and which 'nth' element (row) of that cluster it is, i.e. \n\ncluster elementNr \n1 1 \n1 23 \n2 7\n2 9\n2 14\n\n\nThis recreates the output: \n\nselectme <- data.frame(cluster = c(rep(1,20), rep(2,30)), elementNr = c(sample(1:100, 20, replace = F),sample(1:100,30, replace =F)))\n\n\nAnd this creates the dummy equivalent of my main data table\n\nmydata <- data.table(cluster = sample(c(1:5), 5000, replace = T), val1 = runif(5000, 0.1, 100), val2 = runif(5000, 0.1, 50))\n\n\nWhat I am trying to figure out, is how to subset the data table with the selectme dataframe so that I get the right particles out of there. \ni.e. as the first example, I should end up with the 1st and 23rd row of the rows where cluster == 1, and the 7th, 9th, 14th row of those where cluster == 2\n\nExpected output:\n\nCluster val1 val2\n 1 0.45 2.54 (1st of this cluster \n 1 25.73 84.83 (23rd element of this cluster \n 2 0.26 12.76 (7th el)\n 2 3.16 26.84 (9th el)\n 2 0.76 19.46 (14th el)\n\n\n\nvalues are just examples since the test code creates them at random\n\n\nSo 7th element is not the 7th row of mydata, but the 7th row of the subset where cluster ==2\n And because my data can contain dozens of clusters I would like to put the following logical sentence into code: \n\"For each cluster in selectme, find the rows of the subset of mydata where cluster equals the same cluster and grab the rows that equal the elementnrs of selectme for the current cluster, and produce one output containing all the corresponding rows\"\n\nI can transfer myselection to data.table first if needed of course\n\nUPDATE: real data added\n\nReal data file, real selectme file, and expected output file in RDS form are found here: \ndatafiles" ]
[ "r", "data.table", "subset" ]
[ "Delete user from server if they delete app", "Is it possible to delete a user from a server if they delete your app from their phone?\n\nI am using UUID to create users so they do not have to register but I do not want users to delete the app then rejoin and have a new uuid while the old one is still in the database.\n\nAre there any alternatives to using UUID to avoid registering. Apparently UDID which would have been ideal has been deprecated for IOS 6 and upwards.\n\nPlease help, thanks in advance." ]
[ "ios", "xcode", "nsuserdefaults", "uuid", "udid" ]
[ "SolutionContext.ConfigurationName set returns E_FAIL", "I have the following code in a custom project based on MPF for Projects - Visual Studio 2010:\n\n EnvDTE.Project dteProj = CurrentProject();\n dteProj.ConfigurationManager.AddConfigurationRow(\"MyCustomConfig\", \"Debug\", false);\n var solution = dteProj.DTE.Solution as EnvDTE90.Solution3;\n foreach (EnvDTE80.SolutionConfiguration2 solConfig in solution.SolutionBuild.SolutionConfigurations)\n {\n foreach (EnvDTE.SolutionContext solContext in solConfig.SolutionContexts)\n {\n if (dteProj.UniqueName != solContext.ProjectName)\n continue;\n\n //Returns E_FAIL \n solContext.ConfigurationName = \"MyCustomConfig\";\n }\n }\n\n\nAs you can see everything is pretty straight forward. I create a new configuration for my project and want to use it in a solution context. Setting the configuration name returns E_FAIL. \n\nWhy is the assignment failing? What is the correct programmatic equivalent for selecting a project configuration for a project from the drop down in the Configuration Manager dialog box?\n\nThanks" ]
[ "visual-studio-2010", "envdte", "vs-extensibility" ]
[ "outputing array values specific", "i am working on a very specific problem. this program prompts the user for a number between 1-10000000 and then another number 1-10000. the first number is how many random numbers and the second is what the max those numbers can be is. im trying to print the result on user prompt and print if user wants to print results and the result are number of primes. first problem is i cannot get the program to respond to the user pushing 1 or 0 to print results. second is i cannot get the number of primes that were created to print as a resut \n\nnamespace PRIMECON\n{\n class PRIMECON\n {\n static void Main(string[] args)\n { \n //creates stopwatch\n Stopwatch watch = new Stopwatch();\n\n //creates randoms\n Random rnd = new Random();\n\n //starts the stopwatch\n watch.Start();\n\n //gets number from 1 to 10 million\n Console.WriteLine(\"\\nPlease enter a number between 1 and 10,000,000\");\n\n bool checkn;\n int number; //input\n\n checkn = int.TryParse(Console.ReadLine(), out number);\n\n //gets number from 1 to 10 thousand\n Console.WriteLine(\"\\nPlease enter a number between 1 and 10,000\");\n\n bool checkr;\n int range; //range of values from 0 to r\n\n checkr = int.TryParse(Console.ReadLine(), out range);\n\n if (checkn == true && checkr == true && number > 0 && number <= 10000000 && range > 0 && range <= 10000)\n {\n //array\n int arraySize = 0;\n //int[] array = new int[range];\n\n for (int i = 0; i < number; i++)\n {\n int randomNumber = rnd.Next(1, range);\n bool primeNumber = PRIMELIB.PRIMELIB.IsItPrime(randomNumber); //calls library method\n\n if (primeNumber == true)\n arraySize++; //adds to the array for each prime number\n //array[i] = randomNumber;\n //prints numbers\n Console.WriteLine(i.ToString() + \" \" + randomNumber.ToString() + \" \" + primeNumber.ToString()); // prints index, number, true/false\n }\n //int[] array = new int[arraysize];\n watch.Stop();\n Console.WriteLine(\"\\nElapsed Time = \" + watch.Elapsed.ToString());\n\n int exit = 1;\n\n do\n {\n Console.WriteLine(\"would you like to print results? 0-no 1-yes\");\n Console.ReadLine();\n\n int rangeHigh;\n int rangeLow;\n bool high = int.TryParse(Console.ReadLine(), out rangeHigh);\n bool low = int.TryParse(Console.ReadLine(), out rangeLow);\n\n if (high == true && low == true)\n {\n for (int i = rangeLow; i < rangeHigh; i++)\n {\n //Console.WriteLine( i + \". \" + array[i]);\n }\n }\n }\n while (exit != 0);\n }\n else if (checkn == false || number > 10000000 || number < 0)\n Console.WriteLine(\"First number was not valid\");\n else if (checkr == false || range > 10000000 || range < 0)\n Console.WriteLine(\"Range was not valid\");\n else\n Console.WriteLine(\"entry not valid\");\n\n Console.ReadKey();\n }\n }\n}" ]
[ "c#", "arrays" ]
[ "X, Y Animation Storyboard on button click for windows8 Apps", "I've spent about the entire day looking at examples of XAML storyboarding, but WinRT/Windows8 apps doesn't work the same way WPF does (At least I think), and I'm all confused.\nAll I want is a button that moves 100px left and 100px up when clicked. I'm having the hardest time figuring this out, and I know that once I get something I want working, I'll be able to work from there.\n\nAlso, if anyone can teach me how to use \"Storyboard.TargetProperty\" That'd be amazing. \n\n <Rectangle\n Name=\"Rectangle01\"\n Height=\"100\"\n Width=\"100\"\n Fill=\"Red\">\n <Rectangle.Resources>\n <Storyboard x:Name=\"myboard\">\n <DoubleAnimation \n Storyboard.TargetName=\"Rectangle01\"\n Storyboard.TargetProperty=\"Width\"\n From=\"100\" To=\"3600\" Duration=\"0:0:6\" />\n </Storyboard>\n </Rectangle.Resources>\n </Rectangle>\n\n\nHere's an example of something I tried doing just to mess around with storyboards. This didn't throw an error until I tried to execute it, but it still doesn't work." ]
[ "c#", "windows", "xaml", "winrt-xaml" ]
[ "Change the on-screen position of the Turtle Graphics window?", "Is it possible to change the position of the turtle console on screen?\n\nMy main objective is to write code that can move the window, that's all.\n\nI'm using Python 3.4.0 under Windows 10.\n\nIf any extra information is needed please ask." ]
[ "python", "turtle-graphics" ]
[ "Best practice for reconfiguring and redeploying on AWS autoscalegroup", "I am new to AWS (Amazon Web Services) as well as our own custom boto based python deployment scripts, but wanted to ask for advice or best practices for a simple configuration management task. We have a simple web application with configuration data for several different backend environments controlled by a command line -D defined java environment variable. Sometimes, the requirement comes up that we need to switch from one backend environment to another due to maintenance or deployment schedules of our backend services.\n\nThe current procedure requires python scripts to completely destroy and rebuild all the virtual infrastructure (load balancers, auto scale groups, etc.) to redeploy the application with a change to the command line parameter. On a traditional server infrastructure, we would log in to the management console of the container, change the variable, bounce the container, and we're done.\n\nIs there a best practice for this operation on AWS environments, or is the complete destruction and rebuilding of all the pieces the only way to accomplish this task in an AWS environment?" ]
[ "amazon-web-services", "redeploy" ]
[ "How rotate only a square in Canvas html5", "Hi I'm doing a practice with canvas, I want rotate only a square because when I use the method c.rotate( Degrees*Math.PI/180 ); rotate all canvas because when I move of the origin point, the square is it goes to other place.\n\nfor example I have this square in the ()\n\nI rotate 45 degrees the square\n\n\n\nAnd I move the square the position (0,0) but It goes for other place" ]
[ "javascript", "html", "canvas", "rotation" ]
[ "CSV + FileHelpers + Double Quotes = Nightmare", "I can't seem to handle a CSV I got. It's a file generated by a bank, which looks like this:\n\n\"000,\"\"PLN\"\",\"\"XYZ\"\",\"\"2011-08-31\"\",\"\"2011-08-31\"\",\"\"0,00\"\"\"\n1,\"\"E\"\",\"\"2011-08-30\"\",\"\"2011-08-31\"\",\"\"2011-08-31\"\",\"\"399,00\"\",\"\"0000103817846977\"\",\"\"UZNANIE OTRZYMANE ELIXIR\"\",\"\"23103015080000000550217023\"\",\"\"XXX\"\",\"\"POLISA UBEZPIECZENIA NR XXX \"\",\"\"000\"\"\n3,\"\"E\"\",\"\"2011-08-31\"\",\"\"2011-08-31\"\",\"\"2011-08-31\"\",\"\"1433,00\"\",\"\"0000154450232753\"\",\"\"UZNANIE OTRZYMANE ELIXIR\"\",\"\"000\"\",\"\"XXX\"\",\"\"POLISA UBEZPIECZENIA XXX \"\",\"\"000\"\"\n\n\n(I changed all sensitive information).\n\nI've been trying to parse it since morning but no biggie. I used the LINQ to CSV example found somwhere on the net, the CodeProject one (both of them threw an error which said that the CSV is corrupted) and I ended with FileHelpers which SEEMS to work BUT:\n\n\nIt splits the \"399,00\" and similar values into two fields.\nWhen I use the [(FieldQuoted()] attribute it all goes to hell, since all the fields are quoted in DOUBLE quotation marks. I suspect that is the reason why the other parsers wouldn't work.\n\n\nAny ideas how to handle it?" ]
[ "c#", "parsing", "csv", "filehelpers" ]
[ "Unable to create release-build with RxJava as dependency and proguard-rules", "I'm using 'compile 'io.reactivex:rxjava:1.3.1' in dependencies\n\nI have enabled minifyEnabled true to obfuscate the code.\n\nBut I'm getting below error-\n\nWarning:rx.internal.schedulers.NewThreadWorker: can't find referenced method 'java.util.concurrent.ConcurrentHashMap$KeySetView keySet()' in library class java.util.concurrent.ConcurrentHashMap\n\n\nI have added proguard rules for rxjava as below-\n\n-keep class rx.schedulers.Schedulers {\n public static <methods>;\n}\n-keep class rx.schedulers.ImmediateScheduler {\n public <methods>;\n}\n-keep class rx.schedulers.TestScheduler {\n public <methods>;\n}\n-keep class rx.schedulers.Schedulers {\n public static ** test();\n}\n-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {\n long producerIndex;\n long consumerIndex;\n}\n-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {\n long producerNode;\n long consumerNode;\n}\n\n-keepclassmembers class rx.internal.util.unsafe.** {\n long producerIndex;\n long consumerIndex;\n}\n\n\nI have also tried compile 'com.artemzin.rxjava:proguard-rules:1.3.1.0' but still I'm getting same issue mention at top." ]
[ "android", "android-proguard" ]
[ "SQL Openquery Dynamic Parameter", "I am trying to include a parameter in T-SQL's Openquery function. I have done this successfully in the past, but my current code is not cooperating:\n\ndeclare @bom smalldatetime\ndeclare @eff_date smalldatetime\nset @eff_date = (select min(postdate) from #temp_all)\nset @bom = convert(varchar(25),dateadd(dd,-(day(@eff_date)-1),@eff_date),101)\n\nselect *\ninto #temp\nfrom openquery(db,\n'select l.id\n ,l.date\n from table1 l (nolock)\n inner join table2 m (nolock)\non l.id = m.id and l.date between m.start_date and m.end_date\n inner join table3 d (nolock)\non l.param = d.param\n where l.date = ''''' + convert(varchar(10),@bom,101) + '''''\n and m.param1 = ''Y''\n and m.param2 = ''N''\n and param3 is null\n and d.integer < 30\n')\n\n\nThe issue is with the\n\n where l.date = ''''' + convert(varchar(10),@bom,101) + '''''\n\n\nline. Can someone please tell me what I am doing incorrectly?" ]
[ "sql", "parameters", "parameter-passing", "openquery" ]
[ "Notification with Timer and Buttons?", "I'm creating something like a timer app with flutter. I want to display a notification while the timer is running that displays the current time and that has a button to cancel/pause the timer.\n\nMore precisely I have a Stream that exposes another int value (the time left) every 100 ms. So I would have to subscribe to this Stream in my notification.\n\nI don't really know much about native app developing. I know this is possible for android, I have a similar app installed but is that also possible for iOS? And most importantly is that possible with Flutter with a package or something? I know there are packages for notifications but I haven't really found something for my needs.\n\nAny Ideas? Any help is appreciated!" ]
[ "android", "ios", "flutter" ]
[ "A way to override the constructor on HTMLElement so I can add custom code", "I'm trying to somehow override the constructor of HTMLElement (specifically HTMLDivElement), so that whenever any are created by whatever means, I can run some custom logic.\n\nObviously this doesn't work:\n\n\nHTMLDivElement.prototype.constructor = function()\n{\n alert('div created!');\n}\n\n\nIs there a way to pull this off? Even if there was a way to get some sort of event/trigger when new elements where created (ones not part of the page's source HTML), that would be helpful.\n\nEDIT: Maybe there is something we could do with Mozilla's watch/unwatch methods to watch for a change?" ]
[ "javascript" ]
[ "How to debug failed mapping when I only get Null pointer exception", "I am using Orika in my project usually with great success.\nI have added a new type, registered both source and target and when I map it using mapper.mapAsList(sourceList, targetClass) I get the following exception \n\n[2015-02-11 19:58:19,836][ERROR][platform.fe.baseservice.utils.validators.BasicFEValidator] validateTransformingAPIModelToDataModel\njava.lang.NullPointerException: null\n at ma.glasnost.orika.generated.Orika_HTML5Single_APIHTML5Single_Mapper808888457244295$34.mapAtoB(Orika_HTML5Single_APIHTML5_Mapper808888457244295$34.java) ~[na:na]\n at ma.glasnost.orika.impl.mapping.strategy.UseCustomMapperStrategy.map(UseCustomMapperStrategy.java:65) ~[orika-core-1.4.4.jar:na]\n at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsCollection(MapperFacadeImpl.java:646) ~[orika-core-1.4.4.jar:na]\n at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:391) ~[orika-core-1.4.4.jar:na]\n at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:729) ~[orika-core-1.4.4.jar:na]\n ....\n ....\n\n\nJust null pointer exception. \n\nNow I have been trying to debug it for a long time but without success (mainly because most of it is generated code). \n\nQuestions: \n\n\nWhat is the best way to get a meaningful exception.\nHow can I debug it? \nIs there a way to view the generated classes. \n\n\nThanks" ]
[ "java", "automapper", "automapping", "orika" ]
[ "Solution display loading for waiting Webview load page in Flutter", "I have to load trading view. I use webview_flutter to do that. It lost a few seconds to load. I want to show the loading view until Webview finishes load page. My idea is use a stack and loading view stands over webview. But I don't know how to remove loading view when webview done. Any solution for this ?\n Widget loadTradingView() {\n return Container(\n color: Colors.black,\n height: Get.width,\n child: Stack(children: [\n loadingView(),\n WebView(\n javascriptMode: JavascriptMode.unrestricted,\n onWebViewCreated: (webController) {\n _loadHtmlFromAssets(webController);\n },\n onPageFinished: (str) {\n \n print('done');\n },\n onPageStarted: (str) {\n print('start');\n },\n ),\n ]),\n );\n }" ]
[ "flutter" ]
[ "What's the C++ equivalent of UINT32_MAX?", "In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t data type. However, in C++ the UINT32_MAX gets defined out. I can define __STDC_LIMIT_MACROS before including stdint.h, but this does not work if someone is including my header after already including stdint.h themselves.\n\nSo in C++, what is the standard way of finding out the maximum value representable in a uint32_t?" ]
[ "c++", "types", "c99" ]
[ "Add a custom dijit element to Zend Dojo Form", "I would like to use Dijit elements that are not included into Zend Framework. But I don't know how I should go around it :\n\n$subPrice = new Zend_Dojo_Form_SubForm('priceTab');\n$subPrice->setLegend('Tarification :');\n\n$sign = new Zend_Dojo_Form_Decorator_DijitElement('sign');\n$sign->setDijitParams(array('dojoType' => 'dijit.form.ToggleButton',\n 'label' => '-',\n 'showLabel' => true,\n 'checked' => true,\n 'onChange' => 'toggleLabel(val)'\n ));\n$subPrice->addElement($sign);\n\n\nIn my view I just added dojo.require(\"dijit.form.Button\"); in the javascript\n\nHowever I get this error message from the addElementfunction :\n\nFatal error: Call to a member function getOrder() on a non-object in D:\\www\\tuto\\library\\Zend\\Form.php on line 1055\n\nAny help would be extremely appreciated.\n\nThanks !" ]
[ "zend-framework", "zend-form", "dojo", "zend-form-element" ]
[ "CRC32 calculation doesn't match default one", "I'm writing a program to compute CRC32 in Groovy. For some reason I don't get expected value (same as if I used java.util.zip implementation):\n\ndef crc32(byte[] bytes) {\n return new java.util.zip.CRC32().with { update bytes; value }\n}\n\ndef myCrc32(byte[] bytes) {\n def remainder = 0x0\n def multiple = 0\n def poly = 0xEDB88320 \n\n bytes.each { b ->\n remainder ^= b\n for (int i = 0; i < 8; i++) {\n multiple = (remainder & 1) ? poly : 0;\n remainder = (remainder >> 1) ^ multiple;\n }\n }\n return remainder\n }\n\n\ndef origFile = 'file'\ndef fileBytes = new File(origFile).text.getBytes()\ndef origRes = crc32(fileBytes)\ndef myRes = myCrc32(fileBytes)\n\nprintln origRes\nprintln myRes\n\n\nWhere did I do a mistake? I used the following sources as guide:\n\n\nhttp://www.ross.net/crc/download/crc_v3.txt\nhttps://www.kernel.org/doc/Documentation/crc32.txt\n\n\nResults that I get:\n\n1838399800 - original\n4005013284 - my calculation" ]
[ "java", "groovy", "crc32" ]
[ "Plugin error while starting Gulp local server", "I am using gulp and lately I faced an error which I was unable to fix by reinstalling the plugin, typing PATH to node_modules global variable or rebuilding scss. Also I tried newer version of gulp, but I rolled the project back to the beginning as it didn't work." ]
[ "javascript", "sass", "gulp" ]
[ "Issue while running spring ; No error logs", "I am a new bee to spring and am writing my first spring program.I have the following files.\n\npackage com.springstarter;\n\nimport org.springframework.context.ApplicationContext;\nimport org.springframework.context.support.ClassPathXmlApplicationContext;\n\npublic class SpringUser\n{\n public static void main( String[] args )\n {\n ApplicationContext context = new ClassPathXmlApplicationContext(\"Beans.xml\");\n SpringStarter starter = ( SpringStarter ) context.getBean( \"springstarter\" );\n starter.getMessage();\n }\n}\n\n\nI have a bean called SpringStarter\n\npackage com.springstarter;\n\npublic class SpringStarter\n{\n private String message;\n\n public String getMessage()\n {\n return message;\n }\n\n public void setMessage( String message )\n {\n this.message = message;\n }\n}\n\n\nBeans.xml \n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\">\n\n <bean id=\"springstarter\" class=\"com.springstarter.SpringStarter\">\n <property name=\"message\" value=\"Hello World!\"/>\n </bean>\n</beans>\n\n\nThe following is the package structure:\n\n\n\nI have run the program in eclipse Mars, using Spring 4.2.4.\nI didn't find any compilation issues, but the program is just showing the following logs.\n\nJan 14, 2016 10:36:08 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh\nINFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@73a83205: startup date [Thu Jan 14 10:36:08 IST 2016]; root of context hierarchy\nJan 14, 2016 10:36:08 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions\nINFO: Loading XML bean definitions from class path resource [Beans.xml]\n\n\nThe expected output though, is Hello World!\n\nKindly let me know if i'm making any obvious mistakes." ]
[ "spring" ]
[ "SQL Server : does NEWID() always gives a unique ID?", "Does the NEWID() function never give me the same ID as it already did? Let's say I select a NEWID() and it returns '1' (just as an example). Will it never return '1' again? Is it impossible?" ]
[ "sql", "sql-server", "database", "unique", "newid" ]
[ "Make Publication of geometrical set, SetDirect error", "I'm trying to make a Publication of points, line and planes in a geometrical set of Part using a VBA script. \n\nI get an error on of the SetDirect method of publications1, where the error says \"The method SetDirect failed\". \n\nThe Publication is added to the list, but the Element is empty.\n\nI've tried \npublications1.SetDirect(\"centerPoint1\", reference1) and publications1.SetDirect \"centerPoint1\", reference1.\n\nHere's the documentation; http://catiadoc.free.fr/online/interfaces/interface_Publications.htm \n\nWhat am I doing wrong? I think it could be the making of reference1?\nIs it possible to make Publications using a VBA script?\n\nImage of the part where I want to make the Publication\n\n\n\nThe VBA Code\n\n Sub publicationTest2()\n\n\nSet CATIA = GetObject(, \"CATIA.Application\")\nSet documents1 = CATIA.Documents\n\nSet partDocument1 = documents1.Item(\"Part1.CATPart\")\n\nSet part1 = partDocument1.Part\n\nSet hybridBodies1 = part1.HybridBodies\nSet hybridBody1 = hybridBodies1.Item(\"arr_set\")\nSet hybridShapes1 = hybridBody1.HybridShapes\nSet hybridShapePointOnPlane1 = hybridShapes1.Item(\"centerPoint1\")\n\n'Set publications1 = CATIA.ActiveDocument.Product.Products.Item(partName).Publications\nSet productDocument1 = CATIA.ActiveDocument\nSet product1 = productDocument1.Product\nSet products1 = product1.Products\nSet product2 = products1.Item(\"Part1.1\")\n\nSet publications1 = product2.Publications\n\n\nSet reference1 = hybridShapePointOnPlane1\npublications1.Remove (\"centerPoint1\")\nSet publication1 = publications1.Add(\"centerPoint1\")\npart1.Update\nSet publ1 = publications1.SetDirect(\"centerPoint1\", reference1)\n\nEnd Sub" ]
[ "vba", "catia" ]
[ "hard coded predefined values in xtext", "starting fro here http://www.eclipse.org/Xtext/documentation.html#DomainModelWalkThrough\nI would like to add some predefined type strings so that \n\nentity ent{\n d:INTEGERS\n}\n\n\nis legal. Without the declare statment\n\ndatatype INTEGERS\n\n\nI have tried\n\nType:\n DataType | Entity | value=PredefType;\n\nenum PredefType: INTEGERS='INTEGERS' | STRING='STRING';\n\n\nand\n\nType:\n DataType | Entity | PredefType;\n\nPredefType:\n name='INTEGERS' | name='STRING';\n\n\nbut neither work.\n\nSorry if the question is silly, I'm new to xtext." ]
[ "java", "parsing", "xtext" ]
[ "How to calculate average value in mysql query?", "I have\n\n\r\n\r\n| id | name | v1 | v2 | rate_id |\r\n-------------------------------------\r\n| 1 jack 202 2 18\r\n| 2 jack 202 3 23\r\n| 3 gad 204 2 34\r\n| 4 vad \r\n| 5 mad\r\n| 6 pad\r\n\r\n\r\n\n\navarage = (max rate + min rate) / 2 \nwhere name = jack AND v1 = 202 AND v2 = 2\nalso for each unique row for (name,v1,v2)\n\nand result of avarage should be in other select query:\n\n\r\n\r\nSELECT \r\n m.rate = avarage\r\nFROM messages m\r\nINNER JOIN rates r\r\n ON r.id = m.rate_id" ]
[ "mysql", "sql" ]
[ "Style Sheet getting added but not the style", "I am trying to add some styling to my print page(unfortunately i am a beginner so far so bear with me if i am doing something dumb). Here is the style sheet \n\n\r\n\r\n@font-face {\r\n font-family: 'Cloister';\r\n src: url('../fonts/fonts/CloisterBlack.ttf');\r\n font-weight: normal;\r\n font-style: normal;\r\n}\r\n.navbar {\r\n display: none;\r\n}\r\n.main-navigation{\r\n display: none;\r\n}\r\n.hidden-print {\r\n display: none;\r\n}\r\n.breadcrumb {\r\n display: none;\r\n}\r\n.page-header {\r\n display: none;\r\n}\r\n.footer {\r\n display: none;\r\n}\r\n.main-container {\r\n /*margin: 0 ;\r\n padding: 0 !important;*/\r\n}\r\n.main-content .container{\r\n min-height: auto;\r\n border: none;\r\n background: #0000ff;\r\n}\r\n@page {\r\n margin: 1cm;\r\n}\r\n\r\nh1.page-title {\r\n font-family: 'Cloister';\r\n font-size: 40pt!important;\r\n text-align: center ;\r\n}\r\n\r\n\r\n\n\nand this is my print method. \n\n\r\n\r\n$('#printButton').click( function () {\r\n var divContents = $(\"#printPage\").html();\r\n //console.log(divContents);\r\n var printWindow = window.open();\r\n printWindow.document.write('<html>' +\r\n '<head>' +\r\n '<link rel=\"stylesheet\" href=\"<?= base_url() ?>assets/css/print.css\" type=\"text/css\" media=\"print\"/>'+\r\n '<title>Student Report Card</title>');\r\n printWindow.document.title = '';\r\n printWindow.document.write('<h1 class=\"page-title\"> BeaconHouse Potohar Campus</h1>');\r\n printWindow.document.write('</head><body >');\r\n printWindow.document.write(divContents);\r\n printWindow.document.write('</body></html>');\r\n printWindow.document.close();\r\n printWindow.print();\r\n});\r\n\r\n\r\n\n\nEverything is seems to be working fine until i inspect my print page, there i can also see my style sheet getting added but when i go to the h1 tag, my style sheet doesn't appear and instead there is user agent stylesheet(added by browser as last resort when no style is present on stackoverflow). \n\nFinally i am adding this image just to consolidate what i am trying to convey." ]
[ "javascript", "jquery", "html", "css" ]
[ "Pandas to JSON can't get it in the right format", "This is really frustrating me and I feel like I've tried everything. I have a basic Pandas dataframe that looks like this: \n\norder name lat long open close\n123 Walgreens 37.5 50.4 08:00:00 17:00:00\n456 CVS 16.7 52.4 09:00:00 12:00:00\n789 McDonald's 90.7 59.1 12:00:00 14:00:00 \n\n\nI need to convert that dataframe into a JSON object that looks like this: \n\n {\n \"123\": {\n \"Location\": {\n \"Name\": \"Walgreens\",\n \"Lat\": 37.5,\n \"Long\": 50.4\n },\n \"Open\": 08:00:00,\n \"Close\": 17:00:00\n },\n \"456\": {\n \"Location\": {\n \"Name\": \"CVS\",\n \"Lat\": 16.7,\n \"Long\": 52.4\n },\n \"Open\": 09:00:00,\n \"Close\": 12:00:00\n },\n \"789\": {\n \"Location\": {\n \"Name\": \"McDonald's\", \n \"Lat\": 90.7, \n \"Long\": 59.1\n }, \n \"Open\": 12:00:00, \n \"Close\" : 14:00:00 } } }\n\n\nI have tried quite a few methods trying to get it to look like that, but either I get stuck with extra slashes or I can't get my quotes right no matter what I do. I have done both the Pandas to_json method and made it into a dictionary and then done json.loads or json.dumps and it just won't work right. \n\nOne method I tried is doing this: \n\njson_dict = {}\n\n for i in df.index:\n order_no = df.loc[i, 'order_no']\n stop_name = df.loc[i, 'Name']\n lat = df.loc[i, 'latitude']\n lng = df.loc[i, 'longitude'] \n start = df.loc[i, 'start']\n end = df.loc[i, 'end']\n json_dict[str(order_no)] = '{{\"location\" : {{ \"name\": \"{0}\", \n \"lat\" : \"{1}\", \"long\" : \"{2}\" }}, \"open\" : \"{3}\", \"close\" : \"{4}\" \n }}'.format(name, lat, long, start, end)\n\n json.dumps(json_dict) \n\n\nand it ends up throwing in a whole bunch of backslashes in it. How do I get the formatting right? Thanks for your help!" ]
[ "python", "json", "pandas" ]
[ "make div over another on liquid template", "I'm trying to make two div's, one overlaps on another \n\nAs you can see on the fiddle below there is position:relative; top:-20px; And I would like to make it fully liquid without any px maybe on percentage, however I have no Idea how to make that. \nHere's fiddle" ]
[ "html", "css" ]
[ "jQuery Slider - full width - opening itself from the midddle", "I have to do that :\n\n\n\nHow would you do it ? Would you use a jQuery plugin ?\n\nThank you very much" ]
[ "jquery", "animation", "slider", "width" ]
[ "formatnumber add commas every time how?", "How do I force FormatNumber to use a \"-\" to separate every \"000\"\n\nDepending on my users culture on their computer\nthe result looks like \"123 456 789.1235\" or \"123,456,789.1235\"\n\nHow do I force it\n\nDim A As Decimal = \"123456789.123456\" \n\nDim B As String = FormatNumber(A, 4)" ]
[ "c#", "vb.net" ]
[ "Symfony2 form isValid doesn't work", "My form Type:\n\npublic function buildForm(FormBuilderInterface $builder, array $options)\n{\n\n $builder\n ->add('email', 'email')\n ->add('username')\n ;\n}\npublic function setDefaultOptions(OptionsResolverInterface $resolver)\n{\n $resolver->setDefaults(array(\n 'data_class' => 'MyApp\\UserBundle\\Entity\\User',\n ));\n}\n\n\nAnd controller:\n\n $form = $this->createForm(new OAuthEmailType());\n if ($request->isMethod('POST'))\n {\n $user = new User();\n $form->setData($user);\n $form->bind($request);\n\n // die($form->getErrorsAsString());\n if ($form->isValid()) // always returns true\n {\n // ...\n }\n // ...\n }\n\n\nMy User entity properties have annotations validation. Also this class extends FOSUserBundle User entity.\n\nAnd here is the problem. $form->isValid() always returns true, but the same form type perfectly works with another controller. Why form is not validated exactly in this controller? What I missed?" ]
[ "validation", "symfony", "symfony-forms", "fosuserbundle" ]
[ "GWT Sample Project not working after compiling with no changes made", "I am following this tutorial for a Google Web Toolkit project: https://developers.google.com/web-toolkit/gettingstarted\n\nEverything seems to work except at the very end when I call ant build.\n\nC:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp>ant build\nBuildfile: C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\build.xml\n\nlibs:\n [mkdir] Created dir: C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\lib\n [copy] Copying 1 file to C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\lib\n [copy] Copying 1 file to C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\lib\n\njavac:\n [mkdir] Created dir: C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\classes\n [javac] C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\build.xml:29: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds\n [javac] Compiling 5 source files to C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\classes\n [copy] Copying 1 file to C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\WEB-INF\\classes\n\ngwtc:\n [java] Compiling module com.impulse.mywebapp.MyWebApp\n [java] Compiling 6 permutations\n [java] Compiling permutation 0...\n [java] Compiling permutation 1...\n [java] Compiling permutation 2...\n [java] Compiling permutation 3...\n [java] Compiling permutation 4...\n [java] Compiling permutation 5...\n [java] Compile of permutations succeeded\n [java] Linking into C:\\Users\\Hebron\\Dropbox\\IP\\gwt-2.5.1\\MyWebApp\\war\\mywebapp\n [java] Link succeeded\n [java] Compilation succeeded -- 60.848s\n\nbuild:\n\nBUILD SUCCESSFUL\nTotal time: 1 minute 5 seconds\n\n\nIt looks like the page built properly so when I go to open the MyWebApp.html file, it loads the static content without any issues. However, the textbox and submit button are both gone. When I ran ant devmode the textbox and button appeared and worked without any issues, so I'm just wondering why it doesn't work in 'production mode'.\n\nThanks!" ]
[ "gwt", "ant" ]
[ "C# webbrowser control - Confirm JavaScript function Executed and get response message", "I have a web browser control, I want to open a webpage and execute a JavaScript function that used AJAX to send the data and if data meet some rules it send back a <div ....\nThe <div will display a message whether submit succeed or not.\nI want to check if data sent and stored successfully then Invoke another JavaScript function.\n\nBut now I am using web browser DocumentCompleted event handler to find out page has been loaded and so on ...\n\nI have to use that event handler.\n\nWhat should I do to confirm JavaScript function executed and the response message is success?" ]
[ "javascript", "c#", "browser", "web", "controls" ]
[ "Function that return a console.log if array contains equal values", "I need to check equals values in my array. I try many ways but no one works.\n\nI try:\n\nvar sorted_arr = this.variacaoForm.value.variacoes.sort(); the comparing function here. \n\nfor (var i = 0; i < this.variacaoForm.value.variacoes.length - 1; i++) {\n if (sorted_arr[i + 1].sku == sorted_arr[i].sku) {\n console.log('Equals elements array')\n }\n}\n\n\nIn this way, the first and the third element never fire a console.log()\n\nAlso try:\n\nfor(let i=0;i<this.variacaoForm.value.variacoes.length;i++){\n if(this.produto.sku_prin == this.variacaoForm.value.variacoes[i].sku){\n console.log('Equal values array');\n }\n}\n\n\nin this way i receive console.log same if i don't have equal value\n\nAlso:\n\n for (let i = 0; i < this.variacaoForm.value.variacoes.length-1; i++) {\n for (let j = i+1; j < this.variacaoForm.value.variacoes.length; j++) {\n if (this.variacaoForm.value.variacoes[i].sku === this.variacaoForm.value.variacoes[j].sku) {\n console.log('x')\n }\n }\n }" ]
[ "angular", "typescript" ]
[ "Why is module not found only when doing unit testing with pytest?", "I'm having a problem running unit tests. I have a project structure like this:\nGiven this directory\nwho-said-what/\n |\n |_ wave_encoder.py\n | \n |_ tests/\n |_ test_wave_encoder.py\n\nwhere test_wave_encoder.py looks like this:\nfrom wave_encoder import *\n\nclass TestEncoder():\n def test_plot_no_fit1(self):\n encoder = WaveEncoder()\n self.assertRaises(ValueError, encoder.plot_signal)\n\n def test_plot_no_fit2(self):\n encoder = WaveEncoder()\n self.assertRaises(ValueError, encoder.plot_transform)\n\n def test_plot_no_fit3(self):\n encoder = WaveEncoder()\n self.assertRaises(ValueError, encoder.plot_components)\n\n\nIf I run this test file individually, no issues. However, if I try to run pytest from any directory in the project:\npytest -v --cov ./tests \n# or\npytest -v --cov .\n\nI get a ModuleNotFoundError: No module named 'wave_encoder'.\nHowever, if I move test_wave_encoder.py to the parent directory, it does work (there are other errors, but that's a different question).\nI don't really want a bunch of test files in the parent directory. How do I sort this out?" ]
[ "python", "unit-testing", "pytest", "pytest-cov" ]
[ "Devise breaks migrations in production", "I'm using devise 2.1.0. On dev, things are great. I just tried doing a cap deploy:migrations to a new server i setup in EC2 and its erring out at a devise migration. I'm using rvm with the ruby 1.9.3 running. My database is MySql and its running through Amazon RDS. The migration it errs on is:\n\ndef self.up\n change_table(:users) do |t|\n t.database_authenticatable :null => false\n t.recoverable\n t.rememberable\n t.trackable\n end\n\n add_index :users, :email, :unique => true\n add_index :users, :reset_password_token, :unique => true\n\n\nend\n\nwith this error: undefined method `database_authenticatable' for ActiveRecord::ConnectionAdapters::Table:0x00000004eb8968\n\ni've confirmed the devise gem is installed on the server already. I've also tried running the migration directly from the server and it fails. \n\nAny ideas whats going on?" ]
[ "ruby-on-rails", "devise", "capistrano" ]
[ "How do I determine which AudioContext constructor to use in Safari?", "I'm using the HTML5 web audio API, and I'm trying to dynamically determine which AudioContext constructor to use via\n\nvar constructor = AudioContext || webkitAudioContext;\nvar context = new constructor();\n\n\nHowever, with this code, Safari quips:\n\nReferenceError: Can't find variable: AudioContext\n\n\nFor starters, I didn't even know that ReferenceErrors exist in javascript, since undefined variables by default take on the undefined value. Safari's implementation of javascript apparently differs in big ways from that of Chrome, even though both use webkit engines ...\n\nHow do I determine which constructor to use without triggering this error?" ]
[ "javascript", "safari", "web-audio-api" ]
[ "How to run time expensive code in React Native", "We are currently working on a React Native app. We get some data from the server and have to do a heavy transformation on this data before saving it to the local database (we are using Realm).\n\nWhile this transformation is happening (10-20 seconds) the app cannot respond to any navigation or button presses. \n\nWhat approach should be used to offload this work from the JS thread (or at least split it into manageable chunks)?\n\nWe have tried searching for multi-threaded solutions, however, they do not appear to be well supported or recommended anywhere official. This leads us to believe we are missing a crucial concept." ]
[ "javascript", "react-native" ]
[ "Facebook Requests dialog - is there a way to disable frictionless requests?", "I am developing a Facebook app. \n\nIn that app, i have to send apprequests to multiple users.\nI am using the Requests dialog to send requests. \n\nIn the dialog, the friends list appears with a check box saying \"Don't ask again before sending requests to these friends from this app\". \n\nI do not want that check box. How can i remove that option? Where can i change that setting either in JS SDK or Developer App settings?" ]
[ "facebook", "social-networking", "facebook-requests" ]
[ "Modify variable in Inner class Java", "I have a problem with Java inner classes which I can't figure out. Suppose you have\n\nclass Outer\n{\n int outer = 0;\n class Inner\n {\n int inner = Outer.this.outer; //(or just outer as it is not shadowed)\n inner = 3; //or whatever, even outer = 3\n }\n}\n\n\nWell, when I write the last assignment I get the compilation error\n\nSyntax error on token \";\", , expected\n\n\non the precedent line.\n\nWhy I cannot modify inner?\n\nThank you!" ]
[ "java", "variables", "inner-classes" ]
[ "Android Button Text Color Always Pink", "I am trying to change both the button text color and the button background color when the button toggles between selected state and not. The background works perfectly, but the text just shows as pink (the default colorPrimary, which I have changed).\n\nres/drawable/map_button_background.xml\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item android:state_selected=\"false\">\n <shape android:shape=\"rectangle\">\n <corners android:radius=\"4dp\"/>\n <solid android:color=\"@android:color/transparent\"/>\n </shape>\n </item>\n\n <item android:state_selected=\"true\">\n <shape android:shape=\"rectangle\">\n <corners android:radius=\"4dp\"/>\n <solid android:color=\"@color/colorPrimary\"/>\n </shape>\n </item>\n</selector>\n\n\nres/drawable/map_button_text.xml\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item android:state_selected=\"false\">\n <color android:color=\"@color/colorPrimary\"/>\n </item>\n\n <item android:state_selected=\"true\">\n <color android:color=\"@android:color/white\"/>\n </item>\n</selector>\n\n\nres/styles/styles.xml\n\n<style name=\"Button.Map\">\n <item name=\"android:layout_height\">0dp</item>\n <item name=\"android:layout_weight\">1</item>\n <item name=\"android:layout_margin\">4dp</item>\n <item name=\"android:background\">@drawable/map_button_background</item>\n <item name=\"android:textColor\">@drawable/map_button_text</item>\n</style>\n\n\nAlso, the text color never changes, it just stays pink all the time. I tried adding <item android:color=\"@color:/colorPrimary\"/> to be used as a default, but it still doesn't work.\n\nAny ideas on what's causing it?" ]
[ "android", "xml", "button", "state" ]
[ "Tensorflow-GPU not using GPU with CUDA,CUDNN", "I want to use Tensorflow on GPU. So I install all the needed tool and installed as below-\n\nCUDA-11.2\nCUDNN-11.1\nAnaconda-2020.11\nTensorflow-GPU-2.3.0\n\n\nI tested that my cuda,cudnn is working using deviseQuery example.\nBut Tensorflow not used GPU. Then i find that version compatibility issue is possible so i innstalled CudaToolkit,cudnn using conda environment checking with version compatibility on Tensorflow website which is given below.\n\nCUDA-10.2.89\nCUDNN-7.6.5\nTensorflow-GPU-2.3.0\n\n\n\n\nBut after this try Tensorflow-GPU not used GPU,yet. so what i am doing now? Any steps or suggestion require." ]
[ "python", "tensorflow", "gpu" ]
[ "How to write a proper git pull with libgit2", "I want to write a C++ libgit2 wrapper to perform some basic git operations because libgit2 is too much atomic to be used as is (in my opinion).\nAs libgit2 is written in C, it does not matter if I get a C or C++ oriented solution, I will adapt it by myself.\n\nI encounter difficulties with the gitPull() function that is supposed to be the \"git pull\" equivalent.\n\nI planned to implement it as follows:\n\n\ngit_remote_fetch()\ngit_annotated_commit_from_fetchhead()\ngit_merge() (with the previously got git_annotated_commit)\ngit_commit_create()\n\n\nConsidering that it is the proper way to do it (tell me if it is not), I struggle with two issues:\n\n\nHow to check if the fetched HEAD is equal or different to the local HEAD ? (in order to know if the merge + commit are needed or not, in other words, if there is something to merge or if we already are up-to-date).\nHow or where to get the git_oid * id required by git_annotated_commit_from_fetchhead() ? (the last parameter).\n\n\nI know these questions may look quite basic but I could not find any exploitable information or example neither on the libgit2 API reference documentation nor in the libgit2 samples.\n\nI already have checked the already existing stackoverflow threads about this topic but none of them provide any exploitable code sample.\n\nI will be very grateful if someone could give me some helpful information about how to achieve it or explain what I have misunderstood." ]
[ "c++", "c", "libgit2" ]
[ "java import \"cannot find symbol\"", "I'm about porting a linux tool to windows. The tool works fine on linux system, but now on windows I get this \"cannot find symbol\" error. \n\nI have this little main class:\n\npackage foo;\n\nimport foo.bar;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n bar.getInstance();\n }\n}\n\n\nand the error appears now, while doing javac Main.java:\n\nimport foo.bar: cannot find symbol\n ^\nsymbol: class bar\nlocation: package foo\n\nMain.java and bar.java are in the same directory.\nwhat am I missing?" ]
[ "java", "import" ]
[ "Magento table tfoot location", "Where is the below? I've been looking for but cannot locate where this is.\nIt is a tfoot of order table in view order of my account page. Subtotal/ Shipping & Handling/Grand Total row\n\n\n\n<tfoot>\n <tr class=\"subtotal\">\n <td colspan=\"4\" class=\"a-right\">\n Subtotal </td>\n <td class=\"last a-right\">\n <span class=\"price\">$5,500.00</span> </td>\n</tr>\n <tr class=\"shipping\">\n <td colspan=\"4\" class=\"a-right\">\n Shipping & Handling </td>\n <td class=\"last a-right\">\n <span class=\"price\">$156.00</span> </td>\n</tr>\n <tr class=\"grand_total\">\n <td colspan=\"4\" class=\"a-right\">\n <strong>Grand Total</strong>\n </td>\n <td class=\"last a-right\">\n <strong><span class=\"price\">$5,656.00</span></strong>\n </td>\n</tr>\n </tfoot>\n\n\n\n\nI would like to change the column span from \"4\" to \"3\".\nBecause I removed \"SKU\" low on the td/tr.\n\nHow can I do?" ]
[ "magento" ]
[ "How to base the width of the rest of the elements on the width of the title?", "I have some centered divs that have a title and text below the title. The title is centered but the text is aligned on the left and starts from where the title starts. I used inline-block to make the div adjust in size based on the content. However, if the text is longer than the title, the container adjusts its width based on the text, not the title, so then the text appears wider than the title. How do I keep the width based on the title, not the text? I've included my code below as well as a badly drawn image to better understand what happens.\n\nHTML and CSS:\n\n\r\n\r\n.projects {\r\n width: 30vw;\r\n left: 10vw;\r\n right: 10vw;\r\n margin: 50px auto 0 auto;\r\n text-align: center;\r\n}\r\n\r\n.pContent {\r\n display: inline-block;\r\n margin-bottom: 10px;\r\n}\r\n\r\n.pInfo {\r\n text-align: left;\r\n}\r\n<div class=\"projects\">\r\n <h2>My Projects:</h2>\r\n <div class=\"pContent\">\r\n <h3 id=\"p1\" class=\"pTitle\">Project Title</h3>\r\n <div id=\"p1Info\" class=\"pInfo\">\r\n <p class=\"desc\">This is a project description Lorem Ipsum Dolor</p> \r\n <p class=\"demo\">View a demo of the project.</p>\r\n </div>\r\n </div>\r\n <br>\r\n <div class=\"pContent\">\r\n <h3 id=\"p2\" class=\"pTitle\">Another Project Title</h3>\r\n <div id=\"p2Info\" class=\"pInfo\">\r\n <p class=\"desc\">This is a project</p>\r\n <p class=\"demo\">View.</p>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\n\nHere's an image of what I want and what actually happens." ]
[ "html", "css" ]
[ "Installing .NET 4.5.2 on development machine causes error with System.Management.Automation.dll", "After I installed the framework version 4.5.2 on my development machine, I opened one of my websites in VS2010. I chose to NOT upgrade it, and have verified that the target framework is 3.5, but when I try and build, I get the error\n\n\n error BC32206: The project currently contains references to more than\n one version of System.Core, a direct reference to version 3.5.0.0 and\n an indirect reference (through\n 'System.Management.Automation.PSObject') to version 4.0.0.0. Change\n the direct reference to use version 4.0.0.0 (or higher) of\n System.Core.\n\n\nFor a variety of reasons, I do not want to upgrade the project to v4, and the version of System.Management.Automation.dll remains the same as before (6.1.7601.17514, dated 11/20/2010)\n\nThe problem appears when I'm running the code:\n\n For Each r As PSObject In powerShellObject.Invoke\n Debug.Print(r.ToString)\n returnValue += r.ToString\n Next\n\n\nAny insight would be appreciated." ]
[ ".net", "vb.net", "visual-studio-2010", "powershell" ]
[ "How to improve a trajectory of a camera, built from rotation and translation?", "I am trying to recover a trajectory of a 2D camera, using a sequence of 2D-images and OpenCV. But the trajectory I get is not so good as I would like it to be. It goes back and forth instead of going just forth.\n\nI have a sequence of photos taken on 2D-camera while it was moving (KITTI dataset, outdoors part, namely). For each two sequential frames I compute the rotation matrix (R) and translation vector (t) with E = cv2.findEssentialMat() and cv2.recoverPose(E, ...), and then I estimate the trajectory, assuming that coordinates of every translation vector are given in local coordinate system, which position is set by the corresponding rotation matrix.\n\nupd: Each recovered position looks like [X,Y,Z], and I scatter (X_i, Y_i) for every i (these points are thought to be 2D positions), so the following graphs are my estimated trajectories. \n\nHere's what I get instead of a straight line (the camera was moving straight forward). Previous results were even worse.\n\nThe green point is where it starts and the red point is where it ends. So most of the time it even moves backwards. This, though, is probably because of a mistake in the beginning, which was the cause of everything turning around (right?)\n\nHere's what I do:\n\nE, mask = cv2.findEssentialMat(points1, points2, K_00, cv2.RANSAC, 0.99999, 0.1)\n\ninliers, R, t, mask = cv2.recoverPose(E, points1, points2, K_00, R, t, mask)\n\n\nSeems to me that recoverPose somehow chooses wrong R and t sign on some steps. So the trajectory that was supposed to go forward, goes back. And then forth again.\n\nWhat I did to improve the situation was:\n\n1) skip the frames with too many outliers (I check this both after using findEssentialMat and after using recoverPose)\n\n2) set the threshold for RANSAC method in findEssentialMat to 0.1\n\n3) increase the number of the feature points on each image from 8 to 24.\n\nThis didn't really help.\n\nHere I need to note: I know that on practice, 5-point algorithm, which is used for computing the essential matrix, needs a lot more points than 8 or even 24. And maybe this is actually the problem.\n\nSo the questions are:\n\n1) Can the number of feature points (approx. 8-24) be the cause of recoverPose mistakes?\n\n2) If checking the number of outliers if the right thing, then what percentage of outliers should I set as the limitation?\n\n3) I estimate positions like this (instead of simple p[i+1] = R*p[i]+t):\n\nC = np.dot(R, C)\np[i+1] = p[i] + np.dot(np.linalg.inv(C), t)\n\n\nThis is because I can't help thinking of t as a vector in local coordinates, so C is the transformation matrix, which is updated on every step to summarize the rotations. Is that right or not really?\n\n4) It's really possible that I am missing something, since my knowledge of the topic seems tiny. Is there anything (anything!) you could recommend? \n\nHuge thanks for your time! I would appreciate any advice.\n\nupd: for example, here are the first six rotation matrices, translation vectors, and recovered positions I get. Signs of t seem a bit crazy. \n\nupd: here's my code. (I'm not a really good programmer yet). The main idea is that my feature points are corners of bouding boxes of static objects, which I detect with Faster R-CNN (I used this implementation). So the first part of the code detects objects, and the second part uses detected feature points for recovering the trajectory.\n\nHere's the dataset I use (this is part 2011_09_26_drive_0005 from here)." ]
[ "python", "opencv", "computer-vision", "pose-estimation", "slam" ]
[ "Change strings with different format to dates with the same format in a dataframe", "I have a dataframe which looks like this (it has thounds of date rows like this, ranging from years 18xx until 2019)\n\n date\n1 25 February 1987\n2 20 August 1974\n3 9 October 1984\n4 16-Oct-63\n5 13-11-1961\n6 03/23/87\n7 01.01.1995\n8 February 1988\n9 1988\n10 20050101-20051231\n\n\nI need to change the date column to one date-format (eg.: YYYY-MM-DD, or any other). \nSince there are just some Year values as for ID 9, I also have to autofill them. This should always lead to the last day of the particular year. If it ist like ID 8 a month and a year, it should always fill the last day of the particular month (and check if it was a leap year, like it was in 1988 and return in this case something like 1988-02-29). If it is a timeframe like in the last row, it should always cut off the first part and change it to the 31st of December of the given year.\nHow can I do this?\n\nI thought about using the lubridate package or the anytime package. With lubridate and parse_date or parse_date_time. This even works, but it always fills the missing values for days to the first day of a month and not the last. \n\nlibrary(lubridate)\n\ndate <- c(\"25 February 1987\", \"20 August 1974\", \"9 October 1984\", \"16-Oct-63\", \"13-11-1961\", \"03/23/87\", \"01.01.1995\",\n \"February 1988\", \"1988\", \"20050101-20051231\")\n\ndf <- as.data.frame(date)\n\nparse_date(df$date)\n\nparse_date_time(x = df$date,\n orders = c(\"d m y\", \"d B Y\", \"d/m/Y\",\"B Y\", \"Y\", \"m/d/y\",\n \"Ymd-Ymd\"),\n locale = \"eng\")\n\n\nMy actual results \n\n(parse_date(df$date)): \n\n [1] \"1987-02-25 UTC\" \"1974-08-20 UTC\" \"1984-10-09 UTC\" \"2019-10-16 UTC\" \"2019-11-13 UTC\" \"1987-03-23 UTC\" \"1995-01-01 UTC\"\n [8] \"1988-02-01 UTC\" \"1988-01-01 UTC\" \"2005-12-31 UTC\"\n\n\nFor the parse_date_time I acutally get an error, due to the last orders \"Ymd-Ymd\" (If I just test: parse_date(\"20050101-20051231\") it results in \"2005-12-31 UTC\", which I really want to have!)" ]
[ "r", "rstudio" ]
[ "Unable to return JSON data with Webflux authenticationFailureHandler", "Im building a React SPA and would like to interact with the back end using JSON. When an authentication fail I would like to be able to send a custom error message in the form of JSON. However given the code below:\n\n .authenticationFailureHandler(((exchange, e) -> {\n return Mono.fromRunnable(() -> {\n ServerHttpResponse response = exchange.getExchange().getResponse();\n response.setStatusCode(HttpStatus.OK);\n response.getHeaders().setContentType(MediaType.APPLICATION_JSON);\n DataBuffer buf = exchange.getExchange().getResponse().bufferFactory().wrap(\"{\\\"test\\\":\\\"tests\\\"}\".getBytes(StandardCharsets.UTF_8));\n response.writeWith(Mono.just(buf));\n });\n })\n\n\nIm getting the follwing error:\n\nHTTP/1.1 200 OK\nContent-Type: application/json\nCache-Control: no-cache, no-store, max-age=0, must-revalidate\nPragma: no-cache\nExpires: 0\nX-Content-Type-Options: nosniff\nX-Frame-Options: DENY\nX-XSS-Protection: 1 ; mode=block\nReferrer-Policy: no-referrer\ncontent-length: 0\n\n<Response body is empty>\n\nResponse code: 200 (OK); Time: 1162ms; Content length: 0 bytes\n\n\nHowever If I change response code it gets reflected in the response so I know the code is executed but no response body is returned.\n\nWhat do I need to change to be able to send a response body back when authentication fails?" ]
[ "java", "spring-boot", "spring-security", "spring-webflux" ]
[ "IIS to SQL Server Error 26, Same connection string works outside of IIS but not from within", "I have gone through every checklist I could find for configuring SQL Server I could find. I get the same issue on Windows Server 2008 and Windows 7 Pro. First the environment:\n\n\nSQL Server Express 2012 --installed as main instance (i.e. no named instances)\nIP access turned on\nFirewall exception for SQLServer\nSQL Server user for application access\nWindows Server 2008 service pack 2 (also tested with Windows 7 service pack 1)\nIIS 7 (also tested with 7.5 with the same results)\n.NET 4.0\nOur own database code integrated in a .NET MVC 3 application\n\n\nWe have a tool we developed to import data from the old Ruby on Rails app into the new ASP.NET MVC 3 app. The tool can connect to the database using the user account we created, and that's how I discovered some permissions issues for access to stored procedures. This is the tool we are using to verify the connection works.\n\n\n Data Source=SERVER_IP,1433;Network Library=DBMSSOCN;Database=MYDB;User ID=webuser;Password=webpassword;multipleactiveresultsets=true;\n\n\nWe are using a straight IP address, but to protect our infrastructure I substituted the IP, username, and password. But this is the structure of the connection string we are using. Following the checklists, I was able to connect from another machine on our network using the import tool to the database and import data. I was also able to import data from the same machine that IIS is installed on.\n\nThe same connection string provides the dreaded Error 26 \"can't find the database server\" message on both Windows Server 2008 and Windows 7 Pro:\n\n\n A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) \n\n\nI have exhausted every resource I can find, and can't seem to get any closer to an answer. I'm not trying to mount file based database, IIS has read/write access to the web application in any case.\n\n\n\nI've ruled out the firewall as a cause for the issue. I've tried the settings with the firewall on and completely turned off. There has to be some other permissions level problem that's happening. Problem is I have no idea what permissions level things I have to check." ]
[ "asp.net-mvc-3", "iis", ".net-4.0", "sql-server-2012" ]
[ "Split string of emoji characters by split function with regex", "I want to use split function of Javascript to split string of emoji characters. In stackoverflow there are many question like that, but I cannot find any completed solutions. So I do it by my own way:\n\na) Use split function with regex.\n\nb) Split emoji characters by regex unicode matches: from \\uD800 to \\uDBFF and from \\uDC00 to \\uDFFF.\n\nc) In this regex, exclude zero-with-joiner (\\u200D) and variation selector (\\uFE0F) characters. \nSo I wrote as follows:\n\nvar p = '‍‍‍‍❤️‍‍';\n\n\nand split it:\n\nvar split = p.split(/(?![\\u200D\\uFE0F])([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/);\n\n\nBut the result is wrong :(\n\n[\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"‍\", \"\", \"‍\", \"\", \"‍\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"‍❤️‍\", \"\", \"‍\", \"\", \"\"]\n\n\nDid I use the excluding selector for regex right? If right, the error caused by my idea?\nThe expected result need to be: [\"\", \"\", \"\", \"\", \"\", \"‍‍‍\", \"\", \"\", \"‍❤️‍‍\"]\n\n===\n\nI want to update info. I solved this problem for my site: https://www.emojionline.org. You can test. I just use a dictionary that hold all emojis and I use the replace function to replace every emoji by |emoji|. And I can split string emoji by symbol |. That works well :)" ]
[ "javascript", "regex", "unicode", "emoji" ]
[ "What's inside a Docker image/container?", "Considering the fact that docker images/containers come in various flavours - Ubuntu, CentOS, CoreOS etc.... I'm curious what actually makes up an image/container, and what is shared with the host OS? Where is the dividing line?\n\nFor example, I can download the base Ubuntu image and launch it on a CentOS host. Then, when I poke around inside the Ubuntu container I can see that it looks and feels like an Ubuntu server (filesystem layout etc). But if I run a uname command I see the kernel and the likes of the CentOS host.... \n\nObviously I understand that the underlying kernel is shared by all containers on the same host. But what else is shared with the host OS, and what is part of the image/container?\n\nE.g. the kernel is part of the host, the filesystem layout is part of the the image/container.... Is there a spec that defines this?" ]
[ "linux", "ubuntu", "containers", "docker" ]
[ "Control UIView on Load", "Hi everybody I am trying to make an app with a login page and profile page.\n\nSo i am using two view for them : login_view and profile_view\n\nSo login_view is my view in nib file i.e default view.\n\nbut i want to check if the user has already signed in before in viewdidLoad method like session and show him profile_view instead when app starts.\n\nCan Anybody help me in it?\n\nI tried this but failed\n\nNSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];\n if ([array count] == 0) \n {\n NSNumber * uud = [array objectAtIndex:0];\n [self.view = home];\n\n }" ]
[ "uiview" ]
[ "Issues with invalid syntax error in a url", "In my code Im trying to get the user to log in and retrive some information, but I get a syntax error with my variables user and password. bold print is commented out in code\n\nimport urllib.request\nimport time\nimport pycurl\n#Log in\nuser = input('Please enter your EoBot.com email: ')\npassword = input('Please enter your password: ')\n#gets user ID number\nc = pycurl.Curl()\n#Error below this line with \"user\" and \"password\"\nc.setopt(c.URL, \"https://www.eobot.com/api.aspx?email=\"user\"&password=\"password\")\nc.perform()" ]
[ "python", "variables", "url", "syntax", "pycurl" ]
[ "Unable to use the logout function within the Drawer Navigator", "I am fairly new to react-native but I have been able to make a login with authentication using firebase. Alongside this, I have used a drawer for further navigation. However, when a user is logged in I want them to be able to logout via a button on that drawer. Currently, when I click it is it doing nothing...\n\nI have tried changing to the this.logout function to this.logout() which reaches the console.log(\"here) statement but then returns an undefined error. I have also played around with the bindings but with no results.\n\nexport default class App extends React.Component {\nconstructor(props) {\n super(props);\n this.state = {\n authenticated: false,\n }\n this.logout = this.logout.bind(this)\n};\n\n\ncomponentDidMount() {\n firebaseConfig.auth().onAuthStateChanged((authenticated) => {\n authenticated ? this.setState(() => ({\n authenticated: true,\n })) : this.setState(() => ({\n authenticated: false,\n }));\n });\n}\n\n//Logout of firebase and navigate to login screen\nlogout = () => {\n console.log(\"here\")\n firebaseConfig.auth().signOut()\n .then(() => this.props.navigation.navigate('Login'))\n .catch((err) => {\n console.log(err)\n });\n};\n\n\nrender() {\n //const {currentUser} = this.state\n return (\n <Application/>\n\n )\n }\n}\n\n\nconst DrawerComponents = (props) =>\n<SafeAreaView style={styles.safeArea}>\n <View style={styles.logo}>\n </View>\n <ScrollView>\n <DrawerItems{...props}/>\n <View style={{flex: 1}}>\n <Button title=\"Logout\" onPress={this.logout}/>\n </View>\n </ScrollView>\n</SafeAreaView>\n\n\nconst TabNavigator = createDrawerNavigator({\nHome: {screen: Homepage},\nProfile: {screen: Profile},\nLogin: {\nscreen: Login,\nnavigationOptions: ({navigation}) => {\n return {\n drawerLabel: () => null,\n drawerLockMode: 'locked-closed'\n }\n }\n },\n SignUp: {\n screen: SignUp,\n navigationOptions: ({navigation}) => {\n return {\n drawerLabel: () => null,\n drawerLockMode: 'locked-closed'\n }\n }\n },\n Loading: {\n screen: Loading,\n navigationOptions: ({navigation}) => {\n return {\n drawerLabel: () => null,\n drawerLockMode: 'locked-closed'\n }\n }\n },\n},\n\n{\n headerMode: null,\n contentComponent: DrawerComponents,\n drawerWidth: WIDTH,\n drawerPosition: \"right\",\n initialRouteName: 'Home',\n contentOptions: {\n activeTintColor: \"orange\"\n }\n\n});\n\nconst Application = createAppContainer(TabNavigator)\n});\n\n\nI am expecting that upon clicking logout, the currently logged in user on firebase is signed out and then is redirected to the login screen." ]
[ "reactjs", "react-native", "navigation-drawer" ]
[ "To display Number With 2 Decimal Places", "I have a field in datatable .If 1000 is the value in it, i want to display it as 1000.00.Then if user changes to 1000.50 it should display as it is.Is there anyway to do this?Can anybody help?" ]
[ ".net", "asp.net", "vb.net" ]
[ "GET/POST method not working to get data from mysql database to html using json", "I am trying to get data in html page from mysql database using GET/POST method with help of json and Jquery. The scenario is i am taking two value from user interface (searchtenant.html) and POST it to newterms2.html where newterms2.html is getting data from tenantlistmob2.php using JSON.\nMy searchtenant.html is\n\n<!DOCTYPE HTML>\n<html>\n<body>\n<form action=\"newterms2.html\" method=\"post\">\nFirst Name:<input type=\"text\" id=\"fname\" name=\"fname\" placeholder=\"First Name\" required=\"required\"/><br /><br />\nLast Name: <input type=\"text\" id=\"lname\" name=\"lname\" placeholder=\"Last Name\" required=\"required\"/><br /><br />\n<input type=\"submit\" id=\"save\" name=\"search\" value=\"Search\"/>\n</form>\n</fieldset>\n</body>\n</html>\n\n\nMy tenantlistmob2.php is\n\n<?php \ninclude('connection.php');\n$fname = $_POST['fname'];\n$lname = $_POST['lname'];\n$result = mysql_query(\"SELECT * FROM `tenanttemp` WHERE `TenantFirstName`='$fname' and `TenantLastName`='$lname'\");\n//$result = mysql_query(\"SELECT * FROM `tenanttemp`\");\nwhile ($row = mysql_fetch_assoc($result)) \n{\n $array[] = array($row['TenantFirstName']);\n }\necho json_encode($array);\n?>\n\n\nMy newterms2.html is like\n\n<!DOCTYPE HTML>\n<html>\n<head>\n<script type=\"text/javascript\" src=\"myjquery.js\"></script>\n<script type=\"text/javascript\" language=\"javascript\">\n$(document).ready(function() { \n jQuery.getJSON(\"tenantlistmob2.php\", function (jsonData) {\n jsonData= eval(jsonData);//get json array\n for (i = 0; i < jsonData.length; i++)//iterate over all options\n {\n for ( key in jsonData[i] )//get key => value\n { \n var tblRow = \"<tr>\" + \"<td>\" + \"<a href='#'>\" + jsonData[i][key] + \"</a>\" + \"</td>\" + \"</tr>\"\n $(tblRow).appendTo(\"#getname tbody\");\n }\n }\n\n });\n\n });\n </script></head>\n <body>\n <form name=\"index\">\n <div id=\"getname2\"></div>\n <div>\n <table id=\"getname\" border=\"1\">\n <thead>\n <th>Name</th>\n </thead>\n <tbody>\n\n </tbody>\n</table>\n</div>\n</form>\n</body>\n</html> \n\n\nThis is the total scenario.If i call tenantlistmob2.php directly from searchtenant.html using POST method it works fine.But i need html page to show the data because i will use this html page for both android and iPhone. The query ($result = mysql_query(\"SELECT * FROM tenanttemp\");) works fine and return properly to newterms2.html.But when i use POSTed data ($result = mysql_query(\"SELECT * FROM tenanttemp WHERE TenantFirstName='$fname' and TenantLastName='$lname'\");) it works properly in php but not returning data to newterms2.html page.\n\nWhat is the solution? I like to get the data in html page.Please help.\n\nThanks in advance." ]
[ "php", "mysql", "json", "html" ]
[ "C# - I'm having problems overwriting data in text file from Listbox", "I'm creating a small program that can save website urls/links into a listbox. From there, I can save the contents of the listbox onto a text file. That text file is then saved to a folder on my desktop that was prematurely made for the program. The application can open a text file and display the contents to the listbox as well as create and save a new text file with. My problem is how would I overwrite the text file properly.\n\nThis is the code I have for the Save Toolbox button:\n\nprivate void saveToolStripMenuItem_Click(object sender, EventArgs e)\n{\n SaveFileDialog saveFileDialog1 = new SaveFileDialog();\n string line = \"\";\n\n if (File.Exists(path)) //the path string is a folder on my desktop\n {\n FileStream fstream = File.Open(path, FileMode.Create);\n while (line != null)\n {\n using (StreamWriter write = new StreamWriter(fstream))\n {\n foreach (object item in WebListBox.Items)\n write.WriteLine(item.ToString());\n }\n }\n }\n else\n {\n saveFileDialog1.Filter = \"Text files (*.txt)|*.txt\";\n saveFileDialog1.Title = \"Save as Text File\";\n saveFileDialog1.ShowDialog();\n\n if (saveFileDialog1.ShowDialog() == DialogResult.OK)\n {\n using (FileStream S = File.Open(saveFileDialog1.FileName, FileMode.CreateNew))\n {\n using (StreamWriter st = new StreamWriter(S))\n {\n foreach (var items in WebListBox.Items)\n st.WriteLine(items.ToString());\n }\n }\n }\n }\n}\n\n\nThe problem is that after I create the text file using the Save As ToolBar button, the compiler seemingly ignores the code in my if statement and assumes that I want to always create a new text file to save to. Thanks in advance!" ]
[ "c#", "winforms", "listbox" ]
[ "Best C++ Code Formatter/Beautifier", "There are lots of source code formatting tools out there. Which ones work best for C++?\n\nI'm interested in command-line tools or other things that can be automatically run when checking code in/out, preferably without needing to launch an editor or IDE.\n\n(If you see the one you like already listed as an answer, vote it up. If it's not there, add it.)" ]
[ "c++", "code-formatting" ]
[ "SSIS For Loop Container equivalent in Talend Open Studio", "I have a talend mapping which needs to be executed based on a ID. I want to pass the ID as a parameter. The mapping should execute for one ID at an time. I want to loop the execution for each ID one after the other. This can be achieved in SSIS using the For Loop Container. Can anyone help me finding out the equivalent for the same in Talend Open Studio. \n\nThanks in advance." ]
[ "for-loop", "containers", "talend" ]
[ "Playing wave files in Android", "I am trying to play a wave file(VoiceMail) in Android. The file is downloaded from a remote server and written to sdcard.\n\nI use the following code to play the Wave file usign the MediaPlayer class bundled with the SDK:\n\nFileDescriptor fd = new FileInputStream(songFile).getFD(); \n\n MediaPlayer mMediaPlayer = new MediaPlayer();\n\n mMediaPlayer.reset();\n try{\n mMediaPlayer.setDataSource(fd);\n }\n catch(IllegalStateException e){\n mMediaPlayer.reset();\n mMediaPlayer.setDataSource(fd);\n }\n mMediaPlayer.prepare(); \n mMediaPlayer.start();\n\n\nHowever when I run my code, I get the following error:\nCommand PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported\nerror (1, -4).\n\nNote that when I pull this file on my desktop machine and copy it to the Music folder of my HTC hero device, the Music player of the device can play this file so I am guessing the file format is compatible with Android.\n\nNot sure of what the problem is; please help.\n\nThanks." ]
[ "android" ]
[ "possible to create latex multicolumns in xtable?", "I am using xtable with R Markdown and knitr to produce .tex files that I call with \\input{}. Works great, but I have not figured out how to create multicolumns like the one shown here. Does anyone know how to to this?\n\nSo far I am using:\n\ntbl <- xtable(data, align=\"l r r r r r\")\ncolnames(tbl) <- c(\"Variable\", \n \"Mean\", \"Std Dev\", \n \"Mean\", \"Std Dev\", \n \"Difference\")\ncaption(tbl) <- c(\"Table Title\")\nprint(tbl, \n include.rownames=FALSE,\n caption.placement=\"top\",\n booktabs=TRUE,\n type=\"latex\", \n file=\"output.tex\")\n\n\nI'd like to have a different grouping header over each \"Mean\" and \"Std Dev\" (\"Treatment\" and \"Control\"). \n\nAlternatively, is there a better method for using R Markdown/knitr to automatically generate tables? I don't want to manually edit the tables because the report needs to generate automatically.\n\nUPDATE:\n@agstudy: I'm new to latex, but I think this is the output I am looking to produce automatically with xtable (or something like xtable):\n\n\\begin{tabular}{lrrrrr}\n \\toprule\n & \\multicolumn{2}{c}{Treatment} & \\multicolumn{2}{c}{Control} & \\\\\n \\cmidrule(lr){2-3} \\cmidrule(lr){4-5}\n Variable & Mean & Std Dev & Mean & Std Dev & Difference \\\\ \n \\midrule\n var1 & 1 & 2 & 3 & 4 & 5 \\\\ \n \\bottomrule\n\\end{tabular}\n\n\nUPDATE 2:\n@Jonathan: it took me a few reads to understand what you were suggesting. I took your recommendation, and it worked.\n\nIn the R markdown chunk I now use:\n\ntbl <- xtable(data)\nprint(tbl,\n only.contents=TRUE,\n include.rownames=FALSE,\n type=\"latex\",\n digits(tbl) <- c(0,1,1,1,1,1),\n file=\"output/tblout.tex\")\n\n\nThen in the text, I use:\n\n\\begin{tabular}{lddddd}\n\\toprule\n & \\multicolumn{2}{c}{Treatment} & \\multicolumn{2}{c}{Control} & \\\\\n \\cmidrule(lr){2-3} \\cmidrule(lr){4-5}\n Variable & \\multicolumn{1}{r}{Mean} & \\multicolumn{1}{r}{Std Dev} & \\multicolumn{1}{r}{Mean} & \\multicolumn{1}{r}{Std Dev} & \\multicolumn{1}{r}{Difference} \\\\\n\\midrule\n\\input{../output/tblout}\n\\bottomrule\n\\end{tabular}\n\n\nI'll see if anyone has any other suggestions for a native xtable (or other package) solution. Otherwise, I will accept your answer. Thanks!" ]
[ "r", "latex", "knitr", "xtable", "r-markdown" ]
[ "problem with python tkinter pandas search function", "i am trying to make a program that reads EXCEL files using tkinter and pandas but i having trouble with the search function the program works it searchs and all but it says "empty dataframe" and doesn't show the information i am looking for.\n[![the excel file][1]][1]\nthis is the code i made:\nimport pandas as pd\nfrom tkinter import *\nimport tkinter.ttk as ttk\nfrom tkinter.filedialog import *\nfrom tkinter.messagebox import *\nimport xlrd\nimport xlwt\n\n\nfen = Tk()\nfen.geometry('320x320')\n\nfen.title("test")\n\nlf1=LabelFrame(fen,text='Informations')\nlf1.place(x=10,y=10,width=300,height=300)\n\nLabel(lf1,text='fichier excel :').place(x=10,y=20)\nLabel(lf1,text='Référence :').place(x=10,y=60)\nLabel(lf1,text='Type :').place(x=20,y=140)\nLabel(lf1,text='Famille :').place(x=20,y=220)\nfilo = None\ndef add() :\n global filo\n filo=askopenfilename(filetypes=[("EXCEL","*.xlsx")])\n if filo != '':\n print('you chose a new file')\n##search function\n\ndef search():\n df = pd.read_excel(filo,header=0)\n print(df)\n print(df.loc[(df['Référence Concernée'] == ref ) & (df['Type du non conformitée']== typ )])\n \nfichier=ttk.Button(lf1,text='Ajouter',command=add)\nfichier.place(x=120,y=20)\n\nSearchButton = ttk.Button(lf1,text='search',command = search)\nSearchButton.place(x=120,y=250)\n\nref=Entry(lf1)\nref.place(x=100,y=55)\n\ntyp=Entry(lf1,state='disabled')\ntyp.place(x=100,y=135)\n\nFamille=Entry(lf1,state='disabled')\nFamille.place(x=100,y=220)\n\ndef r1():\n typ.configure(state='normal')\n Famille.configure(state='disabled')\n\n \ndef r2():\n typ.configure(state='disabled')\n Famille.configure(state='normal')\n\nvals = ['A', 'B']\netiqs = ['Managers','techniciens']\nvarGr = StringVar()\n\nr1=ttk.Radiobutton(lf1, variable=varGr, text=etiqs[0], value=vals[0],command=r1)\nr2=ttk.Radiobutton(lf1, variable=varGr, text=etiqs[1], value=vals[1],command=r2)\n\nr1.place(x=10,y=100)\nr2.place(x=10,y=180)\n\n\n [1]: https://i.stack.imgur.com/00UmP.png" ]
[ "python", "tkinter" ]
[ "how to use a class like a range for a data properties in Protege", "I create a data properties named kind. \nI want it range to be StateKing. I don't know how to do. In fact, in the \"Property assertions view\", \"Description view\", when I click on to the 'Add' icon (+) next Ranges pop up appear with a specify datatypes like int, Boolean, integer, ... \nNote that StateKing is an enumerate class. \n\nStateKing: Equivalent classes {choise , final , fork , initial , join , junction , state}. \n\n\nThank you for your advices.\n\nPS: I can't add image now." ]
[ "owl", "protege", "protege4" ]
[ "how to display grouped listview with gridlines?", "i created a listview with many groupds inside meanwhile I set listview.view=details and set gridlines=true but I couldn't find the gridlines in the listview when the listview was displayed." ]
[ "c#", "winforms", "c++-cli" ]
[ "Solr join query between two document", "I have product document having \"sid\" field is foreign key for sales document and another document sales it have \"id\" field this is primary field in sales document. how to get all the products matched sales document having \"sid\" values in sales document.\n\nhow to write solr join query?\n\nExample:\nHaving solr core name \"test\" under this we have following data.\n\"docs\": [\n {\n \"PPS_productID\": \"CB_9457\",\n \"documentType\": \"Sales\",\n \"name\":\"A1\"\n\n },\n {\n \"documentType\": \"Products\",\n \"PPS_productID\": \"PPS3-639\",\n \"PPS_storeid\": \"CB_9457\"\n },\n {\n \"PPS_productID\": \"CB_9458\",\n \"documentType\": \"Sales\",\n \"name\":\"A2\"\n },\n {\n \"documentType\": \"Products\",\n \"PPS_productID\": \"PPS3-640\",\n \"PPS_storeid\": \"CB_9458\"\n }\n {\n \"PPS_productID\": \"CB_9459\",\n \"documentType\": \"Sales\"\n \"name\":\"A3\"\n },\n {\n \"documentType\": \"Products\",\n \"PPS_productID\": \"PPS3-640\",\n \"PPS_storeid\": \"CB_9460\"\n }\n\n\n]\n\nHow to get the following response from join query. \n\"docs\": [\n {\n \"documentType\": \"Products\",\n \"PPS_productID\": \"PPS3-639\",\n \"PPS_storeid\": \"CB_9457\",\n \"name\":\"A1\"\n },\n {\n \"documentType\": \"Products\",\n \"PPS_productID\": \"PPS3-640\",\n \"PPS_storeid\": \"CB_9458\",\n \"name\":\"A2\"\n }\n]" ]
[ "solr" ]
[ "Why am I getting RichEdit line insertion error when I call Delete in OnChange event?", "I've googled and checked many places for a solution, but all cases I found differed or involved something more advanced than simply adding or deleting lines. Basically, I want to make a sort of scrolling rich edit (alternative would be moving the caret to the bottom, which I already found a solution for).\n\nI'm adding lines to it and checking Lines.Count with the OnChange event of the rich edit and as soon as it reaches value greater 15 I want to call Lines.Delete(0), however I get the error:\n\nRichEdit line insertion error\n\n\nCan someone tell me what am I doing wrong here ?" ]
[ "delphi", "delphi-xe2", "richedit" ]
[ "docker interpretes entrypoint path as relative?", "Currently debugging a vscode devcontainer, quite odd:\n$ docker run -a STDOUT -a STDERR -it --entrypoint /bin/sh vsc-282c0b4a9ac1294bc597aabf74e28acf\ndocker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \\"C:/Program Files/Git/usr/bin/sh\\": stat C:/Program Files/Git/usr/bin/sh: no such file or directory": unknown.\n\nhas anyone seen that before? (/bin/sh is a real file:\n$ docker run -a STDOUT -a STDERR -it --entrypoint sh vsc-282c0b4a9ac1294bc597aabf74e28acf\n# ls /bin/sh\n/bin/sh\n\nI am very confused..." ]
[ "windows", "docker" ]
[ "How can I backup an Azure RemoteApp VM?", "I want to be able to create a \"disk image\" of a RemoteApp VM so I can return it later to a certain state.\n\nI've searched but not found any way to do this. Is there a way to do this?" ]
[ "azure", "cloud", "remoteapp" ]
[ "SQL - Search a table for all instances where a value is repeated", "I'm looking to find a way to search a table for duplicate values and return those duplicates (or even just one of the set of duplicates) as the result set.\n\nFor instance, let's say I have these data:\n\n\nuid | semi-unique id\n1 | 12345\n2 | 21345\n3 | 54321\n4 | 41235\n5 | 12345\n6 | 21345\n\n\nI need to return either:\n\n\n12345\n12345\n21345\n21345\n\n\nOr:\n\n\n12345\n21345\n\n\nI've tried googling around and keep coming up short. Any help please?" ]
[ "sql", "sql-server", "database", "tsql" ]
[ "mongoose: findOne using mongo _id", "I get that this can be a duplicated question. I looked up at least 10 related questions and answers, but I am still not able to find the document.\nI am trying to get the document using .findOne(). I have the _id that created by MongoDB. But, I get null for every search I try.\nawait mongoose.connection.db\n .collection('testing')\n .findOne({ _id: req.body.test_id }, (err, result) => {\n if (err) {\n res.status(400);\n } else {\n console.log(`whaaaaaahsidufh ${result}`);\n }\n });\n\nI tried _id: mongoose.Type.ObjectId(req.body.test_id) and other possible way to search. How can I retrieve the result by using _id on mongoose?" ]
[ "node.js", "mongodb", "mongoose" ]
[ "Dynamic topics with socket.io", "I am developing ionic mobile application with node js backend. \nThe problem is, I want to create dynamic topics with user's username or unique id to send data from server to mobile app.\nwhat is the best way to do this task. any ideas or reference?" ]
[ "node.js", "sockets", "ionic-framework", "socket.io" ]
[ "Python I2C LCD exception", "I want to do a program which uses I2C LCD display if possible or cli output if not.\n\nEverything is fine when I start the program on Raspberry Pi where LCD is connected. The problem starts when I move the program to my laptop where there aro no GPIO, no I2C and therefore no LCD at all.\n\nI want to make proper \"if\" but I couldn't find any proper solution.\n\nLine of code which makes problems on my Laptop:\n\n def __init__(self, addr, port=1):\n self.addr = addr\n self.bus = smbus.SMBus(port)\n\nTraceback (most recent call last):\n File \"./lcd\", line 164, in <module>\n lcd=lcd()\n File \"./lcd\", line 114, in __init__\n self.lcd_device = i2c_device(ADDRESS)\n File \"./lcd\", line 25, in __init__\n self.bus = smbus.SMBus(port)\nIOError: [Errno 13] Permission denied\n\n\nAny idea how to handle that \"if\" checking if I can use LCD or not? I use Ubuntu 18 if it changes anything.\n\nThx." ]
[ "python", "ubuntu", "i2c" ]
[ "check if textbox exists vba (using name)", "I am using Ms-Access and I created a userform which has a number of Textboxes on it. The boxes are named: Box1, Box2, Box3 ...\nI need to loop through all boxes, but I don't know which is the last one. To avoid looping through all userform controls I thought of trying the following:\nFor i =1 To 20\n\nIf Me.Controls("Box" & i).value = MyCondition Then\n 'do stuff\nEnd If\n\nNext i\n\nThis errors at Box6, which is the first box not found. Is there a way to capture this error and exit the loop when it happens.\nI know I could use On Error but I 'd rather capture this specific instance with code instead.\nThanks,\nGeorge" ]
[ "vba" ]
[ "R Plotly change color of stacked bar chart", "I have a Plotly stacked bar plot. I'd like to change the colors of the bars so I have Red and Dark Blue instead of the default colors you see below\n\n\n\nMy code below. I tried using the marker function but it converts the whole plot to a single color. Any help would be appreciated.\n\npie_subsegment_split %>%\nplot_ly(x = ~Segment, y = ~Not*100, type = 'bar', name = 'Not') %>%\nadd_trace(y = ~QoL*100, name = 'QoL') %>%\nlayout(yaxis = list(title = 'Percentage (%)'),barmode = \"stack\",showlegend=T) %>%\nlayout(xaxis = list(title=\"Sub-Segment\",showticklabels=FALSE))" ]
[ "r", "plotly" ]
[ "React this.props.children versus createReactClass", "I have the following code that works:\n\n let registered = [];\n React.Children.forEach(this.props.children, (child) => {\n let name = child.type.name;\n if (registered.indexOf(name) === -1) {\n gLayout.registerComponent(name, createReactClass({\n render: () => (child)\n }));\n registered.push(name);\n }\n });\n\n\nHowever, my question is if I can provide the child directly without wrapping it into a new react class.\n\nI tried replacing the createReactComponent with render function, with simply child.type and React.cloneElement(child, {}) but none of them work because the registerComponent function (of golden-layout framework) will complain that either a constructor function or the componentWillUpdate member function is missing.\n\nWrapping a new component around an existing component seems unnecessary overhead and may require me to duplicate code, so I'm looking for a cleaner option." ]
[ "reactjs", "children", "golden-layout" ]
[ "Center div dynamically", "I need to make a website and there is a button which is in the middle horizontally. I can use left 50% or margin-left but when I minimize the window - it isn't in the middle. How do I set the div to be exactly in the middle also when you minimize the window of the browser?\n\nEdit: fixed it by doing as Trix said and adding\n\n.center-div{\nmargin: 0 auto;\n\n\n}" ]
[ "html", "css", "alignment", "vertical-alignment" ]
[ "Java How to Wait Until Thread Exits or User Presses Enter", "I have a need to exit an application when either a user presses enter, or another thread finishes its work. The way I accomplished this in the past was the following:\n\n// Main\nfinal Worker worker = new Worker();\nfinal Thread workerThread = new Thread(worker::run);\nworkerThread.start();\ntry {\n System.in.read();\n} catch (final IOException e) {\n // The worker thread finished executing\n}\n\n// Worker::run\npublic void run() {\n ...\n System.in.close();\n}\n\n\nThis previously seemed to be working just fine, but recently broke after performing some refactoring. Now, in the call to System.in.close() in the other thread, that thread gets hung indefinitely in FileInputStream::close, in the native method close0. Can anyone explain why this method call is getting hung indefinitely, as if there is a deadlock situation?\n\nI do have a work-around for this, which is the following:\n\n// Main.java\nprivate static final Object waitObject = new Object();\n\nprivate static boolean isRunning = true;\n\nprivate static void notifyWaitObject() {\n synchronized (waitObject) {\n isRunning = false;\n waitObject.notify();\n }\n}\n\npublic static void main(final String[] args) {\n // Create a thread to wait until enter is pressed\n final Thread waitThread = new Thread(() -> {\n try {\n System.in.read();\n } catch (final IOException e) {\n // Eat the exception\n } finally {\n notifyWaitObject();\n }\n }, \"User Input Thread\");\n waitThread.setDaemon(true);\n waitThread.start();\n\n // Create a worker thread\n final Worker worker = new Worker();\n final Thread workerThread = new Thread(() -> worker.run(Main::notifyWaitObject));\n workerThread.start();\n\n // Wait until either the worker threads are done, or enter is pressed\n synchronized (waitObject) {\n if (isRunning) waitObject.wait();\n }\n}\n\n// Worker.java\npublic void run(final Runnable exitNotifier) {\n ...\n exitNotifier.run();\n}\n\n\nHowever, the above seems unnecessarily heavy for something that seems like it should be relatively simple. Does anyone know of a better way to implement this in a thread-safe way?" ]
[ "java", "multithreading", "io" ]
[ "Controlling the number of links shown in Wordpress", "I am using the following code to show links of favourite posts in the sidebar but I want to controll the number of links to show only 3 links and if this is exceeded, i want the link to View All favourites to show.\n\nPHP: \n\n<?php\n$favorites = va_get_dashboard_favorites($dashboard_user->ID, (bool) $is_own_dashboard );\n\nif ( $favorites->post_count > 0 ) {\nwhile ( $favorites->have_posts() ) : $favorites->the_post();\n\n$post_status = $is_own_dashboard ? 'post-status' : '';\n?>\n<article id=\"post-<?php the_ID(); ?>\" <?php post_class( $post_status ); ?>>\n <a href=\"<?php echo get_permalink($ID); ?>\">My link to a post or page</a><?php echo get_the_title($ID); ?>\n</article>\n<?php\nendwhile;\n} else {\n?>\n\n<?php\n}\n } \n\n\nHow can I achieve this?\n\nPlease help" ]
[ "php", "wordpress" ]
[ "React 2 elements with props given by the same function causes any update of either element to affect the other", "I have the an app with the following format. The sort_data function is causing some very strange behavior that I would love to understand.\n\nclass App extends Component{\n ... \n render(){return(\n <ChartInterface \n row_data1={sort_data(this.getrow_data1())} \n row_data2={sort_data(this.getrow_data2())}/>\n <Controls \n change_data1={this.control_function1}\n change_data2={this.control_function2}/>\n )}\n\nfunction ChartInterface(props){\n /* notice props.row_data2 is not used*/\n return <div>props.row_data1</div>\n}\n\n\n/*details*/\nfunction sort_data(xdata){\n /* sorting algorithm that takes array of arrays of objects \n and returns xdata but with the indexes were swapped based on\n element properties */ return xdata}\n\n\nThe Controls component has children which will sometimes call one of control_function1 or control_function2. When called these functions invoke a setState in App, which changes some state variable (this.state.x1 or this.state.x2 depending on which function was called).\n\nThese state variables (this.state.x1 and this.state.x2) determine the data returned by this.getrow_data1() and this.getrow_data2() respectively (i.e. this.state.x2 ONLY affects this.getrow_data2()).\n\nTo clarify and summarize so far: Controls component causes state change in App, which changes the data passed as props to <ChartInterface>, and a new <ChartInterface> is created (as per my understanding). \n\nMy app uses a control component where users can select different data lists, and that data is fed back to App, and then to <ChartInterface>. OK.\n\nIf a change in App's state causes getrow_data2 to return different data, that should not have an impact on the behavior of ChartInterface (it doesn't use prop.row_data2 currently)\n\nThe weird part:\n\nwhen prop.row_data2 is changed by getrow_data2, the return <div>row_data1</div> in ChartInterface is actually returning <div>row_data2</div>.\n\nThis ONLY occurs when i have this.getrow_data2() wrapped in my sort_data function. \ni.e. if I initialize ChartInterface without sort_data the code behaves as expected.\n\n <ChartInterface \n row_data1={this.getrow_data1()} \n row_data2={this.getrow_data2()}/>" ]
[ "javascript", "reactjs" ]
[ "Lucene geo-distance sorting performance", "I have a task to sort search results not only by relevance of string fields of indexed documents, but also by distance from a given geographical point to a point associated with each document being indexed. It should be mentioned that only top-ten or so matched documents should be included into a result set. Also it's not important to sort by precise distance, only kind of \"distance levels\" from the given point are important.\n\nTechnically I have successfully implemented the task. The geographical part of the task was implemented as a CustomScoreQuery-derived class:\n\nprivate static class DistanceQuery extends CustomScoreQuery {\n\n public DistanceQuery(final Query _subQuery, final SpatialStrategy _strategy, final Point _bp) {\n super(_subQuery, new FunctionQuery(_strategy.makeDistanceValueSource(_bp)));\n }\n\n @Override\n protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext _context) throws IOException {\n return new CustomScoreProvider(_context) {\n @Override\n public float customScore(int _doc, float _subQueryScore, float _valSrcScore) throws IOException {\n // the spatial strategies makeDistanceValueSource creates a ValueSource which score varies from almost 0 for nearby points to 2.7-2.8 for distant points\n // so I voluntarily chosen 2 as the normalization factor and increase subQueryScore for that factor at max;\n logger.debug(\"customScore for document {}: [subQuery={}, valScore={}\", this.context.reader().document(_doc).getField(IndexedField.id.name()).numericValue().toString(), _subQueryScore, _valSrcScore);\n return (_valSrcScore > 2 || _valSrcScore < 0) ? _subQueryScore : _subQueryScore + (2 - _valSrcScore);\n }\n };\n }\n}\n\n\nand wrap a given \"textual\" query with this geospatial \"enhancement\".\n\nGenerally speaking the chosen strategy gives me pretty reasonable results. As one may see, the final score just slightly exceeds the initial query score (by 2 at max). And with typical results scores of a dozen and more, this geospatial addition works just as a way to \"post-sort\" otherwise similar documents.\n\nWith few hundreds or thousands test documents in the index, performance of the wrapped query was also good enough. It's about 10-50 milliseconds per search and this is just 2-5 times slower than an unwrapped query.\n\nBut when I switched from a test to a real-world DB and the number of documents in the index raised from a thousand to approximately 10 millions and is going to increase even more (with an estimation of a hundred millions in a near future), then the situation have changed dramatically. Actually I can't get any search results anymore because JVM goes out of memory and processor. Currently it can't finish the search in JVM with -Xmx6g and more.\nCertainly I could buy a better hardware for the task, but the problem is likely to be solved by choosing a more appropriate sorting strategy.\n\nOne solution is to completely avoid geo-sorting provided by Lucene and manually sort top N items of the result set if items relevance scores are similar. And I'm going to choose this way if nothing else helps.\n\nBut my question is whether more adequate solutions exist. Maybe I can somehow split result items by classes of equivalence (with same or similar enough scores) and apply geo-spatial sorting only to first few classes? Please suggest." ]
[ "java", "sorting", "lucene", "geospatial" ]
[ "VBA (Excel) - Get error number from a variable that became equal to an error", "Scenario:\n\ndim Result as variant\nResult = Application.Match(string, Wb.Sheets(\"UD_Base\").Range(\"UD_Base[U_ID]\"), 0)\n\n\n\n\nNow if i check the values of -Result- it can either be a number or an error.:\nDebug.Print Result -> 1\nDebug.Print result -> Error 2042\n\n\n\nI can test -Result- with: IsError(result) and it gives True or False\n... but even if -Result- IS an error, I cannot get its number.\n\nResult.Number -> Object or Type error message comes\nso seemingly i cannot use it as in Err.Number\n\nHow can I get the error number of -Result- variable?\nWhat is in this case -Result- really equal with?\n\nIf i say If Result = ??? Then ... when will it be true if i know that its Error 2042?\nI have tested Case \"Error 2042\" ; Case Err ; Case Error ; Case Err(2042) ; ...\nNone of these showed True for -Result- when it debug.printed Error 2042\n\nPlease enlighten me guys." ]
[ "excel", "vba" ]
[ "Php script not getting correct value in android", "Im creating an android app using webview and php. i wrote a php to get the value of the user logged in(0 if no ones logged in) if the users logged in(through the app ofcourse) i need to change the icons of the option menu and if no user is logged in the icons would be different. However the php script is not getting the correct value in android but its working fine when i open it from a computer and test by logging in and out of the website\n\nhere's the code for options menu that calls isloggedin() function\n\nregister=omenu.findItem(R.id.registeraccount);\n login=omenu.findItem(R.id.loginitem);\n\n String checklogin= isloggedin();\n Toast.makeText(this, checklogin, Toast.LENGTH_SHORT).show();\n if(!checklogin.equalsIgnoreCase(\"0\"))\n {\n register.setIcon(R.drawable.account);\n register.setTitle(\"Account\");\n login.setIcon(R.drawable.logout);\n login.setTitle(\"Logout\");\n }\n else{\n register.setIcon(R.drawable.register);\n register.setTitle(\"Register\");\n login.setIcon(R.drawable.login);\n login.setTitle(\"Login\");\n\n }\n\n\nthe isloggedin() function\n\n public String isloggedin()\n{\n\n\n try {\n HttpClient httpclient = new DefaultHttpClient();\n\n HttpPost httpPost = new HttpPost(\"url/checklogin.php\");\n\n ResponseHandler<String> responseHandler = new BasicResponseHandler();\n\n final String response = httpclient.execute(httpPost, responseHandler);\n return response;\n\n }catch (Exception e)\n {\n return \"\";\n\n }\n\n}\n\n\nand then i've also called the invalidateoptionsmenu() on the webviewclient's onpagefinished() method so that the optionsmenu can be recreated and update the icons if required\n\nloadsite.setWebViewClient(new WebViewClient(){\n @Override\n public boolean shouldOverrideUrlLoading(WebView view, String url) {\n // TODO Auto-generated method stub\n view.loadUrl(url);\n progressBar.setVisibility(View.VISIBLE);\n\n return true;\n }\n\n @Override\n public void onPageFinished(WebView view, String url) {\n // TODO Auto-generated method stub\n super.onPageFinished(view, url);\n progressBar.setVisibility(View.GONE);\n invalidateOptionsMenu();\n\n\n }\n });\n ;\n loadsite.loadUrl(\"url\");\n\n\nthe php script executed through the isloggedin() function always returns 0 whether the user is signed in or not. however when i sign in from a laptop the script returns 1 or any othe value other than 0 to indicate which user is logged in\n\nthe php script \n\nglobal $current_user;\n$current_user = wp_get_current_user();\n$id=$current_user->ID\necho $id" ]
[ "java", "php", "android", "webview" ]
[ "PHP Warning: PHP Startup: murmur: Unable to initialize module, compiled with wrong API module", "I'm trying to compile a custom php extension against php7 on centos 7.\n\nWhen I run phpize in the extensions directory I get:\n\nConfiguring for:\nPHP Api Version: 20160303\nZend Module Api No: 20160303\nZend Extension Api No: 320160303\n\n\nHowever when I install the module and run php I get:\n\nPHP Warning: PHP Startup: murmur: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20160303\nThese options need to match\n\n\nSteps I've taken to resolve the issue:\n\n\nyum remove php* -y\nrm php* from /bin, /usr/bin\nverified no other phpize or php-config exists on the system\n\n\nInstalled php7:\n\nrpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm\nyum -y install yum-utils yum-config-manager --enable remi-php71\nyum install -y php php-devel php-mbstring php-common php-pear php-pdo php-mysqlnd php-opcache php-intl php-bcmath php-gd php-pecl-amqp php-pecl-mailparse php-xml php-mcrypt php-imap php-ldap php-pecl-memcached php-process php-cli php-pecl-zip\n\n\nCompiled the custom extension:\n\ncd {extension dir}\nphpize\n./configure --enable-murmur\nmake\n\n\nWhy would phpize tell me the extension is being compiled against PHP Api Version 20160303 but when its being loaded by php it says the module was compiled against Api version 20131226?" ]
[ "php", "centos", "php-7.1" ]
[ "No-args constructor for class used in JAX-WS SEI", "I'm developing a little web service and ran into a detail I don't understand.\n\nThats a part of my Service Endpoint Interface:\n\n@WebService\npublic interface ScriptStarterInterface {\n String getResult(@WebParam(name=\"newFile\") FileContainer newFile);\n}\n\n\nThere is an implemantation of it, too. ;) \nNow when I starteded the Server, following Exception occured:\n\nCaused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions\nsome.package.FileContainer does not have a no-arg default constructor.\n\n\nI added the no-arg constructor to FileContainer and now everything works fine. What I do not understand is: Why do I have to provide this constructor? \nAll the oracle pages I stumbled upon just say that I have to provide one, but never why. :(" ]
[ "web-services", "jax-ws", "cxf" ]
[ "MVC Captcha ViewBag null on failed authentication (ModelState.IsValid)", "I am trying to implement Captcha and i have noticed that when the modelstate evaluates to is not valid my page errors out with the message that all my viewbag.items are now null. Any idea how to fix this? \n\nSo i have a controller that sends a multiple viewbag items to my view. For example something like this:\n\npublic ActionResult Create()\n{\n\n...(code shortened)...\nvar IVariable = from i in db.SomeTable\n select i; \n\nforeach (var x in IVariable)\n {\n BagCategory.Add(x.ArmyCategory);\n } \nViewbag.BagCategory = BagCategory \n\n}\n\n\nThe POST method looks something like this:\n\n[HttpPost]\n[ValidateAntiForgeryToken]\n[CaptchaValidation(\"CaptchaCode\", \"SampleCaptcha\", \"Incorrect CAPTCHA code!\")]\n public ActionResult Create([Bind(Include=\"ID,ItemName,Price,ArmyCategory,Race,Company,PictureLink,Notes,EmailAddress\")] Sell sell)\n {\n if (ModelState.IsValid)\n {\n db.ItemsOffered.Add(sell);\n db.SaveChanges();\n return RedirectToAction(\"Index\");\n }\n\n return View(sell);\n }\n\n\nIn my view i run through the items in viewbag.BagCategory but this is now null when captcha is failed and causes the website to explode. What can i do to fix this? \n\nThank You." ]
[ "asp.net-mvc" ]
[ "Longest path in a Direct Acyclic Graph", "How can I find the longest path in a DAG with no weights?\n\nI know that the longest path from A to B can be found in linear time if the DAG is topologically sorted, but I need to find the longest path in all the graph. Is there any way faster than searching for the longest path between all pairs of vertices( which would be O(n^3))?" ]
[ "algorithm", "directed-acyclic-graphs", "longest-path" ]
[ "Pairwise sum in tensorflow", "I have two tensors A and B, both of shape [10 5]. How do I compute a tensor C of shape [10 5 5] such that C[x, i, j] = A[x, i] + B[x, j]?\n\nEdit: this is the sum analog of outer-product, not the outer product itself." ]
[ "python", "tensorflow", "deep-learning" ]
[ "How to implement a default SQLAlchemy Model class that contains common CRUD methods for inheritance?", "I was wondering whether it is possible (and good practice) to implement a default SQLAlchemy Model class that provides basic CRUD functionality to its subclasses. I would like to use this base class in order to avoid code duplication amongst different database models. \n\nAn example for such functionality would be creating (and saving) an instance of the corresponding model in the DB. I am aware that such methods should only be used for non-interdependent transactions in order to comply with the atomicity principle. Is there any built-in mechanism or workaround for doing this?\n\nHere is an example that obviously does not work (its only purpose is to get the idea across):\n\nimport flask\nimport flask_sqlalchemy\nimport sqlalchemy\nfrom flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\n\n\napp = Flask(__name__)\n\n# app.config['SQLALCHEMY_DATABASE_URI'] = ...\ndb = SQLAlchemy(app)\n\nclass DefaultModel(db.Model):\n def create(self, **attributes):\n try:\n # should be considered pseudocode\n instance = self._init_(attributes) \n db.session.add(instance)\n db.session.commit()\n return instance\n except sqlalchemy.exc.SQLAlchemyError:\n db.session.rollback()\n return None\n\nclass MyModel(DefaultModel):\n __tablename__ = 'mytable'\n\n id = db.Column(db.BigInteger(), primary_key=True)\n # ...\n\n\nThe following Exception is raised since there is no primary key attribute definition in the DefaultModel class:\n\nsqlalchemy.exc.ArgumentError: Mapper Mapper|DefaultModel|default_model could not assemble any primary key columns for mapped table 'default_model'" ]
[ "python", "inheritance", "model", "sqlalchemy", "default" ]
[ "How can I get rid of the scientific notation when selecting big number on Oracle Database?", "I need to import a big number to another table using queries, but it always shows with scientific notation. It has to be a number because sorting is necessary and it does not work with char. \n\nI tried all kinds of casting, it changes the number of decimal places but still shows as scientific notation.\n\nSELECT\n CAST(PO_SID AS decimal(38,0)) AS PO_SID,\nFROM CMS.PO_V'\n\nWhen using \n\n to_number(replace(PO_V.PO_SID,' ',''),\n '9.99999999999999999999EEEE'),\n\n\nit outputs: \n\nErro de SQL: ORA-01722: invalid number\n01722. 00000 - \"invalid number\"" ]
[ "sql", "oracle", "scientific-notation" ]
[ "geo_bounding_box filter parse error Expected [FIELD_NAME] under a [START_OBJECT]", "I am trying to filter a geohash aggregation with a bounding box filter. But I have a strange error : Parse Failure [Expected [FIELD_NAME] under a [START_OBJECT], but got a [START_OBJECT] in [traces]]];\n\nWhen I don't use this filter, my request works fine.\n\nHere is my request\n\nPOST /traces/_search?search_type=count&pretty\n{\n \"aggregations\": {\n \"traces\": {\n \"filter\": {\n \"or\": [{\n \"and\": [\n {\"term\": {\"geoip\": true}},\n {\"term\": {\"trackerId\": \"RG-000000003-1\"}}]\n }],\n \"geo_bounding_box\" : {\n \"loc.coordinates\" : {\n \"top_left\" : {\n \"lat\": 49.109837790524416,\n \"lon\": 14.326171874999998\n },\n \"bottom_right\" : {\n \"lat\": 44.05601169578525,\n \"lon\": -9.404296875\n }\n }\n }\n },\n \"aggregations\": {\n \"trackerId\": {\n \"terms\": {\n \"field\": \"trackerId\",\n \"size\": 0\n },\n \"aggregations\": {\n \"heatmap\": {\n \"geohash_grid\": {\n \"field\": \"loc.coordinates\",\n \"precision\": 1\n\n }\n }\n }\n }\n }\n }\n }\n}\n\n\nHere is a part of my mapping where you can see the location.\n\ncollections: [ {\n name: 'traces',\n index: 'traces',\n type: 'trace',\n mappings: {\n 'trace': {\n 'properties': {\n 'loc': {\n 'type': 'object',\n 'properties': {\n 'type': {\n 'type': 'string'\n },\n 'coordinates':{\n 'type': 'geo_point',\n 'geohash':true,\n 'geohash_prefix':true,\n 'lat_lon':true,\n 'fielddata' : {\n 'format' : 'compressed',\n 'precision' : '1cm'\n }\n }\n }\n }, .....\n\n\nWhat is wrong with my request ?" ]
[ "elasticsearch" ]