Skip to content

Instantly share code, notes, and snippets.

@unosk
unosk / deploy.rb
Last active November 18, 2015 10:12
lock '3.4.0'
set :application, 'smart2channel'
set :deploy_to, "/opt/#{fetch(:application)}"
set :repo_url, '[email protected]:unosk/smart2channel.git'
set :branch, 'master'
set :scm, :git
set :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets vendor/bundle public/uploads)
namespace :itamae do
desc 'Itamae plan(dry-run)'
task :plan do
run_itamae(dry_run: true)
end
desc 'Itamae apply'
task :apply do
run_itamae(dry_run: true)
end
require 'json'
set :itamae_rsync_src, './ops/itamae'
set :itamae_rsync_dst, '/tmp/itamae'
set :itamae_rsync_options, %w(-avzr --delete --exclude='.vagrant')
namespace :itamae do
task :install do
on roles(:all) do
execute <<-SCRIPT
@unosk
unosk / base.json
Created November 8, 2015 07:51
Packer template for itamae
{
"builders": [{
"type": "amazon-ebs",
"region": "ap-northeast-1",
"source_ami": "ami-936d9d93",
"instance_type": "m3.medium",
"ssh_username": "ubuntu",
"ami_name": "smart2channel-base {{timestamp}}"
}],
"provisioners": [
@unosk
unosk / .gitignore
Last active November 8, 2015 07:38
Terraform sample
.terraform/
import android.view.View;
public class UiVisibilityHelper {
private View[] mViews;
public UiVisibilityHelper(View... views) {
mViews = views;
}
public abstract class BaseActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getClass().getAnnotation(InjectLayout.class).value());
ButterKnife.inject(this);
}
}
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* TODO: Add a class header comment!
*/
public class AspectRatioImageView extends ImageView {
@unosk
unosk / VolleyErrorHelper.java
Created April 3, 2015 10:33
VolleyErrorHelper
import android.content.Context;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkError;
import com.android.volley.NoConnectionError;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
public class VolleyErrorHelper {
@unosk
unosk / ArrayAdapter.java
Created April 3, 2015 08:37
Android RecyclerView.Adapter
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public abstract class ArrayAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {