Skip to content

Instantly share code, notes, and snippets.

View mafrosis's full-sized avatar
🍳

Matt Black mafrosis

🍳
  • MACHIN SHIN
  • Melbourne, Australia
View GitHub Profile

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@mattmc3
mattmc3 / 1-setopts.zsh
Last active January 2, 2024 15:47
ZSH - options by framework
## ZSH Options
# http://zsh.sourceforge.net/Doc/Release/Options.html
# Changing Directories
# http://zsh.sourceforge.net/Doc/Release/Options.html#Changing-Directories
setopt auto_cd # if a command isn't valid, but is a directory, cd to that dir
setopt auto_pushd # make cd push the old directory onto the directory stack
setopt pushd_ignore_dups # don’t push multiple copies of the same directory onto the directory stack
setopt pushd_minus # exchanges the meanings of ‘+’ and ‘-’ when specifying a directory in the stack
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reinhrst
reinhrst / install_opencv3_python3_osx.sh
Last active September 21, 2016 03:25
Install opencv master (2015-04-02) on python 3 on OSX
brew install python3
pip3 install numpy
brew install cmake
git clone --depth=1 https://github.com/Itseez/opencv.git
cd opencv
mkdir build
cd build
# note: in the next line, adjust paths to point to the correct python version
cmake -DBUILD_opencv_python3=YES -DBUILD_opencv_python2=NO -DINSTALL_PYTHON_EXAMPLES=YES -DPYTHON3_EXECUTABLE=/usr/local/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/site-packages/numpy/core/include/ -DPYTHON3_PACKAGES_PATH=/usr/local/lib/python3.4/site-packages/ ..
make -j8
@kurokikaze
kurokikaze / gist:350fe1713591641b3b42
Created October 3, 2014 11:40
install chrome from powershell
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec
@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@drmalex07
drmalex07 / helloworld-win32-service.py
Created April 12, 2014 20:08
An example Windows service implemented with pywin32 wrappers. #python #windows-service #pywin32
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time
import logging
logging.basicConfig(
filename = 'c:\\Temp\\hello-service.log',
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@simonvc
simonvc / stats-to-hosted-graphite.py
Last active December 16, 2015 03:39
This little recipe will pump your riak stats into hosted graphite. For more information see hostedgraphite.com @simonvc
import json
from urllib2 import urlopen
import socket
from time import sleep
UDP_ADDRESS = "carbon.hostedgraphite.com"
UDP_PORT = 2003
RIAK_STATS_URL='http://localhost:11098/stats'
HG_API_KEY='Your Api Key from HostedGraphite.com'
@thelinuxkid
thelinuxkid / subprocess_stream.py
Last active December 4, 2023 06:43
Get a Python subprocess' output without buffering. Normally when you want to get the output of a subprocess in Python you have to wait until the process finishes. This is bad for long running processes. Here's a way to get the output unbuffered (in real-time.)
import contextlib
import subprocess
# Unix, Windows and old Macintosh end-of-line
newlines = ['\n', '\r\n', '\r']
def unbuffered(proc, stream='stdout'):
stream = getattr(proc, stream)
with contextlib.closing(stream):
while True:
out = []