Skip to content

Instantly share code, notes, and snippets.

Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com

Collection Type Guidence

When to use what

  • Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
  • Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
  • Use a Generic List when know the type of the elements but not the size of the collection.
  • Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
  • Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
  • Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@disco0
disco0 / WSL.md
Created May 28, 2019 04:32 — forked from koca/WSL

WSL Ubuntu Terminal

WSL

Before installing any Linux distros for WSL, you must ensure that the "Windows Subsystem for Linux" optional feature is enabled:

  1. Open PowerShell as Administrator and run:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
@disco0
disco0 / gist:a47d376ea3ffe80b935c47e74c731978
Created June 1, 2019 06:18 — forked from liwh/gist:894109
reload functon for zsh completion
#when we create new function or install new bin , the default zsh cant get the new completion for us,so we
#can add a new function for this problem,you can add the blow content in your .zshrc file
function reload() {
if [[ "$#*" -eq 0 ]]; then
test -r /etc/zsh/zsh-oli && . /etc/zsh/zsh-oli
test -r ~/.zshrc && . ~/.zshrc
return 0
else
local fn
for fn in $*; do
@disco0
disco0 / waitForKeyElements.js
Created August 24, 2019 01:29 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@disco0
disco0 / VLCxcallbacker.py
Created September 28, 2019 01:21 — forked from dreness/VLCxcallbacker.py
VLCxcallbacker: generate and host a web page of vlc-x-callback links to every video file in a given directory (for #VLC clients on iOS)
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import os
import socket
from datetime import datetime
from urllib import parse
from klein import Klein
from twisted.web.static import File
from twisted.python.filepath import FilePath
@disco0
disco0 / macmodel.py
Created January 18, 2020 08:49 — forked from mattieb/macmodel.py
A slightly less quick-and-dirty way to look up a Mac's friendly model name.
#!/usr/bin/env python
#
# Looks up a Mac's friendly model name.
#
# Based on http://apple.stackexchange.com/a/98089/21050
#
from subprocess import check_output
from urllib import urlopen
import xml.etree.ElementTree as ET
@disco0
disco0 / stylus.md
Created April 19, 2020 10:55 — forked from tj/stylus.md

Stylus

A dynamic, expressive, powerful language compiling to CSS.

SLIDE:

whoami

tj holowaychuk

@disco0
disco0 / mpv.desktop
Created May 11, 2020 10:38 — forked from zoqaeski/mpv.desktop
MPV single instance controller
[Desktop Entry]
Type=Application
Name=mpv Media Player (Single-instance mode)
GenericName=Multimedia player
Comment=Play movies and songs without starting new instance of multimedia player
Icon=mpv
TryExec=mpvctl
Exec=mpvctl add -- %U
Terminal=false
Categories=AudioVideo;Audio;Video;Player;TV;
@disco0
disco0 / Log-.md
Created July 28, 2020 11:58 — forked from bgrins/Log-.md
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,