texts
sequence | tags
sequence |
---|---|
[
"Loading view from NIB returns zero frame view - what to do?",
"I have a view controller, it is creating another view controlling and adding resulting view to its subview. But the problem is that the view is getting created with frame (0, 0, 0, 0).\n\nIf I set the frame manually it is ok, but I don't want to set frame manually, I want autoresizing. Here is the code:\n\nGridViewController *gridVC = [[GridViewController alloc] initWithNibName:@\"GridView\" bundle:nil];\n[self addChildViewController:gridVC];\n[self.view addSubview:gridVC.view];\n\n\nself.view has normal frame, and gridVc.view has (0,0,0,0) frame;\n\nIn xib I have couple of views, View is connected correctly, file owner is set correctly and everything looks good."
] | [
"ios",
"objective-c"
] |
[
"I can't access all the elements in an array inside an object",
"I have array of abjects \"resultArray\" \n\nresultArray= Array[object,object,....]\n\n\nmy object looks like \n\ncolor:\"value\" ,diams:Array[n]\n\n\nwhere n is number of elements inside the diams array.\nassuming \n\nresultArray.diams = \"0\",\"3\",\"5\"\n\n\"0\",\"3\",\"5\" should be index to access the global array diams \nit looks like\n\nvar diams = [60,65,68,69,70,75,76,80,81,82,85,90];\n\nI am trying to display all the selected information by user from this object. This is my code\n\n$.each(resultArray,function(key,value){\n$(\"#renderedOBJ\").append(\"<p id='p\"+key+\"'> color: \"\n+resultArray[key].color+\"; Diameter :<span id='s\"+key+\"'>\"\n+resultArray[key].diams+\"</span> </P>\");\n\n\nI got this \n\ncolor: purple; Diameter :0,2,3\n\n\nbut I wanted\n\ncolor: purple; Diameter :60,68,69 \n\n\nThats why I tried to access the global array diams like this\n\n$.each(resultArray,function(key,value){\n$(\"#renderedOBJ\").append(\"<p id='p\"+key+\"'> Color: \"+resultArray[key].color+\n\"; Diameter: <span id='s\"+key+\"'>\"\n+diams[resultArray[key].diams[key]]+\"</span> </P>\");\n })\n\n\nBut I got only the first value\n\nColor: pink; Diameter :60\n\n\nCould you tell me what am I doing wrong?\nThanks in advanced"
] | [
"javascript",
"jquery"
] |
[
"VBA Error: \"The object invoked has disconnected from its clients\"",
"I am attempting to write a macro that matches up x/y coordinates to ellipses that they fit into. I get the automation error at the \"Else\" line in my code. I have reviewed a lot of other posts but I can't figure out what is wrong with my code. Any assistance is much appreciated. Thank you! \n\nPrivate Sub CommandButton1_Click()\nDim XR As Integer\nDim XC As Integer\nDim YR As Integer\nDim YC As Integer\nDim areaR As Integer\nDim areaC As Integer\nDim hR As Integer\nDim hC As Integer\nDim kR As Integer\nDim kC As Integer\nDim aR As Integer\nDim aC As Integer\nDim bR As Integer\nDim bC As Integer\nDim angleR As Integer\nDim angleC As Integer\nDim matchR As Integer\nDim matchC As Integer\nXR = 2\nXC = 1\nYR = 2\nYC = 2\nDo Until ThisWorkbook.Sheets(\"Sheet1\").Cells(XR, XC).Value = \"\"\nThisWorkbook.Sheets(\"Sheet1\").Activate\nareaR = 2\nareaC = 6\nhR = 2\nhC = 7\nkR = 2\nkC = 8\naR = 2\naC = 9\nbR = 2\nbC = 10\nangleR = 2\nangleC = 11\nmatchR = XR\nmatchC = 12\n Do Until ThisWorkbook.Sheets(\"Sheet1\").Cells(hR, hC).Value = \"\"\n If (((((ThisWorkbook.Sheets(\"Sheet1\").Cells(XR, XC).Value) _\n - (ThisWorkbook.Sheets(\"Sheet1\").Cells(hR, hC).Value)) * _\n Cos((ThisWorkbook.Sheets(\"Sheet1\").Cells(angleR, angleC).Value)) _\n + ((ThisWorkbook.Sheets(\"Sheet1\").Cells(YR, YC).Value) - _\n (ThisWorkbook.Sheets(\"Sheet1\").Cells(kR, kC).Value)) * Sin _\n ((ThisWorkbook.Sheets(\"Sheet1\").Cells(angleR, angleC).Value))) ^ 2) _\n / ((Cells(aR, aC).Value) ^ 2)) + (((((Cells(XR, XC).Value) - _\n (Cells(hR, hC).Value)) * Sin((ThisWorkbook.Sheets(\"Sheet1\").Cells _\n (angleR, angleC).Value)) - ((ThisWorkbook.Sheets(\"Sheet1\").Cells(YR, YC).Value) _\n - (ThisWorkbook.Sheets(\"Sheet1\").Cells(kR, kC).Value)) _\n * Cos((Cells(angleR, angleC).Value))) ^ 2) / ((Cells(bR, bC).Value) ^ 2)) _\n <= 1 Then\n ThisWorkbook.Sheets(\"Sheet1\").Cells(matchR, matchC).Value = _\n ThisWorkbook.Sheets(\"Sheet1\").Cells(areaR, areaC)\n Else\n areaR = areaR + 1\n hR = hR + 1\n kR = kR + 1\n aR = aR + 1\n bR = bR + 1\n angleR = angleR + 1\n End If\n Loop\n XR = XR + 1\n YR = YR + 1\nLoop\n\n\nEnd Sub"
] | [
"vba",
"excel"
] |
[
"How to incorporate code into a for loop using Python",
"Edit: Here is the code I am trying to use:\n\nfrom bs4 import BeautifulSoup\nimport re\nimport sys\nm = re.compile(\"^\\d\\d:\\d\\d$\")\nreadfile = open(\"C:\\\\Temp\\\\LearnPythonTheCompletePythonProgrammingCourse_Udemy.htm\", 'r').read()\nsoup = BeautifulSoup(readfile, \"html.parser\")\n\nci_details = soup.findAll(\"span\",{\"class\":\"ci-details\"})\n\ntimeList = []\nfor detail in ci_details:\n for span in detail.findAll(\"span\"):\n if m.match(span.text):\n timeList.append(span.text)\n\n\nprint (timeList)\n\nfor i in timeList:\n time1=timeList[0]\n print(time1)\n\n\nedit I realized looking this over that I am telling Python to print time1 for every item in timeList. How do I iterate over timeList ?\n\nI want to use dstubeda's code to take each entry in the list, convert it to raw seconds, add them up. Then once done, I will convert them to h:m:s. Where did I go wrong with my for loop?"
] | [
"python",
"loops",
"beautifulsoup"
] |
[
"Data modelling realted to facts and dimensions",
"I have a fact table which already has invoice number from order table, now we have 2 more tables INVOICE and INVOICE LINE I am little confused where should I place the fact measures from these two tables should I place in the fact table where there is already have the invoice number or do I need to create separate fact table to handle this 2 tables in a data warehouse project?"
] | [
"data-modeling",
"data-warehouse",
"dimensions",
"fact"
] |
[
"Advice on Profile Picture System (Rails 3)",
"Just looking for some advice on the best to approach a profile picture system in a rails 3 app. I want to host pictures on cloudfront, so if anyone has any advice or tips its greatly appreciated!"
] | [
"ruby-on-rails",
"ruby",
"ruby-on-rails-3",
"model-view-controller",
"rubygems"
] |
[
"Bootstrap Ajax Form Crashes after Submitting",
"i have created a Bootstrap Form with a ajax backend for sending and error handling.\nAfter i have clicked the submit Button the whole site crashed and I have to restart the Browser.\nHere the Code:\n(Sorry but here teh Full code, i Do not know how to post the code)\nhttp://codebin.org/view/54dd9fe1"
] | [
"ajax",
"twitter-bootstrap"
] |
[
"Cocoa ScriptingBridge Input Polling",
"I am trying to use ScriptingBridge to write a small iTunes controller. The problem is to find an efficient way of getting notifyed whenever any changes occur. My first approch was to poll the input in a loop and just keep checking for differences. But I think there must be a more efficient way of getting notifyed about input!\n\nThanks in advance!"
] | [
"cocoa",
"input",
"polling",
"scripting-bridge"
] |
[
"Share ViewModel instance between module in android",
"I am working on MVVM Architecture. I want to share an instance of view model between module in my android app. when user complete the ride from app module I would like to access my chat module view model instance to perform some db operation i.e clear Conversation Entity, etc. I am using Room Database with View Model. ChatActivityNew is an activity in chat module.\n\nApp Module Booking Activity\n\nDialogs.INSTANCE.showRideStatusDialog(mCurrentActivity, new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n Dialogs.INSTANCE.dismissDialog();\n Dialogs.INSTANCE.showLoader(mCurrentActivity);\n ChatActivityNew.setMukamalListener(iMukamalCallback);\n dataRepository.requestEndRide(mCurrentActivity, driversDataHandler);\n }\n}\n\n\nChat Module ChatActivityNew\n\n/**\n * Set the Mukamal Callback listener & call onMukamal abstract\n * method which takes Message view model as a parameter.\n *\n * @param iMukamalCallback is a callback listener.\n */\npublic static void setMukamalListener(IMukamalCallback iMukamalCallback) {\n mukamalCallback = iMukamalCallback;\n mukamalCallback.onMukamal(mModel);\n}\n\n\nmModel is null because activity is not loaded yet and MessageViewModel is null so how can i access an instance of MessageViewModel.\n\nI have followed the android developer documentation\nhttps://developer.android.com/topic/libraries/architecture/viewmodel\n\nAny Help will will be highly appreciable.\n\nEDIT\n\nDialogs.INSTANCE.showRideStatusDialog(mCurrentActivity, new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n Dialogs.INSTANCE.dismissDialog();\n Dialogs.INSTANCE.showLoader(mCurrentActivity);\n EventBus.getDefault().postSticky(\n new MessageEvent(com.example.chatmodule.utils.Constants.RIDE_COMPLETE)\n );\n dataRepository.requestEndRide(mCurrentActivity, driversDataHandler);\n }\n }\n\n\nChat Module Subscribe Method\n\n@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)\n public void onMessageEvent(MessageEvent event) {\n if (mModel != null && event.message.equalsIgnoreCase(RIDE_COMPLETE)){\n mModel.deleteConversation();\n mModel.deleteMessages();\n }\n }"
] | [
"java",
"android",
"mvvm"
] |
[
"jmeter post request type automatically gets changed in sampler view",
"I am trying to test post api with request type application/json. but somehow in my output it gives me Content-Type as text/html"
] | [
"jmeter"
] |
[
"What are Capistrano binstubs?",
"I'm new to Rails and wish to deploy my app to Ubuntu 14 using Capistrano. Can someone explain to me what are binstubs and whether they are required for deploying my rails app?"
] | [
"ruby-on-rails-4",
"capistrano",
"capistrano3"
] |
[
"reflection in HTML 5 ( Javascript )",
"Does JavaScript supports \"Reflection\" functionality? If yes, can you please provide me some basic example, which will help me to understand."
] | [
"html",
"reflection"
] |
[
"Does Hive have a dynamic pivot function",
"Does Hive have a dynamic pivot functionality? I'm able to find regular pivoting (ie here) but they appear to be hard coded pivots (all values known at runtime) not dynamic (all values determined at runtime).\n\nIf it exists or someone has user defined code that they could share that would be appreciated."
] | [
"azure",
"hadoop",
"hive",
"pivot",
"hql"
] |
[
"Dialogue box does not show up",
"I am creating a dialogue box that should appear to the user in case of the GPS service is disabled. But what is happening is, although I disabled the service manually to force the dialogue appear, the App starts and nothing is happening.\n\nThe code below shows how I tried to create the dialogue box and when. Please let me know if there is any mistake.\n\nJavaCode:\n\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_gpstest00);\n\n locMgr = (LocationManager) getSystemService(LOCATION_SERVICE);\n gpsEnable = locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER);\n if (!gpsEnable) {\n showGPSDialogueBox();\n } \n locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, this.locationListener);\n}\n\n/*if (savedInstanceState == null) {\n getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();\n}*/\n\nprivate void showGPSDialogueBox() {\n AlertDialog.Builder alertDialogue = new AlertDialog.Builder(this);\n alertDialogue.setTitle(\"GPS Settings\");\n alertDialogue.setMessage(\"GPS is deactivated. Do you want to switch \" + to settings menu to activate it?\");\n\n alertDialogue.setPositiveButton(\"Settings\",new DialogInterface.OnClickListener() {\n\n @Override\n public void onClick(DialogInterface dialog, int which) {\n // TODO Auto-generated method stub\n Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);\n startActivity(intent);\n }\n });\n\n alertDialogue.setNegativeButton(\"Cancel\", new DialogInterface.OnClickListener() {\n\n @Override\n public void onClick(DialogInterface dialog, int which) {\n // TODO Auto-generated method stub\n dialog.cancel();\n\n }\n });\n}// Enf of showDialogueBox function."
] | [
"java",
"android"
] |
[
"Reading xml from url using js",
"I was trying to read xml data provided by the url\n\nurl: http://api.simplyhired.co.in/a/jobs-api/xml-v2/q-java/l-hyderabad/ws-10?pshid=46408&ssty=3&cflg=r\n\nbut I am not getting any response data from the url. I tried below code:\n\nvar url = \"http://api.simplyhired.co.in/a/jobs-api/xml-v2/q-java/l-hyderabad/ws-10?pshid=46408&ssty=3&cflg=r\";\n\n$.ajax({\n url: url,\n complete: function(data) {\n alert(data.responseText);\n }\n});\n\n\nWhen I open url in the browser it shows data in xml format. The problem exists even after encoding the url.\n\nIs there any better way of doing this?\n\nThanks."
] | [
"jquery",
"xml",
"ajax"
] |
[
"What is the proper synatx using Mvc3 Razor for from Mvc2",
"In attempting to update working code from Mvc2 to Mvc3 using the Razor engine, we found that this syntax no longer works.\n\n<script type=\"text/javascript\">\n var initialData = <% = new JavaScriptSerializer().Serialize(Model) %>\n</script>\n\n\nA previous post indicated this to be \"pretty trivial\" but we are not finding that so. And the sample pointed to does not appear to use either json2 nor JavaScriptSerializer().\n\nIn the instant case we may choose to use an alternate method; however, it would still be valuable to know if the above line could/should work to transfer data from the @Model into a javascript variable."
] | [
"javascript",
"asp.net-mvc-3",
"syntax",
"razor"
] |
[
"What is the issue in the code with the usage of strstr to search an array of strings?",
"I hate to ask a \"what is wrong here?\" question, but I'm working through the Head First C book and I came across an issue while attempting to compile an example which I took directly from the book. The aim of the code is simply to take input from the user and search the \"Track List\" (the strings in the track array) for any copy of the user's exact input. Since the code is taken directly from the book, it should compile and work perfectly with no issues. However, it is not recognizing when the input is a part of any of the strings. All of my own fruitless attempts to determine the source of the problem seem to point to the if state where the strstr function is used- but it's not overly complicated, and I don't see the issue. Here is the code:\n\n #include <stdio.h>\n #include <string.h>\n\n char tracks[][80] = {\n \"I left my heart in Harvard Med School\",\n \"Newark, Newark - a wonderful town\",\n \"Dancing with a Dork\",\n \"From here to maternity\",\n \"The girl for Iwo Jima\",\n };\n\n void find_track(char search_for[]) {\n int i;\n for (i = 0; i < 5; i++) {\n if (strstr(tracks[i], search_for))\n printf(\"Track %i: '%s'\\n\", i, tracks[i]);\n }\n }\n\n int main() {\n char search_for[80];\n printf(\"Search for: \");\n fgets(search_for, 80, stdin);\n find_track(search_for);\n return 0;\n }"
] | [
"c",
"strstr"
] |
[
"UIBarButtonItem Vertical Positioning",
"How do I set the vertical position of a UIBarButtonItem? I can set the horizontal positioning without much effort, but the vertical position has me stumped. Thanks!\n\nUIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@\"image.png\"] style:UIBarButtonItemStylePlain target:self action:@selector(link:)];\nUIBarButtonItem *leftSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];\n[leftSpacer setWidth:10];\n\nself.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:leftSpacer,leftBarItem,nil];"
] | [
"ios",
"objective-c",
"xcode",
"ios7"
] |
[
"ProcessBuilder gives a \"No such file or directory\" on Mac while Runtime().exec() works fine",
"I have an application, running on the Playframework, which needs to encode some video files. I used \n\nProcess pr = Runtime.getRuntime().exec(execCode)\n\n\nfor this (and it works perfectly), but as I need both, the output stream and the error stream, I am trying to use ProcessBuilder (as is also recommended).\n\nBut I cannot get it to work (testing on a MacBook). Is there a fundamental difference between the Runtime method and the ProcessBuilder?\n\nThis is my code for ProcessBuilder (exactly the same code works when replaced by Runtime.getRuntime().exec())\n\n String execCode = \"/opt/local/bin/ffmpeg -i file [...]\"; \n ProcessBuilder pb = new ProcessBuilder(execCode);\n pb.redirectErrorStream(true);\n pb.directory(new File(\"/Users/[...]/data/\"));\n Process pr = pb.start();\n\n\nThis is the console output:\n\n11:00:18,277 ERROR ~ There was a problem with with processing MediaFile[13] with error Error during coding process: Cannot run program \"/opt/local/bin/ffmpeg -i /Users/[...]/data/media/1/1/test.mov [...] /Users/[...]/data/media/1/13/encoded.mp3\" (in directory \"/Users/[...]/data\"): error=2, No such file or directory\njava.lang.Exception: Error during coding process: Cannot run program \"/opt/local/bin/ffmpeg -i /Users/Luuk/Documents/Java/idoms-server/data/media/1/1/test.mov -y -f mpegts -acodec libmp3lame -ar 48000 -b:a 64000 -vn -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate -1 -bufsize -1 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 /Users/Luuk/Documents/Java/idoms-server/data/media/1/13/encoded.mp3\" (in directory \"/Users/Luuk/Documents/Java/idoms-server/data\"): error=2, No such file or directory\n at logic.server.MediaCoder.encodeMediaFile(MediaCoder.java:313)\n at logic.server.MediaCoder.doJob(MediaCoder.java:54)\n at play.jobs.Job.doJobWithResult(Job.java:50)\n at play.jobs.Job.call(Job.java:146)\n at play.jobs.Job$1.call(Job.java:66)\n at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)\n at java.util.concurrent.FutureTask.run(FutureTask.java:138)\n at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)\n at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)\n at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\n at java.lang.Thread.run(Thread.java:680)\nCaused by: java.io.IOException: Cannot run program \"/opt/local/bin/ffmpeg -i /Users/Luuk/Documents/Java/idoms-server/data/media/1/1/test.mov -y -f mpegts -acodec libmp3lame -ar 48000 -b:a 64000 -vn -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate -1 -bufsize -1 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 /Users/Luuk/Documents/Java/idoms-server/data/media/1/13/encoded.mp3\" (in directory \"/Users/Luuk/Documents/Java/idoms-server/data\"): error=2, No such file or directory\n at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)\n at logic.server.MediaCoder.encodeMediaFile(MediaCoder.java:189)\n ... 11 more\nCaused by: java.io.IOException: error=2, No such file or directory\n at java.lang.UNIXProcess.forkAndExec(Native Method)\n at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)\n at java.lang.ProcessImpl.start(ProcessImpl.java:91)\n at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)\n ... 12 more"
] | [
"java",
"playframework",
"runtime.exec",
"processbuilder"
] |
[
"Dynamics AX Axapta XPO: Setting image property to relative path instead of absolute path?",
"I'm brand new to AX development so forgive me if this is elementary.\n\nI have a case where I'm adding a command button to a form's command bar in AX 2012 and I have a PNG file that I'm using as the button's icon.\n\nI am getting this to display perfectly by using the \"Text & Image Left\" ButtonDisplay attribute and the \"NormalImage\" attribute for the path of the image on the box in which AX is deployed.\n\nHowever, if my 3rd party installer installs the image file to the bin directory of AX I'd like to reference that image file's path in the XPO relatively. How do I go about doing this?\n\nHow do I go about doing this?\nFor instance here is the sample of my XPO entry for this button:\n\nCONTROL COMMANDBUTTON\n PROPERTIES\n Name #myButton\n ElementPosition #596523234\n HierarchyParent #WorkerCustom\n Text #Sample Text\n ButtonDisplay #Text & Image left\n NormalImage #C:\\Program Files (x86)\\Microsoft Dynamics AX\\60\\Client\\Bin\n ENDPROPERTIES"
] | [
"dynamics-ax-2009",
"axapta"
] |
[
"Convert resource name of audio file to resource id",
"My app reads insructions from xml file and execute them. \nOne Of the instructions is an audio filename to play.\nMy xml may contain the sring @raw/filename or whatever you advice. \nNow once I read it in my app, how do i convert it to resource id which can be used with PediaPlayer object?"
] | [
"android",
"android-resources"
] |
[
"TypeScript - Not able to create object of a class using new operator",
"Object creation is happening without error:\n\nlet paginationParams: Common.Models.PaginationModel = {\n PageNumber: this.pageNumber,\n PageSize: this.pageSize,\n SearchText: this.denominationFilter,\n Ascending: true\n};\n\n\nBut when trying to create that object like this:\n\nlet pagParams = new Common.Models.PaginationModel(\n this.pageNumber,\n this.pageSize,\n true,\n this.denominationFilter);\n\n\nGetting error:"
] | [
"angularjs",
"typescript"
] |
[
"opentpty() with setuid in CentOS 7",
"Running executable with set uid that calls openpty() fails under CentOS 7, but works under CentOS 6. The issue appears to be with opentpty() trying to chown /dev/pts/* from effective uid to real uid. Both 6 and 7 do it. It fails in both 6 and 7. However, in 6 the error is \"ignored\", /dev/pty/* is left owned by effective uid and 0 is returned. In 7 the error causes cleanup, /dev/pty/* is removed and -1 returned. \n\nAm I correct in my assesment above? Any ideas of how to make openpty() not fail when run from set uid code?\n\nThanks!\n\nFor: \n\nfprintf(stderr, \"uid: %d, euid: %d\\n\", getuid(), geteuid());\nint ret=openpty(&session->ptyfd, &session->ttyfd, NULL, NULL, &ws);\nfprintf(stderr, \"pty FD: %d, tty FD: %d\\n\", session->ptyfd, session->ttyfd);\n\n\nCentos 6:\n\ngeteuid32() = 506\ngetuid32() = 500\nwrite(2, \"uid: 500, euid: 506\\n\", 20) = 20\nopen(\"/dev/ptmx\", O_RDWR) = 3\nstatfs(\"/dev/pts\", {f_type=\"DEVPTS_SUPER_MAGIC\", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0\nioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0\nioctl(3, TIOCGPTN, [0]) = 0\nstat64(\"/dev/pts/0\", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0\ngetuid32() = 500\nchown32(\"/dev/pts/0\", 500, 5) = -1 EPERM (Operation not permitted)\nclone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb772c728) = 13801\nwaitpid(13801, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 13801\n--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=13801, si_status=0, si_utime=0, si_stime=0} ---\nioctl(3, TIOCSPTLCK, [0]) = 0\nioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0\nioctl(3, TIOCGPTN, [0]) = 0\nstat64(\"/dev/pts/0\", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0\nopen(\"/dev/pts/0\", O_RDWR|O_NOCTTY) = 4\nioctl(4, SNDRV_TIMER_IOCTL_STATUS or TIOCSWINSZ, {ws_row=33566, ws_col=2052, ws_xpixel=24928, ws_ypixel=219}) = 0\nwrite(2, \"pty FD: 3, tty FD: 4\\n\", 21) = 21\n\n\nCentos 7:\n\ngeteuid() = 1003\ngetuid() = 1000\nwrite(2, \"uid: 1000, euid: 1003\\n\", 22) = 22\nopen(\"/dev/ptmx\", O_RDWR) = 3\nstatfs(\"/dev/pts\", {f_type=DEVPTS_SUPER_MAGIC, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOSUID|ST_NOEXEC|ST_RELATIME}) = 0\nioctl(3, TCGETS, {B38400 opost isig icanon echo ...}) = 0\nioctl(3, TIOCGPTN, [5]) = 0\nstat(\"/dev/pts/5\", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0\ngetuid() = 1000\nchown(\"/dev/pts/5\", 1000, 5) = -1 EPERM (Operation not permitted)\nclose(3) = 0\nwrite(2, \"pty FD: 0, tty FD: 0\\n\", 21) = 21"
] | [
"centos",
"redhat",
"setuid"
] |
[
"There is a way to use less than this number of \"if\" There is a way to shorten this code",
"h = int(input ("Enter your working hours in a week:"))\nrate = 8\nif ((h < 0 ) or (h > 168)):\nprint("INVALID")\nelif h <= 40:\nprint ("YOU MADE", rate*h, "DOLLARS THIS WEEK")\nelif 41 <= h <= 50:\nprint("YOU MADE", int(40 * rate + (h - 40) * (1.129 * rate)), "DOLLARS THIS WEEK")\nelse:\n\nprint("YOU MADE",int(40 * rate + (h - 40) * 1.20373 * rate), "DOLLARS THIS WEEK")"
] | [
"python",
"python-3.x",
"printing",
"format"
] |
[
"Execute a Windows command with a controled environment in C++",
"I currently trying to execute a command in C++11 under Windows, and I want the environment to be a char** that I manually set.\n\nI saw the popen(), system() and CreateProcess() functions, but I cannot achieve that with theses functions.\nWhat I am looking for is an alternative to the UNIX exec* functions, with allows us to precise environment."
] | [
"c++",
"c++11",
"winapi"
] |
[
"input field and sign not in the same line",
"i want to have a nested sign in the input tag, like the QM sign at the end (align right). it works but its not the same line height, EUR is bigger than the input field, has anyone an idea ?\n\n<div class=\"col-lg-12 col-md-12 col-sm-6\">\n <div class=\"formBlock\">\n <label for=\"price\">Wohnfl&auml;che ca.</label><br/>\n <div class=\"input-group input-group-md\">\n <input type=\"text\" name=\"immo_id\" id=\"immo_id\" value=\"\" />\n <div class=\"input-group-addon\">QM</div>\n </div>\n </div>\n</div>"
] | [
"twitter-bootstrap"
] |
[
"Why is a blob url not found (404), when it has a fragment identifier in Safari?",
"It appears that Safari does not recognize a URL created with URL.createObjectURL() that contains an anchor on the end of the URL. When there is no anchor, it works fine, but it is a requirement to have the anchor as I am working with SVG's. The code in this question has been isolated to show the issue.\n\nNOTE: This is only an issue in Safari. Chrome and Firefox work fine.\n\nHere is an example of creating a blob URL:\n\nvar blob = new Blob([\n `<svg xmlns=\"http://www.w3.org/2000/svg\">\n <rect id=\"rect\" fill=\"black\" width=\"20\" height=\"20\"></rect>\n </svg>`\n], {type: 'image/svg+xml'});\n\nvar url = URL.createObjectURL(blob) + '#rect';\n\n$.get(url).done(function (res) { console.log(res) });\n\n\nThe above code creates a URL that is formatted like the following:\n\nblob:http://localhost/e060d31f-6eb0-4565-890d-6de601efcc3e#rect\n\n\nBut when I try to get the contents of it, I get a 404 (Not Found) error:\n\nFailed to load resource: the server responded with a status of 404 (Not Found)\n\n\n\n\nHere is the part that doesn't make sense to me, if I remove the anchor from the URL:\n\n// don't use an anchor\nvar url = URL.createObjectURL(blob);\n\n\nThen it works just fine, and get the contents of the \"URL\".\n\n\n\nSince the \"anchor\" is part of a standard URL, it does not need to be encoded. \n\nI did find a logged bug that sounds like it could be the same problem. It has to do with query params, and not anchor tags. Is there some way that I can get this to work now? Or is this something that will have to wait until the related bug gets fixed?"
] | [
"javascript",
"url",
"safari",
"blob"
] |
[
"ASP.NET Core project cannot find class/method in its referenced project",
"as a beginner I tried to follow right way to create a class library project or ASP.Net core webApi. The situation of mine is:\n\n1) I created a class library project (let's call it 'AAA') using .net Core. The framework for a class library should be \"netstandard1.6\" I know. I defined 1 static class and its methods.\n\n2) Then I create another Asp.Net Core WebApi project, and let's call it 'BBB' The default framework in project.json file is \"netcoreapp1.0\" then.\n\nThen in project BBB -- 'References' I add project AAA as reference. No error happens. However if I try to use the static class/method defined in prject AAA, Visual studio told me that static class could not be found. (Instead of traditional .Net project it will auto-pop suggestion and if I click the link, VS automatically add code and sort it out for me.)\n\nBut if I move mouse on top of the red error part, VS (or re-sharper) did suggest like \"Reference prject AAA... NETStandard, Version=v1.6' and use project AAA.static class/method....\". However even if I click on the suggestion, there is still NO changes at all. \n\nHow come for that and how could I fix it? \n\nThanks a lot!!"
] | [
"asp.net-core",
"asp.net-core-mvc",
".net-core"
] |
[
"Bluetooth Developer Studio connecting with real server (ibeacon)",
"Totally new in Bluetooth Developer Studio. How can I connect to actual physical ibeacon?\n\nUsing the HID over GATT profile in a new project, gives Workbench for interacting with a Virual Server. Can I connect directly to an actual ibeacon in range for read/write?"
] | [
"ibeacon",
"bluetooth-lowenergy"
] |
[
"Vue-router 4 - parent redirect : Maximum call stack exceeded",
"I've done this multiple times, but with the new vue-router(v4.0.3) i get an Maximum call stack exceeded. I've got an layout component with a router-view. I redirect the parent route to the child route, so i can use the active classes on the <router-link/>.\nIs there something wrong with my code?\nLayout template\n<template>\n <div class="layout">\n <transition name="animation-fade">\n <router-view />\n </transition>\n </div>\n</template>\n\n\nRouter config courses.ts\nexport default [{\n path: '/courses',\n name: 'courses',\n redirect: '/courses/all',\n template: '<router-view/>',\n children: [\n {\n path: 'all',\n name: 'coursesAll',\n component: Courses,\n },\n {\n path: ':id',\n name: 'courseSingle',\n component: CourseSingle,\n }\n ]\n}]\n\nRouter\nconst router = createRouter({\n history: createWebHistory(process.env.BASE_URL),\n routes (includes course routes)\n})\n\nrouter.beforeEach((to, from, next) => {\n next()\n})\n\nexport default router;"
] | [
"routes",
"parent-child",
"vue-router"
] |
[
"Permission denied while downloading a file in Tkinter",
"i created a button which will pop up a file dialog ask for user file directory and the system will download the file into the selected directory but when i run it, it show permission denied am i missing anything here\nfrom tkinter import filedialog\n\ndef export(request, id):[enter image description here][1]\nexport_csv_file = Document.objects.get(pk = id) #get the file\ncsv_file = p.read_csv(export_csv_file.document) #read the file \nexport_file_path = filedialog.askdirectory()\ntest = csv_file.to_csv(export_file_path, index = False)\nreturn redirect('/')"
] | [
"python",
"tkinter"
] |
[
"how to create in R a vector automatically which contains all groups to be compared with stat_signif package?",
"So the problem is, I am making some boxplots with ggplot2 in R. I am using the package stat_signif to display the paired comparisons. To do so, I must create a list of vectors to state with groups have to be compare. If I have 2 set of data is fine:\n\n ggplot(data=data, aes(x=group,y= value, fill=group)) +\n geom_boxplot() + \n stat_signif(comparisons = list(c(names[1], names[2]))\n\n\nThe problem comes when I have many groups. For example, with 4 groups the list of vectors (d) goes like this:\n\n d <- list(c(names[1],names[3]), c(names[2], names[4]), c(names[1], names[2]), c(names[3], names[4]))\n\n ggplot(data=data, aes(x=group,y= value, fill=group)) +\n geom_boxplot() + \n stat_signif(comparisons = d)\n\n\nIs there a way to create a automatically a list of vectors with all combination possibles not to write to by hand?\n\nThank you so much!"
] | [
"r"
] |
[
"How to Get Pano ID of particular location?",
"I want to show panorama view of particular location.when is search google for particular location then its give url that url show panorama view,but i have to display it android so how I get pano Id of this location.\n\nfor this i have refer these solution:\nGoogle Maps Streetview - How to get Panorama ID\nbut its not working in my case."
] | [
"android"
] |
[
"Javascript regex capturing words and separators in groups",
"I have this regular expression in Javascript capturing two groups. The first one is capturing a word Hello and the second one is capturing the following separators, like !, and so on given a string Hello! I hear you.\n\nThis is the expression I am using:\n\n/(\\b[^\\s]+\\b)?(\\W+)/g\n\n\nThe example is accessible here. The problem I have is that I would like to capture the last word in the source string (to capture group 1) for cases in which there is no following separator character. In the sample I link to you can see that the last word part is not captured.\n\nI have tried a number of variants, but I end up in infinitely number of matches."
] | [
"javascript",
"regex"
] |
[
"a PROGRESS event when uploading ByteArray to server with AS3 & PHP",
"I'm currently creating a series of as3 / PHP classes that upload - encode + download images.\n\nAnyone know if there's a way to report progress while posting a ByteArray to the server?\n\nthe ProgressEvent is not working - \nat least not in the case of uploading a ByteArray -\nit reports progress only after it's been uploaded\n\nhere's a stripped version of the code I'm using ... \n\nurlLoader=new URLLoader;\nurlLoader.dataFormat=URLLoaderDataFormat.BINARY;\nurlLoader.addEventListener(ProgressEvent.PROGRESS,progressHandler);\n// \nfunction progressHandler(e:ProgressEvent):void {\n trace(e.bytesLoaded/e.bytesTotal);\n\n}\n\n\nthanks -MW"
] | [
"php",
"actionscript-3"
] |
[
"How can I realistically test the server response of a controller that has a null pointer exception",
"I want to write a test that evaluates the response of a controller that has a NullPointerException while handling the request.\n\nFor that purpose I wrote a controller that throws a NullPointer while handling the request. Using the MockMVC controller I send a GET request to that controller.\n\nThe controller that throws the Null Pointer while handling it:\n\n@Controller\npublic class Controller{ \n\n @GetMapping(value = \"/api/data\")\n @ResponseBody\n public ResponseEntity<Resource> getData() {\n\n if (true)\n throw new NullPointerException(); // Intended Nullpointer Exception \n\n return ResponseEntity.notFound().build();\n }\n}\n\n\nThe test function that I expect to receive a 500 error:\n\n@RunWith(SpringRunner.class)\n@SpringBootTest\n@AutoConfigureMockMvc\n\npublic class Test {\n\n @Autowired\n protected MockMvc mockMvc;\n\n @Test\n public void shouldReturn500StatusWhenControllerThrowsAnException() throws Exception {\n MvcResult result = this.mockMvc.perform(get(\"/api/data\"))\n .andExpect(status().is5xxServerError())\n .andReturn();\n }\n\n}\n\n\nI expect the MockMVC request to return an error 500, like the real controller does when it runs as server.\nActually instead the MockMVC just fails with a NullPointer Exception, and does not return anything."
] | [
"java",
"spring",
"rest"
] |
[
"instead of in Visual Studio",
"I use Visual Studio for teaching HTML. We use HTML 4.01 Transitional. Visual Studio defaults to XHTML 1.0, and I need to solve one problem with a typical difference among these two HTML standards: Whenever we enter <br> or <hr>, it is automagically changed to <br /> or <hr /> respectively. This is great for XHTML, but unwanted when working in HTML 4.01 mode.\n\nSo how to turn off this automagical feature? We use mainly Visual Studio 2010, and sometimes also 2012 and 2008.\n\n(I know how to easily switch validation to HTMl 4.01 mode, but it still puts slashes to each <br>, <hr> etc.)"
] | [
"html",
"visual-studio-2010",
"visual-studio",
"xhtml"
] |
[
"How to check if menu item contains a word using twig",
"in the menu.html.twig theme template, I want to check if a menu item title contains a specific word.\n\nso I tried this codes, but none of them worked.\n\n{% elseif menu_level == 1 and 'separator' in item.title %}\n{% elseif menu_level == 1 and 'separator' in item.title.raw %}\n{% elseif menu_level == 1 and 'separator' in item.title|render %}\n\n\nand I have the items: 'separator 1', ' separator 2', 'separator'\n\nbut couldn't solve the problem!"
] | [
"drupal",
"menu",
"twig",
"drupal-8"
] |
[
"Mule can't find xsd generated by Devkit",
"I'm having issues the the xsd files that are generated with Devkit. Now the xsd file is generated fine but when trying to run the connector mule can't find the xsd.\n\nI get errors of this sort:\n\norg.xml.sax.SAXParseException; lineNumber: 15; columnNumber: 58; schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/fooCloud/1.0-SNAPSHOT/mule-fooCloud.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .\n\nNow I have been having a deep look for the .xsd file and have found 4 references to it. \n\n\n http://www.mulesoft.org/schema/mule/fooCloud/1.0-SNAPSHOT/mule-fooCloud.xsd\n\n\nBut the actual xsd file only exists in the target/gernerated-sources folder. I have not seen it in the update-site.\nzip\n\nany ideas why mule keeps trying to reference the mule site for the xsd?"
] | [
"mule",
"devkit"
] |
[
"How to query over range of range key of dynamodb?",
"I'm using 'aws-sdk', '~> 2.6.44'. I've an activities table where I store all the activities performed by a user.\n\nparams = {\n table_name: 'activities', # required\n key_schema: [ # required\n {\n attribute_name: 'actor', # required User.1\n key_type: 'HASH', # required, accepts HASH, RANGE\n },\n {\n attribute_name: 'created_at', # timestamp\n key_type: 'RANGE'\n }\n ],....\n\n\nI want to query this table with all the activities performed by user in past 1 day. Looks like the AWS documentation site has the documentation for SDK version 3.\n\ntableName = 'activities'\nparams = {\n table_name: tableName,\n key_condition_expression: \"#user = :actor and #time between :start_time and :end_time\",\n expression_attribute_names: {\n \"#user\" => 'actor',\n \"#time\" => \"created_at\"\n },\n expression_attribute_values: {\n actor: 'User.1',\n \":start_time\" => (Time.now - 1.days).to_i,\n \":end_time\" => (Time.now + 1.days).to_i\n }\n}\n\nDynamodbClient.client.get_item(params)\n# Throws: ArgumentError: no such member :key_condition_expression\n\n\nI tried with filter expression: \n\ntableName = 'activities'\nparams = {\n table_name: tableName,\n key: {\n actor: 'User.1'\n },\n filter_expression: \"created_at BETWEEN (:id1, :id2)\",\n expression_attribute_values: { \":id1\" => (Time.now - 1.days).to_i,\":id2\" => (Time.now + 1.days).to_i},\n projection_expression: \"actor\"\n}\n\nDynamodbClient.client.get_item(params)\n\n# Throws ArgumentError: no such member :filter_expression\n\n\nWhat should be right way to query DynamoDB table with a ranged option for range key?"
] | [
"ruby-on-rails",
"nosql",
"amazon-dynamodb",
"aws-sdk",
"aws-sdk-ruby"
] |
[
"Unable to fix ValueError: Input contains NaN, infinity or a value too large for dtype('float32')",
"I'm unable to solve this error \n\n\n ValueError: Input contains NaN, infinity or a value too large for dtype('float32').\n\n\nFor my dataset which is output from vgg dense layer and I summerized the output by (mean,median , min ,max, skew ) . I tried diferent methods like :\n\nvgg_dev= vgg_dev.apply(pd.to_numeric, errors='coerce').fillna(0, downcast='infer')\nvgg_dev.replace([np.inf, -np.inf], 0, inplace=True)\n\n\nAnd when I check again if there is any null values vgg_dev.isnull().values.any() it shows False.\n\nAnd I also I check :\n\nnp.where(np.isnan(vgg_dev)) \n\n# print\n(array([], dtype=int64), array([], dtype=int64))\n\n\nBut when I run a test on the data it shows same error again\n\nsel = SelectFromModel(RandomForestClassifier(n_estimators=2000),max_features=max_feature) \nsel.fit(train_feat, y.ravel())"
] | [
"python",
"pandas",
"numpy",
"keras",
"vgg-net"
] |
[
"Tkinter Window Freezes after Running a Server from Script",
"I am making a program that creates an separate python web server, the server being:\n\nimport os, sys\nfrom http.server import HTTPServer, CGIHTTPRequestHandler\n\nwebdir = '.'\nport = 8000\nprint('Server Now Running')\nos.chdir(webdir)\nsrvraddr = (('' , port))\nsrvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler)\nsrvrobj.serve_forever()\n\n\nand then original program runs that server from command line:\n\ndef runServer(self):\n os.system('Webserver.py')\n\n\nAll of this is done with buttons in a Tkinter window. When this function is called, the Tkinter window freezes and the next button cannot be pressed (one which would pull up a local html file in Safari, through the server). \n\nI've looked around and it looks like I might need threading or something...\n\nI have am left clueless as to how I would go about this. Can provide more of my original program if necessary (it's a bit clunky).\n\nI'm looking for a simple solution or maybe a specific reference to get me heading in the right direction.\n\nVery new (3 months) to Python, so please keep this in mind."
] | [
"python",
"multithreading",
"tkinter",
"webserver",
"freeze"
] |
[
"How to call back (display) the images which been extracted before?",
"I've done feature extraction using GLCM and k-nn for classification. What I need to do now is troubleshooting, to analyse why the images been classified wrongly. I want to display the nearest neighbor of the testing data, but not just points like below:\n\n\n\nI want to display the images that nearest to that image(test), so that is easy to know why is that the images nearest to each other(visually). But here is my problem, I didn't know how to call back the images which been extracted before, since those are presented in array of numbers only.\n\nWhat should I do?"
] | [
"machine-learning",
"feature-extraction",
"nearest-neighbor",
"glcm"
] |
[
"React resizable only resizing the width of the box, not the height",
"I have a React-mui draggable dialog component on which I am using resizable box:\nreturn (\n <StyledDialog\n open={open}\n classes={{root: classes.dialog, paper: classes.paper}}\n PaperComponent={PaperComponent}\n aria-labelledby="draggable-dialog"\n >\n <ResizableBox\n height={520}\n width={370}\n minConstraints={[300, 500]}\n maxConstraints={[Infinity, Infinity]}\n className={classes.resizable}\n >\n <DialogContent classes={{root: classes.dialogContent}} id="draggable-dialog">\n <IconButton className={classes.clearIcon} aria-label="Clear" onClick={onClose}>\n <ClearIcon/>\n </IconButton>\n <iframe\n src={hjelpemiddel.url}\n title={hjelpemiddel.navn}\n width="100%"\n height="100%">\n </iframe>\n </DialogContent>\n </ResizableBox>\n </StyledDialog>\n);\n\nI would like to resize the iframe inside the dialog along with the ResizableBox. But, it seems I can only resize the width of the ResizableBox, and not the height of the box, at least the maximum height seems to be the one that is set initially. How can I fix that, so that I can resize the height as well?\nUPDATE\nCodesanbox is available here.\nFYI, for some reason sometimes import fail message appears, but everything works fine if you refresh the page of the codesandbox."
] | [
"javascript",
"reactjs",
"react-material"
] |
[
"Using StrSubstitutor to substitue array values",
"I am trying to use StrSubstituor API to substitute array values. So far, it just ends up substituting the array.toString value.\n\nString[] greetings = {\"Hello\", \"World\"}; \nMap<String, String[]> valuesMap = new HashMap<String, String[]>();\nvaluesMap.put(\"greeting\", greetings);\n\nString templateString = \"${greeting} StrSubstitutor APIs.\";\nStrSubstitutor sub = new StrSubstitutor(valuesMap);\nString resolvedString = sub.replace(templateString);\n\n\nThe result should be:\n\nHello World StrSubstitutor APIs.\n\n\nHowever, now it prints something like:\n\n[Ljava.lang.String;@4c011fe StrSubstitutor APIs.\n\n\nLet me know if you need more information. Any pointers would be greatly appreciated. If this is not the way to do this, please suggest what is the best way to do it. Sorry, if I am in completely wrong on this one."
] | [
"java",
"arrays",
"apache-commons-lang"
] |
[
"make div fill up remaining space",
"i have 3 divs conatined within an outer div. i am aligning them horizontally by floating them left. and div3 as float right\n\n<div id=\"outer\">\n\n <div id=\"div1\">always shows</div>\n <div id=\"div2\">always shows</div>\n <div id=\"div3\">sometimes shows</div>\n</div>\n\n\ndiv1 and div3 have fixed sizes. \nif div3 is left out i want div 2 to fill up the remaining space. how can i do it?"
] | [
"html",
"css"
] |
[
"Unable to connect to Gerrit SSHD",
"I am trying to setup gerrit, but I guess I am missing some configuration as I am unable to connect to gerrit sshd. This guide is what I am trying to follow. The web interface is opening up and I was able to register. However when I try ssh [email protected] -p 29418 I am getting a Connection refused. I have verified that gerrit is indeed running. \n\nGerrit is running behind nginx and these are the configuration I have so far:\nNginx config: \n\nserver {\nserver_name my.example.net;\n\n location / {\n proxy_pass http://127.0.0.1:8090;\n proxy_set_header X-Forwarded-For $remote_addr;\n include conf/proxy.conf;\n auth_basic \"Admin\";\n include conf/auth.conf;\n }\n}\n\n\nPart of gerrit.config: \n\n[auth]\n type = HTTP\n[sshd]\n listenAddress = 127.0.0.1:29418\n[httpd]\n listenUrl = proxy-http://127.0.0.1:8090/\n\n\nThe firewall is indeed allowed to accept connections on port 29418\n\n# iptables -L -n | grep 29418\n ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:29418\n\n\nThanks for your help"
] | [
"gerrit"
] |
[
"iOS - pushViewController without sliding Background Image",
"Messing around with pushViewcontroller due to one of the awkward requirement :/\n\nSo there is a rootViewcontroller with 1 Background Image and UITableView with custom cells and there is a detailViewController with similar backgruound image with different views.\n\nRequirement is:\n\nOn tap of UITableViewCell... the whole navigation animation should not affect the background image. Background Image should stay as it is and all other view should slide.\n\nHow I can slide only UITableView and display detail screen without changing background image ?\n\nThere is one possible solution is just add 2 child view controller and apply slide animation on both child. But in that case I have to keep on removing the child. I can't remove child because on tap of custom bottom back button I have to display the 1st screen instantly.\n\nAny other possible solution or improvement ?"
] | [
"ios",
"objective-c",
"uitableview",
"uinavigationcontroller"
] |
[
"Bootstrap modal visibility not responding to button in react",
"I am using react, with bootstrap installed as an node package. N.B. This is the bootstrap packet, not the react-bootstrap, or reactstrap packet. I've followed the instructions on the bootstrap modal page, to create a modal that is toggled by a button. This exact code has worked for me in the past, but not within a react app, so I am confident that this is the issue.\n\nButton:\n\n<button\n type=\"button\"\n className=\"btn btn-primary\"\n data-toggle=\"modal\"\n data-target=\"#exampleModal\"\n>\n Login\n</button>\n\n\nModal:\n\n<div\n className=\"modal fade\"\n id=\"exampleModal\"\n tabindex=\"-1\"\n role=\"dialog\"\n aria-labelledby=\"exampleModalLabel\"\n aria-hidden=\"true\"\n>\n <div className=\"modal-dialog\" role=\"document\">\n <div className=\"modal-content\">\n <div className=\"modal-header\">\n <h5 className=\"modal-title\" id=\"exampleModalLabel\">\n Modal title\n </h5>\n <button\n type=\"button\"\n className=\"close\"\n data-dismiss=\"modal\"\n aria-label=\"Close\"\n >\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div className=\"modal-body\">...</div>\n <div className=\"modal-footer\">\n <button\n type=\"button\"\n className=\"btn btn-secondary\"\n data-dismiss=\"modal\"\n >\n Close\n </button>\n <button type=\"button\" className=\"btn btn-primary\">\n Save changes\n </button>\n </div>\n </div>\n </div>\n</div>\n\n\nThe button renders properly, and so does the modal. Manually switching the modal visibility gives a proper modal, so I can conclude that the issue is in the button toggling the visibility."
] | [
"css",
"reactjs",
"bootstrap-4"
] |
[
"How to set web server to display URL not IP address?",
"I currently have an apache web server setup on my raspberry pi running Raspbian. I've opened the ports on my router and registered a domain name through a website. In the website I set the domain to forward to my pi's external IP address which works fine. \n\nThe problem I'm having is that when the browser gets to the site which is accessed by url, it displays the test page I have set up but in the address bar the IP is displayed and not the URL. Is there a way to change it so it will display my URL?"
] | [
"linux",
"apache",
"web",
"server"
] |
[
"Android How to add external dependency (context) to SubComponent builder in Dagger 2.1.0",
"I am using dependency injection according to google sample\n\nThe only external dependency I can pass is through AppComponent builder\n\n@Singleton\n@Component(modules = {\n AndroidInjectionModule.class,\n AppModule.class,\n MainTabActivityModule.class,\n CoreActivityModule.class\n})\npublic interface AppComponent {\n @Component.Builder\n interface Builder {\n @BindsInstance\n Builder application(Application application);\n AppComponent build();\n }\n void inject(MyApplication myApplication);\n}\n\n\nand injected in app like this\n\n@Override\n public void onCreate() {\n super.onCreate();\n\nDaggerAppComponent\n .builder()\n .application(myApplication)\n .build().inject(myApplication);\n...\n}\n\n\nAccording to document injecting in Activity looks like this. I added what I would like to achieve.\n\npublic class YourActivity extends Activity {\n public void onCreate(Bundle savedInstanceState) {\n AndroidInjection\n//.builder() THIS IS WHAT I WANT TO ACHIEVE\n//.addActivityContext(this) THIS IS WHAT I WANT TO ACHIEVE\n//.build() THIS IS WHAT I WANT TO ACHIEVE\n.inject(this);\n super.onCreate(savedInstanceState);\n }\n}\n\n\nbut the question is how can I add additional parameter to subComponent.\n\n@Subcomponent\npublic interface CoreActivitySubComponent extends AndroidInjector<CoreAppActivity> {\n// @Subcomponent.Builder\n// interface Builder {\n// Builder addContext(Context context) //did not work\n// CoreActivitySubComponent build(); //did not work\n// }\n\n//==or using abstract class\n// in this option I do not know where to add parameter to this builder\n @Subcomponent.Builder\n public abstract class Builder extends AndroidInjector.Builder<CoreAppActivity> {\n\n\n }\n\n}"
] | [
"dagger-2",
"dagger"
] |
[
"One socket connection per cluster",
"I have an webapp built with Jboss Seam, which runs on cluster Jboss EAP. Webapp have a client library, which should stay connected with server for receiving events. When event arrived from client, it fires JMS message. The question is how can I achieve only one client connection per cluster(to avoid JMS message duplication) in this environment?"
] | [
"java",
"jakarta-ee",
"jms",
"jboss-eap-6",
"jboss-seam"
] |
[
"How to execute 2 consecutive commands in a thread without a context switch occurring?",
"I have a C# program, which has an \"Agent\" class. The program creates several Agents, and each Agent has a \"run()\" method, which executes a Task (i.e.: Task.Factory.StartNew()...).\nEach Agent performs some calculations, and then needs to wait for all the other Agents to finish their calculations, before proceeding to the next stage (his actions will be based according to the calculations of the others).\nIn order to make an Agent wait, I have created a CancellationTokenSource (named \"tokenSource\"), and in order to alert the program that this Agent is going to sleep, I threw an event. Thus, the 2 consecutive commands are: \n\n(1) OnWaitingForAgents(new EventArgs());\n(2) tokenSource.Token.WaitHandle.WaitOne();\n\n\n(The event is caught by an \"AgentManager\" class, which is a thread in itself, and the 2nd command makes the Agent Task thread sleep until a signal will be received for the Cancellation Token).\n\nEach time the above event is fired, the AgentManager class catches it, and adds +1 to a counter. If the number of the counter equals the number of Agents used in the program, the AgentManager (which holds a reference to all Agents) wakes each one up as follows: \n\nagent.TokenSource.Cancel();\n\n\nNow we reach my problem: The 1st command is executed asynchronously by an Agent, then due to a context switch between threads, the AgentManager seems to catch the event, and goes on to wake up all the Agents. BUT - the current Agent has not even reached the 2nd command yet !\nThus, the Agent is receiving a \"wake up\" signal, and only then does he go to sleep, which means he gets stuck sleeping with no one to wake him up!\nIs there a way to \"atomize\" the 2 consecutive methods together, so no context switch will happen, thus forcing the Agent to go to sleep before the AgentManager has the chance to wake him up?"
] | [
"c#",
"multithreading",
"task",
"context-switch"
] |
[
"Store an array using strtok",
"int main (){\n\nFILE *file = fopen ( \"C:\\\\input.txt\", \"r\" );\nint i=0, j=0, k=0;\n\nchar *result[10][10]; \nchar line[100]; \nchar *value;\nchar *res[100][100];\n\nfor(i=0; i<=9; i++){ \n for(j=0;j<=9;j++){\n result[i][j] = NULL;\n }\n}\n\nwhile(fgets(line, sizeof(line), file)){\n char *array=strtok(line,\"\\n\");\n res[0][0]=strdup(array); \n\n printf(\"\\n\\n\\n %s RES \\n\",res[0][0]);\n array=strtok(array,\"\\n\");\n res[0][1]=strdup(array);\n\n printf(\"\\n\\n\\n %s RES \\n\",res[0][1]);\n array=strtok(line,\"\\n\");\n res[0][2]=strdup(array);\n}\n\n\nI want to store an array in a txt file line by line. There are 3 rows in my input file. I want every line is stored by in an array. How can I do that ? this is always store first element.\n\nmy input file :\n\nGeorge :Math1,History2,Math2\nELizabeth :Math2,Germany1,spanish1\nAdam :Germany1,History2,Math1"
] | [
"c",
"arrays",
"runtime-error",
"strtok"
] |
[
"Creating arrays containing text attributes from input elements",
"I'm trying to create a slideshow that is opened in a new window when the user presses a button.\n\nIt uses two arrays with the values of the url:s and the texts associated with the images. \n\nWith the current code, I only get the last value of the imageText array pushed into the variable textList.\n\nHow can I get the text-attributes inside the input-tags inserted into my textList array? I only want the values of the images that have the associated checkbox checked. \n\nThe html: (there are multiple divs like this, with different images and texts)\n\n<div class=\"outerDiv\">\n <label><input type=\"checkbox\">\n <img src=\"img/lorem/1.jpg\" alt=\"Img 1\">\n </label>\n <div class=\"innerDiv\">\n <label>Text: <input type=\"text\" value=\"Lorem ipsum\"></label>\n </div> \n</div> \n\n\nThe javascript:\n\nfunction slideShow() {\n var imageCreatiText = [];\n var pictureTexts = [];\n\nfor (i=0; i< outerDiv.length; i++) {\n imageText = textTag.getElementsByTagName(\"input\")[0];\n}\n\n pictureTexts = imageText.getAttribute(\"value\");\n textList.push(pictureTexts);\n\n newWindow(400, 500 , \"images.htm\", imgList, textList); \n\n}\n\n\nThe variable textTag is declared like this in another function:\n\ntextTag = this.getElementsByClassName(\"innerDiv\")[0];"
] | [
"javascript"
] |
[
"Post-receive hook that auto deploy newly pushed data?",
"I'm looking to implement a post-receive script that would deploy my newly pushed data to a local folder.\n\nUsing Linux/bash I already done something equivalent, but I use git pull, and I often have conflicts when the local folder have some changes regarding the pull (the website is running).\n\nI don't know if the best way is to keep the pull, or do a reset or something else, better, cleaner?\n\nBy the way, would it be possible to automatically deploy the newly pushed data only if I indicate it, without having to make a branche/tag everytime? I'm a newbie with git and I don't know if this is possible.\n\nThe reason I'd like this is since a push automatically update the website, I sometime want to save the changes but not everything is fully working.\n\nThank you really much for your help."
] | [
"git",
"auto-update",
"githooks"
] |
[
"Pdfbox2.0 3 add radio button with label on same row/line",
"I need to add three radio buttons with label in a line on a pdf using pdfbox version2.0.4\n\nI am following this code from this post. I tried changing the x and y coordinates and also tried reusing the same PDRectangle object rather than creating a new every time.\nHow to Create a Radio Button Group with PDFBox 2.0\n\nwidget.setRectangle(new PDRectangle(30, PDRectangle.A4.getHeight() - 40 - i * 35, 30, 30));\n\n\nI expect to see 3 radio button with label on the same line like \nradioBtn Yes radioBtn No radioBtn Don't Know"
] | [
"java",
"pdfbox"
] |
[
"Calculating size of Text Rectangle area based on map zoomScale",
"I have custom mapOverlayView that display a text on a map using this code:\n\n- (void)drawMapRect:(MKMapRect)mapRect\n zoomScale:(MKZoomScale)zoomScale\n inContext:(CGContextRef)ctx\n{\n [super drawMapRect:mapRect zoomScale:zoomScale inContext:ctx];\n NSString *t=text2display;\n CGPoint point = CGPointMake(0,30);\n CGFloat fontSize = (3 * MKRoadWidthAtZoomScale(zoomScale)); \n\n UIFont *font = [UIFont fontWithName:@\"Helvetica-Bold\" size:fontSize];\n\n // Draw outlined text.\n CGContextSetTextDrawingMode(ctx, kCGTextStroke);\n // Make the thickness of the outline a function of the font size in use.\n CGContextSetLineWidth(ctx, fontSize/18);\n CGContextSetStrokeColorWithColor(ctx, [[UIColor blackColor] CGColor]);\n [t drawAtPoint:point withFont:font];\n CGContextRestoreGState(ctx);\n UIGraphicsPopContext();\n\n\nI have also a corresponding mapOverlay that create the rectangle area of the text:\n\n- (MKMapRect)boundingMapRect\n{\n\nMKMapRect bounds = MKMapRectMake(upperLeft.x, upperLeft.y-Z , 2000, 2000);\n\n return bounds;\n}\n\n\nI need the bottom line of text to always stay at same level. Thus, I need to change the value of Z in the above code depending on the size of text to be drawn.\n\nThe size of text depends on zoomScale of the map. Is there away to know the zoom scale of the map? so that I could calculate the size of the text."
] | [
"ios"
] |
[
"Determine number of bytes in a line of a binary file Matlab",
"I am working on importing some data interpretation of binary files from Fortran to MATLAB and have come across a bit of an issue. \n\nIn the Fortran file I am working with the following check is performed\n\nCHARACTER*72 PICTFILE\nCHARACTER*8192 INLINE\nINTEGER NPX\nINTEGER NLN\nINTEGER BYTES\nc This is read from another file but I'll just hard code it for now\nNPX = 1024\nNLN = 1024\nbytes=2\n open(unit=10, file=pictfile, access='direct', recl=2*npx, status='old')\n read(10,rec=nln, err=20) inline(1:2*npx)\n go to 21\n20 bytes=1\n21 continue\n close(unit=10)\n\n\nwhere nln is the number of lines in the file being read, and npx is the number of integers contained in each line. This check basically determines whether each of those integers is 1 byte or 2 bytes. I understand the Fortran code well enough to figure that out, but now I need to figure out how to perform this check in MATLAB. I have tried using the fgetl command on the file and then reading the length of the characters contained but the length never seems to be more than 4 or 5 characters, when even if each integer is 1 byte the length should be somewhere around 1000.\n\nDoes someone know a way that I can automatically perform this check in MATLAB?"
] | [
"matlab",
"fortran",
"binaryfiles"
] |
[
"Kendo Grid - Won't bind to remote data MVC",
"Maddening... Trying to utilize AJAX reads with a Kendo Grid. I've done quite a few binding to data passed down from the model. I copy the code straight from the KendoUI site and tweak to meet my demands:\n\n@(Html.Kendo().Grid<FaultReport2.Models.usp_CMC_TopIssues_Result>()\n.Name(\"grid\")\n.Columns(columns =>\n{\n columns.Bound(p => p.description).Title(\"Description\");\n columns.Bound(p => p.responsible).Title(\"Responsibility\");\n columns.Bound(p => p.charged_time).Title(\"Time\");\n columns.Bound(p => p.responsible).Title(\"Responsible\");\n columns.Bound(p => p.root_cause).Title(\"Root Cause\");\n columns.Bound(p => p.counter_measure).Title(\"Countermeasure\");\n columns.Bound(p => p.status).Title(\"Status\");\n})\n.Pageable()\n.DataSource(dataSource => dataSource\n .Ajax()\n .PageSize(10)\n .Read(read => read\n .Action(\"cmcTopIssues\", \"FaultInfo\", new { equipment_id = Model.area_id, start_date = Model.start_date })\n )\n)\n\n\n)\n\nController code for the read.Action():\n\n public ActionResult cmcTopIssues(int equipment_id, DateTime start_date)\n {\n var db = new Models.FAULTEntities1();\n\n var top_issues = db.usp_CMC_TopIssues(equipment_id, start_date).ToList();\n\n return Json(top_issues, JsonRequestBehavior.AllowGet);\n }\n\n\nDoes not work. I verify that my cmcTopIssues method is being called and that the top_issues var is being filled. It just does not populate the grid.\n\nWhen I switch over to local and pass the data down through the model, it works fine.\n\nAny help would be appreciated."
] | [
"c#",
"asp.net-mvc",
"asp.net-mvc-4",
"kendo-grid",
"kendo-asp.net-mvc"
] |
[
"How to end this animation in react?",
"This app changes background width and adds circle that follows mouse and changes its size when you change position too fast.\n\nHow to write this jquery function in react?\n\nI tried to use react hooks to use prevProps and calculate speed but it didn't work. My react code isn't re-rendering when mouse stopped and does not end the animation.\n\napp.js:\n\nexport default class App extends React.Component {\n state = {\n x: 0,\n y: 0\n };\n\n position = e => {\n let x = e.nativeEvent.clientX || e.nativeEvent.pageX;\n let y = e.nativeEvent.clientY || e.nativeEvent.pageY;\n this.setState({\n x: x,\n y: y\n });\n };\n render() {\n return (\n <div\n onMouseMove={e => {\n this.position(e);\n }}\n >\n <ClientPage position={this.state} />\n <Ball position={this.state} />\n </div>\n );\n }\n}\n\n\nball.js:\n\nlet x = 0;\nlet y = 0;\nexport default class Ball extends Component {\n render() {\n let xmouse = this.props.position.x;\n let ymouse = this.props.position.y;\n\n if (!x || !y) {\n x = xmouse;\n y = ymouse;\n } else {\n x += (xmouse - x) * 0.25;\n y += (ymouse - y) * 0.25;\n }\n let speed = Math.min(Math.abs(x - xmouse), 100) / 100;\n let css = `translate(${x - window.innerWidth / 2}px, ${\n y - window.innerHeight / 2\n }px) scale(${0.5 + 0.5 * (1 - speed)})`;\n\n return (\n <Circle\n style={{\n transform: css,\n }}\n />\n );\n }\n}\n\n\nPlaygrounds:\n\n\nJQuery version: JSFiddle\nReact version: CodeSandbox"
] | [
"javascript",
"jquery",
"reactjs",
"performance"
] |
[
"How to play a sound with Rebol 2 on Mac OS X",
"The feature that is missing is to play sound. I'm thinking of calling a system library or a terminal command that would accept the sound name as a parameter.\n\nThe goal is to get some sound from, for example, a button click. \n\nPS. I'm using Rebol/view on an iBook G3 with Mac OS X Panther."
] | [
"macos",
"audio",
"terminal",
"rebol",
"rebol2"
] |
[
"Python (3.5) - Constructing String to Save File - String Contains Escape Characters",
"I am using Python (3.5) to loop through some .msg files, extract data from them, which contains a url to download a file and a folder that the file should go into. I have successfully extracted the data from the .msg file but now when I try to piece together the absolute file path for the downloaded file, the format ends up weird, with backslashes and \\t\\r. \n\nHere's a shortened view of the code: \n\nfor file in files:\n file_abs_path = script_dir + '/' + file\n print(file_abs_path)\n\n outlook = win32com.client.Dispatch(\"Outlook.Application\").GetNamespace(\"MAPI\")\n msg = outlook.OpenSharedItem(file_abs_path)\n\n pattern = re.compile(r'(?:^|(?<=\\n))[^:<\\n]*[:<]\\s*([^>\\n]*)', flags=re.DOTALL)\n results = pattern.findall(msg.Body)\n\n # results[0] -> eventID\n regexID = re.compile(r'^[^\\/\\s]*', flags=re.DOTALL)\n filtered = regexID.findall(results[0])\n eventID = filtered[0]\n # print(eventID)\n\n # results[1] -> title\n title = results[1].translate(str.maketrans('','',string.punctuation)).replace(' ', '_') #results[1]\n title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore')\n title = title.decode('UTF-8')\n #results[1]\n print(title)\n\n # results[2] -> account\n regexAcc = re.compile(r'^[^\\(\\s]*', flags=re.DOTALL)\n filtered = regexAcc.findall(results[2])\n account = filtered[0]\n account = unicodedata.normalize('NFKD', account).encode('ascii', 'ignore')\n account = account.decode('UTF-8')\n # print(account)\n\n # results[3] -> downloadURL\n downloadURL = results[3]\n # print(downloadURL)\n rel_path = account + '/' + eventID + '_' + title + '.mp4'\n rel_path = unicodedata.normalize('NFKD', rel_path).encode('ascii', 'ignore')\n rel_path = rel_path.decode('UTF-8')\n filename_abs_path = os.path.join(script_dir, rel_path)\n # Download .mp4 from a url and save it locally under `file_name`:\n with urllib.request.urlopen(downloadURL) as response, open(filename_abs_path, 'wb') as out_file:\n shutil.copyfileobj(response, out_file)\n\n # print item [ID - Title] when done\n print('[Complete] ' + eventID + ' - ' + title)\n\n del outlook, msg\n\n\nSo as you can see I have some regex that extracts 4 pieces of data from the .msg. Then I have to go through each one and do some further fine tuning, but then have what I need: \n\neventID\n# 123456\n\ntitle \n# Name_of_item_with_underscord_no_punctuation \n\naccount\n# nameofaccount\n\ndownloadURL\n# http://download.com/basicurlandfile.mp4\n\n\nSo this is the data I get, and I've print() it off and it doesn't have any weird characters. But when I try to construct the path for the .mp4 (filename and directory): \n\ndownloadURL = results[3]\n# print(downloadURL)\nrel_path = account + '/' + eventID + '_' + title + '.mp4'\nrel_path = unicodedata.normalize('NFKD', rel_path).encode('ascii', 'ignore')\nrel_path = rel_path.decode('UTF-8')\nfilename_abs_path = os.path.join(script_dir, rel_path)\n# Download .mp4 from a url and save it locally under `file_name`:\nwith urllib.request.urlopen(downloadURL) as response, open(filename_abs_path, 'wb') as out_file:\n shutil.copyfileobj(response, out_file)\n\n\nAfter doing this, the output I get from running the code is: \n\nTraceback (most recent call last): File \"sfaScript.py\", line 65, in <module> with urllib.request.urlopen(downloadURL) as response, open(filename_abs_path, 'wb') as out_file:\nOSError: [Errno 22] Invalid argument: 'C:/Users/Kenny/Desktop/sfa_kenny_batch_1\\\\accountnamehere/123456_Name_of_item_with_underscord_no_punctuation\\t\\r.mp4'\n\nTL;DR - QUESTION\n\nSo the filename_abs_path somehow got changed to \nC:/Users/Kenny/Desktop/sfa_kenny_batch_1\\\\accountnamehere/123456_Name_of_item_with_underscord_no_punctuation\\t\\r.mp4 \n\nI need it to be \n\nC:/Users/Kenny/Desktop/sfa_kenny_batch_1/accountnamehere/123456_Name_of_item_with_underscord_no_punctuation.mp4\n\nThanks for any help provided!"
] | [
"python",
"python-3.5"
] |
[
"XMPP library for iOS (iPhone/iPad)",
"I'm making a GTalk client for iOS and would need a XMPP library to do the heavy lifting.\nAnyone know of such?"
] | [
"iphone",
"objective-c",
"ipad",
"ios"
] |
[
"How to get height of Image in Imageview?",
"I have set an image in imageview. It is showing in center of the screen as I have make its parent layout (Relative layout) to match parent. Imageview height and width is also set to match parent.\n\nI want to get the height and width of Image in imageview.\n\nI have used :\n\nint imagWidth = imageView.getWidth();\nint imagHeight = imageView.getHeight();\n\n\nbut by this we are getting height and width of Imageview .\n\nHere is my xml:\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:id=\"@+id/rl_root\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\">\n\n <ImageView\n android:id=\"@+id/imag\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:adjustViewBounds=\"true\"\n android:background=\"@android:color/black\"\n android:src=\"@drawable/image2\" />\n</RelativeLayout>"
] | [
"android",
"android-layout",
"android-imageview"
] |
[
"Get specific pixel from 1D pixel array",
"I've got a pixel array, containing multiple colors.\n\nint w = 32;\nint h = 32;\nint[] pixels = new int[w*h];\n\n\nAs You can see, the image in this example has the dimensions 32x32. All pixels are stored in the one dimensional array.\n\nNow for example I would like to have the pixel from the coordinates (5/0), that means the fifth element in the first row of the image. Now the problem is that I've got an one dimensional pixel array. Otherwise I just could've called\n\nint target = pixels[5][0];\n\n\nHow can I achieve getting this specific pixel from the one dimensional array?"
] | [
"java",
"arrays",
"pixel"
] |
[
"What is best way to use file_put_contents to write PHP code to file?",
"Here is the script:\n\n<?php \n\n$line0PHP = '<?php';\n$line1PHP = 'defined( '_JEXEC' ) or die( 'Restricted access' );';\n$line2PHP = 'jimport( 'joomla.plugin.plugin');';\n$line3PHP = 'jimport( 'joomla.html.parameter');';\n$line4PHP = 'class&#32;plgSystem'.$titleString.'plugin&#32;extends&#32;JPlugin';\n$line5PHP = '{';\n$line6PHP = 'function plgSystem'.$titleString.'plugin()';\n$line7PHP = '{';\n$line8PHP = '}'; \n$line9PHP = '}';\n$line10PHP = '?>';\n\n$phpFileOutput = $line0PHP.'&nbsp;'.$line1PHP.'&nbsp;'.$line2PHP.'&nbsp;'.$line3PHP.'&nbsp;'.$line4PHP.'&nbsp;'.$line5PHP.'&nbsp;'.$line6PHP.'&nbsp;'.$line7PHP.'&nbsp;'.$line8PHP.'&nbsp;'.$line9PHP.'&nbsp;'.$line10PHP;\n\n$varOutputPhp = print_r($phpFileOutput, true);\n\nfile_put_contents($root,$varOutputPhp);\n\n?>\n\n\n$root and $titleString are defined earlier."
] | [
"php",
"file",
"overwrite",
"htmlspecialchars"
] |
[
"MKAnnotation via XCTest UI Testing",
"How can I access the pins on an MKMapView via XCTest's UI Tests?\n\nI want to count the number, verify specific ones are there (based on accessibility id or title), etc.\n\nThere doesn't seem to be a XCUIElementType for MKAnnotation.\n\nI'm having a hard time finding any documentation on MKMapView + XCTest."
] | [
"swift3",
"xcode8",
"mkannotation",
"xctest",
"xcode-ui-testing"
] |
[
"How to get django-admin.py command working in windows 7",
"I have installed django 1.6.4 on my windows 7 (32-bit) machine, I'm using python 2.7.6\n\nBut when i started to create my project by using following command:\n\nC:\\django-admin.py startproject mysite\n\n\nit doesn't create any folder named mysite under my current directory, instead it just simply runs the django-admin.py script, in fact no matter what i type after django-admin.py command i get the output of django-admin.py script on the command prompt.\n\nC:\\django-admin.py startproject mysite\nC:\\django-admin.py abcdefghi\n\n\nboth of the above commands just simply runs the django-admin.py script and does nothing else.\n\nI checked online but i couldn't seem to find out the actual problem.\n\nI have set all the environment variables of python and of django\n\nPath= C:\\Python27\\;C:\\Python27\\Scripts"
] | [
"python",
"django",
"django-admin"
] |
[
"What is the best way to define string constants in an objective-c protocol?",
"I have defined a protocol that all my plug-ins must implement. I would also like the plug-ins to all use certain strings, like MyPluginErrorDomain. With integers this is quite easily achieved in an enum, but I can't figure out how to do the same with strings. Normally, in classes I would define \n\nextern NSString * const MyPluginErrorDomain;\n\n\nin the .h file and in the .m file:\n\nNSString * const MyPluginErrorDomain = @\"MyPluginErrorDomain\";\n\n\nbut that doesn't work very well in a protocol, because then each plug-in would have to provide its own implementation which defeats the purpose of having a constant.\n\nI then tried\n\n#define MYPLUGIN_ERROR_DOMAIN @\"MyPluginErrorDomain\"\n\n\nbut the implementing classes in the plug-in can't seem to see the #define. Who knows a good solution?"
] | [
"objective-c",
"cocoa",
"nsstring",
"constants",
"protocols"
] |
[
"How to fix an if statement for a moving object?",
"I have an object moving when I press some keys. It also moves diagonally when I press two keys. The issue is the following:\n\n\nI press 'd', the object goes left. \nI keep left pressed and I also press 'w'. The object moves diagonally. \nI release 'w', while 'd' is still pressed. The object stops moving, although 'd' is still down. \n\n\nHow can I fix that?\n\nlet keysPressed = [\"a\", \"w\", \"d\", \"s\"];\nconst box1 = document.getElementById(\"box1\");\n\n\ndocument.addEventListener('keydown', (event) => {\nkeysPressed[event.key] = true;\nvar box1x = box1.offsetLeft;\nvar box1y = box1.offsetTop;\nif (keysPressed['d'] && keysPressed['s']) {\n box1.style.left = box1x + 20 + 'px';\n box1.style.top = box1y + 20 + 'px';\n} else if (keysPressed['a'] && keysPressed['s']) {\n box1.style.left = box1x - 20 + 'px';\n box1.style.top = box1y + 20 + 'px';\n} else if (keysPressed['w'] && keysPressed['a']) {\n box1.style.left = box1x - 20 + 'px';\n box1.style.top = box1y - 20 + 'px';\n} else if (keysPressed['w'] && keysPressed['d']) {\n box1.style.left = box1x + 20 + 'px';\n box1.style.top = box1y - 20 + 'px';\n} else if (keysPressed['w']) {\n box1.style.top = box1y - 20 + 'px';\n} else if (keysPressed['s']) {\n box1.style.top = box1y + 20 + 'px';\n} else if (keysPressed['a']) {\n box1.style.left = box1x - 20 + 'px';\n} else if (keysPressed['d']) {\n box1.style.left = box1x + 20 + 'px';\n}\n});"
] | [
"javascript",
"if-statement",
"dom-events"
] |
[
"Is there a way to click a cell in a DataGridView to expand it with another DataTable?",
"In my Windows Form Application, I am using a DataGridView to display some DataTables I have, in these tables I have some regional information, I am trying to make it so that you can click on these region values in the DataGridViews cell and it will then expand and show all the yearly values I have of that region. For example, if a user clicked on the Cell in the grid that said \"UK\" it will then expand a table in the same datagridview that shows all the information I have on the UK etc.\n\nThank you"
] | [
"c#",
"datagridview"
] |
[
"Java8: compiler error with generic version in lambda function",
"Here I just create two simple class Dad and Son, Son is a subclass of Dad.\n\npublic class Dad {\n }\n\npublic class Son extends Dad {\n}\n\n\nThen I create a Function in other class to test\n\npublic class Test {\n public static void main(String[] args) {\n Function<? extends Dad, String> fun = son -> son.toString();\n fun.apply(new Son());\n}\n\n\nBut I came across a compiler error on fun.apply(new Son()), it says 'apply (captrue in Funtion cannot be appiled to (Son))'. I am confused, the fun need a param of class which extends Dad, I give the subclass but is not right at all.\n\nWhat's more! I try new Dad() as the param for the fun, but also got the error message 'apply (captrue in Funtion cannot be appiled to (Dad))'\n\nFinally, I don't know which param can be used when the Function with generic version.\n\nHelp~~~\nThanks! (⊙o⊙)"
] | [
"generics",
"lambda",
"java-8"
] |
[
"Teamcity and register dll",
"I'm trying to build a project with TeamCity Professional 6.5.2\nI have a MVC Visual Studio 2010 project using a visual foxpro dll.\nThe build fails because the dll is not registered.\nHow can I register that dll in the build machine, as part of the build process?\n\nThanks!!"
] | [
"build",
"teamcity"
] |
[
"Close application without .net framework's error prompt window",
"Codes handles unhandled exceptions as below in my project.\n\n static void FnUnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs _UnhandledExceptionEventArgs)\n {\n Exception _Exception = (Exception)_UnhandledExceptionEventArgs.ExceptionObject;\n OnUnwantedCloseSendEmail(_Exception.Message);\n }\n\n\nI am using OnUnwantedCloseSendEmail method for sending email for error reports. Last line of OnUnwantedCloseSendEmail method is Application.Restart();\n\nWhen this approach correctly works, .net framework show an prompt window for error as below and application not close and restart until press the quit button.\n\n\n\nHow can i exit application without this prompt and how can i apply this approach when application frozen too."
] | [
"c#",
"winforms"
] |
[
"MPI_Comm_spawn from a process other than rank 0",
"I'm trying to make the following :\n\n1-Run the code with mpirun -np 2 xxx\n2-Rank 1 process spawns 2 slaves (spawn_example code found online)\n\nWhen i tried to spawn from rank 0 it worked, but from rank 1 it hangs and keeps on waiting until i stop the execution with ctrl+c \n\nHere's the code, if you run with -np 1 it finishes normally, but with -np 2 it hangs :\n\n#include<string.h>\n#include<stdlib.h>\n#include<stdio.h>\n#include\"mpi.h\"\n\n\nint main(int argc, char **argv)\n{\n\n int tag = 1;\n int tag1 = 2;\n int tag2 = 3;\n int my_rank;\n int num_proc;\n\n int array_of_errcodes[10];\n\n int i;\n\n MPI_Status status;\n MPI_Comm inter_comm;\n\n\n\n MPI_Init(&argc, &argv);\n MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);\n MPI_Comm_size(MPI_COMM_WORLD, &num_proc);\n\n\nif(my_rank==0)\n{\n printf(\"I'm process rank %d \\n \",my_rank);\n}\n\nif(my_rank==1)\n{\n printf(\"Rank %d process is spawning 2 slaves \\n\",my_rank);\n\n MPI_Comm_spawn(\"spawn_example\", MPI_ARGV_NULL, 2, MPI_INFO_NULL,1, MPI_COMM_WORLD, &inter_comm, array_of_errcodes); \n}\n\n MPI_Finalize();\n exit(0);\n}\n\n\nI don't know what i'm doing wrong , i'd like to know how to make it possible so other ranks can spawn their slaves and eventually exchange data. Thanks.\nEdit1: i added the full code , if you need the spawn_example i can provide a link to it."
] | [
"mpi",
"spawn"
] |
[
"Javascript syntax seen in SignalR",
"When learning the SignalR, I see some JS script pattern like below in the auto-generated hubs script. What's this syntax?\n\n(function(a,b,c){...}(e,f));\n\n\nOr in the hubs:\n\n(function($, window, undefined){...}(window.jQuery, window));"
] | [
"javascript",
"signalr"
] |
[
"Style item of mat-expansion-descrption",
"I'm having trouble aligning my description "summary" or more specifically I want to have my item numbers in the panel header at the right end of the panel.\nHere's what I already tried:\n.mat-expansion-panel-header-description {\n flex-grow: 2;\n text-align: end; /*also tried "right"*/\n}\n\nand I also tried applying these properties to my summary class but nothing is working, they don't change their position like shown in my screenshot\n.summary {\n text-align: right;\n}\n\nThis is my html markup:\n<mat-expansion-panel class ="mat-header" hideToggle *ngFor="let key of itemCategories">\n <mat-expansion-panel-header class="panel-header">\n <mat-panel-title>\n {{key}}\n </mat-panel-title>\n <mat-panel-description class="summary">\n <div *ngIf="items[key].length > 0">\n {{items[key].length}}\n </div>\n </mat-panel-description>\n </mat-expansion-panel-header>\n <div class="panel-content" *ngIf="items[key].length > 0">\n <ng-container *ngFor="let item of items[key]">\n <!-- Alle Bereiche -->\n <!-- <ng-container *ngIf="key == 'Alle Bereiche'">\n Alle Bereiche template\n </ng-container> -->\n <div>\n Name: {{item?.name}} <br> Betrag: {{item?.price}} <hr>\n </div>\n </ng-container>\n </div>\n </mat-expansion-panel>\n\nThis is what my app looks like with some explanatory marking\nhttps://snipboard.io/f1aQMi.jpg\nWithout marking:\nhttps://snipboard.io/f1aQMi.jpg\nI can't figure it out and it's my first time working with Angular material, could someone please tell me what I'm doing wrong? Would appreciate any help!"
] | [
"html",
"css",
"sass",
"angular-material"
] |
[
"What are the long term consequences of memory leaks?",
"Suppose I had a program like this:\n\nint main(void)\n{\n int* arr = new int[x];\n //processing; neglect to call delete[]\n return 0;\n}\n\n\nIn a trivial example such as this, I assume there is little actual harm in neglecting to free the memory allocated for arr, since it should be released by the OS when the program is finished running. For any non-trivial program, however, this is considered to be bad practice and will lead to memory leaks. \n\nMy question is, what are the consequences of memory leaks in a non-trivial program? I realize that memory leaks are bad practice, but I do not understand why they are bad and what trouble they cause."
] | [
"c++",
"memory"
] |
[
"How do I identify checkbox value with given HTML element? angularjs-e2e",
"I need some advice with issue below. When checkbox = checked, there will be attribute value checked=checked and for the unchecks, attribute will not be there and I can't uniquely identify. On a page, there will be checked and unchecked checkboxes. Dev refuses to add additional attribute for me and saying that there must be a way to identify (exist or not exist).\n\nSo on my my test page, I have 10 checkboxes with 3 checked and 7 unchecked. \n\nHTML for uncheck checkboxes\n\n<input type=\"checkbox\" disabled=\"disabled\" ng-checked=\"item.unread\">\n\n\nHTML for checked checkboxes\n\n<input type=\"checkbox\" disabled=\"disabled\" ng-checked=\"item.unread\" checked=\"checked\">\n\n\nMy attempt at counting - it will returned exact number and will fail eventually as number may change. \n\nexpect(element.all(by.css('input[checked=\"checked\"]')).count()).toBe(2);\n\n\nNo issue with identifying checked items with attribute - checked=\"checked\"\n\nexpect(element.all(by.css('input[checked=\"checked\"]')).isSelected()).toBeTruthy();\n\n\nbut fails when I check for unchecked item. \n\nexpect(element.all(by.css('input[type=\"checkbox\"]')).isSelected()).toBeFalsy();\n\n\nFailed result for unchecked item - 7 unchecked and 3 checked\n\n[ false false false false true true false false true false]\n\n\nThanks"
] | [
"angularjs",
"testing",
"protractor",
"angularjs-e2e",
"end-to-end"
] |
[
"Image quality lower is not like displaying in photo album",
"Hi i am new to the iOS.\n\nI am developping one app, it contain photo editing feature. for that purpose i can pick the photo from photo library. i could successfully pick the photo and place it in UIImageView.but i feel its not that much good. it has lots of different that displaying in photo album and displaying in UIImageView.\n\nI wish to display it like displaying in photo album. How can i achieve this?\n\nPlease guide me.\n\n- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info\n{\n // Access the uncropped image from info dictionary\n UIImage *originalImage = [info objectForKey:@\"UIImagePickerControllerOriginalImage\"];\n NSLog(@\"size of originalImage is %@\",NSStringFromCGSize(originalImage.size));\n editingPhotoImgVw.frame = CGRectMake(0, 0, 320,self.view.frame.size.height);\n editingPhotoImgVw.image =originalImage;\n [editingPhotoImgVw setContentMode:UIViewContentModeScaleAspectFit];\n [self.view addSubview:editingPhotoImgVw];\n [self dismissModalViewControllerAnimated:YES];\n [picker release];\n\n}\n\n\nDisplaying in photo album\n\nDisplaying in app \n\nAfter changing [editingPhotoImgVw setContentMode:UIViewContentModeScaleAspectFit]; into [editingPhotoImgVw setContentMode:UIViewContentModeScaleToFill]; as per iSanjay comments"
] | [
"iphone",
"ios",
"uiimageview",
"camera",
"photolibrary"
] |
[
"Initialize container in static constructor",
"Is it legit to initialize the simple injector container in a static constructor? \n\nExample:\n\nusing SimpleInjector;\n\npublic static Bootstrapper\n{\n private readonly static Container container;\n\n static Bootstrapper()\n {\n Bootstrapper.container = new Container();\n }\n}"
] | [
"c#",
"simple-injector"
] |
[
"gcc -I and -L options don't seem to work",
"I am trying to compile a project in my system using qmake. Some dependencies of the project are not installed but reside in my home directory, more or less like this: libs files: /home/myusername/local/lib and my includes directory /home/myusername/local/include. Inside the include directory I have a folder, qjson with the needed headers from the library. In the lib folder I have the files libqjson.so libqjson.so.0 libqjson.so.0.7.1.\n\nMy qmake project file looks something like this:\n\nlinux-g++ {\nINCLUDEPATH += /home/myusername/local/include/\nLIBS += -L/home/myusername/local/lib/ -lqjson\n}\n\n\nand the generated makefile will produce commands like this one:\n\ng++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB \\\n -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../qbuzz \\\n -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui \\\n -I/usr/include/qt4 -I/home/myusername/local/include/ -I. -I. -I../myproject -I. \\\n -o qbuzz-result.o ../myproject/myfile.cc\n\n\nIt is clear that my include directory is in the -I option of gcc. myfile.cc contains an include like this one:\n\n#include <qjson/parser.h>\n\n\nHowever, after running make, I get the error:\n\n../myproject/myfile.cc:2:26: fatal error: qjson/parser.h: No such file or directory\ncompilation terminated.\n\n\nNow, if I modify the environment variable CPLUS_INCLUDE_PATH to add my local include file, I have no problems there, but in the linker stage I got the error:\n\n/usr/bin/ld: cannot find -lqjson\ncollect2: ld returned 1 exit status\n\n\nEven though the linker command was:\n\ng++ -omyprogram main.o mainwindow.o myfile.o moc_mainwindow.o -L/usr/lib \\\n -L/home/myusername/local/lib/ -lqjson -lQtGui -lQtNetwork -lQtCore -lpthread \n\n\nI also can get around modifying the environment variable LIBRARY_PATH. However I am looking for a solution that relies on modifying as few environment variables as possible, and after all, why are the options -L and -I there? \n\nI works on Windows without problems using MinGW g++."
] | [
"c++",
"linux",
"gcc",
"include-path",
"qjson"
] |
[
"Concatenate avoiding NAs to produce multiline variable",
"Fake data\n\nFruit <- c(\"Tomato\", \"Banana\", \"Kiwi\", \"Pear\")\nColour <- c(\"Red\", \"Yellow\", NA, \"Green\")\nWeight <- c(10, 12, 6, 8)\n\ndd <- data.frame(Fruit, Colour, Weight)\n\n\nFailed attempt\n\ndd <- dd %>%\n mutate(Description = sprintf(\"%s: %s \\n%s: %s \\n%s: %s\",\n names(dd)[1], Fruit,\n names(dd)[2], Colour,\n names(dd)[3], Weight))\n\ndd$Description[1]\n\n\nDesired output: Multi-line \"Description\" variable ignoring NAs.\n\n\"Description\" variable of Tomato:\n\nFruit: Tomato\nColour: Red\nWeight: 10\n\n\n\"Description\" variable of Kiwi, NA ignored!\n\nFruit: Kiwi\nWeight: 6"
] | [
"r",
"dataframe",
"concatenation",
"missing-data"
] |
[
"Dragging cell to bottom or top will stop and reordering `collectionView` will not reorder",
"I add a longPress Gesture to collectionView, and use system API to implement reordering collectionview. here is my code:\n\nCGPoint point = [sender locationInView:_collectionView];\nNSIndexPath *indexPath = [_collectionView indexPathForItemAtPoint:point];\nif (!indexPath) {\n return;\n}\nDragableCollectionViewCell *tempCell = (DragableCollectionViewCell *)[_collectionView cellForItemAtIndexPath:indexPath];\n\nswitch (sender.state) {\n case UIGestureRecognizerStateBegan: {\n\n AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);\n\n [tempCell showDeletButton];\n [tempCell.deleteButton zkj_addEventHandler:^(id sender) {\n [tempCell hideDeleteButton];\n [self.dataSource[indexPath.section] removeObjectAtIndex:indexPath.item];\n [self.collectionView deleteItemsAtIndexPaths:@[indexPath]];\n } withControlEvents:UIControlEventTouchUpInside];\n\n [_collectionView beginInteractiveMovementForItemAtIndexPath:indexPath];\n }\n break;\n case UIGestureRecognizerStateChanged: {\n [_collectionView updateInteractiveMovementTargetPosition:point];\n }\n break;\n case UIGestureRecognizerStateEnded: {\n [_collectionView endInteractiveMovement];\n }\n break;\n\n default:\n [_collectionView cancelInteractiveMovement];\n break;\n}\n\n\nand I had implement dataSource and delegate of collectionView correctly. After that, it works, I can move drag cell and reorder collectionView. But when I drag cell to bottom or top, the cell will stop at bottom or top, and collectionView will not reorder automatically."
] | [
"ios",
"uicollectionview"
] |
[
"getting compiler error in intelliJ IDE",
"Actually I updated my jdk today but when I opened intelliJ I wasn't able to compile any class..It showed the following message..\n\"java: System Java Compiler was not found in classpath\"\nPlease help me out."
] | [
"java",
"intellij-idea",
"classpath"
] |
[
"Index of geometric functions",
"I am making a sort of command based application to draw geometric figures. So if a user enters something like RECT 100, 50, 200, 120 I draw a rectangle at specified location on the drawing panel.\n\nSo for this i need to map RECT to g.drawRect(100, 50, 200, 120); and all such similar functions to draw geometric figures.\n\nI will use a hash map for mapping, but i don't know how to build a array of functions in java. In C++ i have done this though.\n\nThe key can be 'RECT' and the value the offset of the index.\n\nPlease show me how can i index these functions. Or is there a still better way to address the primary concern?"
] | [
"java",
"swing",
"graphics",
"indexing",
"hashmap"
] |
[
"SEO solution for microblogs?",
"we all have heard about benefits of microblogs but what if we have a microblog and want to boost it's SEO?\n\nthe biggest problem in microblogs is keywords are not related to each other and each topic has a small amount of related keywords.\n\nfor example if we have a microblog that has short tips about all fields in computer sience, and a blog that publish articles in this field too.\n\nthe outlined blog has a better chance to be appeared in SERP, instead the underlined microblog has no chance because of it's limited keywords.\n\nam i right and what is the SEO solution for these microblogs?"
] | [
"seo",
"microblogging"
] |
[
"Exclude first line of error stack in Node? / Custom Error Type in Node?",
"Is there any way to create anError object using a JavaScript factory without including the line from the factory in the stack? \n\nFor example, this:\n\nif (!member) {\n return next(errs.init('Invalid email address.', errs.UNAUTHORIZED));\n}\n\n\n... produces this:\n\nError: Invalid email address.\n at Object.init (/.../bin/utils/errors.util.js:21:16)\n at Query.<anonymous> (/.../routes/auth/auth.routes.js:37:30)\n at /.../node_modules/kareem/index.js:177:19\n at /.../node_modules/kareem/index.js:109:16\n at nextTickCallbackWith0Args (node.js:419:9)\n\n\nThe first line of the stack is actually a line from within the factory. The actual problem starts on the second line of the stack.\n\nI'm using WebStorm and the console window ever only shows the first line of the stack. You must scroll to get to the additional lines."
] | [
"javascript",
"node.js"
] |
[
"Python 3.x Short memory number guessing (Programming/Math)",
"(This could be both a programming problem and a mathematical problem but posting here first.)\n\nI've made a simple program that plays a guessing game between the computer and itself. It generates a number between 0 and 100 inclusive and then gets guesses from another function. The program works but is highly imprecise because the guessing function only knows the last guess and if it should guess higher or lower. (Right now it just randomizes an int between the last guess and the lowest/highest bound.)\n\nThe easiest solution would be with if-else but I would prefer a solution with as little conditionals as possible.\n\nI wonder if there is a way to make the guessing function gradually narrow the width of its guessing when it only knows its last guess, if it should guess higher or lower and the maximum and minimum bounds of the guess?\n\nCurrent code:\n\nimport random as rnd\ndef guess_me_computer(number = None, guess = 50, turns = 0, memory = []): \n \"\"\"Guessing game between two computers.\n\n Args:\n number: Number to be guessed\n guess: Guess made by computer\n turns: How many guesses made so far\n memory: List storing how many turns each run takes\n \"\"\"\n turns += 1\n\n if number == None:\n number = rnd.randint(0, 100)\n\n if guess == number:\n print(\"Correct! My number: {number} was guessed in {turns} tries!\".format(number = number, turns = turns))\n memory.append(turns) #Memory used in another testing function\n return None\n elif guess < number:\n print(\"Wrong! Guess Higher!\")\n guess_me_computer(number = number, guess = guesser_computer(last_guess = guess, higher = True), turns = turns, memory = memory)\n else:\n print(\"Wrong! Guess Lower!\")\n guess_me_computer(number = number, guess = guesser_computer(last_guess = guess, higher = False), turns = turns, memory = memory)\n\n\ndef guesser_computer(last_guess = None, higher = None):\n if higher:\n return rnd.randint(last_guess, 100)\n else:\n return rnd.randint(0, last_guess)\n\n\nAny and all questions about question itself and/or criticism about the writing are very welcome."
] | [
"python",
"python-3.x",
"function",
"math",
"recursion"
] |
[
"WARN Failed to send SSL Close message(Kafka SSL configuration issue)",
"I have done broker and client configuration on same node. \n\nWhen ssl.client.auth=none it works fine but whenever I change that property to \"required\", ssl.client.auth=required and enabled security.inter.broker.protocol=SSL then it gives me an issue on producer side. \n\n[2017-12-13 11:06:56,106] WARN Failed to send SSL Close message (org.apache.kafka.common.network.SslTransportLayer)\njava.io.IOException: Connection reset by peer\n at sun.nio.ch.FileDispatcherImpl.write0(Native Method)\n at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)\n at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)\n at sun.nio.ch.IOUtil.write(IOUtil.java:65)\n at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)\n at org.apache.kafka.common.network.SslTransportLayer.flush(SslTransportLayer.java:194)\n at org.apache.kafka.common.network.SslTransportLayer.close(SslTransportLayer.java:161)\n at org.apache.kafka.common.network.KafkaChannel.close(KafkaChannel.java:45)\n at org.apache.kafka.common.network.Selector.close(Selector.java:442)\n at org.apache.kafka.common.network.Selector.poll(Selector.java:310)\n at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:256)\n at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:216)\n at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:128)\n at java.lang.Thread.run(Thread.java:745)\n\n\nAny solution for this?"
] | [
"ssl",
"apache-kafka"
] |
[
"changing display property with jquery hover",
"I have pictures of different staff members and when the mouse hovers over the image I want display:none; to change to display:block; on the .staffInfo class. I feel like what I have should work, but nothing is happening. I have no console errors. This is an Angular project.\n\nHTML \n\n<div class=\"col-lg-12 staffBlock\">\n <div ng-repeat=\"people in staff\">\n <div class=\"col-lg-4 staffCards\">\n <img src=\"{{people.image}}\" alt=\"\" class=\"img-rounded img-responsive\">\n <div class=\"staffInfo\">\n <h3>Name:{{people.name}}</h3>\n <p>Likes:{{people.likes}}</p>\n </div>\n </div>\n </div>\n </div>\n\n\nSCSS\n\n.staffCards{\n margin-top:10px;\n .staffInfo{\n display:none;\n position:absolute;\n bottom:0px;\n height:100%;\n width:65%;\n border-radius:3%;\n background-color:black;\n opacity:.6;\n color:white;\n }\n}\n\n\njQuery\n\n$('.staffInfo').hover(function(){\n $(this).css('display', 'block');\n});"
] | [
"jquery",
"css",
"angularjs"
] |
[
"How to halt training process at some epoch after which the loss is not improving?",
"I'm trying to implement logistic regression in python, I want to halt the training process at the epoch beyond which the train and test error are not improving. I did the following:\ndef train(X_train,y_train,X_test,y_test,epochs,alpha,eta0):\n N = len(X_train)\n dim = X_train[0]\n w,b = initialize_weights(dim)\n for i in tqdm(range(epochs)):\n for x,y in zip(X_train,y_train):\n dw = gradient_dw(x,y,w,b,alpha,1)\n db = gradient_db(x,y,w,b)\n w = w + (eta0*dw)\n b = b + (eta0*db)\n \n train_prob=[sigmoid((np.dot(w.T,x))+b) for x in X_train]\n train_loss=logloss(y_train,train_prob)\n test_prob=[sigmoid((np.dot(w.T,x))+b) for x in X_test]\n test_loss=logloss(y_test,test_prob)\n \n return w,b,train_loss,test_loss\n\nI am able to get the losses at the end but i wish to stop at the epoch beyond which loss doesn't improve.\nHere initialize_weights(), gradient_dw(), gradient_dw(), sigmoid(), logloss() are defined methods."
] | [
"python",
"python-3.x",
"machine-learning",
"logistic-regression"
] |
[
"Application rotates incorrectly as of iOS 8.3",
"I updated to iOS 8.3 and suddenly the Simulator I'm using to debug my XCode/GLES app (iPad 2) is having trouble responding to mouse clicks in the rightmost portion of the screen.\n\nOur application's delegate class name points it to our AppDelegate which derives from UIViewController. Inside the AppDelegate's applicationDidFinishLaunching we then start creating windows - the top-level window being a UIWindow with its main child being a GLView. The application runs in landscape orientation.\n\nSome (possibly important) pieces of code:\n\nInfo.plist:\n Supported interface orientations\n Item 0: Landscape (right home button)\n\nint main(int argc, char *argv[]) // In main.m\n{\n int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));\n}\n\n@interface MyAppDelegate : UIViewController<UIApplicationDelegate>\n{\n ...\n}\n\n@implementation MyAppDelegate\n- (void)applicationDidFinishLaunching:(UIApplication *)application\n{\n [[UIApplication sharedApplication] setStatusBarHidden:YES]];\n [[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;\n\n CGRect boundingRectangle = CGRectMake(0, 0, 768, 1024);\n uIWindow = [[UiWindow alloc] initWithFrame:boundingRectangle];\n uIWindow.rootViewController = self; // <-- Added this\n [uIWindow setTransform:CGAffineTransformMakeRotation(DegreesToRadians(-90))]; // <-- Added this\n\n boundingRectangle = CGRectMake(0, 260.0, 800, 480);\n glViewWindow = [[GLView alloc] initWithFrame:boundingRectangle];\n [uiWindow addSubView:glViewWindow];\n [uiWindow makeKeyAndVisible];\n}\n@end\n\n\nFrom other stack overflow discussions, it appears the problem is related to the warning we always get \"Application windows are expected to have a root view controller at the end of application launch\". So we added the line \" uIWindow.rootViewController = self;\".\n\nThis causes the application to be rotated 90 degrees. The simulator is correctly in landscape mode, but the application is in portrait. So we added the \"setTransform\" line seen above. That rotated the window into the right orientation, but (1) it's offset down and to the left, and (2) none of the mouse clicks work at all anymore (completely unresponsive).\n\nAny ideas on what might be happening here? What can we try next?"
] | [
"ios",
"objective-c",
"xcode",
"ipad-2"
] |
[
"is it possible to fix a java script error from an external script",
"i use an external script from Air-bnb. The script causes an error in Internet Explorer. For Air bnb it is not possible to fix this script. Is there a possibility to fix it by my self? \n\nThis function is not supported by IE\n\nif(c.includes(r))return t\n\n\nOn this site i load the script via iframe:\n\nhttps://www.immvestwolf.de/rent-a-home-2\n\ni look forward to find a solution...\n\nThanks"
] | [
"javascript"
] |
[
"How can I add a folder to Petalinux-Image?",
"I want to add a folder (110MB) consisting of several sub-folders in my Petalinux.Image, but unfortunately I always get an error message when I run Petalinux-Build.\nHow can I solve the problem?\nThis is my .bb file:\nSUMMARY = "Simple myinit application"\nSECTION = "PETALINUX/apps"\nLICENSE = "MIT"\nLIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"\nSRC_URI = "file://myinit"\nSRC_URI += "file://openocd"\ninherit update-rc.d\nINITSCRIPT_NAME = "myinit"\nINITSCRIPT_PARAMS = "start 99 S ."\nS = "${WORKDIR}"\ndo_install() {\n# myinit is init daemon\ninstall -d ${D}${sysconfdir}/init.d\ninstall -m 0755 ${S}/myinit ${D}${sysconfdir}/init.d/myinit\n \n# my directory\ninstall -d ${D}/home/root/myfolder\ncp -r ${S}/openocd ${D}/home/root/myfolder\n\n}\nFILES_${PN} += "/home/root/myfolder"\nFILES_${PN} += "${sysconfdir}/*""
] | [
"yocto",
"rootfs",
"petalinux"
] |
[
"CouchBase extension install error",
"I use php and couchbase nosql database ,when i installed couchbase-ext on ubuntu i got an erorr like below in php -m command :\n\n PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/couchbase.so' - /usr/lib/php/20131226/couchbase.so: undefined symbol: _zend_hash_str_update in Unknown on line 0"
] | [
"php",
"ubuntu",
"couchbase"
] |
[
"Can I use wxPython wx.ItemContainer in a derived class?",
"I'm trying to make a new wx.Choice-like control (actually a replacement for wx.Choice) which uses the wx.ItemContainer to manage the list of items. Here is a minimal example showing the error:\n\nimport wx\nclass c(wx.ItemContainer):\n def __init__(my): pass\n\nx = c()\nx.Clear()\n\n\nThis fails with:\n\n\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"c:\\python25\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_core.py\", line 1178\n7, in Clear\n return _core_.ItemContainer_Clear(*args, **kwargs)\nTypeError: in method 'ItemContainer_Clear', expected argument 1 of type 'wxItemContainer *'\n\n\nThe other controls using ItemContainer seem to be internal to wxWindows, so it may not be possible for me to use it this way. However, it would certainly be convenient. \n\nAny ideas on what I'm doing wrong?"
] | [
"python",
"wxpython"
] |
[
"VBA Outlook Run-time error '438': Object doesn't support this property or method",
"I am trying to run this to macro to move an email attachment from a folder in my inbox (called toolkit downloads) into a folder on my desktop and rename the attachment. \n\nI get \n\n\n Run-time error '438': Object doesn't support this property or method\n\n\nSub OSP()\n\nDim oOutlook As Outlook.Application\nDim oNs As Outlook.NameSpace 'Main Outlook Today\nDim oFldrSb As Outlook.MAPIFolder 'Sub Folder in Outlook Today\nDim oFldrSbSb As Outlook.MAPIFolder 'Sub in Sub Folder\nDim oFldrSbSbsb As Outlook.MAPIFolder 'Sub in Sub in Sub Folder\n\nDim oMessage As Object\nDim sPathName As String\nDim oAttachment As Outlook.Attachment\nDim Ictr As Integer\nDim iAttachCnt As Integer\n\nsPathName = \"H:\\Desktop\\Toolkit Downloads\\\" 'My Folder Path where to save attachments\n\nSet oOutlook = New Outlook.Application\nSet oNs = oOutlook.GetNamespace(\"MAPI\")\nSet oFldrSb = oNs.Folders(\"[email protected]\")\nSet oFldrSbSb = oFldrSb.Folders(\"Inbox\")\nSet oFldrSbSbsb = oFldrSbSb.Folders(\"Toolkit Downloads\")\n\nFor Each oMessage In oFldrSbSbsb.Items\n\n With oMessage.Attachments \n iAttachCnt = .Count\n\n If iAttachCnt > 0 Then\n For Ictr = 1 To iAttachCnt\n .Item(Ictr).SaveAsFile sPathName _\n & .Item(Ictr).Parent\n Next Ictr\n End If\n End With\n\nDoEvents\n\nNext oMessage\n\nSaveAttachments = True\n\nMsgBox \"All Indepol Download files have been moved !!\" & vbCrLf & vbCrLf & \"It worked... Yahoo\"\n\nEnd Sub"
] | [
"vba",
"outlook"
] |
[
"Classified raster images extract infos loop in R",
"I have 800 classified raster images(7 classes) and each classes from one image needs to be calculated in squaremeters. So far it works with one image but not with the loop. What can I do to solve it?\n\nreport_files<-list(list of 800 tif files)\n for( i in report_files){\n reportfiles_single<-raster(report_files[i])\n df<-as.data.frame(table(reportfiles_single))\n df2<-as.data.frame(df$Freq*(0.070218*0.070218))\n {report_mean<- df2}\n}\n\n\nThis piece works for one-and there is an example file: https://ufile.io/rb7tj\n\na<-raster(\"test060707.tif\")\nval<-values(a)\ntable_val<-data.frame(val)\ndf<-as.data.frame(table(table_val))\ndf2<-as.data.frame(df$Freq*(0.070218*0.070218))"
] | [
"r",
"loops",
"for-loop",
"classification",
"r-raster"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.