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 Person < ActiveRecord::Base | |
| before_update :before_update_changes | |
| attr_accessor :update_changes | |
| def before_update_changes | |
| @update_changes = changes | |
| 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
| def getUriQuery(url) | |
| dots = url.scan(/\./) | |
| dotsSize = dots.size | |
| httpRegex = '(?![https?:\/\/])' | |
| minimumUriRegex = '([^.]+\.[^.]+\...|[^.]+\.[^.]+)$' # Credit to @blaines | |
| dotsSize -= 1 | |
| appendableRegex = '[^.]+\.'*dotsSize | |
| customUriRegex = minimumUriRegex.insert(18, appendableRegex).insert(1, appendableRegex) | |
| fullUriRegex = httpRegex + customUriRegex | |
| uriToQuery = url.slice(Regexp.new(fullUriRegex)) |
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
| search.html.erb | |
| <%= form_tag(:action => "search") do %> | |
| <%= label_tag(:q, "Search for:") %> | |
| <%= text_field_tag(:wth) %> | |
| <%= submit_tag("Search") %> | |
| <% 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
| Answers new method | |
| def new | |
| @survey = Survey.find(params[:survey_id]) | |
| @questions = @survey.questions.all | |
| @answers = @questions.map{|q| q.answers.build} | |
| respond_to do |format| | |
| format.html # new.html.erb | |
| format.xml { render :xml => @answer } | |
| 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
| def new | |
| @questions = Question.find_all_by_survey_id(params[:survey_id]) | |
| @answers = @questions.map{|q| q.answers.build} | |
| respond_to do |format| | |
| format.html # new.html.erb | |
| format.xml { render :xml => @answer } | |
| 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
| def index | |
| @details = Details.where(["id != ?", 0]) | |
| @detail_params = Details.attr_accessible.to_a | |
| for detail_param in @detail_params | |
| if params[detail_param] | |
| @details = @details.where(["#{detail_param} = ?", params[detail_param.intern]]) | |
| end | |
| end | |
| @user_ids = @details.select(:user_id).map{|d| d.user_id} | |
| @users = User.find(@user_ids) |
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
| SIGN UP | |
| curl -H "Content-Type:application/json" -H "Accept:application/json" \ | |
| -d "{\"user\":{\"password_confirmation\":\"12345678\", \"password\":\"12345678\", \"email\":\"[email protected]\"}}" \ | |
| http://your_server.com/users | |
| SIGN IN | |
| curl -H "Content-Type:application/json" -H "Accept:application/json" \ | |
| -d "{\"user\":{\"remember_me\":\"0\", \"password\":\"12345678\", \"email\":\"[email protected]\"}}" \ | |
| http://your_server.com/users/sign_in |
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
| //Customise Backbone.sync to work with Titanium rather than jQuery | |
| Backbone.sync = (function() { | |
| var methodMap = { | |
| 'create': 'POST', | |
| 'read' : 'GET', | |
| 'update': 'PUT', | |
| 'delete': 'DELETE' | |
| }; | |
| var xhr = Ti.Network.createHTTPClient({ timeout: 5000 }); |
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
| /* | |
| Triangle with Shadow | |
| */ | |
| .triangle-with-shadow { | |
| width: 50px; | |
| height: 200px; | |
| position: relative; | |
| overflow: hidden; | |
| box-shadow: 0 16px 10px -17px rgba(0,0,0,0.5); |
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
| export default TechStackCheckboxes extend Component { | |
| createTechStackCheckboxes() { | |
| // starts with unchecked box | |
| const isAllChecked = false; | |
| // map out techStackItems and crate input boxes for each item | |
| return this.props.techStackItems.map((item) => ( | |
| <div key={item}> | |
| <input | |
| key={item} |
OlderNewer