Programming2016. 7. 7. 05:19

Python이 오래됐고 아주 유명해서 많은 개발툴이 있지만, 아주 좋은 공짜 IDE가 있습니다. PyCharm. 한번 써보세요.

MS가 개발툴의 명가라면, JetBrains는 IDE은 신생 샛별정도 될것 같습니다. 아주 좋은 툴이 많이 있는데, 다 공짜는 아니네요.(헉~ 다른 것은 비싸네요) PyCharm은 community버전이 free.

Eclipse는 open source IDE의 강자쯤 퇼까요? (with PyDev Plugin)

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

https://www.jetbrains.com/pycharm/specials/pycharm/pycharm.html

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

설치후 추가 library install

File->Default Setting->Project Interpreter

서치해서 바로 install할수 있음. 설치해야할 library

BeautifulSoup (4)

NumPy, pandas, MatPlotLib, SciPy

IPython

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

IDE for Python

https://wiki.python.org/moin/IntegratedDevelopmentEnvironments

Posted by 쁘레드
Programming2015. 10. 15. 10:28

가끔식 로또할때가 있어서 그냥 무식하게 random으로 찍기는 싫어서 약간의 custom number를 만들수 있도록 간단히 만들어봄.

백만개씩 만들어놓고 당첨번호랑 매칭하는 것도 만들 예정임. 일주일에 백만개씩 사도 로또에 담청될수 없다는 교훈을 가르칠기 위해. ^^

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

import random
import time
#TODO: use current time as random seed

lotterynumbers = range(1,71) # 1-70

# previous winning numbers
# high numbers
# not luckey numbers
exclude_numbers = [12,27,29,43,68,
				66,67,69,70, #68s
				4,22,53]

#print lotterynumbers

for num in exclude_numbers:
	lotterynumbers.remove(num)

print "Number Pool: %s" %lotterynumbers
print "------------------------"

x = 0
while x < 10:
	#lotterynumbers.append(random.randint(1, 10))
	#lotterynumbers.append(random.sample(range(10), 6))
	#lotterynumbers.sort()
	fredarray = random.sample(lotterynumbers, 5)
	fredarray.sort()
	print fredarray
	#print lotterynumbers
	x += 1
print;print

#Mega Number - one lucky number
mega_numbers = range(1,26)  # 1-25
mega_exclude_numbers = [1, 2, 22, 25]

for num in mega_exclude_numbers:
	mega_numbers.remove(num)
print "Mega Number Pool: %s" %mega_numbers
print "------------------------"
y = 0
while y < 5:
	print random.sample(mega_numbers, 1)
	y += 1

#end of the program

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


random_numbers.py


'Programming' 카테고리의 다른 글

C언어 레퍼런스  (0) 2015.10.25
Eclipse for C/C++  (0) 2015.10.17
Internet of Things(IOT) Programming  (0) 2015.10.13
Drupal Web Application Packages  (0) 2015.10.02
Drupal Shell - Drush  (0) 2015.10.02
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. 9. 30. 10:28

주식시세 query

webservicex는 response가 간단해서 빠른편인데, data 자체는 realtime도 아니고 15-20분에 한번씩 update는것 같음.

Google finance는 response자체가 너무 복잡함. 시간이 좀 걸림. 개인적인 용도로는 상관없지만.

간단하게 빠르게 update되는 서버는 무료는 없을듯. Nasdaq에서 한달에 얼마씩 내면 준다고 함.

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

http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=aapl


XML response example)

<string xmlns="http://www.webserviceX.NET/">

<StockQuotes>

<Stock>

<Symbol>aapl</Symbol>

<Last>109.06</Last>

<Date>9/29/2015</Date>

<Time>4:00pm</Time>

<Change>-3.38</Change>

<Open>112.79</Open>

<High>113.51</High>

<Low>107.86</Low>

<Volume>73365384</Volume>

<MktCap>621.94B</MktCap>

<PreviousClose>112.44</PreviousClose>

<PercentageChange>-3.01%</PercentageChange>

<AnnRange>92.00 - 134.54</AnnRange>

<Earns>8.65</Earns>

<P-E>12.62</P-E>

<Name>Apple Inc.</Name>

</Stock>

</StockQuotes>


*but from urllib2 read, all tags are UTF-9 encoded(llike corrupted) like below ==> HTML parser로 escape문자를 바꿔줘야함

<?xml version="1.0" encoding="utf-8"?>

<string xmlns="http://www.webserviceX.NET/">&lt;StockQuotes&gt;&lt;Stock&gt;&lt;Symbol&gt;AAPL&lt;/Symbol&gt;&lt;Last&gt

;109.06&lt;/Last&gt;&lt;Date&gt;9/29/2015&lt;/Date&gt;&lt;Time&gt;4:00pm&lt;/Time&gt;&lt;Change&gt;-3.38&lt;/Change&gt;&

lt;Open&gt;112.79&lt;/Open&gt;&lt;High&gt;113.51&lt;/High&gt;&lt;Low&gt;107.86&lt;/Low&gt;&lt;Volume&gt;73365384&lt;/Vol

ume&gt;&lt;MktCap&gt;621.94B&lt;/MktCap&gt;&lt;PreviousClose&gt;112.44&lt;/PreviousClose&gt;&lt;PercentageChange&gt;-3.0

1%&lt;/PercentageChange&gt;&lt;AnnRange&gt;92.00 - 134.54&lt;/AnnRange&gt;&lt;Earns&gt;8.65&lt;/Earns&gt;&lt;P-E&gt;12.6

2&lt;/P-E&gt;&lt;Name&gt;Apple Inc.&lt;/Name&gt;&lt;/Stock&gt;&lt;/StockQuotes&gt;</string>

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

Pattern matching in XML

import urllib2, time, os, re
import HTMLParser
def fetchStockPrice(ticker):
	url="http://www.webservicex.net/stockquote.asmx/GetQuote?symbol="
	txt=urllib2.urlopen(url+ticker).read()
	html_parser = HTMLParser.HTMLParser()
	parsed = html_parser.unescape(txt)
	#print parsed
	#unicode =  txt.encode('utf-8')
	#print unicode

	#result=re.search('(.*?)',parsed)
	result=re.search('([0-9]+\.[0-9]+)', parsed)
	if result:
		stockprice = result.group(1)
		cur_date = re.search('(.*?)',parsed)
		cur_time = re.search('',parsed)
		ret = stockprice + " " + cur_date.group(1) + " " + cur_time.group(1)
	else:
		stockprice = "Nothing found for: " + ticker
		ret = "Nothing found for: " + ticker
	return ret

print ("NOW = " + time.ctime())
print "Stock Price is " + fetchStockPrice("AAPL") 

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

Just Pattern Matching Python code
import  urllib2, time, os, re
def fetchStockPrice(ticker):
	url="http://www.webservicex.net/stockquote.asmx/GetQuote?symbol="
	txt=urllib2.urlopen(url+ticker).read()
	#f=open("sample.xml")
	#txt = f.read()
	#print txt
	#result=re.search('(.*?)',txt)
	result=re.search('([0-9]+\.[0-9]+)',txt)
	#result=re.search("Last\>(\d+\.\d+)\</Last", txt)
	if result:
		stockprice = result.group(1)
	else:
		stockprice = "Nothing found for: " + ticker
	return stockprice

print(time.ctime())
print fetchStockPrice("AAPL") 


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

XML parsing example

https://docs.python.org/2/library/xml.dom.minidom.html?highlight=xml.dom.minidom#module-xml.dom.minidom

import xml.dom.minidom

document = """\

	
		aapl
		109.06
		9/29/2015
		
		-3.38
		112.79
		113.51
		107.86
		73365384
		621.94B
		112.44
		-3.01%
		92.00 - 134.54
		8.65
		12.62
		Apple Inc.
	

"""

def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def getStockPrice(quote):
	 print "Last Stock Price is :" % getText(quote.childNodes)

def handleToc(stocks):
    for stock in stocks:
		symbol = stock.getElementsByTagName("Symbol")[0]
		print "

%s

" % getText(symbol.childNodes) last = stock.getElementsByTagName("Last")[0] print "

%s

" % getText(last.childNodes) date = stock.getElementsByTagName("Date")[0] print "

%s

" % getText(date.childNodes) time = stock.getElementsByTagName("Time")[0] print "

%s

" % getText(time.childNodes) dom = xml.dom.minidom.parseString(document) stocks = dom.getElementsByTagName("Stock") handleToc(stocks)

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

Stock Quote from Google finance

import urllib2, time, os, re, csv
 
def fetchGF(googleticker):
	url="http://www.google.com/finance?&q="
	txt=urllib2.urlopen(url+googleticker).read()
	#print txt
	#search phase 112.44
	k=re.search('id="ref_(.*?)">(.*?)<',txt)
	#print k
	if k:
		tmp1=k.group(0)
		tmp2=k.group(1)
		#print tmp1
		#print tmp2
		tmp=k.group(2)
		#print tmp
		q=tmp.replace(',','')
		#print q
	else:
		q="Nothing found for: "+googleticker
	return q
	
print(time.ctime())
print fetchGF("AAPL")
#print fetchGF("NASDAQ:AAPL")

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

Stock Portfolio를 query하려면

#file에서 읽어도 좋겠다.
tickers=["NASDAQ:AAPL","NASDAQ:GOOG","NASDAQ:BIDU","NYSE:IBM", \
         "NASDAQ:INTC","NASDAQ:MSFT","NYSEARCA:SPY"]

for ticker in tickers:
	data=combine(ticker)
	print(data)

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

 xmlparsing_finished.py


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

import urllib2, time, os, re
import HTMLParser
def fetchStockPrice(ticker):
    url="http://www.webservicex.net/stockquote.asmx/GetQuote?symbol="
    txt=urllib2.urlopen(url+ticker).read()
    html_parser = HTMLParser.HTMLParser()
    parsed = html_parser.unescape(txt)
    #print parsed
    #unicode =  txt.encode('utf-8')
    #print unicode
 
    #result=re.search('(.*?)',parsed)
    result=re.search('([0-9]+\.[0-9]+)', parsed)
    if result:
        stockprice = result.group(1)
        cur_date = re.search('(.*?)',parsed)
        cur_time = re.search('',parsed)
        cur_percent = re.search('(.*?)',parsed)
        #Text formatting
        ret = '{:4s}: {:7s} {:7s} - {:10s} {:7s}'.format(ticker, stockprice, cur_percent.group(1), cur_date.group(1), cur_time.group(1))
        #ret =  '{:4s}'.format(ticker) + ": " +stockprice + " " + cur_percent.group(1) + " " + cur_date.group(1) + " " + cur_time.group(1)
    else:
        stockprice = "Nothing found for: " + ticker
        ret = "Nothing found for: " + ticker
    return ret
 
print(time.ctime())

#tickers=["NASDAQ:AAPL","NASDAQ:GOOG","NASDAQ:QCOM","NYSE:NUAN", \
#         "NASDAQ:INTC","NYSE:DAL","NYSE:F", "NYSE:SMI", "NASDAQ:HQCL", "NYSEARCA:UCO"]
tickers=["AAPL","GOOG","QCOM","NUAN", \
         "INTC","DAL","F", "SMI", "HQCL", "UCO"]
print ("--------------------------")
#print fetchStockPrice("AAPL")
for ticker in tickers:
    data=fetchStockPrice(ticker)
    print(data)
print ("--------------------------") 

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


stockprices.py


'Programming' 카테고리의 다른 글

VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Python - String, File, Regular Expression  (0) 2015.09.30
VIM resource file  (0) 2015.09.30
Python - Date, Time  (0) 2015.09.29
Python with Django  (0) 2015.09.26
Posted by 쁘레드
IT이야기2015. 6. 6. 08:13

상당히 자세한 분석인데 평균이다 보니 각 지역의 현실을 잘 반영하는것 같지는 않습니다. 추세정보 비교는 가능할것 같네요. 이런 data를 분석해서 인포그래픽으로 만들어 내는 사람들 정말 존경합니다.


  • what to learn
  • which role to play
  • startup or not


----------

If we look at a software engineer’s salary as a journey of many steps, at every step we’ll see that where you are, what you do, what you value most, and when you join the company determines your salary according to recent research by Startup Compass.

How can you get paid the most?

Before we dive into the statistics, let’s see what kind of a software engineer would get paid the most. Let’s call our hypothetical engineer Alex.

When Alex chooses the programming language to learn, she should go for the less user-friendly and hard to learn ones. C++ is the best. She should also focus on programming the backend.

Become the CTO, right away

Next, Alex should aim for being a CTO or VP of Engineering as soon as possible. Being an architect would be the next best thing.

But being a CTO right away is ambitious, unless Alex heads to work in a startup. Luckily, startups tend to pay more than the other two options – traditional IT firms and freelancing. Being the CTO of a startup from day 1 is possible, as long as Alex is really good.

Now that we know Alex is looking to work in a startup, how big should the startup be? Ideally, 51-100 people.

Does it matter that Alex does not yet have experience? Yes. Her salary will rise significantly after 6 years. It will go up almost twice once she has 20 years of experience.

But salaries changes thanks to raises. Alex would likely get a significant raise after the third year. So it makes sense to stay at the startup at least that long.

Just money or a piece of the pie?

But Alex might see more meaning in her work than just getting money. She might be interested in getting a piece of the company she works for – equity. Here, she will have to sacrifice a little. As the CTO, she will get around 13% of the company and about $96,000. Were she a VP of Engineering, she could get 2% of the company instead and take home $120,000.

So at what stage should Alex join a startup? Her salary will be the lowest at a startup with no funding or seed funding. If she wants a higher salary,  she should wait until the startup raises their series B round of funding. Of course, by the time series B comes around there will probably be another CTO at the startup. But that CTO could leave, so joining a well-funded startup as the CTO is still possible, but at that point there will be less equity to go around.

All startups can be divided into consumer product oriented ones and enterprise oriented ones. While building things for consumers might be more exciting, the enterprise oriented startups tend to pay more. So Alex should be looking at startups that describe themselves as “SaaS”, “B2B”, “platform.” If that sounds too boring, there are always more consumer startups out there.

Lastly, there are many kinds of a software engineer Alex could be, aside from her CTO title. The highest-paid kind would be a software architect. The next best thing would be a data scientist.

By now Alex probably realizes that the advice on how to get a higher salary is conflicting. By now she may wonder whether getting the highest salary is less important than her freedom to choose a less popular programming language, to get more equity in a company, or to become a different kind of software engineer. She will have some deciding to do.

Where did we get this data?

In October 2014, Startup Compass  conducted a Tech Salary survey of the engineering community from around the world to gather data on salary and equity. They included basic salary information from different countries, roles and skills as well as technologies from other sources such as Elance-oDeskToptalGlassdoorAngellist and Payscale.

Margaret Hamilton - lead software engineer of Appolo, in action

Margaret Hamilton – lead software engineer of Appolo, who coined the term “Software Engineering”


Posted by 쁘레드
Programming2015. 5. 6. 07:01

아 참 재밌는 프로젝트가 널려있네. 이렇게 high level언어들도 멋진 app들이 빠르게 구동된다니 정말 믿어지지 않을정도로 무섭습니다.


http://python-eve.org/

Python REST API Framework

Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully featured RESTful Web Services.

Eve is powered by FlaskRedisCerberusEvents and offers support for both MongoDB and SQL backends [*].

The codebase is thoroughly tested under Python 2.6, 2.7, 3.3, 3.4 and PyPy.

Eve is Simple

from eve import Eve

app = Eve()
app.run()

The API is now live, ready to be consumed:

$ curl -i http://example.com/people
HTTP/1.1 200 OK


20년간 MS Windows에서 programming했다는 이 사람 재밌네요.

E3550767c858c787c35c280047ff789c?s=47

Nicola Iarocci

10 Presentations

'Programming' 카테고리의 다른 글

Python Web Framework - Pyramid  (0) 2015.05.14
Popcorn time Android App build for Lolllipop  (0) 2015.05.06
Linux Kernel Upgrade  (0) 2015.05.04
ZeroMQ, ØMQ  (0) 2015.04.29
Install Ubuntu on VirtualBox  (0) 2015.04.27
Posted by 쁘레드