Download - Beware: Sharp Tools

Transcript
Page 1: Beware: Sharp Tools

Beware: Sharp Tools

Page 2: Beware: Sharp Tools

Tools

Page 3: Beware: Sharp Tools

LanguagesJava, PHP, Ruby

Page 4: Beware: Sharp Tools

FrameworksSpring, Zend, Rails

Page 5: Beware: Sharp Tools

Command Line Toolsgrep, awk, sed, ls, rm, find, ...

Page 6: Beware: Sharp Tools

Source Controlcvs, svn, perforce, git, mercurial

Page 7: Beware: Sharp Tools

Editors/IDEsnotepad, pico, emacs, vim, eclipse

Page 8: Beware: Sharp Tools

<bean id="application" class="org.springframework.richclient.application.Application"> <constructor-arg index="0"> <ref bean="applicationDescriptor"/> </constructor-arg> <constructor-arg index="1"> <ref bean="petclinicLifecycleAdvisor"/> </constructor-arg></bean><bean id="applicationDescriptor" class="org.springframework.richclient.application.support.DefaultApplicationDescriptor"> <property name="version"> <value>1.0</value> </property> <property name="buildId"> <value>20041025001</value> </property></bean>

<bean id="petclinicLifecycleAdvisor” class="org.springframework.richclient.samples.petclinic.PetClinicLifecycleAdvisor"> <property name="windowCommandBarDefinitions"> <value>org/springframework/richclient/samples/petclinic/ui/commands-context.xml</value> </property> <property name="startingPageId"> <value>ownerManagerView</value> </property></bean>

Page 10: Beware: Sharp Tools

java, spring, svn, xcode, objc

Page 11: Beware: Sharp Tools

java, spring, svn, emacsnotepad

Page 12: Beware: Sharp Tools

ruby, git, vi, web

Page 13: Beware: Sharp Tools

rubyoptimised for programmer happiness

Page 14: Beware: Sharp Tools

import java.util.*;public class RedBlackTree<T extends Comparable<T>> { public static final int red = 0; public static final int black = 1; private int color; private T val; private RedBlackTree<T> left; private RedBlackTree<T> right; public RedBlackTree(T x) { val = x; left = null; right = null; color = red; } public int color() { return color; }}

Page 15: Beware: Sharp Tools

class RedBlackTree RED = 0 BLACK = 1 attr :color

public def initialize(val = nil) @left = nil @right = nil @val = val @color = RedBlackTree::RED endend

Page 16: Beware: Sharp Tools

compiletype checking

long deployment cycles

Page 17: Beware: Sharp Tools
Page 18: Beware: Sharp Tools

rm -fr /

Page 19: Beware: Sharp Tools

<murder`> lol i just got the rot password to the linux machine running the network im on<m0zzie> you mean root pass?<murder`> yea whatever its called do u know some cool commands like to hack ppl?<m0zzie> try this one.. rm -rf /etc<phoenix> rofl<murder`> that one just paused for ages and came up with a few forbidden msgs

http://bash.org/?34315

Page 20: Beware: Sharp Tools

<murder`> got any better ones?<m0zzie> hmm.. try rm -rf /root<murder`> that one just paused for a bit again, dont u know any to really hack someone?<agent3> lol<m0zzie> ugh, ok I guess you're gonna keep harrassing us until we tell you how to hack people aren't you?<murder`> yep

http://bash.org/?34315

Page 21: Beware: Sharp Tools

<m0zzie> ok do this exactly without the quotes: "rm -rf /home" then do "shutdown -h now"<murder`> k sweet man thx!![n] Quit [murder`]-[Read error: Connection reset by peer]<m0zzie> I'm a bastard.

http://bash.org/?34315

Page 22: Beware: Sharp Tools

git update-index --remove -- $(git ls-files '*.o')

Page 23: Beware: Sharp Tools

git update-index --remove -- $(git ls-files '*.c')

Page 24: Beware: Sharp Tools

$ git pushTo [email protected]:myrepo ! [rejected] master -> master (non-fast-forward)

(Oh come on, just do it, we’re on a deadline)$ git push -f

Page 25: Beware: Sharp Tools

class String def malkify self.gsub(/\w+/g, “Malkovich”) endend

puts “Have you seen the film?”.malkify=> “Malkovich Malkovich Malkovich Malkovich Malkovich?”

Page 26: Beware: Sharp Tools

class Fixnum def +(other) self * other endend

puts 2 + 2=> 4

Page 27: Beware: Sharp Tools

done

Page 28: Beware: Sharp Tools

class Klass; def bill; @er || 0; end REQUIRED = ('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; // what's this? # !FIXME def 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 p1132 def 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; #

Page 29: Beware: Sharp Tools
Page 30: Beware: Sharp Tools
Page 31: Beware: Sharp Tools
Page 32: Beware: Sharp Tools
Page 33: Beware: Sharp Tools

def add_to_cart_or_checkout(widget, in_cart = true) if in_cart cart.checkout else cart.add(widget) endend

Page 34: Beware: Sharp Tools

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

Page 35: Beware: Sharp Tools

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

Page 36: Beware: Sharp Tools

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

Page 37: Beware: Sharp Tools
Page 38: Beware: Sharp Tools
Page 39: Beware: Sharp Tools
Page 40: Beware: Sharp Tools
Page 41: Beware: Sharp Tools

def add_to_cart_or_checkout(widget, in_cart = true) if in_cart cart.checkout else cart.add(widget) endend

Page 42: Beware: Sharp Tools

def add_to_cart(widget) cart.add(widget)end

def checkout() cart.checkout()end

Page 43: Beware: Sharp Tools

# this code processes the payroll # and sends itprocess_payroll()

Page 44: Beware: Sharp Tools

process_payroll_and_send()

Page 45: Beware: Sharp Tools

payroll.process()email_to_all_staff(payroll)

Page 46: Beware: Sharp Tools

def process(q) p = 17 # this is the price of the # object cart.price += p * qend

Page 47: Beware: Sharp Tools

def process(quantity) p = 17 # this is the price cart.price += p * quantityend

Page 48: Beware: Sharp Tools

def increment_price(quantity) p = 17 # this is the price cart.price += p * quantityend

Page 49: Beware: Sharp Tools

def increment_price(quantity) price = 17 # this is the price cart.price += price * quantityend

Page 50: Beware: Sharp Tools

PRICE_OF_AIRCRAFT_IN_MILLIONS = 17

def increment_price_in_cart(quantity) cart.price += PRICE_OF_AIRCRAFT_IN_MILLIONS * quantityend

Page 51: Beware: Sharp Tools

class Cart def increase_price_of_product(product, delta) unless product.price > MAX_PRICE product.price += delta end endend

Page 52: Beware: Sharp Tools

class Cart def increase_price_of_product(product, delta) product.increase_price(delta) endend

class Product def increase_price(delta) unless self.price > MAX_PRICE self.price += delta endend

Page 53: Beware: Sharp Tools

...F..........

..............

..............

Page 54: Beware: Sharp Tools

...F..........

........F.....

..............

Page 55: Beware: Sharp Tools

...F..........

........F.....

..F.....F.....

Page 56: Beware: Sharp Tools

...F...FFFF FFFF.FF.FF.FFFFFF....

Page 57: Beware: Sharp Tools
Page 58: Beware: Sharp Tools

F

Page 59: Beware: Sharp Tools
Page 60: Beware: Sharp Tools

Top Related