Skip to content

Instantly share code, notes, and snippets.

View hosshan's full-sized avatar

Shun Hosaka hosshan

View GitHub Profile
@hosshan
hosshan / Variable.kt
Last active March 28, 2018 05:30
RxSwift's Variable.swfit convert to Kotlin
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
/**
* Wrapping Rx BehaviorSubject defaultValue object.
* RxSwfit Variable.swfit https://github.com/jspahrsummers/RxSwift/blob/master/RxSwift/SpinLock.swift
*/
class Variable<T> private constructor(defaultValue: T?) {
companion object {
fun <T> create(): Variable<T> = Variable(null)
@hosshan
hosshan / RxLifecycleObserver.kt
Last active June 25, 2017 07:50
Subscribe LifecycleObserver event as RxLifecycle's LifecycleProvider
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.OnLifecycleEvent
import com.trello.rxlifecycle2.LifecycleProvider
import com.trello.rxlifecycle2.LifecycleTransformer
import com.trello.rxlifecycle2.OutsideLifecycleException
import com.trello.rxlifecycle2.RxLifecycle
import io.reactivex.Observable
import io.reactivex.functions.Function
import io.reactivex.subjects.BehaviorSubject
@hosshan
hosshan / Create github issue from GAS
Last active January 15, 2018 03:34
Create github issue from Google app script sample.
var ghToken = "Your GitHub Token";
function myFunction() {
//1. 現在のスプレッドシートを取得
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
//2. 現在のシートを取得
var sheet = spreadsheet.getActiveSheet();
for(var i=2; ; i++) {
var title = sheet.getRange("B" + i).getValue();
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.constraintlayout.widget.ConstraintHelper
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
class FocusableGroup @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
@hosshan
hosshan / file_search.sh
Created April 8, 2019 04:19
ファイルの一覧と、行数などの入出力を行うスクリプト
for file in $(cat)
do
wc $file | sed -E 's/ +/ /g' | tr " " "\t"
done
# 対象OS:Mac
# コマンドの使用方法
# ls | sh file_search.sh
# find . -name "*.h" | sh file_search.sh
# wcの吐き出しが、複数のスペースにっているのを1つのスペースに圧縮して、タブに置き換える。
@hosshan
hosshan / PawEndPointGenerator.js
Created August 11, 2019 16:28
Paw export only request group and request url end point
(function() {
var EndPointsGenerator;
function logRequestVariableInfo(requestVariable) {
console.log('Request Variable: ' + requestVariable.name + '\n' +
' Request: ' + requestVariable.request.name + '\n' +
' Value: ' + requestVariable.value + '\n' +
' Description: ' + requestVariable.description + '\n' +
' Required: ' + requestVariable.required + '\n' +
' Schema: ' + JSON.stringify(requestVariable.schema));
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import csv
from urllib.request import urlopen
from bs4 import BeautifulSoup
import ssl
def parse_td_contents(cv):
if len(cv.contents) > 0:
return cv.contents[0]
else: