This file contains hidden or 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
| // Precalculate levels according to separator characters. | |
| var nodes = flattenedTree.Select(flatNode => new { | |
| Value = flatNode.Value, | |
| Level = flatNode.Value.Count(c => c == '.'), | |
| IsLeaf = false | |
| }).ToArray(); | |
| // Find leaves by comparing the levels of each two adjacent items. | |
| for (int i = 1; i < nodes.Length; i++) | |
| { |
This file contains hidden or 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
| private static void PopulateNodeWithRandomSubtree(TreeNode nodeToPopulate, int currentLevel) | |
| { | |
| // These can be the arguments of the function if necessary. | |
| const int maxTreeDepth = 5; | |
| const int maxSiblingCount = 4; | |
| // Generate children for this node if a fair coin toss yields 0 at least QUOTA times, | |
| // where QUOTA increases after each level. That way the deeper it gets, the less will | |
| // be the probability of generating more children. |
This file contains hidden or 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
| static class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var indices = Enumerable.Range(0, 26); | |
| var alphabet = indices.Select(i => (char)('A' + i)); | |
| WriteHeader("WhereMonadic"); | |
| foreach (var item in indices.WhereMonadic(item => item % 2 == 0)) | |
| { |
This file contains hidden or 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
| <# | |
| .SYNOPSIS | |
| Dumps the entire file tree of the specified folder(s) and saves the results to a ZIP archive. | |
| .PARAMETER SourceFolderList | |
| Path to the folder(s) to retrieve the file tree for. Multiple folders should be separated by the pipe character ("|"). | |
| .PARAMETER BackupStorageList | |
| Path to the folder(s) where the ZIP file will be stored. Multiple folders should be separated by the pipe character ("|"). |
This file contains hidden or 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
| function applyCustomStyle() { | |
| var config = { | |
| backgroundColor: "rgb(246, 239, 220)", | |
| foregroundColor: "rgb(64, 41, 25)", | |
| highlightColor: "rgb(255, 245, 173)", | |
| codeFontSize: "12px" | |
| }; | |
| var masterFrameContents = $("#KindleReaderIFrame").contents(); | |
| var pageFrameContents = masterFrameContents.find("iframe").contents(); |
This file contains hidden or 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
| #!/bin/bash | |
| # =========== CONFIG ============= | |
| # Assuming we'll set the Google Drive folder to ~/GoogleDrive | |
| GOOGLE_DRIVE_FOLDER=$HOME/GoogleDrive | |
| # ================================ | |
| # =========== ESSENTIAL ALIASES ========== | |
| INSTALL='sudo apt install --yes' |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """ | |
| Clone all public and private repositories from a specific GitHub user or organization. | |
| Uses only the Python standard library (no pip dependencies required). | |
| Usage: github-clone-all [-h] [--org] [--token TOKEN] [--output OUTPUT] [--ssh] [--dry-run] [--skip-existing] [--include PATTERN] [--exclude PATTERN] [--private-only] [--public-only] | |
| [--parallel N] [--quiet] [--verbose] [--version] | |
| target | |
| positional arguments: |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """ | |
| Pull latest changes for all Git repositories in a directory (fast-forward only). | |
| Uses only the Python standard library (no pip dependencies required). | |
| Usage: git-update-all [-h] [--dry-run] [--parallel N] [--quiet] [--verbose] [--version] [directory] | |
| positional arguments: | |
| directory Directory containing repositories (default: current directory) |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import os | |
| import subprocess | |
| import sys | |
| confirmation = raw_input("This script may DISCARD YOUR UNCOMMITTED CHANGES. Are you sure (Y/N)? ") | |
| if confirmation.lower() != "y": | |
| sys.exit(1) |
This file contains hidden or 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
| #!/usr/bin/env python | |
| """ | |
| Clone all GitHub Gists for the specified user. | |
| Copyright (c) 2018 Yuriy Guts | |
| usage: gist-clone-all.py [-h] user token | |
| positional arguments: | |
| user Which user's Gists to clone. |
OlderNewer