App-Cheats
view release on metacpan or search on metacpan
# Perl Modules - B::Deparse
# explain what a perl program is doing (simply)
perl -MO=Deparse -e 'print 111'
#############################################################
## Perl Modules - bignum
#############################################################
# Convert big numbers into full form
# from scientific notation to expanded form
echo "$b" | perl -Mbignum -lpe '$_ += 0'
#############################################################
## Perl Modules - binmode
#############################################################
# Using unicode in perl STDOUT
perl -CO script
perl -C script # Which is same as
$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
# 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(...)
.............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...
# 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'
# Frame Example (Ptk,Appendix B)
# HList Example (Ptk,Appendix B)
perl -MTk -MTk::HList -le '$h=tkinit->HList(-indent => 20)->pack; $h->add(qw/A -text a/); $h->add(qw/A.B -text a->b/); MainLoop'
# Label Example (Ptk,Appendix B)
# LabEntry Example (Ptk,Appendix B)
# Learn how to use Text indices (demo)
perl -MTk -le '%def=qw/-side left/; $mw=tkinit; $t=$mw->Text->pack; ($i,$d)=map{my $v; $mw->LabEntry(-label => "$_:", -textvariable => \$v, -labelPack => [%def])->pack(%def); \$v} qw/Index Data/; $mw->Button(-text => "INSERT", -command => sub{$t->ins...
# LabFrame Example (Ptk,Appendix B)
# ListBox Example (Ptk,Appendix B)
# MainWindow Example (Ptk,Appendix B)
# Menu Example (Ptk,Appendix B)
# MenuButton Example (Ptk,Appendix B)
:set
# View all options (Vim)
:set all
# Check the value/status of an option (Vim)
:set <option>?
:set ic? # noignorecase
# Show full path, get the head, then the tail (Vim)
:echo expand("%:p:h:t")
# Toggle an option (Vim)
:set number!
:set number!
# View status of current file (filename, Vim)
Control + G
#############################################################
#############################################################
## Vim Syntax
#############################################################
# Comment lines in vimrc should start with "
" this is a comment
# Name of file that is opened in vim
let _curfile = expand("%:t")
# Show line numbers in vim (vimrc)
set number
# Vim resource (vimrc) file. other features.
set nowrap
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40
set cursorcolumn
( run in 0.820 second using v1.01-cache-2.11-cpan-5b529ec07f3 )