App-Cheats

 view release on metacpan or  search on metacpan

cheats.txt  view on Meta::CPAN

# Go here
https://search.maven.org/
#
# Search and download these:
org.gebish:geb-core
org.seleniumhq.selenium:selenium-chrome-driver
org.seleniumhq.selenium:selenium-support
#

# Setup Geb (from repo,starting out)
cd D:\my\setup\geb\sample
git clone https://github.com/geb/geb-example-gradle
cd geb-example-gradle
gradlew chromeTest
#
# Install pip
D:\my\setup\pip\get-pip.py
#
# Install selenium
pip install selenium

# Using Python and Selenium (Geb)
#
cd D:\my\setup\geb\chromedriver_win32
ls
	chromedriver.exe
	sample.py
#
cat sample
	import time
	from selenium import webdriver
	driver = webdriver.Chrome(r'D:\my\setup\geb\chromedriver_win32\chromedriver.exe')  # Optional argument, if not specified will search path.
	driver.get('http://www.google.com/');
	time.sleep(5) # Let the user actually see something!
	search_box = driver.find_element_by_name('q')
	search_box.send_keys('ChromeDriver')
	search_box.submit()
	time.sleep(5) # Let the user actually see something!
	driver.quit()

# Cannot click on a element when Geb Testing:
# Use this approach:

cheats.txt  view on Meta::CPAN

JAVA_BIN			C:\Program Files\Java\jdk-14.0.1\bin
JAVA_LIB			C:\Program Files\Java\jdk-14.0.1\lib
#
# Install Gradle (Optional)
https://docs.gradle.org/current/userguide/installation.html
#
# Unzip and copy gradle-6.5 to:
cd C:\Gradle
#
# Setup Environment:
PATH_UNIX		 +=	C:\Gradle\gradle-6.5
GRADLE_HOME			C:\Gradle\gradle-6.5
#
# Check that its setup:
gradle -v
#
# Sample build.gradle
task hello {
	doLast {
		println 'hello Gradle'
	}
}

cheats.txt  view on Meta::CPAN


# Add architecture to the list of architectures for which (DES)
# packages can be installed without using --force-architecture
dpkg --add-architecture i386

# Check if a package is on hold (no updates)
dpkg --get-selections apksigner
apt-mark showhold

# Remove packages marked with rc:
dpkg -l | \grep '^rc' | nth 1 | xargs sudo dpkg --purge


#############################################################
## Linux Commands - dmesg
#############################################################

# View kernel messages
dmesg


cheats.txt  view on Meta::CPAN

# Find out if using 32 or 64 bit linux system
uname -m     # 32 is i686 or i386, 64 is x86_64

# Find out the release name (UI,bench,DES)
lsb_release -a

# Show which debian version name machine is (such as wheezy) (Added: 2017-10-05 11:26:48 AM)
lsb_release -cs

# Get name of our OS:
cat /etc/os-release | \grep '^ID='
ID="centos"


#############################################################
# Linux Startup
#############################################################

# Prevent a program from starting on Ubuntu during boot.
# Click on “Startup Application” and launch Startup Program Preference.

cheats.txt  view on Meta::CPAN

concat 14925373/s     4%     --

# Interpolation vs concat vs comma comparison:
perl -Me -e 'my $v = 123; n { interp => sub { "I got $v dollars"}, concat => sub { "I got " . $v . " dollars" }, comma => sub{ "I got ", $v, " dollars" } }, 10000000'
             Rate interp concat  comma
interp 20408163/s     --    -2%   -57%
concat 20833333/s     2%     --   -56%
comma  47619048/s   133%   129%     --

# Remove duplicate characters.
perl -E '$_ = "abbbc"; s/(.)\g1+/$1/; say'
abc
perl -E '$_ = "abbbc"; tr///cs; say'
abc

# Remove duplicate characters (benchmark).
perl -Me -e '
    $copy = "abbc";
    n {
        s => sub{
            local $_ = $copy;
            s/(.)\g1+/$1/;
            $_;
        },
        tr => sub{
            local $_ = $copy;
            tr///cs;
            $_;
        }
    }, 1000000
'
            (warning: too few iterations for a reliable count)

cheats.txt  view on Meta::CPAN

## Perl Regular Expressions - Captures
#############################################################

# Perl Regular Expressions - Captures
Some examples: 
/(\d)(\d)/  # Match two digits, capturing them into $1 and $2 
/(\d+)/     # Match one or more digits, capturing them all into $1 
/(\d)+/     # Match a digit one or more times, capturing the last into $1

# Perl Regular Expressions - Captures
# To  avoid  this ambiguity,  refer  to  a  capture  group  by  its  number  using  \g{NUMBER},  and  to  an octal  character  by  number  using  \o{OCTNUM}.  
# So  \g{11}  is  always  the  11th  capture group,  and  \o{11}  is  always  the  character  whose  codepoint  is  octal  11

# Perl Regular Expressions - Captures
# branch reset
m{   
  (?|
     (\d+)  \s+ (\pL+)   # these are $1 and $2      
    | 
     (\pL+) \s+ (\d+)    # and so is this pair!   
  )
}x

cheats.txt  view on Meta::CPAN

#############################################################
## Perl Regular Expressions - Lookaround
#############################################################

# variable length lookaround in any PCRE
# http://www.drregex.com/2019/02/variable-length-lookbehinds-actually.html?m=1
perl -E 'say "ABXXXCD" =~ /(?<=X+)/'
Lookbehind longer than 255 not implemented in regex m/(?<=X+)/ at -e line 1.
#
# Workaround:
perl -E '$r = qr/ (?=(?<a>[\s\S]*)) (?<b> X++ (?=\g{a}\z) | (?<= (?= x^ | (?&b) ) [\s\S] ) )/x; say "ABXXXCD" =~ $r'
perl -E '$r = qr/ (?=(?<a>(?s:.*))) (?<b> X++ (?=\g{a}\z) | (?<= (?= x^ | (?&b) ) (?s:.) ) )/x; say "ABXXXCD" =~ $r'
CD
#
# Explanation:
(?=(?'a'[\s\S]*))  # Capture the rest of the string in "a"
(?'b'
  X(?=\k'a'\z)     # Match X followed by the contents of "a" to ensure
                   # the emulated lookbehind stops at the correct point.
  |                # OR
  (?<=             # Look behind (one character) match either:
    (?=

cheats.txt  view on Meta::CPAN

#   (?<name>pattern)
# )
# It is recommended that for this usage you put the DEFINE
# block at the end of the pattern, and that you name any
# subpatterns defined within it.
#
# Then use it like:
# (?&name)
#
# Example:
perl -E '"look mk" =~ / (l (?&same_char) )k \s (.)k (?(DEFINE) (?<same_char> (.) \g{-1} ) ) /x; say "got: 1:$1, 2:$2, 3:$3, 4:$4"'

# Check for existence of a capture group.
# Can use either:
# - ({ exists $+{var} })
# - (?<var>IF|ELSE)
perl -E '
    "abc" =~ /
        (?{ say exists $+{var} ? 1 : 0 })
        (?(<var>)
              (?{ say "if" })

cheats.txt  view on Meta::CPAN


# Check pi revision
cat /proc/cpuinfo
Code	Model	Revision	RAM	Manufacturer
a020d3	3B+		1.3			1GB	Sony UK
#
# Compare to:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md

# Find out the total on a linux machine (pi)
local ram=$(\grep MemTotal /proc/meminfo | perl -lne '($kb)=/(\d+)/; printf "%0.2fGB", $kb/1024/1024')


#############################################################
## PI - Network Interface
#############################################################

# Turn interface card off and on. (pi)
# Useful in cases where connection needs to be reset.
sudo ifconfig eth0 down && sudo ifconfig eth0 up



( run in 0.245 second using v1.01-cache-2.11-cpan-87723dcf8b7 )