サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
レイングッズ
cortyuming.hateblo.jp
(yeoman1.0.4, angularjs1.0.7) Yeoman インストール $ npm install -g yo grunt-cli bower generator-angular 環境構築 $ mkdir guestbook-sample $ cd guestbook-sample $ yo angular guestbook [?] Would you like to include Twitter Bootstrap? Yes : Bootstrap3 ver.2 だったので 3 に上げとく Yeoman で作った AngularJS + Titter Bootstrap のプロジェクトで Bootstrap がまだ Ver.2 だったので 3 にする場合のメモ - 牌語備忘録 - pygo 開発用サーバー起動 grunt server起動すると自動でブラウザにinde
表示確認はFirefox26。 chrome 使う場合は下記のように -allow-file-access-from-files オプション付けて起動する 【小ネタ】Chromeのローカルセキュリティポリシーの回避 | Developers.IO open -a Google\ Chrome --args -allow-file-access-from-files index.html <!doctype html> <html lang="ja"> <head> <meta charset="UTF-8"/> <title>ajax+json</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"></script> <script type="text/javascript"
基本的に元ネタそのまま 関数名と変数名 動詞 - Yamanobori_oldのMemo 動詞 作る create make setup build generate compose 消す delete remove kill clear erase 確保する allocate lock 解放する free release 読む read load 書く write save 探す find search hunt seek extract locale recover 分ける divide つなげる link 得る get 得る query 見る look see peek 実行する execute 起動する invoke do 繰り返す repeat コピーする copy duplicate 始める begin start launch 終わる end 止まる stop やめる qui
(CakePHP2.4.3) 公式サイトの手順だと webroot/index.php だけ修正しているが、修正すべき絶対パスが3ヵ所ある。 絶対パスから相対パスに変更するファイル app/webroot/index.php -define('CAKE_CORE_INCLUDE_PATH', DS . 'Users' . DS . 'username' . DS . 'app_dir' . DS . 'Vendor' . DS . 'pear-pear.cakephp.org' . DS . 'CakePHP'); +define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'Vendor/pear-pear.cakephp.org/CakePHP'); app/webroot/test.php -define('CAKE_CORE_INCLUDE_PATH
(mysql Ver 14.14 Distrib 5.1.58, for debian-linux-gnu (x86_64) using readline 6.2) データベースの場所を調べる mysql -u root -p #パスワード入力 > show variables like 'datadir'; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | datadir | /var/lib/mysql/ | +---------------+-----------------+ 1 row in set (0.00 sec) データベースのディレクトリ変更 /etc/mysql/my.cnf [mysqld] : datadir = /
(Python==3.3, Django==1.6, djangorestframework==2.3.8, angular1.2.0, generator-angular0.6.0-rc.1) Django で apiサーバ作成 virtualenv mkvirtualenv booklist_sample --python /opt/local/bin/python3.3 インストール $ pip install django $ pip install djangorestframework プロジェクト作成と・アプリ作成 $ django-admin.py startproject core $ mv core booklist_api $ cd booklist_api $ python manage.py startapp books モデル作成 books/models.py
(angular1.2.0, generator-angular0.6.0-rc.1, twitter bootstrap 3.0) angular-SimplePagination を利用してお手軽にページネーションしてみる https://github.com/svileng/angular-SimplePagination プロジェクト作成 $ mkdir simple_pagination_sample $ yo angular 仮表示用のデータなど作成 app/scripts/controllers/main.js 'use strict'; angular.module('simplePaginationSampleApp') .controller('MainCtrl', function ($scope, Pagination) { $scope.books = []; f
(Rails3.2.11) javan/whenever · GitHub Installation Gemfile gem 'whenever', :require => false bundle install Getting started $ bundle exec wheneverize . [add] writing `./config/schedule.rb' [done] wheneverized! Example User rails g scaffold User say app/models/user.rb class User < ActiveRecord::Base attr_accessible :say def self.create_say self.create(say: "Hi #{Time.now}") end end Example schedule
(MacOS10.8) Burn.app iDVD が入ってないので Burn 使う ダウンロード Burn - Home 設定 ビデオ 一般 地域を「NTSC」 DVD 「DVDテーマを使用」チェック外す DVD作成 「ビデオ」タブ タイトルを入力 タイトル右のセレクタを「DVD-Video」にする MP4ファイルを追加 変換するか聞いてくるので変換する 「ディスク作成」 参考サイト http://win2mac.seesaa.net/article/144820849.html
Assert 文 は、プログラム内にデバッグ用アサーション (debugging assertion) を仕掛けるための便利な方法です: Python リファレンスマニュアル 6.2 Assert 文 (assert statement) その1 >>> a = 1 >>> b = 2 >>> assert a < b, "error message" >>> #何も起きない >>> a = 5 >>> assert a < b, "error message" Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError: error message >>> その2 try: for c in range(5): print c assert c != 3 except: pri
>>> lst = [i for i in range(10)] >>> lst [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> lst[0::2] [0, 2, 4, 6, 8] >>> lst[1::2] [1, 3, 5, 7, 9]
(python==2.7, arrow==0.3.5) crsmithdev/arrow · GitHub Arrow: better dates and times for Python — Arrow 0.4.4 documentation Arrow - better date & time manipulation for Python : Python <-作者さんが質問に答えてる。名前の由来とか。 dateutilあるけど、arrowもいいらしい。 こっちの方がモダンっぽいらしい。 id:Voluntas師匠に教えてもらった。 >>> import arrow # 現在 >>> arw = arrow.utcnow() >>> arw <Arrow [2013-09-05T15:06:49.312975+00:00]> # 翌月(年月日を複数形で指定して増減) >>> arw.
※ 追記:DEFAULT CHARACTER SET utf8; ※ 修正:pasword変更、 port selectの記述を追加 [Pytho2.7, Django1.4, MacOSX10.8 (Python, pip, MySQL は MacPorts でインストール済)] ささっと実験的なDjangoのプロジェクトを作ろうとしたら、想定外に問題発生したのでメモ MySQL ユーザとDB作成 $ mysql -u root -p CREATE DATABASE dbname DEFAULT CHARACTER SET utf8mb4; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost'; SELE
(Rails3.2.11) collectiveidea/delayed_job · GitHub Installation Gemfile gem 'delayed_job_active_record' shell bundle install rails generate delayed_job:active_record rake db:migrate 確認用メーラー作成 rails g user_mailer send_mail config/environments/development.rb 一応設定 config.action_mailer.default_url_options = { :host => 'localhost:3000' } config.action_mailer.delivery_method = :test Running Jobs rake job
(MacOSX10.8, Sequel Pro1.0.2, Vagrant1.2.2, [Ubuntu, MySQL5.5] in VirtualBox ) コマンドラインからsshで入れるか確認 How to connect to Mysql Server inside VirtualBox Vagrant? - Stack Overflow 上記リンクまま vagrant ssh でなくて $ ssh vagrant@127.0.0.1 -p 2222 (password vagrant)で入ってみる そしてMySQLの設定変更 $ vi /etc/my.cnfコメントアウト ;skip-external-locking ;bind-addressMySQL再起動 sudo service mysql restart Sequel Pro ローカルに戻って Sequel Pro の設定
(Rails3.2.12) Date Picker を英語で表示の手順 #213 Calendars (revised) - RailsCasts Gemfile group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' gem 'jquery-ui-rails' end app/assets/javascripts/application.js //= require jquery //= requir
(Rails3.2.12) プロジェクト作成 rails new sortable_table -T cd new sortable_table rails g scaffold Product name price:decimal released:date rake db:migrate 確認用初期データ投入 db/seeds.rb Product.delete_all Product.create(name: "Katsuo", price: 500, released: 30.days.ago.to_date) Product.create(name: "Wakame", price: 300, released: 20.days.ago.to_date) Product.create(name: "Tarao", price: 50, released: 10.days.ago.
※追記20130622:修正 ※追記20130629:oh-my-zsh 抜けてた (Emacs24.3, Zsh5.0.2, MacOSX10.8) MacPorts で Emacs-app をインストール前提で Emacs init.el ;; server start for emacs-client (require 'server) (unless (server-running-p) (server-start)) キーバインドなど (defun iterm() (interactive) (shell-command "open -a iTerm ") ) (defun show-in-iterm-for-mac() (interactive) (shell-command (concat "open -a iTerm " default-directory)) ) (glo
(Emacs24.2, Python2.7) tkf/emacs-jedi · GitHub Install package.el でインストールしておくもの M-x list-packages auto-complete deferred epc jedi pip とかでインストールしておくもの jedi epc init.el (add-hook 'python-mode-hook '(lambda () (jedi:ac-setup) (define-key python-mode-map (kbd "<C-return>") 'jedi:complete) ))
(Rails3.2.13) http://railscasts.com/episodes/320-jbuilder?language=ja&view=asciicast https://github.com/rails/jbuilder 下準備 $ rails new jbuilder_app -T --skip-bundle $ cd jbuilder_app $ bundle install $ rails generate scaffold Book title price:integer $ rake db:migrate db/seed.rb Book.create(title: "明暗", price: 788) Book.create(title: "草枕", price: 452) $ rake db:seed json出力確認 http://localhost:3000/
修正2014-08-03:Path (MacOSX10.9) Connecting to the Mac App Store rst2html-2.7.py をインストール sudo port install py27-docutils Marked の設定 Prefarence -> Behavior Custom Processor の Custom Markdown Processor にチェック入れて Path を /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/rst2html.pyそんで hoge.rst とか読み込むと表示される。 追記:エディタ指定 Prefarence -> Window Edit with のところで Emacs.app とかエディタを指定すると、Marked.app から
(Rails3.2.13) Ruby on Rails 3 の Ajax いろいろ - yuumi3のお仕事日記 上記リンクの2と3を少々書き換えてやってみた。 下準備(2と3共通) $ rails new ajax_app -T --skip-bundle $ cd ajax_app $ rails g scaffold Todo due:date task $ bundle install $ rake db:migrate 『2. jquery_ujs のcallbackを使う方法』の場合 app/views/todos/index.html.erb <td><%= link_to 'Show', todo, remote: true, "data-type" => "html", class: "show" %></td> : <hr /> <div id="show_area">
(Rails3.2.13) ほかに Spring や Zeus とかありますが、あえて DHH の Commands を使ってみた。 https://github.com/rails/commands http://railscasts.com/episodes/412-fast-rails-commands?language=ja&view=asciicast ちなみに Commands は rails console の中で使うものらしい。 確認用下準備 $ rails new commands -T --skip-bundle $ cd commands Gemfile group :development, :test do gem 'rspec-rails' gem 'commands' end $bundle install $ rails generate scaffold
(rails3.2.13) ちなみに開発環境では問題は無く、 デプロイしたら ActionView::Template::Error になった。 原因 Gemfile の書き方だった jQuery-ui の Date Picker を日本語で使った場合に Gemfile の assets の書き方が原因だった。 デフォで assets グループの中に jquery-ui-rails がいる これだと ActionView::Template::Error になる(production.log) ビューで『We're sorry, but something went wrong.』と表示される。 group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.
(Rails3.2.6, Ruby1.9.3) db/fixtures に hoge.yml を置いた場合 db seeds.rb fixtures hoge.yml fuga.yml : db/fixtures の yml を全て読み込む。 それから yml に erb のタグを書いても読み込むようにする。 ex: hoge: date: <% Date.today %> seeds.rb ext = "yml" filepaths = Dir.glob(File.dirname(__FILE__) + "/fixtures/*." + ext) filepaths.each do | filepath | fixture = File.read("#{filepath}") data = YAML.load(ERB.new(fixture).result) tablename = Fi
修正: 2013-09-18 (MacOSX10.7, Python2.7) 『%』を使うやり方は、そのうち無くなるそうなので『str.format(*args, **kwargs)』を使ってみる。 code hoge.py import datetime today = datetime.datetime.now() # old type print "%(when)s is %(month)02d" % {'when': 'this month', 'month': today.month} #-> this month is 03 # new type 1 print "{when} is {month:02d}".format(when='this month', month=today.month) #-> this month is 03 # new type 2 print
(MacOSX10.8, Emacs24.2, ruby1.9.3[rbenv]) 自分の環境で Rsense がうまく補完してくれなくなってしまった *1 ので rcodetools を使ってやってみた。 auto-complete-ruby.el もうまくいかなかったのでシンプルな感じでやってみた。 やり方 インストール $ sudo gem install rcodetools パスを通してinit.elに設定 gem environmentとかでgemの置いてあるところを調べる。 下記は rbenv でインストールした場合はの例 (add-to-list 'load-path "~/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/rcodetools-0.8.5.0/") (require 'rcodetools) (defi
(Emacs24.2, clisp2.49, MacOSX10.8) Install: clisp sudo port install clisp Install: slime M-x package-list-packages で slime インストール (slime-20130213.745) 修正2013-10-28 init.el ;;;; Common Lisp ;; (setq inferior-lisp-program "ccl64") (setq inferior-lisp-program "clisp") (add-hook 'lisp-mode-hook (lambda () ;; (slime-mode t) (define-key lisp-mode-map (kbd "C-c C-s") 'slime) (add-to-list 'ac-sources 'ac-
(MacOSX 10.8, Emacs 24.2, Google Chrome 24.0) How To AppleScript ~/.emacs.d/reload-chrome.scpt tell application "Google Chrome" tell active tab of first window execute javascript "window.location.reload()" end tell end tell Emacs init.el (defun reload-chrome () (interactive) (shell-command "osascript ~/.emacs.d/reload-chrome.scpt") ) (global-set-key (kbd "s-r") 'reload-chrome) ) 参考サイト http://snipp
次のページ
このページを最初にブックマークしてみませんか?
『牌語備忘録 -pygo』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く