Download presentation
Presentation is loading. Please wait.
Published byAmelia Mitchell Modified over 10 years ago
1
20 Topics in 20 Minutes Eric Wastl @topaz2078 Software Architect Synacor BarCamp Buffalo 2013
2
(Synacor)
3
(Buffalo)
4
(Canada)
5
PHP CSS3 Perl Java JavaScript Linux Apache MySQL Git HTML5 Ruby Lua Bash ActiveMQ Kafka Hadoop Cassandra VMWare jQuery
6
Graphviz digraph G { a -> b b -> c b -> d c -> e c -> f }
7
Graphviz digraph G { concentrate = true; labeljust = r; subgraph cluster_internet { label = "internet" client_a; client_b; client_c } subgraph cluster_internal { label = "internal" node [shape=box] loadbalancer -> server01 loadbalancer -> server02 loadbalancer -> svr_spare [style=dashed] database [shape=box3d] server01 -> database server02 -> database svr_spare -> database [style=dashed] } client_a -> loadbalancer client_b -> loadbalancer client_c -> loadbalancer }
8
Graphviz
11
Perl: userland syntax sugar sub forever { my $code = shift; while (1) { $code->(); } forever(sub { print "round and round...\n"; });
12
Perl: userland syntax sugar sub forever (&) { my $code = shift; while (1) { $code->(); } forever { print "round and round...\n"; };
13
Perl: userland syntax sugar sub if2 (&@) { while (@_) { my $cond = shift; my $code = shift; if ($cond->()) { $code->(); last; } sub then2 (&@) { @_ } sub elsif2 (&@) { @_ } sub else2 (&) { sub{1}, $_[0] }
14
Perl: userland syntax sugar my $x = 3; if2 { $x == 1 } then2 { print "x was 1\n"; } elsif2 { $x == 2 } then2 { print "x was 2\n"; } else2 { print "x was something else\n"; }
15
Polar coordinates y x r t x = r * cos(t) y = r * sin(t) t = atan2(y, x) r = sqrt(x*x + y*y)
16
Operators: Arity To how many things does the operator apply? ! x <- 1: unary a + b <- 2: binary c ? t : f <- 3: ternary
17
Operators: Precedence Given different operators, which goes first? 1 + 2 * 3 1 + (2 * 3) <- * is higher (1 + 2) * 3 <- + is higher
18
Operators: Associativity Given operators of the same precedence, in what order do they apply? a – b – c a – (b – c) <- right- associative (a – b) – c <- left-associative
19
Operators: Fixity To which operands does the operator apply? ! a <- prefix (unary) a ++ <- postifx (unary) a + b <- infix (binary) a b + <- postfix (binary!) + a b <- prefix (binary!)
20
Array mapping in PHP/JS/Perl $input = array(1, 2, 3, 4, 5); function square($v) { return $v*$v; } $output = array_map("square", $input); // $output is array(1, 4, 9, 16, 25)
21
Array mapping in PHP/JS/Perl input = [1,2,3,4,5]; output = input.map(function(v){ return v*v; }); // output is [1, 4, 9, 16, 25]
22
Array mapping in PHP/JS/Perl @input = (1, 2, 3, 4, 5); @output = map { $_*$_ } @input; # @output is (1, 4, 9, 16, 25)
23
Array mapping in PHP/JS/Perl function square($v) { return $v*$v; } $output = array_map("square", $input); output = input.map(function(v){ return v*v; }); @output = map { $_*$_ } @input;
24
PHP: Comparison Operators $a $b
25
PHP: Comparison Operators $a $b
26
PHP: Comparison Operators
27
$ cat circular.php <?php $a = INF; $b = array(); $c = (object)array(); var_dump($a < $b); var_dump($b < $c); var_dump($c < $a); $ php circular.php bool(true)
28
$array = array( INF, array(), (object)array(), ); sort($array); is_sorted($array); //false
29
Git Basics $ git init $ git clone git://... $ git add stuff.c thing.php pants.pl $ git commit –am new stuff $ git push $ git pull
30
CAP Theorem A distributed system cannot simultaneously be consistent, available, and partition-tolerant. consistent – only returns correct answer available – always returns an answer partition-tolerant – works during network failure Node 1 x = 0 Node 2 x = 0 x = 1
31
CAP Theorem A distributed system cannot simultaneously be consistent, available, and partition-tolerant. consistent – only returns correct answer available – always returns an answer partition-tolerant – works during network failure Node 1 x = 0 Node 2 x = 0 x? x = 1 ? ? ?
32
Perl Inline::* Modules use Inline Java => <<'END'; class Java_Class { public Java_Class() {} public int sum(int a, int b) { return a + b; } END my $java_class = new Java_Class(); print "Java: ".$java_class->sum(19, 23). "\n";
33
Perl Inline::* Modules use Inline Python => <<'END'; def python_sum(a, b): return int(a + b) END print "Python: ". python_sum(19, 23). "\n";
34
Perl Inline::* Modules use Inline Lua => <<'END'; function lua_sum(a, b) return a + b end END print "Lua: ". lua_sum(19, 23). "\n";
35
Perl Inline::* Modules use Inline CPP => <<'END'; class Cpp_Class { public: Cpp_Class() {} //nothing to construct ~Cpp_Class() {} //nothing to destruct int sum(int a, int b) { return a + b; } }; END my $cpp_class = new Cpp_Class(); print "CPP: ". $cpp_class->sum(19, 23). "\n";
36
Perl Inline::* Modules use Inline C => <<'END'; int c_sum(int a, int b) { return a + b; } END print "C: ". c_sum(19, 23). "\n";
37
Perl Inline::* Modules use Inline Basic => <<'END'; 10 DEF FNBASICSUM(A,B) = A + B END print "BASIC: ". FNBASICSUM(19, 23). "\n";
38
Perl Inline::* Modules use Inline ASM => 'nasm', ASFLAGS => '-f elf', PROTO => {asm_sum => 'int(int,int)'}; GLOBAL asm_sum SECTION.text asm_sum: mov eax,[esp+4] sum eax,[esp+8] ret END print "ASM: ". asm_sum(0, 23). "\n";
39
Perl Inline::* Modules print "Sum: ". $java_class->sum( asm_sum( python_sum(4, 7), $cpp_class->sum(6, 3) ), c_sum( FNBASICSUM(5, 8), lua_sum(0, 9) ). "\n";
41
Vanilla JS Speed Advantages
43
Screen Basics Keep running console programs if you log out or get disconnected! Run several things at once from one connection! (A billion other reasons I don't have time to talk about!)
44
Screen Basics Start a new session $ screen List sessions $ screen –ls Reconnect to a session $ screen -dr
45
Screen Basics ^A (ctrl-A) talks to screen ^A c New window ^A ^A Switch to previous window ^A 1 Switch to specific window ^A " List windows ^A A Rename window ^A d Detach from screen ^A a Send literal ^A
46
Fractals in your Terminal! +-.- -. -+-.+-..--- ++=....-+-.- -==+.-- -...........+=--...+.--.....+++-. +&+ +=--+--.. +.-.+-..---+=+..+-+....-+---. +++-++.-..--+*. -. -=.-.---.*+... -- --+.-.-- +&..*-+=*#+.+......+...--+-- - +-.--++. --*&=+.-.---.- +*-.-.-.= ----+.--.-.-..+.+-.........=-+*+- -.---..-. ---++=*+.. -. -. --...-- +-.....=. ==+---+=-.+ ++.......-....-=+...-. -. +.-.=.. -.--+=+*-... -...+==. =+-..=.-..-+*=++-.=..-.-+-.+-*-.- --..+..-+=*=...-.-+--.-..-+**-+- &=--.-..-.-++.=---.+......-.---..-==- ++-=+-... *... --.- -.-..-- ++ +.---... -.+ -+....--&.+- -.-.--.-. ----.. -..-. https://github.com/topaz/perl-mandelbrot $./mandelbrot.pl -x -.7435669 -y.1314023 -w.003 -q --lines=24 --cols=80 -v -d 600
47
Perl Symbol Table Hackery package Greeter; sub greet { print "Hello, $_[0]!\n"; } # elsewhere, deep in some call stack Greeter::greet("Fred"); Hello, Fred!
48
Perl Symbol Table Hackery my $old_greet = \&Greeter::greet; *Greeter::greet = sub { print "$_[0]? Nope!\n"; return $old_greet->("pants"); }; # same elsewhere as before Fred? Nope! Hello, pants!
49
Perl Symbol Table Hackery BEGIN { *CORE::GLOBAL::time = sub { return 42; }; } print "It is ".localtime(time)."\n"; It is Wed Dec 31 19:00:42 1969
50
Easy Bash Tips You can search your history for a command by typing ctrl-R and any substring. You can iterate over lists: $ for f in dir/*.log; do grep -i error $f | wc -l; done You can expand multiple similar words: $ cat {access,error}.log -> $ cat access.log error.log $ mv pants{,.ext} -> $ mv pants pants.ext
51
PHP: Adding () can change meaning function &r(&$v){return $v;} $b = array("c"); array_pop( ( r($b) ) ); print_r($b); array_pop( r($b) ); print_r($b); Array( [0] => c ) Array( )
52
Color-grapheme Synesthesia A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 ! @ # $ % ^ & * <
53
Color-grapheme Synesthesia A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 ! @ # $ % ^ & * <
54
Color-grapheme Synesthesia
55
function square($v) { return $v * $v; } $output = array_map("square", $input); output = input.map(function(v){ return v*v; }); @output = map { $_*$_ } @input;
56
Color-grapheme Synesthesia function square($v) { return $v * $v; } $output = array_map("square", $input); output = input.map(function(v){ return v*v; }); @output = map { $_*$_ } @input;
57
Eric Wastl @topaz2078 ewastl@synacor.com phpsadness.com vanilla-js.com
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.