Skip to content

Instantly share code, notes, and snippets.

@hotakasaito
hotakasaito / file0.js
Created December 18, 2014 19:48
slackからAWS SNS経由でpush通知を送る ref: http://qiita.com/hotakasaito/items/620247240b2f76e58e0e
AWS = require('aws-sdk')
AWS.config.region = 'ap-northeast-1'
sns = new AWS.SNS()
platformApplicationArn = 'arn:aws:sns:ap-northeast-1:xxx:xxx'
module.exports = (robot) ->
Date::format = ->
"#{@.getFullYear()}#{@.getMonth() + 1}#{@.getDate()}#{@.getHours()}#{@.getMinutes()}#{@.getSeconds()}"
subscribe = (topicArn, endpointArn) ->
@hotakasaito
hotakasaito / file0.txt
Last active August 29, 2015 14:11
paperclipから呼び出すコマンドの負荷を少しでも下げたい ref: http://qiita.com/hotakasaito/items/8751c5fb05e7883af3f2
require 'paperclip/helpers'
Paperclip::Helpers.module_eval do
def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
command_path = options[:command_path]
Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq
if logging? && (options[:log_command] || local_options[:log_command])
local_options = local_options.merge(:logger => logger)
end
Cocaine::CommandLine.new("#{Rails.env.production? ? 'ionice -c3 -n7 ' : ''}nice -n19 #{cmd}", arguments, local_options).run(interpolation_values)
end
@hotakasaito
hotakasaito / file0.txt
Last active August 29, 2015 14:12
google driveの特定のフォルダをlinux(centos)上で同期させる ref: http://qiita.com/hotakasaito/items/8ed052c1dc12aa118b73
sudo yum install golang git mercurial
1月 2015
日 月 火 水 木 金 土
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
今日が1/17なので
19,20,21,22,23,26,27,28,29,30 あたりで都合がいい日
@hotakasaito
hotakasaito / file0.txt
Created February 3, 2015 10:46
[Spree] 商品管理のオプションタイプ追加時の不具合 ref: http://qiita.com/hotakasaito/items/d1a24b100a3e384c32df
Spree::Admin::OptionTypesController.class_eval do
def update
Spree::OptionType.skip_callback(:touch, :after, :touch_all_products)
super
end
end
@hotakasaito
hotakasaito / file0.txt
Last active August 29, 2015 14:17
Celluloid::Loggerのerrorがthorのerrorに負ける ref: http://qiita.com/hotakasaito/items/3af13db980addab8152f
require 'thor'
require 'celluloid'
include Celluloid::Logger
Celluloid.logger = ::Logger.new("sample.log")
class SampleThor < Thor
desc "test", "sample"
def test
error "test"
end
@hotakasaito
hotakasaito / file0.txt
Last active August 29, 2015 14:18
trelloのカードをgithubのissueにslackから追加する ref: http://qiita.com/hotakasaito/items/a97fad861c460c3faaa2
npm install node-trello --save
npm install octonode --save
@hotakasaito
hotakasaito / file0.coffee
Last active August 29, 2015 14:22
Google Drive push notifications を hubot で受ける ref: http://qiita.com/hotakasaito/items/824b7612667e32328345
robot.router.post "/google/drive/notifications", (req, res) ->
robot.logger.debug req
# 何かしらの処理
res.status(200).send 'ok'
heroku addons:create mongolab:sandbox
module.exports = (robot) ->
sleep = (ms) ->
start = new Date().getTime()
continue while new Date().getTime() - start < ms
robot.on 'my:sleep', (ms) ->
sleep ms