One of the most common technologies that new professional developers struggle with is git.
Many junior developers are eager to start using all of the powerful commands of git and usually end up getting more confused.
Here are a few commands that I recommend to anyone learning git for the first time:
clone # This downloads the entire git repo from a remote server, usually. You will get all revision history and branches.
I use 13-inch MacBook Pro for personal projects and 15-inch for work. My personal MBP would be the last traditional laptop, hopefully. Since most of my work can easily be done on Linux VPS. I have been using a 10.5-inch iPad Pro with Blink shell for most of my side projects. I like the form factor of iPad Pro and I am getting better at Linux administration. Now I am also setting up Docker images so I can bring up new images as needed.
Occasionally, when people find out I am a programmer, they ask me if I will build them a website or an app on the side. As I spend all day programming at my work, I rarely have the motivation to continue programming after work.
However, talking to most people, I realize they don’t need a programmer; most of their needs can be met by a simple SaaS solution. Recently, I directed a few friends to WordPress.com, SmugMug, Shopify, etc. They all were happy with the results and ease of use. Also I am glad they talked to me because one guy was ready to spend a few thousands on a developer for a WordPress-based site.
Managing WordPress can get time consuming. I have tried to move to static website several times but kept going back to WordPress. But there are several advantages of static site generators, so I finally moved for good. I am also advising a lot of my clients to use Hugo especially when they know that they will rarely ever update their sites.
Here are some of the main advantages of Hugo (or other static site generators) vs WordPress and other CMS.
I finally bought a 10.5" iPad Pro (Affiliate Link). It was mostly an impulse purchase. When I first started to use iPad, it felt blah. It is hard to find good apps or what apps you might want to try out.
My main goal with iPad was to have a really small laptop replacement. So I was hoping for a decent code editor. There are some code editing apps but there is no way to try them out before purchasing. So I am spending a lot of time reading reviews before I purchase any app.
Running unit tests in Laravel, I was getting this error:
ReflectionException: Class Tests\Unit\Symfony\Component\HttpKernel\Exception\NotFoundHttpException does not exist
The issue was a missing root backslash, make sure you have expected exception like:
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
I upgraded PHP to version 7.0 on an Ubuntu box. Running php -v on shell would show it as version 7.0. But Apache was still using PHP 5.6. I tried various methods to update settings for Apache but nothing worked until I issued the following commands:
sudo a2dismod php5.6 sudo a2enmod php7.0 sudo service apache2 restart Source: PHP 7.0 (and 5.6) on Ubuntu | LornaJane
After 3 years, I am using Laravel again at work. Laravel has extensive documentation but sometimes it can be a bit verbose. Here are commands to get you started as soon as possible. This assumes pretty much a fresh install of MacOS.
Install Homebrew # Check the official site for the latest command
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install PHP 7.1 # brew install homebrew/php/php7
SELECT w1.website_id, w1.name as website_name, s1.store_id, s1.name as store_name, p1.entity_id as product_id, p1.sku, pname.value as product_name, url.value as url_path, small_image.value as small_image, msrp.value as msrp_price, price.value as price, p1.created_at as product_created_at, p1.updated_at as product_updated_at, visibility.value as visibility, pstatus.value as status, case when (pstatus.value = 1 and visibility.value > 1 ) then 1 else 0 end as enable_flag, c1.entity_id as category_id, cname.value as category_name, c1.parent_id, c1.created_at as category_created_at, c1.updated_at as category_updated_at FROM catalog_product_entity p1 inner join eav_attribute p_attr ON p1.entity_type_id = p_attr.entity_type_id and p_attr.attribute_code = 'name' inner join catalog_product_entity_varchar pname ON pname.entity_id = p1.entity_id and pname.attribute_id = p_attr.attribute_id inner join eav_attribute p_attr2 ON p1.entity_type_id = p_attr2.entity_type_id and p_attr2.attribute_code = 'url_path' inner join catalog_product_entity_varchar url ON url.entity_id = p1.entity_id and url.attribute_id = p_attr2.attribute_id and pname.store_id = url.store_id inner join eav_attribute p_attr3 ON p1.entity_type_id = p_attr3.entity_type_id and p_attr3.attribute_code = 'small_image' inner join catalog_product_entity_varchar small_image ON small_image.entity_id = p1.entity_id and small_image.attribute_id = p_attr3.attribute_id and pname.store_id = small_image.store_id inner join eav_attribute p_attr4 ON p1.entity_type_id = p_attr4.entity_type_id and p_attr4.attribute_code = 'msrp' inner join catalog_product_entity_decimal msrp ON msrp.entity_id = p1.entity_id and msrp.attribute_id = p_attr4.attribute_id and pname.store_id = msrp.store_id inner join eav_attribute p_attr5 ON p1.entity_type_id = p_attr5.entity_type_id and p_attr5.attribute_code = 'price' inner join catalog_product_entity_decimal price ON price.entity_id = p1.entity_id and price.attribute_id = p_attr5.attribute_id and pname.store_id = price.store_id inner join eav_attribute p_attr6 ON p1.entity_type_id = p_attr6.entity_type_id and p_attr6.attribute_code = 'visibility' inner join catalog_product_entity_int visibility ON visibility.entity_id = p1.entity_id and visibility.attribute_id = p_attr6.attribute_id and pname.store_id = visibility.store_id inner join eav_attribute p_attr7 ON p1.entity_type_id = p_attr7.entity_type_id and p_attr7.attribute_code = 'status' inner join catalog_product_entity_int pstatus ON pstatus.entity_id = p1.entity_id and pstatus.attribute_id = p_attr7.attribute_id and pname.store_id = pstatus.store_id inner join catalog_category_product ccp ON ccp.product_id = p1.entity_id inner join catalog_category_entity c1 ON c1.entity_id = ccp.category_id inner join eav_attribute c_attr ON c1.entity_type_id = c_attr.entity_type_id and c_attr.attribute_code = 'name' inner join catalog_category_entity_varchar cname ON cname.entity_id = c1.entity_id and cname.attribute_id = c_attr.attribute_id and pname.store_id = cname.store_id inner join catalog_category_product_index store1 ON store1.product_id = p1.entity_id and store1.category_id = c1.entity_id inner join core_store s1 ON store1.store_id = s1.store_id inner join core_website w1 ON s1.website_id = w1.website_id
I have been playing with OpenShift for the past several hours. It looks great. But a while back I started to get 503 Internal Server Error.
When I checked logs using rhc tail , I saw this error: Layer 7 Wrong Status, Invalid Response 404.
I spent an hour or so troubleshooting. Turns out the issue was NetBeans had added src/main/web/app/WEB-INF/jboss-web.xml when I ran the application locally on my machine. I committed this file, thinking I might need it. Deleting it from the repo fixed the issue.
if ($num == (int) $num) { // It's whole } else { // It's not }
/** * Cleans up multi-dimensional arrays. * 1st dimension is a simple index * 2nd dimension includes the desired keys * * @param mixed $array * @param mixed $keysToInclude */ public function cleanUpArray($array, $keysToInclude) { $returnArray = array(); $i = 0; foreach($array as $item){ foreach($keysToInclude as $key){ $returnArray[$i][$key] = $item[$key]; } $i++; } return $returnArray; }
Are you tired of checking data in your code before inserting? Well MySQL procedures are here to the rescue. This simple procedure shows how you can do that:
CREATE PROCEDURE ` update_insert_user ` ( IN uid2 int ) BEGIN DECLARE last_login2 DATETIME; SELECT ` last_login ` INTO last_login2 FROM ` user ` WHERE ` uid ` = uid2 LIMIT 1 ; IF last_login2 IS NULL THEN INSERT INTO ` user ` ( ` uid ` , ` last_login ` ) values (uid2, now()); ELSE UPDATE ` user ` SET ` last_login ` = now() WHERE ` uid ` = uid2 LIMIT 1 ; END IF ; END
Just spent 3 hours debugging a session bug in my webapp. CodeIgniter was creating a brand new session with each page load. The issue was a misconfiguration with my config file.
Fix was simple, in /application/config/config.php, make sure the correct domain is set for $config['cookie_domain'].
Query Saving is a feature of CI’s database class that stores the results of every query in memory until the controller is finished executing. As it turns out, in version 1.6.0, the ability to turn this off was added. The addition of the save_queries variable is listed in the Change Log, but as of the latest release of 2.0.0 last week, it still hasn’t made the documentation.
$this->db->save_queries = FALSE; via Undocumented CodeIgniter | Green Egg Media.
I tried to login to my server tonight but kept getting the following error message:
ssh_exchange_identification: Connection closed by remote host
The fix was simple, at least if you have access to the server via cPanel. Just restart sshd service via cPanel/WHM.
I am not sure if this works anymore or not. I don’t use Pentaho now but this post seems popular, so leaving it here for now. Contact me if this is incorrect and needs to be corrected or taken down.
Download Pentaho BI Pre-Configured Installation from [http://www.pentaho.org/download/ga.php] Install JDK5. Open C:\pentaho-demo\pentaho-solutions\system\publisher_config.xml. Add a password for publishing reports. Delete all folders except reporting under C:\pentaho-demo\pentaho-solutions\samples. Delete all .xaction and .properties files under reporting. Copy JDBC driver for your database under C:\pentaho-demo\jboss\server\default\lib. I used Oracle 10g driver, it is called ojdbc.jar. Edit .jsp file to change the look of default Pentaho website under C:\pentaho-demo\jboss\server\default\deploy\pentaho.war\jsp. Add path to your JDK in start-pentaho.bat located under C:\pentaho-demo. For example, set JAVA\_HOME=C:\Program Files\Java\jdk1.5.0\_11 Double click on start-pentaho.bat. Open C:\pentaho-demo\jboss\server\default\deploy\pentaho.war\WEB-INF\web.xml. Search for base-url and add your server’s IP. Now you should be able to publish reports to Pentaho using Report Wizard or Report Designer. Once you publish report, you will need to go to C:\pentaho-demo\jboss\server\default\deploy and open the newly created data source file named something like ???????-ds.xml. If your database is Oracle you will need to change driver class property to oracle.jdbc.driver.OracleDriver And your newly published report should be accessible via Pentaho now.
Using sar, you can also collect all performance data on an on-going basis, store them, and do historical analysis to identify bottlenecks.
via 10 Useful Sar (Sysstat) Examples for UNIX / Linux Performance Monitoring.