Skip to content

Instantly share code, notes, and snippets.

@yurfuwa-chan
yurfuwa-chan / gist:1731770
Created February 3, 2012 19:00
coffeescript loop
for name in ["Roger", "Roderick", "Brian"]
alert "Release #{name}"
for name, i in ["Roger the pickpocket", "Roderick the robber"]
alert "#{i} - Release #{name}
release prisoner for prisoner in ["Roger", "Roderick", "Brian"]
prisoners = ["Roger", "Roderick", "Brian"]
@yurfuwa-chan
yurfuwa-chan / Task.coffee
Created February 17, 2012 22:15
Spine Example:Todos
class Task extends Spine.Model
@configure "Task", "name", "done"
@extend Spine.Model.Local
@active: ->
@select (item) -> !item.done
@done: ->
@select (item) -> !!item.done
@yurfuwa-chan
yurfuwa-chan / gist:1892747
Created February 23, 2012 13:19
ライブラリ内のアイテムを走査して、ステージに配置されているアイテムを探す
var doc = fl.getDocumentDOM()
var lib = doc.library.items
lib.forEach(function(item){
if(item instanceof SymbolItem){
var timeline = item.timeline
timeline.layers.forEach(function(layer){
layer.frames.forEach(function(frame){
frame.elements.forEach(function(element){
if(element instanceof Instance && element.libraryItem.name == "hoge"){
@yurfuwa-chan
yurfuwa-chan / Array.js
Created March 2, 2012 13:06
IE7,8にArray.indexofがない件
if(!Array.prototype.indexOf){
Array.prototype.indexOf = function(obj){
var l = this.length;
if(l){
for(var i=0;i<l;i++){
if(this[i] === obj)return i
}
}
return -1
}
@yurfuwa-chan
yurfuwa-chan / jquery.myplugin.coffee
Created March 7, 2012 12:18 — forked from jimeh/jquery.myplugin.coffee
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
test:(options)->
self = $.fn.test
opts = $.extend {}, self.default_options, options
$.extend $.fn.test,
default_options:
version: '1.0'
@yurfuwa-chan
yurfuwa-chan / jquery.inputCheckbox.coffee
Created March 7, 2012 13:47
チェックボックスを自動で全部有効化したり解除したりするjquery plugin
class Module
@isInputElement:(el)->
el instanceof HTMLInputElement
@Module = Module
$.fn.extend
allChecked:()->
@each (i,el)=>
el.checked = true if Module.isInputElement(el)
@yurfuwa-chan
yurfuwa-chan / just.html
Created March 23, 2012 19:59
api.html5please.com
<div id="h5p-message"></div> <script>window.h5please=function(a){ document.getElementById("h5p-message").innerHTML=a.html }</script> <script async src="http://api.html5please.com/websockets.json?callback=h5please&texticon&html"></script>
codestream API_KEY
#closeSign {
animation: swing ease-in-out 9s;
-webkit-animation: swing ease-in-out 9s;
-moz-animation: swing ease-in-out 9s;
-webkit-transform-origin: 50% 0%;
-moz-transform-origin: 50% 0% }
@-keyframes swing { 0% }
10% { -transform: rotate(-2deg) }
@yurfuwa-chan
yurfuwa-chan / gist:3225801
Created August 1, 2012 11:02
ios ローカルディレクトリに保存
NSData *data = UIImagePNGRepresentation([self trimImage:screenImage :CGRectMake(0, 0, 320, 400)]);
NSString *filePath = [NSString stringWithFormat:@"%@/test.png" , [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]];
if ([data writeToFile:filePath atomically:YES]) {
NSLog(@"OK");
} else {
NSLog(@"Error");
}