Monday, June 24, 2019

Keeping 2+ Versions of Code

Creating a custom framework using Slim as the bases, I had to create a small modal that could be used in general. After finalizing the code the modal was pushed into a project that was deployed into production. However, having to use the same modal for another project I realized I had to make some adjustments. This made me want to see how to work with version and if my own custom code could be versioned. I could have made the change and tested the project on production, however I felt I had an opportunity to test out versioning. Production custom Code: composer labeled this code as version ^1.0 Development custom Code: composer labels dev code as dev-master Composer will retrieve the most resent commit of the master if the label is dev-master. As soon as there is a number convention, composer will retrieve that particular commit that was the latest at that time and retrieve on that. Versioning has become that simple, you do not have to create multiple 'jar' files anymore of your code. Test this by making a small change to your code. My example is retrieving content using WordPress API.

public function getPage($id) {  
   try{    
    $uri = $this->wp_api . '/pages/' . $id;
    $response = $this->httpClient->request("GET", $uri, []);
    return  $this->getContent($response);  
   }  
   catch (\Exception $e){    
     $this->logger->error('getPage Err',[$e->getMessage()]);    
     throw new \Exception($e->getMessage(),$e->getCode());  
   }
}

To

public function getPage($id) {  
 try{    
   $uri = $this->wp_api . '/pages/' . $id .'?_embed';    
    $response = $this->httpClient->request("GET", $uri, []);
    return  $this->getContent($response);  
 }  
 catch (\Exception $e){    
   $this->logger->error('getPage Err',[$e->getMessage()]);    
   throw new \Exception($e->getMessage(),$e->getCode());  }
 }

Composer file looks like the following:

"require": {     
    ...
    "lit-framework/mod_wp_content": "^1.0"},

"require": {     
    ...
    "lit-framework/mod_wp_content": "dev-master"},

Run composer update command on both projects and see the outcome. 
First one, the code remains as
$uri = $this->wp_api . '/pages/' . $id; and second project the same dependency 
now as new code of 
$uri = $this->wp_api . '/pages/' . $id .'?_embed'; 

Wednesday, October 22, 2014

Upload Excel or CSV straight to MySQL DB an online SAAS

If you have data you would like to import to a database like MySQL there is a simple cloud based tool that allows you to upload your CSV file and create a MySQL script which you can paste into phpMyAdmin or any other tool of your preference. This works for not just CSV but also CSV, TSV, XLSX, XML and JSON files. Similarly, not only for MySQL db but also Postgres and MS SQL

CSV, TSV, XLSX, XML and JSON files

https://sqlizer.io/#/

 Thank you, D4 Software Ltd 483 Green Lanes, London, N13 4BS. for this great tool.

Nested select statement for MySQL db

Here is a example of how to create nested sql statement that indicate with a value is in the list.

SELECT distinct userid from IPSOS where userid in (SELECT distinct otxid from Mag0_20141021) and userid in (SELECT distinct id from Mag1_20141021) and userid in (SELECT distinct id from Mag2_20141021) and userid in (SELECT distinct id from Mag3_20141021) and userid not in (SELECT distinct otxid from problem) 

Notice the where in and where not in and how userid gets compared to the out come of the next select statement

Wednesday, June 4, 2014

How Do I Properly Install Zend Framework on Bluehost Server?

1. download latest zend framework 2. unzip and upload to your public_html folder 3. rename it to zf 4. download zend skeleton to test your environment on bluehost. 5. unzip and upload it to public_html folder 6. rename it to zf2-tutorial 7. find file zf2-tutorial\init_autoloader.php 8. right click and edit the file 9. replace the line with $zf2Path = false; //$zf2Path = false; $zf2Path = '/home4/mydomainpathhere/public_html/zf/library'; Your are letting the zend locate the zend framework which you added to zf folder. 10. on the url go to http://yourdomain.com/zf2-tutorial/public/

Friday, May 16, 2014

RESTfull PHP enlightened

How did they do that?

http://wisecrack.ca/this/is/my/rest/id/123

Gives me 404 error since I do not have default file of any kind at directory 123

lighting flash thanks to yrrhelp on youtube
you have to create a .htaccess file on you server and redirect traffic according to its containts!

check out a great video https://www.youtube.com/watch?v=5eWC-lf1FxM

Creating a RESTful Web Service in PHP

Monday, March 17, 2014

View Mac External drive on a PC

Here I am at YVR airport at 1.23am waiting to fly to Singapore with my PC and Mac external passport drive. I have all my movies in this external drive as its connected to my Mac Mini at home to the TV. I was fortunate to find a blog explaining how to view files from a Mac formated drive.

Download http://www.catacombae.org/hfsx.html HFSexplorer. Thats it! Absolutely fantastic. Since my second name is Trouble, I usual encounter a run around to able to get anything working. Like my popular Calendar Lighting importing Outlook exchange calendar. That was some doing. But this HFSexplorer, easy as pie thanks to all the developers.

Thursday, March 13, 2014

How to download a file from server using SSH Linux?

scp /path/to/local/file username@hostname:/path/to/remote/file
Copy something from some system to some other system:
scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file

Copy something from another system to this system:
scp username@hostname:/path/to/remote/file /path/to/local/file