texts
sequence | tags
sequence |
---|---|
[
"Populate an array using dynamic variables names in Powershell",
"In this new adventure, I need to populate this matrix fast as i can.\nSo in my mind what i need to do about the variables is:\n\nfor ($r = 0 ; $r -lt 5 ; $r++){\n new-variable r$r\n for ($i = 0 ; $i -lt 5 ; $i++){\n $rand = Get-Random -Minimum 0 -Maximum 50\n r$r += \"$rand,\"\n }\n}\n\n\nBut it doesn't work, it tells me that r0 > is not a known cmdlet.\nThis should create r0...r4 variables, wich means row0...row4 and each rn would be filled with a Random number followed by a comma.\nHow to do it?\nAnd...\nI really don't know if I'm doing my matrices the right way, but this is what I have now:\n\n$r1 = \"\"\n for ($i = 0 ; $i -lt 4 ; $i++){\n $rand = Get-Random -Minimum 0 -Maximum 50\n $r1 += \"$rand,\"\n }\n $r1 = $r1.Replace(\" \",\",\")\n $r1 = $r1.TrimEnd(',')\n# Write-Host $r1\n\n$r2 = \"\"\n for ($i = 0 ; $i -lt 4 ; $i++){\n $rand = Get-Random -Minimum 0 -Maximum 50\n $r2 += \"$rand,\"\n }\n $r2 = $r2.Replace(\" \",\",\")\n $r2 = $r2.TrimEnd(',')\n# Write-Host $r2\n\n$matrix = @(($r1),($r2))\nforeach ($g in $matrix) {$g}"
] | [
"powershell",
"matrix",
"populate",
"dynamic-variables"
] |
[
"Azure Web Role-Some files are not being added to cspkg file",
"Finally after days of trial and error, I managed to get an existing MVC project converted into Azure Web Role. Deployed and it works, mostly. But my biggest issue is that the cspkg is missing some files that are part of the MVC project (they are listed in csproj). It appears that some files are being left out randomly. For example, if a folder has 4 files, I see only one of that included in the cspkg. Is there a way to force inclusion of these files other than listing them in csproj. I noticed that Visual Studio web role deployment process goes through the list of files in csproj. When a file listed in csproj is not found, cspkg creation throws errors. So my assuption was that if a file was listed in csproj and if the file actually exists, it should find its way to cspkg."
] | [
"deployment",
"webrole"
] |
[
"Vue a-href download does not download",
"Hey I am really new to Vue and for this project I have a DOWNLOAD BUTTON from where the users can download a file. When I click on the DOWNLOAD BUTTON it keeps on opening the file in the same browser rather downloading it. Is their a way to make a-href or button function to download the file?\nMy code on jsFiddle https://jsfiddle.net/ez36jmx5/10/ .\nView\n<div id="app">\n <a href="https://homepages.cae.wisc.edu/~ece533/images/airplane.png" download>DOWNLOAD</a>\n <br><br>\n <button v-on:click="clickedDownload()"> <!-- opens files in new tab -->\n DOWNLOAD\n </button>\n</div>\n\nMethod\nnew Vue({\n el: "#app",\n data: {\n \n },\n methods: {\n clickedDownload(){\n var fileName='https://homepages.cae.wisc.edu/~ece533/images/airplane.png';\n window.open(fileName, 'Download');\n }\n }\n})"
] | [
"javascript",
"html",
"vue.js"
] |
[
"Procedure fails but works without variables",
"At the moment I'm working with databses and I got a strange error wirth procedures. I have create one which gets three parameters of the type VARCHAR: title, interpret, album. Here is the code:\n\nBEGIN\n INSERT IGNORE INTO Interpret (Name) VALUES (interpret);\n SET @idInterpret := (SELECT id FROM Interpret WHERE Name = interpret);\n\n INSERT IGNORE INTO Album (Name, Interpret) VALUES (album, @idInterpret);\n SET @idAlbum := (SELECT id FROM Album WHERE Name = album AND Interpret = @idInterpret);\n\n INSERT INTO Lied (Name, Album, Interpret) VALUES (title, @idAlbum, @idInterpret);\nEND\n\n\nIf I start this procedure I get an error which says that the album field can not be null (which is right) but it shouldn't be null because I read the value from the table above. If I call exact the same lines of SQL with real data (not as procedure with varaibles) all works great. Do you have any ideas why this happens?"
] | [
"mysql"
] |
[
"jQuery set checkbox value to URL & get the value in PHP to be an array & query it using NOT IN",
"I have this multiple checbox below\n\n\n\nAnd you can see PDF image there, I set it to be link\n\n<a class=\"openPO\" id=\"<?php echo $dData['po_no']; ?>\"><img src=\"../assets/img/pdf.png\"/></a>\n\n\nAnd now I'm using jQuery to get uncheck checbox and set it to URL value.\n\n$('.openPO').on('click', function()\n{\n var ID = $(this).attr('id');\n\n var final = '';\n\n $('.chkPrint'+ID+':not(:checked)').each(function(){ \n var values = $(this).val();\n final += values;\n });\n\n alert(final);\n\n $(\"#\"+ID).attr(\"href\", \"openPO?po_no=\"+ID+\"&chkPrint=\"+final);\n});\n\n\nResult of set URL\n\nhttp://localhost/nok/PRO/openPO?po_no=BP180300001&chkPrint=RQ201803000003RQ201803000004\n\n\nWhat I want is:\n\nNow on PHP, I want to get the chkPrint to be array and set it to query\n\nSELECT * FROM tb_pro_request WHERE requestid NOT IN('$chkPrint');\n\n\nHow to do that?"
] | [
"php",
"jquery",
"mysql"
] |
[
"How to modify method return value in all derived classes?",
"Imagine you have a class hierarchy as:\n\nclass Base\n{\n public virtual string GetName()\n {\n return \"BaseName\";\n }\n}\n\nclass Derived1 : Base\n{\n public override string GetName()\n {\n return \"Derived1\";\n }\n}\n\nclass Derived2 : Base\n{\n public override string GetName()\n {\n return \"Derived2\";\n }\n}\n\n\nIn most appropriate way, how can I write the code in a way that all \"GetName\" methods adds \"XX\" string to return value in derived class?\n\nFor example: \n\n Derived1.GetName returns \"Derived1XX\"\n\n Derived2.GetName returns \"Derived2XX\"\n\n\nChanging the code of GetName method implementation is not good idea, because there may exist several derived types of Base."
] | [
"c#",
".net",
"oop",
"design-patterns"
] |
[
"LibGDX Scene2D: Applying Actions to Actors in separate class",
"I'm having trouble getting a MoveToAction to work on an Actor (menuBackground), when the Actor is in a separate class. I have attached relevant code below- which doesn't make the Actor move at all.\n\nI have had success in apply other actions to the root stage in the MainMenuScreen class, and to a different Actor (Button) in the MainMenuScreen class, but have had no success applying actions to Actors in a separate class.\n\nI've tried putting the MoveToAction in the act(float delta) method within the MenuBackground class, but that didn't work either. Neither did assigning the MoveToAction to the menuBackground from within the MainMenuScreen class.\n\nNote that I am making a call to super.act(delta); within my MenuBackground class.\n\nI would ultimately like to put the code for the MoveToAction within the Actor MenuBackground class, to make things neat and tidy.\n\nCheers.\n\nClass containing stage:\n\npublic class MainMenuScreen implements Screen\n{\n private Stage stage;\n public MainMenuScreen()\n {\n stage = new Stage(new FitViewport(800, 480));\n Gdx.input.setInputProcessor(stage);\n\n menuBackground = new MenuBackground();\n MoveToAction moveToAction = new MoveToAction();\n moveToAction.setPosition(242f, 276f);\n moveToAction.setDuration(10f);\n menuBackground.addAction(moveToAction);\n stage.addActor(menuBackground);\n\n @Override\n public void render(float delta) \n {\n Gdx.gl.glClearColor(0, 0, 0, 0);\n Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); \n stage.act(Gdx.graphics.getDeltaTime());\n stage.draw();\n }\n...\n}\n\n\nActor Class:\n\npublic class MenuBackground extends Actor\n{\n private Texture menuBackgroundTexture;\n private float actorX;\n private float actorY;\n\n public MenuBackground()\n {\n menuBackgroundTexture = new Texture(Gdx.files.internal(\"data/menuTitleTexture.png\")); \n actorX = 242f;\n actorY = 350f;\n setBounds(actorX,actorY,316,128); \n }\n\n @Override\n public void draw(Batch batch, float alpha)\n {\n batch.draw(menuBackgroundTexture,actorX,actorY);\n }\n\n @Override \n public void act(float delta)\n {\n super.act(delta); \n }\n...\n}"
] | [
"java",
"libgdx",
"scene2d"
] |
[
"How to calculate unix timestamp in days/minutes/seconds?",
"I've got script to compare login date/time and logout date/time after that the difference between these two values is added to totaltime column in MSSQL 2005 table. For example: If the user is online just a few seconds, it will add a value of around 98 unix timestamp for example. So how to display that value onto the website as human reading: days/minutes/seconds if possible?\n\nThanks a lot for checking my question. It will be greatly appreciated to help me out.\n\nThat's my rank script where I want to include that:\n\nfunction TotalTimeRank()\n{\n $db = $this->database[GDB];\n $num_rows = $db->doQuery('SELECT TOP 100 ID, Name, (SELECT SUM(CoolPoint) FROM DATA WHERE DATA.User = INFO.User AND DATA.Auth IN(1, 2)) as Points FROM INFO WHERE INFO.User NOT IN (1199,16300) ORDER BY Points DESC');\n if ($num_rows == -1)\n {\n $db->getError();\n return;\n }\n\n $n = 1;\n $content = '';\n while ($row = $db->doRead())\n {\n $data = array('rank-id' => $row['Num'], 'rank-pos' => $n++, 'rank-name' => $row['Name'], 'rank-points' => number_format(intval($row['Points'])));\n $content .= Template::Load('pointrank-' . ($n % 2 == 1 ? 2 : 1), $data);\n }\n\n $this->content = Template::Load('total_pointrank', array('ranks' => $content));\n}\n\n\nSo, what's the best way to include what I want to my rank script above so I can display total time online per user based on the totaltime column in my data table? I know how to include it but I got confused how to convert it to human reading in this function above."
] | [
"php",
"timestamp"
] |
[
"Notification to View from ViewModel using MVVM Light",
"In my silverlight application I need to send a notification from a ViewModel to a View. In response to it a method on a UI control should be called. I know about 2 ways to accomplish this:\n\n1) Raise an event in the ViewModel and handle it in the View's code behind.\n2) Send a message from the ViewModel (using the MVVM Light messaging support) and respond to this message in the View's code behind.\n\nI'd like to know if there is a way to accomplish this without using code in the View's code behind, for instance through some kind of data binding in the XAML?\n\nPlease share any ideas.\n\nAdditional info about what the View should do when it receives notification from ViewModel\nIn the XAML of the View I declare an instance of a custom Silverlight grid control which has the following method:\npublic void FileExportFinished(bool fileExportSucceeded)\nI want to call this method from the XAML in response to the notification received from the ViewModel passing a boolean value received with the notification."
] | [
"silverlight",
"mvvm",
"mvvm-light"
] |
[
"How to check whether the uploaded file is XLS file or not?",
"I have a file uploader module. The UI is created using simple HTML and Javascript.\nServer side I am using Java code. I want to check the type of the uploaded file."
] | [
"java",
"javascript",
"html",
"file-upload"
] |
[
"Why is a .js file generated for a .ts file that only has an interface",
"Let's say I have a file adder.ts which looks like:\n\nimport { Operand } from './operand';\n\nexport interface Adder {\n add(op1: Operand, op2: Operand): Operand;\n}\n\n\nAnd my tsconfig.json looks like:\n\n{\n \"compilerOptions\": {\n \"declaration\": false,\n \"module\": \"commonjs\",\n \"outDir\": \"./dist\",\n \"target\": \"es6\",\n \"sourceMap\": true\n },\n \"include\": [\n \"src/**/*\"\n ]\n}\n\n\nWhen I transpile this code I would expect to receive only dist/adder.d.ts. However, there is also a dist/adder.js generated with the contents:\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\n\n\nWhy is this file generated? What purpose does it serve? At the end of the day I suppose I don't really care much because it would never actually get required/loaded and will be pruned out by any bundler. The only reason I noticed it was because my coverage tool was reporting this file as uncovered."
] | [
"typescript"
] |
[
"The JUnit report missed the karate.call info after * eval if (xxx)",
"I use the \"* eval if \" keyword to handle my complex logic, however, the JUnit HTML report missed the karate.call('delete-user.feature') process.\n\nThe official example: \n\n* eval if (responseStatus == 200) karate.call('delete-user.feature')\n\n\nThen, I can't find the 'delete-user.feature' running info in the JUnit HTML report. And the report stopped in this sentence even though it indeeds get 'delete-user.feature' called (it's logged in the console as expected)."
] | [
"karate"
] |
[
"Speed limit for scroll view",
"My app scrolling is super fast!\nHow can I limit the scroll speed of a scroll view in my android app?\nThe scroll can be very fast and it's meaningless to scroll in that speed."
] | [
"android",
"android-layout"
] |
[
"Is there an \"app\" tag in Django templates",
"Are there any tags in Django templates to show the current app (e.g. blog)?\n\nSo I can do something like\n\n<nav>\n <li {% if request.app == \"index\" %}class=\"selected\"{% endif %}>Home</li>\n <li {% if request.app == \"blog\" %}class=\"selected\"{% endif %}>Blog</li>\n</nav>"
] | [
"python",
"django",
"django-templates"
] |
[
"is it legit to establish a relationship between two subclasses which sharing the same superclass (IS-A relationship)?",
"I have a question regarding a project I am doing and hope you could provide some help:)\n\nThe police were looking for a murder suspect after a person was shot and killed yesterday. The only clue is that the victim has left a note with five people's names on it, and the police needed to find these five people's information by searching on the citizen database (name is not unique so there may be more than five results. To uniquely identify someone you need the citizen ID). After finding the murderer, the police need to make changes to the murderer's criminal record. I am wondering how could I do this?\n\nSince the entity Victim and the entity Murder_suspects both have the same attributes as the entity Citizen, my original plan was to make victim and murder_suspects become two subclasses sharing the same superclass(citizen), that is to say, victim ISA citizen and murder_suspects ISA citizen. However, I am not sure if it is legit to establish a relationship between two subclasses which share the same superclass (IS-A relationship). Also, I think the primary key of murder_suspects should be citizen.name instead of citizen.id, but I don't think that the subclass's primary key could be different from its superclass's primary key. I am wondering if anyone could help with my confusion and give me some suggestions, thanks in advance:)!\n\nP.S. To make it more clear, the entity citizen has the following attributes: id, name, phone_number, address, criminal_record, etc.\n\nMany thanks for any help anyone is able to provide:)"
] | [
"sql",
"entity-relationship",
"er-diagrams"
] |
[
"Not scrolling to bottom of the page on adding new element",
"On adding new element on the last child of my `container' on the time scroll appears. I'd like to scroll-down to put the new element on browser view.\n\nI tried using '$anchorScroll` but that doesn't work.\n\nHTML\n\n<div class=\"galleryMenu\">\n <!-- <a class=\"live\" ng-click=\"galleryMenu('live')\" href=\"#\">live</a>\n <a class=\"visual\" ng-click=\"galleryMenu('visual')\" href=\"#\">visuals</a> -->\n <a class=\"projects\" ng-click=\"galleryMenu('projects')\" href=\"#\">projects</a> //clicking and calling galleryMenu function\n</div>\n<!-- Focus needs to be applied here, height of element is 180px -->\n<div class=\"appGallery\" ng-show=\"galleryShow\" id=\"anchor3\">\n <a ng-click=\"galleryChanger('prev')\" class=\"prev\" href=\"#\">prev</a>\n <a ng-click=\"galleryChanger('next')\" class=\"next\" href=\"#\">next</a>\n</div>\n\n\nJS\n\n\"use strict\";\n\nangular.module(\"tcpApp\")\n .run(['$anchorScroll', function($anchorScroll) {\n $anchorScroll.yOffset = 180; //running here.\n }])\n .controller(\"homeController\", ['$scope','server', '$anchorScroll', '$location', function ($scope, server, $anchorScroll, $location) {\n\n $scope.galleryMenu = function (gallery) {\n\n var newHash = 'anchor3';\n if ($location.hash() !== newHash) {\n $location.hash('anchor3');\n } else {\n $anchorScroll();\n }\n\n }]);"
] | [
"html",
"css",
"angularjs"
] |
[
"Computed column, or update column by trigger to keep statistics",
"For every user, our application calculates some statistics, like how many times they logged in or how many answers they got wrong in the quiz, ... it can be all sorts of things. The app runs on SQL Server and .NET Entity Framework 6.1\n\nRight now, the statistics are calculated on demand but as the user base grows, this makes the reporting part of the application ever slower.\n\nWe were wondering about either using computed columns (either persisted or not persisted) or use a trigger to store these values with the user.\n\nHow would you go about doing this? It seems to me that computed columns may be easier to implement, but they would get recalculated every time I read the User from the table, which may not be very much faster than what we're doing now. Since we would fit an entire SQL query into the computed column, persisting the column does not seem a right fit either (how will SQL Server deduce that it should update the calculation?).\nA trigger on certain actions seems to be a more logical fit for me.\n\nFor the sake of the argument, suppose all the calculated statistics are count(*) and sum(*) of values in other tables and nothing more interesting than that."
] | [
".net",
"sql-server",
"calculated-columns"
] |
[
"How to get methods in source order",
"I have a custom annotation that I want to use at runtime to display object properties. I would like them to appear in source code order but reflection does not guarantee any particular order for Class.getMethods().\n\nIs there a way, either via reflection or via annotation processing, to get the methods in source order (at least per class if multiple levels of inheritance are involved)?\n\nAs an example, say I had an interface Property\n\n\n\npackage test;\n\npublic @interface Property {\n public String name();\n}\n\n\nand a class using that annotation\n\npackage test;\n\npublic class MyObject {\n @Property(name = \"First\")\n public void getFirst() {}\n\n @Property(name = \"Another\")\n public void getAnother() {}\n}\n\n\nI'd like to reliably get the property \"First\" before the property \"Another\".\n\nI know I can add an ordering property to my annotation and sort on that but I have a lot of classes that would need to be updated if that is required so I'm looking for a generic method to achieve this without modifying individual annotations."
] | [
"java",
"annotations",
"annotation-processing"
] |
[
"How do I conditionally lock in Java?",
"I have been making use of Java's synchronized blocks to make parts of my code thread safe. I am porting a data structure to java that can usually use synchronized blocks, but I don't always know how to use them in a typical Java way.\n\nHere is an example of one scenario:\n\nmyMethod (Bool useLock)\n {\n if (useLock)\n {\n //locks the following section of code until unlocked.\n lockObject.lock();\n }\n\n //do more stuff....\n\n if (useLock)\n {\n //unlocks exclusive control of code.\n lockObject.unlock();\n }\n }\n\n\nHow do I do an equivalent of this in Java? In this code sometimes I want to lock and sometimes I don't, but I want to be smart about it and not have to write two versions of the same code. Are there other ways of locking in Java other than using synchronized blocks?"
] | [
"java",
"locking",
"synchronized"
] |
[
"Flip an UIImageView horizontal on tap will result in \"reversed\" gesture recognizer and only works 1x",
"I implemented giphy stickers like instagram in my camera app.\n\nI want to flip a sticker horizontally on tap with this code:\n\n@objc func tapGesture(_ gesture: UITapGestureRecognizer) {\n guard let gestureView = gesture.view else { return }\n gestureView.transform = CGAffineTransform(scaleX: -1, y: 1)\n}\n\n\n1: This works only one time. It can not be reversed flipped.\n\n2: I have added several gesture recognizer. When I flip the image, the gestures are also reversed (rotating in the different direction, etc)\n\nWhat is the best way to flip and reflip the image, and keep the original gesture recognizer behavior?"
] | [
"swift",
"uigesturerecognizer"
] |
[
"When submit Stripe form \"Cannot charge a customer that has no active card\"",
"I'm trying to get Stripe work with a Symfony2 project. When I submit my form, I got the error \n\n\n Cannot charge a customer that has no active card\n\n\nI don't know how to resolve it... :)\nMy controller\n\n<?php\n\nnamespace L3O1\\ProjetBundle\\Controller;\n\nuse L3O1\\ProjetBundle\\Entity\\Payment;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;\nuse FOS\\UserBundle\\FOSUserEvents;\nuse FOS\\UserBundle\\Event\\GetResponseUserEvent;\nuse FOS\\UserBundle\\Model\\UserInterface;\n\nclass PaymentController extends Controller {\n\n public function chargeAction(Request $request, $id) {\n $token = $request->request->get('stripeToken');\n $email = $request->request->get('stripeEmail');\n $amount = $request->request->get('amount');\n\n $em = $this->getDoctrine()->getManager();\n $projet = $em->getRepository('L3O1ProjetBundle:Projet')->find($id);\n\n $projet->setSommeDepart($projet->getSommeDepart()+$amount);\n $em->persist($projet);\n\n if($this->getUser() != null) {\n $payment = new Payment();\n $payment->setUserId($this->getId());\n $payment->setProjetId($projet->getId());\n $payment->setAmount($amount);\n $payment->setDate(new \\Datetime());\n $em->persist($payment);\n }\n\n $em->flush();\n\n \\Stripe\\Stripe::setApiKey('mykey');\n\n $customer = \\Stripe\\Customer::create(array(\n 'email' => $email,\n 'source' => $token\n ));\n\n $charge = \\Stripe\\Charge::create(array(\n //amount in cent\n 'amount' => $amount*100,\n 'currency' => 'eur',\n 'customer' => $customer->id,\n ));\n\n return $this->render('L3O1ProjetBundle:Payments:charge.html.twig');\n }\n}\n\n\nMy form\n\n{# Stripe payment #}\n <script src=\"https://checkout.stripe.com/checkout.js\"></script>\n <form id=\"chargeForm\" methode=\"POST\" action=\"{{ path('l3o1_projet_charge', { 'id': app.request.get('id') }) }}\">\n <input type=\"number\" name=\"amount\" id=\"custom-donation\" placeholder=\"Enter an amount\" min=\"1.00\" step \"10.00\"/>\n <input type=\"hidden\" name=\"stripeToken\" id=\"stripeToken\" value=\"\">\n <input type=\"hidden\" name =\"stripeEmail\" id=\"stripeEmail\" value=\"\">\n <button id=\"customButton\" class=\"btn btn-lg\"> Back this project </button>\n\n <script>\n var handler = StripeCheckout.configure({\n key:'mykey',\n //image\n token: function(token, args) {\n document.getElementById(\"stripeToken\").value = token.id;\n document.getElementById(\"stripeEmail\").value = token.email;\n document.getElementById(\"chargeForm\").submit();\n }\n })\n\n document.getElementById('customButton').addEventListener('click', function(e) {\n handler.open({\n name: '{{ projet.titre }}',\n description: '{{ projet.shortdesc }}',\n amount: document.getElementById('custom-donation').value*100,\n currency: 'eur',\n });\n e.preventDefault();\n });\n </script>\n\n\nThanks for your help !"
] | [
"php",
"symfony",
"stripe-payments"
] |
[
"Got an error \"Checking for program pkg-config : not found\" during execution \"bitbake image_name\"",
"I want to build the yocto image with some additional layers and additional g-streamer functionality for nunki-PHYboard (IMX6). I have added the meta-freescale layer and accepted for build \"gstreamer-imx\" module and \"imx-codec\".\n\nDuring execution the bitbake build I have got an pkg-config error.\nHere is some screenshots:\nhttps://i.imgur.com/2aEUJKq.png\nhttps://i.imgur.com/VQOqOhJ.png\n\necho $PKG_CONFIG_PATH\n /usr/local/lib/x86_64-linux-gnu/pkgconfig\n\npkg-config --version \n 0.29.1\n\nHow to avoid this error?"
] | [
"build",
"yocto",
"bitbake",
"pkg-config"
] |
[
"How to include dependencies with typescript in rollup?",
"I'm setting up a typescript project using rollup. Below is my rollup config so far.\n\nNow I need to include jQuery. With typescript alone I'd install @types/jquery and that would be it. \n\nRollup however does not seem to include jQuery in bundle it creates, and even though tslint has no objections, I get $ is not defined at runtime. How can I pack jquery along with rest of js?\n\nimport * as fs from 'fs';\nimport resolve from 'rollup-plugin-node-resolve';\nimport typescript from 'rollup-plugin-typescript2';\nimport serve from 'rollup-plugin-serve';\nimport livereload from 'rollup-plugin-livereload';\nimport scss from 'rollup-plugin-scss';\n\nimport sass from 'node-sass';\nimport postcss from 'postcss';\nimport autoprefixer from 'autoprefixer';\nimport CleanCSS from 'clean-css';\n\nexport default {\n input: './src/main.ts',\n output: {\n file: './bundle.js',\n format: 'iife',\n name: 'monoblockPanel'\n },\n plugins: [\n resolve(),\n typescript(),\n scss({\n output: function(styles, styleNodes) {\n postcss([autoprefixer]).process(styles).then(result => {\n result.warnings().forEach(warn => {\n console.warn(warn.toString());\n });\n let minified = new CleanCSS({}).minify(result.css);\n fs.writeFileSync('./styles.css', minified.styles);\n });\n }\n }),\n serve({\n host: '127.0.0.1',\n port: 4201,\n contentBase: '.'\n }),\n livereload()\n ]\n}"
] | [
"typescript",
"rollup"
] |
[
"Layer text on top of linked image without using CSS relative positioning?",
"I wrote a Booking Slots Calendar for fun some time ago. On the page is a live demo.\nMy aim is to layer text over a hyperlinked image within a table cell without using CSS positioning. That's a bit of a mouthfull, let me explain...\n\nEach green or orange block on the calendar indicates a bookable date, and each one is a with the relevant coloured image, each hyperlinked to the relevant date. Overlaying the day number on top of the image was not easy and the only cross browser solution I found was to add a span tag and position it relatively. The problem with this is that the area under the number is non-clickable and it confuses people sometimes because they expect everything within the cell to be clickable. Here is a sample cell: \n\n<td width='21' valign='top' class='days'>\n <a href='calendar.php?month=05&amp;year=2013&amp;day=06'>\n <img src='images/block_free.gif' title='This day is free' border='0' alt=''></a>\n <span>6</span>\n</td>\n\n\nIs there a better way to acomplish this?"
] | [
"javascript",
"css"
] |
[
"Plotting a raster with exponential or quantile color ramp diverging around zero",
"I am using the R function levelplot() from the rasterVis package to plot a stack of three rasters with a single diverging color ramp. I would like to change the scale of a raster color ramp so that the map accentuates differences in lower values. This can be done by non-linear binning of the color breaks.\n\nI'm using the code from a gist written by @jbaums (code included below). Any suggestions on how to adjust the color ramp in this code so that the breaks follow 2^x but the min and max values are preserved? It would seem that changing the sequences of s (below) would have the desired effect.\n\ndiverge0 <- function(p, ramp) {\n # p: a trellis object resulting from rasterVis::levelplot\n # ramp: the name of an RColorBrewer palette (as character), a character \n # vector of colour names to interpolate, or a colorRampPalette.\n require(RColorBrewer)\n require(rasterVis)\n if(length(ramp)==1 && is.character(ramp) && ramp %in% \n row.names(brewer.pal.info)) {\n ramp <- suppressWarnings(colorRampPalette(brewer.pal(11, ramp)))\n } else if(length(ramp) > 1 && is.character(ramp) && all(ramp %in% colors())) {\n ramp <- colorRampPalette(ramp)\n } else if(!is.function(ramp)) \n stop('ramp should be either the name of a RColorBrewer palette, ', \n 'a vector of colours to be interpolated, or a colorRampPalette.')\n rng <- range(p$legend[[1]]$args$key$at)\n s <- seq(-max(abs(rng)), max(abs(rng)), len=1001)\n i <- findInterval(rng[which.min(abs(rng))], s)\n zlim <- switch(which.min(abs(rng)), `1`=i:(1000+1), `2`=1:(i+1))\n p$legend[[1]]$args$key$at <- s[zlim]\n p$par.settings$regions$col <- ramp(1000)[zlim[-length(zlim)]]\n p\n}\n\n\nAnd here is some code that applies this function:\n\nlibrary (rasterVis)\n\nras1 <- raster(nrow=10,ncol=10) \nset.seed(1) \nras1[] <- rchisq(df=10,n=10*10) \nras2 <- ras1*(-1)/2 \ns <- stack(ras1,ras2) \n\np <- levelplot(s, par.settings=RdBuTheme())\n\ndiverge0(p, ramp='RdBu')"
] | [
"r",
"raster",
"levelplot",
"rastervis"
] |
[
"Interweaving vector of binary representations in C++",
"I have a templated function in C++ called weave which takes two unsigned chars and interweaves their binary expansions and returns a unsigned short. It can also take two unsigned shorts and interweaves their binary expansions to return an unsigned long. Here is what I wrote:\n\ntemplate<class Typeout, class Typein>\nTypeout weave(Typein lhs,Typein rhs)\n{\n//Need to check that Typeout contains enough storage to contain 2*Typein:\nassert(sizeof(Typeout)>=2*sizeof(Typein));\n\nTypeout weaved = 0;\nfor(int k=0;k<sizeof(Typein)*8;k++)\n{\n //weave in the kth element of rhs and lhs.\n weaved |=(Typeout(rhs & (Typein)(1<<k)) << k)| (Typeout(lhs & (Typein)(1<<k)) << (k+1));\n}\nreturn weaved;\n};\n\n\nNow I'm having trouble with weaving together vectors. I want to write a function called weave that given a vector of chars interweaves all of their binary expansions and returns this. For instance given a vector of unsigned chars of length 4 it should interweave their binary expansions and return a representation of this. I want this to work for vectors of chars of length greater than 8 so I can no longer keep them in a unsigned long long. I guess I need to return a vector?? But I'm not sure how to cut the resulting binary expansion up.\n\nI'm new to C++ so please feel free to correct the code or give me advice on it. \n\nThanks in advance."
] | [
"c++",
"templates",
"binary"
] |
[
"Techniques for Caching SQL Query Data",
"Having read some on this subject:\n\nCaching MySQL queries\n\nhttp://www.danga.com/memcached/\n\nMy SQL Caching problem:\nhttp://www.petefreitag.com/item/390.cfm\n\nhttp://framework.zend.com/manual/en/zend.cache.html#zend.cache.introduction\n\nI have a very unique (narrow) set of Queries and I think I could implement some caching quite easily within my current FastCGI C API executables (NOT PHP).\n\nZend describes their framework as:\ncache records are stored through backend adapters (File, Sqlite, Memcache...) through a flexible system of IDs and tags.\n\nHOW is this implemented?\n\nSince the same query can return different results if the Table has been changed, I need to monitor not only Queries, but UPDATE, INSERT and DELETE also (MySQL for now) Since this only happens from one of my processes, I could easily add a statement that deletes the cache when a table change is made.\n\nOnly SELECTs are permitted by the clients, in which case I could hash the queries and store them in a hash table or btree index along with a pointer to the file containing the results.\n\nIs there a better way?"
] | [
"mysql",
"caching",
"b-tree"
] |
[
"pass collection of records to policy",
"this is my tables structure :\n\ni want to get all Request State Records where Request_status.Department_id equals with User.Department_id . and user only can see own request_state records i defined a policy to handle this job but this policy only can handle 1 request_state record . this policy can't handle array of request_state Model ! how can i use get() instead of first()\nPolicy :\npublic function view(User $user, RequestState $requestState)\n{\n return$user->department_id===$requestState->department_id&&$user->hasRole('department');\n }\n\nController :\n public function show_request()\n {\n $RequestState=RequestState::where('department_id',auth()->user()->department_id)->first();\n nullable($RequestState)->getOrSend(function (){\n return Responder::requestDoesNotFound();\n });\n if(auth()->user()->can('view',$RequestState)){\n return 'ok';\n }\n\n }"
] | [
"laravel"
] |
[
"How can we get the value from the async Action Method in c#",
"I have a async method like \n\n[HttpPost]\npublic async Task<JsonResult> AddTwoIntegers(int param1, int param2)\n{ \n var result = await (param1 + param2);\n return Json(new {finalValue: result}, JsonRequestBehavior.AllowGet) \n}\n\n\nNow in another Action Method i am calling this function\n\npublic ActionResult SomeFunction(string userSettingsViewModel)\n{ \n Task<JsonResult> jsonData = this.AddTwoIntegers(5,10); \n\n jsonData.ContinueWith(task =>\n {\n JsonResult result = task.Result;\n if (result.Data.ToString() == \"\") {\n var data = result.Data;\n } \n });\n\n // I want to retrieve the value returned and use that value in some operation.\n\n return Json(\"Success\", JsonRequestBehavior.AllowGet);\n}\n\n\nHow can i get the returned value from the Action Result."
] | [
"c#",
"asp.net",
"asp.net-mvc"
] |
[
"Performance of DrawingVisual vs Canvas.OnRender for lots of constantly changing shapes",
"I'm working on a game-like app which has up to a thousand shapes (ellipses and lines) that constantly change at 60fps. Having read an excellent article on rendering many moving shapes, I implemented this using a custom Canvas descendant that overrides OnRender to do the drawing via a DrawingContext. The performance is quite reasonable, although the CPU usage stays high.\n\nHowever, the article suggests that the most efficient approach for constantly moving shapes is to use lots of DrawingVisual instances instead of OnRender. Unfortunately though it doesn't explain why that should be faster for this scenario.\n\nChanging the implementation in this way is not a small effort, so I'd like to understand the reasons and whether they are applicable to me before deciding to make the switch. Why could the DrawingVisual approach result in lower CPU usage than the OnRender approach in this scenario?"
] | [
"wpf",
"performance"
] |
[
"Is it possible to populate a saved document?",
"I have the following mongoose schema for a Book which references an Author:\nBook.js:\nconst mongoose = require("mongoose");\nconst bookSchema = mongoose.Schema({\n // other irrelevant fields...\n author: {\n type: mongoose.Schema.Types.ObjectId,\n ref: 'Author'\n },\n});\nmodule.exports = mongoose.model("Book", bookSchema);\n\nThen, I create a new document for the Book schema using the Book model:\nconst Book = require("./Book.js");\nconst newBook = new Book({\n // other irrelevant fields...\n author: "6dadece123a4cgg258fd1013" // <-- ID of an Author in the authors collection.\n});\n\nnewBook.save((err, doc) => {\n if(!err) console.log(doc);\n});\n\nUpon saving the new book document, the following is outputted:\n{\n // other irrelevant fields...\n author: 5fadecf962a4cee258fd9944\n}\n\nQ: Is it possible to easily replace author id with the Author that the ID refers to in the authors collection? Usually to achieve something like this I would use .populate("author"). However, as I'm saving I can't apply that here (as far as I can tell - I've tried:\nnewBook.populate("author").save((err, doc) => {\n\nbut that did not work). I know I could perform another query to go and find the id and it's related document, but I was wondering if there is an easier way that I've missed.\nWanted Output\n{\n // other irrelevant fields...\n author: { // <-- Example of document in authors collection with the id of `5fadecf962a4cee258fd9944`\n _id: 5fadecf962a4cee258fd9944\n name: "John Doe" \n }\n}"
] | [
"javascript",
"node.js",
"mongoose"
] |
[
"How to count the number of section tags in an article tag?",
"I have been trying to write code that would use an embedded for loop to calculate the number of sections inside of each article (there is more than one so I can't use getID) in a document. When the button is clicked the code works but the numbers it calculates are completely off which means something isn't counting correctly. Here is my function:\n\n<script>\n\n function Calculations() {\n var a = document.getElementsByTagName(\"article\");\n var s = 0;\n var z = 0;\n var x;\n for (x = 0; x < a.length; x++) {\n var cn = a[x].childNodes;\n z++\n for (i = 0; i < cn.length; i++) {\n if (cn[i].nodeType == 1) {\n if (cn[i].tagName == \"P\"); {\n s++;\n }\n }\n }\n alert(\"Article \" + z + \" has \" + s + \" section.\")\n s = 0 \n }\n alert(\"There are \" + a.length + \" total articles.\")\n }\n</script>\n\n\nThank you so much for your help!"
] | [
"javascript",
"if-statement",
"for-loop",
"child-nodes"
] |
[
"Eclipse not publishing to Apache 6.0.32 - Could not publish to the server",
"I have been using Apache 6 with Eclipse and the Web Tools plugin for some time. Until recently, deployment usually went off without a hitch. Now, after trying to install Apache Tomcat v6.0.32, it seems Eclipse has suddenly decided it will no longer cooperate with any version of Tomcat 6. My Googling has been largely unfruitful. \n\nWhen I attempt to publish an application to the server, this is what I get:\n\nSeverity: Error\nMessage: Could not publish to the server.\n\nException Stack Trace:\n\njava.lang.NullPointerException\n at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getMembers(ComponentDeployable.java:148)\n at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.addClassFolderDependencies(J2EEFlexProjDeployable.java:814)\n at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:198)\n at org.eclipse.wst.server.core.internal.ModulePublishInfo.fillCache(ModulePublishInfo.java:285)\n at org.eclipse.wst.server.core.internal.ModulePublishInfo.getDelta(ModulePublishInfo.java:355)\n at org.eclipse.wst.server.core.internal.ServerPublishInfo.getDelta(ServerPublishInfo.java:368)\n at org.eclipse.wst.server.core.internal.Server.getPublishedResourceDelta(Server.java:1363)\n at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.getPublishedResourceDelta(ServerBehaviourDelegate.java:653)\n at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.getPublishedResourceDelta(TomcatServerBehaviour.java:896)\n at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:822)\n at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:708)\n at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:2731)\n at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:278)\n at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)\n\n\nHere's my session data:\n\neclipse.buildId=unknown\njava.version=1.6.0_22\njava.vendor=Sun Microsystems Inc.\nBootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US\nFramework arguments: -product org.eclipse.epp.package.jee.product\nCommand-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product\n\n\nI've had to fight with Eclipse in the past with Tomcat, but it's been a while since I've had such a catastrophic failure. Any attempt to go to an earlier version of Tomcat 6 seems to yield the same problems. For what it's worth, here's the rest of the relevant version information on my IDE:\n\nEclipse build ID: 20100218-1602\nEclipse Java EE Developer Tools: 3.1.1.v200908101600-7_7EGrjFQRwRb4P511ebObS5XZhq\n build: 20100211202452\nEclipse Web Developer Tools: 3.1.1.v200908120400-7R77FStEVw2z07WtDz-OZrhL5C-3\n build: 20100211202452\n\n\nOne snag: This environment is standard for our team. Upgrading any components is an option only if I won't break workspace compatibility."
] | [
"java",
"eclipse",
"tomcat",
"publishing"
] |
[
"Delphi DunitX FMX GUI logger",
"I have a console based DUNITX unit test program which I am trying to convert to the FMX GUI output. Having read the embarcadero docs here, I modified the Test program file by doing the following:\n\n\nincluded the DUnitX.Loggers.GUIX unit\nCommented out the DUnitX.Loggers.Console unit\nCommented out the {$APPTYPE CONSOLE} directive\nChanged the Logger to logger := TGUIXTestRunner.Create(nil);\n\n\nthe modified listing looks like this:\n\nprogram HTMLParserTest;\n\n{$IFNDEF TESTINSIGHT}\n//{$APPTYPE CONSOLE}\n{$ENDIF}{$STRONGLINKTYPES ON}\nuses\n System.SysUtils,\n {$IFDEF TESTINSIGHT}\n TestInsight.DUnitX,\n {$ENDIF }\n // DUnitX.Loggers.Console,\n DUnitX.Loggers.GUIX,\n DUnitX.Loggers.Xml.NUnit,\n DUnitX.TestFramework,\n test.ITUtils.Delphi in 'test.ITUtils.Delphi.pas',\n ITUtils.Delphi in '..\\Concept Test\\ITUtils.Delphi.pas',\n test.ITsimplehtmlparser.Delphi in 'test.ITsimplehtmlparser.Delphi.pas',\n ITTools.simplehtmlparser.Delphi in '..\\Concept \n Test\\ITTools.simplehtmlparser.Delphi.pas';\n\nvar\n runner : ITestRunner;\n results : IRunResults;\n logger : ITestLogger;\n nunitLogger : ITestLogger;\nbegin\n{$IFDEF TESTINSIGHT}\n TestInsight.DUnitX.RunRegisteredTests;\n exit;\n{$ENDIF}\ntry\n//Check command line options, will exit if invalid\nTDUnitX.CheckCommandLine;\n//Create the test runner\nrunner := TDUnitX.CreateRunner;\n//Tell the runner to use RTTI to find Fixtures\nrunner.UseRTTI := True;\n//tell the runner how we will log things\n//Log to the console window\n// logger := TDUnitXConsoleLogger.Create(true);\nlogger := TGUIXTestRunner.Create(nil);\nrunner.AddLogger(logger);\n//Generate an NUnit compatible XML File\nnunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);\nrunner.AddLogger(nunitLogger);\nrunner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;\n\n//Run tests\nresults := runner.Execute;\nif not results.AllPassed then\n System.ExitCode := EXIT_ERRORS;\n\n{$IFNDEF CI}\n//We don't want this happening when running under CI.\nif TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then\nbegin\n System.Write('Done.. press <Enter> key to quit.');\n System.Readln;\nend;\n{$ENDIF}\nexcept\non E: Exception do\n System.Writeln(E.ClassName, ': ', E.Message);\nend;\nend.\n\n\nWhen I run this (using Tokyo 10.2) I get the following error :\n\n\n\nI should also note that I had to include the path to the DUNITX source in my library path as it didn't find the fmx form to compile.\n\nI assume there is something i am missing here, any help would be appreciated as the documentation is a little thin on the ground for this.\n\nThanks"
] | [
"unit-testing",
"delphi",
"dunitx"
] |
[
"Call to undefined function odbc_connect()",
"This is my first time using the php function odbc_connect(), I mostly work with php/mysql. The issue I am having is the function does not work. I have been reading up on the issue and the only resolution I can come up with is that either through php or apache the odbc connection has been disabled.\n\nHere is what I know:\n\n\nI have php installed version 5.1.6 here is the configure command from php_info():\n\n'./configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '-- target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '- -bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'\nThe script I am running is a direct copy from IBM/Netezza Support(need log in):\n\n<?php\n//connect to database\n$connectionstring = odbc_connect(\"nps01\", \"admin\", \"password\");\n$Query = \"SELECT count(*) from _v_table\"; \n$queryexe = odbc_do($connectionstring, $Query); \n//disconnect from database\nodbc_close($connectionstring); \n?>\nI can create a connection through linux isql using odbc:\n\n-bash-3.2$ isql NZSQL\n+---------------------------------------+\n| Connected! |\n| |\n| sql-statement |\n| help [tablename] |\n| quit |\n| |\n+---------------------------------------+\n\n\nIs having both with/without unixODBC contradicting? I would appreciate any insight or trouble shooting advice."
] | [
"php",
"odbc",
"unixodbc",
"netezza"
] |
[
"How to handle two scroll events in a webpage",
"two js function loads on scroll . Say there is two onscroll events to handle \n\nwindow.onscroll = function(e) {\n var footerHeight = 500;\n if ((window.innerHeight + window.scrollY + footerHeight) >= document.body.offsetHeight) {\n if (branchLoaded == false) {\n loadBranch1();\n };\n }\n};\n\nwindow.onscroll = function(e) {\n var footerHeight = 500;\n if ((window.innerHeight + window.scrollY + footerHeight) >= document.body.offsetHeight) {\n if (branchLoaded == false) {\n loadBranch2();\n };\n }\n};"
] | [
"javascript",
"events"
] |
[
"AJAX request to php for getting the list of the file on the server in the specified directory sent by post/get (WITHOUT JQUERY)",
"I have a table in html with only 1 column: My FILES.\n\nWhat I'm trying to reach: (a file explorer of a folder in the server)\n\n\n\nWhen the page loads in body onload i call an ajax function that add a row for every file in my directory on the server. (shows the content of a predefined folder)\n\nevery rows has the name of the file and two kind of icons: one for simple file, another one click-able for directory. A user can click on the directory and another AJAX call is made to update the content of the table for showing the content of the clicked folder.\n\n\n\nMy only experience with ajax of yesterday was to call a php script that update a field in the page notifying the user if a username is available or not for registration purpose. I made this with POST and responseText AJAX format.\n\nI don't know now for the file list what is best if responseXML or responseText and you have suggestion about an easy way to do this??? (it's for educational purpose, just for make you know)"
] | [
"javascript",
"php",
"ajax"
] |
[
"LC50 calculation from bootstrap GLM List",
"I am trying to calculate LC50 from a list of bootstrapped GLM output\n\nI have the output of bootstrapped GLM in a list (named results) as such:\n(I have just put in the last result for ease rather than the whole list)\n\n$thetastar[[100]] \nCall: glm(formula = dead[x] ~ concentration[x] + factor(female.no[x]), \nfamily = binomial, data = subset.data.48hr)\n\nCoefficients:\n (Intercept) concentration[x] factor(female.no[x])3 factor(female.no[x])4 factor(female.no[x])7 \n 0.7386 0.1869 -0.8394 -5.6613 -2.9576 \nfactor(female.no[x])8 factor(female.no[x])9 \n -1.5329 -2.7826 \n\nDegrees of Freedom: 354 Total (i.e. Null); 348 Residual\n(1265 observations deleted due to missingness)\nNull Deviance: 484.2 \nResidual Deviance: 257 AIC: 271\n\n\nusing dose.p from the MASS package I am trying to calculate the LC50 for each individual within the model which has run\n\ndose.p(results$thetastar[[100]], cf = c(2,3), p = 0.5)\n\n\nwhich returns\n\n Dose SE\np = 0.5: 0.2227249 0.161769\n\n\nFrom what I understand this is the LC50 for factor(female.no[x])3. i.e. into dose.p I have put cf = c(2,3) which i take to be column 2 and column 3, the concentration and the factor(female.no[x])3.\n\nIs this correct?\n\nsecondly:\n\nIs there a way I can get LC50 for each of the females, i.e. factor(female.no[x])3, factor(female.no[x])4, factor(female.no[x])7 and so on, I don't see how i can get dose.p work work along the differing variables without manually changing the code cf=:\n\ndose.p(results$thetastar[[100]], cf = c(2,3), p = 0.5)\ndose.p(results$thetastar[[100]], cf = c(2,4), p = 0.5)\ndose.p(results$thetastar[[100]], cf = c(2,4), p = 0.5)\n\n\nfinally:\nMy results are stored in a list, How do i get dose.p to work along the list, would it be something like:\n\ntest=matrix\nfor(i in 1:results){\ntest[i,]= dose.p(results$thetastar[[i]], cf = c(2,3), p = 0.5)\n\n\nThanks for any help"
] | [
"r",
"list",
"glm",
"statistics-bootstrap"
] |
[
"Github Actions: How use strategy/matrix with script",
"I have workflow that needs to have a loop for the steps, which is perfect with strategy/matrix.\n\nThe only problem is that strategy/matrix needs to be set by a constant.\n\nIs it possible to use strategy matrix with a output of a script?\n\nname: tests\non: [push]\n\njobs:\n test:\n runs-on: ${{ ubuntu-latest }}\n strategy:\n fail-fast: false\n matrix:\n versions: $(./script.py)\n\n steps:\n - uses: actions/checkout@v2\n ......."
] | [
"github-actions"
] |
[
"Untokenized field in Lucene search",
"I have stored a field in index file which is untokenized. When I try to get that field value from the index file I'm not able to do get it.\n\nNote: I have another one untokenized field, there I'm able to get that value, the data stored in this field are not having any white spaces among this. \n\nExample: (smith,david,walter,john)... But the one I'm asking is having white spaces among it. Example: (david smith,mark john,bill man)... \n\nI don't think this might be the reason.\n\nYour help is appreciated."
] | [
"lucene"
] |
[
"Publish Jar into Azure Artifact using gradle error",
"What I'm trying to do is to publish a Jar file into the Azure DevOps artifact using Gradle but I got this error massage:\nFAILURE: Build failed with an exception.\n\nWhat went wrong:\nTask 'publish' not found in root project 'Project1'.\n\nTry:\nRun gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n\nGet more help at https://help.gradle.org\n\n\nBUILD FAILED in 1s\nand the Build.gradle file is this:\napply plugin: 'java' \napply plugin: 'maven-publish' \n\npublishing { \n publications { \n myPublication(MavenPublication) { \n groupId 'soft' \n artifactId 'crypto-utils' \n version '5.2.0' \n artifact 'C:\\Users\\d\\Desktop\\Project1\\crypto-utils-5.2.0.jar' \n } \n } \n\n // Repositories *to* which Gradle can publish artifacts \n repositories { \n maven { \n url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1' \n credentials { \n username "myFeed"\n //The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds \n password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken \n } \n } \n } \n} \n \n// Repositories *from* which Gradle can download dependencies; it's the same as above in this example\nrepositories { \n maven { \n url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1' \n credentials { \n username "myFeed" \n //The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds \n password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken \n } \n } \n}\n\nAny help please"
] | [
"azure",
"maven",
"gradle",
"groovy",
"azure-devops"
] |
[
"How to use multiple fields in exists query in Java API Elasticsearch-2.4.4?",
"From the REST API of the elasticsearch (version 2.4.4), we can use multiple fields in exists query as:\n\n{\n \"query\": {\n \"exists\": {\n \"field\": [\n \"field1\",\n \"field2\",\n \"field3\"\n ]\n }\n }\n}\n\n\nBut I couldn't find the equivalent Java API for the same. The java class ExistsQueryBuilder takes only one field as the constructor. So, isn't there really any Java API for it? So, the only way to do it from Java API is using bool-should of exists query for each field?"
] | [
"java",
"elasticsearch",
"exists"
] |
[
"How to use servlets in struts2",
"i have a struts2 web app and I want to use a servlet in my project,but struts2's filter does not allow to call servlets\nI have looked into this solution, but unfortunately it didn't work out and the problem still stands.\n\nAny ideas?\n\nservlet code:\n\nprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n System.out.print(\"morteza\");\n OutputStream o = response.getOutputStream();\n InputStream is = new FileInputStream(new File(\"d:/Desert.jpg\"));\n byte[] buf = new byte[32 * 1024]; \n int nRead = 0;\n while( (nRead=is.read(buf)) != -1 ) {\n o.write(buf, 0, nRead);\n }\n o.flush();\n o.close();\n return; \n }\n\n\nstruts.xml:\n\n<struts>\n\n <constant name=\"struts.enable.DynamicMethodInvocation\" value=\"true\" />\n <constant name=\"struts.devMode\" value=\"false\" />\n <constant name=\"struts.custom.i18n.resources\" value=\"ApplicationResources\" />\n <constant name=\"struts.action.excludePattern\" value=\"Ser\"/>\n</struts>\n\n\nweb.xml:\n\n <servlet>\n <description></description>\n <display-name>Ser</display-name>\n <servlet-name>Ser</servlet-name>\n <servlet-class>Ser</servlet-class>\n </servlet>\n <servlet-mapping>\n <servlet-name>Ser</servlet-name>\n <url-pattern>/Ser</url-pattern>\n </servlet-mapping>\n\n\nwebpage:\n\n<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\"\n pageEncoding=\"UTF-8\"%>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<title>Insert title here</title>\n</head>\n<body>\nfap\n<img src=\"Ser\" height=\"200\" width=\"400\"/>\n\n\n</body>\n</html>"
] | [
"java",
"struts2",
"servlet-filters"
] |
[
"Restrict domain to Chrome visitors? Possible?",
"Is it possible to restrict a domain to only allow visitors using a specific browser? \n\nI'm building an app and it's only been tested in Chrome so far so I only want to allow Chrome users during Beta testing. Basically, I want to white-list browsers as I go through testing. Any suggestions on the approach I should would be greatly appreciated."
] | [
"php",
".htaccess",
"browser",
"restrict"
] |
[
"Issue with Qt 4.8.6 compilation with qpa configured.",
"I am getting the following error when I compile qt 4.8.6 source on Mac OS X version 10.8.5.\n\nIt looks like some platform related flags are not enabled.\n\nIn file included from text/qfontengine_coretext.mm:42:\ntext/qfontengine_coretext_p.h:64: error: expected `)' before‘font’\ntext/qfontengine_coretext_p.h:65: error: expected `)' before‘font’\ntext/qfontengine_coretext_p.h:93: error: ‘CGContextRef’ has not\nbeen declared\ntext/qfontengine_coretext_p.h:111: error: ‘CTFontRef’ does not \nname a type\ntext/qfontengine_coretext_p.h:112: error: ‘CGFontRef’ does not\nname a type\ntext/qfontengine_coretext_p.h:114: error: ‘CGAffineTransform’ does \nnot name a type\ntext/qfontengine_coretext_p.h:122: error: expected ‘,’ or ‘...’\nbefore ‘&’ token\ntext/qfontengine_coretext_p.h:122: error: ISO C++ forbids\ndeclaration of ‘QCFString’ with no type\ntext/qfontengine_coretext_p.h:123: error: expected `)' before\n‘ctFontRef’\ntext/qfontengine_coretext_p.h:134: error: ‘CTFontRef’ does not\nname a type\ntext/qfontengine_coretext_p.h:144: error: ‘CTFontRef’ has not been\ndeclared\ntext/qfontengine_coretext_p.h:145: error: ‘CTFontRef’ does not\nname a type\ntext/qfontengine_coretext_p.h:146: error: ISO C++ forbids\ndeclaration of ‘QCFType’ with no type\ntext/qfontengine_coretext_p.h:146: error: expected ‘;’ before ‘<’\ntoken\ntext/qfontengine_coretext_p.h:147: error: ‘CGAffineTransform’ does\nnot name a type\ntext/qfontengine_coretext_p.h:152: error: ‘CGAffineTransform’ does\nnot name a type\ntext/qfontengine_coretext.mm:53: error: ‘acosf’ was not declared \nin this scope\ntext/qfontengine_coretext.mm:53: error: ‘tanf’ was not declared in \nthis scope\ntext/qfontengine_coretext.mm:55: error: variable or field \n‘loadAdvancesForGlyphs’ declared void\ntext/qfontengine_coretext.mm:55: error: ‘CTFontRef’ was not \ndeclared in this scope\ntext/qfontengine_coretext.mm:56: error: ‘CGGlyph’ was not declared \nin this scope\ntext/qfontengine_coretext.mm:56: error: template argument 1 is \ninvalid\ntext/qfontengine_coretext.mm:56: error: ‘cgGlyphs’ was not \ndeclared in this scope\ntext/qfontengine_coretext.mm:57: error: expected primary-\nexpression before ‘*’ token\ntext/qfontengine_coretext.mm:57: error: ‘glyphs’ was not declared \nin this scope\ntext/qfontengine_coretext.mm:57: error: expected primary-\nexpression before ‘int’\ntext/qfontengine_coretext.mm:58: error: expected primary-\nexpression before ‘flags’\ntext/qfontengine_coretext.mm:59: error: expected primary-\nexpression before ‘const’\ntext/qfontengine_coretext.mm:53: warning: ‘SYNTHETIC_ITALIC_SKEW’ \ndefined but not used\nmake[2]: *** [.obj/debug-shared/qfontengine_coretext.o] Error 1\nmake[1]: *** [debug] Error 2\nmake: *** [sub-gui-make_default-ordered] Error 2\n\n\nAm i missing anything? The configuration command used is:\n\n./configure -debug -opensource -confirm-license -arch \"x86_64\" -cocoa -qpa\n\n\nand I have Xcode Mac base SDKs for 10.7 and 10.8."
] | [
"xcode",
"macos",
"qt",
"qt4"
] |
[
"Error message about wrong origin remote URL when running Brew Doctor",
"I get this message when I run brew doctor. Did they change the url recently or do I have some other error?\n\nWarning: Suspicious git origin remote found.\n\nWith a non-standard origin, Homebrew won't pull updates from\nthe main repository. The current git origin is:\n https://github.com/mxcl/homebrew\n\nUnless you have compelling reasons, consider setting the\norigin remote to point at the main repository, located at:\n https://github.com/Homebrew/homebrew.git"
] | [
"homebrew"
] |
[
"I need to assign time value to a variable",
"I need to assign a variable time value that is in particular cell.\n\nI have tried assigning values differently but everytime it gives me mismatch error:\n\nSub country_despatch(i)\n\nDim tm As Double\nDim date1 As Double\n\nDim lRow As Integer\nDim ws1 As Worksheet\nDim ws2 As Worksheet\n\nlRow = ActiveSheet.Cells(Rows.Count, \"B\").End(xlUp).Row\nWhile i < lRow\n\n date1 = Sheet1.Cells(\"B\", i).Value\n display (date1)\nWend\n\nEnd Sub\n\n\nI need to assign cell B2 value to date1. If the condition is met we move to next cell B3 and assign its value to date1 so on till the end of the rows."
] | [
"excel",
"vba"
] |
[
"Pandas resampling using numpy percentile?",
"Have you ever used the percentile numpy function when using the pandas function resample??\n\nConsidering that \"data\" is a dataframe with just one column with 10min data, I would like to do something like this:\n\ndataDaily=data.resample('D',how=np.percentile(data['Col1'],q=90)\n\n\nI got the following error:\n\n'numpy.float64' object is not callable\n\n\nHave you ever try this?"
] | [
"python",
"numpy",
"pandas"
] |
[
"How to determine if a merge adds new information",
"Following situation:\nSome branch encoder_dev has been merged into a branch encoder. encoder has been merged into integration, integration has been merged into master. All the merges were true merges. The branch encoder_dev has got another commit.\nThe corresponding commit graph:\n* ed9c5fa07889eb9db1294ef92efd75ea42df0143 (HEAD -> encoder_dev) [encoder_dev]: added signal C\n| * 73ec0451e9ac23909fa6558c22a9996a2001fb1c (origin/master, origin/HEAD) included encoder changes\n| |\\\n| | * 257e2dbfb16afb07cded3e17416048863be22e77 (origin/integration) Merge remote-tracking branch 'remotes/origin/encoder' into integration\n| | |\\\n| | | * 0608a1965b10015d3b03d84e4cd2610c8f098f24 (origin/encoder, encoder) initial implementation\n| | | |\\\n| | |/ /\n| |/| /\n| |_|/\n|/| |\n* | | abbbb126781839e3ff74282666515c9a547ff963 (origin/encoder_dev) [encoder_dev]: added entity and architecture\n|/ /\n* | ef425daf81becbe1e2fd5ae92d099d189cc3dbe0 (master) initial checkin; all files are empty\n|\\ \\\n| |/\n| * 886e3783af21fe4138614f26b53c705839749b00 [integration]: added FILE_HISTORY to each file\n|/\n* cabcd5630133ebaac4f505e9f3759ae0e448cfac [***]: initial checkin\n\nNow, origin/master could transport contributions from other branches, but in this case it doesn't. If I merge origin/master into encoder_dev, it would not contribute any new information to encoder_dev, since the only changes to the code were made in the last commit to encoder_dev, all the previous changes landed in origin/master, and origin/master had no code changes since then. Note that fast-forward is not possible. Is there a way to detect this case automatically?"
] | [
"git",
"git-merge"
] |
[
"Update layout_margin inside kotlin class for specific elements",
"So, this should be pretty basic, but I am new to Kotlin. So I basically have the following ImageView inside a RelativeLayout view.\n\n<ImageView\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\" \n app:srcCompat=\"@drawable/moon_0\"\n android:id=\"@+id/imagen_luna\"\n android:layout_marginStart=\"8dp\"\n android:layout_marginEnd=\"8dp\"\n android:layout_marginTop=\"8dp\"\n android:layout_marginBottom=\"8dp\" \n android:layout_alignParentStart=\"true\"\n android:layout_alignParentEnd=\"true\" \n android:layout_alignParentBottom=\"true\"\n android:layout_alignParentTop=\"true\" />\n\n\nThe thing is that under certain condition this ImageView can collide visually with another element, so I have to modify the marginStart and the marginEnd properties. I saw in some tutorials that first I must obtain the current layout margins or something like that, but I am not sure why it's so complicated, in Swift I just modify the properties of each margin.\n\nIs there an easy way to achieve this or in case there isn't what would be the easiest way to do this?\n\nUPDATE - Added code in the Adapter\n\nThis is the code I have in my adapter for this specific ImageView:\n\noverride fun onBindViewHolder(holder: AnoViewHolder, position: Int) {\n ...\n if(respec.nombre_icono_signo != \"\" && respec.imagen_luna != \"\") {\n val layoutParamsLuna = holder.view?.imagen_luna.layoutParams as RelativeLayout.LayoutParams\n layoutParamsLuna.setMargins(1, 8, 15, 8)\n holder.view?.imagen_luna.layoutParams = layoutParamsLuna\n }\n ...\n}\n\n\nThe thing is that this does nothing and my theory is that the setMargins function accepts left and right margins, not start and end margins."
] | [
"android",
"dynamic",
"kotlin",
"runtime",
"layoutmargins"
] |
[
"How does Spring Security differentiate between multiple logged in user",
"I am working on a Spring-MVC application where I am using spring security for authentication. for accessing secured functions, it is compulsory that the user is logged in. I am using a function where it can be determined whether the user is logged in or not. \n\nI just wanted to know if the code I am posting below will hold if there are multiple users logged in at the same time, to distinguish like user A has logged in. If not, any solutions or ideas. Thank you.\n\nPerson Controller :\n@Controller\npublic class PersonController {\n\n private PersonService personService;\n\n// Now whenever there are secure functions to be accessed, like below, I use it the following way :\n }\n @RequestMapping(value = \"/note/list/{id}\",method = RequestMethod.GET)\n public String listNotes(@ModelAttribute(\"notices\") Notes p,@PathVariable int id,Model model) {\nPerson person = personService.getCurrentlyAuthenticatedUser();\nmodel.addAttribute(\"section1\",this.notesService.listNotesBySectionId(1,person));\n}\n\n\nGet currently authenticated user function :\n\n@Override\n public Person getCurrentlyAuthenticatedUser() {\n Authentication authentication = SecurityContextHolder.getContext().getAuthentication();\n String authenticatedUserId = authentication.getName();\n\n Person person = personDAO.findPersonByUsername(authenticatedUserId);\n return person;\n }\n\n\nI am implementing authentication this way :\n\n@Transactional\n@Service(\"userDetailsService\")\npublic class LoginServiceImpl implements UserDetailsService{\n\n @Autowired private PersonDAO personDAO;\n @Autowired private Assembler assembler;\n\n private static final GrantedAuthority USER_AUTH = new SimpleGrantedAuthority(\"ROLE_USER\");\n\n @Override\n public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException,DataAccessException {\n Person person = personDAO.findPersonByUsername(username);\n if(person == null) { throw new UsernameNotFoundException(\"Wrong username or password\");} //Never specify which one was it exactly\n return assembler.buildUserFromUserEntity(person);\n }\n}\n\n\nAssembling the user\n\n@Transactional\n@Service(\"userDetailsService\")\npublic class LoginServiceImpl implements UserDetailsService{\n\n @Autowired private PersonDAO personDAO;\n @Autowired private Assembler assembler;\n\n private static final GrantedAuthority USER_AUTH = new SimpleGrantedAuthority(\"ROLE_USER\");\n\n @Override\n public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException,DataAccessException {\n Person person = personDAO.findPersonByUsername(username);\n if(person == null) { throw new UsernameNotFoundException(\"Wrong username or password\");} \n return assembler.buildUserFromUserEntity(person);\n }\n}"
] | [
"spring-security"
] |
[
"How to get CPU usage or disk usage of application using Windows API from C++?",
"How to proceed to get CPU usage or disk usage of application using API in C++???\n\nI want to get the highest CPU usage or disk usage among the application running on windows.\nI have tried to find out API but there is no direct API for that. Can anyone please let me know how to proceed for this in C++."
] | [
"c++",
"windows",
"cpu",
"disk"
] |
[
"Why isn't \"time.sleep\" delaying the MQTT publish messages?",
"Python 2.7\n\nI want to publish 3 times and interval=3 sec.\n\nSo I try to use time.sleep(3), then publish.\n\nMy code is like:\n\nfor i in range(3):\n print(i)\n mqttc.publish(\"test\", \"hello\")\n time.sleep(3)\n\n\nThe result should be like:\n\n0\n(Publish)\n(delay 3 sec)\n1\n(Publish)\n(delay 3 sec)\n2\n(Publish)\n(delay 3 sec)\n\n\nBut real result is:\n\n0\n(delay 3 sec)\n1\n(delay 3 sec)\n2\n(delay 3 sec)\n(Publish)\n(Publish)\n(Publish)\n\n\nThe real result is found from MQTT.fx and Python subscribe.\n\nDelay is normal worked to \"Print\", but \"Publish\" not,\n\nI don't understand why publish is continuous..."
] | [
"python",
"python-2.7",
"mqtt",
"delay"
] |
[
"Automatically select a submenu in excel",
"I'm trying to automate some excel processing. With autoit I open several Excel with an add-in. This add-in is used to update data in this excel.\n\nIn autoit I managed to open the excel files with the add-in but now I need to select the menuitem to update the excel automatically. I don't have any clue howto do this in autoit3.\n\nI can't find any tutorials or manual howto do this."
] | [
"autoit"
] |
[
"How to verify QVariant of type QVariant::UserType is expected type?",
"I'm writing testing code that will automatically iterate thru all Q_PROPERTY's of widgets and some properties are using types that are registered via qRegisterMetaType. If i want to read/write these into QVariant i need to use QVariant::UserType when storing them into variant. So far so good.\n\nBut when i want to test reads and writes of these properties, i need to also know their type. For stuff that are already standard qt types, i can do this via QVariant::type() but as i have alot of usertypes, how would this be accomplished ?\n\nFrom the api of QVariant, i spotted this:\n\nbool QVariant::canConvert ( Type t ) const\n\nBut i'm slightly doubtful if this will lead to wrong types in case of enums?\n\nSo, what would be the foolproof way to verify what type of usertype is stored in QVariant ?"
] | [
"qt",
"qvariant"
] |
[
"How does #error in C/C++ work?",
"I am guessing from # that it is only a compile-time utility. How can it be used in C/C++ programs?\n\nDid not find much about it on the internet. Any links would be helpful."
] | [
"c++",
"c",
"c-preprocessor"
] |
[
"How to connect client android app with admin website",
"I have created an android app on android studio with firebase database.\n\nNow I want to develop an administrative website through which the admin will control all the operations of the app. \n\nI want to know how to connect the app to the website. Also, should the database be connected to the app or the website?"
] | [
"firebase"
] |
[
"Haskell Formatting I/O Error",
"I'm having a problem figuring out why I am getting a parse error when compiling code. I've tried indenting using tabs and spaces yet no success. Maybe I just need another set of eyes on the code, any help would be greatly appreciated!\n\nThe error seems to be coming from this line:\n\n\n putStrLn \"\\nSelected option: \"\n\n\nmain :: IO()\nmain = do contents <- readFile \"films.txt\";\n let database = (read contents :: [Film])\n putStrLn \"Please enter your name:\";\n name <- getLine;\n putStrLn (\"Hello \" ++ name ++ \"!\");\n menu database\n where menu newDb = do putStrLn \"\\nWhat would you like to do?\";\n putStrLn \"1 -> Add a film\";\n putStrLn \"2 -> Display all films\";\n putStrLn \"3 -> Display all films by director's name\";\n putStrLn \"4 -> Display the films of an average website rating\";\n putStrLn \"5 -> Display the average rating of the films of a particular actor\";\n putStrLn \"6 -> Show the films you have rated, with the rating\";\n putStrLn \"7 -> Rate or ReRate a film\";\n putStrLn \"8 -> Display films released during or after a year, sorted in descending order of rating\";\n putStrLn \"9 -> Exit & Save\";\n putStrLn \"\\nSelected option: \"\n option <- getLine\n case option of \n \"1\" -> do putStr \"Name of Film: \"\n title <- getLine\n putStr \"Name of the Director: \"\n director <- getLine\n putStr \"Year the film was released: \"\n year <- getLine\n putStrLn (map formatFilmOutput $ addFilm title director (read year) [] newDb)\n \"2\" -> do putStrLn (displayAllFilm newDb) >> menu newDb"
] | [
"haskell",
"input",
"formatting",
"output"
] |
[
"Group following rows using only one flag",
"I have a table with a Flag column which can be true/false.\nI would like to group rows and calculate average of column Val as shown in the picture below:\n\nSource table and Desired results"
] | [
"sql",
"sql-server-2008",
"select",
"group-by"
] |
[
"AWS SSH access key generation procedure and putting on EC2",
"I wonder how does AWS EC2 puts the SSH public key on the instance and provides private key to end user. I mean to know how this process of creating an SSH key and putting it on EC2 instance is automated."
] | [
"amazon-web-services",
"amazon-ec2",
"ssh",
"ssh-keys"
] |
[
"Can UNICODE characters be set as parameters in php?",
"The column names of my table are in UNICODE characters. So, can those characters be set as parameters? \n\nThis is the SQL:\n\nINSERT INTO सामान्य_ग्यान\nSET मिति = :मिति, शीर्षक = :शीर्षक, विकल्प_क = :विकल्प_क, विकल्प_ख = :विकल्प_ख, विकल्प_ग = :विकल्प_ग,\nविकल्प_घ = :विकल्प_घ, सही_जवाफ = :सही_जवाफ\n\n\nAnd if I run this query then it throws the following error.\n\n\n Insert Query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':मिति, शीर्षक = :शीर्षक, विकल्प_क ' at line 1\n\n\nHere is my insert code:\n\nfinal protected function insert($data, $is_die = false){\n try {\n $this->sql = \"INSERT INTO \";\n if (!isset($this->table) || empty($this->table)) {\n throw new Exception(\"Table not set\");\n }\n $this->sql .= $this->table;\n $this->sql .= \" SET \";\n if (isset($data) && !empty($data)) {\n if (is_array($data)) {\n $temp = array();\n foreach ($data as $column_name => $value) {\n $str = $column_name.\" = :\".$column_name;\n $temp[] = $str;\n }\n $this->sql .= implode(', ', $temp);\n } else {\n $this->sql .= $data;\n }\n }\n $this->stmt = $this->conn->prepare($this->sql);\n if (isset($data) && !empty($data) && is_array($data)) {\n foreach ($data as $column_name => $value) {\n if (is_int($value)) {\n $param = PDO::PARAM_INT;\n } elseif (is_bool($value)) {\n $param = PDO::PARAM_BOOL;\n } elseif (is_null($value)) {\n $value = null;\n $param = PDO::PARAM_INT;\n } else {\n $param = PDO::PARAM_STR;\n }\n if ($param) {\n $this->stmt->bindValue(\":\".$column_name, $value, $param);\n }\n }\n }\n if ($is_die) {\n debugger($this->sql, true);\n echo $this->sql;\n\n }\n /*error*/\n $this->stmt->execute();\n /*error*/\n return $this->conn->lastInsertId();\n } catch (PDOException $e) {\n error_log(\n date('Y-m-d h:i:s A').\", Insert Query: \".$e->getMessage().\"\\r\\n\"\n , 3, ERROR_PATH.'error.log');\n return false;\n } catch (Exception $e) {\n error_log(\n date('Y-m-d h:i:s A').\", General: \".$e->getMessage().\"\\r\\n\"\n , 3, ERROR_PATH.'/error.log');\n return false;\n }\n }"
] | [
"php",
"mysql",
"parameters"
] |
[
"stl map performance?",
"I am using map<MyStruct, I*> map1;. Apparently 9% of my total app time is spent in there. Specifically on one line of one of my major functions. The map isn't very big (<1k almost always, <20 is common).\n\nIs there an alternative implementation i may want to use? I think i shouldn't write my own but i could if i thought it was a good idea.\n\nAdditional info: I always check before adding an element. If a key exist I need to report a problem. Than after a point i will be using map heavily for lookups and will not add any more elements."
] | [
"c++",
"performance",
"algorithm",
"profiling"
] |
[
"Running Flask via FastCGI in IIS at application level instead of website leve",
"I've configured the basic Flask web sample in a VENV and now it is correctly published through IIS via FastCGI.\nWell, here it is my trivial sample00.py\nfrom flask import Flask\n\napp = Flask(__name__)\n\[email protected]("/")\ndef hello():\n return "Hello, World, from Flask!"\n\nand the web.config, a little more involved:\n<?xml version="1.0" encoding="utf-8"?>\n<configuration>\n <system.webServer>\n <handlers>\n <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" \n scriptProcessor="F:\\Appl\\flask\\venv\\Scripts\\python.exe|F:\\Appl\\flask\\venv\\Lib\\site-packages\\wfastcgi.py" \n resourceType="Unspecified" requireAccess="Script" />\n </handlers>\n </system.webServer>\n <appSettings>\n <add key="PYTHONPATH" value="F:\\Appl\\flask" />\n <!-- Flask apps only: change the project name to match your app -->\n <add key="WSGI_HANDLER" value="sample00.app" />\n <add key="WSGI_LOG" value="F:\\Appl\\flask\\wfastcgi.log" />\n </appSettings>\n</configuration>\n\nAfter some trials and errors, I've discovered that I can enter in IIS Manager > Handler Mappings > select my "PythonHandler", edit the "Executable (optional)", and it checks if the path is correct and asks me to activate the handler, then I can answer "yes" and eventually it all works as expected.\nSo far so good.\nNow, I would like to setup it in IIS not as a separate website, but as a new application under another, existing, website. Is it even possible or is there a documentation saying that it is not permitted? We can close this question or mark it as duplicated, but till now I was not able to find a previous answer to this specific point.\nAnyway, I've tried to do that, but I receive a 404 page error... like if the request is not correctly forwarded to the cgi handler, hence I suspect there could be some problem in managing a Flask app at IIS application level, is it the case or what else am I doing wrong?"
] | [
"python",
"flask",
"iis"
] |
[
"cannot connect to bitbucket from Jenkins",
"I try to connect to bitbucket from Jenkins. I have Git plugin installed. I kept getting the following error message. I tried 2 different repository URL, none of them are working. Please help."
] | [
"jenkins",
"bitbucket",
"jenkins-plugins"
] |
[
"Using a File to Output Arrays and Tables",
"so I have a problem: Write a program to read each student’s name and raw score from a file by calling a method “readData()” and store this information into two parallel arrays “names” and “scores”.\n\nI'm so stumped as to how to do this, the rest of the problem not listed here is easy but i can't do this. the text file that it read from is in this format:\n\nName1 80\nName 2 56"
] | [
"java",
"arrays"
] |
[
"How to create endless scrolling background with scenes switching in SpriteKit ?",
"I am creating a game which possess upto 5 different scenes(levels). However there are multiple scenes, I would want to have only one endless background scrolling forever, even when i transition from one scene to another. \n\nCouldn't find anything on google so expect the answer here."
] | [
"ios",
"swift",
"sprite-kit"
] |
[
"mysql joins and groups",
"I'm new to this forum from the standpoint of posting, as this question may show. I'm having some issues with the way I want my data to appear.\n\nSo, I have 3 tables (I am only showing the columns that I want):\n\nvisitors:\n\ncenter_id (where the visitor was) | state_id (where they came from)\n\n\ncenters:\n\ncenter_id | center\n\n\nstates:\n\nstate_id | state\n\n\nhere is the query that I have been using\n\nSELECT states.state, visitors.center_id, visitors.state_id, centers.center, COUNT(visitors.state_id) AS totalCount \nFROM visitors \nLEFT JOIN states ON states.state_id = visitors.state_id \nLEFT JOIN centers ON centers.center_id = visitors.center_id \nWHERE visitors.vdate = <some date> AND visitors.state_id <> '0' \nGROUP BY centers.center, visitors.state_id\n\n\nThis produces the following array:\n\nArray\n(\n [0] => Array\n (\n [state] => Connecticut\n [location_id] => 1\n [state_id] => 8\n [center] => Little River\n [totalCount] => 1\n )\n\n [1] => Array\n (\n [state] => California\n [location_id] => 5\n [state_id] => 6\n [center] => North Augusta\n [totalCount] => 1\n )\n\n [2] => Array\n (\n [state] => Colorado\n [location_id] => 5\n [state_id] => 7\n [center] => North Augusta\n [totalCount] => 2\n )\n [6] => Array\n (\n [state] => Connecticut\n [location_id] => 9\n [state_id] => 8\n [center] => Santee\n [totalCount] => 2\n )\n\n [7] => Array\n (\n [state] => Virginia \n [location_id] => 9\n [state_id] => 51\n [center] => Santee\n [totalCount] => 1\n )\n)\n\n\nThis is what I really want:\n\nArray\n(\n [Little River] => Array\n (\n [0] => Array\n (\n [state] => Connecticut\n [state_id] => 8\n [totalCount] => 1\n )\n )\n\n [North Augusta] => Array\n (\n [0] => Array\n (\n [state] => California\n [state_id] => 6\n [totalCount] => 1\n )\n\n [1] => Array\n (\n [state] => Colorado\n [state_id] => 7\n [totalCount] => 2\n )\n )\n [Santee] => Array\n (\n [0] => Array\n (\n [state] => Connecticut\n [state_id] => 8\n [totalCount] => 2\n )\n\n [1] => Array\n (\n [state] => Virginia \n [state_id] => 51\n [totalCount] => 1\n )\n )\n)\n\n\nUltimately I'm putting this into a table that looks something like this:\n\n__________________\n|State | Count|\n-------------------\n| Santee |\n-------------------\n| Georgia | 5 |\n-------------------\n| Alabama | 10 |\n-------------------\n| North Augusta |\n-------------------\n| another | 7 |\n-------------------\n\n\nSorry for being long winded, but this was the only way that I could describe it.\n\nI've also tried breaking it out in php, but I'm probably doing something wrong there too. I can make a table with 3 columns with the center listed with each state, but I'm realliy looking for a row that show the center followed by all of the states and counts for that center and on to the next center.\n\nAny assistance would be appreciated."
] | [
"mysql",
"join",
"group-by"
] |
[
"How to create a Power point Template using powerpoint javascript API's?",
"I was very new to this. I'm trying to automate a slide creation part which we used mostly and I'm using office 365 package. Right now I was trying to automate this process. When a user clicks a button I just want to insert a sample template for them which has Header and Footer and body. I refer the below links for that too. But I'm not able to find any useful resources.\nPower Point Office Docs\n Office.context.document.setSelectedDataAsync(\n "Hello World!",\n {\n coercionType: Office.CoercionType.Text\n },\n result => {\n if (result.status === Office.AsyncResultStatus.Failed) {\n console.error(result.error.message);\n }\n }\n );\n\nWhile I was clicking the button I Can able to insert Hello World! but I can't able to insert some HTML content with the help of this API (I tried Office.CoercionType.Html and figure out it'll only work word and outlook add-on). And also any Idea of how to insert charts also?"
] | [
"office365",
"powerpoint",
"office-js",
"office-addins"
] |
[
"Default context menu on canvas element is disabled on Mobile Chrome. ( I tried on Android Chrome)",
"I am new to Web Development. Please help me.\nIs there any way we can enable default context menu on canvas like it has on images (To download image / share image)?\nOn the pc browsers we can right click and save the canvas as image. But on mobile chrome the context menu doesn't pop up on long pressing the canvas.\nIs it possible to fire the same context menu on canvas as image elements gets?\nI have researched a lot about it and didn't find a proper answer. I don't want a custom context menu. I need the default one."
] | [
"javascript",
"html",
"canvas"
] |
[
"Java - how to obtain an interleaved iterator/collection",
"Let's say we receive strings from 3 producers asynchronously. Once a certain amount of these objects have been received I want to iterate over them in an interleaved manner, that is, if receiving the following strings:\n\n\"a1\" received from A,\n\"a2\" received from A,\n\"c1\" received from C,\n\"a3\" received from A,\n\"b1\" received from B,\n\"b2\" received from B,\n\n\nI'd like the \"interleaved\" iterator to return the strings as if we were iterating over the following list:\n\nList<String> interleavedList = {\"a1\", \"b1\", \"c1\", \"a2\", \"c2\", \"a3\"},\n\n\nSo far I've created one List<String> for each producer, and then I'm \"iterating\" over all the strings by working with the 3 list iterators (with a List<Iterator<String>>). This works fine but I think there is a simpler way... Maybe by directly constructing the interleaved list while receiving the strings? but I don't see which Collection or which Comparator to use...\n\nNote that I'm not so much interested in creating one list for each producer and then merging the 3 lists in a 4th interleaved list, as this will probably not be time-efficient."
] | [
"java",
"collections"
] |
[
"Unable to install package 'MvcScaffolding.VS2015",
"'MvcScaffolding.VS2015\nI am unable to install above package on VS 2019.\nPackage manager console shows error"
] | [
"model-view-controller",
"scaffolding"
] |
[
"The text in the textview inside the table view cell is not formatted",
"I am trying to build a Table View in which each cell contains a UITextView with formatted text. I got everything together, and the the table view gets populated by text. The problem is that when I test it in the simulator, the text is not formatted. It gets formatted only after scrolling, when it gets refreshed. \n\nHere I am pasting below the view controller, which calls for the tableview and for the text (from a SQLite database), and the class I use to insert the text in the UITextView and format it. I have tried to force the layout of the container, but it does not work.\n\nThe View Controller\n\nclass ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {\n\n@IBOutlet weak var myTable: UITableView!\n\noverride func viewDidLoad() {\n super.viewDidLoad()\n self.myTable.estimatedRowHeight = 44.0\n self.myTable.rowHeight = UITableViewAutomaticDimension\n}\n\nfunc numberOfSectionsInTableView(tableView: UITableView) -> Int {\n return 1\n}\n\nfunc tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return 200\n} \n\nfunc tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCellWithIdentifier(\"verseCell\") as! VerseTextView\n let row : Int = indexPath.row\n var getVerse = databaseDB()\n var verse = databaseVars()\n (verse.book, verse.chapter, verse.verseText) = getVerse.getVerseBy(row, database: databasePath as String)\n\n if verse.verseNumber == 1 {\n chapterToBePassed = String(verse.chapter)\n }\n else {\n chapterToBePassed = \"\"\n }\n cell.configure(verseChapter: chapterToBePassed, verseText: \"\\(verse.verseText)\")\n return cell\n}\n}\n\n\nthe VerseTextView class\n\nclass VerseTextView: UITableViewCell {\n\n@IBOutlet weak var verse: UITextView!\n\nfunc configure(#verseChapter: String?, verseText: String?) {\n\n// Formats\n var style = NSMutableParagraphStyle()\n style.lineSpacing = 15\n let font = UIFont(name: \"Georgia\", size: 18.0) ?? UIFont.systemFontOfSize(18.0)\n let textFont = [NSFontAttributeName:font, NSParagraphStyleAttributeName : style]\n let fontChapter = UIFont(name: \"Georgia-Bold\", size: 22.0) ?? UIFont.systemFontOfSize(22.0)\n let chapterFont = [NSFontAttributeName:fontChapter]\n let myText = NSMutableAttributedString()\n var versettoId : String = \"\"\n\n if verseChapter != \"\"{\n let myTextChapter = \"\\n\"+verseChapter!+\" \"\n let capitolo = NSAttributedString(string: myTextChapter, attributes:chapterFont)\n myText.appendAttributedString(capitolo)\n }\n\n let testoVerso = verseText!+\" \"\n let verso = NSAttributedString(string: testoVerso, attributes:textFont)\n myText.appendAttributedString(verso)\n verse.attributedText = myText\n// verse.layoutManager.ensureLayoutForTextContainer(verse.textContainer)\n// verse.layoutIfNeeded()\n\n\n }\n}\n\n\nThanks,\nS"
] | [
"ios",
"uitableview",
"uitextview"
] |
[
"check if type has certain value types and the keyword value_type itself using c++20",
"I have following code\n#include <type_traits>\n\ntemplate<typename T, typename U, typename Tout>\nrequires std::is_integral< typename T::value_type >\n&& std::is_floating_point< typename U::value_type >\n&& std::is_floating_point< typename Tout::value_type >\nclass test\n{\n test() =default;\n};\n\n\nint main(int argc, char const *argv[])\n{\n /* code */\n return 0;\n}\n\nI essentially want to ensure that the template argument have certain types, integral or floating point.\nThere are two issues:\n\nThe code does not compile. Complains that it needs '(' for function style cast or type construction. Not sure why?\nI am assuming that T,U,Tout all have the keyword value_type. I also want the class to work out if somebody is passing a raw pointer to an integral type or floating point. Is there an easy way to incorporate that?\nIf not, how can we ensure that the error message is very clear when somebody tries to pass a template argument which does not have the value_type"
] | [
"c++",
"templates",
"c++20",
"typetraits"
] |
[
"MongoDB/Mongoid Tree Structure",
"I'm currently speccing out the architecture for a project. Its on a fairly tight timeline, will need to support a few hundred thousand users fairly soon after launch, and its business logic and model are tied tightly to an extended tree structure. I know I can do this in Mongo in a variety of ways as listed in the documentation. The best seems to be a hybrid approach of a parent field + one of the following: materialized path or array of ancestors. Right now my test implementation is using an array of ancestors, with the array being populated with the ObjectIds of the related documents. On a sample dataset some of the query times are a tad higher than I would like, but still acceptable. Does anyone have any tips for optimizing this structure? I tried the full materialized path, but once my tree went past 10 or so levels performance really seemed to crash. All my test data sets were 500k documents. The other components that might be relevant is a web front-end powered by Rails, using Mongoid for the majority of the interface between Rails and Mongo."
] | [
"ruby-on-rails-3",
"mongodb",
"mongoid3"
] |
[
"add null value to a query where rows doesn't exist in table",
"I have this query:\n\nSELECT\n id,\n nullif(((ad != 3 and ad !=9 and ad !=2) + \n (rg != 3 and rg !=9 and rg !=2) + \n (sr != 3 and sr !=9 and sr !=2) + \n (cm != 3 and cm !=9 and cm !=2) + \n (ba != 3 and ba !=9 and ba !=2) + \n (jt != 3 and jt !=9 and jt !=2) + \n (sg != 3 and sg !=9 and sg !=2)),0) as dia\nFROM\n asistencia\nwhere\n id > 181 and id < 213\n\n\nI already add null if the value is 0, but let's say the table rows id ends at 200\n\nSo, the result query only shows the value rows until row id 200. I want to show complete rows from 181 up to 213 adding null value to rows beyond row id 200\nis that possible?\n\nThis is because I want to show all days in a Highcharts chart."
] | [
"mysql"
] |
[
"group and count array php",
"I have an array which contains another array values:\nEx. \n\narray:69 [▼\n 0 => array:9 [▼\n \"app\" => \"a.log\"\n \"context\" => \"local\"\n \"level\" => \"error\"\n \"level_class\" => \"danger\"\n\n\nI want to group all the error according to their levels\nEx: \n\narray:\n \"error\" => \"count of Errors\",\n \"debug\" => \"count of debug\"\n\n\nI tried doing this:\n\nforeach($logs as $log){\n $result[$log['level']] = $log; \n}\n\n\nThe result i get is: \n\narray:2 [▼\n \"error\" => \"Last error entry in array\"\n \"failed\" => \"Last failed entry in array\"\n]\n\n\nAny help is appreciated.\nThank You."
] | [
"php",
"arrays",
"laravel-5",
"php-7"
] |
[
"Adding Properties into a List or Collection",
"I have come across a situation where I probably needed to add properties(of a class) in a list to invoke them manually(or you can say, I need to assign there values(setter)). That is why because, I don't even know which properties is to set the values, but they are decided at runtime. So far I am trying to find out the solution here and there but still I don't get any article that even hints me a work around for this purpose.\nHere's what I want to do exactly (mentioned as comments)-\n\npublic class DemoClass\n{\n IList<Properties> _listOfProps;\n private int _iFirstProperty;\n private string _iSecondProperty;\n\n public DemoClass()\n {\n _listOfProps = new List<Properties>();\n }\n\n\n public int FirstProperty\n {\n get\n {\n return _iFirstProperty;\n }\n set\n {\n _iFirstProperty = value;\n // Here I want to add this property into the list.\n _listOfProps.Add(FirstProperty);\n RaisePropertyChanged(\"FirstProperty\");\n }\n }\n\n public string SecondProperty\n {\n get\n {\n return _iSecondProperty;\n }\n set\n {\n _iSecondProperty = value;\n RaisePropertyChanged(\"SecondProperty\");\n }\n }\n\n public void HandleChangedProperties()\n {\n foreach (var list in _listOfProps)\n {\n // Here I want to invoke the property. ie. sets the 'value' of this property.\n list.Invoke(value)\n }\n }\n}\n\n\nI know, I can use Func to add in the list like- but I can't go with this.\n\nList<Func<int>> listOfFunc = new List<Func<int>>();\nlistOfFunc.Add(() => { return 0; }); // Adds using lambda expression\nlistOfFunc.Add(temp); // Adds as a delegate invoker\n\nprivate int temp()\n{\n return 0;\n}\n\n\nfrom MSDN \n\n\n Properties can be used as if they are public data members, but they\n are actually special methods called accessors.\n\n\nif properties are internally methods, Why they can't be added as List of Func<> \nAlso, if there's no way I can do that without using Reflection (by getting PropertyInfo list), why Microsoft hasn't designed this in C#?"
] | [
"c#",
"list",
"generics",
"func"
] |
[
"accessing $router (ngNewRouter) inside function in module factory in Angular 1.4 doesn't work",
"I have the following:\n\nangular.module('app', [ 'ngNewRouter', 'security',\n\n\nand security module\n\nangular.module('security', ['ngNewRouter'])\n .factory('authService', ['$http', '$q', '$window', 'CONSTANTS', '$location', '$router', authService ]);\n\nfunction authService($http, $q, $window, CONSTANTS, $location, $router) {\n var service = {};\n\n\n //tries to login user\n var _login = function(loginData) {\n var data = {\n \"email\": loginData.email,\n \"password\": loginData.password\n };\n $http.post(CONSTANTS.baseURL + '/login', data)\n .success(function(data, status, headers, config) {\n _authenticate(data);\n --->>> $router and $location --->>> not defined here, although $http, $q, $window, CONSTANTS are defined\n })\n .error (function (data, status, headers, config) {\n _logOut();\n });\n};\n\n\nWhy is $router and $location not defined inside that function, and the others are?\nWhat am I missing?\n\nI also tried defining security module with and without ngNewRouter"
] | [
"javascript",
"angularjs"
] |
[
"Scraping a webpage with URL in Nepali (Non-English)",
"I am going through a website whose web page have urls in Nepali i.e. Non-English font. How do I give the start_urls for any spider(I am using scrapy for the purpose)? Is there any kind of encoding technique for that? And does the direct copy-paste of urls from browser a chance?\n\nUpdated:\nAnd I need to further parse into links that I get at certain webpage. And of course those links are non- English as well.\nThank you..."
] | [
"python",
"url",
"encoding",
"scrapy",
"screen-scraping"
] |
[
"Can't make localized strings in Windows Phone 7",
"I've followed the instructions of this tutorial Localizing a Windows Phone app Step by Step\n\nBut for some reason the Text=\"{Binding Path=AppResources.Title, Source={StaticResource LocalizedStrings}}\" doesn't work. It doesn't give any errors or anything.\n\nIt's just plain empty box.\n\nAny idea what might be wrong?"
] | [
"windows-phone-7",
"localization"
] |
[
"Mixing STL debug/release libraries",
"I'm aware that mixing debug and release libraries that pass STL containers to each other causes big problems. But what exactly in 'debug' or 'release' causes this?\n\nI have a QT project that gets built as 'release', but it has /DEBUG added to the compiler flags.\nIf I build another QT project under 'debug' (which also has the /DEBUG flag), are they compatible?\n\nOr is there an optimization flag or some other flag that makes them incompatible?\n\nBasically, is there a way I can look at the compilation line of the 2 libraries and see something that says \"DON'T MIX THESE!\"?"
] | [
"c++",
"qt",
"stl"
] |
[
"How to avoid calling same function for a prop for a component : ReactJS",
"Basically i am calling same function multiple times inside the component for a prop which is inside the render function.\n\nHow do i avoid calling the same function multiple times for a component required for that specific prop\n\nBelow is my code\n\ngetProperties = (name, param) => {\n switch(name){\n case 'duration':\n return param.obj1;\n case 'time':\n return param.obj2;\n case 'date':\n return param.obj3;\n case 'place':\n return param.obj4;\n }\n}\n\nrender() {\n return (\n <SampleComponent\n duration={this.getProperties('duration', param1)}\n time={this.getProperties('time', param2)}\n date={this.getProperties('date', param3)}\n place={this.getProperties('place', param4)}\n )\n}\n\n\nSo instead of having multiple methods to get the required details. How to use single method which does manipulation and return object with transformed data?"
] | [
"javascript",
"reactjs",
"react-component"
] |
[
"How to subscribe to Application.ApplicationExit from library assembly",
"Is there a way to subscribe to this event or something similar so I can perform some clean up codes before objects are finalized?"
] | [
"c#",
".net",
"vb.net"
] |
[
"TensorFlow 1.9.0 and Python 3.6.5",
"I'm trying to upgrade to Tensorflow 1.9 within a conda environment (Ubuntu 16.04). I am using python 3.6.5. When I try this:\n\nsource activate myenv\n\nsudo -H pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.9.0rc0-cp36-cp36m-linux_x86_64.whl\n\n\nI get the error:\n\ntensorflow-1.9.0rc0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.\n\n\nSeems strange because the same thing worked fine for TF 1.8\n\nTensorFlow seems to install fine without sudo -H but then when I try:\n\n python -c \"import tensorflow as tf; print(tf.__version__)\"\n\n\nI get the following error:\n\nfrom tensorflow.python.keras._impl.keras.backend import abs\nImportError: cannot import name 'abs'\n\n\nI can't install from conda because it still has 1.8 when I check with:\n\nconda install -c conda-forge tensorflow"
] | [
"python",
"tensorflow",
"installation",
"python-wheel",
"incompatibility"
] |
[
"How to get angular customfilter working?",
"Trying to create a custom angular filter for a list. I am using underscore too:\n\napp.filter('dateRangefilter', function($scope,_) {\n return function(input) {\n console.log('rangefilter');\n _.filter($scope.data, function(row) {\n return row.date >= '01/01/2000' && row.date <= '01/08/2020'\n });\n }\n});\n\n\nhtml:\n\n<ul>\n <li ng-repeat=\"item in data | dateRangefilter \">\n {{item.name}}\n </li>\n</ul>\n\n\nHowever I am getting an error:\n\nError: [$injector:unpr] http://errors.angularjs.org/1.3.0-`beta.14/$injector/unpr?p0=<!-- ngRepeat: item in data | dateRangefilter -->copeProvider%20%3C-%20%24scope%20%3C-%dateRangefilterFilter`\n\n\nHow can I get it to filter the data by daterange? in this case between 1/1/2000 and 1/8/2020?\n\nplunkr:http://plnkr.co/edit/oClJWLaw13Xl2UDxn0Vp?p=preview"
] | [
"angularjs",
"filter"
] |
[
"Changing PyQT Table Item from QComboBox to QTableWidgetItem",
"In my PyQT window, I have a table containing QComboBox in one column. How can the QComboBox later be changed to the regular QTableWidgetItem to display some text?\n\nI tried the following but the QComboBox was not replaced by text from QTableWidgetItem.\n\nmyTable= QTableWidget()\nmyTable.setRowCount(6)\nmyTable.setColumnCount(2)\nmyTable.setHorizontalHeaderLabels(QString(\"Name;Age;\").split(\";\"))\nmyTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)\n\n\n# Populate with QComboBox in column 1\nfor i, name in enumerate(nameList):\n myTable.setItem(i, 0, QTableWidgetItem(name ))\n\n ageCombo = QComboBox()\n for option in ageComboOptions:\n ageCombo.addItem(option)\n myTable.setCellWidget(i, 1, ageCombo)\n\n# Change column 1 to QTableWidgetItem\nfor i, name in enumerate(nameList):\n myTable.setItem(i, 1, QTableWidgetItem(name))"
] | [
"python",
"python-2.7",
"pyqt",
"pyqt4"
] |
[
"Converting from grades to gpa (with decimal)",
"I have this code:\n\nint[][] stuGrades = {{97, 64, 75, 100, 21}}; //extract from data file\n\nString[][] HWdata; // original data file\nfor (int g = 0; g < stuGrades.length; g++) {\n for (int p = 0; p < stuGrades[0].length; p++) {\n int tempScores = stuGrades[g][p];\n if (tempScores <= 100 && tempScores > 98.1) {\n stuGpa[g][p] = 4.0;\n }\n else if (tempScores <= 98 && tempScores > 96.1) {\n stuGpa[g][p] = 3.9;\n }\n }\n}\n\n\nMy goal is to convert the grades array {97, 64, 75, 100, 21} to a new GPA array, which will convert the score to 4.0, 3.9 or something else. I got this error:\n\n\n Exception in thread \"main\" java.lang.NullPointerException at homework7.main. \n\n\nHow can I resolve this issue?"
] | [
"java",
"arrays",
"2d"
] |
[
"Neural Network Neurons output numbers > 1",
"I have read that you calculate the output of a Neuron in a Neural Net by adding up all the inputs times their corresponding weights and then smoothing it with e.g. the Sigmoid Function.\n\nBut what I don't understand is that this sum (without smoothing) could get bigger than 1.\n\nWhen this happens my Sigmoid Function outputs 1.0.\n\nThe function I am using to calculate the Neuron Output (without smoothing) is:\n\ndef sum(self, inputs):\n valu = 0\n for i, val in enumerate(inputs):\n valu += float(val) * self.weights[i]\n return valu\n\n\nSo my question is:\nAm I doing something wrong, because I have read that the output should be between 0 and 1?"
] | [
"neural-network"
] |
[
"Python: lists, bins, and sorting",
"I have a quite specific thing to do and do not know how to accomplish that:\nI have two lists, x and y, of corresponding values (about 10k in each list). \n\nFirst, I need to bin both lists according to their order in x, in bins with N values in each bin. So I cannot pre-define fixed bin edges, I rather need, e.g., 10 values in each bin. \n\nThen I need to compute the median value of the 10 y values corresponding to each x bin. \n\nIn the last step, I have a third list, z, with more values like x (about 100k values), and then check for each value, in which x bin it would fall and add the mean value of the corresponding y bin to it (something like: z + mean[y_m:y_n][where x_m < z < x_n])).\nAny idea how to do that? Thanks!"
] | [
"python",
"list",
"mapping",
"binning"
] |
[
"SQL SERVER generating row number based on criteria",
"I have a table which has columns UserID,DIFFTIME. when I select these columns from the table, I also want to have a derived column which is : If the DiffTime is > 20 I want to increment the count per user id. \n\nFor example if the table has:\n\nUser ID DIFF TIME\n 1 0\n 1 5\n 1 10\n 2 0\n 2 21\n 2 5 \n\n\nI want a result set that is something like this:\n\nUser ID DIFF TIME SESSION NUMBER\n 1 0 1\n 1 5 1\n 1 10 1\n 2 0 1\n 2 21 2\n 2 5 2\n\n\nHow do I accomplish this.\n\nIdeas and suggestions are much appreciated!"
] | [
"sql-server-2008"
] |
[
"How to make vertical submenu expands to the right",
"I'm creating a web with a vertical navigation menu on the left. In this menu, I have several submenus which I would like to be expanded to the right when the mouse hovers the parent item.\n\nHere is the html\n\n <div id=\"leftmenu\">\n <ul>\n <li><a href=\"\">Item</a></li>\n <li><a href=\"\">item</a>\n <ul>\n <li><a href=\"\">SubItem</a></li>\n <li><a href=\"\">SubItem</a></li>\n </ul>\n </li>\n <li><a href=\"\">Item</a>\n <ul>\n <li><a href=\"\">SubItem</a></li>\n <li><a href=\"\">SubItem</a></li>\n <li><a href=\"\">SubItem</a></li>\n </ul>\n </li>\n <li><a href=\"\">item</a>\n <ul>\n <li><a href=\"\">SubItem</a></li>\n <li><a href=\"\">SubItme</a></li>\n <li><a href=\"\">SubItem</a></li>\n </ul>\n </li>\n <li><a href=\"\">item</a></li>\n <li><a href=\"\">Item</a></li>\n </ul>\n </div>\n\n\nAnd here is my CSS\n\n #leftmenu {\n float: left;\n margin: 30px;\n font-weight: bold;\n background: linear-gradient(#ffeb99, #ffe066);\n border: 0;\n border-radius: 10px;\n }\n\n #leftmenu ul {\n position: relative;\n border-radius: 10px;\n display: inline-block;\n }\n\n #leftmenu ul ul {\n display: none;\n background: #e7c702;\n }\n\n #leftmenu ul li:hover > ul {\n display: inline-block;\n width: 100%;\n height: 100%;\n position: absolute;\n left: 100%;\n }\n\n #leftmenu ul li a {\n padding: 15px 30px;\n display: block;\n color: #757575;\n text-decoration: none;\n font-size: 15px;\n text-transform: uppercase;\n }\n\n\nMy problem is when I hover the mouse to an item that has subitems, the subitems appear but it down not in the same line as its parent item. Instead, it appears in the same line of the item the item I'm hovering. I'm learning CSS so I don't want to use any JavaScript in this case.\n\nPlease help me with this.\nSorry if I format something wrong since this is my first post here.\nThank you"
] | [
"css",
"menu"
] |
[
"SqlAlchemy can't determine join condition",
"I have 2 tables defined:\n\nclass TCableSet(Base):\n __tablename__ = 'tCableSet'\n\n ixCableSet = Column(Integer, primary_key=True)\n decCableSetOne = Column(Numeric(8, 2))\n decCableSetTwo = Column(Numeric(8, 2))\n decCableSetThree = Column(Numeric(8, 2))\n\nclass TStepVoltage(Base):\n __tablename__ = 'tStepVoltage'\n\n ixStepVoltage = Column(Integer, primary_key=True)\n ixSubReport = Column(Integer, ForeignKey('tSubReport.ixSubReport'), nullable=False)\n iVoltage = Column(Integer)\n ixPhaseA = Column(Integer, ForeignKey('tCableSet.ixCableSet'), nullable=False)\n ixPhaseB = Column(Integer, ForeignKey('tCableSet.ixCableSet'), nullable=False)\n ixPhaseC = Column(Integer, ForeignKey('tCableSet.ixCableSet'), nullable=False)\n\n sub_report = relationship('TSubReport',\n backref=backref('step_voltage'))\n\n\nI understand why I am getting this error but can't figure out a proper way (yet).\nWhen the table gets saved, I store the values in the tCableSet table and then use the id as a foreign key in my tStepVoltage table. The problem I have is when I go to retrieve the data, I want to be able to get the values(tCableSet row) along with the rest of my tStepVoltage table via a relationship, however I'm not sure how to go about this since I don't have a field in my tCableSet that can directly be linked via relationship to my tStepVoltage. I basically just needed the tCableSet for normalization"
] | [
"python",
"sqlalchemy",
"pyramid"
] |
[
"Module not found: Error: Can't resolve './style.css' in Directory?",
"I am trying to run the command npm run build but it is not working. and I am getting the error below:\n\n> [email protected] build /Users/Prashant/Code/typescript\n> webpack\n\nHash: c6dbd1eb3357da70ca81\nVersion: webpack 3.2.0\nTime: 477ms\n Asset Size Chunks Chunk Names\nbundle.js 2.89 kB 0 [emitted] main\n [0] ./src/index.js 51 bytes {0} [built]\n [1] ./src/index.css 290 bytes {0} [built] [failed] [1 error]\n\nERROR in ./src/index.css\nModule build failed: Unknown word (5:1)\n\n 3 | // load the styles\n 4 | var content = require(\"!!./index.css\");\n> 5 | if(typeof content === 'string') content = [[module.id, content, '']];\n | ^\n 6 | // Prepare cssTransformation\n 7 | var transform;\n 8 |\n\n\n@ ./src/index.js 1:0-22\n\n\nMy web pack config file(webpack.config.js) is:\n\nvar path = require('path');\n\nmodule.exports = {\n entry: './src/index.js',\n output: {\n path: path.resolve(__dirname, 'dist'),\n filename: 'bundle.js'\n },\n module: {\n rules: [\n {\n test: /\\.css$/,\n use: [\n 'css-loader',\n 'style-loader'\n ]\n }\n ]\n }\n};\n\n\nAnd my CSS file(index.css) is \n\nbody {\n color:red;\n}\n\n\nand my js file index.js is below:\n\nrequire(\"./index.css\");\nalert('this is my alert');\n\n\nI am trying to run the file but it is not working I have checked all the spelling also try to add a lot of other CSS but it is not working, can you please help me how can I solve this issue?"
] | [
"css",
"webpack",
"css-loader"
] |
[
"Animate the fall of item WPF",
"Could you please help me to implement in my WPF Application the fall of an image (png) from the outside (from the top) of my window. And finally it should be located in a certain point of the window. Sry for English btw."
] | [
"wpf",
"animation"
] |
[
"Using form in multiple locations -- controller should redirect to different location depending on where the request came from",
"I have a form to add a staff member.\n\nThe form is first used when an account is created in a sequence of view to help the user setup their account.\n\nIt is then used in a different place once the account has already been setup.\n\nThese two use different layouts and controllers, so have different URLs. However, when the form is submitted, they both currently call the same controller#create. Now, if the form is submitted form the setup area, it should redirect to one URL after the create action is called. It should go to a different location if it's called from the main application UI (non-setup).\n\nWhat's the simplest way to set this up?"
] | [
"ruby-on-rails"
] |
[
"SQLBulkCopy: Does Column Count make difference?",
"I try to search but didn't found answer to relative simple thing. I have a CSV, that doesn't have all the column as in my database table, as well as it miss the auto increment, primary key in CSV too. \n\nAll I did is I read CSV into the DataSet, and then run a traditional SQLBulkCopy code to read the first table of dataset to database table. But it give me following error:\n\nThe given ColumnMapping does not match up with any column in the source or destination.\n\nMy code for bulkcopy is \n\nusing (SqlBulkCopy blkcopy = new SqlBulkCopy(DBUtility.ConnectionString))\n{\n\n blkcopy.EnableStreaming = true;\n blkcopy.DestinationTableName = \"Project_\" + this.ProjectID.ToString() + \"_Data\";\n blkcopy.BatchSize = 100;\n foreach (DataColumn c in ds.Tables[0].Columns)\n {\n blkcopy.ColumnMappings.Add(c.ColumnName, c.ColumnName);\n }\n\n blkcopy.WriteToServer(ds.Tables[0]);\n blkcopy.Close();\n}\n\n\nI add Mapping to test, but it doesn't make difference to remove mapping part. If we remove mapping that it try to match column in order and since column are different in count they end up mismatch datatype and lesser column values etc. Oh yes the column names from CSV does match that from Table, and are in same case.\n\nEDIT: I change the mapping code to compare the column name from live DB. For this I simply run a SQL Select query to fetch 1 record from database table and then do following\n\nforeach (DataColumn c in ds.Tables[0].Columns)\n{\n if (LiveDT.Columns.Contains(c.ColumnName))\n {\n blkcopy.ColumnMappings.Add(c.ColumnName, c.ColumnName);\n }\n else\n {\n log.WriteLine(c.ColumnName + \" doesn't exists in final table\");\n }\n}"
] | [
"sql-server",
"sqlbulkcopy"
] |
[
"Get labels and Radiobuttons all on 1 line:",
"Possible Duplicate:\n Radio buttons and label to display in same line \n\n\n\n\nI have 3 labels and radiobuttons that i want to put on 1 line:\n\nWhat i get now is this:\n\nSpoortoegang\nUit\nradiobutton\nAan\nradiobutton\n\n\nWhat i want is: \n\nSpoortoegang Uit radiobutton Aan radiobutton\n\n\nMy code for this is:\n\n<div ><p>Spoortoegang</p><label for=\"no\">Uit;<input dojoType=\"dijit.form.RadioButton\" id=\"valSR\" name=\"group1\" checked=\"checked\" onchange='POI(this);' value=\"Show\" type=\"radio\"/> </label>\n<label for=\"yes\">Aan;<input dojoType=\"dijit.form.RadioButton\" id=\"valSlope\" name=\"group1\" value=\"Hide\" onchange='POI(this)' type=\"radio\"/></label></div>"
] | [
"css",
"radio-button",
"alignment",
"label"
] |
[
"How to set initial condition to get the trajectory as a solution of the equation of the motion?",
"I would like to see the solution of the equation of motion with the electrostatic force. What is wrong in the script below? It the problem in initial condition? Thank you\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.integrate import odeint\n\ndef dr_dt(y, t):\n """Integration of the governing vector differential equation.\n d2r_dt2 = -(e**2/(4*pi*eps_0*me*r**2)) with d2r_dt2 and r as vecotrs.\n Initial position and velocity are given.\n y[0:2] = position components\n y[3:] = velocity components"""\n\n e = 1.602e-19 \n me = 9.1e-31\n eps_0 = 8.8541878128e-12\n r = np.sqrt(y[0]**2 + y[1]**2 + y[2]**2)\n\n dy0 = y[3]\n dy1 = y[4]\n dy2 = y[5]\n dy3 = -e**2/(4 * np.pi * eps_0 * me * (y[0])**2)\n dy4 = -e**2/(4 * np.pi * eps_0 * me * (y[1])**2)\n dy5 = -e**2/(4 * np.pi * eps_0 * me * (y[2])**2)\n return [dy0, dy1, dy2, dy3, dy4, dy5]\n\nt = np.arange(0, 100000, 0.1)\ny0 = [10, 0., 0., 0., 1.e3, 0.]\ny = odeint(dr_dt, y0, t)\nplt.plot(y[:,0], y[:,1])\nplt.show()\n\nThis is the desired result of the shape of the trajectory:\n\nI apply the following initial conditions:\nt = np.arange(0, 2000, 0.1) \ny01 = [-200, 400., 0., 1., 0, 0.] \ny02 = [-200, -400., 0., 1., 0, 0.]\n\nand got this:\n\nWhy is the shape of the trajectory different?"
] | [
"python",
"numpy",
"scipy",
"ode",
"odeint"
] |
[
"Get value from clicked parent in jQuery",
"I have this code:\n\n<div class=\"container\">\n <div class=\"switchStatus btn-group\" data-module=\"xxx\">\n <a class=\"btn btn-primary\">Active</a>\n <a class=\"btn btn-primary\">Inactive</a>\n </div>\n</div>\n\n\nHow can I get the data-module content ?\n\nActually, my code looks like this but it doesn't work:\n\n$('.container').on('click', '.switchStatus a', function() {\n var module = $(this).data('module');\n});\n\n\nThanks."
] | [
"javascript",
"jquery"
] |
[
"Getting the current time (in milliseconds) from the system clock in Windows?",
"How can you obtain the system clock's current time of day (in milliseconds) in C++? This is a windows specific app."
] | [
"c++",
"windows"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.