Skip to content

Instantly share code, notes, and snippets.

@eienf
eienf / makeIcons.sh
Created March 6, 2015 17:11
Create various sizes of iPhone app icons with sips command.
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Uage: $0 ImageFileName"
exit 1
fi
FILE=$1
BASENAME=${FILE%.*}
EXT=${FILE##*.}
DIR=icons
@eienf
eienf / NSInteger.m
Created April 10, 2015 08:38
printf format string for NSInteger
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSInteger i = 101;
NSLog(@"NSInteger %lu",sizeof(NSInteger));
NSLog(@"long %lu",sizeof(long));
NSLog(@"int %lu",sizeof(int));
NSLog(@"%ld",(long)i);
}
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["geochart"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
/* 0…未踏、1…通過、2…接地、3…訪問、4…宿泊、5…居住 */
var data = google.visualization.arrayToDataTable([
@eienf
eienf / url_properties.m
Created August 19, 2012 07:24
check what is what of NSURL properties.
#import <Foundation/Foundation.h>
NSDictionary *dictionaryForURL(NSURL *aURL)
{
NSLog(@"scheme = %@ host = %@ port = %@ fragment = %@ lastPathComponent = %@ parameterString = %@ "
@"query = %@ user = %@ password = %@ resourceSpecifier = %@",
[aURL scheme],[aURL host],[aURL port],[aURL fragment],[aURL lastPathComponent],[aURL parameterString],
[aURL query],[aURL user],[aURL password],[aURL resourceSpecifier]);
NSLog(@"absoluteString = %@",[aURL absoluteString]);
@eienf
eienf / calendarDate2date.m
Created October 5, 2012 09:04
Convert NSDate from NSCalendarDate
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSCalendarDate *cDate = [NSCalendarDate date];
NSLog(@"calendar date = %@",cDate);
NSDate *aDate = [NSDate date];
NSLog(@"calendar date = %@",aDate);
@eienf
eienf / jEras.m
Created October 5, 2012 09:29
Print all era in Japanese Calendar.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSCalendar *japanese = [[NSCalendar alloc] initWithCalendarIdentifier:NSJapaneseCalendar];
NSLocale *aLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSDateComponents *comps = [[NSDateComponents alloc] init];
@eienf
eienf / extract_era_name.m
Created October 5, 2012 13:22
Extract Japanese Era name only after Mac OS X 10.8/iOS6
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSCalendar *japanese = [[NSCalendar alloc] initWithCalendarIdentifier:NSJapaneseCalendar];
NSLocale *aLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSDateFormatter *aFormatter = [[NSDateFormatter alloc] init];
aFormatter.calendar = japanese;
@eienf
eienf / jEras_both.m
Created October 7, 2012 08:57
Print all era in Japanese Calendar (Japanese/English).
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSCalendar *japanese = [[NSCalendar alloc] initWithCalendarIdentifier:NSJapaneseCalendar];
NSDateFormatter *usFormatter = [[NSDateFormatter alloc] init];
usFormatter.calendar = japanese;
usFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
@eienf
eienf / time_list_of_nsstring.m
Created November 9, 2012 01:14
time to produce a series of NSString
#import <Foundation/Foundation.h>
#import <mach/mach_time.h>
// 0 .. 4
#define TEST 0
int main(int argc, const char * argv[])
{
@autoreleasepool {
@eienf
eienf / time_nsdateformatter.m
Last active December 10, 2015 20:58
Time measurement NSDateFormatter creation. Not Use ARC.
//
// main.m
// CodeTest
//
// Created by eien.support@gmail.com on 2013/01/09.
// Copyright (c) 2013 Eien Factory. All rights reserved.
//
// ARC=OFF