1 / 57

20 Topics in 20 Minutes

20 Topics in 20 Minutes. Eric Wastl @topaz2078 Software Architect Synacor. BarCamp Buffalo 2013. (Synacor). (Buffalo). (Canada). Git. CSS3. Ruby. Perl. Hadoop. Bash. MySQL. VMWare. ActiveMQ. PHP. Kafka. Java. jQuery. JavaScript. Apache. Cassandra. Lua. HTML5. Linux.

kimn
Download Presentation

20 Topics in 20 Minutes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 20 Topics in 20 Minutes Eric Wastl @topaz2078 Software Architect Synacor BarCamp Buffalo 2013

  2. (Synacor)

  3. (Buffalo)

  4. (Canada)

  5. Git CSS3 Ruby Perl Hadoop Bash MySQL VMWare ActiveMQ PHP Kafka Java jQuery JavaScript Apache Cassandra Lua HTML5 Linux

  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

  9. Graphviz

  10. 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 t r y x t = atan2(y, x) r = sqrt(x*x + y*y) x = r * cos(t) y = r * sin(t)

  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 $a > $b

  25. PHP: Comparison Operators $a < $b $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) bool(true) 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 Node 2 x = 1 x = 1 x = 0 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 Node 2 x? x = 0 x = 0 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 => <<'END', AS => '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";

  40. Vanilla JS Speed Advantages

  41. Vanilla JS Speed Advantages

  42. 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!)

  43. Screen Basics Start a new session $ screen List sessions $ screen –ls Reconnect to a session $ screen -dr

  44. 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

  45. Fractals in your Terminal! $ ./mandelbrot.pl -x -.7435669 -y .1314023 -w .003 -q --lines=24 --cols=80 -v -d 600 +- .- -. -+-.+-. .--- ++=... .-+-.- -==+.-- -.. .... .....+=--...+.--.....+++-. +&+ +=--+--.. +.-.+-..---+=+..+-+....-+---. +++-++ .-..--+*. -. -=.-.---.*+ . . . -- --+.-.-- +&..*-+=*#+.+ . .....+ .. .--+-- - +-.--++. --*&=+.- .---.- +*-.-.-.= ----+.--.-.- . .+.+- ... . .....=-+*+- -.---..-. ---++=*+.. - . -. --.. .-- +-.. ...=. ==+---+=- .+ ++. ......-....-=+.. .-. -. +.-.=.. - .--+=+*-... -.. .+==. =+-..= .- ..-+*=++-.=. .-.-+- .+-*-.- --..+..-+=*=. ..-.-+--.-..-+**-+- &=--.-..-.-++.=--- .+ .. . .. .-.--- . .-==- ++-=+-. . . *... --.- -.- . .-- ++ +.---... - .+ -+....--&.+- - .-.-- .-. ----.. -..- . https://github.com/topaz/perl-mandelbrot

  46. Perl Symbol Table Hackery package Greeter; sub greet { print "Hello, $_[0]!\n"; } # elsewhere, deep in some call stack Greeter::greet("Fred"); Hello, Fred!

  47. 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!

  48. 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

  49. 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

More Related