Coding/Ruby2011. 1. 8. 02:08
# save image from web
# 2011. 1. 7

require 'open-uri'

def read_url_file(url_name_, number_)
    open(url_name_) { |from| $data = from.read }
    File.open("#{number_}.jpg", "wb:binary") { |to| to.write($data) }
end

read_url_file("http://chobocho.com/photo/sydney.jpg", 2)

'Coding > Ruby' 카테고리의 다른 글

[Ruby] Simple file copy example  (0) 2011.01.07
Posted by chobocho
Coding/Ruby2011. 1. 7. 23:48
# simple file copy
# 2011. 1. 7

File.open("test.png", "rb:binary") { |from| $data = from.read }
File.open("test2.png", "wb:binary") { |to| to.write($data) }

'Coding > Ruby' 카테고리의 다른 글

[Ruby] Save image from web  (0) 2011.01.08
Posted by chobocho
My Life/version 20112011. 1. 1. 08:10

2011년 1월 1일 일출

2011년 1월 1일 일출

 [ 2011년 1월 1일 일출 ]
 

2010년 한 해도 어느새 훌쩍 지나가 버리고, 2011년 새해가 밝았다.

올 한해도 뜻한바(?)를 모두 이루었으면 좋겠다.

'My Life > version 2011' 카테고리의 다른 글

태종대  (3) 2011.02.06
태종대  (0) 2011.02.06
꽝! 다음 기회를...  (0) 2011.01.16
Posted by chobocho
Coding/Python 삽질기2010. 12. 13. 01:29


 

import re
import zipfile


def main():

    target = zipfile.ZipFile("channel.zip", 'r')
       
    number = "90052"
    filename = number + ".txt"
    comment = ""

    while 1:   
        print filename
        data = target.read(filename)
        data_ = re.findall("nothing is ([0-9]+)", data)
        if data_:
            comment += target.getinfo(filename).comment
            filename = "".join(data_) + ".txt"
        else:
            break
       
        print comment
         
if __name__ == "__main__":
    main()


'Coding > Python 삽질기' 카테고리의 다른 글

간단한 반복 작업 매크로  (0) 2011.01.12
http://www.pythonchallenge.com...Level5  (0) 2010.12.13
http://www.pythonchallenge.com...Level4  (0) 2010.12.13
Posted by chobocho
Coding/Python 삽질기2010. 12. 13. 01:00


 

import pickle

def main():
    fp = open("banner.p", 'rb')
    data = pickle.load(fp)
   
    for li in data:
        line = ""
        for ch, count in li:
            line += ch*count
        print line
   
       
if __name__ == "__main__":
    main()


Posted by chobocho
Coding/Python 삽질기2010. 12. 13. 00:37


 

import urllib
import re


def main():

    url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
   
    url_to = url + "12345"
    #url_to = url + "46059" # After get new messages.
   
    while 1:
        source = urllib.urlopen(url_to)
        data = source.read()
        number = re.findall("nothing is ([0-9]+)", data)
        if number:
           url_to = url + "".join(number)
           print url_to
        else:
           break
       
    print data
   
   
if __name__ == "__main__":
    main()

Posted by chobocho
Coding/Python 삽질기2010. 12. 12. 23:11


 

import re

data_ = """_abaAAAbCCC"""

def main():
    p = re.compile ('[a-z]{1}[A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]{1}')
    m = p.findall(data_)
   
    if m:
        print m
        for idx in m:
            print idx[4],
   
   
if __name__ == "__main__":
    main()

Posted by chobocho
Coding/Python 삽질기2010. 12. 6. 23:34
data='''
find at source code...
'''

def main():
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    result = filter(lambda x : x in alphabet, data)
   
    print result
   
if __name__ == "__main__":
    main()

'Coding > Python 삽질기' 카테고리의 다른 글

http://www.pythonchallenge.com...Level3  (0) 2010.12.12
[Python] 파일 zip으로 압축하기  (0) 2010.10.25
1000!  (0) 2010.07.14
Posted by chobocho
Coding/JavsScript 삽질기2010. 11. 30. 00:54

'Coding > JavsScript 삽질기' 카테고리의 다른 글

글자수 세는 자바 스크립트  (2) 2011.11.15
Hex2Ascii Javascript code  (0) 2010.06.15
[Flex] HEXA v0.1  (0) 2009.08.15
Posted by chobocho
Coding/Perl 삽질기2010. 11. 12. 01:26
#
# Date : 2010. 11. 12
#
# Author : chobocho.com
#
# Description : 패턴에 포함된 라인을 출력해주는 스크립트
###############################################
# File Name

$filename = "express.ini";

open (EXP_FILE, "<".$filename) || die $!;
@expressions = <EXP_FILE>;
close(EXP_FILE);

print "!!! chobocho filter V0.01 !!!\n";
print "-----------------------------\n";
print @expressions;
print "\n---------------------------\n";

{
    if (-f $ARGV[0]) 
    {
        print "!!! Read ".$ARGV[0]."!!!\n";
        print "\n---------------------------\n";
    
        open (IN_FILE, "<".$ARGV[0]) || die $!;
         
        while (my $line = <IN_FILE>) 
        {
            foreach $expression(@expressions)
            {
                if ( $line =~ /$expression/ )
                {
                    print $line;
                }
            }
        }

        close (IN_FILE);
    } 
}


[실행파일]
Posted by chobocho