This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| include PaymentContext | |
| def initialize | |
| @user_name = "New Foo User" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html | |
| # are hooks into the life cycle of an Active Record object that allow you to trigger logic | |
| # before or after or around an alteration of the object state. | |
| # types: | |
| ## method reference (symbol) | |
| class User < ActiveRecord::Base | |
| before_destroy :deactivate_payment_methods | |
| has_many :payment_methods | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://guides.rubyonrails.org/active_record_validations.html | |
| # ensure that only valid data is saved into the database | |
| # comes in forms of: | |
| ## database constraints | |
| ## client-side validations | |
| ## controller-level validations | |
| # conditional validations | |
| class Order < ActiveRecord::Base | |
| validates :card_number, presence: true, if: :paid_with_card? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # what should go into your app's bin folder? | |
| # http://reefpoints.dockyard.com/ruby/2012/02/14/love-your-lib-directory.html | |
| # What it's not : | |
| ## it's not a dump | |
| ## it's not an initializer | |
| # What it is: | |
| ## "Application specific libraries. Basically, any kind of custom code that | |
| ## doesn’t belong under controllers, models, or helpers. This directory is in the load path." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2 | |
| """ | |
| Author: takeshix <takeshix@adversec.com> | |
| PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org). | |
| Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP. | |
| """ | |
| import sys,struct,socket | |
| from argparse import ArgumentParser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'sinatra' | |
| gem 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Clone rbenv into ~/.rbenv | |
| git clone git@github.com:sstephenson/rbenv.git ~/.rbenv | |
| # Add rbenv to your PATH | |
| # NOTE: rbenv is *NOT* compatible with rvm, so you'll need to | |
| # remove rvm from your profile if it's present. (This is because | |
| # rvm overrides the `gem` command.) | |
| echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile | |
| exec $SHELL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Understainding Trie in Ruby | |
| #source https://github.com/kanwei/algorithms/blob/81987340f24edb7fd8ca60885b1f04d1907f8c03/lib/containers/trie.rb | |
| =begin rdoc | |
| A Trie is a data structure that stores key value pairs in a tree-like fashion. It allows | |
| O(m) lookup speed, where m is the length of the key searched, and has no chance of collisions, | |
| unlike hash tables. Because of its nature, search misses are quickly detected. | |
| Tries are often used for longest prefix algorithms, wildcard matching, and can be used to | |
| implement a radix sort. |
NewerOlder