페이지

2013년 12월 25일 수요일

CoreGraphics angle,clockwise direction

    //각도의 시작은 우측 수평선에서 시계방향으로 증가한다. 그런데, y 플립이기에 시계방향은 화면에서는 반시계방향이다.


    CGContextBeginPath(context);
    CGContextMoveToPoint(context, 0, 30);
    CGContextAddLineToPoint(context, 60, 30);
    CGContextAddArc(context, 60-15, 30, 15, radian(0), radian(45), false);
    CGContextAddLineToPoint(context, 60-15, 30);
    CGContextClosePath(context);

    CGContextDrawPath(context, kCGPathStroke);

2013년 2월 15일 금요일

Set up Mercurial Server on Mac OS X Server ( 10.7.5 Lion )



  • Install mercurial





after installing mercurial, type "python" and type "import mercurial" on terminal.

user$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mercurial
>>>

if error, refer to http://mercurial.selenic.com/wiki/PublishingRepositories
(cf 3.1.1 Python and Mercurial )










  • Make hgweb script


make hgweb.cgi file in the path "/Volumes/works/hg".
and then add the following contents on it.
( in this guide, we assume that mercurial works are in the path "/Volumes/works/hg". so all config files might be there.)





#!/usr/bin/env python
#
# send python tracebacks to the browser if an error occurs:
import cgitb
cgitb.enable()

# An example CGI script to export multiple hgweb repos, edit as necessary

# adjust python path if not a system-wide install:
import sys
#input mercurial path
sys.path.insert(0, "/Library/python/2.7/site-packages/mercurial")
# enable importing on demand to reduce startup time
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi
application = hgwebdir('hgweb.config')
wsgicgi.launch(application)


  • hg init

type hg init command for repository.

hg init /volumes/works/hg/"repository name"

  • Make hgweb.config 



make hgweb.config file in the path "/Volumes/works/hg".
and then add the following contents on it.



#hgweb.config

[paths]
#project1 = /Volumes/works/hg/project1
#project2 = /Volumes/works/hg/project2
/ = /Volumes/works/hg/*

[web]
#visiting the given URL paths or including subrepositories
descend = True
allow_push = johnson
#allow_push = *
push_ssl = true
#for http://example.com/hg
baseurl = /hg
#for http://hg.example.com
#baseurl =


  • path

if you have only project1 repository, you can define repository's path as like

project1 = /Volumes/works/hg/project1

but, if you want to have multiple repositories, do it like this

/ = /Volumes/works/hg/*


so you can access all repositories under /Volumes/works/hg/

ex)
https://example.com/hg/project1
https://example.com/hg/project2
.... and so on.


  • allow_push

allow_push = johnson

this would allow pushing for johnson.

you can allow pushing for everyone as like this

allow_push = *


  • Defining User Credential

To make user id and password for mercurial, use htpasswd command.

htpasswd -c /Volumes/works/hg/hgusers johnson
(cf htpasswd )


and we have to change permission of repositories.


chown -R _www:_www /Volumes/works/hg
chmod -R g+rw /Volumes/works/hg
chmod -R g+x /Volumes/works/hg
chmod -R g+x /Volumes/works/hg/*
chmod -R g+x /Volumes/works/hg/*/.hg

_www is a group for apache web service.

  • Make httpd-hg.conf file

make httpd-hg.conf file in the path /Volumes/works/hg. and add the following text on it.


# Mercurial setting
ScriptAlias /hg "/volumes/works/hg/hgweb.cgi"

#restrict pushing to known users
<Location /hg>
#Require SSL authentication
SSLRequireSSL
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /volumes/works/hg/hgusers
Require valid-user
</Location>



  • Setting Apache config file

add the following text on /etc/apache2/httpd.conf.

Include /Volumes/works/hg/httpd-hg.conf

and that's all.


if you want to know more or it doesn't work,
please refer to the link.
http://mercurial.selenic.com/wiki/PublishingRepositories









2013년 1월 20일 일요일

NSSet VS NSArray


  • NSSet
    • Primarily access items by comparison
    • Unordered
    • Does not allow duplicates
  • NSArray
    • Can access items by index
    • Ordered
    • Allows duplicates