Skip to content

Instantly share code, notes, and snippets.

View STAR-ZERO's full-sized avatar

Kenji Abe STAR-ZERO

View GitHub Profile
@STAR-ZERO
STAR-ZERO / PostprocessBuildPlayer.rb
Last active June 12, 2023 10:26
UnityのiOSビルド時にFrameworkを追加する
#!/usr/bin/env ruby
require 'xcodeproj'
require 'fileutils'
PROJECT = 'Unity-iPhone'
TARGET = 'Unity-iPhone'
LIBRARY = 'Libraries'
# システムFramework追加
@STAR-ZERO
STAR-ZERO / gist:5928936
Last active March 15, 2023 03:53
動的にiTerm2の背景画像を変える

動的にiTerm2の背景画像を変える

こんな感じのをzshrcに書く。この場合、@キーで画像が変わる。

image_list=("画像1" "画像2") # 絶対パス
image_index=1
bg() {
    if [ -z "$BUFFER" ]; then
        if test $image_index -eq 2; then
@STAR-ZERO
STAR-ZERO / gist:3413415
Created August 21, 2012 08:13
【Android】画像を縮小して読み込み、画像リサイズ
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
/**
* 画像変換クラス
*
*/
public class BitmapUtil {
@STAR-ZERO
STAR-ZERO / SampleFragment.java
Created December 18, 2012 08:39
【Android】AsyncTaskLoaderのサンプル
public class SampleFragment extends Fragment implements LoaderCallbacks<String> {
private static final int LOADER_ID = 0;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_main, container, false);
}
@Override
@STAR-ZERO
STAR-ZERO / MainActivity.kt
Created July 1, 2021 01:31
androidx.core:core-splashscreen の雑サンプル
class MainActivity : AppCompatActivity() {
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen() // ★ SplashScreenを適用
setContentView(R.layout.activity_main)
splashScreen.setKeepVisibleCondition {  // ★ ここでtrueを返してる間はSplashScreenが表示されたまま
@STAR-ZERO
STAR-ZERO / ConcatAdapterExtension.kt
Created October 15, 2020 08:47
Find an adapter from ConcatAdapter global position.
fun ConcatAdapter.findAdapter(position: Int): RecyclerView.Adapter<*>? {
var totalCount = 0
adapters.forEach { adapter ->
totalCount += adapter.itemCount
if (position < totalCount) {
return adapter
}
}
return null
}
@STAR-ZERO
STAR-ZERO / Android resize drawable.jsx
Last active May 31, 2020 07:16
Androidのxxxhdpiの画像から各解像度にリサイズするPhotoshopスクリプト
try {
var xxhdpiImage = File.openDialog("Select xxxhdpi file.", "*.png", false);
if (xxhdpiImage == null) {
throw "";
}
var doc = open(xxhdpiImage, OpenDocumentType.PNG);
if (doc == null) {
@STAR-ZERO
STAR-ZERO / PostprocessBuildPlayer.rb
Last active February 21, 2020 05:44
UnityのiOSビルド時にローカライズファイルを設定する
#!/usr/bin/env ruby
require 'xcodeproj'
require 'fileutils'
PROJECT = 'Unity-iPhone'
TARGET = 'Unity-iPhone'
LIBRARY = 'Libraries'
LOCALIZE = 'Localize'
@STAR-ZERO
STAR-ZERO / about.md
Created March 1, 2012 07:23
要素内の文字の行数を取得する

要素内の文字の行数を取得する

テキトーに書いた。 Chromeでしか確認してない。

@STAR-ZERO
STAR-ZERO / AsyncLiveData.kt
Created June 19, 2017 03:00
LiveData + Kotlin Coroutine
// compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.16"
// compile "android.arch.lifecycle:runtime:1.0.0-alpha3"
// compile "android.arch.lifecycle:extensions:1.0.0-alpha3"
// kapt "android.arch.lifecycle:compiler:1.0.0-alpha3"
class AsyncLiveData<T> private constructor(private val exec: suspend () -> T) : LiveData<T>() {
private var observer: Observer<T>? = null
private var job: Job? = null