Skip to content

Instantly share code, notes, and snippets.

@kgmx
kgmx / image_uploader.rb
Last active September 18, 2015 02:32
ImageUploader
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
storage :fog
def store_dir
"hoge/"
end
@kgmx
kgmx / seed.rb
Created August 19, 2015 01:05
activeadmin/seed.rbでユーザ作成
# db/seed.rb
AdminUser.find_or_create_by(email: 'admin@example.com') do |m|
m.password = 'password'
m.password_confirmation = 'password'
end
AdminUser.find_or_create_by(email: 'myemail@gmail.com') do |m|
m.password = 'mypassword'
m.password_confirmation = 'mypassword'
@kgmx
kgmx / application_controller.rb
Last active August 29, 2015 14:26
rails-error-page
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
# 他のエラーハンドリングでキャッチできなかった時は、500エラーを発生させる
rescue_from Exception, with: :error_500 unless Rails.env.development?
 # 404エラー
@kgmx
kgmx / build.gradle
Created June 9, 2015 07:08
ActiveAndroid組み込み
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yourname.yourapp"
minSdkVersion 15
targetSdkVersion 21
@kgmx
kgmx / getHour.m
Created March 15, 2015 03:19
NSdate型の時刻からhourを取得する関数
// 関数を定義する
-(NSInteger) getHour:(NSDate *)date {
// NSCalendarを取得
NSCalendar *calendar = [NSCalendar currentCalendar];
// 取得したい要素(今回はhour)を表すフラグを添えて、日付からその情報を持ったNSDateComponentsを取得。
NSDateComponents *components = [calendar components:NSCalendarUnitHour fromDate:date];
NSInteger hour = components.hour;
return hour;
{
"name": "app",
"version": "0.0.1",
"description": "grunt環境設定",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "kgmx"
}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta name="description" content="">
<meta name="keyword" content="">
<!-- styles -->
<link rel="stylesheet" href="css/sample.css" type="text/css" media="all">
#main {
background-image: image-url("main.png");
background-repeat: no-repeat;
background-position: 50% 0;
height: 400px;
}
#main {
background-image: url("main.png");
background-repeat: no-repeat;
background-position: 50% 0;
height: 400px;
}
#main
width: 950px
margin: 0 atuo
p
margin: 0 0 1em
span
color: red