Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |
This file contains 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
# Basic Code | |
class Image | |
has_attached_file :attachment | |
def attachment_url(url) | |
require "open-uri" | |
self.attachment = open(url) | |
end | |
end |
This file contains 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://blog.wyeworks.com/2009/7/13/paperclip-file-rename | |
Paperclip.interpolates :default_image_type do |attachment, style| | |
attachment.instance.get_user_default_profile_image | |
end | |
Paperclip.interpolates :normalized_avatar_file_name do |attachment, style| | |
attachment.instance.normalized_avatar_file_name | |
end | |
This file contains 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 ruby | |
# Please read http://otobrglez.opalab.com for more information about this code. | |
class Book < Struct.new(:title) | |
def words | |
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
end |
This file contains 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
# = Icebox : Caching for HTTParty | |
# | |
# Cache responses in HTTParty models [http://github.com/jnunemaker/httparty] | |
# | |
# === Usage | |
# | |
# class Foo | |
# include HTTParty | |
# include HTTParty::Icebox | |
# cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache') |
This file contains 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
# = Icebox : Caching for HTTParty | |
# | |
# Cache responses in HTTParty models [http://github.com/jnunemaker/httparty] | |
# | |
# === Usage | |
# | |
# class Foo | |
# include HTTParty | |
# include HTTParty::Icebox | |
# cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache') |
This file contains 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 'benchmark' | |
require 'thread' | |
class Google | |
include HTTParty | |
base_uri 'http://google.com' | |
def self.benchmark |
This file contains 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
/* Pre-Define HTML5 Elements in IE */ | |
(function(){ var els = "source|address|article|aside|audio|canvas|command|datalist|details|dialog|figure|figcaption|footer|header|hgroup|keygen|mark|meter|menu|nav|picture|progress|ruby|section|time|video".split('|'); for(var i = 0; i < els.length; i++) { document.createElement(els[i]); } } )(); |
This file contains 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
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ | |
window.matchMedia || (window.matchMedia = function() { | |
"use strict"; | |
// For browsers that support matchMedium api such as IE 9 and webkit | |
var styleMedia = (window.styleMedia || window.media); | |
// For those that don't support matchMedium | |
if (!styleMedia) { | |
var style = document.createElement('style'), |
This file contains 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
<script type="text/javascript" src='http://code.jquery.com/jquery-2.1.3.min.js'></script> | |
<audio id="myAudio" src="http://sqr.bartekdrozdz.com/demo/soundviz/assets/spy.mp3" controls><p>Your browser does not support the audio element.</p></audio> | |
<!-- <audio id="myAudio" src="./a-little-something.mp3" controls><p>Your browser does not support the audio element.</p></audio> --> | |
<div id="visualization" style="width:100%; height:500px"></div> | |
<script type="text/javascript"> | |
Number.prototype.map = function ( in_min , in_max , out_min , out_max ) { | |
return ( this - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min; | |
} |
OlderNewer