Skip to content

Instantly share code, notes, and snippets.

local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n%{$reset_color%} "
local user_symbol='%(!.#.$)'
#Only show current and previous directory layer if more than 4 layers
local current_dir="%B%{$fg[blue]%}%(4~|.../%2~|%3~) %{$reset_color%}"
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
local rvm_ruby='$(ruby_prompt_info)'
local venv_prompt='$(virtualenv_prompt_info)'
if [[ "${plugins[@]}" =~ 'kube-ps1' ]]; then
local kube_prompt='$(kube_ps1)'
@DCCoder90
DCCoder90 / combineCSV.ps1
Created July 22, 2021 00:25
Combine all CSVs in directory to single CSV
$CSVFolder = 'C:\path\to\directory\with\csvs';
$OutputFile = 'C:\path\to\combined.csv';
$CSV = Get-ChildItem -Path $CSVFolder -Filter *.csv | ForEach-Object {
Import-Csv -Path $_
}
$CSV | Export-Csv -Path $OutputFile -NoTypeInformation -Force;
@DCCoder90
DCCoder90 / Start-ForAllRepos.ps1
Created May 15, 2021 00:45
Powershell scrip to iterate through a directory containing git repos and perform a specified action. https://stackoverflow.com/questions/66249041/iterate-thru-all-folders-at-the-current-path-where-the-script-resides
function global:Start-ForAllRepos
{
[CmdletBinding()]
param (
[Parameter(Position=0)]
[string]
$Cmd = 'git status',
[Parameter(Position=1)]
[string[]]
@DCCoder90
DCCoder90 / gdown.py
Created September 14, 2020 22:35
Download file from Google Drive using CLI. https://stackoverflow.com/a/39225039
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
@DCCoder90
DCCoder90 / IncList.cs
Created July 23, 2020 08:22
Very simple generic increment/decremental list
public class IncList<T>
{
private readonly IDictionary<T,int> _incList;
public IncList()
{
_incList = new Dictionary<T, int>();
}
public void Add(T item)
@DCCoder90
DCCoder90 / binary.cs
Created September 30, 2019 15:00
Quick and dirty example of a binary search (using LinqPad)
void Main()
{
int[] intArray = new int[]{ 51,83,2523,2452,124,656,254,115,15,5,5,15,156,4378,568,4,37,2,72,2,8,9,10,234,39,23,56,1,63,33};
var list = intArray.ToList();
list.Sort();
var find = search(list,656);
find.Dump();
}
@DCCoder90
DCCoder90 / GOL.cs
Created July 16, 2019 22:11
Simple Game of Life. Need to test to make sure it's following all the rules.
internal class GOL
{
private int _genCounter = 0;
private bool[,] _board;
private int _boardSize;
public void Play()
{
Initialize(30);
PrintBoard();
@DCCoder90
DCCoder90 / AsyncEnumerableExtensions.cs
Last active September 2, 2023 18:41
Convert IEnumerable to IAsyncEnumerable It has come to my attention that this is at the top of google search results. Before attempting to use this please read the comments below. This is old, and outdated. The comments contain better solutions. TL&DR: use System.Linq.Async's ToAsyncEnumerable()
public static class AsyncEnumerableExtensions
{
public static IAsyncEnumerable<TResult> SelectAsync<T, TResult>(this IEnumerable<T> enumerable,
Func<T, Task<TResult>> selector)
{
return AsyncEnumerable.CreateEnumerable(() =>
{
var enumerator = enumerable.GetEnumerator();
var current = default(TResult);
@DCCoder90
DCCoder90 / SecretManagerExample.cs
Created January 1, 2019 19:27
Working with AWS Secret Manager
var awsCredentials = new BasicAWSCredentials("someaccesskey", "somesecretkey");
var secretManager = new SecretManager(awsCredentials);
secretManager.StoreSecret("somesecretKey","mysecret","Just some test secret I wanted to try");
@DCCoder90
DCCoder90 / AWSSecretManager.cs
Created January 1, 2019 19:22
AWS Secret Manager
internal class SecretManager
{
private readonly AWSCredentials _credentials;
private readonly AmazonSecretsManagerConfig _config;
private readonly AmazonSecretsManagerClient _client;
public SecretManager(AWSCredentials creds)
{
_credentials = creds;
_config = new AmazonSecretsManagerConfig { RegionEndpoint = RegionEndpoint.USEast2 };