texts
sequence | tags
sequence |
---|---|
[
"Save downloaded images with python into a local folder",
"I use the following code to scrape image url from a website. What I try to achieve next is to save urls that end with '.jpg' into a local folder which can be the location of the py code.\nI manage to scrape and access urls and to create a folder in that location but I don't know how to save them.\nThis is my code, any ideas are highly appreciated\nfrom selenium import webdriver\nimport requests\nimport os\nfrom bs4 import BeautifulSoup\nimport urllib\nimport urllib.request\nfrom urllib.request import urlretrieve\nimport sys\n\nif sys.version_info[0] >= 3:\n\nfrom urllib.request import urlretrieve\nelse:\n# if Not Python 3\nfrom urllib import urlretrieve\n\nsite = 'https://www.amazon.de/dp/B077S8N26F'\ndirectory = os.path.dirname(os.path.realpath(__file__)) + '/image_folder/'\nif not os.path.exists(directory):\n os.makedirs(directory)\n\ndriver = webdriver.Chrome()\ndriver.get(site)\nsoup = BeautifulSoup(driver.page_source, 'html.parser')\n\nimg_tags = soup.find_all('img')\nurls = [img['src'] for img in img_tags]\nfor url in urls:\nprint(url)\n#only the links that end with .jpg\nimages = [im for im in urls if im.endswith(".jpg")]\nprint(images)\nfor im in images:\n #here is the missing part that saves urls into the folder created"
] | [
"python",
"beautifulsoup",
"save"
] |
[
"Find minimum element and its position in list with Nones",
"I have a list of numbers and Nones like this:\n\nl = [2., None, 3., 1., None, 2., None, 5.]\n\n\nI want to get the minimum number and its index, while the Nones should simply be ignored. For the given example, the result would thus be:\n\n(1., 3)\n\n\nOf course, it is straightforward to write a function that does what I want but I would prefer some efficient built-in or at least high-level approach. \nI am particularly interested in solutions for Python 3, where the min-function does not accept None as an argument."
] | [
"python",
"python-3.x",
"list",
"min"
] |
[
"can AnyOne explain how to properly add constraints to navigation bar buttons or what is wrong with this piece of code?",
"navigationBar.items = [navItem]\n\nlet searchImage = UIImage(named: \"searchIcon\")?.withRenderingMode(.alwaysOriginal)\n\nlet searchButton = UIBarButtonItem(image: searchImage, style: .plain, target: self, action: #selector(handleSearch)) \nlet menubutton = UIBarButtonItem(image: UIImage(named: \"menu\")?.withRenderingMode(.alwaysTemplate), style: .plain, target: self, action: #selector(slideMenu)) \nlet refreshButton = UIBarButtonItem(image: UIImage(named: \"refreshIcon\")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(handleRefresh))\n\n//searchButton.tintColor = UIColor.yellow\n// searchButton.t\nnavigationBar.delegate = self\n\nnavItem.setRightBarButtonItems([searchButton,refreshButton], animated: false)\nnavItem.setLeftBarButton(menubutton, animated: false)"
] | [
"ios",
"swift",
"xcode"
] |
[
"Maven \"checkstyle:checkstyle\" always defaults to \"sun_checks.xml\" with inline checkstyle configuration",
"Trying to figure out whether I'm doing something wrong or if this is a bug in the maven checkstyle plugin. If I do mvn checkstyle:check I get this:\n\njonathanfisher@odin ~/dev/snapjms/snapjms $ mvn checkstyle:check\n[INFO] Scanning for projects...\n[INFO] \n[INFO] ------------------------------------------------------------------------\n[INFO] Building snapjms 1.0.0-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[INFO] \n[INFO] --- maven-checkstyle-plugin:2.17:check (default-cli) @ snapjms ---\n[INFO] There is 1 error reported by Checkstyle 6.11.2 with /Users/jonathanfisher/dev/snapjms/snapjms/target/checkstyle-rules.xml ruleset.\n[ERROR] src/main/java/org/xxx/xxx/snapjms/jms/factories/UnsupportedPayloadException.java:[8] (sizes) LineLength: Line is longer than 135 characters (found 144).\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 1.411 s\n[INFO] Finished at: 2016-06-16T15:33:58-05:00\n[INFO] Final Memory: 17M/371M\n\n\nIf I do mvn checkstyle:checkstyle notice how it flips to sun_checks.xml:\n\njonathanfisher@odin ~/dev/snapjms/snapjms $ mvn checkstyle:checkstyle\n[INFO] Scanning for projects...\n[INFO] \n[INFO] ------------------------------------------------------------------------\n[INFO] Building snapjms 1.0.0-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[INFO] \n[INFO] --- maven-checkstyle-plugin:2.17:checkstyle (default-cli) @ snapjms ---\n[INFO] There are 451 errors reported by Checkstyle 6.11.2 with sun_checks.xml ruleset.\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 1.904 s\n[INFO] Finished at: 2016-06-16T15:35:46-05:00\n[INFO] Final Memory: 24M/361M\n\n\nHere's my inline config:\n\n<build>\n <pluginManagement>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-checkstyle-plugin</artifactId>\n <version>2.17</version>\n <inherited>true</inherited>\n <configuration>\n <logViolationsToConsole>true</logViolationsToConsole>\n <checkstyleRules>\n <module name=\"Checker\">\n <module name=\"SuppressionCommentFilter\" />\n <module name=\"LineLength\">\n <property\n name=\"max\"\n value=\"135\" />\n <property\n name=\"ignorePattern\"\n value=\"@version|@see\" />\n </module>\n </checkstyleRules>\n </configuration>\n </plugin>\n </plugins>\n </pluginManagement>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-checkstyle-plugin</artifactId>\n </plugin>\n </plugins>\n</build>\n<reporting>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-checkstyle-plugin</artifactId>\n </plugin>\n</reporting>\n\n\nThe report on mvn:site also uses sun_checks.xml What am I doing wrong?"
] | [
"java",
"maven",
"checkstyle"
] |
[
"how to get the current sort column in a jqGrid after user clicks a column header",
"I'm in the beforeRequest handler, and would like to know what the current sort column is. How can I find that?"
] | [
"jquery",
"jqgrid"
] |
[
"How to run telnet in qnx",
"I am trying to transfer my console application written in ncurses under the terminal connected to the com port to the virtual terminal using telnetd.\nWhen you try to start telnetd, you get: telnetd: getpeername: Socket operation on non-socket. When connected via putty, the connection crashes. netstat shows:\nnetstat"
] | [
"telnet",
"qnx"
] |
[
"Does Android 4.x support streaming RTSP over TCP?",
"I've used VideoView in Android to play video on wowza successfully. Now I got to deal with my server which the UDP ports seems to be blocked. With the proof of openRTSP command:\n\n-> % openRTSP rtsp://61.218.52.250:554/live/ch00_0\n\nOpening connection to 61.218.52.250, port 554...\n...remote connection opened\nSending request: OPTIONS rtsp://61.218.52.250:554/live/ch00_0 RTSP/1.0\nCSeq: 2\nUser-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16)\n\n\nReceived 105 new bytes of response data.\nReceived a complete OPTIONS response:\nRTSP/1.0 200 OK\nCSeq: 2\nServer: UBNT Streaming Server v1.2\nPublic: DESCRIBE, SETUP, TEARDOWN, PLAY\n\n\nSending request: DESCRIBE rtsp://61.218.52.250:554/live/ch00_0 RTSP/1.0\nCSeq: 3\nUser-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16)\nAccept: application/sdp\n\n\nReceived 562 new bytes of response data.\nReceived a complete DESCRIBE response:\nRTSP/1.0 200 OK\nCSeq: 3\nServer: UBNT Streaming Server v1.2\nContent-Base: rtsp://61.218.52.250:554/live/ch00_0/\nContent-Type: application/sdp\nContent-Length: 393\n\nv=0\no=- 1 1 IN IP4 127.0.0.1\ns=Ubiquiti Live\ni=UBNT Streaming Media\nc=IN IP4 0.0.0.0\nt=0 0\nm=video 0 RTP/AVP 99\nb=AS:50000\na=framerate:25\na=x-dimensions:1280,720\na=x-vendor-id:ubnt,a521\na=x-rtp-ts:4617405454576779984\na=rtpmap:99 H264/90000\na=fmtp:99 profile-level-id=42A01E;packetization-mode=1;sprop-parameter-sets=Z0IAKOkAoAt1xIAG3dAAzf5gDYgQlA==,aM4xUg==\na=control:trackID=0\n\nOpened URL \"rtsp://61.218.52.250:554/live/ch00_0\", returning a SDP description:\nv=0\no=- 1 1 IN IP4 127.0.0.1\ns=Ubiquiti Live\ni=UBNT Streaming Media\nc=IN IP4 0.0.0.0\nt=0 0\nm=video 0 RTP/AVP 99\nb=AS:50000\na=framerate:25\na=x-dimensions:1280,720\na=x-vendor-id:ubnt,a521\na=x-rtp-ts:4617405454576779984\na=rtpmap:99 H264/90000\na=fmtp:99 profile-level-id=42A01E;packetization-mode=1;sprop-parameter-sets=Z0IAKOkAoAt1xIAG3dAAzf5gDYgQlA==,aM4xUg==\na=control:trackID=0\n\nCreated receiver for \"video/H264\" subsession (client ports 63346-63347)\nSending request: SETUP rtsp://61.218.52.250:554/live/ch00_0/trackID=0 RTSP/1.0\nCSeq: 4\nUser-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16)\nTransport: RTP/AVP;unicast;client_port=63346-63347\n\n\nReceived 47 new bytes of response data.\nReceived a complete SETUP response:\nRTSP/1.0 461 Unsupported Transport\nCSeq: 4\n\n\nFailed to setup \"video/H264\" subsession: 461 Unsupported Transport\n\n\nAfter searching around I found it seems Android still not support RTSP over TCP:\n\n\n When streaming to an Android device using RTSP/RTP, the RTP portion\n must flow over UDP. Android doesn't support RTSP/RTP interleaved (RTP\n over TCP). This means that if UDP is unavailable for RTP playback, RTP\n over TCP won't work as a failover and your stream won't play.\n\n\nConsidering it's posted on 2010, does Android 4.x support RTSP over TCP now? I've found lots of post asking for how to force transfer via TCP other than UDP. I guess it's not. \n\nIf not, could I achieve it by re-compiling and using ffmpeg library? \n\nBasically I hope ffmpeg could help me to automatically switch to TCP while UDP not available."
] | [
"android",
"tcp",
"ffmpeg",
"udp",
"rtsp"
] |
[
"PHP - maintain cookie after clearing cache",
"I've to restrict access to a specific page if it's been visited more than once a day, so I did the following:\n\n<?php\n\n if(! isset($_COOKIE[\"VisitCount\"])){\n setcookie(\"VisitCount\", \"1\", strtotime('today 23:59'));\n }\n\n if($_COOKIE[\"VisitCount\"] > 1){\n echo \"<script>alert('You can only play once a day'); location.href='http://example.com';</script>\";\n exit();\n }\n else {\n setcookie(\"VisitCount\", ($_COOKIE[\"VisitCount\"] + 1), strtotime('today 23:59'));\n }\n\n?>\n\n\nBut the user can clear the cache and enter that page again. How can I change it so users are blocked for the remaining of the day?\n\nEDIT:\n\nI added a 'time' column on my table, I suppose I have to use an If statement to check if the last time is within the last 24 hours, but I don't know how to do it.\n\nAlso, the access is limited to once a day, but not exactly every 24 hours since it should reset at midnight, would this require a different code? or the one I provided above could work (slightly modified)?"
] | [
"php",
"cookies"
] |
[
"Mobile emulator/simulator Detox screenshot artifacts differ when run on different hosts",
"I'm taking screenshots with Detox locally and committing them to my source repo. In continuous integration (Circle/macOS executor), I'm running the test again and detecting any file differences. Basically a form of visual regression testing. Unexpectedly, the PNG files differ when run on CI. This is occurring for both iOS and Android. Inspecting the resulting PNG file that was run on CI, the RGB values differ randomly by one. For example RGB(23,42,23) vs RGB(23,42,24). The difference could be in any of the color channels. Spot checking the result, it's usually just one channel (but presumably could be more than one).\n\nSome notes:\n\n\nFor Android, it looks like the adb screencap command is used by Detox, which looks like it can emit raw or PNG output (Detox is using the latter).\nThe same emulator (Android) and simulator (iOS) type is being used in the tests\n\n\nSo my questions are:\n\n\nIs PNG output deterministic given the same input?\nIs adb screencap (and the equivalent on iOS used by Detox) causing this?"
] | [
"android",
"ios",
"circleci",
"libpng",
"detox"
] |
[
"How can I designate 'url' of 'BUNDLE_DIR_NAME' correctly?",
"I'm using Django and react with webpack\n\nWhile setting up WEBPACK_LOADER in settings.py, I've faced the problem!\nMy file tree is like this.\n\nMy File Tree\n\nCebula4\n - back\n - manage.py\n - front\n - bundles\n - MainPage.js (webpacked)\n\n\nand\n\nWEBPACK_LOADER = {\n 'DEFAULT' : {\n 'BUNDLE_DIR_NAME': '/front/bundles/',\n 'STATS_FILE': os.path.join(BASE_DIR, 'front/webpack-stats.json'),\n\n }\n}\n\n\nI'd like to get a bundled(webpacked) file, MainPage.js but, Server said there is none at that url.\n\nPlease understand my low level of programming,\n Could I ask what is the correct url that I can get exact MainPage.js?\n\nAdded part of my STATIC_URL and STATIC_ROOT\n\nSTATIC_URL = '/'\nSTATICFILES_DIRS=[\n os.path.join(BASE_DIR,'static'),\n]\n\nSTATIC_ROOT=os.path.join(BASE_DIR,'staticfiles')"
] | [
"django",
"reactjs",
"webpack",
"webpack-loader",
"django-webpack-loader"
] |
[
"Performance: should I make one or multiple queries to database",
"I have a C# program that has to process about 100 000 items, and ADO.NET access to sql server database, and in one part of the program I have to make a performance decision:\n\nDurring processing, for each item I have to read data from a database: \n\nshould I query database once for every item, or should I query once at the beginning for all items, and keep that 100 000 rows of data (about 10 columns - int and string) in c# object in memory and retrieve required data from it?"
] | [
"c#",
"sql-server",
"tsql"
] |
[
"(CentOS 6) Running Artisan command through crontab causes Reflection exception",
"When I run command php artisan schedule:run, it runs fine. However, when I put the command into the scheduler as follows:\n\n* * * * * php /PATH/TO/PROJECT/artisan schedule:run >> /PATH/TO/PROJECT/storage/logs/scheduler.log 2>&1\n\n\nI get the following error every time it runs.\n\nPHP Fatal error: Uncaught ReflectionException: Class log does not exist ...\n\n\nThis question shows that it's because of an error that happens early in the bootstrap process and tries to log an error before the logger is registered.\n\nI can't seem to figure out where to start debugging since this is the only call stack I get:\n\nPHP Fatal error: Uncaught ReflectionException: Class log does not exist in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php:734\nStack trace:\n#0 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): ReflectionClass->__construct('log')\n#1 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\\Container\\Container->build('log', Array)\n#2 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\\Container\\Container->make('log', Array)\n#3 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(849): Illuminate\\Foundation\\Application->make('log')\n#4 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(804): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter))\n#5 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(773): Illuminate\\Container\\Container in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 734\n\n\nI suspect it may have something to do with permissions, however the crontab is tied to the same user who runs it manually. What is causing the original error?"
] | [
"php",
"linux",
"laravel",
"cron",
"centos"
] |
[
"struts 2 : how to pass a global parameter from one action to another",
"I have a case like this:\n\nJSP -> ACTION 1 -> Redirect-> Action 2 -> JSP\n\nWhile redirecting we loose all the parameters. But there is one parameter that I'd like to pass from one action to another. The parameter is always the same for all actions.\n\nI know that it is possible to write the following code and it works :\n\n<action name=\"myAction\" class=\"myActionClass\" method=\"doThis\">\n <result name=\"success\" type=\"redirect\">doThat.action?myParam=${myParam}</result>\n</action>\n\n\nThe only thing is that I'd like to pass the parameter automatically from one action to another when I have a redirect without writing anything in my action tag, but I don't know how to code it.\n\nIs it possible with struts 2 to do that? \n\nSomeone suggested to put it in global-results, I tried, but still haven't succeeded."
] | [
"struts2"
] |
[
"Powershell implicit type conversion",
"I have the following powershell code, adding to a ArrayList.\nWhen I ToString() and object and put its value in the list and later do a -join it comes out wrong.\n\n$list = New-Object System.Collections.ArrayList \nforeach($key in $keyList)\n{\n $value = $dict[$key]\n\n $value.GetType() # Foo.Bar.SomeObject\n\n $stringValue = $value.ToString()\n $stringValue.GetType() # System.String\n $stringValue # Outputs the actual value eg. John Doe\n\n $list.Add($stringValue)\n}\n\n$list -join \",\" # Outputs Foo.Bar.SomeObject,Foo.Bar.SomeObject,Foo.Bar.SomeObject,Foo.Bar.SomeObject\n\n\nUsing $list.Add(\"$value\") works fine. Causing $list -join \",\" to output the expected list of John Doe,68,1292\n\nWhat is going on?"
] | [
"powershell",
"powershell-3.0"
] |
[
"Powershell7 dll loading into VSCode script",
"My Project: To build an automated task to weekly or monthly save gmail report attachments to Win10 folders for further analysis. This is currently done as a manual process.\nThe platform is a local Win10-PC and does not use Outlook365. Local Outlook.exe linked to Gmail.\nPowershell 7x is the platform and various coding strategies have been attempted and failed.\nNumerous suggestions from Stackoverflow have been studied with no success.\nLatest attempt is by using the Codeplex distribution of ImapiX.zip but working with ImapiX I have never been able to use the dll sucessfully.\n\nUsing the code variants as follows.\n$dllFile="C:\\Users\\Al Perkins\\Desktop\\OL_AutoSaveAttachments\\imapiX-Source\\sourceCode\\ImapX\\bin\\Release\\ImapX.dll"\n$dll=[System.Reflection.Assembly]::LoadFile($dllFile) \n\n# Result\n$dll\n\nImapX, Version=2.0.0.19, Culture=neutral, PublicKeyToken=5992873d65130d1f\n\nSo it appears to load as expected in VSCode.\n$dllFile="C:\\Users\\Al Perkins\\Desktop\\OL_AutoSaveAttachments\\imapiX-Source\\sourceCode\\ImapX\\bin\\Release\\ImapX.dll"\n[System.Reflection.Assembly]::LoadFile($dllFile) \n\n# difference is the Loadfile is not captured to var.\n# The terminal window reports that the dll also loaded as expected.\n \nGAC Version Location\n--- ------- --------\nFalse v4.0.30319 C:\\Users\\Al Perkins\\Desktop\\OL_AutoSaveAttachments\\imapiX-Source\\sourceCode\\ImapX\\bin\\Release\\ImapX.dll\n\nHOWEVER either way when I get to use the dll methods it seems they are not available?\n$client = New-Object ImapiX.ImapClient\n\nNew-Object: C:\\Users\\Al Perkins\\Desktop\\OL_AutoSaveAttachments\\DLAttachments.ps1:27:11\nLine |\n 27 | $client = New-Object ImapiX.ImapClient\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n | Cannot find type [ImapiX.ImapClient]: verify that the assembly containing this type is loaded.\n\nAnd this similarly fails with any subsequent IMAPI method.\nSo I guess the dll is not built correctly but now this is way out of my scope.\nMy ask here is for any relevant suggestions as to how I might correct this issue.\nMany Thanks\nAL"
] | [
"powershell"
] |
[
"\"Node Commands\" printed at prompt when trying to run grunt/ gulp on Windows 7",
"I've installed nodejs, and have used npm to install grunt using\nnpm install grunt \n\nWhen I try to run grunt, I am presented with what appears to be instructions on running node commands: (see image)\n\nthe same applies when trying to run gulp\n\nI have done the same steps on other computers, and had no problem running grunt previously\n\n\nPlease suggest ideas as to what's going on.\nThanks"
] | [
"npm"
] |
[
"React native changing default page while in development",
"When in development it's easier/faster to develop if we can see the currently editing page as soon as the app is displayed in emulator. Is there an easy way to do this without changing the navigation paths manually?"
] | [
"react-native"
] |
[
"How to exclude white spaces while search",
"In Angular2+ I wrote a pipe for searching through an array, which is working fine. but I want to exclude the white spaces in the array.\n\nMy current PIPE\n\nimport { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'arraySearch'\n})\n\nexport class ArraySearchPipe implements PipeTransform {\n\n transform(value: any, args?: any): any {\n if (!args) { return value; }\n return value.filter(item => this.checkValues(item, args));\n }\n\n checkValues(item, args) {\n const value = Object.keys(item).map(k => item[k]);\n return String(value).indexOf(args) > -1;\n }\n\n}\n\n\nThis piece of code searches for terms with exact terms. How to exclude spaces in array items and search?\n\nThanks."
] | [
"typescript"
] |
[
"Windows installer (MSI) does not copy a config file",
"I installed an MSI buillder tool on my visual studio 2017 and started deploying my desktop application with generated MSIs. The istaller is able to copy vital files and adds registery keys but it does not copy some additional config files which are required for logger. According to this page, switching \"Copy to Output Directory Property\" to \"Copy always\" supposed to take care the issue however, it still does not copy the config file into output directory on client's computer. \n\n\n\nCan somebody give an advice about how I can diagnose this problem ?\n\nEdit:\n\nI think I can explicitly add logs files into MSI with following method but I have two concerns on this. Would I add the file into MSI with its global or relative path ? Secondly will it be a good practice ?\n\n\n\nEdit 2:\n\nFor the reference for developers who has the same issue, looks like the method stated above adds files with its relative path. I added screenshot of difference page at source control."
] | [
"c#",
"windows-installer",
"visual-studio-setup-proje"
] |
[
"Facebook share article by image from website",
"Facebook allows us to share our website page on facebook by implementing facebook graph og: structure on top of the page. But what if we want to have share button on actual images in the article. Let's say we have 5 images in article, and we have facebook share button near the image. Is there any tutorial how can implementation be achieved by sharing actual image and url of website, instead of preloaded facebook graph og: settings of the page?"
] | [
"facebook",
"facebook-graph-api"
] |
[
"Configuring PhoneGap 3.5 in Xcode 5.1 breaks plugins",
"So I have an interesting issue. I can create an iOS application using:\n\ncordova platform add ios\ncordova plugin add PluginSrc/MyPlugin\n\n\nEverything works 100%, I can click the button in the WebView and the plugin runs.\n\nI then add some framework files to the plugin, however the frameworks throw an error message because I did not set the linker flags. So I open XCode and add the following to the \"other linker flags\" settings under build settings:\n\n-mthumb -lstdc++ -lz -lm -mfpu=neon\n\n\nOn build, everything works however when I click the button I get the following error message:\n\nCDVPlugin class MyPlugin (pluginName: MyPlugin) does not exist.\nERROR: Plugin 'MyPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.\n\n\nAny reason for this? Is there a way to fix this? Seems like xcode messes up the project file."
] | [
"ios",
"xcode",
"cordova"
] |
[
"Moving a triangle using given coordinate",
"I'm working on a project and I want to animate a rectangle to move a certain amount of coordinate that i have set earlier.\n\nEx: My rectangle is at the position (x=0,y=0). I want with a click of a button to make it move at position (x=150, y=230) in interval of 100 milliseconds. So with one click, it would go to (10,25) at first 100 milliseconds,(20,35) for second 100 milliseconds and so on until the rectangle reach the final position(x=150, y=230)...\n\nI'm working with visual studio and blend on Visual C# wpf.\n\nThis is my progress of codes in code-behind file:\n\npublic partial class MainWindow : Window\n{\n public MainWindow()\n {\n InitializeComponent();\n }\n\nprivate void Button_Click(object sender, System.Windows.RoutedEventArgs e)\n{\n var myRect = (Rectangle)this.FindName(\"myRect\");\n double x = Canvas.GetLeft(myRect);\n double y = Canvas.GetTop(myRect);\n\n Canvas.SetLeft(myRect,x+10);\n Canvas.SetTop(myRect,y);\n\n\nAnd this is in XAML code:\n\n<Window x:Class=\"move.MainWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n xmlns:local=\"clr-namespace:move\"\n mc:Ignorable=\"d\"\n Title=\"MainWindow\" Height=\"350\" Width=\"525\">\n<StackPanel>\n <Border BorderThickness=\"1\" BorderBrush=\"Aqua\">\n <Canvas Name=\"PointCanvas\" Width=\"500\" Height=\"294\" Margin=\"9,0,6,0\">\n <Rectangle x:Name=\"myRect\" Fill=\"#FFF5F4F5\" Height=\"39\" Canvas.Left=\"170\" Stroke=\"Black\" Canvas.Top=\"89\" Width=\"89\"/>\n </Canvas>\n </Border>\n <Button Name=\"Move\" Click=\"Button_Click\">Move</Button>\n</StackPanel>"
] | [
"c#",
"wpf"
] |
[
"Call java method in python with Jpype",
"Sample Java File:\n\npackage com.example.helloworld;\n\npublic class SampleClass {\n\npublic static int square(int x){\n return x*x;\n}\n\npublic static void main(String[] args){\n System.out.println(square(4));\n\n }\n\n}\n\n\nLocal path to Sampleclass.java\n\nC:\\\\Desktop\\\\TestProject\\\\src\\\\main\\\\java\\\\com\\\\example\\\\helloworld\\\\SampleClass.java\n\n\nI am trying to call square method from SampleClass in Python.\n\nCode from reference Calling java methods using Jpype:\n\nfrom jpype import *\nstartJVM(getDefaultJVMPath(),\"-ea\")\nsampleClass = JClass(\"C:\\\\Desktop\\\\TestProject\\\\src\\\\main\\\\java\\\\com\\\\example\\\\helloworld\\\\SampleClass.java\")\n\nprint(sampleClass.square(4))\n\n\nError:\n\njava.lang.NoClassDefFoundError\n\n\nAny suggestions on how to correct this will be great."
] | [
"python",
"python-3.x",
"jpype"
] |
[
"Selecting one row in table without using extra npm packages",
"I'm trying to build a reusable table from scratch without using extra npm packages.\nThe problem I've been trying to solve all day is selecting one row on checkbox click.\nI wanted to achieve this by changing className to 'blue' on state change. className={selectValue ? "blue" : null}\nWhat's happening right now is whichever row I select its selecting all of the rows.\nI was hoping you could point me into the right direction. What are some other ways of changing background color when clicking checkbox?\nI appreciate the help.\nCode and Codesandbox below.\nhttps://codesandbox.io/s/friendly-resonance-48iu3?file=/src/App.js\nimport React, { useState, useEffect } from "react";\nimport "../../App.css";\n\nfunction Student() {\n const [studentState, setStudentState] = useState([]);\n const [selectValue, setSelectValue] = useState("");\n\n useEffect(() => {\n let studentState = [\n { id: 1, firstname: "Stone", lastname: "Cold", major: "wwf" },\n { id: 2, firstname: "Addrian", lastname: "Fox", major: "wwf" },\n { id: 3, firstname: "Harry", lastname: "Pit", major: "wwf" },\n ];\n\n setStudentState(\n studentState.map((d) => {\n return {\n select: false,\n id: d.id,\n firstname: d.firstname,\n lastname: d.lastname,\n major: d.major,\n };\n })\n );\n }, []);\n\n\n return (\n <div className="container">\n <table className="table table-bordered">\n <thead>\n <tr>\n <th scope="col">\n <input\n type="checkbox"\n onChange={(e) => {\n let checked = e.target.checked;\n setStudentState(\n studentState.map((d) => {\n d.select = checked;\n return d;\n })\n );\n \n }}\n ></input>\n </th>\n <th scope="col">First</th>\n <th scope="col">Last</th>\n <th scope="col">Handle</th>\n </tr>\n </thead>\n <tbody>\n {studentState.map((d, i) => (\n <tr key={d.id} className={selectValue ? "blue" : null}>\n <th scope="row">\n <input\n onChange={(event) => {\n let checked = event.target.checked;\n setStudentState(\n studentState.map((data) => {\n if (d.id === data.id) {\n data.select = checked;\n }\n return data;\n })\n );\n setSelectValue(checked)\n }}\n type="checkbox"\n checked={d.select}\n id={d.id}\n ></input>\n </th>\n <td>{d.firstname}</td>\n <td>{d.lastname}</td>\n <td>{d.major}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport default Student;"
] | [
"reactjs"
] |
[
"React: Wrapping element vs. regular JS Library",
"I am new to React and really enjoy the Ecosystem. Today I found a webfont loader for React. When used, it looks like this:\n\n<WebfontLoader config={config}>\n <App />\n</WebfontLoader>\n\n\nWhat is the advantage of implementing it as a React component vs. just as a regular JS Library that is used as Part of the application? Is this the \"React Way\" to do things?\n\nI see the need when using context (Like in Redux Provider), but otherwise, I am not sure.\n\nEdit: By \"Regular JS Library\" I am referring to including a file in the build that waits for DOM ready and then just calls a webfont loader directly, without using a wrapping element in React."
] | [
"javascript",
"reactjs"
] |
[
"No logged in user in Authenticate middleware but in other Middlewares",
"Introduction\nMy problem is, that I have no logged in user when trying to use the auth middleware to restrict a route to logged in users but I do have one when getting redirected back to the login page.\n\nDetails\nLet's just assume I have only these two routes\n\nRoute with web middleware\n\n$router->group(['middleware' => 'web'], function($router) {\n /** @var Registrar $router */\n $router->get('/', ['as' => 'home', 'uses' => 'HomeController@index']);\n});\n\n\nRoute with auth middleware\n\n$router->group(['middleware' => 'auth'], function($router) {\n $router->get('/listings', ['as' => 'listings', 'uses' => 'ListingController@index']);\n});\n\n\nThe first route works without problems, the second route however redirects me back to the login page. This should only be done, when I have no logged in user, but I logged in before! Which is weird.\n\nWhen I add these two lines of code to the handle function of the Middleware Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse which is used in the web group \n\n$user = \\Auth::user();\ndd($user);\n\n\nI'm getting a dump of a the currently logged in user object. However, when adding those lines in the FeedParser\\Http\\Middleware\\Authenticate Middleware I'm getting null as a dump. How can it be, that the user is logged in in the one middleware, but not in the other? What do I need to do to make it work again? Or better: What more information would you need to help me solve the problems\n\nUpdates\nIf someone asks for more information or more code I will post it here"
] | [
"php",
"laravel",
"authentication",
"laravel-5"
] |
[
"Likert Rank ordering optimization heuristic possible?",
"I can't find the type of problem I have and I was wondering if someone knew the type of statistics it involves. I'm not sure it's even a type that can be optimized.\n\nI'd like to optimize three variables, or more precisely the combination of 2. The first is a likert scale average the other is the frequency of that item being rated on that likert scale, and the third is the item ID. The likert is [1,2,3,4]\n\nSo:\n\n3.25, 200, item1. Would mean that item1 was rated 200 times and got an average of 3.25 in rating.\n\nI have a bunch of items and I'd like to find the high value items. For instance, an item that is 4,1 would suck because while it is rated highest, it is rated only once. And a 1,1000 would also suck for the inverse reason.\n\nIs there a way to optimize with a simple heuristic? Someone told me to look into confidence bands but I am not sure how that would work. Thanks!"
] | [
"math",
"statistics",
"probability"
] |
[
"KineticJS setScale / Zoom issue - Random lines",
"If I set the scale / zoom with KineticJS I get a strange error. There appears random lines.\n\nEDIT1: Okay. It looks like if I set the scaleRate to 0.25, 0.125, 0.0625 etc. it works. Is there any other fix?\n\nEDIT2: Well. EDIT1 isn't really a fix. If I zoom the whole page (browser) the lines appear again.\n\n\n\nhttp://jsfiddle.net/2trNz/\n\nHTML:\n\n<a href=\"#\" id=\"zo\">Zoom Out</a>\n<a href=\"#\" id=\"zi\">Zoom In</a>\n<div id=\"viewport\"></div> \n\n\nJavascript:\n\nvar stage = new Kinetic.Stage({\n container: 'viewport',\n width: 500,\n height: 500\n });\n\nvar layer = new Kinetic.Layer();\n\nvar tileWidth = tileHeight = 32;\n\nfor(var row = 0; row < 20; row++) {\n for(var column = 0; column < 20; column++) {\n var tile = new Kinetic.Rect({\n x: column * tileWidth,\n y: row * tileHeight,\n fill: \"green\",\n width: tileWidth,\n height: tileHeight,\n });\n layer.add(tile);\n } \n}\n\nstage.add(layer);\nstage.draw();\n\nvar scale = 1;\nvar scaleRate = 0.05;\n$(\"#zo\").on('click', function(e) {\n scale -= scaleRate;\n layer.setScale(scale);\n stage.draw();\n e.preventDefault();\n});\n$(\"#zi\").on('click', function(e) {\n scale += scaleRate;\n layer.setScale(scale);\n stage.draw();\n e.preventDefault();\n});\n\n\n\n\nAny idea how to fix this?\n\nThanks in advance!"
] | [
"javascript",
"html",
"canvas",
"html5-canvas",
"kineticjs"
] |
[
"How to insert csv file to postgresql using jmeter",
"i'm trying to insert CSV data file to POSTGRESQL from JMETER using \"LOAD DATA\" statement. But LOAD DATA statement won't working. On the internet load statement becoming highlighted and working but on \nmy machine its not becoming highlighted and getting error on it.\n\nHere is my SQL query:\n\n\"LOAD DATA INFILE '/Desktop/Summary/oca_sum.csv' INTO TABLE Load \nFIELDS TERMINATED BY ',' \nENCLOSED BY '\"' \nLINES TERMINATED BY '\\r\\n' \"\n\nAnd error is: \n\norg.postgresql.util.PSQLException: ERROR: syntax error at or near \"DATA\" Position: 6\n\nThanks."
] | [
"sql",
"postgresql",
"jmeter"
] |
[
"qTip and windows 7 tooltip style",
"I am using qTip to add some custom control over my websites tooltips. I'd like to set a custom css design that will look the same as windows 7. I can't for the hell of it, mimic the looks and feels of it though.\n\ndoes anyone know If windows 7 saves custom css files for web browsers somewhere? If not, how else can I mimic a reasonable similar style?"
] | [
"jquery",
"css",
"windows-7"
] |
[
"Like query when any words contain",
"I am new to the mysql database. I have a search bar that allows the user to type keywords and search. \n\nHere is an example for my query. It works ok if I type usa or apple, but If I type usa apple together. the result is 0. What I'd like is that when the user types 'usa apple', to return the row with apples from the usa (The first row).\n\n$search=\"usa apple\";\n\nfruit country\napple usa\napple aus\nbanana usa\norange usa\n\n\nSELECT * FROM market WHERE fruit LIKE '%$search%' || country LIKE '%$search%'"
] | [
"php",
"mysql"
] |
[
"Test error callback in Angular with Jasmine",
"How do you test an error callback in an Angular controller like the following:\n\ncontroller.js\n\n Note\n .query()\n .$promise\n .then(\n function( notes ) {\n // success\n },\n function() {\n // error\n }\n );\n\n\nIn my spec, I can put some random object in the call to queryDeferred.resolve() and test the success callback. But how do I test the error case?\n\nspec.js\n\n//= require spec_helper\n\ndescribe( 'NoteListCtrl', function() {\n // edited for brevity...\n\n beforeEach( inject( function( $controller ) {\n\n NoteMock = {\n query: function() {\n queryDeferred = $q.defer();\n return { $promise: queryDeferred.promise };\n }\n }\n\n spyOn( NoteMock, 'query' ).andCallThrough();\n\n }));\n\n describe( 'Note.getNotes', function() {\n\n describe ( 'Note.query', function() {\n\n beforeEach( function() {\n $scope.getNotes();\n queryDeferred.resolve( ????? ); // What goes here?\n $rootScope.$apply();\n });\n\n });\n\n\n });\n\n});"
] | [
"javascript",
"angularjs",
"jasmine"
] |
[
"C# Add Accept header to HttpClient",
"What is the difference between these two calls? My end goal is to have\nAccept: application/json sent over the wire, not to append to some default set of other MIME types.\n\nHttpClient client = new HttpClient();\nclient.DefaultRequestHeaders.Add(\"Accept\", \"application/json\");\n\n\nvs.\n\nclient.DefaultRequestHeaders\n .Accept\n .Add(new MediaTypeWithQualityHeaderValue(\"application/json\"));\n\n\nMy CLR is .NET Core 2.0.\n\nSniffing the wire reveals no difference:\n\n# just .Add(\"Accept\"...\n~ % nc -l 8000\nGET / HTTP/1.1\nConnection: Keep-Alive\nAccept: application/json\n[...]\n\n# with MediaTypeWithQualityHeaderValue\n~ % nc -l 8000\nGET / HTTP/1.1\nConnection: Keep-Alive\nAccept: application/json\n[...]\n\n\nSo, outside the bizarre naming of that type, nothing else to gain here right?"
] | [
"c#",
"httpclient",
"dotnet-httpclient",
".net-core-2.0",
"http-accept-header"
] |
[
"SQL Multiple Checking",
"I am trying to select some data with the query below, but my \"not equal to\" condition is not limiting my results correctly. I really don't understand what I am doing wrong.\n\nSelect \n JobCode,\n CurrentStatus \nFrom \n JobDetails \nWhere \n (CurrentStatus <> 'Pending for Sparepart' or CurrentStatus <> 'Swap Requested' or CurrentStatus <> 'External Repair')\n AND (CompletionDate IS NULL AND AssignDate IS NOT NULL) \n AND (TechCode='Tech')"
] | [
"sql",
"sql-server"
] |
[
"threading route params with react-router and redux container components",
"Hopefully this is a simple question that I'm just having trouble phrasing.\nPrior to using react-router:\n\nMy app is structured in a way that there is a list of items, clicking an item sets a selected state item in my redux store.\n\nWhen an item is selected, app renders a container component. This component is quite complex and has several other child container components where I use a selector to getSelectedItem(state).\n\nNow that is fine, but when switching to react-router, now the only component with knowledge of the selected value is the most parent component which gets the this.props.params.selected value. Because selected is no longer being stored in the state, it is managed by the router, is it necessary for me to thread the selected value through to all the children container components as well? Where i would now use a selector like getItem(state, selected) or something to that effect.\n\nHopefully that's clear, perhaps i should have been threading that value through all along? Not sure on best practice there. Thanks."
] | [
"reactjs",
"redux",
"react-router"
] |
[
"Spring multiple back up view resolver",
"I am using weblogic portal with spring mvc 3, and have a requirement to have some backup jsp files in view resolver in case a jsp is not found then it should be tried from second path as demonstrated in following code: \n\n<bean\n class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\">\n <property name=\"viewClass\"\n value=\"org.springframework.web.servlet.view.JstlView\" />\n <property name=\"prefix\" value=\"/WEB-INF/jsp/path1/\" />\n <property name=\"suffix\" value=\".jsp\" />\n <property name=\"order\" value=\"1\" />\n </bean>\n\n <bean class=\"org.springframework.web.servlet.view.UrlBasedViewResolver\">\n <property name=\"viewClass\"\n value=\"org.springframework.web.servlet.view.JstlView\" />\n <property name=\"prefix\" value=\"/portlet/application/path2/\" />\n <property name=\"suffix\" value=\".jsp\" />\n <property name=\"order\" value=\"2\" />\n </bean>\n\n\nI read about adding order in view resolvers to do so but same is not working any suggestions on this please."
] | [
"spring",
"spring-mvc"
] |
[
"How to use Line Height plugin in CKEditor?",
"I'm trying to use the Line Height plugin on CKEditor 4.5.3 but it won't work.\n\nCKEditor won't even open. I get a blank space where it should be.\n\nCould someone please help me?\n\nHere's a link to my CKEditor build: link\n\nHere's what my console says:\n\nUncaught TypeError: Cannot read property 'title' of undefined\n\n\nAnd it points to this code line (plugin.js:70):\n\naddCombo( editor, 'lineheight', 'size', editor.lang.lineheight.title, config.line_height, editor.lang.lineheight.title, config.lineHeight_style, 40 );\n\n\nHere are some images to help clarify:\n\n\n\n\n\nPS: Rich Combo, a required plugin for Line Height to work, is installed."
] | [
"javascript",
"jquery",
"css",
"plugins",
"ckeditor4.x"
] |
[
"Why is String class final?",
"Possible Duplicate:\n Why is String final in Java? \n\n\n\n\nThere are various moments in my programming life that I wished the the String class had not been final/sealed/NotInheritable.\n\nWhat are the language architects trying to prevent me from doing that would throw a monkey wrench into the works.\n\nRather, what are the monkey wrenches the language architects would want to prevent me from throwing into the works by restricting me from extending String class?\n\nCould you list a list of pros-cons of extendable string class?"
] | [
"c#",
"java",
"string",
"final",
"sealed"
] |
[
"How to send a push notification from the Firebase console to a specific GCM/FCM device token ID",
"In Urban Airship, when I am composing a notification, I can target specific users by searching for a Urban Airship channel_id (device ID):\n\n\n\n\n\n\n\n\n\nI sent from Urban Airship the push notification that I am showing above, and I received it successfully. Now I want to do the same thing, send a push notification to a specific device, but now using the Firebase console. The problem is that in Firebase, in the step where I need to specify the target, it only allows me to choose User segment or topic. I was expecting to see a third option: Target specific users (for sending notifications to one or many specific GCM/FCM device token IDs. So my alternative is to add a GCM/FCM device token ID to a topic and then send the push notification to that topic, which is something that I have successfully done before. Nonetheless, that would be a workaround and not the way I would prefer to do this. Is it possible to send push notifications to specific users (by defining the target GCM/FCM device token IDs) from the Firebase console? Thank you.\n\nUPDATE 1: See how the Firebase console (https://console.firebase.google.com/) only shows User segment and Topic as the Target:"
] | [
"firebase",
"google-cloud-messaging",
"firebase-cloud-messaging",
"firebase-console"
] |
[
"the loop in magic 8 ball has a bug",
"I'm trying to make a Magic 8 Ball program but my loop has a bug.\n\n\nIf you play again, the loop messes up and behaves like you were hitting enter all the time for about three cycles until it will work again. \nAlso, there is a delay when you enter you question. You have to hit enter twice to get the answer.\n\n\n\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include <conio.h>\nvoid ans(int x);\nint main()\n{\n system(\"color 0A\");\n srand(time(0));\n int num,i;\n\n do{\n\n char question[100] = {\" \"};\n\n num = rand()%10;\n\n puts(\"MAGIC 8 BALL!\");\n puts(\"Press Enter When Ready.\");\n getch();\n system(\"cls\");\n puts(\"Input Yes or No questions only!\");\n printf(\"\\n\");\n scanf(\"%s\",&question);\n getch();\n printf(\"\\nTHE ANSWER | \");\n ans(num);\n getch();\n system(\"cls\");\n printf(\"Press any key to try again.\\nPress [x] to Exit.\");\n\n if(getch()=='x'){\n system(\"cls\");\n break;\n }\n system(\"cls\");\n }while(1);\n}\nvoid ans(int x){\n switch(x){\n case 1 : printf(\"YES!\");break;\n case 2 : printf(\"NO!\");break;\n case 3 : printf(\"It's a thumbs down.\");break;\n case 4 : printf(\"Positive!\");break;\n case 5 : printf(\"As I see it Yes.\");break;\n case 6 : printf(\"Certainly!\");break;\n case 7 : printf(\"Negative!\");break;\n case 8 : printf(\"Don't Count on it.\");break;\n case 9 : printf(\"You don't want to know, trust me.\");break;\n case 10: printf(\"I can't say right now.\");break;\n default : printf(\"Cannot be determined right now\");break;\n }\n}"
] | [
"c",
"function",
"while-loop"
] |
[
"CUDA \"Unknown error\" for unknown reasons",
"In my current project, a call to cudaGetLastError() is returning unknown error and I don't know why. The code compiles just fine, but it is not behaving how I would like it to.\n\nBelow is a brief, not compilable example of what the relevant code consists of:\n\nCU_Main.cu\n\nBelow is the CUDA kernel:\n\n//My CUDA kernel\n__global__ void CU_KernelTest(Kernel* matrix){\n int idx = blockIdx.x * blockDim.x + threadIdx.x; \n int idy = blockIdx.y * blockDim.y + threadIdx.y; \n\n if(idx == 0 && idy == 0){\n printf(\"ID is: %d\\n\", idx);\n matrix->set(1,1, 16.0f);\n }\n}\n\n\nHere is the host code:\n\n//A host function which is called when a button is clicked\nint HOST_OnbuttonClick(){\n Kernel* matrix = new Kernel(3,3,2);\n Kernel* device_matrix;\n\n cudaMalloc(&device_matrix, sizeof(Kernel));\n cudaMemcpy(device_matrix, matrix, sizeof(Kernel), cudaMemcpyHostToDevice);\n\n CU_KernelTest<<<256, 256>>>(device_matrix);\n cudaDeviceSynchronize();\n\n cudaError_t err = cudaGetLastError();\n if (err != cudaSuccess) {\n printf(\"Error: %s\\n\", cudaGetErrorString(err));\n }\n\n\n cudaFree(device_matrix);\n return 0.0f;\n}\n\n\nWhen matrix->set(1,1, 16.0f); is included in the cuda kernel, (err != cudaSuccess) returns true and prints out UNKNOWN ERROR, whereas if I comment set out, i get no error.\n\nThe other struct relevant to this is my own helper for a convolution kernel design I'm going for, naturally called Kernel.\n\nKernel.cuh\n\nstruct Kernel {\n private :\n float* kernel;\n int rows;\n int columns;\n\n public :\n\n __device__ __host__\n Kernel(int _rows, int _columns, float _default) {\n rows = _rows;\n columns = _columns;\n kernel = new float[rows * columns];\n\n for(int r = 0; r < rows; r++){\n for(int c = 0; c < columns; c++){\n kernel[r * rows + c] = _default;\n }\n }\n }\n\n __device__ __host__\n void set(int row, int col, float value){\n kernel[row * rows + col] = value;\n }\n}\n\n\nThe goal of this design is to be able to set all values for the kernel on the host, send it to the CUDA kernel, set values there and then retrieve the updated object back at the host.\n\nSo, there are two issues really, why would I get an unknown error message, and is the code syntactically correct that it should work?\nLet me know if more information is needed.\n\nHere are the results of the memory checker:\n\nNsight Debug\n================================================================================\nCUDA Memory Checker detected 1 threads caused an access violation:\nLaunch Parameters\n CUcontext = 071c7340\n CUstream = 08f3e3b8\n CUmodule = 08fa97a8\n CUfunction = 08fdbbe8\n FunctionName = _Z13CU_KernelTestP6Kernel\n gridDim = {1,1,1}\n blockDim = {256,1,1}\n sharedSize = 128\n Parameters:\n matrix = 0x06b60000 {kernel = 0x07a31718 ???, rows = 3, columns = 3}\n Parameters (raw):\n 0x06b60000\nGPU State:\n Address Size Type Mem Block Thread blockIdx threadIdx PC Source\n-----------------------------------------------------------------------------------------------\n 07a31728 4 adr st g 0 0 {0,0,0} {0,0,0} 000260 c:\\users\n\nSummary of access violations:\nc:\\users....kernel.cuh(26): error MemoryChecker: #misaligned=0 #invalidAddress=2"
] | [
"c++",
"c",
"visual-studio-2010",
"cuda",
"nvidia"
] |
[
"Consequences of Java 32bit on Win(any) 64bit?",
"I am trying to install JAI (Java Advanced Imaging) 1.1.3 in my Vista 64 and it says that in order for it to be installed JDK 1.3 and up must be installed. The problem is that I have already installed the latest JDK for Win64 and it seems that it is not willing to work with it.\nI would like to know if there are any severe consequences if I install JDK 32bit instead of the 64bit in Vista 64.\nThanks in advance for any advice on the subject!\n\nJohn"
] | [
"java",
"vista64",
"jai"
] |
[
"File uploading error: Undefined variable: filePath’",
"Hello could appreciate some help with this code. \n It shows the following error Notice: \n\n\n Undefined variable: filePath’ in\n C:\\wamp\\www\\fileupload\\post_listing.php on line 20.\n\n\nIn addition, its displaying\n\n\n \"You have an error in your SQL syntax; check the manual that\n corresponds to your MySQL server version for the right syntax to use\n near '')' at line 1\"\n\n\nHere is the code\n\n <?php require_once('libs/Conn_host.php'); ?> \n <?php \n if(isset($_POST['upload']))\n {//you get the following information for each file: \n $fileName = $_FILES['userfile']['name'];\n $tmpName = $_FILES['userfile']['tmp_name'];\n $fileSize = $_FILES['userfile']['size'];\n $fileType = $_FILES['userfile']['type'];\n $target_dir = 'images/';\n $filePath = $target_dir .$fileName;\n $result = move_uploaded_file($tmpName, $filePath);\n if($result) {\n mysql_select_db($database_Conn_host, $Conn_host);\n $query = \"INSERT INTO images (name, size, type, path) \".\"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath’)\";\n $rsUpload = mysql_query($query, $Conn_host) or die(mysql_error());\n\n echo \"Successful uploaded\" .$fileName;\n }\nelse {\n echo \"Sorry, there was an error uploading your file.\";\n }\n }\n ?>\n <form method=\"post\" enctype=\"multipart/form-data\">\n <table width=\"350\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"box\">\n <tr> \n <td width=\"246\">\n <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\">\n <input name=\"userfile\" type=\"file\" id=\"userfile\"> \n </td>\n <td width=\"80\"><input name=\"upload\" type=\"submit\" class=\"box\" id=\"upload\" value=\" Upload \"></td>\n </tr>\n </table>\n </form>"
] | [
"php",
"mysql"
] |
[
"POST output into a modal from any form class on page",
"Sorry I am a beginner with jQuery and Javascript. I want to be able to get the results into my modal from any form on the page that has class ajax. My code is below but not working correctly. Currently it opens the post result in a new page and not in the modal. Can anyone shed any light on my code?\nMany thanks\n$(document).ready(function() {\n\n $('.ajax').click(function() {\n var that = $(this),\n url = that.attr('action'),\n type = that.attr('method'),\n data = {};\n\n that.find('name').each(function(index, value) {\n var that = $(this),\n name = that.attr('name'),\n value = that.val();\n\n data[name] = value;\n });\n console.log(value);\n // AJAX request\n $.ajax({\n url: url,\n type: type,\n data: data,\n success: function(response){\n // Add response in Modal body\n $('.modal-body').html(response);\n\n // Display Modal\n $('#aaModal').modal('show');\n }\n });\n });\n });"
] | [
"javascript",
"html",
"jquery"
] |
[
"Adding in Custom Values to jQuery Plugin: Tablesorter 2.0",
"I'm trying to figure a way out to change a value in my table so it's something else.\n\nFor example, if I have a list of these numbers:\n1\n4\n21\n6\n2\n23\n0\n21\n54\n\nI need 0 to be worth the largest amount, so when sorted ascending order, 1 should be in first, and 0 should be in last. Does anyone have any ideas on how to do this?\n\nThanks"
] | [
"jquery-plugins",
"tablesorter"
] |
[
"SharePoint 2010 - How can we get list template name from the list if the list is created from ListTemplate",
"We have created a few list templates in the sharepoint and created the lists with using List Templates. Here is the example,\n\nListTemplates \n\n\nListTemplate1 \nListTemplate2\nListTemplate3\n\n\nLists created following way,\n\nList1 is created using ListTemplate1 \nList2 is created using ListTemplate2 \nList3 is created using ListTemplate3 \n\nAnd later user created List4 using ListTemplate1,\n\nNow we are trying to identify which list is created by which template. But we couldn't identify the listtemplate properly. It is always coming as ListTemplate1 in few site colelctions, ListTemplate2 is the few site collections\n\nCan anyone help me to get the correct listtemplate name for list?\n\nBelow is the Powershell code I have used to get list template for particular list.\n\n$sourceWebURL = \"WebUrl\"\n$sourceListName = \"listname\"\n\n$spSourceWeb = Get-SPWeb $sourceWebURL\n$spSourceList = $spSourceWeb.Lists[$sourceListName]\n$spSourceList.TemplateFeatureId"
] | [
"sharepoint",
"sharepoint-2010",
"sharepoint-listtemplate",
"list-template"
] |
[
"How to delay retry of failed attempt to execute Spark task",
"With spark.task.maxFailures set to a value > 1, Spark will automatically retry a failed task up to the number of allowed failures.\nIf the failure is due to an intermittent failure (for example a blob storage account is temporarily unavailable), retrying with exponential back-off would be preferable to an immediate rescheduling of the task onto the executor (which seems to be the default behavior).\nHow can I make Spark delay subsequent attempts at executing the task?"
] | [
"apache-spark",
"pyspark"
] |
[
"Add Fragment dependent on a Loader result",
"My goal is to write a messenger Activity. Right now there are two kinds of Messages implemented: \n - Simple Text \n - Gallery \nIn my messenger Activity I use the LoaderManager.LoaderCallbacks functions in order to asynchronically query the Messages table in my DB. That query returns (amongst other information): \n - What kind of Message is it (Simple Text or Gallery) \n - What is the ID of that data in the type-specific table (Gallery leads to a table full of pictures, for example) \nNow I have a Fragment for Simple Text and one for Gallery. Those need the data's ID and then use a Loader to query its table in the DB. Ideally I would just dynamically add that type-specific Fragment for every message I have. \n\nIn pseudo code:\n\nfunction allMessagesAreLoaded() {\n for (message : messages) {\n if message is simpleTextMessage then\n add simpleTextMessageFragment\n else if message is gallery then\n add galleryFragment\n end if\n }\n}\n\n\n\nNow to my question:\nIt is not best practice to use Fragments in this case according to this source: http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html \nWhat is the way to go to have an encapsulated layout and function set/class that can be programmatically added during runtime depending on a DB query result? \nMaybe I'm looking at it from the wrong direction. I have no experience in creating Android user interfaces. Any tip/point in the right direction will help me a lot :-) \nThanks for your help!"
] | [
"android",
"user-interface",
"android-fragments",
"android-sqlite",
"loader"
] |
[
"Configure If-Else Component, React",
"I have added an if-else element to my React Component per the documentation; however, due to the syntactical differences between including a React component with <></> and {} I am unsure of how to further configure the component.\nHere is a reduced version of what I have (written in TypeScript):\npublic render() {\n const mediaElement: HTMLMediaElement = this.getMediaElement();\n return { mediaElement };\n}\n\nHere is getMediaElement() reduced:\nprivate getMediaElement() {\n //... video can also be returned\n return document.createElement("audio");\n //...\n}\n\nFrom here, preferably inline, I would like to be able to add class information, etc., something akin to (as also doable in React):\n<li className="media-file-title">\n\nHow do I go about accessing properties on the element with the above syntax? Ultimately, I am in need of assigning a ref. Any documentation would be great!\nIs it only doable through object properties, i.e.:\nmediaElement.src = """
] | [
"reactjs",
"typescript"
] |
[
"How can i return interactive map?",
"I have this code for a map using a netcdf file of European Centre for Medium-Range Weather Forecasts.\ndef interactive_map():\n import netCDF4 as nc\n import numpy as np\n import matplotlib.pyplot as plt\n from mpl_toolkits.basemap import Basemap\n\n #original name -> _grib2netcdf-webmars-public-svc-green-007-6fe5cac1a363ec1525f54343b6cc9fd8-b5oXS9.nc\n fn = '7.nc'\n ds = nc.Dataset(fn)\n\n #variables\n #longitude, latitude, time, pm1\n lons = ds.variables['longitude'][:]\n lats = ds.variables['latitude'][:]\n time = ds.variables['time'][:]\n pm = ds.variables['pm1'][:]\n\n mp = Basemap(projection = 'merc',\n llcrnrlon = 97.085310,\n llcrnrlat = 2.044212,\n urcrnrlon = 106.896219,\n urcrnrlat = 7.403567,\n resolution = 'i')\n\n lon, lat = np.meshgrid(lons, lats)\n x, y = mp(lon, lat)\n\n cscheme = mp.pcolor(x, y, np.squeeze(pm[0,:,:]), cmap = 'turbo')\n mp.drawcoastlines()\n mp.drawstates()\n mp.drawcountries()\n\n cbar = mp.colorbar(cscheme, location = 'right')\n #plt.show()\n plt.savefig('map.png')\n\nhttps://i.imgur.com/4lndRuY.png\nWhat i want is add the map to a view of web2py, i know it saves an image and i can render the image, but it's possible to show in an interactive map?\nThis is what i have to show the map in a view:\n<!--index.html-->\n{{extend 'layout.html'}}\n\n<img src="{{=URL('static','images/map.png')}}" width="500" height="600">"
] | [
"python",
"numpy",
"web2py",
"matplotlib-basemap",
"netcdf4"
] |
[
"Redux Reducer: Is this an acceptable way to toggle a Boolean from the initial state?",
"I have an array of objects as the initial state. This array holds user question/response data. On the HTML page there is a material-ui switch toggle to control whether the question should be public or private. I know redux recommends keeping logic in the action not reducer but this is the solution I came up with. Is the \"toggleSwitch reducer\" an acceptable solution or have I created an anti-pattern?\n\nNote I am using a 'reducer helper' instead of a 'switch statement' to reduce boilerplate code.\nThank you in advance. I am very new to redux.\n\n// ACTION\nexport const toggleQuestion = (questionId) => {\n return {\n type: TOGGLE_QUESTION,\n payload: {\n questionId\n }\n }\n}\n\n\n\n\n//REDUCER \nconst initialState = [{\n id: '1',\n firstName: 'James',\n lastName: 'Smith',\n question: 'Ask a question here?',\n response: 'This is an answer to the question',\n public: true,\n created: '2019-23-11T01:50:00+00:00',\n modified: null\n },\n {\n id: '2',\n firstName: 'Taylor',\n lastName: 'Johnson',\n question: 'Ask another question here?',\n response: 'Here is another answer to another question',\n public: true,\n created: '2019-23-11T01:50:00+00:00',\n modified: null\n }\n];\n\n\nconst toggleSwitch = (state, payload) => {\n return [\n ...state.map((item) => {\n if (item.id === payload.questionId) {\n return Object.assign(item, {\n public: !item.public\n })\n }\n return item\n })\n ]\n}\n\nexport default createReducer(initialState, {\n [CREATE_QUESTION]: createQuestion,\n [UPDATE_QUESTION]: updateQuestion,\n [DELETE_QUESTION]: deleteQuestion,\n [TOGGLE_QUESTION]: toggleQuestion\n});\n\n\n\n\n// HELPER TO CREATE THE REDUCER\nexport const createReducer = (initialState, fnMap) => {\n return (state = initialState, {\n type,\n payload\n }) => {\n const handler = fnMap[type];\n\n return handler ? handler(state, payload) : state\n }\n\n}"
] | [
"reactjs",
"redux",
"react-redux",
"reducers"
] |
[
"what's the benefits of turning off `PRAGMA trusted_schema` in SQLite?",
"quoting the documentation at https://www.sqlite.org/pragma.html#pragma_user_version\n\nThere are advantages to turning it off, and most applications will be unaffected if it is turned off. For that reason, *all applications are encouraged to switch this setting off on every database connection as soon as that connection is opened.*\n\nwhat's the advantages?"
] | [
"sqlite"
] |
[
"Replace excel column values by values in another file",
"I have a excel file with these columns: v1,v2,commID\n\n\n\nI have another file with columns: Index, Name\n\n\n\nNow I want to replace v1 and v2 with corresponding names by referring to second file and write it in a new file.The format is v1,v2,commID, but this time v1 and v2 should be names whereas commID should be the same numbers. I can do it in excel or python or matlab."
] | [
"python",
"excel",
"matlab"
] |
[
"CSS styles and tags been ignored while parsing using Apache Tika",
"While I am parsing the PDF or Word document using AutoDetectParser the \"li\", \"ul\" tags are converted as \"p\" tags. I need the exact HTML content what is been there for PDF or Word Document.\n\nI tried in several ways as below:\n\nToHTMLContentHandler textHandler = new ToHTMLContentHandler();\nMetadata metadata = new Metadata();\nParser parser = new AutoDetectParser();\nParseContext context = new ParseContext();\ncontext.set(HtmlMapper.class, new IdentityHtmlMapper());\nparser.parse(in, textHandler, metadata, context);\n\n\n\n\nSAXTransformerFactory factory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();\nTransformerHandler handler = factory.newTransformerHandler();\nhandler.getTransformer().setOutputProperty(OutputKeys.METHOD, \"html\");\nhandler.getTransformer().setOutputProperty(OutputKeys.INDENT, \"no\");\nhandler.getTransformer().setOutputProperty(OutputKeys.ENCODING, \"utf-8\");\nhandler.setResult(new StreamResult(writer));\nSystem.out.println(handler.toString());\nreturn handler;\n\n\nBut the \"li\" tags are been replaced with \"p\" tags with class but the CSS style is not seen in the parsed HTML output.\n\nAny help is appreciated."
] | [
"java",
"apache-tika"
] |
[
"Add NSDefaults string into InAppSettingsKit",
"I want to be able to change the DefaultValue of one of a UITableView cell in the Settings.bundle. I mainly want to put this...\n\nuserEmail = [defaults objectForKey:@\"username\"];\n\n...into the plist.\n\nI am doing this because I want my app to display the user's email in the settings so that they know what account they are using.\n\nHere is part of the plist data that I want changed.\n\n<dict>\n <key>IASKTextAlignment</key>\n <string>IASKUITextAlignmentRight</string>\n <key>DefaultValue</key>\n <string>EMAIL</string>\n <key>Key</key>\n <string>email</string>\n <key>Title</key>\n <string>Email</string>\n <key>Type</key>\n <string>PSTitleValueSpecifier</string>\n </dict>\n\n\nHow would I do this? Thanks in advance."
] | [
"iphone",
"ios",
"inappsettingskit"
] |
[
"docker-compose exit depends_on service after tests",
"How do I get a service container to exit once the dependent container has finished?\n\nI have test suite running in the app_unittestbot container that depends_on a postgresql db server (postgres:9.5-alpine) running in separate container. Once the test suite exits, I want to check the return code of the test suite and halt the database container. With the docker-compose.yml below, the db service container never halts.\n\ndocker-compose.yml\n\nversion: '2.1'\nservices:\n app_postgresql95:\n build: ./postgresql95/\n ports:\n - 54321:5432\n\n app_unittestbot:\n command: /root/wait-for-it.sh app_postgresql95:5432 --timeout=60 -- nose2 tests\n build: ./unittestbot/\n links:\n - app_postgresql95\n volumes:\n - /app/src:/src\n depends_on:\n - 'app_postgresql95'"
] | [
"postgresql",
"unit-testing",
"docker",
"docker-compose"
] |
[
"Myeclipse: when make change in Design View, automatically change to Source View",
"I'm using MyEclipse and use Matisse to programming Swing.\n\nThis function of MyEclipse has one thing make me annoy: when you change something in design view (add component, resize, add event,... anythings), MyEclipse will automatically generated code and change from Design to Code View.\n\nSo, each time I change something, I must click on design View Tab again. (You can imagine that a button has some properties, such as: method on mouse click, mouse over, text on this button, size of it,....), each property, I must choose View tab again...\n\nPlease help me fix this. \n\nThanks :)"
] | [
"swing",
"myeclipse",
"matisse"
] |
[
"Is it okay to have a SDL_Surface and SDL_Texture for each sprite?",
"I'm trying to build a gameengine in SDL2 with cpp. I have a class called 'entity' which has some data for movement and also some pointers to a surface and a texture. A function "render" is called inmass to render each sprite based on the g_entities vector.\nclass entity {\n ...\n SDL_Surface* image;\n SDL_Texture* texture;\n\n entity(const char* filename, SDL_Renderer * renderer, float size) {\n image = IMG_Load(filename);\n width = image->w * size;\n height = image->h * size;\n texture = SDL_CreateTextureFromSurface(renderer, image);\n g_entities.push_back(this);\n \n }\n\n ~entity() {\n SDL_DestroyTexture(texture);\n SDL_FreeSurface(image);\n //TODO remove from g_entities\n }\n\n void render(SDL_Renderer * renderer) {\n SDL_Rect dstrect = { x, y, width, height };\n SDL_RenderCopy(renderer, texture, NULL, &dstrect);\n }\n ...\n}\n\nSo the program makes a new texture and surface for each sprite. Is this okay? Is there a faster way?\nIf so, I'd like to clean that up before it becomes a bigger mess.\nI made a testlevel with 96 sprites that each take up 2% of the screen with tons of overdraw and ft is 15ms (~65fps)at a resolution of1600x900"
] | [
"c++",
"sdl-2"
] |
[
"Why (1.1-1.0)*10 isn't 1.0?",
"Why result of this code is false? I can't solve this problem.\n\n#include <stdio.h>\nint main(int argc, char **argv)\n{\nif ( (1.1 - 1.0)*10.0 - 1.0 == 0.0 )\n printf(\"True\");\nelse\n printf(\"False\");\nreturn 0;\n}"
] | [
"c"
] |
[
"Can't get properties of GstBaseSink on GstXvImageSink in pygst",
"I'm trying to access the \"last-sample\" property from GstXvImageSink which is derived from GstBaseSink.\nI'm getting: \n\n\n TypeError: object of type 'GstXvImageSink' does not have property 'last-sample'\n\n\nIs there a special way to get properties from base classes in pygtk or is this property somehow hidden?\n\nCode:\n\ndef take_snapshoot(self):\n sample = self.__snapshot_source_video_sink.get_property(\"last-sample\")"
] | [
"python",
"pygtk",
"gstreamer",
"python-gstreamer"
] |
[
"Connect HTML slider with Angular 2 component",
"I use PrimeNG as UI library within my Angular 2 app. In a certain component I require to have a slider component. Thus I've used the respective PrimeNG slider component as follows:\n\n<p-slider [(ngModel)]=\"this.adjustedCalculation.predictionYear\"></p-slider>\n\n\nThis works perfectly. \n\nHowever, I noticed that this component is broken on devices with a touch screen. So I need to find a replacement. \n\nI came across the standard HTML 5 input of type \"range\" described here and added its markup like so:\n\n<input type=\"range\" name=\"points\" id=\"points\" value=\"50\" min=\"0\" max=\"100\" data-show-value=\"true\" data-popup-enabled=\"true\" />\n\n\nHow do I connect this input element with my Angular 2 component variable this.adjustedCalculation.predictionYear? \n\nI want that the value the user selected is represented in this variable.\n\nUPDATE:\n\nI added [(ngModel)] as suggested and it works. Next point is that I want to control the min and max value of this input element. Consider the previous version of the PrimeNG slider:\n\n<p-slider [(ngModel)]=\"this.adjustedCalculation.predictionYear\" [min]=\"this.displayedCalculation.predictionYear - 10\" [max]=\"this.displayedCalculation.predictionYear + 10\"></p-slider>\n\n\nHow do I have to pass the expression \"predictionYear - 10\" resp. + 10 to that input element?\nLet me know if I should rather raise a new question for this purpose.\n\nThanks!"
] | [
"html",
"angular",
"slider",
"angular2-template"
] |
[
"How to increase edittexts' number in for loop",
"I have 8 EditText and I want to check whether these EditTexts are empty or not.\nThis is my code:\n\nif (edt1.getText().toString().equals(\"K\")\n &&!edt2.getText().toString().equals(\"\")\n &&!edt3.getText().toString().equals(\"\")\n &&!edt4.getText().toString().equals(\"\")\n &&!edt5.getText().toString().equals(\"\")\n &&!edt6.getText().toString().equals(\"\")\n &&!edt7.getText().toString().equals(\"\")\n &&!edt8.getText().toString().equals(\"\")){\n next();\n}\n\n\nThis is what i want:\n\nint count=0;\nfor(int i=1;i<=8,i++){\n if(!edt.getText().toString().equals(\"\"))//how can I increase the number of edt, if i=1, edt1 and if i=2, edt2... \n count++;\n}\nif(count==8){\n next();\n}"
] | [
"java",
"android",
"android-edittext"
] |
[
"Does my JVM have a memory leak?",
"I'm attempting to assess the efficiency of the garbage collector on one of my servers.\n\nServer OS is Red Hat Enterprise Linux Server release 6.4 (Santiago)\n2.6.32-573.12.1.el6.x86_64\n\n2CPU 16GB RAM\n\njava version \"1.7.0_65\"\nJava(TM) SE Runtime Environment (build 1.7.0_65-b17)\nJava HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)\n\n-Xms2560M -Xmx2560M\n\n30 minutes after starting the JVM with no user activity whatsoever (test server) - I see the heap usage slowly but consistently growing over time. \n\n\"Heap Usage After GC\" graph \n\n# jstat -gccause 20630 1s\nS0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC\n0.00 46.88 1.99 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 8.11 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 14.08 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 20.18 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 26.15 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 32.24 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 38.19 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 44.26 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 50.23 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 56.30 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 62.26 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 68.32 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 74.27 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 80.36 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 84.33 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 90.40 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n0.00 46.88 96.36 30.33 88.16 195 5.393 3 1.468 6.861 Allocation Failure No GC\n46.88 0.00 4.09 30.34 88.16 196 5.418 3 1.468 6.886 Allocation Failure No GC\n46.88 0.00 10.07 30.34 88.16 196 5.418 3 1.468 6.886 Allocation Failure No GC\n46.88 0.00 16.19 30.34 88.16 196 5.418 3 1.468 6.886 Allocation Failure No GC\n\n\nWondering if this is cause for concern or if any other information is needed to assist with an answer."
] | [
"java",
"memory-leaks",
"garbage-collection",
"jvm"
] |
[
"Can't make Jsoup use proxies: System.setProperty doesn't work",
"I'm trying to get Jsoup to connect to reddit and get its title via a proxy server using this code:\n\npackage js;\n\nimport org.jsoup.Jsoup;\nimport org.jsoup.nodes.Document;\n\npublic class Test {\n public static void main(String[] args) throws Exception {\n System.setProperty(\"http.proxyHost\", \"123.456.789.2342.\");\n System.setProperty(\"http.proxyPort\", \"5846123232\");\n\n Document doc = Jsoup.connect(\"http://reddit.com/\").get();\n String title = doc.title();\n System.out.println(title);\n }\n}\n\n\n\nDespite the proxy data obviously being wrong, this code still works and prints\n\nreddit: the front page of the internet\n\n\nso it didn't seem to use or try to use that proxy server at all. How do I get Jsoup to use a given proxy server?"
] | [
"java",
"proxy",
"jsoup"
] |
[
"AssertThrows failing the test even after the right exception is thrown",
"@Test\nvoid testConnectToInvalidUrl() {\n model.setCredentials("cst8288", "8288");\n assertThrows(SQLException.class,() -> model.connectTo("jdbc:mysql://localhost:3306/redditreader?useUnicode=true&serverTimezone=UTC&useSSL=falses"));\n}\n\nI'm trying to test this method which connects to a MySQL database in JUnit by entering a wrong url as it will throw an SQLException, which it does, but the test fails regardless. Here is the actual method:\npublic void connectTo(String url) {\n\n try {\n connection = DriverManager.getConnection(url, User, Pass);\n\n } catch (SQLException e) {\n e.printStackTrace();\n\n }\n}\n\nThe Exception thrown :\njava.sql.SQLException: The connection property 'useSSL' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'falses' is not in this set.\n\nI know its the extra s at the end, but since its a SQLException, shouldn't assertThrows make the test pass?"
] | [
"java",
"jdbc",
"junit"
] |
[
"Creating A Spreadsheet In A Folder With GSpread",
"I am having trouble finding any documentation on how to create a GSheet in a certain Google Drive directory using GSpread.\n\nI have checked the documentation and had a look around some of the back end code.\n\nI am currently using the code below to create the spreadsheet:\n\nworksheet = sh.add_worksheet(title='Overview', rows='100', cols='9')\n\n\nI want to be able to create the spreadsheet in a directory on a google drive, for example:\n\nX > Y > Spreadsheet\n\nAny help would be greatly appreciated, \n\nCheers."
] | [
"python",
"google-sheets",
"google-drive-api",
"google-sheets-api",
"gspread"
] |
[
"Inserting font awesome icon using JavaScript",
"I am working on a WordPress site using a jobs application plugin. I want to add a font awesome icon to a button using javascript. The hml code I can see for the button is.\n\n<input type = \"button\" class=\"application_button button\" value=\"apply for job\"></input>\n\n\nwhich I think I need to make the following for the icon to show.\n\n<input type = \"button\" class=\"application_button button\" value=\"apply for job\"> <i class = \"fas fa-chevron-right\"></i></input>\n\n\nthe JavaScript I have added to achieve this is,\n\n var d1 = document.querySelector('.application_button');\nd1.insertAdjacentHTML('beforeend', '<i class=\"fas fa-chevron-right\"></i>');\n\n\nWhen I console.log(d1); I can see that I have got the code I want. But the icon does not show. If I use 'afterend' then I do see the icon, but outside the button.\n\nI seem so close, but so far away.\n\nAny advice?"
] | [
"javascript",
"font-awesome"
] |
[
"Get checked values in other view",
"I have list of checkbox with button submit , and I when i click on submit, I have to get all checked values in other view table. I find a lot of answers, but they all propose to get values in the same view,but I need to get values in other view(ajoutFactAdmin2), how can I do that please. this is the code: \n\najoutFactAdmin2.html \n\n<div class=\"row\" ng-repeat=\"x in namesF3\">\n\n <div class=\"col\"><input type=\"checkbox\" name=\"\" ng-modal=\"x.selected\" ng-checked=\"exist(x)\" ng-click=\"toggleSelection(x)\" ng-true-value=\"'{{x.CodeEnvoiColis}}'\" ng-false-value=\"''\" id=\"'{{x.CodeEnvoiColis}}'\"></div>\n <div class=\"col\" >{{x.CodeEnvoiColis}}</div> \n <div class=\"col\" width=\"20%\">{{x.StatutColis}} </div>\n <div class=\"col\" width=\"20%\">{{x.VilleDestColis}}</div> \n\n</div>\n\n<div class=\"selectedcontent\">\n <h3> Selected Names </h3>\n <p ng-repeat = \"selectedName in selected\"> {{selectedName.CodeEnvoiColis}} </p>\n</div>\n <a class=\"button button-info\" ng-click=\"toggleSelection(x)\" href=\"#/ajoutFactAdmin2\" style=\"background-color:#1627C0;float: right;\">Ajouter</a> \n\n\napp.js : \n\n $scope.selected = [];\n $scope.namesF3 = [];\n $scope.exist = function(item){\n return $scope.selected.indexOf(item) > -1;\n }\n\n $scope.toggleSelection = function(item){\n var x = [];\n var idx = $scope.selected.indexOf(item);\n if(idx > -1){\n $scope.selected.splice(idx, 1);\n }\n else{\n $scope.selected.push(item);\n }\n\n }"
] | [
"angularjs",
"ionic-framework"
] |
[
"Difference in image display (MATLAB and VISUAL STUDIO)",
"for(i=0;i<m_bitmap.bmHeight-1; i++)\n{\n for(j=0; j<m_bitmap.bmWidth-1; j++)\n { \n r = GetRValue(imagearr1[i][j]);\n g = GetGValue(imagearr1[i][j]);\n b = GetBValue(imagearr1[i][j]);\n\n temp_r = r/255.00;\n temp_g = g/255.00;\n temp_b = b/255.00;\n\n /////////////////XYZ conversion////////////////\n\n temp_X = (0.412453*temp_r + 0.357580*temp_g + 0.180423*temp_b);\n temp_Y = (0.212671*temp_r + 0.715160*temp_g + 0.072169*temp_b);\n temp_Z = (0.019334*temp_r + 0.119193*temp_g + 0.950227*temp_b);\n\n ///////////////Normalisation/////////////\n\n X = temp_X/0.950456;\n Y = temp_Y/1.00;\n Z = temp_Z/1.088754;\n\n\n if ( X > 0.008856 ) \n {\n X = pow(X , (1.00/3.00) );\n }\n else\n {\n X = ( 7.787 * X ) + ( 16.00 / 116.00 );\n }\n if ( Y > 0.008856 ) \n {\n Y = pow (Y , (1.00/3.00) );\n }\n else\n {\n Y = ( 7.787 * Y ) + ( 16.00 / 116.00 );\n }\n if ( Z > 0.008856 )\n {\n Z = pow (Z , (1.00/3.00) );\n }\n else \n {\n Z = ( 7.787 * Z ) + ( 16.00 / 116.00 );\n }\n\n C_L = ( 116.00 * Y ) - 16.00;\n C_a = (500.00 * ( X - Y )+128);\n C_b = 200.00 * ( Y - Z );\n\n\n imagearr2[i][j] = RGB(C_a,C_a,C_a);\n }\n}\n\nk=0;\n\nfor(i=m_bitmap.bmHeight-1; i>=0; i--)\n{\n for(j=0; j<m_bitmap.bmWidth; j++)\n {\n *(byte+k) = GetBValue(imagearr2[i][j]); \n k++;\n *(byte+k) = GetGValue(imagearr2[i][j]); \n k++;\n *(byte+k) = GetRValue(imagearr2[i][j]); \n k++;\n } \n\n k=k+padding;\n}\n\n\nSetDIBitsToDevice(\n m_hmainmemdc, 0, 0, m_bitmap.bmWidth, m_bitmap.bmHeight, 0, 0 , 0,\n m_bitmap.bmHeight, byte, &bm,DIB_RGB_COLORS);\nBitBlt(dc.m_hDC,0,0,rect.right,rect.bottom, m_hmainmemdc,0,0, SRCCOPY);\n\n\nHi,\n\nI am converting an image (colour) from RGB to LAB colour space and displaying it.\n\nI tried it in MATLAB as well as VISUAL STUDIO but both of them giving me different images (difference it contrast) (I am only interested in a part of Lab image).\n\nPlease see the code which I used to convert then in MATLAB and Visual Studio.\nI Checked for precision errors in this and understood both compilers are giving me same numericals.\n\nSame formula and logic I used in MATLAB but I did not add 128 in the final a value, and for displaying it I used this command\n\n\"imshow(C_a, [])\"\n\nI would like to have result image as in MATLAB, for that what type of conversion I should Use?\n\nThanks in advance!\n\nVisual Studio\n\n\nMATLAB"
] | [
"matlab",
"visual-studio-2012",
"image-processing"
] |
[
"Finding the root of an equation with a constraint",
"In python, I would like to find the roots of equations of the form:\n\n-x*log(x) + (1-x)*log(n) - (1-x)*log(1 - x) - k = 0\n\nwhere n and k are parameters that will be specified.\n\nAn additional constraint on the roots is that x >= (1-x)/n. So just for what it's worth, I'll be filtering out roots that don't satisfy that.\n\nMy first attempt was to use scipy.optimize.fsolve (note that I'm just setting k and n to be 0 and 1 respectively):\n\ndef f(x): \n return -x*log(x) + (1-x)*log(1) - (1-x)*log(1-x) \n\nfsolve(f, 1)\n\n\nUsing math.log, I got value-errors because I was supplying bad input to log. Using numpy.log gave me some divide by zeros and invalid values in multiply.\n\nI adjusted f as so, just to see what it would do:\n\ndef f(x): \n if x <= 0: \n return 1000 \n if x >= 1: \n return 2000 \n return -x*log(x) + (1-x)*log(1) - (1-x)*log(1-x) \n\n\nNow I get\n\n/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:221: RuntimeWarning: The iteration is not making good progress, as measured by the \n improvement from the last ten iterations.\n warnings.warn(msg, RuntimeWarning) \n\n\nUsing python, how can I solve for x for various n and k parameters in the original equation?"
] | [
"python",
"math"
] |
[
"How would you use Docker Swarm as a multiplatform Jenkins agent pool?",
"I've been successful in setting up a Dockerhost and using that host as an agent pool using the Docker plugin.\n\nIt works well, and does what I want it to do (spins up an agent on the host, runs the build, and destroys itself).\n\nI would like to have a similar setup connecting Jenkins to a Docker Swarm with both Linux and Windows Dockerhosts inside the swarm.\n\nIs that possible? If so, what would be the best implementation of this?"
] | [
"docker",
"jenkins"
] |
[
"jQuery $.post not working correctly",
"For some reason... It's not getting any data from script.php and when I submit a form, there seems to be problem with submitting. When I hit submit button. it goes to search.php?search=wasd If I remove $.post function, there is no problem.\n\n$('form').submit(function() {\n var form_data = ($(this).serialize());\n window.location.hash = form_data.replace('=','/');\n return false;\n});\n\n(function() {\n\nwindow.App = {\n Models: {},\n Collections: {},\n Views: {},\n Router: {}\n};\n\nApp.Router = Backbone.Router.extend({\n routes: {\n '': 'index',\n 'search/:search': 'search',\n '*other': 'default'\n },\n\n index: function() {\n $(document.body).append(\"\");\n },\n\n search: $.post(\"script.php\", function(search) {\n $('#result').html(search);\n });\n\n});\n\nnew App.Router();\nBackbone.history.start();\n\n})();"
] | [
"jquery",
"backbone.js"
] |
[
"What is smallest offset for which I can safely omit overflow checking when I add it to a pointer?",
"Can I expect that any \"data\" pointer in user space programs lies in a safe distance from the addresses 0 and 0xffffffff..., so that I can safely add a small offset to the pointer without checking for an overflow? What is the largest positive n for which I can safely assume that p + n doesn't overflow when p is a char pointer into a constant character buffer or a dynamically allocated string (on a modern >= 32-bit operating system)?\n\nTo avoid confusion: I'm talking about overflow checking, not about bounds checking. For example: If you have a pointer p to the beginning of a string with m chars and you want to access the char at the positive offset i, then you either need to check that i < m or you can check indirectly p + i < p + m. However, in the latter case you also have to make sure that p + i doesn't overflow, i.e. you have to make sure that p + i >= p.\n\nUpdate: Ok, p + i is not valid standard C if i > m, regardless of whether p + i is actually dereferenced or whether it overflows. However, the question I'm really interested in is whether there is a small n for which p + n won't overflow in practice. Answering this question obviously requires some knowledge about how modern operating systems organize the address space.\n\nUpdate2: It would already be very interesting to hear about any one particular platform, even if it's not generalizable. Preferably not some obscure embedded one. x86 or Power-based 32-bit Win, Linux and Mac would be most interesting."
] | [
"c++",
"c",
"pointers",
"overflow"
] |
[
"asp.net MVC3 auto generate meta keywords and description based on page content",
"I'm working on an MVC3 web application using the razor view engine. I'm looking for a solution to generate meta keywords and description automatically on my pages.\n\nI've already found this solution here on stackoverflow, the idea is looking good. But since I'm planning to post blogs etc... on my website I want the meta keywords and description to be auto generated based on the content of the page.\n\nSoo far I've got the following things in mind. Let's say that the current HTML looks like below;\n\n <html>\n <head>\n </head>\n <body>\n <header></header>\n <div id=\"container\">\n <div id=\"sideBar\"></div>\n <div id=\"pageHeader\"></div>\n <div id=\"content\">\n <!--This part contains the dynamic content-->\n </div>\n <div class=\"clear\"></div>\n </div>\n <footer></footer>\n </body>\n </html>\n\n\nThe desired situation for me would be something like below;\n\n <html>\n <head>\n @Html.MetaKeywords()\n @Html.MetaDescription()\n </head>\n <body>\n <header></header>\n <div id=\"container\">\n <div id=\"sideBar\"></div>\n <div id=\"pageHeader\"></div>\n <div id=\"content\">\n <!--This part contains the dynamic content-->\n </div>\n <div class=\"clear\"></div>\n </div>\n <footer></footer>\n </body>\n </html>\n\n\nSaid all this I've got the following questions left unanswered, hope someone can help.\n\n\nThe situation described above, with the HTML-helpers. Is this an good and logic approach to generate keywords and description on every single page, based on the content?\nIf this is, does anyone has experience and maybe an good example?\nIf not, are there any other good options? Other then using an attribute on each controller action? This still is an option, but it doesn't generate keywords an description based on my page content.\n\n\nI hope someone can help me out. Thanks!"
] | [
"asp.net",
"asp.net-mvc-3",
"seo",
"razor"
] |
[
"MATLAB Treebagger and Random Forests",
"Does the Treebagger class in MATLAB apply Breiman's Random Forest algorithm? \n\nIf I simply use Treebagger, is it the same as using Random Forests, or do I need to modify some parameters?\n\nThanks."
] | [
"matlab",
"tree",
"random-forest"
] |
[
"Rollup - ignore some imports",
"I am using Vuetify 1.5.18 and have the following code...\nimport Vuetify from 'vuetify'\n...\n// rollup config\nimport VuePlugin from 'rollup-plugin-vue';\nimport css from 'rollup-plugin-css-only';\nimport resolve from 'rollup-plugin-node-resolve';\nimport commonjs from 'rollup-plugin-commonjs';\nimport pkg from './package.json';\n\n// const external = Object.keys(pkg.dependencies);\nconst plugins = [\n resolve({\n module: true,\n main: true\n }),\n commonjs(),\n VuePlugin(),\n css()\n];\nmodule.exports = {\n plugins,\n input: 'src/index.js',\n output: {\n file: 'dist/index.js',\n format: 'esm'\n }\n};\n\nBut when I run rollup I get the following in my output...\nimport vue from 'vue';\n\nAnd when I try to run I get the following error...\n\nFailed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../".`\n\nI load Vue not in the UI project but in my server like this...\n// Footer.pug\nscript(type="module")\n | import Vue from '/vue/vue.esm.browser.js'\n | const global = window || global;\n | global.Vue = Vue;\n\nSo that line shouldn't be there. If I remove Vuetify it goes away. Also if I point to the version I have hosted through the Koa app like this...\nimport * as Vuetify from '/vuetify/vuetify.js';\n\nEverything seems to work as well. I can also go in and manually remove the import Vuetify from 'vuetify' and add this line to the template on the server...\n| const global = window || global;\n| global.vue = global.Vue;\n\nIs there a way I can tell rollup to ignore any "vue" imports?"
] | [
"javascript",
"node.js",
"vue.js",
"ecmascript-6",
"rollup"
] |
[
"Chrome extension id is built new everytime I package the extension",
"I want to host a chrome extension by myself and I want the extension to autoupdate.\nEvery time I pack the extension an new extension id is generated. But if the extension id changes the autoupdate stops working because the id differs from the one in the updates.xml file ?"
] | [
"google-chrome",
"google-chrome-extension"
] |
[
"How to avoid errors in saving data - Cakephp",
"I'm using Cakephp and trying to put in a method to make sure our reservation system doesn't let two users book the same appointment. Ex. User 1 opens the appointment, and User 2 opens it simultaneously. User 1 books the appointment. User 2 tries to book it but the system checks and sees it is no longer available. \n\nI imagine this would take place in validation, or in a beforeSave(), but can't figure out how to do it. \n\nRight now I made a function in the model to call from the controller. In the controller I have:\n\nif ($this->Timeslot->checkIfNotAvailable()) {\n$this->Session->setFlash('This timeslot is no longer available');\n$this->redirect(array('controller' => 'users', 'action' => 'partner_homepage')); \n}\n\n\nand in the model I have this function:\n\nfunction checkIfNotAvailable($data) {\n $this->recursive = -1;\n $timeslot = $this->find('all', array(\n 'conditions' => array(\n 'Timeslot.id' => $this->data['Timeslot']['id'])\n )\n );\n if ($timeslot['student_id'] == 0) {\n //They can reserve it, do not spring a flag\n return false;\n } else {\n //Throw a flag!\n return true;\n }\n}\n\n\nI think I'm mixed up using custom validation when it's not called for. And it's not working obviously. Any suggestions?\n\nThanks!"
] | [
"validation",
"cakephp"
] |
[
"Counting occurrences of rows that have 3 column values the same MySQL",
"MySQL BEFORE INSERT trigger\n\nI have a bookings table. I have 3 columns called \n\nfacility_id, booking_date, time_slot\n\n\nI also have another table called facility with a column called facility_id.\nThey are linked by WHERE bookings.faciliy_id = facility.facility_id\n\nI am trying to count the occurrence of when the 3 columns in the bookings table are repeated, i.e.:\n\n1, 2017-02-02,08:00\n1, 2017-02-02,08:00\n\n\nI would expect this to be 2.\n\nI then am trying to check this result to see if its >= to the facility_capacity which is stored in the facility table. Throw an error message if true.\n\nDELIMITER\n//\n CREATE TRIGGER facility_full BEFORE INSERT ON bookings\n FOR EACH ROW\n BEGIN \n SELECT DISTINCT facility_id, booking_date, timeslot, COUNT(*) FROM bookings \n SET COUNT = Answer\n IF (Answer) >= facility_capacity\n THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Facility Full';\n WHERE bookings.facility_id = facility.facility_id;\n END IF;\n END \n //\n DELIMITER ;"
] | [
"mysql",
"triggers",
"count",
"where",
"sql-insert"
] |
[
"Android Tetris (Ghost Piece/Shadow Piece)",
"I would like to know how I can add a Shadow Piece/ Ghost Piece - This is the piece that leads to show where the falling piece will land should the player do a fastdrop.\n\nI'm doing an android game of Tetris - I'm using the project from https://github.com/Linus1905/Android-Tetris.\n\nI will really appreciate"
] | [
"java",
"android",
"2d-games",
"tetris"
] |
[
"Javascript canvas slides when using sprite sheet animation",
"I am trying to animate using a sprite sheet. However, when changing directions in player movement, the animation seems to slide through the sprite sheet to the animation instead of jumping directly to the sprite I want to use.\n\nHere is my render function:\n\n function renderPlayer(me, player) {\n const { x, y, momentum } = player;\n const canvasX = canvas.width / 2 + x - me.x;\n const canvasY = canvas.height / 2 + y - me.y;\n\n context.save();\n context.translate(canvasX, canvasY);\n\n context.drawImage(\n getAsset('sasuke_sheet.png'),\n 0,\n PLAYER_HEIGHT*momentum,\n PLAYER_WIDTH,\n PLAYER_HEIGHT,\n -PLAYER_WIDTH,\n -PLAYER_HEIGHT,\n PLAYER_WIDTH*2,\n PLAYER_HEIGHT*2,\n );\n context.restore();\n}\n\n\nHere are the values I am setting momentum equal to:\n\nif(this.keys[0]) {\n this.momentum = 3;\n this.y -= dt * this.speed;\n}\nif(this.keys[1]) {\n this.momentum = 1;\n this.x -= dt * this.speed;\n}\nif(this.keys[2]) {\n this.momentum = 0;\n this.y += dt * this.speed;\n}\nif(this.keys[3]) {\n this.momentum = 2;\n this.x += dt * this.speed;\n}\n\n\nsprite sheet"
] | [
"javascript",
"canvas"
] |
[
"Range-based for with brace-initializer over non-const values?",
"I am trying to iterate over a number of std::lists, sorting each of them. This is the naive approach:\n\n#include<list>\nusing namespace std;\nint main(void){\n list<int> a,b,c;\n for(auto& l:{a,b,c}) l.sort();\n}\n\n\nproducing\n\naa.cpp:5:25: error: no matching member function for call to 'sort'\n for(auto& l:{a,b,c}) l.sort();\n ~~^~~~\n/usr/bin/../lib64/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_list.h:1586:7: note: \n candidate function not viable: 'this' argument has type 'const\n std::list<int, std::allocator<int> >', but method is not marked const\n sort();\n ^\n/usr/bin/../lib64/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_list.h:1596:9: note: \n candidate function template not viable: requires 1 argument, but 0 were\n provided\n sort(_StrictWeakOrdering);\n ^\n1 error generated.\n\n\nAm I correctly guessing that brace-initializer is creating copy of those lists? And is there a way to not copy them, and make them modifiable inside the loop? (other than making list of pointers to them, which is my current workaround)."
] | [
"c++",
"c++11",
"initializer-list"
] |
[
"Is the Leptonica implementation of 'Modified Median Cut' not using the median at all?",
"I'm playing around a bit with image processing and decided to read up on how color quantization worked and after a bit of reading I found the Modified Median Cut Quantization algorithm.\n\nI've been reading the code of the C implementation in Leptonica library and came across something I thought was a bit odd.\n\nNow I want to stress that I am far from an expert in this area, not am I a math-head, so I am predicting that this all comes down to me not understanding all of it and not that the implementation of the algorithm is wrong at all.\n\nThe algorithm states that the vbox should be split along the lagest axis and that it should be split using the following logic\n\n\n The largest axis is divided by locating the bin with the median pixel\n (by population), selecting the longer side, and dividing in the center\n of that side. We could have simply put the bin with the median pixel\n in the shorter side, but in the early stages of subdivision, this\n tends to put low density clusters (that are not considered in the\n subdivision) in the same vbox as part of a high density cluster that\n will outvote it in median vbox color, even with future median-based\n subdivisions. The algorithm used here is particularly important in\n early subdivisions, and 3is useful for giving visible but low\n population color clusters their own vbox. This has little effect on\n the subdivision of high density clusters, which ultimately will have\n roughly equal population in their vboxes.\n\n\nFor the sake of the argument, let's assume that we have a vbox that we are in the process of splitting and that the red axis is the largest. In the Leptonica algorithm, on line 01297, the code appears to do the following\n\n\nIterate over all the possible green and blue variations of the red color\nFor each iteration it adds to the total number of pixels (population) it's found along the red axis\nFor each red color it sum up the population of the current red and the previous ones, thus storing an accumulated value, for each red \n\n\nnote: when I say 'red' I mean each point along the axis that is covered by the iteration, the actual color may not be red but contains a certain amount of red\n\nSo for the sake of illustration, assume we have 9 \"bins\" along the red axis and that they have the following populations\n\n\n 4 8 20 16 1 9 12 8 8\n\n\nAfter the iteration of all red bins, the partialsum array will contain the following count for the bins mentioned above\n\n\n 4 12 32 48 49 58 70 78 86\n\n\nAnd total would have a value of 86\n\nOnce that's done it's time to perform the actual median cut and for the red axis this is performed on line 01346\n\nIt iterates over bins and check they accumulated sum. And here's the part that throws me of from the description of the algorithm. It looks for the first bin that has a value that is greater than total/2\n\nWouldn't total/2 mean that it is looking for a bin that has a value that is greater than the average value and not the median ? The median for the above bins would be 49\n\nThe use of 43 or 49 could potentially have a huge impact on how the boxes are split, even though the algorithm then proceeds by moving to the center of the larger side of where the matched value was.. \n\nAnother thing that puzzles me a bit is that the paper specified that the bin with the median value should be located, but does not mention how to proceed if there are an even number of bins.. the median would be the result of (a+b)/2 and it's not guaranteed that any of the bins contains that population count. So this is what makes me thing that there are some approximations going on that are negligible because of how the split actually takes part at the center of the larger side of the selected bin.\n\nSorry if it got a bit long winded, but I wanted to be as thoroughas I could because it's been driving me nuts for a couple of days now ;)"
] | [
"c",
"algorithm",
"math",
"colors",
"quantization"
] |
[
"synchronous issue of multiple consumers and multiple producers using pthread conditional variables?",
"Three producers and each has a queue. Two consumers consume msg both from a specific queue and a common queue. How to synchronize them with pthread_cond?"
] | [
"pthreads",
"producer-consumer"
] |
[
"rails CanCan: Letting users set-up certain permissions themselves (photo gallery use case)",
"I'm developing a photo gallery with Rails, where the \"owners\" of a photo set should be able to set permissions themselves (i.e.: allow certain users or groups to do certain actions with the photo set).\n\nRight now I made my first steps with Devise and CanCan an can set static permissions via CanCan's Ability class.\n\nDoes anyone have an idea on how to make this more dynamically so that I can achieve my goal?\n\nThanks in advance"
] | [
"ruby-on-rails",
"dynamic",
"permissions",
"cancan"
] |
[
"No tab completion for IPython in Emacs textmode",
"When I run IPython inside emacs in textmode (i.e. inside a terminal), I don't get any tab completion. Rather than given tab completion it jumps four spaces. \n\nWhen I run emacs in normal GUI mode there is fine tab completion. \n\nIs there a way to fix that for text mode?\n\nI'm using Linux Mint 15, Emacs 24.3 and IPython 1.1.0"
] | [
"emacs",
"ipython",
"tab-completion",
"linux-mint"
] |
[
"Guessing game help needing with random number",
"So im having issues with my code using C.\nHavent learned how to use do/while commands yet. I never can see to get the final to be correct.\nI tried coding to display the random (9 for example)\ni press 9 and says too low. it then at the end the random number says is 14. \nI'm not sure how get the random number consistent throughout the user's input attempts. \n\n// This is a guessing game. You have 4 attempts to guess the number between 1-20. \n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n\nint main(){\n\n int usersInput;\n int range; \n range = rand() %21;\n\n printf(\"Hello and welcome to my game! I have a number in my head between 1-20.\\n\");\n printf(\"Try and guess what it is.\\n\");\n printf(\"Please enter your guess as an integer.\\n\");\n scanf(\"%d\", &usersInput);\n// These are the cases for your first attempted\n// Attempt 1\n if (usersInput > range) {\n printf(\"Your guess is too high. Please try again\\n\");\n }\n else if (usersInput < range){\n printf(\"Your guess is too low. Please try again\\n\");\n }\n else if (usersInput == range){\n printf(\"You are correct! Congratulations, you win!!\\n\");\n return 0;\n }\n// Attempt 2 \n scanf(\"%d\", &usersInput);\n if (usersInput > range){\n printf(\"Your guess is too high. Please try again\\n\");\n }\n else if(usersInput < range){\n printf(\"Your guess is too low. Please try again\\n\");\n }\n else if(usersInput == range){\n printf(\"You are correct! Congratulations, you win!!\\n\");\n return 0;\n }\n// Attempt 3\n scanf(\"%d\", &usersInput);\n if (usersInput > range){\n printf(\"Your guess is too high. Please try again\\n\");\n }\n else if(usersInput < range){\n printf(\"Your guess is too low. Please try again\\n\");\n }\n else if(usersInput == range){\n printf(\"You are correct! Congratulations, you win!!\\n\");\n return 0;\n }\n// Attempt 4\n scanf(\"%d\", &usersInput);\n if (usersInput > range){\n printf(\"Your guess is too high. You lose!\\n\");\n printf(\"the random number is %d \\n\", rand() %21);\n }\n else if(usersInput < range){\n printf(\"Your guess is too low. You Lose!\\n\");\n printf(\"the random number is %d \\n\", rand() %21);\n }\n else if(usersInput == range){\n printf(\"You are correct! Congratulations, you win!!\\n\");\n printf(\"the random number is %d \\n\", rand() %21);\n return 0;\n }\n}"
] | [
"c",
"if-statement",
"random"
] |
[
"Google Forms & Sheets: Drop down answer from Sheet tabs",
"I have created a Google Form and linked it to an existing Google Sheet with multiple tabs on it, I now need to:\n\n\nGet Sheet tab names and populate a Form drop down question with them\n\n\nI've found App Script code to get Sheet tab names from inside the sheet itself but not from the Form. I'm new to App script and how everything connects. If the best solution is to create a Form solely with App Script then that is what I will strive to do."
] | [
"google-apps-script"
] |
[
"asp.net form submitting data to a mysql on Apache server",
"Basically to start with is it even possible to have a form that runs in asp.net and have it write data to a mysql database on a remote Apache web server? If so any pointers!? Not even sure really where to start researching it!"
] | [
"asp.net",
"mysql",
"apache"
] |
[
"Get \"Stop Sharing\" click event in chrome after sharing my screen",
"I got a solution after searching\nstream.getVideoTracks()[0].onended = function () {\n //get stop event\n};\n\nBut I got the error\n\nstream is not defined no-undef\n\nHow can I get this event?"
] | [
"javascript",
"reactjs",
"screensharing"
] |
[
"Python tkinter - rename a treeview item",
"I am making a user interface with tkinter's treeview and one thing that I want to be able to do with it is to allow the user the ability to change the names displayed by the items whenever they want. However, from what I can tell from the documentation, the function that could do this, set only allows for column values to be changed.\n\nIs there any way to change the text of a treeview item without deleting it and remaking it?"
] | [
"python",
"tkinter",
"treeview"
] |
[
"Android Facebook SDK profile.getId() returning the wrong ID",
"My facebook profile is https://www.facebook.com/nathan.moore.5209. I am using the Facebook SDK version 4.9. When I use Profile.getCurrentProfile.getId() I get 1115799235114823 but if I use findmyfbid.com and put in www.facebook.com/nathan.moore.5209 it tells my ID is 100000542702029 which is what I should be getting. \n\nDoes anyone know why this is happening or how to fix it?"
] | [
"android",
"facebook",
"facebook-graph-api",
"facebook-android-sdk"
] |
[
"passing 2D array to function ** vs [][N]",
"tried the following:\n\n#define N 3\nvoid print(int **arr, int m)\n{\n int i, j;\n for (i = 0; i < m; i++)\n for (j = 0; j < N; j++)\n printf(\"%d \", arr[i][j]);\n}\n\nint main()\n{\n int arr[][3] = { { 1, 2, 3 },{ 4, 5, 6 },{ 7, 8, 9 } };\n print(arr, 3);\n return 0;\n}\n\n\nand it crashed. when i replaced it with void print(int [][N], int m) it worked.\ncouldent understand the difference. i was sure that ** means pointer to pointer, in other words array of pointers, in other words array of arrays.\nThe same way array is treated as a pointer to the first cell."
] | [
"c",
"arrays"
] |
[
"How to validate textfield based on input of other textfield in React Material Ui?",
"I am using material ui textfield. I ran into problem where I Want to write a code where one textfield is dependent on other. Like if in textfield one i enter no 4, then number in textfield two should always be greater than 4.That means textfield two depends on textfield one. Please see code in code sandbox. https://codesandbox.io/s/textfield-with-outline-color-forked-8oj2z\n <TextField\n id="outlined-email-input"\n label="Email"\n className={classes.textField}\n type="number"\n defaultValue="0"\n name="email"\n autoComplete="email"\n margin="normal"\n variant="outlined"\n />"
] | [
"javascript",
"reactjs",
"ecmascript-6",
"material-ui",
"frontend"
] |
[
"Makefile rule using the automatic variable $^ without dependencies",
"I learnt from the GNU Make manual that the sign $^ is an automatic variable which represents the names of all the prerequisites. However I fell upon a makefile like this one:\n\nSVR_OBJECT_FILES = server.o\\\n server_func.o\n\nCLT_OBJECT_FILES = client.o\n\nCFLAGS = -Wall -Werror -W\n\n\nCC = gcc\n\nall: client/client server/serveur\n\nclient/client: $(CLT_OBJECT_FILES)\n\nserver/serveur: $(SVR_OBJECT_FILES)\n\nclient/client server/serveur:\n @mkdir -p $(dir $@)\n $(CC) $(CFLAGS) $^ -o $@\n\n%.o: %.c\n $(CC) -c $<\n\nclean:\n rm -f client/client server/serveur *.o\n\n\nWhich works fine so my question is :\n How can the command below can link the right object files while the $^ variable is refering no preprerequisites at all. (the rule has no prerequisites)\n\n $(CC) $(CFLAGS) $^ -o $@"
] | [
"variables",
"makefile",
"prerequisites"
] |
[
"autohotkey looping tooltip and confirm selection with enter",
"I want to accomplish an apparently easy task with autohotkey: when certain hotstring is detected, then show a tooltip (in this case, with the current date). While the tooltip is displayed I want to react to UP and DOWN key-presses showing the next and previous item on an array respectively. Then when the Enter key is pressed I want to confirm the \"selection\" and paste that tooltip text. Here is the current code, which looks too big for a task that is so simple.\n\n ; ------------------------ Date tooltip\n\n::#curdate::\n EnteringDate := True\n DateSeparator := [\".\",\"/\",\"-\"]\n SelectedSep := 1\n GoSub, ShowToolTip\nreturn \n\nShowToolTip:\n Sep := DateSeparator[SelectedSep]\n FormatTime, Time,, dd%Sep%MM%Sep%yyyy ; dd MM yyyy is day month year\n ToolTip, %Time%\nreturn\n\n#If EnteringDate\n\nUp::\nSelectedSep := cycle(SelectedSep,DateSeparator.MaxIndex(),1)\nGoSub, ShowToolTip\nreturn\n\nDown::\nSelectedSep := cycle(SelectedSep,DateSeparator.MaxIndex(),-1)\nGoSub, ShowToolTip\nreturn\n\nEnter::\nEnteringDate := False\nSendInput, %Time%\nToolTip ; Clear the tool tip\nreturn\n\n#If ; end entering date\n\ncycle(value,maxValue,increment:=1){\n value += increment\n if value not between 1 and %maxValue%\n value := increment<0 ? maxValue : 1\n return value\n}"
] | [
"autohotkey"
] |
[
"Are the compilers in VisualStudio 2010 Express less optimized than their Professional version counterparts?",
"I recall in the old days the Express version of the C++ portion of Visual Studio did not include the optimizing compiler. Is this the case? I would guess that it's less of an issue for the managed languages since the optimization occurs during JITting?"
] | [
"visual-studio",
"visual-studio-2010",
"compiler-construction",
"visual-studio-express"
] |
[
"Get first value that is not false from json mixed types",
"This seems like it should be straight forward but I'm not sure why Powershell is having trouble.\n\nI'm getting data from Node.js converting it to JSON and then I want to get the first object which is not false.\n\n(Invoke-WebRequest -UseBasicParsing -Uri \"https://nodejs.org/dist/index.json\").Content |\n ConvertFrom-Json | ? { $_.lts -ne 'False' }\n\n\nI also tried but it didn't work either:\n\n| ? { -not (-not $_.lts) }\n\n\nI know the above doesn't actually get me the first value. I haven't found that solution yet. But help with that would be nice too!\n\nThe data set is something like this:\n\n[\n {\"lts\": false},\n {\"lts\": 'Carbon'}\n]\n\n\nYou can see the complete data set here.\n\nUpdate\n\nWhen I set the JSON value to a variable it works. Strange."
] | [
"powershell",
"powershell-3.0"
] |
[
"Calculate number of descendants recursively",
"I have a table with navigation that joins back on its self using ParentId. I am trying to calculate how many descendents each record has, I know that I need to increment a counter in the recursion, I'm just not sure how to go about it! \n\nAny help would be greatly appreciated!\n\nCREATE TABLE [dbo].[Navigation](\n [Id] [int] IDENTITY(1,1) NOT NULL,\n [AnchorText] [varchar](50) NOT NULL,\n [ParentID] [int] NULL)\n\ninsert into Navigation\nselect 'Level 1', null\nunion\nselect 'Level 2', 1\nunion\nselect 'Level 3', 2\nunion\nselect 'Level 4', 3\n\n\nWITH NavigationCTE (Id, AnchorText, ParentId, NumberofDescendants) as\n(\n Select Id, AnchorText, ParentId, 'Number of Descendants Here' as NumberofDescendants\n from dbo.Navigation nav\n\n union ALL \n\n select nav.Id, nav.AnchorText, nav.ParentId, 'Number of Descendants Here' as NumberofDescendants\n from dbo.Navigation nav\n\n join Navigation ON nav.ParentId = nav.Id\n)\n\n\nSELECT * FROM NavigationCTE\n\n\nEDIT Added Level and Incremented in recursion:\n\nWITH NavigationCTE (Id, AnchorText, ParentId, Level) as\n(\n Select nav.Id, nav.AnchorText, nav.ParentId, 0 as Level\n from dbo.Navigation AS nav\n\n UNION ALL \n\n select nav.Id, nav.AnchorText, nav.ParentId, Level + 1\n from dbo.Navigation AS nav\n\n join Navigation AS nav2 ON nav.ParentId = nav2.Id\n)\n\n\nSELECT * FROM NavigationCTE"
] | [
"sql",
"recursive-descent"
] |
[
"styling not working but others will",
"I am using django and my <p> selector is working but the <h1> is not.\n\nI cant understand why some css is working and others isnt.\n\nWhat order does bootstrap work in?\n\nIt does find the style.css file my text of the element works\n\n style.css\n\nfont-family: 'Wendy One', sans-serif;\nfont-family: 'Baloo', cursive;\nfont-family: 'Libre Baskerville', serif;\n\n\nh1 {\n color:yellow;\n font-family: \"Baloo\", cursive;\n}\n\np {\n color: red;\n font-family: 'Libre Baskerville',sans-serif;\n}\n\n\nindex.html\n\n{% extends \"base.html\" %}\n\n\n{% block content %}\n<h1 class=\"text-center\" >The Wish Fairy Foundation</h1>\n<p> this should be the index of wishfairies.</p>\n{% endblock %}\n\n\nbase.html\n\n{% load static %}\n\n<!DOCTYPE html>\n\n<html lang=\"en\">\n\n\n\n\n{% block title %}{% endblock %}\n\n\n\n\n<head>\n<link href=\"https://fonts.googleapis.com/css?family=Baloo|Libre+Baskerville|Wendy+One\" rel=\"stylesheet\">\n\n<link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css\">\n<link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css\">\n\n<link rel=\"stylesheet\" href=\"{% static 'css/style.css' %}\">\n\n</head>\n\n\n\n{% block header %}\n\n\n{% endblock %}\n\n<body>\n\n{% block sidebar %}\n\n\n\n{% endblock %}\n\n\n<div class=\"container\">\n\n{% block content %} \n\n{% endblock %}\n</div>\n\n{% block footer %}\n\n\n\n{% endblock %}\n\n</div>\n</div>\n</div>\n</body>\n</html>"
] | [
"html",
"css",
"django",
"twitter-bootstrap"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.