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
| // CUSTOM AJAX FUNCTION FOR STRUCTURED ERROR HANDLING | |
| (function(){ | |
| // Store a reference to the original ajax method. | |
| var originalAjaxMethod = jQuery.ajax; | |
| var EF = function(){}; | |
| // override the default $.ajax to include special handlers for error and success | |
| // to utilize new custom error box. existing success and error callbacks are | |
| // left intact and given the expected params. | |
| jQuery.ajax = function(options) { | |
| var thisSuccess = (typeof options.success == 'function') ? options.success : EF; |
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
| <cfcomponent extends="Controller" output="false" hint="A set of functions to interface with the jQuery validator plugin"> | |
| <cfscript> | |
| function measurement() { | |
| // gets either params.w, params.d or params.h | |
| // m = params.w OR params.d OR params.h; | |
| if (isDefined("params.w")) { m = params.w; } | |
| if (isDefined("params.d")) { m = params.d; } | |
| if (isDefined("params.h")) { m = params.h; } |
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 'rubygems' | |
| require 'httparty' | |
| require 'HTTMultiParty' | |
| require 'base64' | |
| # This is a quick example to demonstrate the use of ruby to interact with the Specify API. | |
| # I am a beginner rubyist, so please excuse my rudimentary code! | |
| # Depends on httparty for clean and simple API wrapper code https://github.com/jnunemaker/httparty | |
| # Depends on httpmultiparty to allow image and file uploads https://github.com/jwagener/httmultiparty |
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
| var dmp = new diff_match_patch(); | |
| var text1 = "your input text source"; | |
| var text2 = "your input text destination"; | |
| var current_unicode = parseInt('2000',16); | |
| var charmap = {}; | |
| var replaceFirstTag = function(str,code) { | |
| var nu = code+1; |
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
| namespace :assets do | |
| # Prepend the assets:precompile_prepare task to assets:precompile. | |
| task :precompile => :precompile_prepare | |
| # This task will be called before assets:precompile to optimize the | |
| # compilation, i.e. to prevent any DB calls. | |
| task 'precompile_prepare' do | |
| # Without this assets:precompile will call itself again with this var set. | |
| # This basically speeds things up. | |
| # ENV['RAILS_GROUPS'] = 'assets' |
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
| ruby-1.9.2-p180 :061 > Signup.last | |
| Signup Load (0.4ms) SELECT "signups".* FROM "signups" ORDER BY "signups"."token" DESC LIMIT 1 | |
| #<Signup:0x0000010a51f5a8> { | |
| :token => "ab377c84", | |
| :email => "email1@example.com", | |
| :referred_by => nil, | |
| :notified => nil, | |
| :user_id => nil, | |
| :created_at => Tue, 01 Nov 2011 13:25:06 PDT -07:00, | |
| :updated_at => Tue, 01 Nov 2011 13:25:06 PDT -07:00, |
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 ScoreKeeper | |
| class Player | |
| attr_accessor :name, :scores | |
| def initialize(name) | |
| @name = name | |
| @scores = [] | |
| end | |
| def <<(points) | |
| @scores << points |
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
| $('#products').append('<%= j render(@products) %>'); | |
| <% if @products.next_page %> | |
| $('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
| <% else %> | |
| $('.pagination').remove(); | |
| <% 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 'digest/sha1' | |
| module Extensions | |
| module CachedFinder | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| def cached(options = {}) | |
| options_hash = Digest::SHA1.hexdigest(options.to_s) | |
| Rails.cache.fetch [self.class.to_s.underscore, options_hash].join('/'), :expires_in => 1.hour, :race_condition_ttl => 10 do | |
| all options |
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
| prompt = require 'prompt' | |
| gm = require 'googlemaps' | |
| red = '\u001b[31m' | |
| blue = '\u001b[34m' | |
| reset = '\u001b[0m' | |
| l = (content) -> | |
| console.log content |
OlderNewer