Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshihiko Arai araemon

View GitHub Profile
View debug.swift
#if DEBUG
print("デバッグ時のみ実行")
#else
print("リリース時のみ実行")
#endif
View singleton.swift
class Hoge {
static let shared = Hoge()
func doSomething() {
...
}
}
View myColor.swift
extension UIColor {
class var hogeColor: UIColor {
return UIColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1)
}
}
View radar.py
# -*- coding: utf-8 -*-
# このプログラムはpython2で実行すること
import RPi.GPIO as GPIO
import time
import os
import signal
GPIO.setmode(GPIO.BCM) # 役割ピン番号で命名
TRIG = 20
View hc-sr04.py
# -*- coding: utf-8 -*-
# python2で実行すること
import RPi.GPIO as GPIO
import time
import os
import signal
GPIO.setmode(GPIO.BCM)
TRIG = 20
View servo.py
# -*- coding: utf-8 -*-
# python2で実行すること
import RPi.GPIO as GPIO
import time
import os
import signal
GPIO.setmode(GPIO.BCM)
SIG = 26
View factorial.py
n = 5
r = 3
result = factorial(n) / (factorial(n - r) * factorial(r))
print(result)
View factorial.py
def factorial(n):
res = 1
for i in range(1, n + 1):
res *= i
return res
View combination.py
n = 35
total = 0
for r in range(1, n+1):
res = combination(n, r)
print("{n}C{r} = {res}".format(
n=n,
r=r,
res=res))
total += res
View combination.py
def combination(n, r):
return factorial(n) / (factorial(n - r) * factorial(r))
You can’t perform that action at this time.