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
class Api::Private::ArticlesController < Api::Private::BaseController | |
include ArticlesSearch | |
before_filter :find_or_create_article, except: [:index] | |
PAGE_SIZE = 20 | |
def index | |
@articles = Article.scoped | |
total_pages = 0 | |
page = params[:page] ? params[:page] : 1 |
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
module ArticlesSearch | |
def articles_search(search_criteria, state = nil) | |
@articles = Article.includes(:categories).where('title LIKE ? OR categories.name LIKE ?', "%#{search_criteria}%", "%#{search_criteria}%") | |
if state | |
@articles = @articles.where(state: state) | |
end | |
@articles |
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
class Api::Private::ArticlesController < Api::Private::BaseController | |
before_filter :find_or_create_article, except: [:index] | |
def index | |
@articles = Article.scoped | |
if params[:state] == Article::PENDING | |
@articles = Article.pending.order(:published_at) | |
elsif params[:state] == Article::APPROVED | |
@articles = Article.approved.order('approved_at DESC') |
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
class Article < ActiveRecord::Base | |
include Categorizable | |
APPROVED = 'approved' | |
PENDING = 'pending' | |
REJECTED = 'rejected' | |
attr_accessible :approved_at, :url, :body, :image, :rating, :state, :title | |
validates :url, :uniqueness => true |
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
/** | |
* | |
*/ | |
/** | |
* Smart Cloud, Inc. Nov 14, 2013. | |
* @author Alex Bush | |
* | |
*/ | |
public class CollectionTest { |
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
public class ExampleWeak { | |
private WeakReference<Context> weakContext; | |
public ExammpleWeak(Context context) { | |
this.weakContext = context; | |
} | |
public Context getContext() { | |
return weakContext.get(); | |
} |
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
FactoryGirl.define do | |
factory :post do | |
sequence(:post_title) {|n| "Post#{n}"} | |
post_date { Time.now - 10.days } | |
post_date_gmt { (Time.now - 10.days).gmtime } | |
post_modified { Time.now - 10.minutes } | |
post_modified_gmt { (Time.now - 10.minutes).gmtime } | |
post_status {"publish"} | |
factory :artist, :class => 'Artist' do |
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
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Some Title Here" | |
message:@"And some description message here" | |
delegate:nil | |
cancelButtonTitle:@"Ok" | |
otherButtonTitles: nil] autorelease]; | |
[alert show]; |
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
if ARGV.count != 1 || !File.directory?(ARGV[0]) | |
p 'Please specify a folder.' | |
exit | |
end | |
def calculate_size(file) | |
#p 'calculating ' + file | |
if File.directory? file |
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
public class AndroidOnClickDefinitionInXMLActivity extends Activity implements OnClickListener { | |
private Button buttonWithActivityAsListener; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |