Skip to content

Instantly share code, notes, and snippets.

@watr
watr / gist:1594883
Created January 11, 2012 14:23
Launch Reminder.app on iOS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"x-apple-reminder://"]];
@watr
watr / CellosSing
Created February 23, 2012 14:21
Mac sing a song "In the Hall of the Mountain King" using word you gave.
#!/bin/sh
################################
# set base word
################################
DEFAULT_WORD="foo"
word=$DEFAULT_WORD
# if argument exists, update word with argument[1]
if [ $# -gt 0 ]; then
word=$1
fi
@watr
watr / print all git remote branches
Created February 25, 2013 05:20
Print all git remote branches.
#!/bin/bash
current_directory=`pwd`;
echo "current directory: ""$current_directory";
find . -name ".git" | while read local_git_folder;
do
cd "$local_git_folder";
cd ..;
parent=`pwd`;
name=`basename "$parent"`;
@watr
watr / UIImage+BezierPath.h
Created April 23, 2014 01:07
Convenient category to create UIImage from UIBezierPath
#import <UIKit/UIKit.h>
@interface UIImage (BezierPath)
+ (UIImage *)imageWithBezierPathFill:(UIBezierPath *)bezierPath;
+ (UIImage *)imageWithBezierPathStroke:(UIBezierPath *)bezierPath;
@end
@watr
watr / remove_images_on_added.rb
Created January 26, 2016 05:05
remove image files on added
#! /bin/sh
exec ruby -S -x "$0" "$@"
#! ruby
require 'fssm'
specified_path = ARGV[0]
# 渡されたパラメータがあれば、それを監視対象のディレクトリにする。
# なければ、ワーキングディレクトリを監視対象にする。
@watr
watr / open-line-sticker-shop-with-app-builtin-store.js
Last active July 28, 2016 14:18
Bookmarklet opens LINE sticker shop with LINE.app builtin store. (Works on iOS but NOT work on macOS.)
javascript:window.location=window.location.href.replace(/(http|https):\/\/store.line.me\/stickershop\/product\/([0-9]*)(\/\w*)/g,'line:\/\/shop\/detail\/$2')
@watr
watr / play-video-in-webbrowser-with-captions.html
Created July 31, 2016 03:55
Play video in web browser with captions(.vtt).
<html>
<body>
<video controls autoplay name="media" style="max-width:100%; max-height:100%">
<source src="Branching Paths Playism 1080p.mp4" type="video/mp4">
<track label="Japanese" kind="captions" src="Branching paths_JP.vtt" srclang="ja" default></track>
</video>
</body>
</html>
@watr
watr / add-artwork-to-m4a.sh
Last active June 23, 2024 16:20
find artwork image and add to '*.m4a' files
## this script depends on 'mp4art', one part of 'mp4v2'.
# brew install mp4v2
## if you need to remove artworks first,
# find . -type f -name '*.m4a' -print0 | xargs -0 mp4art --remove
## find local artwork image file and add to '*.m4a' files
artwork=`find . -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) -print | head -1`;
if [ -e "$artwork" ]; then find . -type f -name '*.m4a' -print0 | xargs -0 mp4art --add "$artwork" ; fi
import Foundation
extension CharacterSet {
static var fileNameAllowed: CharacterSet {
return CharacterSet(charactersIn: "/").inverted
}
}
@watr
watr / macos-deployment-target.sh
Last active December 13, 2016 07:15
print macOS binary's deployment target
#!/bin/sh
## usase: $ sh ./macos-deployment-targer.sh <path-to-binary>
path_to_binary="$1"
otool -lv "$path_to_binary" | grep -A 3 LC_VERSION_MIN_MACOSX | grep "version" | awk '{print $2;}'