Skip to content

Instantly share code, notes, and snippets.

@lxyuma
lxyuma / gist:7508850
Created November 17, 2013 03:48
yeomanのgenerator backboneを使って、handlebarsをtemplateにしたprojectでひな形作るまで

前提

node.js / npm / yeoman をinstall

手順

project作成

$ npm install -g backbone

@lxyuma
lxyuma / gist:6424131
Last active December 22, 2015 05:28
marionette script
// sample
var MyView = Marionette.ItemView.extend({
template: "my-template-id"
});
var myView = new MyView({ model: Dog});
myView.render();
// ItemView sample
@lxyuma
lxyuma / gist:5660240
Last active December 17, 2015 19:29
jasmine rails
@lxyuma
lxyuma / gist:5642687
Last active December 17, 2015 16:59
mongodb backup

mongodb dump

やり方

  • ファイルコピー
  • メリット:高速
  • デメリット:DB停止かロック(db.fsyncLock())が必要
  • (replica setはoplog溢れないよう注意)
  • mongodump
  • メリット:ファイル小さくなる
@lxyuma
lxyuma / gist:5642433
Last active December 17, 2015 16:59
mongodb replicaset basic memo

dataとlogディレクトリの準備

mkdir -p /srv/mongodb/rs0/ /srv/mongodb/rs1/ /srv/mongodb/rs2/

mkdir /var/log/mongo
@lxyuma
lxyuma / gist:5202528
Created March 20, 2013 05:28
ruby omniauth twitter feed
# omniauth + omniauth-twitter gems are required
class TwitterApi
SITE = "http://api.twitter.com"
API_URL = { :update_status => SITE + "/1.1/statuses/update.json"}
def self.feed
access_token = official_access_token
response = access_token.request(:post,
API_URL[:update_status],
# railsのmodelで***_path(resourceのURL)を使う方法
- Rails.application.routes.url_helpers.posts_path
- 参考
- http://stackoverflow.com/questions/5380703/rails-get-resource-path-in-model
- ところが、これだと、パスしか分からない。URLのホスト部分が入らない。
- posts_urlに変えると、以下のエラーが出る。
- ArgumentError (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
@lxyuma
lxyuma / new_gist_file_0.md
Last active December 12, 2015 10:29
mysql user command

よく忘れてしまうので、mysqlのuser系のコマンドのまとめ

  • ユーザー作成

  • create user 'username'@'host'

  • ユーザー変更

  • rename user old to new

  • ユーザー一覧

  • select Host,User from mysql.user;