{"page":1,"pageSize":50,"results":[{"id":"so_10005939","prompt":"How do I consume the JSON POST data in an Express application I'm sending the following JSON string to my server. ( { id = 1; name = foo; }, { id = 2; name = bar; } ) On the server I have this. app.post('/', function(request, response) { console.log(\"Got response: \" + response.statusCode); response.on('data', function(chunk) { queryResponse+=chunk; console.log('data'); }); response.on('end', function(){ console.log('end'); }); }); When I send the string, it shows that I got a 200 response, but those other two methods never run. Why is that?","source":"https://stackoverflow.com/questions/10005939/how-do-i-consume-the-json-post-data-in-an-express-application","category":"json","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10011011","prompt":"How do I read a JSON file into (server) memory? I am doing some experimentation with Node.js and would like to read a JSON object, either from a text file or a .js file (which is better??) into memory so that I can access that object quickly from code. I realize that there are things like Mongo, Alfred, etc out there, but that is not what I need right now. How do I read a JSON object out of a text or js file and into server memory using JavaScript/Node?","source":"https://stackoverflow.com/questions/10011011/how-do-i-read-a-json-file-into-server-memory","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10075990","prompt":"Upgrading Node.js to the latest version So, I have Node.js installed and now when I tried to install Mongoosejs, I got an error telling me that I don't have the needed version of Node.js (I have v0.4.11 and v0.4.12 is needed). How can I upgrade to this version? I suppose I just could install it again with the latest version, but I don't want to do it before I'm sure that my project folders in the folder &quot;node&quot; won't be deleted.","source":"https://stackoverflow.com/questions/10075990/upgrading-node-js-to-the-latest-version","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10112178","prompt":"Differences between Socket.IO and websockets What are the differences between Socket.IO and websockets in Node.js? Are they both server push technologies? The only differences I felt was, Socket.IO allowed me to send/emit messages by specifying an event name. In the case of Socket.IO a message from server will reach on all clients, but for the same in websockets I was forced to keep an array of all connections and loop through it to send messages to all clients. Also, I wonder why web inspectors (like Chrome, Firebug, and Fiddler) are unable to catch these messages (from Socket.IO/websocket) from the server? Please clarify this.","source":"https://stackoverflow.com/questions/10112178/differences-between-socket-io-and-websockets","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10232192","prompt":"Exec : display stdout &quot;live&quot; I have this simple script : var exec = require('child_process').exec; exec('coffee -cw my_file.coffee', function(error, stdout, stderr) { console.log(stdout); }); where I simply execute a command to compile a coffee-script file. But stdout never get displayed in the console, because the command never ends (because of the -w option of coffee). If I execute the command directly from the console I get message like this : 18:05:59 - compiled my_file.coffee My question is : is it possible to display these messages with the node.js exec ? If yes how ? !","source":"https://stackoverflow.com/questions/10232192/exec-display-stdout-live","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10377998","prompt":"How can I iterate over files in a given directory? I need to iterate through all .asm files inside a given directory and do some actions on them. How can this be done in a efficient way?","source":"https://stackoverflow.com/questions/10377998/how-can-i-iterate-over-files-in-a-given-directory","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10382929","prompt":"How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version I am trying to use Notepad++ as my all-in-one tool edit, run, compile, etc. I have JRE installed, and I have setup my path variable to the .../bin directory. When I run my &quot;Hello world&quot; in Notepad++, I get this message: java.lang.UnsupportedClassVersionError: test_hello_world : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) ... More recent versions of Java produce a more detailed exception message: java.lang.UnsupportedClassVersionError: com/xxx/yyy/Application has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 I think the problem here is about versions; some versions of Java may be old or too new. How do I fix it? Should I install the JDK, and setup my path variable to the JDK instead of JRE? What is the difference between the PATH variable in JRE or JDK?","source":"https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_104420","prompt":"How do I generate all permutations of a list? How do I generate all the permutations of a list? For example: permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1]","source":"https://stackoverflow.com/questions/104420/how-do-i-generate-all-permutations-of-a-list","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10563644","prompt":"How to specify HTTP error code using Express.js? I have tried: app.get('/', function(req, res, next) { var e = new Error('error message'); e.status = 400; next(e); }); and: app.get('/', function(req, res, next) { res.statusCode = 400; var e = new Error('error message'); next(e); }); but always an error code of 500 is announced.","source":"https://stackoverflow.com/questions/10563644/how-to-specify-http-error-code-using-express-js","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10617070","prompt":"How do I measure the execution time of JavaScript code with callbacks? I have a piece of JavaScript code that I am executing using the node.js interpreter. for(var i = 1; i < LIMIT; i++) { var user = { id: i, name: \"MongoUser [\" + i + \"]\" }; db.users.save(user, function(err, saved) { if(err || !saved) { console.log(\"Error\"); } else { console.log(\"Saved\"); } }); } How can I measure the time taken by these database insert operations? I could compute the difference of date values after and before this piece of code but that would be incorrect because of the asynchronous nature of the code.","source":"https://stackoverflow.com/questions/10617070/how-do-i-measure-the-execution-time-of-javascript-code-with-callbacks","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1069066","prompt":"How can I get the current stack trace in Java? How do I get the current stack trace in Java, like how in .NET you can do Environment.StackTrace ? I found Thread.dumpStack() but it is not what I want - I want to get the stack trace back, not print it out.","source":"https://stackoverflow.com/questions/1069066/how-can-i-get-the-current-stack-trace-in-java","category":"stack-trace","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10712002","prompt":"Create an empty list with certain size in Python How do I create an empty list that can hold 10 elements? After that, I want to assign values in that list. For example: xs = list() for i in range(0, 9): xs[i] = i However, that gives IndexError: list assignment index out of range . Why?","source":"https://stackoverflow.com/questions/10712002/create-an-empty-list-with-certain-size-in-python","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1085709","prompt":"What does &#39;synchronized&#39; mean? I have some questions regarding the usage and significance of the synchronized keyword. What is the significance of the synchronized keyword? When should methods be synchronized ? What does it mean programmatically and logically?","source":"https://stackoverflow.com/questions/1085709/what-does-synchronized-mean","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_10865347","prompt":"Node.js get file extension Im creating a file upload function in node.js with express 3. I would like to grab the file extension of the image. so i can rename the file and then append the file extension to it. app.post('/upload', function(req, res, next) { var is = fs.createReadStream(req.files.upload.path), fileExt = '', // I want to get the extension of the image here os = fs.createWriteStream('public/images/users/' + req.session.adress + '.' + fileExt); }); How can i get the extension of the image in node.js?","source":"https://stackoverflow.com/questions/10865347/node-js-get-file-extension","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1102891","prompt":"How to check if a String is numeric in Java How would you check if a String was a number before parsing it?","source":"https://stackoverflow.com/questions/1102891/how-to-check-if-a-string-is-numeric-in-java","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11104028","prompt":"Why is process.env.NODE_ENV undefined? I'm trying to follow a tutorial on NodeJS. I don't think I missed anything but whenever I call the process.env.NODE_ENV the only value I get back is undefined . According to my research the default value should be development . How is this value dynamically set and where is it set initially?","source":"https://stackoverflow.com/questions/11104028/why-is-process-env-node-env-undefined","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1112343","prompt":"How do I capture SIGINT in Python? I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a Ctrl + C signal, and I'd like to do some cleanup. In Perl I'd do this: $SIG{'INT'} = 'exit_gracefully'; sub exit_gracefully { print &quot;Caught ^C \\n&quot;; exit (0); } How do I do the analogue of this in Python?","source":"https://stackoverflow.com/questions/1112343/how-do-i-capture-sigint-in-python","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11177954","prompt":"How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19. My node version is: node -v v0.6.1-pre NVM says this (after I install a version of node for the first time in one bash terminal): nvm ls v0.6.19 current: v0.6.19 But when I restart bash, this is what I see: nvm ls v0.6.19 current: v0.6.1-pre default -> 0.6.19 (-> v0.6.19) So where is this phantom node 0.6.1-pre version and how can I get rid of it? I'm trying to install libraries via NPM so that I can work on a project. I tried using BREW to update before NVM, using brew update and brew install node . I've tried deleting the \"node\" directory in my /usr/local/include and the \"node\" and \"node_modules\" in my /usr/local/lib . I've tried uninstalling npm and reinstalling it following these instructions. All of this because I was trying to update an older version of node to install the \"zipstream\" library. Now there's folders in my users directory, and the node version STILL isn't up to date, even though NVM says it's using 0.6.19. Ideally, I'd like to uninstall nodejs, npm, and nvm, and just reinstall the entire thing from scratch on my system.","source":"https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11248073","prompt":"How do I remove all packages installed by pip? How do I uninstall all packages installed by pip from my currently activated virtual environment?","source":"https://stackoverflow.com/questions/11248073/how-do-i-remove-all-packages-installed-by-pip","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1132941","prompt":"&quot;Least Astonishment&quot; and the Mutable Default Argument def foo(a=[]): a.append(5) return a Python novices expect this function called with no parameter to always return a list with only one element: [5] . The result is different and astonishing: >>> foo() [5] >>> foo() [5, 5] >>> foo() [5, 5, 5] >>> foo() [5, 5, 5, 5] >>> foo() The behavior has an underlying explanation, but it is unexpected if you don't understand internals. What is the reason for binding the default argument at function definition, and not at function execution? I doubt the experienced behavior has a practical use (who really used static variables in C, without breeding bugs?) Edit : Baczek made an interesting example . Together with your comments and Utaal's in particular , I elaborated: def a(): print(&quot;a executed&quot;) return [] def b(x=a()): x.append(5) print(x) a executed >>> b() [5] >>> b() [5, 5] It seems that the design decision was relative to where to put the scope of parameters: inside the function, or &quot;together&quot; with it? Doing the binding inside the function would mean that x is effectively bound to the specified default when the function is called, not defined, something that would present a deep flaw: the def line would be &quot;hybrid&quot; in the sense that part of the binding (of the function object) would happen at definition, and part (assignment of default parameters) at function invocation time. The actual behavior is more consistent: everything of that line gets evaluated when that line is executed, meaning at function definition.","source":"https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11461607","prompt":"Can&#39;t start Eclipse - Java was started but returned exit code=13 I am trying to get my first taste of Android development using Eclipse. I ran into this problem when trying to run Eclipse, having installed version 4.2 only minutes ago. After first trying to start Eclipse without any parameters to specify the Java VM, I got an error message saying it couldn't find a Java VM called javaw.exe inside the Eclipse folder , so I found where Java was installed and specified that location as the parameter in the shortcut's target. Now I get a different error, Java was started but returned exit code=13 . Similar questions seem to indicate that it's a 32-bit/64-bit conflict, but I'm 99% positive that I downloaded 64-bit versions of both Eclipse and Java (RE 7u5) , which I chose because I have 64-bit Windows 7. If anyone knows how to confirm that my Eclipse and Java are 64-bit, that'd be appreciated. If you think my problem is a different one, please help! Please speak as plainly as you can, as I am totally new to Eclipse and Java. Shortcut Target: \"C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\eclipse.exe\" -vm \"C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe\" Full error code...: Java was started but returned exit code=13 C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe -Xms40m -Xmx512m -XX:MaxPermSize=256m -jar C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\\\plugins/org.eclipse.equinox.launcher_1.30v20120522-1813.jar -os win32 -ws win32 -arch x86_64 -showsplash C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\\\plugins\\org.eclipse.platform_4.2.0.v201206081400\\splash.bmp -launcher C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\eclipse.exe -name Eclipse --launcher.library C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\\\plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v201205221813\\eclipse_1503.dll -startup C:\\Program Files\\Eclipse-SDK-4.2-win32-x86_64\\eclipse\\\\plugins/org.eclipse.equinox.launcher_1.30v20120522-1813.jar --launcher.","source":"https://stackoverflow.com/questions/11461607/cant-start-eclipse-java-was-started-but-returned-exit-code-13","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11928013","prompt":"&quot;NODE_ENV&quot; is not recognized as an internal or external command, operable command or batch file I'm trying to setup an environment for a Node.js app. but I'm getting this error every time. \"NODE_ENV\" is not recognized as an internal or external command, operable command or batch file. What does this mean and how can I solve this problem? I'm using Windows and also tried set NODE_ENV=development but had no luck.","source":"https://stackoverflow.com/questions/11928013/node-env-is-not-recognized-as-an-internal-or-external-command-operable-comman","category":"windows","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_11944932","prompt":"How to download a file with Node.js (without using third-party libraries)? How do I download a file with Node.js without using third-party libraries ? I don't need anything special. I only want to download a file from a given URL, and then save it to a given directory.","source":"https://stackoverflow.com/questions/11944932/how-to-download-a-file-with-node-js-without-using-third-party-libraries","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1207406","prompt":"How to remove items from a list while iterating? I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria. for tup in somelist: if determine(tup): code_to_remove_tup What should I use in place of code_to_remove_tup ? I can't figure out how to remove the item in this fashion.","source":"https://stackoverflow.com/questions/1207406/how-to-remove-items-from-a-list-while-iterating","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1247486","prompt":"List comprehension vs map Is there a reason to prefer using map() over list comprehension or vice versa? Is either of them generally more efficient or considered generally more Pythonic than the other?","source":"https://stackoverflow.com/questions/1247486/list-comprehension-vs-map","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12478679","prompt":"npm install vs. update - what&#39;s the difference? What is the practical difference between npm install and npm update ? When should I use which?","source":"https://stackoverflow.com/questions/12478679/npm-install-vs-update-whats-the-difference","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12594541","prompt":"NPM global install &quot;cannot find module&quot; I wrote a module which I published to npm a moment ago ( https://npmjs.org/package/wisp ) So it installs fine from the command line: npm i -g wisp However, when I run it from the command line, I keep getting an error that optimist isn't installed: wisp Output: Error: Cannot find module 'optimist' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:12:10) at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:96:4) at Module._compile (module.js:449:26) at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25) at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29) at fs.stat.notSources.(anonymous function) (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18) However, I have specified it in package.json as a dependency: { &quot;name&quot;: &quot;wisp&quot;, &quot;author&quot;: &quot;Brendan Scarvell <bscarvell@gmail.com>&quot;, &quot;version&quot;: &quot;0.1.0&quot;, &quot;description&quot;: &quot;Global nodejs file server&quot;, &quot;dependencies&quot;: { &quot;optimist&quot;: &quot;~0.3.4&quot; }, &quot;repository&quot;: &quot;git://github.com/tehlulz/wisp&quot;, &quot;bin&quot;: { &quot;wisp&quot; : &quot;./wisp&quot; } } What can I do to get this running? I know its to do with the bin part adding the executable to bin and the node_modules folder folder in that directory being empty.","source":"https://stackoverflow.com/questions/12594541/npm-global-install-cannot-find-module","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1264709","prompt":"Convert InputStream to byte array in Java How do I read an entire InputStream into a byte array?","source":"https://stackoverflow.com/questions/1264709/convert-inputstream-to-byte-array-in-java","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12682268","prompt":"Is it possible to compile TypeScript into minified code? Is there an option to compile TypeScript code's output as minified? Or are we left to deal with that in a separate process? And does obfuscation affect the answer?","source":"https://stackoverflow.com/questions/12682268/is-it-possible-to-compile-typescript-into-minified-code","category":"typescript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12709074","prompt":"How do you explicitly set a new property on `window` in TypeScript? I setup global namespaces for my objects by explicitly setting a property on window . window.MyNamespace = window.MyNamespace || {}; TypeScript underlines MyNamespace and complains that: The property 'MyNamespace' does not exist on value of type 'window' any\" I can make the code work by declaring MyNamespace as an ambient variable and dropping the window explicitness but I don't want to do that. declare var MyNamespace: any; MyNamespace = MyNamespace || {}; How can I keep window in there and make TypeScript happy? As a side note I find it especially funny that TypeScript complains since it tells me that window is of type any which by definitely can contain anything.","source":"https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript","category":"typescript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12710905","prompt":"How do I dynamically assign properties to an object in TypeScript? If I wanted to programmatically assign a property to an object in Javascript, I would do it like this: var obj = {}; obj.prop = &quot;value&quot;; But in TypeScript, this generates an error: The property 'prop' does not exist on value of type '{}' How do I assign any new property to an object in TypeScript?","source":"https://stackoverflow.com/questions/12710905/how-do-i-dynamically-assign-properties-to-an-object-in-typescript","category":"typescript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12789231","prompt":"Class type check in TypeScript In ActionScript, it is possible to check the type at run-time using the is operator : var mySprite:Sprite = new Sprite(); trace(mySprite is Sprite); // true trace(mySprite is DisplayObject);// true trace(mySprite is IEventDispatcher); // true Is it possible to detect if a variable (extends or) is a certain class or interface with TypeScript? I couldn't find anything about it in the language specs. It should be there when working with classes/interfaces.","source":"https://stackoverflow.com/questions/12789231/class-type-check-in-typescript","category":"typescript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_129507","prompt":"How do you test that a Python function throws an exception? How does one write a unit test that fails only if a function doesn't throw an expected exception?","source":"https://stackoverflow.com/questions/129507/how-do-you-test-that-a-python-function-throws-an-exception","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12957820","prompt":"How to reuse existing C# class definitions in TypeScript projects I am just going to start use TypeScript in my HTML client project which belongs to a MVC project with a entity framework domain model already there. I want my two projects (client side and server side) totally separated as two teams will work on this... JSON and REST is used to communicate objects back and forth. Of course, my domain objects on the client side should match the objects on the server side. In the past, I have normally done this manually. Is there a way to reuse my C# class definitions (specially of the POJO classes in my domain model) to create the corresponding classes in TypeScript\"?","source":"https://stackoverflow.com/questions/12957820/how-to-reuse-existing-c-class-definitions-in-typescript-projects","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_12973777","prompt":"How to run a shell script at startup On an Amazon S3 Linux instance, I have two scripts called start_my_app and stop_my_app which start and stop forever (which in turn runs my Node.js application). I use these scripts to manually start and stop my Node.js application. So far so good. My problem: I also want to set it up such that start_my_app is run whenever the system boots up. I know that I need to add a file inside init.d and I know how to symlink it to the proper directory within rc.d , but I can't figure out what actually needs to go inside the file that I place in init.d . I'm thinking it should be just one line, like, start_my_app , but that hasn't been working for me.","source":"https://stackoverflow.com/questions/12973777/how-to-run-a-shell-script-at-startup","category":"linux","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13212625","prompt":"TypeScript function overloading Section 6.3 of the TypeScript language spec talks about function overloading and gives concrete examples on how to implement this. However if I try something like this: export class LayerFactory { constructor(public styleFactory: Symbology.StyleFactory) { // Init... } createFeatureLayer(userContext: Model.UserContext, mapWrapperObj: MapWrapperBase): any { throw new Error('not implemented'); } createFeatureLayer(layerName: string, style: any): any { throw new Error('not implemented'); } } I get a compiler error indicating duplicate identifier even though function parameters are of different types. Even if I add an additional parameter to the second createFeatureLayer function, I still get a compiler error. Ideas, please.","source":"https://stackoverflow.com/questions/13212625/typescript-function-overloading","category":"typescript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13375357","prompt":"Proper use cases for Android UserManager.isUserAGoat()? I was looking at the new APIs introduced in Android 4.2 . While looking at the UserManager class I came across the following method: public boolean isUserAGoat() Used to determine whether the user making this call is subject to teleportations. Returns whether the user making this call is a goat. How and when should this be used?","source":"https://stackoverflow.com/questions/13375357/proper-use-cases-for-android-usermanager-isuseragoat","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13542667","prompt":"Create Directory When Writing To File In Node.js I've been tinkering with Node.js and found a little problem. I've got a script which resides in a directory called data . I want the script to write some data to a file in a subdirectory within the data subdirectory. However I am getting the following error: { [Error: ENOENT, open 'D:\\data\\tmp\\test.txt'] errno: 34, code: 'ENOENT', path: 'D:\\\\data\\\\tmp\\\\test.txt' } The code is as follows: var fs = require('fs'); fs.writeFile(\"tmp/test.txt\", \"Hey there!\", function(err) { if(err) { console.log(err); } else { console.log(\"The file was saved!\"); } }); Can anybody help me in finding out how to make Node.js create the directory structure if it does not exits for writing to a file?","source":"https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13784192","prompt":"Creating an empty Pandas DataFrame, and then filling it I'm starting from the pandas DataFrame documentation here: Introduction to data structures I'd like to iteratively fill the DataFrame with values in a time series kind of calculation. I'd like to initialize the DataFrame with columns A, B, and timestamp rows, all 0 or all NaN. I'd then add initial values and go over this data calculating the new row from the row before, say row[A][t] = row[A][t-1]+1 or so. I'm currently using the code as below, but I feel it's kind of ugly and there must be a way to do this with a DataFrame directly or just a better way in general. import pandas as pd import datetime as dt import scipy as s base = dt.datetime.today().date() dates = [ base - dt.timedelta(days=x) for x in range(9, -1, -1) ] valdict = {} symbols = ['A','B', 'C'] for symb in symbols: valdict[symb] = pd.Series( s.zeros(len(dates)), dates ) for thedate in dates: if thedate > dates[0]: for symb in valdict: valdict[symb][thedate] = 1 + valdict[symb][thedate - dt.timedelta(days=1)]","source":"https://stackoverflow.com/questions/13784192/creating-an-empty-pandas-dataframe-and-then-filling-it","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13786160","prompt":"Copy folder recursively in Node.js Is there an easier way to copy a folder and all its content without manually doing a sequence of fs.readir , fs.readfile , fs.writefile recursively? I am just wondering if I'm missing a function which would ideally work like this: fs.copy(&quot;/path/to/source/folder&quot;, &quot;/path/to/destination/folder&quot;); Regarding this historic question. Note that fs.cp and fs.cpSync can copy folders recursively and are available in Node v16+","source":"https://stackoverflow.com/questions/13786160/copy-folder-recursively-in-node-js","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_13890935","prompt":"Does Python&#39;s time.time() return the local or UTC timestamp? Does time.time() in the Python time module return the system's time or the time in UTC?","source":"https://stackoverflow.com/questions/13890935/does-pythons-time-time-return-the-local-or-utc-timestamp","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14014086","prompt":"What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA? What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA ? When I see the examples on the web, I see them there used kind of interchangeably. What is the difference between them? Why would you want to use one over the other?","source":"https://stackoverflow.com/questions/14014086/what-is-difference-between-crudrepository-and-jparepository-interfaces-in-spring","category":"java","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14031763","prompt":"Doing a cleanup action just before Node.js exits I want to tell Node.js to always do something just before it exits, for whatever reason — Ctrl + C , an exception, or any other reason. I tried this: process.on('exit', function (){ console.log('Goodbye!'); }); I started the process, killed it, and nothing happened. I started it again, pressed Ctrl + C , and still nothing happened...","source":"https://stackoverflow.com/questions/14031763/doing-a-cleanup-action-just-before-node-js-exits","category":"node.js","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14040562","prompt":"How to search in array of object in mongodb Suppose the mongodb document(table) 'users' is { _id: 1, name: { first: 'John', last: 'Backus' }, birth: new Date('Dec 03, 1924'), death: new Date('Mar 17, 2007'), contribs: ['Fortran', 'ALGOL', 'Backus-Naur Form', 'FP'], awards: [ { award: 'National Medal', year: 1975, by: 'NSF' }, { award: 'Turing Award', year: 1977, by: 'ACM' } ] } // ...and other object(person)s I want to find the person who has the award 'National Medal' and must be awarded in year 1975 There could be other persons who have this award in different years. How can I find this person using award type and year. So I can get exact person.","source":"https://stackoverflow.com/questions/14040562/how-to-search-in-array-of-object-in-mongodb","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14249506","prompt":"How can I wait In Node.js (JavaScript)? l need to pause for a period of time I'm developing a console script for personal needs. I need to be able to pause for an extended amount of time, but, from my research, Node.js has no way to stop as required. It’s getting hard to read users’ information after a period of time... I’ve seen some code out there, but I believe they have to have other code inside of them for them to work such as: setTimeout(function() { }, 3000); However, I need everything after this line of code to execute after the period of time. For example, // start of code console.log('Welcome to my console,'); some-wait-code-here-for-ten-seconds... console.log('Blah blah blah blah extra-blah'); // end of code I've also seen things like yield sleep(2000); But Node.js doesn't recognize this. How can I achieve this extended pause?","source":"https://stackoverflow.com/questions/14249506/how-can-i-wait-in-node-js-javascript-l-need-to-pause-for-a-period-of-time","category":"javascript","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1471994","prompt":"What is setup.py? What is setup.py and how can it be configured or used?","source":"https://stackoverflow.com/questions/1471994/what-is-setup-py","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14770735","prompt":"How do I change the figure size with subplots? How do I increase the figure size for this figure ? This does nothing: f.figsize(15, 15) Example code from the link: import matplotlib.pyplot as plt import numpy as np # Simple data to display in various forms x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) plt.close('all') # Just a figure and one subplot f, ax = plt.subplots() ax.plot(x, y) ax.set_title('Simple plot') # Two subplots, the axes array is 1-d f, axarr = plt.subplots(2, sharex=True) axarr[0].plot(x, y) axarr[0].set_title('Sharing X axis') axarr[1].scatter(x, y) # Two subplots, unpack the axes array immediately f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) ax1.plot(x, y) ax1.set_title('Sharing Y axis') ax2.scatter(x, y) # Three subplots sharing both x/y axes f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True) ax1.plot(x, y) ax1.set_title('Sharing both axes') ax2.scatter(x, y) ax3.scatter(x, 2 * y ** 2 - 1, color='r') # Fine-tune figure; make subplots close to each other and hide x ticks for # all but bottom plot. f.subplots_adjust(hspace=0) plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False) # row and column sharing f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row') ax1.plot(x, y) ax1.set_title('Sharing x per column, y per row') ax2.scatter(x, y) ax3.scatter(x, 2 * y ** 2 - 1, color='r') ax4.plot(x, 2 * y ** 2 - 1, color='r') # Four axes, returned as a 2-d array f, axarr = plt.subplots(2, 2) axarr[0, 0].plot(x, y) axarr[0, 0].set_title('Axis [0,0]') axarr[0, 1].scatter(x, y) axarr[0, 1].set_title('Axis [0,1]') axarr[1, 0].plot(x, y ** 2) axarr[1, 0].set_title('Axis [1,0]') axarr[1, 1].scatter(x, y ** 2) axarr[1, 1].set_title('Axis [1,1]') # Fine-tune figure; hide x ticks for top plots and y ticks for right plots plt.setp([a.get_xticklabels() for a in axarr[0, :]], visible=False) plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False) # Four polar axes f, axarr = plt.subplots(2, 2, subpl","source":"https://stackoverflow.com/questions/14770735/how-do-i-change-the-figure-size-with-subplots","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_14774907","prompt":"TypeScript: Convert a bool to string value I am unable to convert a boolean to a string value in TypeScript. I have tried to use the toString() method but it does not seem to be implemented on bool.","source":"https://stackoverflow.com/questions/14774907/typescript-convert-a-bool-to-string-value","category":"casting","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_1504717","prompt":"Why does comparing strings using either &#39;==&#39; or &#39;is&#39; sometimes produce a different result? Two string variables are set to the same value. s1 == s2 always returns True , but s1 is s2 sometimes returns False . If I open my Python interpreter and do the same is comparison, it succeeds: >>> s1 = 'text' >>> s2 = 'text' >>> s1 is s2 True Why is this?","source":"https://stackoverflow.com/questions/1504717/why-does-comparing-strings-using-either-or-is-sometimes-produce-a-differe","category":"python","created_at":"2026-05-22T07:38:10.956Z"},{"id":"so_15182496","prompt":"Why does this code using random strings print &quot;hello world&quot;? The following print statement would print \"hello world\". Could anyone explain this? System.out.println(randomString(-229985452) + \" \" + randomString(-147909649)); And randomString() looks like this: public static String randomString(int i) { Random ran = new Random(i); StringBuilder sb = new StringBuilder(); while (true) { int k = ran.nextInt(27); if (k == 0) break; sb.append((char)('`' + k)); } return sb.toString(); }","source":"https://stackoverflow.com/questions/15182496/why-does-this-code-using-random-strings-print-hello-world","category":"java","created_at":"2026-05-22T07:38:10.956Z"}],"nextPage":2}