This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search through current directory and all sub directories for text | |
dir -Recurse | Select-String -pattern "STRING" | |
# Recursive search and table formatting | |
dir -Recurse | Select-String -pattern "latest_net_G" | Select Path, LineNumber, Line | Format-Table | |
# Search through all files with the .EXT extension in the current directory | |
# and find any lines that match with STRING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from slackclient import SlackClient | |
slack_client = SlackClient(SLACK_OAUTH) | |
# Print a list of users and their respective IDs | |
request = slack_client.api_call("users.list") | |
if request['ok']: | |
for item in request['members']: | |
print("{}: {}".format(item['name'], item['id'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Trim ending characters of a filename of every file in a folder | |
Get-ChildItem 'FOLDER_NAME' | rename-item -newname { $_.name.substring(0, $_.name.length-N) } | |
# Trim beginning N characters of a filename of every file in a folder | |
get-childitem *.txt | rename-item -newname { [string]($_.name).substring(N) } | |
# Append a file extension to every file in a folder | |
Get-ChildItem 'FOLDER_NAME' | rename-item -NewName {$_.FullName + ".pdf"} | |
# Append text to every filename BEFORE the file extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read authentication credentials from file | |
var fs = require('fs'); | |
fs.readFile('credentials.txt', 'utf8', function(err, contents) { | |
var text = contents.split("\n") | |
text[1] = text[1].substring(0, text[1].length - 1); | |
text[2] = text[2].substring(0, text[2].length - 1); | |
username = text[1]; | |
password = text[2]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Number of villages | |
N = int(input()) | |
#List of village positions | |
villages = list() | |
for i in range(N): | |
villages.append(float(input())) | |
#List of distances between villages | |
distances = list() |
NewerOlder