Skip to content

Instantly share code, notes, and snippets.

View daisuke-nomura's full-sized avatar

Daisuke Nomura daisuke-nomura

View GitHub Profile
@TomoyaShibata
TomoyaShibata / MainActivity.kt
Last active September 8, 2018 10:56
Kotlin Coroutines でリトライをしながら通信を試行する
package com.example.tomoyashibata.myapplication
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.experimental.CommonPool
@Tanapruk
Tanapruk / Camera2.md
Last active October 20, 2022 07:49
Camera2 API

TextureView

You need to initialize TextureView before opening a camera. TextureView is for displaying the image from camera on the device. However, you cannot use it unless the texture is ready, either because the screen is currently off or it is initializing.

You should check mTextureView.isAvailable() before opening your camera. Else you will mTextureView.setSurfaceTextureListener(). And open your camera in the callback method onSurfaceTextureListener.

Camera

Before opening your camera you should check for a camera permission first.

@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alumican
alumican / ReplaceFont.as
Last active December 11, 2015 17:19
FlashのTextField内の特定文字列を指定したフォントに置換するスクリプト
/**
* TextField内のアスキー文字列(半角英数記号)を指定のフォントに置換する
* @param field 操作対象のTextField
* @param font 置換後のフォント
*/
function replaceAsciiFont(tf:TextField, font:String):void
{
replaceFont(tf, /[\u0020-\u007e]+/g, font);
}
@dakatsuka
dakatsuka / gist:4275258
Created December 13, 2012 09:32
CentOS 5.8 - ufwでファイアーウォールの設定

CentOS 5.8 - ufwでファイアーウォールの設定

Ubuntuのぬるま湯につかっていたのでFWはufwで済ませたい。

CentOS 5.8に標準で入っているPythonだとufwが動かないので2.7を入れる。

$ su -
# cd /usr/local/src
# wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
# tar zxvf Python-2.7.1.tgz 
@JakeWharton
JakeWharton / AspectRatioImageView.java
Created June 2, 2012 02:14
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
@miyukki
miyukki / ZeroFix.user.js
Created May 2, 2012 08:48
ZeroFix is ZeroWatch of niconico fixer. ZeroWatchが改良するまでの暫定的なユーザースクリプトです。 タイトルの縮小、タグの複数段表示、市場エリアを投稿者情報に、コメント入力エリアを下に、フェードを無効化などの機能があります。
// ==UserScript==
// @name ZeroFix
// @namespace applest.net
// @version 0.9
// @description ZeroFix is ZeroWatch of niconico fixer. ZeroWatchが改良するまでの暫定的なユーザースクリプトです。 タイトルの縮小、タグの複数段表示、市場エリアを投稿者情報に、コメント入力エリアを下に、フェードを無効化などの機能があります。
// @include http://www.nicovideo.jp/watch/*
// @license MIT License(http://en.wikipedia.org/wiki/MIT_License)
// ==/UserScript==
/*********************************************