Skip to content

Instantly share code, notes, and snippets.

View naoyashiga's full-sized avatar

Naoya / nao-chan / naoya-tech naoyashiga

View GitHub Profile
@naoyashiga
naoyashiga / file0.swift
Last active October 4, 2015 14:39
[Swift]省略記法で$0.0と$0.1を使う例 ref: http://qiita.com/naoyashiga/items/4f06692c2c9a652f36ba
let array = ["カレー","ラーメン","ハンバーグ"]
array.enumerate().forEach { (index, element) in
print("index:\(index) element:\(element)")
}
//省略記法
array.enumerate().forEach {
print("index:\($0.0) element:\($0.1)")
}
@naoyashiga
naoyashiga / BaseParticleWithVector.pde
Last active August 29, 2015 14:28
Trigonometric function(三角関数) ~ Interactive Coding workshop at Tokyo ~
class BaseParticleWithVector implements BaseParticleWithVectorInterface {
PVector location;
PVector velocity;
float scalarVelocity;
float r;
BaseParticleWithVector() {
location = new PVector(random(width), random(height));
velocity = new PVector(0, 0);
@naoyashiga
naoyashiga / UIButton+Animation.swift
Created August 18, 2015 23:14
Implicit and Explicit Bounce Animation Button
extension UIButton {
func playImplicitBounceAnimation() {
let bounceAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
bounceAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
bounceAnimation.duration = NSTimeInterval(0.5)
bounceAnimation.calculationMode = kCAAnimationCubic
layer.addAnimation(bounceAnimation, forKey: "bounceAnimation")
}
@naoyashiga
naoyashiga / SampleViewController.swift
Created August 1, 2015 06:15
rootViewControllerのときだけNavigationBarを非表示にさせる ref: http://qiita.com/naoyashiga/items/c1dc03a60df085321fe3
override func viewWillDisappear(animated: Bool) {
navigationController?.setNavigationBarHidden(true, animated: true)
}
override func viewWillAppear(animated: Bool) {
navigationController?.setNavigationBarHidden(false, animated: true)
}
@naoyashiga
naoyashiga / TimingFunction.swift
Created May 28, 2015 11:46
TimingFunction.swift
import Foundation
enum timingFunction{
case Linear,EaseIn,EaseOut,EaseInOut,
Spring,
EaseInSine,EaseOutSine,EaseInOutSine,
EaseInQuad,EaseOutQuad,EaseInOutQuad,
EaseInCubic,EaseOutCubic,EaseInOutCubic,
EaseInQuart,EaseOutQuart,EaseInOutQuart,
EaseInQuint,EaseOutQuint,EaseInOutQuint,
@naoyashiga
naoyashiga / main.js
Created May 16, 2015 10:14
Convert Photoshop Textlayer text to json
(function(){
"use strict";
var PLUGIN_ID = require("./package.json").name,
MENU_ID = "tutorial",
MENU_LABEL = "$$$/JavaScripts/Generator/Tutorial/Menu=Tutorial";
var _generator = null,
_currentDocumentId = null,
_config = null;
@naoyashiga
naoyashiga / catApi.rb
Created March 18, 2015 13:30
Seeing a cat image or GIF by using the Cat API
# -*- encoding: UTF-8 -*-
require 'nokogiri'
require 'open-uri'
API_URL = "http://thecatapi.com/api/images/get?format=xml"
doc = Nokogiri::XML(open(API_URL).read)
url_nodes = doc.xpath("//url").text
@naoyashiga
naoyashiga / gist:3fca2f2e51bc36c5fb09
Created June 3, 2014 12:16
Swift draw Particles.
//
// ViewController.swift
// DrawParticle
//
// Created by naoyashiga on 2014/06/03.
// Copyright (c) 2014年 naoyashiga. All rights reserved.
//
import UIKit