Skip to content

Instantly share code, notes, and snippets.

View alexvbush's full-sized avatar

Alex Bush alexvbush

View GitHub Profile
@alexvbush
alexvbush / UIAlertViewPopupExample.m
Created January 27, 2012 07:26
iOS UIAlertView popup
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Some Title Here"
message:@"And some description message here"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil] autorelease];
[alert show];
@alexvbush
alexvbush / calculate_folder_size.rb
Created September 23, 2011 11:35
Recursively calculates the size of a folder(path to folder is the first input in terminal). Found other solutions using system calls but decide to write my own.
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
@alexvbush
alexvbush / ActivityImplementsOnClickListener.java
Created September 9, 2011 09:38
Android various definition of OnClickListeners.
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);
@alexvbush
alexvbush / Activity's Inner Class implements View.OnClickListener.
Created September 9, 2011 09:00
Activity implements various OnClickListeners.
package com.smartcloudcompany.onclickinxml;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class AndroidOnClickDefinitionInXMLActivity extends Activity implements OnClickListener {
@alexvbush
alexvbush / custom_daemon_start_stop.rb
Created June 22, 2011 21:03
how to start and stop custom daemon in Rails. According to Ryan Bates.
RAILS_ENV=development lib/daemons/mailer_ctl start
RAILS_ENV=development lib/daemons/mailer_ctl stop
@alexvbush
alexvbush / HLPlaceResourceManager.h
Last active August 29, 2015 14:10
RestKit RKObjectManager Setup
//
// HLPlaceResourceManager.h
// HeyLets2
//
// Created by Alex Bush on 11/18/14.
// Copyright (c) 2014 HeyLets. All rights reserved.
//
#import <Foundation/Foundation.h>
@alexvbush
alexvbush / boolean_value.rb
Last active August 29, 2015 14:04
Global Settings for storing app configuration(with caching)
class BooleanValue < Value
end
@alexvbush
alexvbush / article.rb
Created July 14, 2014 02:06
Final version of Article model.
class Article < ActiveRecord::Base
include Categorizable
APPROVED = 'approved'
PENDING = 'pending'
REJECTED = 'rejected'
attr_accessible :approved_at, :url, :body, :image, :rating, :state, :title, :news_source_id, :published_at
validates :url, :uniqueness => true
@alexvbush
alexvbush / articles_controller.rb
Created July 14, 2014 02:04
Final version of Articles controller.
class Api::Private::ArticlesController < Api::Private::BaseController
include ArticlesSearch
before_filter :find_or_create_article, except: [:index]
PAGE_SIZE = 20
attr_accessor :total_pages
def index
@articles = Article
@alexvbush
alexvbush / article.rb
Last active August 29, 2015 14:03
Second iteration of Article model.
class Article < ActiveRecord::Base
include Categorizable
APPROVED = 'approved'
PENDING = 'pending'
REJECTED = 'rejected'
attr_accessible :approved_at, :url, :body, :image, :rating, :state, :title, :news_source_id, :published_at
validates :url, :uniqueness => true