This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPTNAME=$(basename "$0") | |
function realpath () { | |
f=$@; | |
if [ -d "$f" ]; then | |
base=""; | |
dir="$f"; | |
else | |
base="/$(basename "$f")"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To Compile: cc -fobjc-arc -framework Cocoa -framework CoreImage monochro.m -o monochro | |
#import <Cocoa/Cocoa.h> | |
#import <CoreImage/CoreImage.h> | |
#include <stdio.h> | |
void usage() | |
{ | |
printf("Usage: argv[0] < INPUTFILE > OUTPUTFILE\n"); | |
printf(" argv[0] INPUTFILE > OUTPUTFILE\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To Compile: cc -fobjc-arc -framework Cocoa -framework Photos random256x256.m -o random256x256 | |
#import <Cocoa/Cocoa.h> | |
#import <Photos/Photos.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
@autoreleasepool{ | |
PHFetchResult *assets = [PHAsset fetchAssetsWithMediaType: PHAssetMediaTypeImage options: nil]; | |
NSUInteger idx = arc4random() % assets.count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreLocation/CoreLocation.h> | |
#import <Foundation/Foundation.h> | |
// CoreLocation を使って住所から 経度・緯度を求める。 | |
// 引数は住所。空白を含む場合はクオートすること。 | |
// COMPILE: cc -fobjc-arc -framework Foundation -framework CoreLocation AddressToCoordinate.m -o AddressToCoordinate | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool{ | |
__block int ret = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile: | |
// cc -framework Foundation listEraSymbols.m -o listEraSymbols | |
// Usage: listEraSymbols [locale] | |
// Examples: | |
// listEraSymbols -- Gengo List in default Language (C locale) | |
// listEraSymbols ja_JP -- Gengo List in Japanese | |
// listEraSymbols zh_CN -- Gengo List in Chinese | |
// listEraSymbols en_US -- Gengo List in English |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Photos" | |
activate | |
tell album "動画" -- 「写真」が「ムービー」「である」スマートアルバム (Smart album that collect all movie files) | |
set outFolder to choose folder | |
set mvList to media items whose (width = 3840 or height = 3840) | |
export mvList to outFolder with using originals | |
end tell | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// parse a date and time | |
#import <Foundation/Foundation.h> | |
int | |
main(int argc, char *argv[]) | |
{ | |
@autoreleasepool{ | |
NSError *error = nil; | |
if(argc != 2){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- use AppleScript version "2.4" | |
-- use scripting additions | |
use framework "Foundation" | |
set aRec to {q:"hogbehoge", n:999} -- AppleScript's Record | |
-- create an instance of NSMutableDictionary | |
set aDic to current application's (NSMutableDictionary's dictionaryWithDictionary:aRec) | |
-- use NSMutableDictionary's methods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Microsoft Excel" | |
activate | |
set sheet_num to count sheets | |
repeat with i from 1 to sheet_num - 1 | |
move sheet 1 to after sheet (sheet_num - i + 1) | |
end repeat | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set targetList to {"/Users/rok/tmp/", "/Users/rok/work/"} | |
tell application "Finder" | |
activate | |
set tabCount to count targetList | |
if tabCount ≥ 1 then | |
open (item 1 of targetList) as POSIX file | |
tell front window | |
repeat with i from 2 to tabCount |
NewerOlder