기본 콘텐츠로 건너뛰기

4월, 2014의 게시물 표시

[linux] How to connet to a WPA/WPA2 WIFI network using Linux command line

source: http://linuxcommando.blogspot.kr/2013/10/how-to-connect-to-wpawpa2-wifi-network.html This is a step-to-step guide for connecting to a WPA/WPA2 WiFi network via the Linux command line interface. The tools are: wpa_supplicant iw ip ping iw  is the basic tool for WiFi network-related tasks, such as finding the WiFi device name, and scanning access points.  wpa_supplicant  is the wireless tool for connecting to a WPA/WPA2 network.  ip  is used for enabling/disabling devices, and finding out general network interface information. The steps for connecting to a WPA/WPA2 network are: Find out the wireless device name. $ /sbin/iw dev phy#0 Interface wlan0 ifindex 3 type managed The above output showed that the system has 1 physical WiFi card, designated as  phy#0 . The device name is  wlan0 . The type  specifies the operation mode of the wireless device. managed  means the device is a WiFi station or client that connects to an access point. Check that the wireless

[python] python doesn't provide the feature of overloading. workarounds?

source: http://stackoverflow.com/questions/12179271/python-classmethod-and-staticmethod-for-beginner Though   classmethod   and   staticmethod   are quite similar, there's a slight difference in usage for both entities:   classmethod   must have a reference to a class object as the first parameter, whereas   staticmethod   can have no parameters at all. Let's look at all that was said in real examples. Boilerplate Let's assume an example of a class, dealing with date information (this is what will be our boilerplate to cook on): class Date ( object ): day = 0 month = 0 year = 0 def __init__ ( self , day = 0 , month = 0 , year = 0 ): self . day = day self . month = month self . year = year This class obviously could be used to store information about certain dates (without timezone information; let's assume all dates are presented in UTC). Here we have  __init__ , a typical initializer of Python class

[python] @staticmethod, @classmethod

source: Maybe a bit of example code will help: Notice the difference in the call signatures of  foo ,  class_foo  and  static_foo : class A ( object ): def foo ( self , x ): print "executing foo(%s,%s)" %( self , x ) @classmethod def class_foo ( cls , x ): print "executing class_foo(%s,%s)" %( cls , x ) @staticmethod def static_foo ( x ): print "executing static_foo(%s)" % x a = A () Below is the usual way an object instance calls a method. The object instance,  a , is implicitly passed as the first argument. a . foo ( 1 ) # executing foo(<__main__.A object at 0xb7dbef0c>,1) With classmethods , the class of the object instance is implicitly passed as the first argument instead of  self . a . class_foo ( 1 ) # executing class_foo(<class '__main__.A'>,1) You can also call  class_foo  using the class. In fact, if you define something to be a classmethod, it is