5506
Replicant
Free as in free software
android  privacy  security 
4 weeks ago
[no title]
# Recommended way of installing ESLint for projects
# Requires a minimal .eslintrc.* file for eslint to work
Local Installation and Usage

If you want to include ESLint as part of your project's build system, we recommend installing it locally. You can do so using npm:

$ npm install eslint --save-dev

You should then setup a configuration file:

$ ./node_modules/.bin/eslint --init

After that, you can run ESLint on any file or directory like this:

$ ./node_modules/.bin/eslint yourfile.js

Any plugins or shareable configs that you use must also be installed locally to work with a locally-installed ESLint.
eslint  vim  recommended  eslintrc 
january 2018
google/re2: RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
RE2 was designed and implemented with an explicit goal of being able to handle regular expressions from untrusted users without risk. One of its primary guarantees is that the match time is linear in the length of the input string. It was also written with production concerns in mind: the parser, the compiler and the execution engines limit their memory usage by working within a configurable budget – failing gracefully when exhausted – and they avoid stack overflow by eschewing recursion.

It is not a goal to be faster than all other engines under all circumstances. Although RE2 guarantees linear-time performance, the linear-time constant varies depending on the overhead entailed by safe handling of the regular expression. In a sense, RE2 behaves pessimistically whereas backtracking engines behave optimistically, so it can be outperformed in various situations.

It is also not a goal to implement all of the features offered by Perl, PCRE and other engines. As a matter of principle, RE2 does not support constructs for which only backtracking solutions are known to exist. Thus, backreferences and look-around assertions are not supported.

For more information, please refer to Russ Cox's articles on regular expression theory and praxis:

Regular Expression Matching Can Be Simple And Fast
https://swtch.com/~rsc/regexp/regexp1.html
Regular Expression Matching: the Virtual Machine Approach
https://swtch.com/~rsc/regexp/regexp2.html
Regular Expression Matching in the Wild
https://swtch.com/~rsc/regexp/regexp3.html
google  re2  regex  regexp  regular  expression  expressions 
january 2018
[no title]
Converting arbitrary Golang data types such as JSON, YAML, etc.

map[string]interface -> struct
map[interface]interface -> struct
golang  struct  map  interface  string  mapstructure  library 
january 2018
Go Mock Yourself
re-assigning stdlib functions to mock unit tests (monkey-patching)
interface  golang  unit  test  unit-testing  testing  unit-tests  unit-test  mock  mocking 
december 2017
Interface With Your Database in Go Tests
Workaround for making stubs in Databases etc. when testing.
interface  golang  unit  test  unit-testing  testing  unit-tests  unit-test  mock  mocking 
december 2017
fmt - The Go Programming Language
%v the value in a default format
when printing structs, the plus flag (%+v) adds field names
%#v a Go-syntax representation of the value
%T a Go-syntax representation of the type of the value
%% a literal percent sign; consumes no value

Boolean:

%t the word true or false

Integer:

%b base 2
%c the character represented by the corresponding Unicode code point
%d base 10
%o base 8
%q a single-quoted character literal safely escaped with Go syntax.
%x base 16, with lower-case letters for a-f
%X base 16, with upper-case letters for A-F
%U Unicode format: U+1234; same as "U+%04X"

Floating-point and complex constituents:

%b decimalless scientific notation with exponent a power of two,
in the manner of strconv.FormatFloat with the 'b' format,
e.g. -123456p-78
%e scientific notation, e.g. -1.234456e+78
%E scientific notation, e.g. -1.234456E+78
%f decimal point but no exponent, e.g. 123.456
%F synonym for %f
%g %e for large exponents, %f otherwise. Precision is discussed below.
%G %E for large exponents, %F otherwise

String and slice of bytes (treated equivalently with these verbs):

%s the uninterpreted bytes of the string or slice
%q a double-quoted string safely escaped with Go syntax
%x base 16, lower-case, two characters per byte
%X base 16, upper-case, two characters per byte

Pointer:

%p base 16 notation, with leading 0x

The default format for %v is:

bool: %t
int, int8 etc.: %d
uint, uint8 etc.: %d, %#x if printed with %#v
float32, complex64, etc: %g
string: %s
chan: %p
pointer: %p

For compound objects, the elements are printed using these rules, recursively, laid out like this:

struct: {field0 field1 ...}
array, slice: [elem0 elem1 ...]
maps: map[key1:value1 key2:value2]
pointer to above: &{}, &[], &map[]

Width is specified by an optional decimal number immediately preceding the verb. If absent, the width is whatever is necessary to represent the value. Precision is specified after the (optional) width by a period followed by a decimal number. If no period is present, a default precision is used. A period with no following number specifies a precision of zero. Examples:

%f default width, default precision
%9f width 9, default precision
%.2f default width, precision 2
%9.2f width 9, precision 2
%9.f width 9, precision 0

Width and precision are measured in units of Unicode code points, that is, runes. (This differs from C's printf where the units are always measured in bytes.) Either or both of the flags may be replaced with the character '*', causing their values to be obtained from the next operand, which must be of type int.

For most values, width is the minimum number of runes to output, padding the formatted form with spaces if necessary.

For strings, byte slices and byte arrays, however, precision limits the length of the input to be formatted (not the size of the output), truncating if necessary. Normally it is measured in runes, but for these types when formatted with the %x or %X format it is measured in bytes.

For floating-point values, width sets the minimum width of the field and precision sets the number of places after the decimal, if appropriate, except that for %g/%G precision sets the total number of significant digits. For example, given 12.345 the format %6.3f prints 12.345 while %.3g prints 12.3. The default precision for %e, %f and %#g is 6; for %g it is the smallest number of digits necessary to identify the value uniquely.

For complex numbers, the width and precision apply to the two components independently and the result is parenthesized, so %f applied to 1.2+3.4i produces (1.200000+3.400000i).

Other flags:

+ always print a sign for numeric values;
guarantee ASCII-only output for %q (%+q)
- pad with spaces on the right rather than the left (left-justify the field)
# alternate format: add leading 0 for octal (%#o), 0x for hex (%#x);
0X for hex (%#X); suppress 0x for %p (%#p);
for %q, print a raw (backquoted) string if strconv.CanBackquote
returns true;
always print a decimal point for %e, %E, %f, %F, %g and %G;
do not remove trailing zeros for %g and %G;
write e.g. U+0078 'x' if the character is printable for %U (%#U).
' ' (space) leave a space for elided sign in numbers (% d);
put spaces between bytes printing strings or slices in hex (% x, % X)
0 pad with leading zeros rather than spaces;
for numbers, this moves the padding after the sign
golang  fmt  printf  format  formatstring  formats 
december 2017
syntax - The Go Programming Language
Single characters:

. any character, possibly including newline (flag s=true)
[xyz] character class
[^xyz] negated character class
\d Perl character class
\D negated Perl character class
[[:alpha:]] ASCII character class
[[:^alpha:]] negated ASCII character class
\pN Unicode character class (one-letter name)
\p{Greek} Unicode character class
\PN negated Unicode character class (one-letter name)
\P{Greek} negated Unicode character class
Composites:

xy x followed by y
x|y x or y (prefer x)
Repetitions:

x* zero or more x, prefer more
x+ one or more x, prefer more
x? zero or one x, prefer one
x{n,m} n or n+1 or ... or m x, prefer more
x{n,} n or more x, prefer more
x{n} exactly n x
x*? zero or more x, prefer fewer
x+? one or more x, prefer fewer
x?? zero or one x, prefer zero
x{n,m}? n or n+1 or ... or m x, prefer fewer
x{n,}? n or more x, prefer fewer
x{n}? exactly n x
Implementation restriction: The counting forms x{n,m}, x{n,}, and x{n} reject forms that create a minimum or maximum repetition count above 1000. Unlimited repetitions are not subject to this restriction.

Grouping:

(re) numbered capturing group (submatch)
(?P<name>re) named & numbered capturing group (submatch)
(?:re) non-capturing group
(?flags) set flags within current group; non-capturing
(?flags:re) set flags during re; non-capturing

Flag syntax is xyz (set) or -xyz (clear) or xy-z (set xy, clear z). The flags are:

i case-insensitive (default false)
m multi-line mode: ^ and $ match begin/end line in addition to begin/end text (default false)
s let . match \n (default false)
U ungreedy: swap meaning of x* and x*?, x+ and x+?, etc (default false)
Empty strings:

^ at beginning of text or line (flag m=true)
$ at end of text (like \z not Perl's \Z) or line (flag m=true)
\A at beginning of text
\b at ASCII word boundary (\w on one side and \W, \A, or \z on the other)
\B not at ASCII word boundary
\z at end of text
Escape sequences:

\a bell (== \007)
\f form feed (== \014)
\t horizontal tab (== \011)
\n newline (== \012)
\r carriage return (== \015)
\v vertical tab character (== \013)
\* literal *, for any punctuation character *
\123 octal character code (up to three digits)
\x7F hex character code (exactly two digits)
\x{10FFFF} hex character code
\Q...\E literal text ... even if ... has punctuation
Character class elements:

x single character
A-Z character range (inclusive)
\d Perl character class
[:foo:] ASCII character class foo
\p{Foo} Unicode character class Foo
\pF Unicode character class F (one-letter name)
Named character classes as character class elements:

[\d] digits (== \d)
[^\d] not digits (== \D)
[\D] not digits (== \D)
[^\D] not not digits (== \d)
[[:name:]] named ASCII class inside character class (== [:name:])
[^[:name:]] named ASCII class inside negated character class (== [:^name:])
[\p{Name}] named Unicode property inside character class (== \p{Name})
[^\p{Name}] named Unicode property inside negated character class (== \P{Name})
Perl character classes (all ASCII-only):

\d digits (== [0-9])
\D not digits (== [^0-9])
\s whitespace (== [\t\n\f\r ])
\S not whitespace (== [^\t\n\f\r ])
\w word characters (== [0-9A-Za-z_])
\W not word characters (== [^0-9A-Za-z_])
ASCII character classes:

[[:alnum:]] alphanumeric (== [0-9A-Za-z])
[[:alpha:]] alphabetic (== [A-Za-z])
[[:ascii:]] ASCII (== [\x00-\x7F])
[[:blank:]] blank (== [\t ])
[[:cntrl:]] control (== [\x00-\x1F\x7F])
[[:digit:]] digits (== [0-9])
[[:graph:]] graphical (== [!-~] == [A-Za-z0-9!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])
[[:lower:]] lower case (== [a-z])
[[:print:]] printable (== [ -~] == [ [:graph:]])
[[:punct:]] punctuation (== [!-/:-@[-`{-~])
[[:space:]] whitespace (== [\t\n\v\f\r ])
[[:upper:]] upper case (== [A-Z])
[[:word:]] word characters (== [0-9A-Za-z_])
[[:xdigit:]] hex digit (== [0-9A-Fa-f])
golang  regex  regexp  syntax  character  char  classes  class 
december 2017
Configuration file — Ansible Documentation
# specify a custom directory for ansible roles
roles_path = /etc/ansible/roles:~/src/ansible
# ^ has to include default directory to get roles from galaxy
configuration  management  ansible  roles_path  role  roles 
december 2017
string - Replace all variables in Sprintf with same variable - Stack Overflow
It's possible, but the format string must be modified, you must use explicit argument indicies:

Explicit argument indexes:

In Printf, Sprintf, and Fprintf, the default behavior is for each formatting verb to format successive arguments passed in the call. However, the notation [n] immediately before the verb indicates that the nth one-indexed argument is to be formatted instead. The same notation before a '*' for a width or precision selects the argument index holding the value. After processing a bracketed expression [n], subsequent verbs will use arguments n+1, n+2, etc. unless otherwise directed.
Your example:

val := "foo"
s := fmt.Sprintf("%[1]v in %[1]v is %[1]v", val)
fmt.Println(s)
Output (try it on the Go Playground):

foo in foo is foo
Of course the above example can simply be written in one line:

fmt.Printf("%[1]v in %[1]v is %[1]v", "foo")
Also as a minor simplification, the first explicit argument index may be omitted as it defaults to 1:

fmt.Printf("%v in %[1]v is %[1]v", "foo")
golang  sprintf  fmt  var  variable  single  same 
december 2017
run everything but test files in golang with zsh
go run *.go~*_test.go
# ^ every .go file without _test.go files
zsh  go  run  glob  globbing  test  golang  from notes
december 2017
julienschmidt/httprouter: A high performance HTTP request router that scales well
fastest golang router with variables and .GET/.POST methods

!!! DOES NOT SUPPORT REGEX URIs
httprouter  golang 
december 2017
go - How to check for an empty struct? - Stack Overflow
if (Session{}) == session {
fmt.Println("is zero value")
}
empty  struct  golang  check 
december 2017
Users of /r/linux, What simple changes to your Linux system have lead to you having a much better experience as a user? : linux
alt+backspace/d (delete to the start/end of the word)
ctrl+a/e (go to the start/end of the line)
alt+left/right (go to next/previous word)
ctrl+u/k (delete to the start/end of the line)
alt+. (paste last argument from previous command, can be used repeatedly)
shell  bash  shortcut  shortcuts  keyboard  zsh  zshell 
december 2017
[no title]
gpg --list-keys

# create a new 2048 is fine
gpg --gen-key

# By default GnuPG uses the same subkey for signing (e.g. signing an email message) and certifying (e.g. signing another key). It is useful to separate those purposes as one is way more important than the other.
gpg --edit-key <short_key_fingerprint>
# choose (4) RSA (sign only)
gpg> addkey

# export public key as ASCII
gpg --export -a

# export private key as ASCII # wait until you added extra signing key if you want it included
gpg -a --export-secret-keys

# export secret subkeys as ASCII
gpg -a --export-secret-subkeys

# show keys with long keyid (less collidable, safer)
gpg --keyid-format LONG -k 0x<FINGERPRINT>

# Before importing a key, verify the fingerprint
gpg --with-fingerprint <keyfile>

# you want your keys to expire this way you can set an expiry if you don't have one or you need to extend your current key
gpg --edit-key '<fingerprint>'

# generate revocation cert ASCII
gpg --gen-revoke '<fingerprint>'

# Now select the subkey for which you want to set an expiration date (e.g. the first one), or none to set the expiration on your primary key and then issue the ‘expire’ command:
gpg> key 1
gpg> expire

# Then set the date to a reasonable one, and save the key and exit (e.g. 2 years):
Key is valid for? (0) 2y
gpg> save

# Then you may send your key to the keyservers to publish this change:
gpg --send-key '<fingerprint>'

## Keep private key completely offline
# extract the primary key (copy-paste)
gpg -a --export-secret-key john.doe@example.com

# extract the subkeys (copy-paste), which we will reimport later
# the ! at the end is intentional and required
gpg -a --export-secret-subkeys <ENCRYPT_KEY_ID>!
gpg -a --export-secret-subkeys <SIGN_KEY_ID>!

# *delete* the secret keys from the keyring, so only subkeys are left
$ gpg --delete-secret-keys john.doe@example.com
Delete this key from the keyring? (y/N) y
This is a secret key! - really delete? (y/N) y

# verify everything is in order
$ gpg --list-secret-keys

# reimport the subkeys (they should be there still but if not)
$ gpg --import

## Usage

# Encrypting a message to a recipient and add yourself to be able to read the encrypted message
gpg -e -s -a -r person@email.com -r yourmail@lol.com

## Verify

# This will verify your key security (apt-get install hopenpgp-tools)
hkt export-pubkeys <KEY_ID> | hokey lint

https://riseup.net/en/security/message-security/openpgp/best-practices

# Verify passphrase is correct (exit status will be 0 in that case)
gpg -q --sign --local-user <KEY_ID> --output /dev/null --yes <DUMMY_FILE>
!gpg  gpg  from notes
november 2017
Understanding Go panic output – joe shaw
github.com/joeshaw/example.UpdateResponse(0xad3c60, 0xc420257300, 0xc4201f4200, 0x16, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
^ the last 0x0's are the empty return values from the function
golang  panic  SIGSEGV  SIGINFO  SEGV_MAPERR  program  counter  pc  addr  code  segmentation  fault  signal  segfault  stack  debug  debugging 
november 2017
brew/docs/Formula-Cookbook.md
Formula The package definition /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/foo.rb
Keg The installation prefix of a Formula /usr/local/Cellar/foo/0.1
opt prefix A symlink to the active version of a Keg /usr/local/opt/foo
Cellar All Kegs are installed here /usr/local/Cellar
Tap A Git repository of Formulae and/or commands /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Bottle Pre-built Keg used instead of building from source qt-4.8.4.mavericks.bottle.tar.gz
Cask An extension of homebrew to install macOS native apps /Applications/MacDown.app/Contents/SharedSupport/bin/macdown
Brew Bundle An extension of homebrew to describe dependencies brew 'myservice', restart_service: true

HOMEBREW_PREFIX /usr/local
prefix #{HOMEBREW_PREFIX}/Cellar/#{name}/#{version} /usr/local/Cellar/foo/0.1
opt_prefix #{HOMEBREW_PREFIX}/opt/#{name} /usr/local/opt/foo
bin #{prefix}/bin /usr/local/Cellar/foo/0.1/bin
doc #{prefix}/share/doc/foo /usr/local/Cellar/foo/0.1/share/doc/foo
include #{prefix}/include /usr/local/Cellar/foo/0.1/include
info #{prefix}/share/info /usr/local/Cellar/foo/0.1/share/info
lib #{prefix}/lib /usr/local/Cellar/foo/0.1/lib
libexec #{prefix}/libexec /usr/local/Cellar/foo/0.1/libexec
man #{prefix}/share/man /usr/local/Cellar/foo/0.1/share/man
man[1-8] #{prefix}/share/man/man[1-8] /usr/local/Cellar/foo/0.1/share/man/man[1-8]
sbin #{prefix}/sbin /usr/local/Cellar/foo/0.1/sbin
share #{prefix}/share /usr/local/Cellar/foo/0.1/share
pkgshare #{prefix}/share/foo /usr/local/Cellar/foo/0.1/share/foo
etc #{HOMEBREW_PREFIX}/etc /usr/local/etc
var #{HOMEBREW_PREFIX}/var /usr/local/var
buildpath A temporary directory somewhere on your system /private/tmp/[formula-name]-0q2b/[formula-name]
homebrew  brew  formula  variable  variables  keg  opt  cellar  tap  bottle  cask  bundle  prefix  opt_prefix  bin  doc  include  info  lib  libexec  man  sbin  share  pkgshare  etc  var  buildpath 
november 2017
« earlier      
!work 2 3 addon addons ajax android api app apple apps art asm asp asp.net assembly audio auto backup bash bil book books browser browsers bsd car cars cell chap2 chapter2 cheatsheet cisco class classes cloth clothing cmdline code coding color command commandline commands comparison compatible computer console control crack cracking csharp css danish data database debian debug debugging del.icio.us denmark design dev development django dnb documentary dotnet download dubstep ebook ebooks ecig editor edu education encryption entertainment exploit exploits extension extensions fashion file files firefox flash framework free freebsd fun funny game gamer gamers games gaming gfx git golang google graphics guide hack hacking harddisk harddrive hardware health howto html http image imported inspiration install internet ip iphone javascript jquery js kernel keyboard learning linux mac macintosh macosx malware microsoft mobile motor movie mozilla music mysql network networking newbie news object objects of oop open open-source opensource optimization optimize os osx party password performance photoshop php playstation playstation3 plugin privacy production program programming ps3 psychedelic python quora rave recipe reference regex reverse reverse-engineering script scripting search searching security serial server shell smartphone software sony sound source sql ssh studio supported sysadmin system terminal test timewaste tips tools tuning tutorial tv tweak unix usb video vim visual visualstudio warez web webdesign webdev webserver webshop windows wishlist youtube zsh

Copy this bookmark:



description:


tags: