texts
sequence
tags
sequence
[ "How to Update a record if it exists otherwise insert a new record in MySQL", "I am trying to write a MySQL query to update a record if it exists otherwise create a new record into 2 different tables. I found some information online but i can't seems to nail it.\n\nThis is my current query\n\nSet @time_now := NOW();\n\n if exists(SELECT 1 FROM phone_calls WHERE account_id = 8 AND call_code_id = 5 AND status = 1)\n BEGIN\n UPDATE phone_calls\n SET trigger_on=@time_now,\n isAppointment=1,\n modified_by = 2,\n modified_on = @time_now\n WHERE account_id =8 AND call_code_id = 5 AND status = 1;\n END\n ELSE\n BEGIN\n INSERT INTO phone_calls (mid_id, account_id, call_code_id, trigger_on, created_on, call_subject, status, next_call_id\n , call_direction, owner_id, workflow_generated, call_notes, total_attempts, isAppointment)\n VALUES (1, 8, 5, @time_now, @time_now, 'This is a test', 1, 0 , \"OUTBOUND\", 2, 1, \"\", 0, 0);\n INSERT INTO inventory_engine_history(phone_call_id, new_phone_call_id, created_by, new_call_owner, action, trigger_on) \n VALUES(1000, LAST_INSERT_ID(), 2, 2, '', @time_now)';\n END\n\n\nI am running into a syntax error\n\n#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if exists(SELECT 1 FROM phone_calls WHERE account_id = 8 AND call_code_id = 5 AN' at line 1 \n\n\nCan someone please help me with this error?\n\nNote: if multiple records exists I should update all of them but if no record exist them insert only 1 record in each table.\n\nThanks" ]
[ "mysql", "sql-update", "mysql-insert-id" ]
[ "How to simulate an external event during testing at a particular point in code", "I am trying to work out the best way to simulate something bad happening at very specific points during the execution of code I’m testing, to make sure the code which is supposed to recover from the \"bad thing\" actually works as expected.\n\nIn my particular case I want to simulate a user making detrimental changes to various files, but really any arbitrary example you could think of would apply.\n\nThe simplest way I can think of to do this is to make calls to an empty “stub” method which would do nothing at all in production, but which I will mock out during testing with a patch to do the actual work of making the bad thing happen. In my example the patch would rename or delete files which were being operated on by the script.\n\nConsider the following generic example which is in Python but could be written in any language you'd like:\n\nscript.py:\n\ndef simulate_bad_thing_during_testing():\n # This is an intentionally empty stub to be mocked out during testing.\n pass\n\ndef main():\n # Do some work.\n ...\n\n simulate_bad_thing_during_testing()\n\n # Do some more work, even if bad thing has happened.\n ...\n\n\ntest_script.py:\n\ndef do_bad_thing():\n # Do the bad thing here.\n ...\n\[email protected]('simulate_bad_thing_during_testing', side_effect=do_bad_thing)\ndef test_main_recovers_from_bad_thing():\n main()\n\n # assert all was well and the script recovered from the bad thing.\n ...\n\n\nIs this way of doing it common practice? I've been trying to find examples of this on the net and have failed.\n\nIf others have done it before, then what is it called? Perhaps my Google-fu would be better if I had a better term for this. I've come across \"mutation\" testing and \"fuzz\" testing, but both of those terms seem to denote something different.\n\nIs there a better way to simulate arbitrary worst-case scenarios at particular points in code under test? Perhaps one that won't raise the eyebrows of teammates wondering why I've chosen such an \"invasive\" way of doing this. I do feel slightly uncomfortable with such tight coupling between the implementation of my function and the tests covering the function, but how else can I \"hook\" into a particular line in this fashion?" ]
[ "testing", "mocking" ]
[ "In WooCommerce is there a shortcode for Thankyou page?", "How to get Thankyou page shortcode?\nI want make custom page using Thankyou page shortcode.\nI have made custom cart page using cart shortcode: [woocommerce_cart]\nNow I need woocommerce Thankyou page shortcode." ]
[ "wordpress", "woocommerce", "shortcode" ]
[ "Web dev-frameworks, compatible with .net 3.5 +", "For someone, new to .Net based Web development: what web development frameworks are provided with or are compatible with .Net framework 3.5 +.\n\nLike\n\n\nASP.NET Web Forms pattern\nASP.NET MVC framework / pattern (1.0, 2.0)\n\n\ncan you provide links as well\n\nThanks" ]
[ "c#", ".net", "asp.net", ".net-3.5", "frameworks" ]
[ "Instance or static Controllers?", "Multiple times I created a Model class and the including controller, whereas the controller was static. But often I saw people having their controllers as an instance which holds a model inside. Are there any advantages over static controller?" ]
[ "c#", ".net", "model-view-controller" ]
[ "How to update database table with values from another table", "I have the following tables:\nTable1(ID, user_id , phone, rating, drive)\nID | user_id | phone | rating |drive| \n-------------------------------------\n1 | 100 | | | |\n2 | 200 | | | |\n3 | 300 | | | |\n\nand Table 2\nID | user_id | key | value | \n----------------------------------\n1 | 100 | phone | 222222 |\n2 | 100 | rating | 4.5 |\n3 | 100 | drive | Yes |\n3 | 200 | phone | 333333 |\n3 | 200 | rating | 3.5 |\n3 | 200 | drive | No |\n3 | 300 | phone | 444444 |\n3 | 300 | rating | 5.0 |\n3 | 300 | drive | Yes |\n\nHow do I update Table1 so that I end up with the following table:\nTable1\nID | user_id | phone | rating |drive| \n-------------------------------------\n1 | 100 |222222 | 4.5 | Yes |\n2 | 200 |333333 | 3.5 | No |\n3 | 300 |444444 | 5.0 | Yes |\n\nI've tried:\nUPDATE Table1 \n SET phone = "(SELECT Table2.value WHERE Table2.key=' phone')" \nWHERE Table2.user_id = Table1.user_id;\n\nbut get the error: Unknown column 'Table2.user_id' in 'where clause'." ]
[ "sql", "sql-update" ]
[ "why am I getting always \"TypeError: callback is not a function\"", "Simple problem in React, I just want to make a simple callback to delay the loading of the data\n\nfunction getSettings(callback) {\n getColors();\n callback();\n }\n\n useEffect(() => {\n getSettings().console.log(settings);\n // eslint-disable-next-line\n }, []);\n\n\nand I get:\n\n\"TypeError: callback is not a function\"" ]
[ "javascript", "reactjs", "callback" ]
[ "Symfony DateInterval form type: settings on Doctrine side and Twig", "I am trying to use the DateInterval form field type with Symfony but I am a bit lost as how to use it properly. As far as the form field goes, it says in the doc (https://symfony.com/doc/current/reference/forms/types/dateinterval.html#input) that we can use as an input: string, DateInterval object or an array. \n\nBut what type should I use on the Doctrine side (I use MySql) to store the result? I have tried string, datetime, integer and array. I manage to only making it work using array type on both side but I would rather use DateInterval object if it is possible and it seems like it should be possible. Anyone has an idea?\n\nThen, second problem: how do I print the stored result as a string in Twig? Even if I store it as an array, I have to create a filter in Twig to parse this array properly? \n\nIt looks like I am missing some informations here but I can not find anything on Google. Anyone can help?" ]
[ "symfony", "doctrine", "dateinterval" ]
[ "How to return all rows from DataRow.GetChildRows()", "I have a System.Data.DataRow with a relation to another table in a DataSet. I am calling \n\nvar childRows = dr.GetChildRows(\"childRelation\")\n\n\nBut this will only return certain rows (Original, Added, Modified). It does not return Deleted rows even when I specify DataRowVersion.Default I'd expect it to considering the summary text for Default is\n\n\n The default version of System.Data.DataRowState. For a DataRowState\n value of Added, Modified or Deleted, the default version is Current.\n For a System.Data.DataRowState value of Detached, the version is\n Proposed.\n\n\nHow can I get all child rows regardless of version or state?" ]
[ "c#" ]
[ "Recursion not working inside a loop in C++", "I have a problem to solve in C++ which is as follow : 1 + (1/2!) + (1/3!) + (1/4!) + (1/5!)... and so on\n\nThe code I have written for the same is as follows \n\n#include <iostream>\nusing namespace std;\n\nint fact(int);\n\nint main()\n{\n int n; float sum=0;\n cout<<\"Enter number of terms:\";\n cin>>n;\n\n for(int i=1;i<=n;i++)\n {\n sum = sum + (float)(1/(fact(i)));\n }\n\n cout<<endl<<\"The sum is :\"<<sum;\n return 0;\n}\n\nint fact(int x)\n{\n if(x == 0 || x == 1)\n return 1;\n else\n return x * fact(x-1);\n}\n\n\nThe above code is not returning any output. Earlier I have computed factorial without using for loop. And the recursion has worked." ]
[ "c++", "recursion" ]
[ "Flutter - SimpleDialog in FloatingActionButton", "I'm trying to create a SimpleDialog after a tap on the FloatingActionButton, however when pressing that button nothing happens.\n\nWhat was I doing wrong?\n\nimport \"package:flutter/material.dart\";\n\nvoid main() {\n runApp(new ControlleApp());\n}\n\nclass ControlleApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return new MaterialApp(\n home: new HomePage(),\n );\n }\n}\n\nclass HomePage extends StatelessWidget {\n @override\n Widget build(BuildContext context) => new Scaffold(\n appBar: new AppBar(\n backgroundColor: new Color(0xFF26C6DA),\n ),\n floatingActionButton: new FloatingActionButton(\n tooltip: 'Add',\n child: new Icon(Icons.add),\n backgroundColor: new Color(0xFFF44336),\n onPressed: (){\n new SimpleDialog(\n title: new Text('Test'),\n children: <Widget>[\n new RadioListTile(\n title: new Text('Testing'), value: null, groupValue: null, onChanged: (value) {},\n )\n ],\n );\n } \n ), \n );\n}" ]
[ "dart", "flutter" ]
[ "JS CSS line clamp reset (TextOverflowClamp.js)", "I'm using TextOverflowClamp.js to try and line clamp some text. It works while decreasing window width, but does not reset after increasing window width. Can someone help with resetting the line clamp after the clamp is triggered and window width becomes greater than set conditional size?\n\nCodepen \n\nAll the code is in the Codepen, but my resize and load functions are here:\n\nvar winWidth;\n$(window).resize(function () {\n winWidth = $(window).width();\n if (winWidth <= 991) {\n loadClamp();\n }\n else {\n // reset line clamp code here\n }\n}).resize();\n\nfunction loadClamp() {\n $(window).on('resize', function() {\n\n // TextOverflowClamp.js\n clamp(document.getElementById('js-toclamp1'), 1);\n\n });\n}" ]
[ "javascript", "jquery", "html", "css" ]
[ "RXJava - continuously emit values for determined period", "I have a heart-rate sensor that emits a value periodically (anywhere between 500-3000 milli). When the heart rate sensor emits is non-deterministic. With RXJava, i would like to have a constant emitting the 'last seen' heart rate value and the constant emits the value for up to 10 Seconds until it marks it as too-stale & sends a NULL instead. NULL denotes that the heart rate sensor is no longer emitting sensor readings.\nI have the following (kotlin) code:\n val heartRateObservable: Observable<BLEDataValue> = observable\n .flatMap { it.setupNotification(characteristic.uniqueIdentifier) }\n .flatMap { it }\n .map { BTDataPacket(characteristic.uniqueIdentifier, BleParseable(it)).btValue() }.onErrorReturn { BLEDataValueHeartRate(null) }\n return Observable.combineLatest(Observable.interval(1000, TimeUnit.MILLISECONDS), heartRateObservable, BiFunction { _, t2 -> t2 })\n\nQuestion: Is it possible to introduce a way to replay the last seen heart-rate value up to when the last value becomes stale (i.e. after not seeing any heart-rate readings for 10 seconds).. when a heart rate value is seen it replay this until a new heart-rate value arrives OR the timeout of 10 seconds passes as the last value is now too-stale?" ]
[ "android", "rx-java" ]
[ "django nested body request not being set", "I'm trying to make a request to the box api using python and django. I'm getting a 400 Entity body should be a correctly nested resource attribute name\\\\/value pair error. \n\nMy requests looks like: \n\nrequests.options(headers.kwargs['url'], headers=headers.headers, \n data={'parent': {'id': 'xxxx'}, 'name': 'name.pdf'})\n\n\nWhen I inspect the 400 request.body it contains 'parent=id&name=name.pdf' which leads me to believe I'm not setting the body properly\n\nA curl works with the body \n\n-d '{\"name\": \"name.pdf\", \"parent\": {\"id\": \"xxxxx\"}}'" ]
[ "python", "django" ]
[ "Sapper event for route change", "I need to redirect users to login page if they are not authenticated. I need something like route.beforeEach in Vue.js, ideally:\n\nsapper.beforeRouteChange((to, from, next) => {\n\n const isAuth = \"[some session or token check]\";\n\n if (!isAuth) {\n next('/login')\n }\n\n next()\n})\n\n\nI found Sapper - protected routes (route guard) this question but I think it's not enough for my needs. What if token or auth changes in runtime? OR is it covered by reactivity?\n\nEdit 1: I think that this issue on Sapper GitHub solves my problem." ]
[ "javascript", "svelte", "sapper" ]
[ "Filter for Highest Available Time at a Day of a Pandas DataFrame Smaller Than Certain Limit", "For this Python Pandas DataFrame, I would like to have that row of the day with the highest time smaller than 14h00:\n\nimport pandas as pd\n\nimport datetime\nimport numpy as np\n\ndf = pd.DataFrame({\"a\": [\"31.12.1997 23:59:12\",\n \"31.12.1998 12:59:12\",\n \"31.12.1999 11:59:13\",\n \"31.12.1999 12:59:13\",\n \"31.12.1999 23:59:14\"],\n \"b\": [2,3,4, 5, 6]})\ndf[\"date\"]=pd.to_datetime(df.a)\ndf[\"day\"]=df.date.dt.date\n\n\nSo that the result would be:\n\n a b date day\n1 31.12.1998 12:59:12 3 1998-12-31 12:59:12 1998-12-31\n3 31.12.1999 12:59:13 5 1999-12-31 12:59:13 1999-12-31\n\n\nAs the real DataFrame is quite big, a high execution performance would be nice." ]
[ "python", "pandas", "dataframe" ]
[ "Align shared legends to the center of the plot grid (with cowplot)", "The reproducible example can be found in this tutorial for the package cowplot.\n\nhttps://cran.r-project.org/web/packages/cowplot/vignettes/shared_legends.html\n\nCopying example code:\n\nlibrary(ggplot2)\nlibrary(cowplot)\n#down-sampled diamonds data set\ndsamp <- diamonds[sample(nrow(diamonds), 1000), ]\n\n# Make three plots.\n# We set left and right margins to 0 to remove unnecessary spacing in the\n# final plot arrangement.\np1 <- qplot(carat, price, data=dsamp, colour=clarity) +\n theme(plot.margin = unit(c(6,0,6,0), \"pt\"))\np2 <- qplot(depth, price, data=dsamp, colour=clarity) +\n theme(plot.margin = unit(c(6,0,6,0), \"pt\")) + ylab(\"\")\np3 <- qplot(color, price, data=dsamp, colour=clarity) +\n theme(plot.margin = unit(c(6,0,6,0), \"pt\")) + ylab(\"\")\n\n# arrange the three plots in a single row\nprow <- plot_grid( p1 + theme(legend.position=\"none\"),\n p2 + theme(legend.position=\"none\"),\n p3 + theme(legend.position=\"none\"),\n align = 'vh',\n labels = c(\"A\", \"B\", \"C\"),\n hjust = -1,\n nrow = 1\n )\nlegend_b <- get_legend(p1 + theme(legend.position=\"bottom\"))\n\n# add the legend underneath the row we made earlier. Give it 10% of the height\n# of one plot (via rel_heights).\np <- plot_grid( prow, legend_b, ncol = 1, rel_heights = c(1, .2))\np\n\n\nThis example shows a plot in which the legend is drawn aligned to the bottom left of the grid. \nHowever, it used to be differently, as the legend was then drawn aligned to the bottom center of the plot. Here is an example generated by my personal code some months ago.\nhttps://s1.postimg.org/8pf2en1zen/Untitled.png (Upload tool currently not working for me)\n\nRerunning my old code after an unknown amount of changes in either packages delivers a legend aligned to the bottom left (as also shown in the tutorial, third plot from above):\nhttps://s1.postimg.org/3agjw7n9gf/Untitled2.png\n\nThe question is how to adjust the code to draw the legend aligned to bottom center." ]
[ "r", "ggplot2", "cowplot" ]
[ "Eclipse and Hadoop 2.2 Location Status Updater Error", "I'm using Linux Mint 16 and have installed Eclipse (Kepler) and Hadoop 2.2.0. I have set Eclipse to use the Map/Reduce perspective and I have created a new Hadoop location. When I created the location, I went into the Advanced tab and set the path for:\n\n\ndfs.datanode.data.dir\ndfs.namenode.name.dir\ndfs.data.dir\ndfs.name.dir\n\n\nWhen I click the + sign next to the location name, I get the following error:\n\n\n 'Map/Reduce location status updater' has encountered a problem. An internal error occurred during \"Map/Reduce location status updater\".\n\n\nWhen I click on Details, I get the following:\n\n\n An internal error occurred during \"Map/Reduce location status updater\". java.land.NullPointerException\n\n\nI have seen a few items on stackoverflow regarding Hadoop versions prior to 2.2 and they haven't solved this error for me. Any suggestions?" ]
[ "eclipse", "hadoop", "linux-mint" ]
[ "Run script over SSH, get input from remote host keyboard", "I have a (python) script that waits for user input.\nI want to run that script on my raspberry PI that I access over an SSH connection.\nI would like to capture the user input via the keyboard that is attached to my raspberry via a USB.\nHow could I achieve this? I only seem to be able to capture input from the machine that starts the ssh connection." ]
[ "ssh", "raspberry-pi", "stdin", "tty" ]
[ "Back-end for Location sharing between two clients", "Want to create one back-end for location sharing between clients and back-end should be in .net-core and MS-SQL.\nSimple approach is user1 send x and y co-ordinates and save to db every 2 second and user2 call the get api and get the x and y co-ordinates in every 2 second.\nIssue - If 1 million user register then 1 million request per 2 sec will hit. Not good for servers and MS-SQL\nQuestion - Is it possible to create web socket for every user which send their location and send the data to that socket in every 2 sec and when other user who want to see the location, merge that user with socket.\nor any other approach???" ]
[ "c#", "asp.net", ".net", "asp.net-core", "location" ]
[ "How to get the max count of coherently cells?", "I have following data in my table:\n\nID - Data\n\n1 - 0\n2 - 10\n3 - 100\n4 - 60\n5 - 0\n6 - 0\n7 - 15\n8 - 100\n9 - 100\n10 - 70\n11 - 10\n12 - 0\n13 - 0 \n\nWhat I want is the max count of rows > 0.\n\nThis data shows the energy using of a device in percent of a given total.\nWhat I basicly want to know is: how long is the device \"on\" the longest timeperiod?" ]
[ "sql" ]
[ "Cisco CVP Integration with Custom Modify Element", "I have one external Project in Cisco CVP, i have imported that project into the Cisco CVP IDE. This project has some custom Element, i have their related classes as well. I have placed their related classes in the cisco\\cvp\\plugin\\commin library as well as in the deploy\\application\\java\\classes folder as well but still my custom element are showing an error ..Can any body has any idea how to overcome this. i have placed the screen shot as well." ]
[ "java", "customization", "cisco", "ivr" ]
[ "how to upload image from localhost to server path in laravel?", "I am getting error 'Can't write image data to path', and i have folder permission too. \n\n $image = $request->file('image');\n $name = time().\"_\". $image->getClientOriginalName();\n $img = Image::make($image->getRealPath());\n $img->save('http://test.server.com/upload/' . $name);" ]
[ "laravel-5", "laravel-5.2" ]
[ "Why is 275481/69/100089 the max date \"new Date()\" will parse?", "Possible Duplicate:\n Is JavaScript’s Date object susceptible to the Y2038 problem? \n\n\n\n\nSo after stumbling across an issue w/ jquery.validate's date validator, I was testing the upper bounds of JavaScript's new Data() parser.\n\nOddly, this works:\n\nvar d = new Date(\"275481/69/100089\")\n// d = Date {Fri Sep 12 275760 00:00:00 GMT-0400 (Eastern Daylight Time)}\n\n\nHowever, all of these fail:\n\nvar d = new Date(\"275481/69/100090\")\nvar d = new Date(\"275481/70/100089\")\nvar d = new Date(\"275482/69/100089\")\n\n\nHave I just discovered the date the world will end?" ]
[ "javascript" ]
[ "Simple IF EXISTS in TRIGGER fails", "I've created a simple TRIGGER:\n\nALTER TRIGGER [dbo].[SprawdzZajetosc] ON [dbo].[Wypozyczenia]\nFOR insert, update\nAS\nBEGIN\nIF EXISTS (SELECT * FROM Wypozyczenia)\n BEGIN\n RAISERROR('Wybrany pojazd został już wypożyczony w wybranym przedziale czasu.', 16, 1)\n ROLLBACK TRANSACTION\n END\nEND\n\n\nI can't understand why 'if' is returning me TRUE even if table 'Wypozyczenia' is empty? It doesn't matter what 'Wypozyczenia' contains - it always returns me TRUE.\n\nI tried with count(*) it always returns me a value > 0.\n\nWhy is that?" ]
[ "sql", "sql-server", "triggers", "exists" ]
[ "FIREBASE APP Failed to deploy, HTTP Error: 500, Request contains an invalid argument", "I have a firebase app that when I go to deploy it [firebase deploy] it returns this error.\n\nHTTP Error: 500, Request contains an invalid argument.\n\nTerminal output\n\n\nThe debug log says:\n\n[debug] ----------------------------------------------------------------------\n[debug] Command: /usr/local/bin/node /usr/local/bin/firebase deploy\n[debug] CLI Version: 3.1.0\n[debug] Platform: darwin\n[debug] Node Version: v4.6.1\n[debug] Time: Tue Nov 08 2016 19:28:28 GMT-0500 (EST)\n[debug] ----------------------------------------------------------------------\n[debug] \n[debug] > command requires scopes: [\"email\",\"openid\",\"https://www.googleapis.com/auth/cloudplatformprojects.readonly\",\"https://www.googleapis.com/auth/firebase\"]\n[debug] > refreshing access token with scopes: [\"email\",\"https://www.googleapis.com/auth/cloudplatformprojects.readonly\",\"https://www.googleapis.com/auth/firebase\",\"openid\"]\n[debug] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token\n[debug] <<< HTTP RESPONSE 200\n[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/chat-4d6fb \n[debug] <<< HTTP RESPONSE 200\n[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/chat-4d6fb/tokens \n[debug] <<< HTTP RESPONSE 200\n[info] \n[info] === Deploying to 'chat-4d6fb'...\n[info] \n[info] i deploying database, storage, hosting\n[info] ✔ database: rules ready to deploy.\n[info] i storage: checking rules for compilation errors...\n[debug] >>> HTTP REQUEST POST https://firebaserules.googleapis.com/v1/projects/chat-4d6fb:test\n[debug] <<< HTTP RESPONSE 200\n[info] ✔ storage: rules file compiled successfully\n[info] i hosting: preparing ./ directory for upload...\n[debug] >>> HTTP REQUEST PUT https://deploy.firebase.com/v1/hosting/chat-4d6fb/uploads/-KW5U6Mb3XEOtWn_Kfam?fileCount=14&message= \n[debug] <<< HTTP RESPONSE 200\n[info] ✔ hosting: ./ folder uploaded successfully\n[info] ✔ hosting: 14 files uploaded successfully\n[info] i starting release process (may take several minutes)...\n[debug] >>> HTTP REQUEST POST https://deploy.firebase.com/v1/projects/chat-4d6fb/releases\n[debug] <<< HTTP RESPONSE 500\n[debug] <<< HTTP RESPONSE BODY\n[error] \n[error] Error: HTTP Error: 500, Request contains an invalid argument.\n[debug] Error Context: {\n \"body\": {\n \"error\": {\n \"code\": \"UNKNOWN_ERROR\",\n \"message\": \"Request contains an invalid argument.\"\n }\n },\n \"response\": {\n \"statusCode\": 500,\n \"body\": {\n \"error\": {\n \"code\": \"UNKNOWN_ERROR\",\n \"message\": \"Request contains an invalid argument.\"\n }\n },\n \"headers\": {\n \"server\": \"nginx\",\n \"date\": \"Wed, 09 Nov 2016 00:28:39 GMT\",\n \"content-type\": \"application/json; charset=utf-8\",\n \"content-length\": \"84\",\n \"connection\": \"close\",\n \"access-control-allow-origin\": \"*\",\n \"access-control-allow-methods\": \"GET, PUT, POST, DELETE, OPTIONS\",\n \"strict-transport-security\": \"max-age=31556926; includeSubDomains; preload\",\n \"x-content-type-options\": \"nosniff\"\n },\n \"request\": {\n \"uri\": {\n \"protocol\": \"https:\",\n \"slashes\": true,\n \"auth\": null,\n \"host\": \"deploy.firebase.com\",\n \"port\": 443,\n \"hostname\": \"deploy.firebase.com\",\n \"hash\": null,\n \"search\": null,\n \"query\": null,\n \"pathname\": \"/v1/projects/chat-4d6fb/releases\",\n \"path\": \"/v1/projects/chat-4d6fb/releases\",\n \"href\": \"https://deploy.firebase.com/v1/projects/chat-4d6fb/releases\"\n },\n \"method\": \"POST\"\n }\n }\n}\n\n\nDoes anyone know why this is happening or have any advice that I could try?" ]
[ "http", "firebase", "deployment" ]
[ "Best place for CSS and LESS external libs in PhpStorm or PyCharm project", "I want my IDE to see Bootstrap files for CSS classes autocompletion and on-the-fly LESS compiling. But I don't want to store Bootstrap inside my project folder structure and copy libraries in each project. How can I make IDE know where is libs?\n\nSome approaches I tried.\n\n\nUsing relative paths. @import '../../../../../Bootstrap 3/less/mixins'; does not look good. Moreover, despite import statement is correct (without red underlining), IDE does not \"know\" about imported mixins. When I just copy libraries, IDE \"knows\" about them.\nConnect as JS libs. I see them in project files view. LESS syntax checker cannot locate them, no matter what path i specify. Import statement is underlined with red wavy line.\n\n\nNow, I can use only copy and paste technique or use links (or directory junctions). I am not sure that this is correct way.\n\nI tried this PhpStrom and PyCharm, but I suppose that WebStorm cannot resolve this problem too." ]
[ "css", "twitter-bootstrap", "phpstorm", "pycharm" ]
[ "why showing .GIF image increase memory continuously?", "i am showing simple code sample. I showed an gif image in a Jlabel. When run the programme, TASK manager shows that memory is increasing continuously. Why it happens?\n\nEdited:\n\ntry this code please... on show glass button, glass panel is shown with gif image and a hide glass button in it and with that memory will be started increasing. On clicking hide glass button, glass panel will be hidden and memory increasing will b stopped.\n\n@mKorbel : I had debugged it, the constructor will be called once, so no re-initializing of JFrame and also included : setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n\npublic class circle extends JFrame {\npublic ImageIcon pic;\nfinal JPanel glass;\npublic JButton glass_show;\npublic JButton hide_glass;\n\npublic circle() {\n super(\"Hi shamansdsdsd\");\n setSize(500, 300);\n // Image icon initialize once :\n pic = new ImageIcon(\"images/loadinag.gif\");\n glass_show = new JButton(\"Show Glass panel\");\n this.add(glass_show);\n\n this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n\n glass = (JPanel) this.getGlassPane();\n hide_glass = new JButton(\"Hide Glass panel\");\n glass.add(hide_glass);\n glass.add(new JLabel(pic));\n glass.setOpaque(false);\n\n}\npublic void initialize_listeners(){\n glass_show.addActionListener(new ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent A) {\n glass.setVisible(true);\n }\n });\n\n hide_glass.addActionListener(new ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent A) {\n glass.setVisible(false);\n }\n });\n}\n public static void main(String[] args) {\n circle mFrame = new circle();\n mFrame.initialize_listeners();\n mFrame.setVisible(true);\n}\n\n\n}" ]
[ "java", "swing", "memory-management", "gif", "jlabel" ]
[ "pagination from filtered search", "I am doing a search in jQuery:\n\n$('#MainContent_myTable tr:gt(0)').each(function () {\n $(this).find('td:eq(0)').not(':contains(' + filterVal + ')').parent().hide();\n});\n\n\nI'd like to be able to do some quick pagination (without a plugin) from the rows that remain in the table from the above find.\n\nWhat is the best way to do this?" ]
[ "jquery" ]
[ "Reinitialize SVGweb for ajax", "I have no problem using SVGweb when page is simply loaded (opened).\n\nHow is it possible to reinitialize SVGweb in order to redraw all SVG on the page?\n\nAnotherwords I need SVGweb to rescan and rerender everything on the page.\n\nsource (from this):\n\n<script type=\"image/svg+xml\">\n <svg>\n ...\n </svg>\n</script>\n\n\nto this (like SVGweb si doing that when simply open the page):\n\n<svg>\n...\n</svg>\n\n\nI need this because I change the SVG graphics using ajax and need to rerender it on the page." ]
[ "svg", "svgweb" ]
[ "Linking Entries from Two Columns", "I have IDs in two columns, let's say column A and column B. In these columns are ids and they will appear in either a or b multiple times. What I'd like to do is provide a batch number like the example below, where any related ID is put under one batch. \n\nAre there any good ideas of how to do this in excel/vba? I have 15000 rows. So far I have tried looping through each row and trying to tag 1 with 2, then 2 to 4 etc but the for loops suddenly become almost unlimited. I don't care about providing code, it's more the logic side!" ]
[ "vba", "excel" ]
[ "Azure DevOps Build Xamarin.Android 9.4.1.0 as target in hosted macOS image", "I have an Application written with Xamarin and a buildpipline on Azure Devops. This builds fine when I built it locally with Xamarin.Android 9.4.1.0. However, I would like to update to SDK 9.4.1.0 since the default version in the mac agent is 9.0.0-20.\n\nI'm facing an issue which was discussed and had a solution here.\nhttps://github.com/luberda-molinet/FFImageLoading/issues/1320\n\nThe solution is to change the Xamarin.Android sdk from 9.0 to 9.2(higher)." ]
[ "xamarin", "xamarin.android", "azure-devops", "azure-pipelines", "azure-pipelines-build-task" ]
[ "Microsoft multi factor authentication using angular redirect issue", "In my angular project, I am using Microsoft Authentication. The issue which I am facing is when I give insted popup to redirect, after authentication my page is refreshing many times. But for the popup case it is working fine.\nMsalModule.forRoot({\n auth: {\n clientId: 'Enter_the_Application_Id_Here',\n authority: 'Enter_the_Cloud_Instance_Id_HereEnter_the_Tenant_Info_Here',\n redirectUri: 'Enter_the_Redirect_Uri_Here',\n },\n cache: {\n cacheLocation: 'localStorage',\n storeAuthStateInCookie: isIE, // set to true for IE 11\n },\n },\n {\n popUp: true,\n consentScopes: [\n 'user.read',\n 'openid',\n 'profile',\n ],\n unprotectedResources: [],\n protectedResourceMap: [\n ['Enter_the_Graph_Endpoint_Herev1.0/me', ['user.read']]\n ],\n extraQueryParameters: {}\n })\n ],\n\nIf I give popUp: true it is working as expected. But if I give popUp: false and if I am not giving anything it is redirecting to login page but after login the page is getting refreshed many times" ]
[ "angular", "multi-factor-authentication" ]
[ "Append to JSON array via JS", "I have the JSON array in the file colors.json\n\n{\n\"colors\": [\n {\"RGB\": \"100, 33, 93\",\"HEX\": \"Computer Science\"},\n {\"RGB\": \"33, 82, 100\",\"HEX\": \"#55d1ff\"},\n {\"RGB\": \"32, 56, 11\",\"HEX\": \"#518e1d\"}\n ]\n}\n\n\nand the js addColors.js\n\nfunction addColor(){\n //code\n}\n\n\nthat is run from an html form.\n\nAfter getting data from by html form, via the js, how would I then append it to the colors.json file?\n\nThank you\nJosh" ]
[ "javascript", "html", "json", "append" ]
[ "How to draw a multiple line chart using plotly_express?", "I need to create a line chart from multiple columns of a dataframe. In pandas, you can draw a multiple line chart using a code as follows:\n\ndf.plot(x='date', y=['sessions', 'cost'], figsize=(20,10), grid=True)\n\n\nHow can this be done using plotly_express?" ]
[ "python", "charts", "plotly" ]
[ "Modify entity with EntityListener on cascade", "I have a database in which an entity (say, User) has a list of entities (say, List). As a requirement, I must have a denormalized count of the entities on the list:\n\n@Entity\nclass User {\n /* ... */\n @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)\n private List<Friendship> friends;\n\n public int friendsCount;\n /* ... */\n}\n\n\nWhen I add a new element to the list, I must, transactionally, increase the corresponding counter.\n\nI tried to do so using an EntityListener:\n\nclass MyBrokenEntityListener {\n @PostPersist\n public void incrementCounter(Friendship friendship) {\n friendship.getUser1().incrementFriendsCount();\n }\n}\n\n\nThe entity listener is being correctly called, and while debugging I can see that it correctly modifies the entity. However, Hibernate sends no UPDATE query to the database, only the INSERT query (corresponding to the Friendship entity).\n\nI have tried different events on the EntityListener, but it does not seem to work.\n\nWhat I suppose is happening here is that the entity listener is triggered by an update to the a User. It then identifies all the dirty properties of the user, which consist of the List alone. Therefore it has nothing to do about the User, it has only to insert a Friendship. It then cascades the operation to the Friendship. The entity listener is called, it modifies the user, but at this time Hibernate has already determined that it had not to worry about the user, therefore it does not update the user.\n\nIs this reasoning correct?\n\nIf so, how can I properly achieve this?\n\nThanks,\nBruno" ]
[ "hibernate", "orm", "jpa", "cascade", "entitylisteners" ]
[ "Count the users based on category in nested list python", "I have a list with two sub lists.\nHere it looks like this\n\na = [['user1', 'referral'], ['user2', 'referral'], ['user1', 'referral'], ['user1', 'affiliate'], ['user7', 'affiliate'], ['user1', 'affiliate'], ['user9', 'affiliate'], ['user4', 'cpc'], ['user4', 'referral'], ['user2', 'referral'], ['user7', 'affiliate'], ['user14', 'cpc'], ['user3', 'orgainic'], ['user2', 'orgainic'], ['user4', 'cpc'], ['user2', 'cpc'], ['user8', 'cpc'], ['user2', 'orgainic']]\n\n\nI want to count the users(unique) based on the category.\n\nRequired:\n\nrequired = [['referral',3],['affiliate',3],['cpc',4],['orgainic',2]]\n\n\nOutput I got:\n\n{'referral': 3, 'affiliate': 2, 'cpc': 4, 'orgainic': 3}\n\n\nIt was counting wrong. \n\nHere's the Code i tried:\n\na = [['user1', 'referral'], ['user2', 'referral'], ['user1', 'referral'], ['user1', 'affiliate'], ['user7', 'affiliate'], ['user1', 'affiliate'], ['user9', 'affiliate'], ['user4', 'cpc'], ['user4', 'referral'], ['user2', 'referral'], ['user7', 'affiliate'], ['user14', 'cpc'], ['user3', 'orgainic'], ['user2', 'orgainic'], ['user4', 'cpc'], ['user2', 'cpc'], ['user8', 'cpc'], ['user2', 'orgainic']]\n\nrequired = [['referral',3],['affiliate',3],['cpc',4],['orgainic',2]]\n\nc = {}\nvisits = []\nfor i in a:\n # print(i)\n for j in i[1:]:\n if j not in c and i[0] not in visits:\n c[j] = 1\n visits.append(i[0])\n elif j in c and i[0] not in visits:\n c[j] = c[j]+1\nprint(c)\n\n\nHelp me with some solutions..." ]
[ "python", "python-3.x", "list", "dictionary" ]
[ "Using Mysql or PowerBI and 3 tables(datasets), how do you add working days to date sold?", "I have the following tables in Mysql server and PowerBI (a solution for any of them works).\n\nSales Table\n\nDate sold | Product | item | address\n24-11-2018 | socks | 02 | orlando \n26-11-2018 | socks | 02 | mexico df\n\n\nCalendar table\n\nDate | isWeekend | isHoliday | isWorkday\n24-11-2018 | 1 |  0 | 0\n25-11-2018 | 1 |  1 | 0\n26-11-2018 | 0 |  0 | 1\n27-11-2018 | 0 |  0 | 1\n\n\nDays to Deliver By Location table\n\naddress | days to deliver in workdays\norlando |  4\n\n\nI need to add a new column in \"Sales Table\" where i get the \"Date to Deliver\", which is the sum of \"Date Sold\" + Days to deliver\". Now, the problem i have is that i can't / don't know how i can manage to add only the working days." ]
[ "mysql", "powerbi", "powerbi-desktop" ]
[ "Powerpoint within Apple TV 4th generation", "Now that the Apple TV 4th Generation is a few years old and some changes, such as increasing the limit for the file size, have been made; is there yet a good way to display a simple PPT file? I've done this in the past by converting PPT to PDF, but that caused me to build a separate app for the Apple TV from its iOS counterpart, so it would not double up the number of files on either target." ]
[ "ios", "uiwebview", "powerpoint", "tvos" ]
[ "python : strange str.contains behaviour", "i have a dataframe named df as df = pd.read_csv('my.csv')\n\n CUSTOMER_MAILID EVENT_GENRE EVENT_LANGUAGE \n0 [email protected] |ROMANCE| Hindi \n1 [email protected] |DRAMA| TAMIL \n2 [email protected] |ROMANCE| Hindi \n3 [email protected] |DRAMA| Hindi \n4 [email protected] |ACTION|ADVENTURE|SCI-FI| English \n5 [email protected] |ACTION|ADVENTURE|COMEDY| English \n6 [email protected] |ACTION| Hindi \n7 [email protected] |DRAMA| Hindi \n8 [email protected] |FANTASY|HORROR|ROMANCE| English \n9 [email protected] |ACTION|ADVENTURE|THRILLER| English \n10 [email protected] |DRAMA| Hindi \n11 [email protected] |ROMANCE|THRILLER| KANNADA \n12 [email protected] |DRAMA| Hindi \n13 [email protected] |ACTION|ADVENTURE|DRAMA| English \n14 [email protected] |ACTION|ADVENTURE|DRAMA| TELUGU \n15 [email protected] |BIOPIC|DRAMA| Hindi \n16 [email protected] |HORROR|THRILLER| Hindi \n17 [email protected] |ACTION|COMEDY|THRILLER| ODIA \n18 [email protected] |ACTION|ADVENTURE|SCI-FI| English \n19 [email protected] |ROMANCE| Hindi \n\n\nBut when i was querying i found some discrepancy in the sense the str.contains does not returned me the expected output.\n\n d = df.query((df['EVENT_GENRE'].str.contains('|ROMANCE|')) & (df['EVENT_LANGUAGE'] == 'Hindi'))\n d\n Out[53]: \n CUSTOMER_MAILID EVENT_GENRE EVENT_LANGUAGE\n 0 [email protected] |ROMANCE| Hindi\n 2 [email protected] |ROMANCE| Hindi\n 3 [email protected] |DRAMA| Hindi\n 6 [email protected] |ACTION| Hindi\n 7 [email protected] |DRAMA| Hindi\n 10 [email protected] |DRAMA| Hindi\n 12 [email protected] |DRAMA| Hindi\n 15 [email protected] |BIOPIC|DRAMA| Hindi\n 16 [email protected] |HORROR|THRILLER| Hindi\n 19 [email protected] |ROMANCE| Hindi\n\n\nAs you can see EVENT_GENRE field contains no 'ROAMNCE', but when i am doing without '|' ex. '|ROMANCE|' to 'ROMANCE', i am getting the expected output.\n\nd = df.query((df['EVENT_GENRE'].str.contains('ROMANCE')) & (df['EVENT_LANGUAGE'] == 'Hindi'))\n\nd\nOut[55]: \n CUSTOMER_MAILID EVENT_GENRE EVENT_LANGUAGE\n0 [email protected] |ROMANCE| Hindi\n2 [email protected] |ROMANCE| Hindi\n19 [email protected] |ROMANCE| Hindi\n\n\nThen i tried for different scenario with '|' (strange result found) and without('|') (expected result found).\n\nI am just curious if '|' symbol has some effect on str.contains() method.I highly doubt it behaves like \"or\" operation. Bcoz when i tried with \n\ndd = df.query(df['EVENT_GENRE'].str.contains('FANTASY|HORROR'))\n\ndd\nOut[21]: \n CUSTOMER_MAILID EVENT_GENRE EVENT_LANGUAGE \n8 [email protected] |FANTASY|HORROR|ROMANCE| English \n16 [email protected] |HORROR|THRILLER| Hindi \n\n\nAs it seems it treats FANTASY and HORROR with \"or\" operation.***NOT SURE\n\nAnd with dd = df.query(df['EVENT_GENRE'].str.contains('|FANTASY|HORROR|')) it select all data.\n\nAs of my knowledge inside a strind all included in '' or \"\" treated as char only(except \\t,\\r,\\n).But i did not know if logical operators ever worked in same way(as many times i have seen & inside a string).\n\nCan anybody please clarify that.Thanks in Adv." ]
[ "python", "string", "pandas" ]
[ "Error:java.util.concurrent.ExecutionException", "I have been working on this app for a while and a couple of days ago i came across this error message when I try to build the project: \n\nError:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process C:\\Users\\USER_NAME\\AppData\\Local\\Android\\Sdk\\build-tools\\26.0.3\\aapt.exe.\n\n\nAlso everytime I use R. (for example R.Drawable) it says cannot resolve symbol R.\n\nI already tried to change the buildToolsVersion to the most recent version, added android.enableAapt2=true to the gradle.properties, cleaning and rebuilding the project but nothing seems to help.\n\nI´ve been trying to solve this problem for a while, I've found a lot of similar questions on StackOverflow, but don't seem to be able to fix it despite of the several attempts to do it. If someone were to help me would very much appreciatted." ]
[ "android", "gradle", "aapt" ]
[ "Entity Framework Navigation Properties not loading til new DbContext is established", "I'm still relatively new to EF, so forgive me if I'm missing an obvious concept.\n\nLet me see if I can simplify this...Old question is in edit history, but I think I can distill this down:\n\nFWIW, DbContext is PER REQUEST, not static, which is why the first example works. Not using DI/IoC on the controller at this point.\n\npublic class OrdersController : ApiController {\n private MyDbContext db = new MyDbContext();\n\n //controller methods....\n\n protected override void Dispose(bool disposing) {\n db.Dispose();\n }\n}\n\n\nWorks (2 separate requests):\n\n//request 1: client code sends in a new order to be added to db\npublic Order Post([FromBody]Order order) {\n db.Orders.Add(order);\n db.SaveChanges();\n\n return order;\n}\n\n//request 2: someone punches a button to send an email to CS about this order\npublic void NotifyCustomerService(int orderid) {\n var order = db.Orders.Find(orderid);\n //do email code here\n}\n\n\nBroken (single request):\n\n//request: client code sends in a new order to be added to db AND notifies CS at same time\npublic Order Post([FromBody]Order order) {\n db.Orders.Add(order);\n db.SaveChanges();\n\n //notify CS via email here (nav properties are not populating)\n\n return order;\n}\n\n\nWorks (single request) (but i know this is horrible practice):\n\n//request: client code sends in a new order to be added to db AND notifies CS at same time (using a new dbcontext in the notification code)\npublic Order Post([FromBody]Order order) {\n db.Orders.Add(order);\n db.SaveChanges();\n\n using(var db2 = new MyDbContext()) {\n var sameOrderWTF = db.Orders.Find(order.ID);\n //notify CS via email using sameOrderWTF instance here (nav properties ARE populating)\n }\n return order;\n}\n\n\nSo, it seems to me, that there's some side effect of adding a new never-before-seen entity to the context, and then trying to get it's nav properties to populate. But if you create a new DbContext... even in the same request, it has to directly hit the DB for that entity, not use the in-mem copy, so then the nav properties magically work. That's the part that has me stumped.\n\nWorking Solution\n\n//request: client code sends in a new order to be added to db AND notifies CS at same time\npublic Order Post([FromBody]Order o) {\n Order order = db.Orders.Create();\n db.Orders.Add(order);\n\n //copy values from input to proxy instance\n db.Entry(order).CurrentValues.SetValues(o);\n\n //copy input lines to proxy instance (same process as order for each line)\n o.OrderLines.ToList().ForEach(l => {\n var line = db.OrderLines.Create();\n db.OrderLines.Add(line);\n db.Entry(line).CurrentValues.SetValues(l);\n order.OrderLines.Add(line);\n });\n\n db.SaveChanges();\n\n //notify CS via email here (nav properties are not populating)\n\n return order;\n}\n\n\nSo while we'll consider this question answered (thanks Uber Bot), the need to go through all of that seems more laborious than my other (admittedly short) experience with ASP.NET MVC and EF. I guess maybe I should be using ViewModels and mapping the VM properties to a proxy instance instead of trying to use the EF classes directly, but I just can't really see the benefit for a simple call like this." ]
[ "c#", "entity-framework" ]
[ "Sending Whole Json to kafka with avro serialization?", "I have a json file that i want to sent it's contents to a Kafka consumer. The kafka uses Avro and a Schema that adheres to the Json i want to send .So is there a way to read the json and then send the whole contents of it through kafka without the need to first parse the json and then send everything separately with keys and values?\n\nThanks." ]
[ "java", "json", "data-structures", "apache-kafka", "avro" ]
[ "Polygon onclick event problem with its shape", "I've build a square surround it by 4 polygon (trapezium shape) I need to change its colors in a sequence by clicking on it. \n\nI couldn't find any similar problem over the web.\nbut i did try changing zIndex on mouse over and out but it wasnt a good solution. \n\nThe problem you can check here https://jsfiddle.net/d9Lh31sv/1/\nEven as a polygon html shows it like a rectangle and they´re are over each other on its sides as you see on this image \n\nWondering if there is a way that the click event can respect only its polygon limit..\nThanks in advance.\n\n\r\n\r\n var objTrapezium = document.getElementsByClassName('trapezium'); \r\n if (objTrapezium) { \r\n for (var i = 0; i < objTrapezium.length; i++) {\r\n objTrapezium[i].onclick = function() {\r\n var _Color = this.firstChild.nextSibling.attributes.fill.value; \r\n _Color = _Color==\"none\" ? \"grey\" : _Color ==\"grey\" ? \"red\": _Color ==\"red\" ? \"green\": _Color ==\"green\" ?\"blue\": _Color ==\"blue\" ? \"grey\": \"\"; \r\n this.firstChild.nextSibling.attributes.fill.value = _Color;\r\n \r\n };\r\n\r\n objTrapezium[i].onmouseover = function() {\r\n this.style.zIndex = 9999;\r\n this.style.backgroundColor = \"lightsteelblue\";\r\n }\r\n objTrapezium[i].onmouseout = function(){\r\n this.style.zIndex = 1;\r\n this.style.backgroundColor = \"transparent\";\r\n }\r\n\r\n\r\n }\r\n\r\n }\r\n.trapezium{\r\n position: relative;\r\n}\r\n.square{\r\n left: 202px;\r\n width: 73px;\r\n height: 73px;\r\n top: 102px;\r\n}\r\n.bottom{\r\n left: 53px;\r\n top: 175px;\r\n z-index: 1;\r\n}\r\n.left{\r\n transform: rotate(90deg);\r\n left: -243px;\r\n top: 102px;\r\n}\r\n.right{\r\n transform: rotate(-90deg);\r\n left: -315px;\r\n top: 101px;\r\n}\r\n.top{\r\n transform: rotate(-180deg);\r\n left: 129px;\r\n top: -48px;\r\n}\r\n<div>\r\n <svg class=\"trapezium square\">\r\n <rect stroke=\"black\" fill=\"none\" width=\"73\" height=\"73\" /> \r\n </svg>\r\n <svg class=\"trapezium bottom\" height=\"72\" width=\"217\">\r\n <polygon stroke=\"black\" fill=\"none\" points=\"0,72 72,0 144,0 216,72\" />\r\n </svg>\r\n <svg class=\"trapezium left\" height=\"72\" width=\"217\">\r\n <polygon stroke=\"black\" fill=\"none\" points=\"0,72 72,0 144,0 216,72\" />\r\n </svg>\r\n <svg class=\"trapezium right\" height=\"72\" width=\"217\">\r\n <polygon stroke=\"black\" fill=\"none\" points=\"0,72 72,0 144,0 216,72\" />\r\n </svg>\r\n <svg class=\"trapezium top\" height=\"72\" width=\"217\">\r\n <polygon stroke=\"black\" fill=\"none\" points=\"0,72 72,0 144,0 216,72\" />\r\n </svg>\r\n</div>" ]
[ "javascript", "svg", "polygon" ]
[ "Azure On-Premises Gateway with SSASaaS", "I currently have two windows VMs on azure, both running SQL server 2016. One is for our development environment and one is for production. \n\nI also have two instances of SSASaaS on Azure for Dev and production. \n\nMy question is, I'm having trouble understanding how to set up the On-premises gateway correctly for this environment. Do I need an on-prem gateway on each? Since I need access to two different servers." ]
[ "sql-server", "azure", "ssas" ]
[ "Error:1004 unable to get week num property of the worksheet function class", "Below is the code i have been using.\n\nStartWeekNum = Application.WorksheetFunction.WeekNum(StartDate, 21)\nEndWeekNum = Application.WorksheetFunction.WeekNum(EndDate, 21)\n\n\nThis code worked properly in excel 2010 version, when it comes to 2007 it is getting runtime error." ]
[ "excel", "vba", "runtime-error", "week-number" ]
[ "How to select all ms access table records based on date", "i'm new to MS Access..\n\none of my Access table CHECKOUT having a column name CHECK-TIME with Date/time data type\n\nvalues in that column are like 7/15/2013 10:56:22 AM,9/19/2013 6:54:37 PM....\n\ni want to select the data based on date like `7/15/2013'\n\n\nhow to write the query for this task ???\n\nthanks in advance.." ]
[ "sql", "ms-access" ]
[ "Send email to multiple recipients with bcc 'hidden' address - Django 1.6", "I'm developing an app on Django 1.6\n\nIn this app, there is a section, where a User which publishes a project can receive a message from a freelancer interested into this project.\n\nSo far this is the code I have:\n\n# Send email\n if user_profile.contracting:\n subject = _('Your question on project {} has been answered')\n body = _('You can read your answer here {}')\n email = question.user.email\n\n else:\n subject = _('Your have a new question on project {}')\n body = _('You can read your question here: {}')\n email = project.user.email\n\n send_mail(subject.format(project.name),\n body.format(\n os.environ.get('CURRENT_URL') + '/' +\n reverse('projects_id', args=(project.id,))[1:]),\n '[email protected]', [email, '[email protected]'])\n\n return HttpResponseRedirect(reverse('projects_id',\n args=(project.id,)))\n\n else:\n d = {'form': ProjectMessagesForm(request.POST)}\nreturn render_to_response('projects/questions.html', d,\n context_instance=RequestContext(request))\n\n\nIf you look at this line:\n\[email protected]', [email, '[email protected]'])\n\n\nI'm adding the previous 'email' declaration and another recipient [email protected], this second recipient fails, I don't receive any error message, but the message is not sent.\n\nI don't know what the cause could be... Since I don't have any traceback to it...\n\nAny ideas?\n\nEDIT\n\nThis line works: \n\[email protected]', [email, '[email protected]'])\n\n\nBut I just need to make [email protected] to be like a bcc address, I mean invisible to the email user." ]
[ "python", "django", "email", "django-1.6" ]
[ "Redirects - alternative to \"\"?", "Possible Duplicate:\n Best redirect methods? \n\n\n\n\nHello\n\nI am working with some legacy code that includes a module for user registration / login. There is a block that queries the DB to see if the user is logged in, then re-directs to the login page. \n\nThe re-direct is handled by <meta http-equiv='refresh' content='=2;index.php' /> but I have since learnt this is depreciated, and doesn't work in all browsers.\n\nIs there an alternative way to put a re-direct within the code below?\n\n $username = mysql_real_escape_string($_POST['username']);\n $password = md5(mysql_real_escape_string($_POST['password']));\n\n $checklogin = mysql_query(\"SELECT * FROM users WHERE username = '\".$username.\"' AND password = '\".$password.\"'\");\n\n if(mysql_num_rows($checklogin) == 1)\n {\n $row = mysql_fetch_array($checklogin);\n $email = $row['email'];\n\n $_SESSION['username'] = $username;\n $_SESSION['email'] = $email;\n $_SESSION['LoggedIn'] = 1;\n\n echo \"<h1>Success</h1>\";\n echo \"<p>We are now redirecting you</p>\";\n echo \"<meta http-equiv='refresh' content='=2;index.php' />\";\n }\n else\n {\n echo \"<h2>Error</h2>\";\n echo \"<p>Sorry, your account could not be found. Please <a href=\\\"index.php\\\">click here to try again</a>.</p>\";\n }\n\n\nMany thanks for any pointers." ]
[ "php", "mysql", "redirect" ]
[ "How to convert json schema to avro schema", "My application has been using json schema (org.everit.json.schema.Schema ) to validate JSON messages whether they comply to a particular format. We are now thinking of moving to the Avro schema. This involves converting previously-stored schema.json files to be converted to Avro schema schema.avsc. Also, the current behavior is we get schema in JSON format via an API /schema/create and store it schema.json format after validating it using SchemaLoader, for example, SchemaLoader.load(JSONObject obj). \n\nWe also need a way to convert this schema.json to schema.avsc as we receive it run time via API. Is there any utility/tool we can use to convert the schema.json to schema.avsc?" ]
[ "json", "avro", "jsonschema", "avro-tools" ]
[ "Device to device messaging using GCM without registering an app server", "Is it possible for a device to send message to other devices using Google cloud messaging without an app server at all?\n\nI have a centralized database using Google Cloud Datastore. The app will get required registration ids from the centralized database and the database is updated by all the devices. So, getting registration ids is not a problem. \n\nCan this be done using upstream messaging? I am not sure because i have searched a lot but never saw an example where app server is not used for this purpose.\n\nThis question is not duplicate of another question, because here i have central database to store registration ids which is mentioned as a problem in another question." ]
[ "android", "google-cloud-messaging", "google-cloud-datastore" ]
[ "Admob Ads not displaying iOS", "I have a banner ad and an interstitial ad. They are appearing when I use the adUnitID's for testing purposes that AdMob gives you, but neither of them are showing when I use live ads. The banner just doesn't appear at all. When the interstitial ad appears, it is just completely black. The adUnitID's are correct. The ads on my other apps are currently appearing just fine. The problem occurs both when I use the iOS simulator and my device. Any ideas?\n\nvar interstitial: GADInterstitial!\n\nfunc createAndLoadAd() -> GADInterstitial{\n let ad = GADInterstitial(adUnitID: \"ca-app-pub-7863284438864645/1835730011\")\n let request = GADRequest()\n ad.loadRequest(request)\n return ad\n\n}\n\n\noverride func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n authenticateLocalPlayer()\n self.bannerView.adUnitID = \"ca-app-pub-7863284438864645/9358996816\"\n self.bannerView.rootViewController = self\n let request: GADRequest = GADRequest()\n self.bannerView.loadRequest(request)\n self.interstitial = self.createAndLoadAd()\n\n}\n\noverride func viewDidAppear(animated: Bool) {\n _ = GADRequest()\n //request.testDevices = [\"2077ef9a63d2b398840261c8221a0c9b\"]\n showAd()\n\n}\nfunc showAd(){\n\n if(self.interstitial.isReady){\n print(\"ad ready\")\n self.interstitial.presentFromRootViewController(self)\n\n }\n else{\n print(\"ad not ready\")\n self.interstitial = createAndLoadAd()\n }\n\n\n}" ]
[ "ios", "admob" ]
[ "Simple Webpack 4 + Babel 7 + React ClickHandler in ES6 syntax", "I'm just getting set up with a really simple React + Webpack 4 + Babel 7 following this great guide here - https://www.robinwieruch.de/minimal-react-webpack-babel-setup/\n\nI've got things running on my local host and created my first custom \"hello world\" style jsx component which is great!\n\nThen I've tried to create a really simple clickHandler\n\nimport React, { Component } from 'react';\n\nexport default class testComponent extends Component {\n\nClickHandler = () => {\n console.log(\"I was called\")\n};\n\nrender() {\n\n return (\n <div>\n Test component test\n <button onClick={this.ClickHandler}>Click me</button>\n </div>\n )\n }\n}\n\n\nThis now causes my localhost to fall over with a blank page but I think my code is correct?\n\nMy guess was my usage of ES6 arrow function, even though I thought babel did it's thing and converted that if need .. so I've also tried ES5 syntax but still falls over with a blank screen\n\nFeels like I've missed some understanding of what is actually happening here - I can't think where I would begin to debug this" ]
[ "reactjs", "webpack", "babeljs" ]
[ "Are the following data type allocations analagous?", "I'm very interested in languages and their underpinnings, and I'd like to pose this question to the community. Are the following analagous to eachother in these languages?\n\nC#\n\nFoo bar = default(Foo); //alloc\nbar = new Foo(); //init\n\n\nVB.NET\n\nDim bar As Foo = Nothing 'alloc\nbar = New Foo() 'init\n\n\nObjective-C\n\nFoo* bar = [Foo alloc]; //alloc\nbar = [bar init]; //init" ]
[ "c#", "objective-c", "vb.net", "types" ]
[ "Passing parameter in XSL", "I'm an XSL beginner struggling with a parameter problem.\n\nMy XML looks likes this:\n\n<?xml version=\"1.0\"?>\n <Enterprise CompanyName=\"Some Name\">\n <HeaderData FileName=\"File21.xml\" SequenceNumber=\"00021\"/>\n <DetailData CusomterID=\"2\">\n <Location LocationID=\"Some Location1\" Name=\"SomeName\">\n <Address StreetName=\"Name of the street\"/>\n <Contact Name=\"\" FunctionDescription=\"\"/>\n </Location>\n <Location LocationID=\"Some Location2\" Name=\"SomeName\">\n <Address StreetName=\"Name of the street\"/>\n <Contact Name=\"\" FunctionDescription=\"\"/>\n </Location>\n </DetailData>\n <FooterData NumOfTags=\"7\"/>\n</Enterprise>\n\n\nIn the stylesheet I want to add the Sequencenumber from the HeaderData to each Location element in the DetailData.\nI tried xsl:param, xsl:variable in the root node, outside the rootnode, nothing works for me.\n\nHope somenone can help. Thanks." ]
[ "xml", "variables", "xslt", "parameters" ]
[ "Phone applications written in c++", "I have an application idea that I want to create and I want to create this app for both iOS-iphone and Android.\n\nSo I would like to ask for some advise!\n\nIs it possible to create a full fledged ( IOS and ANDROID ) application in pure C++ ?\n\nIs it smart to create an application in C++ for both ( IOS and ANDROID ) or is it better to write the application in ( Objective-C and Java ) for each devise target." ]
[ "java", "android", "c++", "ios", "objective-c" ]
[ "LINQ-to-entities - Null reference", "I could swear this was working the other day:\n\nvar resultSet =\n (from o in _entities.Table1\n where o.Table2.Table3.SomeColumn == SomeProperty\n select o\n ).First();\nSelectedItem = resultSet.Table2.SomeOtherColumn;\n\n\nI am getting a null reference exception on the last line: resultSet.Table2 is null.\nNot only am I sure that all the foreign keys and whatnot have the correct values, but I don't see how Table2 could be null, since o.Table2.Table3.SomeColumn == SomeProperty.\n\nresultSet has all the correct values, with the exception that Table2 is null.\n\n[Edit] This works:\n\nSelectedItem = _entities.Table2.First(\n o => o.Table2.SomeColumn == SomeProperty).SomeOtherColumn; \n\n\nAnd, above, resultSet has all the correct values, so it is not a problem with the data in the database; LINQ-to-entities is simply doing something wrong." ]
[ "c#", "linq", "null", "linq-to-entities" ]
[ "RSS/Atom feed of Subversion commit comments", "We have recently introduced version control in Subversion in our development cycle, and a team mate asked me today if it was possible to get all commit comments in an RSS feed. Since I think it's a pretty cool idea, I looked around in the Visual SVN Server option windows, and here on SO, but couldn't find anything relevant. (Most searches on anything with RSS in it here turns to discussions/questions regarding the format itself... unless you have infinite search-fu, which I don't.)\n\nSo, is there some (easy) way to publish SVN commit comments in a feed?" ]
[ "svn", "rss", "comments", "atom-feed" ]
[ "Android - how to: load google/facebook user profile in 1 activity and set the listener result to any active/current activity", "I have:\n\n+----------+\n|user class|\n+-----+----+\n |\n+-----+-----+\n|App Class |\n+-----------+\n|User object|\n|GoogleAPI |\n|FB API |\n+-----+-----+\n |\n +----not------+------a------+--sequential-+--activity---+\n | | | | |\n+-----+-----+ +-----+-----+ +-----+-----+ +-----+-----+ +-----+-----+\n|Activity 1 | |Activity 2 | |Activity 3 | |Activity 4 | |Activity 5 |\n+-----------+ +-----------+ +-----------+ +-----+-----+ +-----+-----+\n\n\nin the activity 1, i may trigger both google API and FB API to get user basic profile: FName, LName, Email, Profile Pict (asynchronously), then from there my app will 'not care' / wait until i have the result from Google and FB, user may go to any other activity (activity 2 or Activity 3 or any other other) - once Google or FB send the result, i would like to store the data in my user class (object in my app class)\n\nif i go to activity 2 (for example) and the user profile result has been returned before i go to activity 2, then it's easy, i just call user object to present the data in activity 2 - because the data is there already.\n\nthe question is: if i go to any other activity but the result is not back yet, how to setup a listener, to load the result to the active activity?\ne.g. i'm in activity 3, the profile result is not ready, then i may just show loading text (for example) but then when the result come from google/FB, i need to load the result to the current activity respectively.\n\nis there a way to achieve this?\n\nThanks," ]
[ "android", "facebook-graph-api", "google-signin" ]
[ "Mechanics of 'x % y != 0' in C++", "Can someone please explain the under-the-hood mechanics of x % y !=0 in C++? It evaluates to 0 if there is no remainder in integer division and it evaluates to 1 if there is any remainder of any amount. I find this to be quite useful, but I'd like to understand what is taking place, as the syntax is not intuitive to me. \n\nI discovered this in a separate thread, which I do not have permissions to comment in: \n\nFast ceiling of an integer division in C / C++\n\nThank you. \n\n(Please forgive any formatting faux pas; this is my first go here)" ]
[ "c++", "modulus", "integer-division" ]
[ "Why can't I center an inline flex-item?", "I'm creating navigation bars using flexbox and ran into this particular issue when trying to create buttons out of anchor tags (i.e. link in the centre of a box).\n\nI have the li set to display flex so I can centre the a, but as soon as I give the a some height, the a aligns to the top-left. Is there any way of getting the a centred?\n\n\r\n\r\n* {\r\n box-sizing: border-box;\r\n}\r\n\r\nhtml,\r\nbody {\r\n margin: 0;\r\n padding: 0;\r\n font: sans-serif;\r\n}\r\n\r\n#top-nav {\r\n border-bottom: 4px solid blue;\r\n}\r\n\r\n#center-section {\r\n display: flex;\r\n width: 1000px;\r\n margin: auto;\r\n}\r\n\r\n#center-section>* {\r\n flex: 1 1 0;\r\n}\r\n\r\nheader section {\r\n background: blue;\r\n height: 90px;\r\n width: 500px;\r\n}\r\n\r\n.navbar {\r\n display: flex;\r\n}\r\n\r\n.navbar ul {\r\n list-style-type: none;\r\n padding: 0;\r\n display: flex;\r\n flex-direction: row;\r\n width: 100%;\r\n height: 100%;\r\n align-self: center;\r\n border: 1px solid red;\r\n}\r\n\r\n.navbar ul li {\r\n display: flex;\r\n flex: 1 1 100%;\r\n}\r\n\r\n.navbar ul li a {\r\n background-color: yellow;\r\n align-self: center;\r\n width: 100%;\r\n height: 100%;\r\n}\r\n\r\n.navbar ul li a:hover {\r\n background-color: green;\r\n}\r\n<header>\r\n <div id=\"top-nav\">\r\n <div id=\"center-section\">\r\n <section id=\"logo\">\r\n <a href=\"\">Home</a>\r\n </section>\r\n <div class=\"navbar\">\r\n <ul>\r\n <li><a href=\"\">About</a></li>\r\n <li><a href=\"\">Store</a></li>\r\n <li><a href=\"\">Contact</a></li>\r\n </ul>\r\n </div>\r\n </div>\r\n </div>\r\n</header>" ]
[ "html", "css", "flexbox" ]
[ "If I duplicate a class object in an array list and add it into the same array list, do I have to set it's values again, or do the values carry over?", "product1 is an Array List of my stock class, so if I had this declared previously\n\nproduct1.add(s);\nproduct1.get(0).setPrice(price);\nproduct1.get(0).setCalories(calories); \n\n\nDoes this also set the price and calories for the duplicate?\n\nproduct1.add(product1.get(0));\n\n\nOr do I still have to set it myself?\nIf I do have to set it myself, is this acceptable?\n\nproduct1.get(product1.size() - 1).setPrice(product1.get(0).getPrice);\nproduct1.get(product1.size() - 1).setCalories(product1.get(0).getCalories);" ]
[ "java", "arraylist" ]
[ "How can garbage collectors be faster than explicit memory deallocation?", "I was reading this html generated, (may expire, Here is the original ps file.)\n\nGC Myth 3: Garbage collectors are always slower than explicit memory deallocation.\nGC Myth 4: Garbage collectors are always faster than explicit memory deallocation.\n\nThis was a big WTF for me. How would GC be faster then explicit memory deallocation? isnt it essentially calling a explicit memory deallocator when it frees the memory/make it for use again? so.... wtf.... what does it actually mean?\n\n\n Very small objects & large sparse\n heaps ==> GC is usually cheaper,\n especially with threads\n\n\nI still don't understand it. Its like saying C++ is faster then machine code (if you don't understand the wtf in this sentence please stop programming. Let the -1 begin). After a quick google one source suggested its faster when you have a lot of memory. What i am thinking is it means it doesn't bother will the free at all. Sure that can be fast and i have written a custom allocator that does that very thing, not free at all (void free(void*p){}) in ONE application that doesnt free any objects (it only frees at end when it terminates) and has the definition mostly in case of libs and something like stl. So... i am pretty sure this will be faster the GC as well. If i still want free-ing i guess i can use an allocator that uses a deque or its own implementation thats essentially\n\nif (freeptr < someaddr) {\n *freeptr=ptr;\n ++freeptr; \n}\nelse\n{\n freestuff();\n freeptr = freeptrroot;\n}\n\n\nwhich i am sure would be really fast. I sort of answered my question already. The case the GC collector is never called is the case it would be faster but... i am sure that is not what the document means as it mention two collectors in its test. i am sure the very same application would be slower if the GC collector is called even once no matter what GC used. If its known to never need free then an empty free body can be used like that one app i had.\n\nAnyways, i post this question for further insight." ]
[ "garbage-collection" ]
[ "How do I keep a mySQL database secure?", "I'm going to be implementing a PHP/mySQL setup to store credit card information.\nIt seems like AES_ENCRYPT/AES_DECRYPT is the way to go,\nbut I'm still confused on one point:\nHow do I keep the encryption key secure?\nHardwiring it into my PHP scripts (which will live on the same server as the db) seems like a major security hole.\nWhat's the "best practice" solution here?" ]
[ "php", "mysql", "security", "aes" ]
[ "Paging not advancing when using cached query", "My index method does not advance through the result set when it's pulled from the cache; without caching, it works as expected. The page number in\nthe query params is correctly incremented.\n\nI've reviewed several very old SO questions about this, but they are very out of date with the current CakePHP release (3.8).\n\ncase ('F'): // Full, paid members\n $query = $this->Members->find('currentFullMembers');\n\n $cacheKey = md5($this->request->getParam('controller') . \n $this->request->getParam('action') . $report) . 'FM';\n $query->cache($cacheKey);\n\n $this->set('baseYear', $baseYear);\n $this->set('reportTitle', 'Full Members');\n break;\n\n\nIs there something else I need to do for pagination?" ]
[ "caching", "cakephp", "pagination" ]
[ "Trouble with saving file onto expo filesystem. I get the uri for the recording but can't seem to get the file after leaving the screen", "So my problem is what the title says, and I have been stuck on this problem for over a week now and am at a loss for what I can do. Here's the code\n\nI've tried many different methods but none seem to work, at least with the saving of the file. Please let me know if you need to see more code.\n\nasync _stopRecordingAndEnablePlayback() {\n this.setState({\n isLoadingz: true\n });\n try {\n await this.recording.stopAndUnloadAsync();\n } catch (error) {\n }\n const info = await FileSystem.getInfoAsync(this.recording.getURI());\n console.log(\n `FILE INFO: ${JSON.stringify(info)}`,\n info.uri\n );\n const arr = [];\n const xFileInfo = JSON.stringify(info);\n arr.push(xFileInfo);\n this.setState({ fileInfo: arr, fileUri: info.uri });\n console.log(arr);" ]
[ "react-native", "expo" ]
[ "Repositories should always return objects?", "This question got me today, my repositories should always return full objects? They can not return partial data (in an array for example)?\n\nFor example, I have the method getUserFriends(User $user) inside my repository Friends, in this method I execute the following DQL:\n\n$dql = 'SELECT userFriend FROM Entities\\User\\Friend f JOIN f.friend userFriend WHERE f.user = ?0';\n\nBut this way I'm returning the users entities, containing all the properties, the generated SQL is a SELECT of all fields from the User table. But let's say I just need the id and the name of the user friends, there would be more interesting (and quick) get just these values?\n\n$dql = 'SELECT userFriend.id, userFriend.name FROM Entities\\User\\Friend f JOIN f.friend userFriend WHERE f.user = ?0';\n\nThese methods are executed in my service class." ]
[ "php", "zend-framework", "repository-pattern", "doctrine-orm" ]
[ "two dimensional array horizontal average output", "I am stuck with a problem and i don't know how to put this in a for loop.\nI need the hotizontal average of the next matrix:\n\n1 2 3 4 5\n\n5 4 3 2 1\n\n3 2 1 4 5\n\n\nWhat i got so far:\n\nvar dArray = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [3, 2, 1, 4, 5]];\n\n for (x=0; x<dArray.length; x++)\n {\n //this loop needs to go trough each horizontal matrix and put \n //the average in a variable so i can print it later\n //average .... team[0][x] something?\n //document.write(average)\n }\n\n\nThe end product is something like this\n\nI want to make a table at the end and put the average per \"array\n\nArr 0 1 2 3 4 5 average:\n\nArr 1 5 4 3 2 1 average:\n\nArr 2 3 2 1 4 5 average:" ]
[ "javascript" ]
[ "What is best practices for syncing service cached Angular 1.3?", "I am working on a legacy project with angular 1.3 and got stuck on a decision what is the best way to keep service variables and $scope in sync after updating or if receiving the data takes longer than the digest cycle.\n\nI am implementing variable caching in my service, which returns a getter for a variable something like this:\n\nreturn function () {\n if(!this.games)\n {\n this.games= [];\n if(!!this.gameTypeId)\n this.getAll(this.gameTypeId);\n else\n this.getAll();\n };\n return this.games;\n }\n\n\nand if the getAll function takes longer than the digest cycle the view does not update. So a work around is to use $apply, but it feels that I am approaching this the wrong way. Because the promise looks like this:\n\nreturn Resource.query({id: gameTypeId, resourceName: \"Games/ByGameType\"})\n .$promise.then(function(response){\n if(!$rootScope.$$phase) {\n $rootScope.$apply(function () {\n angular.extend(this.games, response);\n });\n }\n else\n angular.extend(this.games, response);\n });\n\n\nAnd you have to check if the $digest cycle really ended (if the promise returns the value faster the the view updates on its own). \n\nThe other way is to sprinkle promise returns all around the controller and update the $scope.games there, on this side the controller gets little bit more crowded. And instead of returning a function in the getter just return a way to rebind $scope.games to service->this.games value. The first way is implemented now and works, but not sure if it is the best way." ]
[ "javascript", "angularjs", "service" ]
[ "Display Chrome extension popup at middle of page", "I am new to writing chrome extensions and was wondering how can i do the following.\n\nHow can i make the popup(when someone clicks on extension icon) display at the center of the webpage instead of displaying the popup at the top right corner ?" ]
[ "google-chrome", "google-chrome-extension" ]
[ "Add value from data layer variable at the end of hyperlink", "I am trying to get a vlaue from a data layer variable and add it to the end of a hyperlink.\nSo if my hyperlink is https://www.somehyperlink.com and my variable is variable1 with value 23 i want the final hyperlink to be https://www.somehyperlink.com/23.\n\nI've got this code, which is probably not the best way to do it, but I'm not sure how to replace the last part of it with the value from the variable:\n\n(function () {\n var links = document.querySelectorAll( 'a[href=\"https://www.somehyperlink.com/replace\"]')\n var searchString = \"replace\"\n var replacementString = \"value-from-variable\"\n\n links.forEach(function(link){\n var original = link.getAttribute(\"href\");\n var replace = original.replace(searchString,replacementString)\n link.setAttribute(\"href\",replace)\n })\n})();\n\n\nI would appreciate any help.\n\nThanks" ]
[ "javascript", "google-analytics", "google-tag-manager", "google-datalayer" ]
[ "vue2.js component vmodel passing data", "I'm missing a piece of understanding of how to use pass v-model data to a component.\n\nCan I directly access the checkbox model data or do I need to pass into the component via props?\n\nIf someone code explain or point me to somewhere helpful?\n\nMy Html\n\n <template id=\"my-child\">\n\n <tr>\n <td >{{ item.title }}</td>\n <td style=\"padding:20px\" v-for=\"price in item.prices\" v-bind:price=\"price\" >{{ price }}</td>\n </tr>\n </template>\n\n\n <template id=\"my-parent\">\n\n <div class=\"box\" >\n <div v-for=\"item in items\">\n <h1>{{ item.name }}</h1>\n <img :src=\"item.imageUrl\" style=\"width:200px;\">\n <p>{{item.extract}}</p>\n {{ item.holidayType }}\n\n <div is=\"task\" v-for=\"avail in item.avail\" v-bind:item=\"avail\" >\n\n </div> \n\n\n </div>\n </div>\n\n </template>\n\n <div id=\"root\">\n <div id=\"homesFilters\">\n\n\n <input type=\"checkbox\" id=\"1\" value=\"hottub\" v-model=\"test\"> hot tub\n <input type=\"checkbox\" id=\"2\" value=\"garden\" v-model=\"test\"> garden\n <input type=\"checkbox\" id=\"3\" value=\"cottage\" v-model=\"test\"> cottage\n </div>\n\n <task-list></task-list>\n </div>\n\n\nMy code\n\nVue.component('task-list', {\n template: '#my-parent',\n props: ['test'],\n data: function() {\n return {\n items: [],\n\n }\n },\n methods: {\n getMyData: function(val) {\n\n console.log(this.test);\n\n var _this = this;\n $.ajax({\n url: 'vuejson.php',\n method: 'GET',\n success: function (data) {\n\n _this.items = data;\n },\n error: function (error) {\n alert(JSON.stringify(error));\n } \n })\n\n }\n },\n mounted: function () {\n this.getMyData(\"0\");\n }\n});\n\nVue.component('task', {\n\n template: '#my-child',\n props: ['item'],\n\n data: function() {\n return {\n\n }\n }\n});\n\n\nnew Vue({\n el: \"#root\",\n data: {\n test:[]\n },\n\n});\n\n</script>" ]
[ "javascript", "vue.js", "vuejs2" ]
[ "Can't get rid of a certain barrier thrown by a site while logging in", "I'm trying to log into a site using selenium but I come across this issue. After entering the username when the script is supposed to enter the password, that page appears. When I do the same manually in chrome browser, I get success.\nI've tried with:\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.wait import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\n\nlink = 'https://merchants.google.com/mc/default?hl=en&fmp=1&utm_id=gfr&mcsubid=us-en-z-g-mc-gfr'\n\nusername = "your_gmail_id"\npassword = "your_password"\n\ndriver = webdriver.Chrome()\nwait = WebDriverWait(driver, 10)\ndriver.get(link)\nwait.until(EC.presence_of_element_located((By.CSS_SELECTOR,"input#identifierId"))).send_keys(username)\nwait.until(EC.presence_of_element_located((By.CSS_SELECTOR,"#identifierNext"))).click()\nwait.until(EC.presence_of_element_located((By.CSS_SELECTOR,"input[aria-label='Enter your password']"))).send_keys(password)\n\n\nHow can I get rid of that barrier?" ]
[ "python", "python-3.x", "selenium", "selenium-webdriver", "web-scraping" ]
[ "Jackson polymorphic type conversion deletes the property after using it", "I am trying to use Jackson to automatically parse my JSON payload to subtypes\n\nAll is working as intended and the object is being parsed to the right subtype. but the property used for discriminating is deleted at the end of the process.\n\n\n@JsonTypeInfo(\n use = JsonTypeInfo.Id.NAME,\n include = JsonTypeInfo.As.PROPERTY,\n property = \"type\")\n@JsonSubTypes({\n @Type(value = MySubClass.class, name = \"type1\") })\n\n\n\nIn this case the property \"type\" is null in the MySubClass instance. \n\nHow do i tell jackson to leave the data intact.\n\nThanks." ]
[ "java", "json", "jackson" ]
[ "python - register all subclasses", "I have a class Step, which I want to derive by many sub-classes. I want every class deriving from Step to be \"registered\" by a name I choose for it (not the class's name), so I can later call Step.getStepTypeByName().\n\nSomething like this, only working :):\n\nclass Step(object):\n _STEPS_BY_NAME = {}\n\n @staticmethod\n def REGISTER(cls, name):\n _STEPS_BY_NAME[name] = cls\n\nclass Derive1(Step):\n REGISTER(Derive1, \"CustomDerive1Name\")\n ...\n\nclass Derive2(Step):\n REGISTER(Derive2, \"CustomDerive2Name\")\n ..." ]
[ "python" ]
[ "Python 3 on Django 2 throws a UnicodeEncodeError", "On my Django 2 / Python 3 project I get a UnicodeDecodeError when uploading an image to the server. Interestingly I don't get this error on my development PC. I only get this on the staging server. \n\nmodels.py\n\nfrom sorl.thumbnail import ImageField\n\nclass CustomUser(AbstractUser):\n ext_code = models.PositiveIntegerField(\"ext_code\")\n avatar = ImageField(upload_to=\"avatars\", default=\"\", blank=True)\n\n\nviews.py\n\nif request.method == \"POST\":\n image = request.FILES.get(\"avatar\")\n user.avatar = image\n user.save() # <-- Error is thrown here\n\n\nmy locale setup on the server\n\nLANG=en_GB.UTF-8\nLANGUAGE=\nLC_CTYPE=\"en_GB.UTF-8\"\nLC_NUMERIC=\"en_GB.UTF-8\"\nLC_TIME=\"en_GB.UTF-8\"\nLC_COLLATE=\"en_GB.UTF-8\"\nLC_MONETARY=\"en_GB.UTF-8\"\nLC_MESSAGES=\"en_GB.UTF-8\"\nLC_PAPER=\"en_GB.UTF-8\"\nLC_NAME=\"en_GB.UTF-8\"\nLC_ADDRESS=\"en_GB.UTF-8\"\nLC_TELEPHONE=\"en_GB.UTF-8\"\nLC_MEASUREMENT=\"en_GB.UTF-8\"\nLC_IDENTIFICATION=\"en_GB.UTF-8\"\nLC_ALL=\n\n\non manage.py shell I get this:\n\nPython 3.5.2 (default, Oct 8 2019, 13:06:37)\n[GCC 5.4.0 20160609] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n(InteractiveConsole)\n>>> import sys\n>>> sys.stdout.encoding\n'UTF-8'\n>>> import locale\n>>> locale.getpreferredencoding(False)\n'UTF-8'\n\n\nAnd this is the error:\n\nUnicodeEncodeError: 'ascii' codec can't encode character '\\xf3' in position 75: ordinal not in range(128)\n\n\nI also have included # coding=utf-8 on all my python files. \n\nMy code seems to be OK, because the same image (filename is: Vs_Filemón.png) uploads fine on my development machine. So, I guess there must something broken on my staging machine which is this:\n\nNo LSB modules are available.\nDistributor ID: Ubuntu\nDescription: Ubuntu 16.04.6 LTS\nRelease: 16.04\nCodename: xenial" ]
[ "django", "python-3.x", "ubuntu" ]
[ "How to use thread lock when reading and writing a csv file in python?", "I am working on refining dummy blockchain code, and want to make it impossible to read and write csv file if it's already being used. What should do i do? \n\nI've put start(), join(), acquire(), release() etc all the places that i could thought, but i weren't work at all. Once gotten a message that \"Permission denied\" while i opened my file, however, it still gave me the information in the file. (All the other functions are working properly.) \n\ndef readBlockchain(blockchainFilePath, mode = 'internal'): \n\nget_lock.acquire()\nprint(\"readBlockchain is called\")\nimportedBlockchain = [] \n\ntry:\n with open(blockchainFilePath, 'r', newline='') as file: \n blockReader = csv.reader(file)\n for line in blockReader:\n block = Block(line[0], line[1], line[2], line[3], line[4], line[5],line[6])\n\n importedBlockchain.append(block) \n\n print(\"Pulling blockchain from csv...\")\n get_lock.release()\n return importedBlockchain\n\nexcept: \n if mode == 'internal': \n blockchain = generateGenesisBlock() \n importedBlockchain.append(blockchain) \n writeBlockchain(importedBlockchain) \n get_lock.release()\n return importedBlockchain\n\n else:\n get_lock.release()\n return None \n\n\nI expect it not to be read if i've opened the csv file, and to be read after i closed the file. \n\nI'll look forward to your answers!\nThanks." ]
[ "python-3.x", "multithreading", "csv", "locking" ]
[ "Why the time complexity of this function is not O(m!)?", "When I try to find the time complexity of this function, I come with m!.\nWhat I did is\n\nT(n,m)=m*T(n-1,m-1)=m(m-1)T(n-2,m-2)=....=m!T(1,1)\n\n\nbut the answer of the time complexity is O(n). Why?\n\nvoid f3 (int n, int m)\n{\n if (n <= 1)\n return;\n if (m > 1)\n return m*f3(n-1, m-1);\n f3(n-1, m);\n}" ]
[ "c", "function", "time-complexity", "big-o", "complexity-theory" ]
[ "button in repeat under other repeat can't get data row", "I have a first repeat control that finds the name and pictures of the different types of products from the selected main product group.\nIn this first repeat control I have another repeat that finds every single article , stock and description for each product type of the first repeat. In this second repeat I have a button to order the specific article. \nThe strange thing is in the label of the button I can put the article number, but in the onclick event I can't get the correct article number.\nThe data from the first repeat is comming from the domino server and is put in a viewscope array. The second repeat control get's it's data from an iseries server and is also put in an viewscope array, in order to put eveything into a table.\nThe code :\n\n`<xp:repeat id=\"repeat3\" rows=\"30\" value=\"#{viewScope.lijst}\"\n var=\"hoofdlijn\" indexVar=\"index1\">\n <xp:text escape=\"true\" id=\"produktnaam\">\n <xp:this.value><![CDATA[#{javascript:hoofdlijn[0];}]]></xp:this.value>\n </xp:text>\n <xp:this.value><![CDATA[#{javascript:hoofdlijn[1];}]]></xp:this.value>\n </xp:text>\n\n\n`\nThen I have a computed field that is getting it's data from iseries for the given line and put's it's data into another viewscope array : \"producten1\"\nThen comes the second repeat to display all the lines of this viewscope :\n\n<xp:repeat id=\"repeat5\" rows=\"30\"\n value=\"#{viewScope.producten1}\" var=\"dezelijn2\">\n <xp:text escape=\"true\" id=\"computedField42\">\n <xp:this.value><![CDATA[#{javascript:dezelijn4[4];}]]></xp:this.value><!-- this works fine -->\n </xp:text><xp:button id=\"button3\" styleClass=\"btn btn-xs btn-primary\">\n\n <xp:this.value><![CDATA[#{javascript:\"Bestel \"+dezelijn4[0]}]]><!-- this gives the correct value for dezelijn4 -->\n </xp:this.value>\n\n <xp:eventHandler event=\"onclick\" submit=\"true\" refreshMode=\"partial\" execMode=\"partial\" refreshId=\"menuPanel\">\n <xp:this.action>\n <![CDATA[#{javascript:if \n (sessionScope.containsKey[(\"besteld\")]){\n sessionScope.besteld.push ([dezelijn4[0],\"1\"]);\n }\n else {\n sessionScope.besteld = new Array();\n sessionScope.besteld.push ([dezelijn4[0],\"1\"]);\n }\n }]]></xp:this.action><!-- gives a wrong value for dezelijn4 -->\n </xp:eventHandler>\n </xp:button>\n </xp:repeat>\n </xp:repeat>\n\n\nThe label of the button display's the article number (dezelijn4[0]) correctly.\nThe article number in the onclick event seems always to be the verry last article number of the very last product type.\n\nHow can I get the correct article number in my onclick event ?" ]
[ "xpages", "repeat", "xpages-ssjs" ]
[ "React - Strict Mode off, functional component constructed second time after first state change only", "I'm confused why function components (non class components don't confuse with functional) are constructed twice when state changes?\nMy understanding was that the function is constructed once just like a class' component constructor?\nNote: React is NOT running in strict mode.\nCodesandbox\nSample code:\nindex.js:\nconst rootElement = document.getElementById("root");\nReactDOM.render(<App />, // notice no strict mode\n rootElement\n);\n\nEg 1: LogStatement called once - simple and obvious:\nfunction App1() {\n console.log("App constructed");\n return <div>Hello</div>;\n}\n\nEg 2: LogStatement called twice - not quite obvious but maybe its due to setDidMount ? :\nfunction App2() {\n console.log("App constructed");\n const [didMount, setDidMount] = useState(false);\n\n useEffect(() => {\n setDidMount(true);\n }, []);\n\n return <div>Hello</div>;\n}\n\nEg 3: LogStatement called twice. no matter how many independent state variables:\nfunction App3() {\n console.log("App constructed:" + i++);\n\n const [didMount, setDidMount] = useState(false);\n const [someState, setSomeState] = useState("empty");\n\n useEffect(() => {\n setDidMount(true);\n }, []);\n\n useEffect(() => {\n setSomeState("full");\n }, []);\n\n return <div>Hello</div>;\n}\n\nFinally class component\nEg 4: LogStatement called once - as expected\nclass App4 extends Component {\n constructor() {\n super();\n this.state = {\n didMount: false\n };\n console.log("App constructed:" + i++);\n }\n\n componentDidMount() {\n this.setState({\n didMount: true\n });\n }\n\n render() {\n return <div>Hello</div>;\n }\n}" ]
[ "reactjs" ]
[ "@JsonInclude not working on Deserialization with Spring, using mutable objects", "I have found a lot about this, but no one having this same issue, the only that i can think is the last answer in this question where the mutability of the object makes the annotation work different.\n\nSo, I have an object like this\n\n@JsonIgnoreProperties(ignoreUnknown = true)\n@JsonInclude(value = Include.NON_EMPTY)\npublic class Invoice implements Serializable {\n @JsonInclude(value = Include.NON_EMPTY)\n private String originCode;\n\n @JsonInclude(value = Include.NON_EMPTY)\n public String getOriginCode() {\n return originCode;\n }\n\n @JsonInclude(value = Include.NON_EMPTY)\n public void setOriginCode(String originCode) {\n this.originCode = originCode;\n }\n}\n\n\nWhen deserializing this object from a JSON, using spring framework the value of originCode keeps coming empty, if i use \n\n{ \n \"originCode\" : \"\"\n}\n\n\nIn the other way around if I use this object where originCode is already empty and I serialize it, the originCode is ignores in the serialized json.\n\nWhy this is working just when serializing?, how the fact that this object is mutable can affect in the use of this annotation when deserializing?\n\n\n\n---EDIT---\n\nThe solution proposed here below did not fix the problem, I thought the problem was actually in spring. So I tried like this\n\n@RequestMapping(method = RequestMethod.POST, value = \"/test\")\n@ResponseBody\npublic ResponseEntity<InvMessage> testInvoice(\n @PathVariable(value = \"someId\") @Example({ \"1233232-7\" }) InvoicerId invoicerId,\n @RequestBody Invoice2 invoiceRequest,\n InvMessage messageContainer) {\n\n ObjectMapper mapper = new ObjectMapper();\n try {\n\n String jsonString1 = mapper.writeValueAsString(invoiceRequest);\n Invoice2 invoiceTest1 = mapper.readValue(jsonString1, Invoice2.class);\n String jsonInString2 = \"{\\\"originCode\\\" : \\\"\\\",\\\"originText\\\" : \\\"Original\\\"}\";\n Invoice2 testInvoice = mapper.readValue(jsonInString2, Invoice2.class);\n\n } catch (JsonProcessingException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n return ok(messageContainer);\n}\n\n\nSo, when sending a request with body \n\n{ \n \"originCode\" : \"\",\n \"originText\" : \"Original\"\n}\n\n\nThe results are\n\n\njsonString1: \"{\"originText\" : \"Original\"}\"\ninvoiceTest1 (originCode null) \ninvoiceTest2 (originCode: \"\")\n\n\nChecking those results, i can see that always when deserializing that empty string I'm getting also an empty string inside the object, even I have defined the class like.\n\n@JsonIgnoreProperties(ignoreUnknown = true)\npublic class Invoice2 implements Serializable {\n private static final long serialVersionUID = 1L;\n @JsonInclude(value = Include.NON_EMPTY)\n private String originCode; \n private String originText; \n public String getOriginCode() {\n return originCode;\n }\n public void setOriginCode(String originCode) {\n this.originCode = originCode;\n }\n public String getOriginText() {\n return originText;\n }\n public void setOriginText(String originText) {\n this.originText = originText;\n }\n}\n\n\nJackson-databind version 2.5" ]
[ "spring", "jackson" ]
[ "Anything similar to Emacs' buffer/window support for Eclipse?", "I'm trying to make the switch from Emacs to Eclipse. One thing that seems to be missing is its buffer/window support.\n\nI know in Eclipse I can drag an editor's tab title over to split the view, creating the equivalent of a new Emacs window, which is a step in the right direction. \n\nI can't find any key bindings for this functionality, though. Ideally, I'd like to be able to set keys to split horizontal, split vertical, switch to next (there is a next editor, but I want the next window/whatever you call it), switch to previous, close this window split (not this editor), close all other editor window splits.\n\nAs it is, the only way I've found to close a split pane is to drag all the files over one by one until none are left. Things like this make working with split screens tedious in Eclipse.\n\nAny help would be appreciated, hopefully there's something simple I'm missing." ]
[ "eclipse", "emacs" ]
[ "Executing a Stored procedure", "I'm trying to execute an oracle stored procedure that has an in-out parameter of table of record:\n\nTYPE RECORD_TYP IS RECORD (\n CAT_CD VARCHAR2(4),\n MOD_ID NUMBER(6)\n);\n\n\nI found this example that talks about List<String> and List<Integer>:\nhttp://viralpatel.net/blogs/java-passing-array-to-oracle-stored-procedure/.\n\nBut what about List<MyRecordDTO>?\n\nEDIT: I found an answer here where the poster used an oracle.sql.STRUCT type.\nhttp://betteratoracle.com/posts/32-passing-arrays-of-record-types-between-oracle-and-java\n\nUsing this example, I found the exception java.sql.SQLException: Internal Error: Inconsistent catalog view. Googling this exception, I called the DBA to grant me access to \"RECORD_TYP\"" ]
[ "java", "oracle" ]
[ "Post Method with Guzzle doesn't work / Laravel 5", "I want to execute a scheduled task with laravel, which make a post with a single param.\n\nI already checked with Postman my POST, so, I just have to hit myurl.com with param ID=188888 for instance. I get it working with postman.\n\nSo, first, I'm making the Laravel command : check:time, which just performs the post, and then, once I get it working, I will schedule it.\n\nThing is it appears commands is doing nothing, and I have no error logs.\n\nSo, really, it is not so easy to debug it...\n\nHere is my Command Code:\n\nclass CheckTime extends Command\n{\n\nprotected $signature = 'check:time {empId}';\n\nprotected $description = 'Check your time';\n\npublic function handle()\n{\n $client = new Client;\n $numEmp = $this->argument('empId');\n $response = $client->post('http://example.com/endpoint.php', ['ID' => $numEmp]);\n var_dump($response);\n }\n}\n\n\nWhen I print $response, I get: \n\n class GuzzleHttp\\Psr7\\Response#495 (6) {\n private $reasonPhrase =>\n string(2) \"OK\"\n private $statusCode =>\n int(200)\n private $headers =>\n array(6) {\n 'date' =>\n array(1) {\n [0] =>\n string(29) \"Wed, 01 Jun 2016 00:17:52 GMT\"\n }\n 'server' =>\n array(1) {\n [0] =>\n string(22) \"Apache/2.2.3 (Red Hat)\"\n }\n 'x-powered-by' =>\n array(1) {\n [0] =>\n string(10) \"PHP/5.3.15\"\n }\n 'content-length' =>\n array(1) {\n [0] =>\n string(3) \"146\"\n }\n 'connection' =>\n array(1) {\n [0] =>\n string(5) \"close\"\n }\n 'content-type' =>\n array(1) {\n [0] =>\n string(24) \"text/html; charset=UTF-8\"\n }\n }\n private $headerLines =>\n array(6) {\n 'Date' =>\n array(1) {\n [0] =>\n string(29) \"Wed, 01 Jun 2016 00:17:52 GMT\"\n }\n 'Server' =>\n array(1) {\n [0] =>\n string(22) \"Apache/2.2.3 (Red Hat)\"\n }\n 'X-Powered-By' =>\n array(1) {\n [0] =>\n string(10) \"PHP/5.3.15\"\n }\n 'Content-Length' =>\n array(1) {\n [0] =>\n string(3) \"146\"\n }\n 'Connection' =>\n array(1) {\n [0] =>\n string(5) \"close\"\n }\n 'Content-Type' =>\n array(1) {\n [0] =>\n string(24) \"text/html; charset=UTF-8\"\n }\n }\n private $protocol =>\n string(3) \"1.1\"\n private $stream =>\n class GuzzleHttp\\Psr7\\Stream#493 (7) {\n private $stream =>\n resource(311) of type (stream)\n private $size =>\n NULL\n private $seekable =>\n bool(true)\n private $readable =>\n bool(true)\n private $writable =>\n bool(true)\n private $uri =>\n string(10) \"php://temp\"\n private $customMetadata =>\n array(0) {\n }\n }\n}\n\n\nI checked that $numEmp is OK, also, I printed $response and everything seems to be fine\n\nAs I said, I also execute the post with Postman, and it works, so, I don't really understand what's going on... \n\nAny idea??" ]
[ "laravel" ]
[ "How to create an interface for any service in Spring Boot", "I want all the Service classes in my backend to have CRUD methods.\nFor that purpose, I thought of creating an interface:\npublic interface ServiceCRUD {\n\n public Object save(Object object);\n...\n}\n\n\nAnd then on my service, implement it:\n@Service\npublic class SampleService implements ServiceCRUD {\n @Autowired\n private SampleRepository repository;\n\n @Override\n public Sample save(Sample sample) {\n return repository.save(sample);\n }\n\n...\n}\n\nI haven't touched Java in a while, but if I recall correctly, every object extend Object, so why is it that I can't use Object to have the service accept all the entities I might have?\nBest regards" ]
[ "java", "spring-boot", "interface" ]
[ "Cross-Platform Mobile Application Solution", "I am developing an mobile application which can be run on mobile devices (with OS like Android, iOS, WP7...). This application will get data from online database then store them to local database in device and I can do CRUD with data. There are three ideas:\n\n\nI'll create a webservice to handle with database on host and use some cross-platform framework to building an app then connect to webservice in order to get and put data to server. Issues:\n\n\nWhich technology should I use to create webservice? (RESTful/SOAP...?)\nWhich type of return data for easy to handle? (XML/JSON...?)\nHow to sync between local database and database on host?\n\nI'll make an application for loading an external URL and build a website (with all of features that I need to work with database). Issues:\n\n\niOS, Android, WP7... accept for loading external URL in applications?\nHow to sync data like my first idea?\nShould I use single page application technology?\n\nI'll make an application using cross-platform framework and it will work with local database. I just handle syncing between local database and host database. Issue: which is the best database and best framework to do this?\n\n\nThank you" ]
[ "database", "mobile", "cordova", "cross-platform" ]
[ "how do I do the following from a shell script (run several commands at once and wait for them)?", "I want to write a shell scripts that executes a few commands and waits for all of them to terminate.\n\nI think what I would have to do is use\n\n cmd1 &\n cmd2 &\n cmd3 &\n ....\n\n\netc.\n\nbut what I don't know is how to wait for them to terminate.\n\nany ideas?" ]
[ "shell" ]
[ "How to get name of called method (added dynamically) in Python?", "I have class:\n\nclass SimpleClass:\n def __init__(self):\n pass\n\n def init_levels(self):\n levels = get_levels_list()\n for level in levels:\n Transplant(foo, Simplelog, method_name=level)\n\n\nTransplant is a class for dynamically adding methods to class:\n\nclass Transplant:\n def __init__(self, method, host, method_name=None):\n self.host = host\n self.method = method\n self.method_name = method_name\n setattr(host, method_name or method.__name__, self)\n\n def __call__(self, *args, **kwargs):\n nargs = [self.host]\n nargs.extend(args)\n return apply(self.method, nargs, kwargs)\n\n\nFoo is a function for \"transplanting\":\n\ndef foo(self):\n return\n\n\nHow can I get called method name inside foo?\n\nFor example I execute:\n\nsimpleinst = SimpleClass()\nsimpleinst.init_levels()\n\n\nHow can I modify my code for getting called method name in foo definition body?" ]
[ "python", "oop", "methods" ]
[ "Writing Simple and Efficient Database Custom ORM Code in Java", "I have a Java object that I want to store in a local in-memory database. The Object has a One-Many FK relationship, otherwise it has 20 or so Integer/String/Enumerated fields. \n\nI would like to avoid using a framework.\n\nEven though the objects themselves are not very large, there will be a large amount of these objects being inserted/updated at a high frequency (20,000 updates every 5 seconds).\n\nWhat is the simplest way to tackle this problem? What I would like is Java Object into this ORM layer, Java Object out out of this ORM layer (when queried for). I want to be able to Query for objects as well.\n\nAny Tips?" ]
[ "java", "sql", "orm", "jakarta-ee" ]
[ "strcasecmp is not returning zero", "I want to know why strcasecmp() is returning 0 the first time I use it but not the second.\n\nIn this example i'm specifically entering \"hello world\" into standard input.\nInstead of printing 0 0 it's printing 0 10. I have the following code.\n\n#include \"stdio.h\"\n#include \"string.h\"\n\nint main(void) {\n\n char input[1000];\n char *a;\n\n fgets(input, 1000, stdin);\n\n a = strtok(input, \" \");\n printf(\"%d\\n\",strcasecmp(a,\"hello\")); //returns 0 \n\n a = strtok(NULL, \" \");\n printf(\"%d\\n\",strcasecmp(a,\"world\")); //returns 10\n\n\n return 0;\n}\n\n\nWhat am I doing wrong?" ]
[ "c" ]
[ "Python missing required positional arguments. Gives nonsense location", "I'm working on a little project in Python. I set up a class that needs to have multiple initializers for convenience. Python keeps telling me I'm missing positional arguments, but I don't call the initializer anywhere where I don't explicitly pass in the right number. I tried to replicate the problem in a smaller test case, but I can't get it to do the same thing. It's a bit of code, so it's hosted at :https://gist.github.com/anonymous/6568115\n\nThe error it gives is:\n\n File \"./cards.py\", line 40, in types\n if is_subset(types, self.__class__().VALID_TYPES):\nTypeError: __init__() missing 5 required positional arguments: 'name', 'types', 'colors', 'land_type', and 'required_types'" ]
[ "python", "exception" ]
[ "Reliably extract names of R functions from a text file", "I would like to find the named functions I use frequently in my R scripts (ignoring operators such as \"+\" and \"$\" and \"[). How to write an elegant and reliable regex that matches names of functions has stumped me. Here is a small example and my clumsy code so far. I welcome cleaner, more reliable, and more comprehensive code.\n\ntest1 <- \"colnames(x) <- subset(df, max(y))\" \ntest2 <- \"sat <- as.factor(gsub('International', 'Int'l', sat))\"\ntest3 <- \"score <- ifelse(str_detect(as.character(sat), 'Eval'), 'Importance', 'Rating')\"\ntest <- c(test1, test2, test3)\n\n\nThe test object includes eight functions (colnames, subset, max, as.factor, gsub, ifelse, str_detect, as.character), and the first two twice. Iteration one to match them is:\n\n(result <- unlist(strsplit(x = test, split = \"\\\\(\")))\n [1] \"colnames\" \"x) <- subset\" \n [3] \"df, max\" \"y)\" \n [5] \"sat <- as.factor\" \"gsub\" \n [7] \"'International', 'Int'l', sat)))\" \"score <- ifelse\" \n [9] \"str_detect\" \"as.character\" \n[11] \"sat), 'Eval'), 'Importance', 'Rating')\"\n\n\nThen, a series of hand-crafted gsubs cleans the result from this particular test set, but such manual steps will undoubtedly fall short on other, less contrived strings (I offer one below).\n\n(result <- gsub(\" <- \", \" \", gsub(\".*\\\\)\", \"\", gsub(\".*,\", \"\", perl = TRUE, result))))\n [1] \"colnames\" \" subset\" \" max\" \"\" \"sat as.factor\" \"gsub\" \"\" \n [8] \"score ifelse\" \"str_detect\" \"as.character\"\n\n\nThe object, test4, below includes the functions lapply, function, setdiff, unlist, sapply, and union. It also has indenting so there is internal spacing. I have included it so that readers can try a harder situation.\n\ntest4 <- \"contig2 <- lapply(states, function(state) {\n setdiff(unlist(sapply(contig[[state]], \n function(x) { contig[[x]]})), union(contig[[state]], state))\"\n\n(result <- unlist(strsplit(x = test4, split = \"\\\\(\"))) \n(result <- gsub(\" <- \", \" \", gsub(\".*\\\\)\", \"\", gsub(\".*,\", \"\", perl = TRUE, result))))\n\n\nBTW, this SO question has to do with extracting entire functions to create a package.\nA better way to extract functions from an R script?\n\nEDIT after first answer\n\ntest.R <- c(test1, test2, test3) # I assume this was your first step, to create test.R\nsave(test.R,file = \"test.R\") # saved so that getParseData() could read it\nlibrary(dplyr)\ntmp <- getParseData(parse(\"test.R\", keep.source=TRUE))\ntmp %>% filter(token==\"SYMBOL\") # token variable had only \"SYMBOL\" and \"expr\" so I shortened \"SYMBOL_FUNCTION_CALL\"\n line1 col1 line2 col2 id parent token terminal text\n1 1 1 1 4 1 3 SYMBOL TRUE RDX2\n2 2 1 2 1 6 8 SYMBOL TRUE X\n\n\nSomething happened with all the text. What should I have done?" ]
[ "regex", "r" ]
[ "Dynamic Programming resources in C?", "I'll be writing the online Google test tomorrow as a fresher. Apparently, they definitely ask one problem on Dynamic Programming? \n\nDoes anyone know of a good resource for collection of DP problems in C along with solutions? I know what DP is & have used it on an occasion or twice. However I feel to crack a DP problem in test, prior practice of typical problems will make it easier to approach.\n\nAny good resources or problem sets with solutions in C will be highly appreciated. Thanks." ]
[ "c", "algorithm", "dynamic-programming" ]
[ "Angular Validation: Access a Form from another Form", "I have these two simple forms - \n\n<form novalidate name=\"frm1\" class=\"form-horizontal\" role=\"form\">\n <fieldset>\n <div class=\"form-group row\">\n <label for=\"sectionTxt\" class=\"control-label col-sm-2\">Section(s)</label>\n <div class=\"col-sm-2\" ng-class=\"{ 'has-error':lq.section.$error.pattern}\">\n <input type=\"text\" id=\"sectionTxt\" name=\"section\" ng-model=\"query.section\" class=\" col-sm-2 form-control\" ng-pattern=\"/^(\\d)+$/\" />\n </div>\n <div style=\"color:red\" ng-show=\"form1.section.$error.pattern\">Numbers Only Please</div>\n</fieldset>\n</form>\n\n<form novalidate name=\"frm2\" class=\"form-horizontal\" role=\"form\">\n <fieldset>\n <div class=\"form-group row\">\n <button class=\"col-sm-1 col-sm-push-8 btn btn-default\" type=\"submit\" ng-click=\"filterGrid()\" ng-disabled=\"!frm1.$error\">Search</button>\n </div>\n</fieldset>\n</form>\n\n\nForm1 is always null or falsy in form2.\n\nHow do I access form1 from form2 in the ng-disabled directive? I need to inspect whether or not form1 is valid before enabling the submit button in form2.\n\nI'd also prefer to do the validation completely in the markup and not write any JS code in the controller or directives." ]
[ "javascript", "angularjs", "forms" ]
[ "Modifying Date.prototype and binding this", "Simple task and many questions.\n\nI needed a simple way to display the week day.\nFor this the easiest way was modifying the Date.prototype as follow:\n\nDate.prototype.getWeekDay = function () {\n const weekday = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n return weekday[this.getDay()];\n}\n\n\nI know, that we generally should avoid modifying prototype. But in this case I don't think that it causes any problems. Am I right? Can I do so? Or is it considering bad coding?\n\nThe second question is regarding the binding the this in arrow functions.\nIf I modify the above function to an arrow function like this:\n\nDate.prototype.getWeekDay = () => {\n const weekday = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n return weekday[this.getDay()];\n}\n\n\nThe function doesn't work any more, because of the this keyword. I know that I have to bind this but I don't know how to do so. How should I bind this correctly?" ]
[ "binding", "prototype" ]
[ "Terminating With Uncaught Exception - Swift 2 Parse", "I am using Parse for my databases, and I just updated the parse SDKs and Xcode to version 7 with swift 2. However, now I am getting an error when the query below starts. The problem starts at the \"findobjectsinbackground\" part as the \"third\" print is not seen. Any ideas?\n\nThe Error:\n\n\n 2015-09-22 09:57:45.247 MyProject[456:133409] * Terminating app due\n to uncaught exception 'NSInternalInconsistencyException', reason:\n 'This query has an outstanding network connection. You have to wait\n until it's done.'\n * First throw call stack: (0x275d386b 0x38f86dff 0x275d37b1 0x638ac9 0x638b41 0x639bf9 0x6397bb 0x6399bf 0x2b5e78 0x2b4e94 0x2b5154\n 0x2b6e56ab 0x2b79fe97 0x2b79fd91 0x2b79f135 0x2b79ed8f 0x2b79e9dd\n 0x2b79e957 0x2b6e16bb 0x2afad67d 0x2afa8d79 0x2afa8c09 0x2afa8129\n 0x2afa7deb 0x2b6d860d 0x275960f1 0x275943e7 0x27594825 0x274e71e9\n 0x274e6fdd 0x3078baf9 0x2b74c18d 0x5fa6f4 0x396b1873) libc++abi.dylib:\n terminating with uncaught exception of type NSException\n\n\n followArray.removeAll(keepCapacity: false)\n followArray2.removeAll(keepCapacity: false)\n\n\n let followQuery = PFQuery(className: \"follow\")\n followQuery.whereKey(\"user\", equalTo: PFUser.currentUser()!.username!)\n followQuery.whereKey(\"followAproval\", equalTo: 1)\n followQuery.addDescendingOrder(\"createdAt\")\n\n var myObjects = [PFObject]()\n\n followQuery.findObjectsInBackgroundWithBlock {\n (objects:[PFObject]?, error:NSError?) -> Void in\n\n if error == nil {\n\n myObjects = objects!\n\n for object in myObjects {\n\n self.followArray.append(object.objectForKey(\"userToFollow\") as! String)\n\n }\n\n }\n }\n\n\n var myObjects2 = [PFObject]()\n\n let generalQuery = PFQuery(className: \"tweets\")\n generalQuery.addDescendingOrder(\"createdAt\")\n generalQuery.limit = 100\n\n followQuery.findObjectsInBackgroundWithBlock {\n (objects:[PFObject]?, error:NSError?) -> Void in\n\n if error == nil {\n\n myObjects2 = objects!\n\n for object in myObjects2 {\n\n self.followArray2.append(object.objectForKey(\"userName\") as! String)\n\n }\n }\n }" ]
[ "ios", "swift", "parse-platform", "swift2" ]
[ "Dynamic adding specific favicon on selection from dropdown", "Full code with + button which is calling apparance of div block above, and the <div class=\"item_socails\"> where new <li> components must be added : \n\nI have a dropdown like this : \n\n<div class=\"item_socails\">\n <ul>\n <li><i class=\"fa fa-facebook-f\"></i>\n <input value=\"laurie.lowe13\" type=\"text\">\n </li>\n <li><i class=\"fa fa-odnoklassniki\"></i>\n <input value=\"laurie.lowe1997\" type=\"text\">\n </li>\n <li><i class=\"fa fa-vk\"></i>\n <input value=\"laurie.lowe7\" type=\"text\">\n </li>\n <li>\n <button id=\"add_social_top\" class=\"dropdown-button add_social waves-effect waves-blue\" type=\"button\"><span>+</span></button>\n </li>\n </ul>\n</div>\n\n\n<div class=\"show_social\">\n <select>\n <option value=\"1\">Twitter</option>\n <option value=\"2\">LinkedIn</option>\n <option value=\"3\">Facebook</option>\n </select>\n <input class=\"txt_select\" type=\"text\" value=\"laurie.lowe13\">\n <button class=\"waves-effect waves-blue btn z-depth-1\" type=\"submit\">Add</button>\n</div>\n\n\nSo, basically user is clicking on the + button, and this div appears, where user have to select one of social networks, and in input to introduce it's link. On \"add\" submit button I want to generate a new item like \n\n<li><i class=\"fa fa-facebook-f\"></i> <input value=\"laurie.lowe13\" type=\"text\" </li>\n\n\nBasically, a new list item on a specific div, with a favicon of selected social network and an input with introduced value.\n\nHow can I achieve it ? Thanks." ]
[ "javascript", "jquery", "html", "css", "dropdown" ]
[ "Search based on value from a dropdown", "I have a project which acts as a web bookstore. I have implemented a search which at the moment, only searches books by author. What I'd like to do is enable search by author/title/something else.\n\nI have a general idea on how I think this could work, but I'm missing some pieces which is why I'm asking for advice here.\n\nHere is what I think might be a good approach:\n\n\nHave a dropdown selector in the view in which I can specify searching by author / booktitle\nThat would get passed from the view to the controller and I would be able to search by the passed in value (author / booktitle).\n\n\nI'd like to know how is it possible to implement my approach, as well as discuss \n different ideas which might work as well. Thank you for your time.\n\nBelow is the code in the controller which returns books by author that I search for, pretty simple.\n\n public IActionResult Index(string searchString)\n {\n bool hasSearchResults = false;\n var model = _bookstoreData.GetAll();\n if (!string.IsNullOrEmpty(searchString))\n {\n model = model.Where(s => s.Author.Contains(searchString));\n hasSearchResults = true;\n }\n return hasSearchResults ? View(\"SearchResult\", model) : View(model);\n }\n\n\nThis is the matching view:\n\n<form asp-controller=\"Home\" asp-action=\"Index\">\n <div class=\"container searchBar\">\n <div class=\"container searchBar\">\n <input type=\"text\" name=\"searchString\" class=\"form-control\" placeholder=\"Search books by title, author...\">\n <input type=\"hidden\" />\n </div>\n </div>\n</form>" ]
[ "c#", "asp.net", "search", "razor" ]
[ "Hour Wise data in mySql", "I have the table with following fields\n\nCreatedon(datetime)\nAmount(double)\n\n\nI need to find the sum of amounts for next 24 hours of the given date. If there are no results then the sum should be zero. \ne.g \n\nduration sum\n0000-0001 25.43\n0001-0002 36.85\n0002-0003 0\n.\n.\n.\n.\n0022-0023 38.56\n\n\nCan you please help me creating a query to find the required solution" ]
[ "mysql", "datetime", "group-by", "time-series", "aggregate-functions" ]
[ "Error when calling dynamics ax soap service method from php", "I have a PHP webapp that needs to connect to dynamics 365 ax soap services. \n\nI was given a wsdl url and from there i am trying to get the values. \n\nI used to get Forbidden error:608 now i get HTTP code 400 Bad Request \n\nI am authenticating, getting token, and passing it with my POST method\n\nPOST /soap/services/ webservice?wsdl HTTP/1.1 \nHost: domain.sandbox.ax.dynamics.com \nAccept: text/xml \nConnection:Keep-Alive \nContent-type: text/xml \nAuthorization: Bearer tokenString \nSoapaction: \"http://tempuri.org/webservice/method\" \nContent-Length lengthOfXML\n\n\nServer Response:\n\nHTTP/1.1 400 Bad Request Cache-Control: private Server:.. Strict-Transport-Security: max-age..; includeSubDomains Set-Cookie:ASP.NET_sessionId=.....;path=/;secure; HttpOnly Set-Cookie: ms-dyn-csrftoken:........ p3p: CP=\"No P3P policy defined. Read Microsoft privacy ... LinkID=271135\" .. \n\n//my XML that i pass as a curl POSTFIELD\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:i0=\"http://tempuri.org\" xmlns:wsp=\"http://www.w3.org/ns/ws-policy\" xmlns:wsap=\"http://schemas.xmlsoap.org/ws/2004/08/addressing/policy\" >\n<soap:Header>\n <CallContext xmlns=\"schemas.microsoft.com/.../datacontracts\">\n <Company>some</Company>\n <Language>en-us</Language>\n <MessageId>0</MessageId>\n <PartitionKey>286942</PartitionKey>\n </CallContext>\n</soap:Header>\n\n<soap:Body>\n <i0:nameofmethod >\n <parameter>25536</parameter>\n </i0:nameofmethod>\n</soap:Body>\n</soap:Envelope>\n\n\nI need to get some kind of value a HTTP 200 OK at least.. I should get an array of strings." ]
[ "php", "xml", "soap", "bad-request", "httpforbiddenhandler" ]