Monkey patch

A monkey patch is a way to extend or modify the run-time code of dynamic languages without altering the original source code. This process has also been termed duck punching and shaking the bag.

The term monkey patch seems to have come from an earlier term, guerrilla patch,[2] which referred to changing code sneakily at runtime.

In Ruby, Python,and many other dynamic programming languages, the term monkey patch only refers to dynamic modifications of a class or module at runtime, motivated by the intent to patch existing third-party code as a workaround to a bug or feature which does not act as desired.

  • define a class method inside a class has defined already.

http://metalelf0dev.blogspot.com/2010/04/ruby-mixin-and-monkey-patching-examples.html

Advertisements

basic data structure APIs

  • Array has member length, String has a function length()
  • initialize a variable even you are sure that u assign a value later; it might be uninitialized.
  • HashMap:
  • String
    • public char charAt(int index)
    • substring(int beginIndex, int endIndex) 
      • endIndex — the end index, exclusive.
      • beginIndex -- the begin index, inclusivehttps://myrubylearning.wordpress.com/wp-admin/post.php?post=1184&action=edit
    • boolean isEmpty()
    • String is immutable. Char array is not. A string is implemented with a char array underneath but every time you try to modify it (like with concatenation, replace etc.) it gives you a new String object.
  • queue
    • peek()
      Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
    • poll()
      Retrieves and removes the head of this queue, or returns null if this queue is empty.
    • add(E e)
      Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
    • isEmpty() or size()  ==0 to tell if the queue is empty or not
    • LinkedList is an extention of queue; has similar API of queue
  • ArrayList
    • get(int index)
      Returns the element at the specified position in this list.
    • add(E e)
      Appends the specified element to the end of this list.
    • remove(int index)
      Removes the element at the specified position in this list.
    • contains(Object o)
      Returns true if this list contains the specified element.
    • size()
  • Integer.MAX_SIZE
  • Queue<TreeNode> nodes = new LinkedList<TreeNode>();
  • Stack<TreeNode> nodes = new Stack<TreeNode>();
  • Queue
    boolean add(E e)

    Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
    E element()

    Retrieves, but does not remove, the head of this queue.
    boolean offer(E e)

    Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
    E peek()

    Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
    E poll()

    Retrieves and removes the head of this queue, or returns null if this queue is empty.
  • Stack
    boolean empty() // isEmpty() also works. remember isEmpty() which exists for all collections

    Tests if this stack is empty.
    E peek()

    Looks at the object at the top of this stack without removing it from the stack.
    E pop()

    Removes the object at the top of this stack and returns that object as the value of this function.
    E push(E item)

    Pushes an item onto the top of this stack.

sql injection

SQL injection is a code injection technique, used to attack data driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).[1] SQL injection must exploit a security vulnerability in an application’s software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vector for websites but can be used to attack any type of SQL database.

see the examples from wiki http://en.wikipedia.org/wiki/SQL_injection

salt

Salt (cryptography)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In cryptography, a salt is random data that are used as an additional input to a one-way function that hashes a password or passphrase.[1] The primary function of salts is to defend against dictionary attacks and pre-computed rainbow table attacks.

A new salt is randomly generated for each password. In a typical setting, the salt and the password are concatenated and processed with a cryptographic hash function, and the resulting output (but not the original password) is stored with the salt in a database. Hashing allows for later authentication while defending against compromise of the plaintext password in the event that the database is somehow compromised.

Web application implementations

It is common for a web application to store in a database the hash value of a user’s password. Without a salt, a successful SQL injection attack may yield easily crackable passwords. Because many users re-use passwords for multiple sites, the use of a salt is an important component of overall web application security.[2] Some additional references for using a salt to secure password hashes in specific languages (PHP, .NET, etc.) can be found in the external links section below.

american games

GameWorks is a chain of location-based entertainment venues featuring video games, simulators, prizes, and a full-service bar and restaurant. There are currently five GameWorks venues throughout the U.S. The first GameWorks opened in Downtown Seattle in March 1997.

A LAN party is a temporary gathering of people with computers or game consoles, between which they establish a local area network (LAN), primarily for the purpose of playing multiplayer video games. The size of these networks may vary from the very small (two people) to very large installations. Small parties can form spontaneously, but large ones usually require a fair amount of planning and preparation. As of 2010, the world record for the size of a LAN party is 12,754 connected systems, set at DreamHack, in Jönköping, Sweden.[1]

 

wget

GNU Wget (or just Wget, formerly Geturl) is a computer program that retrieves content from web servers, and is part of the GNU Project. Its name is derived from World Wide Web and get. It supports downloading via HTTP, HTTPS, and FTP protocols.

http://en.wikipedia.org/wiki/Wget

Using Wget

Basic usage

Typical usage of GNU Wget consists of invoking it from the command line, providing one or more URLs as arguments.

# Download the title page of example.com to a file
# named "index.html".
wget http://www.example.com/

# Download Wget's source code from the GNU ftp site.
wget ftp://ftp.gnu.org/pub/gnu/wget/wget-latest.tar.gz

More complex usage includes automatic download of multiple URLs into a directory hierarchy.

# Download *.gif from a website
# (globbing, like "wget http://www.server.com/dir/*.gif", only works with ftp)
wget -e robots=off -r -l1 --no-parent -A.gif ftp://www.example.com/dir/

# Download the title page of example.com, along with
# the images and style sheets needed to display the page, and convert the
# URLs inside it to refer to locally available content.
wget -p -k http://www.example.com/

# Download the entire contents of example.com
wget -r -l 0 http://www.example.com/