Skip to content

Instantly share code, notes, and snippets.

@uchcode
uchcode / JXAReader.js
Last active April 14, 2022 11:34
JXA with Require
//
// JXAReader.js
//
// Created by uchcode on 2016/05/28.
// Copyright © 2016 uchcode. All rights reserved.
//
function read(fname) {
function LibPath(fname, resourcePath) {
return $(resourcePath + '/Script Libraries/' + fname).stringByStandardizingPath.js
@uchcode
uchcode / nsapp_servicesmenu_example.js
Created June 3, 2016 03:18
NSApp.servicesMenu in JXA
#!/usr/bin/osascript -l JavaScript
ObjC.import('Cocoa')
function MainMenu() {
function MenuItem(title, action, key) {
return $.NSMenuItem.alloc.initWithTitleActionKeyEquivalent(title, action, key)
}
@uchcode
uchcode / bar.scpt
Created June 22, 2016 10:54
runScript() のwithParametersバグとその回避・代替案 ref: http://qiita.com/tom-u/items/a9335672f21e91a4a69d
function run(argv) {
$.NSLog('%@', JSON.stringify(argv))
return argv
}
@uchcode
uchcode / virtualTyping.scpt
Created June 27, 2016 08:06
JXAで日本語入力のエミュレーション ref: http://qiita.com/tom-u/items/e06143e048dde7839c89
ObjC.import('Foundation')
ObjC.import('Carbon')
function virtualTyping(source) {
if (!source) {
throw new Error('Missing source')
}
if (typeof source !== 'string' || source.trim().length === 0) {
throw new Error('Invalid source')
}
@uchcode
uchcode / 0_reuse_code.js
Created June 27, 2016 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@uchcode
uchcode / sam-hello-world.html
Last active July 14, 2016 02:24
State Action Model Patterm(SAM) example
<!DOCTYPE html>
<html>
<body>
<h1>Hello world</h1>
<div id="present"></div>
<script>
@uchcode
uchcode / mvr-hello-world.html
Last active July 14, 2016 08:31
MVR: Model View Reactive pattern
<!DOCTYPE html>
<html>
<body>
<h1>Hello world</h1>
<div id="present"></div>
<script>
@uchcode
uchcode / circulation-hello-world.html
Last active July 15, 2016 04:55
Circulation design pattern.
<!DOCTYPE html>
<html>
<body>
<h1>Circulation design pattern</h1>
<h2>Hello world</h2>
<h3 style="font-size:70%;">for chrome web browser.</h3>
<div id="component"></div>
<div id="application"></div>
@uchcode
uchcode / hello-amv.js
Last active July 18, 2016 12:48
Application( Model, View ) pattern
'use strict';
class Model {
constructor() {
this.name = 'John';
}
}
class View {
render(id, contents) {
@uchcode
uchcode / view-in-app.md
Last active July 21, 2016 12:50
ビューの基本と応用

ビューの基本

出力の例

document.getElementById('contents').innerHTML += '<p>hello again</p>'

アルゴリズムのサブルーチン化