Skip to content

Instantly share code, notes, and snippets.

View kumamotone's full-sized avatar
🐈
hello

kumamotone kumamotone

🐈
hello
View GitHub Profile
@kumamotone
kumamotone / gifencode.sh
Created May 9, 2019 08:15
Automation Script
for f in "$@"
do
ext=${f##*.}
if [ $ext = "mov" ]; then
osascript -e 'display notification "'$f'" with title "Gif encode start"'
/usr/local/bin/ffmpeg -i $f -filter_complex "[0:v] fps=8,scale=600:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" $f.gif
osascript -e 'display notification "'$f'" with title "Gif encode end"'
fi
done
@kumamotone
kumamotone / enum.swift
Created September 15, 2018 17:33
Use enum case's name
import Foundation
extension Encodable {
func asDictionary(convertToSnakeCase: Bool = false) throws -> [String: Any] {
let encoder = JSONEncoder()
if convertToSnakeCase { encoder.keyEncodingStrategy = .convertToSnakeCase }
let data = try encoder.encode(self)
guard let dictionary = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
throw NSError()
}
return dictionary
@kumamotone
kumamotone / gridview.xml
Created July 6, 2018 10:54
GridView で端まで広げる
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:stretchMode="columnWidth"
android:numColumns="2"/>
@kumamotone
kumamotone / gridlayoutmanager.kt
Created July 6, 2018 10:53
GridLayoutManager で 最初の行だけ打ち抜きで表示する
recyclerView.also { recyclerView ->
val columnsNum = 3
val layoutManager = GridLayoutManager(applicationContext, columnsNum)
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return when (position) {
0 -> columnsNum
else -> 1
}
@kumamotone
kumamotone / ReduceFileSizeCustom.qfilter
Created March 29, 2018 08:29
プレビュー.app の書き出しでQuartzフィルタに指定してやるとPDFのファイルサイズを削減できる デフォルトのReduce File Sizeは画像などが汚くなりすぎるので、個人的に使えそうなぐらいのクオリティにパラメータ調整している /Library/Filters/ReduceFileSizeCustom.qfilter として保存すると良い たしかここを参照した http://d.hatena.ne.jp/zariganitosh/20130312/my_pdf_quartz_filter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Domains</key>
<dict>
<key>Applications</key>
<true/>
<key>Printing</key>
<true/>
@kumamotone
kumamotone / IntToBool.swift
Created March 21, 2018 17:56
A Codable struct converting a Int value to Bool.
public struct IntToBool: Codable {
public var value: Bool
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let intValue = try container.decode(Int.self)
self.value = (intValue != 0)
}
public init(value: Bool) {
@kumamotone
kumamotone / rmlist.js
Created February 18, 2018 03:46
RM Bridgeでキャプチャした信号  シーリングライトはパナソニック HH-CB0870A https://www.amazon.co.jp/dp/B01G568LVC/ エアコンは 白くまくん RAS-R22B
module.exports = {"light_on":
"2600ac00723a0d0f0d100d2c0d2c0d100c2d0c100d100c100d2c0d100c100d2c0d100c2d0c100d2c0d100c100d2c0d100c100d100c110c2d0c100d2c0d2c0d100c2d0c100d100c110c100c2d0c100d100c2d0c110c100c0009a1703a0d100c110c2c0d2d0c100c2d0c100d110b100d2c0d100c100d2c0d110b2d0d100c2d0c100d110b2d0c100d110b100d110b2d0c110c2c0d2c0d110b2d0c110c110b110c110b2d0c110c110c2c0d100c100d000d05000000000000000000000000",
"light_off":"2600ac00723a0d0f0d100d2c0d2c0d0f0d2c0d100d0f0d100d2c0d100c100d2c0d100c2d0c100d2c0d100c100d2c0d100d0f0d100c100d2c0d2c0d2c0d2c0d100d2c0d0f0d100d0f0d2d0c2d0c100d100c2d0c100d100c00099e733a0d100c100d2c0d2c0d100c2d0c100d100c100d2c0d100c110c2c0d100c2d0d0f0d2c0d100d100c2c0d110c100c100d100c2d0c2d0c2d0c2d0c100d2c0d100c100d100c2d0d2c0d100c100d2c0d0f0d100d000d05000000000000000000000000",
"aircon_off":"26005c030003eb00068c6c380d2b0c0f0c100c0f0d0f0c0f0d0f0c0f0d0f0c100c0f0c100c2b0c0f0d0f0c0f0d0f0c100c0f0c100c0f0d0f0c0f0d0f0c100c0f0c100c0f0d0f0c0f0d2a0d0f0c2b0c2b0d2a0d2a0d2b0c2b0c0f0d2a0d2a0d2b0c2b0c2b0c
@kumamotone
kumamotone / index.js
Created February 18, 2018 03:36
rmminiで家電を操作
var firebase = require("firebase");
var config = {
apiKey: "秘密",
authDomain: "秘密.firebaseapp.com",
databaseURL: "https://秘密.firebaseio.com",
projectId: "秘密",
storageBucket: "",
messagingSenderId: "秘密"
};
firebase.initializeApp(config);
@kumamotone
kumamotone / WeatherStationActivity.kt
Last active February 18, 2018 02:56
WeatherStationActivity.kt
class WeatherStationActivity : Activity() {
private var mDisplay: AlphanumericDisplay? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d(TAG, "Weather Station Started")
try {
mDisplay = RainbowHat.openDisplay()
mDisplay?.setEnabled(true)
@kumamotone
kumamotone / WeatherStationActivity.java
Created February 18, 2018 02:50
WeatherStationActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "Weather Station Started");
try {
mDisplay = RainbowHat.openDisplay();
mDisplay.setEnabled(true);
mDisplay.display("OK ");