App-Cheats
view release on metacpan or search on metacpan
void *send_thread (void * args){
COMMAND_PATTERN* pattern = (COMMAND_PATTERN*) args; // Can use pattern normally
...
}
#
# Make sure to end the function with this:
# (it will exit the thread. don't use in main otherwise will get defunct/zombie process)
pthread_exit(NULL);
# Determine version and library used for threads
# NPTL - Native POSIX Threads Library # Threads share PID
# LinuxThreads # May be different PIDs (plus may other differences)
getconf GNU_LIBPTHREAD_VERSION # NPTL 2.7
#############################################################
## C,CPP - Debug
#############################################################
# Sleepy poll (debug,ddd,gdb,break)
# How to debug a progam
# Then after getting in using ddd, set wait_variable=0
int wait_variable = 1; while (wait_variable) sleep(1);
# Debug a UI program (DES,UI)
# Flags after --args are passed to the program
gdb progarm --args arg1 arg2
# Debug a c program given its pid (DES,UI)
gdb --pid 21620
gdb --pid `myps | grep snv | grep -v grep | awk '{print $4}'`
# gdb debugger navitation (commands,DES,UI)
(gdb) l[ist] # view code
(gdb) l[ist] main # view main code
(gdb) b[reak] main # Put a breakpoint at main()
(gdb) r[un] # start the program
(gdb) h[elp] all # View all help sections
(gdb) f[rame] # Show current line (line number and file)
(gdb) c[ontinue] # Continue to a breakpoint
(gdb) d[elete] # Delete all breakpoints
# View all functions in ddd (gdp,debugger)
info functions
# View entry point of executable program (OMS)
readelf -h omsGUI | grep "Entry point address"
# was: 0x80524a0
ddd <pid>
att <pid>
b * 0x80524a0
c
# Problem: Debugger (ddd,gdb) is ignoring my breakpoint and
# moving unto another function
# Answer: Add this line inside the function you want to breakpoint
# Note: Causes a segmentation fault SIGSEGV
*(char*)0 = 0;
# Set outer variable in bash shell (hack)
a=123; (gdb --batch-silent -ex "attach $$" -ex 'set bind_variable("a", "456", 0)'); echo $a
#############################################################
## C,CPP - Errors
#############################################################
# Error: Illegal deallocation of memory
//
// my.c:
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
//
// int main(int argc, char ** argv){
// char * str;
//
// if (argc>1) {
// str = (char *) malloc(10);
// }
//
// printf("Str: %s\n",str);
// free(str);
//
// return 0;
// }
//
// MAKE.bat
g++ my.c -o my.exe
# Try Catch in Cpp
# No throw means no catch
//
#include <iostream>
using namespace std;
int main(int,char**){
int n = 10;
int m = 0;
try {
// if( m == 0 ) throw "Division by zero condition!";
int val = n / m;
cout << "Divided: " << val << endl;
}
catch (...){
cout << "Caught error" << endl;
}
cout << "DONE" << endl;
return 0;
}
# Nested Try Catch in Cpp
# No throw means no catch
//
#include <iostream>
using namespace std;
int main(int,char**){
int n = 10;
int m = 0;
int val;
try {
try {
rm -f /var/lib/docker/containers/* # just "sudo ..." doesnt work for some reason.
exit
sudo systemctl start docker.service
#############################################################
## Docker Logs
#############################################################
# View messages from containers.
docker logs CONTAINER
docker logs -f CONTAINER
#############################################################
## Docker Attach/Detach
#############################################################
# Attach to a container.
docker run CONTAINER
docker start -a CONTAINER
# Detach from a container.
docker run -d CONTAINER
#############################################################
## DockerHub (push/pull)
#############################################################
# Need to first create an auth key on dockerhub
docker login -u poti1
# Upload to dockerhub.
# Make sure repo is public or you cant upload due to restrictions.
docker push poti1/my-perl-server:latest
# Fetch image.
docker pull poti1/my-perl # Always fetches the latest.
docker run poti1/my-perl # Fetches only if missing locally.
# Use an uploaded image.
docker run -it --rm poti1/my-perl -E 'say 123'
#############################################################
## Docker Data/Volumes
#############################################################
# 2 types of volumes/mount
# -v LOCAL:DOCKER:PERMISSIONS
docker run -v /app/data # Anynymous volume.
docker run -v data:/app/data # Named volume.
docker run -v $(pwd)/data:/app/data # Bind mount.
docker run -v $(pwd)/data:/app/data:ro # Bind mount (read-only).
#
# anonymous - closed on shutdown
# named - persistent.
# View docker volumes
# Does NOT show bind mounts.
# Only for development use.
docker volume ls
# Create anonymous docker volume
VOLUME [ "/app/path" ]
# Same as:
-v /app/path
# Create named docker volume
# Not deleted on container shutdown.
# NAME:/PATH_IN_CONTAINER:PERMISSIONS
# NAME should be absolute
docker run -v $(pwd)feedback:/app/feedback feedback-node
docker run -v $(pwd)feedback:/app/feedback:ro feedback-node
# Docker volume gotchas.
# Mount a folder will overwrite all content in container folder.
# If clash of volume paths, longer wins.
docker run -d --rm -p 3000:80 --name feedback-app -v $(pwd)/feedback:/app/feedback -v $(pwd):/app -v /app/node_modules feedback-node
#############################################################
## Docker ARG/ENV
#############################################################
# Using environmental variables in a Dockerfile.
ENV PORT 80
EXPOSE $PORT
# Build and run using an environmental variable
docker run --env DEBUG=1
docker run --rm --env PORT=8000 poti1/my-perl -E 'say "123 $ENV{PORT}"'
# Provide arguments when building a docker image.
ARG DEFAULT_PORT=8080
ENV PORT $DEFAULT_PORT
EXPOSE $PORT
docker build --build-arg DEFAULT_PORT=3000
#############################################################
## Docker Networking
#############################################################
# Docker networking - talk to website.
# Just works "out of the box" by using -p LOCAL_PORT:CONTAINER_PORT
# Docker networking - talk to host machine.
# Need to change url in the address.
# localhost -> host.docker.internal
# Docker networking - talk to another container.
# Every container SHOULD do just one main thing.
# 1 container for the server.
# 1 container for the database.
# Docker networking - steps - 1
docker build -t favorites-node:latest .
docker run --name favorites --rm -p 3000:3000 favorites-node
# Will fail due to:
MY_VAR: ABC
# env-file:
# - ./env/mongo.env
backend:
build: ./frontend
container_name: backend
ports:
- "80:80"
volumes:
- logs:/app/logs # Named. Need to also add to main volumes.
- ./backend:/app # No need for absolute paths :)
- /app/node_modules # Anonymous.
depends_on:
- mongodb
frontend:
build: ./frontend
container_name: frontend # --name
ports: # -p
- "3000:3000"
volumes: # -v
- ./frontend/src:/app/src
depends_on:
- mongodb
- backend
stdin_open: true # -i
tty: true # -t
volumes:
data:
logs:
# Run docker compose commands
docker-compose up # build and run all images.
docker-compose down # Removes all containers (does NOT remove volumes).
docker-compose up -d # Dettached
docker-compose build # Force image rebuild.
docker-compose up --build # Force image rebuild and start.
#############################################################
## Docker Utility Containers
#############################################################
# Start node dettached and run commands inside of it.
docker run -it -d --rm --name mynode node
docker exec -it mynode npm init
# Check postgres on docker image
docker exec -it keycloak-postgres bash
psql -h localhost -U keycloak
# Run a command when starting a container
docker run -it --rm --name mynode node [DEFAULT_COMMAND_TO_RUN]
# Create a utility container.
# Try 1: Dockerfile to build setup something on the host machine.
# (without needing the extra tools)
FROM node:14-alpine
WORKDIR /app
ENTRYPOINT [ "npm" ] # Prefix to "docker run" command.
#
# Mirror generated files to the host machine (By using a bind mount).
# This will create package.json on the local machine.
docker build -t mynpm .
docker run -it --rm -v $(pwd):/app mynpm init
docker run -it --rm -v $(pwd):/app mynpm install
docker run -it --rm -v $(pwd):/app mynpm install express --save
# Create a utility container.
# Try 2: Similar, but now using docker-compose.
version: "3.8"
services:
npm:
build: ./
stdin_open: true
tty: true
volumes:
- ./:/app
#
docker-compose run --rm npm init
docker-compose run --rm -- npm install express --save
# Create a utility container.
# Try 3: Same, but do NOT need a Dockerfile now.
version: "3.8"
services:
npm:
stdin_open: true # -i
tty: true # -t
volumes: # -v
- ./:/app
image: node:14-alpine
working_dir: /app
entrypoint: npm
docker-compose run --rm npm init
docker-compose run --rm -- npm install express --save
#############################################################
## Docker Complex Setup
#############################################################
# Docker Complex Setup. Make laravel project.
docker-compose run --rm -- composer create-project --prefer-dist laravel/laravel .
docker-compose up -d --build server
docker-compose run --rm artisan migrate
# Start only specific services (containers)
docker-compose up -d server php mysql
docker-compose up -d server # if server "depends_on" others.
docker-compose up -d --build server # Always rebuild
http://localhost:8000/
# Check php version inside of a container.
docker-compose run --rm -- php php -v
#############################################################
## Docker Multistage Builds
#############################################################
# Docker Multistage Builds - Use artifacts from a different stage.
# Allocates a shared memory segment (IPC)
man shmget
# example from rtfsched.c:
# if ((shmid = shmget(key, sizeof(RTFSCHED_SDEF), 0666|create)) == -1)
# Fix UI start up error: Waiting for master session to start
ipcx
ipcclean
#############################################################
## Linux Commands - kill, killall, skill
#############################################################
# kills all possible processes
kill -9 -1
# Kill all of someones processes
skill -KILL -u xbe4092
killall -u xbe4092
# Remove myself from someone's bench (kill)
killall -u $USER
# Kill all user sessions/windows (cleanup)
skill -KILL <user>
#############################################################
## Linux Commands - last, lastlog
#############################################################
# Display all users that are logged in
last
last -i # IP address
# View all last login times for all users
lastlog
lastlog | NOT "Never logged" | AND "Jan\s+(9|10)"
# View last login for a user
last xbe4092
#############################################################
## Linux Commands - ld
#############################################################
# Check if library can be found (gnu make)
ld -libmy.a
#############################################################
## Linux Commands - ldd, ldconfig
#############################################################
# Print shared library dependancies (Added: 2017-10-04 02:02:51 PM)
ldd `which svn`
# configure dynamic library linker run-time bindings (Added: 2017-10-04 02:11:12 PM)
ldconfig -v
# Search locations of system libraries (DES, Setup new machine)
ldconfig -p | grep my_lib
#############################################################
## Linux Commands - libreoffice
#############################################################
# Convert excel to csv on the command line.
# https://help.libreoffice.org/latest/en-GB/text/shared/guide/csv_params.html
# 76 - UTF-8 encoding.
# 44 - Comma.
# 34 - Double quote.
my $csv_format = qq(csv:"Text - txt - csv (StarCalc)":44,34,76);
my $command = qq(libreoffice --headless --convert-to $csv_format $excel_file);
system $command;
die if $?;
#############################################################
## Linux Commands - locate
#############################################################
# Search for a c header file (DES)
sudo updatedb # If added from apt-get
locate my_header
#############################################################
## Linux Commands - ls, ll
#############################################################
# Apply a character class to list (ls files)
ll *2[1-3]
#############################################################
## Linux Commands - mail
#############################################################
# Email the contents of a file to someone
echo $(cat mail.dat) | mail -s "File Name" timofey.potapov@pw.utc.com
# Print fixed width (monospace) emails
cat batch_report.formatted | perl -le 'print "<html><body><pre>\n", <>, "\n</pre></body></html>"' | mail -s "html report -a " -a "Content-Type: text/html" timofey.potapov@pw.utc.com
# Send email with a file as an attachment
cat ENV_linux.txt | mail -s "attachement" -a "Content-Type: html" timofey.potapov@pw.utc.com
# Send mail from another bench
ssh potapov@lnxbr25 'cat ~/bin/date.dat | mail -s "subject" timofey.potapov@pw.utc.com'
# Find out which benches can send emails
run_on_all_benches.p 'echo "on bench `uname -n`" | mail -s "`uname -n`" melvin.williams@pw.utc.com'
# View emails on bench
mail
perl -le 'sub func{my($t)=@_; our $s; my $m = $t =~ m{ (?{ $s //= $-[0] }) \d}x; print "t=[$t]\ns=[$s]\nm=[$m]\n"} func 1; func 1'
# Segmentation fault in perl on some systems (Gentoo,SEGV)
# https://github.com/Perl/perl5/issues/19147
perl -we '$a{$b}'
# Run script multiple times in order and stop on the first error.
for n in {1..1000}; do perl -I. -IKernel/cpan-lib -MSchedule::Cron::Events -E 'eval{ Schedule::Cron::Events->new("* * 0 * *", Date => [ 16, 25, 16, 10, 7, 123])}; say "OK"'; if [ $? -ne 0 ]; then echo "STOPPED on run: $n"; break; fi; done
# Perl SEGV due to confess
https://github.com/Perl/perl5/issues/15928
# Variable suicide bug (fixed pre v5.6)
https://perldoc.perl.org/perlfaq7#What-is-variable-suicide-and-how-can-I-prevent-it?
perl -E 'my $f = 'foo'; sub func { while ($i++ < 3) { my $f = $f; $f .= "bar"; say $f }} func; say "Finally $f\n"' foobar foobar
foobar
Finally foo
# Perl lexical variable eval bug (fixed after 5.40).
https://www.perlmonks.org/?node_id=11158351
https://github.com/Perl/perl5/pull/22097
# Refresh a Module (bug):
https://www.perlmonks.org/?node_id=11161935
#############################################################
## Perl Compile
#############################################################
# Compile a perl script into c code (only on lnxbr42) (really slow)
pp -o hello hello.pl
# Run c/cpp code inside perl (Compile)
perldoc Inline
#############################################################
## Perl Configuration
#############################################################
# Print all the perl configuration variables
perl -V:.*
# Check if little or big endian
perl -V:byteorder
byteorder='12345678' # Little
# Show all perl configuration options.
perl -MConfig -Me -e 'p \%Config'
#############################################################
## Perl Debugger
#############################################################
# Library to enable using up arrow key in perl debugger window (-de0)
sudo apt install libreadline-dev
# Check for paste bracketing
bind -V | grep paste
enable-bracketed-paste is set to `on'
#
# Enable paste bracketing
if [ -n "$PS1" ]; then
bind 'set enable-bracketed-paste on'
fi
# Create a perl debug file. Watch parameters. view code around (v) (debugger)
cat > .perldb
@DB::typeahead = (
'{{v',
# 'c',
# 'Nonstop',
# 'frame=0',
);
parse_options('inhibit_exit=0');
# Go into a similar session as with python (debugger)
perl -de0
# Graphical perl debugger (only on lnxbr42)
perl -d:ptkdb -e 'print for 1..10'
#############################################################
## Perl DOS
#############################################################
# Template to use the same file for perl and dos
@REM='
@echo off
perl -x -S -l %0 %*
exit /b
';
#!perl
print "HELLO WORLD";
#############################################################
## Perl Endian
#############################################################
# Check type of endian (little or big)
perl -le 'print unpack "h*", pack "S2",1,2' # 10002000 means little endian
# Big to little endian converter
perl -nle 'print pack "V*", unpack "N*", $_'
# Check if Big Endian
perl -le 'print unpack "H08",pack "L",2'
2 -> 02000000 mean Big Endian
# Force little endian
perl -le 'print unpack "H08",pack "L<",2'
# Force big endian
perl -le 'print unpack "H08",pack "L>",2'
# Convert Big Endian to Little Endian (approach 1)
echo 0x89346512 | perl -ple 's/(\d\d)(\d\d)(\d\d)(\d\d)/$4$3$2$1/'
# Convert Big Endian to Little Endian (approach 2)
echo 0x3487 | perl -ple 's/(?:(\d\d)(\d\d))?(\d\d)(\d\d)/$4$3$2$1/'
echo 0x89346512 | perl -ple 's/(?:(\d\d)(\d\d))?(\d\d)(\d\d)/$4$3$2$1/'
#############################################################
## Perl Modules - Socket
#############################################################
# Simple client using perl Socket module.
use Socket;
my $socket;
my $port = 171717;
my $address = 'localhost';
my $packed_addr = pack_sockaddr_in(
$port,
inet_aton($address),
);
my $data;
socket $socket, AF_INET, SOCK_STREAM, 0;
connect $socket, $packed_addr or die $!;
while($data = <$socket>)
{
print "From Server - $data";
}
close $socket or die $!;
#############################################################
## Perl Modules - Storable
#############################################################
# Create a deep clone of a reference.
perl -MStorable=dclone -E 'my $h={a => [1..2]}; my $h2 = dclone($h); say $_, " ", $_->{a} for $h, $h2'
# Storable error: Max. recursion depth with nested structures exceeded
# Can update the Storable recursion limit with:
$Storable::recursion_limit = 10000;
$Storable::recursion_limit = -1; # Disables all limits.
#
# Create a heavily nested structure.
perl -Me -e '$d = [$d] for 1..1000000; clone $d'
Max. recursion depth with nested structures exceeded at -e line 1.
#
# Its about depth. This is ok:
perl -MStorable=dclone -e '$Storable::recursion_limit = 2; dclone( [ [ ], [], [], [] ] )'
#
# Whereas, this one is not:
perl -MStorable=dclone -e '$Storable::recursion_limit = 2; dclone( [ [ [] ] ] )'
Max. recursion depth with nested structures exceeded at -e line 1.
# Storable recursion limit seems to be about depth, not size, and not accumulative depth:
perl -MStorable=dclone -e '$Storable::recursion_limit = 3; dclone( [ [ [] ], [ 111, [222] ], [ [ 333, 444] ], [ [ 555, 666 ], [ 777, 888 ], { aaa => 999 }, [], [], [], [], [] ], [], 111 ], )'
# Simple server using perl Socket module.
use Socket;
my ($socket,$new_socket);
my $port = 171717;
my $address = 'localhost';
my $MAX_CONN = 10;
my $packed_addr = pack_sockaddr_in(
$port, inet_aton($address),
);
my $client_addr;
socket $socket, AF_INET, SOCK_STREAM, 0;
bind $socket, $packed_addr or die $!;
setsockopt $socket, SOL_SOCKET, SO_REUSEADDR, 1 or die $!;
listen $socket, $MAX_CONN or die $!;
print "Listening on port=$port, address=$address";
while($client_addr = accept $new_socket, $socket)
{
my $name = gethostbyaddr $client_addr, AF_INET;
print "Someone connected ($name)";
print $new_socket "I'm from the Server";
print $new_socket "I'm from the Server 2";
close $new_socket;
}
#############################################################
## Perl Modules - Subs::Trace
#############################################################
# WhoAmI to all functions in a class.
+ #!/usr/bin/perl
+
+ package Subs::Trace;
+
+ use v5.32;
+
+ sub import {
+ my $pkg = caller();
+
+ INIT {
+ no strict 'refs';
+
+ for my $func (sort keys %{"${pkg}::"}) {
+ my $code = ${"${pkg}::"}{$func}->*{CODE};
+ next if not $code;
+
+ ${"${pkg}::"}{$func}->** = sub {
+ say "-> $pkg\::$func";
+ &$code;
+ }
+ }
+ }
+ }
+
+
+ 1
# Subs::Trace use case (example)
perl -I. -E '{ package P; use Subs::Trace; sub F1{10} sub F2{20} } say P::F1() + P::F2()'
# Subs::Trace cpan modules.
cpanm Subs::Trace
perl -E '{ package P; sub F1{10} sub F2{20} sub F4{40} use Subs::Trace; sub F3{30} } say P::F1() + P::F2() + P::F3() + P::F4()'
-> P::F1
-> P::F2
-> P::F4
100
#############################################################
## Perl Modules - Template (Toolkit,tt)
#############################################################
## Perl Modules - Time::Seconds
#############################################################
# Date arithmetic in Javascript (add 90 days to a date)
# Time::Seconds imports ONE_DAY
perl -MTime::Seconds -MTime::Piece -le "$now=localtime; $now+=$now->tzoffset; $now += ONE_DAY * 90; print $now->strftime('%Y-%m-%d')"
# Subtract days.
perl -MPOSIX -le '
@t = localtime; $t[3] -= 1299;
print scalar localtime mktime @t
'
# Seconds to HMS (hhmmss)
use Time::Seconds;
my $time = Time::Seconds->new(time - $time0)->pretty;
#
perl -MTime::Seconds -E 'say Time::Seconds->new(time)->pretty;'
# 18845 days, 18 hours, 4 minutes, 21 seconds
#############################################################
## Perl Modules - Tk (General)
#############################################################
# Create a simple Tk window
perl -MTk -le '$mw=MainWindow->new; $mw->title("Hello"); $mw->Button(-text => "Done", -command => sub{exit})->pack; MainLoop'
# Create a simple grid window
perl -MTk -le '$m=MainWindow->new; $m->Button->grid($m->Button,$m->Button); $m->Button->grid($m->Button,$m->Button); MainLoop'
# Create a simple grid window with last button spanning several columns
perl -MTk -le '$m=MainWindow->new; $m->Button->grid($m->Button,$m->Button); $m->Button->grid($m->Button,"-", -sticky => "nsew"); MainLoop'
# Create a simple grid window with last button spanning several rows
perl -MTk -le '$m=MainWindow->new; $m->Button->grid($m->Button,$m->Button, -sticky => "nsew"); $m->Button->grid($m->Button,"^"); MainLoop'
# Create a simple grid window with last button removed/ignored/skipped
perl -MTk -le '$m=MainWindow->new; $m->Button->grid($m->Button,$m->Button); $m->Button->grid("x",$m->Button, -sticky => "nsew"); MainLoop'
# Have a button to disable another button
perl -MData::Dumper -MTk -wle '
$mw = MainWindow->new;
$exit_b = $mw->Button(-text => "exit", -command => sub{exit})->pack(-ipadx => 20, -ipady => 10);
$text = "Disable Exit";
$mw->Button(-textvariable => \$text, -command => sub{
if( ($exit_b->configure(-state))[-1] eq "disabled" ){
$exit_b->configure(-state => "normal");
$text = "Disable Exit";
}
else{
$exit_b->configure(-state => "disabled");
$text = "Enable Exit";
}
})->pack;
MainLoop;
'
# TODO: Check if Unigraph is perl tk
# Create Menu Buttons (PTk,bind method)
perl -MTk -le '$mw=MainWindow->new; $mw->Button(-text => "Exit", -command => sub{exit})->pack(-side => "bottom", -fill => "both", -expand => 1); $f=$mw->Frame(-relief => "ridge", -borderwidth => 2)->pack(-side => "top", -expand => 1, -fill => "both")...
# Perk Tk Event Types (PTk,bind method)
ButtonPress (or Button)
ButtonRelease
Circulate
Colormap
Configure
Destroy
Enter
Expose
FocusIn
FocusOut
Gravity
KeyPress (or Key)
KeyRelease
Leave
Map
Motion
Reparent
Unmap
Visibility
# Perl Tk Event Info Usage program
perl -MTk -le '$mw=MainWindow->new; $b=$mw->Button->pack(-ipadx => 60); $b->bind("<Key>", [sub{print "ARGV: @_[1..$#_]"}, Ev("k"), Ev("K"), Ev("N"), Ev("T")]); MainLoop'
# Perl Tk Event Info (PTk,bin methods,Ev)
#
# Coordinates (relative to window)
Ev('x')
Ev('y')
#
# Coordinates (relative to root of window)
Ev('X')
Ev('Y')
#
# Button Number (of mouse click)
Ev('b')
#
# Size of widget
Ev('h') # height
Ev('w') # width
#
# Keyboard Info
Ev('k') # Physical Key Value 37 37
Ev('K') # Letter A a
Ev("N") # Decimal 65 97
#
# Event Type
Ev('T') # KeyPress
# Perl Tk Event Info (PTk,bin methods,Ev)
# Stop events in callback.
return # Exits only current sub
Tk::break # Stops all callbacks for an event
# View order of bindings for a widget (PTk,bin methods,Ev)
print for $b->bindtags
print "$_: ", $b->bind($_) for $b->bindtags
# Order order of bindings for a widget (PTk,bin methods,Ev)
$b->bindtags("[all]")
# View the bindtags for (PTk):
# Class
# Install
# Toplevel
# All
perl -MTk -le '$b=MainWindow->new->Button->pack; $b->bind("<ButtonRelease-1>", sub{exit}); map {print $_; printf " $_\n" for $b->bind($_)} $b->bindtags'
# Check if widget exists, if widget if packed (mapped,PTk)
perl -MTk -le '$mw=MainWindow->new; $b=$mw->Button(-text => "unpack", -command => sub{$b->packForget})->pack; $mw->Button(-text => "Check status", -command => sub{print for "",Exists($b), $mw->appname, $b->ismapped()})->pack; MainLoop'
# Track mouse movements (PTk)
perl -MTk -le '$mw=MainWindow->new; $mw->geometry("200x200+0+0"); $w=$mw->Label(-textvariable => \$t, -width => 20)->pack; $mw->bind("<Motion>", sub{$t=join ", ", $mw->pointerxy}); MainLoop'
# Track mouse movements (PTk)
# More positional values
perl -MTk -le '$w=tkinit; $w->geometry("200x200"); $w->Label(-textvariable => \$t, -justify => "left")->pack; $w->bind("<Motion>", sub{$t=sprintf "pointerxy:%s,%s\nxy:%s,%s\nroot:%s.%s\nvroothw:+%s,+%s\nvrootxy:%s,%s\nscreen:%s", $w->pointerxy, $w->x...
# Add tab completion to an entry widget
perl -MTk -le '$mw=MainWindow->new; $e=$mw->Entry(-textvariable => \$t)->pack; $e->focus; $e->bind("<Tab>", sub{@a=glob "$t*"; $t=shift @a if @a; $e->selectionClear}); MainLoop'
# Bind Enter/Carriage Return key (PTk)
$e->bind("<Return>"
# Swap button (PTk)
perl -MTk -le '$mw=MainWindow->new; for(1..3){my $b=$mw->Button(-text => "B$_", -width => 20)->pack; $b->configure(-command => sub{ ($n)=grep{$b[$_] eq $b}0..$#b; return unless $n > 0; @b[$n,$n-1]=@b[$n-1,$n]; $_->packForget for @b; $_->pack for @b})...
# Drag and swap buttons (PTk)
perl -MTk -le '$mw=MainWindow->new; my @b; sub id{my($n)=grep{$b[$_] eq $_[0]}0..$#b; $n} for(1..3){push @b, $mw->Button(-text => "B$_", -width => 20)->pack} $mw->bind("<ButtonRelease-1>",[sub{$m=id(shift); $n=id($mw->containing(@_)); @b[$m,$n]=@b[$n...
# Swap frames of buttons (PTk)
perl -MTk -le '$mw=MainWindow->new; my @b; sub id{my($n)=grep{$b[$_] eq $_[0]}0..$#b; $n} for my $fi(1..3){my $f=$mw->Frame->pack; push @b,$f; $f->Button(-text => "Btn - $fi - $_", -width => 20)->pack(-side => "left") for 1..3} $mw->bind("<ButtonRele...
# Notebook example 1. multiple pages/tabs (PTk)
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook->pack(-fill => "both", -expand => 1); @pgs = map { $nb->add("page$_", -label => "Page $_") } 0..5; $pgs[0]->Button(-text => "Button $_")->pack(-fill => "both") for 1..5; $pgs[1]->Label(-text...
# Notebook example 2. multiple pages/tabs (PTk)
# Command when clicking a page/tab
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook(-font => "Courier 14 bold")->pack(-fill => "both", -expand => 1); @pgs = map { $nb->add("page$_", -label => "Page $_") } 0..20; $pgs[0]->Button(-text => "Button $_")->pack(-fill => "both") f...
# Notebook example 3. multiple pages/tabs (PTk)
# Page deletion
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook->pack(-fill => "both", -expand => 1); @pgs = map { $nb->add("page$_", -label => "Page $_") } 0..10; $nb->pagecget("page0", "-state"); $pgs[0]->Button(-text => "Button $_")->pack(-fill => "bo...
# Notebook example 4. multiple pages/tabs (PTk)
# Get page by name
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook->pack(-fill => "both", -expand => 1); @pgs = map { $nb->add("page$_", -label => "Page $_") } 0..10; $nb->pagecget("page0", "-state"); $pgs[0]->Button(-text => "Button $_")->pack(-fill => "bo...
# Notebook example 5. multiple pages/tabs (PTk)
# 2 rows
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook->pack(-fill => "both", -expand => 1); $nb->add("page0$_", -label => "Page $_") for 1..5; map { my $nb = $_; $nb->add("page1$_", -label => "Page $_") for 6..10; } map $_->NoteBook->pack, ma...
# Notebook example 6. multiple pages/tabs (PTk)
perl -MTk -MTk::NoteBook -le '$nb=MainWindow->new->NoteBook->pack; $nb->add("page0$_", -label => "Page $_") for 1..5; @pgs = map $nb->page_widget($_), $nb->pages; ($p,@rest)=@pgs; $nb1=$p->NoteBook->pack; $nb1->add("page1$_", -label => "Page $_") for...
# Entry widget validation options (PTk)
perl -MTk -le 'MainWindow->new->Entry(-validate => "key", -validatecommand => sub{$_[1] =~ /\d/}, -invalidcommand => sub{ print "ERROR" })->pack->focus; MainLoop'
# Making Scrollbars (PTk)
# When text widget is scrolled its "-yscrollcommand" command is invoked. This calls $s->set(...)
# When the scrollbar is clicked on "-command" is invoked which calls $t->yview(...)
perl -MTk -le '$mw=MainWindow->new; $s=$mw->Scrollbar; $t=$mw->Text(-yscrollcommand => ["set" => $s]); $s->configure(-command => ["yview" => $t]); $s->pack(-side => "right", -fill => "y"); $t->pack(-fill => "both"); MainLoop'
# Scale widget example (PTk)
perl -MTk -le 'MainWindow->new->Scale(-from => 1, -to => 5, -tickinterval => 1, -showvalue => 0)->pack; MainLoop'
# Balloon widget example (PTk)
perl -MTk -MTk::Balloon -le '$mw=MainWindow->new; $b=$mw->Button(-text => "DO NOTHING")->pack; $mw->Balloon->attach($b, -msg => "button"); MainLoop'
# Balloon widget example (PTk)
perl -MTk -le '$w=tkinit; $bt=$w->Button(-text => "this does nothing")->pack; $w->Balloon->attach($bt, -msg => "really nothing"); MainLoop'
# Listbox example (PTk)
perl -MTk -le '$w=MainWindow->new; $lb=$w->Scrolled("Listbox", -scrollbars => "osoe")->pack; $lb->insert(0,1..10); $w->Button(-text => "SHOW", -command => sub{@s=$lb->curselection; print $lb->get(@s) if @s})->pack; MainLoop'
# Handle clicking the "X" button on a window to close (PTk)
perl -MTk -le '$w=MainWindow->new; sub e{print "safe exit"; $w->destroy} $w->protocol("WM_DELETE_WINDOW", \&e); $w->Button(-text => "EXIT", -command => \&e)->pack; MainLoop'
# Menu(bar) example (PTk)
perl -MTk -le '$w=MainWindow->new; $m=$w->Menu; $w->configure(-menu => $m); %h=map{$_ => $m->cascade(-label => "~$_")} qw/File Edit Help/; $h{File}->command(-label => "Exit", -command => sub{exit}); MainLoop'
# Menu(bar) example using -menuitems (PTk)
perl -MTk -le '$w=MainWindow->new; $m=$w->Menu; $w->configure(-menu => $m); %h=map{$_ => $m->cascade(-label => "~$_", -menuitems => [[checkbutton => "MY_CHECK"],[command => "MY_CMD", -command => sub{print "exit"}, -accelerator => "Ctrl-o"],[radiobutt...
# Simple Menu(bar) example using -menuitems (PTk)
perl -MTk -le '$w=MainWindow->new; $m=$w->Menu; $w->configure(-menu => $m); $m->cascade(-label => "~File", -menuitems => [[command => "new", -accelerator => "Ctrl-n"],"",[command => "Open", -accelerator => "Ctrl-o"]]); MainLoop'
# Simple 2 Menu(bar) example using -menuitems (PTk)
perl -MTk -le '$w=MainWindow->new; $m=$w->Menu; $w->configure(-menu => $m); $m->cascade(-label => "~File", -menuitems => [[cascade => "new", -accelerator => "Ctrl-n", -menuitems => [map [command => $_],qw/PNG JPEG TIFF/], -tearoff => 0],"",[command =...
# Color changing menu(bar) (PTk)
perl -MTk -le '$color="$red"; $w=MainWindow->new; $mi=[[cascade => "~Edit", -menuitems => [[cascade => "~Background", -menuitems => [map [radiobutton => $_, -variable => \$color, -command => [sub{my $c=shift; $w->configure(-background => $c); print "...
# Simple composite Mega-Widget based on a Toplevel (PTk)
perl -MTk -le '{package Tk::My; use base "Tk::Toplevel"; Construct Tk::Widget "My" } $w=MainWindow->new; $w->My; MainLoop'
# Define own bitmap
perl -MTk -le '$w=MainWindow->new; $p=pack("b5"x5,"..1..",".111.","11111",".111.","..1.."); $bm=$w->DefineBitmap(up => 5,5,$p); $w->Button(-width => 10, -height => 30, -bitmap => "up")->pack; MainLoop'
# Define own bitmap (fansy)
cat star.bm
..............................
..............................
..............................
..............1...............
..............1...............
.............111..............
.............111..............
............1.1.1.............
.......11...1.1.1...11........
.......11..1..1..1..11........
.........1.1..1..1.1..........
..........1...1...1...........
.........1.1..1..1.11.........
.......11...1.1.1....11.......
.....11......111.......11.....
...111111111111111111111111...
.....11......111.......11.....
.......11...1.1.1....11.......
.........1.1..1..1.11.........
..........1...1...1...........
.........1.11.1.11.1..........
.......11...1.1.1...11........
.......11...1.1.1...11........
.............111..............
.............111..............
..............1...............
..............1...............
..............................
..............................
..............................
perl -MTk -le '$w=MainWindow->new; $s=30; $p=pack("b$s"x$s,`cat start.bm`); $w->DefineBitmap(start => $s,$s,$p); $w->Button(-bitmap => "start")->pack; MainLoop'
# DirTree example (PTk)
perl -MTk -le 'MainWindow->new->Scrolled("DirTree")->pack(qw/-fill both -expand 1/); MainLoop'
# LabEntry example (PTk,label and entry in one)
perl -MTk -le 'tkinit->LabEntry(-label => "name", -textvariable => \$name, -labelPack => [qw/ -side left /], -width => 20)->pack; MainLoop'
# Clicking a button will send it to the top. Cycle through
perl -MTk -le '$w=tkinit; @b=map{$w->Button(-text => $_)->pack} a..c; $_->configure(-command => sub{$b[-1]->pack(-before => $b[0]); unshift @b, pop @b }) for @b; MainLoop'
# Show or hide widgets based on a checkbutton (advanced options)
perl -MTk -le '$w=tkinit; $b=$w->Button->pack(qw/ -side bottom /); $p=1; $w->Checkbutton(-text => "Pack", -variable => \$p, -command => sub{ if($p){ $i=$b->{packInfo}; $b->pack(@$i) } else { $b->{packInfo} = [$b->packInfo]; $b->packForget } })->pack...
# Sleep/Wait (PTk)
$mw->after(3000) # ms
#############################################################
## Perl Modules - Tk (Bind)
#############################################################
# Make Control-C binding (PTk)
perl -MTk -le '$b=tkinit->Button(-text => "Try Control-C"); $b->configure(-command => sub{$b->focus}); $b->pack->bind("<Control-Key-c>", sub{print "Hit C"}); MainLoop'
# Show the name an value of each pressed key (PTk)
perl -MTk -le '$e=tkinit->Entry->pack; $e->focus; $e->bind("<Key>", sub{my($w)=@_; my $E=$w->XEvent; printf "%s %s\n", $E->K, $E->N}); MainLoop'
#
# Simpler
perl -MTk -le '$e=tkinit->Entry->pack; $e->focus; $e->bind("<Key>", sub{my $E=shift->XEvent; printf "%s %s\n", $E->K, $E->N}); MainLoop'
#
# Using newer "Tk::event"
perl -MTk -le '$e=tkinit->Entry->pack; $e->focus; $e->bind("<Key>", sub{printf "%s %s\n", $Tk::event->K, $Tk::event->N}); MainLoop'
# Three (3) ways to get the widget reference of a binding (PTk)
perl -MTk -le '$b=tkinit->Button(-command => \&cb)->pack; $b->bind("<ButtonRelease-3>", \&cb); sub cb {print "\nargs: @_"; print "->W" . $Tk::event->W; print "widget " . $Tk::widget}; MainLoop'
# Find out value of keypress
perl -MTk -le 'tkinit->Entry->pack->bind("<KeyPress>", sub{$e=$Tk::event; print $e->K . " " . $e->N}); MainLoop'
#############################################################
## Perl Modules - Tk (Canvas)
#############################################################
# Take a canvas and create a postscript then a pdf
perl -MTk -le '$w=tkinit; $c=$w->Canvas->pack; $c->createLine(20,20,200,200,200,20); $b=$w->Button(-text => "Save", -command => sub{$c->postscript(-file => "tk.ps")})->pack; MainLoop'
ps2pdf tk.ps tk.pdf
xpdf tk.pdf
#############################################################
## Perl Modules - Tk (Tags)
#############################################################
# Text tags example (PTk)
perl -MTk -le '$t=tkinit->Text->pack; $t->tagConfigure("bold", -font => "Courier 24 bold"); $t->insert("end", "Normal Text\n"); $t->insert("end", "Bold Text\n", "bold"); MainLoop'
# Make select text bold (PTk)
perl -MTk -le '$w=tkinit; $t=$w->Text->pack; $t->tagConfigure("bold", -font => "bold"); $t->insert("end", "A Bunch of text"); $w->Button(-text => "BOLD", -command => sub{$t->tagAdd("bold", "sel.first", "sel.last")} )->pack; MainLoop'
# Check if a selection exists (PTk)
perl -MTk -le '$w=tkinit; $t=$w->Text->pack; $t->tagConfigure("bold", -font => "bold"); $t->insert("end", "A Bunch of text"); $w->Button(-text => "BOLD", -command => sub{$t->tagAdd("bold", "sel.first", "sel.last") if $t->tagRanges("sel")} )->pack; Ma...
#############################################################
## Perl Modules - Tk (Appendix B)
#############################################################
# Adjuster example (PTk,Appendix B)
perl -MTk -le '$w=tkinit; %def=qw/-fill both -expand 1/; $b=$w->Button(-text => "Button A")->pack(%def); $w->Adjuster(-side => "top", -widget => $b)->pack(qw/-fill x/); $w->Button(-text => "Button B")->pack(%def); MainLoop'
# Balloon Example (Ptk,Appendix B)
perl -MTk -le '$w=tkinit; $btn=$w->Button(-text => "Button A")->pack; $bl=$w->Balloon; $bl->attach($btn, -msg => "click me"); MainLoop'
# Bitmap Example (Ptk,Appendix B)
# BrowseEntry Example (Ptk,Appendix B)
#
# Simple
perl -MTk -MTk::BrowseEntry -le 'tkinit->BrowseEntry(-label => "label", -variable => \$v, -choices => [1..10], -browsecmd => sub{print "Clicked $v"})->pack; MainLoop'
#
# Insert additional values
perl -MTk -MTk::BrowseEntry -le '$b=tkinit->BrowseEntry(-label => "label", -variable => \$v, -choices => [1..10], -browsecmd => sub{print "Clicked $v"})->pack; $b->insert("end",20,30); MainLoop'
# Button Example (Ptk,Appendix B)
# Canvas Example (Ptk,Appendix B)
#
# Simple useless canvas
perl -MTk -le '$c=tkinit->Scrolled("Canvas")->pack; MainLoop'
#
# Click in canvas window will show x,y coordinates
perl -MTk -le 'sub print_xy { my($c,$x,$y)=@_; print "(x,y) = @{[ $c->canvasx($x) ]}, @{[ $c->canvasy($y) ]} " } $c=tkinit->Scrolled("Canvas")->pack; $c->Subwidget("canvas")->CanvasBind("<Button-1>", [ \&print_xy, Ev("x"), Ev("y") ]); MainLoop'
# ColorEditor Example (Ptk,Appendix B)
# Dialog Example (Ptk,Appendix B)
# DirTree Example (Ptk,Appendix B)
# Type the Enter/Return key in Selenium.
perl -C -E 'say "\N{U+E007}"' î
perl -C -E 'say "\x{E007}"' î
# Make sure to use the apt firefox and not snap
# when seeing: Firefox profile not missing or not accessible.
sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox
#############################################################
## SQLite3 Database
#############################################################
# Install sqlite on Unix (after in zipping the amalgamation file. make sure these 3 are present:
# shell.c, sqlite3.c, sqlite3.h). rename to a.out to sqlite3
# (database, sqlite3)
gcc shell.c sqlite3.c -lpthread -ldl
# View all the tables in a database (database, sqlite3)
sqlite3 my.db '.tables'
# Turn on column names on query results (database, sqlite3)
sqlite3 my.db '.explain on' 'select * from page_groups'
# Print database structure and data (database, sqlite3)
sqlite3 my.db '.dump'
# View current status/info (database, sqlite3)
sqlite3 my.db '.show'
# REFERENCES and FOREIGN KEYS are (database, sqlite3)
# used to ensure that the tables keys are valid since they
# are found in the foreign table.
# Output the results with a header and evenly spaced columns
sqlite3 my.db --header -column 'select * from my_table'
# Create a new database, table, and data (nathan)
sqlite3 my.db 'create table Users(name,date)'
sqlite3 my.db 'insert into Users values ("bob",20)'
sqlite3 my.db 'insert into Users values ("Joe",25)'
sqlite3 my.db '.explain on' '.width auto' 'select * from Users'
# Case Insensitive Search in SQL query
SELECT ... FROM ... WHERE ... ORDER BY name COLLATE NOCASE ASC LIMIT 5
# Master sqlite table (.tables)
if (table == "") {
query = m_interface->prepare("SELECT name from sqlite_master"); // .tables
}
# View the .schema
else if (haveVerbose) {
query = m_interface->prepare("SELECT sql FROM sqlite_master WHERE name=:table"); // .schema
query.bind(":table", table);
}
# View the columns
else {
query = m_interface->prepare("SELECT name FROM PRAGMA_TABLE_INFO(:table)"); // column names
query.bind(":table", table);
# Get all columns names from SQLite
sqlite3 my.db "PRAGMA table_info(myTable)"
#
sqlite3 my.db "SELECT name FROM pragma_table_info('myTable') ORDER BY name"
# Provide default for null values using COALESCE (sqlite3)
SELECT DISTINCT COALESCE(col,'NULL') FROM myTable ORDER BY col ASC
# SQLite if/else, concat(merge) columns(strings)
SELECT name,
CASE WHEN var1 = 1 THEN 'x' ELSE '-' END ||
CASE WHEN var2 = 1 THEN '/x' ELSE '/-' END ||
CASE WHEN var3 = 1 THEN '/x' ELSE '/-' END ||
CASE WHEN var4 = 1 THEN '/x' ELSE '/-' END
AS var
FROM myTable
ORDER BY name;
# SQL inner join to get a summary of possibilities
sqlite3 my2.db "SELECT DISTINCT col1,col2 FROM myTable AS INNER JOIN (SELECT col1 FROM tool_types GROUP BY col1) USING(col1) INNER JOIN (SELECT col FROM tool_types GROUP BY col) USING(col) ORDER BY col1,col ASC"
# Avoid using "NOT IN" (SQL)
http://www.dbatodba.com/sql-server/how-tos/typical-solutions-to-avoid-using-not-in-on-sql-server/
# NOT IN works, but as the number of records grows, NOT IN performs worse
# Fastest solution so far (Using LEFT JOIN)
#
# Final query
SELECT t1.name,t1.changed
FROM
myTable1 AS t1
LEFT OUTER JOIN
(SELECT * FROM myTable2 WHERE id='123') AS t2
ON t1.name=t2.uid
WHERE
t2.changed IS NULL
OR
t1.changed!=t2.changed;
# Switch statement in SQLite3
SELECT
CASE WHEN item IS NULL THEN 'NULL'
WHEN item = 0 THEN '?'
WHEN item = 1 THEN 'Dummy'
WHEN item = 2 THEN 'Adapter'
ELSE item
END AS item2
FROM
queue
#############################################################
## Stegohide
#############################################################
# Hide a file inside of another file,
# then get it back.
steghide embed -cf COVER.jpg -ef SECRET_TO_EMBED
steghide extract -sf COVER.jpg
## Visual Boy Advance (VBA)
#############################################################
# Install VBA
# Add to: /etc/apt/sources.list
deb [trusted=yes] http://ftp.de.debian.org/debian bullseye main
# Install:
sudo apt install visualboyadvance
# Install VBA Dev environment:
https://medium.com/@microaeris/getting-started-with-gba-development-on-linux-a2c17ea826ea
sudo apt install devkitpro-pacman
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
#
# wav2agb
git clone https://github.com/ipatix/wav2agb
export $HOME/git/wav2agb
# Example VBA hello world.
cp $DEVKITPRO/examples/gba/template/ my -r
cd my
make
VisualBoyAdvance my.gba
# Apply updates to VBA.
perl -i -0777pe '$_ .= "ETERNATUS_ETERNAMAX\n" if not /ETERNATUS_ETERNAMAX/' src/tm_compatibility/*.txt src/tutor_compatibility/*.txt
python3 scripts/make.py
# Toggle level 100/255 (VBA)
perl -i -lpe 's/ MAX_LEVEL ,? \s+ \K \d+ /100/x' $(grep_text_files 'MAX_LEVEL.*(255|100)' -l)
#############################################################
## Visual Studio (Windows 10)
#############################################################
# Fold all code in Visual Studio (Toggle Fold)
Control+M, Control+L
# Visual Studio 2015 Change encoding of a file
File -> âAdvanced Save Optionsâ
Select âUnicode (UTF-8 â¦â)
# Visual Studio column mode
Alt + Click and drag.
#
# Visual Studio ZoomIn/Out
Control +
Control -
#############################################################
## Visual Studio Code
#############################################################
# Visual Studio Code (VSC) block edit (mode)
Shift + Alt + Click and Drag
# Visual Studio Code (VSC) bring up keybpard bindings
Control + Shift + P
# Decode AndroidManifest.xml, update it and build apk again.
Visual Studio Code
# Install APKLab
Control + Shift + P
Search: APK Lab
Select how to decompile.
Update AndroidManifest.xml
extractNativeLibs="true"
ReBuild and Sign APK
Right-Click on or inside apktool.yml file â APKLab: Rebuild the APK
#############################################################
## VPN
#############################################################
# Open VPN file storage location on Ubuntu:
/etc/NetworkManager/system-connections/
# For android, change '=' to ' '
# Manually run openvpn.
cd ~/my/git/otrs/SETUP/vpn_setup/EasyRSA/pki/private
sudo openvpn --config vpn-otrs.conf
#############################################################
## VLC
#############################################################
# Install support for creating soft subtitles in vlc videos (mp4)
sudo apt install gnome-subtitles
rm -fr ~/.cache/gstreamer-1.0/* # If error opennig file.
gnome-subtitles
#############################################################
## Vue - General
#############################################################
# Vue shorthand (shortcuts)
@click = v-on:click
:value = v-bind:value
# Check Vue version
npm v vue
# Create Vue CLI app
vue create vue-first-app
# Run Vue server (start)
cd vue-first-app
npm run serve
#
# The npm run commands can be found in:
package.json /"scripts":
#
# Defaut script commands:
serve
build
lint
# Missing Node modules folder
npm install
# Setup vue webpack (many files)
npm install --global vue-cli
vue init webpack
# Vue - Watch for changes to this.$refs
this.$watch(() => this.timerRef ? this.timerRef.timer.time : null, (newTime, oldTime) => {
console.log('Watched time: ', newTime, oldTime);
this.$refs.form.values.AccountedTime = newTime;
});
#############################################################
## WII
#############################################################
# Write files/games to WII.
https://mariokartwii.com/showthread.php?tid=121
https://www.gametdb.com/Wii/Search
#############################################################
## Windows Bugs
#############################################################
# Windows stuck in control mode (Tobias Wulf,windows bug)
Recovery: Most of the time, Ctrl + Alt + Del re-sets key status
to normal if this is happening. (Then press Esc to exit system screen.)
Another method: You can also press stuck key: so if you clearly see that
it is Ctrl which got stuck, press and release both left and right Ctrl .
# Why I have to press keys two times to get the ^ or ´ or ` (windows bug)
With this keyboard layout the ^ keystroke becomes a modifier to
enabling entering of special characters.
To get a single ^ character you will need to type ^+Space.
#############################################################
## Windows Command Prompt (DOS)
( run in 1.852 second using v1.01-cache-2.11-cpan-2398b32b56e )