rynop's tech blog http://rynop.com Most recent posts at rynop's tech blog posterous.com Wed, 05 Oct 2011 06:43:00 -0700 Tight budget with couchbase(membase) server on amazon EC2 http://rynop.com/tight-budget-with-couchbasemembase-server-on http://rynop.com/tight-budget-with-couchbasemembase-server-on

In a previous post I discussed the benefits of using membase server.  I mentioned that I was using the "memcached" bucket type instead of the membase bucket type, because I wanted to save money.  I was using EBS backed EC2 instances, and while the membase writes to disk do not impact performance significantly, disk I/O in EC2 costs you money if your using EBS.

Instance-store to the rescue.

Instead of using EBS, you can use the local "instance store" to back your root device.  AWS does not charge for I/O to instance-store. The downside, is the data is not persistent (if your instance dies/terminates, so does the data on the root device).  The good thing is membase supports replication - so if you do need to make sure your data does not go away, simply enable replication (its a SINGLE checkbox in membase :)

To summarize:

  • Using instance-store instances to create your membase cluster will give you the ability to use membase buckets without the I/O cost
  • Using membase buckets is good because 1) has more features 2) in my personal opinion, membase buckets are more stable because they are more common, and thus have much more burn-in out in the field
  • Making your own instance-store backed AMI is a pain, but its doable.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Fri, 16 Sep 2011 20:38:00 -0700 HOWTO setup Eclipse 3.7 (Indigo) for CakePHP 1.3 development http://rynop.com/howto-setup-eclipse-37-indigo-for-cakephp-13 http://rynop.com/howto-setup-eclipse-37-indigo-for-cakephp-13

There are lots of great resources out there for developing CakePHP apps in eclipse - but they are outdated and scattered.  I took the time tonight to setup my environment, so I figured I'd blog about it.  Below are the steps I took to get thinks as I like 'em. I run Ubuntu 10.10 64bit, but these directions should apply to any OS.  This requires you have CakePHP 1.3.X extracted someplace on your box.

  1. Install Eclipse 3.7 (indigo). If your just gonna do PHP development, get the classic version.
  2. Help > install new software > work with: all available sites > search for PDT. Install PDT.
  3. Optional: Install Subversive if you use SVN, or install Egit if you use git/github. Subversive is available in default indigo eclipse repo. For Egit, i'd recomend using the http://download.eclipse.org/egit/updates repo.
  4. Setup your PATH to use the cake console (optional, requires php5-cli to be installed).  This allows you to call 'cake bake help' for example, from your terminal.  Edit ~/.profile and add to the bottom of the file
    PATH="/path/to/cake/runtime/13/cake/console:$PATH"
  5. Setup eclipse so it can run 'cake bake directly' from the IDE.
    1. Open eclipse, go to your PHP explorer perspective.  From the menu choose Run > External Tools > External Tools Configurations
    2. Click Program, then new program (white page upper left). Give it a name like Cake bake.
    3. In the Location field put the full path to the cake console script.  I have 1 shared runtime on my box for all my CakePHP 1.3 based apps. Ex: /opt/cake/runtime/13/cake/console/cake. Note: If you typically run diff versions of cake or have the cake runtime directly in your project, you can insert variables in the location box (like workspace).
    4. Under Working Directory put ${project_loc}/app
    5. Under Arguments put 'bake'
    6. Now click Apply then close.
    7. Test it out by clicking on a cake project (must have the structure of 'project name' with a subfolder called 'app'), then clicking Run>External tools>Cake bake.  This will open a console that you can type in.
  6. Repeat Step 5 for other cake console things you would like to use from the IDE (like 'cake console' for example)
  7. Setup syntax highlighting for .ctp files:
    1. Window > Preferences > General > Appearance > content Types > Text > PHP Content type > Add.. , then put in *.ctp.
  8. Install Open Cake File eclipse plugin to enable fast switching between your MVC classes/files. This is not well known, but its a nifty plugin.

 

Thats it! If you know of any other cool things email me, and I'll add em. Note: I left off code completion intentionally, as I big fan of the implementation of the solutions I've seen.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Fri, 02 Sep 2011 11:16:00 -0700 Use Membase and you'll never want to mess with memcached servers again http://rynop.com/use-membase-and-youll-never-want-to-mess-with http://rynop.com/use-membase-and-youll-never-want-to-mess-with

I've used memcached quite frequently in projects, it is a great product.  I heard of a memcached compatable product called Membase about 8 months or so ago, but did not have time to try it out until last week.  All I can say is WOW. I'll never use stand alone memcached server(s) again.

Highlights

  • crazy easy to install and make a cluster.
  • 0 changes to your app code. Operates seamlessly with memcached protocol.  If you want to take advantage of advanced features, you need to modify app code.
  • you can dynamically add and remove nodes without losing all your keys/data.
  • 2 bucket types:
    1. Membase: supports data persistence (writes them ionicely to disk) and replication (one node dies, you dont lose your key/value pairs). It sends data to disk as fast as it can (while giving priority to getting data back from disk). This is done asynchronously (with an option for synchronous), so clients shouldn't be able to perceive a difference between Membase and memcached data buckets.
    2. Memcached: no persistence or replication. all in memory. I would highly recomend going membase bucket unless you have some I/O concerns (like you get charged for I/O in the cloud).
  • Awesome admin web UI. You can get feel for it in this screencast (this is for v2.0, but its similar). It updes real time, gives great stats, and is intuitive.
  • lots of documentation
  • helpful community (I found the freenode #couchbase irc channel to be really helpful) 

How I'm using Membase

I have a membase cluster setup in EC2. All m1.smalls. I would not recomend smalls if you can afford going larger, as smalls only have 1 cpu core and have "moderate" I/O.  Because of the I/O cost ($) in EC2, and because I don't need persistence or replication for my apps (at this point), I went with membase bucket.  I'd highly recomend going Membase bucket if you can.  I've spoken with one of the Couchbase dev's, and in practice they have not seen much performance difference between the membase and memcached buckets.

I've had pretty good transactions/sec with just 2 m1.smalls - easily over 1,250/second.  I'm sure I could get more no problem. I get roughly the same numbers when using membase and memcached buckets.

I have 2 autoscale groups setup to keep my cluster highly available AND easily scale up/down based on load.  Essentially, I have one "master" node that I assign an elastic IP. Its in a auto scale group of min 1/max 1 - so if there are problems it gets replaced and automatically gets the EIP. I then have a second autoscale group that on startup joins the cluster via the master node EIP. This is a super cheap way of getting enterprise class HA and scale - 4 data centers (availability zones), "ip failover".

I could have the cluster automatically scale up based on load, but I decided not to go this route based on the fact that when the cluster topology changes it needs to be "rebalanced".  This can be a resource intensive task - so I would not want it happening while I was under load (the reason it scaled up in the first place).  For now I just monitor load manually, and scaling up is 1 command to add a node, and a push of a button to rebalance (when I deem its a good time).

If you do decide to run membase in the cloud, you must read Membase in the cloud docs.

How my app connects to Membase

My apps that consume the membase cluster are php based. Spefically I use php-fpm and nginx.  FPM has some great features like fastcgi_finish_request(), but thats another blog post in its self.  Anyways, Membase has a great app called Moxi. It runs either client side (where your webapp is) or server side (on Membase cluster nodes).  If you want to get up and running fast (without touching your existing app), just point your app at any server in the membase cluster (port 11211 by default) and it will use the moxi on the membase server without you even knowing.

If you want to improve performance, and take advantage of connection pooling - check out client side moxi.  Client side moxi will stay in contact with the cluster, so if any node goes down it will handle it transparently for you. Also, because it stays in contact with the cluster, when interacting with a  key, it goes directly to the correct node that has that key (performance++).  Client side moxi also has connection pooling - which is great for fast CGI processes.  After installing client side moxi, just have your app make a persistent memcache connection to localhost:11211 and your done.  Moxi acts as a proxy and does all the work.

In conclusion ...

  • If you use memcache servers, using Membase in their place is a no-brainer.  Community version is free (if you can adhere to the open source licence). You can get everything up and running in < 5 minutes on Debain, RPM or windows based machines.
  • When creating buckets, you should use membase type buckets.  Using memcached buckets does not make sense in most cases.
  • Spend the time to research client side moxi. Also, you may be using a language that supports a type 2 membase client. If so you may want to use it instead of moxi.

I'm still not a membase expert, so if you have any thoughts/improvements please leave me a comment.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 23 Aug 2011 07:56:00 -0700 Use JMeter to test a load balanced web application http://rynop.com/use-jmeter-to-test-a-load-balanced-web-applic http://rynop.com/use-jmeter-to-test-a-load-balanced-web-applic

I often use JMeter to test web apps and web services - it is a great tool - easy to use (GUI based), java based (so runs on any platform), lots of function etc....

Now that most production level apps/services sit behind a load balancer (AWS ELB for example) JMeter will not really test all the servers behind the ELB without some configuration.  Why? Java DNS cache.  For load balancers that use a DNS based distrubution method (like round robin), your HTTP client makes a connection to the load balancer, and the load balancer says "hey use IP x.x.x.x".  Your HTTP cleint then caches that ip for future requests.

This is not good when trying to test your load balanced app, as you will only be testing one of the nodes that is behind the load balancer.  To get around this in JMeter, just change the JVM dns ttl by passing a properties file to JMeter. Example:

 

$ cat test.properties 

networkaddress.cache.ttl=0
sun.net.inetaddr.ttl=0

 

Now run JMeter via:
jmeter -q test.properties -t test_plan.jmx 

 

Thats it!

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Fri, 27 May 2011 12:19:00 -0700 cakephp 1.3 and php 5.3 performance improvement http://rynop.com/cakephp-13-and-php-53-performance-improvement http://rynop.com/cakephp-13-and-php-53-performance-improvement

I've been doing some profiling of my cake apps. Found a decent improvement.

For your production apps only

in core.prod.php change
        Configure::write('log', true);
to

define('DISABLE_DEFAULT_ERROR_HANDLING',1);
Configure::write('log', E_ERROR | E_WARNING);

You don't even know it (cuz it never logs) but because cake has backwards compatibility with php4, there are tons of notices and strict notices thrown that cake swollows.  Thing is, there are 300+ of these every request - thats 300+ extra method and stack increases each request.  The downside of my "fix" above is PHP warnings/errors will no longer be written to the tmp/logs/error.log - instead it will go to the generic php5-fpm /var/log log.  Which to me is way worth the perf increase.

I opened a ticket u can read if u want more info - this should be a no-issue in cake 2.0.

Want to profile your app? I highly recomend http://www.xdebug.org/docs/profiler and easy x-debug plugin for Firefox.  You can see my post on setting up a debugger for php and eclipse for more info.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 03 May 2011 07:20:00 -0700 Take website screenshots on headless linux display http://rynop.com/take-website-screenshots-on-headless-linux-di http://rynop.com/take-website-screenshots-on-headless-linux-di

Here are the steps to setup a linux headless display server to take screenshots of websites using http://cutycapt.sourceforge.net/ and Xvfb. This example is using ubuntu 10.10 64bit.

*this assumes you have cutycapt installed and working - as well as Xvfb

  1. If your taking multiple screenshots (like as a service for example) you'll want to run Xvfb as a service.  Create the following file in /etc/init.d/screencap

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    
    #!/bin/sh

    ### BEGIN INIT INFO
    # Provides: screencap
    # Required-Start: $local_fs $remote_fs $network $syslog
    # Required-Stop: $local_fs $remote_fs $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts the Xvfb server
    # Description: starts Xvfb using start-stop-daemon
    ### END INIT INFO

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/bin/Xvfb
    NAME=screencap
    DESC=screencap
    DAEMON_OPTS=":1 -screen 1 1024x768x24 -nolisten tcp"

    test -x $DAEMON || exit 0

    set -e

    . /lib/lsb/init-functions

    case "$1" in
    start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --make-pidfile --background --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON -- $DAEMON_OPTS || true
    echo "$NAME."
    ;;

    stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON || true
    echo "$NAME."
    ;;

    restart|force-reload)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON || true
    sleep 1
    start-stop-daemon --start --make-pidfile --background --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
    echo "$NAME."
    ;;

    status)
    status_of_proc -p /var/run/$NAME.pid "$DAEMON" Xvfb && exit 0 || exit $?
    ;;
    *)
    echo "Usage: $NAME {start|stop|restart|status}" >&2
    exit 1
    ;;
    esac

    exit 0

  2. Make it so it runs at startup

    sudo update-rc.d screencap defaults
    sudo chmod 700 /etc/init.d/screencap
  3. Now you can restart, or run:

    sudo /etc/init.d/screencap start
     

  4. Now from another terminal take the screenshot:

    DISPLAY=:1 /usr/bin/CutyCapt --url="http://rynop.com" --out="rynop.jpg" --out-format=jpeg --plugins=off --delay=4000

 

So why not use xvfb-run? I intend to take multiple screenshots, so starting Xvfb before every screenshot, then killing (which xvfb-run does) it alot of wasted overhead.  I see the Xvfb process only takes up ~ 7megs of memory - so its not really all that bloated.

Taking screenshots is pretty slow, as you have to wait for page to render.  If anyone has tips on how to improve performance please let me know.

Extra credit - monitor the service with monit

  1. Create the following file: /etc/monit/conf.d/screencap.monitrc

    1
    2
    3
    4
    5
    
    check process Xvfb
        with pidfile /var/run/screencap.pid
        start program = "/etc/init.d/screencap start"
        stop program = "/etc/init.d/screencap stop"

  2. Run /etc/init.d/monit restart

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Fri, 29 Apr 2011 15:02:00 -0700 Eclipse PDT, XDebug, nginx, PHP5-fpm http://rynop.com/eclipse-pdt-xdebug-nginx-php5-fpm http://rynop.com/eclipse-pdt-xdebug-nginx-php5-fpm

So I finally got Eclispe setup to debug my PHP5 fpm through nginx and I figured I'd share how to do it, since I was unable to find anywhere on the web that had clear step by step instructions.  These assume you have eclipse installed, as well as nginx with php5-fpm as well as the xdebug php modlue.  For me, php5-fpm was running under localhost on port 9000 on ubuntu 10.10 64bit.

  1. Setup xdebug.ini (/etc/php5/fpm/conf.d/xdebug.ini on ubuntu)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    zend_extension="/usr/lib/php5/20090626/xdebug.so"

    xdebug.profiler_output_dir=/home/<username>/Desktop/profile
    xdebug.profiler_enable_trigger=1
    xdebug.profiler_enable=0

    xdebug.remote_enable=true
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9001
    xdebug.remote_handler=dbgp
    xdebug.remote_autostart=0
  2. Restart php5-fpm
  3. From eclipse:
    1. window > preferences > PHP > debug:
      Debugger: xdebug. Click configure and put port 9001 for XDebug port. And for Accept remote session (JIT) choose any.
      Uncheck "Break at first line"
    2. Next to server click PHP Servers. Click New, put in any name, and the URL you would put into your web browser to get to the page on your local system (mine for example is https://localhost.mydomain.com - I put an entry into /etc/hosts that maps localhost.mydomain.com to 127.0.0.1)
    3. window > preferences > General > We Browser:
      Clcik Use external, add your fav browser (I did new, /usr/bin/firefox).
    4.  From PHP perspective in eclipse, do run > debug configurations..
      1. Click PHP Web page and press "new launch configuration"
      2. Give it a name, choose:
        Server Debugger: XDebug
        PHP Server: <name of server u made in step 3.2 above>
        File: <the file in your workspace u want to debug - click browse button for help finding it>
        Uncheck break at first line
        Uncheck autogenerate, and put in a valid URL 

 

OK so now you should be able to press "debug" and your external browser will open (firefox in my case).  Use your browser and navigate to the php page where you have set a breakpoint. It should instantly flip to debug perspective in eclipse and hit ur breakpoint.  

Happy debugging. If you have any tricks that I don't know about please get ahold of me and I'll update this post.

Update 5/27/11: You gotta check out the easy x-debug plugin for Firefox. It allows you to enable remote debugging and/or profiling with 1 click. If you use this plugin, you can skip steps 3 and 4 above. Just click the start icon in firefox, then request your page. If you have a breakpoint setup in your php project in eclipse it should automatically launch the debug view.

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Mon, 29 Nov 2010 20:10:00 -0800 CakePlate - a boilerplate CakePHP distribution for rapid web apps http://rynop.com/cakeplate-a-boilerplate-cakephp-distribution http://rynop.com/cakeplate-a-boilerplate-cakephp-distribution

You know how as a developer each time you create a new web app you spend the first few hours downloading, installing, and configuring the important add-ons that you need for nearly any production-level project? When all you really want to do is get started on your kick-ass code! That's why a friend and I decided to do something about it. We're launching CakePlate, a open source distribution of CakePHP that's ready to rock, right out of the box.

Check out the announcement and learn more by visiting http://cakeplate.posterous.com/

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 02 Nov 2010 19:07:00 -0700 HOWTO setup Eclipse 3.7 (Indigo) for CakePHP 1.3 development http://rynop.com/setting-up-eclipse-36-for-cakephp-13-developm http://rynop.com/setting-up-eclipse-36-for-cakephp-13-developm

Note: updated 9/9/11 for eclipse 3.7 (Indigo)

There are lots of great resources out there for developing CakePHP apps in eclipse - but they are outdated and scattered.  I took the time tonight to setup my environment, so I figured I'd blog about it.  Below are the steps I took to get thinks as I like 'em. I run Ubuntu 10.10 64bit, but these directions should apply to any OS.  This requires you have CakePHP 1.3.X extracted someplace on your box.

  1. Install Eclipse 3.7 (indigo). If your just gonna do PHP development, get the classic version.
  2. Help > install new software > work with: all available sites > search for PDT. Install PDT.
  3. Optional: Install Subversive if you use SVN, or install Egit if you use git/github. Subversive is available in default indigo eclipse repo. For Egit, i'd recomend using the http://download.eclipse.org/egit/updates repo.
  4. Setup your PATH to use the cake console (optional, requires php5-cli to be installed).  This allows you to call 'cake bake help' for example, from your terminal.  Edit ~/.profile and add to the bottom of the file
    PATH="/path/to/cake/runtime/13/cake/console:$PATH"
  5. Setup eclipse so it can run 'cake bake directly' from the IDE.
    1. Open eclipse, go to your PHP explorer perspective.  From the menu choose Run > External Tools > External Tools Configurations
    2. Click Program, then new program (white page upper left). Give it a name like Cake bake.
    3. In the Location field put the full path to the cake console script.  I have 1 shared runtime on my box for all my CakePHP 1.3 based apps. Ex: /opt/cake/runtime/13/cake/console/cake. Note: If you typically run diff versions of cake or have the cake runtime directly in your project, you can insert variables in the location box (like workspace).
    4. Under Working Directory put ${project_loc}/app
    5. Under Arguments put 'bake'
    6. Now click Apply then close.
    7. Test it out by clicking on a cake project (must have the structure of 'project name' with a subfolder called 'app'), then clicking Run>External tools>Cake bake.  This will open a console that you can type in.
  6. Repeat Step 5 for other cake console things you would like to use from the IDE (like 'cake console' for example)
  7. Setup syntax highlighting for .ctp files:
    1. Window > Preferences > General > Appearance > content Types > Text > PHP Content type > Add.. , then put in *.ctp.
  8. Install Open Cake File eclipse plugin to enable fast switching between your MVC classes/files. This is not well known, but its a nifty plugin.

 

Thats it! If you know of any other cool things email me, and I'll add em. Note: I left off code completion intentionally, as I big fan of the implementation of the solutions I've seen.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Fri, 23 Jul 2010 02:39:00 -0700 Amarok 2.3.1 steps up its game http://rynop.com/2010/07/amarok-you-are-starting-to-earn-my.html http://rynop.com/2010/07/amarok-you-are-starting-to-earn-my.html Amarok you are starting to earn my trust back. 2.3.1 is the first 2.x release that has made me say "wow" a few times.  Glad you are getting your form back.

Few slick features that have been added (some were in 1.x):

  • Automated playlist generator
  • Bookmarkable Filters ex: added:<1week
  • Randomize current playlist
yea I'm a dork that gets excited about stuff like this.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 20 Jul 2010 04:50:00 -0700 CakePHP Cache::config and the prefix problem http://rynop.com/2010/07/cakephp-cacheconfig-and-prefix-problem.html http://rynop.com/2010/07/cakephp-cacheconfig-and-prefix-problem.html

I use memcache heavily when using CakePHP.  I ran into a problem tonight where one of my CakePHP webapps seemed to be using some cache files from another CakePHP webapp on the same server.

The fix was simple - the problem is the example values for Cache::config are a bit misleading. So here is the default config for memcache for CakePHP 1.3

Cache::config('default', array(
  'engine' => 'Memcache', //[required]
  'duration'=> 3600, //[optional]
  'probability'=> 100, //[optional]
   'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
   'servers' => array(
    '127.0.0.1:11211' // localhost, default port 11211
   ), //[optional]
   'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
 ));

You will notice that by default, the prefix of your memcache keys is 'APP_DIR' define. Problem is, in app/webroot/index.php 'APP_DIR' is typically defined as 'app' - and what makes the app unique is really the 'ROOT' in index.php (I always change this value to my application root for performance reasons).

So webapp 1 and webapp 2 were both using keys prefixed by 'app_' - which of course will cause collisions. So the race condition was taking full form here, 1st webapp to load with a empty cache at the given key, got the write.

So the fix is simple, if your 'APP_DIR's are not unique (like mine) then choose something else instead of the APP_DIR.  Any per web app unique string will do - Inflector::slug will make sure its safe for a key.

So here is an example of how mine is implemented:

Cache::config('default', array(
  'engine' => 'Memcache', //[required]
  'duration'=> 3600, //[optional]
  'probability'=> 100, //[optional]
   'prefix' => Inflector::slug('leaguelogix.com') . '_', //[optional]  prefix every cache file with this string
   'servers' => array(
    '127.0.0.1:11211' // localhost, default port 11211
   ), //[optional]
   'compress' => true, // [optional] compress data in Memcache (slower, but uses less memory)
 ));

Hope this helps someone else..

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 20 Jul 2010 04:30:00 -0700 Posting source code to blogger.com and blogspot.com blog http://rynop.com/2010/07/posting-source-code-to-bloggercom-and.html http://rynop.com/2010/07/posting-source-code-to-bloggercom-and.html

Want a super easy way to post source code to your blogger.com blog, without having to "upload" any dependencies (css and js files)? Yea I did too.

After coming across this Please Make A Note post and Geek Talkin Siebel's post, I decided to take it a step further.  The technique I came up with was to use Alex Gorbatchev's hosted current version of his SyntaxHighlighter.

Here are the steps:

  1. Login to your blogger.com blog, click on the 'dashboard' link, then click on the 'Design' tab, then click on the 'edit HTML' tab
  2. Now in the text area (scrollable input box) search for '</head>' (ctrl+f in most modern browsers).  Note: when searching, omit the ' characters.
  3. Now add the following lines right before the </head> tag :

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 29 Jun 2010 01:51:00 -0700 Dual monitor setup in Ubuntu 10.04 using EDID and CustomEDID http://rynop.com/2010/06/dual-monitor-setup-in-ubuntu-1004-using.html http://rynop.com/2010/06/dual-monitor-setup-in-ubuntu-1004-using.html I just got a new monitor and was having trouble getting my nvidia card to detect my old monitors native resolution(s) over the VGA port.

Here is my setup:

  • GeForce 6600 GT (using nvidia binary drivers)
  • Dell E228 WFP (22" LCD) over VGA
  • Hans G HH281 (28" LCD) over DVI (DVI from card to HDMI input on monitor)
  • Ubuntu 10.04 X11 server
And the solution:
xorg.conf's CustomEDID option. EDID is essentially a set of bits that describes your monitors settings to your video card and hence your OS/display and/or windowing manager.  If you are familiar with X11 and xorg.conf you know how big of a pain in the ass it can be when it does not detect your monitor settings correctly - you have to mess around with modeline and a bunch of other stuff that should be autodetected.

The EDID comes right from your monitor, and in a single tiny binary file, it contains all the info your vid card needs - resolution, frefresh rates etc.

So how do you get your monitor's EDID? If you have an nvidia card and at least 1 DVI input its stupid easy.  First install nvidia settings 
sudo apt-get install nvidia-settings
Now plug the monitor you want to extract the EDID of, into your DVI port.  You may ultimately plug this monitor into the VGA slot, but you need to initially plug it into the DVI port to extract the EDID.  Restart your computer (or just log out and back in to restart X). Then startup nvidia-settings (under the administration menu).  Your resolution at this point may be all jacked up, but be patient.

From the NVIDIA X Server Settings, select your monitor from the "GPU X" category.  Mine was DFP-0 by default. Now click the 'extract EDID' button.  Save this to a common place, like /etc/X11/edids or something.  Make sure everyone can read (sudo chmod a+r nameofyouredid.bin)

Now you'll need to setup your xorg.conf.  NOTE: make a backup of this file before continuing (cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak).  I'll inline my xorg.conf for reference, but basically just add 'option "CustomEDID" "CRT-0:<full edid.bin="" file="" path="" to="" your="">" to the Device section.</full>


Here is my xorg.conf:



Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection


Section "Files"
EndSection


Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection


Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection


Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "DELL E228WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection


Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 6600 GT"
    Option         "CustomEDID" "CRT-0:/hdd2/monitorEDID/E228WFPedid.bin"
EndSection


Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "CRT: 1680x1050_60 +0+0, DFP: nvidia-auto-select +1680+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection








'nvidia-auto-select' should work for the monitor that is plugged into your DVI. 1680x1050_60 is the native res of my monitor - not sure its needed here cuz of the CustomEDID, but was just to be safe.  Also, not sure if HorizSync or VertRefresh is needed, but I knew em so I left it in.

Now log out and back in, and you should be able to launch up nvidia-settings and tweak your monitor layout how you wish (determine which monitor is primary etc).

If stuff gets messed up, and you want to do trial and error, simply copy back your xorg.conf.back, logout/restart tweak, and retry.

Hope this helps.

Here are some handy edid tools if you dont roll NVIDIA: http://manpages.ubuntu.com/manpages/lucid/man1/get-edid.1.html

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop
Tue, 29 Jun 2010 01:23:00 -0700 Sound Blaster Audigy SE microphone setup in Ubuntu and gtk recordmydesktop http://rynop.com/2010/06/sound-blaster-audigy-se-microphone.html http://rynop.com/2010/06/sound-blaster-audigy-se-microphone.html
So I’m trying to make some simple screencasts, but was running into problem after problem trying to get the mic input working on my Sound Blaster Audigy SE (sb0570) working in ubuntu 9.10. After running down multiple ratholes (like removing pulseaudio) and even trying my on-board sound card. No dice.
So what was the solution? good ‘ol old school alsamixer (v 1.0.20). My card and chip are CA0106. Simply configure alsamixer to look like the following:

Media_http2bpblogspot_hedih

Note: if you want to use gtk-recordmydesktop, specify ‘pulse’ as the audio recording device.
Note2: I also had to add ‘-width 1280 -height 720 –v_bitrate 2000000′ to the ‘Extra options’ field.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/725840/me.jpg http://posterous.com/users/4woXEmqqHCgx rynop rynop