Merge pull request #135 from terminalforlife/master

Allow in-file disabling of lenchk (#134)
pull/136/head
Igor Chubin 4 years ago committed by GitHub
commit 827f498778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,7 +8,8 @@ import (
// define a type for the response
type Hello struct{}
// let that type implement the ServeHTTP method (defined in interface http.Handler)
// let that type implement the ServeHTTP method (defined in interface
// http.Handler)
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello!")
}

@ -35,7 +35,8 @@ abstract class D { ... }
class C extends D { ... }
class D(var x: R)
// inheritance and constructor params. (wishlist: automatically pass-up params by default)
// inheritance and constructor params. (wishlist: automatically pass-up params
// by default)
class C(x: R) extends D(x)
// define a singleton. (module-like)
@ -44,8 +45,10 @@ object O extends D { ... }
// traits.
trait T { ... }
// interfaces-with-implementation. no constructor params
// mixin-able: http://docs.scala-lang.org/tutorials/tour/mixin-class-composition.html
// interfaces-with-implementation. no constructor params. mixin-able:
//
// http://docs.scala-lang.org/tutorials/tour/mixin-class-composition.html
//
class C extends T { ... }
class C extends D with T { ... }

@ -3,39 +3,40 @@
(xs zip ys) map( (x,y) => x*y ) // BAD
// "v42" is interpreted as a name matching any Int value, and "42" is printed.
// BAD
// This is bad.
val v42 = 42
Some(3) match {
case Some(v42) => println("42")
case _ => println("Not 42")
}
// "`v42`" with backticks is interpreted as the existing val v42, and “Not 42” is printed.
// GOOD
// "`v42`" with backticks is interpreted as the existing val v42, and “Not 42”
// is printed. This is good.
val v42 = 42
Some(3) match {
case Some(`v42`) => println("42")
case _ => println("Not 42")
}
// UppercaseVal is treated as an existing val, rather than a new pattern variable, because it starts with an uppercase letter.
// Thus, the value contained within UppercaseVal is checked against 3, and “Not 42” is printed.
// GOOD
// UppercaseVal is treated as an existing val, rather than a new pattern
// variable, because it starts with an uppercase letter. Thus, the value
// contained within UppercaseVal is checked against 3, and “Not 42” is printed.
// This is good.
val UppercaseVal = 42
Some(3) match {
case Some(UppercaseVal) => println("42")
case _ => println("Not 42")
}
// Creating an alias for a match
// This will maintain the original value passed into the match function, using the '@' symbol, and print "Matched Some(3)"
// Creating an alias for a match. This will maintain the original value passed
// into the match function, using the '@' symbol, and print "Matched Some(3)"
Some(3) match {
case foundSome @ Some(_) => println("Matched " + foundSome)
case _ => println("Matched nothing")
}
// Case Classes
// This method allows you to match on any combination of properties of a case class
// Case Classes. This method allows you to match on any combination of
// properties of a case class
case class Example(a: Int, b: String, c: Boolean)
Example(1, "word", true) match {
case Example(3, _, _) => println("Matches any Example where a = 3")

@ -9,18 +9,18 @@
// * Optional a variable that can hold either a value or no value.
// * Tuples
//
// | -------|-------------------|-----------------------------------------------|
// | Type | Typical Bit Width| Typical Range |
// | -------|-------------------|-----------------------------------------------|
// | Int8 | 1byte | -127 to 127 |
// | UInt8 | 1byte | 0 to 255 |
// | Int32 | 4bytes | -2147483648 to 2147483647 |
// | UInt32 | 4bytes | 0 to 4294967295 |
// | Int64 | 8bytes | -9223372036854775808 to 9223372036854775807 |
// | UInt64 | 8bytes | 0 to 18446744073709551615 |
// | Float | 4bytes | 1.2E-38 to 3.4E+38 (~6 digits) |
// | Double | 8bytes | 2.3E-308 to 1.7E+308 (~15 digits) |
// | -------|-------------------|-----------------------------------------------|
// +--------+-------------------+--------------------------------------------+
// | Type | Typical Bit Width | Typical Range |
// | -------|-------------------|--------------------------------------------+
// | Int8 | 1byte | -127 to 127 |
// | UInt8 | 1byte | 0 to 255 |
// | Int32 | 4bytes | -2147483648 to 2147483647 |
// | UInt32 | 4bytes | 0 to 4294967295 |
// | Int64 | 8bytes | -9223372036854775808 to 9223372036854775807|
// | UInt64 | 8bytes | 0 to 18446744073709551615 |
// | Float | 4bytes | 1.2E-38 to 3.4E+38 (~6 digits) |
// | Double | 8bytes | 2.3E-308 to 1.7E+308 (~15 digits) |
// +--------+-------------------+--------------------------------------------+
// Type Aliases:
//

@ -1,6 +1,6 @@
# Recursion
# Def: "...is a method where the solution to a problem depends on solutions to smaller instance of the same problem.." - wiki
# TL;DR: a function that calls itself inside its body.
# Method for when the solution to a problem depends on solutions to smaller
# instance of the same problem; a self-calling function.
# Recursive programs - Pseduocode
function factorial:

@ -1,35 +1,37 @@
# doas
# Execute commands as another user
#
# OpenBSD lightweight sudo alternative, "dedicated openbsd application subexecutor"
# It was created by Ted Unangst after he was dissatisfied with the complexity
# of sudo and had issues with the default sudo configuration
# OpenBSD's lightweight sudo alternative, "dedicated openbsd application
# subexecutor", was created by Ted Unangst after he was dissatisfied with the
# complexity of sudo(8) and had issues with its default configuration.
# Remove the folder of "/home/user" as user
# If the -u option is not specified, the command will be executed as root
doas -u user ls /home/user
# Execute COMMAND as USER. If the -u option is not specified, `doas` will by
# default operate as the 'root' user.
doas -u USER COMMAND
# Show the contents of "/etc/shadow" as root
# Show the contents of '/etc/shadow' as root
doas cat /etc/shadow
# Execute the shell defined in $SHELL as root
# Execute the shell defined in `$SHELL` as root
doas -s
# Permission to execute commands as another user are given in the config file "/etc/doas.conf"
# The following line grants permission for every user in the wheel group to execute commands as root
# Permission to execute commands as another user are given in the config file
# '/etc/doas.conf'. The following line grants permission for every user in the
# 'wheel' group to execute commands as the 'root' user:
#
# permit persist keepenv :wheel
# permit persist keepenv :wheel
#
# Where the option "persist" makes doas only ask for the password once in each shell session
# Where the colon specifies that "wheel" is a group, not a user
# And where the option "keepenv" keeps the current environment variables
# The option 'persist' makes doas only ask for the password once in each
# shell session. The use of the colon (':') specifies that "wheel" is a
# group, not a user. The option 'keepenv' keeps the current environment
# variables.
#
# The following line rejects permission for "user" to run commands as anon,
# if the user is not specified, it will default to root
# The following line rejects permission for 'user' to run commands as 'anon', -
# if the user is not specified, it will default to the 'root' user.
#
# deny user as anon
# deny user as anon
#
# The following line allows "user" to execute only the program "shutdown" as root,
# without asking for a password
# The following line allows "user" to execute only the program "shutdown" as
# root, without asking for a password.
#
# permit nopass user cmd shutdown
# permit nopass user cmd shutdown

@ -1,34 +1,33 @@
# launchctl
# launchctl
# A command-line interface to Apple's launchd manager
# for launch daemons (system-wide services) and launch agents (per-user programs).
# launchd loads XML-based *.plist files placed in the appropriate locations,
# and runs the corresponding commands according to their defined schedule.
#
# for launch daemons (system-wide services) and launch agents (per-user
# programs). launchd loads XML-based *.plist files placed in the appropriate
# locations, and runs the corresponding commands according to their defined
# schedule.
# Activate a user-specific agent to be loaded into launchd
# whenever the user logs in:
# Activate user-specific agent to load into launchd whenever the user logs in.
launchctl load ~/Library/LaunchAgents/my_script.plist
# Activate an agent which requires root privileges to run
# and/or should be loaded whenever any user logs in (note the absence of ~ in the path):
# Activate an agent which requires root privileges to run and/or should be
# loaded whenever any user logs in (note the absence of ~ in the path).
sudo launchctl load /Library/LaunchAgents/root_script.plist
# Activate a system-wide daemon to be loaded
# whenever the system boots up (even if no user logs in):
# Activate a system-wide daemon to be loaded whenever the system boots up, -
# even if no user logs in.
sudo launchctl load /Library/LaunchDaemons/system_daemon.plist
# Show all loaded agents/daemons, with the PID if the process they specify is currently running,
# and the exit code returned the last time they ran:
# Show all loaded agents/daemons, with the PID if the process they specify is
# currently running, and the exit code returned the last time they ran.
launchctl list
# Unload a currently loaded agent, e.g. to make changes
# (note: the plist file is automatically loaded into launchd after a reboot and/or logging in):
# Unload a currently-loaded agent to, for example, make changes. The plist file
# is automatically loaded into launchd after a reboot and/or logging in.
launchctl unload ~/Library/LaunchAgents/my_script.plist
# Manually run a known (loaded) agent/daemon, even if it isnt the right time
# (note: this command uses the agent's label, rather than the filename):
# This command uses the agent's label, rather than the filename.
launchctl start my_script
# Manually kill the process associated with a known agent/daemon, if it's running:
# Manually kill the process associated with a known agent/daemon, if running.
launchctl stop my_script

@ -1,45 +1,104 @@
# SysVinit to Systemd Cheatsheet
# Services
#-------------------------------------------------------------------------------------------------------------------------------------------------
# Sysvinit Command Systemd Command Notes
#-------------------------------------------------------------------------------------------------------------------------------------------------
# service frobozz start systemctl start frobozz Used to start a service (not reboot persistent)
# service frobozz stop systemctl stop frobozz Used to stop a service (not reboot persistent)
# service frobozz restart systemctl restart frobozz Used to stop and then start a service
# service frobozz reload systemctl reload frobozz When supported, reloads the config file without interrupting pending operations.
# service frobozz condrestart systemctl condrestart frobozz Restarts if the service is already running.
# service frobozz status systemctl status frobozz Tells whether a service is currently running.
# ls /etc/rc.d/init.d/ systemctl Used to list the services that can be started or stopped
# (or) systemctl list-unit-files --type=service
# (or) ls /lib/systemd/system/*.service /etc/systemd/system/*.service
# chkconfig frobozz on systemctl enable frobozz Turn the service on, for start at next boot, or other trigger.
# chkconfig frobozz off systemctl disable frobozz Turn the service off for the next reboot, or any other trigger.
# chkconfig frobozz systemctl is-enabled frobozz Used to check whether a service is configured to start or not in the current environment.
# chkconfig --list systemctl list-unit-files --type=service
# (or) ls /etc/systemd/system/*.wants/
# Print a table of services that lists which runlevels each is configured on or off
# chkconfig --list | grep 5:on systemctl list-dependencies graphical.target
# Print a table of services that will be started when booting into graphical mode
# chkconfig frobozz --list ls /etc/systemd/system/*.wants/frobozz.service
# Used to list what levels this service is configured on or off
# chkconfig frobozz --add systemctl daemon-reload Used when you create a new service file or modify any configuration
# SysVinit to Systemd Cheatsheet
# Runlevels/targets
#--------------------------------------------------------------------------------------------------------------------------------------------------
# Sysvinit Runlevel Systemd Target Notes
#--------------------------------------------------------------------------------------------------------------------------------------------------
# 0 runlevel0.target Halt the system.
# poweroff.target
# 1, s, single runlevel1.target Single user mode.
# rescue.target
# 2, 4 runlevel2.target User-defined/Site-specific runlevels. By default, identical to 3.
# runlevel4.target
# multi-user.target
# 3 runlevel3.target Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.
# multi-user.target
# 5 runlevel5.target Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.
# graphical.target
# 6 runlevel6.target Reboot
# reboot.target
# emergency emergency.target Emergency shell
# Ways in which to control an available service.
#
# SysVinit:
service SERVICE [start/stop/restart/reload/condrestart/status]
# SystemD:
systemctl [start/stop/restart/reload/condrestart/status] SERVICE
# List services which can be started or stopped.
#
# SysVinit:
ls /etc/rc.d/init.d/
# SystemD Methods (one per line):
systemctl
systemctl list-unit-files --type=service
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
# Enable or disable a service from running; noticeable at next boot.
#
# SysVinit:
chkconfig SERVICE [on/off]
# SystemD:
systemctl [enable/disable] SERVICE
# Check whether a service is enabled or disabled; see above.
#
# SysVinit:
chkconfig SERVICE
# SystemD:
systemctl is-enabled SERVICE
# Print a table of services, listing for which runlevel each is configured.
#
# SysVinit:
chkconfig --list
# SystemD Methods (one per line):
systemctl list-unit-files --type=service
ls /etc/systemd/system/*.wants/
# Print a table of services which will be started when booting into the GUI.
#
# SysVinit:
chkconfig --list | grep 5:on
# SystemD:
systemctl list-dependencies graphical.target
# Used to list which levels a service is configured; on or off.
#
# SysVinit:
chkconfig SERVICE --list
# SystemD:
ls /etc/systemd/system/*.wants/SERVICE.service
# Used when you create a new service file or modify any configurations.
#
# SysVinit:
chkconfig SERVICE --add
# SystemD:
systemctl daemon-reload
# Runlevel/Target -- Half the system.
#
# SysVinit Runlevel: 0
# SystemD Target: runlevel0.target
# poweroff.target
#
# Single-user mode.
#
# SysVinit Runlevel: 1, s, single
# SystemD Target: runlevel1.target
# rescue.target
#
# User-defined/Site-specific runlevels. By default, identical to 3.
#
# SysVinit Runlevel: 2, 4
# SystemD Target: runlevel2.target
# runlevel2.target
# multi-user.target
#
# Multi-user. Non-graphical. Users can usually login via multiple consoles or
# via the network.
#
# SysVinit Runlevel: 3
# SystemD Target: runlevel3.target
# multi-user.target
#
# Multi-user. Graphical. Usually has all the services of runlevel 3 plus a
# graphical login.
#
# SysVinit Runlevel: 5
# SystemD Target: runlevel5.target
# graphical.target
#
# Reboot.
#
# SysVinit Runlevel: 6
# SystemD Target: runlevel6.target
# reboot.target
#
# Emergency shell.
#
# SysVinit Runlevel: emergency
# SystemD Target: emergency.target

@ -1,11 +1,11 @@
# taste (Bash-Snippets)
# A recommendation engine that provides 3 similar items based on some input topic.
# Recommendation engine providing 3 similar items based on some input topic.
# Get the names of three recommendations based on supplied item
# Get names of three recommendations based on supplied item.
taste Catcher in the Rye
# Get the names and information on three recommendations based on supplied item
# Get names of and information on three recommendations based on supplied item.
taste -i Kendrick Lamar
# Get information on the supplied item
# Get information on the supplied item.
taste -s Red Hot Chili Peppers

@ -1,17 +1,20 @@
# Unless configured otherwise, this will set the umask ("user mask" or "file mode
# creation mask") for only the current user, and only his or her current session.
# The (one) leading zero is optional, unless you otherwise need it.
# umask
# Display or set file mode mask
# Unless configured otherwise, this will set the umask ("user mask" or "file
# mode creation mask") for only the current user, and only his or her current
# session. The (one) leading zero is optional, unless you otherwise need it.
#
# This umask setting is actually recommended for security by RHEL, and is also
# mentioned and I believe recommended in the Arch Linux Wiki.
#
# The result of '0077' being -- and I'll use standard octal with which we're all
# probably familiar -- that all new files are created using the '600'
# The result of '0077' being -- and I'll use standard octal with which we're
# all probably familiar -- that all new files are created using the '600'
# permissions, and directories are '700'.
#
# Remember, the standard format means 4=read, 2=write, and 1=execute. However, the
# umask uses the same, but is inverted, so a umask of '077' would be 700, and
# correctly lowers to 600 when it's just a file.
# Remember, the standard format means 4=read, 2=write, and 1=execute.
# However, the umask uses the same, but is inverted, so a umask of '077' would
# be 700, and correctly lowers to 600 when it's just a file.
umask 0077
# Akin to above, but instead, output the current umask setting.

@ -1,5 +1,6 @@
# wacaw
# A little command-line tool for Mac OS X that allows you to capture both still pictures and video from an attached camera.
# Command-line tool for Mac OS X that allows you to capture both pictures and
# video from an attached camera.
# Take a picture from webcam:
wacaw filename

@ -5,7 +5,7 @@
xfs_repair /dev/dm-0
# last resort option:
# -L: Force Log Zeroing. zero the log even if it is dirty (contains metadata changes).
# When using this option the filesystem will likely appear to be corrupt,
# and can cause the loss of user files and/or data.
# -L: Force Log Zeroing. zero the log even if it is dirty (contains metadata
# changes). When using this option the filesystem will likely appear to be
# corrupt, and can cause the loss of user files and/or data.
xfs_repair -v -L /dev/dm-0

@ -1,7 +1,8 @@
# Shows information about the Xen host
xm info
# Shows information about doms (states include r for running, b for blocked, c for crashed, p for paused and the worse, d for dying).
# Shows information about doms (states include r for running, b for blocked, c
# for crashed, p for paused and the worse, d for dying).
xm list
# Shows virtual interfaces for doms
@ -44,7 +45,7 @@ xm shutdown
# but if the host is rebooted then state is lost (otherwise use suspend)
xm pause
# Suspends a VM, which writes the data to disk, so changes wouldn't be lost on restart.
# Suspends VM, which writes data to disk, so changes won't be lost on restart.
xm suspend
# Rename installed VMs
@ -79,4 +80,3 @@ xm vcpu-set
# Move a domain to another server (e.g. using the -l operator to do so live)
xm migrate

@ -14,12 +14,13 @@ Usage(){
Usage: $Progrm [OPTS] [DIR_1 [DIR_2 ...]]
-h, --help - Display this help information.
-C, --no-color - Provide color via esscape sequences.
-D, --no-subdirs - Ignore the 'sheets/_*' subdirectories.
-I, --no-lenchk-line - Ignore the special 'lenchk=.*' line.
-N, --no-preview - Omit the preview of each triggered line.
-P, --no-pager - Do not use less(1) or more(1) for paging.
-S, --no-summary - Omit the summary before $Progrm exits.
-W, --no-whilelist - Do not use the whitelist file.
-c, --colorize - Provide color via esscape sequences.
-l, --limit [INT] - Override the limit of 80 columns.
-w, --wl-file [FILE] - Use an alternative whitelist file.
@ -38,6 +39,9 @@ Usage(){
The location of the whitelisting file ('$Progrm-excludes') must
remain in the same directory in which $Progrm is stored, unless
otherwise specified.
Alternatively, a file can be whitelisted by ensuring the very first
line contains only 'lenchk=disable', akin to a vim(1) modeline.
EOF
}
@ -65,14 +69,16 @@ while [ "$1" ]; do
NoPager='True' ;;
--no-preview|-N)
NoPreview='True' ;;
--colorize|-c)
DoColor='True' ;;
--no-color|-C)
NoColor='True' ;;
--no-summary|-S)
NoSummary='True' ;;
--no-subdirs|-D)
NoSubDirs='True' ;;
--no-whitelist|-W)
NoWhiteList='True' ;;
-I|--no-lenchk-line)
NoLenChkLine='True' ;;
--wl-file|-w)
shift
@ -89,6 +95,10 @@ while [ "$1" ]; do
shift
done
# Thank you, Chubin. Feature apparently added in version 3.0 alpha, so should
# be OK, but if anyone is having issues, just `cd` to the 'tests' directory.
[ ${BASH_VERSINFO[0]:-0} -eq 3 ] || cd "${BASH_SOURCE[0]%/*}" &> /dev/null
# Confirm we are in the right place.
git rev-parse --is-inside-work-tree 1> /dev/null 2>&1 ||
Err 0 'Not inside a Git repository.'
@ -124,6 +134,16 @@ if [ "$NoWhiteList" != 'True' ] && [ -f "$WLFile" ]; then
done < "$WLFile"
fi
# Using tput(1) for portability.
if type -fP tput &> /dev/null; then
C_Ellipses=`tput dim; tput setaf 7`
C_LineNums=`tput bold; tput setaf 2`
C_FileNames=`tput bold; tput setaf 1`
C_Reset=`tput sgr0`
else
Err 1 'Unable to colorize output -- tput(1) not found.'
fi
Main(){
for File in "${Dirs[@]}"; {
[ -f "$File" ] || continue
@ -133,6 +153,12 @@ Main(){
[ "$File" == "$CurWL" ] && continue 2
}
# Per chubin's desire to have an "in-bound flag"; see #134 for info.
if [ "$NoLenChkLine" != 'True' ]; then
read Buffer < "$File"
[ "$Buffer" == 'lenchk=disable' ] && continue
fi
HaveBeenHit='False'
LineNum=0
@ -154,9 +180,9 @@ Main(){
[ "$NoPreview" == 'True' ] || printf '\n'
# The filename containing problematic line lengths.
[ "$DoColor" == 'True' ] && printf '\e[1;31m'
[ "$NoColor" == 'True' ] || printf "$C_FileNames"
printf '%s\n' "${File#../}"
[ "$DoColor" == 'True' ] && printf '\e[0m'
[ "$NoColor" == 'True' ] || printf "$C_Reset"
HaveBeenHit='True'
let Hits++
@ -164,9 +190,9 @@ Main(){
if ! [ "$NoPreview" == 'True' ]; then
# The line number of the problematic length.
[ "$DoColor" == 'True' ] && printf '\e[1;32m'
[ "$NoColor" == 'True' ] || printf "$C_LineNums"
printf ' %7d ' $LineNum # <-- allows for 9,999,999 lines.
[ "$DoColor" == 'True' ] && printf '\e[0m'
[ "$NoColor" == 'True' ] || printf "$C_Reset"
# Cannot make this 80 columns long, due to the indentation
# and padding, but if you need to test this, for the sake
@ -175,9 +201,9 @@ Main(){
printf '%s' "${REPLY:0:70}"
# Cut-off ellipses.
[ "$DoColor" == 'True' ] && printf '\e[2;1m'
[ "$NoColor" == 'True' ] || printf "$C_Ellipses"
printf '...\n'
[ "$DoColor" == 'True' ] && printf '\e[0m'
[ "$NoColor" == 'True' ] || printf "$C_Reset"
fi
fi
done < "$File"

Loading…
Cancel
Save