Skip to content

Instantly share code, notes, and snippets.

View touyou's full-sized avatar
💻
Develop Design

Fujii Yosuke touyou

💻
Develop Design
View GitHub Profile
@surajsau
surajsau / ParallaxScreen.kt
Last active June 28, 2024 21:14
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
@Treeki
Treeki / TurnipPrices.cpp
Last active May 27, 2024 15:18
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// munged from https://github.com/simontime/Resead
namespace sead
{
class Random
{
@ha1f
ha1f / NthTimeLucky.swift
Last active May 25, 2018 03:22
An Observable emits item only if _current == timeToLucky. Useful for testing.
//
// NthTimeLucky.swift
//
// Created by はるふ on 2018/05/24.
// Copyright © 2018年 ha1f. All rights reserved.
//
import Foundation
import RxSwift
#coding: utf-8
import threading
import socket
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse
page_head = """
<!doctype html>
@mono0926
mono0926 / nil.swift
Last active December 1, 2016 06:39
class MyClass {
var value: Int?
// nilである時に呼び出されることを普通に想定しているならこんな感じ
func someMethod1() {
guard let value = value else {
return
}
print(value)
}
@ha1f
ha1f / Regex.swift
Last active May 5, 2020 18:36
Swiftで正規表現
//
// Regex.swift
// ha1fRegex
//
// Created by はるふ on 2016/09/30.
// Copyright © 2016年 はるふ. All rights reserved.
//
import Foundation
@shu223
shu223 / CustomActivity.swift
Last active November 4, 2020 17:59
Custom UIActivity in Swift 3
import UIKit
class CustomActivity: UIActivity {
override class var activityCategory: UIActivityCategory {
return .action
}
override var activityType: UIActivityType? {
guard let bundleId = Bundle.main.bundleIdentifier else {return nil}
@gamako
gamako / optional+swift2LikeFlatmap.swift
Created May 17, 2016 12:30
RxSwift extension for flatmap like Swift2.x
extension Observable {
/**
example:
Observable<String>.of("1", "a", "3", "4")
.flatMap { Int($0) }
.subscribeNext { print("\($0)") }
result:
1
3
4
@uramonk
uramonk / mnist_for_ml_beginners.py
Created May 12, 2016 02:31
TensorFlow MNIST For ML Beginners チュートリアルのコード
# -*- coding: utf-8 -*-
# TensowFlowのインポート
import tensorflow as tf
# MNISTを読み込むためinput_data.pyを同じディレクトリに置きインポートする
# input_data.pyはチュートリアル内にリンクがあるのでそこから取得する
# https://tensorflow.googlesource.com/tensorflow/+/master/tensorflow/examples/tutorials/mnist/input_data.py
import input_data
import time
@shuhei
shuhei / couple.rb
Created May 9, 2016 16:23
愛を生む二人を探して
# Extract meaningful bits.
# https://en.wikipedia.org/wiki/UTF-8#Description
def code_bits(bits)
bits.each_slice(8).with_index.map do |byte, i|
i == 0 ? byte[4..-1] : byte[2..-1]
end.flatten
end
# Returns unicode charactor from bits.
def bits_to_char(bits)