IT이야기2015. 10. 10. 08:49

Fitbit 기기중 가장 highend smart watch이지요. Heart rate과 GSP까지 포함되고도 battery life가 일주일이나 간다고 합니다.

무려 250불이나 하는데 주변에 사용하는 사람은 상당히 만족하는 것을 봤습니다. 저는 Fitbit Charge제품을 몇개월째 사용중인데 정말 대단한 제품이라고 생각됩니다.


iFixit.com에 따르면

Cypress - Touch controller

Silicon Lab EFM32 - AP

MediaTek GSP

TI Bluetooth Controller가 들어갔다고 합니다.

Screen는 E-Ink같은 기술이 들어갔고요.


배터리 용량과 GPS를 어떻게 효율적으로 운용했는지 참 궁금합니다.

OS나 SW는 뭐가 올라갈까요?



---------------

https://www.ifixit.com/Teardown/FitBit+Surge+Teardown/42344


EditStep 7  Microcontroller 

  • After removing the large shield on the main PCB the brains of the gadget become visible

    • Silicon Labs EFM32 Giant Gecko (ARM Cortex-M3) EFM32GG395F1024

    • Micron Serial NOR FlashN25Q064A11ESEA0F

    • (Cypress touchscreen controller still visible here plugged into the main PCB)


Posted by 쁘레드
자동차이야기2015. 10. 3. 03:22

이전 '2015년 9월 미국 자동차 판매현황' 글에서

  • 현대차/기아차 상황은

    현대차는 작년동기 대비 14.3%

    기아차는 작년동기 대비 22.6%

    로 상당히 좋은 실적을 기록했습니다.

    둘다 합해서 모기업으로만 비교해 보면 현대/기아차 그룹은 작년동기대비 17.8%입니다. 어쨌거나 좋은 성적입니다.


현대에서 럭셔리모델이라고 불리우는 3가지 모델 판매량은 그닥이고 어렵다는 말을 지울수가 없네요. 현대차/기아차는 저렴한 모델만 판매량이 늘었다고 봐야할것 같습니다. 마진이 상대적으로 높아야 하는 비싼 모델들은 오히려 출혈경쟁을 할수밖에 없는 상황이 계속 이어지고 있습니다.

제네시스도 판매량이 계속 줄고 있고 K900의 마케팅도 다시 반짝 마케팅으로 끝나는것으로 보입니다. 가격을 항상 낮게 유지할수만은 없겠지요.


--------------

MonthHyundai Genesis
U.S. Sales 2015
Hyundai Equus
U.S. Sales 2015
Kia K900
U.S. Sales 2015
January2573220119
February279320762
March306421488
April3159178140
May3168170133
June2513170168
July2474174480
August2440185386
September2239212329
October
November
December






Posted by 쁘레드
자동차이야기2015. 10. 3. 03:09

우선 이번 9월은 미국의 노동절 Labor Day판매가 온전히 9월에만 포함되는 특이한 해이기때문에 9월에 판매가 폭등한것 처럼 보일거라는 예상이 있었습니다. 이런것을 고려하지 않는다면 미국의 자동차 판매량은 작년에 비해 폭등상황이니 현재의 경제상황을 잘못해석할수도 있겠지요. 이런 상황에서도 8월도 증가하긴 했으니 좋은 상황임에는 분명합니다.

Toyota의 괄목할만한 성장이 눈에 뛰네요. Camry판매량이 다시 좋은 수준으로 올라가고 있네요, 동네에서도 새로운 모델이 많이 보이는걸 보면 좋은 가격으로 판매하고 있을것으로 생각됩니다. 

폭스바겐은 배기가스 조작으로 추락은 예상되었지만 원래 미국 시장에서 큰 비중이 없었으니 의미있는 data는 아닌것 같고요. 미국이나 다른 나라에서 판매량 추이를 몇개월 관찰하는게 좋을것 같습니다.



------------------

Top 20 Best-Selling Car

August 2015 • September 2014

Rank
Best-Selling Car
September
2015
September
2014
%
Change
2015
YTD
2014
YTD
%
Change
#1
Toyota Camry
34,48728,50721.0%326,330334,978-2.6%
#2
Honda Accord
33,64132,9562.1%264,814304,382-13.0%
#3
Honda Civic
28,27822,26327.0%249,749253,430-1.5%
#4
Toyota Corolla
26,63620,53029.7%278,742258,8057.7%
#5
Ford Fusion
24,94221,69315.0%231,475240,585-3.8%
#6
Nissan Altima
24,22421,67511.8%262,424256,9352.1%
#7
Hyundai Elantra
20,72418,84810.0%193,962176,40310.0%
#8
Nissan Versa
18,05312,07249.5%109,832110,272-0.4%
#9
Chevrolet Malibu
17,06615,18612.4%147,161148,574-1.0%
#10
Hyundai Sonata
16,12414,9188.1%157,680164,934-4.4%
#11
Subaru Outback
15,12611,31533.7%108,41997,26611.5%
#12
Nissan Sentra
14,19612,55713.1%154,270141,2169.2%
#13
Chevrolet Cruze
14,03218,415-23.8%177,970208,114-14.5%
#14
Kia Soul
13,61410,80226.0%112,683115,579-2.5%
#15
Ford Focus
13,43715,397-12.7%163,864176,156-7.0%
#16
Kia Optima
11,71910,9087.4%118,301122,646-3.5%
#17
Chrysler 200
11,36410,9953.4%147,07375,14295.7%
#18
Toyota Prius
10,168833921.9%89,812110,455-18.7%

Toyota Prius Liftback ^
9952798624.6%85,77898,613-13.0%

Toyota Prius Plug-In ^
216353-38.8%403411,842-65.9%
#19
Ford Mustang
94563158199%96,22559,83160.8%
#20
Chevrolet Impala
935992251.5%85,466107,162-20.2%

http://www.goodcarbadcar.net/2015/10/20-best-selling-cars-america-september-2015.html

------------------

업체별로 보면 포드가 젤 좋은 성적을 보이고 있습니다. 

August 2015 • September 2014 • Updated at 7:54 PM AT on 10.01.2015

Rank
 ▾
AutomakerSeptember
2015
%
Change
2015
YTD
%
Change
Sept.
2015
Market
Share
YTD
Market
Share
#1
Ford
212,589
23.4%
1,891,518
4.5%
14.7%
14.5%
#2
170,675
10.9%
1,596,182
3.5%
11.8%
12.2%
#3
162,566
15.1%
1,580,726
3.5%
11.3%
12.1%
#4
119,046
14.0%
1,056,547
1.5%
8.3%
8.1%
#5
111,562
17.3%
1,026,920
5.0%
7.7%
7.9%
#6
77,201
39.8%
632,910
22.6%
5.4%
4.8%
#7
64,015
14.3%
578,190
3.7%
4.4%
4.4%
#8
53,070
27.8%
428,702
14.2%
3.7%
3.3%
#9
49,820
22.6%
475,978
7.0%
3.5%
3.6%
#10
47,386
23.8%
410,239
12.0%
3.3%
3.1%


모기업까지 하나로 해서 비교해봐도

Ford가 작년동기 대비 23.3%나 증가하는 실적을 발표했습니다.

------------------

현대차/기아차 상황은

현대차는 작년동기 대비 14.3%

기아차는 작년동기 대비 22.6%

로 상당히 좋은 실적을 기록했습니다.

둘다 합해서 모기업으로만 비교해 보면 현대/기아차 그룹은 작년동기대비 17.8%입니다. 어쨌거나 좋은 성적입니다.

------------------

포드자동차의 경우 전체적으로 실적이 다 좋았지만  캐쉬카우인 F-150가 판매량이 폭증하고 있습니다. 알루미늄 바디 공급문제가 정말 해결되고 있는것으로 보여집니다. 흠이 있다면 모델체인이를 앞두고 있는 Focus가 실적이 좋지 않네요. 경쟁자들 Honda Civic, Toyota Corolla, Hyundai Elantra(아반떼)가 좋은 성적을 거두고 있는것과 비교됩니다.


Click Column Headers To Sort • August 2015 • September 2014

RankBest-Selling TruckSeptember
2015
September
2014
%
Change
2015
YTD
2014
YTD
%
Change
#1
69,651
59,86316.4%564,451557,0371.3%
#2
53,725
50,1767.1%440,904382,15315.4%
#336,59836,612-0.04%330,643319,8683.4%
#4
19,754
16,76317.8%161,653147,2899.8%
#5
11,165
11,993-6.9%133,229114,72916.1%
#6
8472
8736-3.0%90,05488,8691.3%
#7
7334
3620,272%63,23210957,911%




Posted by 쁘레드
Programming2015. 10. 2. 18:17

Drupal이 순정이라면 Drupal을 기반으로 좀더 customized한 package들.

Acquia가 젤 유명했는데 쇼핑몰하려면 Drupal Commerce를 이용하면 좋을것 같고, 왠만한 사이트는 OpenPublic으로 만들면 좋을듯. 기본적으로 100개 이상의 Module이 설치되어서 나옴

----------------

Acquia Drupal - https://www.acquia.com/


Drupal Commerce - https://drupalcommerce.org/


OpenPublic - http://openpublicapp.com/

'Programming' 카테고리의 다른 글

Python - Lottery number generator  (0) 2015.10.15
Internet of Things(IOT) Programming  (0) 2015.10.13
Drupal Shell - Drush  (0) 2015.10.02
Python - JSON을 이용한 지진검색  (0) 2015.10.01
VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Posted by 쁘레드
Programming2015. 10. 2. 14:43




Web Frameworkd으로 CMF(Content Management Framework)/CMS(** System)중 하나인 Drupal을 오래동안 써왔는데 Menu를 왔다리갔다리 하던 노가다가 많았는데 누가 이런 shell을 만들어서 하나의 모듈이 아니라 프로젝트로 독립했네요. 자주쓰는 기능은 commandline에서 치는게 훨씬 좋지요. 대단한 사람들입니다.

-----------------

Drush is a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache. Drush can be extended by 3rd party commandfiles.

http://www.drush.org/

https://github.com/drush-ops/drush ; github를 통해서 공개가 되었네요

-----------------

CommandDescription
drush statusShows the status of your Drupal Install
drush dlDownload and install a drupal module. This defaults to the sites/all/modules directory.
drush enEnable a module
drush disDisable a module
drush upCheck for available updates, download updated modules, and run update.php
drush upCheck to see if the specific module needs updating, and if so, download it and run update.php
drush dl pathauto && drush en pathauto -yDownload Pathauto and its dependent module and enable it.
drush sql-dump --result-file=db-backup.sqlDump the entire Drupal database into a file called db-backup.sql. In other words, backup your database.
drush sql-cli < db-backup.sqlConnect to the database server and run the commands in db-backup.sql. In other words, restore the database from db-backup.sql
drush cc allClear all caches
drush vset preprocess_css 0 --yesTurn off CSS caching. This is useful when developing themes.
drush vset preprocess_js 0 --yes    Turn off JavaScript caching
drush cronRun cron
drush vset site_offline 1 --yesPut a site into maintenance mode (D6 only)
drush vset maintenance_mode 1 --yesPut a site into maintenance mode (D7 only)
drush vset site_offline 0 --yesTake a site out of maintenance mode (D6 only)
drush vset maintenance_mode 0 --yesTake a site out of maintenance mode (D7 only)

-----------------

  • drush pm-download cck views (Downloads specified modules with a space between each one.)
  • drush pm-enable cck views (Enables specified modules. No more checking boxes!)
  • drush pm-disable cck views (Disables specified modules)
  • drush pm-uninstall cck views (Uninstalls specified modules)
  • drush status (Shows the status of your Drupal Install)
  • drush pm-update (Updates all Modules and Drupal Core)
  • drush cache-clear (Clear all Cache)

-----------------


'Programming' 카테고리의 다른 글

Internet of Things(IOT) Programming  (0) 2015.10.13
Drupal Web Application Packages  (0) 2015.10.02
Python - JSON을 이용한 지진검색  (0) 2015.10.01
VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Python - String, File, Regular Expression  (0) 2015.09.30
Posted by 쁘레드
IT이야기2015. 10. 2. 09:14



최근에 Intel Core I7-5500U 노트북을 저렴하게 하나 샀는데, I7-6500U랑 비교해보면 DDR4를 사용한다는 것과 새로운 아키텍쳐라 좀더 빠를것으로 생각되는데... 실제 성능은 두가지를 이득을 고려해도 가격차이를 설명하기 너무 어려운 차이라 보여짐.

인텔 독점체제라 기술개발을 일부러 천천히 하는 느낌이랄까. Broadwell vs Skylake 인텔이 좀더 열심히 해줬으면 좋았을텐데...

https://en.wikipedia.org/wiki/Skylake_(microarchitecture)

-----------------


Intel Core i7-6500U @ 2.50GHzIntel Core i7-5500U @ 2.40GHz
PriceSearch OnlineSearch Online
Socket TypeFCBGA1356FCBGA1168
CPU ClassLaptopLaptop
Clockspeed2.5 GHz2.4 GHz
Turbo SpeedUp to 3.1 GHzUp to 3.0 GHz
# of Physical Cores2 (2 logical cores per physical)2 (2 logical cores per physical)
Max TDP15W15W
First Seen on ChartQ2 2015Q1 2015
# of Samples2822
Single Thread Rating17671547
CPU Mark44603948

https://cpubenchmark.net/compare.php?cmp[]=2607&cmp[]=2470

-----------------

Mini Review

Intel Core i7-5500U advantages

  • None

    Intel Core i7-6500U advantages

  • Operating frequency of this processor is higher than the frequency of the Core i7-5500U microprocessor.
  • The CPU officially supports faster DDR4-2133 memory, as such, it has higher memory bandwidth, which is quite beneficial to programs, that work with large data sets. Performance gains in non-memory bound tasks will be lower.


i7-5500U vs i7-6500U specifications comparison

The charts below compare the most important features of the i7-6500U and Intel i7-5500U CPUs. These characteristics, along with an IPC (instructions per cycle) number, determine how well a microprocessor performs. The "Number of cores / threads" graph displays the number of cores (darker area). Lighter area on the graph corresponds to the number of additional threads, provided by Hyper-Threading technology. The "Operating frequency" chart uses dark color for base frequency, whereas lighter area is for extra frequency, provided by Turbo feature. Darker area on the "On-chip cache" graph is for the On-chip L2 cache. Lighter area is for the L3 cache cache. Although the L3 cache cache is usually larger than the On-chip L2 cache, it is always slower.

The number of cores / threads
5
4
3
2
1
0
 
 
4
 
4
 
 
Higher is better
Operating frequency
4
3.2
2.4
1.6
0.8
0
 
 
3GHz
 
3.1GHz
 
 
Higher is better
On-chip L2 + L3 cache
6000
4800
3600
2400
1200
0
 
 
4608KB
 
4608KB
 
 
Higher is better
Thermal Design Power
20
16
12
8
4
0
 
 
15W
 
15W
 
 
Lower is better

  - Intel Core i7-5500U       - Intel Core i7-6500U

http://www.cpu-world.com/Compare/860/Intel_Core_i7_Mobile_i7-5500U_vs_Intel_Core_i7_Mobile_i7-6500U.html


 Intel Core i7-5500UIntel Core i7-6500U
Market segmentMobile
ManufacturerIntel
FamilyCore i7 Mobile
Basic details
Model numberi7-5500Ui7-6500U
CPU part numberFH8065801620004FJ8066201930408
Introduction dateJanuary 5, 2015September 1, 2015
Current official price$393 (as of Sep 2015) 
 
CPU features
Core nameBroadwellSkylake-U
MicroarchitectureBroadwellSkylake
Technology (micron)0.014
Data width (bits)64
SocketBGA1168BGA1356
Frequency (MHz)24002500
Turbo Frequency (MHz)3000 / 29003100 / 3000
Clock Multiplier2425
L1 cache64 KB (code) / 64 KB (data)
L2 cache (KB)512
L3 cache (KB)4096
Max temperature (°C)105100
TDP (Watt)15
Cores2
Threads4
Multiprocessing1


Posted by 쁘레드
IT이야기2015. 10. 2. 06:29

윈도우즈 새로 깔고 설치할 프로그램 리스트

-----------------

  • 7-zip
  • notepad++
  • chrome browser
  • Firefox
  • VNC client
  • putty
  • Xming
  • Source Insight
  • Python 2.7.x
  • Aptana ; IDE for java/java script/python
  • Beyond Compare
  • Meld
  • goldwave
  • cygwin64 or MinGW
  • Eclipse C/C++ Mars
  • fastcopy
  • Agent Ransack
  • MediaInfo
  • Daum PotPlayer
  • Visual Studio or Visual Studio Code ; free version
  • alpass ; 더 이상 지원이 안됨
  • Adobe Lightroom
  • VM Virtualbox + Ubuntu
  • Printer driver
  • ...


Posted by 쁘레드
Programming2015. 10. 1. 08:53


-------------------

*USGS Json data structure

http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson_detail.php


*Past Day M2.5+ Earthquakes

http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson


-------------------


# 

import urllib2
import json

def printResults(data):
  # Use the json module to load the string data into a dictionary
  theJSON = json.loads(data)
  
  # now we can access the contents of the JSON like any other Python object
  if "title" in theJSON["metadata"]:
    print theJSON["metadata"]["title"]
  
  # output the number of events, plus the magnitude and each event name  
  count = theJSON["metadata"]["count"];
  print "Yesterday Total " + str(count) + " events recorded"
  
  # for each event, print the place where it occurred
#  for i in theJSON["features"]:
#    print i["properties"]["place"]

  # print the events that only have a magnitude greater than 4
  print"\n"
  print "Magnitude greater than 4:\n"
  for i in theJSON["features"]:
    if i["properties"]["mag"] >= 4.0:
      print "%2.1f" % i["properties"]["mag"], i["properties"]["place"]

  # print only the events where at least 1 person reported feeling something
  print "\n"
  print "Events that were felt:\n"
  for i in theJSON["features"]:
    feltReports = i["properties"]["felt"]
    placeOccur = i["properties"]["place"]
    if (feltReports != None) & (feltReports > 0):
        if (i["properties"]["place"].find("California") > 0 or i["properties"]["place"].find("Mexico") > 0) :
		    print "*****************************************"
        print "%2.1f" % i["properties"]["mag"], i["properties"]["place"], " reported " + str(feltReports) + " times"
 
  
def main():
  # define a variable to hold the source URL
  # In this case we'll use the free data feed from the USGS
  # This feed lists all earthquakes for the last day larger than Mag 2.5
  #Fred: http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
  urlData = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson"
  
  # Open the URL and read the data
  webUrl = urllib2.urlopen(urlData)
  print ("USGS is alive, response=%d" % webUrl.getcode())
  if (webUrl.getcode() == 200):
    data = webUrl.read()
    # print out our customized results
    printResults(data)
  else:
    print "Received an error from server, cannot retrieve results " + str(webUrl.getcode())

if __name__ == "__main__":
  main()

-------------------

sample file


jsondata_finished.py



'Programming' 카테고리의 다른 글

Drupal Web Application Packages  (0) 2015.10.02
Drupal Shell - Drush  (0) 2015.10.02
VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Python - String, File, Regular Expression  (0) 2015.09.30
Python - Stock Price Quote  (0) 2015.09.30
Posted by 쁘레드
Programming2015. 10. 1. 07:00

VM Virtualbox에 linux 설치하기는 여러 글이 많이 있지만 그 다음에...

  • Host에서 SSH로 Ubuntu에 접속하기
  • Shared folder를 mount해서 Ubuntu에서 read/write하기
  • Ubuntu screen resolution이 640x480이상으로 하기
  • LAMP을 설치후 Drupal 설치하고 web programming하기
  • Android build environment 설치하기

--------------

sudo apt-get install openssh-server 


#port check

netstat -ant | grep 2222

netstat -lnpt | grep 22

-------------

Port forwarding

포트포워딩 3개를 네트워크 세팅에다 넣어줌

SSH TCP 2222 to 22

HTTP TCP 8080 to 80

MYSQL TCP 3306 to 3306

MYSQL UDP 3306 to 3306

-------------

http://unix.stackexchange.com/questions/145997/trying-to-ssh-to-local-vm-ubuntu-with-putty


Two network devices

1. Bridged (as default for internet)

2. Host only


eth0      Link encap:Ethernet  HWaddr 08:00:27:16:f4:3c

          inet addr:10.42.130.246  Bcast:10.255.255.255  Mask:255.0.0.0

          inet6 addr: fe80::a00:27ff:fe16:f43c/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:157 errors:0 dropped:0 overruns:0 frame:0

          TX packets:126 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:11529 (11.5 KB)  TX bytes:14439 (14.4 KB)


eth1      Link encap:Ethernet  HWaddr 08:00:27:be:3b:1f

          inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:febe:3b1f/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:138 errors:0 dropped:0 overruns:0 frame:0

          TX packets:172 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:14585 (14.5 KB)  TX bytes:27815 (27.8 KB)



SSH to 192.168.*.*

----------

Share forlders from VM setting.

------------

Guest Additions

sudo apt-get install virtualbox-guest-dkms virtualbox-guest-x11

GuestAdditions is required, no need cdrom is requried.

http://askubuntu.com/questions/456400/why-cant-i-access-a-shared-folder-from-within-my-virtualbox-machine


Start VM

Devices > Insert Guest Additions CD image...

I had to manually mount the CD: sudo mount /dev/cdrom /media/cdrom

Install the necessary packages: sudo apt-get install make gcc linux-headers-$(uname -r)

Install the Guest Additions: sudo /media/cdrom/VBoxLinuxAdditions.run

Now you can mount your share using:


mkdir ~/host

sudo mount -t vboxsf La_Build ~/host

-----------

GuestAdditions이 있으면 화면 해상도도 자유로워짐

-----------

$ sudo apt-get update
$ sudo apt
-get install openjdk-7-jdk
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g
-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5
-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
  libgl1
-mesa-dev libxml2-utils xsltproc unzip

https://source.android.com/source/initializing.html

$ sudo update-alternatives --config java
$ sudo update
-alternatives --config javac

*repo ?

sudo apt-get install phablet-tools


------------

 sudo apt-get install lamp-server^

*config apach

https://help.ubuntu.com/community/ApacheMySQLPHP

------------


------------


------------

'Programming' 카테고리의 다른 글

Drupal Shell - Drush  (0) 2015.10.02
Python - JSON을 이용한 지진검색  (0) 2015.10.01
Python - String, File, Regular Expression  (0) 2015.09.30
Python - Stock Price Quote  (0) 2015.09.30
VIM resource file  (0) 2015.09.30
Posted by 쁘레드
Programming2015. 9. 30. 14:37


-----------------

>>> ord(b'A')

65

>>> ord(b'!')

33

>>> list(b'Example')

[69, 120, 97, 109, 112, 108, 101]


>>> chr(65)

'A'

>>> chr(33)

'!'


>>>'This is an example, with punctuation and UPPERCASE.'.encode('ascii')

b'This is an example, with punctuation and UPPERCASE.'

>>> ascii = 'This is a test'.encode('ascii')

>>> ascii

b'This is a test'

>>> ascii.decode('utf-8')


{0}, {1}


>>> import os.path

>>> '{0:>20}{1}'.format(*os.path.splitext('contents.txt'))

'            contents.txt'

>>> for filename in ['contents.txt', 'chapter.txt', 'index.txt']:

... print('{0:<10}{1}'.format(*os.path.splitext(filename)))

contents .txt

chapter  .txt

index     .txt


>>> heading('Standard Format Specification')

'=====Standard Format Specification======'

>>> heading('This is a longer heading, beyond 40 characters')

'=This is a longer heading, beyond 40 characters='

>>> heading('Standard Format Specification', padding='-', width

'---------------Standard Format Specification----------------'



print string + str(123)


days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]

for i, d in enumerate(days):

    print i, d


0 Mon

1 Tue

2 Wed

3 Thu

4 Fri

5 Sat

6 Sun


-----------------

String and Parsing

http://www.tutorialspoint.com/python/string_find.htm


str1 = "this is string example....wow!!!";
str2 = "exam";

print str(len(str1))+ " " +str(len(str2))
print str1.find(str2)
print str1.find(str2, 10)
print str1.find(str2, 40)
print str1.find("this", 0, len(str1))

str = "Line1-abcdef \nLine2-abc \nLine4-abcd";
print str.split( )
print str.split(' ', 1 )

str1.capitalize()
str1.lower()
str1.upper()

-----------------

File

f = open("textfile.txt") # by default, read only
f = open("textfile.txt","r")
f = open("textfile.txt","w+")
f = open("textfile.txt","a+")

if f.mode == 'r': # check to make sure that the file was opened

txt = f.read() # read entire content

fl = f.readlines() # readlines reads the individual lines into a list
for x in fl:
  print x

# write some lines of data to the file
for i in range(10):
  f.write("This is line %d\r\n" % (i+1))

-----------------

File Path

import os
from os import path
import datetime
from datetime import date, time, timedelta
import time

def main():
  # Print the name of the OS
  print os.name
  
  # Check for item existence and type
  print "Item exists: " + str(path.exists("textfile.txt"))
  print "Item is a file: " + str(path.isfile("textfile.txt"))
  print "Item is a directory: " + str(path.isdir("textfile.txt"))
  
  # Work with file paths
  print "Item's path: " + str(path.realpath("textfile.txt"))
  print "Item's path and name: " + str(path.split(path.realpath("textfile.txt")))
  
  # Get the modification time
  t = time.ctime(path.getmtime("textfile.txt"))
  print t
  print datetime.datetime.fromtimestamp(path.getmtime("textfile.txt"))
  
  # Calculate how long ago the item was modified
  td= datetime.datetime.now() - datetime.datetime.fromtimestamp(path.getmtime("textfile.txt"))
  print "It has been " + str(td) + "The file was modified"
  print "Or, " + str(td.total_seconds()) + " seconds"
  
if __name__ == "__main__":
  main()

-----------------

Regular Expression

import time, os, re
# display time corresponding to your location
print(time.ctime())
f=open("sink_info.txt")
txt = f.read()
#AU_LINUX_ANDROID_LA.BF64.1.2.2.05.01.01.110.103
result = re.search("AU_LINUX_ANDROID_LA.\w+.\d.\d.\d.\d{2}.\d{2}.\d{2}.\d{3}.\d{3}", txt)
#result = re.search("AU_LINUX_ANDROID_LA.(HB|BF64).[0-9].[0-9].[0-9].[0-9]{2}.[0-9]{2}.[0-9]{2}.[0-9]{3}.[0-9]{3}", txt)
print result
if result:
	tmp1=result.group(0)
	#tmp2=result.group(1)
	print tmp1
	#print tmp2

#RUN SINK command with this AU


'Programming' 카테고리의 다른 글

Python - JSON을 이용한 지진검색  (0) 2015.10.01
VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Python - Stock Price Quote  (0) 2015.09.30
VIM resource file  (0) 2015.09.30
Python - Date, Time  (0) 2015.09.29
Posted by 쁘레드