Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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
# 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

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.
function new-PowershellWebGUI ($HTMLRaw,$Title,$Runspace) {
[xml]$xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="$Title" Height="500" Width="700">
<Grid>
<DockPanel>
<WebBrowser Name="WebBrowser" DockPanel.Dock="Top" Margin="30">
</WebBrowser>
Function Trace-Word
{
[Cmdletbinding()]
[Alias("Highlight")]
Param(
[Parameter(ValueFromPipeline=$true, Position=0)] [string[]] $content,
[Parameter(Position=1)]
[ValidateNotNull()]
[String[]] $words = $(throw "Provide word[s] to be highlighted!")