Skip to content

Instantly share code, notes, and snippets.

View Slowhand0309's full-sized avatar
🏠
Working from home

Slowhand Slowhand0309

🏠
Working from home
View GitHub Profile
@Slowhand0309
Slowhand0309 / ContextExt.kt
Created July 27, 2019 04:50
[Kotlin Extension Context] #Kotlin #Android
/**
* Toastの簡易版
*
* @param text 表示文字列
* @param duration デフォルト: Toast.LENGTH_LONG
* @return {@link Toast}
*/
@Suppress("NOTHING_TO_INLINE")
inline fun Context.toast(text: CharSequence, duration: Int = Toast.LENGTH_LONG): Toast {
@Slowhand0309
Slowhand0309 / gradle.properties
Last active September 18, 2020 07:48
[Android Gradleビルド高速化設定] gradle.propertiesの設定 #Android #Gradle
#メモリ -Xmx: AndroidStudio起動時
org.gradle.jvmargs=-Xmx3072M -Xmx4096M -XX:MaxPermSize=2048M
#並列ビルドモードを有効
org.gradle.parallel=true
#必要な部分をビルド
org.gradle.configureondemand=true
#デーモンプロセスを使う
org.gradle.daemon=true
@Slowhand0309
Slowhand0309 / ServiceGenerator.kt
Created June 3, 2018 22:34
Retrofit+Rx+Moshi+Log sample.
object ServiceGenerator {
private lateinit var moshi: Moshi
private lateinit var retrofit: Retrofit
/**
* Initialize{@link Moshi}and{@link Retrofit}
*/
fun init(context: Context?) {
moshi = Moshi.Builder()
@Slowhand0309
Slowhand0309 / Commands-Xcode.txt
Last active July 27, 2019 05:27
[Command lists related to Xcode] #Xcode #Command
# Show current path
xcode-select -print-path
# Switch xcode
xcode-select --switch /Applications/XcodeXX.app
# Search active xcodebuild path
xcrun --find xcodebuild
# Show simulator list
@Slowhand0309
Slowhand0309 / tree_ignore_example
Last active July 27, 2019 05:29
[Tree command with ignore pattern] #Command
tree -a -I '.git|node_modules|.bundle|vendor|.DS_Store'
@Slowhand0309
Slowhand0309 / get_battery.sh
Created July 17, 2016 14:37
Get battery percent of mouse
#!/usr/bin/env bash
# Mouse
ioreg -c BNBMouseDevice | grep BatteryPercent | grep -v { | sed 's/[^[:digit:]]//g'
# Keyboard
ioreg -c AppleBluetoothHIDKeyboard | grep BatteryPercent | grep -v { | sed 's/[^[:digit:]]//g'
@Slowhand0309
Slowhand0309 / canvas_loupe.js
Last active August 31, 2018 14:46
Loupe on html5 canvas.
/**
* canvas_loupe.js
*/
var loupe = {
x: 0, // Current x.
y: 0, // Current y.
w: 0, // Image width.
h: 0, // Image height.
@Slowhand0309
Slowhand0309 / gist:425e24a5cd01b5a0d0a6
Created January 31, 2016 08:03
Search the defined location for extended method. (ruby)
ex)
irb
2.1.0 :001 > require 'active_support'
=> true
2.1.0 :002 > cahce = ActiveSupport::Cache::MemoryStore.new
=> <#ActiveSupport::Cache::MemoryStore entries=0, size=0, options={}>
2.1.0 :006 > cahce.method(:blank?).source_location
=> ["/Users/xxxx/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.5.1/lib/active_support/core_ext/object/blank.rb", 16]
2.1.0 :007 > cahce.method(:blank?).owner
=> Object
@Slowhand0309
Slowhand0309 / install_test_mac.sh
Last active July 27, 2019 05:29
[Install googletest for cmake] #Script
#!/bin/sh
echo "make directory build"
mkdir build
cd build
cmake ..
make
echo "copy header and library"
sudo cp -r ../googletest/include/gtest /usr/local/include/
@Slowhand0309
Slowhand0309 / update
Created October 24, 2015 09:14
git-hooks update for print info by push
#!/usr/bin/env ruby
refname = ARGV[0]
oldrev = ARGV[1]
newrev = ARGV[2]
puts "push info >> \n(#{refname}) (#{oldrev[0,6]}) (#{newrev[0,6]})"
sharevs = `git rev-list #{oldrev[0,6]}..#{newrev[0,6]}`.split("\n")
sharevs.each do |rev|