Skip to content

Instantly share code, notes, and snippets.

View kumamotone's full-sized avatar
🐈
hello

kumamotone kumamotone

🐈
hello
View GitHub Profile
@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 / 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 / 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 / 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 / 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
import Foundation
import Combine
struct MyPublisher: Publisher {
typealias Output = Int
typealias Failure = Error
func receive<S>(subscriber: S) where S : Subscriber,
Failure == S.Failure,
Output == S.Input {
@kumamotone
kumamotone / movtogif.sh
Created August 12, 2019 11:37
Making GIF Animation by ffmpeg
osascript -e 'display notification "start" with title "GIF Encode"'
/usr/local/bin/ffmpeg -i "${@}" -filter_complex "[0:v] fps=8,scale=600:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" "${@}".gif
osascript -e 'display notification "Gif encode end"'
import SwiftUI
struct GameSettings {
var isHard: Bool = false
}
struct NextView: View {
@Binding var settings: GameSettings
var body: some View {
@kumamotone
kumamotone / viewHeight.swift
Created February 6, 2020 10:21
仮想的にUIHostingControllerのなかにぶちこんで高さを取得する
let canvas = swiftuiView
let hosting = UIHostingController(rootView: canvas)
hosting.view.frame = window.frame
window.addSubview(hosting.view)
window.makeKeyAndVisible()
hosting.view // これが UIView
@kumamotone
kumamotone / gist:ee2dc368f5bb1cfe846bd509f0a92689
Created April 12, 2020 15:35
OnlineJudgeHelperで毎回ファイルをダウンロードし直す
diff --git a/onlinejudge.py b/onlinejudge.py
index 16f3f48..80100ae 100644
--- a/onlinejudge.py
+++ b/onlinejudge.py
@@ -149,6 +149,9 @@ class OnlineJudge:
print('CompileError')
exit(-1)
+ for input_file_path in glob.iglob(os.path.join(self.options.testcase_directory, '*.in.txt')):
+ os.remove(input_file_path)