Skip to content

Instantly share code, notes, and snippets.

佐藤剛士 SatoTakeshiX

Block or report user

Report or block SatoTakeshiX

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SatoTakeshiX
SatoTakeshiX / convert.swift
Created May 29, 2019
UIView convert method
View convert.swift
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = UIColor.blue
View file0.swift
let today = Date() //2018年12月18日に実行
// 中国の農暦 = 旧暦
let chineseCalendar = Calendar(identifier: .chinese)
let comp = chineseCalendar.dateComponents([.year, .month, .day], from: today)
print(comp.debugDescription)
// year: 35 month: 11 day: 12 isLeapMonth: false
@SatoTakeshiX
SatoTakeshiX / CodePiece.swift
Created Dec 18, 2018
Calendar型の.chineseは旧暦、中国の農暦を表すとのこと #swift #CodePiece
View CodePiece.swift
// 旧暦(農暦)
let chine = Calendar(identifier: .chinese)
@SatoTakeshiX
SatoTakeshiX / Fibonacci.swift
Created Oct 27, 2018
フィボナッチ数列
View Fibonacci.swift
// インデックス番号を入れたらその番号のフィボナッチ数を出力
func fib(index: Int) -> Int {
guard index > 1 else { return 1 }
var a = 1
var b = 1
(2...index).forEach { (index) in
(a, b) = (a + b, a)
}
return a
@SatoTakeshiX
SatoTakeshiX / CodePiece.swift
Created Oct 8, 2018
LINE Messageing API、コンテンツ取得するさいのコンテンツの拡張子って何で調べればいいんだと悩んでいたらHeaderに書いてた。。 #結婚式パーティー余興 #CodePiece
View CodePiece.swift
GET https://api.line.me/v2/bot/message/{messageId}/content
@SatoTakeshiX
SatoTakeshiX / CodePiece.swift
Created Mar 1, 2018
このクロージャー、返り値Int? #CodePiece #tryswiftconf
View CodePiece.swift
let myVariable: Int = {
while(true){}
}()
@SatoTakeshiX
SatoTakeshiX / CodePiece.swift
Created Mar 1, 2018
Voidがリターン #CodePiece #tryswiftconf
View CodePiece.swift
var myVariable = 42
let r = (myVariable = 50) //Void
(obj?.myVariable = 50) //Optional<Void>
@SatoTakeshiX
SatoTakeshiX / CodePiece.go
Created Feb 13, 2018
簡単な実装. #read_go #CodePiece
View CodePiece.go
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
z := 1.0
@SatoTakeshiX
SatoTakeshiX / CodePiece.go
Created Feb 13, 2018
定義を上からしなくてもよい。Smallでしたの方に定義したBit定数を使える #read_go #CodePiece
View CodePiece.go
package main
import "fmt"
const (
// Shift it right again 99 places, so we end up with 1<<1, or 2.
Small = Big >> 99
// Create a huge number by shifting a 1 bit left 100 places.
// In other words, the binary number that is 1 followed by 100 zeroes.
Big = 1 << 100
You can’t perform that action at this time.