Skip to content

Instantly share code, notes, and snippets.

View fumiyasac's full-sized avatar
🎯
Focusing

Fumiya Sakai fumiyasac

🎯
Focusing
View GitHub Profile
@mogaming217
mogaming217 / sample.tsx
Created January 14, 2022 06:46
useEffectを使っているタイミング
// firebase authを使って、ログインユーザーが変わった時に何か取得する
export const Sample1: VFC = () => {
const [authState, setAuthState] = useState()
useEffect(() => {
if (!process.browser) return
let cancel = false
const unsubscribe = auth.onAuthStateChanged(
async firebaseUser => {
import 'package:collection/collection.dart';
import 'package:grinder/grinder.dart';
void main(List<String> args) => grind(args);
@Task('Open Upgraded Package Changelog')
void openUpgradedPackageChangelog() {
_openUpgradedPackageChangelog(
[
'.',
@sho-ito-1027
sho-ito-1027 / SharedPref.kt
Last active November 12, 2020 06:54
SharedPref.kt
val list: List<String> = listOf("a", "b", "c")
val sharedPreferences = getSharedPreferences("pref", MODE_PRIVATE)
val editor = sharedPreferences.edit()
editor.putString("Key", Gson().toJson(list)).apply()
val jsonData = sharedPreferences.getString("Key", "")
val data = Gson().fromJson(jsonData, ArrayList<String>().javaClass) // ArrayList<String>()::class.java でも書ける
print(data)
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {
import UIKit
class HeaderView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setUp()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
@KyleGoslan
KyleGoslan / UIImage+Extension.swift
Created November 27, 2016 21:47
Resize UIImage Swift 3
import UIKit
extension UIImage {
func resizeWith(percentage: CGFloat) -> UIImage? {
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: size.width * percentage, height: size.height * percentage)))
imageView.contentMode = .scaleAspectFit
imageView.image = self
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
@akuraru
akuraru / 休日一覧.md
Last active August 18, 2017 04:57
祝日についての覚書
休日 期日 適用開始年 適用終了年
元日 1月1日 1948年7月20日 -
元始祭 1月3日 1873年10月14日 1948年7月20日
新年宴会 1月5日 1873年10月14日 1948年7月20日
成人の日 1月15日 1948年7月20日 2000年1月1日
成人の日 1月の第2月曜日 2000年1月1日 -
孝明天皇祭 1月30日 1873年10月14日 1912年
紀元節 2月11日 1873年10月14日 1948年7月20日
extension CollectionType {
func shuffled() -> [Generator.Element] {
var source = Array(self)
var result : [Generator.Element] = []
while !source.isEmpty {
let index = Int(arc4random()) % source.count
result.append(source[index])
source.removeAtIndex(index)
}
return result