App-Cheats
view release on metacpan or search on metacpan
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>
# -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.
# 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:
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
#############################################################
#############################################################
## 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',
);
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;
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
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')
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 -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
# 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)
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"
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
( run in 0.860 second using v1.01-cache-2.11-cpan-2398b32b56e )