Currently Viewing Posts Tagged Code

Reasons to Learn How to Code

The world is becoming more and more reliant on digital technology and digital communications. It is estimated that there are roughly 1.95 billion websites on the Internet right now. That number is only going to grow as the years go by. Websites are not only increasing in number, buy they are also increasing in complexity. The simple HTML/CSS webpage that seemed phenomenal a decade or more ago is now so boring that no one would give it a second look.

As a result, more and more people are deciding that they may want to learn how to code. Along the way, they have made use of tools like Austin web development bootcamp to give them the fundamentals that they need in order to delve into the world of coding. Many people would argue that the decision to start developing websites changed their lives in a number of ways.

One of the reasons that many have fallen in love with coding is because it has given them a freedom they did not have previously. Once they become proficient at coding, they are able to have a job where they have unlimited freedom and are able to make their own schedule. They are able to transition out of the 9-to-5 cubicle job and become part of the nomad employment group. They will still need to meet with clients, but knowing how to code has given them the freedom to decide when they will meet with clients.

Another benefit that people have seen once they have learned about web development is that they are able to charge more, make more money, and work fewer hours. In this field it is not uncommon for a developer who has years of experience and a portfolio full of high profile clients to charge in excess of $100 an hour for freelance work. This ability to make more money while working less is something that has attracted many people to the Austin Coding Academy as a way of improving their coding skills.

Continuing on the line of freedom and flexibility, when a person is a coder, they are able to select the jobs they will work on as a freelancer. It is likely that as an individual starts out they are going to take any job that they can get, even if the compensation is poor. However, as they improve their skills, grow their customer base, and start making more money, they are able to turn away clients who they do not want. Jobs that are uninteresting, jobs are going to require a lot of time and energy, or jobs that require one to work with a personality they don’t gel with can all be declined. With skill, a web designer knows that there is almost nowhere they can go on the earth that doesn’t need a web designer.

Lots of favicon.ico requests from Mainland China

I check the Nginx error log file regularly. I noticed that a lot of attempted accesses to favicon.ico coming from mainland China.

They come from different IP addresses and with different User Agents.  Each of these IPs is only doing this, sometimes repeatedly.

They are just waste my server’s time and CPU.  How to stop them or reduce the effect on my VPS.

Continue reading “Lots of favicon.ico requests from Mainland China”

Untrack files already added to git repository based on .gitignore

There is some files added to your git repository before you created .gitignore file. So they are already in the repos. Even you input the file name into .gitignore.  It is still there. Every time you change this file. It will be tere.

How to remove it?

Step 1: Commit all your changes.

It is the first step. Check your git status and commit all your changes. Including the .gitignore file.

Step 2: Remove everything from the repository

It is clean up. Enter following command:

git rm -r --cached .
  • rm is the remove command
  • -r  is an option to allow recursive removal
  • -cached will only remove files from the index. Your files will still be there, untouched.
  • The . indicates that all files will be untracked.

Step 3: Add everthing now

git add .

Step 4: Commit

git commit -m ".gitignore fix"

Step 5: Push

git push 

Then. Your repository is as clean as you expect.

Dirty Hack: Add CDN support into phpBB 3.1.6

It works for phpBB 3.1.x, not just phpBB 3.1.6. For a national forum or global forum, it is a must to have a CDN support.

The way I used is not a formal extension or plugin. It is a hack, actually a dirty hack. If you have no experience for it, you can close this page now.

Now, let’s start.

  1. Backup everything of your phpBB, include files and database.\
  2. URL path example.
    Forum url is http://www.myforum.com/
    CDN url is http://myforum.kxcdn.com/
  3.  Open /includes/functions.php
    add following in line 5112

    // Add CDN path
    $cdn_cache = '//myforum.kxcdn.com/';

    Find following around Line 5216

    'T_ASSETS_PATH'         => "{$web_path}assets",
    'T_THEME_PATH'         => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme',
    'T_TEMPLATE_PATH'      => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template',
          

    Replace by

    'T_ASSETS_PATH'         => $cdn_cache."assets",
    'T_THEME_PATH'         => $cdn_cache."styles/" . rawurlencode($user->style['style_path']) . '/theme',
    'T_TEMPLATE_PATH'      => $cdn_cache."styles/" . rawurlencode($user->style['style_path']) . '/template',

    Find following around Line 5230

    'T_STYLESHEET_LINK'      => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . 'https://d22rw8pyewxbkl.cloudfront.net/theme/stylesheet.css' . $config['assets_version'],
    'T_STYLESHEET_LANG_LINK'    => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . 'https://d22rw8pyewxbkl.cloudfront.net/stylesheet.css' . $config['assets_version'],

    Replace by

    'T_STYLESHEET_LINK'      => $cdn_cache."styles/" . rawurlencode($user->style['style_path']) . 'https://d22rw8pyewxbkl.cloudfront.net/theme/stylesheet.css' . $config['assets_version'],
    'T_STYLESHEET_LANG_LINK'    => $cdn_cache."styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . 'https://d22rw8pyewxbkl.cloudfront.net/stylesheet.css' . $config['assets_version'],

    Save and overwrite the original file.

  4.   Open /includes/functions_content.php
    Find following around Line 902

    return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);

    Replace by

    return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' .'//forum.kxcdn.com/forum/'.$root_path. $config['smilies_path'] . '/\2 />', $text);

    Save and overwrite the old file.

  5. Then purge cache in the ACP.

Look at the waterfall chat after this hack.

cdn-phpbb-hack

The CDN service provider is KEYCDN. You can apply through this link.

Remove link of comment in WordPress

By default all links posted in the comments under your articles are turned by WordpPress into links.

Unfortunately, this features encourages spammers to post many unwanted comments in your blog.

To disable turning URLs from comments into actual links, go to your admin area and then navigate to Appearance -> Editor.

remove-clickable-link

Select the functions.php file from the right column and add the following line just above the closing php tag ( ?> ):

remove_filter('comment_text', 'make_clickable', 9);

Then, I purged all caches and reloaded one post. Then there are no hyper-link in comments. Theses links are just pure text now, not clickable.

Some changes on Timthumb script

What is Timthumb?

It is a small php script for cropping, zooming and resizing web images (jpg, png, gif).

 

Here is the official place to donwload the script. https://code.google.com/p/timthumb/

Even the developers said it is not supported any more, there are still a lot of sites or plugins of wordpress and joomla.

Here is some modification I did on one of the plugin of Joomla.

1) Change default quality of image file.

The original default is 90%, it is not good enough. Especially when testing the output on webpagetest.org. So reduce the default image quality to 70. Find the following in tb.php


if(! defined('DEFAULT_Q') )                                     define ('DEFAULT_Q', 70);                                                               // Default image quality. Allows overrid in timthumb-config.php

It can also be overrid in url paraments. Such as http://your.domain.name/tb.php?src=/images/abc.jpg&q=70

2) Add interlace or Make jpeg file progressive

It is good to make jpg file to be progressive. It is similar file size but make it display on the monitor faster.

This is actually a mod on the original timthumb script.

Add following in the defaults section of timthumb script.


if(! defined('JPEG_IS_PROGRESSIVE') )    define ('JPEG_IS_PROGRESSIVE', TRUE);

Then find following script


$imgType = 'jpg';
imagejpeg($canvas, $tempfile, $quality);

And add one line in the middle. Looks like below:


                        $imgType = 'jpg';
                        imageinterlace($canvas, JPEG_IS_PROGRESSIVE);
                        imagejpeg($canvas, $tempfile, $quality);

timthumb

 

 

Max Gorin Coder

In today’s highly advanced technological age, there has to be a place where those who understand the major components and aspects of code and sourcing gather together and hang out.

The modern hangout for computer enthusiasts like coders is no longer a library or computer center; such coders and other online data and content managers have a totally different type of hangout these days. They can be found getting together online on collaborative sites and networks that allow for the free flow of shared ideas and solutions as well as a display of source coding and databases. These same sites host plenty of examples of game development, engineering and coding for Mac and Windows operating systems. Coders keep a portfolio of repositories developed on their own as well as in collaboration with other coders online and otherwise.

Coders come together online in order to solve issues and work collaboratively to conquer coding problems. While sharing their work online, coders can post repositories of code solutions as well as join collaborative discussions with other coders. Coders share ideas and insights through open and free-flowing discussions on coding and technological language. Through this type of collaboration, professionals and amateurs alike uncover the solutions necessary to construct intricate SQL database and online games as well as mobile applications and other usages.

Special websites let coders post profiles to connect with each other and clients. These sites offer coders an opportunity to post their listings of repositories like an online portfolio. Along with a coder’s profile and portfolio, coders can add links to their social media and social networking accounts as well as a photo or an avatar for their landing page. In many cases, coders can also post a brief bio along with some other highlights such as their specialties, like if they are a master of Java or other code languages. These profile pages allow others to get a sense and feel for who else is online to chat with as well as possibly enter into a collaborative work relationship with online. From financial budgeting apps to fantasy roleplay games, some of the best programs have evolved from this type of collaboration between coders with similar interests.

On Internet hangout sites like GitHub and other networks, coder profile pages span the full gamut from goofy and comical to those that tend to have more of a professional appeal. A prime example of a coder profile viewable on GitHub is Max Gorin coder under the handle Nomad Coder. His profile reveals his contact information as well as an online display of his body of work and his online activity feed. By reviewing such coder profiles and features, other users can gain some insights into how to collaborate and communicate with coders, content writers and gaming engineers as well as mobile app developers. This way, coders with similar interests can reach out to ask and answer relevant coding questions, and clients can find technically savvy Internet users and coding artists to collaborate with on special projects.

Implement New Relic server service on Centos 6.4 64bit

It is a very popular service on web application and mobile apps. I like its server service.

The servers New Relic supported includes Linux, Windows.:

  • Centos / Red Hat
  • Ubuntu / Debian
  • Other Linux
  • Windows 2003, 2008

servers

I followed the instruction of Centos to install the service on my ServerMania VPS.
Step 1: SSH to VPS as Root
Step 2: Add the New Relic yum repository

rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm

step 3: Install the Server Monitor package

yum install newrelic-sysmond

Step 4: Configure & start the Server Monitor daemon
Add license key to config file: (See /etc/newrelic/nrsysmond.cfg for other config options)

nrsysmond-config --set license_key=your_own_key

Start the daemon:

/etc/init.d/newrelic-sysmond start

Step 5: Done!
The data is update just in minutes.

Continue reading “Implement New Relic server service on Centos 6.4 64bit”

Day 4 and Day 5 – Two Week Campaign

Weekend, it is time for rest, but I am still keep my two week campaign moving on.
Remove some old code from monthly archives. These code make the page shown very slow.
Follow twelve people on twitter each day.
Make a new kind archive template. It generate the last 10 post each category. Then I can pick one or two categories and shown them on home page. Right now I add Hardware, Software and Internet on home page. These three are most active categories.

Continue reading “Day 4 and Day 5 – Two Week Campaign”

  • Archives