Compare commits

...

43 Commits

Author SHA1 Message Date
ff8ba4e717 Merge pull request #209 from chrisallenlane/edit-after-copy
Resolves #207
2015-02-10 19:37:05 -05:00
718ec4f685 Resolves #207
- Solves issue whereby global cheatsheets fail to save after editing

- `cheat` no longer asks a user if a global cheatsheet should be copied
  locally before editing, and instead just silently does so.
2015-02-10 19:35:14 -05:00
3d8343a878 Version bump 2015-02-09 18:10:08 -05:00
a5352ad9e5 Trivial edits to uniq cheatsheet 2015-02-09 18:07:17 -05:00
f5ee3d5e29 Merge branch 'master' of https://github.com/shigemk2/cheat into shigemk2-master
* 'master' of https://github.com/shigemk2/cheat:
  Refer sort -u
  Fix dc option
  uniq: add examples
2015-02-09 18:06:20 -05:00
e64babc972 Trivial edits to cheatsheets. 2015-02-09 18:05:13 -05:00
cd465ef84f Merge branch 'master' of https://github.com/Aayush-Kasurde/cheat into Aayush-Kasurde-master
* 'master' of https://github.com/Aayush-Kasurde/cheat:
  Added perforce commands
  Added udisksctl
  Added Journalctl commands
  Added zoneadm commands
2015-02-09 18:03:28 -05:00
96e26a38d4 Added newline to end of dnf file. 2015-02-09 18:01:40 -05:00
998ed00424 Merge branch 'dnf' of https://github.com/amitsaha/cheat into amitsaha-dnf
* 'dnf' of https://github.com/amitsaha/cheat:
  Add cheatsheet for dnf
2015-02-09 18:00:38 -05:00
1fd03d3305 Merge pull request #205 from thylong/dpkg
Add cheat for dpkg
2015-02-09 17:58:24 -05:00
77cba58599 Merge pull request #203 from amitsaha/docker_update
docker: add 'docker exec'
2015-02-09 17:57:39 -05:00
c5a738a8b1 Merge pull request #199 from Mic92/patch-8
ip: better route example
2015-02-09 17:56:57 -05:00
250a265b25 Added perforce commands 2015-01-27 22:07:43 +05:30
c232721119 Add cheatsheet for dnf 2015-01-22 16:30:49 +10:00
55492c50ac Added udisksctl 2015-01-20 21:34:11 +05:30
d9df28e3f2 Update dpkg 2015-01-20 12:22:47 +01:00
710c7bcf70 Add cheat for dpkg 2015-01-20 01:42:26 +01:00
efba736aee Added Journalctl commands 2015-01-18 20:03:42 +05:30
95774db7c5 Added zoneadm commands 2015-01-14 21:12:23 +05:30
da63c5d27f docker: add 'docker exec' 2015-01-13 13:51:35 +10:00
2e1cda114a Refer sort -u 2015-01-12 21:29:35 +09:00
353fe48d60 Fix dc option 2015-01-12 21:17:55 +09:00
a96bd229a6 uniq: add examples 2015-01-10 00:28:18 +09:00
be2cb6e632 Version 2.1.3
- Added new cheatsheets
- Appended to `.gitignore`
2015-01-05 20:44:25 -05:00
426b0aaa0d Merge pull request #197 from thylong/gzip
Add cheat for gzip
2015-01-05 20:39:35 -05:00
9041c57d21 Merge pull request #200 from poliveira89/new_cheatsheets
New cheatsheets
2015-01-05 20:38:19 -05:00
1dd9d85509 Merge branch 'gzip' of github.com:thylong/cheat into gzip
Conflicts:
	cheat/cheatsheets/gzip
2015-01-04 13:24:52 +01:00
9506167af8 Add cheat for gzip 2015-01-04 13:23:47 +01:00
27482cbabd ip: better route example
Assigning a subnet is already covered in the example below. Setting a default route via a router is the most common use case of ip route IMHO.
2014-12-30 10:07:13 +01:00
03bb651bf0 Version bump 2014-12-29 21:45:46 -05:00
c4a5ca3900 Merge pull request #198 from thylong/ssh_forward
Update cheat ssh
2014-12-29 21:37:39 -05:00
03b587f538 Merge pull request #196 from Mic92/patch-7
ss
2014-12-29 21:36:59 -05:00
e4d7722476 Merge pull request #195 from Mic92/master
ping6
2014-12-29 21:36:18 -05:00
3807aa5433 Merge pull request #194 from Mic92/patch-6
smbclient
2014-12-29 21:35:40 -05:00
956ce7fadd Update cheat ssh 2014-12-26 15:57:01 -05:00
57876ed0e7 Add cheat for gzip 2014-12-26 15:46:48 -05:00
58abb16ca1 ss 2014-12-24 21:42:16 +01:00
54e30022f0 ping6: fix typo 2014-12-24 18:08:56 +01:00
c412cd0534 ping6 2014-12-24 12:15:03 +01:00
2d67038188 smbclient 2014-12-24 12:13:29 +01:00
603bc360c0 Version bump 2014-12-09 20:58:15 -05:00
61458933eb SSH cheatsheet updated: support for SSH tunnels between local host and remote host 2014-11-22 17:15:51 +00:00
6f579f9234 New cheatsheet added: support for Bower (frontend package manager) 2014-11-22 17:09:58 +00:00
20 changed files with 182 additions and 31 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
*.pyc
MANIFEST
build
cheat.egg-info
dist

View File

@ -38,7 +38,7 @@ from docopt import docopt
if __name__ == '__main__':
# parse the command-line options
options = docopt(__doc__, version='cheat 2.1.0')
options = docopt(__doc__, version='cheat 2.1.5')
# list directories
if options['--directories']:

26
cheat/cheatsheets/bower Normal file
View File

@ -0,0 +1,26 @@
# Install a package locally
bower install <package-name>
# Install a package locally directly from github
bower install <user>/<repo>
# Install a specific package locally
bower install <package-name>#<version>
# Install a package locally and save installed package into bower.json
bower install <package-name> --save
# Retrieve info of a particular package
bower info <package-name>
# List local packages
bower list
# Search for a package by name
bower search <package-name>
# Update a package to their newest version
bower update <package-name>
# Remove a local package
bower uninstall <package-name>

16
cheat/cheatsheets/dnf Normal file
View File

@ -0,0 +1,16 @@
# To install the latest version of a package:
dnf install <package name>
# To search package details for the given string
dnf search <string>
# To find which package provides a binary
dnf provides <path to binary>
# The following are available after installing "dnf-plugins-core"
# Download a package
dnf download <package name>
# install the build dependencies for a SRPM or from a .spec file
dnf builddep <srpm/.spec file>

View File

@ -4,6 +4,9 @@ docker -d
# start a container with an interactive shell
docker run -ti <image_name> /bin/bash
# "shell" into a running container (docker-1.3+)
docker exec -ti <container_name> bash
# inspect a running container
docker inspect <container_name> (or <container_id>)

11
cheat/cheatsheets/dpkg Normal file
View File

@ -0,0 +1,11 @@
# Install the package or upgrade it
dpkg -i test.deb
# Remove a package including configuration files
dpkg -P test.deb
# List all installed packages with versions and details
dpkg -I
# Find out if a Debian package is installed or not
dpkg -s test.deb | grep Status

17
cheat/cheatsheets/gzip Normal file
View File

@ -0,0 +1,17 @@
# To create a *.gz compressed file
gzip test.txt
# To create a *.gz compressed file to a specific location using -c option (standard out)
gzip -c test.txt > test_custom.txt.gz
# To uncompress a *.gz file
gzip -d test.txt.gz
# Display compression ratio of the compressed file using gzip -l
gzip -l *.gz
# Recursively compress all the files under a specified directory
gzip -r documents_directory
# To create a *.gz compressed file and keep the original
gzip < test.txt > test.txt.gz

View File

@ -19,8 +19,8 @@ ip route
# Display all routes for IPv6
ip -6 route
# Add route via gateway IP
ip route add 192.168.0.0/24 via 192.168.1.1
# Add default route via gateway IP
ip route add default via 192.168.1.1
# Add route via interface
ip route add 192.168.0.0/24 dev eth0

View File

@ -19,3 +19,14 @@ journalctl /usr/bin/dbus-daemon
# Filter by PID
journalctl _PID=123
# Filter by Command, e.g., sshd
journalctl _COMM=sshd
# Filter by Command and time period
journalctl _COMM=crond --since '10:00' --until '11:00'
# List all available boots
journalctl --list-boots
# Filter by specific User ID e.g., user id 1000
journalctl _UID=1000

5
cheat/cheatsheets/p4 Normal file
View File

@ -0,0 +1,5 @@
# Print details related to Client and server configuration
p4 info
# Open a file and add it to depot
p4 add <filename>

2
cheat/cheatsheets/ping6 Normal file
View File

@ -0,0 +1,2 @@
# get all ipv6 neighbors via broadcast ping
ping6 -I eth0 ff02::1

View File

@ -0,0 +1,5 @@
# To display public shares on the server:
smbclient -L <hostname> -U%
# To connect to a share:
smbclient //<hostname>/<share> -U<username>%<password>

18
cheat/cheatsheets/ss Normal file
View File

@ -0,0 +1,18 @@
ss
Utility to investigate sockets
Args
-4/-6 list ipv4/ipv6 sockets
-n numeric addresses instead of hostnames
-l list listing sockets
-u/-t/-x list udp/tcp/unix sockets
-p Show process(es) that using socket
# show all listing tcp sockets including the corresponding process
ss -tlp
# show all sockets connecting to 192.168.2.1 on port 80
ss -t dst 192.168.2.1:80
# show all ssh related connection
ss -t state established '( dport = :ssh or sport = :ssh )'

View File

@ -4,12 +4,19 @@ ssh -i /path/to/file.pem user@example.com
# To connect on an non-standard port:
ssh -p 2222 user@example.com
# To connect and forward the authentication agent
ssh -A user@example.com
# To execute a command on a remote server:
ssh -t user@example.com 'the-remote-command'
# To tunnel an x session over SSH:
ssh -X user@example.com
# Redirect traffic with a tunnel between local host (port 8080) and a remote
# host (remote.example.com:5000) through a proxy (personal.server.com):
ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N
# To launch a specific x application over SSH:
ssh -X -t user@example.com 'chromium-browser'

View File

@ -0,0 +1,11 @@
# Get info about block device
udisksctl info -b <block_device>
# Mounting device
udisksctl mount --block-device <block_device>
# Unmounting device
udisksctl unmount --block-device <block_device>
# Get help
udisksctl help

18
cheat/cheatsheets/uniq Normal file
View File

@ -0,0 +1,18 @@
# show all lines without duplication
# `sort -u` and `uniq` is the same effect.
sort file | uniq
# show not duplicated lines
sort file | uniq -u
# show duplicated lines only
sort file | uniq -d
# count all lines
sort file | uniq -c
# count not duplicated lines
sort file | uniq -uc
# count only duplicated lines
sort file | uniq -dc

21
cheat/cheatsheets/zoneadm Normal file
View File

@ -0,0 +1,21 @@
# Halt zone
zoneadm -z <zone_name> halt
# Delete Zone
zoneadm -z <zone_name> halt
zoneadm -z <zone_name> uninstall
# Verify Zone
zoneadm -z <zone_name> verify
# Installing Zone
zoneadm -z <zone_name> install
# Boot Zone
zoneadm -z <zone_name> boot
# Reboot Zone
zoneadm -z <zone_name> reboot
# List Zones
zoneadm list -cv

View File

@ -32,21 +32,9 @@ def create_or_edit(sheet):
# if the cheatsheet exists but is not writable...
elif exists(sheet) and not is_writable(sheet):
# ... ask the user if we should copy the cheatsheet to her home directory for editing
yes = prompt_yes_or_no(
'The ' + sheet + ' sheet is not editable. Do you want to copy it to '
'your user cheatsheets directory before editing? Keep in mind that '
'your sheet will always be used before system-wide one.'
)
# if yes, copy the cheatsheet to the home directory before editing
if yes:
copy(path(sheet), os.path.join(sheets.default_path(), sheet))
edit(sheet)
# if no, just abort
else:
die('Aborting.')
# copy the cheatsheet to the home directory before editing
copy(path(sheet), os.path.join(sheets.default_path(), sheet))
edit(sheet)
def create(sheet):

View File

@ -2,13 +2,6 @@ from cheat import cheatsheets
from cheat.utils import *
import os
# @kludge: it breaks the functional paradigm to a degree, but declaring this
# var here (versus within get()) gives us a "poor man's" memoization on the
# call to get(). This, in turn, spares us from having to call out to the
# filesystem more than once.
cheats = {}
def default_path():
""" Returns the default cheatsheet path """
@ -37,11 +30,7 @@ def default_path():
def get():
""" Assembles a dictionary of cheatsheets as name => file-path """
# if we've already reached out to the filesystem, just return the result
# from memory
if cheats:
return cheats
cheats = {}
# otherwise, scan the filesystem
for cheat_dir in reversed(paths()):

View File

@ -3,7 +3,7 @@ import os
setup(
name = 'cheat',
version = '2.1.0',
version = '2.1.5',
author = 'Chris Lane',
author_email = 'chris@chris-allen-lane.com',
license = 'GPL3',