Determine installed PowerShell version
How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?
- Modified
- 6 Dec at 14:49
How do I update Node.js?
I did the following to update my npm: ``` npm update npm -g ``` But I have no idea how to update Node.js. Any suggestions? (I'm using Node.js 0.4.1 and want to update to Node.js 0.6.1.)
- Modified
- 8 Nov at 20:57
How do I merge two dictionaries in a single expression in Python?
I want to merge two dictionaries into a new dictionary. ``` x = {'a': 1, 'b': 2} y = {'b': 3, 'c': 4} z = merge(x, y) >>> z {'a': 1, 'b': 3, 'c': 4} ``` Whenever a key `k` is present in both diction...
- Modified
- 12 Feb at 07:3
Undo a Git merge that hasn't been pushed yet
I accidentally ran `git merge some_other_branch` on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge? --- After merging, `git status` says: ``` # On br...
How do I lowercase a string in Python?
Is there a way to convert a string to lowercase? ``` "Kilometers" → "kilometers" ```
Importing files from different folder
I have this folder structure: ``` application ├── app │ └── folder │ └── file.py └── app2 └── some_folder └── some_file.py ``` How can I import a function from `file.py`, from wit...
- Modified
- 28 Aug at 02:26
"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6
I'm using ArcGIS JSAPI 4.12 and wish to use [Spatial Illusions](https://github.com/spatialillusions/milsymbol) to draw military symbols on a map. When I add `milsymbol.js` to the script, the console ...
- Modified
- 8 Mar at 22:36
Python: Find in list
I use the following to check if `item` is in `my_list`: ``` if item in my_list: print("Desired item is in list") ``` Is "`if item in my_list:`" the most "pythonic" way of finding an item in a lis...
The Definitive C++ Book Guide and List
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programming languages, which are often picked up on the go from tuto...
How do I remove local (untracked) files from the current Git working tree?
How do I delete untracked local files from the current working tree?
- Modified
- 3 Aug at 04:58
How do I tell if a file does not exist in Bash?
This checks if a file exists: ``` #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi ``` How do I only check if the file does e...
Sort array of objects by string property value
I have an array of JavaScript objects: ``` var objs = [ { first_nom: 'Lazslo', last_nom: 'Jamf' }, { first_nom: 'Pig', last_nom: 'Bodine' }, { first_nom: 'Pirate', last_nom: 'Pr...
- Modified
- 15 Feb at 21:49
How do I generate a random integer in C#?
How do I generate a random integer in C#?
How does the Java 'for each' loop work?
Consider: ``` List<String> someList = new ArrayList<String>(); // add "monkey", "donkey", "skeleton key" to someList ``` ``` for (String item : someList) { System.out.println(item); } ``` W...
- Modified
- 23 Feb at 13:21
How to check if a string contains a substring in Bash
I have a string in Bash: ``` string="My string" ``` How can I test if it contains another string? ``` if [ $string ?? 'foo' ]; then echo "It's there!" fi ``` Where `??` is my unknown operator. Do ...
How to check if the string is empty?
Does Python have something like an empty string variable where you can do: ``` if myString == string.empty: ``` Regardless, what's the most elegant way to check for empty string values? I find hard...
- Modified
- 1 Nov at 13:1
How do I create a copy of a directory in Unix/Linux?
I want to [recursively](https://en.wikipedia.org/wiki/Recursion) create a copy of a directory and all its contents (e.g. files and subdirectories).
Fastest way to check if a value exists in a list
What is the fastest way to check if a value exists in a very large list?
- Modified
- 6 Jun at 04:40
Remove duplicate values from JS array
I have a very simple JavaScript array that may or may not contain duplicates. ``` var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"]; ``` I need to remove the duplicates and put the un...
- Modified
- 27 Dec at 00:58
How do I exit Vim?
I am stuck and cannot escape. It says: ``` type :quit<Enter> to quit VIM ``` But when I type that it simply appears in the object body.
How do I install pip on macOS or OS X?
I spent most of the day yesterday searching for a clear answer for installing `pip` (package manager for Python). I can't find a good solution. How do I install it?
- Modified
- 8 Apr at 16:21
What is Python's equivalent of && (logical-and) in an if-statement?
This doesn't work: ``` if cond1 && cond2: ```
- Modified
- 2 Mar at 00:0
How do I reset or revert a file to a specific revision?
How do I revert a modified file to its previous revision at a specific commit hash (which I determined via [git log](https://git-scm.com/docs/git-log) and [git diff](https://git-scm.com/docs/git-diff)...
- Modified
- 8 Jul at 04:17
How do I kill the process currently using a port on localhost in Windows?
How can I remove the current process/application which is already assigned to a port? For example: `localhost:8080`
- Modified
- 20 Jan at 09:21
Length of a JavaScript object
I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object? ``` const myObject = new Object(); myObject["firstname"] = "Gareth"; myObject["lastname"...
- Modified
- 10 Jul at 18:31