Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • webscriptz 10:51 pm on November 30, 2014 Permalink | Reply
    Tags: Apple, cake, , CLI, , , , , PHPCLI,   

    CakePHP connection problems MAMP 

    So I have been testing CakePHP as a way to replace Yii which isn’t my favorite anymore due to the 2.0 release I haven’t found it to be that which it was before, but to everyone his own opinion on this.

    Cake has given me a small run for my money together with the MAMP installation that also gives a few funny interactions but I have managed to clear this out. the most annoying problem was the CLi in MAMP. I got this error:

     Bash |  copy code |? 
    01
    Welcome to CakePHP v2.5.6 Console
    02
    −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
    03
    App : app
    04
    Path: /Users/Tim/Downloads/cakephp−cakephp−1e79eee/app/
    05
    −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
    06
    Interactive Bake Shell
    07
    −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
    08
    [D]atabase Configuration
    09
    [M]odel
    10
    [V]iew
    11
    [C]ontroller
    12
    [P]roject
    13
    [F]ixture
    14
    [T]est case
    15
    [Q]uit
    16
    What would you like to Bake? (D/M/V/C/P/F/T/Q) 
    17
    > M
    18
    −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
    19
    Bake Model
    20
    Path: /Users/Tim/Downloads/cakephp−cakephp−1e79eee/app/Model/
    21
    −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
    22
    Use Database Config: (development/default) 
    23
    [development] > 
    24
    Error: Database connection "Mysql" is missing, or could not be created.
    25
    #0 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Model/Datasource/DboSource.php(260): Mysql−>connect()
    26
    #1 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Model/ConnectionManager.php(105): DboSource−>__construct(Array)
    27
    #2 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/Task/ModelTask.php(948): ConnectionManager::getDataSource('development')
    28
    #3 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/Task/ModelTask.php(885): ModelTask−>getAllTables(NULL)
    29
    #4 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/Task/ModelTask.php(975): ModelTask−>listAll(NULL)
    30
    #5 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/Task/ModelTask.php(203): ModelTask−>getName()
    31
    #6 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/Task/ModelTask.php(91): ModelTask−>_interactive()
    32
    #7 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Command/BakeShell.php(109): ModelTask−>execute()
    33
    #8 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/Shell.php(440): BakeShell−>main()
    34
    #9 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/ShellDispatcher.php(209): Shell−>runCommand(NULL, Array)
    35
    #10 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher−>dispatch()
    36
    #11 /Users/Tim/Downloads/cakephp−cakephp−1e79eee/app/Console/cake.php(47): ShellDispatcher::run(Array)
    37
    #12 {main}
    38
    Tims−MacBook−Pro:app Tim$ ./Console/cake.php bake

    So this error can be resolved on OS X:

    First thing you need to do is create the folder:

     Bash |  copy code |? 
    1
    2
    sudo mkdir /var/mysql
    3

    Secondly you need to create a symbolic link from /var/mysql/mysql.sock to your MAMP mysql.sock:

     Bash |  copy code |? 
    1
    2
    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
    3

     
  • webscriptz 2:40 pm on June 9, 2014 Permalink | Reply
    Tags: cent6, , connection, eth0, , ifconfig, , networking, ,   

    CentOS 6 minimal install on VM – network connection 

    Just installed CentOS 6 and by default the eth0 is not connected in the VM, even if the VM configuration indicates it is connected. You’ll see this when you cat /etc/sysconfig/network-scripts/ifcfg-eth0. Note all these actions are executed as the root user.

    DEVICE="eth0" HWADDR=MAC Address*System MAC* NM_CONTROLLED="no" ONBOOT="no" BOOTPROTO="dhcp"

    So you need to do the following to correct the issue.

    nano /etc/sysconfig/network-scripts/ifcfg-eth0

    Edit the contents of that file to end up having this:

    DEVICE="eth0" HWADDR=MAC Address*System MAC* NM_CONTROLLED="no" ONBOOT="yes" BOOTPROTO="dhcp"

    Then save (CTRL + x, yes and enter, enter) and then reboot:

    reboot

    CentOS will do the rest for you.

     
  • webscriptz 10:58 pm on February 4, 2014 Permalink | Reply
    Tags: , , , iptables, , , remote access, selinux, , tigervnc, vnc, vncserver   

    Vnc Server on CentOS 6.x 

    Thank to: http://wiki.centos.org/HowTos/VNC-Server#head-86a610f73b0fa6b5ecf2fe40f0bb301ea0038a26 for the incredible tutorial and reference material!

    1. Installing the software packages

    The server package is called ‘vnc-server’. Starting for a clean slate, install it with the command: yum install vnc-server.

    Make sure to install a window manager in order to get a full-featured GUI desktop. Gnome, Mate, KDE or XFCE.

    2. Create the VNC user accounts

    If you want to have it just for your user, meaning the regular desktop user that you use for the desktop, you can skip this.

    As a root user:

    $ su root
    # useradd userOne
    # passwd PssswdOn

    3. Edit the server configuration

    Edit /etc/sysconfig/vncservers, and add the following to the end of the file.

    [root@localhost]# cat /etc/sysconfig/vncservers
    # The VNCSERVERS variable is a list of display:user pairs.
    #
    # Uncomment the lines below to start a VNC server on display :2
    # as my 'myusername' (adjust this to your own).  You will also
    # need to set a VNC password; run 'man vncpasswd' to see how
    # to do that.  
    #
    # DO NOT RUN THIS SERVICE if your local area network is
    # untrusted!  For a secure way of using VNC, see this URL:
    # http://kbase.redhat.com/faq/docs/DOC-7028
    
    # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
    
    # Use "-localhost" to prevent remote VNC clients connecting except when
    # doing so through a secure tunnel.  See the "-via" option in the
    # `man vncviewer' manual page.
    
    # VNCSERVERS="2:userOne"
    # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

    4. Set your users’ VNC passwords

    Switch user into the account for each user, and as noted below, run: vncpasswd This will create the .vnc directory for that userid:

    [~]# su - userOne
    [~]$ vncpasswd
    [~]$ cd .vnc
    [.vnc]$ ls
    passwd
    [.vnc]$ exit

     5. Confirm that the vncserver will start and stop cleanly

    We will create the xstartup scripts by starting and stopping the vncserver as root. We also enable the vncserver service to be automatically started. You can always do this through the services gui application in system ->administration.

    # /sbin/service   vncserver start
    # /sbin/service   vncserver stop
    # /sbin/chkconfig vncserver on

    6. The iptables

    The iptables rules in /etc/sysconfig/ need to be modified to open the VNC ports; as needed, if a local ipv6 setup is being used, those need to be amended as well. first check with NIC you use to go to the internet with the server/pc.

    You need to add something similar to this: -A INPUT -i eth1 -j ACCEPT where eth0 is your NIC. Don’t skip this step or you’ll never be able to access your server!

    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -i eth1 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT
    [root@xen-221 sysconfig]#         

    … and then restart the iptables:
    # /sbin/service iptables restart

    7. Start the VNC server

    Start the vncserver as root. if you get an error with “display configuration” then you don’t have the .vnc directory for the user executing the start command!

    # /sbin/service vncserver start

    Now You need to test and everything should work as planned!

     
  • webscriptz 9:38 am on February 4, 2014 Permalink | Reply
    Tags: , high performance, , PHP phalcon, ,   

    Phalcon php, a serious replacement for Yii framework 

    I’ve been using Yii a lot, in various projects that I have been writing the past three years and up until now it has always delivered. However, recently I have been looking at the version 2 of the Yii Framework, while still a very nice framework, I don’t think it will be to my liking. The structure for projects is just to different en the use of composer is not my favorite thing so I have been looking for high performance frameworks written for PHP.

    Obviously all the frameworks pass through on the screen an non where really good for me. That was until I read something about frameworks in 2014 end one of them was Yii but another was Phalcon a PHP framework written in C and added to the PHP parser in the .ini file.

    Obviously this means that you’ll have to have administrative privileges on the webhost, ask the hoster to accommodate or use like Amazon aws services. In any I’ll be experimenting with the framework and see how it functions, my experiences and tutorials will be posted!

     
  • webscriptz 11:09 pm on October 14, 2013 Permalink | Reply
    Tags: clientscript, , javascript, , registerscript, , ,   

    Yii retain speed when using Javascript 

    CClientScript can be useful for including css files and javscript files, while avoiding duplication, you only need to learn and control the darn thing right.

    Before we begin or if you tried it already and have come searching for this:

    1. Yii writes the code for css files just above thetag in the html document. So, if you want to override, put your
    or (preferred) AFTER the

    2. I recommend putting all your
    and in theand all your just before . are blocking, so your page will load faster if the are at the bottom. use:

    1
    Yii::app()->getClientScript()->coreScriptPosition = CClientScript::POS_END;

    3. If you want to include some inline javascript in a view, but make it load at the bottom, after say jquery, use the registerScript() method.

    1
    /* load some formatted js into a php variable: */
    2
    $js = <<<EOF
    3
    var = 'some javascript here!';
    4
        function() { return 'you can format it as you like, and include php $variables'; };
    5
    EOF;
    6
     
    7
    /* write the script at the bottom of the document  */
    8
    Yii::app()->getClientScript()->registerScript("some id", $js, CClientScript::POS_END);

     
  • webscriptz 3:26 pm on October 13, 2013 Permalink | Reply
    Tags: dropdownlist, nestled structure, , treeview, , ,   

    Yii dropdownlist treestructure 

    A possible solution to having an tree type display of a nestled structure in a dropDownlist or activeDropDownList.

     

    01
    public static function getListModulesTreeView() {
    02
            return self::visualTree(SystemModules::model()->findAll('moduleIdFk is NULL'), 0);
    03
        }
    04
     
    05
        private static function visualTree($moduleTree, $level) {
    06
            //resultset to be returned -------------------------------------------//
    07
            $results = array(0=>Yii::t('gui', 'noSubmodules'));
    08
            // looping the data --------------------------------------------------//
    09
            if ($moduleTree) {
    10
                // looping the results -------------------------------------------//
    11
                foreach ($moduleTree as $module) {
    12
                    // adding to mail array --------------------------------------//
    13
                    $results[$module['moduleId']] = str_pad('', $level * 2, '-')  . $module['moduleName'];
    14
                    // do we have children? --------------------------------------//
    15
                    if ($module->systemModules) {
    16
                        $temp = self::visualTree($module->systemModules, $level + 1);
    17
                        // moduleId : $key ---------------------------------------//
    18
                        foreach ($temp as $key => $val) {
    19
                            $results[$key] = $val;
    20
                        }
    21
                    }
    22
                }
    23
            }
    24
            return $results;
    25
        }

     
  • webscriptz 11:05 pm on September 7, 2013 Permalink | Reply
    Tags: , ERD, , , mamp pro, models, , , reverse engeneering, uml, workbench   

    MAMP Pro & MySQL workbench 

    I’ve been looking for a few hours for a quick and easy solution to my connection problem between MySQL workbench and the database itself using MAMP Pro. In itself it isn’t a real problem because you have phpMyAdmin readily available but for ERD models and reverse engineering options. I found my answer on stackoverflow without a lot of trouble but it was a hasty answer and I like to explain a bit complete. So here goes.

    First open MAMP Pro on your Mac and you’ll see the following image

    mamp1

    See to it that your ports are the same as mine or adjust accordingly if you want to keep them.

    Next you will need to open workbench, I Presume you have it already installed in your Mac. The first thing you’ll have, is the possibility to create a connection or edit one if you have tried and failed as I have before. open or create the connection that you want to establish but can’t. You’ll get something along these lines, if not, please search for it.

    workb1

    When you have the first form filled out correctly go to ‘Advanced’ in the same window!

    workb2

    In the ‘Others’ section you will have to add a line and you’ll be good to go. You have to add: socket=/Applications/MAMP/tmp/mysql/mysql.sock and go back to the ‘Parameters’ and use ‘test connection’, normally this should have you up and running. If not, is MAMP started? Are your ports correctly configured? User/password? ….

     
  • webscriptz 7:00 pm on June 29, 2013 Permalink | Reply
    Tags: , Gii, modules, , , submodules, , , ,   

    Module and submodule in Yii framework 

    Yii framework is a very fast and usable framework, within you can create modules to house some sort of sub-applications, link a forum for example but how do you make use of sub-modules?

    First you need to create the top most modules, in my case ‘main’. You can do this by using the Gii tool to generate it. After this you need to add the created module to the config/main.php

     PHP |  copy code |? 
    01
    'modules' => array(
    02
            'gii' => array(
    03
                'class' => 'system.gii.GiiModule',
    04
                'password' => 'admin',
    05
                'generatorPaths' => array(
    06
                    'bootstrap.gii'
    07
                ),
    08
            ),
    09
            // main application components
    10
            'main',
    11
        ),

    After this you can create the submodules by using Gii, don’t forget to do it like this main/NewModuleName, the system then knows where to place them.

    And now we go back to the config/main.php

     PHP |  copy code |? 
    01
    'modules' => array(
    02
    'gii' => array(
    03
    'class' => 'system.gii.GiiModule',
    04
    'password' => 'admin',
    05
    'generatorPaths' => array(
    06
    'bootstrap.gii'
    07
    ),
    08
    ),
    09
    // main application components
    10
    'main'=>array('NewModuleName1','...'),
    11
    ),

     
  • webscriptz 9:58 am on June 15, 2013 Permalink | Reply
    Tags: bookmarks, , FF, , , mozilla, newtabpage,   

    Firefox: new tab page tweak 

    I use Firefox daily in my browsing and i like the new tab page a lot but 9 sites doesn’t cut it for me anymore so it was time to tweak things a bit.

    Firefox uses an internal database to store it’s configuration values an that’s where you’ll need to go: type in the address bar: “about:config”. Firefox will warn you and just click “ok” but be careful anyway. now search for “browser.newtabpage.”, there you’ll have not more then 10 results, search for rows and columns with their standard value 3. 

    You’ll want to have a grid, I did the following, columns = 5 and rows = 4, everything is smaller but still readable and not more taxing on the browser itself.

    about.config thumbnails

     
  • webscriptz 8:16 pm on May 27, 2013 Permalink | Reply  

    Windows SBS 2008 

    To make hibernation unavailable, follow these steps:

    1. Click Start, and then type cmd in the Start Search box.
    2. In the search results list, right-click Command Prompt, and then click Run as Administrator.
    3. When you are prompted by User Account Control, click Continue.
    4. At the command prompt, type powercfg.exe /hibernate off, and then press Enter.
    5. Type exit, and then press Enter to close the Command Prompt window.

    To make hibernation available, follow these steps:

    1. Click Start, and then type cmd in the Start Search box.
    2. In the search results list, right-click Command Prompt, and then click Run as Administrator.
    3. When you are prompted by User Account Control, click Continue.
    4. At the command prompt, type powercfg.exe /hibernate on, and then press Enter.
    5. Type exit, and then press Enter to close the Command Prompt window.
     
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
shift + esc
Cancel