Skip to content

Instantly share code, notes, and snippets.

@macneko-ayu
macneko-ayu / LayerObjectCount.jsx
Created January 30, 2016 01:58
Illustratorのレイヤーに配置されたオブジェクトの数を数えてファイルに書き出すJavaScript Raw
main();
function main() {
var str = layerObjectCount(app.activeDocument);
writeFile(str);
}
function layerObjectCount(docObj) {
var mergeStrings = "";
for (var i = 0, iLen = docObj.layers.length; i < iLen ; i++) {
@macneko-ayu
macneko-ayu / UINavigationBar+Height.swift
Created March 16, 2017 10:16 — forked from siberianisaev/UINavigationBar+Height.swift
Change height of UINavigationBar
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
@macneko-ayu
macneko-ayu / private.xml
Created May 22, 2018 08:31 — forked from kickbase/private.xml
Karabiner private.xml for Emacs, Vim, VSCode, Unity, Houdini.
<?xml version="1.0"?>
<root>
<appdef>
<appname>TERMINAL</appname>
<equal>com.apple.Terminal</equal>
</appdef>
<appdef>
<appname>ITERM2</appname>
<equal>com.googlecode.iterm2</equal>
</appdef>
@macneko-ayu
macneko-ayu / Playground.swift
Last active February 14, 2019 08:10
UILabelの文字列に線をつけて袋文字にするextension
// Please, paste the code in playground and execute it.
import UIKit
extension UILabel{
/// makeOutLine
///
/// - Parameters:
/// - strokeWidth: 線の太さ。負数
@macneko-ayu
macneko-ayu / hideTableViewCellSeparator.swift
Created May 8, 2019 07:58
UITableViewCellのsubviewsを走査してセパレーターを非表示にするやつ
// 参考:https://stackoverflow.com/questions/29006311/grouped-uitableview-remove-outer-separator-line
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.subviews.forEach { subview in
if subview != cell.contentView, subview.frame.width == cell.frame.width, subview.frame.height == 0.5 {
// 特定のセクション、かつ特定のクラスだけ処理を変える場合
if indexPath.section == 99,
let cell = cell as? SampleTableViewCell {
// TODO: なにかする
} else {
subview.isHidden = true
@macneko-ayu
macneko-ayu / InterfaceController.swift
Last active April 25, 2020 13:05
WKInterfaceLabel to automatically scroll horizontally
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var notEndlessLabel: WKInterfaceLabel!
@IBOutlet var endlessLabel: WKInterfaceLabel!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
@macneko-ayu
macneko-ayu / create-font-sample.jsx
Last active June 10, 2020 23:58
Extendscript for creating font samples in Indesign
// sample movie: https://user-images.githubusercontent.com/5406126/49324964-f631aa80-f57c-11e8-9199-0ab51231422c.gif
main();
function main() {
// 関数定義
function applyFontToStory(targetFont) {
@macneko-ayu
macneko-ayu / StreamReader.swift
Last active November 22, 2020 06:55
A sample file loading process using swift.
import Cocoa
final class Reader {
let fileUrl: URL
var data: Data?
init(filePath: String) {
fileUrl = URL(fileURLWithPath: filePath)
}
@macneko-ayu
macneko-ayu / aiver.swift
Last active November 22, 2020 07:08
Extract the creation application version and saved version of an Illustrator file (ai, eps) ref: https://gist.github.com/monokano/8bffac0c07401627c5a1ebf020b93b0e
import Cocoa
/// ファイルを指定されたバイト数分ずつ読み込む
final class StreamReader: NSObject, StreamDelegate {
let maxLength: Int
let inputStream: InputStream?
var readedAction: (Versions) -> Void = { _ in }
var createVersion = ""
var saveVersion = ""
@macneko-ayu
macneko-ayu / Playground.swift
Created January 25, 2021 14:22
OperationQueue sample
import UIKit
final class SampleOperation: Operation {
let message: String
init(message: String) {
self.message = message
}
override func main() {