App-Cheats

 view release on metacpan or  search on metacpan

cheats.txt  view on Meta::CPAN

ar -rav 1.o libMy.a 3.o 4.o 5.o
#
# Order is not quite expected since the insert location
# is constant ("|" below).
# 1.o | 5.o 4.o 3.o 2.o

# Update a member of an archive of if a newer file exists
ar -ruv libMy.a 1.o

# Alternate syntax to link to an archive library
-lABC          # looks for libABC.so, then for libABC.a
-l:libABC.a    # Looks for libABC.a (more explicit, but simplier)


#############################################################
## C,CPP - String
#############################################################

# Convert anything to a string in cpp using string streams (DWORD,int)
#include <string>
#include <sstream>

cheats.txt  view on Meta::CPAN

Brief is better than long-winded.
But readability counts.
So use whitespace to enhance readability.
Not because you're required to.
Practicality always beats purity.
In the face of ambiguity, do what I mean.
There's more than one way to do it.
Although that might not be obvious unless you're a Monk.
At your discretion is better than not at all.
Although your discretion should be used judiciously.
Just because the code looks clean doesn't mean it is good.
Just because the code looks messy doesn't mean it is bad.
Reuse via CPAN is one honking great idea -- let's do more of that

# Zen of Perl
According to Larry Wall, there are three great virtues of a programmer; Laziness, Impatience and Hubris
- Laziness:
    - The quality that makes you go to great effort to reduce overall energy expenditure.
    - It makes you write labor-saving programs that other people will find useful and
    - document what you wrote so you don't have to answer so many questions about it.
- Impatience:
    - The anger you feel when the computer is being lazy.

cheats.txt  view on Meta::CPAN


# Override a class method that is defined in a role (Moose,around)
# Approach 4 - Moose::around class.
#
+ Moose::around $Package, $Method => sub {
+    my ($Orig,$Self,%Param) = @_;
+    $Orig->($Self,%Param);
+    return 1;
+ };

# The basic Moose type hierarchy looks like this (perl,OOP):
Any
    Item
        Bool
        Maybe[`a]
        Undef
        Defined
            Value
                Str
                    Num
                        Int

cheats.txt  view on Meta::CPAN

perl -MOpcode=opdump -e 'opdump shift' ATTRIBUTE

# Run code to evaluate arithemetic
perl -MSafe -le '$comp=Safe->new; $comp->deny(qw(:default)); $comp->permit(qw(padany lineseq const add leaveeval subtract)); while(<>){chomp; $res=$comp->reval($_) or warn $@ and next; print "$_ = $res"}'


#############################################################
## Perl Modules - Scalar::Util
#############################################################

# perl looks_like_number example.
perl -MScalar::Util=looks_like_number -E 'printf("%s: %s\n", $_, looks_like_number($_)) for qw/ 1 cat bat 1.5 1e10 4.5 fat /'
1: 1
cat:
bat:
1.5: 1
1e10: 1
4.5: 1
fat:

# Example of using a dualvar in perl.
use Scalar::Util 'dualvar';



( run in 0.306 second using v1.01-cache-2.11-cpan-64827b87656 )