Month: January 2013

  • Solve PyGame sh: smpeg-config: command not found in Fedora

    Installing PyGame via pip will showing this problems. The easy is installing from yum by: 1sudo yum install pygame

  • Example create socket connection between Node JS and Python

    I build an experiment which is a multiplayer Pong game that using NodeJS and Django. This game need to build communication between browser in mobile phone as GamePad and browser in my laptop as display. Then, I facing this performance issue which there are delay between button get pressed in mobile browser and pong bar […]

  • Synergy between Mac and Linux and solve connection refused problem

    To make Synergy works in both Mac (as client) and Linux (as server), we should do this things: 1. Make sure have same version If synergy version on client and server different, then connection problem will be occur. So make sure we installing same version on both client and server. 2. Use Version 1.3.7 I […]

  • Django models objects get attribute fields using string

    We can get django objects fields using string by “getattr”. For instance, I have profile objects. 1getattr(profile, "name") Easy! 😀

  • Find foreign key fields in Django models

    On some spesific task, we need to list all fields on object and identify which that have foreign key type. For instance I have “profile” objects taken from Profile models. 1234profile = Profile.objects.get(id=1) # get all fields profile._meta.fields Now, to identify which fields that ForeignKey type, we can iterate through the fields and check on […]

  • Example using Express 3 and Socket.io on the same ports

    Here is a quick example of using Express and Socket.io together. Usually, you landed into this pages because having problem like “express socket.io not found”, “static files in express to find socket.io.js” or someother else. 1. package.json 123456{  "name" : "example-express-socketio",  "version" : "0.1.0",  "dependencies" : {"socket.io" : "0.9.6",             […]

  • Setup httpd conf virtualhost apache in Fedora 18

    Configuring apache / httpd in Fedora 18 to works with custom folder like “htdocs” and do the directory listing index is a bit irritating. Here is the errors that you might be facing like: 1234AH01630: client denied by server configuration htaccess: allow not allowed here AH01276: Cannot serve directory /var/www/: No matching DirectoryIndex (index.html,index.php) found, […]

  • Fix httpd apache wont start problem in Fedora 18

    I found that I can’t start httpd / apache services in Fedora 18. There is several problem here. Let’s go to the first problem by running “service httpd start” : 12Redirecting to /bin/systemctl restart  httpd.service Job for httpd.service failed. See ‘systemctl status httpd.service’ and ‘journalctl -xn’ for details. This give me errors : 1sudo systemctl […]

  • How to change Grub OS order in Fedora 18

    There is a change in grub.cfg in Fedora 18. Right know, it’s not located in “/boot/grub2/” anymore. You can find it on “/boot/efi/EFI/fedora/grub.cfg”. Here is the example of changing the OS order sequence: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960… ### BEGIN /etc/grub.d/10_linux ### menuentry ‘Fedora’ –class fedora –class gnu-linux –class gnu –class os $menuentry_id_option ‘gnulinux-simple-69bfc31f-6ea3-4f28-aa18-6ef94dc3eed8’ {         […]

  • Example encode and decode image using base64 in Python

    This is the simple way to encode images using base64 library in Python and decoded it back into the images based on the string encoded results. Here is the code : 12345678910111213141516import base64 def convert(image):     f = open(image)     data = f.read()     f.close()     string = base64.b64encode(data)     […]

  • Solve creating file buffer problem that make Aptana very slow

    I notice this today which I download the latest Aptana and run it under Fedora 18. It’s very slow and every time opening a new file, I got “creating file buffer” notification and takes like 1-3 minutes to finish. Then I realize the problem because the Java version I use. In Fedora 18, by default […]

  • Guide setup Fedora 18 in Macbook Pro

    Here is the full guide setup Fedora 18 Spherical Cow in Macbook Pro. 1. Install Wireless Please follow my another tutorial : http://www.yodi.sg/fix-broadcom-wireless-not-working-in-fedora-18/. 2.Install development packages 123sudo yum install make automake gcc gcc-c++ libxslt libxslt-devel libxml2 libxml2-devel libffi libffi-devel libcurl libcurl-devel openssl-devel sqlite-devel libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 libxslt-devel sudo yum install postgresql-server postgresql-devel nmap ImageMagick […]

  • Fix Broadcom Wireless not working in Fedora 18

    Fedora 18 “Spherical Cow” have problem with wireless driver. I use macbook Pro at this example, and here is my wireless by “lspci” : 1202:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01) 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5764M Gigabit Ethernet PCIe (rev 10) Then I need to install the “broadcom-wl” […]

  • Example XMLRPC communication between Django and Java

    XMLRPC is useful when we need to send / receive information from one platform to others. In this case, I will use Django as the server which provide services that can be accessed as XMLRPC method from Java. First, we need to setup Django projects and set the XMLRPC server. In quick way, I use […]

  • Solve android XMLRPC client can’t connect to 127.0.0.1 or localhost

    When you got error that your Android application can’t do XMLRPC client to host like 127.0.0.1 or localhost or some IP address like this: 12345678910111213141516171819202122232425262728293031323301-16 03:45:06.650: W/System.err(7414): org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.4:8000 refused 01-16 03:45:06.660: W/System.err(7414):         at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178) 01-16 03:45:06.660: W/System.err(7414):         at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 01-16 03:45:06.660: W/System.err(7414):     […]

  • Aware with the way Python treat and re-use existing objects

    Python has a unique way when creating and re-using objects. See this example : 12345678def x(y=[]):     y.append("1")     return y if __name__ == "__main__":     print x()     print x()     print x() This will showing result: 123[‘1’] [‘1’, ‘1’] [‘1’, ‘1’, ‘1’] Why this is happen? See the […]

  • Converting image with Base64 encode will give bigger results size

    Base64 usually needed to represent binary data into ASCII format, or in other case to make it more “readable”. Some case study why we need to convert binary into ASCII like this : 1. There is Android App that have function to take picture 2. This picture will send to website 3. In Website (Django […]

  • Solve load font face Cloudfront, Amazon S3 and Firefox / IE caused by CORS access control allow origin *

    Usually we try host our custom font into Amazon S3, cached by Cloudfront and use it into our website. If you can’t load your font using font face from Firefox / IE, this posting is match for your problem. This problem mostly occur on Firefox and IE because this browser have restriction on Cross Origin […]

  • Setup WSGI Apache for Django 1.4 Production

    Here is the example of wsgi under your //wsgi.py: 12345678910111213141516171819202122232425262728293031323334353637383940""" WSGI config for bodyslap project. This module contains the WSGI application used by Django’s development server and any production WSGI deployments. It should expose a module-level variable named “application“. Django’s “runserver“ and “runfcgi“ commands discover this application via the “WSGI_APPLICATION“ setting. Usually you will have […]

  • I select particular number of item in selection on Lettuce test

    I select particular number of item in selection on Lettuce test and simply by: 1234@step(‘I select item "([^"]*)" from "([^"]*)"’) def i_select_item_number_from_select(step, number, select_name):     world.browser.find_by_xpath(‘//select[@name="%s"]/option[%s]’ %                                 (select_name, number)).click()

  • Python try except exception showing the message error

    When we don’t know about what the kind of error that throwed by try: … except: .., we can just print out the message by: 1except Exception, e: And get the error from “message” attribute of “e”. For instance: 123456a = [] try:     a[100] except Exception, e:     print e.message

  • Fix Django RuntimeError: Settings already configured when executed scripts manually

    Sometimes we need to create independent files that need to load Django environment and to get executed manually outside from Django apps. For instance, we need to create backup.py which will backup the django project database but read settings.py for the database configuration. Usually, we can do on this way, assume the files located in […]