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
| iex(10)> Process.alive? tile_pid | |
| true | |
| iex(11)> Process.register tile_pid, :foo | |
| ** (ArgumentError) argument error | |
| :erlang.register(:foo, #PID<0.163.0>) | |
| (elixir) lib/process.ex:333: Process.register/2 |
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
| tasks> mix compile | |
| Unchecked dependencies for environment dev: | |
| * cowboy (package) | |
| the dependency cowboy in mix.exs is overriding a child dependency: | |
| > In mix.exs: | |
| {:cowboy, "~> 1.0.0", [hex_app: :cowboy]} | |
| > In deps/phoenix/mix.exs: | |
| {:cowboy, "~> 0.10.0", [git: "git://github.com/extend/cowboy.git", optional: true]} |
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
| public class ValidateChildAttribute : ValidationAttribute { | |
| public override bool IsValid(object value) { | |
| if (value == null) return true; | |
| var isValid = IsItValid(value); | |
| if (!isValid) return false; | |
| if (value is IEnumerable) return ((IEnumerable)value).Cast<object>().All(IsItValid); | |
| return true; | |
| } |
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
| (function(jQuery) { | |
| jQuery.fn.validator = function(options) { | |
| var isEmpty = function(obj) { return obj == null || obj.length == 0; }; | |
| var opts = jQuery.extend(true, { // Allows for overriding any messages or validator functions | |
| wrapperClass: "invalid", messageClass: "message", useMessages: true, | |
| onValidation: null, onValidationFailed: null, // Callbacks which recieve an object containing the element and state { el: el, state: state } | |
| validateOn: "blur", // The jQuery events that cause validation to occur |
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
| Backbone.Model.prototype.save = (function(original) { | |
| return function(attrs, options) { | |
| var me = this; | |
| options = options || {}; | |
| var origSuccess = options.success; | |
| var wasNew = this.isNew(); | |
| options.success = function(model, response) { | |
| if (me.collection && !wasNew) { me.collection.trigger("update", me); } | |
| if (origSuccess) { origSuccess(model, response); } | |
| }; |
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
| Backbone.View.prototype.proxy = function(source, eventName, options) { | |
| if (!options) { options = {}; } | |
| var self = this; | |
| source.bind(eventName, function(args) { | |
| var name = options["proxyName"] || eventName; | |
| var newArgs = options["proxyArgs"] ? _.combine(args, options["proxyArgs"]) : args; | |
| self.trigger(name, newArgs); | |
| }); | |
| }; |
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
| module Mongoid | |
| module NumericIdentity | |
| module InstanceMethods | |
| def generate_identity | |
| id_attempt = (self.class.last.try(:id) || 0) + 1 | |
| dup_check = self.class.where(:id => id_attempt).first | |
| if dup_check.nil? | |
| self.id = id_attempt |
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
| task :deploy => ['deploy:push', 'deploy:restart', 'deploy:tag'] | |
| namespace :deploy do | |
| task :migrations => [:push, :off, :migrate, :restart, :on, :tag] | |
| task :rollback => [:off, :push_previous, :restart, :on] | |
| task :push do | |
| puts 'Deploying site to Heroku ...' | |
| puts `git push heroku` | |
| 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
| require 'benchmark' | |
| module Kernel | |
| alias old_require require | |
| def require(path) | |
| output = nil | |
| @required_files ||= [] | |
| benchmark = Benchmark.measure do | |
| output = old_require 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
| class Product < ActiveRecord::Base | |
| def self.find_by_criteria(params) | |
| query = where("id IS NOT null") # A little odd but not sure how to get an ActiveRecord::Relation that returns "all" | |
| query = query.where("price = ?", params[:price]) if params[:price].present? | |
| query = query.where("manufacturer = ?", params[:manufacturer]) if params[:manufacturer].present? | |
| query = query.where("retailer = ?", params[:retailer]) if params[:retailer].present? | |
| query = query.where("category = ?", params[:category]) if params[:category].present? | |
| query | |
| end |
OlderNewer