beware: sharp tools

Download Beware: Sharp Tools

Post on 24-May-2015

241 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

  • 1. Beware: Sharp Tools

2. Tools 3. Languages Java, PHP, Ruby 4. Frameworks Spring, Zend, Rails 5. Command Line Toolsgrep, awk, sed, ls, rm, nd, ... 6. Source Control cvs, svn, perforce, git, mercurial 7. Editors/IDEsnotepad, pico, emacs, vim, eclipse 8. 1.020041025001org/springframework/richclient/samples/petclinic/ui/commands-context.xmlownerManagerView 9. public class Person{private Person person;...}...// --- Create an Employee person ---Person emplPerson = new Person();...// --- Create a Customer person ---Person custPerson = new Person(); 10. java, spring, svn, xcode, objc 11. java, spring, svn, emacs notepad 12. ruby, git, vi, web 13. rubyoptimised for programmer happiness 14. import java.util.*;public class RedBlackTree> {public static final int red= 0;public static final int black = 1;private int color;private T val;private RedBlackTree left;private RedBlackTree right;public RedBlackTree(T x) {val= x;left = null;right= null;color = red;}public int color() {return color;}} 15. class RedBlackTreeRED = 0BLACK = 1attr :colorpublicdef initialize(val = nil)@left= nil@right = nil@val = val@color = RedBlackTree::REDendend 16. compile type checkinglong deployment cycles 17. rm -fr / 18. lol i just got the rot passwordto the linux machine running the network imon you mean root pass? yea whatever its called do u knowsome cool commands like to hack ppl? try this one.. rm -rf /etc rofl that one just paused for ages andcame up with a few forbidden msgshttp://bash.org/?34315 19. got any better ones? hmm.. try rm -rf /root that one just paused for a bitagain, dont u know any to really hacksomeone? lol ugh, ok I guess youre gonna keepharrassing us until we tell you how to hackpeople arent you? yephttp://bash.org/?34315 20. ok do this exactly without thequotes: "rm -rf /home" then do "shutdown -hnow" k sweet man thx!![n] Quit [murder`]-[Read error: Connectionreset by peer] Im a bastard.http://bash.org/?34315 21. git update-index --remove -- $(git ls-les *.o) 22. git update-index --remove -- $(git ls-les *.c) 23. $ git pushTo git@github.com:myrepo ! [rejected] master -> master (non-fast-forward)(Oh come on, just do it, were on a deadline)$ git push -f 24. class Stringdef malkify self.gsub(/w+/g, Malkovich)endendputs Have you seen the lm?.malkify=> Malkovich Malkovich Malkovich MalkovichMalkovich? 25. class Fixnumdef +(other) self * otherendendputs 2 + 2=> 4 26. done 27. class Klass; def bill; @er || 0; endREQUIRED = (A..D).inject({}) {|hash, ltr| (ltr == A ? (hash[ltr]={:a=>3, :x=>20}) :(ltr == B ? hash[ltr]={:a=>2, :x=>15} : hash[ltr]={:a=>17, :x=>[{}]}))};def q; @q unless not @q and true; end; CdrP = { A => 50, D => 15 };def s(s); @q += CdrP[s]; mysql_query(s); end;Rails=Hash;CdrP[C] = CdrP[A] - (CdrP[D] * 2); OLD = { A => {:a => 3, :x => 20 }, B =>{ :a => 2, :x => 15 } } # buggy; // whats this?# !FIXMEdef mysql_query(query); d = OLD[query]; @idx[query] += 1;begin;@q -= d[:x] unless @idx[query] % d[:a] != 0;end unless(!d) unless false and bill;end rescue(me) or $die;;#!IMPORTANT READ SPEC DOC p1132def initialize; @er = $stream = @q = 0; @idx = Rails.new(bill || $stream); CdrP[B]= CdrP[A] - CdrP[C]; end;end;#if foo=mysql_query(select * from users); print foo; end;# 28. def add_to_cart_or_checkout(widget, in_cart = true) if in_cart cart.checkout else cart.add(widget) endend 29. def add_to_cart_or_checkout(widget,in_cart = true, discount_offer = true) if in_cart cart.checkout elsif discount_offer cart.add(widget, widget.price *widget.discount) endend 30. def add_to_cart_or_checkout(widget, in_cart = true, discount_offer = true, discount = 0.65) if in_cart cart.checkout elsif discount_offer cart.add(widget, widget.price * (discount !=1.0 ? discount : widget.discount) endend 31. def add_to_cart_or_checkout(widget, in_cart = true, discount_offer = true, discount = 0.65, coupon = ) if in_cart cart.checkout elsif discount_offer cart.add(widget, widget.price * (discount != 1.0 ? discount : widget.discount)) if coupon != cart.apply_coupon(coupon, (discount != 1.0 ? discount : widget.discount)) end endend 32. def add_to_cart_or_checkout(widget, in_cart = true) if in_cart cart.checkout else cart.add(widget) endend 33. def add_to_cart(widget)cart.add(widget)enddef checkout() cart.checkout()end 34. # this code processes the payroll# and sends itprocess_payroll() 35. process_payroll_and_send() 36. payroll.process()email_to_all_staff(payroll) 37. def process(q) p = 17 # this is the price of the # object cart.price += p * qend 38. def process(quantity) p = 17 # this is the price cart.price += p * quantityend 39. def increment_price(quantity) p = 17 # this is the price cart.price += p * quantityend 40. def increment_price(quantity) price = 17 # this is the price cart.price += price * quantityend 41. PRICE_OF_AIRCRAFT_IN_MILLIONS =17def increment_price_in_cart(quantity) cart.price += PRICE_OF_AIRCRAFT_IN_MILLIONS * quantityend 42. class Cartdef increase_price_of_product(product, delta) unless product.price > MAX_PRICEproduct.price += delta endendend 43. class Cartdef increase_price_of_product(product, delta) product.increase_price(delta)endendclass Productdef increase_price(delta) unless self.price > MAX_PRICEself.price += delta endend 44. ...F...................................... 45. ...F..................F................... 46. ...F..................F.......F.....F..... 47. ...F...FFFFFFFF.FF.FF.FFFFFF.... 48. F