texts
sequence | tags
sequence |
---|---|
[
"Expression Encoder 4 / IIS 7 on Windows 7 - 400 Bad Request, no image in the",
"Hi I'm using Expression Encoder 4 with IIS 7 on Windows 7. I have tried the getting started guide and I'm running into a couple of problems. Here's what I did: \n\n\n1) Installed Media Services and I\nhad confirmed that it had installed\nby making sure that Live Smooth\nStreaming Publishing icon is\navailable under the Media Services\nsection in IIS 7. \nNext I installed\nExpression Encoder 4\nConnected my\nwebcam (Microsoft HD Cam\nAdded a\nsource, selected the video input as\nMicrosoft HD Cam in Expression\nEncoder\nSelected IIS H.264 preset\nfor IIS Smooth Streaming\nIn IIS\nLive Smooth Streaming... I added a\npublishing point and saved it as\nMyWork and it saved a ISML file as\nMyWork.isml in my site root\ndirectory. \nBack in Expression Encoder 4, I set the output as publishing point of : http://192.168.0.2/MyWork.isml\nThen I opened my browser and tried 192.168.0.2/MyWork.isml \n\n\nand this did not work. I received 400 Bad Request. I tried 192.168.0.2/MyWork.isml/manifest and this displayed the XML. What am I doing wrong here ?? I googled this and the only post that I've seen is an issue where the user didn't press the CUE (FYI, I had pressed the CUE and started the streaming sucessfully according to Expression Encoder 4)."
] | [
"silverlight",
"iis-7"
] |
[
"Imported classes are prefixed in Client Library",
"In Python I'm creating backend for my Android app. My code is too big so I broke it to 2 files with functions and one with shared classes (shared_classes.py) which inherit from messages.Message.\n\nWhen I generate client library, all classes get prefixed with name of the python file I stored them in (they look like: SharedClassesExampleName.java). \n\nIs it possible to force endpointscfg.py to stop generating library with prefixed python classes?"
] | [
"java",
"android",
"python",
"google-app-engine",
"google-cloud-endpoints"
] |
[
"TclTk standalone application Icon for Windows",
"I want my standalone application written in TclTk to have a custom icon, not the default blue feather. I managed to accomplish this in OSX but I cannot do it in Windows. I have created an ico file from a png file. The problem is that when I create the startpack I receive the following error:\n\ncustomizing tclkit.ico in executable\n icon 48x48/256: NOT SAME SIZE\n icon 32x32/256: NOT SAME SIZE\n icon 16x16/256: NOT SAME SIZE\n icon 0x0/256: NOT SAME SIZE\n icon 48x48/256: replaced\n icon 32x32/256: replaced\n icon 16x16/256: replaced\n\n\nAnd indeed in several cases the icon shown in Windows Explorer is the blue feather and in some cases the icon is my custom icon.\n\nI have prepared my ico file using ImageMagic like:\n\nconvert -background transparent p97-1o.png -depth 4 -colors 16 -resize 48x48 1.png\nconvert -background transparent p97-1o.png -depth 4 -colors 16 -resize 32x32 2.png\nconvert -background transparent p97-1o.png -depth 4 -colors 16 -resize 16x16 3.png\nconvert -background transparent p97-1o.png -depth 8 -colors 256 -resize 48x48 4.png\nconvert -background transparent p97-1o.png -depth 8 -colors 256 -resize 32x32 5.png\nconvert -background transparent p97-1o.png -depth 8 -colors 256 -resize 16x16 6.png\nconvert -background transparent p97-1o.png -depth 32 -colors 256 -resize 256x256 7.png\nconvert -background transparent p97-1o.png -depth 32 -colors 256 -resize 48x48 8.png\nconvert -background transparent p97-1o.png -depth 32 -colors 256 -resize 32x32 9.png\nconvert -background transparent p97-1o.png -depth 32 -colors 256 -resize 16x16 10.png\n\nconvert 1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png tclkit.ico\nrm 1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png\n\n\nThen I copy tclkit.ico to myapp.vfs/.\n\nThen I create the start pack:\n\ntclkit sdx.kit wrap myapp -runtime tclkit-8.6.3-win32-x86_64-2.exe\n\n\nI have also tried several online converter but there are still several resolutions in the ico file that are not correctly change.\n\nAny suggestions regarding how should I modify my ImageMagic conversion of the original png file so I get a proper icon file?"
] | [
"icons",
"tcl",
"tk",
"explorer"
] |
[
"updating modifying codes in ASP.NET C# project",
"I want to update an application with modified code in some files,So Is it enough to update the .dll file extension and the necessary files or Do i need to replace the whole project?"
] | [
"c#",
"asp.net"
] |
[
"Twitter4j: search for keywords within a hashtag",
"I'm working on an app using Twitter4j.\nI'm trying to import tweets with a certain hashtag (ex: weather)\nThen, I want to categorize the Tweets with that hashtag, by searching for keywords.\n\nFor example:\nSome of the Tweets imported could be\n\n- OMG, I hate this rain #weather\n- This sunshine makes me feel so happy #weather\n- Such strange #weather! One moment it rains, the next the sun shines. Confusing!\n- Rain makes me sad #weather\n- I love the sunshine! #weather\n\n\nThen, I want to categorize these tweets as:\n\n- hate, Confusing, sad,... are negative \n- happy, love,... are positive\n\n\nPositiveTweets would be:\n\n- This sunshine makes me feel so happy #weather\n- I love the sunshine! #weather\n\n\nNegativeTweets would be:\n\n- OMG, I hate this rain #weather\n- Such strange #weather! One moment it rains, the next the sun shines. Confusing!\n- Rain makes me sad #weather\n\n\nSo, NegativeTweets=3 and the PositiveTweets=2\n\nCan anyone help me with this or point me towards something similar?"
] | [
"java",
"twitter",
"filter",
"twitter4j",
"hashtag"
] |
[
"How to make a new request with $http.get every 3 seconds and get data outside function",
"I want to get some data from this page http://orbit5.ds.cs.umu.se:8888/vrio/debug/blk. the data on this page updates every time you refresh the page. So I would like to have these updated values. In order to update the values I could use $timeout but then I need to somehow get these values outside of getdata because I want to then plug these values into another function for making a chart otherwise the whole chart will keep on rendering every time the function updates. and I cannot get the values outside of the function I found this answer on stackoverflow but most of the answers as far as I understand use data from inside the function. \n\nHow can I get the updated values outside of the JavaScript function and plug them into another function? Or maybe there is another better approach to solve this problem?\n\nmy code:\n\n function getData(){\n var data;\n\n $http.get(path).then(function(response){\n data = response.data\n console.log(response.data) //works fine\n })\n return data\n}\n\nconsole.log(data)//returns undefined\n\n\nNow If I want to update the function with $timeout \n\nI would need to do something like this \n\n$timeout(getData, 3000)\n\n\nnow how can I get to these updated values? \n\nEdit:\n\nvar myData = setInterval( function(){\n $http.get(path).then(function(response){\n return response.data['Block Devices']\n })\n}, 1000 );\n\nconsole.log(myData)\n });\n\n\nreturns 14 I dont know what that is but certainly not right data"
] | [
"javascript",
"jquery",
"angularjs",
"json"
] |
[
"Map method in Ruby giving error",
"\"aaabbb\".chars.to_a.permutation.map(&:join).uniq \n\n\nworks correctly and gives the desired output which is all the words that can be formed using the given string, but the same code fails if the string is \"cdcdcdcdeeeef\" or \"cdefghmnopqrstuvw\" instead of \"aaabbb\". I just tried for these three test cases as of now out of which three fail.\n\n\"cdefghmnopqrstuvw\".chars.to_a.permutation.map(&:join).uniq \n\n\nThe above line of code just doesn't return any result. It seems like it goes into an infinite loop.\n\nWhat's going wrong?"
] | [
"ruby",
"irb",
"ruby-1.9.3"
] |
[
"Error while using postgresql on ruby on rails",
"I have installed postgresql and then I type\nrails new TravelApp --database=postgresql\nbundle install , rails s\nHowever, when I visit localhost:3000, it shows this error.\n\nShould I edit some configurations ?"
] | [
"ruby-on-rails",
"ruby",
"postgresql"
] |
[
"7-zip-JBinding usage to unzip a file",
"I have used below java code to unzip a .gz file. The .gz file contains a folder/textFile. It is working fine only if there is some data in the text file.I need it to work even if there is no data in text file. Help me with any modifications in the below java code.\n\npublic static void main(String[] args) {\n String sourceZipFile = \"C:/SKKIKRFULL20151014.gz\";\n final String destinationDir = \"C:/\";\n RandomAccessFile randomAccessFile = null;\n ISevenZipInArchive inArchive = null;\n try {\n randomAccessFile = new RandomAccessFile(sourceZipFile, \"r\");\n inArchive = SevenZip.openInArchive(null, // autodetect archive type\n new RandomAccessFileInStream(randomAccessFile));\n\n // Getting simple interface of the archive inArchive\n ISimpleInArchive simpleInArchive = inArchive.getSimpleInterface();\n\n for (final ISimpleInArchiveItem item : simpleInArchive.getArchiveItems()) {\n\n final int[] hash = new int[] { 0 };\n\n if (!item.isFolder()) {\n\n ExtractOperationResult result;\n result = item.extractSlow(new ISequentialOutStream() {\n\n public int write(final byte[] data) throws SevenZipException {\n try {\n\n if (item.getPath().indexOf(File.separator) > 0) {\n\n String path = destinationDir + File.separator\n + item.getPath().substring(0, item.getPath().lastIndexOf(File.separator));\n\n File folderExisting = new File(path);\n\n if (!folderExisting.exists()) {\n\n new File(path).mkdirs();\n }\n }\n OutputStream out = new FileOutputStream(\n destinationDir + File.separator + item.getPath());\n\n out.write(data);\n out.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n hash[0] |= Arrays.hashCode(data);\n return data.length; // Return amount of proceed data\n }\n }); \n if (result == ExtractOperationResult.OK) {\n System.out.println(String.format(\"%9X | %s\", hash[0], item.getPath()));\n } else {\n System.err.println(\"Error extracting item: \" + result);\n }\n }\n }\n } catch (Exception e) {\n e.printStackTrace();\n } finally {\n if (inArchive != null) {\n try {\n inArchive.close();\n } catch (SevenZipException e) {\n System.err.println(\"Error closing archive: \" + e);\n e.printStackTrace();\n }\n }\n if (randomAccessFile != null) {\n try {\n randomAccessFile.close();\n } catch (IOException e) {\n System.err.println(\"Error closing file: \" + e);\n e.printStackTrace();\n }\n }\n }\n}\n\n\nAs i debugged it. It is not entering the below block.\n\n result = item.extractSlow(new ISequentialOutStream() {//write() method})\n\n\nWanted to know How can i modify the code to make it work."
] | [
"java",
"unzip",
"7zip"
] |
[
"How to make fullscreen alertDialog in flutter",
"I need help to make my alert dialog fullscreen, this is the code i have so far, how can i achieve this? I dont know if its possible to define width as the screen size and height aswell.\n\n createNewMessage() {\n return showDialog(\n barrierDismissible: false,\n context: context,\n builder: (BuildContext context) {\n return StatefulBuilder(builder: (context, setState) {\n return WillPopScope(\n onWillPop: () {},\n child: Container(\n child: new AlertDialog(\n title: Column(\n children: <Widget>[\n new Text(Translations.of(context).trans('finishmessage') +\n '?'),\n Container(\n height: 20,\n ),\n DropdownButton(\n hint: new Text('Para'),\n isExpanded: true,\n onChanged: (value) {\n setState(() => selected = value);\n },\n value: selected,\n items: workers.map((worker) {\n return DropdownMenuItem(\n child: new Text(worker.vNome),\n value: worker.vCodigo,\n );\n }).toList(),\n ),\n Container(\n height: 10,\n ),\n TextField(decoration: InputDecoration(labelText: \"Data\")),\n Container(\n height: 10,\n ),\n TextField(decoration: InputDecoration(labelText: \"Hora\")),\n Container(\n height: 10,\n ),\n TextField(\n decoration: InputDecoration(labelText: 'Mensagem'))\n ],\n ),\n actions: <Widget>[\n FlatButton(\n child:\n Text(Translations.of(context).trans('sendMessage')),\n onPressed: () {}),\n FlatButton(\n child:\n Text(Translations.of(context).trans('closealert')),\n onPressed: () {\n setState(() => selected = null);\n Navigator.of(context).pop();\n }),\n ],\n )));\n });\n });\n }\n\n\nThis is the result so far:\nAlert dialog current\n\n\nThank you for your help and time"
] | [
"flutter",
"flutter-alertdialog"
] |
[
"Learning prolog - Getting error { >/2: Arguments are not sufficiently instantiated.}",
"Nrs_Between(X,Y,Nr) :-\n Z>X,\n Z<Y,\n Nr is Z.\n\n\n-------------------------*-----------------------------\n\n?- Nrs_Between(1,10,X).\n\n\nWaiting for output:\n\nZ = 2;\nZ = 3;\netc\n\n\nGetting output:\n\n>/2: Arguments are not sufficiently instantiated.\n\n\n-------------------------*-----------------------------\n\nAnyone?"
] | [
"prolog"
] |
[
"Java Server Socket Response",
"I'm trying to create a simple client/server socket communication application (chat client). I've spent countless hours looking on how to fix this with still no luck, I can send the message to the server but I'm stuck with sending the message back from the server to the client.\n\nI believe the issue is how I'm getting the message from the server after it's sent back, I deleted what I had which was an InputStreamReader which I couldn't get to work.\n\n(I apologize in advance for the sloppy code)\n\nServer.java\n\npublic class Server extends Thread {\n@SuppressWarnings(\"unused\")\nprivate static Socket socket;\nstatic int port = 1337;\nstatic ObjectOutputStream output;\n\n@SuppressWarnings(\"resource\")\npublic static void main(String[] args) throws IOException{ \n ServerSocket ss = new ServerSocket(port);\n System.out.println(\"Server started on port: \" + port);\n while(!Thread.interrupted()){\n try { \n Socket clientSocket = ss.accept();\n DataInputStream dis = new DataInputStream(clientSocket.getInputStream()); \n PrintStream output = new PrintStream(clientSocket.getOutputStream());\n String str = (String)dis.readUTF();\n String[] split = str.split(\"-\");\n String subStringUsername = split[0];\n String subStringMessage = split[1];\n Date date = new Date();\n SimpleDateFormat sdf = new SimpleDateFormat(\"h:mm:ss a\");\n String formattedTimestamp = sdf.format(date);\n System.out.println(\"Message from \" + subStringUsername + \": \" + subStringMessage + \" - at \" + formattedTimestamp);\n output.flush();\n\n output.println(\"Message received! Hello client!\");\n System.out.println(\"Reply sent\");\n output.flush();\n\n //TODO create new thread handle new users instead of Thread sleep\n //TODO chat commands and user ID / can't be existing user\n\n Thread.sleep(500);\n }\n catch(Exception e){\n System.out.println(e);\n } \n }\n}\n\n\ngetMessage.java\n\npublic class GetMessage extends Thread { \n public void run(){\n while(true) {\n InputStreamReader be = new InputStreamReader();\n }\n }\n}\n\n\nThis is what I have left of the getMessage class as I deleted everything in frustration, I'm running getMessage as a thread which I don't know is the best way or not. I've tried 10's of methods to get the message from the server with still not luck, if someone could point me in the right direction I would be greatly appreciative."
] | [
"java",
"sockets",
"client",
"serversocket"
] |
[
"Invalid text representation: 7 ERROR: invalid input syntax for uuid: \"test\"",
"I'm using Symfony 3.2 with doctrine and postgresql.\n\nI've created an entity with a uuid as primary key.\n\nMy entity definition:\n\n/**\n * Booking\n *\n * @ORM\\Table(name=\"booking\")\n * @ORM\\Entity(repositoryClass=\"AppBundle\\Repository\\BookingRepository\")\n * @ORM\\EntityListeners({\"AppBundle\\EventListener\\BookingListener\"})\n */\nclass Booking {\n /**\n * @var string\n *\n * @ORM\\Column(type=\"guid\")\n * @ORM\\Id\n * @ORM\\GeneratedValue(strategy=\"UUID\")\n */\n private $id;\n}\n\n\nIn my controller I have a show action like this:\n\n/**\n * @Route(\"booking/{id}\", name=\"booking_show\")\n * @Method({\"GET\"})\n */\npublic function showAction(Request $request, Booking $booking) {\n ...\n}\n\n\nEverything seems to work fine, but when I try to load a route putting an wrong value as an ID (i.e. /booking/hello123), I receive a:\n\nSQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for uuid: \"hello123\"\n\n\nInstead I would expect a 404.\n\nIs there a way to capture this exception and redirect to a 404 page?"
] | [
"postgresql",
"symfony",
"doctrine-orm"
] |
[
"Unable to subscribe data from the Service to component",
"I am trying to get the data from the service in to the component below is my service \n\nService.ts\n\nexport class PrjService {\n tDate: Observable<filModel[]>;\n prjData:Observable<filModel[]>;\nentityUrl;\nconstructor(){\nthis.entityUrl = 'PrjDetail/GetByRep';\n this.tDate = service.get<ShipDateFilterModel[]>(this.entityUrl);\n}\n\n\nAnd the component where I try to retrieve is like below\n\nexport class RFComponent implements OnInit {\n cachedResults: any[];\n shipToData: any;\n\nconstructor(private psService: PrjService)\n{}\n ngOnInit() {\n this.psService.tDate.subscribe(x => this.cachedResults = x);\n this.filterData = [...new Set(this.cachedResults.map(item => item.cus_name))].filter(Boolean);\n }\n\n\nHere whenever the Call to the service is made this.cachedResults is undefined and I get the error in the below like where I am trying to filter \n\n\n ERROR TypeError: Cannot read property 'map' of undefined\n\n\nNot sure what I am missing here"
] | [
"javascript",
"angular",
"typescript",
"angular7",
"angular-routing"
] |
[
"Printing a bootstrap page from Google Chrome cause (sometimes) truncation height of the printed page",
"Starting from this official template:\nhttp://getbootstrap.com/examples/jumbotron/ of bootsrap v. 3.3.7 and using Google Chrome v. 54.0.2840.99 m (64-bit), on maximized window 1920px monitor, when i try to print the page in A4 horizontal format the print preview (and the saved PDF or printed page) is height truncated.\nIn this specific case should be 2 pages height instead of 1.\nThis happened when:\n\n\nPrinting from Chrome (in Firefox v50.0.1 and IE11 the issue is not present)\nWhen the cols are not collapsed while i'm printing in screen mode (in the above boostrap example when the width of the window is greater or equal than 992px and press print. If the window is less than 992px and i press print, the print preview is not truncated)\nThe single paper height is shorten than the bootstrap page (in the above bootstrap example A4 Vertical do not reproduce the issue because there is not enough content)\n\n\nI noticed that if i remove the float:left;from all the .col-**-* the print preview does not truncate but clearly the single column template is not always suitable for printing.\n\nYou can replicate the bug also on the original bootstrap example.\nHow can I get the bootstrap grid in print mode and the printed page not truncated by Chrome?"
] | [
"css",
"google-chrome",
"twitter-bootstrap-3",
"printing",
"height"
] |
[
"Mapping factory methods with anonymous functions/delegates using Dictionary for faster lookup?",
"Currently, I have a static factory method like this:\n\npublic static Book Create(BookCode code) {\n if (code == BookCode.Harry) return new Book(BookResource.Harry);\n if (code == BookCode.Julian) return new Book(BookResource.Julian);\n // etc.\n}\n\n\nThe reason I don't cache them in any way is because BookResource is sensitive to culture, which can change between the calls. The changes to culture needs to reflect in the returned book objects.\n\nDoing those if-statements is possible a speed bottleneck. But what if we map book codes to anonymous functions/delegates? Something like the following:\n\ndelegate Book Create();\nprivate static Dictionary<BookCode, Delegate> ctorsByCode = new Dictionary<BookCode, Delegate>();\n// Set the following somewhere\n// not working!\nctorsByCode[BookCode.Harry] = Create () => { return new Book(BookResource.Harry); }\n// not working!\nctorsByCode[BookCode.Julian] = Create () => { return new Book(BookResource.Julian); } \npublic static Book Create(BookCode code) {\n return (Book)ctorsByCode[code].DynamicInvoke(null);\n}\n\n\nHow could I get those Create() => { lines to actually work?\n\nIs this worth it speed-wise, when there are <50 book codes (thus <50 if-statements)?\n\nThis is a similar question, but unfortunately the author doesn't post his code Enum, Delegate Dictionary collection where delegate points to an overloaded method\n\nUpdate\n\nDid some performance benchmarks ifs vs delegates. I picked the unit code randomly and used the same seed for both methods. The delegate version is actually slightly slower. Those delegates are causing some kind of overhead. I used release builds for the runs.\n\n5000000 iterations\nCreateFromCodeIf ~ 9780ms\nCreateFromCodeDelegate ~ 9990ms"
] | [
"c#",
".net",
"dictionary",
"anonymous-function",
"anonymous-delegates"
] |
[
"calling php code with ajax results in an error",
"I'm trying to call some php code using ajax:\n\n$(document).ready(function() {\n $(\"#email_address\").on(\"keypress\", function() {\n request = $.ajax({\n url: '../verify_email.php',\n data: {email: $(\"#email_address\").val(),\n submitted: true},\n type: 'post'\n });\n\n request.done(function(response) {\n //fooling around to see if this works\n if(response) {\n alert(\"valid email\");\n } else {\n alert(\"invalid email\");\n }\n });\n\n request.error(function(response) {\n alert(\"an error occurred\");\n });\n });\n});\n\n\nHowever, the request.error function runs. I'm not too sure why. Here is the php code:\n\n<?php\n if(isset($_POST['submitted']) and isset($_POST['email'])) {\n if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {\n echo 'true';\n } else {\n echo 'false';\n }\n }\n?>\n\n\nThanks in advance."
] | [
"php",
"jquery",
"ajax"
] |
[
"Why is constructor of a grand parent deleted in this case?",
"The compiler is complaining the constructor of D is deleted because of ill forming why ?\n\n#include<iostream>\nusing namespace std;\n\nclass A\n{\n int x;\n public:\n A(int i) { x = i; }\n void print() { cout << x; }\n};\n\nclass B: virtual public A\n{\n public:\n B():A(10) { }\n};\n\nclass C: virtual public A \n{\n public:\n C():A(10) { }\n};\n\nclass D: public B, public C {\n};\n\nint main()\n{\n D d;\n d.print();\n return 0;\n}\n\n\nOutput\n\n\n main.cpp:37:4: error: use of deleted function 'D::D()' D d;\n ^ main.cpp:32:7: note: 'D::D()' is implicitly deleted because the default definition would be ill-formed: class D: public B, public C {\n ^"
] | [
"c++",
"multiple-inheritance"
] |
[
"Can we pass the beanshell assertion variable (in a thread) to cookie manager user defined variable (outside the thread) in jmeter?",
"Can we pass the beanshell assertion variable (in a thread) to cookie manager user defined variable (outside the thread) in jmeter ?\n\nThis is the image of user defined cookies which are been used on my request\n\n\nThis is bean shell variable"
] | [
"jmeter",
"session-cookies",
"assertions",
"beanshell"
] |
[
"Get last commit for every file of a file list in Mercurial",
"I have an hg repository and I would like to know the last commit date of every file in sources/php/dracca/endpoint/wiki/**/Wiki*.php\n\nSo far, I have this one liner:\n\nfind sources/php/dracca/endpoint/wiki/ -name \"Wiki*.php\" -exec hg log --limit 1 --template \"{date|shortdate}\" {} \\; -exec echo {} \\;\n\n\nBut this seems utterly slow as (I suppose) find makes 1 hg call per file, leading to 15seconds of computation for the (say) ~40 files I have in there...\n\nIs there a faster way?\n\nThe output of this command looks like:\n\n2019-09-20 sources/php/dracca/endpoint/wiki/characters/colmarr/WikiCharactersColmarrEndpoint.php\n2019-09-20 sources/php/dracca/endpoint/wiki/characters/dracquints/allgroup/WikiCharactersDracquintsAllgroupEndpoint.php\n...\n\n\nIt might be changed a bit if needed (I won't mind having, say, 1 date and then the list of files changed for that date, or whatever like this)"
] | [
"find",
"mercurial"
] |
[
"Deploy to only one role / server with capistrano",
"I'm trying to set up multiple roles, one for live, and another for dev. They look like this:\n\nrole :live, \"example.com\"\nrole :dev, \"dev.example.com\"\n\n\nWhen I run cap deploy, however, it executes for both servers. I've tried the following and it always executes on both. \n\ncap deploy live\ncap ROLE=live deploy\n\n\nWhat am I missing? I know I can write a custom task that only responds to one role, but I don't want to have to write a whole bunch of tasks just to tell it to respond to one role or another. Thanks!"
] | [
"ruby",
"capistrano"
] |
[
"EditText in ListView is updated by onTextChanged when scrolling",
"I have been searching for an answer to this, but the solutions don't seem to work for me. I have a TextView and an EditText in a list item. I am trying to update the stored values for the EditTexts when the user edits them.\n\n@Override\npublic View getView(int index, View convertView, ViewGroup parent) {\n ViewHolder holder = null;\n final int pos = index;\n if (convertView == null) {\n convertView = mInflater.inflate(R.layout.user_details_list_row, parent,false);\n holder = new ViewHolder();\n holder.mCaptionTextView = (TextView)convertView.findViewById(id.user_detail_row_caption);\n holder.mDetailEditText = (EditText)convertView.findViewById(id.user_detail_row_value);\n convertView.setTag(holder);\n }else{\n holder = (ViewHolder) convertView.getTag();\n }\n\n holder.mDetailEditText.addTextChangedListener(new TextWatcher() {\n @Override\n public void onTextChanged(CharSequence s, int start, int before, int count) {\n }\n\n @Override\n public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {\n // TODO Auto-generated method stub\n\n }\n\n @Override\n public void afterTextChanged(Editable s) { \n mUserDetails.set(pos, s.toString());\n }\n }); \n\n holder.mCaptionTextView.setText(mUserCaptions.get(index));\n holder.mDetailEditText.setText(mUserDetails.get(index),BufferType.EDITABLE);\n\n return convertView;\n}\n\npublic static class ViewHolder{\n public TextView mCaptionTextView;\n public EditText mDetailEditText;\n}\n\n\nWhen I do this, scrolling triggers the TextWatcher and updates the values, overwriting correct text with duplicate text from one of the other EditTexts.\n\nInstead of a TextWatcher, I've also tried this code:\n\nholder.mDetailEditText.setOnFocusChangeListener(new OnFocusChangeListener() {\n\n@Override\npublic void onFocusChange(View v, boolean hasFocus) {\n if (!hasFocus){\n EditText et = (EditText)v.findViewById(id.user_detail_row_value);\n mUserDetails.set(index, et.getText().toString().trim());\n }\n}\n});\n\n\nAnd it also updates the wrong EditTexts. What am I missing here?\n\nEdit: Also tried this:\n\n final ViewHolder testHolder = holder; \n holder.mDetailEditText.setOnFocusChangeListener(new OnFocusChangeListener() {\n\n @Override\n public void onFocusChange(View v, boolean hasFocus) {\n if (!hasFocus){\n EditText et = (EditText)v.findViewById(id.user_detail_row_value);\n mUserDetails.set(testHolder.ref, et.getText().toString().trim());\n }\n }\n });\n\n\nIt corrects the scrolling change issue I was seeing, but now after editing one of the EditTexts, it changes a bunch of the others as well."
] | [
"android",
"android-listview",
"android-edittext"
] |
[
"Mongoid: (Replication) configuration file yml not loaded",
"development:\n hosts: [[database_1.mongolab.com, 12345], [database_2.mongolab.com, 12345]]\n database: database_name\n username: database_user\n password: database_pass\n persist_in_safe_mode: true\n raise_not_found_error: false\n\n\nThis configuration file (config/mongoid.yml) is loaded using :\n\nMongoid.load!(\"config/mongoid.yml\")\n\n\nBut I get this error :\n\nMongo::ConnectionFailure at /\nFailed to connect to a master node at localhost:27017"
] | [
"ruby",
"mongodb",
"sinatra",
"mongoid",
"yaml"
] |
[
"Sum the value of array in hash",
"This is my array\n\n[{:amount=>10, :gl_acct_id=>1, :alt_amount=>20}, {:amount=>20, :gl_acct_id=>2\n, :alt_amount=>30}]\n\n\ni want result \n\n[{:amount => 30}] or {:amount = 30}\n\n\nAny idea?"
] | [
"ruby",
"hash"
] |
[
"Add rows with td indexes considering thead and tbody",
"I'm trying to create a toolbar to modify the table table_content_inv. \n\nColumn management works, but it is the rows that cause me problems, whether it is adding or removing. It is because I specify a thead and a tbody which cause troubles with indexes. When I select an element of thead (row index 0), it will be added to the tbody (row index 0) - I know it's me who specified it but I don't know how to proceed.\n\nI get the indexes of the tds with the function .index() without managing if the element is in thead or tbody. \nShould I change the way I retrieve the indexes (or something else) from the td elements or somehow add the fact that it's either the element is in thead or tbody?\n\n\r\n\r\n//set selected row\r\nvar rowIndex = '';\r\n$(document).on('click', '#table_content_inv td', function() {\r\n rowIndex = $(this).closest('tr').index();\r\n});\r\n\r\n//delete selected row \r\n$(document).on('click', '#button_del_row', function() {\r\n $('#table_content_inv > tbody > tr').eq(rowIndex).remove();\r\n});\r\n\r\n//add row to table\r\n$(document).on('click', '#button_add_row', function() {\r\n var indexNewRow = rowIndex + 1;\r\n var newRow = '<tr>';\r\n\r\n var colCount = document.getElementById('table_content_inv').rows[0].cells.length;\r\n for (i = 0; i < colCount; i++) {\r\n newRow += '<td>new entry</td>';\r\n }\r\n newRow += '</tr>';\r\n\r\n $('#table_content_inv > tbody > tr').eq(rowIndex).after(newRow);\r\n});\r\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\r\n<table id=\"table_content_inv\">\r\n <thead>\r\n <tr>\r\n <td>entry</td>\r\n <td>entry</td>\r\n <td>entry</td>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr>\r\n <td>entry</td>\r\n <td>entry</td>\r\n <td>entry</td>\r\n </tr>\r\n <tr>\r\n <td>entry</td>\r\n <td>entry</td>\r\n <td>entry</td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n<div id=\"toolbar-content\" class=\"toolbar-content\">\r\n <button id=\"button_add_row\" class=\"button button-secondary\" type=\"button\">Ajout ligne</button> \r\n <button id=\"button_del_row\" class=\"button button-secondary\" type=\"button\">Supprimer ligne</button>\r\n</div>"
] | [
"jquery"
] |
[
"MySQL query to get last N failed payments",
"My database has two tables: users and payments. There is a one to many relationship between users and payments: each user can have o or more payments and a payment belongs to a user. Also, each payment can be successful or failed.\n\nI need to write a query to get all the users who failed exactly the last N payments.\n\nI've found this query, that allows to all users with N or more payments (in this example, 4 or more):\n\nSELECT x.user_id, count(*) as cnt \nFROM (\n SELECT a.user_id, a.date, a.status FROM payment AS a WHERE \n (SELECT COUNT(*) FROM payment AS b \n WHERE b.user_id = a.user_id AND b.date >= a.date) <= 4 \n ORDER BY a.user_id ASC, a.date DESC) AS x \nWHERE x.status = 'failed' \nGROUP BY x.user_id\nHAVING cnt >=4;\n\n\nBut I cannot make it work for an exact number (in this example, exactly 4).\n\nThe structure of the tables is:\n\n\nusers: id, name, email, password, created_at, updated_at\npayments: id, date (the date they payment belongs to), status (success, failed), user_id, created_at, updated_at\n\n\nAn example:\n\nThis sqlfiddle might help to understand what I need. It should return only user 4 (which is the user with the exactly the latest 4 payments failed but is also returning user 5 (which has 5 failed payments).\n\nDDLs of same:\n\nCREATE TABLE users\n (`id` int, `name` varchar(6), `email` varchar(7), `password` varchar(10), `created_at` timestamp, `updated_at` timestamp)\n;\n\nINSERT INTO users\n (`id`, `name`, `email`, `password`)\nVALUES\n (1, 'name 1', 'email 1', 'password 1'),\n (2, 'name 2', 'email 2', 'password 2'),\n (3, 'name 3', 'email 3', 'password 3'),\n (4, 'name 4', 'email 4', 'password 4'),\n (5, 'name 5', 'email 5', 'password 5')\n;\n\n\nCREATE TABLE payments\n (`id` int, `date` varchar(10), `status` varchar(7), `user_id` int ,`created_at` timestamp, `updated_at` timestamp)\n;\n\nINSERT INTO payments\n (`id`, `date`, `status`, `user_id`)\nVALUES\n (1, '2019-01-01', 'success', 1),\n (2, '2019-01-01', 'failed', 2),\n (3, '2019-01-01', 'failed', 3),\n (4, '2019-01-01', 'success', 4),\n (5, '2019-01-01', 'success', 5),\n (6, '2019-01-02', 'success', 1),\n (7, '2019-01-02', 'success', 2),\n (8, '2019-01-02', 'success', 3),\n (9, '2019-01-02', 'success', 4),\n (10, '2019-01-02', 'success', 5),\n (11, '2019-01-03', 'success', 1),\n (12, '2019-01-03', 'failed', 2),\n (13, '2019-01-03', 'success', 3),\n (14, '2019-01-03', 'failed', 4),\n (15, '2019-01-03', 'failed', 5),\n (16, '2019-01-04', 'success', 1),\n (17, '2019-01-04', 'failed', 2),\n (18, '2019-01-04', 'failed', 3),\n (19, '2019-01-04', 'failed', 4),\n (20, '2019-01-04', 'failed', 5),\n (21, '2019-01-05', 'success', 1),\n (22, '2019-01-05', 'failed', 2),\n (23, '2019-01-05', 'failed', 3),\n (24, '2019-01-05', 'failed', 4),\n (25, '2019-01-05', 'failed', 5),\n (26, '2019-01-06', 'success', 1),\n (27, '2019-01-06', 'success', 2),\n (28, '2019-01-06', 'failed', 3),\n (29, '2019-01-06', 'failed', 4),\n (30, '2019-01-06', 'failed', 5),\n (31, '2019-01-07', 'failed', 5)\n;"
] | [
"php",
"mysql"
] |
[
"Cloudformation KeyValuePair List as a parameter",
"When creating ECS infrastructure we describe our Task Definitions with CloudFormation. We want to be able to dynamically pass environment variables as a parameter to the template. According to the docs, Environment has a KeyValuePair type, but CloudFormation parameters do not have this type.\nWe can not hardcode Environment variables to the template, because this template is used as a nested stack so environment variables will be dynamically passed inside it.\n\nThe only possible way I see so far is to pass all arguments as a CommaDelimitedList, and then somehow parse and map it using CloudFormation functions. I can Fn::Split every entity in key and value, but how to dynamically build an array of KeyValuePair in CloudFormation? \n\nOr maybe there is an easier way, and I'm missing something? Thanks in advance for any ideas."
] | [
"amazon-web-services",
"amazon-cloudformation",
"amazon-ecs"
] |
[
"ng-bind-html content invisible issue in Angularjs",
"I used ng-bind-html like this\n\n<p ng-bind-html=\"{{content.content}}\">\n</p>\n\n\nbut it didn't appear. But when I inspect, they are there. How come? It's not css issue."
] | [
"javascript",
"angularjs"
] |
[
"Neither user 10004 nor current process has android.permission.READ_PHONE_STATE",
"java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ultraliant.brandcommunity.jaijinendra/com.ultraliant.brandcommunity.jaijinendra.EmailActivity}: java.lang.SecurityException: getDeviceId: Neither user 10004 nor current process has android.permission.READ_PHONE_STATE.\n at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)\n at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)\n at android.app.ActivityThread.access$1100(ActivityThread.java:221)\n at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)\n at android.os.Handler.dispatchMessage(Handler.java:102)\n at android.os.Looper.loop(Looper.java:158)\n at android.app.ActivityThread.main(ActivityThread.java:7225)\n at java.lang.reflect.Method.invoke(Native Method)\n at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)\n at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)\nCaused by: java.lang.SecurityException: getDeviceId: Neither user 10004 nor current process has android.permission.READ_PHONE_STATE.\n at android.os.Parcel.readException(Parcel.java:1620)\n at android.os.Parcel.readException(Parcel.java:1573)\n at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:5371)\n at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:812)\n at com.ultraliant.brandcommunity.jaijinendra.EmailActivity.doPermissionGrantedStuffs(EmailActivity.java:198)\n at com.ultraliant.brandcommunity.jaijinendra.EmailActivity.loadIMEI(EmailActivity.java:103)\n at com.ultraliant.brandcommunity.jaijinendra.EmailActivity.onCreate(EmailActivity.java:67)\n at android.app.Activity.performCreate(Activity.java:6876)\n at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)\n at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)\n ... 9 more"
] | [
"android-studio"
] |
[
"How to load a Java class dynamically on android/dalvik?",
"I'm wondering if and how one can load dex or class files dynamically \nin dalvik, some quick'n'dirty test function I wrote was this: \n\n public void testLoader() { \n InputStream in; \n int len; \n byte[] data = new byte[2048]; \n try { \n in = context.getAssets().open(\"f.dex\"); \n len = in.read(data); \n in.close(); \n DexFile d; \n Class c = defineClass(\"net.webvm.FooImpl\", data, 0, len); \n Foo foo = (Foo)c.newInstance(); \n } catch (IOException e1) { \n // TODO Auto-generated catch block \n e1.printStackTrace(); \n } catch (IllegalAccessException e) { \n // TODO Auto-generated catch block \n e.printStackTrace(); \n } catch (InstantiationException e) { \n // TODO Auto-generated catch block \n e.printStackTrace(); \n } \n } \n\n\nwhereas the Foo interface is this \n\n public interface Foo { \n int get42(); \n } \n\n\nand f.dex contains some dx'ed implementation of that interface: \n\n public class FooImpl implements Foo { \n public int get42() { \n return 42; \n } \n } \n\n\nThe above test driver throws at defineClass() and it doesn't \nwork and I investigated the dalvik code and found this: \n\nhttp://www.google.com/codesearch/p?hl=en#atE6BTe41-M/vm/Jni.c&q=Jni.c... \n\nSo I'm wondering if anyone can enlighten me if this is possible in \nsome other way or not supposed to be possible. If it is not possible, \ncan anyone provide reasons why this is not possible?"
] | [
"java",
"android",
"classloader",
"dalvik"
] |
[
"Best practice for checking data types at runtime objective-c",
"I have JSON data being provided to my application but unfortunatly it is not very well formed. Sometimes I am getting String representations of numbers when I am expecting numbers.\n\nFor some reason some values may have a prefix of whitespace. \n\nWhat is the best way to deal with this? Currently I am forced to check the types via 'isKindOfClass' but having recently worked mainly on python applications this seems awkward.\n\nCan anyone recommend a better way to do this? I am fully aware that @try,@catch etc are not useful in this situation.\n\nThanks for your help guys, I know this question is being flagged as subjective but I would appreciate some input!\n\nJ"
] | [
"iphone",
"objective-c",
"json",
"types"
] |
[
"Add an object from another class to a JPanel",
"Ok i have a JPanel such as this one :\n\npublic class GUI {\nJFrame frame = new JFrame(\"Net\");\n\nJPanel panel = new JPanel();\npublic GUI()\n{\nframe.setSize(835,650);\nframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);\nframe.setVisible(true); \nframe.add(panel);\npanel.setSize(600,600);\npanel.setLocation(215,5);}\n\n\nThere are some other panels in there tables etc. My main is this one :\n\npublic static void main(String[] args) {\n\n SwingUtilities.invokeLater(new Runnable(){ \n @Override\n public void run(){\n //new GUI();\n new GUI().buildTable();\n\n }\n\n });\n\n\nAnd there i another class this one :\n\npublic class DrawPlanes extends GUI \n{ \n\nprivate static int centreX, centreY, radius;\nprivate Color colour;\n\npublic DrawPlanes()\n{\ncentreX = 300;\ncentreY = 300;\nradius = 200;\ncolour = Color.BLACK;\n}\n\npublic DrawPlanes(int centreX,int centreY, int radius, Color colour)\n{\nthis.centreX = centreX;\nthis.centreY = centreY;\nthis.radius = radius;\nthis.colour = colour;\n\n}\n\n@Override\nprotected void paintComponent(Graphics g)\n{\n\n super.paintComponent(g);\n System.out.println(\"ppp\");\n Graphics2D g2D = (Graphics2D) g; \n g2D.setStroke(new BasicStroke(2F)); \n g.setColor(Color.BLACK);\n g.drawOval(centreX - radius , centreY - radius, radius * 2 , radius * 2);\n ......\n }\n }\n\n\nNow i cant add this class to my panel i tried creating an object in main and then adding the object to my panel. I ve also tried \n\npanel.add(new DrawPlanes(int x, int y, int radius,Color colour));\n\n\nbut it didnt get the drawing added in the panel.Any suggestions?"
] | [
"java",
"swing",
"class",
"jpanel",
"draw"
] |
[
"App crashing from ipa file but run from xcode",
"My app is crashing from ipa file. This is my console log. I am using firebase in this project? I can not figure out the problem. Is it arising for firebase or other causes? \n\nVersion: 3.5 (3.5)\nCode Type: ARM-64 (Native)\nRole: Foreground\nParent Process: launchd [1]\n\n\nDate/Time: 2018-05-07 14:00:50.9291 +0600\nLaunch Time: 2018-05-07 14:00:50.7374 +0600\nOS Version: iPhone OS 11.2.1 (15C153)\nBaseband Version: 4.30.02\nReport Version: 104\n\nException Type: EXC_CRASH (SIGABRT)\nException Codes: 0x0000000000000000, 0x0000000000000000\nException Note: EXC_CORPSE_NOTIFY\nTriggered by Thread: 0\n\nApplication Specific Information:\nabort() called\n\nFiltered syslog:\nNone found\n\nLast Exception Backtrace:\n0 CoreFoundation 0x1823be364 __exceptionPreprocess + 124\n1 libobjc.A.dylib 0x181604528 objc_exception_throw + 55\n2 CoreFoundation 0x1823be2ac +[NSException raise:format:] + 115\n3 Photo 0x1049f62e0 _h`enter code here`idden#57437_ + 171\n4 Photo 0x1049f60a4 _hidden#57435_ + 383\n5 Photo 0x1049f5e44 _hidden#57433_ + 359\n6 CoreFoundation 0x18235033c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 19\n7 CoreFoundation 0x18234f8dc _CFXRegistrationPost + 419\n8 CoreFoundation 0x18234f640 ___CFXNotificationPost_block_invoke + 59\n9 CoreFoundation 0x1823cd024 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1407\n10 CoreFoundation 0x182285f60 _CFXNotificationPost + 379\n11 Foundation 0x182cb3348 -[NSNotificationCenter postNotificationName:object:userInfo:] + 67\n12 Photo 0x104973d30 _hidden#53366_ + 387\n13 Photo 0x104972bdc _hidden#53351_ + 287\n14 Photo 0x104972a10 _hidden#53349_ + 391\n15 Photo 0x1047056e8 _hidden#31344_ + 3348200 (__hidden#31777_:205)\n16 UIKit 0x18b90e37c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 383\n17 UIKit 0x18baffc58 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3435\n18 UIKit 0x18bb04aa8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1711\n19 UIKit 0x18bda02d4 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 799\n20 UIKit 0x18c07812c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 159\n21 UIKit 0x18bd9ff38 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 251\n22 UIKit 0x18bda0798 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 731\n23 UIKit 0x18c5257d0 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 259\n\n\nHow to solve this problem. Please help."
] | [
"crash",
"ipa"
] |
[
"How to cancel event from onstart Javascript call",
"How can I cancel event from onstart javascript function?\n\nI've tried this, but the event is not canceled. Button code:\n\n<p:commandButton id=\"cmbtInsertar\" value=Insertar\"\n onstart=\"return verificarNulidad();\"\n</p:commandButton>\n\n\nand the function code:\n\nfunction verificarNulidad() \n{ \n puedeInsertar = true;\n\n var frm = document.getElementById(\"formInicio\");\n\n for (var i=0; i<frm.elements.length;i++)\n { \n if((frm.elements[i].id.indexOf(\"XX\") != -1 || frm.elements[i].id.indexOf(\"XX\") != '-1') && (frm.elements[i].id.indexOf(\"focus\") == -1 || frm.elements[i].id.indexOf(\"focus\") == '-1')) \n {\n var nombreCampo = (frm.elements[i].id.substring(frm.elements[i].id.indexOf(\"_\")+1)).replace('_input','');\n\n if(frm.elements[i].value == null || frm.elements[i].value.trim == '' )\n {\n alert('El Campo '+nombreCampo+' no puede estar en blanco');\n puedeInsertar = false;\n frm.elements[i].focus;\n break; \n }\n else if(frm.elements[i].value == '0' || frm.elements[i].value == 0 || frm.elements[i].value == '-1' || frm.elements[i].value == -1)\n {\n alert('El Campo '+nombreCampo+' no puede ser cero');\n puedeInsertar = false;\n frm.elements[i].focus;\n break;\n }\n } \n }\n return puedeInsertar; \n}"
] | [
"javascript",
"jsf",
"primefaces"
] |
[
"MATLAB: Error using symbol array in my system of ODEs",
"syms L(t) [1 n];\nsyms M(t) [1 n];\nsyms massbal_tray [1 n];\nmassbal_tray(1) = diff(M(1),t) == L(2)-L(1);\n\nI want to use the above code so I can create a system with n ODEs, but I need to treat the first equation differently. I plan to do the rest in a for loop. However I'm getting an error and can't isolate the problem:\n\nUnable to perform assignment because the left and right sides have a\ndifferent number of elements.\nError in sym/privsubsasgn (line 1151)\n\n\n L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);\n\nError in sym/subsasgn (line 972)\n\n\n C = privsubsasgn(L,R,inds{:});\n\nError in msche_dist (line 28)\nmassbal_tray(1) = diff(M(1),t) ==\n> L(2)-L(1);"
] | [
"matlab",
"system",
"symbols",
"ode"
] |
[
"Asyncio: keep multiple coroutines running",
"I have multiple coroutines which need to be running (forever) at the same time. For error handling one of the routines occasionally ends and needs to be respawned and I use the following code, which however assumes that it is coroutine1 that needs restarting.\n\npending = {coroutine1(), coroutine2()}\nwhile True:\n a = asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)\n done, pending = loop.run_until_complete(a)\n pending = pending | {coroutine1()}\n\n\nHow can I solve this in a better and more general way?"
] | [
"python",
"python-3.x",
"python-asyncio"
] |
[
"ASP MVC 1.0 - Throwing 404 error from Controller so Web Crawlers will stop indexing",
"Having Issues trying to throw a 404 error page in MVC 1 from a Controller so that the page actually comes up as page not found. How would I go about doing this?"
] | [
"asp.net",
"asp.net-mvc",
"vb.net"
] |
[
"jQuery UI draggable revert",
"I have 4 tables generated dynamically. There is two divs in each cell (td). All the divs are droppable. I dont know why but only the 2nd div accepts the draggable, the first one reverts it. There is no different between the two divs (exepts one has a \"dotted\" class).\n\nHere is the jsbin:\nhttp://jsbin.com/OMIbOGU/22/edit\n\nJS\n\n$(\"document\").ready(function(){\n\n function init(){\n var table = $(\"<table></table>\");\n $(\"body\").append(table);\n for(var i=0 ;i < 9; i++){\n var row = $(\"<tr></tr>\");\n var cell = $(\"<td></td>\");\n for(var j = 0;j<2;j++){\n var slot = $(\"<div></div>\").addClass('slot');\n\n slot.droppable({\n accept: \".unassigned\"\n });\n\n if (j!==1)\n slot.addClass(\"dotted\");\n cell.append(slot);\n }\n row.append(cell); \n table.append(row);\n\n }\n\n $(\".unassigned\").draggable({\n revert: \"invalid\",\n snap: \"td div\"\n });\n }\n for(var i = 0 ; i<4;i++)\n init();\n});"
] | [
"jquery-ui",
"draggable",
"jquery-ui-droppable"
] |
[
"Can the preprocessor tell if SystemVerilog is enabled?",
"I'd like to be able to write code like this:\n\n`ifdef SYSTEMVERILOG_ENABLED\n .. systemverilog code here.\n`else\n .. verilog-2001 equivalent code here.\n`endif\n\n\nBut the SystemVerilog reference manual doesn't seem to reference any such standard predefined constant. This seems like an oversight -- is there a simple way to do what I intend here?"
] | [
"verilog",
"system-verilog"
] |
[
"Material UI: Why does my select update the state, but not display the selected value",
"As many of my select options are very similar to each other, I tried to create a single component for them. I read that I have to forward the refs, so I did this, and now I do not have any error messages anymore and my state is being updated correctly after the selection. \n\nThe only thing which does not update is the select field, which always display empty.\n\nDropdown.js\n\nimport { Select } from \"@material-ui/core\";\nimport CustomOption from \"./CustomOption\";\n\nclass Dropdown extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n selection: 0\n };\n }\n\n handleChange = name => event => {\n console.log(event.target.value);\n switch (name) {\n // More cases\n default:\n this.setState({ [name]: event.target.value });\n break;\n }\n };\n\n render = () => {\n return (\n <>\n <Select\n value={this.state.selection}\n onChange={this.handleChange(\"selection\")}\n >\n <CustomOption text=\"A\" value={0} testValue={2} />\n <CustomOption text=\"B\" value={1} testValue={2} />\n <CustomOption text=\"C\" value={2} testValue={1} />\n <CustomOption text=\"D\" value={3} testValue={2} />\n </Select>\n <br />\n <br />\n {this.state.selection}\n </>\n );\n };\n}\n\nexport default Dropdown;\n\n\nCustomOption.js\n\nimport React from \"react\";\nimport { ListItemText, MenuItem } from \"@material-ui/core\";\n\nconst DropdownEntry = React.forwardRef((props, ref) => {\n if (props[\"data-value\"] > props.testValue) {\n return (\n <MenuItem disabled ref={ref} {...props}>\n <ListItemText>{props.text}</ListItemText>\n </MenuItem>\n );\n }\n\n // User may select this option\n return (\n <MenuItem ref={ref} {...props}>\n <ListItemText>{props.text}</ListItemText>\n </MenuItem>\n );\n});\n\nexport default DropdownEntry;\n\n\n\nCodesandbox: https://codesandbox.io/s/us4ml"
] | [
"javascript",
"reactjs",
"material-ui"
] |
[
"Easiest way to convert month name to month number in JS ? (Jan = 01)",
"Just want to covert Jan to 01 (date format)\n\nI can use array() but looking for another way...\n\nAny suggestion?"
] | [
"javascript",
"date"
] |
[
"How to fetch user using the TrueVault API",
"I'm trying to fetch a user from the TrueVault API using curl.\n\nI've been using the following curl command (as per the documentation):\n\ncurl https://api.truevault.com/v2/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx7ce \\\n -X GET \\\n -u API_KEY:\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx461\"\n\n\nThe credentials:\n\nuser_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx7ce\napi key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx461 \n\n\nEvery time I send the request I'm getting an error:\n\n\"error\": {\n \"code\": \"AUTH.UNSUCCESSFUL\",\n \"message\": \"Authentication Failure.\",\n \"type\": \"invalid_request_error\"\n},\n\"result\": \"error\",\n\"transaction_id\": \"xxxxxxxx-xxxx-xxxx-xxxx-3ba883e31f99\"\n\n\nSo I wanted to check if maybe I'm doing wrong or might be something else.\n\nThis user has all permissions (Create, Read, Update, Delete)."
] | [
"truevault"
] |
[
"Dot character cancels completion in Sublime Text plugin",
"I'm working on a Sublime Text 3 plugin, which contains a number of completions for the standard library. Some of these functions (e.g. io.open( filename, mode )) contain the dot character (\".\").\n\nThe problem is, Sublime Text cancels the completion dialog when a \".\" is typed (word boundary).\n\nTo get around this, I've tried using underscores instead of dots in the triggers:\n\n{\"trigger\": \"io_open( filename, mode )\", \"contents\": \"io.open( ${1:filename}, ${2:mode} )\"}\n\n\nHowever, this doesn't work very well at all. If the user tries to type in io.open instead of io_open, Sublime restarts the completion at the dot, and they end up with io.io.open.\n\nIs there any way around this? Having the dot character as word boundary is useful for selecting text, so I'd like to keep that if it is possible."
] | [
"regex",
"sublimetext3",
"sublime-text-plugin"
] |
[
"iOS - SQLite not updating but prepare and step are successfully executing",
"The title is pretty much all the information I have because I cannot find an issue with the code. The same instance of database that is being used in the code below is able to successfully insert, delete and select, but this function does not work. No error code is retured(Always 0), and the program continues to run nominally after executing this function. \n\nHere is the table information:\n\nreminder (uniqueID integer primary key autoincrement, title text not null, details text, time integer)\n\n\nCode in question: \n\n- (void) updateEntryData:(ReminderData *)data\n{\n sqlite3_stmt *statement; \n char *updateCommand = \"UPDATE reminder SET title = '?', details = '?', time = ? WHERE uniqueID = ?\";\n\n int e = sqlite3_prepare_v2(database, updateCommand, -1, &statement, nil);\n if(e != SQLITE_OK) {\n NSLog(@\"Problem with updateEntryWithUniqueID\");\n NSLog(@\"Error Code: %d, message '%s'\", e, sqlite3_errmsg(database));\n return;\n }\n\n sqlite3_bind_text(statement, 1, [data.title UTF8String], -1, SQLITE_TRANSIENT);\n sqlite3_bind_text(statement, 2, [data.details UTF8String], -1, SQLITE_TRANSIENT); \n sqlite3_bind_int(statement, 3, [data.time timeIntervalSince1970]);\n sqlite3_bind_int(statement, 4, data.uniqueID);\n NSLog(@\"\\nID: %d\\nTitle: %@\\nDetails: %@\\nTime: %@\", data.uniqueID, data.title, data.details, data.time);\n\n if(sqlite3_step(statement) != SQLITE_DONE) {\n NSLog(@\"Problems updating entry in reminder\");\n }\n\n /* Finished */ \n sqlite3_finalize(statement);\n}\n\n\nAny help would be greatly appreciated; I am stumped. \n\nEdit: Forgot to mention that the sql command used works when entered into the sqlite console."
] | [
"objective-c",
"ios",
"sql",
"sqlite"
] |
[
"How to select only nodes that are not only spaces using Nokogiri?",
"I have the following XML document:\n\n<w:p w14:paraId=\"572705D7\" w14:textId=\"77777777\" w:rsidP=\"00CA0169\" w:rsidR=\"00CA0169\" w:rsidRDefault=\"00CA0169\" w:rsidRPr=\"00777A35\">\n <w:r>\n <w:t xml:space=\"preserve\"/>\n </w:r>\n <w:r>\n <w:t>synthesized in cyanobacteria under unsuitable condition</w:t>\n </w:r>\n</w:p>\n\n\nI currently select all nodes that begin with as follows:\n\ntext_nodes = p.xpath('w:r')\n\n\nHowever, I would like to select only those text nodes that contain text and are not only spaces as the first node is as shown in the xml sample above.\n\nI have extended the String Class to test for spaces as follows:\n\nclass String\n def spaces?\n x = self =~ /^\\s+$/\n x == 0\n end\nend\n\n\nSo I can do:\n\nelement.text.spaces?\n\n\nI just don't know how to put it together with the p.xpath('w:r')to select only nodes that are NOT only spaces."
] | [
"ruby",
"xpath",
"nokogiri"
] |
[
"Maintain ResultReceiver for IntentService across Orientation Change without Fragments",
"I have been doing some work writing clients to execute (potentially) long-running operations against a REST api.\n\nMy first iteration used an IntentService with a ResultReceiver to communicate back to the Activity. After this, I implemented a client using AsyncTask. Finally, a third client extended the AsyncTask client to use Fragments so I could handle things like orientation changes.\n\nNow I'd like to revist my first two iterations and \"orientation-change proof\" them. Is this possible without using fragments? I have tried to use onSaveInstanceState / onCreate to save/recreate the ResultReceiver, but it doesn't seem to work (and this does not suprise me).\n\nI'm not anti-fragment, just wondering if there is a pre-fragment pattern for accomplishing this (something to do with BroadcastReceiver perhaps)? Or is this just a known pre-fragment issue?"
] | [
"android",
"android-fragments",
"android-asynctask",
"intentservice"
] |
[
"How do I load a value on TextField in JetpackCompose",
"I have this TextField that I want it to load a name a get from an object in Firestore and then I want to be able to change the value and update in Firestore. I tried a few ways but when I load the value I cannot change it or the app crashes.\nBelow is my last attempt where the textField (editText) appears blank. I need to load the players.name in the textField so I can update it\n@HiltViewModel\nclass ProfileViewModel @Inject constructor(\n private val repository: PlayersRepository\n) : ViewModel() {\n\n var loading = mutableStateOf(false)\n\n val data: MutableState<Player?> = mutableStateOf(null)\n val editText = mutableStateOf(\n data.value?.name ?: ""\n )\n\n init {\n getUser()\n }\n\n fun onValueChanged(text: String){\n this.editText.value = text\n }\n\n private fun getUser() {\n loading.value = true\n viewModelScope.launch {\n val loggedUser = repository.getPlayerFromFirestore().data\n loggedUser!!.addOnSuccessListener { document ->\n val logged = document.toObject(Player::class.java)\n data.value = logged!!\n loading.value = false\n }\n }\n }\n\n@AndroidEntryPoint\nclass ProfileFragment : Fragment() {\n\n private val viewModel: ProfileViewModel by viewModels()\n override fun onCreateView(\n inflater: LayoutInflater, container: ViewGroup?,\n savedInstanceState: Bundle?\n ): View {\n\n return ComposeView(requireContext()).apply {\n setContent {\n val player = viewModel.data.value\n selectedImageUri.value = player?.image?.toUri()\n ReiDoFifaTheme {\n\nif (player != null) {\n OutlinedTextField(\n modifier = Modifier\n .align(Alignment.CenterHorizontally)\n .padding(bottom = 16.dp),\n value = editText,\n onValueChange = { newValue ->\n viewModel.onValueChanged(newValue)\n }\n\n )\n\nAlso, how can I specify that a textField only accepts positive Integers and limit it to 2 digits?"
] | [
"android",
"kotlin",
"textfield",
"android-jetpack-compose"
] |
[
"Spring MVC submit only one element of render List in page",
"I have been looking for this answer here and in google without any success. I will explain what I´m looking for and let´s see if someone can help me.\n\nUsing Spring MCV I´m rendering a List of A objects \"aList\" into my view.JSP.\n\n @RequestMapping(method = RequestMethod.GET)\n public final ModelAndView getAList(){\n ModelAndView mav = new ModelAndView(\"view\");\n List<A> aList = new ArrayList<>();\n aList.add(new A(\"a1\");\n aList.add(new A(\"a2\");\n mav.addObject(\"aList\", aList);\n return mav;\n }\n\n\nWhere A looks like\n\n public class A{\n @Getter\n @Setter\n private String value; \n public A(String value){\n this.value=value;\n }\n } \n\n\nFor every iteration of the list I´m creating a form. The form looks like\n\n <c:forEach var=\"a\" items=\"${aList}\"\n varStatus=\"status\">\n\n <form:form id=\"A${a.id}\"\n method=\"post\" action=\"save.do\"\n modelAttribute=\"a\">\n\n <input type=\"submit\" value=\"Save\"/>\n </form:form>\n </c:forEach>\n\n\nso after finish the render I have so many forms as objects in my list.\nEvery form as you can imagine has his submit button. \nNow what I´m trying to do without any success is to send one of this form to my controller, but not the whole list of A that I render but A. So my controller will look something like.\n\n RequestMapping(value = \"/save\", method = RequestMethod.POST)\n public final ModelAndView save(@ModelAttribute(\"a\") A a) {\n\n\nBut I´m receiving a \"IllegalStateException: Neither BindingResult nor plain target object for bean name\" because the render name of my modelAndView \"aList\" is not the same than \"a\".\n\nWhat I think I understand is that Spring MVC components like form dont allow submit a different class that was used in the render. Even if is a nested class of the render class, what is too bad.\n\nI would like to avoid have to send the aList again.\n\nAny idea?\n\nRegards."
] | [
"java",
"spring",
"spring-mvc"
] |
[
"Accessing MQ with JMS",
"i am using MQ7 and trying to access a queue with JMS api's. Getting this error.\nHas anyone seen it before? How do i resolve this? TIA\n\n\n Exception in thread \"main\" com.ibm.msg.client.jms.DetailedJMSException: \n JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.\n \n Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd]\n \n Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd in java.library.path"
] | [
"java",
"jakarta-ee",
"jms",
"ibm-mq"
] |
[
"Place text over image when hover certain part of the image using css",
"Like the title said, I want to place a text box over an image when the mouse is hover over certain part of the image.\n\nI was able to do it when the mouse is hover over ANY part of the image but not specific part.\n\nHere is my html:\n\n<h1>World Map</h1>\n<div class=\"map\">\n <img src=\"assets/strangemap.png\" usemap=\"#testing\">\n <map name=\"testing\">\n <area shape=\"rect\" coords=\"100,100,200,200\" class=\"overlay\">\n </map>\n <span class=\"text-content\"><span>Strange World</span></span>\n</div>\n\n\nHere is my css:\n\n.map {\n display: inline-block;\n position: relative;\n border-top: 3px solid $gray-lighter;\n border-left: 3px solid $gray-lighter;\n border-bottom: 3px solid $gray-light;\n border-right: 3px solid $gray-light;\n}\n\n.overlay {\n cursor: default;\n}\n\nspan.text-content {\n background: rgba(0,0,0,0.5);\n color: white;\n display: table;\n height: 100px;\n left: 0;\n position: absolute;\n top: 0;\n width: 100px;\n opacity: 0;\n -webkit-transition: opacity 500ms;\n -moz-transition: opacity 500ms;\n -o-transition: opacity 500ms;\n transition: opacity 500ms;\n}\n\nspan.text-content span {\n display: table-cell;\n text-align: center;\n vertical-align: middle;\n}\n\n.overlay:hover span.text-content {\n opacity: 1;\n}\n\n\nThanks!"
] | [
"html",
"css"
] |
[
"How to automate a webpage in Google chrome using powershell",
"while navigating to the url , i have different buttons and i want to automate the click on all the buttons and also fetch some data into a file and send email with attachment if something fails using powershell script. I just started writing the script but unable to proceed further. Please suggest.\nCode:\n$ie=Start-Process -FilePath "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" -ArgumentList "abc.aspx"\n$ie.Document.getElementsByName('').click( )\n\nError:\nYou cannot call a method on a null-valued expression.\nAt line:2 char:2"
] | [
"powershell"
] |
[
"How to link a value to a string in a vector?",
"I am doing an assignment that requires me to make a header for the car inventory to be used in a driver program. The main program is supposed to let the user choose an option to either add a car, delete a car, print the current inventory, or exit. I started to make a vector for car makes but have no clue how to connect a price to the cars or how to make it possible for a user to add or delete cars from the list. Basically what I am asking is how can I make a table for car makes and prices to be assessed and for the table to be edited by the user. I cannot use standard arrays, I must use vectors.\n#include<iostream>\n#include<string>\n#include<vector>\n\nusing namespace std;\n\nvector <string> carMake;\n\ncarMake.push_back("toyota");\ncarMake.push_back("honda");\ncarMake.push_back("kia");\ncarMake.push_back("subaru");\ncarMake.push_back("hyundai");\ncarMake.push_back("ford");\ncarMake.push_back("chevy");\ncarMake.push_back("buick");\ncarMake.push_back("gmc");\ncarMake.push_back("cadillac");\ncarMake.push_back("mercedes");\ncarMake.push_back("acura");\ncarMake.push_back("lexus");\ncarMake.push_back("infiniti");\ncarMake.push_back("lincoln");\ncarMake.push_back("jeep");\ncarMake.push_back("land rover");\n\nvector <int> carPrice;\n\ncarPrice.push_back()"
] | [
"list",
"vector",
"menu",
"header",
"driver"
] |
[
"Group multiple rows in R",
"I have an excel spread sheet with companies names and data regarding sales. Some companies are related and I want to group them together under the same row. I want each column in this row to have the sum of all related companies.\nI'm using R, and would appreciate if someone can give me a direction on how to\nstart.\nEdit- Example of the data:\n\n\n\n\nCompany name\nJan sales\nJan expenses\nJan revenue\n\n\n\n\nCompany A\n1000\n500\n500\n\n\nCompany B\n2000\n500\n1500\n\n\nCompany C\n3000\n400\n2600\n\n\nCompany D\n4000\n100\n3900\n\n\n\n\nI want to group all this companies under a single row by the name Company A.\nI want it to look like this:\n\n\n\n\nCompany name\nJan sales\nJan expenses\nJan revenue\n\n\n\n\nCompany A\n10000\n1500\n8500"
] | [
"r"
] |
[
"From jQuery to Prototype",
"Please help to replace these jQuery functions with Prototype ones:\n\n$(\"button,input,label,select,textarea\").bind('mouseover mouseout',\n function(){$(this).toggleClass('hover')});\n$(\"button,input,select,textarea\").bind('focus blur',\n function(){$(this).toggleClass('focus')});"
] | [
"jquery",
"function",
"prototypejs"
] |
[
"How to access subcollections from Firestore in Javascript?",
"I want to create a collection and a subcollection, with the collection's name being a variable that the user inputs. I don't know the code to actually call the subcollection when the collection is a variable.\n\nI've done it before in Dart, and essentially used:\nreturn db.collection('$company/users').doc(cred.user.uid).set({...\nbut js appears to just read it as a string.\nI've tried several variations:\n\nreturn db.collection('${company}/users').doc(cred.user.uid).set({...\nreturn db.collection(company'/users').doc(cred.user.uid).set({...\nreturn db.collection(company + '/users').doc(cred.user.uid).set({...\nreturn db.collection(company, '/users').doc(cred.user.uid).set({...\nreturn db.collection(company).collection('users').doc(cred.user.uid).set({...\n\n\nExpected results: Collection and Subcollection area created, with the collection taking in the company String and the subcollection being users.\nThe exact code works with a single collection, whether I try \"users\" or the variable company, but I don't know how to get them to work together.\n\nActual results: No collection made, error of \"Invalid Collection Reference\"\n(slightly different errors depending on what I tried)."
] | [
"javascript",
"google-cloud-firestore"
] |
[
"Can we print error message before form begin in mvc?",
"can we print error message before form start, I am using mvc v4\n\nthis is my controller action code\n [HttpGet]\n\n public ActionResult ChangePassword(string aToken)\n {\n aToken = Server.UrlDecode(aToken);\n\n if (aToken != null)\n {\n .........\n }\n else\n {\n ViewBag.Error = \"Sorry, this link is not being recognized as valid. \n }\n\n return view();`enter code here`\n }\n\n\nthis is my cshtml file\n\n @if (ViewBag.Error != null)\n\n {\n <p class=\"text-danger\">\n @ViewBag.Error\n </p>\n }\n else\n {\n using (Html.BeginForm(\"ChangePassword\", \"Account\", FormMethod.Post, new { \n @class = \"form-horizontal \", role = \"form\" }))\n {\n\n ........................\n }\n\n }`enter code here`\n\n\ntechnicality, is this correct?"
] | [
"asp.net-mvc"
] |
[
"AngularJs component based architecture using for kendo grid",
"I'm very new to angular , i know little basic of angular only.\n\nI'm trying to integrate kendo ui grid in my view using angular component.\n\nMy Angular Component :\n\nclass GetAllPostController{\n\n constructor(API, ToastService){\n 'ngInject';\n\n this.API = API;\n this.ToastService = ToastService;\n }\n\n submit(){\n var data = {\n name: this.name,\n topic: this.topic\n };\n\n this.API.all('posts').post(data).then((response) => {\n this.ToastService.show('Post added successfully');\n });\n }\n\n test(){\n alert('');\n this.gridOptions = {\n sortable: true,\n selectable: true,\n dataSource: [\n { text: \"Foo\", id: 1 },\n { text: \"Bar\", id: 2 },\n { text: \"Baz\", id: 3 }\n ],\n columns: [\n { field: \"text\", title: \"Text\" }\n ]\n };\n\n }\n}\n\nexport const GetAllPostComponent = {\n templateUrl: './views/app/components/get_all_post/get_all_post.component.html',\n controller: GetAllPostController,\n controllerAs: 'vm',\n bindings: {},\n\n}\n\n\nMy View :\n\n<div kendo-grid k-options=\"gridOptions\" k-ng-delay=\"gridOptions\" ng-init=\"vm.test()\"></div>\n\n\nBut it's now working. Any one please help ? \n\nAnd please explain how to use scope inside componenet and view?\n\nI'm using Laravel Angular Material"
] | [
"angularjs",
"kendo-grid",
"components"
] |
[
"WMI Exception: \"COM object that has been separated from its underlying RCW cannot be used\"",
"I'm subscribing to a WMI event and receiving a \"COM object that has been separated from its underlying RCW cannot be used\" error when my application closes. This question has been asked before, but it is quite different from my circumstances.\n\nI am calling this code from my main thread:\n\nstring strComputer = @\".\";\nManagementScope scope = new ManagementScope(@\"\\\\\" + strComputer + @\"\\root\\wmi\");\nscope.Connect();\n\nEventQuery query = new EventQuery(\"Select * from MSNdis_StatusMediaDisconnect\");\n\nManagementEventWatcher watcher = new ManagementEventWatcher(scope, query);\n\nwatcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); // some function that does stuff when the event occurs.\nwatcher.Start();\n\n\nThe event is reported correctly. I suspect the problem is related to the way these objects are deallocated when my application closes. How do I prevent the error? Should I explicitly Dispose of the watcher, scope and query before my application closes?"
] | [
"c#",
"winforms",
"com",
"wmi"
] |
[
"Firebase Update just a Parent Node",
"This is a small question and if need be I'll just rewrite everything, but I want to save myself the work.\n\nI have a structure that looks like users/usernames/<someUN>/. I checked out the Firebase documentation but I couldn't find examples of how to update in a 'tight' tree.\n\nNow if I want to change <someUN>, you can see the problem\n\nthis.database.ref('users/usernames/' + this.UN).update({\n username: newUsernameVariable\n})\n\n\nI would have to restructure an unchangable value and do something like users/usernames/<userID>/username/<username> but \n\n\nit goes against denormalizing the database and \nI already have a tree holding uids/<uid>/usernames/<UN>, so that would be extra redundant\n\n\nNow if you tried to move the ref up a notch:\n\nthis.database.ref('users/usernames').update({\n this.UN: newUsernameVariable\n})\n\n\nThis is very close to what I want but unfortunately is not valid JSON. The left hand side is not converted to string. I've tried doing this\n\nvar UNJSON = JSON.stringify(this.UN);\nthis.database.ref('users/usernames/').update({\n UNJSON: newUsername\n});\n\n\nBut it won't work, just treats UNJSON as a word\n\nEDIT:\n\nI've changed it to \n\nvar updates = {};\nupdates[this.UN] = newUsername;\nthis.database.ref('users/usernames').update(updates);\n\n\nWhich almost works, but now the children node are replaced!\n\nI've changed the question of this title because essentially I've gotten to the point where I have something like users/usernames/myawesomeusername/{manychildren} and I want to keep the children while editing myawesomeusername.\n\nEDIT 2: this.UN is populated in onAuthStateChanged by the time it hits the update code. Here is the setting of this.UN\n\n// UN is a global read/write username string that persists throughout the session.\n// SETTING THE VALUE OF this.UN WITH UID\nif(this.UN == undefined) {\n console.log('this.UN was null. Fetch the real one with UID from the database');\n this.database.ref('uids/' + user.uid).once('value', function(snapshot){\n this.UN = snapshot.val().username;\n console.log('Grabbed from snapshot.username');\n if(this.UN == undefined) {\n console.log('Impossible error');\n }\n }.bind(this)).catch(function(err){\n console.log('Error obtaining userID from database', err);\n this.UN = user.displayName || \"User\" + user.uid;\n }.bind(this));\n} else {\n console.log(this.UN);\n}\n\n\nI use this.UN to handle any time I need the username for the rest of the app."
] | [
"javascript",
"json",
"firebase",
"firebase-realtime-database"
] |
[
"How to use Airbnb's iCalendar Link Programmatically",
"I have gotten the iCalendar link of a Airbnb listing.\nWhen I visit that link using any browser, the browser automatically downloads the .ics iCalendar file.\nI am trying to program an application that will sync with the iCalendar of that particular Airbnb listing.\nI thought I should just fetch the iCalendar link and I can read the contents of the .ics file and parse it and process the information.\nHowever when I try to use isomorphic-fetch on the same Airbnb Calendar link I am getting the following Response:\nResponse {\n size: 0,\n timeout: 0,\n [Symbol(Body internals)]: {\n body: PassThrough {\n _readableState: [ReadableState],\n _events: [Object: null prototype],\n _eventsCount: 5,\n _maxListeners: undefined,\n _writableState: [WritableState],\n allowHalfOpen: true,\n [Symbol(kCapture)]: false,\n [Symbol(kTransformState)]: [Object]\n },\n disturbed: false,\n error: null\n },\n [Symbol(Response internals)]: {\n url: 'https://www.airbnb.com/calendar/ical/22342432.ics?s=56501a678175afddd0ef3874b7a1b28b',\n status: 200,\n statusText: 'OK',\n headers: Headers { [Symbol(map)]: [Object: null prototype] },\n counter: 0\n }\n}\n\nFetchError: invalid json response body at https://www.airbnb.com/calendar/ical/22342432.ics?s=56501a678175afddd0ef3874b7a1b28b reason: Unexpected token B in JSON at position 0\n\nIdeally I would like to query that link from NODE.js (Next.js) and instead of downloading a .ics file I would like to be able to parse the info of the .ics in JSON format so I can process the data and find out which dates are available and which dates are not available for that listing....\nHow can I do that?\nbtw I used isomorphic-fetch npm library to do the fetching...e.g.\nconst response = await fetch(`https://www.airbnb.com/calendar/ical/22342432.ics?s=56501a678175afddd0ef3874b7a1b28b`);\n \n\n console.log('response');\n console.log(response);\n\n console.log('response.body', response.body);\n \n\n stories = await response.json();\n\n console.log('stories');\n console.log(stories);\n\n res.status(200).json(stories)\n\n } catch(err) {\n console.log('error')\n console.log(err)\n stories = [];\n\n }"
] | [
"javascript",
"node.js",
"next.js",
"icalendar",
"airbnb"
] |
[
"How can I set the title of a HTML element based on a complex expression using AngularJS?",
"I know about the {{ }} but how can I set the title of an element based on the value of three different variables:\n\nI am wanting a message saying:\n\n\"Required field\" if !forms.register.userName.$dirty && forms.register.submitted\n\n\"Already taken\" if forms.register.userName.$dirty && forms.register.userName.$error.uniqueName\n\n\nCan I put into the {{ }} something like an if else or a switch or is there some other way of doing this?"
] | [
"angularjs"
] |
[
"Create custom shape consisting of multiple single lines",
"i want to create a simple cross, that consists of two lines. The lines should have different colors. I've created a class that inherits form Shape. This class contains the two lines and computes the coordinates of the lines. I've read that i have to implement the DefiningGeometry property if i inherit from Shape. But how can i return both lines in the get section of that property?\n\nThanks in advance."
] | [
"wpf",
"shape"
] |
[
"jquery accordion menu open middle on page load",
"I have a simple accordion drop down menu that has four main levels. I can get the first one to open on page load and the last one to open on page load. What I would like is to get the third one to open on page load.\nHere is my HTML:\n\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title></title>\n <link href=\"CSS/Accordion1.css\" rel=\"stylesheet\" />\n <script src=\"Scripts/JQuery.js\" type=\"text/javascript\"></script>\n <script src=\"Scripts/Accordion1.js\" type=\"text/javascript\"></script>\n\n</head>\n<body>\n <div id=\"Wrapper\">\n <div class=\"accordion\">\n <div class=\"primary\">Employee Web Links:</div>\n <div class=\"secondary\">\n SharePoint Webpart\n <!--Place Code Between these Markers-->\n\n <!--Place Code Between these Markers-->\n </div>\n <div class=\"primary\">Phone Directory:</div>\n <div class=\"secondary\">\n Sharepoint Webpart\n <!--Place Code Between these Markers-->\n\n <!--Place Code Between these Markers-->\n </div>\n <div class=\"primary\">Web Search:</div>\n <div class=\"secondary\">\n Sharepoint Webpart\n <!--Place Code Between these Markers-->\n\n <!--Place Code Between these Markers-->\n </div>\n <div class=\"primary\">Industry News:</div>\n <div class=\"secondary\">\n SharePoint Webpart\n <!--Place Code Between these Markers-->\n\n <!--Place Code Between these Markers-->\n </div>\n </div>\n </div> \n</body>\n</html>\n\n\nAnd here is my jquery code:\n\n$(function () {\n\n $(\".accordion .secondary\").hide();//hides containers\n $(\"div.accordion .secondary:last\").slideDown('fast');//opens last container on load\n $(\".accordion .primary\").click(function () {\n $(this).next(\".accordion .secondary\").slideToggle(\"fast\");\n })\n})\n\n\nIn the forth line of the code I can change the \".secondary:last\" to \".secondary:first\" and that will open the first accordion menu. But I would like to have the third accordion menu open on load. I have tried \".secondary:third\" and \".secondary:2\" but those do not work. Could someone help me with this?"
] | [
"jquery",
"accordion",
"onload"
] |
[
"Avoid reloading Pandas dataFrame if already in name space",
"Everytime i run my script the (very large) dataset is being reloaded. This is a time consuming and inefficient process which i want to avoid. So I was trying to get around the reloading by checking if the dataFrame already exists in the name space with the try/except command, looking like this:\ntry: \n df.tail()\nexcept NameError:\n df = pd.read_excel(...)\n\nFor the check the tail function is used, considering it an 'inexpensive' operation.\nAnyways... Doesn't work. Are there any hints or suggestions on how to solve this? Or is there even a built-in pandas functionality that I missed?"
] | [
"python",
"pandas"
] |
[
"What's the point of Actions and Reducers in Redux?",
"I have been using Redux for a while, but I still can't see the point of actions and reducers.\n\nAs described in the docs, a reducer can be summarised as (previousState, action) => newState. The same principle applies for React's useReducer.\n\nSo this reducer function basically handles all actions, which seems like a violation of the Single Responsibility Principle. I'm sure that there's a good reason to do it this way, but I don't see it.\n\nIt would make more sense to me to just have a function per action. So instead of having an ADD_TODO action you would have a addTodo(previousState, todoText) => newState function. This would reduce (no pun intended) a lot of boilerplate code and might even give a slight performance improvement as you no longer need to switch through the action types.\n\nSo my question is: What's the advantage of having a reducer as opposed to a single-action function?"
] | [
"javascript",
"reactjs",
"redux"
] |
[
"CSS gradient on border",
"In the following code, the gradient has a width of 100% and goes over the border on the left side. \n\nJSFiddle\n\n\r\n\r\ninput {\r\n background: transparent;\r\n font-family:'Open Sans';\r\n border: 1px solid rgba(255, 255, 255, 0.2);\r\n box-sizing: border-box;\r\n padding: 5px;\r\n color: rgb(164, 164, 164);\r\n}\r\ninput:focus {\r\n outline: none;\r\n border: 1px solid rgba(255, 255, 255, 0.5)\r\n}\r\n#demo {\r\n background : transparent linear-gradient(to right, rgba(109, 179, 242, 0) 0%, rgb(24, 189, 70) 100%, rgba(54, 144, 240, 0) 0%, rgba(58, 107, 182, 0) 100%);\r\n}\r\nbody {\r\n background: hsla(0, 5%, 5%, 1) linear-gradient(to right top, rgba(10%, 0%, 0%, 1), rgba(0%, 0%, 0%, 1)) no-repeat fixed;\r\n}\r\n<input type=\"text\" id=\"demo\" />\r\n<input type=\"text\" />\r\n\r\n\r\n\n\nWhy does this happen and how can I avoid this?"
] | [
"html",
"css",
"background",
"border",
"gradient"
] |
[
"How to do time remaining with JAVA and SQL?",
"I am working on an Android based app and using JAVA for my web services too. I mean my website is built with JAVA too. So here is thing, I am new at JAVA programming and this is for my learning stuffs. I have been searching for help to create something like \"TIME REMAINING\" notification in Android. So deal is I don't know how to use TIME/SQL related class in JAVA.\n\nWhat I want to do is for example, event is happened on 1st July, 2015 at 12:00 am and will be available for next 48 hours. So, I want to add expire time in database. I don't want to use \"2015-07-12 06:47:39.154\n\" for my database, instead of that I want to save milliseconds where I can subtract current time and can say that you have few hours left etc. And in my android app, I want to show it like SNAPCHAT. Like how you can see photo cropped in circle during 24 hours. \n\nI will work on this for my android stuff. The thing I am looking for is when my app communicates to server, my website will respond in percentage of remaining time. Like if 36 hours remaining than 75, if 30 than 65 or some, if 24 than 50 etc. So, can anyone help me how can I use it? I am looking for help so, help will be appreciated.\n\nMy actual time code in java,\n\n//for timestamp\nlong retryDate = System.currentTimeMillis();\n\nint sec = 604800;\n\nTimestamp original = new Timestamp(retryDate);\nCalendar cal = Calendar.getInstance();\ncal.setTimeInMillis(original.getTime());\ncal.add(Calendar.SECOND, sec);\nTimestamp later = new Timestamp(cal.getTime().getTime());"
] | [
"java",
"android",
"sql",
"time"
] |
[
"Why can't I remove elements from an Array in its willSet event?",
"The logic is to clear an Array when it has a specified amount of elements. I could put the check outside of the Array but I was trying to see what if do it in Array's willSet event. The result is elements in Array stay still.\n\nHere is the code\n\nvar MyArr=[String]() {\n willSet{\n print(\"now count is:\\(MyArr.count)\")\n if MyArr.count>2 {\n print(\"now remove all!\")\n MyArr.removeAll()\n }\n }\n}\n\nMyArr.append(\"hello\")\nMyArr.append(\",world\")\nMyArr.append(\"!\")\nMyArr.append(\"too much.\")\n\nprint(\"The conent is \\(MyArr)\")\n\n\nMyArr was expected to have only one elements while actual result was four."
] | [
"arrays",
"swift",
"value-type",
"didset",
"property-observer"
] |
[
"How can we trigger act_window action from on_change function?",
"I have a selection widget with several items that happen to be names of different models, on selecting a model, I want to trigger an act_window based on that model so how can we trigger an action from on_change function?\n\nAs far as I'm aware, it only reads \"value\", \"domain\" and \"warning\". I want similar functionality to a button \"type=object\" where we can simply return the action and everything works fine but I'm having no luck reproducing this from an on_change method."
] | [
"python",
"action",
"onchange",
"openerp"
] |
[
"How to convert a Regex Match to String c#",
"i've made a Program that goes a big chunk of text from a calendar website, searches for tags of events and puts them into a text file. I've added a function so you can do the query many days in the past, adn I wanted to add a search function, so you can search through the tags. I wanted to use a simple String.Contains(), but the output tags are Regex Matches, so I need to convert them.\nMy Code:\nusing System;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Threading;\nusing System.Net;\nusing System.IO;\nusing System.Text.RegularExpressions;\nnamespace ESEL_Scraper\n{\n class Program\n {\n static void Main(string[] args)\n {\n int queryResults = 0;\n Stopwatch stopWatch = new Stopwatch();\n stopWatch.Start();\n Console.WriteLine("How many days do you want to go back?");\n String userInput = Console.ReadLine();\n Console.WriteLine("What do you want to search for?");\n String userInput2 = Console.ReadLine();\n int result = Int32.Parse(userInput);\n for(int i = 0; i < result; i++) {\n DateTime somePreviousDay = DateTime.Now.Date.AddDays(-i);\n String somePreviousDayString = somePreviousDay.ToString("dd.MM.yyyy");\n Console.WriteLine(somePreviousDayString);\n WebClient client = new WebClient();\n client.Encoding = System.Text.Encoding.UTF8;\n string site = client.DownloadString($"https://esel.at/api/termine/data?date={somePreviousDayString}&selection=false");\n String tags = "\\"tags\\":\\"";\n String endTags = "\\",";\n Regex regex = new Regex($"{tags}(.*?){endTags}");\n MatchCollection matches = regex.Matches(site);\n foreach (Match match in matches)\n {\n if(match.Contains(userInput2)) {\n using (System.IO.StreamWriter file =\n new System.IO.StreamWriter(@"eselTags.txt", true))\n {\n file.WriteLine(match);\n queryResults++;\n }\n }\n\n }\n stopWatch.Stop();\n TimeSpan ts = stopWatch.Elapsed;\n string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",\n ts.Hours, ts.Minutes, ts.Seconds,\n ts.Milliseconds / 10); \n Console.WriteLine($"Time taken: " + elapsedTime); \n Console.WriteLine($"Found tags: " + queryResults); \n\n }\n \n\n}\n}\n}\n\nThe big chunk of text: https://esel.at/api/termine/data?date=05.09.2020&selection=false\nI hope someone can help me."
] | [
"c#",
"regex",
"string",
"web-scraping",
".net-core"
] |
[
"Recursive Components in AngularJS 1.x",
"Finally trying to learn AngularJS and I can't quite figure out how to make components work recursively. I have a simple example that's not rendering as expected.\n\nHTML\n\n<body ng-app=\"myApp\" ng-controller=\"myCtrl as vm\">\n <nested-list list=\"vm.list\"></nested-list>\n</body>\n\n\nJavaScript\n\nangular.module('myApp', [])\n\n .controller('myCtrl', ['$scope', function($scope) {\n $scope.list = [\n { \"name\": \"Item 1\" }, \n { \"name\": \"Item 2\",\n \"subItems\": [\n { \"name\": \" Item 2.1\" }\n ]\n }, \n { \"name\": \"Item 3\",\n \"subItems\": [\n { \"name\": \" Item 3.1\" }, \n { \"name\": \"Item 3.2\",\n \"subItems\": [\n { \"name\": \"Item 3.2.1\" },\n { \"name\": \"Item 3.2.2\" }\n ]\n }\n ]\n }];\n }])\n\n .component('nestedList', {\n bindings: {\n list: '<'\n },\n template: `\n <div ng-repeat=\"item in $ctrl.list\" >\n <div> {{item.name}} </div>\n <nested-list list=\"item.subItems\"></nested-list>\n </div>\n `\n });\n\n\nUndoubtedly because I'm missing something obvious, the list from the app's main controller myCtrl isn't getting bound to the root component. If anyone can provide insight, I'd be grateful.\n\nStephen"
] | [
"javascript",
"angularjs",
"angularjs-components"
] |
[
"View restrictions about distinct?",
"I found information that we cannot delete rows from view which in query have distinct but I want to show example :\n\ncreate table tb001 ( id number );\ninsert into tb001 values (1); \ninsert into tb001 values (2);\n\ncreate table tb002 ( id number );\ninsert into tb002 values (1); \ninsert into tb002 values (2);\ninsert into tb002 values (2);\n\ncreate view vw_tb001 as select distinct(id) from tb001;\ncreate view vw_tb002 as select distinct(id) from tb002;\n\n\nSo in the first version we can delete from view vw_tb001, because we havn't duplicate rows\nIn the second version we cannot delete from view vw_tb002.\nSo I am confused in rule about restrictions ? Need experts help."
] | [
"oracle",
"view",
"distinct"
] |
[
"Finding the number of paths of given length in a undirected unweighted graph",
"'Length' of a path is the number of edges in the path.\n\nGiven a source and a destination vertex, I want to find the number of paths form the source vertex to the destination vertex of given length k.\n\n\nWe can visit each vertex as many times as we want, so if a path from a to b goes like this: a -> c -> b -> c -> b it is considered valid. This means there can be cycles and we can go through the destination more than once.\nTwo vertices can be connected by more than one edge. So if vertex a an vertex b are connected by two edges, then the paths , a -> b via edge 1 and a -> b via edge 2 are considered different.\nNumber of vertices N is <= 70, and K, the length of the path, is <= 10^9.\nAs the answer can be very large, it is to be reported modulo some number.\n\n\nHere is what I have thought so far:\n\nWe can use breadth-first-search without marking any vertices as visited, at each iteration, we keep track of the number of edges 'n_e' we required for that path and product 'p' of the number of duplicate edges each edge in our path has.\n\nThe search search should terminate if the n_e is greater than k, if we ever reach the destination with n_eequal to k, we terminate the search and add p to out count of number of paths.\n\nI think it we could use a depth-first-search instead of breadth first search, as we do not need the shortest path and the size of Q used in breadth first search might not be enough. \n\nThe second algorithm i have am thinking about, is something similar to Floyd Warshall's Algorithm using this approach . Only we dont need a shortest path, so i am not sure this is correct.\n\nThe problem I have with my first algorithm is that 'K' can be upto 1000000000 and that means my search will run until it has 10^9 edges and n_e the edge count will be incremented by just 1 at each level, which will be very slow, and I am not sure it will ever terminate for large inputs.\n\nSo I need a different approach to solve this problem; any help would be greatly appreciated."
] | [
"algorithm",
"graph",
"routes",
"depth-first-search",
"breadth-first-search"
] |
[
"Why use a return when calling parent?",
"I am learning OO PHP and I was experimenting with using a parent::method in a child class. I noticed i had to use an \"extra\" return for the output of the parent method to show up. Could someone explain me why this is?\n\nThis is the code I used and in the code I made a comment.\n\nclass ShopProduct {\n\n public $productnumber;\n\n public function __construct($productnumber) {\n $this->productnumber = $productnumber;\n }\n public function getSummary(){\n return $this->productnumber;\n }\n}\n\nclass BookProduct extends ShopProduct {\n\n public function __construct($productnumber) {\n parent::__construct($productnumber);\n }\n public function getSummary() {\n return parent::getSummary(); // if i dont use return it doesnt work? why is that?\n // parent::getSummary(); is not enough it seems.\n }\n}\n\n$product = new BookProduct(11111);\necho $product->getSummary();\n?>"
] | [
"php"
] |
[
"Why won't selected form value in HTML Service Pass to Server-Side variable in Apps Script?",
"I have a table that pops up in an HTML UI on command in my Google Sheet file that allows the file's user a look at a summary of orders listed in one of my Google Sheet tabs. The table includes a radio button selection option for each order listed for the user to click on any order they'd like to review in greater detail. Right now, onClick, the file triggers an alert stating which order has been selected. This tells me everything is working properly, but when I move the alert code out of the client-side HTML section and to a server-side call via google.script.run, the alert no longer pops up 'onClick'. Let me know, if you can, where I am going wrong:\n\nfunction htmlOrders() {\n var active = SpreadsheetApp.getActive();\n var sheet = active.getSheetByName(\"POHistory\");\n var lastRow = sheet.getLastRow();\n var myRange = sheet.getRange(\"A2:K\" + lastRow); \n var data = myRange.getDisplayValues();\n var optionsHTML = \"\";\n var seenType = {};\n for (var i = 0; i < data.length; i++) {\n if(seenType[data[i][0]]) {\n continue;}\n seenType[data[i][0]] = true;\n optionsHTML += \"<tr>\";\n optionsHTML += \"<td><input type='radio' name='selectedPO' value='\" + \n data[i][0] + \"'onclick='google.script.run.editPO()';></td>\";\n optionsHTML += \"<td>\" + data[i][0] + \"</td>\";\n optionsHTML += \"<td>\" + data[i][2] + \"</td>\";\n optionsHTML += \"<td>\" + data[i][1] + \"</td>\";\n optionsHTML += \"<td>\" + data[i][10] + \"</td>\";\n optionsHTML += \"</tr>\"\n }\nreturn optionsHTML;} \n\nfunction editPO(){\n var whichPO = document.getElementsByName(\"selectedPO\");\n for(i=0 ; i < whichPO.length ; i++) {\n if(whichPO[i].checked)\n {\n alert(\"you have chosen \"+ whichPO[i].value);\n }}}\n\n\nHTML: \n\n<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n<form>\n<table name=\"table\" id=\"table\">\n <tr>\n <th>Edit?</th>\n <th>PO No.</th>\n <th>Vendor</th>\n <th>Date</th>\n <th>Total</th>\n </tr>\n <?!= htmlOrders(); ?>\n</table>\n<script>\n</script>\n</form>\n</body>\n</html>"
] | [
"google-apps-script"
] |
[
"How do I create relationships between a single table?",
"I have the above tables in a database I'm designing right now, in MySQL. The primary purpose of the database is to create Bill Of Materials for a database and enforce revision control on these Bill Of Materials.\n\nThe Parts table follows Single Table Inheritance and has 3 different types of parts: Connectors, Terminals, Seals.\n\nBrief Description Each Type\n\nConnector: These are automotive grade connectors used in the manufacturing of automotive wiring harnesses.\n\nTerminals: A connector has crimped wires inserted into it. A Terminal is crimped onto a wire in order to create a solder-less joint. These terminals then mate with their counterparts when the connecter is mated with it's counterpart in a vehicle.\n\nSeals: These are special type of seals that are inserted onto the the wire in order to prevent water/dust getting through to the interconnection.\n\nA connector can be used with multiple types of terminal and a terminal can also be used with multiple types of connectors.\n\nThe relationship between a connector and a seal is similar. A seal and terminal have no relationship.\n\nWhat I'm aiming for:\n\n\nIf the user is browsing some part, I would like the view to show all it's related/associated parts. For instance, if Connector id 1 can be used with 5 different types of terminals, I would like all these terminals be shown in the view.\nSimilarly, when Terminal is being viewed, I would like all the different connectors that it can be used with shown as well.\nFurthermore, a Connector can have substitute parts and I would like to relate that as well. This is a one-to-many relationship as a connector can have multiple substitutes.\nAnd finally, a Connector can have multiple counter-parts and I would like these to be related as well.\n\n\nI'm new to database design and I'm having trouble seeing the forest through the trees. Personally, I think I should ditch the Single Table idea and go with separate tables for Connectors, Seals and Terminals and draw up relationships between them.\n\nThat still answer how I can show substitutes and counter-part connectors."
] | [
"mysql",
"database",
"database-design"
] |
[
"c# Language : Error while trying to save parameters to MySql DB using C#",
"I am using MySql database in my C# program.\nBelow is my code and when I execute the following method, it throws me an exception \"MySql Syntax Exception\". \n\nPlease help me in figuring out the error. Also let me know, if any further information is required to resolve this.\n\nI would be very glad if you guys can help me.\n\n private void btnVerify_Click(object sender, EventArgs e)\n {\n con.Open();\n\n try\n {\n string cmdText = \"INSERT INTO cheque(customer_name, national_id, drawn_bank, chq_number, bnk_br_code, ac_number, drawndate, amount, commission_rate, commission, order, recieved_date, due_date, reminder_date, chq_image_frnt, chq_image_back) VALUES(@customer_name,@national_id,@drawn_bank,@chq_number,@bnk_br_code,@ac_number,@drawndate,@amount,@commission_rate,@commission,@order,@recieved_date,@due_date,@reminder_date,@chq_image_frnt,@chq_image_back)\";\n MySqlCommand cmd = new MySqlCommand(cmdText, con);\n cmd.Parameters.AddWithValue(\"@customer_name\", txtCustomerName.Text);\n cmd.Parameters.AddWithValue(\"@national_id\", txtIDNumber.Text);\n cmd.Parameters.AddWithValue(\"@drawn_bank\", txtDrawnBank.Text);\n cmd.Parameters.AddWithValue(\"@chq_number\", txtChqNo.Text);\n cmd.Parameters.AddWithValue(\"@bnk_br_code\", txtBnkBrCode.Text);\n cmd.Parameters.AddWithValue(\"@ac_number\", TxtAcNo.Text);\n cmd.Parameters.AddWithValue(\"@drawndate\", dateTimePickerDrawnDate.Text);\n cmd.Parameters.AddWithValue(\"@amount\", TxtAmount.Text);\n cmd.Parameters.AddWithValue(\"@commission_rate\", txtCommissionRate.Text);\n cmd.Parameters.AddWithValue(\"@commission\", txtCommission.Text);\n cmd.Parameters.AddWithValue(\"@order\", Ordercb.Text);\n cmd.Parameters.AddWithValue(\"@recieved_date\", dateTimePickerRecieved.Text);\n cmd.Parameters.AddWithValue(\"@due_date\", dateTimePickerDue.Text);\n cmd.Parameters.AddWithValue(\"@reminder_date\", dateTimePickerReminder.Text);\n cmd.Parameters.AddWithValue(\"@chq_image_frnt\", picChqFrnt.Image);\n cmd.Parameters.AddWithValue(\"@chq_image_back\", picChqBack.Image);\n\n\n cmd.ExecuteNonQuery();\n MessageBox.Show(\"Cheque has been inserted to the database\");\n ClearData();\n con.Close();\n }\n catch (MySqlException x)\n {\n MessageBox.Show(x.Message);\n }\n\n }"
] | [
"c#",
"mysql"
] |
[
"Read-only user gets full access",
"Aim is to create a read-only user for production namespace for my EKS cluster. However, I see the user has full access. As I am new to EKS and Kubernetes, please let me know the error that I have injected.\n\nI have created an IAM user without any permission added. ARN is: arn:aws:iam::460764xxxxxx:user/eks-prod-readonly-user. Also, I have noted down the access key id and secret access key -\n\naws_access_key_id= AKIAWWxxxxxxxxxxxxx\naws_secret_access_key= lAbtyv3zlbAMPxym8Jktal+xxxxxxxxxxxxxxxxxxxx\n\n\nThen, I have created the production namespace, role, and role binding as follows –\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl create namespace production\n\nubuntu@ip-172-16-0-252:~$ cat role.yaml\nkind: Role\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n namespace: production\n name: prod-viewer-role\nrules:\n- apiGroups: [\"\", \"extensions\", \"apps\"]\n resources: [\"*\"] \n verbs: [\"get\", \"list\", \"watch\"]\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl apply -f role.yaml\n\nubuntu@ip-172-16-0-252:~$ cat rolebinding.yaml\nkind: RoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n name: prod-viewer-binding\n namespace: production\nsubjects:\n- kind: User\n name: eks-prod-readonly-user\n apiGroup: \"\"\nroleRef:\n kind: Role\n name: prod-viewer-role\n apiGroup: \"\"\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl apply -f rolebinding.yaml\n\n\nThen, we have added the newly created user to aws-auth configuration map and have applied the changes -\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl -n kube-system get configmap aws-auth -o yaml > aws-auth-configmap.yaml\nubuntu@ip-172-16-0-252:~$ vi aws-auth-configmap.yaml\n\n\nThe following section is added under ‘mapUsers’ –\n\n- userarn: arn:aws:iam::460764xxxxxx:user/eks-prod-readonly-user\n username: eks-prod-readonly-user\n groups:\n - prod-viewer-role\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl apply -f aws-auth-configmap.yaml\n\n\nNow, I include this user details as a new section inside AWS credential file ( ~/.aws/credentials ) so that this user can be authenticated to API server of Kubernetes -\n\n[eksprodreadonlyuser]\naws_access_key_id= AKIAWWxxxxxxxxxxxxx\naws_secret_access_key= lAbtyv3zlbAMPxym8Jktal+xxxxxxxxxxxxxxxxxxxx\nregion=eu-west-2\noutput=json\n\n\nI activate this AWS profile -\n\nubuntu@ip-172-16-0-252:~$ export AWS_PROFILE=\"eksprodreadonlyuser\"\nubuntu@ip-172-16-0-252:~$ aws sts get-caller-identity\n\n\nWe see the correct user ARN in the output of get-caller-identity command.\n\nWhile trying to see pods of default namespace, it works. Ideally it shall not as the user is given access on the production namespace only -\n\nubuntu@ip-172-16-0-252:~$ sudo kubectl get pods\nNAME READY STATUS RESTARTS AGE\ntest-autoscaler-697b95d8b-5wl5d 1/1 Running 0 7d20h\nubuntu@ip-172-16-0-252:~$\n\n\nLet know pointers to resolve. Thanks in advance!"
] | [
"amazon-web-services",
"kubernetes",
"kubectl",
"amazon-eks"
] |
[
"mainWindow.loadURL is not a function",
"I am getting this error but not getting the solution to resolve this issue.\n\n\n mainWindow.loadURL is not a function \n\n\nconst electron = require('electron');\nconst {Menu} = require('electron');\nconst {app} = require('electron');\nconst BrowserWindow = require('browser-window');\nconst conn = require('mysql');\nconst path = require('path');\nconst url = require('url');\nvar mainWindow;\napp.on('ready', function () {\n mainWindow = new BrowserWindow({ width: 1024, height: 768, backgroundcolor: 'black' });\n **mainWindow.loadURL(url.format({** //Here I am getting an error.\n pathname: 'popupcheck.html',\n protocol: 'file:',\n slashes: true\n }));\n mainWindow.webContents.openDevTools();\n mainWindow.setProgressBar(1);\n});"
] | [
"javascript",
"electron"
] |
[
"Docker container to NAS Storage",
"I'm trying to mount the storage volume to inside the container. like the linux i given the below command \n\n**mount 10.#.##.###:/nvol1 /tmp**\n\n\nthis gives \"Access denied\" error, i have added the Container and host IP to storage to allow the traffic from the Container & the host server. But i cannot mount the storage volume in the container ? Am i missing something ? i'm using Centos Operating System.\n\nEdit Note: I have already mount the storage to the Docker host successfully and made the communication between the host file system and the container. however this new test case seeking directly mount the storage volume on the container not on the Docker host."
] | [
"docker",
"containers",
"storage"
] |
[
"How can I use react-native with php with fetch return data is always null",
"My return is always null. i cant seems to get this to work. How can I use react-native with php with fetch json. anyone can help?\n\nPHP\n\n$myArray = array();\n$myArray['lat'] = $_POST['lat']; \n$myArray['lng'] = $_POST['lng'];\necho $_POST['lat'];\n\n\nReact-Native Fetch\n\nfetch(url, { \n method: 'post',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n lat: region.latitude,\n lng: region.longitude\n })\n})\n.then((response) => response.json())\n.then((responseData) => {\n console.log(responseData);\n })\n .catch((error) => {\n console.warn(error);\n })\n .done();"
] | [
"javascript",
"php",
"ios",
"json",
"react-native"
] |
[
"windows phone 8 how to swipe local html files just like pivot or panaroma control?",
"i'm beginner for windows phone 8., actually i have created a project which has some html files(40 files) in local folder and i want to show all html files one by one when user swipe horizontally just like pivot or panaroma control., \ni know statically how to call local html files by using web browser control and i did in many projects., but i don't know to show all files one by one when user swipe horizontally.,\n\nand i tried to dynamically add web browser control inside pivot item., \n\nthis is my code for create dynamic pivot items with web browser controls inside\n\n\" pivotPage.cs \"\n\n void pivotPage_Loaded(object sender, RoutedEventArgs e)\n {\n for (int i = 0; i < 40; i++)\n {\n string _url = \"ways/a\"+ i + \".html\";\n PivotItem newPivotItem = new PivotItem();\n newPivotItem.Margin = new Thickness(0, -10, 0, 0);\n WebBrowser newWebBrowser = new WebBrowser();\n newWebBrowser.Navigate(new Uri(_url, UriKind.Relative));\n newPivotItem.Content = newWebBrowser;\n pivotList.Items.Add(newPivotItem);\n }\n }\n\n\nand my pivotPage.xaml is\n\n <Grid x:Name=\"ContentPanel\" Margin=\"0,0,0,0\" Grid.RowSpan=\"2\" Background=\"#FF378FB1\">\n <phone:Pivot x:Name=\"pivotList\" Background=\"White\" Margin=\"10,130,10,80\"/>\n </Grid>\n\n\nif i try to create maximum of \" 25 \" pivot items using for loop like this means i got output with 25 pivot items and i can able to swipe., the code like this\n\n for(int i=0; i<25; i++)\n {\n string _url = \"ways/a\"+ i + \".html\";\n PivotItem newPivotItem = new PivotItem();\n newPivotItem.Margin = new Thickness(0, -10, 0, 0);\n WebBrowser newWebBrowser = new WebBrowser();\n newWebBrowser.Navigate(new Uri(_url, UriKind.Relative));\n newPivotItem.Content = newWebBrowser;\n pivotList.Items.Add(newPivotItem);\n }\n\n\nbut i need to show 40 files, so if i make condition like this means\n\n for (int i = 0; i < 40; i++)\n {\n\n }\n\n\nit shows nothing and app was closed., \n\nis there any limit for maximum no.of pivot items shown ???\n\n could you please some one try to give me solution for this and also \n\n tell me that is there any control for showing html files like swipe view?\n\n\nsimply said my requirement is \" how to show local html files one by one like swipe view in WP8 apps ?\"\n\nthanks in advance., am waiting for some answers.,"
] | [
"windows-phone-8"
] |
[
"Simple code neither working on jsfiddle nor codepen, but running on my browser (Chrome)?",
"I was trying to make a simple mouse movement recorder using pure javascript. This recorder is perfectly working on my browser (Chrome) but not working either on jsfiddle, or codepen.io, and not even properly in stackoverflow's console. I am not aware of any compatibility issues with such programs.\n\n\r\n\r\nvar button1 = document.getElementById(\"start\");\r\nbutton1.addEventListener(\"click\", startOrPlay);\r\nvar button2 = document.getElementById(\"stop\");\r\nbutton2.addEventListener(\"click\", stopOrAgain);\r\nvar pointer = document.getElementById(\"pointer\");\r\nvar title = document.getElementById(\"title\");\r\ntitle.textContent = \"Start Recording\";\r\nvar recording = [];\r\nvar index = 0,\r\n length = 0,\r\n r;\r\n\r\nfunction record(e) {\r\n recording[index] = [];\r\n recording[index][0] = e.clientX;\r\n recording[index][1] = e.clientY;\r\n index++;\r\n}\r\n\r\nfunction play() {\r\n pointer.style.top = recording[index][1];\r\n pointer.style.left = recording[index][0];\r\n index++;\r\n if (index == length) {\r\n clearInterval(r);\r\n }\r\n}\r\n\r\nfunction startOrPlay() {\r\n if (button1.textContent === \"START\") {\r\n document.addEventListener(\"mousemove\", record);\r\n button1.removeEventListener(\"click\", startOrPlay);\r\n title.textContent = \"Recording your mouse positions...\";\r\n } else {\r\n index = 0;\r\n pointer.style.display = \"initial\";\r\n pointer.style.top = recording[index][1];\r\n pointer.style.left = recording[index][0];\r\n r = setInterval(play, 10);\r\n }\r\n}\r\n\r\nfunction stopOrAgain() {\r\n if (button2.textContent === \"STOP\") {\r\n document.removeEventListener(\"mousemove\", record);\r\n length = index;\r\n index = 0;\r\n document.querySelector(\"#start p\").textContent = \"PLAY\";\r\n document.querySelector(\"#stop p\").textContent = \"AGAIN\";\r\n button1.addEventListener(\"click\", startOrPlay);\r\n title.textContent = \"Recorded\";\r\n } else {\r\n index = 0;\r\n length = 0;\r\n recording = [];\r\n title.textContent = \"Start Recording\";\r\n pointer.style.display = \"none\";\r\n document.querySelector(\"#start p\").textContent = \"START\";\r\n document.querySelector(\"#stop p\").textContent = \"STOP\";\r\n }\r\n}\r\nbody {\r\n position: relative;\r\n margin: 0;\r\n}\r\n#start,\r\n#stop {\r\n position: absolute;\r\n border: 1px solid black;\r\n border-radius: 10px;\r\n width: 80px;\r\n height: 30px;\r\n transition: background-color 0.5s;\r\n text-align: center;\r\n}\r\ndiv p {\r\n margin: 0;\r\n padding-top: 6px;\r\n}\r\n#start:hover,\r\n#stop:hover {\r\n background-color: cyan;\r\n cursor: pointer;\r\n}\r\n#start {\r\n top: 300px;\r\n left: 200px;\r\n}\r\n#stop {\r\n top: 300px;\r\n left: 1000px;\r\n}\r\n#pointer {\r\n display: none;\r\n width: 14px;\r\n position: absolute;\r\n padding: 0;\r\n margin: 0;\r\n}\r\n#pointer img {\r\n width: 100%;\r\n}\r\n#title {\r\n font-size: 40px;\r\n text-align: center;\r\n}\r\n#instructions {\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n height: 20px;\r\n overflow: hidden;\r\n margin: 10px;\r\n border: 1px dotted black;\r\n}\r\n#instructions:hover {\r\n height: 220px;\r\n}\r\n<html>\r\n\r\n<head>\r\n <link href=\"style.css\" rel=\"stylesheet\">\r\n</head>\r\n\r\n<body>\r\n <div id=\"instructions\">Instructions\r\n <br>1) This app will\r\n <br>track and record\r\n <br>you mouse's position\r\n <br>from the time of\r\n <br>clicking start to\r\n <br>clicking stop.\r\n <br>2) Use Full Screen\r\n <br>Window\r\n <br>3) Close any console.\r\n <br>4) Keep mouse inside\r\n <br>window</div>\r\n <div id=\"title\"></div>\r\n <div id=\"start\">\r\n <p>START</p>\r\n </div>\r\n <div id=\"stop\">\r\n <p>STOP</p>\r\n </div>\r\n <div id=\"pointer\">\r\n <img src=\"https://openclipart.org/image/90px/svg_to_png/222076/Mouse-Cursor-Arow-Fixed.png\"></img>\r\n </div>\r\n <script src=\"script.js\"></script>\r\n</body>\r\n\r\n</html>"
] | [
"javascript",
"html",
"css"
] |
[
"Save PDF as Arabic Name (PHP)",
"Good Day!\n\nI am saving PDF as English Name _ Employee number i.e. abc_123\n\nBut It is not working for arabic name _ employee number\n\nI have tried all ways like meta charset or meta-equip or all additions in headers or top of php files or before queries meta charset etc.\n\nplease Guide\n\nI am trying code given below:\n\n mysqli_query($connection,\"SET character_set_client=utf8\");\n\n $emp_number =($_POST['emp_number']);\n $owner_name =($_POST['owner_name']);\n $result110= mysqli_query($connection,\"SELECT * FROM accessories where emp_number='\".$emp_number.\"'\");\n while($row19 = mysqli_fetch_assoc($result110)) \n { \n $pdf->SetFont('aealarabiya', '', 15);\n $pdf->Output($row19['owner_name'].'_'.$row19['emp_number'].'.pdf', 'D');\n}\n\n\nAbove code is fine for English names but not Arabic..It shows __employeenumber for Arabic names like __1234.pdf\n\nPls guide\n\nThanks"
] | [
"php",
"mysql",
"mysqli",
"pdf-generation"
] |
[
"HTMLDOM: How to change text \"files selected\" from upload button using jquery or javascript?",
"How to change the text \"files selected\" on upload button using jquery / javascript ? \n\n\n\nthanks\n\nNote: this is default build-in input file button"
] | [
"jquery",
"html",
"css",
"forms",
"dom"
] |
[
"Password Grant or Personal Tokens",
"My goal is for secure access from my SPA to my Laravel 7 REST API back-end using Passport. At this stage Im botheree about using it for authentication and not loading the tokens with authorization info.\n\nReading through lots of online examples, I find some going the route of Password Grant Tokens and some Personal Access Tokens.\n\nThe main difference I see in implementation is that with Grant Tokens, one needs to worry about calling the oauth/token route in a proxy with extra comfig details whilst with Personal Tokens, you can simply pass user name and password from the SPA. \n\nQuestion 1: is this the only difference technically in giving secure access from an SPA? Are there any risks/ disadvantages of using either method? If Personal is easier, why do people bother with Grant?\n\nQuestion 2: In the 7.x docs, I see a further simplified method (it seems, since my SPA is a JS app) using \"CreateFreshApiToken\" where apparently Passport does everything for me. Nevertheless I've not come across any example on the Internet using this. Do I somehow misunderstand its application or is this just because its a new feature entirely?"
] | [
"authentication",
"laravel-passport",
"laravel-7"
] |
[
"request() not secure in Laravel with load balancer and TrustedProxies",
"Why is request()->isSecure() returning false when visiting a HTTPS-url? I am using Laravel Forge and I have a load balancer. Logging the request I get this data:\n\nrequest()->url(), // \"http://xx.xx\"\nrequest()->isSecure(), // false\nrequest()->getClientIps(), // XX.XX.XX.XX \n\n\nIn TrustProxies (which is added in the $middleware array in Http/Kernel.php):\n\nprotected $proxies = [\n 'XX.XX.XX.XX', // exactly the same as in the logged data above\n];\n\n\nIn my AppServiceProvider's boot() method:\n\nif (env('APP_ENV') == 'production') {\n \\URL::forceScheme('https');\n}\n\n\nEdit:\n\nI am also using Cloudflare, and I have added all the Cloudflare proxies to $proxies as well. Check the logs, I see these headers in the request:\n\nX-Forwarded-Proto: http\nCf-Visitor: {\"scheme\":\"https\"}\nReferer: https://xx.xx/someurl"
] | [
"laravel",
"load-balancing",
"laravel-forge"
] |
[
"Download file to website using php",
"I have a file with URL !\n\n$url = \"http://www.example.com/aa.txt\";\n\n\nand I want to download this file and save it to path on my website\n\nthis is my website ( online )\n\n$path = \"server/username/\";\n\n\ni want the $url file saved to $path ,,\n\ni try this \n \n\nif (file_exists($file)) {\n header('Content-Description: File Transfer');\n header('Content-Type: application/octet-stream');\n header('Content-Disposition: attachment; filename='.basename($file));\n header('Expires: 0');\n header('Cache-Control: must-revalidate');\n header('Pragma: public');\n header('Content-Length: ' . filesize($file));\n readfile($file);\n exit;\n}\n?>\n\n\nwhen I test the code , it make the file download to my computer not to my website"
] | [
"php"
] |
[
"How to handle a javax.persistence.NoResult Exception when there are no entries in database?",
"I have a database query and check by the email address if there is a user with this email address.\nI´m using Hibernate ORM.\nThis works so far. But if there are no users in the database, I get the following error:\n\njavax.persistence.NoResultException: No entity found for query\n\nQuery code:\npublic UserEntity findUserEntityByEmail(String email) {\n UserEntity userEntity = null;\n try {\n startOperation(false);\n userEntity = getSession().createQuery("SELECT u FROM UserEntity u WHERE u.email IN :email", UserEntity.class)\n .setParameter("email", email)\n .getSingleResult();\n } catch (HibernateException e) {\n handleException(e);\n } finally {\n getSession().close();\n }\n return userEntity;\n}\n\nI also understand the error message. But how can I work around this case, when there are no entries in the Database?\nDoes anyone know about this case?"
] | [
"java",
"hibernate"
] |
[
"How do I set the log level for ony one custom rails logger in rails",
"The examples I've seen for setting log level seems straightforward in most instances however how do I set the log level for my custom logger:\n\nconfig.active_record.logger = Logger.new(\"log/custom_log_file.log\")\n\nAccording to the rails guides I should be able to make one of the following calls\nto set a log level to debug, but I believe this is a global thing.\n\nconfig.log_level = :warn # In any environment initializer, or\nRails.logger.level = 2 # at any time"
] | [
"ruby-on-rails",
"ruby",
"logging"
] |
[
"Microsoft Bot Framework 403 BotDisabledByAdmin",
"Our bot, uploaded on a customer's tenant as a Microsoft Teams tenant sideloaded/custom app, then installed into different Teams teams, is getting a 403 "BotDisabledByAdmin" error when we make a Microsoft Bot Framework REST API request to send a message to users.\nThe bot was installed successfully and correctly messaged users. However, when attempting to message a new user who had not previously interacted with the bot, the error above occurred.\nDo you have any idea what could be causing this? We have looked at app permission policies & org-wide settings and everything should be OK.\nEdit\nI believe I have figured out the issue. The app is only allowed for certain users in the "Permission Policies" tab, which indicates these users can install the app. Actually, that's not what it does: it allows users not only to install, but also to interact with the app. So, if a user has a policy where "Custom apps" is turned off, that means they cannot message the app and the app cannot message them. I would really suggest Microsoft to fix this dialog in the Permissions tab, because it is very misleading. Installing is not the same thing as interacting.\nSource\nWe are now testing with "Custom apps" turned on in Permission Policies for all users, given that there's usually a propagation delay of about 24 hours I will give an update tomorrow.\nOur issue now is that while we want all users that are part of a team the bot is installed in to be able to use the bot, we do not want all users to be able to install the bot to a team. It is a tenant app, so any user can view it. How can we prevent users from installing the app to new teams but allow users to interact (e.g. message privately, click buttons, receive messages from) with the app that is part of their team?"
] | [
"botframework",
"microsoft-teams"
] |
[
"Making a histogram of string values in python",
"OK so I have six possible values for data to be which are '32', '22', '12', '31', '21' and '11'. I have these stored as strings. Is it possible for python to sort through the data and just make six bins and show how many of each I have? Or do the inputs to a histogram HAVE to be numerical?"
] | [
"python",
"string",
"histogram"
] |
[
"How to path through a page to any wordpress page in .htaccess?",
"I want to show any wordpress page If user access to site top. (site top is not made by wordpress)\n\nBUT I do NOT want to redirect the page, Or rewrite page uri.\n\nSo I try that problem by pass through in .htaccess, Like this.\n\nFrom: /\n\nTo: /wordpress/category1/ (post_id 112)\n\n# That show not found page BUT page uri is still \"http://example.com/\"\nRewriteEngine On\nRewriteRule ^$ /wordpress/category1 [PT]\n\n\nFrom: /\n\nTo: /wordpress/index.php?p=112 (that equals /wordpress/category1/)\n\n# That show expected page BUT page uri is rewrite to \"http://exmaple.com/wordpress/category1/\"\nRewriteEngine On\nRewriteRule ^$ /wordpress/index.php?p=112 [PT]\n\n\nI wanna...\n\nFrom: /\n\nTo: /wordpress/category1/\n\nRewriteEngine On\nRewriteRule ^$ /wordpress/category1 [some great magic to here]\n\n\nCan I do that?"
] | [
"wordpress",
".htaccess"
] |
[
"how can i disable bottom bar of tab",
"I want to disable bottom bar of android tab. I don't want it to be disabled permanently (using sure lock). I just want it to be disabled for an app because I have buttons in my app which will take the user back and home. I tried this but no use.\n\ngetWindow().getDecorView()\n .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);"
] | [
"android"
] |
[
"Maintain a user session, and authentication, when using RESTful services",
"I'm very new to enterprise java web app development, so please be gentle.\n\nA co-worker and I are working on a small application for our company, and this will run entirely within the private network which has zero exposure to the big internet. Using Spring and writing the server side as a set of REST APIs.\n\nRegarding REST authentication; I have done some research, including this topic which was very helpful.\n\nI plan on using HTTP basic authentication over SSL, but I am worried about performance. Our company has an LDAP user-lookup authentication service. With REST being stateless, obviously every REST call needs to be authenticated. If LDAP is slow for some reason, every action in the application will be impacted.\n\nI had an idea which I'm wondering if makes sense: \n\n\nHave the user log in once, then we generate a unqiue token that gets stored in a session table - including the user's userid, log-in timestamp and last-action timestamp.\nThe token gets sent back to the client, and it is up to the client to continue to re-send it back with every REST call (we could stick it into the HTTP authentication header).\nThe token is checked for validity before any REST call is executed.\nWith every successful REST call, the user's last-action timestamp is updated in the sessions table.\nAnother thread runs on a 60 second cycle, which checks for elapsed time since last-action for each user -- and if anyone is inactive for a period of time (e.g. two hours) -- their session token is wiped out.\n\n\nIs this a reasonable approach? I know I'd have to handle (or disallow) multiple logins from a single user from different clients; haven't thought through that yet."
] | [
"java",
"rest",
"authentication",
"restful-authentication"
] |
[
"AngularJS image upload preview without directive",
"I'm uploading files via service:\n\nvar addFile = function(files) {\n var deferred = $q.defer();\n var fd = new FormData();\n fd.append(\"file\", files[0]);\n $http.post(\"/files\", fd, {\n ***\n })\n .success(function(data, status, headers, config) {\n ***\n })\n .error(function(err, status) {\n ***\n });\n ***\n};\n\n\nand in controller I have something like:\n\nuplService.addFile($scope.files).then(function(url) {\n $scope.news.Photo = url;\n});\n\n\nand in HTML view:\n\n<input type=\"file\" name=\"file\" onchange=\"angular.element(this).scope().photoChanged(this.files)\" />\n\n\nbefore that I uploaded file on-the-go, when I select file it goes directly to server, but now I need to display it in my form when I select it, but upload later, all I see in web is using directives, but how could I organize it without using directives?"
] | [
"javascript",
"angularjs",
"image"
] |
[
"Decrease loading time large query with images",
"I have a table on my website which gives the visitor an overview of many football players including their photo, club and nation image. It loads these players from a database which has 14000 of them and shows only 30 players per page. Now the problem is, it takes too long to load these players and their 3 images. I already tried Lazyloader which took away some of the loading time but not enough. \n\nDo you have any tips how I can decrease the loading time of my page?\n\nEdit* Link to page loading stats: http://nl.tinypic.com/r/x51hl0/8\n\nIt seems that the request loading time causes 76% (over 1 sec.) of the loading time. How do I decrease this?"
] | [
"mysql",
"image"
] |
[
"Multiple xcode versions in Lion OSX",
"I want to install xcode 4.1 in my iMac OSX Lion. But in my iMac, I have Xcode 4.2.1. How to install iOS 4.1 but not override Xcode 4.2.1?"
] | [
"xcode",
"osx-lion",
"multiple-versions"
] |
[
"Binding an Event to Child of ListView and Changing the ListView based on the Click action in android",
"I have a ListView and an Adapter to handle the ListView. I want to bind the Click Event to the child(let's say 'Button') of ListView. Whenever the button is Clicked, I need to apply the changes on the View of ListView. \n\nFor Example, \n\nActivity:\n\nClass SampleActivity extends Activity{\n ListView listView;\n SampleAdapter adapter;\n List<SampleObject> sampleObjects;\n\n onCreate(){\n sampleObjects = new ArrayList<SampleObject>;\n listView = findViewById(R.id.listView);\n SampleAdapter adapter = new SampleAdapter(context, R.layout.list_view_item, sampleObjects);\n listView.setAdapter(adapter)\n }\n\n}\n\n\nLayout of ListViewItem\n\n\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:orientation=\"horizontal\"\n android:padding=\"5.0dip\">\n\n <TextView\n android:id=\"@+id/sampleName\"\n android:layout_width=\"fill_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_centerVertical=\"true\"\n android:layout_marginLeft=\"3.0dip\"\n android:layout_weight=\"1\" />\n\n <Button\n android:id=\"@+id/sampleButton\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:text=\"@string/btnText\" />\n\n</LinearLayout>\n\n\nAdapter Class\n\npublic class SampleAdapter extends ArrayAdapter<SampleObject>{\n public SampleAdapter(Context context, Integer resourceId, List<SampleObject> objects ){\n super(context, resourceId, objects);\n }\n\n @Override\n public View getView(final int position, View convertView, ViewGroup parent) {\n if (convertView == null) {\n LayoutInflater myInflater = (LayoutInflater) getContext().getSystemService(getContext().LAYOUT_INFLATER_SERVICE);\n convertView = myInflater.inflate(R.layout.friends_list_aitem, null);\n }\n SampleObject currentSampleObject = getItem(position);\n TextView name = (TextView) convertView.findViewById(R.id.sampleName);\n name.setText(currentSampleObject.getName());\n Button button = (Button) convertView.findViewById(R.id.sampleButton);\n button.setOnClickListener(new OnClickListener(){\n public void onClick(View view){\n // Here I want make Some Changes on the name of currentSampleObject. and I want to apply the changes on the View of ListItem\n }\n });\n }\n}"
] | [
"android",
"listview",
"android-listview"
] |
[
"Is it better to use local variables or chain methods inline?",
"If I have a series of method invocations, the value of each used for the next call, should I store them in local variables, like so:\n\nDynamicForm filledForm = Form.form().bindFromRequest();\nString shareIdStr = filledForm.get(\"data[shareId]\");\nUUID shareId = UUID.fromString(shareIdStr);\nShare share = Share.find.byId(shareId);\n\n\nor as a single invocation chain, like so:\n\nShare share = Share.find.byId(UUID.fromString(Form.form().bindFromRequest().get(\"data[shareId]\")));\n\n\nIn this case, the only value that is used again is share. Perhaps the answer is somewhere in-between, or is something completely different. What's your opinion?"
] | [
"java",
"coding-style"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.