Instantly share code, notes, and snippets.

View peco_select_branch.fish
function peco_select_branch
set -l query (commandline)
if test -n $query
set peco_flags --query "$query"
end
git branch | peco --prompt "GIT BRANCH>" $peco_flags | sed -e "s/^\* //g" -e "s/^ //g" | read line
if [ $line ]
View private.xml
<?xml version="1.0"?>
<root>
<appdef>
<appname>SLACK</appname>
<equal>com.tinyspeck.slackmacgap</equal>
</appdef>
<item>
<name>For Slack Command+Shift+Bracket(Left or Right) to move channel</name>
<identifier>private.app_slack_move_channel</identifier>
<only>SLACK</only>
View chapter7_list20.js
// js/note_form.js
App.NoteFormView = Backbone.View.extend({
render: function() {
var template = $('#noteForm-template').html();
var compiled = _.template(template);
var html = compiled(this.model.toJSON());
this.$el.html(html);
return this;
},
View chapter7_list5.js
// js/note_detail.js
App.NoteDetailView = Backbone.View.extend({
render: function() {
var template = $('#noteDetailView-template').html();
var compiled = _.template(template);
var html = compiled(this.model.toJSON());
this.$el.html(html);
return this;
}
View chapter7_list1.js
App.NoteListItemView = Backbone.View.extend({
tagName: 'tr',
initialize: function() {
// モデルのdestroyイベントを監視して
// Backbone.Viewのremove()メソッドを呼び出す
this.listenTo(this.model, 'destroy', this.remove);
},
// [Delete]ボタンを監視して
// onClickDelete()メソッドを呼び出す
events: {
View chapter6_list8.js
// js/note_list_item.js
App.NoteListItemView = Backbone.View.extend({
tagName: 'tr',
render: function() {
var template = $('#noteListItemView-template').html();
var compiled = _.template(template);
var html = compiled(this.model.toJSON());
this.$el.html(html);
return this;
View chapter4_list13.js
var Todo = Backbone.Model.extend({
defaults: {
title: '',
completed: false
}
});
var TodoView = Backbone.View.extend({
template: '<label>' +
' <input class="toggle" type="checkbox">' +
View chapter4_listA.js
var ContactView = Backbone.View.extend({
template: '<div>Name: <%= firstName %> <%= lastName %></div>' +
'<div>Email: <%= email %></div>',
render: function() {
var compiled = _.template(this.template);
var html = compiled(this.model.toJSON());
this.$el.html(html);
return this;
}
View chapter4_list3.js
var ContactView = Backbone.View.extend({
render: function() {
// HTMLテンプレートを取得する
var template = $('#contact-template').html();
// HTMLテンプレートにモデルのデータを適用する
// モデルのtoJSON()メソッドを使って属性を
// オブジェクトの形式で書き出す
var compiled = _.template(template)
var html = compiled(this.model.toJSON());
// 自身が保持しているDOM要素を更新する
View fizzbuzz.js
Array.apply(null,Array(100)).map(function(i,j){++j;i='';!(j%3)&&(i='fizz');!(j%5)&&(i+='buzz');console.log(i||j)})