Updates from Shiki RSS Toggle Comment Threads | Keyboard Shortcuts

  • Shiki 4:57 pm on April 15, 2010 Permalink | Reply
    Tags: console, curl, ,   

    The undefined curl function in console (WampServer) 

    Stupid stupid me. On Windows/WampServer, I’ve always had this problem when working with PHP code that can run in the console and using cURL methods..

    PHP Fatal error:  Call to undefined function curl_init() in D:\Shiki\github\yii-clockwerk\test-app\CurlHelper.php on line 90
    Fatal error: Call to undefined function curl_init() in D:\Shiki\github\yii-clockwerk\test-app\CurlHelper.php on line 90

    It (cURL) works in the browser but not when in console. I didn’t think that it was this simple to fix. The PHP CLI uses a different config file (php.ini) compared to the one used by WampServer/Apache. You can see the location of the config file being used by typing:

    php --ini

    Result:

    Configuration File (php.ini) Path: C:\Windows
    Loaded Configuration File:         C:\wamp\bin\php\php5.3.0\php.ini
    Scan for additional .ini files in: (none)
    Additional .ini files parsed:      (none)

    You can then fix the curl problem by enabling it in the php.ini file being used. Make sure this is not commented out:

    extension=php_curl.dll
     
  • Shiki 7:59 pm on March 30, 2010 Permalink | Reply
    Tags: firebug, firephp, log, , yii   

    FirePHP Logger for Yii Framework 

    I made this a few weeks ago. It is a Yii Framework extension which routes log messages to FirePHP.

    Requirements

    Installation

    1. Download and extract the “shiki” folder to your extensions directory. This is usually “/protected/extensions”.
    2. Download the FirePHP core class and put it somewhere in your “/protected” directory. I usually put these files in /protected/vendors.
    3. Modify your config file to include this LogRoute class and set the “fbPath” property to the path of fb.php. Use a Yii alias (i.e. application.vendors.FirePHPCore031.lib.FirePHPCore.fb):
    config file code (i.e. /protected/config/main.php)
    ....

    'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
            // the default (file logger)
            array(
                'class'=>'CFileLogRoute',
                'levels'=>'error, warning',
            ),
            // the FirePHP LogRoute
            array(
                'class' => 'ext.shiki.firePHPLogRoute.ShikiFirePHPLogRoute', // "ext" alias points to /protected/extensions
                'fbPath' => 'application.vendors.FirePHPCore031.lib.FirePHPCore.fb', // set path to fb.php
            ),
        ),
    ),

    ....

    Usage

    Once you’ve got the extension setup in the config, you can use Yii’s logging methods to log messages to FirePHP.

    // logging an INFO message (arrays will work and looks awesome in FirePHP)
    Yii::log(array('username' => 'Shiki', 'profiles' => array('twidl', 'twitter', 'facebook')), CLogger::LEVEL_INFO);

    // logging a WARNING message
    Yii::log("You didn't setup a profile, are you really a person?", CLogger::LEVEL_WARNING);

    // logging with a CATEGORY (categories are displayed as "labels" in FirePHP -- just an additional info text)
    Yii::log('Profile successfully created', CLogger::LEVEL_INFO, 'application.user.profiles');

    // tracing simple text
    Yii::trace('Loading application.user.profiles.ninja', 'application.user.profiles');

    // logging an ERROR
    Yii::log('We have successfully determined that you are not a person', CLogger::LEVEL_ERROR, 'Any category/label will work');
     
  • Shiki 2:23 pm on March 15, 2010 Permalink | Reply
    Tags: memcached, , , windows   

    Installing Memcached for PHP 5.3 on Windows 7 

    First off, all credits go to this guy. I’m just listing the steps on how I did it in Windows 7 with PHP 5.3. Also, I tested this using WampServer but I believe it should work on any PHP install.

    Install memcached

    1. Download the Memcached Win32 library here: http://code.jellycan.com/memcached/. Extract the downloaded archive file in a directory (i.e. c:\memcached). There should be a memcached.exe in there.
    2. Run a command prompt as an administrator. Some info on how to do that here.
    3. Install memcached as a service. Go to the memcached directory, type and run:
      memcached -d install
    4. Start the memcached service by running:
      memcached -d start

    Install PHP Memcache extension (php_memcache.dll)

    1. Chances are you don’t have php_memcache.dll in your PHP extensions yet. You can download a build of it here. Make sure to download the correct one for your system. Mine was 32bit and PHP 5.3 so I used this: php_memcache-cvs-20090703-5.3-VC6-x86.zip. The archive should contain php_memcache.dll. Extract the archive to your php extensions directory. On my system (WampServer), this was C:\wamp\bin\php\php5.3.0\ext.
    2. Edit php.ini, add this line to enable the extension:
      extension=php_memcache.dll

      This is a little easier for WampServer users because there’s a menu for enabling extensions ^_^x

    Test

    Test the installation using the sample PHP code here: http://www.php.net/manual/en/memcache.examples-overview.php

     
    • orlando 7:27 pm on March 28, 2010 Permalink

      this is sucks, the php client library is not memcacheD its just ‘memcache’ (without D), if any of you find this fucking D please let me know.

    • Shiki 7:49 pm on March 29, 2010 Permalink

      @orlando Thanks for pointing that out. Sorry I always get confused by that D.

    • paul 3:55 pm on April 30, 2010 Permalink

      Tnx man, you saved my life :D

    • Dominic Watson 6:00 pm on May 12, 2010 Permalink

      how are we supposed to let you know? you didn’t provide contact details ^^

      Thanks for this article

    • Ronen 1:37 am on July 5, 2010 Permalink

      Great helpful work Shiki! worked great for me.
      Thanks.

  • Shiki 11:54 am on January 18, 2010 Permalink | Reply
    Tags: dropbox, git   

    “Ignoring funny ref” error on Git + Dropbox 

    At Twidl HQ, we use a combination of Git and Dropbox for managing our source code. It’s a simple but awesome setup. Sometimes, we get this really cryptic error when fetching from our main repo (our shared Dropbox folder):

    Ignoring funny ref 'refs/remotes/origin/master (Shiki's conflicted copy 2010-01-14)' locally

    It seems to happen when 2 people push to origin/master at almost the same time. This makes Dropbox update the same file and seems to be the cause of the error. When this happens, you can bet that one of the people who did the push will lose his changes to origin/master. So you’ll have to fix it accordingly.

    The “funny ref” error does not have any critical effect on the repo and Git seems to work perfectly. It will just annoy you every time you try to fetch ^_^x It turns out that this “master (Shiki’s conflicted copy 2010-01-14)” is a branch in the main repo. Simply deleting it will remove the error. In terminal, go to your main repo’s (Dropbox) root folder:

    git branch -d "master (Shiki's conflicted copy 2010-01-14)"

    If you’re not sure of the name of the conflicting branch, you can execute “git branch” to show all branches. There should at least be a “master” branch and your conflicting branch.

     
    • Filipe Correia 6:16 am on July 16, 2010 Permalink

      Hi! Thanks for writting this post. It was the only reference I’ve found to this issue… :|
      I’m finding the same problem myself (using dropbox too), but I’m not being able to solve it the same way you did.

      Here’s what I’m seeing:

      $ git pull
      error: * Ignoring funny ref 'refs/remotes/origin/master (fcorreia's conflicted copy 2010-07-14)' locally
      Already up-to-date.
      $ git branch "merge" "master (fcorreia's conflicted copy 2010-07-14)"
      fatal: Not a valid object name: 'master (fcorreia's conflicted copy 2010-07-14)'.
      $ git branch
      * master

      Any thoughts that might help?

      Thanks!

    • Shiki 3:55 pm on July 16, 2010 Permalink

      From my experience, you could no longer merge with that branch. It seems to be a corrupted branch file because it was overwritten by somebody else who pushed to the dropbox repo.

      Deleting the branch didn’t work for you? Are you deleting it from the dropbox repo? When I get errors like this, I just delete that conflicted branch and fetch-merge-push again. I never lost any of my commits due to the conflict. They just didn’t get pushed properly because of dropbox’ syncing conflicts.

    • Filipe Correia 5:49 pm on July 16, 2010 Permalink

      I’m not being able to delete it. In fact, it’s not showing up when I list the branches (only “master” shows up). It seems there isn’t actually a branch named “master (fcorreia’s conflicted copy 2010-07-14)”.

    • Filipe Correia 6:10 pm on July 16, 2010 Permalink

      Ok, I think i’m on to something. I’ve just checked my repo files (on dropbox) and found these two files on the path “/refs/heads”:

      master
      master (fcorreia's conflicted copy 2010-07-14)

      It seems that this “master” file as conflicted, so dropbox automatically copied it to another filename. I wonder if I can just delete this file from the repo without leaving other garbage behind, and without losing commits.

    • Shiki 10:36 am on July 17, 2010 Permalink

      Yes that’s right. You should use the repo on Dropbox. I’ve deleted conflicted branches like that with no problem. All I had to do was fetch-merge-push again to put my local changes to the Dropbox repo. Use

      branch -D

      to delete it if you can’t delete it with “branch -d” (small d).

      Also, notice that your Git repo actually still works with that conflicted copy in there. It just annoys you with the warning message when you fetch.

    • Filipe Correia 8:19 pm on July 19, 2010 Permalink

      Ok, got it. Turns out I was trying to delete the branch locally (although it obviously only existed on the server). Thanks!

  • Shiki 9:40 pm on September 23, 2009 Permalink | Reply
    Tags: , box2d, , ,   

    Creating custom Box2D shape components in PushButton Engine 

    If you ever need to use other ways of creating Box2D shapes that are not currently available in PushButton Engine, you can simply make one yourself. You’ll just need to create a subclass of CollisionShape and use it just like the PBE shape classes.

    Here’s a sample class we use to create an oriented box shape:

    package cavalcade.box2D
    {
        import Box2D.Collision.Shapes.b2PolygonDef;
        import Box2D.Collision.Shapes.b2ShapeDef;
        import Box2D.Common.Math.b2Vec2;
       
        import com.pblabs.box2D.CollisionShape;
       
        import flash.geom.Point;

        public class OrientedBoxCollisionShape extends CollisionShape
        {
            public var halfWidth:Number = 0.5;
            public var halfHeight:Number = 0.5;
            public var center:Point = new Point();
            public var angle:Number = 0;
           
            public function OrientedBoxCollisionShape()
            {
                super();
            }
           
            override protected function doCreateShape():b2ShapeDef
            {
                var scale:Number = _parent.manager.inverseScale;            
               
                var shape:b2PolygonDef = new b2PolygonDef();
                shape.SetAsOrientedBox(halfWidth * scale * _parent.size.x, halfHeight * scale * _parent.size.y, b2Vec2.Make(center.x, center.y), angle);            
                return shape;
            }
        }
    }

    As you can see, the class inherits from CollisionShape and overrides the doCreateShape method in order to create the actual Box2D oriented box shape from there. Use it in the level files like this:

    <component type="com.pblabs.box2D.Box2DSpatialComponent" name="Cart">
        <collidesWithTypes childType="String">
            <_0>Platform</_0>
        </collidesWithTypes>

        <collisionShapes childType="com.pblabs.box2D.CollisionShape">
            <_0 type="cavalcade.box2D.OrientedBoxCollisionShape">
                <halfWidth>0.42</halfWidth>
                <halfHeight>0.12</halfHeight>
                <density>50</density> <!-- you can still use the same properties in CollisionShape -->
                <friction>2</friction>
                <restitution>0</restitution>
                <angle>3</angle> <!-- specify an angle of rotation -->
                <center> <!-- you can override the location of the box so it won't be positioned somewhere other than the center of the entity -->
                  <x>1</x>
            <y>-0.5</y>
          </center>
            </_0>                
        </collisionShapes>
        <collisionType childType="String">
            <_0>Renderable</_0>
        </collisionType>
        <manager componentReference="SpatialDB" />
            <position type="">
                <x>0</x>
                <y>110</y>
            </position>
            <size type="">
                <x>60</x>
                <y>45</y>
            </size>
    </component>
     
  • Shiki 1:11 am on September 16, 2009 Permalink | Reply
    Tags: , , , movieclip, , swf   

    Experiment: Using SWF MovieClips in PushButton Engine 

    Important: This tutorial is now deprecated due to the new and awesome, fully rewritten, rendering components. You can see some discussions about it here.

    I’ve been working with PushButton Engine for a short while now but last night was actually the first time I tried integrating/using a MovieClip from a SWF into PBE. Unfortunately, there are no documentations on how do this at the moment. The examples mostly use images (pngs). I won’t b*tch about it because that is totally understandable. The PBE team are working their a**es off to get to 1.0 and the documentation is the least of their worries. I could at least thank them for doing such a good job — PBE’s a well thought-out framework, everything I learned from it made a lot of sense.

    Anyway, what I wanted to do was simply to put my MovieClip in a SWF library into the stage. I am using FlexBuilder 3 + the latest PBE code from the SVN. I somehow got some ideas on how to do this when I was hanging out at the #pbengine IRC channel. And I did a lot of digging on the PBE code and did lots of experiments to try to understand how to use them. There are 2 different components we can use:

    • com.pblabs.rendering2D.SWFSpriteSheetComponent. This one actually had a class description: “A class that is similar to the SpriteSheetComponent except the frames are loaded by rasterizing a MovieClip rather than a single image”. Assuming you’ve gone through the PBE examples, I think this means that instead of creating the frames from a sprite sheet image and have it used by SpriteRenderComponent, you’ll be getting your frames from a loaded MovieClip instead. Nevertheless, this isn’t what I was aiming for.
    • com.pblabs.rendering2D.SWFRenderComponent. This component somehow works like SpriteRenderComponent, only it uses MovieClips. A little code investigation later, looks like this component will need to be subclassed in order for it to work. From that subclass, you can do what you want to do with your movieclip  using a protected _clip variable.

    Since I still wanted control over a movieclip, I used SWFRenderComponent. I’ll explain below how I did it. Please do note that I am still a novice with PBE (and Flex for that matter) so the method I used might not be good practice. (More …)

     
    • Ben Garney 10:43 am on September 17, 2009 Permalink

      Hey Shiki,

      Awesome post! I’d love to work with you to do a followup showing some improvements on how you did things here. Interested? Shoot me an e-mail or hit me up on IRC. :)

      Ben

    • Shiki 5:20 pm on September 18, 2009 Permalink

      Thanks! Sure thing Ben. I’ll talk to you soon on IRC.

    • Cubny 5:29 am on October 17, 2009 Permalink

      thanks :)

    • Dimid 6:00 am on November 15, 2009 Permalink

      Hi. Properties and with SWFRenderComponent don’t work. I too tried its. I think this component is not ready yet for using

    • Dimid 6:03 am on November 15, 2009 Permalink

      Properties…sizeReference and rotationReference….

    • Shiki 7:43 am on November 15, 2009 Permalink

      Hey Dimid, thanks for the comment. This tutorial however can no longer be used with the latest PBE code. They did a full rewrite of the rendering components and these properties should work now. See here: http://pushbuttonengine.com/forum/viewtopic.php?f=5&t=353

  • Shiki 11:47 pm on August 31, 2009 Permalink | Reply
    Tags: eclipse, proxy, putty, remote-editing, ssh, tunnel, zend-studio   

    Zend Studio (Eclipse) Remote Editing through a secure proxy 

    Remote Editing in Zend Studio for Eclipse has to be one of the biggest reasons why I use it in my current job. I work from home and our team’s development environment is securely setup on a Linux server with a firewall open only to specific IP addresses. This is a no biggie if my IP address never changes or if I work only in one place. Unfortunately, that’s not the case for my DSL setup — I get a different IP address everyday. And since I can’t bug the server admin every time I need to have my IP address added to the firewall, I connect through our proxy server first and then connect to the main development server. The setup’s kinda like this:

    Local Machine to Proxy Server to Development Server setup

    The problem now is Zend Studio doesn’t seem to support this kind of setup. At least, that’s what I concluded after so many hours of googling. Then I found this super awesome article. We can use Putty! Or just plain ol’ Terminal on a Mac (Linux should be the same I think). (More …)

     
  • Shiki 8:37 pm on August 24, 2009 Permalink | Reply
    Tags: adobe, cs4, extract, photoshop, plugin   

    Installing the missing Extract feature in Photoshop CS4 

    Extract Filter in Adobe Photoshop CS4

    Yeah so I’m a little late on this. Primarily because I’m no designer and I don’t use Photoshop that much. But I just found out that the Extract filter has been removed from CS4. Or maybe CS3 too? I didn’t notice until I needed to use it at work today where I just had to take out some cats and dogs out of their backgrounds.

    So, with some googling I found this article by John Nack. There he explains why they took Extract and other filters/plugins away. I still wish they retained Extract though, it’s kinda useful for us noob Photoshop users :p Thankfully you can still install the missing features. Just follow these steps:

    1. Download the plugins package. Download here for Mac, and here for Windows.
    2. In the package you should find 3 language folders. Open the one you need (ie English) and copy the child folder named Goodies and paste it somewhere safe like the Photoshop application folder. That’s /Applications/Adobe Photoshop CS4 for Mac and somewhere in C:/Program Files/ for Windows (sorry I can’t be too precise).
    3. Open Photoshop. Go to Preferences > Plug-Ins. Find a setting named Additional Plug-Ins Folder and set that to the Goodies folder.
    4. Restart Photoshop.

    That should do it.

     
    • Stephen 11:34 pm on October 8, 2009 Permalink

      Thank you THANK YOU for posting this online. I was having trouble getting it to work.

    • Shiki 7:39 am on October 9, 2009 Permalink

      Glad I could help!

    • Dan 11:55 pm on November 30, 2009 Permalink

      Magnificent! you are a legend!

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel