texts
list | tags
list |
---|---|
[
"Height of cell taller than cell contents - view rendering issue",
"I have an odd problem I was hoping someone could perhaps explain. Searching yields nothing in this case.\n\nIf heightForRowAtIndexPath specifies a height which is taller than that of the contents drawn as a result of cellForRowAtIndexPath then upon scrolling, once the view refreshes its contents, it won't draw some of the cell contents that I've rendered (each row height is dynamic). However, if I reduce the row height somewhat, everything will be rendered correctly.\n\nIs there some documentation pertaining to this problem? Should heightForRowAtIndexPath always return the precise row height based on contents? For example, I just made the row heights rather large so I could always see the contents, but alas, cellForRowAtIndexPath wouldn't be called as many times as it should, and general rendering problems ensued.\n\nApologies for the fuzzy description, but perhaps those who have experienced the same problem could offer some insight.\n\nCheers."
]
| [
"ios",
"ios7"
]
|
[
"How to make R insert a '0' in place of missing values while reading a CSV?",
"We have a multi-column CSV file of the following format:\n\nid1,id2,id3,id4\n1,2,3,4\n,,3,4,6\n2,,3,4\n\n\nThese missing values are to be assumed as a '0' when reading the CSV column by column. The following is the script we currently have:\n\ndata <- read.csv(\"data.csv\")\n\ndfList <- lapply(seq_along(data), function(i) {\n seasonal_per <- msts(data[, i], seasonal.periods=c(24,168))\n best_model <- tbats(seasonal_per)\n fcst <- forecast.tbats(best_model, h=24, level=90)\n dfForec <- print(fcst)\n result <- cbind(0:23, dfForec[, 1])\n result$id <- names(df)[i]\n\n return(result[c(\"id\", \"V1\", \"V2\")])\n})\n\nfinaldf <- do.call(rbind, dfList)\nwrite.csv(finaldf, file = \"out.csv\", row.names = FALSE)\n\n\nThis script breaks when the CSV has missing values giving the error Error in tau + 1 + adj.beta + object$p : \n non-numeric argument to binary operator. How do we tell R to assume a '0' when it encounters a missing value?\n\nI tried the following:\n\nlibrary(\"forecast\")\nD <- read.csv(\"data.csv\",na.strings=\".\")\nD[is.na(D)] <- 0\n\ndfList <- lapply(seq_along(data), function(i) {\n seasonal_per <- msts(data[, i], seasonal.periods=c(24,168))\n best_model <- tbats(seasonal_per)\n fcst <- forecast.tbats(best_model, h=24, level=90)\n dfForec <- print(fcst)\n result <- cbind(0:23, dfForec[, 1])\n result$id <- names(df)[i]\n\n return(result[c(\"id\", \"V1\", \"V2\")])\n})\n\nfinaldf <- do.call(rbind, dfList)\nwrite.csv(finaldf, file = \"out.csv\", row.names = FALSE)\n\n\nbut it gives the following error:\n\nError in data[, i] : object of type 'closure' is not subsettable"
]
| [
"r",
"csv"
]
|
[
"Is it possible to run dhclient from C code without using system()?",
"I am going to write an application that will be able to manage Internet connection. Is it possible to run and stop dhclient from C code without using system() function?"
]
| [
"c",
"linux",
"networking",
"dhcp",
"dhclient"
]
|
[
"How to squash merged commits into one?",
"I have a git history like this:\n\nmaster branch:\n\n* 0001: lastest commit\n* 0002: commit1\n* 0003: commit2\n* 0004: Merge commit\n \\\n * 1001: aa\n * 1002: bb\n * 1003: cc\n /\n* 0005: commit3\n* 0006: commit4\n* 0007: Merge commit\n* \\\n * 2001: aa\n * 2002: bb\n * 2003: cc\n /\n* \n....\n\n\n\nI want to squash 1001~1003 into one commit, and 2001~2003 into one commit, and other merge commits into one commit\n\nI tried git rebase first-commit and try to squash 1001~1003, etc, it's very hard and never successes.\n\nIs there some command like git squash master 1001..1003, which means squash 1001 to 1003 into one commit in master branch?"
]
| [
"git"
]
|
[
"Is there the ability to store encrypted data on a desktop app created with tideSDK?",
"I have searched but couldn't find anything. We need to be able to store data offline in our desktop app and we are looking for cross-platform solutions. TideSDK looks promising but I am not sure if it has this functionality."
]
| [
"encryption",
"tidesdk"
]
|
[
"How to stop to close the JDialog when esc key is press",
"how i can stop JDialog to close to close when the Esc key is press. i want keep it as it is.\ni have already tried the dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); but this is not working on Esc key"
]
| [
"java",
"swing",
"jdialog"
]
|
[
"Unit testing examples for APIs in Django Rest Framework for GET and DELETE",
"I am using Django Rest Framework and I am trying to write the unit tests for api methods inside views.py file.Here is http://www.django-rest-framework.org/api-guide/testing/#example given a example But I have no idea to write unit tests for api views with GET and DELETE\nHere are my api views:\n\nviews.py\n\n@api_view(['GET'])\ndef getAllCustomers(request):\n if request.method == 'GET':\n k = Customer.objects.all()\n serializer = CustomerSerializer(k, many=True)\n return Response(serializer.data)\n\n\n@api_view(['DELETE'])\ndef deleteCustomer(request, pk):\n try:\n k = Customer.objects.get(pk=pk)\n except Customer.DoesNotExist:\n return HttpResponse(status=404)\n\n if request.method == 'DELETE':\n k.delete()\n return Response(status=status.HTTP_204_NO_CONTENT)\n\n\nURLS.PY\n\nurl(r'^Customer/$', getAllCustomers, name='getAllCustomers'),\nurl(r'^Customer/del/(?P<pk>[0-9]+)$', deleteCustomer, name='deleteCustomer'),\n\n\nThanks To All!"
]
| [
"django",
"unit-testing",
"django-rest-framework"
]
|
[
"ImportError: No module named functools_lrc_cache (discord.py bot)",
"I'm trying to set up a Discord modmail bot and host it on my Raspberry Pi, however I seem to be getting a traceback error that ends with ImportError: No module named functools_lrc_cache. I'm using Python 3.7 and pipenv to run the bot.py file. What could I do to resolve it?\nHere below is the full Traceback error and the steps I'm following for selfhosting the bot: https://taaku18.github.io/modmail/local-hosting/\nTraceback (most recent call last):\n File "/home/pi/.local/bin/pipenv", line 10, in <module>\n sys.exit(cli())\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 829, in __call__\n return self.main(*args, **kwargs)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 782, in main\n rv = self.invoke(ctx)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1236, in invoke\n return Command.invoke(self, ctx)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke\n return ctx.invoke(self.callback, **ctx.params)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke\n return callback(*args, **kwargs)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func\n return ctx.invoke(f, obj, *args, **kwargs)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke\n return callback(*args, **kwargs)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func\n return f(get_current_context(), *args, **kwargs)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/cli/command.py", line 204, in cli\n clear=state.clear,\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/core.py", line 580, in ensure_project\n pypi_mirror=pypi_mirror,\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/core.py", line 498, in ensure_virtualenv\n python = ensure_python(three=three, python=python)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/core.py", line 388, in ensure_python\n path_to_python = find_a_system_python(python)\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/core.py", line 347, in find_a_system_python\n from .vendor.pythonfinder import Finder\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/pythonfinder/__init__.py", line 10, in <module>\n from .models import SystemPath, WindowsFinder\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/pythonfinder/models/__init__.py", line 11, in <module>\n from ..utils import KNOWN_EXTS, unnest\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/pythonfinder/utils.py", line 17, in <module>\n from .compat import Path, lru_cache, TimeoutError # noqa\n File "/home/pi/.local/lib/python2.7/site-packages/pipenv/vendor/pythonfinder/compat.py", line 15, in <module>\n from backports.functools_lru_cache import lru_cache # type: ignore # noqa\nImportError: No module named functools_lru_cache"
]
| [
"python",
"raspberry-pi",
"discord.py"
]
|
[
"Using refresh token with Google directory service API",
"Is there any way to use a refresh token with Google directory service API?\nI couldn't find any examples how to do that (I'm using Python).\nI'm looking for something similar to the following code (this works for Google Adwords API), with previosly set credentials:\n\noauth2_client = oauth2.GoogleRefreshTokenClient(\n CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)\n\nadwords_client = adwords.AdWordsClient(\n DEVELOPER_TOKEN, oauth2_client, USER_AGENT, CLIENT_CUSTOMER_ID)\n\nself.managed_customer_service = adwords_client.GetService(\n 'ManagedCustomerService', version='v201402')\n\n\nFor Directory API I found just the following code snippet, but I have no idea how I could use a refresh token with it:\n\nflow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)\nauthorize_url = flow.step1_get_authorize_url()\nprint 'Go to the following link in your browser: ' + authorize_url\ncode = raw_input('Enter verification code: ').strip()\ncredentials = flow.step2_exchange(code)\n\n# Create an httplib2.Http object and authorize it with our credentials\nhttp = httplib2.Http()\nhttp = credentials.authorize(http)\n\nself.directory_service = build('admin', 'directory_v1', http=http)\n\n\nMy final goal is to authorize my application using just the refresh token and without having to open the browser, login and get a new token each time."
]
| [
"python",
"google-api",
"google-admin-sdk",
"google-directory-api"
]
|
[
"How to use preciseDiff from readable-range.js Plugin",
"I am using Dynamic CRM 2013 and need to calculate date difference between 2 dates. I added to the form moment.js and readable-range.js.\n\nAll functions in moment.js are working fine. When it comes to preciseDiff from readable-range.js and use:\n\nvar bDt = new moment(\"2/22/2009\");\nvar eDt = new moment(\"2/29/2016\");\nvar dtDiff = moment.preciseDiff(bDt, eDt);\n\n\nI am getting the following error:\nObject doesn't support property or method 'preciseDiff'\n\nPlease advise."
]
| [
"javascript",
"momentjs"
]
|
[
"Laravel updateExistingPivot get column own value",
"I want to update a pivot column, but I need to access its own value\n\nis there a way to access it, here is the code and the operation that I need to perform:\n\n(supply_early's value - $winner_tender_volume)\n\n$config_team_product->supplies()->updateExistingPivot($tender->year_id, [\n 'supply_early' => \"here I need supply_early's column value\" - $winner_tender_volume\n]);"
]
| [
"laravel"
]
|
[
"utl_file.put_line not working",
"I need to generate a XML and write it to a file.\nI have used utl_file.put_line. It creates the file, but nothing is written into it. Also, it shows no errors.\nI've already checked if I have the permissions to write on the directory.\nCode:\n\nSET serveroutput ON;\nDECLARE\n ctx DBMS_XMLGEN.CTXHANDLE;\n resposta CLOB;\n xml_file utl_file.file_type;\nBEGIN\n xml_file:=utl_file.fopen ('DATA_PUMP_DIR', 'xml.txt', 'W');\n ctx := dbms_xmlgen.newContext ('select * from tb_museu M where M.cnpj=111111 OR M.cnpj=222222');\n dbms_xmlgen.setRowsetTag (ctx, 'TODOS_OS_MUSEUS');\n dbms_xmlgen.setRowTag (ctx, 'MUSEU');\n resposta :=dbms_xmlgen.getXML (ctx);\n utl_file.put_line (xml_file,'teste');\n --utl_file.put_line (xml_file,resposta);\n dbms_xmlgen.closeContext(ctx);\nEND;\n/"
]
| [
"oracle10g",
"utl-file"
]
|
[
"Finding view of an icon in overflow menu",
"I am trying to findview of an overflow icon. After clicking and opening the overflow icon, I tried using in onoptionsitemselected:\n\nView view = getActivity().findViewById(R.id.menu_tag); // null\nView view = getActivity().findViewById(R.id.mainMenu); // not null.\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\nxmlns:app=\"http://schemas.android.com/apk/res-auto\">\n\n<item\n android:id=\"@+id/mainMenu\"\n android:title=\"@string/text\"\n android:orderInCategory=\"101\"\n android:icon=\"@drawable/ic_more_vert_white_24dp\"\n app:showAsAction=\"always\">\n <menu>\n\n <item\n android:id=\"@+id/menu_tag\"\n android:icon=\"@drawable/tag_32\"\n app:showAsAction=\"always|withText\"\n android:title=\"@string/tags\"/>\n <item\n android:id=\"@+id/menu_profile\"\n android:icon=\"@drawable/user_32\"\n app:showAsAction=\"always|withText\"\n android:title=\"@string/profile\"/>\n <item\n android:id=\"@+id/menu_debug\"\n android:icon=\"@drawable/insect_32\"\n app:showAsAction=\"always|withText\"\n android:title=\"@string/debug\"/>\n </menu>\n</item>\n</menu>\n\n\nIt is giving me null but working fine for actionbar items."
]
| [
"android",
"toolbar",
"menuitem"
]
|
[
"How to get data from txt file in python log analysis?",
"I am beginner to python, I am trying to do log analysis, but I do not know how to get the txt file.\n\nThis is the code for outputting date, but these dates must be taken from the txt file :\n\nimport sys\nimport re\n\nfile = open ('desktop/trail.txt')\n\nfor line_string in iter(sys.stdin.readline,''):\n line = line_string.rstrip()\n date = re.search(r'date=[0-9]+\\-[0-9]+\\-[0-9]+', line)\n date = date.group()\n print date"
]
| [
"python",
"analytics",
"log-analysis"
]
|
[
"How to link from html site to any site in view in Ruby on Rails",
"I have got my main page in project_name/public/index.html. I want to link from index.html site to controller view located in project_name/app/views/my_controller\n\nHow can I recive that?"
]
| [
"html",
"ruby-on-rails"
]
|
[
"how to remove unnecessary margins from toolbar",
"I have this layout I have already added app:contentInset but its not removing left and right margins to tool bar. Any idea how to remove this margins.\n\n<android.support.v7.widget.Toolbar\n android:id=\"@+id/toolbar\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_alignParentTop=\"true\"\n android:background=\"@color/back_transparent\"\n app:contentInsetEnd=\"0dp\"\n app:contentInsetLeft=\"0dp\"\n app:contentInsetRight=\"0dp\"\n app:contentInsetStart=\"0dp\"\n app:layout_collapseMode=\"pin\"\n android:visibility=\"invisible\"\n app:layout_scrollFlags=\"scroll|exitUntilCollapsed\"\n app:popupTheme=\"@style/ThemeOverlay.AppCompat.Light\">"
]
| [
"android",
"xml"
]
|
[
"Vue.js: _this is not defined at eval -- Java Spring backend json request",
"Vue.js:\n\ncreated() {\n axios.get('/people')\n .then((response) => {\n this.people = response._embedded.data.people\n })\n .catch((error) => {\n console.log(error)\n })\n },\n\n\nGET request response according to chrome network: https://pastebin.com/bDmKQFgB\n\nConsole log:\n\nerror\nApp.vue?234e:298 ReferenceError: _this is not defined\nat eval (App.vue?234e:294)\n\n\nThe second line comes from the catch() part.\n\nWhere the json comes from: Java Spring Backend with mongodb like: https://spring.io/guides/gs/accessing-mongodb-data-rest/"
]
| [
"java",
"json",
"spring",
"vue.js",
"get-request"
]
|
[
"Is it possible to convert an avi file to mp4 in real time?",
"I have an AVI file that I would like to be played inside Flowplayer. I understand it uses HTML5 which requires movie files to be converted to MP4/OGV, so I was wondering if there was a framework that exists which will convert an AVI file to an MP4 file in real-time (and without necessarily being stored on the server)\n\n...the more I think about this, the more I'm beginning to think this isn't possible. Please prove me wrong."
]
| [
"html"
]
|
[
"Getting temperature difference between intervals",
"my question is more \"theoretical\" than practical - in other words, Im not really looking for a particular code for how to do something, but more like an advice about how to do it. Ive been thinking about it for some time but cannot come up with some feasible solution.\nSo basically, I have a MySQL database that saves weather information from my weather station. \n\nColumn one contains date and time of measurement (Datetime format field), then there is a whole range of various columns like temp, humidity etc. The one I am interested in now is the one with the temperature. The data is sorted by date and time ascending, meaning the most recent value is always inserted to the end. \n\nNow, what I want to do is using a PHP script, connect to the db and find temperature changes within a certain interval and then find the maximum. In other words, for example lets say I choose interval 3h. Then I would like to find the time, from all the values, where there was the most significant temperature change in those 3 h (or 5h, 1 day etc.). \n\nThe problem is that I dont really know how to do this. If I just get the values from the db, Im getting the values one by one, but I cant think of a way of getting a value that is lets say 3h from the current in the past. Then it would be easy, just subtracting them and get the date from the datetime field at that time, but how to get the values that are for example those 3 h apart (also, the problem is that it cannot just simply be a particular number of rows to the past as the intervals of data save are not regular and range between 5-10mins, so 3 h in the past could be various number of rows).\n\nAny ideas how this could be done? \n\nThx alot"
]
| [
"php",
"mysql",
"intervals"
]
|
[
"Facebook Comment widget returns \"Content no longer available\"",
"Following the upgrade from Graph 1.0 to Graph 2.0 the comment widgets have stopped working for me, returning the following JSON response following any attempt to post a comment:\n\n{\n bootloadable: {}\n error: 1357031\n errorDescription: \"The content you requested cannot be displayed right now. It may be temporarily unavailable, the link you clicked on may have expired, or you may not have permission to view this page.\"\n errorSummary: \"This content is no longer available\"\n ixData: {}\n lid: \"0\"\n payload: null\n}\n\n\nI've been through the steps so far of regenerating the comment code, making sure the comment block code itself is set to use version 2.3 (as well as trying without this just to be safe). The error code itself doesn't return anything in the FB docs, and the only reference I can find to the error description is from 2 years ago to which FB noted that it was a server issue. Given that our comments have been broken (and thus hidden) for 2 months now I don't think that's the problem.\n\nI've confirmed that the code pulls in sdk.js rather than all.js using the code they provide and I just can't seem to get it to work. Any help would be appreciated!"
]
| [
"facebook-graph-api",
"facebook-javascript-sdk"
]
|
[
"HBase client thread stuck waiting on HBaseClient.call()",
"I have a standalone instance of HBase (single instance, on localhost, no Hadoop).\n\nAfter reading a few thousand records using a scanner my thread gets stuck waiting, always on the same record. \n\nAdditionally if I run count 'table' from the hbase shell it also get's stuck, at about record 10k.\n\nhbase(main):001:0> count 'cache'\n\n\nThere are no errors, or anything unusual in the HBase logs.\n\nIn both instances the client thread in the HBase server is stuck waiting:\n\n\"main\" prio=10 tid=0x0000000001102000 nid=0xbd1 in Object.wait() [0x00007f8e9088f000]\n java.lang.Thread.State: WAITING (on object monitor)\n at java.lang.Object.wait(Native Method)\n at java.lang.Object.wait(Object.java:503)\n at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:757)\n\n\nAny clues?"
]
| [
"java",
"hbase"
]
|
[
"Error while converting text to QR code",
"I am trying to create a text to QR code converter.\n\nI used the core2.2.jar from http://code.google.com/p/zxing/downloads/list and the code as told in Integrating the ZXing library directly into my Android application. \n\nMy Main.Activity is as shown below\n\npackage com.example.qr_androidone;\n\nimport com.google.zxing.BarcodeFormat;\nimport com.google.zxing.WriterException;\n\nimport android.os.Bundle;\nimport android.app.Activity;\nimport android.graphics.Bitmap;\nimport android.view.Menu;\nimport android.widget.ImageView;\n\npublic class MainActivity extends Activity {\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n //super.onCreate(savedInstanceState);\n //setContentView(R.layout.activity_main);\n ImageView imageView = (ImageView) findViewById(R.id.qrCode);\n\n String qrData = \"Data I want to encode in QR code\";\n int qrCodeDimention = 500;\n\n QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrData, null,\n Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimention);\n\n try {\n Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();\n imageView.setImageBitmap(bitmap);\n } catch (WriterException e) {\n e.printStackTrace();\n }\n }\n\n @Override\n public boolean onCreateOptionsMenu(Menu menu) {\n // Inflate the menu; this adds items to the action bar if it is present.\n getMenuInflater().inflate(R.menu.main, menu);\n return true;\n }\n\n}\n\n\nI used the \"Contents.java\" and \"QRCodeEncoder.java\" as shown in link Integrating the ZXing library directly into my Android application. I changed \"activity_main.xml\" also , as shown in above link\n\nThere are no errors in compiling, but there is error when the app runs\n\n\n Could not find class 'com.google.zxing.EncodeHintType', referenced\n from method com.example.qr_androidone.QRCodeEncoder.encodeAsBitmap\n \n Could not find class 'com.google.zxing.MultiFormatWriter', referenced\n from method com.example.qr_androidone.QRCodeEncoder.encodeAsBitmap\n \n java.lang.NoClassDefFoundError: com.google.zxing.BarcodeFormat\n\n\nPlease help me solve the error"
]
| [
"android",
"barcode"
]
|
[
"Angular httpclient CORS request returns 404 error",
"I started a sample Angular application that runs on 127.0.0.1:4200 (PC A), I started a web browser at the same computer and everything works fine.\n\nIn the application, there is a heroService.ts that calls this.http.get etc to get the data from 127.0.0.1:4200.\n\nI then started another http server using nodejs express which provides some API services, the IP is 192.168.2.101:3000 (PC B). The api is perfectly fine because I can run it in any web browser and see the results (all in json). In nodejs express, I installed cors too and use app.use(cors()) to enable CORS support.\n\nThe following is where the problem is.\n\nI followed heroService.ts in PC A, and created apiService.ts, and use this.http.get(\"http://192.168.2.101:3000\").subscribe(_=>console.log(\"ok\")); to call the API at PC B (PC B should already have cors enabled).\n\nHowever, it seems that Angular running at browser cannot identify this address, and in browser's debug window, I can see 404 error, http://192.168.2.101:3000 cannot be found. Note that the same url http://192.168.2.101:3000 works perfectly in web browser directly.\n\nThe weird thing is that in the browser's (chrome and edge) network debug window, I could not see any request was sending out, there's no such request sent to the server. And at the nodejs's server side, I tried to log any connections and I could not see any too. It seemed to me that the web browser didn't send this http get out, and the angular library returned 404 directly.\n\nI tried to search the same error but could not find anything useful.\n\nI would guess that Angular's library will keep using the base url (127.0.0.1:4200) and will not parse http://192.168.2.101:3000 ? Is there a way to solve it?\n\nI hope I explained the problem clearly.\n\nThanks for help."
]
| [
"node.js",
"angular",
"typescript",
"cors"
]
|
[
"Does iteratee I/O make sense in non-functional languages?",
"In Haskell, Iteratee based I/O seems very attractive. Iteratees are a composable, safe, fast ways of doing I/O inspired by the 'fold' a.k.a. 'reduce' function in functional languages. \nBasically, if you have a traversal the idea is to encapsulate the traversal state into a so-called \"enumerator\" who calls the \"iteratee\" which is in turn a function either returning a value or a request for more data along with a continuation for the enumerator to call. So only the enumerator knows the state of the traversal while the iteratee knows what to do with the data and builds values out of it. The nice thing about it is that iteratees are automatically composable, where output of one iteratee is fed to another to make a bigger one.\n\nSo, two questions: \n\n\nDoes the concept even make sence in other languages, like plain object oriented languages or is it only useful for overcoming the shortcomings of Haskell's lazy I/O?\nAre there any actual implementations for other languages, especially C# (as that is what my company uses)? (A google search turns up one mention of iteratees in Scala; well, I'm not that interested in Scala right now)."
]
| [
"c#",
"haskell",
"iteration"
]
|
[
"jquery - referencing a jquery object",
"So I'm using the ui library, and I have something like:\n\n$('#trash-bin').droppable({\n tolerance: 'touch',\n drop: function(event, ui) {\n alert(ui.draggable.id + \" was dropped\");\n }\n });\n $('#images').draggable({});\n\n\nWhich I know is wrong (the alert says \"undefined dropped\")\n\nHow can I reference the image's id that was dropped?"
]
| [
"jquery",
"jquery-ui"
]
|
[
"Numbering bars in Pine editor",
"How do I number bars in trading view pine editor? For example for an intraday chart of 15mins how can I number the first opening candle as number 1 and second 15min candle as number 2 and so on?"
]
| [
"pine-script",
"candlestick-chart"
]
|
[
"prefix or postfix operation on c pointer",
"#include<stdio.h>\nvoid increment(int *p) {\n*p = *p + 1;\n}\nvoid main() {\nint a = 1;\nincrement(&a);\nprintf(\"%d\", a);\n}\n\n\nfor above if I run above code it prints 2\nbut if I replace *p = *p + 1; with *p++;\nit is printing 1.Why is it so?..."
]
| [
"c",
"pointers"
]
|
[
"Conditional load Angular2",
"I need make redirect to login page, before load Angular2 application(without loading it).\nMy project is based on angular2-quicksart\n\nWhen I load angular2 js file after uglifyjs\n\n<script>\n var cookie = $.cookie(COOKIE_NAME);\n if (cookie == undefined){\n window.location.href = LOGIN_SERVER_URL\n } else {\n var head = document.getElementsByTagName('head')[0];\n var script = document.createElement('script');\n script.src = \"build/app/bundle.min.js\";\n head.appendChild(script);\n head.innerHTML += (\"<script>System.import('app').catch(function(err){ console.error(err); }); <\\/script>\");\n }\n</script>\n\n\nThis solution works. JS was loaded and application is running.\n\nWhen I use systemjs file to load Angular app, systemjs.config.js was loaded, but app doesn't run.\n\n`script.src = \"systemjs.config.js\";\n\nCan I load systemjs dynamically?"
]
| [
"javascript",
"html",
"angular",
"systemjs"
]
|
[
"Bouncy Castle and WebPush: NoSuchMethodError: org.bouncycastle.math.ec.ECCurve$Fp",
"I'm trying to extend and existing web app (I don't have control of) with a jar extension to add push notification feature. I tried to follow the instructions here:\n\nhttps://github.com/web-push-libs/webpush-java/wiki/Usage-Example\n\nBut when BouncyCastle comes into play I'm getting the following exception:\n\njava.lang.NoSuchMethodError: org.bouncycastle.math.ec.ECCurve$Fp.<init>(Ljava/math/BigInteger;Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n\n\nwhile processing nl.martijndwars.webpush.Utils.loadPublicKey(String) method.\n\n public static PublicKey loadPublicKey(String encodedPublicKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException {\n byte[] decodedPublicKey = Base64Encoder.decode(encodedPublicKey);\n KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM, PROVIDER_NAME);\n ECParameterSpec parameterSpec = ECNamedCurveTable.getParameterSpec(CURVE);\n ECCurve curve = parameterSpec.getCurve();\n ECPoint point = curve.decodePoint(decodedPublicKey);\n ECPublicKeySpec pubSpec = new ECPublicKeySpec(point, parameterSpec);\n\n return keyFactory.generatePublic(pubSpec);\n}\n\n\nThe return-line then throws the exception.\nThe spi instance of the keyFactory is \"org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi$ECDH@5a15f280\" which also seems right...\n\nIm using the jar via maven. \"Luckily\" the parent web application brings BouncyCastle on it's own in Version 1.54. That's the dependency in the web apps pom.xml\n\n <dependency>\n <groupId>org.bouncycastle</groupId>\n <artifactId>bcprov-jdk15on</artifactId>\n <version>1.54</version>\n </dependency>\n\n\nWhich actually should exactly match the library's version (e.g. https://github.com/web-push-libs/webpush-java/blob/master/build.gradle)\n\nAnd when I call java.security.Security.getProviders() I'm getting a list that already contains 'BCFIPS version 1.01, BC version 1.54', which is because the parent application already provides it during runtime.\n\nWhen checking out the sources (http://javadox.com/org.bouncycastle/bcprov-jdk15on/1.53/org/bouncycastle/math/ec/ECCurve.Fp.html for instance) the constructor exists.\n\nI also tried to remove and add the BouncyCastleProvider from java.security.Security before executing the code.\n\nEDIT#1:\n\nI've made some progress in understanding the issue. I noticed that the web-server jre has a external library (bc-fips-1.0.1.jar) which seems to bring another implementation of org.bouncycastle.math.ec.ECCurve$Fp. This jar also seems to be the reason for the 'BCFIPS version 1.01' security provider.\n\nBy calling keyFactory.generatePublic(pubSpec) is seem that the KeyFactory somehow (classloading issue I guess) uses the other version ECCurve$Fp that really does not have the constructor from the error message.\n\nEDIT#2:\n\nI've debugged a while and could proof my theory. The WepAppClassloader picks the class from the lib-folder (which is the wrong one). Now I've tried somehow to preload the correct class for the right jar. But this does not seems to work.\n\nEDIT#3:\n\nThe final solution for me was to repackage the bouncy castle lib. Not nice but I had no ideas anymore."
]
| [
"java",
"bouncycastle"
]
|
[
"Is it possible to search buttons that contain certain aria-label text with screen readers?",
"For example I have <button aria-label=\"Play video\">+</button> on a page. How do I search with screen readers for a element containing \"play video\" on the page? Is there a better way? \n\nI'm trying to understand if there's a way for screen readers to \"jump\" to a part of the page, ie search for an element."
]
| [
"html",
"accessibility",
"wai-aria"
]
|
[
"Requests & Pandas in Google Cloud",
"I have a rest API that I want to call using python and requests. The outputs come through in json. I either want to write them to google cloud storage and schedule a big query job to run on top.\nOR and this is by far my preferred route, I would like to run pandas on top of them and just write to CSV that can be visualised in Google Data Studio.\nCan someone help with the best way to architect this? What google services should I be looking at?"
]
| [
"pandas",
"google-cloud-functions",
"visualization",
"serverless"
]
|
[
"adwhirl house ads for iPad",
"I have an app in which I show advertisement and to do so I'm using adWhirl. But my app is universal. I found out how to show iAd and Admob there, but I also need to show house ads. I'm looking for a solution of showing house ads for iPad using adWhirl. Does anybody have any idea how to manage that?"
]
| [
"ipad",
"adwhirl"
]
|
[
"How Do I Separate Two Overlapping Bitmaps From Each Other",
"I am having a trouble about my 2 bitmaps in my game. They're overlapping each other and I dunno how to separate them. Any ideas guys?\n\nHere's the screenshot of my game.The one that is highlighted in a box is my object that are overlapping. \n\nThen it's my code for my Game.\n\n// taya\n kspeed = kspeed - 20;\n int height = taya.getHeight() & spikeweed.getHeight();\n canvas.drawBitmap(taya, kspeed, (15 * sy / 19) - height / 2, null);\n if (kspeed < 0) {\n kspeed = sx;\n health -= 25;\n } \n int width = spikeweed.getHeight();\n canvas.drawBitmap(spikeweed, kspeed, (15 * sy / 17) - height / 2, null);\n if (kspeed < 0) {\n kspeed = sx;\n health -= 25;\n }\n\n\nWhere \"sy\" that is indicated in my code is \"sy\" = display.getHeight(), \"kspeed\" = x/4 and \"x\" = 0\n\nTaya and Spikeweed are my two objects."
]
| [
"java",
"android",
"eclipse",
"bitmap"
]
|
[
"Restoring data without recreating MySQL Tables",
"This may sounds like a stupid question but can't find anything on google, probably using the wrong key words.\n\nAnyway, I have been working on a project - version 1 which has a MySQL Database. I ready to release to version 2 but there are changes to the database tables, e.g. extra columns. \n\nIf I backup the current database with the data and create a database with the new structure. How can I add the data from the old database into the new database. \n\nI know there won't be any problems with the existing data being added to the new database structure as the existing fields haven't changed, its just extra columns.\n\nThanks for your help."
]
| [
"mysql"
]
|
[
"CloudSQL close idle connections",
"I want to create an instance in cloudSQL. I am a google app engine with PHP. I would like to know about idle connections, and how much I will be charged. It says that idle connections will be active for around 12 hours. I dont want that to happen. Right now , my script looks like this:\n\n<?php\ninclude 'database.php'; //connects to the database\n while($time<60)\n {\n\n if(any new messages) {\n die (new messages) \n }\n\n\n\n sleep(1);\n $time++;\n\n }\n\ndie(no new messages);\n\n\nThere is no place where I am running mysqli_close here. so even if this script stops executing, am I still going to be charged money ? if so, what should I do to shut down the cloudsql instance when not in use ?"
]
| [
"php",
"mysql",
"google-app-engine",
"google-cloud-sql"
]
|
[
"iOS app development for a classic bluetooth device",
"We are developing an android and ios mobile app for a hardware device. We have to read files generated from the device and move it to mobile app. The device is not a low energy device. It's a Bluetooth 2.1. Currently, we are unable to pair the device with the iPhone. \nWe need to understand is there any restriction to connect the iphone with classic Bluetooth devices? Does the manufacture need to register under MFI? Can we use some developer license/API to start developing the app and later we go for MFI?\n\nCan you please help me with this?"
]
| [
"ios",
"iphone",
"bluetooth",
"core-bluetooth",
"mfi"
]
|
[
"How do I use array_map to also specify keys?",
"Using the canonical PHPdoc example, this code:\n\n<?php\nfunction cube($n)\n{\n return($n * $n * $n);\n}\n\n$a = array( 3, 4, 5);\n$b = array_map(\"cube\", $a);\nprint_r($b);\n?>\n\n\noutputs\n\nArray\n\n(\n [0] => 27\n [1] => 64\n [2] => 125\n)\n\n\nBut what I really want it to output is something along these lines:\nArray\n\n(\n [3] => 27\n [4] => 64\n [5] => 125\n)\n\n\nThat is, I want the array_map to use the same keys as in the original array. Is there any way to do that? Thanks!"
]
| [
"php"
]
|
[
"Grouping items by match set",
"I am trying to parse a large amount of configuration files and group the results into separate groups based by content - I just do not know how to approach this. For example, say I have the following data in 3 files:\n\n\nconfig1.txt\nntp 1.1.1.1\nntp 2.2.2.2\n\nconfig2.txt\nntp 1.1.1.1\n\nconfig3.txt\nntp 2.2.2.2\nntp 1.1.1.1\n\nconfig4.txt\nntp 2.2.2.2\n\n\n\nThe results would be:\nSets of unique data 3:\nSet 1 (1.1.1.1, 2.2.2.2): config1.txt, config3.txt\nSet 2 (1.1.1.1): config2.txt\nSet 3 (2.2.2.2): config4.txt\n\n\nI understand how to glob the directory of files, loop the glob results and open each file at a time, and use regex to match each line. The part I do not understand is how I could store these results and compare each file to a set of result, even if the entries are out of order, but a match entry wise. Any help would be appreciated.\n\nThanks!"
]
| [
"python"
]
|
[
"Sql query to find Id tagged to multiple rows",
"I have a student table with the below structure.\n\nStudentId StudentName SubjectId\n 123 Lina 1\n 456 Andrews 4\n 123 Lina 3 \n 123 Lina 4\n 456 Andrews 5\n\n\nNeed to write a query to get the studentId where the subjectid is equal to 1,3 and studentid is not equal to 4\n\nSelect studentId from student where subject Id='1' and SubjectId ='3' and \nsubjectId ='4' .\n\n\nOutput studentId should be 123\n\nBut it does not work out. Any help is appreciated"
]
| [
"mysql",
"sql",
"oracle10g"
]
|
[
"save image in gallery android",
"I am using this code to save the image:\n\nURL url = null;\n try {\n url = new URL(\"image\");\n } catch (MalformedURLException e1) {\n e1.printStackTrace();\n }\n Bitmap bmp = null;\n try {\n bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());\n } catch (IOException e1) {\n e1.printStackTrace();\n }\n OutputStream output;\n File filepath = Environment.getExternalStorageDirectory();\n File dir = new File(filepath.getAbsolutePath() + \"/folder name/\");\n dir.mkdirs();\n File file = new File(dir, image + \".png\");\n Toast.makeText(HomeActivity.this, \"Image Saved to SD Card\", Toast.LENGTH_SHORT).show();\n try {\n\n output = new FileOutputStream(file);\n bmp.compress(Bitmap.CompressFormat.PNG, 100, output);\n output.flush();\n output.close();\n\n }\n\n catch (Exception e) {\n e.printStackTrace();\n }\n\n\nThe issue is when this code runs on lollipop devices, Images are not showing in gallery. I have to install File Manager to check these images.\n\nWith this code:\n\n MediaStore.Images.Media.insertImage(getContentResolver(), bmp, \"image\";\n\n\nImages are saved in camera folder.\n\nI want to show images in gallery with a specific folder name in all android devices.\n\nPlease help."
]
| [
"android",
"gallery"
]
|
[
"Google Dfp (Doubleclick For Publishers) for UWA (Windows 10)",
"I'm working on a Universal Windows Application (UWP / Windows 10) and need to integrate Doubleclick For Publishers (Dfp), but not getting very far. \n\nI've looked at the the open source libraries on github to try and see if I could re-build the required dlls as a universal application library, but it seems many of the libraries/dependencies used are not available when targeting the UWP target.\n\nHow can I integrate Dfp into a Windows 10 app?"
]
| [
"c#",
"win-universal-app",
"windows-10",
"google-dfp"
]
|
[
"why $gt operator does not work without $expr in this case?",
"let criteria={\n $and:[\n {vendorId:req.userData._id},\n {status:APP_CONSTANT.STATUS.ACTIVE},\n {$gt:['$createdAt',{$toDate:{$subtract:[new Date(),1000*60*60*24*days]}}]}\n ]\n}\n\nthat query does not work and gives this error:\nMongoError: unknown top-level operator: $gt\nbut we add $expr then that is working, I don't understand why?\nlet criteria={\n $and:[\n {vendorId:req.userData._id},\n {status:APP_CONSTANT.STATUS.ACTIVE},\n {$expr:{$gt:['$createdAt',{$toDate:{$subtract:[new Date(),1000*60*60*24*days]}}]}}\n ]\n}\n\nand also one query without $and that does not work, why?\nlike this:\nlet criteria={\n vendorId:req.userData._id,\n status:APP_CONSTANT.STATUS.ACTIVE,\n $expr:{$gt:['$createdAt',{$toDate:{$subtract:[new Date(),1000*60*60*24*days]}}]}\n}\n\nand my overall query is that:\nlet criteria={\n $and:[\n {vendorId:req.userData._id},\n {status:APP_CONSTANT.STATUS.ACTIVE},\n {$expr:{$gt:['$createdAt',{$toDate:{$subtract:[new Date(),1000*60*60*24*days]}}]}}\n ]\n}\n\nlet pipeline=[\n {\n $match:criteria\n },\n {\n $project:{\n year:{$year:'$createdAt'},\n month:{$month:'$createdAt'},\n day:{$dayOfMonth:'$createdAt'}\n }\n },\n {\n $group:{\n _id:{year:'$year',month:'$month',day:'$day'},\n count:{$sum:1}\n }\n }\n]"
]
| [
"mongodb"
]
|
[
"Return JavaScript into a HTML attribute",
"How is it possible to return a string from a JavaScript Code into a HTML attribute like in the following example?\n\n<div class=\"xx\" animation=\"yy\" animate-duration=\"<spript>Code goes here<script>\" ...>\n</div>\n\n\nI can not get it right, is there a solution?"
]
| [
"javascript",
"html",
"css",
"attributes",
"element"
]
|
[
"Is it possible to compare comma delimited string in T-SQL without looping?",
"Let's say I have 2 tables where both has column called Brand. The value is comma delimited so for example if one of the table has \n\nACER,ASUS,HP \nAMD,NVIDIA,SONY\n\n\nas value. Then the other table has \n\nHP,GIGABYTE \nMICROSOFT \nSAMSUNG,PHILIPS\n\n\nas values. \n\nI want to compare these table to get all matched record, in my example ACER,ASUS,HP and HP,GIGABYTE match because both has HP. Right now I'm using loop to achieve this, I'm wondering if it's possible to do this in a single query syntax."
]
| [
"sql",
"sql-server",
"tsql",
"split"
]
|
[
"Not another Sencha Touch 2 vs JQMobile 1.2.0 Performance Comparison Thread",
"I know this has been asked a million times but i can't seem to find a good comparison that is with the new Sencha Touch 2 and the currently released and optimized JQMobile 1.2.0 or 1.1.1 even.\n\nMy main concern is i have worked with both but only with the old non optimized version of JQMobile so my question is.\n\nHow big is the improvement of the new JQuery Mobile that was just released in comparison to Sencha Touch 2 when it comes to packaging it into a native mobile application?\n\nTHanks,\nAlex"
]
| [
"jquery-mobile",
"sencha-touch-2"
]
|
[
"How to get the Hololens Locatable Camera view and projection matrices out of the WinRT Windows.Media API",
"The documentation for the Hololens gives an example of how to extract the Locatable Camera view and projection matrices using the Media Foundation API here: https://developer.microsoft.com/en-us/windows/mixed-reality/locatable_camera#locating_the_device_camera_in_the_world.\n\nIt claims that this is also possible with the WinRT API, and links to this documentation reference: https://docs.microsoft.com/en-us/uwp/api/Windows.Media.Devices.Core.CameraIntrinsics.\n\nHowever, this class does not seem to have any API to retrieve the extended Hololens attributes, only the default Windows Phone ones like the distortion matrix and pinhole properties.\n\nIs the Hololens documentation incorrect and is it simply not possible to retrieve the Locatable Camera metadata in the WinRT API? Or am I missing something?\n\nThe Spatial Coordinate System (3rd and last extended sample metadata attribute) does seem to be available as MediaFrameReference.CoordinateSystem (https://docs.microsoft.com/en-us/uwp/api/windows.media.capture.frames.mediaframereference), which makes this even more confusing..."
]
| [
"c#",
"windows",
"windows-runtime",
"win-universal-app",
"hololens"
]
|
[
"Creating Read-Only tagged Value in enterprise architect through c# add-ins",
"I am currently working on add-in where I need to create read-only tag values through code. \nThe default way to add tagged values Element.TaggedValues.AddNew(\"Value\", \"\")creates tagged values of type string only. \nI read that defining Type=Const creates read-only tagged values but when I tried Element.TaggedValues.AddNew(\"Value\", \"Const\"),it creates tagged values of type string only. \nKindly help.Thanks in advance."
]
| [
"c#",
"add-in",
"enterprise",
"enterprise-architect"
]
|
[
"Whose responsibility is it to delete",
"In C++, whose responsibility is it to delete members of a class: the class, or the creator of an instance of that class?\nFor example, in the following code:\n\nclass B {\n public:\n B(int x) { num = x; }\n int num;\n};\n\nclass A {\n public:\n A(B* o) { obj = o; }\n B* obj;\n};\n\nint main(void) {\n A myA(new B(3));\n return 0;\n}\n\n\nShould main delete the instance of B, or should A's destructor delete its local variable obj? Is this true in most cases, and in which cases if any is it not?"
]
| [
"c++",
"memory-management"
]
|
[
"ThreadPool exceptions in gevent do not get returned",
"I'm using gevent on Python 2.7 to do some multithreaded work. However, I am unable to catch exceptions that are raised in the spawned methods. I am using the .get() method on the returned AsyncResult object (returned when calling the .spawn() method on the thread pool).\nPer the gevent documentation: http://www.gevent.org/gevent.event.html#gevent.event.AsyncResult.get:\n\nget(block=True, timeout=None)\nReturn the stored value or raise the exception.\nIf this instance already holds a value or an exception, return or raise it immediately.\n\nHowever, instead of returning the exception, .get() returns NoneType. Additionally, in the console, the exception details are printed out. Instead, .get() should return the Exception back.\nHere is some sample code and corresponding output that showcases this:\nfrom gevent import threadpool\n\ndef this_will_fail():\n raise Exception('This will fail')\n\nresult_list = []\nfor i in range(1,5):\n tpool = threadpool.ThreadPool(5)\n result_list.append(tpool.spawn(this_will_fail))\n\ntpool.join()\n\nfor result in result_list:\n try:\n returned_object = result.get()\n print type(returned_object)\n\n except Exception as e:\n print 'This is not running for some reason...'\n\nOutput:\nTraceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/gevent/threadpool.py", line 193, in _worker\n value = func(*args, **kwargs)\n File "<stdin>", line 2, in this_will_fail\nException: This will fail\n(<ThreadPool at 0x107c79e50 0/1/5>, <function this_will_fail at 0x107c848c0>) failed with Exception\n\nTraceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/gevent/threadpool.py", line 193, in _worker\n value = func(*args, **kwargs)\n File "<stdin>", line 2, in this_will_fail\nException: This will fail\n(<ThreadPool at 0x107c99210 0/1/5>, <function this_will_fail at 0x107c848c0>) failed with Exception\n\nTraceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/gevent/threadpool.py", line 193, in _worker\n value = func(*args, **kwargs)\n File "<stdin>", line 2, in this_will_fail\nException: This will fail\n(<ThreadPool at 0x107c99410 0/1/5>, <function this_will_fail at 0x107c848c0>) failed with Exception\n\nTraceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/gevent/threadpool.py", line 193, in _worker\n value = func(*args, **kwargs)\n File "<stdin>", line 2, in this_will_fail\nException: This will fail\n(<ThreadPool at 0x107c99610 0/1/5>, <function this_will_fail at 0x107c848c0>) failed with Exception\n\n<type 'NoneType'>\n<type 'NoneType'>\n<type 'NoneType'>\n<type 'NoneType'>\n\nAm I missing something obvious, or is this a bug in gevent?\nEDIT: concurrent.futures doesn't have this problem. While that is an acceptable solution for my use case, I would still like to understand why gevent doesn't properly return the exception."
]
| [
"python",
"multithreading",
"exception",
"exception-handling",
"gevent"
]
|
[
"Laravel 4 - paginate with the filter Eloquent ORM",
"I want to filter my ORM request with 2 relations many-to-many : Regions and Jobs.\n\nI need paginate, but $final->paginate() is not possible, but i don't know, why.\n\nHow ameliorated my code for to use ->paginate() and no Paginatore::make\n\n /* sélectionne tout les candidats qui sont disponnibles, et qui ont une date inférieure\n * à celle configuré\n */\n $contacts = Candidate::with('regions', 'jobs')\n ->where('imavailable', '1')\n ->where('dateDisponible', '<=', $inputs['availableDate'])\n ->get(); // ta requete pour avoir tes contacts, ou par exemple tu fais un tri normal sur tes regions. Il te reste à trier tes jobs.\n\n // ajoute un filtre, pour n'afficher que ceux qui reponde true aux 2 test dans les foreachs \n $final = $contacts->filter(function($contact) use($inputs) {\n\n // par défaut ils sont false\n $isJob = false;\n $isRegion = false;\n\n // test que le candidat à l'un des jobs recherché par l'entreprise\n foreach($contact->jobs as $job) {\n\n // si le job id du candidat est dans la liste, alors on retourne true\n if(in_array($job->id, $inputs['job'])) {\n\n $isJob = true;\n }\n }\n // test que le candidat accepte de travailler dans l'une des régions echerchées\n foreach($contact->regions as $region) {\n\n // si region id du candidat est dans la liste, alors on retourne true\n if(in_array($region->id, $inputs['region'])) {\n\n $isRegion = true;\n }\n }\n\n // si les 2 renvoie true, alors nous returnons le candidat à la vue\n if($isRegion && $isJob){\n\n return true;\n }\n else{\n\n return false;\n }\n });\n\n // converti le resultat en tableau pour l'importer dans le Paginator\n $finalArray = $final->toArray();\n\n // calcule le nombre de candidat dans le tableau\n $finalCount = count($finalArray);\n\n // créer le pagniate manuellement, car on ne peux faire $final->paginate(20)\n $paginator = Paginator::make($finalArray, $finalCount, 2);\n\n // return la liste des candidats\n return $paginator;\n\n\nThanks."
]
| [
"orm",
"filter",
"laravel",
"eloquent",
"paginate"
]
|
[
"Understanding contradictions found in VB's official conventions guidelines",
"I was hoping fellow members could assist me in making sense of the following six contradictory guidelines:\n\na) Name Length:\n\nAdvises abbreviation...\n\n\n For long [...] terms, use abbreviations to keep name lengths\n reasonable.\n\n\nSource\n\nAdvises against abbreviation:\n\n\n DO NOT use abbreviations or contractions as part of identifier names.\n\n\nSource\n\nWhich is it? To contract or not to contract? PromotionalNumberTextBox or PromNumTextBox?\n\nb) Event Handler names:\n\n\n Begin event handler names with a noun describing the type of event\n followed by the \"EventHandler\" suffix, as in \"MouseEventHandler\".\n\n\nSource\n\nThia doesn't correspond with what Visual Studio automatically generates. See Button1_Click event handler below that follows the format of control, underscore and event.\n\nEdit: Not, in fact, a contradiction. See comment by jmcilhinney for explanation.\n\nPrivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click\n '... \nEnd Sub\n\n\nc) Hungarian Notation:\n\n\n DO NOT use Hungarian notation.\n\n\nSource\n\n...and yet both of the following seem like a variant of Hungarian Notation. \n\n\n Objects should be named with a consistent prefix that makes\n it easy to identify the type of object. [...] chkReadOnly [...]\n lblHelpMessage\n\n\nSource\n\n\n Use [...] prefixes to indicate a variable's data type. [...]\n intQuantity\n\n\nSource\n\nd) Acronyms Capitalization:\n\n\n For long [...] terms, use abbreviations [...] for example, \"HTML\",\n instead of \"Hypertext Markup Language\".\n\n\nSource\n\n\n [...] PascalCasing [...] for [...] acronyms over two letters in length\n [...] examples: [...] HtmlTag\".\n\n\nSource\n\nThis is ambiguous. Let's say I have the acronym PIN. Should it be PINTextBox or PinTextBox?\n\ne) Comments:\n\n\n Put comments on a separate line instead of at the end of a line of\n code.\n\n\nSource\n\n\n Comments can follow a statement on the same line, or occupy an entire\n line.\n\n\nSource\n\nThis is ambiguous. Are inline comments recommended or not?\n\nf) Asterisk Line Separators:\n\n\n Do not surround comments with formatted blocks of asterisks.\n\n\nSource\nHowever, the following example using formatted blocks asterisks is also provided:\n\n'*****************************************************\n' Purpose: Locates the first occurrence of a\n' specified user in the UserList array.\n' Inputs:\n' strUserList(): the list of users to be searched.\n' strTargetUser: the name of the user to search for.\n' Returns: The index of the first occurrence of the\n' rsTargetUser in the rasUserList array.\n' If target user is not found, return -1.\n'*****************************************************\n\n\nSource"
]
| [
"vb.net",
"winforms",
"naming-conventions",
"naming",
"convention"
]
|
[
"Tensorboard: How to connect to hdfs directory",
"I have used TensorflowOnSpark to train a RNN model with tensorboard enabled(store_true). Summary events have been logged in a HDFS directory.\n\nHow can I visualize the RNN events(from hdfs directory) using tensorboard?\n\nI tried to start tensorboard using hdfs log directory but it failed to start with message: \"hdfs not supported\".\n\nPlease let me know if anybody has any idea about it."
]
| [
"apache-spark",
"hdfs",
"tensorboard"
]
|
[
"RMA MPI window access latency",
"I use Fortran (with gfortran) and MPI 2 (OpenMPI). Through MPI_Win_lock and MPI_Win_unlock together with put and get operations (in non-overlapping regions of memory) all processes update a variable on my master process, which is exposed through a window.\n\nIn a test case I have noticed, however, that the unlock operations from processes that are not the master do not return until the master has finished some task, in this case sleeping for some seconds.\n\nIf instead of sleeping the master, I make it wait for some seconds using a while loop and a timer, and in the meantime I make the master lock and unlock the window, everything goes much faster:\n\ncall start_time(time_left)\ndo while (time_left .gt. 0)\n call MPI_Win_lock(...)\n call MPI_Win_unlock(...)\n call update_time(time_left)\nend do\n\n\nHowever, in my real code the master performs operations just as the other processes, so it is impossible for it to continuously lock and unlock the window. Also, it seems to me rather wasteful. \n\nMy question is therefore how to decrease this latency?\n\nDo I really need to sprinkle my code with locks and unlocks for the master? Or is there another solution? Is this compiler / implementation dependent?"
]
| [
"fortran",
"mpi",
"latency"
]
|
[
"How to get IntelliSense to reliably work in Visual Studio 2008",
"Does anyone know how to get IntelliSense to work reliably when working in C/C++ projects? It seems to work for about 1 in 10 files. Visual Studio 2005 seems to be a lot better than 2008.\n\nEdit: Whilst not necessarily a solution, the work-around provided here: \n\nHow to get IntelliSense to reliably work in Visual Studio 2008\n\nIs probably the best bet if I want a decent IntelliSense system."
]
| [
"c++",
"c",
"visual-studio-2008",
"intellisense"
]
|
[
"file: URIs and Slashes",
"An application I'm working on involves accessing files on network file shares, and we're using URIs to specify the files' locations.\n\nMy understanding of the file: URI is that they should take the form of file://+path. In the case of a Windows network share, this path looks something like \\\\servername\\dir\\file, so the resultant URI becomes file:////servername/dir/file.\n\nThis seems to be working great for Java's URI class, but the Win32 API seems to want a file://servername/dir/file style URI, which Java rejects because it \"has an authority component\".\n\nAm I understanding network-share URIs correctly? Is there another way to specify a path without Java complaining about the authority?\n\nEdit: We were hoping to be able to store paths as URIs, so as to make use of the scheme-part of the URI to specify other locations (e.g. file: versus other:). But as pointed out, it looks like Java may just have its own issues with URIs..."
]
| [
"java",
"windows",
"uri",
"file-uri"
]
|
[
"Sorting of files list in directory based on modifaction date in C programming",
"I am trying to figure out how to apply a C program function to sort the file lists of the sub-folders inside my parent directory with modification date. For instance, if I have 12 files inside a directory called foo, I'd like to sort them by modification date and then remove the oldest 6. How should I approach this?"
]
| [
"c",
"dynamic-programming"
]
|
[
"Why isn't my bubble sort sorting my array correctly?",
"So I have this bubble sort, first time trying to create one and this is what I have.\nFor some reason it's printing out the array in a weird way.\nIt should sort it by letters as far as I know.\n\nHow do I properly do a bubble sort without using LINQ or Array.Sort(); This is for school so I need to do the bubble sort algorithm.\n\nHere is an image of what it prints out.\n\n\n\nclass Program\n {\n static string[] animals = new string[] { \"cat\", \"elephant\", \"tiger\", \"fish\", \"dolphin\", \"giraffe\", \"hippo\", \"lion\", \"rat\", \"string ray\" };\n\n static void Main(string[] args)\n {\n BubbleSort();\n Console.ReadLine();\n }\n\n private static void BubbleSort()\n {\n bool swap;\n string temp;\n\n string[] animals = new string[] { \"cat\", \"elephant\", \"tiger\", \"fish\", \"dolphin\", \"giraffe\", \"hippo\", \"lion\", \"rat\", \"string ray\" };\n\n for (int index = 0; index < (animals.Length - 1); index++)\n {\n if (string.Compare(animals[index], animals[index + 1], true) < 0) //if first number is greater then second then swap\n {\n //swap\n temp = animals[index];\n animals[index] = animals[index + 1];\n animals[index + 1] = temp;\n swap = true;\n }\n }\n\n foreach (string item in animals)\n {\n Console.WriteLine(item);\n }\n }\n }"
]
| [
"c#",
"arrays",
"string",
"sorting"
]
|
[
"Which plot should be used for dataframe containing multiple columns?",
"I have a pandas dataframe consisting of 1000+ entries.\n\nsession_id CategoriesViewed productsViewed totalclicks\n7.0 2 16 28.0\n8.0 3 7 9.0\n9.0 3 3 4.0\n11.0 1 2 2.0\n15.0 3 4 4.0\nand so on...\n\n\nI am not able to plot a graph to co-relate these values. Is there any plot where I can add all the column's at once and understand (I don't want to use a bubble chart)."
]
| [
"python",
"pandas",
"matplotlib"
]
|
[
"CSS - flex grid layout",
"I have a simple grid using flex.\n\nI need three columns and a margin in between each block but not on the last block of each row.\n\nThis is working here but I also need all the blocks to be 100% of the container so I dont want the margin after the 3rd block.\n\nIs it possible to have a grid like this where the blocks are a percentage and the margin on the inside and not against the container.\n\n\r\n\r\n.block {\r\n border: 1px solid red;\r\n display: flex;\r\n flex-wrap: wrap;\r\n max-width: 900px;\r\n justify-content: flex-start;\r\n\r\n}\r\n\r\n.block__item {\r\n background: grey;\r\n height: 20px;\r\n margin-bottom: 2px;\r\n width: calc(33.33% - 2px);\r\n margin-right:2px; \r\n}\r\n<div class=\"block\">\r\n <div class=\"block__item\"></div>\r\n <div class=\"block__item\"></div>\r\n <div class=\"block__item\"></div>\r\n <div class=\"block__item\"></div>\r\n <div class=\"block__item\"></div>\r\n</div>"
]
| [
"css",
"html",
"flexbox"
]
|
[
"How to force a class to declare a final variable?",
"For the moment, I created an abstract class like this:\n\npublic abstract class MyClass {\n public final static String TAG;\n ...\n}\n\n\nBut it gives me an error of not initializing a final variable. Then I tried to initialize it from a constructor, but it didn't work either (gives the same error plus another one of trying to set a value to a final variable), although many stackoverflow posts says that really works...\n\npublic abstract class MyClass {\n public final static String TAG;\n\n public MyClass(String u){\n this.TAG = u;\n }\n}\n\n\nIt seems like final variables have to be assigned only when declaring the variable. Is this correct? How can I achieve this?"
]
| [
"android",
"abstract-class",
"final"
]
|
[
"How do I linear search two arrays in c++?",
"I have two arrays of data type double - called array1[10] and array2[8]. I am required to search for array2 inside array1 at each element using a linear search function. The function declaration is \n\nstring linSearch (double array1[10], double array2[8]);\n\n\nIf array2 is found inside array1 then I need to print out the index of where it is found in array1. If its not found I need the output to be \"NA\". This output must be a delimited-comma- string.\neg.\n\n//given the two arrays:\narray1={1.1,1.2,6,7,3.5,2,7,8.8,9,23.4}\narray2={6,45,2,7,1.1,5,4,8.8}\n\n//after the linear search completes, the output must be the index in which //array2 is found in array1. if its not found, then it must be NA:\n\n2,NA,5,6,0,NA,NA,7\n\n\nSo far I have the code that follows. Its my first time working with arrays and I am still having difficulties grasping the concept- like once I define the function how do I even call it in the main program?! anyway..the function definition I have (excluding the main program) is:\n\nstring linSearch (double array1[10], double array2[8])\n{\n int index1 = 0;\n int index2 =0;\n int position =-1;\n bool found = false;\n while (index1<10 && !found && index2<8)\n {\n if array1[index1] == array2[index2])\n {\n found = true;\n position = index1;\n }\n index1++;\n index2++;\n }\n\n return position;\n\n}\n\n\nI am EXTREMELY confused about searching for one array in the other and how to output the delimited list as well as how to connect it to my main program. Any help would be GREATLY appreciated. Thanks!"
]
| [
"c++",
"arrays",
"function",
"cout",
"linear-search"
]
|
[
"Mocha beforeEach in one suite is being run in another suite",
"I have two test suites (I am using mocha's TDD UI, which uses suite(), test() rather than describe() and it()):\n\nsuite('first suite'), function(){\n ....\n})\n\n\nsuite('second suite', function(){\n\n beforeEach(function(done){\n console.log('I SHOULD NOT BE RUN')\n this.timeout(5 * 1000);\n deleteTestAccount(ordering, function(err){\n done(err)\n })\n })\n\n ... \n\n}()\n\n\nRunning mocha -g 'first suite only runs tests from the first suite, but runs the beforeEach, printing I SHOULD NOT BE RUN on the console.\n\nHow can I make the beforeEach() only run in the suite it is contained within?\n\nNote: I can workaround the issue with:\n\nbeforeEach(function(done){\n this.timeout(5 * 1000);\n if ( this.currentTest.fullTitle().includes('second suite') ) {\n deleteTestAccount(ordering, function(err){\n done(err)\n })\n } else {\n done(null)\n }\n})"
]
| [
"node.js",
"mocha.js"
]
|
[
"Telerik RadHtmlChart skip days in x-axis",
"I am using Telerik RadHtmlChart (the chart screenshot), I need to remove from the x axis Saturdays and Sundays. What I mean, I need that the distance between friday and Monday be the same as Monday to Tuesday, my data will return only information for day weeks not for weekend.\n\nIt's possible?"
]
| [
"telerik",
"radhtmlchart"
]
|
[
"connecting to Postgres with Perl",
"I have installed Postgres in my machine, and I'm trying to connect to it using Perl.\n\n$database = \"heatmap\";\n$user = \"postgres\";\n$password = \"<password>\";\n\n#connect to Postgres database\nmy $db = DBI->connect(\n \"DBI:Pg:database=$db;\",\n $user,\n $password\n) or die \"Can't Connect to database: $DBI::errstr\\n\";\n\n\nHowever, I'm getting the following error:\n\nDBI connect('database=;','postgres',...) failed: FATAL: password authentication failed for user \"souzamor\" at C:/Users/souzamor/workspace/Parser/Parser.pl line 13.\nCan't Connect to database: FATAL: password authentication failed for user \"souzamor\"\n\n\nsouzamor is my Windows username. However, I'm trying to connect as postgres. I went ahead and created an user called souzamor in Postgres, but I got:\n\nDBI connect('database=;','souzamor',...) failed: FATAL: database \"user='souzamor'\" does not exist at C:/Users/souzamor/workspace/Parser/Parser.pl line 13.\nCan't Connect to database: FATAL: database \"user='souzamor'\" does not exist\n\n\nI'm totally new with Postgres. Any ideas?\nThanks"
]
| [
"perl",
"postgresql"
]
|
[
"Nodejs require config",
"I am writing Nodejs at this moment and I was wondering what is better for requiring configuration:\n\n\nIn my main file I require conf.js only once and then pass it to the other files require('./jwt)(config)\nIn every file where I need something from the config I require it\n\n\nWhich one is better? I think it's the first one but I have some files that are used by the controllers (eg. jwt.js - veryfy and create token). Is it a best practise to require this module in the main file (where I don't need it) and pass the config or to use the second way?"
]
| [
"node.js"
]
|
[
"How can I catch a C# AppCrash because of a native C++ DLL fail",
"I have a DLL created from native c++(say XYZ.dll). I link against that DLL in a wrapper that is C++ .NET. An object of this wrapper is used in my highest level C# code.\n\nMy question is: sometimes a function in my DLL crashes and my highest level C# code crashes with AppCrash; crash module: XYZ.dll. I am trying to figure our where it is crashing my native C++ code, but that is proving to be fruitless. I was wondering if there was a way for me to catch this crash in my C# code and move on."
]
| [
"c#",
"c++",
".net",
"try-catch",
"crash"
]
|
[
"How to finish creating Caesar cipher?",
"Here is my code so far. The program is designed to take a message and encrypt or decrypt a message by shifting each letter a certain number of letters in the alphabet. I managed to get the programs talking to each other (there are two methods here by the way) and the first prompt works, however I am not sure how to get the decryption working as well as with either upper or lower case? Any help is greatly appreciated.\n\npublic class CaesarCipher\n{\n public static String encrypt(String message, int key)\n {\n String alphaLower = \"abcdefghijklmnopqrstuvwxyz\";\n String alphaUpper = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n int sum = 0;\n String encryptedMessage = \"\";\n\n //Find the index of every char in the string \"message\" \n //Add 1 to every index.\n //Take that index and turn it back into a char. \n\n for (int i = 0; i < message.length(); i++)\n {\n if (alphaLower.indexOf(message.charAt(i)) > -1)\n {char letter = message.charAt(i);\n\n int index =(alphaLower.indexOf(message) + key)%26;\n\n\n char newLetter = alphaLower.charAt(index);\n encryptedMessage += newLetter;\n }\n else if (alphaUpper.indexOf(message.charAt(i)) )\n {char letter = message.charAt(i);\n\n int index = alphaUpper.indexOf(message) + key;\n\n\n char newLetter = alphaUpper.charAt(index);\n encryptedMessage += newLetter;\n\n }\n else \n {\n encryptedMessage\n }\n }\n\n return encryptedMessage;\n }\n\n public static String decrypt(String message, int key)\n {\n String decryptedMessage;\n decryptedMessage = encrypt(message, -key)\n return decryptedMessage;\n }\n}\n\n\npublic class CaesarTester\n{\n public static void main(String[] args)\n {\n\n System.out.println(\"Test 1 - simple encrypt:\");\n System.out.println(\"Expected: j offe npofz\");\n System.out.println(\"Actual: \" + CaesarCipher.encrypt(\"i need money\", 1));\n System.out.println();\n\n System.out.println(\"Test 2 - simple decrypt:\");\n System.out.println(\"Expected: i need money\");\n System.out.println(\"Actual: \" + CaesarCipher.decrypt(\"j offe npofz\", 1));\n System.out.println();\n\n System.out.println(\"Test 3 - simple encrypt w/ casing:\");\n System.out.println(\"Expected: Fyx M jsvksx qc TMR jsv xli EXQ\");\n System.out.println(\"Actual: \" + CaesarCipher.encrypt(\"But I forgot my PIN for the ATM\", 4));\n System.out.println();\n\n System.out.println(\"Test 4 - simple decrypt w/ casing:\");\n System.out.println(\"Expected: But I forgot my PIN for the ATM\");\n System.out.println(\"Actual: \" + CaesarCipher.decrypt(\"Fyx M jsvksx qc TMR jsv xli EXQ\", 4));\n System.out.println();\n\n System.out.println(\"Test 5 - simple encrypt w/ casing and symbols:\");\n System.out.println(\"Expected: Un xomnz. VOT oy 1234!\");\n System.out.println(\"Actual: \" + CaesarCipher.encrypt(\"Oh right. PIN is 1234!\", 6));\n System.out.println();\n\n System.out.println(\"Test 6 - simple decrypt w/ casing and symbols:\");\n System.out.println(\"Expected: Oh right. PIN is 1234!\");\n System.out.println(\"Actual: \" + CaesarCipher.decrypt(\"Un xomnz. VOT oy 1234!\", 6));\n System.out.println();\n\n System.out.println(\"Test 7 - complex encrypt:\");\n System.out.println(\"Expected: Hiq, qbun'm gs qczc jummqilx?!\");\n System.out.println(\"Actual: \" + CaesarCipher.encrypt(\"Now, what's my wifi password?!\", 20));\n System.out.println();\n\n System.out.println(\"Test 8 - complex decrypt:\");\n System.out.println(\"Expected: Now, what's my wifi password?!\");\n System.out.println(\"Actual: \" + CaesarCipher.decrypt(\"Hiq, qbun'm gs qczc jummqilx?!\", 20));\n System.out.println();\n }\n}"
]
| [
"java",
"encryption"
]
|
[
"Replace null in a column of a dataframe with other value",
"I have a Dataset like the following\n\nmonthYear code\n201601 11\n201601 12\n201601 12\n201601 10\n201602 null\n201602 21\n201602 21\n201602 21\n201603 null\n\n\nWhen code is null I want to replace that with the code that appeared the most during the last month. For the above example, the first null will get replaced by 12 and the second one with 21.\n\nSo the result would be the following.\n\nmonthYear code\n201601 11\n201601 12\n201601 12\n201601 10\n201602 12\n201602 21\n201602 21\n201602 21\n201603 21\n\n\nHow can I achieve this?"
]
| [
"scala",
"apache-spark",
"spark-dataframe"
]
|
[
"SSL offloading on AWS Cloudfront level",
"We use the following AWS infrastructure:\n\nRoute53-> CloundFront -> Elasticbeanstalk(+LoadBalancer=ELB) -> EC2 instances\n\nNow we have ssl certificates set up on CloudFront level and the same one on ELB level thus providing us end-to-end encryption between CF and ELB.\nEnd2End between AWS CF and origin is described as best practice here.\n\nThis refers to Full SSL(strict) on this picture(this is for CloudFlare stack but it is for better illustration so never mind). We want to offload SSL on AWS CF level to avoid roundtrips from CF to ELB moving to Flexible SSL as depicted on the picture.\n\nIs it a good idea to offload SSL on CF level? Will there be any performance improvements worth dropping end2end encryption after CF level?\n\nCan we somehow restrict ELB to accept connections only from some AWS CF?\n\nMoreover there are some performance concerns about ELB SSL performance(seems to be proven to be good at it but I still have concerns). In general it also interesting if AWS CF is performing better at SSL decryption work than ELB."
]
| [
"amazon-web-services",
"ssl",
"amazon-cloudfront",
"amazon-elb"
]
|
[
"ValueError: unknown is not supported on multiclass dependent variable",
"I'm trying to fit a vector in sklearn, but I'm receiving this error:\n\n\n ValueError: unknown is not supported\n This is my code:\n\n\n X = df_features.values\n X = X.reshape((len(X),len(df_features.columns)))\n Y = df_train['action'].values\n Y = Y.reshape((len(Y),))\n\npipeline = Pipeline([\n ('clf', RandomForestClassifier())\n])\n\nparameters = {\n 'clf__max_depth': [5,7,9],\n 'clf__max_features': [3,4,5],\n 'clf__min_samples_leaf': [3,4,5,6,7],\n 'clf__bootstrap': [True]\n}\n\nscore_func = make_scorer(metrics.f1_score,average='weighted')\n\ngrid_search = GridSearchCV(pipeline, parameters, n_jobs=3,\n verbose=1, scoring=score_func)\n\ngrid_search.fit(X, Y)\n\n\nThis is Y sample data:\n\n\n ['NOTHING', 'NOTHING', 'SELL', 'SELL', 'NOTHING',\n 'NOTHING', 'NOTHING']\n\n\nHow can I fix this?\nThanks"
]
| [
"python",
"scikit-learn"
]
|
[
"NSTimeinterval problem for date in iphone sdk",
"I am converting the date into NSTimeinterval like the code below:\n\nNSDate *currentDate = [NSDate date];\nNSTimeInterval currentyInterval = [appDelegate setTimeInterval:currentDate]; \nNSDate *expiryDate = [appDelegate setReverseDate:warrObj.expiredOn];\n\n\nNSTimeInterval expiryInterval = [appDelegate setTimeInterval:expiryDate];\n//Here I am getting the nil value and exception is generated.\n//It happens only in 3.1\n\n\n-(NSTimeInterval )setTimeInterval:(NSDate *)selectedDate\n{\n NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init] ;\n [dateFormatter setDateFormat:@\"dd-MMM-yyyy 00:00:00\"];\n NSString *currStr = [dateFormatter stringFromDate:selectedDate];\n NSDate *newCurrentDate = [dateFormatter dateFromString:currStr];\n\n NSTimeInterval timeInterval = [newCurrentDate timeIntervalSinceReferenceDate];\n [dateFormatter release];\n return timeInterval;\n}\n\n\nCan anyone suggest me how to get rid of this.\n\nThanks to all,\nMadan."
]
| [
"objective-c",
"ios"
]
|
[
"Failing conversion of string to int in JavaScript",
"I am trying to get the input from a 2d php string array and convert the values in arr[i][1] (where i can be treated as a row and 1 as column in matrix) to integer as follows:\n\nJavaScript function:\n\n\r\n\r\nvar _input = <? php echo json_encode($output); ?> ; //2D String\r\nvar _sro = []; //string\r\nvar _src = []; //string\r\nvar _sru = []; //string\r\n\r\nvar aL = _input.length;\r\nfor (var i = 0; i < aL; i++) {\r\n _sro.push(_input[i][0]); //string\r\n _src.push(_input[i][1]); //string\r\n _sru.push(_input[i][2]); //string\r\n}\r\n\r\nalert(_src.toString()); //result = 1,1,2,9,6,1,24...\r\nalert(typeof(_src).toString()); //res = string\r\n\r\nvar _lb = new Array(); //empty\r\nvar _dt = new Array(); //empty\r\n\r\nfor (var i = 0; i < aL; i++) {\r\n _dt.push(parseInt(_src[i])); //convert to int and push to arr\r\n}\r\n\r\nalert(_dt.toString()); //result = NaN,NaN,NaN,NaN.....\r\nalert(typeof(_dt).toString()); //res = string\r\n\r\n_lb = _sro;\r\n\r\n\r\n\n\nThe problem I am experiencing is that the end output for each value of _dt is NaN which means that it does not get converted appropriately. To resolve this I have tried following:\n\n\nusing parseInt\nusing Number()\nusing the \"+\" operator\nusing both parseInt and Number()\n\n\nFor example:\n\n\r\n\r\nfor (var i = 0; i < aL; i++) {\r\n _dt.push(Number(parseInt(_src[i]))); //convert to int and push to arr\r\n}\r\n\r\n\r\n\n\nand all these have failed. I am really lost and I have ran out of ideas after 2 days of googling and maybe someone in their wisdom will be able to help for which thank you in advance. \n\nEDIT: \n\nPHP Function:\n\nthe below function generates the PHP array passed through to JS:\n\n\r\n\r\n//set error reporting\r\nerror_reporting(E_ALL & ~E_NOTICE);\r\n\r\n//set variables\r\n$result = array();\r\n$output = array();\r\n\r\n//read in csv file\r\nforeach(file(\"1OnScreen.csv\") as $key => $str) {\r\n if ($key == 0)\r\n continue; // skip first line\r\n\r\n $values = str_getcsv($str, \"\\t\", '', '');\r\n $result[] = $values;\r\n}\r\n$output = $result;\r\n\r\n\r\n\n\nCSV DATA\n\nThe CSV File contains following data and the delimiter is \\t:\n\n\r\n\r\nOwner Count Unassigned Other\r\nAA1 1 0 1\r\nAD 1 0 1\r\nAR 2 0 2\r\nBW 9 0 9\r\nCM 6 0 6\r\nCT 1 0 1\r\nDB 24 0 24\r\nEU 8 0 8\r\nGM 5 0 5\r\nGO 21 0 21\r\nJF 1 0 1\r\nJW 2 0 2\r\nNH 10 0 10\r\nRB 2 0 2\r\nSPC 4 0 4\r\nSP 2 0 2\r\nTC 2 0 2\r\nTG 1 0 1\r\nVS 4 0 4\r\n\r\n\r\n\n\nJSON Output in JS\nOutput of _input as I see it when running alert(_input) i think that the comma on the beginning of the new lines can be impacting the conversion and making it fail but I do not know how to go around that.\n\n\r\n\r\nAA1,1,0,1\r\n,AD,1,0,1\r\n,AR,2,0,2\r\n,BW,9,0,9\r\n,CM,6,0,6\r\n,CT,1,0,1\r\n,DB,24,0,24\r\n,EU,8,0,8\r\n,GM,5,0,5\r\n,GO,21,0,21\r\n,JF,1,0,1\r\n,JW,2,0,2\r\n,NH,10,0,10\r\n,RB,2,0,2\r\n,SPC,4,0,4\r\n,SP,2,0,2\r\n,TC,2,0,2\r\n,TG,1,0,1\r\n,VS,4,0,4"
]
| [
"javascript",
"php",
"arrays",
"csv",
"type-conversion"
]
|
[
"Creating a generalized resource map without using strings?",
"Let's assume I want to create an object that will hold some arbitrary data.\n\n// Pseudocode\nclass MyContainer {\n map<key, pair<void*, size>>;\n}\n\n\nThe key in this case also identifies the kind of data stored in the void* (e.g an image, a struct of some kind, maybe even a function).\n\nThe most general way to del with this is have the key be a string. Then you can put whatever on earth you want and then you can just read it. As a silly example, the key can just be:\n\n\"I am storing a png image and the source file was at location/assets/image.png and today is sunday\".\n\n\ni.e you can encode whatever you want. This is however slow. A much faster alternative is using enumerators and your keys are then IMAGE, HASHMAP, FUNCTION, THE_ANSWER_TO_LIFE...\n\nHowever that requires you know every single case you need to handle beforehand and create an enumerator for it manually (which is tedious and not very extensible).\n\nIs there a compromise that can be made? i.e something that uses only one key but is faster than strings and more extensible than enums?\n\nEdit:\nThe exact use case I am trying to use this for is as a generalized storage for rendering data. This includes images, vertex buffers, volumetric data, lighting information... Or any other conceivable thing you may need.\n\nThe only way I know to create \"absolute polymorphism\" (i.e represent literally any form of conceivable data) is to use void pointers and rely on algorithms to understand the data.\n\nExample:\n\nSay our key is a JSON string where the key of each element is the name of a field in a compact struct and the value is the offset in bytes.\n\nE.g \n\n {\n m_field1: 0,\n m_field2: 32,\n m_field3: 128,\n }\n\n\nThen to access any of the elements in the void* all you need to do is do symbol manipulation to get the number and then ptr + offset.\n\nYou can do the same with a set of unique identifiers (enums) and associated functions that get you the fields based on the identifier (hard coded approach).\n\nHopefully this makes the question less obscure."
]
| [
"c++",
"string",
"design-patterns",
"enums"
]
|
[
"How to change image of ImageView inside custom adapter when click button on main activity?",
"Now, I set image for each item listView from MainActivity class\n\nprivate void setBackground(int position, int drawable){\n ViewListItem item = adapter.getItem(itemID);\n\n switch (position){\n case 0:\n item.ivPlayerAnswer1 = (ImageView)findViewById(R.id.ivPlayerAnswer1);\n item.ivPlayerAnswer1.setImageResource(drawable);\n break;\n case 1:\n item.ivPlayerAnswer2 = (ImageView)findViewById(R.id.ivPlayerAnswer2);\n item.ivPlayerAnswer2.setImageResource(drawable);\n break;\n case 2:\n item.ivPlayerAnswer3 = (ImageView)findViewById(R.id.ivPlayerAnswer3);\n item.ivPlayerAnswer3.setImageResource(drawable);\n break;\n case 3:\n item.ivPlayerAnswer4 = (ImageView)findViewById(R.id.ivPlayerAnswer4);\n item.ivPlayerAnswer4.setImageResource(drawable);\n break;\n }\n}\n\n\nonClick method to get the button clicked will be set background for image of position (image1: position = 0, image2: position = 1, ...)\n\n@Override\npublic void onClick(View view) {\n switch (view.getId()){\n case R.id.ivChoice1:\n setBackground(position, intRes[0]);\n break;\n case R.id.ivChoice2:\n setBackground(position, intRes[1]);\n break;\n case R.id.ivChoice3:\n setBackground(position, intRes[2]);\n break;\n case R.id.ivChoice4:\n setBackground(position, intRes[3]);\n break;\n case R.id.ivChoice5:\n setBackground(position, intRes[4]);\n break;\n case R.id.ivChoice6:\n setBackground(position, intRes[5]);\n break;\n }\n position++; //postion (0, 1, 2, 3...) of each image on item of listview (position is from left to right)\n if(position > 3){\n itemID++; //id of listview 0, 1, 2, 3...\n position = 0;\n }\n}\n\n\ngetView method like below:\n\n@Override\npublic View getView(int position, View view, ViewGroup parent) {\n LayoutInflater inflater = ((Activity) context).getLayoutInflater();\n\n ViewListItem item; //item of listview\n if(view==null)\n {\n view = inflater.inflate(R.layout.item_list, null);\n item = new ViewListItem(this.context);\n\n item.ivSuggestAnswer1 = (ImageView)view.findViewById(R.id.ivSuggestAnswer1);\n item.ivSuggestAnswer2 = (ImageView)view.findViewById(R.id.ivSuggestAnswer2);\n item.ivSuggestAnswer3 = (ImageView)view.findViewById(R.id.ivSuggestAnswer3);\n item.ivSuggestAnswer4 = (ImageView)view.findViewById(R.id.ivSuggestAnswer4);\n item.ivPlayerAnswer1 = (ImageView)view.findViewById(R.id.ivPlayerAnswer1);\n item.ivPlayerAnswer2 = (ImageView)view.findViewById(R.id.ivPlayerAnswer2);\n item.ivPlayerAnswer3 = (ImageView)view.findViewById(R.id.ivPlayerAnswer3);\n item.ivPlayerAnswer4 = (ImageView)view.findViewById(R.id.ivPlayerAnswer4);\n\n view.setTag(item);\n } else {\n item = (ViewListItem)view.getTag();\n }\n\n return view;\n }\n}\n\n\nThis only set for first item listView, the other item of listView can not set for them."
]
| [
"android"
]
|
[
"Loop in a activity diagram",
"I am trying to design an activity diagram for an image editing application. Let's say that the application has one adjustment to edit an image. that's brightness. When the user opens the application he can change the brightness again and again. Then finally save it. That's really not a loop. but it's a repetitive process. How can I represent such a process. I have found stack answers for looping through documents and for loops. But didn't found a matching scenario for like this.\nThank you!"
]
| [
"uml",
"diagram",
"activity-diagram"
]
|
[
"Programmatically, what needs to be done to use X.509 Client Certificates in your calls to SAP?",
"I'm currently using User ID / password basic authentication. What do I need to do, in order to start using X.509 Digital Certificates?\n\nMy web application is written in C# and is running on top of IIS.\n\nAdditional info: I'll be invoking BAPIs/ zBAPIs with code generated by Rafael My SAP Proxy Visual Studio Plug-in: http://tools.rafaelc.net/default.aspx?id=72. It automatically generates a proxy code.\n\nI'm wondering wether this generated code can be changed to use client certificates and, in this case, what do I need to do."
]
| [
"c#",
"iis",
"sap",
"x509certificate"
]
|
[
"Batch renaming a file name with specific conditions",
"I want to batch rename a set of files in a folder with specific conditions, which is (add prefix, start from a specific number and increase in +1 series, skip a specific number in the series, add files with same number using an underscore)\n\nI have a set of scanned document files, starting from a specif number let's say 10 and increments with 1. Ex 10,11,12,...\n\n.But some files will be missing for ex maybe 13 will be missing, so need an option to skip that 13 and start with 14. Also some documents will be 2 pages, so need to put underscore to distinguish. For ex 15th document is 2 pages, so need to put 15_2 for the second file.\n\nUPDATE1: I have fixed almost everything, now its working perfectly, but now i need to do two things\n1. Need a while loop to check whether the entered number for skip is less than or equal to x. \n\n\nI have no idea on how to do the below condtion:\n\n\nAlso some documents will be 2 pages, so need to put underscore to distinguish. For ex 15th document is 2 pages, so need to put 15_2 for the second file.\n\nUPDATE 2 : I have added the condition for when there in repeated files but syntax error as below\nUPDATE 3 : My friend helped me to get rid of the syntax error.\n\nUPDATE 4 : My friend helped with some logic and i have solved the puzzle, updated here for reference. Thank you Jishnu\n\nline 20\ni -= 1 and dst = pre.upper() + str(i) + \"_2.pdf\"\n\n\nimport os\n\npre = str(input(\"Enter prefix : \"))\n\nwhile pre not in (\"cin\", \"CIN\", \"CRT\", \"crt\", \"inv\", \"INV\", \"DO\", \"do\"):\n pre = str(input(\"Please check the entered prefix and try again : \"))\n\nx = int(input(\"Enter first no : \"))\nskip = int(input(\"Skip : \"))\nrt = int(input(\"Enter repeating number\"))\nrt = rt + 1\ndef main():\n i = x\n\n\n for filename in os.listdir(\"C:/Users/Ajeshhome/Desktop/scan/\"):\n if skip == i:\n i += 1\n dst = pre.upper() + str(i) + \".pdf\"\n src = 'C:/Users/Ajeshhome/Desktop/scan/' + filename\n dst = 'C:/Users/Ajeshhome/Desktop/scan/' + dst\n os.rename(src, dst)\n i += 1\n\n elif rt == i:\n dst = pre.upper() + str(i-1) + \"_2.pdf\"\n src = 'C:/Users/Ajeshhome/Desktop/scan/' + filename\n dst = 'C:/Users/Ajeshhome/Desktop/scan/' + dst\n os.rename(src, dst)\n i += 1\n else:\n dst = pre.upper() + str(i) + \".pdf\"\n src = 'C:/Users/Ajeshhome/Desktop/scan/' + filename\n dst = 'C:/Users/Ajeshhome/Desktop/scan/' + dst\n os.rename(src, dst)\n i += 1\n\ndef lis():\n\n path = 'C:/Users/Ajeshhome/Desktop/scan/'\n\n files = []\n # r=root, d=directories, f = files\n for r, d, f in os.walk(path):\n for file in f:\n if '.pdf' in file:\n files.append(os.path.join(r, file))\n\n for f in files:\n print(f)\n\n\n\n\n\n\n# Driver Code\nif __name__ == '__main__':\n # Calling main() function\n main()\n lis()\n os.system('pause')"
]
| [
"python",
"python-3.x"
]
|
[
"Calling C code from C# - stuck with a couple of issues",
"I have some C code that and I trying to use from C#. Most of the conversion is done. I have a couple of issues though.\n\nPart of the 'C' code looks like this.\n\ntypedef struct r_GetCPL {\n\n UInt8 Storage;\n UInt8 Key[16]; //(1) \n\n UInt8 *Buff; //(2)\n Array16 *CryptoKeyIDs; //(3)\n\n} REPLY_GETCPL;\n\n\nalias defined in 'C'\n\ntypedef unsigned char UInt8;\ntypedef unsigned short UInt16;\ntypedef unsigned long UInt32;\ntypedef unsigned long long UInt64;\n\ntypedef UInt8 Array8[8];\ntypedef UInt8 Array16[16];\ntypedef UInt8 Array32[32];\ntypedef UInt8 Array64[64];\ntypedef UInt8 Array128[128];\n\n\nI am assuming I can replace the typedef with a direct struct definition. Is this fine?\nThe equivalent C# struct I defined is,\n\npublic struct REPLY_GETCPL \n{\n Byte Storage;\n Byte[16] Key; //(1) Is this right?\n\n UInt8 *Buff; //(2) What is the equivalent?\n Array16 *CryptoKeyIDs; //(3) What is the equivalent?\n}\n\n\nAlso, There are a couple of methods import that I am stuck at\n\nvoid hex_print(char* data, UInt32 length);\nDRMKLVItem *NewDRMKLVItem(UInt32 lenBuff, UInt32 cmdId);\nRESULT DRMKLVLengthDecode(const UInt8 *s, UInt32 *pLen);\n\n\nC#\n\n//I think this one is defined right\n[DllImport(\"DoremiSource.dll\")]\npublic static extern void hex_print([MarshalAs(UnmanagedType.LPStr)]string data, UInt32 length);\n\n//(How to convert the function return type?)\n[DllImport(\"DoremiSource.dll\")]\npublic static extern DRMKLVItem *NewDRMKLVItem(UInt32 lenBuff, UInt32 cmdId); //(4)\n\n//(How do i convert the function parameters here)\n[DllImport(\"DoremiSource.dll\", CharSet = CharSet.Ansi)]\npublic static extern int DRMKLVLengthDecode(const UInt8 *s, ref UInt32 pLen); //(5)"
]
| [
"c#",
"c"
]
|
[
"Nodejs extra-security actions necessary if frontend uses SSL?",
"I developed a website that will be hosted on a webhosting server with dedicated IP in order to be able to use SSL (https). \nThis website makes some calls to a node.js app running on a VPS i am hiring. In this VPS i have some sensible data (database) and in the app i have a sensible user and password. I would like to know if the frontend uses SSL is enough to secure my VPS and app.js, or if there are some other actions i should perform.\n\nAlso i would be grateful if you can advise which is the best solution to hire: Dedicated IP WebHosting(frontend) + VPS (backend) Versus VPS (backedn and frontend). It's my first website and I need some experienced advices.\n\nRegards,"
]
| [
"node.js",
"security",
"ssl",
"action",
"frontend"
]
|
[
"Center image in row with floated element",
"I am working with bootstrap 3 and want to center a logo on a page, but also include a button to its right. The logo should center across the page, and disregard the button's width.\n\nI have achieved this with JS but i want a pure CSS solution. I am using LESS if this helps.\n\n\r\n\r\n$(document).ready(function() {\r\n var logo = $('.logo img');\r\n var pdfBtn = $('#pdf-button');\r\n var win = $(window);\r\n\r\n var alignlogo = function() {\r\n var pdfBtnWidth = pdfBtn.outerWidth();\r\n logo.css({\r\n 'position': 'relative',\r\n 'left': pdfBtnWidth / 2\r\n })\r\n };\r\n\r\n win.on('load resize orientationchange', alignlogo);\r\n});\r\n.transaction-head {\r\n text-align: center;\r\n}\r\n.transaction-head-logo {\r\n max-width: 200px;\r\n max-height: 50px;\r\n margin-bottom: 20px;\r\n @media screen and (min-width: @screen-sm) {\r\n max-width: 300px;\r\n max-height: 75px;\r\n }\r\n}\r\n<script src=\"https://code.jquery.com/jquery-1.12.4.min.js\" integrity=\"sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=\" crossorigin=\"anonymous\"></script>\r\n<div class=\"transaction-head\">\r\n <div class=\"top-block clearfix\">\r\n <a id=\"pdf-button\" class=\"btn btn-primary pull-right\" href=\"/url/to/generate/pdf\" target=\"_new\">\r\n Download PDF\r\n </a>\r\n <div class=\"logo\">\r\n <img class=\"transaction-head-logo\" src=\"url/to/logo\">\r\n </div>\r\n </div>\r\n</div>"
]
| [
"html",
"css",
"twitter-bootstrap"
]
|
[
"Why isn't Google's Closure library hosted on their CDN?",
"Google hosts a number of JavaScript libraries such as jQuery and dojo on their CDN. For some reason, their own Google Closure library does not seem to be included. Is there a hosted version of the Closure library?"
]
| [
"javascript",
"cdn",
"google-closure",
"google-cdn"
]
|
[
"How can I create a UI that is visible even when other applications are in fullscreen for mac?",
"I'm trying to create a UI that is visible at all times even when I switch over to a fullscreen application for mac. For example, something similar to zoom being being able to show participant information even when you switch over to fullscreen safari. See image below. This can be done in any language but preferably java or python.\nZoom example which has mute/video options visible in fullscreen safari"
]
| [
"user-interface"
]
|
[
"How to adjust the cursor size using AppleScript?",
"We can adjust the cursor size in System Preferences -> Accessibility -> Display. How to do this using AppleScript? Maybe do shell script \"....\" or tell application \"System Preferences\"?"
]
| [
"macos",
"shell",
"cursor"
]
|
[
"How to convert UTF-8 String to String US-ASCI codepage 437 when send String to bluetooth printer with codepage CP437 US-ASCII android studio",
"How to convert UTF-8 String to String US-ASCI codepage 437 when send String to bluetooth printer who is with embeded codepage CP437 US-ASCII from Android studio?\n\nI'm new to Android studio. I have little bit older POS printer with bluetooth. In my app I send to printer some strings for example the name of articles ( items) . Strings are in UTF-8 format from date base and also in utf-8 in String variables in Android Studio. POS printer have embedded codepage CP437 , US-ASCI. How I can transform string variable from UTF-8 to CP437 US-ASCI or replace only special character for example Š,š,Č,č,Ć,ć,Đ,đ,Ž,ž with another, etc S,s,C,c,D,d,Z,z... or maybi define my own nice (normal) visiably character before send to printer . \n\nThank You very much for answers...\n\nI tray on this way, but it not work good. Print results are hieroglyphics for special letters...\n\n nameitem=substring(format(\"%1$\"+ (-18)+\"s\",somearray[0]),0,18); \n\n byte[] b= nameitem.getBytes(\"UTF-8\");\n nameitem = substring(new String(b, StandardCharsets.US_ASCII),0,18);\n doprint(nameitem);\n\n\nOn printer I have hieroglyphics results for that chars(letters) etc:\n?1/2ß÷×~a....\nI wish to have\nCcScD..\nOr maybe in best solution, defined on some own way graphically\nČ抚Đ..."
]
| [
"android",
"android-studio"
]
|
[
"JQuery scrollTo plugin becomes Jerky on iOS",
"I'm using the JQuery scrollTo plugin on our one-page site to vertically scroll between the different sections.\n\nThe scroll works well in all browsers except iOS Safari which scrolls but is very jerky. I'm using a number of other Jquery plugins on the page so it may be a conflict with one of these.\n\nIf anyone knows an alternative to scrollTo that works smoothly on the iPad or can suggest where to start tackling the issue I'd appreciate the help. I've tried this solution but without success."
]
| [
"jquery",
"ios",
"scrollto",
"flicker"
]
|
[
"Use HTML formatting in SVG for text alignment",
"I'm trying to make the numbers in this code line up regardless if they are positive or negative.\n\n\r\n\r\npointer_labels = [\"PANTS\", \"SOCKS\", \"SHOES\"]\r\nvals = [0, 0.8, -0.2]\r\n\r\nvar svg = d3.select(\"#root\").append(\"svg\")\r\nvar texts = svg.selectAll(\"text\").data(pointer_labels);\r\n\r\ntexts.enter()\r\n .append(\"text\")\r\n .attr(\"x\", 15)\r\n .attr(\"y\", function(d, i) {\r\n return i * 20 + 9;\r\n })\r\n .html(function(d, i) {\r\n var sign = '<foreignObject x=\"20\" y=\"9\" width=\"150\" height=\"200\">&nbsp;<span>&plus</span></foreignObject>';\r\n if (vals[i] < 0) {\r\n sign = \"&nbsp;&minus;\";\r\n }\r\n return pointer_labels[i] + \" \" + sign + Math.abs(vals[i]).toFixed(2);\r\n });\r\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js\"></script>\r\n<div id=\"root\">\r\n</div>\r\n\r\n\r\n\n\nI'm trying to accomplish this by inserting an invisible minus sign, but whenever I insert an HTML tag, the text isn't displayed, despite being inserted into the DOM. I've reviewed the questions similar to this one and have tried the foreignObject trick, but that doesn't seem to be working either.\n\nNote that the reason I'm using SVG despite the fact that I seem only to be working with text, is that this is actually for plot legends that I'm making. This is how it looks in the actual application:"
]
| [
"javascript",
"html",
"d3.js",
"svg"
]
|
[
"Importing a package from within a directory fails",
"I have a project directory structure as follows:\n\nrootdir/\nsomefile.py\n- proj/\n - __init__.py\n - __main__.py\n - file1.py\n - file2.py\n\n\nfile2 has an import, from file1 import some_module\n\nWhen I am in rootdir and I call something like import proj.file2.bla_bla as bla_bla from somefile.py\n\nI get an error like\n\nerror in file2\n\n\n cannot find file1 or no such module such as file1 \n\n\nWhat do you think is going wrong?"
]
| [
"python",
"python-3.x",
"import",
"codebase"
]
|
[
"how do I set a delegate in a view that is not my main view",
"I have a xib. the xib has a button that swaps another xib.\n\nthe second xib has a uitextfield and a uilabel.\n\nhow do I make the keyboard go away when I'm done typing? what do I need to wire or code? the second xib has it's own class (called CustomSign.m)\n\nInside CustomSign.m, I've implemented the following method\n\n-(void)textFieldDidEndEditing:(UITextField *)textField {\n[customText resignFirstResponder];\nsignedLabel.text = customText.text;\n}\n\n- (void)awakeFromNib\n{\n//assume textField is an ivar that is connected to the textfield in IB\n[customText setDelegate:self];\n}\n\n\nI get the following warning\n\nClass \"CustomSign\" does not implement the UITextFieldDelegate protocol"
]
| [
"objective-c",
"uikit",
"delegates",
"uitextfield",
"uilabel"
]
|
[
"Cannot find POI via google-places-api that can be found on google-maps and google-plus",
"I am trying to find a specific listing via the google-maps-places API, but I don't get any results. This is strange to me, as there is a Google+ page and also a google-maps entry. \n\nLet's take a look at the links: \n\nGoogle+:\nhttps://plus.google.com/115673722468988785755/about\n\nMaps: \nhttps://www.google.de/maps/place/AMWAY+Beratung+%26+Vertrieb+Haegebarth/@53.171976,9.465828,17z/data=!3m1!4b1!4m2!3m1!1s0x47b106116fc69d69:0xe17811ab2780c71d\n\nIf I use the very same coordinates from the maps entry in my nearby search and use the name from the entry as the keyword (or location for what it's worth) the results is empty.\n\nPlaces-API (with exact same coordinates):\nhttps://maps.googleapis.com/maps/api/place/nearbysearch/json?sensor=false&radius=2000&name=amway&location=53.171976,9.465828&language=de-DE&key=YOURKEY \n\nI can of course imagine that the db for the Google+ POIs is a different one. But then again I don't see how the maps api does not find what I can find on the maps web app.\n\nThanks a lot for any help!"
]
| [
"google-maps",
"google-plus",
"google-places-api"
]
|
[
"View inside RelativeLayout not showing up in landscape",
"I'm trying to position two LinearLayouts on the screen: one small one at the bottom and a larger one taking up the rest of the screen space.\n\nThey are inside a RelativeLayout. I have the bottom linear layout set to anchor to the bottom of the screen, with a hardcoded height in dp. The larger LinearLayout is set to be above the bottom one.\n\nThis works as expected in portrait, but I cannot get the bottom (smaller) linearlayout to show up in landscape. Even if I set its height to a very high number. Both layouts look as expected in the Android Studio editor by the way.\n\nHere's the XML:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:layout_weight=\"1\"\n android:background=\"#ff1b284b\"\n android:orientation=\"vertical\">\n\n\n <LinearLayout\n android:orientation=\"horizontal\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_above=\"@+id/plusZoomMinusButtons\">\n\n -- Removed inner views --\n\n </LinearLayout>\n\n <LinearLayout\n android:id=\"@+id/plusZoomMinusButtons\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"40dp\"\n android:gravity=\"top\"\n android:orientation=\"horizontal\"\n\n android:layout_alignParentBottom=\"true\">\n\n -- Removed inner views --\n\n </LinearLayout>\n</RelativeLayout>\n\n\nedit: The problem wasn't even with the layout, I found a piece of code elsewhere in the program that messed with the layout, but only in landscape :|"
]
| [
"android",
"xml",
"layout"
]
|
[
"Worst case scenario in Linear Programming with variable constraints",
"I have a linear optimization problem: \n\nminimize c^T x\nwhere A x = b\n\n\nBut I want to find the 'worst case scenario' when b is flexible (m_i < b_i < M_i). A naive approach would be applying a non-linear optimization to the linear one:\n\nmaximize [minimize c^T x where A x = b] where b_min < b < b_max\n\n\nIs there any better way to do this?\n\nMaybe a real example: \nThe famous diet problem, where we look for a cheapest combination of foods that satisfy all nutritional requirements. But as nutritional requirements aren't completely set (and depend on person and his daily activity), constraints are flexible and we want to find a worst case scenario - what would be most expensive set of constraints - if food combination is optimized.\n\nhttps://en.wikipedia.org/wiki/Bilevel_optimization - this is basically what I need, I'll try the linked optimizer and post the result."
]
| [
"linear-programming",
"nonlinear-optimization"
]
|
[
"How convert spectral image elements to RGB in R language?",
"I'm planning to convert multispectral images to rgb based images- (RGB values of visible spectrum)\n\nBasically, I'm reading png spectral image by \"readPNG\" function in R. \n\nSo, I have 2 dimensions 512X512 matrix. then according to the link above I write function that return values for R,G,B.\n\nNow, my question is how I can apply this RGB to the my image to convert to rgb?\n\nSome part of my code: \n\nimg <-readPNG(\"sample_img.png\") # 512 X 512 Matrix \n\n# after calculate R,G,B \nr = 1\ng = 0.892\nb = 0\n\nel1 <- img * r \nel2 <- img * g\nel3 <- img * b\n\ncol <- as.matrix(el1, el2, el3)\nplot (1:512 , type=\"n\" ) \nrasterImage(col, 1, 1, 512, 512)\n\n\nI'm doing code like above , and still couldn't convert to get color image.\n\n(more information about spectral: multispectral )"
]
| [
"r",
"image-processing"
]
|
[
"javascript on change needs refresh",
"I'm trying to make a textbox, with a counter to show how many signs you have left (pure for user interface purposes, not the actual validation). \n\nI tried to use this code:\n\nfunction checkRemainingChars () {\n\n var maxChars = 500;\n var text = document.getElementById('textArea').value;\n console.log(text);\n var usedChars = text.length;\n var remainingChars = maxChars - usedChars;\n var message = \"<p>\" + remainingChars + \"out of \" + maxChars + \" characters remaining </p>\";\n console.log(message);\n $('#remaining').append(message);\n}\n\n\n$(document).ready( function () {\n\n $('#textArea').on('change',checkRemainingChars());\n\n});\n\n\nwhere #textArea is the textarea where the user puts his text, and #remaining is an aside with the message how much signs he has remaining.\n\nthis only works when the page loads/refreshes. then I tried to add something simple, to eliminate possible mistakes in my code:\n\n$(document).ready( function () {\n\n $('#textArea').on(\"change\",alert(1));\n\n});\n\n\nbut even here I only get the alert when I refresh the page. What do I have to do to make the text update as soon as the user types something?"
]
| [
"javascript",
"jquery",
"onchange"
]
|
[
"What type of arguments does [NSString stringWithFormat] take?",
"I know that the method stringWithFormat is usually used as follows:\n\n[NSString stringWithFormat: @\"%@ %@\", arg1, arg2];\n\n\nMy question is, what exactly is the type of the last argument of this method (the one with ... in the specs).\n\nI want to be able to do something like the following:\n\nNSArray *array = [NSArray arrayWithObjects: @\"Hi\", @\"Bob\"];\n[NSString stringWithFormat: @\"%@ %@\", array]\n\n\nAs you can see one datastructure array is holding all of the arguments. Unfortunately, this doesn't work. Is there a way to do this so that I don't have to explicitly list out all of my arguments in the stringWithFormat method?"
]
| [
"iphone",
"ios",
"objective-c"
]
|
[
"List available generators in rails application",
"How to get a list of available generators in a Rails application, including those from included gems like devise? (Similar to rake -T for a list of rake tasks)"
]
| [
"ruby-on-rails"
]
|
[
"Webkit isn't loading a long JavaScript file",
"I'm having issues where both Chrome and Safari aren't loading all my JavaScript. My file is rather large uncompressed, 16000+ lines, but it's working fine in Firefox and Opera. I'm using Mac as well and haven't tested Windows yet.\n\nDoes anyone know if Webkit clips a file after a certain line number?"
]
| [
"javascript",
"webkit"
]
|
[
"differnce between struct reg and struct user_regs_struc?",
"What is the difference between struct reg and struct user_regs_struc on Linux 64 bit machine?"
]
| [
"ptrace"
]
|
[
"Why my Page Speed Insights have \"?\" as the score",
"Every other data seems fine but the page speed index is displaying error as such\n"Chrome didn't collect any screenshots during the page load. Please make sure there is content visible on the page, and then try re-running Lighthouse. (SPEEDINDEX_OF_ZERO)"\nError that shows "?" while testing my page speed\nMy other Lab Data score\nPlease help me to resolve this issue."
]
| [
"performance",
"pagespeed",
"lighthouse",
"google-pagespeed"
]
|
[
"No component blocks in QuickFIX/N and QuickFix c++",
"In QuickFIX/J, it implements the component blocks, such as quickfix.fix43.component.Instrument.\n\nComponent blocks do not exist in QuickFIX/N and neither in QuickFix c++ version. Why is it so? Is there any quick way to generate the classes in C#?"
]
| [
"quickfix",
"quickfixj"
]
|
[
"dockerd vs docker-containerd vs docker-runc vs docker-containerd-ctr vs docker-containerd-shim",
"This stuff is really getting confused now. Can someone please explain what's going on. Just the straight one liner difference.\n\n\ndockerd\nlibcontainerd\ncontainerd\ndocker-containerd\ndocker-runc\ndocker-containerd-ctr\ndocker-containerd-shim\n\n\nthanks"
]
| [
"docker",
"docker-machine",
"docker-swarm",
"boot2docker"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.