texts
sequence
tags
sequence
[ "Disable error handling for mocha.js", "Does anyone know if there a way to disable error handling by Mocha?\n\nI'd really like to let the exception bubble up and be handled by the browser during debugging.\n\nUpdate:\nThe context is this. \n- Some code throw's an unexpected error. \n- I would like to disable \"try/catch\" (something like jasmine's tests do) and be thrown into the debugger in chrome.\n\nThis way I can inspect the current state of the application at that moment.\nIt sounds like there isn't something built in, and I will need to manually do this each time I get some odd error in a test. Maybe by wrapping my code with\n\ntry {\n somethingThatBreaks();\n} catch(e) {\n debugger;\n}" ]
[ "javascript", "mocha.js" ]
[ "Sitecore Analytics tracking click events", "In a project I am working on tracking click events is done by the following code:\n\nvar goal = new PageEventItem(goalItem);\n\nvar eventRow = Tracker.Current.Interaction.CurrentPage.Register(goal);\neventRow.DataKey = ID;\neventRow.Data = NAME;\neventRow.Text = DATA;\n\n\nThis will be recorded to the interactions table on MongoDB, What I need know is to create a report that display these registered data? so my question is how I can read these data from MongoDb?" ]
[ "sitecore", "sitecore-analytics" ]
[ "a do-until loop in Swift 3.0", "Is there a condition controlled loop in Swift 3.0 with a posttest that executes so long as the condition is false? If not, what would be the equivalent of a do-until loop in Swift 3.0? What is the performance benefits of the equivalents?" ]
[ "swift", "algorithm", "loops" ]
[ "Neo4j OGM session object creation policy", "I have a web application which exposes api for saving nodes in neo4j.\n\nI am using neo4j OGM.\n\nEvery http request should use an existing neo4j session or create a new neo4j session for every request?" ]
[ "neo4j", "neo4j-ogm" ]
[ "How to save user input img in ImageField in Django", "I'm trying to save a user image in my database. Here below is my input form:\n\n<form method=\"POST\" action=\"/savedata/\">\n{% csrf_token %}\n<input id=\"file-upload\" type=\"file\" accept=\"image/*\" name='profileimg' />\n<input type=\"submit\" value=\"upload\">\n</form>\n\n\nHow could I save the selected image in the database using form submit\n\nMy model class:\n\nclass usertab(models.Model):\n img = models.ImageField(upload_to='user_img')\n\n\nI am able to save an image using superuser but I need to save this using submission form, how could I possibly do it?\n\nmany thanks in advance." ]
[ "python", "html", "django" ]
[ "aws s3 can upload via cli and console but not nodejs sdk", "The bucket is configured to have public access disabled, but with the following bucket policy:\n\n{\n \"Version\": \"2012-10-17\",\n \"Id\": \"Policy1571348371588\",\n \"Statement\": [\n {\n \"Sid\": \"Stmt1571348370292\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"AWS\": [\n \"arn:aws:iam::932534461852:user/test-user\"\n ]\n },\n \"Action\": [\n \"s3:GetObject\",\n \"s3:ListBucket\",\n \"s3:PutObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::test.test.com\",\n \"arn:aws:s3:::test.test.com/*\"\n ]\n }\n ]\n}\n\n\nThe IAM is also attached with this policy:\n\n{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"VisualEditor0\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:PutObject\",\n \"s3:GetObject\",\n \"s3:DeleteObject\"\n ],\n \"Resource\": \"arn:aws:s3:::*/*\"\n },\n {\n \"Sid\": \"VisualEditor1\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::test.test.com\"\n },\n {\n \"Sid\": \"VisualEditor2\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:PutAccountPublicAccessBlock\",\n \"s3:ListAllMyBuckets\"\n ],\n \"Resource\": \"*\"\n }\n ]\n}\n\n\nThe bucket's public access setting is:\n\nBlock all public access\nOn\n\n Block public access to buckets and objects granted through new access control lists (ACLs)\n On\n Block public access to buckets and objects granted through any access control lists (ACLs)\n On\n Block public access to buckets and objects granted through new public bucket policies\n On\n Block public and cross-account access to buckets and objects through any public bucket policies\n On\n\n\nI have verified that the cli and the sdk are using the same access key and secret key, and I can use console and cli to upload files without problem, but when I try with node.js's aws-sdk: 2.551.0, I got access denied error.\n\nWhere can go wrong?" ]
[ "amazon-web-services", "amazon-s3", "aws-sdk", "aws-sdk-nodejs" ]
[ "Kivy ScreenManager switch screens leaving buttons", "I am using ScreenManager to swicth screens but when I switch screens normally the buttons on that screen stay with it. I have to copy the buttons to each screen. Is there a way to switch screens while leaving the buttons in place?\n\nThis is my app code as it stands:\n\nimport (...)\n\n\nclass AppContainer(FloatLayout):\n pass\n\n\nclass NavButtons(BoxLayout):\n pass\n\n\nclass FirstScreen(Screen):\n pass\n\n\nclass SecondScreen(Screen):\n pass\n\n\nclass Screens(ScreenManager):\n pass\n\n\nclass MainApp(App):\n def build(self):\n return AppContainer()\n\n\n(...)\n\nand the kv file looks like this:\n\n#:import BoxLayout kivy.uix.boxlayout.BoxLayout\n\n<AppContainer>:\n NavButtons:\n Screens:\n FirstScreen:\n SecondScreen:\n ThirdScreen:\n\n\n<NavButtons>:\n orientation:'vertical'\n Button:\n on_press: root.manager.current=\"first\"\n text: 'First'\n pos_hint:{\"top\": 1, \"left\": 0}\n Button:\n on_press: root.manager.current=\"second\"\n text: 'Second'\n pos_hint:{\"top\":0.8, \"left\": 0}\n<Button>:\n size_hint: 0.2, 0.2\n\n\n<FirstScreen>:\n name: \"first\"\n Label:\n text: \"First Screen\"\n\n\n<SecondScreen>:\n name: \"second\"\n Label:\n text: \"Second Screen\"\n\n\nBut this throws an error: AttributeError: 'NavButtons' object has no attribute 'manager'\n\nAny ideas?" ]
[ "python", "kivy", "kivy-language" ]
[ "what is the best way to enter multiple child records in a web form", "for example, we have a web form to let the user enter personal info such as address and phone number, then the user need to enter the spouse and dependents information. I usually use a gridview for this, but some users complain it is difficult to use. so what is the most user-friendly or conventional way to handle it? \n\nthanks." ]
[ "user-interface" ]
[ "id_rsa invalid format in Dockerfile when using Makefile", "I am attempting to pass an SSH key into a Dockerfile so I can pull down private repos from Git.\n\nIt works when I use this on the command line\n\nexport SSH_PRIVATE_KEY=\"$(cat ~/.ssh/id_rsa)\"\ndocker build --build-arg SSH_PRIVATE_KEY --tag image:latest .\n\n\nBelow is a snippet of my Dockerfile\n\nARG SSH_PRIVATE_KEY\n\nRUN apt-get update && apt-get install -y git && apt-get install -y nano && \\\n apt-get update && apt-get install -y python3.7 python3-pip python3.7-dev && \\\n rm -rf /var/lib/apt/lists/*\n\nRUN mkdir -p ~/.ssh && umask 0077 && echo \"${SSH_PRIVATE_KEY}\" > ~/.ssh/id_rsa \\\n && git config --global url.\"[email protected]:\".insteadOf https://github.com/ \\\n && ssh-keyscan github.com >> ~/.ssh/known_hosts\n\n\nHowever when I try and run it from a makefile like so\n\nSSH_PRIVATE_KEY=$(shell cat ~/.ssh/id_rsa)\n\n\nbuild-image:\n docker build --build-arg SSH_PRIVATE_KEY=\"${SSH_PRIVATE_KEY}\" --tag image:latest -f ./docker/Dockerfile .\n\n\nI get the error \n\n\n Load key \"/root/.ssh/id_rsa\": invalid format\n\n\nAm I doing anything obviously wrong here?\n\nThanks!" ]
[ "docker", "github", "makefile", "dockerfile", "ssh-keys" ]
[ "Sequential Row IDs in Column Oriented DBs (HBase, Cassandra)?", "I've seen two contradictory pieces of advice when it comes to designing row IDs in HBase, (specifically, but I think it applies to Cassandra as well.)\n\n\nGroup keys that you'll be aggregating together often to take advantage of data locality. (White, Hadoop: The Definitive Guide and I recall seeing it on the HBase site, but can't find it...)\nSpread keys around so that work can be distributed across multiple machines (Twitter, Pig, and HBase at Twitter slide 14)\n\n\nI'm guessing which one is optimal can depend on your use case, but does anyone have any experience with either strategy?" ]
[ "nosql", "cassandra", "hbase", "column-oriented" ]
[ "What's the rationale of the exceptions of temporary object lifetime expansion when bound to a reference?", "In 12.2 of C++11 standard:\n\nThe temporary to which the reference is bound or the temporary that is\nthe complete object of a subobject to which the reference is bound\npersists for the lifetime of the reference except:\n\nA temporary bound\nto a reference member in a constructor’s ctor-initializer (12.6.2)\npersists until the constructor exits.\n\nA temporary bound to a\nreference parameter in a function call (5.2.2) persists until the\ncompletion of the full-expression containing the call.\n\nThe lifetime\nof a temporary bound to the returned value in a function return\nstatement (6.6.3) is not extended; the temporary is destroyed at the\nend of the full-expression in the return statement.\n\nA temporary\nbound to a reference in a new-initializer (5.3.4) persists until the\ncompletion of the full-expression containing the new-initializer.\n\n\n\nAnd there is an example of the last case in the standard:\nstruct S {\n int mi; \n const std::pair<int,int>& mp;\n}; \nS a { 1,{2,3} }; // No problem.\nS* p = new S{ 1, {2,3} }; // Creates dangling reference\n\nTo me, 2. and 3. make sense and easy to agree. But what's the reason bebind 1. and 4.? The example looks just evil to me." ]
[ "c++", "c++11", "object-lifetime", "temporary-objects" ]
[ "@Resource private WebServiceContext context is giving null value", "I am trying to take ServletContext in my web service ,but WebServiceContext is always NULL.Can anyone tell what am I doing wrong, I am using spring framework and tomcat.\n\npackage com.xyz.webser;\n\nimport java.sql.Timestamp;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Properties;\nimport java.util.Set;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\nimport javax.annotation.Resource;\nimport javax.jws.WebService;\nimport javax.servlet.http.HttpSession;\nimport javax.servlet.ServletContext;\nimport javax.xml.ws.WebServiceContext;\nimport javax.xml.ws.handler.MessageContext;\nimport org.apache.commons.lang3.ObjectUtils;\nimport org.apache.commons.lang3.StringUtils;\nimport org.apache.commons.logging.Log;\nimport org.apache.commons.logging.LogFactory;\nimport org.springframework.beans.factory.annotation.Autowired;\n\n@WebService(serviceName = \"myWebService\", endpointInterface = \"com.xyz.webser.MyWebService\")\npublic class MyWebServiceImpl implements MyWebService {\n\n @Resource\n private WebServiceContext context;\n\n public void setContext(WebServiceContext context) {\n this.context = context;\n}" ]
[ "web-services", "tomcat" ]
[ "Calculating days to a specific date", "Dim intYear, intMonth, intDay As Integer, strResult As String, tspResult As TimeSpan\n\n\n intYear = Integer.Parse(txtYear.Text)\n intMonth = Integer.Parse(txtMonth.Text)\n intDay = Integer.Parse(txtDay.Text)\n\nDim dteDatum As New System.DateTime(intYear, intMonth, intDay)\n\n tspResult = Now.Subtract(dteDate)\n strResult = Math.Abs(tspResult.Days).ToString\n MessageBox.Show(strResult)\n\n\nFor example:\ntoday it is the 1st of october and i want to know how many days till the 4th of october.\nThe program will say 2days but that's wrong, it must be 3 days.\nHow can i fix this?\n(Calculations in the past are good)\nThanks in advance and sorry if my english sucks." ]
[ "vb.net", "datetime" ]
[ "MouseDown event for NSButton?", "I'm trying to call an ibaction method when an NSButton is clicked down, but I can't figure out how to get do to that instead of having it called when clicked up." ]
[ "objective-c", "xcode", "macos", "ibaction", "nsbutton" ]
[ "Process not running if tooltip open", "I have a function that checks to see if a given process is running and it works except for when that process has a tooltip open. If the process does have a tooltip open then this function returns false and i can't seem to figure out the problem.\n\npublic static bool isRunning(string progName, bool isId, int id)\n{\n foreach (Process pro in Process.GetProcesses(\".\"))\n if (isId)\n {\n if (pro.Id == id)\n return true;\n }\n else\n {\n if (pro.ProcessName == progName)\n return true;\n }\n\n return false;\n}\n\n\nAn example of calling this function - isRunning(\"chrome.exe\", false, -1) or isRunning(\"\", true, 248).\nIs there something I am doing wrong or something else i need to check for?\n\nHere is the full code for the file: http://ideone.com/9CUJ5V\n\nEDIT: I partially solved my issue. I added this:\n\nforeach(Process pro in Process.GetProcessesByName(progName)){\n if(pro.MainWindowHandle != (IntPtr)0)\n return true;\n\n\nAccording to the msdn Documentation on Process.MainWindowHandle, it will return zero if it does not have a graphical interface. \n\nBut the next issue is, for example, if I am running steam minimized to the taskbar (so no window actually visible), it returns true." ]
[ "c#", "winforms", "process", "tooltip" ]
[ "Nested http requests with map with rxjs in Angular2", "I'm new to Rxjs (and Angular2 in general) and I'm having trouble understanding the subtleties of RxJS.\n\nI want to make two REST calls to the GitLab API: \n\n\nReceive all the groups of a certain user (via gitlab.com/api/v4/groups). this will give me back a JSON like this one:\n\n[\n{\n \"id\": 1511397,\n \"name\": \"some name\",\n \"parent_id\": 1505403,\n...\n},\n{\n \"id\": 1511403,\n \"name\": \"some other name\",\n \"parent_id\": 1505403,\n...\n}\n]\nReceive all the projects of per group (via gitlab.com/api/v4/groups/:id) which give you a detailed version of 1 group:\n\n{\n\"id\": 1511397,\n\"name\": \"group name\",\n\"parent_id\": 1505403,\n\"projects\": [\n {\n \"id\": 3099499,\n \"description\": \"project 1\"\n },\n {\n \"id\": 3099489,\n \"description\": \"Project 2\"\n }\n]\n}\n\n\nSo basically I need to loop over all ID's given by the first request and deliver an array of group-details:\n\n[\n {\n \"id\": 1511397,\n \"name\": \"group name\",\n \"parent_id\": 1505403,\n \"projects\": [\n {\n \"id\": 3099499,\n \"description\": \"project 1\"\n },\n {\n \"id\": 3099489,\n \"description\": \"Project 2\"\n }\n ]\n },\n {\n \"id\": 1194997,\n \"name\": \"a second group name\",\n \"parent_id\": 152393,\n \"projects\": [\n {\n \"id\": 9423423,\n \"description\": \"project 3\"\n },\n {\n \"id\": 2394238,\n \"description\": \"Project 4\"\n }\n ]\n }\n]\n\n\nHow can this be done? I already tried something along the lines of switchMap, concatMap and MergeMap, but I never can get it to work..." ]
[ "angular", "gitlab", "rxjs", "angular2-observables" ]
[ "Android Facebook SDK2.3, session state stay OPENING in ActivityResult", "I check some issues similary to mine,and know it may be wrong about my Override method,but I couldn't find where the problem is.In main activity I Override the onActivityReslut: \n\n@Override\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n facebookLoginPlugin.onActivityResult(requestCode, resultCode, data);\n}\n\n\nfacebookLoginPlugin is a instace of Class FBLogin;\n\nfacebookLoginPlugin = new FBLogin(this);\n\n\nand in FBLogin I call onActivityResult like this:\n\npublic void onActivityResult(int requestCode,int resultCode,Intent data)\n{\n uiHelper.onActivityResult(requestCode, requestCode, data);\n Session session = Session.getActiveSession();\n session.onActivityResult(activity, requestCode, resultCode, data);\n\n Log.i(TAG,\"onActivityResult =====\"+session.isOpened()+\" \"+session.isClosed());\n String status = getStatus(0);\n Log.i(TAG,\"status of facebook now is \"+status);\n Log.i(TAG,\"resultCode =\"+resultCode);\n}\n\n\nbut when I loggin to facebook I got session.isOpend()==false,and the status now is \"Openging\",I am sure the keyhash and the appid can work for the sampleHellofacebook,and the dashboad implement that I am loginto the app ,please help,thanks." ]
[ "android", "facebook" ]
[ "How to create a javafx 2.0 application MDI", "How to implement something kinda internal frame in JavaFx 2.0 specifically?\n\nMy attempt is as so..\n\nimport javafx.application.Application;\nimport javafx.event.ActionEvent;\nimport javafx.event.EventHandler;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Button;\nimport javafx.scene.layout.StackPane;\nimport javafx.stage.Stage;\n\npublic class Main extends Application {\n\n ConnectDb connection;\n\n public static void main(String[] args) {\n Application.launch(args);\n }\n\n @Override\n public void start(Stage stage) throws Exception {\n final Stage stage1 = new Stage();\n StackPane pane = new StackPane();\n Button btn = new Button(\"Click Me\");\n btn.setOnAction(new EventHandler<ActionEvent>() {\n @Override\n public void handle(ActionEvent event) {\n connection = new ConnectDb();\n try {\n connection.start(stage1);\n } catch (Exception e) {\n e.printStackTrace(); \n }\n System.out.println(\"Fire some thing..\");\n }\n });\n pane.getChildren().add(btn);\n stage.setScene(new Scene(pane ,200, 300));\n stage.show();\n }\n}\n\n\nConnectDb.java\n\nimport javafx.application.Application;\nimport javafx.event.ActionEvent;\nimport javafx.event.EventHandler;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Button;\nimport javafx.scene.layout.StackPane;\nimport javafx.stage.Stage;\n\npublic class ConnectDb extends Application {\n\n @Override\n public void start(Stage stage) throws Exception {\n StackPane pane = new StackPane();\n Button btn = new Button(\"Click On Button which is me\");\n btn.setOnAction(new EventHandler<ActionEvent>() {\n @Override\n public void handle(ActionEvent event) {\n System.out.println(\"Something here..\");\n }\n });\n pane.getChildren().add(btn);\n stage.setScene(new Scene(pane ,200, 300));\n stage.show();\n }\n}" ]
[ "modal-dialog", "javafx", "mdi" ]
[ "How to speed up Copy Paste Values when using Offset", "I want make this basic function of \"copy&paste-values-on-a-new-row-each-time\" run as fast as possible since the macro repeats the calculations hundreds of thousands of times. I just can't find the exact answer after searching this forum for ages.\n\nCurrently, I'm copying output numbers from a fixed range and, elsewhere on the worksheet, pasting the values on a new row for each new set of results.\n\nHere's the portion of the code doing this:\n\nRow = Row +1\nRange(\"g15:ax15\").copy\nRange(\"ea18\").select\nActiveCell.Offset(Row,0).select\nSelection.PasteSpecial Paste:=xlPasteValues\n\n\nNow from what I have found on this forum, I can replace the Copy/Paste functions completely with Range(destination).value = Range(results).value to speed things up. However, I can't figure out how to do this if the destination rows need to be offset by 1 each time. Also, I've read that one could even do away with \"select\" to speed things up further! How?" ]
[ "excel", "vba" ]
[ "How to convert list of lists in tuple to list of lists in python?", "I have this as output:\n\nL = ([['AAA', '193.0', 'GGG']], [['BBB', '196.33333333333334', 'TTT']], \n[['CCC', '18.666666666666668', 'AAA']])\n\n\nI want it to be converted to a list of lists like:\n\nL = [['AAA', '193.0', 'GGG'], ['BBB', '196.33333333333334', 'TTT'], \n['CCC', '18.666666666666668', 'AAA']]\n\n\nI have tried to use\n\nL = list(L)\n\n\nand\n\n[list(elem) for elem in L]\n\n\nand\n\nL = map(list, L)\n\n\nBut I cannot get any of them to work. \nCan someone please help me out?" ]
[ "python", "tuples" ]
[ "_bstr_t to char pointer and calling atof(...)", "Is this code not going to produce an error:\n\n_bstr_t text=n.GetText();\n\n atof((char*)text)\n\n\nWhere text is a double value.\n\nI know that the _bstr_t produces a const char* in the conversion; so I'm not sure if the atof() is going to work?" ]
[ "c++", "com" ]
[ "Highcharts Legend Overlaps with X-Axis", "I'm setting up a chart where the legend is located below the line graph. For some reason, the legend seems to overlap with the x-axis above it. My settings for the legend are as follows:\n\n legend: {\n layout: 'horizontal',\n align: 'center',\n itemWidth: LegendWidth,\n verticalAlign: 'bottom',\n floating: true,\n margin: 25,\n borderWidth: 3,\n useHTML:true,\n }\n\n\nWhere LegendWidth is dynamically set. I've already added a value for margin but it still overlaps." ]
[ "javascript", "highcharts" ]
[ "Adding a price to each item in a listbox - C# .Net, Windows Forms Applications", "I am trying to build an windows forms application with c#.\nThe main functionality of the application is that it is going to allow the user to add items to a shopping cart (an listbox probably) and sum up (to a Label Text) the total price for the products added to this cart. Also, a product can be added more than once. So basically it can be called a shopping cart app.\n\nMy question here is, how can I calculate the total price of items added to the shopping cart? \nBecause, first of all, I have added all the products to this listbox as a list of strings (with Listbox.Items.Add(\"Product1\"). So I don't know how to add a price for each product (string element of this list), and later be able to add it up. \n\nShould I somehow add the products as objects of type Product Class (with 2 properties, name and price)? If so, how do I pass just the name property to the list of listbox items?\n\nSo far, here is some of my main code:\n\npublic Form1()\n{\n InitializeComponent();\n Product products = new Product();\n AddProducts(); \n}\n\nList<string> productList = new List<string>();\n\npublic void AddProducts()\n{\n productNames.Add(\"Product X\");\n productNames.Add(\"Product Z\");\n\n foreach (var product in productList) \n {\n ProductListBox.Items.Add(product);\n }\n}" ]
[ "c#", "listbox", "shopping-cart" ]
[ "In order to get a speed boost for my python program, should I spawn a separate thread or a separate process for logging?", "In order to get a speed boost for my python program, should I spawn a separate thread or a separate process for logging? My program uses a lot of logging and I am not sure if threading is suitable because of GIL. A lot of resources seem to suggest that it should be fine for I/O. I think that logging is I/O but I am not sure what does \"should be fine\" mean for most of the resources out there. I just need speed." ]
[ "python", "multithreading", "performance" ]
[ "Why can be nonstable work of X3D in Win 10 MS Edge and Mozilla Firefox?", "I've launched examples from X3DOM.org. Sphere worked normally, but in Edge it's blown away.\nWhen pasting elementary code for the box, it's not showing.\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <title>Touchsensor in X3DOM</title>\n\n <link href="http://www.x3dom.org/download/x3dom.css" rel="stylesheet" />\n <style>\n #myDiv {\n color: blue;\n margin: 20px 0;\n }\n x3d {\n display: block;\n width: 600px;\n height: 400px;\n background: #EEEEEE;\n border: none;\n }\n </style>\n</head>\n<body>\n\n\n <div id="myDiv">\n Click the sphere to hide this div\n </div>\n\n <x3d>\n <Scene>\n<shape> \n <appearance> \n <material diffuseColor='1 0 0'></material> \n </appearance> \n <box></box> \n </shape> </Scene>\n </x3d>\n\nThere were some warnings in Firefox earlier about GL exhausted and triangles. What's this and why this example doesn't work?" ]
[ "javascript", "shapes", "box", "x3d", "x3dom" ]
[ "Convert mac path to posix in python", "I'm stuck trying to convert a Mac Path to a POSIX path in Python. I want to convert something like this:\n\n'Main HD:Users:sasha:Documents:SomeText.txt'\n\n\nto this:\n\n'/Users/sasha/Documents/SomeText.txt'\n\n\nI know I could simply split the string into a list and then rejoin it with the correct separator. But I believe there must be a much more elegant solution I'm missing, possibly involving the \"macpath\" or \"os.path\" python modules. However, I've not been able to figure out a function within these modules that will do the trick of converting between the two formats.\n\nAn additional problem of the simple string manipulation solution is that if I have multiple HDs, then a simple solution won't work. For instance:\n\nIf you have a path like:\n\n'Extra HD:SomeFolder:SomeOtherText.txt'\n\n\nwe would want that to be converted to:\n\n'/Volumes/Extra HD/SomeFolder/SomeOtherText.txt'\n\n\nNot to:\n\n'/SomeFolder/SomeOtherText.txt'" ]
[ "python", "macos", "path" ]
[ "How to convert Array[String] to String* in scala with spark", "I hava a RDD and a Array[String],I want to convert RDD to DataFrame,the Array[String]'s value are colnames,but DataFrame.toDf() function need a String* type\n\nthis is toDF()'s source code:\n\n def toDF(colNames: String*): DataFrame = ds.toDF(colNames : _*)\n\n\nthis is my code:\n\n val sqlContext = new SQLContext(sc)\n import sqlContext.implicits._\n val arr=Array(\n (1,2),\n (3,2),\n (4,2),\n (5,2),\n (7,2)\n\n )\n val colNames=Array(\"first\",\"second\")\n val df = sc.parallelize(arr,2).toDF(\"??\",\"??\")\n\n\nthis is my expect result:\n\n+-----+------+\n|first|second|\n+-----+------+\n| 1| 2|\n| 3| 2|\n| 4| 2|\n| 5| 2|\n| 7| 2|\n+-----+------+" ]
[ "apache-spark", "apache-spark-sql" ]
[ "only one C# event handler being invoked", "My (admittedly shaky) understanding is that you should be able to add any number of delegates to a C# event, and they all get invoked (in some undefined order). But that does not appear to be the case in my project. I've got it boiled down to two delegates added to the Activated event of an NSButton (this is in MonoMac), like so:\n\nnsButton = new NSButton(new System.Drawing.RectangleF(0, 0, 100, 100));\nnsButton.StringValue = \"Click me!\";\n\nnsButton.Activated += delegate(object sender, EventArgs e) {\n Console.WriteLine(\"Handler 1!\");\n};\nnsButton.Activated += delegate(object sender, EventArgs e) {\n Console.WriteLine(\"Handler 2?\");\n};\n\n\n(and then this button gets added to a window, of course). When I click it, I see \"Handler 1!\" but I do not see \"Handler 2?\" appear in the Console. If I comment out the lines that add handler 1, then handler 2 fires.\n\nIt is behaving exactly as if only the first delegate added works, and any subsequent ones are ignored. But this defies everything I can find about how events in C# are supposed to work. What am I doing wrong?" ]
[ "c#", "events", "delegates", "mono", "monomac" ]
[ "how to implement an toggle functionality for update link", "currently i have an link as mentioned in below format\n\n<%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo(\"update\", \"notes\"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>\n\n\ni would like to apply toggle functionality on update could anyone please help me." ]
[ "ruby-on-rails" ]
[ "How to compose ecto queries with join", "I have three models User, Group, UserMembership.\n\nRelationship among them is \n\ndefmodule Samajika.Group do\n has_many :user_memberships, MyApp.UserMembership\n has_many :users, through: [:user_memberships, :user]\nend\n\n\nUserMembership model has a type column that stores the type of membership. For eg., it might store owner, tenant etc.\n\nNow I want to query Group and get its members who are only tenants.\n\nEcto.assoc(group, :users) |> Repo.all\n\n\nThe above gives me all users. The query looks like this\n\n#Ecto.Query<from u0 in Samajika.User, join: u1 in Samajika.UserMembership,\n on: u1.group_id in ^[1], where: u0.id == u1.user_id, distinct: true>\n\n\nI want to use Ecto query composition to add where clause with type on user_memberships table.\n\nI have added this code in my group\n\ndef tenant(query) do\n from c in query, where: c.type == \"tenant\"\nend\n\n\nand I do this\n\nEcto.assoc(group, :users) |> Group.tenant\n\n\nhowever this adds where clause on the users table, rather than join table user_memberships\n\nWhat should I modify in my tenant function to add the condition on the join table?" ]
[ "elixir", "ecto" ]
[ "editing mode UITableView, cant prevent movement of content view to right", "In my chat application, i can't prevent movement of some content views to right, on screenshot blue bubble with text movement to right in edit mode, can anyone help me?" ]
[ "ios", "uitableview" ]
[ "Extract Salesforce record Id from URL with Zapier Push", "I need a way to extract the Salesforce record ID from a URL using Zapier Push. How can I find the first 3 characters in a string that match the start of the Id like 006 and then return a set number of characters after that?\n\nThe url is formatted as such: \n\nhttps://useindio.lightning.force.com/lightning/r/Opportunity/006f400000AiVufAAF/view" ]
[ "url", "salesforce", "extract", "zapier" ]
[ "How to disable a checkbox \"toggle switch\" from javascript", "I am fairly new to css and html. I tried this for creating a checkbox toggle switch. Now all I want is to disable this toggle switch say on clicking a different button 'Reset', so that it appears to be in OFF state with no background color.\nI am looking for a solution in java script. Not sure if this requires any CSS to be modified. Any help is appreciated." ]
[ "javascript", "html", "css" ]
[ "Rebuild only if the source was modified by a previous command", "I have a python script which extracts information from a C++ source file and writes it to a header file. Whenever this generated header changes (which happens rarely), I want to re-compile it (via the GCC precompiled header feature).\n\nObviously, the command invoking the script depends on the source file, and the recompiling command depends on the header file generated by the script.\n\nadd_custom_command(OUTPUT \"file.pch.h\" COMMAND <script> DEPENDS \"file.cpp\")\nadd_custom_command(OUTPUT \"file.pch.h.gch\" COMMAND <compile> DEPENDS \"file.pch.h\")\n\n\nBut now file.pch.h.gch depends on file.cpp and is recompiled whenever it changes. How can I avoid this?" ]
[ "makefile", "cmake", "precompiled-headers" ]
[ "How can I access system time using NASM?", "How can I access the system time using NASM, on Linux?\n(Editor's note: the accepted answer is for 16-bit DOS with direct hardware access; it would work inside DOSBox. The other answers are actually for Linux.)" ]
[ "linux", "assembly", "time", "x86", "nasm" ]
[ "Reaping zombie process - child", "I am taking command line arguments to main from parent to child and counting them and printing. My question is that i am not sure that i am reaping the child? dont i just need an exit 0\nor do i need to call fork again?\n\n#include <sys/wait.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <string.h>\n\nint main(int argc, char *argv[])\n{\n\nint length = 0;\nint i, n;\n\nint fdest[2]; // for pipe\npid_t pid; //process IDs\nchar buffer[BUFSIZ];\n\n\nif ((pid = fork()) < 0) /* attempt to create child / parent process */\n\n{\n printf(\"fork error\");\n} \n\nif (pipe(fdest) < 0) /* attempt to create pipe */\n printf(\"pipe error\");\n\n/* parent process */\nelse if (pid > 0) { \n close(fdest[0]);\n\n for(i = 1; i < argc; i++) /* write to pipe */\n {\n write(fdest[1], argv[i], strlen(argv[1]));\n }\n\n} else { \n\n /* child Process */\n close(fdest[1]);\n\n for(i = 1; i < argc; i++)\n {\n length +=( strlen(argv[i])); /* get length of arguments */\n }\n\n n = read(fdest[0], buffer, length);\n printf(\"\\nchild: counted %d characters\\n\", n);\n\n}\nexit(0);\n}" ]
[ "c" ]
[ "Adding default record in rails 4.0 throws symbol missing with polymorphic relationship", "I'm a C++ programmer, so I'm not really sure what needs to go into the title. I've stripped the example down as far as I think I can...\n\nRails 4.1.5, ruby 2.0.0p353, Rubymine 6.3.3, Fedora 20\n\nI have no idea why this issue is happening. I'm trying to populate the database with a default Admin on migrate, but I am getting an undefined method while running rake db:migrate.\n\nFirst, the models\n\nclass Login < ActiveRecord::Base\n belongs_to :user, polymorphic: true\nend\n\n\nclass Admin < ActiveRecord::Base\n has_one :login, :as=>:user, :dependent => :destroy, :autosave => true\n accepts_nested_attributes_for :login\n\n def method_missing(symbol, *args)\n self.login.send(symbol,*args)\n end\n\nend\n\n\nBasically, there is a \"is_a\" relationship between admin and login (In the real application, there are other records that can also be logins, but they have different fields). \n\nNext, the migrations\n\n**_create_logins.rb\n\nclass CreateLogins < ActiveRecord::Migration\n def change\n create_table :logins do |t|\n t.string :username\n t.string :password\n t.references :user, polymorphic: true\n t.timestamps\n end\n end\nend\n\n\n**_create_admins.rb\n\nclass CreateAdmins < ActiveRecord::Migration\n def change\n create_table :admins do |t|\n t.string :name\n\n t.timestamps\n end\n end\nend\n\n\nThis works great in the rest of the app: I can call get a admin or whatever in a polymorphic fashion from a login by calling login.user. I can easily add admins in the admin controller. They are all updating the database just fine. Good times are had by all.\n\nFinally, I made a \"create default admin:\n\n**_create_default_admin.rb\n\nclass CreateDefaultAdmin < ActiveRecord::Migration\n def self.up\n down();\n\n Admin.create(:name=>'Default Admin', :login_attributes=>{:username=>'admin', :password=>'password'})\n end\n\n def self.down\n Admin.delete_all\n end\nend\n\n\nSo you can see I'm just trying to create a single Default Admin.\n\nWhen I try running\n\nrake db:drop\nrake db:create\nrake db:migrate\n\n\nI get\n\nundefined method `name=' for nil:NilClass/home/asdf/RubymineProjects/untitled/app/models/admin.rb:11:in `method_missing'\n\n\nFor some reason, the name symbol is not being created, AND loging is nil.\n\nputting a breakpoint in method_missing shows self.login is in fact nil, which I found odd. Putting the breakpoint on super shows login created. Running AFTER you put a breakpoint on super never gets to method_missing. Instead, \n\n unknown attribute: user_id/home/asdf/RubymineProjects/untitled/app/models/admin.rb:7:in `initialize'\n\n\nQuestions\n\n\nWhat is going on here? (What did I do wrong, why is it wrong, and why am I getting this weird behaviour?)\nWhat is the correct way to add default values to a database?\n\n\nUpdate: the error happens if I move the create to seed.rb as well.\nUpdate2: I've determined that the cause of the problem is the method missing (removing that seems to fix the problem). Now to the why the method missing is bad, and how to fix it?" ]
[ "ruby-on-rails", "ruby" ]
[ "jQuery interference in Magento Lightbox, Menu & Tabs", "I am working on editing a template where I need to add a Lightbox that shows up some HTML content on product pages. Precisely, instead of \"Add to Cart\" button there will be a Button that pops over some inline lightbox content. \n\nAll the lightbox alternatives I've looked at, require me to inherit jQuery using CDN. Like this:\n <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\"></script>\n\nAnd the template I am using is using a bunch of custom scripts in head.phtml & other pages.\nLike:\n\n<script type=\"text/javascript\" src=\"<?php echo $this->getSkinUrl('js/ver_menu.js');?>\"></script>\n<script type=\"text/javascript\" src=\"<?php echo $this->getSkinUrl('js/custommenu.js');?>\"></script>\n\n\nSo, when I add this line in head.phtml or even the product page, My Top Menu stops dropping down & The product information tabs stop working and all the information is displayed right on my product page (instead of appearing under their respective tabs).\n\nIs there a way I can avoid this interference between the jQuery scripts to make the lightbox (on product page - view.phtml) work and not have my menu & information tabs affected. \n\nBeen struggling with this for a while and the theme authors aren't willing to help either. \n\nI have already tried to play around with the placement of the jQuery Line I posted above, but no luck. Any way I can use the magento's core jQuery script to make my lightbox work...\n\nAlso, I am using colorbox for the lightbox effect. (http://www.jacklmoore.com/colorbox)\n\nI can't do much but I can offer a dinner & a beer on me to whoever can help me get this resolved. Really counting on you guys..." ]
[ "jquery", "magento", "lightbox", "colorbox", "magento-1.7" ]
[ "Multiple partial views on one main asp.net", "trying to put a strongly typed partial view on a homepage in asp.net but it wont seem to work it, here is my code\n\nnew to asp.net and partial views.\n\nController :\n\n public ActionResult VenuePartial()\n {\n ViewData[\"Message\"] = _entities.VenuePartialList();\n return View();\n }\n\n\nRepository :\n\n public IEnumerable<Venue> VenuePartialList()\n {\n var list = from s in _entities.Venue\n orderby s.name ascending\n select s;\n return list.ToList();\n }\n\n\nIRepository :\n\n IEnumerable<Venue> VenuePartialList();\n\n\nIndex Page :\n\n <%Html.RenderPartial(\"~/Views/Venue/VenuePartial.ascx\");%>\n\n\nAny help would be grateful asap please\nregards T" ]
[ "asp.net-mvc", "controller", "repository", "partial-views", "irepository" ]
[ "PDF file inside webview click not working in few devices", "I need to load a PDF file within my webview on a button click within it. I have used google docs URL for loading the same. It works perfectly in S8 edge(v9.0) but it's not working in S6 edge(v6.0.1). It is not calling the shouldOverrideUrlLoading method even. Not able to understand what is the exact reason for it.\n\nMy code:\n\nprivate final String googleDocs = \"http://docs.google.com/gview?embedded=true&url=\";\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n webView.setWebViewClient(new WebViewClient() {\n\n @Override\n public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {\n if (request.getUrl().toString().endsWith(\"pdf\")) {\n String pdfUrl = googleDocs + request.getUrl().toString();\n view.loadUrl(pdfUrl);\n } else {\n view.loadUrl(request.getUrl().toString());\n }\n return true;\n }\n });\n WebSettings webSettings = binding.webView.getSettings();\n webSettings.setJavaScriptEnabled(true);\n webView.loadUrl(url); \n}" ]
[ "android", "pdf", "webview" ]
[ "Windows 8 store package fails on WACK when login to developer account", "I'm trying to put a simple app on windows store. I made a fail attempt once, I submitted an app which failed to pass WACK, eventually it failed on submission too. Even then, when I try to package an app with my developer account logged in, I get a performance launch error. \n\nEven on a blank app. also right after I create package logged in, my app's package name and provider fields on appmanifest are changes too. app's package name changes to the first app I submitted, and the provider changes to I guess my developer account's key.\n\nI deleted my failed submission on dashboard, deleted all the names I reserved, including the failed one. But even when I reserve a new name and package my app with that name, my package name still changes to the very first one and fails on wack. \n\nBUT, when I create package of my app WITHOUT logging in, I mean without associate with windows store, I can package my app with the name I want and pass the WACK. I hope anyone can help me with this.\n\nEdit: C# application." ]
[ "windows-8", "visual-studio-2012", "package", "windows-store-apps", "app-certification-kit" ]
[ "A function in a class without any decorator or `self`", "I have following class with a function: \n\nclass A: \n def myfn():\n print(\"In myfn method.\")\n\n\nHere, the function does not have self as argument. It also does not have @classmethod or @staticmethod as decorator. However, it works if called with class: \n\nA.myfn()\n\n\nOutput: \n\nIn myfn method.\n\n\nBut give an error if called from any instance: \n\na = A()\na.myfn()\n\n\nError output: \n\nTraceback (most recent call last):\n File \"testing.py\", line 16, in <module>\n a.myfn()\nTypeError: myfn() takes 0 positional arguments but 1 was given\n\n\nprobably because self was also sent as an argument.\n\nWhat kind of function will this be called? Will it be a static function? Is it advisable to use function like this in classes? What is the drawback?\n\nEdit: This function works only when called with class and not with object/instance. My main question is what is such a function called?\n\nEdit2: It seems from the answers that this type of function, despite being the simplest form, is not accepted as legal. However, as no serious drawback is mentioned in any of many answers, I find this can be a useful construct, especially to group my own static functions in a class that I can call as needed. I would not need to create any instance of this class. In the least, it saves me from typing @staticmethod every time and makes code look less complex. It also gets derived neatly for someone to extend my class. Although all such functions can be kept at top/global level, keeping them in class is more modular. However, I feel there should be a specific name for such a simple construct which works in this specific way and it should be recognized as legal. It may also help beginners understand why self argument is needed for usual functions in a Python class. This will only add to the simplicity of this great language." ]
[ "python", "function", "oop" ]
[ "mod rewrite troubles", "I want to use modrewrite to give me clean urls like:\n\nhttp://www.mydomain.com/about/\n\nto be:\n\nhttp://www.mydomain.com/index.php?page=about\n\nAnd to go three layers in. I wrote this but its not working at all:\n\nRewriteRule ^([^/\\.]+)/?$ /index.php?page=$1 [L]\nRewriteRule ^([^/\\.]+)/([^/\\.]+)/?$ /index.php?section=$1&page=$2 [L]\nRewriteRule ^([^/\\.]+)/([^/\\.]+)/([^/\\.]+)/?$ /index.php?section=$1&subsection=$2&page=$3 [L]\n\n\nI tested by adding print_r($_GET); and its empty when I go to\n\nmydomain.com/about/ \n\nEdit, got it working. Stupid me i didnt need the \"/\" above before index.php. \n\nHowever, now it will not show me my css/images. I added this but its still not working.\n\nRewriteRule \\.(css|jpe?g|gif|png)$ - [L]\n\n\nWhat it is doing is appending the url parameters onto the image requests as such:\n\n/page/images/bg.jpg\n\nrather than:\n\n/images/bg.jpg\n\nAny ideas?" ]
[ "php", "regex", "apache", "mod-rewrite" ]
[ "how to get index of first occurence of group in a column?", "C1 C2\n------\na 11\na 2\na 2\nb 2\nb 34\nc 2\nc 4\nc 1\nd 4\n\nhow can i get index of a groupname first occurence\nfor example: in column A first occurence of 'b' index is 4\nlike that i need to get all indexes of first occurence of group" ]
[ "r" ]
[ "Type the returnType of a function that receive dynamic args", "I have a function that receives args that can be either typed as string or as [string, Record<string, string>].\nThis function returns an object for which the keys are either the args of the function if these args are typed string or the first string in the array if these arg are typed [string, Record<string, string>]. All the values of this object are typed as string\nFor example :\nexampleFunction("test1", "test2", ["test3", { result: "randomstring" }], "test4");\n\nshould return something typed like this:\ntype tResult = {\n test1: string;\n test2: string;\n test3: string;\n test4: string;\n};\n\nThis function can take any amount of args and any of those args can be either string or [string, Record<string, string>].\nThe challenge is to type the returnType of this exampleFunction.\nTypescript sandbox link here\nI tried to type it tExampleFunctionReturn<T> with:\ntype tExampleFunctionReturn<T extends tExampleFunctionArgs> = Record<\n T[number] extends string ? T[number] : T[number][0],\n string\n>\n\nBut it does not work.\nCan someone please help me ? Thank you for your answer." ]
[ "typescript" ]
[ "swift switch statement cases have different and shared things to do", "i have code like this\n\nswitch thing {\n case thisThing:\n do thing #1\n do thing #2\n case thatThing:\n do thing #2\n do thing #3\n case anotherThing:\n do thing #4\n default:\n default\n}\n\n\nSo, EVERY case has something that ONLY IT does. Some cases also do the same things as one or more other cases.\n\nIs there a way to accomplish this if I don't want any repetitive code? \n\nOR, is there a much more efficient way of doing this without switch statements at all?? I mean, I could, for example, use if statements, but like switch statements, I can't think of a way to accomplish what I want without using repetitive code.\n\nalso, this example might be more clear than the above\n\nmyFavoriteNumbers = []\nmyLeastFavoriteNumbers = []\n\nswitch myNumber {\ncase 1:\n print(\"my number is number 1\") // do this only for case 1\n myFavoriteNumbers += [1] // do this for case 1 and case 2\ncase 2:\n print(\"this is number 2\") // do this only for case 2\n myFavoriteNumbers += [2] // do this for case 1 and case 2\ncase 3:\n print(\"I don't like number 3\") // do this only for case 3\n myLeastFavoriteNumbers += [3] // do this for case 3 and case 4\ncase 4:\n print(\"Number Four\") // do this only for case 4\n myLeastFavoriteNumbers += [4] // do this for case 3 and case 4\ndefault:\n print(\"Default\")\n}" ]
[ "ios", "swift", "switch-statement", "control-flow" ]
[ "How to replace a values present of a url in a text file", "I have a har file which consist of lot of http values and site information. my requirement is to find and replace the \"http://testing.smart\" to \"http://staging.smart\" in all occurrences of the same file. How to do this in shell ?\n\nExample\ntest.har\n\nOutput:\nReplace all \"http://testing.smart\" modified to \"http://staging.smart\" in test.har\n\nThanks!!" ]
[ "shell", "jenkins", "find", "replaceall", "har" ]
[ "Jasper Report with Map of the world and circles of different color as overlay on top of different countries", "I've created a jasper report with the image and a set of small ellipse/circle on top of that image. The color of the small cirles has to change based on the data that is used for generating the report. So I created a style and applied that style to the ellipse element. Here is my style:\n\n<style name=\"ZFieldStyle\">\n <conditionalStyle>\n <conditionExpression><![CDATA[$F{value} < 2L]]></conditionExpression>\n <style backcolor=\"#00ff00\"/>\n </conditionalStyle>\n <conditionalStyle>\n <conditionExpression><![CDATA[$F{value} > 2L]]></conditionExpression>\n <style backcolor=\"#FF0000\"/>\n </conditionalStyle>\n</style>\n\n\nAnd here is how I apply it to the ellipse:\n\n <ellipse>\n <reportElement style=\"ZFieldStyle\" mode=\"Opaque\" x=\"285\" y=\"47\" width=\"17\" height=\"17\" forecolor=\"#FF00FF\" >\n\n </reportElement>\n </ellipse>\n\n\nbut I'm want to associate the circles to distinct data elements so that way when the conditional style is applied the value that is considered is the value that pertains to that country.\n\nFor your reference, the data that's passed is a JRDataSource that wraps a list of Country instances.\n\nInstance 1.\nname=\"Canada\";\nvalue=0;\n\nInstance 2.\nname=\"US\"\nvalue=3;\n\n..etc. And the value field dictates what color is to be displayed on the circle on top of the image.\n\nHow can I do this in Jasper?\n\nNB. All circles will show in the report. (nothing hidden) The question is about binding the i'th circle which is at position (x=34, y=90) to a specific data item and color it as c,\nthe j'th circle which is at position (x=8, y=12) to a specific data item and color it d...etc. \nWhere c, d are colors.\n\nI've a mvn + java + jasper project that I'm testing with here: It has 3 data Items and 3 circles already placed in the title section on top of an image.\n\nhttps://drive.google.com/file/d/0B5GhWVO8BNlcVlNaRHpodm1Hd0k/edit?usp=sharing" ]
[ "java", "jasper-reports", "report", "ireport" ]
[ "JavaScript: The Good Parts - chapter 8, function.apply()", "For the following code, based on page 84 of \"JavaScript: The Good Parts\", can someone explain why [1] and [0] are used? I understand that they're supplying the arguments 1 and 0 to slice, respectively, but what's the point of that?\n\nFunction.prototype.bind = function (that) { \n var method = this;\n var slice = Array.prototype.slice;\n var args = slice.apply(arguments, [1]); // Why is [1] here?\n\n return function () { \n return method.apply(that, args.concat(slice.apply(arguments, [0]))); // Why is [0] here?\n };\n};\n\nvar x = function () { \n return this.value;\n}.bind({ value: 666 }); \n\nconsole.log(x()); // Returns 666.\n\n\nI believe I understand the big picture - the function x has been designed to extract the value of the value property. We then bind an object that has a value property name/value pair and execute the x function. The x function reaches into the supplied object, as if it where a method of that object, and returns the value of the value property.\n\nWhat I do not understand is how this is accomplished (I note Crockford's quasi-amusing use of 666). Thanks in advance." ]
[ "javascript", "bind", "apply" ]
[ "Laravel : Syntax error or access violation: 1055 Error", "I want use WhereIn and Groupby in Same Query to fetch Result.\n\nI've tried this:\n\n$loadids=explode(\"#@*\",$reciptdet->loading_id);\n$loadingdatas=DB::table('loading')->groupBy('vehicle_no')->whereIn('id',$loadids)->get();\n\n\nBut I got this error message:\n\n\n SQLSTATE[42000]: Syntax error or access violation: 1055 'sbrtpt.loading.id' isn't in GROUP BY (SQL: select * from loading where id in (14, 15, 16) group by vehicle_no)" ]
[ "php", "laravel", "laravel-5" ]
[ "What is the fastest way to get a shallow copy the data of an object?", "Vanilla JS only please\n\nThat is, its the output should be an object that only contains data, and ignores the original's methods/prototype. Complex data structures that inherit from the default Object, like Array, can be copied in a shallow manner, as references. The way I do it now is:\n\nfunction shallowCopyObjectData(obj) {\n output = {};\n for (var i in item) {\n output[i] = obj[i];\n }\n return output;\n};\n\n\nThe other way I've seen is:\n\nfunction shallowCopyObjectData(obj) {\n return JSON.parse(JSON.stringify(obj));\n};\n\n\nWhat is the most performant way to do it?\n\nI've made a running jsPerf to compare speeds. If you come up with a solution, please feel free to fork and add: http://jsperf.com/shallow-object-data-copy\n\nEdit\n@Barmar: I know a similar question has already been posted, but it asked about the fastest way to clone an object, which implied a deep copy that keep the constructor, prototype, etc. This question asks about the fastest way to copy just the data in the top level" ]
[ "javascript" ]
[ "HTML5 Canvas rotate function", "function drawNumbers(){\n var rad, num;\n\n cx.font= \"30px Arial\";\n cx.textAlign = \"center\";\n cx.textBaseline = \"middle\";\n\n //numbers around the inner circumference\n for(num=1; num < 13; num++){\n rad = num * Math.PI/6; //angle for every number\n cx.rotate(rad);\n cx.translate(0, -175);\n cx.rotate(-rad);\n cx.fillText(num.toString(),0,0);\n cx.rotate(rad);\n cx.translate(0, 175);\n cx.rotate(-rad);\n }\n}\n\nfunction drawHands(){\n //getting the time\n var time = new Date();\n var hours = time.getHours();\n var minutes = time.getMinutes();\n var seconds = time.getSeconds();\n\n //setting the radians based on the time\n //hour hand\n hours %= 12;\n hours = (hours * Math.PI/6) + (minutes * Math.PI/360) + (seconds * Math.PI/21600);\n hands(hours, radius * 0.04, radius * 0.5);\n\n //minute hand\n minutes = (minutes * Math.PI/30) + (seconds * Math.PI/1800);\n hands(minutes, radius * 0.03, radius * 0.65);\n\n //second hand\n seconds = (seconds * Math.PI/30);\n hands(seconds, radius * 0.01, radius * 0.68);\n}\n\nfunction hands(ang, width, length){\n cx.beginPath();\n cx.lineWidth = width;\n cx.lineJoin = \"round\";\n cx.lineCap = \"round\";\n cx.moveTo(0, 0);\n cx.rotate(ang);\n cx.lineTo(0, -length);\n cx.stroke();\n cx.rotate(-ang);\n}\n\n\nI was learning the HTML5 canvas in W3Schools and the tutorial was teaching how to make a working clock.\n1. I just don't understand how the extra rotates work in the functions. \n2. When applying a rotate function, does it always rotate from the center of origin (0, 0) of the canvas?" ]
[ "javascript", "html5-canvas", "rotatetransform" ]
[ "Word 2010 \"object error\" during template load", "We have recently upgraded to Office 2010 from 2003. VBScript type code that was working fine in 2003 now fails intermittently in 2010, with 'object error' or 'command failed'.\n\nFrom what I've managed to work out, this appears to be the result of the Normal template still downloading/loading, despite the CreateObject call completing. When the code works, it seems that normal has loaded quickly.\n\nCode:\n\nDim oWord As Object\nSet oWord = CreateObject(\"Word.Application\")\noWord.Visible = True\nSet document = oWord.Documents.Open(\"\\\\networkshare\\networkshare\\mytemplate.dot\")\n\n\nThe code fails on \"Set document =\"\n\nI have looked for solutions to this however I haven't found any trace of people having this issue elsewhere. If I insert a delay between oWord.Visible and Set document, the issue is resolved. I'd prefer to fix this properly though, as we often deal with many hundreds of documents in one run.\nI have tried to detect the completion of loading for Normal, however have been unsuccessful in this regard.\n\nHas anyone else seen this issue and found a solution?\n\nMany thanks\n\nPhilip" ]
[ "vbscript", "word-2010" ]
[ "Using LZ4HC algorithm in an ARM Cortex-M3 processor", "I have this embedded system with a flash memory placed on the board to store a huge number of data. The main controller is an ARM Cortex-M3 processor and I'm supposed to compress the data placed on a part of flash and put the compressed data on another part of the flash.\n\nNow since the amount of SRAM is limited in these kind of systems how exactly can I use the LZ4HC algorithm? I can't compress the whole data at once like we do in PC and I guess I have to do this on a little chunk of data or block by block (for example every 512 or 4096 bytes of data). I'm just not sure how. I couldn't totally understand the functions.\nIs that even possible to do this block by block?\nI couldn't find any example. And the open source code does not come with a good documentation. Actually I think there is no documentation." ]
[ "arm", "compression", "cortex-m3", "lz4" ]
[ "Twitter API: Getting Data for Analytics", "I am looking to create a simple graph showing 2 numbers of time for my personal twitter. They are:\n\n\nNumber of followers per day\nNumber of mentions per day\n\n\nFrom my research so far, the search API does not provide a date so I am not about to do a GROUP BY. The only way I can have access to dates is through the OAuth Api but that requires interaction from the end user which I am trying to avoid. \n\nCan someone point me in the right direction in order to achieve this? Thanks." ]
[ "python", "twitter" ]
[ "Can OneNote file be viewed inside my application?", "I want to see OneNote file inside my windows store application. Is it possible? Does OneNote api facilitate it? Is there any OneNote viewer that can be integrated for custom made Windows Store apps?" ]
[ "c#", "windows-store-apps", "office365", "onenote" ]
[ "How does PE take place for a Truffle interpreter AOT-compiled with native-image?", "Using native-image to improve startup times of Truffle interpreters seems to be common.\n\nMy understanding is that AOT compilation with native-image will result in methods compiled to native code that are run in the special-purpose SubstrateVM.\n\nAlso, that the Truffle framework relies on dynamically gathered profiling information to determine which trees of nodes to partially evaluate. And that PE works by taking the JVM bytecode of the nodes in question and analyzing it with the help of the Graal JIT compiler.\n\nAnd here's where I'm confused. If we pass a Truffle interpreter through native-image, the code for each node's methods will be native code. How can PE proceed, then? In fact, is Graal even available in SubstrateVM?" ]
[ "graalvm", "graalvm-native-image" ]
[ "in Qt weatherinfo demo, some contents go out of window boundary", "We are running the Qt weatherinfo demo for a test. It is a well known demo and here are the codes.\nhttp://qt-project.org/doc/qt-4.8/demos-embedded-weatherinfo.html\nand the main source is here.\nhttp://qt-project.org/doc/qt-4.8/demos-embedded-weatherinfo-weatherinfo-cpp.html\n\nWhen the code is run, it looks good and like this.\nhttps://www.flickr.com/photos/129456552@N07/16544262919/\n\nWe wanted to be able to select cities. So, even though we don't use SYMBIAN, we added cities menu by commenting out the SYMBIAN code guard in the constructor as below.\n\n// #if defined(Q_OS_SYMBIAN)\n menuBar()->addAction(action);\n// #endif\n\n\nNow the problem is that some contents go out of bounds of the main window.\nIt looks like this below(top and bottom goes out of bound).\n\nI don't know much about Qt, how can I fix this?" ]
[ "c++", "qt", "qtgui" ]
[ "How to kafka-python consumers parallely", "I have a set of kafka-python consumers that consume from different kafka topics continuously and parallely.\n\nMy question is how to kick off the consumers in parallel using single python script? \nAnd what is the best way to manage(start/stop/monitor) these consumers.\n\nif I write ex:\nrun.py \n\nimport consumer1, consumer2, consumer3\n\nconsumer1.start()\nconsumer2.start()\nconsumer3.start()\n\n\nIt just hangs on consumer1.start() as the script does not return any value and keeps running." ]
[ "python-3.x", "kafka-python" ]
[ "Set mipmap image as linearLayout background programmatically", "I have a .png image in mipmap directory. know I want to set this image as the linearLayout background programmatically. and after some processes remove it.\n\ntarget SDK : 23\nmin SDK : 14\n\n\nwhich function shall I use?\n\nthis can change background color:\n\nll.setBackgroundColor(getResources().getColor(R.color.color_mtn));\n\n\nbut where is background image?" ]
[ "android", "background-image" ]
[ "How do you make code rerun from the first line in python?", "I am trying to make a to do list app and I want to know how to make the code go back to the first line after I enter something into a list to add another item. Im new to Python BTW. As soon as they put enter input I want the program to execute the code then prompt them to add another item to the list.\n\nprint(\"Enter list item\");\nlist_item = input();\nlist=list();\ntry:\n\n list_item\n\nexcept:\n print('You didnt enter a task');\nfinally:\n list.append(list_item);\nprint(list);\n\n\nIs there anyway to go back to line 1?" ]
[ "python", "list", "try-catch" ]
[ "Thread synchronization behavior on VMWare with same guest OS, different host OS", "I'm a TA for a computer science course and I've run into an interesting problem. A recent assignment involved synchronization techniques for pthreads. The students had to avoid deadlocks using mutexes, barriers, conditional variables, etc... Each student is running the same version of Ubuntu on a VMWare virtual machine (either Workstation or Fusion depending on their system). Obviously the host OS may be different for each student.\n\nNow here's the confusing part: the synchronization behavior for some students is very different from what I see when I run their program. For some student, I may run her assignment and see a deadlock immediately. However, when she runs it at home she never gets a deadlock.\n\nFrom my understanding, the deadlocking behavior seems only dependent on the guest OS's scheduler. The host OS should have nothing to do with this. Yet, even though we all have the same guest OS the problem persists. Does anyone have any idea of why this might be?\n\nThanks!" ]
[ "operating-system", "pthreads", "vmware", "virtual-machine" ]
[ "implement Interface in an abstract class", "Is it possible to implement the interface in an abstract class and change the implemented interface method into abstract?\n\ninterface ITest\n{\n string GetData();\n int ProcessData();\n}\n\npublic abstract class MyAbstract:ITest\n{\n public int Process()\n {\n // some code\n }\n\n public abstract string GetData(); // Change the implemented method into abstract Is it Possible?\n}" ]
[ "c#", ".net", "oop" ]
[ "Class::Method::Modifiers - How to apend parameters in \"before\"?", "See https://stackoverflow.com/a/45590793/2139766 for the original problem.\n\nHow to append parameter(s) to @_ in before provided by Class::Method::Modifiers?\n\nbefore 'MIME::Lite::__opts' => sub {\n # grep { s/^Hello$/SSL/ } @_; # OK - changes $_[1] \n push(@_,'SSL'); # no effect\n};" ]
[ "perl" ]
[ "Converting a string into a multi-dimensional array with commas and pipes", "Tried searching but nothing was exactly what I was looking for.\n\nI have a string that looks like this:\n\n$string = \"sku1,2|sku2,5\";\n\n\nI would like to convert it into a multi-dimensional array that would end up looking like this:\n\nArray\n(\n [0] => Array\n (\n [sku] => sku1\n [qty] => 2\n )\n\n [1] => Array\n (\n [sku] => sku2\n [qty] => 5\n )\n\n)\n\n\nSo far I've tried using:\n\nexplode(',',$string);\n\n\nWhich is the right idea but it doesn't account for the pipe delimiter to know when to go to the next array group." ]
[ "php", "arrays", "string", "multidimensional-array" ]
[ "bash to move select fields to match file prefix in two directories", "In the below bash I am trying to use the prefix 123_Last-First of file1 to match to prefix 123_Last-First in file2. There will always be a match found (that is if there is a file1 there has to be a file2). In file2 the contents of $5,&6,and $7 (always tab-delimited)\n\n$5 = Total_Targets with value under it that can be a decimal or integer\n\n$6 = Targets_less_than250x with value under it that can be a decimal or integer\n\n$7 = Percent_more_than250x with value under it that can be a decimal or integer\n\nare copied to it under the header Quality metrics. The below executes but there is no output produced. I have added comments to help and show my thinking. Thank you :).\n\nfile1 in /home/cmccabe/oncomine/250x\n\n123_Last-First_250x.txt\nPosition Gene Type Reads Total_Targets Targets_less_than250x Percent_more_than250x\nchr4:55141051 PDGFRA NOCALL 13 2353 1 99.9575\n\n\nfile2 in /home/cmccabe/oncomine/report\n\n123_Last-First_oca.txt\nControls:\n4 expression controls detected\n\n\noutput in /home/cmccabe/oncomine/report/final\n\n123_Last-First_oncomine.txt\nQuality metrics:\nTotal_Targets Targets_less_than250x Percent_more_than250x\n2353 1 99.9575\nControls:\n4 expression controls detected\n\n\nawk\n\nawk 'FNR==NR{A[$5,$6,$7]=$0;next}$1 in A' OFS=\\'t' 123_Last-First_250x.txt 123_Last-First_oca.txt | awk 'NR>1{print \"Quality metrics:\"}' > /home/cmccabe/oncomine/report/final/123_Last-First_oncomine.txt" ]
[ "bash" ]
[ "Displaying binary number in asm", "I'm trying to do a 'AND' operation but I end up getting the wrong display results.\nMy codings seems fine but I just dont know why it couldn't display the result I want in binary.\n\nThis is my code for the operations:\n\nmov ah, 09h\n lea dx,sAnd\n int 21h\n\n mov ah, 09h\n lea dx, sInputX\n int 21h\n\n mov ah,0ah \n lea dx,x\n int 21h\n\n jmp VerifyX\n\n mov ah, 09h\n lea dx, sInputY\n int 21h\n\n mov ah,0ah \n lea dx,y\n int 21h\n\n jmp Operation1\n\nOperation1:\n mov Al, x\n and Al, y\n mov result, Al\n jmp CONVERSION\n\nCONVERSION:\n mov ah, 09h\n lea dx, result\n int 21h" ]
[ "assembly", "binary", "x86", "x86-16" ]
[ "Python is operator not giving the same result as id function when working with numpy", "I have always thought that is operator is checking whether its operands are stored in the same memory location. If they are, then they must be the same object and if they are not, then they are different objects (possibly with the same value, but that is not what I am interested in).\nThis has been demonstrated over and over using id function which returns an integer representing the unique memory location where the object is stored. This also corresponds to python documentation of id function, which states\nid(obj, /)\n Return the identity of an object.\n \n This is guaranteed to be unique among simultaneously existing objects.\n (CPython uses the object's memory address.)\n\nIn all the examples that I have seen where they were actually using id and is over the years (quite a bit), if ids of two objects were equal then is returned True. So, somehow I have thought that this always hold.\nHere is a quick example using list.\nc = [[1], [2], [3]]\nc[0] = c[1]\n\nNow, c[0] should point to the same memory location as c[1]. If we check the ids and compare them with is operator, everything looks as expected.\nc[0] is c[1], id(c[0]) == id(c[1]) , id(c[0]), id(c[1]), type(c[0])\n# (True, True, 112392630432, 112392630432, list)\n\nIf I do a similar thing, but with the numpy array, then the ids will be the same, but is operator will return False\nc = np.array([1, 2, 3])\nc[0] = c[1]\nc[0] is c[1], id(c[0]) == id(c[1]) , id(c[0]), id(c[1]), type(c[0])\n# (False, True, 112400242960, 112400242960, numpy.int64)\n\nNow, is is telling me that these two objects are not sitting in the same memory location but ids are equal. Even if I construct a list using numpy.int64 elements (in the first example, I was using list of lists), is will return True.\nc = [np.int64(1), np.int64(2), np.int64(3)]\nc[0] = c[1]\nc[0] is c[1], id(c[0]) == id(c[1]) , id(c[0]), id(c[1]), type(c[0])\n# (True, True, 112277646832, 112277646832, numpy.int64)\n\nSo my conclusion is that it has something to do with the numpy.ndarrays themselves. Later I have found that this is not unique to numpy. If you change numpy.ndarray to torch.Tensor, then the behavior is the same - ids are equal but comparison using is operator returns False.\nCan anyone explain why a is b returns False while id(a) == id(b) returns True when working with these numerical libraries?" ]
[ "python", "arrays", "numpy" ]
[ "Creating an album-centered app -- is RSS the only way to go?", "Trying to create an iOS (iphone) app centered around a photo album that will be updated daily. New to this. Learning coding slowly. First, I'd like some advice - anyone know what the best way to go about this would be? Should I take the RSS route and implement an RSS feed from some album site? Is there a way to do it that depends less on an account made with another site? Even a blog rss would be better because at least I'd have full control over the blog.\n\nI find that implementing an RSS feed for a photo blog site still ends up creating a look that is more article style - where each post is listed with post time, date, header, etc., rather than a thumbnail click-to-expand album style.\n\nI'll be implementing getsocialize so that each photo can be liked, tweeted, etc.\n\nSome guidance in the right direction would be appreciated!" ]
[ "objective-c", "xcode", "rss" ]
[ "How to output multi-dimensional arrays alongside single-dimension arrays in a for loop", "I would like to output the following code in the console so that the result reads:\n\nMy hobbies on Mondays are Poker, VideoGames\n\nMy hobbies on Tuesday are Board Games, Hiking, Rockclimbing\n\nMy hobbies on Wednesdays are Driving, Shopping\n\nI know this is fairly basic stuff, but for some reason none of the help I've found online has solved this for me (definitely me just misreading or misunderstanding things).\n\nI'm using nested for loops, which I think is correct, but for some reason I can't get past the first array in the multi-dimensional hobbies array. The weekdays output as I need them to, but for each weekday I want to output the entirety of the first, second and third array in the variable hobbies for Monday, Tuesday and Wednesday respectively. Can anyone point me in the right direction?\n\nvar hobbies = ['Poker','VideoGames'];\n\n ['Board Games', 'Hiking', 'Rockclimbing'];\n\n ['Driving', 'Shopping'];\n\nconst weekdays = [\"Monday\", \"Tuesday\", \"Wednesday\"];\n\nfor (i = 0; i < 3; i++) {\nconsole.log(\"My hobbies on\", weekdays[i], \"are \");\nfor (x = 0; x < 5; x++)\n console.log(hobbies[?]);\n}" ]
[ "javascript", "arrays", "for-loop" ]
[ "How to (really) unit test an Adapter", "my question is really simple, shall an adapter (design pattern) class should be unit tested, and how?\n\nExample:\n\nI want to create a class ClientSocket with PHP wich is an adapter of the fsockopen, fread, fwrite. \n\nClass ClientSocket extends SenderAdapterAbstract\n{\n private $s = null;\n\n public function __construct($host, $port)\n {\n $this->s = fsockopen($host, $port);\n }\n\n // Abstract method concrete implementation\n public function send($message)\n {\n fwrite($this->s, $message);\n\n $result = fgets($this->s);\n fclose($this->s);\n }\n}\n\n\nShould I test this class? a unit test is not really one if it talks to the network..." ]
[ "php", "unit-testing", "sockets", "tdd", "adapter" ]
[ "Debugging closures in javascript", "When I try to debug the javascript code which has a lot of closures I use to put a breakpoints.\n\nThen I go to see the stack but most of the times I just see a call stack full of anonymous functions which is a nightmare for me.\n\nWhat is the best way to debug closure in javascript?" ]
[ "javascript", "debugging", "closures" ]
[ "Ignoring ? in a regex in String replaceFirst method", "I have below program:\n\nString one = \"Hello I am IN (?)\";\nString two = one.replaceFirst(\" IN (?)\", \" IN ('one','two')\");\nSystem.out.println(two);\n\n\nThe output is:\n\nHello I am IN ('one','two')(?)\n\n\nThe output I am expecting is:\n\nHello I am IN ('one','two')\n\n\nWhat is the issue? It has to do with replaceFirst method having first argument as a regex." ]
[ "java", "string" ]
[ "Json4s parse JSON string error", "I have the following piece of code:\n\ndef fromString[T <: AnyRef](str: String)(implicit m: Manifest[T]): T = {\n val json = parse(str)\n json.extract[T](formats,m)\n}\n\n\nI also have a case class that is defined as such:\n\ncase class Points(pts: Seq[Point])\ncase class Point(date: LocalDate, value: Double)\n\n\nWhen I try to make the function call:\n\nfromString[Points]\n\n\nI get an error stating: \n\nexpected field or array\nNear: \\\",\\\"value\\\":2.0}]}\"\n\n\nSo normally this would imply that the JSON string is malformatted, but I confirmed that it is valid JSON. (see input string below)\n\n\"{\\\"pts\\\":[{\\\"date\\\":\\\"12-31-1969\\\",\\\"value\\\":1.0},{\\\"date\\\":\\\"01-31-1970\\\",\\\"value\\\":2.0}]}\"\n\n\nI have tried implementing a CustomSerializer and put it in scope of the implicit formats, but still no luck.\n\nWhat am I missing?" ]
[ "json", "scala", "json4s" ]
[ "is there something like httpPost in k8s", "I know that k8s have readynessProbe with httpGet method to check if service ready to work or not.\nIs there something like httpPost method to run POST request to /api/postService with some body and check return code?\nOr some tricky way to do it in yaml file." ]
[ "post", "kubernetes" ]
[ "Cross-thread tab drawing", "Basically, I have a TabControl.\nI am drawing the text for the headers myself so they can be coloured when required.\nThe calls to change colour are on a different thread then the one the TabControl is, so I am using delegates and such for cross-thread operations.\nUnfortunatly my method is not exactly reliable.\n\nHere is the cross-threading part:\n\ndelegate TabControl getTabDelegate();\nprivate TabControl getTab()\n{\n if (this.channelTabs.InvokeRequired)\n {\n getTabDelegate d = new getTabDelegate(getTab);\n this.Invoke(d);\n return null;\n }\n else\n {\n return channelTabs;\n }\n}\n\n\nand here is the drawing code:\n\nprivate void channelTabs_DrawItem(object sender, DrawItemEventArgs e)\n{\n try\n {\n TabControl ct = getTab();\n using (Brush br = new SolidBrush(TabColors[ct.TabPages[e.Index]]))\n {\n e.Graphics.FillRectangle(br, e.Bounds);\n SizeF sz = e.Graphics.MeasureString(ct.TabPages[e.Index].Text, e.Font);\n e.Graphics.DrawString(ct.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + (e.Bounds.Width - sz.Width) / 2, e.Bounds.Top + (e.Bounds.Height - sz.Height) / 2 + 1);\n\n Rectangle rect = e.Bounds;\n rect.Offset(0, 1);\n rect.Inflate(0, -1);\n e.Graphics.DrawRectangle(Pens.DarkGray, rect);\n e.DrawFocusRectangle();\n }\n }\n catch(Exception err)\n {\n MessageBox.Show(err.Message, \"1\");\n }\n}\n\n\nAs you can see, in some cases getTab(); returns null, which isn't exactly helpful.\nIs there any more...reliable method of doing this?\n\nHere is the method that is called from the second thread to change the header colour:\n\nprivate void SetTabHeader(TabPage page, Color color)\n{\n TabColors[page] = color;\n channelTabs.Invalidate();\n}\n\n\nWithout the cross-threading part, of course, I get exceptions thrown.\n\nAnd as you can probably imagine, channelTabs is the GUI tab control.\n\nAny help is apperciated, thanks!\n\n--\nOh yea, and if it is actually helpful:\n private Dictionary TabColors = new Dictionary();" ]
[ "c#" ]
[ "Check if file has finished copying Objective C", "I am writing an application in objective c, one of the functions of the application is that it monitors a local folder for new files. The local folder is shared for other users, so anyone is able to put (usually files around 5gb) on there. Im looking for a way to interact with the new files that are put on the shared folder. These files have to be done copying before the applications tries to access them.\n\nI've tried to monitor the size of the new file, the problem is that these files are also copied over wireless, so in case of a hickup the size stays the same and the application will already start interacting with the file.\n\nThe client side that puts files on the share is not running any copy applications, just finder or windows explorer. So there is no way to work with lock files or anything like that.\n\nHow is for instance Dropbox doing this?" ]
[ "objective-c", "file-io" ]
[ "Paging is not working in my kendo ui grid in angular js", "I want to implement server side paging,sorting and filtering in kendo grid ui with script in angular js but problem is paging is not working.\n\nFirst 10 records are displaying but when i click on page no 2 then server side call is not going and no records are displayed.\n\nSource:http://demos.telerik.com/kendo-ui/grid/angular\n\nThis is my View:\n\n <link href=\"~/css/kendo.common-material.min.css\" rel=\"stylesheet\" />\n <link href=\"~/css/kendo.rtl.min.css\" rel=\"stylesheet\" />\n <link href=\"~/css/kendo.material.min.css\" rel=\"stylesheet\" />\n <div class=\"table-responsive\" ng-controller=\"GridDemoCtrl\">\n <kendo-grid options=\"mainGridOptions\">\n </kendo-grid>\n </div>\n <!-- jQuery -->\n <script src=\"~/vendor/jquery/jquery.min.js\"></script>\n\n <!-- Angular -->\n <script src=\"~/vendor/angular/angular.js\"></script>\n <script src=\"~/js/kendo.all.min.js.js\"></script>\n\n\nMy Script:\n\napp.controller('GridDemoCtrl', ['$scope', '$http', function ($scope, $http) {\n $scope.mainGridOptions = {\n dataSource: {\n transport: {\n read: {\n url: \"../Holiday/GetListofHolidays\",\n contentType: \"application/json\",\n type: \"POST\"\n }\n },\n schema: {\n data: \"Data\",\n total: \"Total\",\n },\n pageSize: 10,\n serverPaging: true\n },\n pageable: true,\n columns: [\n {\n field: \"HolidayName\",\n title: \"Holiday Name\"\n },\n {\n field: \"HolidayDiscription\",\n title: \"Holiday Description\"\n }\n ]\n };\n}]);\n\n\nMy Controller:\n\n[HttpPost]\n public ActionResult GetListofHolidays(DataSourceRequest command)\n {\n var holidayList = _holidayService.GetAllHolidays(command.Page - 1, command.PageSize,null);\n var gridModel = new DataSourceResult\n {\n Data = holidayList.Select(x =>\n {\n var holidayModel = new HolidayModel();\n holidayModel.HolidayName = x.HolidayDiscription;\n holidayModel.HolidayDate = x.HolidayDate;\n holidayModel.HolidayDiscription = x.HolidayDiscription;\n return holidayModel;\n }),\n Total = holidayList.TotalCount,\n };\n return Json(gridModel);\n }\n\npublic class DataSourceRequest\n {\n public int Page { get; set; }\n\n public int PageSize { get; set; }\n\n public DataSourceRequest()\n {\n this.Page = 1;\n this.PageSize = 10;\n }\n }\n\npublic class DataSourceResult\n {\n public object ExtraData { get; set; }\n\n public IEnumerable Data { get; set; }\n\n public object Errors { get; set; }\n\n public int Total { get; set; }\n }\n\n\nSo please anybody can guide me whats the problem with my code and why paging is not working???" ]
[ "angularjs", "kendo-ui", "kendo-grid", "kendo-asp.net-mvc" ]
[ "How to show a small hovering non pop up message in PyQt", "What i want to achieve is something like toast messages in android . I don't want a message box to be displayed to the user with an overlaying window of its own. I just want to display a small message that tells the user that some process is done. The message involves no user interaction and is only there to notify the user while he is interacting with the other GUI elements . \n\nI have no idea how to do this in PyQt. Any help is greatly appreciated." ]
[ "python", "qt", "pyqt", "qmessagebox" ]
[ "Meteor and Iron Router: raise 404 when id doesn't exist", "I'm using Iron Router for my urls and I have this route:\n\nthis.route('regionEdit', {\n path: '/region/:_id',\n waitOn: function() {\n return Meteor.subscribe('region', this.params._id);\n },\n data: function() {\n return Regions.findOne({\n _id: this.params._id\n });\n }\n});\n\n\nThis works fine when I use this path http://example.com/region/xgok3Etc5mfhtmD7j\n\nWhere xgok3Etc5mfhtmD7j is the _id of region. However, when I access to http://example.com/region/whatever, the page renders normally, but without data.\n\nHow can I raise a 404 error for this?" ]
[ "meteor", "iron-router" ]
[ "Tracker afterFlush error with Meteor and Hammer JS package", "I'm trying to use the hammer:hammer 2.0.4_2 package with Meteor 1.0.1 and I'm getting the following error:\n\n\n Exception from Tracker afterFlush function: undefined is not a\n function TypeError: undefined is not a function\n\n\nI figured that the error has something to do with DOM not being rendered yet, because of the Helper Block. So far I couldn't find an answer to this anywhere. Does someone else have the same error or knows how this can be fixed?\n\n\n\nclient/profile.js\n\nTemplate.myTemplate.rendered = function() {\n\n this.$('body').hammer({ <-- Line of the Error in Console..\n drag_min_distance:1,\n swipe_velocity:0.1\n })\n }\n\nTemplate.myTemplate.events({\n 'press #mcPress': function() {\n console.log('yay!')\n }\n})\n\n\n\n\nclient/profile.html \n\n{{#with thisUser}}\n\n // some html stuff\n\n <div id=\"mcPress\">Some content</div>\n\n{{/with}}" ]
[ "javascript", "meteor", "hammer.js" ]
[ "Using a variable as a hash key Perl 5.32", "I am reading user IDs from a csv file and trying to check if that user ID exists in my hash, however I have found that my checking through if(exists($myUserIDs{"$userID"})) is never returning true, despite testing with multiple keys that are in my hash.\nopen $file, "<", "test.csv";\nwhile(<$file>)\n{\n chomp;\n @fields = split /,/, $_;\n $userID = @fields[1];\n \n if(exists($myUserIDs{"$userID"}))\n {\n #do something\n }\n}" ]
[ "perl" ]
[ "Segmentation Error : Command Arguments (argv)", "#include<stdio.h>\n#include <cs50.h>\n#include <string.h>\n#include <stdlib.h>\n#include <ctype.h>\nint main(int argc, string argv[])\n{\n if (argc == 2)\n {\n printf ("%s \\n", argv[1]);\n \n if (isdigit (argv[1]) !=0)\n {\n printf("Success\\n");\n printf("%s \\n", argv[1]);\n }\n else\n {\n printf(" %s key \\n", argv[0]);\n }\n }\n else\n {\n printf(" %s key \\n", argv[0]);\n }\n\n}\n\nHello everyone, I am trying to run this program that takes command line arguments and checks them for digits.After that I have to store it into a variable. I am stuck and it is giving the error "Segmentation fault". I googled it and I think it means that the program is not able to read the value. Please let me know why it is giving the error, what "Segmentation fault" means and how to fix it." ]
[ "c", "segmentation-fault", "command-line-arguments", "cs50" ]
[ "How to run spark-ec2-branch-2 script for Ohio region?", "I am trying to run spark-ec2-branch-2 script for creating a cluster in Ohio. I need to create a cluster in Ohio because Ohio is one of the regions that allows VPC peering. \n\n ./spark-ec2 --key-pair=ohio --identity-file=ohio.pem \n--region=us-east-2 --zone=us-east-2c --vpc-id=vpc-1906ca71 --subnet-id=subnet-26e2ae6b\n--instance-type=t2.micro -s 1 launch ohio_cluster\n\n\nI have set up a cluster in other regions using the similar script. As far as I know ohio is us-east-2 (link). But I am getting the following error:\n\nSetting up security groups... \nTraceback (most recent call last): \nFile \"./spark_ec2.py\", line 1573, in <module> \nmain() \nFile \"./spark_ec2.py\", line 1565, in main \nreal_main() \nFile \"./spark_ec2.py\", line 1394, in real_main \n(master_nodes, slave_nodes) = launch_cluster(conn, opts, cluster_name) \nFile \"./spark_ec2.py\", line 523, in launch_cluster \nmaster_group = get_or_make_group(conn, cluster_name + \"-master\", \nopts.vpc_id)\nFile \"./spark_ec2.py\", line 371, in get_or_make_group \ngroups = conn.get_all_security_groups() \nAttributeError: 'NoneType' object has no attribute 'get_all_security_groups' \n\n\nI guess the script cannot set up a connection in this region, or cannot find this region. But I am failing to understand why. In any case, if anyone can guide and help me to setup a spark cluster using script in Ohio region I will be very grateful. Thanks in advance." ]
[ "amazon-web-services", "apache-spark", "amazon-ec2", "spark-ec2" ]
[ "Efficiently Standardizing Images in a Numpy Array", "I have a numpy array of images of shape (N, H, W, C) where N is the number of images, H the image height, W the image width and C the RGB channels.\n\nI would like to standardize my images channel-wise, so for each image I would like to channel-wise subtract the image channel's mean and divide by its standard deviation.\n\nI did this in a loop, which worked, however it is very inefficient and as it makes a copy my RAM is getting too full.\n\ndef standardize(img):\n mean = np.mean(img)\n std = np.std(img)\n img = (img - mean) / std\n return img\n\nfor img in rgb_images:\n r_channel = standardize(img[:,:,0])\n g_channel = standardize(img[:,:,1])\n b_channel = standardize(img[:,:,2])\n normalized_image = np.stack([r_channel, g_channel, b_channel], axis=-1)\n standardized_images.append(normalized_image)\nstandardized_images = np.array(standardized_images)\n\n\nHow can I do this more efficiently making use of numpy's capabilities?" ]
[ "python", "image", "numpy", "computer-vision", "normalization" ]
[ "Set TTL Apache Camel JAva DSL", "How do you set the TTL for a message when using Java DSL?\n\nI have something like this:\n\n...\nfrom (\"timer:something?delay=3000&period=15000\")\n ...\n .to(\"{{some.property}}\")\n .end()\n...\n\n\nI want to set a time to live on the message being sent." ]
[ "apache-camel" ]
[ "How can I make ExpandableListView not selectable?", "I have a expandable list view with all the list already expanded. I don't want the user to be able to selected any parent items (group items). I have made it so that clicking it will not collapse the list, but cannot figure out how to make the item un-selectable." ]
[ "java", "android", "android-listview", "expandablelistview" ]
[ "Can't set a cookie using NextJS 9's API Route", "Typically it seems that when using Express, in the \"res\" object there is \"cookie\" so you can do something like:\n\nres.cookie('session', sessionCookie, options);\n\n\nIn the API routes offered by NextJS in Next 9, when looking at res, this does not exist. Is there a way to set the cookie for a response object in a Next API Route function?" ]
[ "javascript", "node.js", "next.js" ]
[ "Android: How to check why an app is \"Not Compatible\"", "My app is targeting API/minSDKversion 5 and runs fine on 2.2. My friend just tried to download my app onto his Samsung Galaxy S2 running 2.3.4 but was met with the \"not compatible\" warning. Is there some way I can see why my app is not compatible?" ]
[ "android", "api", "incompatibility" ]
[ "how to save video programmatically on iPad1 iOS SDK", "i have array of images and i converted them to movie video and now i want to now how to save that converted video to ipad.\n\ncan i save that converted video to iPad photo library\n\nNSError *error = nil;\n\nAVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:path] fileType:AVFileTypeQuickTimeMovie error:&error];\n\nNSParameterAssert(videoWriter);\n\nNSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:\n AVVideoCodecH264, AVVideoCodecKey,\n [NSNumber numberWithInt:size.width], AVVideoWidthKey,\n [NSNumber numberWithInt:size.height], AVVideoHeightKey,\n nil];\nAVAssetWriterInput* writerInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings] retain];\n\n\n// NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:kCVPixelFormatType_32ARGB], kCVPixelBufferPixelFormatTypeKey, nil];\n\nAVAssetWriterInputPixelBufferAdaptor *adaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:nil];\n\n\nNSParameterAssert(writerInput);\nNSParameterAssert([videoWriter canAddInput:writerInput]);\n[videoWriter addInput:writerInput];\n\n//Start a session:\n[videoWriter startWriting];\n[videoWriter startSessionAtSourceTime:kCMTimeZero];\n\nCVPixelBufferRef buffer = NULL;\n\n//convert uiimage to CGImage.\n\nCFDataRef imgData = (CFDataRef)[array objectAtIndex:0];\nCGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData (imgData);\nCGImageRef image1 = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);\n\nbuffer = [self pixelBufferFromCGImage:image1];\n[adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];\n\n//Write samples:......\n\n//Finish the session:\n[writerInput markAsFinished];\n[videoWriter finishWriting];" ]
[ "ipad", "video", "photolibrary" ]
[ "Rewrite Rules with [R=301] in .htaccess", "I have decided to introduce folders into my URLs for SEO reasons. Now im trying to 301 all the old URLs.\n\nThe physical location of these 100+ pages is in the root:\n\nwww.mydomain.com/pageA1.php\nwww.mydomain.com/pageA2.php \nwww.mydomain.com/pageB1.php\nwww.mydomain.com/pageB2.php\n\nI now want the URLs to include a folder name - but the physical location to stay the same:\n\nwww.mydomain.com/a-waste/pageA1.php\nwww.mydomain.com/a-waste/pageA2.php\nwww.mydomain.com/b-waste/pageB1.php\nwww.mydomain.com/b-waste/pageB2.php\n\nMy current rules are:\n\nRewriteRule a-waste/pageA1.php /pageA1.php\nRewriteRule a-waste/pageA2.php /pageA2.php\nRewriteRule b-waste/pageB1.php /pageB1.php\nRewriteRule b-waste/pageB2.php /pageB2.php\n\n\nThis works fine in the sense that if I browse www.mydomain.com/a-waste/pageA1.php - this URL stays in my address bar and it shows the page physically located www.mydomain.com/pageA1.php.\n\nNow if I add [R=301,L] to this rule to tell google its permanent, it no longer rewrites the URL, it just redirects it instead? What am i missing?\n\nthanks.\nAlex." ]
[ "php", "apache", ".htaccess", "mod-rewrite" ]
[ "How to get xml fill to advance table using php", "I want to get xml from: http://sportsfeeds.bovada.lv/basic/ATP.xml to fill it to a special table like: http://sports.bovada.lv/sports-betting/tennis-atp.jsp\n\nCurrent, I'm using DOMDocument to get it, but not ok, because it show not by order parent -> children.\n\n Time | Name | Odds\n\n John 3.65\n David 5.65\n John 3.65\n David 5.65\n\n\nI want show such as:\n\nTime\n\n 3:50p | Name | Odds\n\n John 3.65\n David 5.65\n\n 9:50a | Name | Odds\n John 3.65\n David 5.65\n\n\nLike it" ]
[ "php", "xml", "dom", "rss" ]
[ "Contiguous Memory Allocation", "In an application i have to allocate two buffers of 480 MB each. Memory allocation is done using HeapAlloc method. The application works fine in the systems where not many applications are running. But in system where other applications are also running memory is not allocated because of non availability of contiguous memory. Even though the memory space(non contiguous) is available but it is not allocated. \n\nNeed help to allocate two buffers of 480 MB even if non contiguous memory is available." ]
[ "c++", "memory-management" ]
[ "Background Image Not saving to Local Storage", "Hello I'am trying to save background image to local storage. Image changing works perfectly but its not saving to Local storage please check my code.\n\n$(\".theme3\").click(function () {\nvar backgroundImage = 'my image Url';\nlocalStorage.removeItem('background-image');\n$('.Menutopcover').css('background-image', 'url(' + backgroundImage + ')');\nlocalStorage.setItem(\"background-image\", backgroundImage);\n}" ]
[ "javascript", "jquery" ]
[ "Why does the frequency spectra change when the sampling frequency is changed?", "Here is my code for generating a triangular waveform in the time domain and for generating its corresponding fourier series/transform (I don't know whether its series or transform because matlab only has fourier transform function but since the signal is periodic, references say that the fourier counterpart must be called fourier series).\n\nx = 0;\ns = 50; % number of sinusoidal components\nfs = 330; % hertz\ndt = 1/fs; % differential time\nt = [0:dt:4]; % seconds\nconst = 2 / (pi^2);\n\nfor k = 1:2:s,\n x = x + (((-1)^((k - 1) / 2)) / (k^2)) * sin(4*pi*k*t);\nend\n\nx = const * x;\n\n% amplitude = max(x) = 0.2477\n% period = 0.5 seconds\n\nf = linspace(-fs/2,fs/2,length(x));\nxk = fftshift(fft(x));\nfigure;\n\nsubplot(3,1,1);\nplot(t,x);\ngrid on;\nxlabel('time(seconds)');\ntitle('Time Domain');\n\nsubplot(3,1,2);\nplot(f,abs(xk));\ngrid on;\nxlabel('frequency(hertz)');\ntitle('Magnitude Spectrum');\n\nsubplot(3,1,3);\nplot(f,angle(xk));\ngrid on;\nxlabel('frequency(hertz)');\ntitle('Phase Spectrum');\n\n\nAnd here is the generated plots for the time domain signal, magnitude spectrum, and phase spectrum.\n\nlink:\nfs = 330hz\n\nMy problem is when I changed the sampling frequency (fs which is currently equal to 330 hz) to another value, the plots of the magnitude and phase spectra change.\n\nHere is the plots of the magnitude and phase spectra when the sampling frequency is equal to 400 hz:\n\nlink:\nfs = 400 hz\n\nCan you explain why does this happen? And what can I do in order to get a constant plots for the magnitude and phase spectra given any sampling frequency?" ]
[ "matlab", "signal-processing", "fft", "frequency", "continuous-fourier" ]
[ "Changing the database from SQL Server to PostgreSQL in creating ASP.NET web application?", "I am currently using SQL Server for database and Dapper (ORM) for mapping relation to model classes. I have used multiple reads in Dapper so I am able to get multiple tables at one call to the database. But due to a certain circumstance, I have to change my database connection from SQL Server to PostgreSQL. In Postgresql, there are no options facilities for using the power of query multiple reads.\n\nIs there any way to handle the below situation in Postgresql?\n\nusing (var multi = conn.QueryMultiple(query, param, commandType: CommandType.StoredProcedure))\n{\n obj.InventoryItemOrder = multi.Read<InventoryItemOrder>()\n .FirstOrDefault(); //getting single object data (so firstordefault)\n obj.InventoryItemDataModel = multi.Read<InventoryItemDataModel>(); //list\n}\n\n\nCan I use this concept when dealing with PostgreSQL and Dapper in building an ASP.NET application?" ]
[ "asp.net", "postgresql", "dapper" ]
[ "Tesseract API ResultIterator error compil", "I want to use ResultIterator from tesseract, I use the source give on APIExample like this:\n\nPix *image = pixRead(\"test.png\");\ntesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();\napi->Init(NULL, \"eng\");\napi->SetImage(image);\napi->Recognize(0);\ntesseract::ResultIterator* ri = api->GetIterator();\ntesseract::PageIteratorLevel level = tesseract::RIL_WORD;\nif (ri != 0) {\n do {\n const char* word = ri->GetUTF8Text(level);\n float conf = ri->Confidence(level);\n int x1, y1, x2, y2;\n ri->BoundingBox(level, &x1, &y1, &x2, &y2);\n printf(\"word: '%s'; \\tconf: %.2f; BoundingBox: %d,%d,%d,%d;\\n\",\n word, conf, x1, y1, x2, y2);\n delete[] word;\n } while (ri->Next(level));\n}\n\n\nBut I have this error when I compile:\n\nocr.cpp: In function ‘int main(int, char**)’:\nocr.cpp:82:34: error: invalid use of incomplete type ‘class tesseract::ResultIterator’\nIn file included from ocr.cpp:10:0:\n/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’\nocr.cpp:83:28: error: invalid use of incomplete type ‘class tesseract::ResultIterator’\nIn file included from ocr.cpp:10:0:\n/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’\n ocr.cpp:85:15: error: invalid use of incomplete type ‘class tesseract::ResultIterator’\nIn file included from ocr.cpp:10:0:\n/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’\nocr.cpp:89:20: error: invalid use of incomplete type ‘class tesseract::ResultIterator’\nIn file included from ocr.cpp:10:0:\n/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’\n\n\nMy version of tesseract-ocr-dev is 3.02.01-6 and version of libtesseract-dev is 3.02.01-6" ]
[ "c++", "ocr", "tesseract" ]
[ "Is it possible to make this \"lyric-listing\" program easier/simpler?", "def listingLyrics(song):\n """\n returns the lyrics of a song in a list, and lowercased\n """\n\n lyricList = []\n song = song.lower()\n alphabet = 'abcdefghijklmonpqrstuvwxyz' #characters to be used in lyrics\n lyric = ''\n\n for char in song:\n \n if char not in alphabet:\n lyricList.append(lyric)\n lyric = '' #reset lyric value, but returns many ['']\n continue\n else:\n lyric += char \n \n lyricList = [e for e in lyricList if e not in ''] #added this to remove [''] from list\n \n return lyricList\n \n\nx = "She! loves you, yeah, yeah, yeah She loves you, yeah, yeah, yeah She loves you, yeah, yeah, yeah, yeah."\ny = "can't"\n\nHey everyone, so I'm doing this as a challenge for myself, a program that returns lyrics of a song in a list, all lowercased. For example, listingLyrics(x) returns ['she', 'loves', 'you', 'yeah', 'yeah', 'yeah', ...]. Is there a more efficient way to make this work, with smaller steps, and perhaps removing the list comprehension? Or is the list comprehension necessary? Can this be done recursively? Thanks." ]
[ "list", "recursion", "iteration", "list-comprehension", "simplify" ]
[ "Dragging down safari extension leaves grey overlay", "I have a safari extension which covers 80% height of the screen:\n\nFrom within the safari extension, if I try and drag and close the extension, it leaves a grey/black overlay over safari which I cannot close or dismiss\n\nHas anyone experiences this before, or have any ideas how to solve this?" ]
[ "ios", "swift", "xcode", "safari-extension" ]
[ "grep --ignore-case --only", "grep fails when using both --ignore-case and --only-match options.\nExample:\n\n$ echo \"abc\" | grep -io abc\nabc\n$ echo \"ABC\" | grep -io abc\n$ \n\n\nBut\n\n$ echo \"abc\" | grep -i abc\nabc\n$ echo \"ABC\" | grep -i abc\nABC\n\n\nAccording to man page:\n\n\n -o, --only-matching\n Show only the part of a matching line that matches PATTERN.\n -i, --ignore-case\n Ignore case distinctions in both the PATTERN and the input files.\n\n\n\nIs it a bug of grep or I didn't get the map page?\n\nI am using Mac OS X 10.6.8 and \n\n$ grep --version\ngrep (GNU grep) 2.5.1\n\n\nFound this link: http://lists.gnu.org/archive/html/bug-gnu-utils/2003-11/msg00040.html\n\nOf course it is possible to use workaround like grep -o [aA][bB][cC], but this doesn't seem to be a good option." ]
[ "regex", "bash", "unix", "grep", "gnu" ]