แสดงบทความที่มีป้ายกำกับ python แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ python แสดงบทความทั้งหมด

วันพฤหัสบดีที่ 19 พฤศจิกายน พ.ศ. 2563

Kivy on Big Sur , Mac OS X 11.0.1

 A few project i used Kivy(www.kivy.org).

When Mac OS X 11.0.1 Big Sur come. I need to recompile Kivy again. Here is my way.


Python3.7 from brew

Gstreamer-1.0-1.18.0-x86_64 (http://gstreamer.freedesktop.org/data/pkg/osx/1.18.0/gstreamer-1.0-1.18.0-x86_64.pkg)

Gstreamer-1.0-devel-1.18.0-x86_64 (http://gstreamer.freedesktop.org/data/pkg/osx/1.18.0/gstreamer-1.0-devel-1.18.0-x86_64.pkg)

SDL2-2.0.12 (https://www.libsdl.org/release/SDL2-2.0.12.dmg)

SDL2_image-2.0.5 (https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.dmg)

SDL2_mixer-2.0.4 (https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.dmg)

SDL2_ttf-2.0.15

# Install python3.7

$ brew install python@3.7


# Create new virtualenv

$ virtualenv -p /usr/local/opt/python@3.7/bin/python python3env


# Install SDL2 Gstreamer from here (https://kivy.org/doc/stable/installation/installation-devel.html#)


# then install kivy 1.11.1 from Kivy

# Updated 2.0.0 passed test.

$ pip install https://github.com/kivy/kivy/archive/stable.zip

Successfully installed Kivy-1.11.1 Kivy-Garden-0.1.4 certifi-2020.11.8 chardet-3.0.4 docutils-0.16 idna-2.10 pygments-2.7.2 requests-2.25.0 urllib3-1.26.2

Good Luck!

วันอาทิตย์ที่ 29 มีนาคม พ.ศ. 2558

Iot with Kivy, Autobahn, Twisted and Crossbar

Kivy is an object programming framework. It's a collection of the python applications together. So everyone can learn Kivy easily!

You need to know about Class!

Kivy is event loop programming. When you understand how event work you can go with many event driven programming.

Twisted -> Autobahn -> Crossbar.io

Twisted is also reactor. It's event loop! Autobahn is web-socket programming framework. Crossbar.io is WAMP router.

All components is event ! Asynchronous Programming!


Let's start :)

Kivy, main application should start with main.py (It's very important). In main.py we create WAMP component here.

วันพุธที่ 11 มีนาคม พ.ศ. 2558

Run Kivy with WAMP on Crossbar.io

Begin with my Raspberry Pi Project about Digital Signage. Totally it is going to be Iot (Internet of Things).

And this is the beginning of way i have to develop another project. The important thing about this project is Python Universal Language.

First i started with Python on Raspberry Pi with Serial Interface with nurse equipment. Old stuff start this project with web server and repeatedly refresh the web client every second.

After first version is outed. The requirement  never stop. They want to add more video in background when specific time meet, play sound and show IP camera.

Raspberry can not answer those answers.

Then we move all projects to minimal PC. It's work!

After all requirements are setting. I decide move the project into the Internet of Thing.

The players are Kivy, Twisted, Autobahn and Crossbar.io.

The next topic will be "How to implement those technologies for IoT"

วันพุธที่ 7 มกราคม พ.ศ. 2558

Fews minitue with swift and python

Notthing to do for me today. Then it's time to do something new again.

After finished projects with Kivy then i take a look to HTML5 mobile development framework. 

Do i need cross platform? May be yes and may be no!

But new player is comming  Swift . The first look on Swift for me is "Is it python version on native language on Apple?"

Let's first start with HTML5 mobile development framework. Then do native if it need.

ref: https://www.apple.com/hotnews/thoughts-on-flash/

วันอาทิตย์ที่ 26 ตุลาคม พ.ศ. 2557

Learn from both Kivy and Twisted

I, myself searched for many months to see what can i integrate Kivy and Twisted together.

Now my idea is come true.

https://github.com/digitaltrails/piKam

วันเสาร์ที่ 11 ตุลาคม พ.ศ. 2557

Haskell, What is that for me?

Today one guy come and talk with me while he's waiting for finishing of laundering machine.  He asked me about freelance in Thailand.

Am i a freelance?

He said "with freelance i can earn money more than i work in company". Is that true?


It's depend on the job you do and what kind of people see you.

In Thailand, the local company in Thailand. Most of them think in difference way.

Let's he see.

Another topic he show me the Haskell Programming Language.  I heard this Haskell before , But i now in love with python.




วันอาทิตย์ที่ 5 ตุลาคม พ.ศ. 2557

Another Raspberry PI with Kivy and implementation on Twisted.

I visited this site last month. At that time i did not know how to use it. But now i have any idea to do with this.

please visit this. Then i will do my test.


วันจันทร์ที่ 29 กันยายน พ.ศ. 2557

Brewing Gst-Python

From the last post about gstreamer. I would like to do my work on Python. Then i have to brew gst-python again.

$ brew create http://anongit.freedesktop.org/git/gstreamer/gst-python.git --set-name GstPython

Then edit formula. My formula is. $ brew edit GstPython

require "formula"

class Gstpython < Formula
  homepage "http://gstreamer.freedesktop.org/releases/gst-python/1.3.90.html"
  url "http://anongit.freedesktop.org/git/gstreamer/gst-python.git", :using => :git
  sha1 ""

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "glib" => :build
  depends_on "gstreamer" => :build
  depends_on "pkg-config" => :build
  depends_on "pygobject3" => :build
  depends_on "libffi" => :build

  def install
    system "./autogen.sh"
    system "./configure", "--disable-debug",
                          "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--prefix=#{prefix}"

    system "make"
    system "make install"
  end

end

But!!!

Remember i've not install any python yet. Yes we use python site-packages from /usr/local/lib/python2.7/site-packages/ . Homebrew can have their python environment. Then we have to install python first.

First we have to uninstall our previous python package first. Then install python by $ brew install --verbose python 

Then you will have to install GStreamer again. 

It's time to brewing get-python from now.

$ brew install --verbose GstPython

Then you can try the installation by 
Python 2.7.8 (default, Sep 29 2014, 18:34:51) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from gi.repository import Gst, GObject

In [2]: Gst.version()
Out[2]: (1L, 4L, 1L, 0L)



วันจันทร์ที่ 18 สิงหาคม พ.ศ. 2557

How to understand asyncio from python3 for me?

It is not easy for someone who is coding with synchronous applications before. For me, luckily i was learn from twisted matrix for a while.

So i read many from twisted and more on tonado framework. Then asyncio is very interesting to learn.

Please visit http://www.getoffmalawn.com/blog/playing-with-asyncio

I wish twisted will going to get asyncio from python3 as soon as.


updated: 20 Aug 2014
More documentation here http://www.drdobbs.com/open-source/the-new-asyncio-module-in-python-34-even/240168401?queryText=The%2BNew%2Basyncio%2BModule%2Bin%2BPython%2B3.4

update: 21 Aug 2014
Any twisted very briefly can be found here. http://www.aosabook.org/en/twisted.html

update: 29 Aug 2014
asyncio will avoid the "series of asynchronous callback chain."

วันเสาร์ที่ 26 กรกฎาคม พ.ศ. 2557

Kivy, another UIX for new device.

Long time on web application development. First we thought web application can easy to deploy on many operating systems and devices.

Some use java applet, flash. But when the applications are more complicated. The better way to do is going back to server side again. Then we began to use java script to do client functions.  Javascript framework are continue developing. We've switch to new framework over and over because we need the simple usage that hide the complex of javascript behind.

When personal devices are popular.  Most of users use web browser do some general purpose, like searching. Developer do responsive UI for many kind of screen width. Many standard come out like HTML5.  But it is 1 step behind user need.

After a few months with Kivy. The development for myself is changed.

Web is only is web, high-level of networks, data infrastructure. We going to use web-service to scales our application and support many kind of devices.

So i going to use Framework like Kivy to change the way.

Please try..

Webpy, Flask, Django, Tornado Web, Kivy

Then i live with Python.:)

วันเสาร์ที่ 5 กรกฎาคม พ.ศ. 2557

Why Python?

Many people ask me about this question!

My answer is "It's easy"

I, personally grew with C before and try to do next with Java, Then do more big projects with PHP.
But meanwhile i often use Python.

Someone ask me to go to Ruby. But as my answer I'm lazy to go to Ruby.

Python, for me is more fun. I can extend my new job base on Python!

.

วันพฤหัสบดีที่ 10 เมษายน พ.ศ. 2557

Moving to "Data a Brewery"

3 years with Pentaho. It was an amazing!

For my next self learning, it's time for Brewery

The reason are:

  1. Brewery is a set of Python Framework.
  2. SQLAlchemy is my favorite, and can learn at the same time with Brewery.
  3. When it's python, It's easy to tech other one.
  4. Pentaho is not easy for beginner (esp. for my students).




วันพุธที่ 31 ตุลาคม พ.ศ. 2555

What make me here?

Life has no boundaries
...
Thank for พระพุทธเจ้า to give me the way to do
Thank to my family for living
Thank for my teacher to teach
Thank for friend to completed me
Thank for other to support me
...

Favorit
Music: Classic, Soundtrack,
Band: X-Japan, Within Temptation,
Movie: ET, Star war, Beautiful mind,
Cartoon: Ghibli
Country: Thailand, Japan, Germany,
Hobby: Traveling, Book, Movie,

Far Future
50-year old
A little house on High mountain
2 dogs run around me
A few farm
Fresh air

Near Future
Contribute my knowledge to community

Next
MQ i don't want to "lost" anything
Twisted Matrix "amazing project"

Migrate
PHP to Python
SQL to ORM
html to template
Web page to Web Application
Horizontal to Vertically
Everyone is user for system
"in Band, very skilled and less skilled musician need to adopt together"

Platform
2012
We need other platform
Codeigniter.... no
Cake PHP ... no
Zend ... no
Symfony ... no
Java? ... no
Python ... yes
django ... yes
"Simple is more complexities behind"

Software Project Management
2007
Flag ship, CRM
Project management on Trac
Revision control on SVN
{{Applications}}
CRM, Case management, Knowledge management
Sales Management, Marketing Management
Email Mass Marketing
Business Inteligent
{{Application}}
We'd get our platform?
Hosting service
Customization service
Software as service
Cloud service
Python
django, my hero
"Service on Software"

Size Does Matter
2006
Fast growing database, web application was delivered to biggest TV response company
AIX RS/600 was amazing in Thailand
PostgreSQL on AIX, Possible here!
... Now our system serve more than 150GB of data...
... more than 500 users concurrent ...
"Big Huge Giant"

Software Engineering
2003
Requirement analysis
Design
Documentation
Develop
Project management
Implement
Maintain
Version control was implement
CVS SVN
Software Test
Software Quality
"Imagine is more important"

Coding Era
2001
Open source came back
PHP + PostgreSQL+ Apache
First software/service served for businesses
All software written for web, web page!
"team work"

Telephony Network
2001
Move to PABX system
Where voice and data merge here!
Business applications, CRM, messaging system, monitoring software were introduced
Many software are integrated together to complete requirement
"meeting, meeting, business!"

Work!
2000
1-year computer networks, internet servers
ATM, Router, Switch had been setup to serve user
Some on MCU to make meeting over network
We served 600 users with single mail server! with Linux Debian
Open source begin!
Python first introduced
"i'm hungry to know more"

Big Moves
1999
Rosenheim, Germany was next moves
Signal Processing in Big Firm, Siemens
Linux first come in to my life
Environment change
Vision changes
Attitude changes
Life changes
Explore Resenheim
"2nd miracle, Amazing! Incridible"

University
1999
Electrical Engineering Department
Computer/Communication was my major
Digital Image processing using DSP was my project
i fork here
"First miracle, it happend all the time."

Technical School
1996
Knight Rider brought me here
"Time and Time to wait and go for get it"

Next School
1993
Math-Sci was my major here
Music, was my hobby
Trumpet, French-horn were my next instruments in school band
"in a Band, very skilled and low skilled musician need to adopt together"

School
1990
My school was near Wat
I had to walk to school from home every day
I played music on last 3 year in first school
My first instrument was melodeon
"music is one of meditation"

Childhood
I was the second child of three children
We lived close to Wat
I have to learn Buddhism without knowing it
"know nothing means know everything"

Begin
1977
I was born on 10 April
Male
Bangkok, Thailand was my birth place
"a Child can make things"

วันจันทร์ที่ 10 พฤษภาคม พ.ศ. 2553

TTS กับเพชรพระอุมา

จำได้ว่าใช้เวลาในการอ่านเพชรพระอุมาไป 2 ปีเต็ม ๆ ตอนนี้กะว่าจะอ่านอีกรอบ แต่ก็ยังไม่มีเวลานั่งอย่างจริงจังเท่าไหร่ ในรอบใหม่นี้จะทำความเข้าใจกับสำนวนมากกว่าเนื้อหาเหมือนคราวก่อน ๆ พอดีไปค้นว่าคนอื่นเค้าอ่านแล้วได้อะไรกันบ้าง กลับเจอว่ามีคนอ่านเพชรพระอุมา ให้คนพิการทางสายตา หรือเข้าถึงหนังสือได้ยากฟัง

หลังจากที่ได้ฟังการอ่านบางตอนแล้วก็พบว่า คิดถึง "นกน้อย" หรือคณะพากษ์ละคร ที่มีในสมัยก่อนมาก

แต่ในฐานะนักพัฒนาระบบแล้ว ผมกลับอยากพัฒนาระบบ Text to Speech เพื่ออ่านหนังสืออื่น ๆ ด้วย เพราะจะพึ่งการอ่านจากคนต้องใช้เวลาและความร่วมมือค่อนข้างสูง

ที่ดูไว้ก็มี pyTTS, pyTTSx นั่นแหละ

วันอังคารที่ 4 พฤษภาคม พ.ศ. 2553

Sphinx! then with Thai Latex on Mac snow leopard

อ้างอิง: http://vuthi.blogspot.com/2005/03/thai-latex-mac-os-x.html

คราวนี้ก็ต้องมาทำหน้าที่เป็นผู้แต่งหนังสือคู่มือการใช้งาน นานมาแล้วเคยใช้ Latex ซึ่งมันก็ยอดมาก แต่ว่าดูแล้วมันซับซ้อนและเข้าใจยากและยิ่งผมไม่ค่อยได้จับมานาน ก็ยิ่งงงกันไปใหญ่

มาคราวนี้เห็นเค้าพูดกันหนักหนาว่า Sphix นั้นมันดีทีเดียวสำหรับการเขียนคู่มือ โดยเฉพาะอย่างยิ่ง สำหรับการเขียนเอกสารโดยโปรแกรมเมอร์

แต่พอทำเสร็จแล้วลูกค้าอยากได้เป็น PDF ซะงั้น เอา! ตามเค้าไป

แน่นอนคงไม่พ้น Latex แต่ปัญหามันอยู่ว่า ต้องทำให้เครื่อง Mac Book ผมใช้งาน Latex ภาษาไทยได้ด้วยสิ

มาเร่ิมกันครับ


  1. ติดตั้ง Fink ก่อน
  2. จากนั้นก็ติดตั้ง sphinx
  3. แล้วก็มาถึงคราว Latex
    ปกติแล้วการติดตั้ง sphinx จะมี latex มาให้ด้วยแต่ก็ติดตรงที่ว่า ไม่สามารถใช้งานภาษาไทยได้ดี สุดท้ายต้องติดตั้ง thailatex
    1. ติดตั้ง Thai latex จาก ftp://linux.thai.net/pub/thailinux/software/thailatex/thailatex-0.4.3.tar.gz
      $ tar xzvpf thailatex-0.4.3.tar.gz
      $ cd thailatex-0.4.3
      $ ./configure --prefix=/sw #ติดตั้งไว้ที่ fink
      $ sudo make
      $ sudo make install
    2. แล้วตามด้วยการตัดคำภาษาไทย ผมใช้ swath เพราะว่าหา cttext ไม่เจอ ติดตั้งจาก ftp://linux.thai.net/pub/thailinux/software/swath/swath-0.4.0.tar.gz
      $ tar xzvpf swath-0.4.0.tar.gz
      $ cd swath-0.4.0
      $ ./configure --prefix=/sw
      $ sudo make
      $ sudo make install
    3. อย่าพึ่งดีใจไป ปัญหาที่บอกจากเว็บข้างบนต้องแก้ไขก่อน
      $ updmap --disable thai.map --nohash --nomkmap
      $ updmap --enable Map thai.map
พอเราติดตั้งเสร็จก็เป็นอันเสร็จสำหรับ Latex แต่พอมาใช้กับ sphinx ดันมีบางสิ่งที่ต้องทำแฮะ

ไปแก้ไข conf.py ที่ source directory โดยเพิ่มอันนี้เข้าไปต่อจาก Latex Output

# Latex Elements
latex_elements = {
'babel': '\\usepackage[thai,thainumber]{babel}',
'inputenc': '\\usepackage[utf8x]{inputenc}',
}

เมื่อเราทำการ make latex ที่ source directory แล้ว ก็ทำดังนี้
_build/latex $ swath -u u,u -f latex <> file2.tex # ตัดคำให้สวยงาน
_build/latex $ mv file2.tex file.tex # เปลี่ยนชื่อซักหน่อย
_build/latex $ make all-pdf
เท่า นี้เราก็จะได้ file.pdf แล้ว

Extend User Model in Django

ref: http://docs.djangoproject.com/en/dev/topics/auth/
ในระบบทั่ว ๆ ไปก็ต้องการ Login เพื่อตรวจสอบการใช้งานของผู้ใช้งาน และด้วย Django นั่นมีระบบจัดการ User ให้แล้ว ดังนั้นจะเป็นการดีมากหากเรานำมาใช้งานต่อได้

ใน Django นั้นมีระบบที่เรียกว่า User authentication มาให้ดวย โดยระบบดังกล่าวประกอบด้วย

  1. Users
  2. Permission
  3. Groups
  4. Messages
ใน Class models.User นั่นประกอบด้วยข้อมูลไว้สำหรับทำการ Login แต่ว่าด้วยระบบส่วนใหญ่ที่ผมทำนั้นจะประกอบด้วย Organization, Company, Department, Team ... ดังนั้นก็เลยต้องทำการ extend models นั่นเอง

ผมก็สร้าง app มาใหม่ชื่อว่า user แล้วทำการสร้าง model ดังนี้

from django.contrib.auth.models import User
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
code = models.CharField(max_length=100, null=True)
prefix = models.ForeignKey(Prefix, null=True)
email2 = models.EmailField(null=True)
gender = models.ForeignKey(Gender, null=True)
home_phone = models.CharField(max_length=100, null=True, db_index=True)
mobile_phone = models.CharField(max_length=100, null=True, db_index=True)
work_phone = models.CharField(max_length=100, null=True, db_index=True)
pic_url = models.ImageField(upload_to='emp', max_length=200, null=True)
signature = models.TextField(null=True)

def __unicode__(self):
return self.user.get_full_name()


เท่านี้เราก็จะได้การจัดการ User แล้ว

pyCon ที่ Asia

สืบเนื่องมาจากผมใช้ Python หาเงินใช้มาก็หลายโครงการ ถ้าหากมีเวลาและมีค่าใช้จ่ายพอ ก็คิดว่าจะแวะไปดูงานนี้ซักหน่อย

http://apac.pycon.org/