Skip to content

Instantly share code, notes, and snippets.

@foo9
foo9 / Gruntfile.coffee
Last active December 20, 2015 05:18
編集 → 結合 → 再読み込み
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
watch:
options:
livereload: true
@foo9
foo9 / app.js
Last active December 20, 2015 14:48
Backbone.jsでModelによってViewを分ける
var App = {
Views: {},
Models: {},
Collections: {}
};
App.Models.Item = Backbone.Model.extend({
defaults: function() {
return {
viewtype: '',
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<script type='text/javascript' src='http://code.jquery.com/jquery-git2.js'></script>
<style type='text/css'>
.selected {
background: #f00;
}
@foo9
foo9 / gist:6267702
Last active December 21, 2015 06:59
on work_folder(the_path)
tell application "Finder"
set the_files to every file of the_path
repeat with afile in the_files
peel_label(afile) of me
end repeat
set the_folders to every folder of the_path
@foo9
foo9 / gist:6304230
Created August 22, 2013 07:45
Copy POSIX Path to Clipboard
to joinList(aList, delimiter)
set retVal to ""
set prevDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set retVal to aList as string
set AppleScript's text item delimiters to prevDelimiter
return retVal
end joinList
on run {input, parameters}
@foo9
foo9 / gist:6590945
Last active December 23, 2015 05:59
contenteditableを使って簡単にドキュメントを翻訳できる仕組みを作りたい。
(function() {
var map = {};
var elems = document.querySelectorAll('h1, h2, h3, h4, h5, h6, h7, p, li, dt, dd');
var cid;
var text;
for (var i = 0, iz = elems.length; i < iz; i++) {
cid = 'c' + i;
elems[i].setAttribute('contenteditable', 'true');
elems[i].setAttribute('data-cid', cid);
@foo9
foo9 / gist:6724770
Created September 27, 2013 06:20
Ctrl + s
$(document).on('keydown', function(event) {
if ((event.which == 115 || event.which == 83) && (event.ctrlKey || event.metaKey) || (event.which == 19)) {
event.preventDefault();
// do something
return false;
}
return true;
});
@foo9
foo9 / backbone-shape.js
Last active December 25, 2015 02:39
Backbone.js & svg.js
Backbone.Shape = {};
Backbone.Shape.Rect = Backbone.View.extend({
className: 'shape rect',
isClosed: false,
paper: null,
shape: null,
body {
background: #ccc;
}
@foo9
foo9 / gist:7152506
Last active December 26, 2015 12:39
$(function () {
var $win = $(window);
var $doc = $(document);
var $body = $('body');
var winWidth = $win.width();
var winHeight = $win.height();
var $vertical = $('<div/>').css({
position: 'absolute',
top: 0,
left: winWidth * 0.5,