Skip to content

Instantly share code, notes, and snippets.

@hoshi-takanori
hoshi-takanori / sync.pl
Created April 3, 2014 05:52
Sync files in local and remote directories via SFTP by perl.
#!/usr/bin/perl
use strict;
use Fcntl ':mode';
use File::stat 'stat';
use Net::SFTP::Foreign;
my $HOST = 'user@example.com';
my $PASS = '********';
my $MORE = [ -o => 'StrictHostKeyChecking no' ];
@hoshi-takanori
hoshi-takanori / MyTest.java
Created April 1, 2014 20:36
Java unit test with JUnit vs groovy's power assert.
import junit.framework.TestCase;
public class MyTest extends TestCase {
private int a, b;
@Override
public void setUp() {
a = 1;
b = 2;
}
@hoshi-takanori
hoshi-takanori / Makefile
Last active October 3, 2019 18:17
Testing Objective-C class by XCTest with plain old Makefile in command line.
CLASS_NAME = MyObject
OBJS = main.o $(CLASS_NAME).o $(CLASS_NAME)Tests.o
PROGRAM = a.out
CFLAGS = -Wall -F$(FWPATH)
LIBS = -F$(FWPATH) -framework XCTest -framework Foundation
FWPATH = /Applications/Xcode.app/Contents/Developer/Library/Frameworks
XCTEST = /Applications/Xcode.app/Contents/Developer/usr/bin/xctest
@hoshi-takanori
hoshi-takanori / NSUndoManager+Logging.m
Created December 31, 2013 06:02
Logging category of NSUndoManager class.
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface NSUndoManager (Logging)
@end
@implementation NSUndoManager (Logging)
+ (void)load
@hoshi-takanori
hoshi-takanori / MyTextView.h
Last active February 11, 2020 23:07
UITextView subclass to replace range with attributed text, with undo/redo support. (iOS 7 only)
#import <UIKit/UIKit.h>
@interface MyTextView : UITextView
- (void)replaceSelectionWithAttributedText:(NSAttributedString *)text;
- (void)replaceRange:(NSRange)range withAttributedText:(NSAttributedString *)text;
@end